codesearch-mcp 0.3.0-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 +59 -6
- package/LICENSE +661 -21
- package/README.md +33 -17
- package/dist/app.js +13 -20
- 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/commands/EvalCommand.d.ts +7 -3
- package/dist/src/commands/EvalCommand.js +36 -158
- package/dist/src/commands/IndexCommand.d.ts +10 -4
- package/dist/src/commands/IndexCommand.js +52 -124
- package/dist/src/commands/McpCommand.d.ts +6 -3
- package/dist/src/commands/McpCommand.js +19 -14
- package/dist/src/commands/WebCommand.d.ts +9 -3
- package/dist/src/commands/WebCommand.js +17 -8
- 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-store.d.ts +0 -1
- package/dist/src/config-store.js +3 -4
- package/dist/src/config.d.ts +1 -1
- package/dist/src/config.js +1 -1
- package/dist/src/constants.d.ts +15 -0
- package/dist/src/constants.js +34 -6
- package/dist/src/container.d.ts +4 -2
- package/dist/src/container.js +7 -5
- package/dist/src/db/drizzle-types.d.ts +7 -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/declarations/DeclarationTree.d.ts +1 -1
- package/dist/src/eval-results.js +16 -2
- package/dist/src/eval-vector-index.d.ts +5 -0
- package/dist/src/eval-vector-index.js +60 -0
- package/dist/src/help.js +9 -1
- 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 +2 -1
- 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/IDatabase.d.ts +6 -2
- package/dist/src/interfaces/IDependencyGraph.d.ts +24 -0
- package/dist/src/interfaces/IDependencyGraph.js +2 -0
- 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/IMcpReadiness.d.ts +12 -0
- package/dist/src/interfaces/IMcpReadiness.js +2 -0
- package/dist/src/interfaces/IProjectCatalog.d.ts +13 -0
- package/dist/src/interfaces/IProjectCatalog.js +2 -0
- package/dist/src/interfaces/IProjectRoots.d.ts +3 -0
- package/dist/src/interfaces/IProjectRoots.js +2 -0
- package/dist/src/interfaces/IRetrievalEvaluator.d.ts +21 -2
- 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/project-scope.d.ts +1 -0
- package/dist/src/project-scope.js +5 -0
- package/dist/src/retrieval-eval.d.ts +2 -1
- package/dist/src/retrieval-eval.js +45 -2
- 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/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 +8 -44
- package/dist/src/services/AstParserService.js +19 -938
- package/dist/src/services/DatabaseService.d.ts +8 -10
- package/dist/src/services/DatabaseService.js +29 -86
- package/dist/src/services/IndexerService.d.ts +7 -10
- package/dist/src/services/IndexerService.js +36 -255
- package/dist/src/services/McpReadiness.d.ts +18 -0
- package/dist/src/services/McpReadiness.js +73 -0
- package/dist/src/services/McpServer.d.ts +32 -9
- package/dist/src/services/McpServer.js +78 -41
- package/dist/src/services/WebServerService.d.ts +4 -3
- package/dist/src/services/WebServerService.js +16 -8
- package/dist/src/setup.d.ts +16 -4
- package/dist/src/setup.js +115 -40
- package/dist/src/symbol-name.d.ts +1 -0
- package/dist/src/symbol-name.js +16 -12
- 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 +35 -28
- package/dist/src/tools/GetDependentsTool.d.ts +20 -8
- package/dist/src/tools/GetDependentsTool.js +47 -33
- 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 +69 -51
- package/dist/src/tools/format-helpers.d.ts +9 -3
- package/dist/src/tools/format-helpers.js +59 -14
- package/dist/src/tools/tool-args.d.ts +38 -0
- package/dist/src/tools/tool-args.js +95 -0
- 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 +4 -3
- package/dist/src/interfaces/ISearcher.d.ts +0 -46
- package/dist/src/services/SearcherService.d.ts +0 -235
- package/dist/src/services/SearcherService.js +0 -1118
- /package/dist/src/{interfaces/ISearcher.js → db/drizzle-types.js} +0 -0
|
@@ -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
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.',
|
|
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
|
-
};
|
|
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
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.',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
required: ['file_path'],
|
|
24
|
-
},
|
|
25
|
-
};
|
|
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 {};
|
|
@@ -1,38 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ListFilesTool = 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
|
+
path: (0, tool_args_1.pathArg)((0, format_helpers_1.pathArgDescription)('directory'), 'directory'),
|
|
10
|
+
depth: (0, tool_args_1.intInRange)('Tree depth: 1 = immediate children only, up to 5. Default: 2.', { min: 1, max: 5, fallback: 2 }),
|
|
11
|
+
pattern: (0, tool_args_1.optionalText)('Optional filename filter (substring or extension like ".ts"). Only matching files are shown.'),
|
|
12
|
+
});
|
|
13
|
+
class ListFilesTool extends McpTool_1.McpTool {
|
|
14
|
+
paths;
|
|
15
|
+
files;
|
|
16
|
+
constructor(paths, files, logger) {
|
|
17
|
+
super({
|
|
14
18
|
name: 'list_files',
|
|
15
19
|
description: 'List files and directories under a workspace directory as an indented tree. Use to understand project structure before reading files; list_projects prints each project\'s directory.',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
depth: { type: 'number', description: 'Tree depth: 1 = immediate children only, up to 5. Default: 2.' },
|
|
21
|
-
pattern: { type: 'string', description: 'Optional filename filter (substring or extension like ".ts"). Only matching files are shown.' },
|
|
22
|
-
},
|
|
23
|
-
required: ['path'],
|
|
24
|
-
},
|
|
25
|
-
};
|
|
20
|
+
args: ARGS,
|
|
21
|
+
}, logger);
|
|
22
|
+
this.paths = paths;
|
|
23
|
+
this.files = files;
|
|
26
24
|
}
|
|
27
|
-
async
|
|
28
|
-
const
|
|
29
|
-
const rawDepth = Number(args.depth);
|
|
30
|
-
const depth = isNaN(rawDepth) || rawDepth < 1 ? 2 : Math.min(5, rawDepth);
|
|
31
|
-
const pattern = args.pattern ? String(args.pattern) : null;
|
|
32
|
-
const resolved = await this.searcher.resolveToolPath(input);
|
|
25
|
+
async run({ path: input, depth, pattern }) {
|
|
26
|
+
const resolved = await this.paths.resolveToolPath(input);
|
|
33
27
|
if (!resolved.ok)
|
|
34
28
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'list_files', 'path', input, input, resolved, 'directory');
|
|
35
|
-
const result = await this.
|
|
29
|
+
const result = await this.files.listFiles(resolved.relPath, depth, pattern ?? null);
|
|
36
30
|
if (!result.ok)
|
|
37
31
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'list_files', 'path', input, resolved.relPath, result, 'directory');
|
|
38
32
|
return (0, format_helpers_1.textResponse)(`**Directory:** ${resolved.relPath}\n\`\`\`\n${result.tree}\n\`\`\``);
|
|
@@ -1,8 +1,12 @@
|
|
|
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 { IProjectCatalog } from '../interfaces/IProjectCatalog';
|
|
4
|
+
import type { ILogger } from '../interfaces/ILogger';
|
|
5
|
+
import { McpTool } from './McpTool';
|
|
6
|
+
declare const ARGS: z.ZodObject<{}, z.core.$strip>;
|
|
7
|
+
export declare class ListProjectsTool extends McpTool<typeof ARGS> {
|
|
8
|
+
private catalog;
|
|
9
|
+
constructor(catalog: IProjectCatalog, logger?: ILogger);
|
|
10
|
+
protected run(): Promise<ToolResponse>;
|
|
8
11
|
}
|
|
12
|
+
export {};
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ListProjectsTool = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const LoggerService_1 = require("../services/LoggerService");
|
|
4
6
|
const format_helpers_1 = require("./format-helpers");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return {
|
|
7
|
+
const McpTool_1 = require("./McpTool");
|
|
8
|
+
const ARGS = zod_1.z.object({});
|
|
9
|
+
class ListProjectsTool extends McpTool_1.McpTool {
|
|
10
|
+
catalog;
|
|
11
|
+
constructor(catalog, logger = LoggerService_1.LoggerService.silent()) {
|
|
12
|
+
super({
|
|
12
13
|
name: 'list_projects',
|
|
13
14
|
description: 'List all indexed projects with their chunk counts, workspace-relative directory (`path:`) and metadata (description, stack, notes, relations from .ragmeta.json).',
|
|
14
|
-
|
|
15
|
-
};
|
|
15
|
+
args: ARGS,
|
|
16
|
+
}, logger);
|
|
17
|
+
this.catalog = catalog;
|
|
16
18
|
}
|
|
17
|
-
async
|
|
18
|
-
const rows = await this.
|
|
19
|
+
async run() {
|
|
20
|
+
const rows = await this.catalog.listProjects();
|
|
19
21
|
if (rows.length === 0) {
|
|
20
22
|
return (0, format_helpers_1.textResponse)('No indexed projects found.');
|
|
21
23
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import type { IMcpToolHandler, ToolDefinition, ToolResponse } from '../interfaces/IMcpToolHandler';
|
|
3
|
+
import type { ILogger } from '../interfaces/ILogger';
|
|
4
|
+
export interface McpToolSpec<S extends z.ZodObject> {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
args: S;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class McpTool<S extends z.ZodObject> implements IMcpToolHandler {
|
|
10
|
+
private readonly spec;
|
|
11
|
+
protected readonly logger: ILogger;
|
|
12
|
+
private cachedDefinition?;
|
|
13
|
+
constructor(spec: McpToolSpec<S>, logger: ILogger);
|
|
14
|
+
definition(): ToolDefinition;
|
|
15
|
+
handle(raw: Record<string, unknown>): Promise<ToolResponse>;
|
|
16
|
+
protected abstract run(args: z.output<S>): Promise<ToolResponse>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.McpTool = void 0;
|
|
4
|
+
const format_helpers_1 = require("./format-helpers");
|
|
5
|
+
const tool_args_1 = require("./tool-args");
|
|
6
|
+
class McpTool {
|
|
7
|
+
spec;
|
|
8
|
+
logger;
|
|
9
|
+
cachedDefinition;
|
|
10
|
+
constructor(spec, logger) {
|
|
11
|
+
this.spec = spec;
|
|
12
|
+
this.logger = logger;
|
|
13
|
+
}
|
|
14
|
+
definition() {
|
|
15
|
+
const { name, description, args } = this.spec;
|
|
16
|
+
return this.cachedDefinition ??= { name, description, inputSchema: (0, tool_args_1.toInputSchema)(args) };
|
|
17
|
+
}
|
|
18
|
+
async handle(raw) {
|
|
19
|
+
const parsed = (0, tool_args_1.parseToolArgs)(this.spec.args, raw);
|
|
20
|
+
if (parsed.ok)
|
|
21
|
+
return this.run(parsed.args);
|
|
22
|
+
const { failure } = parsed;
|
|
23
|
+
return failure.kind === 'missing-path'
|
|
24
|
+
? (0, format_helpers_1.pathErrorResponse)(this.logger, this.spec.name, failure.arg, '', '', { ok: false, reason: 'invalid', missing: true }, failure.pathKind)
|
|
25
|
+
: (0, format_helpers_1.errorResponse)(failure.text);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.McpTool = McpTool;
|
|
@@ -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
|
+
file_path: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
9
|
+
start_line: z.ZodType<number, unknown, z.core.$ZodTypeInternals<number, unknown>>;
|
|
10
|
+
end_line: z.ZodType<number | undefined, unknown, z.core.$ZodTypeInternals<number | undefined, unknown>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
export declare class ReadFileRangeTool extends McpTool<typeof ARGS> {
|
|
13
|
+
private paths;
|
|
14
|
+
private files;
|
|
15
|
+
constructor(paths: IToolPaths, files: IWorkspaceFiles, logger: ILogger);
|
|
16
|
+
protected run(args: z.output<typeof ARGS>): Promise<ToolResponse>;
|
|
10
17
|
}
|
|
18
|
+
export {};
|
|
@@ -1,37 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReadFileRangeTool = 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
|
+
start_line: (0, tool_args_1.intInRange)('First line to read (1-based). Use the **Line** number from search_codebase results. Default: 1.', { min: 1, fallback: 1 }),
|
|
11
|
+
end_line: (0, tool_args_1.intInRange)('Last line to read (1-based, inclusive). Default: start_line + 99.'),
|
|
12
|
+
});
|
|
13
|
+
class ReadFileRangeTool extends McpTool_1.McpTool {
|
|
14
|
+
paths;
|
|
15
|
+
files;
|
|
16
|
+
constructor(paths, files, logger) {
|
|
17
|
+
super({
|
|
14
18
|
name: 'read_file_range',
|
|
15
19
|
description: 'Read a specific line range from a file under the workspace, indexed or not. Use this when a search result looks incomplete — read the surrounding lines to get full context.',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
start_line: { type: 'number', description: 'First line to read (1-based). Use the **Line** number from search_codebase results. Default: 1.' },
|
|
21
|
-
end_line: { type: 'number', description: 'Last line to read (1-based, inclusive). Default: start_line + 99.' },
|
|
22
|
-
},
|
|
23
|
-
required: ['file_path'],
|
|
24
|
-
},
|
|
25
|
-
};
|
|
20
|
+
args: ARGS,
|
|
21
|
+
}, logger);
|
|
22
|
+
this.paths = paths;
|
|
23
|
+
this.files = files;
|
|
26
24
|
}
|
|
27
|
-
async
|
|
28
|
-
const input = args.file_path
|
|
29
|
-
const startLine =
|
|
30
|
-
const endLine =
|
|
31
|
-
const resolved = await this.
|
|
25
|
+
async run(args) {
|
|
26
|
+
const input = args.file_path;
|
|
27
|
+
const startLine = args.start_line;
|
|
28
|
+
const endLine = args.end_line ?? startLine + 99;
|
|
29
|
+
const resolved = await this.paths.resolveToolPath(input);
|
|
32
30
|
if (!resolved.ok)
|
|
33
31
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'read_file_range', 'file_path', input, input, resolved);
|
|
34
|
-
const range = await this.
|
|
32
|
+
const range = await this.files.readFileRange(resolved.relPath, startLine, endLine);
|
|
35
33
|
if (!range.ok)
|
|
36
34
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'read_file_range', 'file_path', input, resolved.relPath, range);
|
|
37
35
|
const numbered = range.lines.map((line, i) => `${startLine + i}: ${line}`).join('\n');
|
|
@@ -1,10 +1,17 @@
|
|
|
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
|
+
file_path: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
9
|
+
max_lines: z.ZodType<number, unknown, z.core.$ZodTypeInternals<number, unknown>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare class ReadFileTool extends McpTool<typeof ARGS> {
|
|
12
|
+
private paths;
|
|
13
|
+
private files;
|
|
14
|
+
constructor(paths: IToolPaths, files: IWorkspaceFiles, logger: ILogger);
|
|
15
|
+
protected run({ file_path: input, max_lines: maxLines }: z.output<typeof ARGS>): Promise<ToolResponse>;
|
|
10
16
|
}
|
|
17
|
+
export {};
|
|
@@ -1,36 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ReadFileTool = 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
|
+
max_lines: (0, tool_args_1.intInRange)('Maximum lines to return (default 300, max 1000)', { min: 1, max: 1000, fallback: 300 }),
|
|
11
|
+
});
|
|
12
|
+
class ReadFileTool extends McpTool_1.McpTool {
|
|
13
|
+
paths;
|
|
14
|
+
files;
|
|
15
|
+
constructor(paths, files, logger) {
|
|
16
|
+
super({
|
|
14
17
|
name: 'read_file',
|
|
15
18
|
description: 'Read a complete file under the workspace, indexed or not. Returns contents with line numbers. Truncates at max_lines with a hint to continue with read_file_range.',
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
max_lines: { type: 'number', description: 'Maximum lines to return (default 300, max 1000)' },
|
|
21
|
-
},
|
|
22
|
-
required: ['file_path'],
|
|
23
|
-
},
|
|
24
|
-
};
|
|
19
|
+
args: ARGS,
|
|
20
|
+
}, logger);
|
|
21
|
+
this.paths = paths;
|
|
22
|
+
this.files = files;
|
|
25
23
|
}
|
|
26
|
-
async
|
|
27
|
-
const
|
|
28
|
-
const rawMax = Number(args.max_lines);
|
|
29
|
-
const maxLines = isNaN(rawMax) || rawMax < 1 ? 300 : Math.min(1000, rawMax);
|
|
30
|
-
const resolved = await this.searcher.resolveToolPath(input);
|
|
24
|
+
async run({ file_path: input, max_lines: maxLines }) {
|
|
25
|
+
const resolved = await this.paths.resolveToolPath(input);
|
|
31
26
|
if (!resolved.ok)
|
|
32
27
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'read_file', 'file_path', input, input, resolved);
|
|
33
|
-
const result = await this.
|
|
28
|
+
const result = await this.files.readFile(resolved.relPath, maxLines);
|
|
34
29
|
if (!result.ok)
|
|
35
30
|
return (0, format_helpers_1.pathErrorResponse)(this.logger, 'read_file', 'file_path', input, resolved.relPath, result);
|
|
36
31
|
const numbered = result.lines.map((line, i) => `${i + 1}: ${line}`).join('\n');
|
|
@@ -1,13 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolResponse } from '../interfaces/IMcpToolHandler';
|
|
3
|
+
import type { IChunkSearch } from '../interfaces/IChunkSearch';
|
|
4
|
+
import type { IDependencyGraph } from '../interfaces/IDependencyGraph';
|
|
3
5
|
import type { ILogger } from '../interfaces/ILogger';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import { McpTool } from './McpTool';
|
|
7
|
+
declare function searchArgs(defaultLimit: number, maxLimit: number, defaultThreshold: number): z.ZodObject<{
|
|
8
|
+
query: z.ZodType<string, unknown, z.core.$ZodTypeInternals<string, unknown>>;
|
|
9
|
+
limit: z.ZodType<number, unknown, z.core.$ZodTypeInternals<number, unknown>>;
|
|
10
|
+
project: z.ZodType<string | undefined, unknown, z.core.$ZodTypeInternals<string | undefined, unknown>>;
|
|
11
|
+
include_neighbors: z.ZodType<boolean | undefined, unknown, z.core.$ZodTypeInternals<boolean | undefined, unknown>>;
|
|
12
|
+
include_graph_context: z.ZodType<boolean | undefined, unknown, z.core.$ZodTypeInternals<boolean | undefined, unknown>>;
|
|
13
|
+
threshold: z.ZodType<number | undefined, unknown, z.core.$ZodTypeInternals<number | undefined, unknown>>;
|
|
14
|
+
per_file: z.ZodType<number, unknown, z.core.$ZodTypeInternals<number, unknown>>;
|
|
15
|
+
rerank: z.ZodType<boolean | undefined, unknown, z.core.$ZodTypeInternals<boolean | undefined, unknown>>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
type SearchArgs = ReturnType<typeof searchArgs>;
|
|
18
|
+
export declare class SearchCodebaseTool extends McpTool<SearchArgs> {
|
|
19
|
+
private chunks;
|
|
20
|
+
private dependencies;
|
|
8
21
|
private defaultThreshold;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
definition(): ToolDefinition;
|
|
12
|
-
handle(args: Record<string, unknown>): Promise<ToolResponse>;
|
|
22
|
+
constructor(chunks: IChunkSearch, dependencies: IDependencyGraph, defaultLimit: number, maxLimit: number, defaultThreshold: number, logger: ILogger);
|
|
23
|
+
protected run(args: z.output<SearchArgs>): Promise<ToolResponse>;
|
|
13
24
|
}
|
|
25
|
+
export {};
|