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
|
@@ -1,8 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolResponse } from '../interfaces/IMcpToolHandler';
|
|
3
|
+
import type { ISymbolLookup } from '../interfaces/ISymbolLookup';
|
|
4
|
+
import type { SymbolKind } from '../interfaces/ISymbolLookup';
|
|
5
|
+
import type { ILogger } from '../interfaces/ILogger';
|
|
6
|
+
import { McpTool } from './McpTool';
|
|
7
|
+
declare const ARGS: z.ZodObject<{
|
|
8
|
+
name: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
9
|
+
project: z.ZodType<string | undefined, unknown, z.core.$ZodTypeInternals<string | undefined, unknown>>;
|
|
10
|
+
kind: z.ZodType<SymbolKind, unknown, z.core.$ZodTypeInternals<SymbolKind, unknown>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare class FindSymbolTool extends McpTool<typeof ARGS> {
|
|
13
|
+
private symbols;
|
|
14
|
+
constructor(symbols: ISymbolLookup, logger?: ILogger);
|
|
15
|
+
protected run({ name, project, kind }: z.output<typeof ARGS>): Promise<ToolResponse>;
|
|
16
|
+
private emptyText;
|
|
8
17
|
}
|
|
18
|
+
export {};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FindSymbolTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const LoggerService_1 = require("../services/LoggerService");
|
|
4
6
|
const format_helpers_1 = require("./format-helpers");
|
|
7
|
+
const McpTool_1 = require("./McpTool");
|
|
8
|
+
const tool_args_1 = require("./tool-args");
|
|
5
9
|
const VALID_KINDS = [
|
|
6
10
|
'function', 'class', 'type', 'interface', 'variable',
|
|
7
11
|
'method', 'get_accessor', 'set_accessor', 'constructor', 'function_property', 'method_signature',
|
|
@@ -13,13 +17,17 @@ const GRAPHQL_KINDS = new Set([
|
|
|
13
17
|
]);
|
|
14
18
|
const GRAPHQL_STALE_INDEX_HINT = 'Files indexed before GraphQL indexing was added have no GraphQL rows until `rag-index --reindex` — ' +
|
|
15
19
|
'this miss does not prove the name is absent.';
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const GREP_ADVICE = 'The index may be behind the source, so check with Grep before concluding the symbol does not exist.';
|
|
21
|
+
const PARTIAL_NOTE = '*(partial — some files could not be searched)*';
|
|
22
|
+
const ARGS = zod_1.z.object({
|
|
23
|
+
name: (0, tool_args_1.requiredText)('Bare, qualified (Class.method), quoted, or computed symbol name (case-sensitive)'),
|
|
24
|
+
project: (0, tool_args_1.optionalText)('Limit search to this project (optional). Use list_projects to find names.'),
|
|
25
|
+
kind: (0, tool_args_1.oneOf)('Symbol kind filter. Default: all.', VALID_KINDS, 'all'),
|
|
26
|
+
});
|
|
27
|
+
class FindSymbolTool extends McpTool_1.McpTool {
|
|
28
|
+
symbols;
|
|
29
|
+
constructor(symbols, logger = LoggerService_1.LoggerService.silent()) {
|
|
30
|
+
super({
|
|
23
31
|
name: 'find_symbol',
|
|
24
32
|
description: 'Find TypeScript/JavaScript symbol definitions by exact name: top-level declarations (functions, classes, types, ' +
|
|
25
33
|
'interfaces, variables), class/object-literal members (methods, get/set accessors, constructors, function ' +
|
|
@@ -30,48 +38,59 @@ class FindSymbolTool {
|
|
|
30
38
|
'resolve field (`@ResolveField`) or type (`@ObjectType`/`@InputType`/`@InterfaceType`) by its GraphQL name — the ' +
|
|
31
39
|
'name the schema exposes, which may differ from the TypeScript declaration name. Pass the matching `graphql_*` ' +
|
|
32
40
|
'kind when the name comes from a schema, a GraphQL document or a frontend.',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
name: { type: 'string', description: 'Bare, qualified (Class.method), quoted, or computed symbol name (case-sensitive)' },
|
|
37
|
-
project: { type: 'string', description: 'Limit search to this project (optional). Use list_projects to find names.' },
|
|
38
|
-
kind: { type: 'string', enum: VALID_KINDS, description: 'Symbol kind filter. Default: all.' },
|
|
39
|
-
},
|
|
40
|
-
required: ['name'],
|
|
41
|
-
},
|
|
42
|
-
};
|
|
41
|
+
args: ARGS,
|
|
42
|
+
}, logger);
|
|
43
|
+
this.symbols = symbols;
|
|
43
44
|
}
|
|
44
|
-
async
|
|
45
|
-
const name = String(args.name ?? '');
|
|
46
|
-
const project = args.project ? String(args.project) : null;
|
|
47
|
-
const rawKind = args.kind;
|
|
48
|
-
const kind = VALID_KINDS.includes(rawKind) ? rawKind : 'all';
|
|
45
|
+
async run({ name, project, kind }) {
|
|
49
46
|
let parsed;
|
|
50
47
|
try {
|
|
51
|
-
parsed = await this.
|
|
48
|
+
parsed = await this.symbols.findSymbol(name, project ?? null, kind);
|
|
52
49
|
}
|
|
53
50
|
catch (err) {
|
|
54
51
|
return (0, format_helpers_1.errorResponse)(err.message);
|
|
55
52
|
}
|
|
56
|
-
const { hits, truncated,
|
|
53
|
+
const { hits, truncated, grep } = parsed;
|
|
54
|
+
if (hits.length === 0)
|
|
55
|
+
return (0, format_helpers_1.textResponse)(this.emptyText(name, project ?? null, kind, parsed).join('\n'));
|
|
57
56
|
const lines = [];
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
const notes = [
|
|
58
|
+
...(truncated ? [`*(truncated to ${hits.length} results)*`] : []),
|
|
59
|
+
...(grep.outcome === 'partial' ? [PARTIAL_NOTE] : []),
|
|
60
|
+
];
|
|
61
|
+
if (notes.length > 0)
|
|
62
|
+
lines.push(`${notes.join(' ')}\n`);
|
|
63
|
+
const grepTag = name.includes('.')
|
|
64
|
+
? ' (grep — not in index; container not checked; may be stale or imprecise)'
|
|
65
|
+
: ' (grep — not in index; may be stale or imprecise)';
|
|
67
66
|
for (const h of hits) {
|
|
68
67
|
const staticTag = h.isStatic ? ' static' : '';
|
|
69
68
|
const targetTag = h.target ? ` → \`${h.target}\`` : '';
|
|
70
|
-
const
|
|
71
|
-
lines.push(`**${h.kind}** \`${h.qualified}\`${staticTag}${targetTag} \`${h.filePath}\` line ${h.line}, col ${h.column}${
|
|
69
|
+
const sourceTag = h.source === 'grep' ? grepTag : '';
|
|
70
|
+
lines.push(`**${h.kind}** \`${h.qualified}\`${staticTag}${targetTag} \`${h.filePath}\` line ${h.line}, col ${h.column}${sourceTag}`);
|
|
72
71
|
lines.push(`\`\`\`\n${h.signature}\n\`\`\``);
|
|
73
72
|
}
|
|
74
73
|
return (0, format_helpers_1.textResponse)(lines.join('\n'));
|
|
75
74
|
}
|
|
75
|
+
emptyText(name, project, kind, { grep, similar }) {
|
|
76
|
+
const suffix = grep.outcome === 'failed' ? ` (grep fallback failed: ${grep.cause})` : '';
|
|
77
|
+
const lines = [`No definitions found for symbol: ${name}${suffix}`];
|
|
78
|
+
if (GRAPHQL_KINDS.has(kind))
|
|
79
|
+
return [...lines, GRAPHQL_STALE_INDEX_HINT];
|
|
80
|
+
if (grep.outcome === 'no-project-directory') {
|
|
81
|
+
lines.push(`Project \`${project}\` has no directory in the workspace, so source files were not searched. Check the name with \`list_projects\`.`);
|
|
82
|
+
}
|
|
83
|
+
if (grep.outcome === 'other-container') {
|
|
84
|
+
const dot = name.lastIndexOf('.');
|
|
85
|
+
lines.push(`\`${name.slice(dot + 1)}\` is indexed, but not under \`${name.slice(0, dot)}\`, so source files were not searched.`);
|
|
86
|
+
}
|
|
87
|
+
if (similar.names.length > 0) {
|
|
88
|
+
lines.push('Similar indexed names:', ...similar.names.map(n => ` → \`${n}\``));
|
|
89
|
+
if (similar.truncated)
|
|
90
|
+
lines.push(`*(truncated to ${similar.names.length} results)*`);
|
|
91
|
+
lines.push(GREP_ADVICE);
|
|
92
|
+
}
|
|
93
|
+
return lines;
|
|
94
|
+
}
|
|
76
95
|
}
|
|
77
96
|
exports.FindSymbolTool = FindSymbolTool;
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolResponse } from '../interfaces/IMcpToolHandler';
|
|
3
|
+
import type { IToolPaths } from '../interfaces/IToolPaths';
|
|
4
|
+
import type { ICallGraph } from '../interfaces/ICallGraph';
|
|
3
5
|
import type { ILogger } from '../interfaces/ILogger';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { McpTool } from './McpTool';
|
|
7
|
+
declare const ARGS: z.ZodObject<{
|
|
8
|
+
symbol: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
9
|
+
project: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
10
|
+
callee_file: z.ZodType<string | undefined, unknown, z.core.$ZodTypeInternals<string | undefined, unknown>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare class GetCallersTool extends McpTool<typeof ARGS> {
|
|
13
|
+
private paths;
|
|
14
|
+
private calls;
|
|
15
|
+
constructor(paths: IToolPaths, calls: ICallGraph, logger: ILogger);
|
|
16
|
+
protected run({ symbol, project, callee_file: input }: z.output<typeof ARGS>): Promise<ToolResponse>;
|
|
10
17
|
}
|
|
18
|
+
export {};
|
|
@@ -1,59 +1,89 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetCallersTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
4
5
|
const format_helpers_1 = require("./format-helpers");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const McpTool_1 = require("./McpTool");
|
|
7
|
+
const tool_args_1 = require("./tool-args");
|
|
8
|
+
const symbol_name_1 = require("../symbol-name");
|
|
9
|
+
function truncationMarker(shown, truncated) {
|
|
10
|
+
return truncated ? [`*(truncated to ${shown} results)*`] : [];
|
|
11
|
+
}
|
|
12
|
+
function renderCause(project, calleeFile, cause) {
|
|
13
|
+
switch (cause.kind) {
|
|
14
|
+
case 'no-call-graph':
|
|
15
|
+
return [`Project \`${project}\` has no call graph. Check the name with \`list_projects\`. If the project is not indexed yet, run \`rag-index --project ${project}\`; an indexed project without internal calls has no graph to show.`];
|
|
16
|
+
case 'unknown-symbol':
|
|
17
|
+
return [
|
|
18
|
+
'No such symbol is indexed in this project.',
|
|
19
|
+
...(cause.suggestions.length > 0 ? ['Similar indexed names:', ...cause.suggestions.map(q => ` → \`${q}\``)] : []),
|
|
20
|
+
...truncationMarker(cause.suggestions.length, cause.truncated),
|
|
21
|
+
'Look a name up with `find_symbol`. The index may be behind the source, so check with Grep before concluding the symbol does not exist.',
|
|
22
|
+
];
|
|
23
|
+
case 'no-recorded-calls': {
|
|
24
|
+
const recorded = calleeFile ? `No calls to \`${calleeFile}\` are recorded in this project` : 'No calls are recorded in this project';
|
|
25
|
+
const lastReasons = calleeFile ? 'or it is passed as a callback' : 'it is passed as a callback, or it is unused';
|
|
26
|
+
return [
|
|
27
|
+
'Defined at:',
|
|
28
|
+
...cause.definitions.map(d => ` → \`${d.qualified}\` \`${d.filePath}\`${d.line != null ? ` line ${d.line}` : ''}`),
|
|
29
|
+
...truncationMarker(cause.definitions.length, cause.truncated),
|
|
30
|
+
`${recorded}, because the call graph holds direct calls only, per calling project. ` +
|
|
31
|
+
'Possibly it is called from another project, a framework invokes it (decorators, dependency injection), ' +
|
|
32
|
+
'a call goes through an interface-typed receiver and is recorded under the interface member, ' +
|
|
33
|
+
`it is instantiated with \`new\`, ${lastReasons}.`,
|
|
34
|
+
'Find importers with `get_dependents` and retry `get_callers` with the project that owns an importer\'s path, as `list_projects` shows, or use Grep.',
|
|
35
|
+
];
|
|
36
|
+
}
|
|
37
|
+
case 'lookup-failed':
|
|
38
|
+
return ['The cause could not be determined.'];
|
|
11
39
|
}
|
|
12
|
-
|
|
13
|
-
|
|
40
|
+
}
|
|
41
|
+
function renderNoCallers(symbol, project, calleeFile, cause) {
|
|
42
|
+
return [
|
|
43
|
+
`No call sites found for \`${symbol}\` in project \`${project}\`.`,
|
|
44
|
+
...renderCause(project, calleeFile, cause),
|
|
45
|
+
...(calleeFile ? ['Retry without `callee_file` to match calls to any definition.'] : []),
|
|
46
|
+
].join('\n');
|
|
47
|
+
}
|
|
48
|
+
const ARGS = zod_1.z.object({
|
|
49
|
+
symbol: (0, tool_args_1.requiredText)('Bare or qualified (Class.method) function/method name (case-sensitive)'),
|
|
50
|
+
project: (0, tool_args_1.requiredText)('Project name (from list_projects)'),
|
|
51
|
+
callee_file: (0, tool_args_1.optionalPathArg)(`Optional: only calls to the definition in this file, to disambiguate overloaded names. ${(0, format_helpers_1.pathArgDescription)()}`),
|
|
52
|
+
});
|
|
53
|
+
class GetCallersTool extends McpTool_1.McpTool {
|
|
54
|
+
paths;
|
|
55
|
+
calls;
|
|
56
|
+
constructor(paths, calls, logger) {
|
|
57
|
+
super({
|
|
14
58
|
name: 'get_callers',
|
|
15
59
|
description: 'Find all call sites of a function or method by exact name. Accepts a bare name (every call site with that ' +
|
|
16
60
|
'callee name) or a qualified name (`Class.method`, from find_symbol output) to disambiguate same-named methods ' +
|
|
17
61
|
'of different classes. Uses the call graph index — faster and more precise than grep. A call through an ' +
|
|
18
62
|
'interface-typed receiver is recorded under the interface member (e.g. `IEmbedder.embedBatch`), not the ' +
|
|
19
63
|
'implementing class. Use after find_symbol to trace where a symbol is actually called.',
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
project: { type: 'string', description: 'Project name (from list_projects)' },
|
|
25
|
-
callee_file: { type: 'string', description: `Optional: only calls to the definition in this file, to disambiguate overloaded names. ${(0, format_helpers_1.pathArgDescription)()}` },
|
|
26
|
-
},
|
|
27
|
-
required: ['symbol', 'project'],
|
|
28
|
-
},
|
|
29
|
-
};
|
|
64
|
+
args: ARGS,
|
|
65
|
+
}, logger);
|
|
66
|
+
this.paths = paths;
|
|
67
|
+
this.calls = calls;
|
|
30
68
|
}
|
|
31
|
-
async
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const rawCallee = args.callee_file;
|
|
69
|
+
async run({ symbol, project, callee_file: input }) {
|
|
70
|
+
if (!(0, symbol_name_1.parseCallerSymbol)(symbol))
|
|
71
|
+
return (0, format_helpers_1.errorResponse)('Invalid symbol name');
|
|
35
72
|
let calleeFile = null;
|
|
36
|
-
if (
|
|
37
|
-
const
|
|
38
|
-
const resolved = await this.searcher.resolveToolPath(input);
|
|
73
|
+
if (input !== undefined) {
|
|
74
|
+
const resolved = await this.paths.resolveToolPath(input);
|
|
39
75
|
if (!resolved.ok)
|
|
40
76
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'get_callers', 'callee_file', input, input, resolved);
|
|
41
|
-
const failure = await this.
|
|
77
|
+
const failure = await this.paths.checkGraphPath(resolved.relPath);
|
|
42
78
|
if (failure)
|
|
43
79
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'get_callers', 'callee_file', input, resolved.relPath, failure);
|
|
44
80
|
calleeFile = resolved.relPath;
|
|
45
81
|
}
|
|
46
|
-
|
|
47
|
-
try {
|
|
48
|
-
rows = await this.searcher.getCallers(symbol, project, calleeFile);
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
return (0, format_helpers_1.errorResponse)(err.message);
|
|
52
|
-
}
|
|
82
|
+
const rows = await this.calls.getCallers(symbol, project, calleeFile);
|
|
53
83
|
const lines = [];
|
|
54
84
|
if (rows.length === 0) {
|
|
55
|
-
|
|
56
|
-
return (0, format_helpers_1.textResponse)(
|
|
85
|
+
const cause = await this.calls.explainNoCallers(symbol, project);
|
|
86
|
+
return (0, format_helpers_1.textResponse)(renderNoCallers(symbol, project, calleeFile, cause));
|
|
57
87
|
}
|
|
58
88
|
lines.push(`**Call sites of \`${symbol}\`** (${rows.length} found)\n`);
|
|
59
89
|
for (const r of rows) {
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolResponse } from '../interfaces/IMcpToolHandler';
|
|
3
|
+
import type { IToolPaths } from '../interfaces/IToolPaths';
|
|
4
|
+
import type { IDependencyGraph } from '../interfaces/IDependencyGraph';
|
|
3
5
|
import type { ILogger } from '../interfaces/ILogger';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { McpTool } from './McpTool';
|
|
7
|
+
declare const ARGS: z.ZodObject<{
|
|
8
|
+
file_path: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
9
|
+
symbol: z.ZodType<string | undefined, unknown, z.core.$ZodTypeInternals<string | undefined, unknown>>;
|
|
10
|
+
transitive: z.ZodType<boolean | undefined, unknown, z.core.$ZodTypeInternals<boolean | undefined, unknown>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare class GetDependenciesTool extends McpTool<typeof ARGS> {
|
|
13
|
+
private paths;
|
|
14
|
+
private dependencies;
|
|
15
|
+
constructor(paths: IToolPaths, dependencies: IDependencyGraph, logger: ILogger);
|
|
16
|
+
protected run(args: z.output<typeof ARGS>): Promise<ToolResponse>;
|
|
10
17
|
}
|
|
18
|
+
export {};
|
|
@@ -1,45 +1,52 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetDependenciesTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
4
5
|
const format_helpers_1 = require("./format-helpers");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const McpTool_1 = require("./McpTool");
|
|
7
|
+
const tool_args_1 = require("./tool-args");
|
|
8
|
+
const ARGS = zod_1.z.object({
|
|
9
|
+
file_path: (0, tool_args_1.pathArg)((0, format_helpers_1.pathArgDescription)()),
|
|
10
|
+
symbol: (0, tool_args_1.optionalText)('Filter direct dependencies to named imports of this name (optional). Only named imports match, so default, namespace, side-effect and `export *` imports never match it; indirect (transitive) rows are not filtered by it.'),
|
|
11
|
+
transitive: (0, tool_args_1.flag)('Include transitive (indirect) dependencies. Default: false.'),
|
|
12
|
+
});
|
|
13
|
+
class GetDependenciesTool extends McpTool_1.McpTool {
|
|
14
|
+
paths;
|
|
15
|
+
dependencies;
|
|
16
|
+
constructor(paths, dependencies, logger) {
|
|
17
|
+
super({
|
|
14
18
|
name: 'get_dependencies',
|
|
15
|
-
description: 'Show what files a given file imports (direct or transitive), in any project. Use to understand what a file depends on before modifying it.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
symbol: { type: 'string', description: 'Filter to a specific imported symbol name (optional)' },
|
|
21
|
-
transitive: { type: 'boolean', description: 'Include transitive (indirect) dependencies. Default: false.' },
|
|
22
|
-
},
|
|
23
|
-
required: ['file_path'],
|
|
24
|
-
},
|
|
25
|
-
};
|
|
19
|
+
description: 'Show what files a given file imports (direct or transitive), in any project. Use to understand what a file depends on before modifying it. The direct section prints one line per imported file, with the names imported from it.',
|
|
20
|
+
args: ARGS,
|
|
21
|
+
}, logger);
|
|
22
|
+
this.paths = paths;
|
|
23
|
+
this.dependencies = dependencies;
|
|
26
24
|
}
|
|
27
|
-
async
|
|
28
|
-
const input = args.file_path
|
|
29
|
-
const symbol = args.symbol
|
|
30
|
-
const transitive =
|
|
31
|
-
const resolved = await this.
|
|
25
|
+
async run(args) {
|
|
26
|
+
const input = args.file_path;
|
|
27
|
+
const symbol = args.symbol ?? null;
|
|
28
|
+
const transitive = args.transitive ?? false;
|
|
29
|
+
const resolved = await this.paths.resolveToolPath(input);
|
|
32
30
|
if (!resolved.ok)
|
|
33
31
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'get_dependencies', 'file_path', input, input, resolved);
|
|
34
32
|
const filePath = resolved.relPath;
|
|
35
|
-
const rows = await this.
|
|
33
|
+
const rows = await this.dependencies.getDependencies(filePath, symbol, transitive);
|
|
36
34
|
if (rows.length === 0) {
|
|
37
|
-
const failure = await this.
|
|
35
|
+
const failure = await this.paths.checkGraphPath(filePath);
|
|
38
36
|
if (failure)
|
|
39
37
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'get_dependencies', 'file_path', input, filePath, failure);
|
|
40
|
-
return (0, format_helpers_1.textResponse)(`No dependencies found for: ${filePath}`);
|
|
41
38
|
}
|
|
42
|
-
|
|
39
|
+
if (symbol && !rows.some(r => (r.depth ?? 1) === 1)) {
|
|
40
|
+
const unfiltered = await this.dependencies.getDependencies(filePath, null, false);
|
|
41
|
+
if (unfiltered.length > 0) {
|
|
42
|
+
const miss = (0, format_helpers_1.formatDependenciesFilterMiss)(filePath, symbol, unfiltered);
|
|
43
|
+
const indirect = (0, format_helpers_1.formatTransitiveSection)(rows, symbol, 'dependencies');
|
|
44
|
+
return (0, format_helpers_1.textResponse)(indirect ? `${miss}\n\n${indirect}` : miss);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (rows.length === 0)
|
|
48
|
+
return (0, format_helpers_1.textResponse)(`No dependencies found for: ${filePath}`);
|
|
49
|
+
return (0, format_helpers_1.textResponse)((0, format_helpers_1.formatDependencies)(filePath, rows, transitive, symbol));
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
exports.GetDependenciesTool = GetDependenciesTool;
|
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolResponse } from '../interfaces/IMcpToolHandler';
|
|
3
|
+
import type { IToolPaths } from '../interfaces/IToolPaths';
|
|
4
|
+
import type { IDependencyGraph } from '../interfaces/IDependencyGraph';
|
|
5
|
+
import type { IProjectRoots } from '../interfaces/IProjectRoots';
|
|
6
|
+
import type { ISymbolLookup } from '../interfaces/ISymbolLookup';
|
|
3
7
|
import type { ILogger } from '../interfaces/ILogger';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
import { McpTool } from './McpTool';
|
|
9
|
+
declare const ARGS: z.ZodObject<{
|
|
10
|
+
file_path: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
11
|
+
symbol: z.ZodType<string | undefined, unknown, z.core.$ZodTypeInternals<string | undefined, unknown>>;
|
|
12
|
+
transitive: z.ZodType<boolean | undefined, unknown, z.core.$ZodTypeInternals<boolean | undefined, unknown>>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export declare class GetDependentsTool extends McpTool<typeof ARGS> {
|
|
15
|
+
private paths;
|
|
16
|
+
private dependencies;
|
|
17
|
+
private roots;
|
|
18
|
+
private symbols;
|
|
19
|
+
constructor(paths: IToolPaths, dependencies: IDependencyGraph, roots: IProjectRoots, symbols: ISymbolLookup, logger: ILogger);
|
|
20
|
+
protected run(args: z.output<typeof ARGS>): Promise<ToolResponse>;
|
|
10
21
|
}
|
|
22
|
+
export {};
|
|
@@ -1,53 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GetDependentsTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const symbol_name_1 = require("../symbol-name");
|
|
4
6
|
const format_helpers_1 = require("./format-helpers");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
const McpTool_1 = require("./McpTool");
|
|
8
|
+
const tool_args_1 = require("./tool-args");
|
|
9
|
+
const ARGS = zod_1.z.object({
|
|
10
|
+
file_path: (0, tool_args_1.pathArg)((0, format_helpers_1.pathArgDescription)()),
|
|
11
|
+
symbol: (0, tool_args_1.optionalText)('Exported symbol name. Two behaviors: (1) narrows direct graph dependents to named imports of this symbol — only named imports match, so default, namespace, side-effect and `export *` imports never match it, and indirect (transitive) rows are not filtered by it; (2) if no graph row remains after the filter, triggers a whole-word text-search fallback (grep -F -w) across all .ts/.tsx/.js/.jsx files of the project owning the file to find runtime usages — DI containers, singletons, dynamic lookups, string references. Capped at 200 matches.'),
|
|
12
|
+
transitive: (0, tool_args_1.flag)('Include transitive (indirect) dependents. Default: false.'),
|
|
13
|
+
});
|
|
14
|
+
class GetDependentsTool extends McpTool_1.McpTool {
|
|
15
|
+
paths;
|
|
16
|
+
dependencies;
|
|
17
|
+
roots;
|
|
18
|
+
symbols;
|
|
19
|
+
constructor(paths, dependencies, roots, symbols, logger) {
|
|
20
|
+
super({
|
|
14
21
|
name: 'get_dependents',
|
|
15
|
-
description: 'Show which files import a given file (reverse graph), in any project. Use before refactoring to find all callers and avoid breaking changes.
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
required: ['file_path'],
|
|
24
|
-
},
|
|
25
|
-
};
|
|
22
|
+
description: 'Show which files import a given file (reverse graph), in any project. Use before refactoring to find all callers and avoid breaking changes. The direct section prints one line per importing file, with the names imported and the enclosing declarations that use them — only those resolved unambiguously, so the list can be partial or absent.',
|
|
23
|
+
args: ARGS,
|
|
24
|
+
}, logger);
|
|
25
|
+
this.paths = paths;
|
|
26
|
+
this.dependencies = dependencies;
|
|
27
|
+
this.roots = roots;
|
|
28
|
+
this.symbols = symbols;
|
|
26
29
|
}
|
|
27
|
-
async
|
|
28
|
-
const input = args.file_path
|
|
29
|
-
const symbol = args.symbol
|
|
30
|
-
const transitive =
|
|
31
|
-
|
|
30
|
+
async run(args) {
|
|
31
|
+
const input = args.file_path;
|
|
32
|
+
const symbol = args.symbol ?? null;
|
|
33
|
+
const transitive = args.transitive ?? false;
|
|
34
|
+
if (symbol && symbol.length > symbol_name_1.MAX_GREPPED_NAME_LEN)
|
|
35
|
+
return (0, format_helpers_1.errorResponse)('Invalid symbol name');
|
|
36
|
+
const resolved = await this.paths.resolveToolPath(input);
|
|
32
37
|
if (!resolved.ok)
|
|
33
38
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'get_dependents', 'file_path', input, input, resolved);
|
|
34
39
|
const filePath = resolved.relPath;
|
|
35
|
-
const rows = await this.
|
|
36
|
-
if (rows.length
|
|
37
|
-
|
|
40
|
+
const rows = await this.dependencies.getDependents(filePath, symbol, transitive);
|
|
41
|
+
if (rows.length === 0) {
|
|
42
|
+
const failure = await this.paths.checkGraphPath(filePath);
|
|
43
|
+
if (failure)
|
|
44
|
+
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'get_dependents', 'file_path', input, filePath, failure);
|
|
45
|
+
}
|
|
46
|
+
let header = `**Dependents of** \`${filePath}\`\n\n**Direct:** No direct import dependents found.`;
|
|
47
|
+
if (symbol && !rows.some(r => (r.depth ?? 1) === 1)) {
|
|
48
|
+
const unfiltered = await this.dependencies.getDependents(filePath, null, false);
|
|
49
|
+
if (unfiltered.length > 0)
|
|
50
|
+
header = (0, format_helpers_1.formatDependentsFilterMiss)(filePath, symbol, unfiltered);
|
|
51
|
+
const indirect = (0, format_helpers_1.formatTransitiveSection)(rows, symbol, 'dependents');
|
|
52
|
+
if (indirect && unfiltered.length > 0)
|
|
53
|
+
return (0, format_helpers_1.textResponse)(`${header}\n\n${indirect}`);
|
|
38
54
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'get_dependents', 'file_path', input, filePath, failure);
|
|
42
|
-
const header = `**Dependents of** \`${filePath}\`\n\n**Direct:** No direct import dependents found.`;
|
|
55
|
+
if (rows.length > 0)
|
|
56
|
+
return (0, format_helpers_1.textResponse)((0, format_helpers_1.formatDependents)(filePath, rows, transitive, symbol));
|
|
43
57
|
if (!symbol) {
|
|
44
58
|
return (0, format_helpers_1.textResponse)(`${header}\n\nTip: pass \`symbol\` to trigger a text-search fallback for runtime usages (e.g. via singleton or container).`);
|
|
45
59
|
}
|
|
46
|
-
const rootDir = this.
|
|
60
|
+
const rootDir = this.roots.fallbackRoot(filePath);
|
|
47
61
|
if (rootDir === null)
|
|
48
62
|
return (0, format_helpers_1.textResponse)(header);
|
|
49
63
|
const fallbackHeader = `**Fallback \`[text search]\` for \`${symbol}\`:**`;
|
|
50
|
-
const grep = await this.
|
|
64
|
+
const grep = await this.symbols.grepSymbol(symbol, rootDir, filePath);
|
|
51
65
|
if (!grep.ok) {
|
|
52
66
|
return (0, format_helpers_1.textResponse)(`${header}\n\n${fallbackHeader} failed`);
|
|
53
67
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolResponse } from '../interfaces/IMcpToolHandler';
|
|
3
|
+
import type { IToolPaths } from '../interfaces/IToolPaths';
|
|
4
|
+
import type { IWorkspaceFiles } from '../interfaces/IWorkspaceFiles';
|
|
3
5
|
import type { ILogger } from '../interfaces/ILogger';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
import { McpTool } from './McpTool';
|
|
7
|
+
declare const ARGS: z.ZodObject<{
|
|
8
|
+
path: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
9
|
+
depth: z.ZodType<number, unknown, z.core.$ZodTypeInternals<number, unknown>>;
|
|
10
|
+
pattern: z.ZodType<string | undefined, unknown, z.core.$ZodTypeInternals<string | undefined, unknown>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare class ListFilesTool extends McpTool<typeof ARGS> {
|
|
13
|
+
private paths;
|
|
14
|
+
private files;
|
|
15
|
+
constructor(paths: IToolPaths, files: IWorkspaceFiles, logger: ILogger);
|
|
16
|
+
protected run({ path: input, depth, pattern }: z.output<typeof ARGS>): Promise<ToolResponse>;
|
|
10
17
|
}
|
|
18
|
+
export {};
|