@colbymchenry/codegraph 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.
Files changed (47) hide show
  1. package/README.md +100 -17
  2. package/dist/bin/codegraph.d.ts +1 -0
  3. package/dist/db/migrations.d.ts +1 -1
  4. package/dist/db/queries.d.ts +43 -0
  5. package/dist/db/sqlite-adapter.d.ts +7 -0
  6. package/dist/directory.d.ts +34 -2
  7. package/dist/extraction/astro-extractor.d.ts +79 -0
  8. package/dist/extraction/extraction-version.d.ts +25 -0
  9. package/dist/extraction/function-ref.d.ts +118 -0
  10. package/dist/extraction/grammars.d.ts +7 -1
  11. package/dist/extraction/index.d.ts +34 -0
  12. package/dist/extraction/languages/c-cpp.d.ts +8 -0
  13. package/dist/extraction/languages/csharp.d.ts +22 -0
  14. package/dist/extraction/languages/r.d.ts +3 -0
  15. package/dist/extraction/languages/typescript.d.ts +13 -0
  16. package/dist/extraction/liquid-extractor.d.ts +7 -0
  17. package/dist/extraction/razor-extractor.d.ts +42 -0
  18. package/dist/extraction/tree-sitter-types.d.ts +33 -0
  19. package/dist/extraction/tree-sitter.d.ts +211 -0
  20. package/dist/extraction/vue-extractor.d.ts +15 -0
  21. package/dist/index.d.ts +34 -2
  22. package/dist/installer/instructions-template.d.ts +34 -11
  23. package/dist/installer/targets/opencode.d.ts +9 -1
  24. package/dist/installer/targets/shared.d.ts +14 -0
  25. package/dist/mcp/daemon.d.ts +60 -1
  26. package/dist/mcp/dynamic-boundaries.d.ts +41 -0
  27. package/dist/mcp/ppid-watchdog.d.ts +44 -0
  28. package/dist/mcp/proxy.d.ts +6 -0
  29. package/dist/mcp/server-instructions.d.ts +12 -1
  30. package/dist/mcp/session.d.ts +2 -0
  31. package/dist/mcp/stdin-teardown.d.ts +27 -0
  32. package/dist/mcp/tools.d.ts +71 -0
  33. package/dist/resolution/callback-synthesizer.d.ts +3 -3
  34. package/dist/resolution/frameworks/astro.d.ts +9 -0
  35. package/dist/resolution/frameworks/index.d.ts +1 -0
  36. package/dist/resolution/import-resolver.d.ts +10 -0
  37. package/dist/resolution/index.d.ts +80 -0
  38. package/dist/resolution/name-matcher.d.ts +61 -0
  39. package/dist/resolution/types.d.ts +27 -3
  40. package/dist/resolution/workspace-packages.d.ts +48 -0
  41. package/dist/search/query-utils.d.ts +17 -1
  42. package/dist/sync/watcher.d.ts +124 -32
  43. package/dist/telemetry/index.d.ts +146 -0
  44. package/dist/types.d.ts +17 -2
  45. package/dist/upgrade/index.d.ts +132 -0
  46. package/dist/utils.d.ts +30 -24
  47. package/package.json +7 -7
@@ -2,10 +2,18 @@
2
2
  * opencode target.
3
3
  *
4
4
  * - MCP server entry to `~/.config/opencode/opencode.jsonc` (global,
5
- * XDG-style; `%APPDATA%/opencode/opencode.jsonc` on Windows) or
5
+ * XDG-style on EVERY platform, Windows included — see below) or
6
6
  * `./opencode.jsonc` (local). Falls back to `opencode.json` when a
7
7
  * `.json` file already exists; defaults new installs to `.jsonc`
8
8
  * because that's what opencode itself creates on first run.
