@colbymchenry/codegraph 0.9.7 → 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.
Files changed (120) hide show
  1. package/README.md +116 -32
  2. package/dist/bin/codegraph.d.ts +25 -0
  3. package/dist/bin/node-version-check.d.ts +37 -0
  4. package/dist/bin/uninstall.d.ts +14 -0
  5. package/dist/context/formatter.d.ts +30 -0
  6. package/dist/context/index.d.ts +119 -0
  7. package/dist/context/markers.d.ts +19 -0
  8. package/dist/db/index.d.ts +101 -0
  9. package/dist/db/migrations.d.ts +44 -0
  10. package/dist/db/queries.d.ts +344 -0
  11. package/dist/db/sqlite-adapter.d.ts +46 -0
  12. package/dist/directory.d.ts +57 -0
  13. package/dist/errors.d.ts +136 -0
  14. package/dist/extraction/dfm-extractor.d.ts +31 -0
  15. package/dist/extraction/generated-detection.d.ts +30 -0
  16. package/dist/extraction/grammars.d.ts +100 -0
  17. package/dist/extraction/index.d.ts +138 -0
  18. package/dist/extraction/languages/c-cpp.d.ts +4 -0
  19. package/dist/extraction/languages/csharp.d.ts +3 -0
  20. package/dist/extraction/languages/dart.d.ts +3 -0
  21. package/dist/extraction/languages/go.d.ts +3 -0
  22. package/dist/extraction/languages/index.d.ts +10 -0
  23. package/dist/extraction/languages/java.d.ts +3 -0
  24. package/dist/extraction/languages/javascript.d.ts +3 -0
  25. package/dist/extraction/languages/kotlin.d.ts +3 -0
  26. package/dist/extraction/languages/lua.d.ts +3 -0
  27. package/dist/extraction/languages/luau.d.ts +3 -0
  28. package/dist/extraction/languages/objc.d.ts +3 -0
  29. package/dist/extraction/languages/pascal.d.ts +3 -0
  30. package/dist/extraction/languages/php.d.ts +3 -0
  31. package/dist/extraction/languages/python.d.ts +3 -0
  32. package/dist/extraction/languages/ruby.d.ts +3 -0
  33. package/dist/extraction/languages/rust.d.ts +3 -0
  34. package/dist/extraction/languages/scala.d.ts +3 -0
  35. package/dist/extraction/languages/swift.d.ts +3 -0
  36. package/dist/extraction/languages/typescript.d.ts +3 -0
  37. package/dist/extraction/liquid-extractor.d.ts +52 -0
  38. package/dist/extraction/mybatis-extractor.d.ts +48 -0
  39. package/dist/extraction/parse-worker.d.ts +8 -0
  40. package/dist/extraction/svelte-extractor.d.ts +56 -0
  41. package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
  42. package/dist/extraction/tree-sitter-types.d.ts +193 -0
  43. package/dist/extraction/tree-sitter.d.ts +317 -0
  44. package/dist/extraction/vue-extractor.d.ts +36 -0
  45. package/dist/extraction/wasm-runtime-flags.d.ts +38 -0
  46. package/dist/graph/index.d.ts +8 -0
  47. package/dist/graph/queries.d.ts +106 -0
  48. package/dist/graph/traversal.d.ts +127 -0
  49. package/dist/index.d.ts +498 -0
  50. package/dist/installer/config-writer.d.ts +28 -0
  51. package/dist/installer/index.d.ts +100 -0
  52. package/dist/installer/instructions-template.d.ts +18 -0
  53. package/dist/installer/targets/antigravity.d.ts +57 -0
  54. package/dist/installer/targets/claude.d.ts +56 -0
  55. package/dist/installer/targets/codex.d.ts +18 -0
  56. package/dist/installer/targets/cursor.d.ts +35 -0
  57. package/dist/installer/targets/gemini.d.ts +26 -0
  58. package/dist/installer/targets/hermes.d.ts +18 -0
  59. package/dist/installer/targets/kiro.d.ts +27 -0
  60. package/dist/installer/targets/opencode.d.ts +30 -0
  61. package/dist/installer/targets/registry.d.ts +35 -0
  62. package/dist/installer/targets/shared.d.ts +77 -0
  63. package/dist/installer/targets/toml.d.ts +52 -0
  64. package/dist/installer/targets/types.d.ts +101 -0
  65. package/dist/mcp/daemon-paths.d.ts +46 -0
  66. package/dist/mcp/daemon.d.ts +161 -0
  67. package/dist/mcp/engine.d.ts +105 -0
  68. package/dist/mcp/index.d.ts +112 -0
  69. package/dist/mcp/proxy.d.ts +81 -0
  70. package/dist/mcp/server-instructions.d.ts +19 -0
  71. package/dist/mcp/session.d.ts +77 -0
  72. package/dist/mcp/tools.d.ts +413 -0
  73. package/dist/mcp/transport.d.ts +188 -0
  74. package/dist/mcp/version.d.ts +19 -0
  75. package/dist/resolution/callback-synthesizer.d.ts +10 -0
  76. package/dist/resolution/frameworks/cargo-workspace.d.ts +18 -0
  77. package/dist/resolution/frameworks/csharp.d.ts +8 -0
  78. package/dist/resolution/frameworks/drupal.d.ts +51 -0
  79. package/dist/resolution/frameworks/expo-modules.d.ts +3 -0
  80. package/dist/resolution/frameworks/express.d.ts +8 -0
  81. package/dist/resolution/frameworks/fabric.d.ts +3 -0
  82. package/dist/resolution/frameworks/go.d.ts +8 -0
  83. package/dist/resolution/frameworks/index.d.ts +48 -0
  84. package/dist/resolution/frameworks/java.d.ts +8 -0
  85. package/dist/resolution/frameworks/laravel.d.ts +13 -0
  86. package/dist/resolution/frameworks/nestjs.d.ts +26 -0
  87. package/dist/resolution/frameworks/play.d.ts +19 -0
  88. package/dist/resolution/frameworks/python.d.ts +10 -0
  89. package/dist/resolution/frameworks/react-native.d.ts +3 -0
  90. package/dist/resolution/frameworks/react.d.ts +8 -0
  91. package/dist/resolution/frameworks/ruby.d.ts +8 -0
  92. package/dist/resolution/frameworks/rust.d.ts +8 -0
  93. package/dist/resolution/frameworks/svelte.d.ts +9 -0
  94. package/dist/resolution/frameworks/swift-objc.d.ts +37 -0
  95. package/dist/resolution/frameworks/swift.d.ts +10 -0
  96. package/dist/resolution/frameworks/vue.d.ts +9 -0
  97. package/dist/resolution/go-module.d.ts +26 -0
  98. package/dist/resolution/import-resolver.d.ts +68 -0
  99. package/dist/resolution/index.d.ts +116 -0
  100. package/dist/resolution/lru-cache.d.ts +24 -0
  101. package/dist/resolution/name-matcher.d.ts +32 -0
  102. package/dist/resolution/path-aliases.d.ts +68 -0
  103. package/dist/resolution/strip-comments.d.ts +27 -0
  104. package/dist/resolution/swift-objc-bridge.d.ts +134 -0
  105. package/dist/resolution/types.d.ts +209 -0
  106. package/dist/search/query-parser.d.ts +57 -0
  107. package/dist/search/query-utils.d.ts +71 -0
  108. package/dist/sync/git-hooks.d.ts +45 -0
  109. package/dist/sync/index.d.ts +19 -0
  110. package/dist/sync/watch-policy.d.ts +48 -0
  111. package/dist/sync/watcher.d.ts +191 -0
  112. package/dist/sync/worktree.d.ts +54 -0
  113. package/dist/types.d.ts +377 -0
  114. package/dist/ui/glyphs.d.ts +42 -0
  115. package/dist/ui/shimmer-progress.d.ts +11 -0
  116. package/dist/ui/shimmer-worker.d.ts +2 -0
  117. package/dist/ui/types.d.ts +17 -0
  118. package/dist/utils.d.ts +205 -0
  119. package/npm-sdk.js +75 -0
  120. package/package.json +18 -7
