Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 51 additions & 4 deletions packages/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,30 @@ const DEFAULT_SUPPORTED_EXTENSIONS = [
'.cs', '.go', '.rs', '.php', '.rb', '.swift', '.kt', '.scala', '.m', '.mm',
// Text and markup files
'.md', '.markdown', '.ipynb',
// '.txt', '.json', '.yaml', '.yml', '.xml', '.html', '.htm',
// '.css', '.scss', '.less', '.sql', '.sh', '.bash', '.env'
// Config, infrastructure, and supporting files
'.json', '.yaml', '.yml', '.xml', '.html', '.htm', '.toml',
'.css', '.scss', '.less', '.sql', '.sh', '.bash',
'.prisma', '.graphql', '.gql', '.proto',
'.dockerfile', '.tf', '.hcl',
];

/**
* Well-known extension-less filenames that should be indexed.
* Users can extend this via CUSTOM_EXTENSIONLESS_FILENAMES env var (comma-separated).
*/
const DEFAULT_EXTENSIONLESS_FILENAMES = new Set([
'Dockerfile', 'dockerfile',
'Makefile', 'makefile', 'GNUmakefile',
'Jenkinsfile',
'Vagrantfile',
'Gemfile', 'Rakefile', 'Guardfile',
'Procfile',
'Brewfile',
'Caddyfile',
'Fastfile',
'Appfile',
]);

const DEFAULT_IGNORE_PATTERNS = [
// Common build output and dependency directories
'node_modules/**',
Expand Down Expand Up @@ -102,6 +122,7 @@ export class Context {
private codeSplitter: Splitter;
private supportedExtensions: string[];
private ignorePatterns: string[];
private extensionlessFilenames: Set<string>;
private synchronizers = new Map<string, FileSynchronizer>();

constructor(config: ContextConfig = {}) {
Expand Down Expand Up @@ -145,7 +166,14 @@ export class Context {
// Remove duplicates
this.ignorePatterns = [...new Set(allIgnorePatterns)];

console.log(`[Context] 🔧 Initialized with ${this.supportedExtensions.length} supported extensions and ${this.ignorePatterns.length} ignore patterns`);
// Build extensionless filename set from defaults + env
const envExtensionlessFilenames = this.getCustomExtensionlessFilenamesFromEnv();
this.extensionlessFilenames = new Set([
...DEFAULT_EXTENSIONLESS_FILENAMES,
...envExtensionlessFilenames,
]);

console.log(`[Context] 🔧 Initialized with ${this.supportedExtensions.length} supported extensions, ${this.extensionlessFilenames.size} extensionless filenames, and ${this.ignorePatterns.length} ignore patterns`);
if (envCustomExtensions.length > 0) {
console.log(`[Context] 📎 Loaded ${envCustomExtensions.length} custom extensions from environment: ${envCustomExtensions.join(', ')}`);
}
Expand Down Expand Up @@ -677,7 +705,11 @@ export class Context {
await traverseDirectory(fullPath);
} else if (entry.isFile()) {
const ext = path.extname(entry.name);
if (this.supportedExtensions.includes(ext)) {
if (ext === '') {
if (this.extensionlessFilenames.has(entry.name)) {
files.push(fullPath);
}
} else if (this.supportedExtensions.includes(ext)) {
files.push(fullPath);
}
}
Expand Down Expand Up @@ -1158,6 +1190,21 @@ export class Context {
}
}

/**
* Get custom extensionless filenames from environment variables.
* Supports CUSTOM_EXTENSIONLESS_FILENAMES as comma-separated list (e.g. "Dockerfile,Makefile").
*/
private getCustomExtensionlessFilenamesFromEnv(): string[] {
const envValue = envManager.get('CUSTOM_EXTENSIONLESS_FILENAMES');
if (!envValue) return [];
try {
return envValue.split(',').map(f => f.trim()).filter(f => f.length > 0);
} catch (error) {
console.warn(`[Context] ⚠️ Failed to parse CUSTOM_EXTENSIONLESS_FILENAMES: ${error}`);
return [];
}
}

/**
* Add custom extensions (from MCP or other sources) without replacing existing ones
* @param customExtensions Array of custom extensions to add
Expand Down
35 changes: 5 additions & 30 deletions packages/core/src/vectordb/milvus-vectordb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export class MilvusVectorDatabase implements VectorDatabase {
private async initializeClient(address: string): Promise<void> {
const milvusConfig = this.config as MilvusConfig;
console.log('🔌 Connecting to vector database at: ', address);
const timeoutMs = Number(process.env.MILVUS_TIMEOUT_MS) || 60000;
this.client = new MilvusClient({
address: address,
username: milvusConfig.username,
password: milvusConfig.password,
token: milvusConfig.token,
ssl: milvusConfig.ssl || false,
timeout: timeoutMs,
});
}

Expand Down Expand Up @@ -742,42 +744,15 @@ export class MilvusVectorDatabase implements VectorDatabase {
throw new Error('MilvusClient is not initialized. Call ensureInitialized() first.');
}

const collectionName = `dummy_collection_${Date.now()}`;
const createCollectionParams = {
collection_name: collectionName,
description: 'Test collection for limit check',
fields: [
{
name: 'id',
data_type: DataType.VarChar,
max_length: 512,
is_primary_key: true,
},
{
name: 'vector',
data_type: DataType.FloatVector,
dim: 128,
}
]
};

try {
await this.client.createCollection(createCollectionParams);
// Immediately drop the collection after successful creation
if (await this.client.hasCollection({ collection_name: collectionName })) {
await this.client.dropCollection({
collection_name: collectionName,
});
}
return true;
const response = await this.client.listCollections();
const maxCollections = Number(process.env.MILVUS_MAX_COLLECTIONS) || 4;
return response.data.length < maxCollections;
} catch (error: any) {
// Check if the error message contains the collection limit exceeded pattern
const errorMessage = error.message || error.toString() || '';
if (/exceeded the limit number of collections/i.test(errorMessage)) {
// Return false for collection limit exceeded
return false;
}
// Re-throw other errors as-is
throw error;
}
}
Expand Down