@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
|
@@ -28,45 +28,45 @@ editing code, not during.
|
|
|
28
28
|
## Answer directly — don't delegate exploration
|
|
29
29
|
|
|
30
30
|
For "how does X work", architecture, trace, or where-is-X questions,
|
|
31
|
-
answer DIRECTLY
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
answer DIRECTLY — usually with ONE \`codegraph_explore\` call.
|
|
32
|
+
\`codegraph_explore\` takes either a natural-language question or a bag of
|
|
33
|
+
symbol/file names and returns the verbatim source of the relevant symbols
|
|
34
|
+
grouped by file, so it is Read-equivalent and most often the ONLY
|
|
35
|
+
codegraph call you need. Codegraph IS the pre-built search index — so
|
|
36
|
+
delegating the lookup to a separate file-reading sub-task/agent, or
|
|
37
|
+
running your own grep + read loop, repeats work codegraph already did and
|
|
38
|
+
costs more for the same answer. Reach for raw Read/Grep only to confirm a
|
|
39
|
+
specific detail codegraph didn't cover. A direct codegraph answer is
|
|
40
|
+
typically one to a few calls; a grep/read exploration is dozens.
|
|
39
41
|
|
|
40
42
|
## Tool selection by intent
|
|
41
43
|
|
|
42
|
-
- **"
|
|
43
|
-
- **"
|
|
44
|
-
- **"What
|
|
45
|
-
- **"What calls this?"** → \`codegraph_callers\`
|
|
46
|
-
- **
|
|
47
|
-
- **"What would changing this break?"** → \`codegraph_impact\`
|
|
48
|
-
- **"Show me this symbol's source / signature / docstring."** → \`codegraph_node\`
|
|
49
|
-
- **"Show me several related symbols' source / survey an area."** → \`codegraph_explore\` (ONE capped call; prefer over many codegraph_node/Read)
|
|
44
|
+
- **Almost any question — "how does X work", architecture, a bug, "what/where is X", or surveying an area** → \`codegraph_explore\` (PRIMARY — call FIRST; ONE capped call returns the verbatim source of the relevant symbols grouped by file; most often the ONLY call you need)
|
|
45
|
+
- **"How does X reach/become Y? / the flow / the path from X to Y"** → \`codegraph_explore\`, naming the symbols that span the flow (e.g. \`mutateElement renderScene\`) — it surfaces the call path among them, including dynamic-dispatch hops (callbacks, React re-render, JSX children) grep can't follow
|
|
46
|
+
- **"What is the symbol named X?" (just its location)** → \`codegraph_search\`
|
|
47
|
+
- **"What calls this?" / "What does this call?" / "What would changing this break?"** → \`codegraph_callers\` / \`codegraph_callees\` / \`codegraph_impact\`
|
|
48
|
+
- **One specific symbol's full source (esp. a body \`codegraph_explore\` trimmed), or an OVERLOADED name** → \`codegraph_node\` (with \`includeCode\`): for an ambiguous name it returns EVERY matching definition's body in one call, so you never Read a file to find the right overload
|
|
50
49
|
- **"What's in directory X?"** → \`codegraph_files\`
|
|
51
50
|
- **"Is the index ready / what's its size?"** → \`codegraph_status\`
|
|
52
51
|
|
|
53
52
|
## Common chains
|
|
54
53
|
|
|
55
|
-
- **
|
|
54
|
+
- **Flow / "how does X reach Y"**: ONE \`codegraph_explore\` with the symbol names spanning the flow — it surfaces the call path among them (riding dynamic-dispatch hops) AND returns their source. No need to reconstruct the path with \`codegraph_search\` + \`codegraph_callers\`.
|
|
55
|
+
- **Onboarding / understanding any area**: ONE \`codegraph_explore\` is usually the whole answer. Only follow up — \`codegraph_node\` for a specific symbol — if something is still unclear.
|
|
56
56
|
- **Refactor planning**: \`codegraph_search\` → \`codegraph_callers\` → \`codegraph_impact\`. The blast-radius answer comes from impact, not from walking callers manually.
|
|
57
57
|
- **Debugging a regression**: \`codegraph_callers\` of the suspected symbol; widen with \`codegraph_impact\` if an unexpected call appears.
|
|
58
58
|
|
|
59
59
|
## Anti-patterns
|
|
60
60
|
|
|
61
|
-
- **
|
|
61
|
+
- **Trust codegraph's results — don't re-verify them with grep.** They come from a full AST parse; re-checking with grep is slower, less accurate, and wastes context.
|
|
62
62
|
- **Don't grep first** when looking up a symbol by name — \`codegraph_search\` is faster and returns kind + location + signature.
|
|
63
|
-
- **Don't
|
|
64
|
-
- **Don't chain \`codegraph_search\` + \`codegraph_node\`** when you just want context — \`codegraph_context\` is one round-trip.
|
|
63
|
+
- **Don't chain \`codegraph_search\` + \`codegraph_node\`** to understand an area — ONE \`codegraph_explore\` returns the relevant symbols' source together in a single round-trip.
|
|
65
64
|
- **Don't loop \`codegraph_node\` over many symbols** — one \`codegraph_explore\` call returns them all grouped by file, while each separate call re-reads the whole context and costs far more. Use \`codegraph_node\` for a single symbol.
|
|
66
|
-
- **
|
|
65
|
+
- **After editing, check the staleness banner.** When a tool response starts with "⚠️ Some files referenced below were edited since the last index sync…", the listed files are pending re-index — Read those specific files for accurate content. Every file NOT in that banner is fresh, so still trust codegraph. \`codegraph_status\` also lists pending files under "Pending sync".
|
|
67
66
|
|
|
68
67
|
## Limitations
|
|
69
68
|
|
|
69
|
+
- If a tool reports the project isn't initialized, \`.codegraph/\` doesn't exist yet — offer to run \`codegraph init -i\` to build the index.
|
|
70
70
|
- Index lags file writes by ~1 second.
|
|
71
71
|
- Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.
|
|
72
72
|
- No live correctness validation — that's still the TypeScript compiler / test suite / linter's job. Codegraph supplements those with structural context they don't have.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP per-connection session — speaks the JSON-RPC protocol (initialize,
|
|
3
|
+
* tools/list, tools/call) over a single {@link JsonRpcTransport}. It owns
|
|
4
|
+
* per-client state only (which protocol version the client asked for, whether
|
|
5
|
+
* it advertised `roots`, the one-shot roots/list latch); the heavyweight
|
|
6
|
+
* resources (CodeGraph, watcher, ToolHandler) live in the shared
|
|
7
|
+
* {@link MCPEngine} so daemon mode can collapse N inotify sets / DB handles
|
|
8
|
+
* to one.
|
|
9
|
+
*
|
|
10
|
+
* The state-machine itself mirrors what `MCPServer` used to do inline before
|
|
11
|
+
* issue #411 split it out — the same regression tests in
|
|
12
|
+
* `__tests__/mcp-initialize.test.ts` still drive this code path.
|
|
13
|
+
*/
|
|
14
|
+
import { JsonRpcTransport } from './transport';
|
|
15
|
+
import { MCPEngine } from './engine';
|
|
16
|
+
/**
|
|
17
|
+
* MCP Server Info — kept on the session because some clients log it. The
|
|
18
|
+
* version tracks the real package version (was a hard-coded '0.1.0').
|
|
19
|
+
*/
|
|
20
|
+
export declare const SERVER_INFO: {
|
|
21
|
+
name: string;
|
|
22
|
+
version: string;
|
|
23
|
+
};
|
|
24
|
+
/** MCP Protocol Version (latest the server claims). */
|
|
25
|
+
export declare const PROTOCOL_VERSION = "2024-11-05";
|
|
26
|
+
export interface MCPSessionOptions {
|
|
27
|
+
/**
|
|
28
|
+
* Explicit project path from the `--path` CLI flag. When set, the session
|
|
29
|
+
* will not bother asking the client for `roots/list` — we already know
|
|
30
|
+
* where the project lives.
|
|
31
|
+
*/
|
|
32
|
+
explicitProjectPath?: string | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* One MCP client's view of the server. Created fresh per stdio launch
|
|
36
|
+
* (direct mode) or per socket connection (daemon mode).
|
|
37
|
+
*/
|
|
38
|
+
export declare class MCPSession {
|
|
39
|
+
private transport;
|
|
40
|
+
private engine;
|
|
41
|
+
private clientSupportsRoots;
|
|
42
|
+
private rootsAttempted;
|
|
43
|
+
private resolvePromise;
|
|
44
|
+
private explicitProjectPath;
|
|
45
|
+
constructor(transport: JsonRpcTransport, engine: MCPEngine, opts?: MCPSessionOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Start handling messages from the transport. Returns immediately — the
|
|
48
|
+
* session lives for as long as the transport is open.
|
|
49
|
+
*/
|
|
50
|
+
start(): void;
|
|
51
|
+
/**
|
|
52
|
+
* Tear down the session. Does NOT touch the engine (the engine may serve
|
|
53
|
+
* other sessions) or call `process.exit` (the daemon decides when to exit).
|
|
54
|
+
*/
|
|
55
|
+
stop(): void;
|
|
56
|
+
/** Underlying transport — exposed for daemon-side close hooks. */
|
|
57
|
+
getTransport(): JsonRpcTransport;
|
|
58
|
+
private handleMessage;
|
|
59
|
+
private handleInitialize;
|
|
60
|
+
private handleToolsList;
|
|
61
|
+
private handleToolsCall;
|
|
62
|
+
/**
|
|
63
|
+
* Lazy default-project resolution. Three layers:
|
|
64
|
+
* 1. await the in-flight init kicked off from `handleInitialize` (if any);
|
|
65
|
+
* 2. if still uninitialized and we never asked the client for its roots,
|
|
66
|
+
* do so now (one-shot); fall back to cwd if the client lacks roots;
|
|
67
|
+
* 3. last-resort: re-walk from the best candidate — picks up projects
|
|
68
|
+
* that were `codegraph init`'d *after* the server started.
|
|
69
|
+
*/
|
|
70
|
+
private retryInitIfNeeded;
|
|
71
|
+
/**
|
|
72
|
+
* Ask the client for its workspace root via `roots/list` and open the
|
|
73
|
+
* first one. Falls back to `process.cwd()` on timeout or empty answer.
|
|
74
|
+
*/
|
|
75
|
+
private initFromRoots;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/mcp/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAuC,gBAAgB,EAAc,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAKrC;;;GAGG;AAGH,eAAO,MAAM,WAAW;;;CAGvB,CAAC;AAEF,uDAAuD;AACvD,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAmC7C,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED;;;GAGG;AACH,qBAAa,UAAU;IAOnB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IAPhB,OAAO,CAAC,mBAAmB,CAAS;IACpC,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,cAAc,CAA8B;IACpD,OAAO,CAAC,mBAAmB,CAAgB;gBAGjC,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,SAAS,EACzB,IAAI,GAAE,iBAAsB;IAK9B;;;OAGG;IACH,KAAK,IAAI,IAAI;IAIb;;;OAGG;IACH,IAAI,IAAI,IAAI;IAIZ,kEAAkE;IAClE,YAAY,IAAI,gBAAgB;YAIlB,aAAa;YA0Cb,gBAAgB;YAsChB,eAAe;YAOf,eAAe;IA8B7B;;;;;;;OAOG;YACW,iBAAiB;IAyB/B;;;OAGG;YACW,aAAa;CAgB5B"}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MCP per-connection session — speaks the JSON-RPC protocol (initialize,
|
|
4
|
+
* tools/list, tools/call) over a single {@link JsonRpcTransport}. It owns
|
|
5
|
+
* per-client state only (which protocol version the client asked for, whether
|
|
6
|
+
* it advertised `roots`, the one-shot roots/list latch); the heavyweight
|
|
7
|
+
* resources (CodeGraph, watcher, ToolHandler) live in the shared
|
|
8
|
+
* {@link MCPEngine} so daemon mode can collapse N inotify sets / DB handles
|
|
9
|
+
* to one.
|
|
10
|
+
*
|
|
11
|
+
* The state-machine itself mirrors what `MCPServer` used to do inline before
|
|
12
|
+
* issue #411 split it out — the same regression tests in
|
|
13
|
+
* `__tests__/mcp-initialize.test.ts` still drive this code path.
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.MCPSession = exports.PROTOCOL_VERSION = exports.SERVER_INFO = void 0;
|
|
50
|
+
const path = __importStar(require("path"));
|
|
51
|
+
const transport_1 = require("./transport");
|
|
52
|
+
const tools_1 = require("./tools");
|
|
53
|
+
const server_instructions_1 = require("./server-instructions");
|
|
54
|
+
const version_1 = require("./version");
|
|
55
|
+
/**
|
|
56
|
+
* MCP Server Info — kept on the session because some clients log it. The
|
|
57
|
+
* version tracks the real package version (was a hard-coded '0.1.0').
|
|
58
|
+
*/
|
|
59
|
+
// Exported so the proxy can answer `initialize` locally with the IDENTICAL
|
|
60
|
+
// payload the daemon would send — no drift between the two handshake paths.
|
|
61
|
+
exports.SERVER_INFO = {
|
|
62
|
+
name: 'codegraph',
|
|
63
|
+
version: version_1.CodeGraphPackageVersion,
|
|
64
|
+
};
|
|
65
|
+
/** MCP Protocol Version (latest the server claims). */
|
|
66
|
+
exports.PROTOCOL_VERSION = '2024-11-05';
|
|
67
|
+
/**
|
|
68
|
+
* How long to wait for the client's `roots/list` response before giving up
|
|
69
|
+
* and falling back to the process cwd.
|
|
70
|
+
*/
|
|
71
|
+
const ROOTS_LIST_TIMEOUT_MS = 5000;
|
|
72
|
+
/**
|
|
73
|
+
* Convert a file:// URI to a filesystem path. Handles URL encoding and
|
|
74
|
+
* Windows drive letter paths.
|
|
75
|
+
*/
|
|
76
|
+
function fileUriToPath(uri) {
|
|
77
|
+
try {
|
|
78
|
+
const url = new URL(uri);
|
|
79
|
+
let filePath = decodeURIComponent(url.pathname);
|
|
80
|
+
if (process.platform === 'win32' && /^\/[a-zA-Z]:/.test(filePath)) {
|
|
81
|
+
filePath = filePath.slice(1);
|
|
82
|
+
}
|
|
83
|
+
return path.resolve(filePath);
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return uri.replace(/^file:\/\/\/?/, '');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** First usable filesystem path from a `roots/list` result, or null. */
|
|
90
|
+
function firstRootPath(result) {
|
|
91
|
+
if (!result || typeof result !== 'object')
|
|
92
|
+
return null;
|
|
93
|
+
const roots = result.roots;
|
|
94
|
+
if (!Array.isArray(roots) || roots.length === 0)
|
|
95
|
+
return null;
|
|
96
|
+
const first = roots[0];
|
|
97
|
+
if (typeof first?.uri !== 'string')
|
|
98
|
+
return null;
|
|
99
|
+
return fileUriToPath(first.uri);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* One MCP client's view of the server. Created fresh per stdio launch
|
|
103
|
+
* (direct mode) or per socket connection (daemon mode).
|
|
104
|
+
*/
|
|
105
|
+
class MCPSession {
|
|
106
|
+
transport;
|
|
107
|
+
engine;
|
|
108
|
+
clientSupportsRoots = false;
|
|
109
|
+
rootsAttempted = false;
|
|
110
|
+
resolvePromise = null;
|
|
111
|
+
explicitProjectPath;
|
|
112
|
+
constructor(transport, engine, opts = {}) {
|
|
113
|
+
this.transport = transport;
|
|
114
|
+
this.engine = engine;
|
|
115
|
+
this.explicitProjectPath = opts.explicitProjectPath ?? null;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Start handling messages from the transport. Returns immediately — the
|
|
119
|
+
* session lives for as long as the transport is open.
|
|
120
|
+
*/
|
|
121
|
+
start() {
|
|
122
|
+
this.transport.start(this.handleMessage.bind(this));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Tear down the session. Does NOT touch the engine (the engine may serve
|
|
126
|
+
* other sessions) or call `process.exit` (the daemon decides when to exit).
|
|
127
|
+
*/
|
|
128
|
+
stop() {
|
|
129
|
+
this.transport.stop();
|
|
130
|
+
}
|
|
131
|
+
/** Underlying transport — exposed for daemon-side close hooks. */
|
|
132
|
+
getTransport() {
|
|
133
|
+
return this.transport;
|
|
134
|
+
}
|
|
135
|
+
async handleMessage(message) {
|
|
136
|
+
const isRequest = 'id' in message;
|
|
137
|
+
switch (message.method) {
|
|
138
|
+
case 'initialize':
|
|
139
|
+
if (isRequest)
|
|
140
|
+
await this.handleInitialize(message);
|
|
141
|
+
break;
|
|
142
|
+
case 'initialized':
|
|
143
|
+
// Notification that client has finished initialization — no action needed.
|
|
144
|
+
break;
|
|
145
|
+
case 'tools/list':
|
|
146
|
+
if (isRequest)
|
|
147
|
+
await this.handleToolsList(message);
|
|
148
|
+
break;
|
|
149
|
+
case 'tools/call':
|
|
150
|
+
if (isRequest)
|
|
151
|
+
await this.handleToolsCall(message);
|
|
152
|
+
break;
|
|
153
|
+
case 'ping':
|
|
154
|
+
if (isRequest)
|
|
155
|
+
this.transport.sendResult(message.id, {});
|
|
156
|
+
break;
|
|
157
|
+
case 'resources/list':
|
|
158
|
+
// We expose no MCP resources, but some clients (opencode, Codex) probe
|
|
159
|
+
// for them on connect; reply with an empty list instead of a
|
|
160
|
+
// MethodNotFound error that surfaces as a scary `-32601` log line. (#621)
|
|
161
|
+
if (isRequest)
|
|
162
|
+
this.transport.sendResult(message.id, { resources: [] });
|
|
163
|
+
break;
|
|
164
|
+
case 'resources/templates/list':
|
|
165
|
+
if (isRequest)
|
|
166
|
+
this.transport.sendResult(message.id, { resourceTemplates: [] });
|
|
167
|
+
break;
|
|
168
|
+
case 'prompts/list':
|
|
169
|
+
// Likewise — no prompts exposed, but answer the probe cleanly. (#621)
|
|
170
|
+
if (isRequest)
|
|
171
|
+
this.transport.sendResult(message.id, { prompts: [] });
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
if (isRequest) {
|
|
175
|
+
this.transport.sendError(message.id, transport_1.ErrorCodes.MethodNotFound, `Method not found: ${message.method}`);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async handleInitialize(request) {
|
|
180
|
+
const params = request.params;
|
|
181
|
+
this.clientSupportsRoots = !!params?.capabilities?.roots;
|
|
182
|
+
// Explicit project signal, strongest first: client-provided rootUri /
|
|
183
|
+
// workspaceFolders (LSP-style), else the --path the server was launched
|
|
184
|
+
// with. cwd is NOT used here — we defer it so a roots/list answer can
|
|
185
|
+
// win over it. See issue #196.
|
|
186
|
+
let explicitPath = null;
|
|
187
|
+
if (params?.rootUri) {
|
|
188
|
+
explicitPath = fileUriToPath(params.rootUri);
|
|
189
|
+
}
|
|
190
|
+
else if (params?.workspaceFolders?.[0]?.uri) {
|
|
191
|
+
explicitPath = fileUriToPath(params.workspaceFolders[0].uri);
|
|
192
|
+
}
|
|
193
|
+
else if (this.explicitProjectPath) {
|
|
194
|
+
explicitPath = this.explicitProjectPath;
|
|
195
|
+
}
|
|
196
|
+
// Respond to the handshake BEFORE doing any heavy init — see issue #172.
|
|
197
|
+
this.transport.sendResult(request.id, {
|
|
198
|
+
protocolVersion: exports.PROTOCOL_VERSION,
|
|
199
|
+
capabilities: { tools: {} },
|
|
200
|
+
serverInfo: exports.SERVER_INFO,
|
|
201
|
+
instructions: server_instructions_1.SERVER_INSTRUCTIONS,
|
|
202
|
+
});
|
|
203
|
+
if (explicitPath) {
|
|
204
|
+
// Kick off engine init in the background. If another session in the
|
|
205
|
+
// same daemon already opened the project, `ensureInitialized` is a
|
|
206
|
+
// ~free no-op — N concurrent clients pay exactly one open.
|
|
207
|
+
this.resolvePromise = this.engine.ensureInitialized(explicitPath);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
async handleToolsList(request) {
|
|
211
|
+
await this.retryInitIfNeeded();
|
|
212
|
+
this.transport.sendResult(request.id, {
|
|
213
|
+
tools: this.engine.getToolHandler().getTools(),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
async handleToolsCall(request) {
|
|
217
|
+
const params = request.params;
|
|
218
|
+
if (!params || !params.name) {
|
|
219
|
+
this.transport.sendError(request.id, transport_1.ErrorCodes.InvalidParams, 'Missing tool name');
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const toolName = params.name;
|
|
223
|
+
const toolArgs = params.arguments || {};
|
|
224
|
+
const tool = tools_1.tools.find((t) => t.name === toolName);
|
|
225
|
+
if (!tool) {
|
|
226
|
+
this.transport.sendError(request.id, transport_1.ErrorCodes.InvalidParams, `Unknown tool: ${toolName}`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
await this.retryInitIfNeeded();
|
|
230
|
+
const result = await this.engine.getToolHandler().execute(toolName, toolArgs);
|
|
231
|
+
this.transport.sendResult(request.id, result);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Lazy default-project resolution. Three layers:
|
|
235
|
+
* 1. await the in-flight init kicked off from `handleInitialize` (if any);
|
|
236
|
+
* 2. if still uninitialized and we never asked the client for its roots,
|
|
237
|
+
* do so now (one-shot); fall back to cwd if the client lacks roots;
|
|
238
|
+
* 3. last-resort: re-walk from the best candidate — picks up projects
|
|
239
|
+
* that were `codegraph init`'d *after* the server started.
|
|
240
|
+
*/
|
|
241
|
+
async retryInitIfNeeded() {
|
|
242
|
+
if (this.resolvePromise) {
|
|
243
|
+
try {
|
|
244
|
+
await this.resolvePromise;
|
|
245
|
+
}
|
|
246
|
+
catch { /* fall through to retry */ }
|
|
247
|
+
this.resolvePromise = null;
|
|
248
|
+
}
|
|
249
|
+
if (this.engine.hasDefaultCodeGraph())
|
|
250
|
+
return;
|
|
251
|
+
const hint = this.explicitProjectPath ?? this.engine.getProjectPath();
|
|
252
|
+
if (!hint && !this.rootsAttempted) {
|
|
253
|
+
this.rootsAttempted = true;
|
|
254
|
+
this.resolvePromise = this.clientSupportsRoots
|
|
255
|
+
? this.initFromRoots()
|
|
256
|
+
: this.engine.ensureInitialized(process.cwd());
|
|
257
|
+
try {
|
|
258
|
+
await this.resolvePromise;
|
|
259
|
+
}
|
|
260
|
+
catch { /* fall through */ }
|
|
261
|
+
this.resolvePromise = null;
|
|
262
|
+
if (this.engine.hasDefaultCodeGraph())
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
// Last resort: walk from the best candidate (sync open). Picks up
|
|
266
|
+
// projects that appeared after the server started.
|
|
267
|
+
const candidate = hint ?? process.cwd();
|
|
268
|
+
this.engine.retryInitializeSync(candidate);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Ask the client for its workspace root via `roots/list` and open the
|
|
272
|
+
* first one. Falls back to `process.cwd()` on timeout or empty answer.
|
|
273
|
+
*/
|
|
274
|
+
async initFromRoots() {
|
|
275
|
+
let target = process.cwd();
|
|
276
|
+
try {
|
|
277
|
+
const result = await this.transport.request('roots/list', undefined, ROOTS_LIST_TIMEOUT_MS);
|
|
278
|
+
const rootPath = firstRootPath(result);
|
|
279
|
+
if (rootPath) {
|
|
280
|
+
target = rootPath;
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
process.stderr.write('[CodeGraph MCP] Client returned no workspace roots; falling back to process cwd.\n');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
288
|
+
process.stderr.write(`[CodeGraph MCP] roots/list request failed (${msg}); falling back to process cwd.\n`);
|
|
289
|
+
}
|
|
290
|
+
await this.engine.ensureInitialized(target);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
exports.MCPSession = MCPSession;
|
|
294
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/mcp/session.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,2CAAgG;AAEhG,mCAAgC;AAChC,+DAA4D;AAC5D,uCAAoD;AAEpD;;;GAGG;AACH,2EAA2E;AAC3E,4EAA4E;AAC/D,QAAA,WAAW,GAAG;IACzB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,iCAAuB;CACjC,CAAC;AAEF,uDAAuD;AAC1C,QAAA,gBAAgB,GAAG,YAAY,CAAC;AAE7C;;;GAGG;AACH,MAAM,qBAAqB,GAAG,IAAI,CAAC;AAEnC;;;GAGG;AACH,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,QAAQ,GAAG,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC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