Skip to content

Commit 9a5552a

Browse files
committed
fix: address analyzer hint review feedback
1 parent a0b731b commit 9a5552a

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/core/indexer.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ import {
2121
} from '../types/index.js';
2222
import { analyzerRegistry } from './analyzer-registry.js';
2323
import type { AnalyzerSelectionOptions } from './analyzer-registry.js';
24-
import { isCodeFile, isBinaryFile } from '../utils/language-detection.js';
24+
import {
25+
getSupportedExtensions,
26+
isBinaryFile,
27+
isCodeFile
28+
} from '../utils/language-detection.js';
2529
import {
2630
getEmbeddingProvider,
2731
getConfiguredDimensions,
@@ -227,6 +231,7 @@ export class CodebaseIndexer {
227231
private rootPath: string;
228232
private config: CodebaseConfig;
229233
private projectOptions: AnalyzerSelectionOptions;
234+
private supportedCodeExtensions: Set<string>;
230235
private progress: IndexingProgress;
231236
private onProgressCallback?: (progress: IndexingProgress) => void;
232237
private incrementalOnly: boolean;
@@ -238,6 +243,11 @@ export class CodebaseIndexer {
238243
preferredAnalyzer: options.projectOptions?.preferredAnalyzer,
239244
extraFileExtensions: options.projectOptions?.extraFileExtensions
240245
};
246+
this.supportedCodeExtensions = new Set(
247+
getSupportedExtensions(this.projectOptions.extraFileExtensions).map((extension) =>
248+
extension.toLowerCase()
249+
)
250+
);
241251
this.onProgressCallback = options.onProgress;
242252
this.incrementalOnly = options.incrementalOnly ?? false;
243253

@@ -1101,7 +1111,7 @@ export class CodebaseIndexer {
11011111
}
11021112

11031113
// Check if it's a code file
1104-
if (!isCodeFile(file, this.projectOptions.extraFileExtensions) || isBinaryFile(file)) {
1114+
if (!isCodeFile(file, this.supportedCodeExtensions) || isBinaryFile(file)) {
11051115
continue;
11061116
}
11071117

src/utils/language-detection.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,14 @@ export function detectLanguage(filePath: string): string {
187187
/**
188188
* Check if a file is a code file
189189
*/
190-
export function isCodeFile(filePath: string, extraExtensions?: Iterable<string>): boolean {
190+
export function isCodeFile(
191+
filePath: string,
192+
extensions?: Iterable<string> | ReadonlySet<string>
193+
): boolean {
191194
const ext = path.extname(filePath).toLowerCase();
192-
return buildCodeExtensions(extraExtensions).has(ext);
195+
const supportedExtensions =
196+
extensions instanceof Set ? extensions : buildCodeExtensions(extensions);
197+
return supportedExtensions.has(ext);
193198
}
194199

195200
/**

tests/mcp-client-templates.test.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ describe('templates/mcp/http/.mcp.json', () => {
6060
mcpServers: Record<string, unknown>;
6161
};
6262
expect(config.mcpServers).toHaveProperty('codebase-context');
63+
});
64+
6365
it('server entry points to the local HTTP endpoint', () => {
6466
const config = readJson('templates/mcp/http/.mcp.json') as {
6567
mcpServers: Record<string, { url?: string; type?: string }>;
@@ -68,9 +70,6 @@ describe('templates/mcp/http/.mcp.json', () => {
6870
expect(entry.url).toBe('http://127.0.0.1:3100/mcp');
6971
expect(entry.type).toBe('http');
7072
});
71-
const entry = config.mcpServers['codebase-context'];
72-
expect(entry.url).toBe('http://127.0.0.1:3100/mcp');
73-
});
7473
});
7574

7675
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)