codesearch-mcp 0.2.3-alpha → 0.4.0-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +88 -5
- package/LICENSE +661 -21
- package/README.md +76 -40
- package/dist/app.js +17 -38
- package/dist/src/ast/CallExtractor.d.ts +8 -0
- package/dist/src/ast/CallExtractor.js +68 -0
- package/dist/src/ast/GraphqlNameExtractor.d.ts +22 -0
- package/dist/src/ast/GraphqlNameExtractor.js +240 -0
- package/dist/src/ast/ImportEdgeExtractor.d.ts +11 -0
- package/dist/src/ast/ImportEdgeExtractor.js +129 -0
- package/dist/src/ast/IndexedNodeResolver.d.ts +14 -0
- package/dist/src/ast/IndexedNodeResolver.js +217 -0
- package/dist/src/ast/MemberExtractor.d.ts +8 -0
- package/dist/src/ast/MemberExtractor.js +129 -0
- package/dist/src/ast/TopLevelSymbolExtractor.d.ts +5 -0
- package/dist/src/ast/TopLevelSymbolExtractor.js +86 -0
- package/dist/src/ast/graphql-grammar.d.ts +24 -0
- package/dist/src/ast/graphql-grammar.js +93 -0
- package/dist/src/ast/node-helpers.d.ts +11 -0
- package/dist/src/ast/node-helpers.js +55 -0
- package/dist/src/chunking/AstChunker.d.ts +12 -0
- package/dist/src/chunking/AstChunker.js +30 -0
- package/dist/src/chunking/CharacterChunkStrategy.d.ts +8 -0
- package/dist/src/chunking/CharacterChunkStrategy.js +15 -0
- package/dist/src/chunking/DeclarationChunkStrategy.d.ts +15 -0
- package/dist/src/chunking/DeclarationChunkStrategy.js +87 -0
- package/dist/src/chunking/FragmentMerger.d.ts +11 -0
- package/dist/src/chunking/FragmentMerger.js +61 -0
- package/dist/src/chunking/ImportOnlyFilter.d.ts +5 -0
- package/dist/src/chunking/ImportOnlyFilter.js +14 -0
- package/dist/src/chunking/LangchainTextSplitter.d.ts +21 -0
- package/dist/src/chunking/LangchainTextSplitter.js +133 -0
- package/dist/src/chunking/MinSizeSplitPolicy.d.ts +9 -0
- package/dist/src/chunking/MinSizeSplitPolicy.js +18 -0
- package/dist/src/chunking/RunPacker.d.ts +12 -0
- package/dist/src/chunking/RunPacker.js +84 -0
- package/dist/src/chunking/create-chunker.d.ts +3 -0
- package/dist/src/chunking/create-chunker.js +15 -0
- package/dist/src/chunking/interfaces.d.ts +27 -0
- package/dist/src/commands/ConfigCommand.js +1 -9
- package/dist/src/commands/EvalCommand.d.ts +10 -5
- package/dist/src/commands/EvalCommand.js +60 -149
- package/dist/src/commands/IndexCommand.d.ts +10 -4
- package/dist/src/commands/IndexCommand.js +52 -146
- package/dist/src/commands/McpCommand.d.ts +6 -3
- package/dist/src/commands/McpCommand.js +19 -20
- package/dist/src/commands/WebCommand.d.ts +9 -3
- package/dist/src/commands/WebCommand.js +17 -11
- package/dist/src/commands/eval/baseline-comparison.d.ts +6 -0
- package/dist/src/commands/eval/baseline-comparison.js +54 -0
- package/dist/src/commands/eval/eval-args.d.ts +6 -0
- package/dist/src/commands/eval/eval-args.js +71 -0
- package/dist/src/commands/eval/eval-corpora.d.ts +6 -0
- package/dist/src/commands/eval/eval-corpora.js +76 -0
- package/dist/src/commands/eval/eval-metadata.d.ts +17 -0
- package/dist/src/commands/eval/eval-metadata.js +75 -0
- package/dist/src/commands/eval/index-inspector.d.ts +3 -0
- package/dist/src/commands/eval/index-inspector.js +21 -0
- package/dist/src/commands/eval/staged-search.d.ts +3 -0
- package/dist/src/commands/eval/staged-search.js +20 -0
- package/dist/src/commands/eval/suite-loader.d.ts +8 -0
- package/dist/src/commands/eval/suite-loader.js +52 -0
- package/dist/src/commands/index/backend-probe.d.ts +2 -0
- package/dist/src/commands/index/backend-probe.js +15 -0
- package/dist/src/commands/index/embedding-setup.d.ts +3 -0
- package/dist/src/commands/index/embedding-setup.js +16 -0
- package/dist/src/commands/index/index-summary.d.ts +2 -0
- package/dist/src/commands/index/index-summary.js +22 -0
- package/dist/src/commands/index/legacy-ollama-guard.d.ts +3 -0
- package/dist/src/commands/index/legacy-ollama-guard.js +23 -0
- package/dist/src/commands/index/prune-step.d.ts +3 -0
- package/dist/src/commands/index/prune-step.js +22 -0
- package/dist/src/commands/index/scan-targets.d.ts +8 -0
- package/dist/src/commands/index/scan-targets.js +107 -0
- package/dist/src/config-error.d.ts +0 -4
- package/dist/src/config-error.js +0 -4
- package/dist/src/config-store.d.ts +1 -55
- package/dist/src/config-store.js +11 -73
- package/dist/src/config.d.ts +9 -18
- package/dist/src/config.js +36 -35
- package/dist/src/constants.d.ts +17 -28
- package/dist/src/constants.js +35 -29
- package/dist/src/container.d.ts +10 -2
- package/dist/src/container.js +19 -8
- package/dist/src/db/drizzle-types.d.ts +7 -0
- package/dist/src/db/drizzle-types.js +2 -0
- package/dist/src/db/index.d.ts +1 -0
- package/dist/src/db/schema-steps.d.ts +8 -0
- package/dist/src/db/schema-steps.js +105 -0
- package/dist/src/db/schema.d.ts +17 -0
- package/dist/src/db/schema.js +1 -6
- package/dist/src/declarations/DeclarationTree.d.ts +19 -0
- package/dist/src/declarations/DeclarationTree.js +66 -0
- package/dist/src/declarations/DeclarationTreeBuilder.d.ts +22 -0
- package/dist/src/declarations/DeclarationTreeBuilder.js +179 -0
- package/dist/src/declarations/SourceLines.d.ts +37 -0
- package/dist/src/declarations/SourceLines.js +415 -0
- package/dist/src/dependency-traversal.d.ts +0 -6
- package/dist/src/dependency-traversal.js +0 -6
- package/dist/src/enriched-prompt.d.ts +0 -6
- package/dist/src/enriched-prompt.js +0 -6
- package/dist/src/error-record.d.ts +12 -0
- package/dist/src/error-record.js +248 -0
- package/dist/src/eval-corpus.d.ts +16 -0
- package/dist/src/eval-corpus.js +169 -0
- package/dist/src/eval-results.d.ts +6 -3
- package/dist/src/eval-results.js +323 -26
- package/dist/src/eval-vector-index.d.ts +5 -0
- package/dist/src/eval-vector-index.js +60 -0
- package/dist/src/file-utils.d.ts +0 -5
- package/dist/src/file-utils.js +0 -5
- package/dist/src/graph.d.ts +0 -25
- package/dist/src/graph.js +0 -28
- package/dist/src/help.js +9 -1
- package/dist/src/hnsw-settings.d.ts +3 -0
- package/dist/src/hnsw-settings.js +24 -0
- package/dist/src/index-args.d.ts +13 -0
- package/dist/src/index-args.js +48 -0
- package/dist/src/indexing/AnalysisBatcher.d.ts +12 -0
- package/dist/src/indexing/AnalysisBatcher.js +28 -0
- package/dist/src/indexing/ChunkEmbedder.d.ts +24 -0
- package/dist/src/indexing/ChunkEmbedder.js +37 -0
- package/dist/src/indexing/ConsoleScanReporter.d.ts +10 -0
- package/dist/src/indexing/ConsoleScanReporter.js +73 -0
- package/dist/src/indexing/EmbeddingSchemaPreparer.d.ts +14 -0
- package/dist/src/indexing/EmbeddingSchemaPreparer.js +66 -0
- package/dist/src/indexing/FileIngestor.d.ts +22 -0
- package/dist/src/indexing/FileIngestor.js +116 -0
- package/dist/src/indexing/IndexStore.d.ts +24 -0
- package/dist/src/indexing/IndexStore.js +69 -0
- package/dist/src/indexing/StaleFilePruner.d.ts +8 -0
- package/dist/src/indexing/StaleFilePruner.js +55 -0
- package/dist/src/indexing/analysis-rows.d.ts +4 -0
- package/dist/src/indexing/analysis-rows.js +65 -0
- package/dist/src/indexing/project-notices.d.ts +2 -0
- package/dist/src/indexing/project-notices.js +63 -0
- package/dist/src/interfaces/IAstParser.d.ts +4 -40
- package/dist/src/interfaces/ICallGraph.d.ts +28 -0
- package/dist/src/interfaces/ICallGraph.js +2 -0
- package/dist/src/interfaces/IChunkSearch.d.ts +42 -0
- package/dist/src/interfaces/IChunkSearch.js +2 -0
- package/dist/src/interfaces/IChunker.d.ts +3 -12
- package/dist/src/interfaces/ICorpusInspector.d.ts +7 -0
- package/dist/src/interfaces/ICorpusInspector.js +2 -0
- package/dist/src/interfaces/IDatabase.d.ts +8 -24
- package/dist/src/interfaces/IDependencyGraph.d.ts +24 -0
- package/dist/src/interfaces/IDependencyGraph.js +2 -0
- package/dist/src/interfaces/IEmbedder.d.ts +0 -9
- package/dist/src/interfaces/IIndexIdentityGuard.d.ts +3 -0
- package/dist/src/interfaces/IIndexIdentityGuard.js +2 -0
- package/dist/src/interfaces/IIndexedNodeResolver.d.ts +10 -0
- package/dist/src/interfaces/IIndexedNodeResolver.js +2 -0
- package/dist/src/interfaces/ILogger.d.ts +1 -11
- package/dist/src/interfaces/IMcpReadiness.d.ts +12 -0
- package/dist/src/interfaces/IMcpReadiness.js +2 -0
- package/dist/src/interfaces/IMcpToolHandler.d.ts +0 -5
- package/dist/src/interfaces/IMonorepoResolver.d.ts +0 -22
- package/dist/src/interfaces/IProjectCatalog.d.ts +13 -0
- package/dist/src/interfaces/IProjectCatalog.js +2 -0
- package/dist/src/interfaces/IProjectDiscovery.d.ts +0 -17
- package/dist/src/interfaces/IProjectRoots.d.ts +3 -0
- package/dist/src/interfaces/IProjectRoots.js +2 -0
- package/dist/src/interfaces/IRetrievalEvaluator.d.ts +153 -12
- package/dist/src/interfaces/IScanReporter.d.ts +13 -0
- package/dist/src/interfaces/IScanReporter.js +2 -0
- package/dist/src/interfaces/ISymbolLookup.d.ts +49 -0
- package/dist/src/interfaces/ISymbolLookup.js +2 -0
- package/dist/src/interfaces/IToolPaths.d.ts +62 -0
- package/dist/src/interfaces/IToolPaths.js +2 -0
- package/dist/src/interfaces/IWorkspaceFiles.d.ts +28 -0
- package/dist/src/interfaces/IWorkspaceFiles.js +2 -0
- package/dist/src/interfaces/SymbolKind.d.ts +1 -0
- package/dist/src/interfaces/SymbolKind.js +2 -0
- package/dist/src/interfaces/index.d.ts +12 -1
- package/dist/src/interrupt.js +0 -2
- package/dist/src/owner-path.d.ts +9 -10
- package/dist/src/owner-path.js +11 -23
- package/dist/src/project-scope.d.ts +1 -12
- package/dist/src/project-scope.js +5 -12
- package/dist/src/project-selector.d.ts +0 -5
- package/dist/src/project-selector.js +0 -11
- package/dist/src/retrieval-eval.d.ts +15 -6
- package/dist/src/retrieval-eval.js +388 -59
- package/dist/src/search/CallGraph.d.ts +9 -0
- package/dist/src/search/CallGraph.js +84 -0
- package/dist/src/search/ChunkSearch.d.ts +23 -0
- package/dist/src/search/ChunkSearch.js +115 -0
- package/dist/src/search/DependencyGraph.d.ts +19 -0
- package/dist/src/search/DependencyGraph.js +180 -0
- package/dist/src/search/IndexIdentityGuard.d.ts +11 -0
- package/dist/src/search/IndexIdentityGuard.js +37 -0
- package/dist/src/search/ProjectCatalog.d.ts +11 -0
- package/dist/src/search/ProjectCatalog.js +38 -0
- package/dist/src/search/SymbolLookup.d.ts +24 -0
- package/dist/src/search/SymbolLookup.js +97 -0
- package/dist/src/search/chunks/CandidateFetcher.d.ts +19 -0
- package/dist/src/search/chunks/CandidateFetcher.js +40 -0
- package/dist/src/search/chunks/IterativeScanGate.d.ts +10 -0
- package/dist/src/search/chunks/IterativeScanGate.js +42 -0
- package/dist/src/search/chunks/RerankStage.d.ts +15 -0
- package/dist/src/search/chunks/RerankStage.js +42 -0
- package/dist/src/search/chunks/search-metrics.d.ts +18 -0
- package/dist/src/search/chunks/search-metrics.js +32 -0
- package/dist/src/search/chunks/search-plan.d.ts +18 -0
- package/dist/src/search/chunks/search-plan.js +19 -0
- package/dist/src/search/create-search-services.d.ts +26 -0
- package/dist/src/search/create-search-services.js +29 -0
- package/dist/src/search/index-paths.d.ts +1 -0
- package/dist/src/search/index-paths.js +5 -0
- package/dist/src/search/result-shaping.d.ts +4 -0
- package/dist/src/search/result-shaping.js +19 -0
- package/dist/src/search/symbol-sql.d.ts +13 -0
- package/dist/src/search/symbol-sql.js +66 -0
- package/dist/src/search/symbols/SymbolGrepFallback.d.ts +19 -0
- package/dist/src/search/symbols/SymbolGrepFallback.js +106 -0
- package/dist/src/search/symbols/SymbolIndexQuery.d.ts +14 -0
- package/dist/src/search/symbols/SymbolIndexQuery.js +52 -0
- package/dist/src/search/symbols/SymbolTextSearch.d.ts +13 -0
- package/dist/src/search/symbols/SymbolTextSearch.js +84 -0
- package/dist/src/search/symbols/TargetColumnGate.d.ts +7 -0
- package/dist/src/search/symbols/TargetColumnGate.js +23 -0
- package/dist/src/search/symbols/find-symbol-constants.d.ts +4 -0
- package/dist/src/search/symbols/find-symbol-constants.js +8 -0
- package/dist/src/search/symbols/grep-args.d.ts +3 -0
- package/dist/src/search/symbols/grep-args.js +7 -0
- package/dist/src/search/symbols/grep-patterns.d.ts +4 -0
- package/dist/src/search/symbols/grep-patterns.js +60 -0
- package/dist/src/services/AstParserService.d.ts +10 -106
- package/dist/src/services/AstParserService.js +37 -1068
- package/dist/src/services/DatabaseService.d.ts +10 -17
- package/dist/src/services/DatabaseService.js +71 -115
- package/dist/src/services/EmbedderFactory.d.ts +0 -4
- package/dist/src/services/EmbedderFactory.js +0 -5
- package/dist/src/services/IndexerService.d.ts +7 -26
- package/dist/src/services/IndexerService.js +38 -286
- package/dist/src/services/InfinityEmbedder.d.ts +0 -21
- package/dist/src/services/InfinityEmbedder.js +0 -15
- package/dist/src/services/LoggerService.d.ts +7 -5
- package/dist/src/services/LoggerService.js +37 -41
- package/dist/src/services/McpReadiness.d.ts +18 -0
- package/dist/src/services/McpReadiness.js +73 -0
- package/dist/src/services/McpServer.d.ts +50 -19
- package/dist/src/services/McpServer.js +132 -62
- package/dist/src/services/MonorepoAwareDiscoveryService.d.ts +1 -45
- package/dist/src/services/MonorepoAwareDiscoveryService.js +1 -51
- package/dist/src/services/NxMonorepoResolver.d.ts +0 -29
- package/dist/src/services/NxMonorepoResolver.js +5 -56
- package/dist/src/services/OpenAICompatibleEmbedder.d.ts +0 -6
- package/dist/src/services/OpenAICompatibleEmbedder.js +0 -14
- package/dist/src/services/ProjectDiscoveryService.d.ts +0 -4
- package/dist/src/services/ProjectDiscoveryService.js +0 -4
- package/dist/src/services/VoyageEmbedder.d.ts +0 -6
- package/dist/src/services/VoyageEmbedder.js +0 -6
- package/dist/src/services/WebServerService.d.ts +5 -56
- package/dist/src/services/WebServerService.js +25 -63
- package/dist/src/services/http-retry.d.ts +0 -7
- package/dist/src/services/http-retry.js +1 -10
- package/dist/src/services/infinity-provisioning.d.ts +0 -74
- package/dist/src/services/infinity-provisioning.js +5 -88
- package/dist/src/services/legacy-ollama-index.d.ts +0 -16
- package/dist/src/services/legacy-ollama-index.js +0 -23
- package/dist/src/services/reranker.d.ts +0 -9
- package/dist/src/services/reranker.js +46 -12
- package/dist/src/setup.d.ts +24 -24
- package/dist/src/setup.js +205 -103
- package/dist/src/symbol-name.d.ts +1 -12
- package/dist/src/symbol-name.js +16 -25
- package/dist/src/symbol-rows.d.ts +0 -14
- package/dist/src/symbol-rows.js +0 -14
- package/dist/src/tool-call-log.d.ts +2 -0
- package/dist/src/tool-call-log.js +24 -0
- package/dist/src/tools/FindSymbolTool.d.ts +17 -7
- package/dist/src/tools/FindSymbolTool.js +54 -35
- package/dist/src/tools/GetCallersTool.d.ts +16 -8
- package/dist/src/tools/GetCallersTool.js +65 -35
- package/dist/src/tools/GetDependenciesTool.d.ts +16 -8
- package/dist/src/tools/GetDependenciesTool.js +36 -29
- package/dist/src/tools/GetDependentsTool.d.ts +20 -8
- package/dist/src/tools/GetDependentsTool.js +48 -34
- package/dist/src/tools/ListFilesTool.d.ts +16 -8
- package/dist/src/tools/ListFilesTool.js +20 -26
- package/dist/src/tools/ListProjectsTool.d.ts +11 -7
- package/dist/src/tools/ListProjectsTool.js +13 -11
- package/dist/src/tools/McpTool.d.ts +17 -0
- package/dist/src/tools/McpTool.js +28 -0
- package/dist/src/tools/ReadFileRangeTool.d.ts +16 -8
- package/dist/src/tools/ReadFileRangeTool.js +23 -25
- package/dist/src/tools/ReadFileTool.d.ts +15 -8
- package/dist/src/tools/ReadFileTool.js +19 -24
- package/dist/src/tools/SearchCodebaseTool.d.ts +22 -10
- package/dist/src/tools/SearchCodebaseTool.js +71 -50
- package/dist/src/tools/format-helpers.d.ts +9 -9
- package/dist/src/tools/format-helpers.js +146 -28
- package/dist/src/tools/tool-args.d.ts +38 -0
- package/dist/src/tools/tool-args.js +95 -0
- package/dist/src/web/dashboard.d.ts +0 -8
- package/dist/src/web/dashboard.js +7 -10
- package/dist/src/workspace/GrepRunner.d.ts +15 -0
- package/dist/src/workspace/GrepRunner.js +104 -0
- package/dist/src/workspace/ProjectRoots.d.ts +22 -0
- package/dist/src/workspace/ProjectRoots.js +102 -0
- package/dist/src/workspace/ToolPaths.d.ts +31 -0
- package/dist/src/workspace/ToolPaths.js +312 -0
- package/dist/src/workspace/WorkspaceFiles.d.ts +19 -0
- package/dist/src/workspace/WorkspaceFiles.js +285 -0
- package/dist/src/workspace/fs-access.d.ts +9 -0
- package/dist/src/workspace/fs-access.js +47 -0
- package/dist/src/workspace/path-helpers.d.ts +3 -0
- package/dist/src/workspace/path-helpers.js +43 -0
- package/package.json +5 -4
- package/dist/src/interfaces/ISearcher.d.ts +0 -35
- package/dist/src/services/AstChunker.d.ts +0 -42
- package/dist/src/services/AstChunker.js +0 -158
- package/dist/src/services/SearcherService.d.ts +0 -342
- package/dist/src/services/SearcherService.js +0 -1199
- package/docs/web-dashboard.md +0 -206
- /package/dist/src/{interfaces/ISearcher.js → chunking/interfaces.js} +0 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.NODE_FS = void 0;
|
|
37
|
+
exports.errorCode = errorCode;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
exports.NODE_FS = {
|
|
40
|
+
realpath: p => fs.promises.realpath(p),
|
|
41
|
+
stat: p => fs.promises.stat(p),
|
|
42
|
+
readdir: p => fs.promises.readdir(p, { withFileTypes: true }),
|
|
43
|
+
createReadStream: p => fs.createReadStream(p),
|
|
44
|
+
};
|
|
45
|
+
function errorCode(err) {
|
|
46
|
+
return err?.code ?? 'EIO';
|
|
47
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripTrailingSlash = stripTrailingSlash;
|
|
4
|
+
exports.isWithin = isWithin;
|
|
5
|
+
exports.editDistance = editDistance;
|
|
6
|
+
function stripTrailingSlash(p) {
|
|
7
|
+
return p.length > 1 && p.endsWith('/') ? p.slice(0, -1) : p;
|
|
8
|
+
}
|
|
9
|
+
function isWithin(p, root) {
|
|
10
|
+
if (root === '.')
|
|
11
|
+
return true;
|
|
12
|
+
if (root === '/')
|
|
13
|
+
return p.startsWith('/');
|
|
14
|
+
return p === root || p.startsWith(root + '/');
|
|
15
|
+
}
|
|
16
|
+
function editDistance(a, b, max) {
|
|
17
|
+
const x = [...a];
|
|
18
|
+
const y = [...b];
|
|
19
|
+
const over = max + 1;
|
|
20
|
+
if (Math.abs(x.length - y.length) > max)
|
|
21
|
+
return over;
|
|
22
|
+
let prev = Array.from({ length: y.length + 1 }, (_, j) => (j <= max ? j : over));
|
|
23
|
+
let row = new Array(y.length + 1).fill(over);
|
|
24
|
+
for (let i = 1; i <= x.length; i++) {
|
|
25
|
+
const from = Math.max(1, i - max);
|
|
26
|
+
const to = Math.min(y.length, i + max);
|
|
27
|
+
row[0] = i <= max ? i : over;
|
|
28
|
+
row[from - 1] = from === 1 ? row[0] : over;
|
|
29
|
+
let best = row[0];
|
|
30
|
+
for (let j = from; j <= to; j++) {
|
|
31
|
+
const cell = Math.min(prev[j] + 1, row[j - 1] + 1, prev[j - 1] + (x[i - 1] === y[j - 1] ? 0 : 1), over);
|
|
32
|
+
row[j] = cell;
|
|
33
|
+
if (cell < best)
|
|
34
|
+
best = cell;
|
|
35
|
+
}
|
|
36
|
+
if (to < y.length)
|
|
37
|
+
row[to + 1] = over;
|
|
38
|
+
if (best > max)
|
|
39
|
+
return over;
|
|
40
|
+
[prev, row] = [row, prev];
|
|
41
|
+
}
|
|
42
|
+
return prev[y.length];
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codesearch-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-alpha",
|
|
4
4
|
"description": "Local semantic codebase search via MCP — indexes projects into pgvector, exposes search to Claude",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "AGPL-3.0-only",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mcp",
|
|
8
8
|
"model-context-protocol",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"infinity"
|
|
17
17
|
],
|
|
18
18
|
"engines": {
|
|
19
|
-
"node": ">=
|
|
19
|
+
"node": "^22.13.0 || >=23.5.0"
|
|
20
20
|
},
|
|
21
21
|
"main": "dist/app.js",
|
|
22
22
|
"bin": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"files": [
|
|
30
30
|
"dist/",
|
|
31
31
|
"docker/",
|
|
32
|
-
"docs/",
|
|
32
|
+
"docs/architecture.svg",
|
|
33
33
|
"README.md",
|
|
34
34
|
"CHANGELOG.md"
|
|
35
35
|
],
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@types/cli-progress": "^3.11.6",
|
|
66
66
|
"@types/node": "^22.0.0",
|
|
67
67
|
"@types/pg": "^8.20.0",
|
|
68
|
+
"ai-aleks-tool": "^2.5.4",
|
|
68
69
|
"ts-node": "^10.9.2",
|
|
69
70
|
"typescript": "^5.6.0",
|
|
70
71
|
"vitest": "^5.0.5"
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { SearchResult, NeighborResult, GraphContext, DependencyRow, ProjectRow, SymbolKind, SymbolHit, CallerRow, FileRangeResult, ListFilesResult, GrepSymbolResult, ResolvedToolPath, PathFailure } from '../services/SearcherService';
|
|
2
|
-
/**
|
|
3
|
-
* Searcher abstraction — McpServer depends on this interface
|
|
4
|
-
* rather than the concrete SearcherService.
|
|
5
|
-
*/
|
|
6
|
-
export interface ISearcher {
|
|
7
|
-
prepareQuery(raw: string): Promise<{
|
|
8
|
-
query: string;
|
|
9
|
-
translated: boolean;
|
|
10
|
-
}>;
|
|
11
|
-
assertIndexMatches(): Promise<void>;
|
|
12
|
-
listProjects(): Promise<ProjectRow[]>;
|
|
13
|
-
getProjectEdges(): Promise<{
|
|
14
|
-
from: string;
|
|
15
|
-
to: string;
|
|
16
|
-
}[]>;
|
|
17
|
-
searchChunks(query: string, limit: number, project: string | null, threshold?: number, rerankOverride?: boolean): Promise<SearchResult[]>;
|
|
18
|
-
fetchNeighbors(results: SearchResult[]): Promise<NeighborResult[]>;
|
|
19
|
-
fetchGraphContext(results: SearchResult[]): Promise<Map<string, GraphContext>>;
|
|
20
|
-
getDependencies(filePath: string, symbol?: string | null, transitive?: boolean): Promise<DependencyRow[]>;
|
|
21
|
-
getDependents(filePath: string, symbol?: string | null, transitive?: boolean): Promise<DependencyRow[]>;
|
|
22
|
-
getCallers(symbol: string, project: string, calleeFile?: string | null): Promise<CallerRow[]>;
|
|
23
|
-
grepSymbol(symbol: string, rootDir: string, excludeFile: string): Promise<GrepSymbolResult>;
|
|
24
|
-
findSymbol(name: string, project: string | null, kind: SymbolKind): Promise<{
|
|
25
|
-
hits: SymbolHit[];
|
|
26
|
-
truncated: boolean;
|
|
27
|
-
grepFailed: boolean;
|
|
28
|
-
}>;
|
|
29
|
-
listFiles(relPath: string, depth: number, pattern: string | null): Promise<ListFilesResult>;
|
|
30
|
-
readFile(relPath: string, maxLines: number): Promise<FileRangeResult>;
|
|
31
|
-
readFileRange(relPath: string, startLine: number, endLine: number): Promise<FileRangeResult>;
|
|
32
|
-
resolveToolPath(input: string | null | undefined): Promise<ResolvedToolPath>;
|
|
33
|
-
checkGraphPath(relPath: string): Promise<PathFailure | null>;
|
|
34
|
-
fallbackRoot(relPath: string): string | null;
|
|
35
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { Config } from '../config';
|
|
2
|
-
import type { IChunker, ChunkPiece, ChunkOpts } from '../interfaces/IChunker';
|
|
3
|
-
/**
|
|
4
|
-
* Splits TS/JS source into embeddable pieces aligned to top-level declaration
|
|
5
|
-
* ranges (AST strategy). Falls back to the character-based recursive splitter
|
|
6
|
-
* for schema files, files without symbol analysis, or when strategy is
|
|
7
|
-
* 'character' — that path is byte-for-byte the previous behavior.
|
|
8
|
-
*/
|
|
9
|
-
export declare class AstChunker implements IChunker {
|
|
10
|
-
private config;
|
|
11
|
-
private readonly jsSplitter;
|
|
12
|
-
private readonly schemaSplitter;
|
|
13
|
-
private readonly chunkSize;
|
|
14
|
-
constructor(config: Config);
|
|
15
|
-
chunk(code: string, opts: ChunkOpts): Promise<ChunkPiece[]>;
|
|
16
|
-
private produce;
|
|
17
|
-
/**
|
|
18
|
-
* True iff every significant line (blank and comment lines stripped) belongs
|
|
19
|
-
* to an `import` / re-export statement and at least one is an import or
|
|
20
|
-
* re-export keyword — so the chunk carries no value/type declaration and is
|
|
21
|
-
* never a search answer. Any `export const|let|var|function|class|interface|
|
|
22
|
-
* enum|namespace|default|declare|async function|type X = …` disqualifies
|
|
23
|
-
* exclusion. Pure. Distinguishes `export { … } from` / `export type { … }`
|
|
24
|
-
* (re-export → drop) from `export type X = …` (declaration → keep).
|
|
25
|
-
*/
|
|
26
|
-
static isImportOrReexportOnly(content: string): boolean;
|
|
27
|
-
/** Character-splitter path for a whole file; line numbers from splitter metadata. */
|
|
28
|
-
private splitWholeFile;
|
|
29
|
-
private chunkByAst;
|
|
30
|
-
/**
|
|
31
|
-
* Build disjoint, sorted line intervals from symbol ranges. Overlapping /
|
|
32
|
-
* nested ranges merge into the outermost (a merged region covers any symbol
|
|
33
|
-
* inside it). Ranges are clamped to the file's line count.
|
|
34
|
-
*/
|
|
35
|
-
private static buildIntervals;
|
|
36
|
-
/**
|
|
37
|
-
* Emit pieces for a 1-based inclusive line region. Whitespace-only gaps are
|
|
38
|
-
* dropped; regions longer than chunkSize are sub-split with the char splitter,
|
|
39
|
-
* with sub-piece line numbers offset back to absolute file lines.
|
|
40
|
-
*/
|
|
41
|
-
private regionPieces;
|
|
42
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AstChunker = void 0;
|
|
4
|
-
const textsplitters_1 = require("@langchain/textsplitters");
|
|
5
|
-
/**
|
|
6
|
-
* Splits TS/JS source into embeddable pieces aligned to top-level declaration
|
|
7
|
-
* ranges (AST strategy). Falls back to the character-based recursive splitter
|
|
8
|
-
* for schema files, files without symbol analysis, or when strategy is
|
|
9
|
-
* 'character' — that path is byte-for-byte the previous behavior.
|
|
10
|
-
*/
|
|
11
|
-
class AstChunker {
|
|
12
|
-
config;
|
|
13
|
-
jsSplitter;
|
|
14
|
-
schemaSplitter;
|
|
15
|
-
chunkSize;
|
|
16
|
-
constructor(config) {
|
|
17
|
-
this.config = config;
|
|
18
|
-
this.chunkSize = config.indexer.chunkSize;
|
|
19
|
-
this.jsSplitter = textsplitters_1.RecursiveCharacterTextSplitter.fromLanguage('js', {
|
|
20
|
-
chunkSize: config.indexer.chunkSize,
|
|
21
|
-
chunkOverlap: config.indexer.chunkOverlap,
|
|
22
|
-
});
|
|
23
|
-
this.schemaSplitter = new textsplitters_1.RecursiveCharacterTextSplitter({
|
|
24
|
-
chunkSize: config.indexer.chunkSize,
|
|
25
|
-
chunkOverlap: config.indexer.chunkOverlap,
|
|
26
|
-
separators: ['\n\n', '\n', ' '],
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
async chunk(code, opts) {
|
|
30
|
-
const pieces = await this.produce(code, opts);
|
|
31
|
-
// Single post-chunk pass: drop pieces whose only significant content is
|
|
32
|
-
// import / re-export statements. Both chunk sources — AST "gap" regions and
|
|
33
|
-
// the whole-file character path for barrel files — can emit these, so we
|
|
34
|
-
// filter once over the final pieces. Dependency edges are untouched (they
|
|
35
|
-
// come from analyzeProject → code_dependency, not from chunk text).
|
|
36
|
-
return pieces.filter(p => !AstChunker.isImportOrReexportOnly(p.content));
|
|
37
|
-
}
|
|
38
|
-
async produce(code, opts) {
|
|
39
|
-
if (opts.isSchemaFile) {
|
|
40
|
-
return this.splitWholeFile(code, this.schemaSplitter);
|
|
41
|
-
}
|
|
42
|
-
if (opts.strategy === 'character' || opts.symbols.length === 0) {
|
|
43
|
-
return this.splitWholeFile(code, this.jsSplitter);
|
|
44
|
-
}
|
|
45
|
-
return this.chunkByAst(code, opts.symbols);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* True iff every significant line (blank and comment lines stripped) belongs
|
|
49
|
-
* to an `import` / re-export statement and at least one is an import or
|
|
50
|
-
* re-export keyword — so the chunk carries no value/type declaration and is
|
|
51
|
-
* never a search answer. Any `export const|let|var|function|class|interface|
|
|
52
|
-
* enum|namespace|default|declare|async function|type X = …` disqualifies
|
|
53
|
-
* exclusion. Pure. Distinguishes `export { … } from` / `export type { … }`
|
|
54
|
-
* (re-export → drop) from `export type X = …` (declaration → keep).
|
|
55
|
-
*/
|
|
56
|
-
static isImportOrReexportOnly(content) {
|
|
57
|
-
const lines = content
|
|
58
|
-
.replace(/\/\*[\s\S]*?\*\//g, '') // strip block comments
|
|
59
|
-
.split('\n')
|
|
60
|
-
.map(l => l.trim())
|
|
61
|
-
.filter(l => l !== '' && !l.startsWith('//') && !l.startsWith('*'));
|
|
62
|
-
if (lines.length === 0)
|
|
63
|
-
return false;
|
|
64
|
-
const IMPORT = /^import\b/;
|
|
65
|
-
const REEXPORT = /^export\s+(\*|type\s+\{|\{)/; // export * | export type { | export {
|
|
66
|
-
const DISQUALIFY = /^export\s+(default|async\b|function\b|const\b|let\b|var\b|class\b|abstract\b|interface\b|enum\b|namespace\b|declare\b|type\s+[A-Za-z_$])/;
|
|
67
|
-
const CONTINUATION = /^(\}?\s*from\s+['"][^'"]+['"];?|[{}]|(type\s+)?[A-Za-z_$][\w$]*(\s+as\s+[A-Za-z_$][\w$]*)?,?|['"][^'"]*['"];?)$/;
|
|
68
|
-
let keywords = 0;
|
|
69
|
-
for (const line of lines) {
|
|
70
|
-
if (DISQUALIFY.test(line))
|
|
71
|
-
return false;
|
|
72
|
-
if (IMPORT.test(line) || REEXPORT.test(line)) {
|
|
73
|
-
keywords++;
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
if (CONTINUATION.test(line))
|
|
77
|
-
continue;
|
|
78
|
-
return false; // unrecognized line → real code, keep the chunk
|
|
79
|
-
}
|
|
80
|
-
return keywords >= 1;
|
|
81
|
-
}
|
|
82
|
-
/** Character-splitter path for a whole file; line numbers from splitter metadata. */
|
|
83
|
-
async splitWholeFile(code, splitter) {
|
|
84
|
-
const docs = await splitter.createDocuments([code]);
|
|
85
|
-
return docs.map((d) => {
|
|
86
|
-
const from = (d.metadata?.loc?.lines?.from ?? 1);
|
|
87
|
-
const to = (d.metadata?.loc?.lines?.to ?? from);
|
|
88
|
-
return { content: d.pageContent, startLine: from, endLine: to };
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
async chunkByAst(code, symbols) {
|
|
92
|
-
const lines = code.split('\n');
|
|
93
|
-
const total = lines.length;
|
|
94
|
-
const intervals = AstChunker.buildIntervals(symbols, total);
|
|
95
|
-
const pieces = [];
|
|
96
|
-
let cursor = 1;
|
|
97
|
-
for (const iv of intervals) {
|
|
98
|
-
if (cursor < iv.start) {
|
|
99
|
-
pieces.push(...await this.regionPieces(lines, cursor, iv.start - 1, true));
|
|
100
|
-
}
|
|
101
|
-
pieces.push(...await this.regionPieces(lines, iv.start, iv.end, false));
|
|
102
|
-
cursor = iv.end + 1;
|
|
103
|
-
}
|
|
104
|
-
if (cursor <= total) {
|
|
105
|
-
pieces.push(...await this.regionPieces(lines, cursor, total, true));
|
|
106
|
-
}
|
|
107
|
-
return pieces;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Build disjoint, sorted line intervals from symbol ranges. Overlapping /
|
|
111
|
-
* nested ranges merge into the outermost (a merged region covers any symbol
|
|
112
|
-
* inside it). Ranges are clamped to the file's line count.
|
|
113
|
-
*/
|
|
114
|
-
static buildIntervals(symbols, total) {
|
|
115
|
-
const raw = symbols
|
|
116
|
-
.filter(s => s.line != null && s.line >= 1 && s.line <= total)
|
|
117
|
-
.map(s => ({
|
|
118
|
-
start: s.line,
|
|
119
|
-
end: Math.min(Math.max(s.endLine ?? s.line, s.line), total),
|
|
120
|
-
}))
|
|
121
|
-
.sort((a, b) => a.start - b.start || b.end - a.end);
|
|
122
|
-
const merged = [];
|
|
123
|
-
for (const iv of raw) {
|
|
124
|
-
const last = merged[merged.length - 1];
|
|
125
|
-
if (last && iv.start <= last.end) {
|
|
126
|
-
last.end = Math.max(last.end, iv.end);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
merged.push({ ...iv });
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return merged;
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Emit pieces for a 1-based inclusive line region. Whitespace-only gaps are
|
|
136
|
-
* dropped; regions longer than chunkSize are sub-split with the char splitter,
|
|
137
|
-
* with sub-piece line numbers offset back to absolute file lines.
|
|
138
|
-
*/
|
|
139
|
-
async regionPieces(lines, start, end, isGap) {
|
|
140
|
-
const text = lines.slice(start - 1, end).join('\n');
|
|
141
|
-
if (isGap && text.trim() === '')
|
|
142
|
-
return [];
|
|
143
|
-
if (text.length <= this.chunkSize) {
|
|
144
|
-
return [{ content: text, startLine: start, endLine: end }];
|
|
145
|
-
}
|
|
146
|
-
const docs = await this.jsSplitter.createDocuments([text]);
|
|
147
|
-
return docs.map((d) => {
|
|
148
|
-
const from = (d.metadata?.loc?.lines?.from ?? 1);
|
|
149
|
-
const to = (d.metadata?.loc?.lines?.to ?? from);
|
|
150
|
-
return {
|
|
151
|
-
content: d.pageContent,
|
|
152
|
-
startLine: start + from - 1,
|
|
153
|
-
endLine: start + to - 1,
|
|
154
|
-
};
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
exports.AstChunker = AstChunker;
|