@colbymchenry/codegraph-darwin-x64 0.9.9 → 1.0.0
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/lib/dist/bin/codegraph.d.ts +1 -0
- package/lib/dist/bin/codegraph.d.ts.map +1 -1
- package/lib/dist/bin/codegraph.js +246 -3
- package/lib/dist/bin/codegraph.js.map +1 -1
- package/lib/dist/context/index.d.ts.map +1 -1
- package/lib/dist/context/index.js +7 -0
- package/lib/dist/context/index.js.map +1 -1
- package/lib/dist/db/index.d.ts.map +1 -1
- package/lib/dist/db/index.js +2 -1
- package/lib/dist/db/index.js.map +1 -1
- package/lib/dist/db/migrations.d.ts +1 -1
- package/lib/dist/db/migrations.d.ts.map +1 -1
- package/lib/dist/db/migrations.js +10 -1
- package/lib/dist/db/migrations.js.map +1 -1
- package/lib/dist/db/queries.d.ts +43 -0
- package/lib/dist/db/queries.d.ts.map +1 -1
- package/lib/dist/db/queries.js +103 -7
- package/lib/dist/db/queries.js.map +1 -1
- package/lib/dist/db/schema.sql +1 -0
- package/lib/dist/db/sqlite-adapter.d.ts +7 -0
- package/lib/dist/db/sqlite-adapter.d.ts.map +1 -1
- package/lib/dist/db/sqlite-adapter.js +3 -0
- package/lib/dist/db/sqlite-adapter.js.map +1 -1
- package/lib/dist/directory.d.ts +34 -2
- package/lib/dist/directory.d.ts.map +1 -1
- package/lib/dist/directory.js +129 -35
- package/lib/dist/directory.js.map +1 -1
- package/lib/dist/extraction/astro-extractor.d.ts +79 -0
- package/lib/dist/extraction/astro-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/astro-extractor.js +320 -0
- package/lib/dist/extraction/astro-extractor.js.map +1 -0
- package/lib/dist/extraction/extraction-version.d.ts +25 -0
- package/lib/dist/extraction/extraction-version.d.ts.map +1 -0
- package/lib/dist/extraction/extraction-version.js +28 -0
- package/lib/dist/extraction/extraction-version.js.map +1 -0
- package/lib/dist/extraction/function-ref.d.ts +118 -0
- package/lib/dist/extraction/function-ref.d.ts.map +1 -0
- package/lib/dist/extraction/function-ref.js +727 -0
- package/lib/dist/extraction/function-ref.js.map +1 -0
- package/lib/dist/extraction/generated-detection.d.ts.map +1 -1
- package/lib/dist/extraction/generated-detection.js +3 -0
- package/lib/dist/extraction/generated-detection.js.map +1 -1
- package/lib/dist/extraction/grammars.d.ts +7 -1
- package/lib/dist/extraction/grammars.d.ts.map +1 -1
- package/lib/dist/extraction/grammars.js +52 -4
- package/lib/dist/extraction/grammars.js.map +1 -1
- package/lib/dist/extraction/index.d.ts +34 -0
- package/lib/dist/extraction/index.d.ts.map +1 -1
- package/lib/dist/extraction/index.js +346 -62
- package/lib/dist/extraction/index.js.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.d.ts +8 -0
- package/lib/dist/extraction/languages/c-cpp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/c-cpp.js +87 -28
- package/lib/dist/extraction/languages/c-cpp.js.map +1 -1
- package/lib/dist/extraction/languages/csharp.d.ts +22 -0
- package/lib/dist/extraction/languages/csharp.d.ts.map +1 -1
- package/lib/dist/extraction/languages/csharp.js +84 -2
- package/lib/dist/extraction/languages/csharp.js.map +1 -1
- package/lib/dist/extraction/languages/dart.d.ts.map +1 -1
- package/lib/dist/extraction/languages/dart.js +161 -1
- package/lib/dist/extraction/languages/dart.js.map +1 -1
- package/lib/dist/extraction/languages/go.d.ts.map +1 -1
- package/lib/dist/extraction/languages/go.js +43 -2
- package/lib/dist/extraction/languages/go.js.map +1 -1
- package/lib/dist/extraction/languages/index.d.ts.map +1 -1
- package/lib/dist/extraction/languages/index.js +2 -0
- package/lib/dist/extraction/languages/index.js.map +1 -1
- package/lib/dist/extraction/languages/java.d.ts.map +1 -1
- package/lib/dist/extraction/languages/java.js +42 -1
- package/lib/dist/extraction/languages/java.js.map +1 -1
- package/lib/dist/extraction/languages/javascript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/javascript.js +16 -0
- package/lib/dist/extraction/languages/javascript.js.map +1 -1
- package/lib/dist/extraction/languages/kotlin.d.ts.map +1 -1
- package/lib/dist/extraction/languages/kotlin.js +69 -0
- package/lib/dist/extraction/languages/kotlin.js.map +1 -1
- package/lib/dist/extraction/languages/objc.d.ts.map +1 -1
- package/lib/dist/extraction/languages/objc.js +42 -0
- package/lib/dist/extraction/languages/objc.js.map +1 -1
- package/lib/dist/extraction/languages/pascal.d.ts.map +1 -1
- package/lib/dist/extraction/languages/pascal.js +11 -0
- package/lib/dist/extraction/languages/pascal.js.map +1 -1
- package/lib/dist/extraction/languages/php.d.ts.map +1 -1
- package/lib/dist/extraction/languages/php.js +90 -1
- package/lib/dist/extraction/languages/php.js.map +1 -1
- package/lib/dist/extraction/languages/r.d.ts +3 -0
- package/lib/dist/extraction/languages/r.d.ts.map +1 -0
- package/lib/dist/extraction/languages/r.js +314 -0
- package/lib/dist/extraction/languages/r.js.map +1 -0
- package/lib/dist/extraction/languages/ruby.d.ts.map +1 -1
- package/lib/dist/extraction/languages/ruby.js +35 -0
- package/lib/dist/extraction/languages/ruby.js.map +1 -1
- package/lib/dist/extraction/languages/rust.d.ts.map +1 -1
- package/lib/dist/extraction/languages/rust.js +35 -2
- package/lib/dist/extraction/languages/rust.js.map +1 -1
- package/lib/dist/extraction/languages/scala.d.ts.map +1 -1
- package/lib/dist/extraction/languages/scala.js +61 -1
- package/lib/dist/extraction/languages/scala.js.map +1 -1
- package/lib/dist/extraction/languages/swift.d.ts.map +1 -1
- package/lib/dist/extraction/languages/swift.js +61 -0
- package/lib/dist/extraction/languages/swift.js.map +1 -1
- package/lib/dist/extraction/languages/typescript.d.ts +13 -0
- package/lib/dist/extraction/languages/typescript.d.ts.map +1 -1
- package/lib/dist/extraction/languages/typescript.js +38 -0
- package/lib/dist/extraction/languages/typescript.js.map +1 -1
- package/lib/dist/extraction/liquid-extractor.d.ts +7 -0
- package/lib/dist/extraction/liquid-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/liquid-extractor.js +53 -9
- package/lib/dist/extraction/liquid-extractor.js.map +1 -1
- package/lib/dist/extraction/razor-extractor.d.ts +42 -0
- package/lib/dist/extraction/razor-extractor.d.ts.map +1 -0
- package/lib/dist/extraction/razor-extractor.js +285 -0
- package/lib/dist/extraction/razor-extractor.js.map +1 -0
- package/lib/dist/extraction/svelte-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/svelte-extractor.js +6 -3
- package/lib/dist/extraction/svelte-extractor.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter-helpers.js +59 -10
- package/lib/dist/extraction/tree-sitter-helpers.js.map +1 -1
- package/lib/dist/extraction/tree-sitter-types.d.ts +33 -0
- package/lib/dist/extraction/tree-sitter-types.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.d.ts +211 -0
- package/lib/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/lib/dist/extraction/tree-sitter.js +1681 -49
- package/lib/dist/extraction/tree-sitter.js.map +1 -1
- package/lib/dist/extraction/vue-extractor.d.ts +15 -0
- package/lib/dist/extraction/vue-extractor.d.ts.map +1 -1
- package/lib/dist/extraction/vue-extractor.js +94 -3
- package/lib/dist/extraction/vue-extractor.js.map +1 -1
- package/lib/dist/extraction/wasm/tree-sitter-c_sharp.wasm +0 -0
- package/lib/dist/extraction/wasm/tree-sitter-r.wasm +0 -0
- package/lib/dist/graph/queries.d.ts.map +1 -1
- package/lib/dist/graph/queries.js +13 -40
- package/lib/dist/graph/queries.js.map +1 -1
- package/lib/dist/graph/traversal.d.ts.map +1 -1
- package/lib/dist/graph/traversal.js +16 -4
- package/lib/dist/graph/traversal.js.map +1 -1
- package/lib/dist/index.d.ts +34 -2
- package/lib/dist/index.d.ts.map +1 -1
- package/lib/dist/index.js +90 -8
- package/lib/dist/index.js.map +1 -1
- package/lib/dist/installer/index.d.ts.map +1 -1
- package/lib/dist/installer/index.js +52 -2
- package/lib/dist/installer/index.js.map +1 -1
- package/lib/dist/installer/instructions-template.d.ts +34 -11
- package/lib/dist/installer/instructions-template.d.ts.map +1 -1
- package/lib/dist/installer/instructions-template.js +44 -12
- package/lib/dist/installer/instructions-template.js.map +1 -1
- package/lib/dist/installer/targets/claude.d.ts.map +1 -1
- package/lib/dist/installer/targets/claude.js +6 -10
- package/lib/dist/installer/targets/claude.js.map +1 -1
- package/lib/dist/installer/targets/codex.js +4 -6
- package/lib/dist/installer/targets/codex.js.map +1 -1
- package/lib/dist/installer/targets/gemini.js +4 -6
- package/lib/dist/installer/targets/gemini.js.map +1 -1
- package/lib/dist/installer/targets/opencode.d.ts +9 -1
- package/lib/dist/installer/targets/opencode.d.ts.map +1 -1
- package/lib/dist/installer/targets/opencode.js +91 -40
- package/lib/dist/installer/targets/opencode.js.map +1 -1
- package/lib/dist/installer/targets/shared.d.ts +14 -0
- package/lib/dist/installer/targets/shared.d.ts.map +1 -1
- package/lib/dist/installer/targets/shared.js +16 -0
- package/lib/dist/installer/targets/shared.js.map +1 -1
- package/lib/dist/mcp/daemon.d.ts +60 -1
- package/lib/dist/mcp/daemon.d.ts.map +1 -1
- package/lib/dist/mcp/daemon.js +221 -8
- package/lib/dist/mcp/daemon.js.map +1 -1
- package/lib/dist/mcp/dynamic-boundaries.d.ts +41 -0
- package/lib/dist/mcp/dynamic-boundaries.d.ts.map +1 -0
- package/lib/dist/mcp/dynamic-boundaries.js +359 -0
- package/lib/dist/mcp/dynamic-boundaries.js.map +1 -0
- package/lib/dist/mcp/index.d.ts.map +1 -1
- package/lib/dist/mcp/index.js +18 -9
- package/lib/dist/mcp/index.js.map +1 -1
- package/lib/dist/mcp/ppid-watchdog.d.ts +44 -0
- package/lib/dist/mcp/ppid-watchdog.d.ts.map +1 -0
- package/lib/dist/mcp/ppid-watchdog.js +27 -0
- package/lib/dist/mcp/ppid-watchdog.js.map +1 -0
- package/lib/dist/mcp/proxy.d.ts +6 -0
- package/lib/dist/mcp/proxy.d.ts.map +1 -1
- package/lib/dist/mcp/proxy.js +153 -24
- package/lib/dist/mcp/proxy.js.map +1 -1
- package/lib/dist/mcp/server-instructions.d.ts +12 -1
- package/lib/dist/mcp/server-instructions.d.ts.map +1 -1
- package/lib/dist/mcp/server-instructions.js +43 -16
- package/lib/dist/mcp/server-instructions.js.map +1 -1
- package/lib/dist/mcp/session.d.ts +2 -0
- package/lib/dist/mcp/session.d.ts.map +1 -1
- package/lib/dist/mcp/session.js +49 -2
- package/lib/dist/mcp/session.js.map +1 -1
- package/lib/dist/mcp/stdin-teardown.d.ts +27 -0
- package/lib/dist/mcp/stdin-teardown.d.ts.map +1 -0
- package/lib/dist/mcp/stdin-teardown.js +49 -0
- package/lib/dist/mcp/stdin-teardown.js.map +1 -0
- package/lib/dist/mcp/tools.d.ts +71 -0
- package/lib/dist/mcp/tools.d.ts.map +1 -1
- package/lib/dist/mcp/tools.js +703 -85
- package/lib/dist/mcp/tools.js.map +1 -1
- package/lib/dist/mcp/transport.d.ts.map +1 -1
- package/lib/dist/mcp/transport.js +18 -2
- package/lib/dist/mcp/transport.js.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.d.ts +3 -3
- package/lib/dist/resolution/callback-synthesizer.d.ts.map +1 -1
- package/lib/dist/resolution/callback-synthesizer.js +549 -21
- package/lib/dist/resolution/callback-synthesizer.js.map +1 -1
- package/lib/dist/resolution/frameworks/astro.d.ts +9 -0
- package/lib/dist/resolution/frameworks/astro.d.ts.map +1 -0
- package/lib/dist/resolution/frameworks/astro.js +169 -0
- package/lib/dist/resolution/frameworks/astro.js.map +1 -0
- package/lib/dist/resolution/frameworks/expo-modules.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/expo-modules.js +6 -1
- package/lib/dist/resolution/frameworks/expo-modules.js.map +1 -1
- package/lib/dist/resolution/frameworks/index.d.ts +1 -0
- package/lib/dist/resolution/frameworks/index.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/index.js +5 -1
- package/lib/dist/resolution/frameworks/index.js.map +1 -1
- package/lib/dist/resolution/frameworks/java.js +6 -1
- package/lib/dist/resolution/frameworks/java.js.map +1 -1
- package/lib/dist/resolution/frameworks/python.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/python.js +7 -3
- package/lib/dist/resolution/frameworks/python.js.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react-native.js +53 -3
- package/lib/dist/resolution/frameworks/react-native.js.map +1 -1
- package/lib/dist/resolution/frameworks/react.d.ts.map +1 -1
- package/lib/dist/resolution/frameworks/react.js +15 -3
- package/lib/dist/resolution/frameworks/react.js.map +1 -1
- package/lib/dist/resolution/frameworks/svelte.js +5 -1
- package/lib/dist/resolution/frameworks/svelte.js.map +1 -1
- package/lib/dist/resolution/frameworks/vue.js +24 -27
- package/lib/dist/resolution/frameworks/vue.js.map +1 -1
- package/lib/dist/resolution/import-resolver.d.ts +10 -0
- package/lib/dist/resolution/import-resolver.d.ts.map +1 -1
- package/lib/dist/resolution/import-resolver.js +564 -2
- package/lib/dist/resolution/import-resolver.js.map +1 -1
- package/lib/dist/resolution/index.d.ts +80 -0
- package/lib/dist/resolution/index.d.ts.map +1 -1
- package/lib/dist/resolution/index.js +457 -7
- package/lib/dist/resolution/index.js.map +1 -1
- package/lib/dist/resolution/name-matcher.d.ts +61 -0
- package/lib/dist/resolution/name-matcher.d.ts.map +1 -1
- package/lib/dist/resolution/name-matcher.js +590 -14
- package/lib/dist/resolution/name-matcher.js.map +1 -1
- package/lib/dist/resolution/types.d.ts +27 -3
- package/lib/dist/resolution/types.d.ts.map +1 -1
- package/lib/dist/resolution/workspace-packages.d.ts +48 -0
- package/lib/dist/resolution/workspace-packages.d.ts.map +1 -0
- package/lib/dist/resolution/workspace-packages.js +208 -0
- package/lib/dist/resolution/workspace-packages.js.map +1 -0
- package/lib/dist/search/query-utils.d.ts +17 -1
- package/lib/dist/search/query-utils.d.ts.map +1 -1
- package/lib/dist/search/query-utils.js +79 -10
- package/lib/dist/search/query-utils.js.map +1 -1
- package/lib/dist/sync/watcher.d.ts +124 -32
- package/lib/dist/sync/watcher.d.ts.map +1 -1
- package/lib/dist/sync/watcher.js +326 -111
- package/lib/dist/sync/watcher.js.map +1 -1
- package/lib/dist/telemetry/index.d.ts +146 -0
- package/lib/dist/telemetry/index.d.ts.map +1 -0
- package/lib/dist/telemetry/index.js +544 -0
- package/lib/dist/telemetry/index.js.map +1 -0
- package/lib/dist/types.d.ts +17 -2
- package/lib/dist/types.d.ts.map +1 -1
- package/lib/dist/types.js +3 -0
- package/lib/dist/types.js.map +1 -1
- package/lib/dist/upgrade/index.d.ts +132 -0
- package/lib/dist/upgrade/index.d.ts.map +1 -0
- package/lib/dist/upgrade/index.js +462 -0
- package/lib/dist/upgrade/index.js.map +1 -0
- package/lib/dist/utils.d.ts +30 -24
- package/lib/dist/utils.d.ts.map +1 -1
- package/lib/dist/utils.js +64 -48
- package/lib/dist/utils.js.map +1 -1
- package/lib/node_modules/.package-lock.json +1 -29
- package/lib/package.json +1 -2
- package/package.json +1 -1
- package/lib/node_modules/chokidar/LICENSE +0 -21
- package/lib/node_modules/chokidar/README.md +0 -305
- package/lib/node_modules/chokidar/esm/handler.d.ts +0 -90
- package/lib/node_modules/chokidar/esm/handler.js +0 -629
- package/lib/node_modules/chokidar/esm/index.d.ts +0 -215
- package/lib/node_modules/chokidar/esm/index.js +0 -798
- package/lib/node_modules/chokidar/esm/package.json +0 -1
- package/lib/node_modules/chokidar/handler.d.ts +0 -90
- package/lib/node_modules/chokidar/handler.js +0 -635
- package/lib/node_modules/chokidar/index.d.ts +0 -215
- package/lib/node_modules/chokidar/index.js +0 -804
- package/lib/node_modules/chokidar/package.json +0 -69
- package/lib/node_modules/readdirp/LICENSE +0 -21
- package/lib/node_modules/readdirp/README.md +0 -120
- package/lib/node_modules/readdirp/esm/index.d.ts +0 -108
- package/lib/node_modules/readdirp/esm/index.js +0 -257
- package/lib/node_modules/readdirp/esm/package.json +0 -1
- package/lib/node_modules/readdirp/index.d.ts +0 -108
- package/lib/node_modules/readdirp/index.js +0 -263
- package/lib/node_modules/readdirp/package.json +0 -70
package/lib/dist/mcp/session.js
CHANGED
|
@@ -52,6 +52,8 @@ const transport_1 = require("./transport");
|
|
|
52
52
|
const tools_1 = require("./tools");
|
|
53
53
|
const server_instructions_1 = require("./server-instructions");
|
|
54
54
|
const version_1 = require("./version");
|
|
55
|
+
const directory_1 = require("../directory");
|
|
56
|
+
const telemetry_1 = require("../telemetry");
|
|
55
57
|
/**
|
|
56
58
|
* MCP Server Info — kept on the session because some clients log it. The
|
|
57
59
|
* version tracks the real package version (was a hard-coded '0.1.0').
|
|
@@ -106,6 +108,8 @@ class MCPSession {
|
|
|
106
108
|
transport;
|
|
107
109
|
engine;
|
|
108
110
|
clientSupportsRoots = false;
|
|
111
|
+
/** From the initialize handshake — attributes usage rollups to the agent host. */
|
|
112
|
+
clientInfo;
|
|
109
113
|
rootsAttempted = false;
|
|
110
114
|
resolvePromise = null;
|
|
111
115
|
explicitProjectPath;
|
|
@@ -154,6 +158,22 @@ class MCPSession {
|
|
|
154
158
|
if (isRequest)
|
|
155
159
|
this.transport.sendResult(message.id, {});
|
|
156
160
|
break;
|
|
161
|
+
case 'resources/list':
|
|
162
|
+
// We expose no MCP resources, but some clients (opencode, Codex) probe
|
|
163
|
+
// for them on connect; reply with an empty list instead of a
|
|
164
|
+
// MethodNotFound error that surfaces as a scary `-32601` log line. (#621)
|
|
165
|
+
if (isRequest)
|
|
166
|
+
this.transport.sendResult(message.id, { resources: [] });
|
|
167
|
+
break;
|
|
168
|
+
case 'resources/templates/list':
|
|
169
|
+
if (isRequest)
|
|
170
|
+
this.transport.sendResult(message.id, { resourceTemplates: [] });
|
|
171
|
+
break;
|
|
172
|
+
case 'prompts/list':
|
|
173
|
+
// Likewise — no prompts exposed, but answer the probe cleanly. (#621)
|
|
174
|
+
if (isRequest)
|
|
175
|
+
this.transport.sendResult(message.id, { prompts: [] });
|
|
176
|
+
break;
|
|
157
177
|
default:
|
|
158
178
|
if (isRequest) {
|
|
159
179
|
this.transport.sendError(message.id, transport_1.ErrorCodes.MethodNotFound, `Method not found: ${message.method}`);
|
|
@@ -163,6 +183,12 @@ class MCPSession {
|
|
|
163
183
|
async handleInitialize(request) {
|
|
164
184
|
const params = request.params;
|
|
165
185
|
this.clientSupportsRoots = !!params?.capabilities?.roots;
|
|
186
|
+
if (params?.clientInfo) {
|
|
187
|
+
this.clientInfo = {
|
|
188
|
+
name: typeof params.clientInfo.name === 'string' ? params.clientInfo.name : undefined,
|
|
189
|
+
version: typeof params.clientInfo.version === 'string' ? params.clientInfo.version : undefined,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
166
192
|
// Explicit project signal, strongest first: client-provided rootUri /
|
|
167
193
|
// workspaceFolders (LSP-style), else the --path the server was launched
|
|
168
194
|
// with. cwd is NOT used here — we defer it so a roots/list answer can
|
|
@@ -177,12 +203,23 @@ class MCPSession {
|
|
|
177
203
|
else if (this.explicitProjectPath) {
|
|
178
204
|
explicitPath = this.explicitProjectPath;
|
|
179
205
|
}
|
|
206
|
+
// Pick the instructions variant by the workspace's index state — a cheap
|
|
207
|
+
// synchronous walk-up (existsSync loop only, no DB open, so the #172
|
|
208
|
+
// respond-fast contract holds). An unindexed workspace gets the short
|
|
209
|
+
// "inactive this session" note instead of the full playbook: the playbook
|
|
210
|
+
// tells the agent to lean on tools that would all fail, and early failures
|
|
211
|
+
// teach the agent to abandon codegraph entirely. `tools/list` is gated the
|
|
212
|
+
// same way (empty list when unindexed). When no explicit path is known yet
|
|
213
|
+
// (roots/list dance pending), cwd is the best predictor of where the
|
|
214
|
+
// default project will resolve — and on a mismatch the worst case is the
|
|
215
|
+
// optimistic full playbook backstopped by the empty tool list.
|
|
216
|
+
const indexed = (0, directory_1.findNearestCodeGraphRoot)(explicitPath ?? process.cwd()) !== null;
|
|
180
217
|
// Respond to the handshake BEFORE doing any heavy init — see issue #172.
|
|
181
218
|
this.transport.sendResult(request.id, {
|
|
182
219
|
protocolVersion: exports.PROTOCOL_VERSION,
|
|
183
220
|
capabilities: { tools: {} },
|
|
184
221
|
serverInfo: exports.SERVER_INFO,
|
|
185
|
-
instructions: server_instructions_1.SERVER_INSTRUCTIONS,
|
|
222
|
+
instructions: indexed ? server_instructions_1.SERVER_INSTRUCTIONS : server_instructions_1.SERVER_INSTRUCTIONS_UNINDEXED,
|
|
186
223
|
});
|
|
187
224
|
if (explicitPath) {
|
|
188
225
|
// Kick off engine init in the background. If another session in the
|
|
@@ -193,8 +230,15 @@ class MCPSession {
|
|
|
193
230
|
}
|
|
194
231
|
async handleToolsList(request) {
|
|
195
232
|
await this.retryInitIfNeeded();
|
|
233
|
+
// An unindexed workspace serves an EMPTY tool list: absence is the one
|
|
234
|
+
// signal an agent can't misread. Listing 8 tools that all fail wastes the
|
|
235
|
+
// agent's calls and teaches it codegraph is broken (observed: one or two
|
|
236
|
+
// early isError responses and the agent stops calling codegraph for the
|
|
237
|
+
// whole session). A `codegraph init` run after the server started is
|
|
238
|
+
// picked up on the next tools/list — retryInitIfNeeded re-walks — though
|
|
239
|
+
// most hosts only request the list once per connection.
|
|
196
240
|
this.transport.sendResult(request.id, {
|
|
197
|
-
tools: this.engine.getToolHandler().getTools(),
|
|
241
|
+
tools: this.engine.hasDefaultCodeGraph() ? this.engine.getToolHandler().getTools() : [],
|
|
198
242
|
});
|
|
199
243
|
}
|
|
200
244
|
async handleToolsCall(request) {
|
|
@@ -213,6 +257,9 @@ class MCPSession {
|
|
|
213
257
|
await this.retryInitIfNeeded();
|
|
214
258
|
const result = await this.engine.getToolHandler().execute(toolName, toolArgs);
|
|
215
259
|
this.transport.sendResult(request.id, result);
|
|
260
|
+
// After the reply is on the wire — telemetry must never delay a tool
|
|
261
|
+
// response (in-memory increment only; see src/telemetry).
|
|
262
|
+
(0, telemetry_1.getTelemetry)().recordUsage('mcp_tool', toolName, !result.isError, this.clientInfo);
|
|
216
263
|
}
|
|
217
264
|
/**
|
|
218
265
|
* Lazy default-project resolution. Three layers:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/mcp/session.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,2CAAgG;AAEhG,mCAAgC;AAChC,+
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/mcp/session.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,2CAAgG;AAEhG,mCAAgC;AAChC,+DAA2F;AAC3F,uCAAoD;AACpD,4CAAwD;AACxD,4CAAwD;AAExD;;;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,EAAE,CAAC;YAClE,QAAQ,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;IAC1C,CAAC;AACH,CAA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K,CAAC,oFAAoF,CAAC,CAAC;YAC7G,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7D,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,8CAA8C,GAAG,mCAAmC,CAAC,CAAC;QAC7G,CAAC;QACD,MAAM,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC9C,CAAC;CACF;AA5OD,gCA4OC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Treat a stdin failure as a shutdown signal — issue #799.
|
|
3
|
+
*
|
|
4
|
+
* An MCP stdio server's lifeline is its stdin: when the host/client goes away,
|
|
5
|
+
* stdin should end and the server should exit. The server paths listened for
|
|
6
|
+
* `'end'` and `'close'` — but NOT `'error'`.
|
|
7
|
+
*
|
|
8
|
+
* That gap bites with a socket-backed stdin, which is the shape VS Code /
|
|
9
|
+
* Claude Code use (a socketpair, not a pipe). When the client dies, the socket
|
|
10
|
+
* can surface as an `'error'` (ECONNRESET / hangup) rather than a clean
|
|
11
|
+
* `'close'`. With no `'error'` listener, Node escalates it to the process-wide
|
|
12
|
+
* `uncaughtException` handler, which logs and keeps running — so the server
|
|
13
|
+
* orphans instead of exiting. Worse, on Linux a `POLLHUP` socket fd left
|
|
14
|
+
* registered in epoll wakes the event loop continuously, pinning a core at
|
|
15
|
+
* 100% CPU (the spin reported in #799); once the main thread spins, the
|
|
16
|
+
* `setInterval` PPID watchdog can't even fire, so the orphan runs forever.
|
|
17
|
+
*
|
|
18
|
+
* Fix: listen for `'error'` as well, and DESTROY the stdin stream on any
|
|
19
|
+
* terminal event so the fd leaves epoll and can't keep churning, then run the
|
|
20
|
+
* caller's shutdown. Fires `onTerminal` at most once — callers' shutdowns are
|
|
21
|
+
* already re-entry-guarded, but the single-shot guard also keeps `destroy()`'s
|
|
22
|
+
* follow-on `'close'` from re-invoking it.
|
|
23
|
+
*
|
|
24
|
+
* `stream` is injectable for tests; it defaults to `process.stdin`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function treatStdinFailureAsShutdown(onTerminal: () => void, stream?: NodeJS.ReadableStream): void;
|
|
27
|
+
//# sourceMappingURL=stdin-teardown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin-teardown.d.ts","sourceRoot":"","sources":["../../src/mcp/stdin-teardown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,MAAM,IAAI,EACtB,MAAM,GAAE,MAAM,CAAC,cAA8B,GAC5C,IAAI,CAiBN"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.treatStdinFailureAsShutdown = treatStdinFailureAsShutdown;
|
|
4
|
+
/**
|
|
5
|
+
* Treat a stdin failure as a shutdown signal — issue #799.
|
|
6
|
+
*
|
|
7
|
+
* An MCP stdio server's lifeline is its stdin: when the host/client goes away,
|
|
8
|
+
* stdin should end and the server should exit. The server paths listened for
|
|
9
|
+
* `'end'` and `'close'` — but NOT `'error'`.
|
|
10
|
+
*
|
|
11
|
+
* That gap bites with a socket-backed stdin, which is the shape VS Code /
|
|
12
|
+
* Claude Code use (a socketpair, not a pipe). When the client dies, the socket
|
|
13
|
+
* can surface as an `'error'` (ECONNRESET / hangup) rather than a clean
|
|
14
|
+
* `'close'`. With no `'error'` listener, Node escalates it to the process-wide
|
|
15
|
+
* `uncaughtException` handler, which logs and keeps running — so the server
|
|
16
|
+
* orphans instead of exiting. Worse, on Linux a `POLLHUP` socket fd left
|
|
17
|
+
* registered in epoll wakes the event loop continuously, pinning a core at
|
|
18
|
+
* 100% CPU (the spin reported in #799); once the main thread spins, the
|
|
19
|
+
* `setInterval` PPID watchdog can't even fire, so the orphan runs forever.
|
|
20
|
+
*
|
|
21
|
+
* Fix: listen for `'error'` as well, and DESTROY the stdin stream on any
|
|
22
|
+
* terminal event so the fd leaves epoll and can't keep churning, then run the
|
|
23
|
+
* caller's shutdown. Fires `onTerminal` at most once — callers' shutdowns are
|
|
24
|
+
* already re-entry-guarded, but the single-shot guard also keeps `destroy()`'s
|
|
25
|
+
* follow-on `'close'` from re-invoking it.
|
|
26
|
+
*
|
|
27
|
+
* `stream` is injectable for tests; it defaults to `process.stdin`.
|
|
28
|
+
*/
|
|
29
|
+
function treatStdinFailureAsShutdown(onTerminal, stream = process.stdin) {
|
|
30
|
+
let fired = false;
|
|
31
|
+
const fire = () => {
|
|
32
|
+
if (fired)
|
|
33
|
+
return;
|
|
34
|
+
fired = true;
|
|
35
|
+
// Drop the fd from epoll so a hung/half-closed socket can't keep waking
|
|
36
|
+
// the loop. Best-effort: the stream may already be torn down.
|
|
37
|
+
try {
|
|
38
|
+
stream.destroy?.();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
/* already gone */
|
|
42
|
+
}
|
|
43
|
+
onTerminal();
|
|
44
|
+
};
|
|
45
|
+
stream.on('end', fire);
|
|
46
|
+
stream.on('close', fire);
|
|
47
|
+
stream.on('error', fire);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=stdin-teardown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdin-teardown.js","sourceRoot":"","sources":["../../src/mcp/stdin-teardown.ts"],"names":[],"mappings":";;AAyBA,kEAoBC;AA7CD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,SAAgB,2BAA2B,CACzC,UAAsB,EACtB,SAAgC,OAAO,CAAC,KAAK;IAE7C,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,MAAM,IAAI,GAAG,GAAS,EAAE;QACtB,IAAI,KAAK;YAAE,OAAO;QAClB,KAAK,GAAG,IAAI,CAAC;QACb,wEAAwE;QACxE,8DAA8D;QAC9D,IAAI,CAAC;YACF,MAAuC,CAAC,OAAO,EAAE,EAAE,CAAC;QACvD,CAAC;QAAC,MAAM,CAAC;YACP,kBAAkB;QACpB,CAAC;QACD,UAAU,EAAE,CAAC;IACf,CAAC,CAAC;IACF,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IACvB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACzB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC3B,CAAC"}
|
package/lib/dist/mcp/tools.d.ts
CHANGED
|
@@ -5,6 +5,25 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type CodeGraph from '../index';
|
|
7
7
|
import type { PendingFile } from '../sync';
|
|
8
|
+
/**
|
|
9
|
+
* An expected, recoverable "codegraph can't serve this" condition — most
|
|
10
|
+
* importantly a project with no index. The dispatch catch converts these to
|
|
11
|
+
* SUCCESS-shaped responses (guidance text, NO isError): an `isError: true`
|
|
12
|
+
* early in a session teaches the agent the toolset is broken and it stops
|
|
13
|
+
* calling codegraph entirely (observed repeatedly), which is exactly wrong
|
|
14
|
+
* for conditions the agent can simply work around (use built-in tools for
|
|
15
|
+
* that codebase / pass projectPath). isError is reserved for "stop trying"
|
|
16
|
+
* cases: security refusals ({@link PathRefusalError}) and genuine
|
|
17
|
+
* malfunctions.
|
|
18
|
+
*/
|
|
19
|
+
export declare class NotIndexedError extends Error {
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A security refusal (sensitive system path). Stays `isError: true` WITHOUT
|
|
23
|
+
* retry guidance — abandoning this path is the desired agent reaction.
|
|
24
|
+
*/
|
|
25
|
+
export declare class PathRefusalError extends Error {
|
|
26
|
+
}
|
|
8
27
|
/**
|
|
9
28
|
* Calculate the recommended number of codegraph_explore calls based on project size.
|
|
10
29
|
* Larger codebases need more exploration calls to cover their surface area,
|
|
@@ -241,6 +260,16 @@ export declare class ToolHandler {
|
|
|
241
260
|
* Handle codegraph_search
|
|
242
261
|
*/
|
|
243
262
|
private handleSearch;
|
|
263
|
+
/**
|
|
264
|
+
* Group symbol matches into DISTINCT DEFINITIONS — one group per
|
|
265
|
+
* (filePath, qualifiedName), so same-file overloads stay together while
|
|
266
|
+
* unrelated same-named classes across a monorepo's apps (#764: one
|
|
267
|
+
* `UserService` per NestJS app) are kept apart. Optionally narrowed by a
|
|
268
|
+
* `file` path/suffix first.
|
|
269
|
+
*/
|
|
270
|
+
private groupDefinitions;
|
|
271
|
+
/** Section heading for one distinct definition in grouped output. */
|
|
272
|
+
private definitionHeading;
|
|
244
273
|
/**
|
|
245
274
|
* Handle codegraph_callers
|
|
246
275
|
*/
|
|
@@ -275,6 +304,27 @@ export declare class ToolHandler {
|
|
|
275
304
|
* dropping unrelated `OmsOrderService::list`.
|
|
276
305
|
*/
|
|
277
306
|
private buildFlowFromNamedSymbols;
|
|
307
|
+
/**
|
|
308
|
+
* Dynamic-boundary surfacing (#687): when the flow among the agent's named
|
|
309
|
+
* symbols does not fully connect, scan the disconnected symbols' bodies for
|
|
310
|
+
* dynamic-dispatch sites (computed member calls, getattr, reflection, typed
|
|
311
|
+
* message buses, runtime-keyed emits) and ANNOUNCE the boundary — the exact
|
|
312
|
+
* site, the form, and (when a key is statically visible) candidate targets —
|
|
313
|
+
* instead of guessing edges. The answer to "how does A reach B" when no
|
|
314
|
+
* static path exists IS the dispatch site: that's where the flow continues
|
|
315
|
+
* at runtime. Query-time, deterministic, zero graph mutation; a fully
|
|
316
|
+
* connected flow never reaches this method.
|
|
317
|
+
*/
|
|
318
|
+
private buildDynamicBoundaries;
|
|
319
|
+
/**
|
|
320
|
+
* Shortlist candidate runtime targets for a dispatch key surfaced by
|
|
321
|
+
* {@link buildDynamicBoundaries}. Exact conventional names first (`save` →
|
|
322
|
+
* `onSave`/`handleSave`; `CreateCmd` → `CreateCmdHandler`), then FTS, with a
|
|
323
|
+
* normalized-containment post-filter (FTS camel-splitting is fuzzier than a
|
|
324
|
+
* candidate list should be). Symbols the agent already named sort first and
|
|
325
|
+
* are marked — that's the "you were right, here's the wiring" case.
|
|
326
|
+
*/
|
|
327
|
+
private boundaryCandidates;
|
|
278
328
|
/**
|
|
279
329
|
* Compact "blast radius" for the entry symbols of an explore result: who
|
|
280
330
|
* depends on each (callers) and which test files cover it — LOCATIONS ONLY,
|
|
@@ -317,6 +367,20 @@ export declare class ToolHandler {
|
|
|
317
367
|
* Handle codegraph_node
|
|
318
368
|
*/
|
|
319
369
|
private handleNode;
|
|
370
|
+
/**
|
|
371
|
+
* FILE READ MODE: resolve `fileArg` (path or basename) to an indexed file and
|
|
372
|
+
* read it like the Read tool — its current on-disk source with line numbers,
|
|
373
|
+
* narrowable with `offset`/`limit` exactly as Read's are — preceded by a
|
|
374
|
+
* one-line blast-radius header (which files depend on it). `symbolsOnly`
|
|
375
|
+
* returns just the structural map (symbols + dependents) instead of source.
|
|
376
|
+
*
|
|
377
|
+
* Parity goal: the numbered source block is byte-for-byte the shape Read
|
|
378
|
+
* returns (`<n>\t<line>`, no padding), so the agent treats it as a Read — only
|
|
379
|
+
* faster (served from the index) and with the blast radius attached. Security:
|
|
380
|
+
* yaml/properties files are summarized by key, never dumped (#383); reads go
|
|
381
|
+
* through validatePathWithinRoot (#527).
|
|
382
|
+
*/
|
|
383
|
+
private handleFileView;
|
|
320
384
|
/** Render one symbol: details + (optional) body/outline + its caller/callee trail. */
|
|
321
385
|
private renderNodeSection;
|
|
322
386
|
/**
|
|
@@ -396,6 +460,13 @@ export declare class ToolHandler {
|
|
|
396
460
|
private truncateOutput;
|
|
397
461
|
private formatSearchResults;
|
|
398
462
|
private formatNodeList;
|
|
463
|
+
/**
|
|
464
|
+
* Relationship label for a non-`calls` edge in callers/callees lists. A
|
|
465
|
+
* function-as-value edge (#756) is the high-signal one: `callers(cb)`
|
|
466
|
+
* showing "via callback registration" tells the agent this is where the
|
|
467
|
+
* callback is WIRED, not where it's invoked.
|
|
468
|
+
*/
|
|
469
|
+
private edgeLabel;
|
|
399
470
|
private formatImpact;
|
|
400
471
|
/**
|
|
401
472
|
* Build a compact structural outline of a container symbol from its
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAW3C;;;;;;;;;;GAUG;AACH,qBAAa,eAAgB,SAAQ,KAAK;CAAG;AAE7C;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;CAAG;AA+C9C;;;;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;IACrB,gFAAgF;IAChF,sBAAsB,EAAE,MAAM,CAAC;IAC/B,0EAA0E;IAC1E,2BAA2B,EAAE,MAAM,CAAC;IACpC,2CAA2C;IAC3C,oBAAoB,EAAE,OAAO,CAAC;IAC9B,yEAAyE;IACzE,sBAAsB,EAAE,OAAO,CAAC;IAChC,sEAAsE;IACtE,yBAAy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