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
2 changes: 1 addition & 1 deletion packages/core/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export class Context {
await this.loadIgnorePatterns(codebasePath);

// To be safe, let's initialize if it's not there.
const newSynchronizer = new FileSynchronizer(codebasePath, this.ignorePatterns);
const newSynchronizer = new FileSynchronizer(codebasePath, this.ignorePatterns, this.supportedExtensions);
await newSynchronizer.initialize();
this.synchronizers.set(collectionName, newSynchronizer);
}
Expand Down
10 changes: 8 additions & 2 deletions packages/core/src/sync/synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ export class FileSynchronizer {
private rootDir: string;
private snapshotPath: string;
private ignorePatterns: string[];
private supportedExtensions: string[];

constructor(rootDir: string, ignorePatterns: string[] = []) {
constructor(rootDir: string, ignorePatterns: string[] = [], supportedExtensions: string[] = []) {
this.rootDir = rootDir;
this.snapshotPath = this.getSnapshotPath(rootDir);
this.fileHashes = new Map();
this.merkleDAG = new MerkleDAG();
this.ignorePatterns = ignorePatterns;
this.supportedExtensions = supportedExtensions;
}

private getSnapshotPath(codebasePath: string): string {
Expand Down Expand Up @@ -81,6 +83,10 @@ export class FileSynchronizer {
} else if (stat.isFile()) {
// Verify it's really a file and not ignored
if (!this.shouldIgnore(relativePath, false)) {
const ext = path.extname(entry.name);
if (this.supportedExtensions.length > 0 && !this.supportedExtensions.includes(ext)) {
continue;
}
try {
const hash = await this.hashFile(fullPath);
fileHashes.set(relativePath, hash);
Expand Down Expand Up @@ -345,4 +351,4 @@ export class FileSynchronizer {
}
}
}
}
}
4 changes: 2 additions & 2 deletions packages/mcp/src/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export class ToolHandlers {
const { FileSynchronizer } = await import("@zilliz/claude-context-core");
const ignorePatterns = this.context.getIgnorePatterns() || [];
console.log(`[BACKGROUND-INDEX] Using ignore patterns: ${ignorePatterns.join(', ')}`);
const synchronizer = new FileSynchronizer(absolutePath, ignorePatterns);
const synchronizer = new FileSynchronizer(absolutePath, ignorePatterns, this.context.getSupportedExtensions());
await synchronizer.initialize();

// Store synchronizer in the context (let context manage collection names)
Expand Down Expand Up @@ -864,4 +864,4 @@ export class ToolHandlers {
};
}
}
}
}
8 changes: 6 additions & 2 deletions packages/vscode-extension/src/commands/indexCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ export class IndexCommand {
// Initialize file synchronizer
progress.report({ increment: 0, message: 'Initializing file synchronizer...' });
const { FileSynchronizer } = await import("@zilliz/claude-context-core");
const synchronizer = new FileSynchronizer(selectedFolder.uri.fsPath, this.context.getIgnorePatterns() || []);
const synchronizer = new FileSynchronizer(
selectedFolder.uri.fsPath,
this.context.getIgnorePatterns() || [],
this.context.getSupportedExtensions() || []
);
await synchronizer.initialize();
// Store synchronizer in the context's internal map using the collection name from context
await this.context.getPreparedCollection(selectedFolder.uri.fsPath);
Expand Down Expand Up @@ -173,4 +177,4 @@ export class IndexCommand {
}


}
}