9
+ *
10
+ * opencode resolves its config dir with the `xdg-basedir` package
11
+ * (sst/opencode `packages/core/src/global.ts`): `XDG_CONFIG_HOME`
12
+ * if set, else `~/.config` — unconditionally, on all platforms. It
13
+ * never reads `%APPDATA%`; that layout belonged to the discontinued
14
+ * Go fork. We previously wrote there on Windows, so opencode never
15
+ * saw the entry (#535) — install/uninstall now also sweep a stale
16
+ * codegraph entry out of the legacy `%APPDATA%/opencode` location.
9
17
  * - Instructions to `~/.config/opencode/AGENTS.md` (global) or
10
18
  * `./AGENTS.md` (local). opencode reads AGENTS.md for agent
11
19
  * instructions — same convention Codex CLI uses.
@@ -64,6 +64,20 @@ export declare function jsonDeepEqual(a: unknown, b: unknown): boolean;
64
64
  * existing block already matches `body`.
65
65
  */
66
66
  export declare function replaceOrAppendMarkedSection(filePath: string, body: string, startMarker: string, endMarker: string): 'created' | 'updated' | 'appended' | 'unchanged';
67
+ /**
68
+ * Upsert the CodeGraph instructions block into an agent instructions
69
+ * file (CLAUDE.md / AGENTS.md / GEMINI.md). The one write shared by
70
+ * every target: self-heals a stale pre-#529 long block (markers match →
71
+ * replaced by the current short one), appends after existing user
72
+ * content otherwise, and reports `unchanged` on byte-equal re-runs so
73
+ * install stays idempotent. See `instructions-template.ts` for why this
74
+ * block exists (#704: subagents + non-MCP harnesses never see the MCP
75
+ * initialize instructions).
76
+ */
77
+ export declare function upsertInstructionsEntry(file: string): {
78
+ path: string;
79
+ action: 'created' | 'updated' | 'unchanged';
80
+ };
67
81
  /**
68
82
  * Inverse of `replaceOrAppendMarkedSection`. Strips the marker
69
83
  * block from `filePath` if present. If the file becomes empty after
@@ -54,6 +54,20 @@ export interface DaemonHello {
54
54
  socketPath: string;
55
55
  protocol: 1;
56
56
  }
57
+ /**
58
+ * Optional reverse-handshake line a proxy sends right after it verifies the
59
+ * daemon hello, carrying its own pids so the daemon can reap the client if its
60
+ * process dies WITHOUT the socket ever signalling close (the Windows named-pipe
61
+ * hazard behind #692). Entirely optional and fail-safe: a connection that never
62
+ * sends it (a legacy/direct client) just falls back to the socket-close
63
+ * lifecycle. The `codegraph_client` marker is what tells it apart from the
64
+ * client's first JSON-RPC message.
65
+ */
66
+ export interface DaemonClientHello {
67
+ codegraph_client: 1;
68
+ pid: number;
69
+ hostPid: number | null;
70
+ }
57
71
  export interface DaemonStartResult {
58
72
  /** Always-non-null for a successfully-started daemon. */
59
73
  socketPath: string;
@@ -75,14 +89,21 @@ export declare class Daemon {
75
89
  private projectRoot;
76
90
  private server;
77
91
  private clients;
92
+ /** Per-client peer pids from the optional client-hello, for the liveness sweep. */
93
+ private clientPeers;
78
94
  private idleTimer;
79
95
  private idleTimeoutMs;
96
+ private maxIdleMs;
97
+ private lastActivityAt;
98
+ private maxIdleTimer;
99
+ private clientSweepTimer;
80
100
  private engine;
81
101
  private stopping;
82
102
  private socketPath;
83
103
  private pidPath;
84
104
  constructor(projectRoot: string, opts?: {
85
105
  idleTimeoutMs?: number;
106
+ maxIdleMs?: number;
86
107
  });
87
108
  /**
88
109
  * Bind the socket, kick off engine init, and register signal handlers. The
@@ -101,6 +122,26 @@ export declare class Daemon {
101
122
  private dropClient;
102
123
  private armIdleTimer;
103
124
  private disarmIdleTimer;
125
+ /**
126
+ * Defense-in-depth against a daemon that outlives its clients (#692), for the
127
+ * cases the refcount + idle timer miss because a socket close never arrives:
128
+ * - **Inactivity backstop:** exit if no inbound traffic for `maxIdleMs` while
129
+ * clients are still (nominally) connected. A phantom client sends nothing,
130
+ * so it can't pin the daemon past this window.
131
+ * - **Liveness sweep:** drop any client whose peer process has died (per the
132
+ * client-hello pids), which re-arms the idle timer once the last real
133
+ * client is gone. Catches a dead peer within one sweep instead of waiting
134
+ * out the whole backstop.
135
+ * Both timers are unref'd — the listening server keeps the loop alive, and
136
+ * neither should hold it open on its own.
137
+ */
138
+ private startLivenessTimers;
139
+ /**
140
+ * Drop every connected client whose peer process is gone. Returns the count
141
+ * reaped. `isAlive` is injected for testing. Clients with unknown pids (no
142
+ * client-hello) are skipped — they rely on the socket-close path.
143
+ */
144
+ reapDeadClients(isAlive: (pid: number) => boolean): number;
104
145
  private cleanupLockfile;
105
146
  }
106
147
  /**
@@ -128,7 +169,7 @@ export type AcquireResult = {
128
169
  * the file existed but was empty; under concurrent daemon startup a third
129
170
  * candidate could read that empty file, decode it as `null`, and `unlink` the
130
171
  * winner's lock → two daemons (two watchers, two writers). The window was
131
- * normally too small to hit, but the chokidar watcher's extra startup time made
172
+ * normally too small to hit, but the file watcher's extra startup time made
132
173
  * concurrent daemons overlap enough to reproduce it reliably.
133
174
  *
134
175
  * The fix writes the complete record to a private temp file, then hard-links it
@@ -156,6 +197,24 @@ export declare function clearStaleDaemonLock(pidPath: string, expectedDeadPid?:
156
197
  * mistake a live daemon for a dead one and clear its lock.
157
198
  */
158
199
  export declare function isProcessAlive(pid: number): boolean;
200
+ /**
201
+ * Parse one client-hello line. Returns the peer pids if `line` is a well-formed
202
+ * client-hello (carries the `codegraph_client` marker), or null otherwise — in
203
+ * which case the caller treats the bytes as ordinary JSON-RPC.
204
+ */
205
+ export declare function parseClientHelloLine(line: string): {
206
+ pid: number;
207
+ hostPid: number | null;
208
+ } | null;
209
+ /**
210
+ * A client's peer is dead when its proxy process is gone, or when its known
211
+ * host process is gone. Unknown pid (no client-hello) is never "dead" on this
212
+ * basis — those clients rely on the socket-close path. Exported for testing.
213
+ */
214
+ export declare function peerIsDead(peers: {
215
+ pid: number | null;
216
+ hostPid: number | null;
217
+ }, isAlive: (pid: number) => boolean): boolean;
159
218
  /** Exported for test stubs that need to bound the hello-line read. */
160
219
  export { MAX_HELLO_LINE_BYTES };
161
220
  //# sourceMappingURL=daemon.d.ts.map
@@ -0,0 +1,41 @@
1
+ export interface BoundaryMatch {
2
+ /** Stable form id, e.g. 'computed-call' — used for per-form dedupe. */
3
+ form: string;
4
+ /** Human label for the dispatch form, e.g. 'computed member call'. */
5
+ label: string;
6
+ /** One-line source snippet of the site (from the original, untrimmed text). */
7
+ snippet: string;
8
+ /** 1-based line within the scanned body's FILE (absolute, ready to print). */
9
+ line: number;
10
+ /**
11
+ * Statically-visible dispatch key, when one exists: the string literal in
12
+ * `handlers['save']`, the `:symbol` in ruby `send`, the type name in
13
+ * `Send(new CreateCmd(...))`. Drives candidate lookup. Undefined when the
14
+ * key is a runtime value (variable, computed expression).
15
+ */
16
+ key?: string;
17
+ /** For typed-bus matches the key is a TYPE name (candidates ~ `${key}Handler`). */
18
+ keyIsType?: boolean;
19
+ /** Additional sites of the same form+key in this body beyond the reported one. */
20
+ moreSites?: number;
21
+ }
22
+ /**
23
+ * Blank the CONTENTS of string literals (quotes preserved, offsets preserved)
24
+ * so dispatch-shaped prose — docs, error messages, template text — can't fire
25
+ * a matcher. Run AFTER comment stripping (comments are already spaces).
26
+ * Backslash escapes are honored; `'`/`"` strings end at a newline (treated as
27
+ * unterminated, matching the comment stripper); backticks span lines, and
28
+ * `${...}` interpolations inside them are blanked too — missing a dispatch
29
+ * inside a template literal is acceptable, false-firing on prose is not.
30
+ */
31
+ export declare function blankStringContents(text: string): string;
32
+ /**
33
+ * Scan one symbol's body for dynamic-dispatch sites.
34
+ *
35
+ * @param body the symbol's source text (sliced from the file)
36
+ * @param language Node.language of the symbol
37
+ * @param fileStartLine 1-based line where `body` starts in its file — returned
38
+ * line numbers are absolute file lines.
39
+ */
40
+ export declare function scanDynamicDispatch(body: string, language: string, fileStartLine: number): BoundaryMatch[];
41
+ //# sourceMappingURL=dynamic-boundaries.d.ts.map
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Shared decision logic for the PPID watchdog (#277, #692).
3
+ *
4
+ * The watchdog's job: notice that the process we depend on — our parent, or the
5
+ * MCP host reached past an intermediate launcher — has died, so an orphaned
6
+ * proxy / direct server shuts itself down instead of leaking forever.
7
+ *
8
+ * Parent death surfaces differently per OS, and getting this wrong is what
9
+ * caused the unbounded daemon/proxy leak on Windows (#692, #576):
10
+ *
11
+ * - **POSIX** reparents an orphan to init (pid 1), so `process.ppid` *changes*
12
+ * the instant the parent dies. That divergence is the classic #277 signal.
13
+ * - **Windows** never reparents: `process.ppid` keeps reporting the original
14
+ * (now-dead) parent forever, so the change-check can never fire. There we
15
+ * must poll the original parent's *liveness* instead.
16
+ *
17
+ * The liveness fallback is deliberately gated to Windows. On POSIX a
18
+ * double-forked grandparent can legitimately outlive the reparent, so a dead
19
+ * `originalPpid` is not proof of orphaning there — the change-check is the
20
+ * correct and sufficient POSIX signal, and using liveness too would risk a
21
+ * false-positive shutdown.
22
+ */
23
+ export interface SupervisionState {
24
+ /** `process.ppid` captured at startup. */
25
+ originalPpid: number;
26
+ /** `process.ppid` right now. */
27
+ currentPpid: number;
28
+ /**
29
+ * The MCP host pid threaded past an intermediate launcher
30
+ * (`CODEGRAPH_HOST_PPID`), or null when unknown — e.g. the standalone bundle,
31
+ * which pre-bakes `--liftoff-only` and so never runs the relaunch that sets it.
32
+ */
33
+ hostPpid: number | null;
34
+ /** Liveness probe — `process.kill(pid, 0)` in production, stubbed in tests. */
35
+ isAlive: (pid: number) => boolean;
36
+ /** Defaults to `process.platform`. */
37
+ platform?: NodeJS.Platform;
38
+ }
39
+ /**
40
+ * Returns a human-readable reason string when the process has lost its
41
+ * supervisor and should shut down, or null while it is still supervised.
42
+ */
43
+ export declare function supervisionLostReason(state: SupervisionState): string | null;
44
+ //# sourceMappingURL=ppid-watchdog.d.ts.map
@@ -18,7 +18,13 @@
18
18
  * the direct-mode server uses; see issue #277.
19
19
  */
20
20
  import * as net from 'net';
21
+ import { DaemonHello } from './daemon';
21
22
  import type { MCPEngine } from './engine';
23
+ /**
24
+ * Log a successful daemon attach — gated behind {@link LOG_ATTACH_ENV} so it is
25
+ * silent by default (see #618). Exported for tests.
26
+ */
27
+ export declare function logAttachedDaemon(socketPath: string, hello: DaemonHello): void;
22
28
  export interface ProxyResult {
23
29
  /**
24
30
  * `proxied` — successfully attached to a same-version daemon and piped
@@ -15,5 +15,16 @@
15
15
  * burn tokens. Reference only tools that exist on `main`; gate any
16
16
  * conditional tools behind feature checks if/when they ship.
17
17
  */
18
- export declare const SERVER_INSTRUCTIONS = "# Codegraph \u2014 code intelligence over an indexed knowledge graph\n\nCodegraph is a SQLite knowledge graph of every symbol, edge, and file\nin the workspace. Reads are sub-millisecond; the index lags writes by\nabout a second through the file watcher. Consult it BEFORE writing or\nediting code, not during.\n\n## Answer directly \u2014 don't delegate exploration\n\nFor \"how does X work\", architecture, trace, or where-is-X questions,\nanswer DIRECTLY \u2014 usually with ONE `codegraph_explore` call.\n`codegraph_explore` takes either a natural-language question or a bag of\nsymbol/file names and returns the verbatim source of the relevant symbols\ngrouped by file, so it is Read-equivalent and most often the ONLY\ncodegraph call you need. Codegraph IS the pre-built search index \u2014 so\ndelegating the lookup to a separate file-reading sub-task/agent, or\nrunning your own grep + read loop, repeats work codegraph already did and\ncosts more for the same answer. Reach for raw Read/Grep only to confirm a\nspecific detail codegraph didn't cover. A direct codegraph answer is\ntypically one to a few calls; a grep/read exploration is dozens.\n\n## Tool selection by intent\n\n- **Almost any question \u2014 \"how does X work\", architecture, a bug, \"what/where is X\", or surveying an area** \u2192 `codegraph_explore` (PRIMARY \u2014 call FIRST; ONE capped call returns the verbatim source of the relevant symbols grouped by file; most often the ONLY call you need)\n- **\"How does X reach/become Y? / the flow / the path from X to Y\"** \u2192 `codegraph_explore`, naming the symbols that span the flow (e.g. `mutateElement renderScene`) \u2014 it surfaces the call path among them, including dynamic-dispatch hops (callbacks, React re-render, JSX children) grep can't follow\n- **\"What is the symbol named X?\" (just its location)** \u2192 `codegraph_search`\n- **\"What calls this?\" / \"What does this call?\" / \"What would changing this break?\"** \u2192 `codegraph_callers` / `codegraph_callees` / `codegraph_impact`\n- **One specific symbol's full source (esp. a body `codegraph_explore` trimmed), or an OVERLOADED name** \u2192 `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\n- **\"What's in directory X?\"** \u2192 `codegraph_files`\n- **\"Is the index ready / what's its size?\"** \u2192 `codegraph_status`\n\n## Common chains\n\n- **Flow / \"how does X reach Y\"**: ONE `codegraph_explore` with the symbol names spanning the flow \u2014 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`.\n- **Onboarding / understanding any area**: ONE `codegraph_explore` is usually the whole answer. Only follow up \u2014 `codegraph_node` for a specific symbol \u2014 if something is still unclear.\n- **Refactor planning**: `codegraph_search` \u2192 `codegraph_callers` \u2192 `codegraph_impact`. The blast-radius answer comes from impact, not from walking callers manually.\n- **Debugging a regression**: `codegraph_callers` of the suspected symbol; widen with `codegraph_impact` if an unexpected call appears.\n\n## Anti-patterns\n\n- **Trust codegraph's results \u2014 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.\n- **Don't grep first** when looking up a symbol by name \u2014 `codegraph_search` is faster and returns kind + location + signature.\n- **Don't chain `codegraph_search` + `codegraph_node`** to understand an area \u2014 ONE `codegraph_explore` returns the relevant symbols' source together in a single round-trip.\n- **Don't loop `codegraph_node` over many symbols** \u2014 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.\n- **After editing, check the staleness banner.** When a tool response starts with \"\u26A0\uFE0F Some files referenced below were edited since the last index sync\u2026\", the listed files are pending re-index \u2014 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\".\n\n## Limitations\n\n- If a tool reports the project isn't initialized, `.codegraph/` doesn't exist yet \u2014 offer to run `codegraph init -i` to build the index.\n- Index lags file writes by ~1 second.\n- Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.\n- No live correctness validation \u2014 that's still the TypeScript compiler / test suite / linter's job. Codegraph supplements those with structural context they don't have.\n";
18
+ export declare const SERVER_INSTRUCTIONS = "# Codegraph \u2014 code intelligence over an indexed knowledge graph\n\nCodegraph is a SQLite knowledge graph of every symbol, edge, and file in\nthe workspace \u2014 pre-computed structure you would otherwise re-derive by\nreading files (cached intelligence: thousands of parse/trace decisions you\ndon't pay to re-reason each run). Reads are sub-millisecond; the index lags\nwrites by ~1s through the file watcher. Reach for it BEFORE *and* while\nwriting or editing code \u2014 not just for questions: one call returns the\nverbatim source PLUS who calls it and what it affects, so you edit with the\nblast radius in view. More accurate context, in far fewer tokens and\nround-trips than reading files yourself.\n\n## Use codegraph instead of reading files \u2014 for questions AND edits\n\nWhether you're answering \"how does X work\" or implementing a change (fixing\na bug, adding a feature), reach for codegraph before you Read. For\nunderstanding, answer DIRECTLY \u2014 usually with ONE `codegraph_explore` call.\n`codegraph_explore` takes either a natural-language question or a bag of\nsymbol/file names and returns the verbatim source of the relevant symbols\ngrouped by file, so it is Read-equivalent and most often the ONLY\ncodegraph call you need. Codegraph IS the pre-built search index \u2014 so\ndelegating the lookup to a separate file-reading sub-task/agent, or\nrunning your own grep + read loop, repeats work codegraph already did and\ncosts more for the same answer. Reach for raw Read/Grep only to confirm a\nspecific detail codegraph didn't cover. A direct codegraph answer is\ntypically one to a few calls; a grep/read exploration is dozens.\n\n## Tool selection by intent\n\n- **Almost any question \u2014 \"how does X work\", architecture, a bug, \"what/where is X\", or surveying an area** \u2192 `codegraph_explore` (PRIMARY \u2014 call FIRST; ONE capped call returns the verbatim source of the relevant symbols grouped by file; most often the ONLY call you need)\n- **\"How does X reach/become Y? / the flow / the path from X to Y\"** \u2192 `codegraph_explore`, naming the symbols that span the flow (e.g. `mutateElement renderScene`) \u2014 it surfaces the call path among them, including dynamic-dispatch hops (callbacks, React re-render, JSX children) grep can't follow\n- **\"What is the symbol named X?\" (just its location)** \u2192 `codegraph_search`\n- **\"What calls this?\" / \"What would changing this break?\"** \u2192 `codegraph_callers` \u2014 EVERY call site with file:line, including where a function is **registered as a callback** (passed as an argument, assigned to a function pointer/field, listed in a handler table) \u2014 labeled \"via callback registration\" \u2014 so a function with no direct calls is NOT dead if it's wired up somewhere. When several UNRELATED symbols share a name (one `UserService` per monorepo app), it reports **one section per definition** (never a merged list) \u2014 pass `file` to focus the definition you mean. The wider blast radius arrives automatically on `codegraph_explore` (its \"Blast radius\" section) and `codegraph_node` (the dependents note)\n- **\"What does this call?\"** \u2192 `codegraph_node` with that symbol and `includeCode: true` \u2014 the body IS the callee list, and the caller/callee trail comes with it\n- **Reading a source FILE (any time you'd use the `Read` tool)** \u2192 `codegraph_node` with a `file` path and no `symbol`. It returns the file's **current source with line numbers \u2014 the same `<n>\\t<line>` shape `Read` gives you, safe to `Edit` from** \u2014 narrowable with `offset`/`limit` exactly like `Read`, PLUS a one-line note of which files depend on it. Same bytes as `Read`, faster (served from the index), with the blast radius attached. Use it **instead of `Read`** for indexed source files; fall back to `Read` only for what codegraph doesn't index (configs, docs). Pass `symbolsOnly: true` for just the file's structure.\n- **About to read or edit a symbol you can name** \u2192 `codegraph_node` with that `symbol` (SECONDARY \u2014 the after-explore depth tool): the verbatim source (`includeCode: true`) PLUS its caller/callee trail, so before changing it you see what calls it and what your edit would break. For an OVERLOADED name it returns EVERY matching definition's body in one call, so you never Read a file to find the right overload\n\n## Common chains\n\n- **Flow / \"how does X reach Y\"**: ONE `codegraph_explore` with the symbol names spanning the flow \u2014 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`.\n- **Onboarding / understanding any area**: ONE `codegraph_explore` is usually the whole answer. Only follow up \u2014 `codegraph_node` for a specific symbol \u2014 if something is still unclear.\n- **Refactor planning**: `codegraph_callers` for the complete call-site list to update; the wider blast radius is already attached to `codegraph_explore` / `codegraph_node` output.\n- **Debugging a regression**: `codegraph_callers` of the suspected symbol; `codegraph_node` on anything unexpected that appears.\n\n## Anti-patterns\n\n- **Trust codegraph's results \u2014 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.\n- **Don't grep first** when looking up a symbol by name \u2014 `codegraph_search` is faster and returns kind + location + signature.\n- **Don't chain `codegraph_search` + `codegraph_node`** to understand an area \u2014 ONE `codegraph_explore` returns the relevant symbols' source together in a single round-trip.\n- **Don't loop `codegraph_node` over many symbols** \u2014 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.\n- **Don't reach for the `Read` tool on an indexed source file** \u2014 `codegraph_node` with a `file` reads it for you (same `<n>\\t<line>` source, `offset`/`limit` like Read, faster, with its blast radius), and with a `symbol` it returns the source plus the caller/callee trail. Reach for raw `Read` only for what codegraph doesn't index (configs, docs) or when the staleness banner flags a file as pending re-index.\n- **After editing, check the staleness banner.** When a tool response starts with \"\u26A0\uFE0F Some files referenced below were edited since the last index sync\u2026\", the listed files are pending re-index \u2014 Read those specific files for accurate content. Every file NOT in that banner is fresh, so still trust codegraph.\n\n## Limitations\n\n- If a tool reports a project isn't indexed (no `.codegraph/`), stop calling codegraph tools for that project for the rest of the session and use your built-in tools there instead. Indexing is the user's decision \u2014 mention they can run `codegraph init` if it comes up, but don't run it yourself.\n- Index lags file writes by ~1 second.\n- Cross-file resolution is best-effort name matching; ambiguous calls may return multiple candidates.\n- No live correctness validation \u2014 that's still the TypeScript compiler / test suite / linter's job. Codegraph supplements those with structural context they don't have.\n";
19
+ /**
20
+ * Instructions variant sent when the workspace has NO codegraph index.
21
+ *
22
+ * Sending the full playbook ("lean on codegraph for everything") into a
23
+ * session where every call would fail wastes the agent's calls and — worse —
24
+ * the failures teach it codegraph is broken. The unindexed variant is a
25
+ * short, unambiguous "inactive this session" note; `tools/list` is gated to
26
+ * empty in the same state, so the agent has nothing to mis-call. Indexing is
27
+ * deliberately left to the user: the agent is told NOT to run init itself.
28
+ */
29
+ export declare const SERVER_INSTRUCTIONS_UNINDEXED = "# Codegraph \u2014 inactive (workspace not indexed)\n\nThis workspace has no codegraph index (no `.codegraph/` directory), so no\ncodegraph tools are available this session. Work with your built-in tools as\nusual.\n\nIndexing is the user's decision \u2014 do not run it yourself. If the user asks\nabout codegraph, they can enable it by running `codegraph init` in the\nproject root and starting a new session.\n";
19
30
  //# sourceMappingURL=server-instructions.d.ts.map
@@ -39,6 +39,8 @@ export declare class MCPSession {
39
39
  private transport;
40
40
  private engine;
41
41
  private clientSupportsRoots;
42
+ /** From the initialize handshake — attributes usage rollups to the agent host. */
43
+ private clientInfo;
42
44
  private rootsAttempted;
43
45
  private resolvePromise;
44
46
  private explicitProjectPath;
@@ -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
@@ -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
@@ -2,9 +2,9 @@ import type { QueryBuilder } from '../db/queries';
2
2
  import type { ResolutionContext } from './types';
3
3
  /**
4
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.
5
+ * React re-render + JSX children + Vue templates + SvelteKit load + RN event
6
+ * channel + Fabric native-impl + MyBatis Java↔XML + Gin middleware chain).
7
+ * Returns the count added. Never throws into indexing — callers wrap in try/catch.
8
8
  */
9
9
  export declare function synthesizeCallbackEdges(queries: QueryBuilder, ctx: ResolutionContext): number;
10
10
  //# sourceMappingURL=callback-synthesizer.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Astro Framework Resolver
3
+ *
4
+ * Handles Astro component references, the `Astro` global, `astro:*` virtual
5
+ * module imports, and Astro's `src/pages/` file-based routing.
6
+ */
7
+ import { FrameworkResolver } from '../types';
8
+ export declare const astroResolver: FrameworkResolver;
9
+ //# sourceMappingURL=astro.d.ts.map
@@ -33,6 +33,7 @@ export { nestjsResolver } from './nestjs';
33
33
  export { reactResolver } from './react';
34
34
  export { svelteResolver } from './svelte';
35
35
  export { vueResolver } from './vue';
36
+ export { astroResolver } from './astro';
36
37
  export { djangoResolver, flaskResolver, fastapiResolver } from './python';
37
38
  export { railsResolver } from './ruby';
38
39
  export { springResolver } from './java';
@@ -27,6 +27,16 @@ export declare function clearCppIncludeDirCache(): void;
27
27
  * Returns paths relative to projectRoot.
28
28
  */
29
29
  export declare function loadCppIncludeDirs(projectRoot: string): string[];
30
+ /**
31
+ * Is this reference a PHP include/require PATH (vs a namespace `use` symbol)?
32
+ *
33
+ * include/require emit a file path ("lib.php", "inc/db.php", "../x.php"),
34
+ * whereas namespace use is an FQN (App\Foo\Bar) or a bare class symbol
35
+ * (Closure). PHP identifiers contain neither '/' nor '.', so a slash or dot
36
+ * marks a path-shaped include. Such references resolve to files only — never
37
+ * to a same-named symbol — so callers must not fall back to the name-matcher.
38
+ */
39
+ export declare function isPhpIncludePathRef(ref: UnresolvedRef): boolean;
30
40
  /**
31
41
  * Extract import mappings from a file
32
42
  */
@@ -17,6 +17,9 @@ export declare class ReferenceResolver {
17
17
  private queries;
18
18
  private context;
19
19
  private frameworks;
20
+ private deferredChainRefs;
21
+ private deferredThisMemberRefs;
22
+ private razorUsingsCache;
20
23
  private nodeCache;
21
24
  private fileCache;
22
25
  private importMappingCache;
@@ -29,6 +32,7 @@ export declare class ReferenceResolver {
29
32
  private cachesWarmed;
30
33
  private projectAliases;
31
34
  private goModule;
35
+ private workspacePackages;
32
36
  constructor(projectRoot: string, queries: QueryBuilder);
33
37
  /**
34
38
  * Initialize the resolver (detect frameworks, etc.)
@@ -86,6 +90,20 @@ export declare class ReferenceResolver {
86
90
  * Resolve and persist edges to database
87
91
  */
88
92
  resolveAndPersist(unresolvedRefs: UnresolvedReference[], onProgress?: (current: number, total: number) => void): ResolutionResult;
93
+ /**
94
+ * Second resolution pass for chained static-factory / fluent calls whose
95
+ * chained method is defined on a SUPERTYPE the receiver's type conforms to —
96
+ * a protocol-extension / inherited / default-interface method (#750). The
97
+ * first pass can't resolve these because `implements`/`extends` edges aren't
98
+ * built yet; this runs AFTER edges are persisted, so `context.getSupertypes`
99
+ * (and the conformance fallback in resolveMethodOnType) can walk them.
100
+ *
101
+ * Operates only on the leftover unresolved refs that have the `inner().method`
102
+ * chain shape, for the dotted-chain languages — a small set — and is idempotent
103
+ * (re-resolving an already-resolved ref is a no-op since it's been deleted).
104
+ * Returns the number of newly-created edges.
105
+ */
106
+ resolveChainedCallsViaConformance(): number;
89
107
  /**
90
108
  * Resolve and persist in batches to keep memory bounded.
91
109
  * Processes unresolved references in chunks, persisting edges and cleaning
@@ -108,6 +126,68 @@ export declare class ReferenceResolver {
108
126
  * Get language from node ID
109
127
  */
110
128
  private getLanguageFromNodeId;
129
+ /**
130
+ * Drop an import/name-strategy resolution that crosses a language family.
131
+ * Two regimes (mirrors `applyLanguageGate`'s candidate filter):
132
+ * - `references` (type usage): STRICT — a `Type.member` static read names a
133
+ * same-family type, never a coincidentally same-named symbol in another
134
+ * language. Drops any non-same-family target.
135
+ * - `imports` (import binding / `#include`): both-known — a C++ `#include
136
+ * "X.h"` must not resolve to a same-named ObjC header on another platform
137
+ * (basename collision), but a singleton-family / SFC language (`vue` →
138
+ * `.ts`) importing across is left alone.
139
+ * Applies to the import (strategy 2) + name-match (strategy 3) results.
140
+ */
141
+ /**
142
+ * Collect the `@using` namespaces in scope for a `.razor`/`.cshtml` file: its
143
+ * own `@using` directives plus every `_Imports.razor` from the file's folder up
144
+ * to the project root (Razor `_Imports` cascade). Cached per file.
145
+ */
146
+ private getRazorUsings;
147
+ /**
148
+ * Resolve a Razor/Blazor simple type ref through the file's `@using`
149
+ * namespaces: `CatalogBrand` + `@using BlazorShared.Models` → the node whose
150
+ * qualified name is `BlazorShared.Models::CatalogBrand`. Only resolves when the
151
+ * `@using` set yields exactly ONE type (otherwise it stays ambiguous and falls
152
+ * through to name-matching).
153
+ */
154
+ private resolveRazorUsing;
155
+ /**
156
+ * Resolve a `this.<member>` function-as-value reference (#756/#808) to the
157
+ * ENCLOSING CLASS's own member — never a same-named symbol elsewhere. The
158
+ * registration idiom (`btn.on('click', this.handleClick)`) names a member
159
+ * of the class being defined, so the only valid target shares the
160
+ * from-symbol's qualified-name scope. Function/method targets only — a
161
+ * property (a data field, post-#808 classification) yields no edge — same
162
+ * file required, no fallback of any kind.
163
+ */
164
+ private resolveThisMemberFnRef;
165
+ /**
166
+ * Second pass for `this.<member>` refs whose member wasn't on the enclosing
167
+ * class itself (#808): once implements/extends edges exist, walk the
168
+ * class's supertypes (transitively, depth-capped) and resolve the member on
169
+ * the nearest one that declares it — `this.handleSubmit` registered in a
170
+ * subclass resolves to `FormBase::handleSubmit`. Validated targets only
171
+ * (function/method kind, same language family); no match → no edge.
172
+ * Mirrors resolveChainedCallsViaConformance's lifecycle. Returns the number
173
+ * of newly-created edges.
174
+ */
175
+ resolveDeferredThisMemberRefs(): number;
176
+ private gateLanguage;
177
+ /**
178
+ * Drop a FRAMEWORK-strategy resolution that crosses two *known* language
179
+ * families for a type-usage (`references`) or import-binding (`imports`)
180
+ * edge. The framework strategy is intentionally ungated for cross-language
181
+ * bridges, but those legitimate bridges are either `calls` edges (RN/Expo
182
+ * JS → native) or config↔code edges whose config side (`yaml`/`blade`/…) is
183
+ * not a known programming-language family. A `references`/`imports` edge
184
+ * between two *known* families is always a coincidental name collision — the
185
+ * React/Svelte/Vue PascalCase component resolvers name-match `getNodesByName`
186
+ * without a language check, so a TS `<TestRunner>` ref happily matched a
187
+ * Kotlin `class TestRunner`. Gating only the both-known-cross-family case
188
+ * lets config bridges and `calls` bridges through untouched.
189
+ */
190
+ private gateFrameworkLanguage;
111
191
  }
112
192
  /**
113
193
  * Create a reference resolver instance