@stupidloud/codegraph 0.8.1 → 0.9.9
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/README.md +319 -152
- package/dist/bin/codegraph.d.ts +4 -0
- package/dist/bin/codegraph.d.ts.map +1 -1
- package/dist/bin/codegraph.js +354 -90
- package/dist/bin/codegraph.js.map +1 -1
- package/dist/bin/node-version-check.d.ts +17 -0
- package/dist/bin/node-version-check.d.ts.map +1 -1
- package/dist/bin/node-version-check.js +37 -0
- package/dist/bin/node-version-check.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -11
- package/dist/config.js.map +1 -1
- package/dist/context/formatter.d.ts.map +1 -1
- package/dist/context/formatter.js +25 -6
- package/dist/context/formatter.js.map +1 -1
- package/dist/context/index.d.ts +22 -0
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +257 -6
- package/dist/context/index.js.map +1 -1
- package/dist/context/markers.d.ts +19 -0
- package/dist/context/markers.d.ts.map +1 -0
- package/dist/context/markers.js +22 -0
- package/dist/context/markers.js.map +1 -0
- package/dist/db/index.d.ts +30 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +75 -25
- package/dist/db/index.js.map +1 -1
- package/dist/db/queries.d.ts +104 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +328 -31
- package/dist/db/queries.js.map +1 -1
- package/dist/db/sqlite-adapter.d.ts +24 -23
- package/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/dist/db/sqlite-adapter.js +54 -174
- package/dist/db/sqlite-adapter.js.map +1 -1
- package/dist/directory.d.ts.map +1 -1
- package/dist/directory.js +6 -20
- package/dist/directory.js.map +1 -1
- package/dist/extraction/generated-detection.d.ts +30 -0
- package/dist/extraction/generated-detection.d.ts.map +1 -0
- package/dist/extraction/generated-detection.js +80 -0
- package/dist/extraction/generated-detection.js.map +1 -0
- package/dist/extraction/grammars.d.ts +23 -1
- package/dist/extraction/grammars.d.ts.map +1 -1
- package/dist/extraction/grammars.js +107 -3
- package/dist/extraction/grammars.js.map +1 -1
- package/dist/extraction/index.d.ts +22 -14
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +272 -183
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/dist/extraction/languages/c-cpp.js +45 -0
- package/dist/extraction/languages/c-cpp.js.map +1 -1
- package/dist/extraction/languages/csharp.d.ts.map +1 -1
- package/dist/extraction/languages/csharp.js +2 -1
- package/dist/extraction/languages/csharp.js.map +1 -1
- package/dist/extraction/languages/go.d.ts.map +1 -1
- package/dist/extraction/languages/go.js +18 -2
- package/dist/extraction/languages/go.js.map +1 -1
- package/dist/extraction/languages/index.d.ts.map +1 -1
- package/dist/extraction/languages/index.js +6 -0
- package/dist/extraction/languages/index.js.map +1 -1
- package/dist/extraction/languages/java.d.ts.map +1 -1
- package/dist/extraction/languages/java.js +6 -0
- package/dist/extraction/languages/java.js.map +1 -1
- package/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/dist/extraction/languages/kotlin.js +6 -0
- package/dist/extraction/languages/kotlin.js.map +1 -1
- package/dist/extraction/languages/lua.d.ts +3 -0
- package/dist/extraction/languages/lua.d.ts.map +1 -0
- package/dist/extraction/languages/lua.js +150 -0
- package/dist/extraction/languages/lua.js.map +1 -0
- package/dist/extraction/languages/luau.d.ts +3 -0
- package/dist/extraction/languages/luau.d.ts.map +1 -0
- package/dist/extraction/languages/luau.js +37 -0
- package/dist/extraction/languages/luau.js.map +1 -0
- package/dist/extraction/languages/objc.d.ts +3 -0
- package/dist/extraction/languages/objc.d.ts.map +1 -0
- package/dist/extraction/languages/objc.js +133 -0
- package/dist/extraction/languages/objc.js.map +1 -0
- package/dist/extraction/mybatis-extractor.d.ts +48 -0
- package/dist/extraction/mybatis-extractor.d.ts.map +1 -0
- package/dist/extraction/mybatis-extractor.js +198 -0
- package/dist/extraction/mybatis-extractor.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +14 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.d.ts +84 -0
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +715 -16
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/extraction/vue-extractor.d.ts +15 -0
- package/dist/extraction/vue-extractor.d.ts.map +1 -1
- package/dist/extraction/vue-extractor.js +88 -0
- package/dist/extraction/vue-extractor.js.map +1 -1
- package/dist/extraction/wasm/tree-sitter-lua.wasm +0 -0
- package/dist/extraction/wasm/tree-sitter-luau.wasm +0 -0
- package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
- package/dist/extraction/wasm-runtime-flags.d.ts.map +1 -0
- package/dist/extraction/wasm-runtime-flags.js +106 -0
- package/dist/extraction/wasm-runtime-flags.js.map +1 -0
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +76 -38
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +77 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -19
- package/dist/index.js.map +1 -1
- package/dist/installer/config-writer.d.ts +7 -8
- package/dist/installer/config-writer.d.ts.map +1 -1
- package/dist/installer/config-writer.js +7 -27
- package/dist/installer/config-writer.js.map +1 -1
- package/dist/installer/index.d.ts +51 -16
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +120 -29
- package/dist/installer/index.js.map +1 -1
- package/dist/installer/instructions-template.d.ts +11 -21
- package/dist/installer/instructions-template.d.ts.map +1 -1
- package/dist/installer/instructions-template.js +12 -56
- package/dist/installer/instructions-template.js.map +1 -1
- package/dist/installer/targets/antigravity.d.ts +57 -0
- package/dist/installer/targets/antigravity.d.ts.map +1 -0
- package/dist/installer/targets/antigravity.js +308 -0
- package/dist/installer/targets/antigravity.js.map +1 -0
- package/dist/installer/targets/claude.d.ts +26 -1
- package/dist/installer/targets/claude.d.ts.map +1 -1
- package/dist/installer/targets/claude.js +118 -40
- package/dist/installer/targets/claude.js.map +1 -1
- package/dist/installer/targets/codex.d.ts.map +1 -1
- package/dist/installer/targets/codex.js +15 -13
- package/dist/installer/targets/codex.js.map +1 -1
- package/dist/installer/targets/cursor.d.ts.map +1 -1
- package/dist/installer/targets/cursor.js +61 -36
- package/dist/installer/targets/cursor.js.map +1 -1
- package/dist/installer/targets/gemini.d.ts +26 -0
- package/dist/installer/targets/gemini.d.ts.map +1 -0
- package/dist/installer/targets/gemini.js +167 -0
- package/dist/installer/targets/gemini.js.map +1 -0
- package/dist/installer/targets/hermes.d.ts +18 -0
- package/dist/installer/targets/hermes.d.ts.map +1 -0
- package/dist/installer/targets/hermes.js +359 -0
- package/dist/installer/targets/hermes.js.map +1 -0
- package/dist/installer/targets/kiro.d.ts +27 -0
- package/dist/installer/targets/kiro.d.ts.map +1 -0
- package/dist/installer/targets/kiro.js +178 -0
- package/dist/installer/targets/kiro.js.map +1 -0
- package/dist/installer/targets/opencode.d.ts.map +1 -1
- package/dist/installer/targets/opencode.js +15 -13
- package/dist/installer/targets/opencode.js.map +1 -1
- package/dist/installer/targets/registry.d.ts.map +1 -1
- package/dist/installer/targets/registry.js +8 -0
- package/dist/installer/targets/registry.js.map +1 -1
- package/dist/installer/targets/shared.d.ts.map +1 -1
- package/dist/installer/targets/shared.js +3 -2
- package/dist/installer/targets/shared.js.map +1 -1
- package/dist/installer/targets/types.d.ts +1 -16
- package/dist/installer/targets/types.d.ts.map +1 -1
- package/dist/mcp/daemon-paths.d.ts +46 -0
- package/dist/mcp/daemon-paths.d.ts.map +1 -0
- package/dist/mcp/daemon-paths.js +125 -0
- package/dist/mcp/daemon-paths.js.map +1 -0
- package/dist/mcp/daemon.d.ts +161 -0
- package/dist/mcp/daemon.d.ts.map +1 -0
- package/dist/mcp/daemon.js +403 -0
- package/dist/mcp/daemon.js.map +1 -0
- package/dist/mcp/engine.d.ts +105 -0
- package/dist/mcp/engine.d.ts.map +1 -0
- package/dist/mcp/engine.js +270 -0
- package/dist/mcp/engine.js.map +1 -0
- package/dist/mcp/index.d.ts +70 -52
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +355 -331
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/proxy.d.ts +81 -0
- package/dist/mcp/proxy.d.ts.map +1 -0
- package/dist/mcp/proxy.js +510 -0
- package/dist/mcp/proxy.js.map +1 -0
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.d.ts.map +1 -1
- package/dist/mcp/server-instructions.js +21 -21
- package/dist/mcp/session.d.ts +77 -0
- package/dist/mcp/session.d.ts.map +1 -0
- package/dist/mcp/session.js +294 -0
- package/dist/mcp/session.js.map +1 -0
- package/dist/mcp/tools.d.ts +171 -15
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +1714 -298
- package/dist/mcp/tools.js.map +1 -1
- package/dist/mcp/transport.d.ts +111 -29
- package/dist/mcp/transport.d.ts.map +1 -1
- package/dist/mcp/transport.js +181 -71
- package/dist/mcp/transport.js.map +1 -1
- package/dist/mcp/version.d.ts +19 -0
- package/dist/mcp/version.d.ts.map +1 -0
- package/dist/mcp/version.js +71 -0
- package/dist/mcp/version.js.map +1 -0
- package/dist/resolution/callback-synthesizer.d.ts +10 -0
- package/dist/resolution/callback-synthesizer.d.ts.map +1 -0
- package/dist/resolution/callback-synthesizer.js +1300 -0
- package/dist/resolution/callback-synthesizer.js.map +1 -0
- package/dist/resolution/frameworks/csharp.d.ts.map +1 -1
- package/dist/resolution/frameworks/csharp.js +36 -8
- package/dist/resolution/frameworks/csharp.js.map +1 -1
- package/dist/resolution/frameworks/drupal.d.ts +51 -0
- package/dist/resolution/frameworks/drupal.d.ts.map +1 -0
- package/dist/resolution/frameworks/drupal.js +367 -0
- package/dist/resolution/frameworks/drupal.js.map +1 -0
- package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
- package/dist/resolution/frameworks/expo-modules.d.ts.map +1 -0
- package/dist/resolution/frameworks/expo-modules.js +143 -0
- package/dist/resolution/frameworks/expo-modules.js.map +1 -0
- package/dist/resolution/frameworks/express.d.ts.map +1 -1
- package/dist/resolution/frameworks/express.js +102 -19
- package/dist/resolution/frameworks/express.js.map +1 -1
- package/dist/resolution/frameworks/fabric.d.ts +3 -0
- package/dist/resolution/frameworks/fabric.d.ts.map +1 -0
- package/dist/resolution/frameworks/fabric.js +354 -0
- package/dist/resolution/frameworks/fabric.js.map +1 -0
- package/dist/resolution/frameworks/go.d.ts.map +1 -1
- package/dist/resolution/frameworks/go.js +6 -3
- package/dist/resolution/frameworks/go.js.map +1 -1
- package/dist/resolution/frameworks/index.d.ts +6 -0
- package/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/dist/resolution/frameworks/index.js +29 -1
- package/dist/resolution/frameworks/index.js.map +1 -1
- package/dist/resolution/frameworks/java.d.ts.map +1 -1
- package/dist/resolution/frameworks/java.js +339 -12
- package/dist/resolution/frameworks/java.js.map +1 -1
- package/dist/resolution/frameworks/laravel.d.ts.map +1 -1
- package/dist/resolution/frameworks/laravel.js +17 -8
- package/dist/resolution/frameworks/laravel.js.map +1 -1
- package/dist/resolution/frameworks/nestjs.d.ts.map +1 -1
- package/dist/resolution/frameworks/nestjs.js +324 -0
- package/dist/resolution/frameworks/nestjs.js.map +1 -1
- package/dist/resolution/frameworks/play.d.ts +19 -0
- package/dist/resolution/frameworks/play.d.ts.map +1 -0
- package/dist/resolution/frameworks/play.js +111 -0
- package/dist/resolution/frameworks/play.js.map +1 -0
- package/dist/resolution/frameworks/python.d.ts.map +1 -1
- package/dist/resolution/frameworks/python.js +134 -16
- package/dist/resolution/frameworks/python.js.map +1 -1
- package/dist/resolution/frameworks/react-native.d.ts +3 -0
- package/dist/resolution/frameworks/react-native.d.ts.map +1 -0
- package/dist/resolution/frameworks/react-native.js +360 -0
- package/dist/resolution/frameworks/react-native.js.map +1 -0
- package/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/dist/resolution/frameworks/react.js +96 -3
- package/dist/resolution/frameworks/react.js.map +1 -1
- package/dist/resolution/frameworks/ruby.d.ts.map +1 -1
- package/dist/resolution/frameworks/ruby.js +106 -2
- package/dist/resolution/frameworks/ruby.js.map +1 -1
- package/dist/resolution/frameworks/rust.d.ts.map +1 -1
- package/dist/resolution/frameworks/rust.js +102 -5
- package/dist/resolution/frameworks/rust.js.map +1 -1
- package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
- package/dist/resolution/frameworks/swift-objc.d.ts.map +1 -0
- package/dist/resolution/frameworks/swift-objc.js +252 -0
- package/dist/resolution/frameworks/swift-objc.js.map +1 -0
- package/dist/resolution/frameworks/swift.d.ts.map +1 -1
- package/dist/resolution/frameworks/swift.js +30 -6
- package/dist/resolution/frameworks/swift.js.map +1 -1
- package/dist/resolution/go-module.d.ts +26 -0
- package/dist/resolution/go-module.d.ts.map +1 -0
- package/dist/resolution/go-module.js +78 -0
- package/dist/resolution/go-module.js.map +1 -0
- package/dist/resolution/import-resolver.d.ts +28 -0
- package/dist/resolution/import-resolver.d.ts.map +1 -1
- package/dist/resolution/import-resolver.js +617 -5
- package/dist/resolution/import-resolver.js.map +1 -1
- package/dist/resolution/index.d.ts +11 -0
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +196 -10
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/lru-cache.d.ts +24 -0
- package/dist/resolution/lru-cache.d.ts.map +1 -0
- package/dist/resolution/lru-cache.js +62 -0
- package/dist/resolution/lru-cache.js.map +1 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +212 -0
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/resolution/swift-objc-bridge.d.ts +134 -0
- package/dist/resolution/swift-objc-bridge.d.ts.map +1 -0
- package/dist/resolution/swift-objc-bridge.js +256 -0
- package/dist/resolution/swift-objc-bridge.js.map +1 -0
- package/dist/resolution/types.d.ts +44 -0
- package/dist/resolution/types.d.ts.map +1 -1
- package/dist/resolution/workspace-packages.d.ts +48 -0
- package/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/dist/resolution/workspace-packages.js +208 -0
- package/dist/resolution/workspace-packages.js.map +1 -0
- package/dist/search/query-utils.d.ts +18 -0
- package/dist/search/query-utils.d.ts.map +1 -1
- package/dist/search/query-utils.js +30 -0
- package/dist/search/query-utils.js.map +1 -1
- package/dist/sync/git-hooks.d.ts.map +1 -1
- package/dist/sync/git-hooks.js +2 -0
- package/dist/sync/git-hooks.js.map +1 -1
- package/dist/sync/index.d.ts +3 -1
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +8 -1
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/watcher.d.ts +214 -12
- package/dist/sync/watcher.d.ts.map +1 -1
- package/dist/sync/watcher.js +467 -55
- package/dist/sync/watcher.js.map +1 -1
- package/dist/sync/worktree.d.ts +54 -0
- package/dist/sync/worktree.d.ts.map +1 -0
- package/dist/sync/worktree.js +137 -0
- package/dist/sync/worktree.js.map +1 -0
- package/dist/types.d.ts +9 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -1
- package/dist/utils.js +1 -1
- package/package.json +2 -2
- package/scripts/add-lang/bench.sh +60 -0
- package/scripts/add-lang/check-grammar.mjs +75 -0
- package/scripts/add-lang/dump-ast.mjs +103 -0
- package/scripts/add-lang/verify-extraction.mjs +70 -0
- package/scripts/agent-eval/arms-F.sh +21 -0
- package/scripts/agent-eval/arms-matrix.sh +37 -0
- package/scripts/agent-eval/bench-readme.sh +28 -0
- package/scripts/agent-eval/bench-why-repo.sh +22 -0
- package/scripts/agent-eval/block-read-hook.sh +19 -0
- package/scripts/agent-eval/hook-settings.json +15 -0
- package/scripts/agent-eval/itrun.sh +24 -11
- package/scripts/agent-eval/parse-arms.mjs +116 -0
- package/scripts/agent-eval/parse-bench-readme.mjs +84 -0
- package/scripts/agent-eval/probe-context.mjs +21 -0
- package/scripts/agent-eval/probe-explore.mjs +40 -0
- package/scripts/agent-eval/probe-node.mjs +20 -0
- package/scripts/agent-eval/probe-sweep.mjs +119 -0
- package/scripts/agent-eval/probe-trace.mjs +20 -0
- package/scripts/agent-eval/run-arms.sh +56 -0
- package/scripts/agent-eval/seq-matrix.mjs +137 -0
- package/scripts/build-bundle.sh +118 -0
- package/scripts/npm-sdk.js +75 -0
- package/scripts/npm-shim.js +246 -0
- package/scripts/pack-npm.sh +119 -0
- package/scripts/prepare-release.mjs +270 -0
- package/scripts/patch-tree-sitter-dart.js +0 -112
- package/scripts/release.sh +0 -68
package/dist/mcp/tools.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Defines the tools exposed by the CodeGraph MCP server.
|
|
5
5
|
*/
|
|
6
|
-
import CodeGraph from '../index';
|
|
6
|
+
import type CodeGraph from '../index';
|
|
7
|
+
import type { PendingFile } from '../sync';
|
|
7
8
|
/**
|
|
8
9
|
* Calculate the recommended number of codegraph_explore calls based on project size.
|
|
9
10
|
* Larger codebases need more exploration calls to cover their surface area,
|
|
@@ -49,8 +50,30 @@ export interface ExploreOutputBudget {
|
|
|
49
50
|
includeCompletenessSignal: boolean;
|
|
50
51
|
/** Include the explore-budget reminder at the end. */
|
|
51
52
|
includeBudgetNote: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Hard-drop test/spec/icon/i18n files from the relevant-file set unless
|
|
55
|
+
* the query itself mentions tests. Today they're only deprioritized in
|
|
56
|
+
* the sort, which on tiny repos still lets one slip into the top N (e.g.
|
|
57
|
+
* cobra's `command_test.go` displaced `args.go` and contributed ~10KB of
|
|
58
|
+
* pure noise to "How does cobra parse commands?"). Off by default; on
|
|
59
|
+
* for the very-tiny tier where one slip dominates the budget.
|
|
60
|
+
*/
|
|
61
|
+
excludeLowValueFiles: boolean;
|
|
52
62
|
}
|
|
53
63
|
export declare function getExploreOutputBudget(fileCount: number): ExploreOutputBudget;
|
|
64
|
+
/**
|
|
65
|
+
* Per-file staleness banner emitted at the top of a tool response when the
|
|
66
|
+
* file watcher has pending events for files referenced by the response.
|
|
67
|
+
* The agent uses this to fall back to Read for those specific files
|
|
68
|
+
* without waiting for the debounced sync (issue #403).
|
|
69
|
+
*/
|
|
70
|
+
export declare function formatStaleBanner(stale: PendingFile[]): string;
|
|
71
|
+
/**
|
|
72
|
+
* Compact footer listing pending files that are NOT referenced in this
|
|
73
|
+
* response. Gives the agent a complete project-wide freshness picture
|
|
74
|
+
* without bloating the main banner.
|
|
75
|
+
*/
|
|
76
|
+
export declare function formatStaleFooter(stale: PendingFile[]): string;
|
|
54
77
|
/**
|
|
55
78
|
* MCP Tool definition
|
|
56
79
|
*/
|
|
@@ -82,12 +105,20 @@ export interface ToolResult {
|
|
|
82
105
|
/**
|
|
83
106
|
* All CodeGraph MCP tools
|
|
84
107
|
*
|
|
85
|
-
* Designed for minimal context usage - use
|
|
86
|
-
* and only use other tools for
|
|
108
|
+
* Designed for minimal context usage - use codegraph_explore as the primary tool
|
|
109
|
+
* (one call usually answers the whole question), and only use other tools for
|
|
110
|
+
* targeted follow-up queries.
|
|
87
111
|
*
|
|
88
112
|
* All tools support cross-project queries via the optional `projectPath` parameter.
|
|
89
113
|
*/
|
|
90
114
|
export declare const tools: ToolDefinition[];
|
|
115
|
+
/**
|
|
116
|
+
* Allowlist-filtered tool definitions WITHOUT an engine — the static surface the
|
|
117
|
+
* proxy answers `tools/list` with before any project is open. Mirrors
|
|
118
|
+
* `ToolHandler.getTools()` in the no-CodeGraph case (the dynamic per-repo budget
|
|
119
|
+
* note in a description only adds once `cg` is loaded; the schemas are static).
|
|
120
|
+
*/
|
|
121
|
+
export declare function getStaticTools(): ToolDefinition[];
|
|
91
122
|
/**
|
|
92
123
|
* Tool handler that executes tools against a CodeGraph instance
|
|
93
124
|
*
|
|
@@ -98,11 +129,21 @@ export declare class ToolHandler {
|
|
|
98
129
|
private cg;
|
|
99
130
|
private projectCache;
|
|
100
131
|
private defaultProjectHint;
|
|
132
|
+
private worktreeMismatchCache;
|
|
133
|
+
private catchUpGate;
|
|
101
134
|
constructor(cg: CodeGraph | null);
|
|
102
135
|
/**
|
|
103
136
|
* Update the default CodeGraph instance (e.g. after lazy initialization)
|
|
104
137
|
*/
|
|
105
138
|
setDefaultCodeGraph(cg: CodeGraph): void;
|
|
139
|
+
/**
|
|
140
|
+
* Engine-only: register the catch-up sync promise so the next `execute()`
|
|
141
|
+
* call awaits it before serving. The handler swallows rejections (the
|
|
142
|
+
* engine logs them) so a sync failure never propagates as a tool error;
|
|
143
|
+
* we still want to serve a best-effort result over the same potentially-
|
|
144
|
+
* stale data, which is what would have happened without the gate.
|
|
145
|
+
*/
|
|
146
|
+
setCatchUpGate(p: Promise<void> | null): void;
|
|
106
147
|
/**
|
|
107
148
|
* Record the directory the server tried to resolve the default project from.
|
|
108
149
|
* Used only to make the "no default project" error actionable.
|
|
@@ -112,10 +153,22 @@ export declare class ToolHandler {
|
|
|
112
153
|
* Whether a default CodeGraph instance is available
|
|
113
154
|
*/
|
|
114
155
|
hasDefaultCodeGraph(): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Optional allowlist of exposed tools, parsed from the CODEGRAPH_MCP_TOOLS
|
|
158
|
+
* env var (comma-separated short names, e.g. "trace,search,node,context").
|
|
159
|
+
* Unset/empty → every tool is exposed. Lets an operator (or an A/B harness)
|
|
160
|
+
* trim the tool surface without rebuilding the client config; the ablated
|
|
161
|
+
* tool is then truly absent from ListTools rather than merely denied on call.
|
|
162
|
+
* Matching is on the short form, so "node" and "codegraph_node" both work.
|
|
163
|
+
*/
|
|
164
|
+
private toolAllowlist;
|
|
165
|
+
/** Whether a tool name passes the CODEGRAPH_MCP_TOOLS allowlist (if any). */
|
|
166
|
+
private isToolAllowed;
|
|
115
167
|
/**
|
|
116
168
|
* Get tool definitions with dynamic descriptions based on project size.
|
|
117
169
|
* The codegraph_explore tool description includes a budget recommendation
|
|
118
|
-
* scaled to the number of indexed files.
|
|
170
|
+
* scaled to the number of indexed files. Honors the CODEGRAPH_MCP_TOOLS
|
|
171
|
+
* allowlist so a trimmed surface is reflected in ListTools.
|
|
119
172
|
*/
|
|
120
173
|
getTools(): ToolDefinition[];
|
|
121
174
|
/**
|
|
@@ -133,25 +186,61 @@ export declare class ToolHandler {
|
|
|
133
186
|
*/
|
|
134
187
|
closeAll(): void;
|
|
135
188
|
/**
|
|
136
|
-
* Validate that a value is a non-empty string
|
|
189
|
+
* Validate that a value is a non-empty string within length bounds.
|
|
190
|
+
*
|
|
191
|
+
* The `maxLength` cap protects against MCP clients that ship huge
|
|
192
|
+
* payloads (10MB+ query strings either by accident or maliciously).
|
|
193
|
+
* Without this, a single oversized input can pin the FTS5 index or
|
|
194
|
+
* exhaust memory before any real work runs.
|
|
137
195
|
*/
|
|
138
196
|
private validateString;
|
|
139
197
|
/**
|
|
140
|
-
*
|
|
198
|
+
* Validate an optional path-like string input. Returns the value if
|
|
199
|
+
* valid (or undefined), or a ToolResult with the error.
|
|
141
200
|
*/
|
|
142
|
-
|
|
201
|
+
private validateOptionalPath;
|
|
143
202
|
/**
|
|
144
|
-
*
|
|
203
|
+
* Cached git worktree/index mismatch for a tool call's effective project.
|
|
204
|
+
*
|
|
205
|
+
* The "effective project" is what the request targets: an explicit
|
|
206
|
+
* `projectPath` arg, else the directory the server resolved its default
|
|
207
|
+
* project from (`defaultProjectHint`), else cwd. Memoized per start path —
|
|
208
|
+
* see `worktreeMismatchCache`. Best-effort: if the project can't be resolved
|
|
209
|
+
* (e.g. nothing initialized yet), it reports "no mismatch" so a tool is never
|
|
210
|
+
* broken by this check.
|
|
145
211
|
*/
|
|
146
|
-
private
|
|
212
|
+
private worktreeMismatchFor;
|
|
213
|
+
/**
|
|
214
|
+
* Prefix a successful read-tool result with a compact worktree-mismatch
|
|
215
|
+
* notice when the resolved index belongs to a different git working tree than
|
|
216
|
+
* the caller's (issue #155). Without this, an agent in a nested worktree
|
|
217
|
+
* silently trusts main-branch results. No-op on error results and when there
|
|
218
|
+
* is no mismatch. `codegraph_status` is excluded — it embeds its own verbose
|
|
219
|
+
* warning — so it stays out of this path.
|
|
220
|
+
*/
|
|
221
|
+
private withWorktreeNotice;
|
|
222
|
+
/**
|
|
223
|
+
* Annotate a successful read-tool result with per-file staleness — the
|
|
224
|
+
* non-blocking answer to issue #403. The file watcher tracks every event
|
|
225
|
+
* it sees per path; here we intersect "files referenced in this response"
|
|
226
|
+
* against that pending set and prepend a compact banner so the agent can
|
|
227
|
+
* fall back to Read for those *specific* files without waiting for the
|
|
228
|
+
* debounced sync to fire. Other pending files in the project (not
|
|
229
|
+
* referenced by this response) get a small footer so the agent has a
|
|
230
|
+
* complete picture without bloating the banner.
|
|
231
|
+
*
|
|
232
|
+
* Cost when nothing is pending — the common case — is one boolean check.
|
|
233
|
+
* No I/O, no parsing of markdown beyond a per-pending-file substring scan.
|
|
234
|
+
*/
|
|
235
|
+
private withStalenessNotice;
|
|
147
236
|
/**
|
|
148
|
-
*
|
|
237
|
+
* Execute a tool by name
|
|
149
238
|
*/
|
|
150
|
-
|
|
239
|
+
execute(toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
|
|
151
240
|
/**
|
|
152
|
-
*
|
|
241
|
+
* Handle codegraph_search
|
|
153
242
|
*/
|
|
154
|
-
private
|
|
243
|
+
private handleSearch;
|
|
155
244
|
/**
|
|
156
245
|
* Handle codegraph_callers
|
|
157
246
|
*/
|
|
@@ -164,6 +253,54 @@ export declare class ToolHandler {
|
|
|
164
253
|
* Handle codegraph_impact
|
|
165
254
|
*/
|
|
166
255
|
private handleImpact;
|
|
256
|
+
/**
|
|
257
|
+
* Describe a synthesized (dynamic-dispatch) edge for human output: how the
|
|
258
|
+
* callback was wired up — the bridge static parsing can't see. Returns null
|
|
259
|
+
* for ordinary static edges. Used by trace + the node trail so a synthesized
|
|
260
|
+
* hop reads as "registered via onUpdate at App.tsx:3148", not a bare arrow.
|
|
261
|
+
*/
|
|
262
|
+
private synthEdgeNote;
|
|
263
|
+
/**
|
|
264
|
+
* Flow-from-named-symbols: an agent's codegraph_explore query is a bag of
|
|
265
|
+
* symbol names that usually spans the flow it's investigating (e.g.
|
|
266
|
+
* "PmsProductController getList PmsProductService list PmsProductServiceImpl").
|
|
267
|
+
* Surface the longest call chain AMONG those named symbols — scoped to what the
|
|
268
|
+
* agent explicitly named, so (unlike a fuzzy relevance set) there's no
|
|
269
|
+
* wrong-feature wandering. Rides synthesized edges, so controller→service-
|
|
270
|
+
* interface→impl shows up. Returns '' if no chain of >=3 nodes exists.
|
|
271
|
+
*
|
|
272
|
+
* Ambiguous tokens (Java `list` → dozens of nodes) are disambiguated by
|
|
273
|
+
* CO-NAMING: the agent names the class too, so we keep only `list` candidates
|
|
274
|
+
* whose qualifiedName contains another named token (`PmsProductServiceImpl::list`),
|
|
275
|
+
* dropping unrelated `OmsOrderService::list`.
|
|
276
|
+
*/
|
|
277
|
+
private buildFlowFromNamedSymbols;
|
|
278
|
+
/**
|
|
279
|
+
* Compact "blast radius" for the entry symbols of an explore result: who
|
|
280
|
+
* depends on each (callers) and which test files cover it — LOCATIONS ONLY,
|
|
281
|
+
* no source, so the agent knows what to update / re-verify before editing
|
|
282
|
+
* without reaching for a separate impact call. Always-on, but skips symbols
|
|
283
|
+
* that have no dependents (nothing to warn about), and returns '' when none
|
|
284
|
+
* qualify so a leaf-only exploration stays clean.
|
|
285
|
+
*/
|
|
286
|
+
private buildBlastRadiusSection;
|
|
287
|
+
/**
|
|
288
|
+
* Graph-connectivity relevance via Random-Walk-with-Restart (personalized
|
|
289
|
+
* PageRank) from the query's matched SEED nodes over the call/reference graph.
|
|
290
|
+
*
|
|
291
|
+
* This is the ranking signal text search (FTS/bm25) CANNOT provide, and it's
|
|
292
|
+
* codegraph's home turf: relevance by STRUCTURE, not words. A file whose
|
|
293
|
+
* symbols are call-connected to the matched cluster accrues walk mass and
|
|
294
|
+
* ranks high; a lone TEXT match — e.g. `LensSwitcher.swift` matched the word
|
|
295
|
+
* "switch" from `switchOrganization`, but calls none of `setUser`/`fetchUser`
|
|
296
|
+
* — gets only its own restart probability and ranks ~0. Immune to the
|
|
297
|
+
* tokenization trap that fools term matching, deterministic, no embeddings.
|
|
298
|
+
*
|
|
299
|
+
* Undirected adjacency (reachability both ways), restart α=0.25 to the seeds,
|
|
300
|
+
* power iteration to convergence. Bounded to the already-relevant subgraph, so
|
|
301
|
+
* it's a few hundred nodes × ~25 iterations — negligible cost.
|
|
302
|
+
*/
|
|
303
|
+
private computeGraphRelevance;
|
|
167
304
|
/**
|
|
168
305
|
* Handle codegraph_explore — deep exploration in a single call
|
|
169
306
|
*
|
|
@@ -180,6 +317,18 @@ export declare class ToolHandler {
|
|
|
180
317
|
* Handle codegraph_node
|
|
181
318
|
*/
|
|
182
319
|
private handleNode;
|
|
320
|
+
/** Render one symbol: details + (optional) body/outline + its caller/callee trail. */
|
|
321
|
+
private renderNodeSection;
|
|
322
|
+
/**
|
|
323
|
+
* Build the "trail" for a symbol: its direct callees (what it calls) and
|
|
324
|
+
* callers (what calls it), each with file:line — so codegraph_node doubles as
|
|
325
|
+
* the structural Grep→Read→expand primitive: a spot PLUS where to go next.
|
|
326
|
+
* Capped to stay cheap. Walk the graph by calling codegraph_node on a trail
|
|
327
|
+
* entry; no Read needed for covered hops. Empty edges on a non-leaf often mean
|
|
328
|
+
* dynamic dispatch the static graph couldn't resolve — that absence is itself
|
|
329
|
+
* a signal (read that one hop) rather than a dead end.
|
|
330
|
+
*/
|
|
331
|
+
private formatTrail;
|
|
183
332
|
/**
|
|
184
333
|
* Handle codegraph_status
|
|
185
334
|
*/
|
|
@@ -227,7 +376,15 @@ export declare class ToolHandler {
|
|
|
227
376
|
* Python — `stage_apply::run` matches a `run` in `stage_apply.rs`)
|
|
228
377
|
*/
|
|
229
378
|
private matchesSymbol;
|
|
230
|
-
|
|
379
|
+
/**
|
|
380
|
+
* Find ALL definitions matching a name, ranked, so codegraph_node can return
|
|
381
|
+
* every overload instead of guessing one (the wrong guess → a Read). Keepers
|
|
382
|
+
* rank before generated stubs (.pb.go etc.); stable within a group preserves
|
|
383
|
+
* FTS order. Returns [] when nothing matches; a qualified lookup that finds no
|
|
384
|
+
* exact match returns [] rather than a misleading fuzzy file hit (#173); a
|
|
385
|
+
* bare name with no exact match falls back to the single top fuzzy result.
|
|
386
|
+
*/
|
|
387
|
+
private findSymbolMatches;
|
|
231
388
|
/**
|
|
232
389
|
* Find ALL symbols matching a name. Used by callers/callees/impact to aggregate
|
|
233
390
|
* results across all matching symbols (e.g., multiple classes with an `execute` method).
|
|
@@ -249,7 +406,6 @@ export declare class ToolHandler {
|
|
|
249
406
|
*/
|
|
250
407
|
private buildContainerOutline;
|
|
251
408
|
private formatNodeDetails;
|
|
252
|
-
private formatTaskContext;
|
|
253
409
|
private textResult;
|
|
254
410
|
private errorResult;
|
|
255
411
|
}
|
package/dist/mcp/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,SAAS,MAAM,UAAU,CAAC;AAetC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAuD3C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAM1D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,cAAc,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,eAAe,EAAE,MAAM,CAAC;IACxB,4EAA4E;IAC5E,eAAe,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAC;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