@@ -0,0 +1,413 @@
1
+ /**
2
+ * MCP Tool Definitions
3
+ *
4
+ * Defines the tools exposed by the CodeGraph MCP server.
5
+ */
6
+ import type CodeGraph from '../index';
7
+ import type { PendingFile } from '../sync';
8
+ /**
9
+ * Calculate the recommended number of codegraph_explore calls based on project size.
10
+ * Larger codebases need more exploration calls to cover their surface area,
11
+ * but smaller ones should use fewer to avoid unnecessary overhead.
12
+ */
13
+ export declare function getExploreBudget(fileCount: number): number;
14
+ /**
15
+ * Adaptive output budget for `codegraph_explore`, scaled to project size.
16
+ *
17
+ * Smaller codebases get a tighter total cap, fewer default files, smaller
18
+ * per-file cap, and tighter clustering — so a focused query on a 100-file
19
+ * project doesn't dump a whole file's worth of source into the agent's
20
+ * context. Larger codebases keep the generous defaults because the
21
+ * agent's native discovery cost (grep + find + many Reads) genuinely
22
+ * dwarfs a fat explore call at that scale.
23
+ *
24
+ * Meta-text (relationships map, "additional relevant files" list,
25
+ * completeness signal, budget note) is gated off for tiny projects
26
+ * where one rich call is the whole story and the extra prose is just
27
+ * overhead.
28
+ *
29
+ * Tier breakpoints mirror `getExploreBudget` so a project sits in the
30
+ * same tier across both knobs.
31
+ */
32
+ export interface ExploreOutputBudget {
33
+ /** Hard cap on total output characters. */
34
+ maxOutputChars: number;
35
+ /** Default `maxFiles` when the caller didn't specify one. */
36
+ defaultMaxFiles: number;
37
+ /** Cap on contiguous source returned per file (across all its clusters). */
38
+ maxCharsPerFile: number;
39
+ /** Cluster gap threshold in lines — tighter clustering on small projects. */
40
+ gapThreshold: number;
41
+ /** Max symbols listed in the per-file header (`#### path — sym(kind), ...`). */
42
+ maxSymbolsInFileHeader: number;
43
+ /** Max edges shown per relationship kind in the Relationships section. */
44
+ maxEdgesPerRelationshipKind: number;
45
+ /** Include the "Relationships" section. */
46
+ includeRelationships: boolean;
47
+ /** Include the "Additional relevant files (not shown)" trailing list. */
48
+ includeAdditionalFiles: boolean;
49
+ /** Include the "Complete source code is included above…" reminder. */
50
+ includeCompletenessSignal: boolean;
51
+ /** Include the explore-budget reminder at the end. */
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;
62
+ }
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;
77
+ /**
78
+ * MCP Tool definition
79
+ */
80
+ export interface ToolDefinition {
81
+ name: string;
82
+ description: string;
83
+ inputSchema: {
84
+ type: 'object';
85
+ properties: Record<string, PropertySchema>;
86
+ required?: string[];
87
+ };
88
+ }
89
+ interface PropertySchema {
90
+ type: string;
91
+ description: string;
92
+ enum?: string[];
93
+ default?: unknown;
94
+ }
95
+ /**
96
+ * Tool execution result
97
+ */
98
+ export interface ToolResult {
99
+ content: Array<{
100
+ type: 'text';
101
+ text: string;
102
+ }>;
103
+ isError?: boolean;
104
+ }
105
+ /**
106
+ * All CodeGraph MCP tools
107
+ *
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.
111
+ *
112
+ * All tools support cross-project queries via the optional `projectPath` parameter.
113
+ */
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[];
122
+ /**
123
+ * Tool handler that executes tools against a CodeGraph instance
124
+ *
125
+ * Supports cross-project queries via the projectPath parameter.
126
+ * Other projects are opened on-demand and cached for performance.
127
+ */
128
+ export declare class ToolHandler {
129
+ private cg;
130
+ private projectCache;
131
+ private defaultProjectHint;
132
+ private worktreeMismatchCache;
133
+ private catchUpGate;
134
+ constructor(cg: CodeGraph | null);
135
+ /**
136
+ * Update the default CodeGraph instance (e.g. after lazy initialization)
137
+ */
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;
147
+ /**
148
+ * Record the directory the server tried to resolve the default project from.
149
+ * Used only to make the "no default project" error actionable.
150
+ */
151
+ setDefaultProjectHint(searchedPath: string): void;
152
+ /**
153
+ * Whether a default CodeGraph instance is available
154
+ */
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;
167
+ /**
168
+ * Get tool definitions with dynamic descriptions based on project size.
169
+ * The codegraph_explore tool description includes a budget recommendation
170
+ * scaled to the number of indexed files. Honors the CODEGRAPH_MCP_TOOLS
171
+ * allowlist so a trimmed surface is reflected in ListTools.
172
+ */
173
+ getTools(): ToolDefinition[];
174
+ /**
175
+ * Get CodeGraph instance for a project
176
+ *
177
+ * If projectPath is provided, opens that project's CodeGraph (cached).
178
+ * Otherwise returns the default CodeGraph instance.
179
+ *
180
+ * Walks up parent directories to find the nearest .codegraph/ folder,
181
+ * similar to how git finds .git/ directories.
182
+ */
183
+ private getCodeGraph;
184
+ /**
185
+ * Close all cached project connections
186
+ */
187
+ closeAll(): void;
188
+ /**
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.
195
+ */
196
+ private validateString;
197
+ /**
198
+ * Validate an optional path-like string input. Returns the value if
199
+ * valid (or undefined), or a ToolResult with the error.
200
+ */
201
+ private validateOptionalPath;
202
+ /**
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.
211
+ */
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;
236
+ /**
237
+ * Execute a tool by name
238
+ */
239
+ execute(toolName: string, args: Record<string, unknown>): Promise<ToolResult>;
240
+ /**
241
+ * Handle codegraph_search
242
+ */
243
+ private handleSearch;
244
+ /**
245
+ * Handle codegraph_callers
246
+ */
247
+ private handleCallers;
248
+ /**
249
+ * Handle codegraph_callees
250
+ */
251
+ private handleCallees;
252
+ /**
253
+ * Handle codegraph_impact
254
+ */
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;
304
+ /**
305
+ * Handle codegraph_explore — deep exploration in a single call
306
+ *
307
+ * Strategy: find relevant symbols via graph traversal, group by file,
308
+ * then read contiguous file sections covering all symbols per file.
309
+ * This replaces multiple codegraph_node + Read calls.
310
+ *
311
+ * Output size is adaptive to project file count via
312
+ * `getExploreOutputBudget` — see #185 for why a fixed 35k cap was a
313
+ * tax on small projects while earning its keep on large ones.
314
+ */
315
+ private handleExplore;
316
+ /**
317
+ * Handle codegraph_node
318
+ */
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;
332
+ /**
333
+ * Handle codegraph_status
334
+ */
335
+ private handleStatus;
336
+ /**
337
+ * Handle codegraph_files - get project file structure from the index
338
+ */
339
+ private handleFiles;
340
+ /**
341
+ * Convert glob pattern to regex
342
+ */
343
+ private globToRegex;
344
+ /**
345
+ * Format files as a flat list
346
+ */
347
+ private formatFilesFlat;
348
+ /**
349
+ * Format files grouped by language
350
+ */
351
+ private formatFilesGrouped;
352
+ /**
353
+ * Format files as a tree structure
354
+ */
355
+ private formatFilesTree;
356
+ /**
357
+ * Find a symbol by name, handling disambiguation when multiple matches exist.
358
+ * Returns the best match and a note about alternatives if any.
359
+ */
360
+ /**
361
+ * Check if a node matches a symbol query.
362
+ *
363
+ * Accepts simple names (`run`) and three flavors of qualifier:
364
+ * - dotted `Session.request` (TS/JS/Python)
365
+ * - colon-pair `stage_apply::run` (Rust, C++, Ruby)
366
+ * - slash `configurator/stage_apply` (path-ish)
367
+ *
368
+ * Multi-level qualifiers compose: `crate::configurator::stage_apply::run`
369
+ * works. Rust path prefixes (`crate`, `super`, `self`) are stripped so
370
+ * the canonical `crate::module::symbol` form resolves.
371
+ *
372
+ * Resolution order, last part must always equal `node.name`:
373
+ * 1. Suffix-match against `qualifiedName` (handles class-scoped methods
374
+ * where the extractor builds the qualified name from the AST stack)
375
+ * 2. File-path containment (handles file-derived modules in Rust/
376
+ * Python — `stage_apply::run` matches a `run` in `stage_apply.rs`)
377
+ */
378
+ private matchesSymbol;
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;
388
+ /**
389
+ * Find ALL symbols matching a name. Used by callers/callees/impact to aggregate
390
+ * results across all matching symbols (e.g., multiple classes with an `execute` method).
391
+ */
392
+ private findAllSymbols;
393
+ /**
394
+ * Truncate output if it exceeds the maximum length
395
+ */
396
+ private truncateOutput;
397
+ private formatSearchResults;
398
+ private formatNodeList;
399
+ private formatImpact;
400
+ /**
401
+ * Build a compact structural outline of a container symbol from its
402
+ * indexed children (methods, fields, properties, …) — name, kind,
403
+ * line number, and signature — so the agent gets the shape of a class
404
+ * without the full source of every method. Returns '' when the container
405
+ * has no indexed children, so the caller can fall back to full source.
406
+ */
407
+ private buildContainerOutline;
408
+ private formatNodeDetails;
409
+ private textResult;
410
+ private errorResult;
411
+ }
412
+ export {};
413
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1,188 @@
1
+ /**
2
+ * MCP JSON-RPC Transports
3
+ *
4
+ * Two flavors share the same wire format (newline-delimited JSON-RPC 2.0):
5
+ *
6
+ * - `StdioTransport` — original transport; reads/writes the process's
7
+ * stdin/stdout. Used by direct-mode MCP servers.
8
+ * - `SocketTransport` — wraps a single `net.Socket`. Used by the shared-daemon
9
+ * architecture (see {@link ./daemon}) to multiplex multiple MCP clients onto
10
+ * one CodeGraph instance via per-connection sessions.
11
+ *
12
+ * Both implement {@link JsonRpcTransport} so the session-level protocol logic
13
+ * (initialize / tools/list / tools/call, plus server-initiated `roots/list`)
14
+ * is identical regardless of where the bytes come from.
15
+ */
16
+ import type { Socket } from 'net';
17
+ /**
18
+ * JSON-RPC 2.0 Request
19
+ */
20
+ export interface JsonRpcRequest {
21
+ jsonrpc: '2.0';
22
+ id: string | number;
23
+ method: string;
24
+ params?: unknown;
25
+ }
26
+ /**
27
+ * JSON-RPC 2.0 Response
28
+ */
29
+ export interface JsonRpcResponse {
30
+ jsonrpc: '2.0';
31
+ id: string | number | null;
32
+ result?: unknown;
33
+ error?: JsonRpcError;
34
+ }
35
+ /**
36
+ * JSON-RPC 2.0 Error
37
+ */
38
+ export interface JsonRpcError {
39
+ code: number;
40
+ message: string;
41
+ data?: unknown;
42
+ }
43
+ /**
44
+ * JSON-RPC 2.0 Notification (no id, no response expected)
45
+ */
46
+ export interface JsonRpcNotification {
47
+ jsonrpc: '2.0';
48
+ method: string;
49
+ params?: unknown;
50
+ }
51
+ export declare const ErrorCodes: {
52
+ readonly ParseError: -32700;
53
+ readonly InvalidRequest: -32600;
54
+ readonly MethodNotFound: -32601;
55
+ readonly InvalidParams: -32602;
56
+ readonly InternalError: -32603;
57
+ };
58
+ export type MessageHandler = (message: JsonRpcRequest | JsonRpcNotification) => Promise<void>;
59
+ /**
60
+ * Generic JSON-RPC transport interface — common surface for stdio and socket
61
+ * carriers. Anything below the session layer (initialize, tool dispatch, etc.)
62
+ * talks to this, not to a concrete transport class.
63
+ */
64
+ export interface JsonRpcTransport {
65
+ start(handler: MessageHandler): void;
66
+ stop(): void;
67
+ send(response: JsonRpcResponse): void;
68
+ notify(method: string, params?: unknown): void;
69
+ request(method: string, params?: unknown, timeoutMs?: number): Promise<unknown>;
70
+ sendResult(id: string | number, result: unknown): void;
71
+ sendError(id: string | number | null, code: number, message: string, data?: unknown): void;
72
+ }
73
+ /**
74
+ * Shared implementation of newline-delimited JSON-RPC 2.0 over any
75
+ * `Readable`/`Writable` stream pair. Stdio and socket transports both wrap
76
+ * this — the only difference between them is which streams get plugged in
77
+ * and how a "close" propagates back to the owning code.
78
+ */
79
+ declare abstract class LineBasedJsonRpcTransport implements JsonRpcTransport {
80
+ protected messageHandler: MessageHandler | null;
81
+ protected pending: Map<string | number, {
82
+ resolve: (value: unknown) => void;
83
+ reject: (error: Error) => void;
84
+ }>;
85
+ protected nextRequestId: number;
86
+ protected stopped: boolean;
87
+ abstract start(handler: MessageHandler): void;
88
+ protected abstract write(line: string): void;
89
+ protected abstract idPrefix(): string;
90
+ abstract stop(): void;
91
+ /**
92
+ * Send a server-initiated request to the client and await its response.
93
+ *
94
+ * MCP is bidirectional: the server can ask the client questions too. We use
95
+ * this for `roots/list` — the spec-blessed way to learn the workspace root
96
+ * when the client didn't pass one in `initialize` (see issue #196). Rejects
97
+ * on timeout so callers can fall back rather than hang forever.
98
+ */
99
+ request(method: string, params?: unknown, timeoutMs?: number): Promise<unknown>;
100
+ send(response: JsonRpcResponse): void;
101
+ notify(method: string, params?: unknown): void;
102
+ sendResult(id: string | number, result: unknown): void;
103
+ sendError(id: string | number | null, code: number, message: string, data?: unknown): void;
104
+ /**
105
+ * Fail any in-flight server-initiated requests so their awaiters don't hang.
106
+ * Called from `stop()` in subclasses.
107
+ */
108
+ protected rejectPending(reason: string): void;
109
+ /**
110
+ * Handle an incoming line of JSON. Both transports feed lines here.
111
+ */
112
+ protected handleLine(line: string): Promise<void>;
113
+ /**
114
+ * Resolve (or reject) the pending server-initiated request matching this
115
+ * response's id. Unknown ids are ignored — the client may echo something we
116
+ * never sent, or a request may have already timed out.
117
+ */
118
+ private handleResponse;
119
+ /**
120
+ * Check if message is a valid JSON-RPC 2.0 message
121
+ */
122
+ private isValidMessage;
123
+ }
124
+ export interface StdioTransportOptions {
125
+ /**
126
+ * If true, the transport calls `process.exit(0)` when stdin closes. Set to
127
+ * `false` in shared-daemon mode where the stdio "session" is just *one* of
128
+ * many clients — losing it shouldn't drag the daemon down. The default
129
+ * (true) matches the original single-process behavior callers rely on.
130
+ */
131
+ exitOnClose?: boolean;
132
+ /**
133
+ * Optional callback fired when the stdin stream closes. The daemon uses
134
+ * this to decrement its connected-clients refcount.
135
+ */
136
+ onClose?: () => void;
137
+ }
138
+ /**
139
+ * Stdio Transport for MCP
140
+ *
141
+ * Reads JSON-RPC messages from stdin and writes responses to stdout. Used by
142
+ * the direct (single-process) MCP server path, where the MCP host launches
143
+ * one server per session and talks to it over the child's stdio. Also used by
144
+ * shared-daemon mode for the launcher's session (with `exitOnClose: false`)
145
+ * so the daemon outlives its launcher.
146
+ */
147
+ export declare class StdioTransport extends LineBasedJsonRpcTransport {
148
+ private rl;
149
+ private opts;
150
+ constructor(opts?: StdioTransportOptions);
151
+ start(handler: MessageHandler): void;
152
+ stop(): void;
153
+ protected write(line: string): void;
154
+ protected idPrefix(): string;
155
+ }
156
+ /**
157
+ * Socket Transport for MCP daemon sessions.
158
+ *
159
+ * Wraps a single `net.Socket` (Unix domain socket on POSIX, named pipe on
160
+ * Windows). One instance per connected MCP client. Unlike {@link StdioTransport},
161
+ * `stop()` and stream-close *don't* call `process.exit` — a daemon-side session
162
+ * ending must not bring down the whole daemon.
163
+ */
164
+ export declare class SocketTransport extends LineBasedJsonRpcTransport {
165
+ private socket;
166
+ private prefix;
167
+ private buffer;
168
+ private closeHandlers;
169
+ constructor(socket: Socket, prefix?: string);
170
+ /**
171
+ * Register a callback fired exactly once when the socket closes (from either
172
+ * side). Used by the daemon to decrement its connected-clients refcount.
173
+ */
174
+ onClose(handler: () => void): void;
175
+ start(handler: MessageHandler): void;
176
+ stop(): void;
177
+ /**
178
+ * Write a one-shot line directly to the socket (no JSON-RPC framing applied
179
+ * by this class — caller produces the line). The daemon uses this for the
180
+ * hello/handshake line that precedes the JSON-RPC stream.
181
+ */
182
+ writeRaw(line: string): void;
183
+ protected write(line: string): void;
184
+ protected idPrefix(): string;
185
+ private handleSocketClose;
186
+ }
187
+ export {};
188
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Resolved package version, computed once at module load.
3
+ *
4
+ * The version string is the rendezvous datum between cooperating daemon and
5
+ * proxy processes: the daemon advertises its version in the hello line, and
6
+ * the proxy refuses to share IPC across a mismatch (falls back to direct
7
+ * mode). Keeping the resolution in one place avoids drift between the CLI
8
+ * `--version` output (which reads `package.json` directly) and the daemon
9
+ * handshake.
10
+ *
11
+ * Resolution strategy: read the bundled `package.json` two levels up from
12
+ * this file — same relative position whether we're loaded from `src/mcp/` or
13
+ * the `dist/mcp/` output, since `tsc` preserves the layout. If reading fails
14
+ * (e.g. the package was unpacked oddly), fall back to "0.0.0-unknown" — a
15
+ * sentinel that will never match a real version, so the proxy harmlessly
16
+ * falls back to direct mode.
17
+ */
18
+ export declare const CodeGraphPackageVersion: string;
19
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1,10 @@
1
+ import type { QueryBuilder } from '../db/queries';
2
+ import type { ResolutionContext } from './types';
3
+ /**
4
+ * Synthesize dispatcher→callback edges (field observers + EventEmitters +
5
+ * React re-render + JSX children + Vue templates + RN event channel +
6
+ * Fabric native-impl + MyBatis Java↔XML + Gin middleware chain). Returns the
7
+ * count added. Never throws into indexing — callers wrap in try/catch.
8
+ */
9
+ export declare function synthesizeCallbackEdges(queries: QueryBuilder, ctx: ResolutionContext): number;
10
+ //# sourceMappingURL=callback-synthesizer.d.ts.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Cargo Workspace Resolver Helper
3
+ *
4
+ * Parses a project's root Cargo.toml and member crate manifests to
5
+ * build a crate-name -> member-directory map. Used by the Rust
6
+ * resolver to resolve `use crate_name::...` references that point
7
+ * into workspace member crates.
8
+ */
9
+ import { ResolutionContext } from '../types';
10
+ /**
11
+ * Build a map from crate-name aliases to workspace member directory paths.
12
+ * Example: "mytool-core" and "mytool_core" -> "crates/mytool-core"
13
+ *
14
+ * Supports glob members (e.g. `members = ["crates/*"]`) via picomatch
15
+ * when the context exposes `listDirectories`.
16
+ */
17
+ export declare function getCargoWorkspaceCrateMap(context: ResolutionContext): Map<string, string>;
18
+ //# sourceMappingURL=cargo-workspace.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * C# Framework Resolver
3
+ *
4
+ * Handles ASP.NET Core, ASP.NET MVC, and common C# patterns.
5
+ */
6
+ import { FrameworkResolver } from '../types';
7
+ export declare const aspnetResolver: FrameworkResolver;
8
+ //# sourceMappingURL=csharp.d.ts.map