@colbymchenry/codegraph 0.9.9 โ†’ 1.0.1

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 (52) hide show
  1. package/README.md +120 -24
  2. package/dist/bin/codegraph.d.ts +1 -0
  3. package/dist/bin/fatal-handler.d.ts +20 -0
  4. package/dist/db/migrations.d.ts +1 -1
  5. package/dist/db/queries.d.ts +43 -0
  6. package/dist/db/sqlite-adapter.d.ts +7 -0
  7. package/dist/directory.d.ts +49 -2
  8. package/dist/extraction/astro-extractor.d.ts +79 -0
  9. package/dist/extraction/extraction-version.d.ts +25 -0
  10. package/dist/extraction/function-ref.d.ts +118 -0
  11. package/dist/extraction/grammars.d.ts +7 -1
  12. package/dist/extraction/index.d.ts +34 -0
  13. package/dist/extraction/languages/c-cpp.d.ts +8 -0
  14. package/dist/extraction/languages/csharp.d.ts +22 -0
  15. package/dist/extraction/languages/r.d.ts +3 -0
  16. package/dist/extraction/languages/typescript.d.ts +13 -0
  17. package/dist/extraction/liquid-extractor.d.ts +7 -0
  18. package/dist/extraction/razor-extractor.d.ts +42 -0
  19. package/dist/extraction/tree-sitter-types.d.ts +33 -0
  20. package/dist/extraction/tree-sitter.d.ts +211 -0
  21. package/dist/extraction/vue-extractor.d.ts +15 -0
  22. package/dist/index.d.ts +34 -2
  23. package/dist/installer/instructions-template.d.ts +34 -11
  24. package/dist/installer/targets/opencode.d.ts +9 -1
  25. package/dist/installer/targets/shared.d.ts +14 -0
  26. package/dist/mcp/daemon-manager.d.ts +42 -0
  27. package/dist/mcp/daemon-registry.d.ts +47 -0
  28. package/dist/mcp/daemon.d.ts +60 -1
  29. package/dist/mcp/dynamic-boundaries.d.ts +41 -0
  30. package/dist/mcp/index.d.ts +1 -0
  31. package/dist/mcp/liveness-watchdog.d.ts +18 -0
  32. package/dist/mcp/ppid-watchdog.d.ts +44 -0
  33. package/dist/mcp/proxy.d.ts +6 -0
  34. package/dist/mcp/server-instructions.d.ts +12 -1
  35. package/dist/mcp/session.d.ts +2 -0
  36. package/dist/mcp/stdin-teardown.d.ts +27 -0
  37. package/dist/mcp/tools.d.ts +71 -0
  38. package/dist/resolution/callback-synthesizer.d.ts +3 -3
  39. package/dist/resolution/frameworks/astro.d.ts +9 -0
  40. package/dist/resolution/frameworks/index.d.ts +1 -0
  41. package/dist/resolution/import-resolver.d.ts +10 -0
  42. package/dist/resolution/index.d.ts +80 -0
  43. package/dist/resolution/name-matcher.d.ts +61 -0
  44. package/dist/resolution/types.d.ts +27 -3
  45. package/dist/resolution/workspace-packages.d.ts +48 -0
  46. package/dist/search/query-utils.d.ts +17 -1
  47. package/dist/sync/watcher.d.ts +124 -32
  48. package/dist/telemetry/index.d.ts +146 -0
  49. package/dist/types.d.ts +17 -2
  50. package/dist/upgrade/index.d.ts +132 -0
  51. package/dist/utils.d.ts +30 -24
  52. package/package.json +7 -7
package/README.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  # CodeGraph
4
4
 
5
+ ## ๐ŸŽ‰ 1.0 Released!
6
+
7
+ Already installed? Run `codegraph upgrade` to update in place.
8
+
9
+ Follow [@getcodegraph](https://x.com/getcodegraph) on X for updates.
10
+
5
11
  ### Supercharge Claude Code, Cursor, Codex, OpenCode, Hermes Agent, Gemini, Antigravity, and Kiro with Semantic Code Intelligence
6
12
 
7
13
  **~16% cheaper ยท ~58% fewer tool calls ยท 100% local**
@@ -25,10 +31,20 @@
25
31
  [![Antigravity](https://img.shields.io/badge/Antigravity-supported-blueviolet.svg)](#supported-agents)
26
32
  [![Kiro](https://img.shields.io/badge/Kiro-supported-blueviolet.svg)](#supported-agents)
27
33
 
34
+ <br>
35
+
36
+ **The CodeGraph platform is coming** โ€” for every PR, know exactly what to test, what could break, which flows are affected, and whether business logic is compromised.
37
+
38
+ <a href="https://getcodegraph.com"><img alt="Join the waitlist for early beta access" src="https://raw.githubusercontent.com/colbymchenry/codegraph/main/assets/waitlist.svg?v=2" height="52"></a>
39
+
40
+ <sub>Get <b>early beta access</b> to the hosted product ยท <a href="https://getcodegraph.com">getcodegraph.com</a></sub>
41
+
28
42
  </div>
29
43
 
30
44
  ## Get Started
31
45
 
46
+ ### 1. Install the CLI
47
+
32
48
  **No Node.js required** โ€” one command grabs the right build for your OS:
33
49
 
34
50
  ```bash
@@ -39,23 +55,37 @@ curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install
39
55
  irm https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.ps1 | iex
40
56
  ```
41
57
 
42
- Already have Node? Use npm instead (works on any version):
58
+ <details>
59
+ <summary><b>Already have Node? Use npm instead (works on any version)</b></summary>
43
60
 
44
61
  ```bash
45
- npx @colbymchenry/codegraph # zero-install, or:
46
62
  npm i -g @colbymchenry/codegraph
47
63
  ```
48
64
 
49
- <sub>CodeGraph bundles its own runtime โ€” nothing to compile, no native build, works the same everywhere. The interactive installer auto-configures your agent(s) โ€” Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity IDE, Kiro.</sub>
65
+ <sub>CodeGraph bundles its own runtime โ€” nothing to compile, no native build, works the same everywhere. The installer puts `codegraph` on your PATH but **doesn't change your current shell** โ€” open a new terminal before the next step so the command resolves.</sub>
50
66
 
51
- ### Initialize Projects
67
+ <sub>**Upgrade any time** with `codegraph upgrade` โ€” it detects how you installed (bundle, npm, or npx) and updates in place. Add `--check` to see if an update is available, or `codegraph upgrade <version>` to pin one.</sub>
68
+
69
+ </details>
70
+
71
+ ### 2. Wire up your agent(s)
72
+
73
+ In a **new terminal**, run the installer to connect CodeGraph to the agents you use:
74
+
75
+ ```bash
76
+ codegraph install
77
+ ```
78
+
79
+ <sub>Detects and auto-configures Claude Code, Cursor, Codex CLI, opencode, Hermes Agent, Gemini CLI, Antigravity IDE, and Kiro โ€” wiring the CodeGraph MCP server into each. **This is the step that connects CodeGraph to your agent;** installing the CLI in step 1 does not do it on its own. (Shortcut: `npx @colbymchenry/codegraph` downloads and runs this in one go.)</sub>
80
+
81
+ ### 3. Initialize each project
52
82
 
53
83
  ```bash
54
84
  cd your-project
55
- codegraph init -i
85
+ codegraph init
56
86
  ```
57
87
 
58
- <sub>`codegraph init` just creates the local `.codegraph/` index directory; adding `-i` (`--index`) also builds the initial graph in the same step. Without `-i`, run `codegraph index` afterwards to populate it.</sub>
88
+ <sub>`codegraph init` creates the local `.codegraph/` directory and builds the full graph in the same step โ€” one command, done.</sub>
59
89
 
60
90
  <div align="center">
61
91
 
@@ -63,6 +93,10 @@ codegraph init -i
63
93
 
64
94
  </div>
65
95
 
96
+ ### 4. No more syncing!
97
+
98
+ Auto-sync is enabled by default. CodeGraph watches the project and updates the graph on every file change โ€” while your agent edits code, or you add, modify, or delete files. **The index is never stale, and there is nothing to re-run.**
99
+
66
100
  ### Uninstall
67
101
 
68
102
  Changed your mind? One command removes CodeGraph from every agent it configured:
@@ -204,8 +238,8 @@ CodeGraph cuts **tokens, tool calls, and wall-clock time on every repo** โ€” acr
204
238
  | **Full-Text Search** | Find code by name instantly across your entire codebase, powered by FTS5 |
205
239
  | **Impact Analysis** | Trace callers, callees, and the full impact radius of any symbol before making changes |
206
240
  | **Always Fresh** | File watcher uses native OS events (FSEvents/inotify/ReadDirectoryChangesW) with debounced auto-sync โ€” the graph stays current as you code, zero config |
207
- | **20+ Languages** | TypeScript, JavaScript, Python, Go, Rust, Java, C#, PHP, Ruby, C, C++, Objective-C, Swift, Kotlin, Dart, Lua, Luau, Svelte, Liquid, Pascal/Delphi |
208
- | **Framework-aware Routes** | Recognizes web-framework routing files and links URL patterns to their handlers across 14 frameworks |
241
+ | **20+ Languages** | TypeScript, JavaScript, Python, Go, Rust, Java, C#, PHP, Ruby, C, C++, Objective-C, Swift, Kotlin, Scala, Dart, Lua, Luau, R, Svelte, Vue, Astro, Liquid, Pascal/Delphi |
242
+ | **Framework-aware Routes** | Recognizes web-framework routing files and links URL patterns to their handlers across 17 frameworks |
209
243
  | **Mixed iOS / React Native / Expo** | Closes cross-language flows that static parsing misses: Swift โ†” ObjC bridging, React Native legacy bridge + TurboModules + Fabric view components, native โ†’ JS event emitters, Expo Modules |
210
244
  | **100% Local** | No data leaves your machine. No API keys. No external services. SQLite database only |
211
245
 
@@ -253,11 +287,14 @@ CodeGraph detects web-framework routing files and emits `route` nodes linked by
253
287
  | **Drupal** | `*.routing.yml` routes (`_controller`, `_form`, entity handlers); `hook_*` implementations in `.module`/`.theme`/`.install`/`.inc` |
254
288
  | **Rails** | `get '/x', to: 'users#index'`, hash-rocket `=>` syntax |
255
289
  | **Spring** | `@GetMapping`, `@PostMapping`, `@RequestMapping` on methods |
290
+ | **Play** | `GET`/`POST`/โ€ฆ verb routes in `conf/routes` โ†’ `Controller.method` actions (Scala + Java) |
256
291
  | **Gin / chi / gorilla / mux** | `r.GET(...)`, `router.HandleFunc(...)` |
257
292
  | **Axum / actix / Rocket** | `.route("/x", get(handler))` |
258
293
  | **ASP.NET** | `[HttpGet("/x")]` attributes on action methods |
259
294
  | **Vapor** | `app.get("x", use: handler)` |
260
295
  | **React Router** / **SvelteKit** | Route component nodes |
296
+ | **Vue Router** / **Nuxt** | `pages/` file-based routes, `server/api/` endpoints, route middleware |
297
+ | **Astro** | `src/pages/` file-based routes (`.astro` pages + `.ts` endpoints, `[param]`/`[...rest]` syntax) |
261
298
 
262
299
  ---
263
300
 
@@ -302,7 +339,7 @@ The installer will:
302
339
  - Ask which agent(s) to configure โ€” auto-detects installed ones from: **Claude Code**, **Cursor**, **Codex CLI**, **opencode**, **Hermes Agent**, **Gemini CLI**, **Antigravity IDE**, **Kiro**
303
340
  - Prompt to install `codegraph` on your PATH (so agents can launch the MCP server)
304
341
  - Ask whether configs apply to all your projects or just this one
305
- - Write each chosen agent's MCP server config (the codegraph usage guide is delivered by the MCP server itself, so no instructions file is added to `CLAUDE.md` / `AGENTS.md` / etc.)
342
+ - Write each chosen agent's MCP server config, plus a small marker-fenced CodeGraph section in the agent's instructions file (`CLAUDE.md` / `AGENTS.md` / `GEMINI.md`) โ€” that's how subagents and non-MCP agents learn the `codegraph explore` / `codegraph node` commands, since the MCP server's own guidance only reaches the main agent. Removed cleanly by `codegraph uninstall`.
306
343
  - Set up auto-allow permissions when Claude Code is one of the targets
307
344
  - Initialize your current project (local installs only)
308
345
 
@@ -331,10 +368,10 @@ Restart your agent (Claude Code / Cursor / Codex CLI / opencode / Hermes Agent /
331
368
 
332
369
  ```bash
333
370
  cd your-project
334
- codegraph init -i
371
+ codegraph init
335
372
  ```
336
373
 
337
- Builds the per-project knowledge graph index. A single global `codegraph install` works in every project you open โ€” no need to re-run the installer per project.
374
+ Builds the per-project knowledge graph index, which then auto-syncs on every file change. A single global `codegraph install` works in every project you open โ€” no need to re-run the installer per project.
338
375
 
339
376
  That's it โ€” your agent will use CodeGraph tools automatically when a `.codegraph/` directory exists.
340
377
 
@@ -382,14 +419,14 @@ npm install -g @colbymchenry/codegraph
382
419
  <details>
383
420
  <summary><strong>Agent Tool Guidance</strong></summary>
384
421
 
385
- CodeGraph's MCP server delivers its usage guidance to your agent **automatically**, in the MCP `initialize` response โ€” there's no instructions file to manage and nothing is added to your `CLAUDE.md` / `AGENTS.md` / `GEMINI.md`. In short, it tells the agent to:
422
+ CodeGraph's MCP server delivers its usage guidance to your agent **automatically**, in the MCP `initialize` response. In short, it tells the agent to:
386
423
 
387
424
  - **Answer structural questions directly with CodeGraph** โ€” it *is* the pre-built index, so a grep/read loop just repeats work it already did. Treat the returned source as already read.
388
- - **Pick the tool by intent:** `codegraph_explore` for almost anything โ€” "how does X work", a flow/"how does X reach Y", or surveying an area (one call returns the relevant symbols' source grouped by file); `codegraph_search` to just locate a symbol; `codegraph_callers`/`codegraph_callees` to walk call flow; `codegraph_impact` before editing; `codegraph_node` for one specific symbol's full source (it returns every overload for an ambiguous name).
425
+ - **Pick the tool by intent:** `codegraph_explore` for almost anything โ€” "how does X work", a flow/"how does X reach Y", or surveying an area (one call returns the relevant symbols' source grouped by file); `codegraph_search` to just locate a symbol; `codegraph_callers` for every call site (including callback registrations); `codegraph_node` for one symbol's full source + callers, or to read a file like the Read tool.
389
426
  - **Trust the results โ€” don't re-verify with grep**, and check the staleness banner after edits.
390
- - If `.codegraph/` doesn't exist yet, offer to run `codegraph init -i`.
427
+ - In a workspace with no index, CodeGraph announces itself inactive and serves no tools โ€” indexing stays your decision.
391
428
 
392
- The exact text is `src/mcp/server-instructions.ts` โ€” the single source of truth.
429
+ The exact text is `src/mcp/server-instructions.ts` โ€” the single source of truth for the main agent. Because subagents and non-MCP harnesses never see the MCP guidance, the installer also writes a four-line marker-fenced section into the agent's instructions file pointing at the `codegraph explore` / `codegraph node` CLI equivalents.
393
430
 
394
431
  </details>
395
432
 
@@ -439,13 +476,20 @@ codegraph uninit [path] # Remove CodeGraph from a project (--force to
439
476
  codegraph index [path] # Full index (--force to re-index, --quiet for less output)
440
477
  codegraph sync [path] # Incremental update
441
478
  codegraph status [path] # Show statistics
479
+ codegraph unlock [path] # Remove a stale lock file that's blocking indexing
442
480
  codegraph query <search> # Search symbols (--kind, --limit, --json)
481
+ codegraph explore <query> # Relevant symbols' source + call paths in one shot (same output as the codegraph_explore MCP tool)
482
+ codegraph node <symbol|file> # One symbol's source + callers, or read a file with line numbers (same output as codegraph_node)
443
483
  codegraph files [path] # Show file structure (--format, --filter, --max-depth, --json)
444
484
  codegraph callers <symbol> # Find what calls a function/method (--limit, --json)
445
485
  codegraph callees <symbol> # Find what a function/method calls (--limit, --json)
446
486
  codegraph impact <symbol> # Analyze what code is affected by changing a symbol (--depth, --json)
447
487
  codegraph affected [files...] # Find test files affected by changes (see below)
448
- codegraph serve --mcp # Start MCP server
488
+ codegraph daemon # Manage background daemons โ€” pick one to stop (alias: daemons)
489
+ codegraph telemetry [on|off] # Show or change anonymous usage telemetry
490
+ codegraph upgrade [version] # Update to the latest release (--check, --force)
491
+ codegraph version # Print the installed version (also -v, --version)
492
+ codegraph help [command] # Show help, optionally for one command
449
493
  ```
450
494
 
451
495
  ### `codegraph affected`
@@ -480,18 +524,18 @@ fi
480
524
 
481
525
  ## MCP Tools
482
526
 
483
- When running as an MCP server, CodeGraph exposes these tools to Claude Code:
527
+ When running as an MCP server, CodeGraph exposes a focused set of four tools โ€” measured agent behavior showed a leaner list steers agents to the right tool and saves context every session:
484
528
 
485
529
  | Tool | Purpose |
486
530
  |------|---------|
487
531
  | `codegraph_explore` | **Primary.** Answer almost any question in one call โ€” "how does X work", a flow ("how does X reach Y"), or surveying an area โ€” returning the relevant symbols' verbatim source grouped by file, plus a relationship map and blast radius. Surfaces dynamic-dispatch hops (callbacks, React re-render, interfaceโ†’impl) grep can't follow. |
532
+ | `codegraph_node` | One symbol's full source + caller/callee trail (every overload for an ambiguous name) โ€” or pass a file path to **read a whole file like the Read tool** (same line-numbered output, `offset`/`limit`), with its dependents attached. |
488
533
  | `codegraph_search` | Find symbols by name across the codebase |
489
- | `codegraph_callers` | Find what calls a function |
490
- | `codegraph_callees` | Find what a function calls |
491
- | `codegraph_impact` | Analyze what code is affected by changing a symbol |
492
- | `codegraph_node` | Get one specific symbol's details + full source (returns every overload for an ambiguous name) |
493
- | `codegraph_files` | Get indexed file structure (faster than filesystem scanning) |
494
- | `codegraph_status` | Check index health and statistics |
534
+ | `codegraph_callers` | Every call site of a function โ€” including where it's registered as a callback โ€” with one section per definition when several share a name |
535
+
536
+ Four more tools (`codegraph_callees`, `codegraph_impact`, `codegraph_files`, `codegraph_status`) stay fully functional but unlisted by default โ€” measured across eval runs, agents never or rarely picked them, and their information already arrives inline on the four above (explore's blast-radius section, node's dependents note, a symbol's body as its callee list). Re-enable any of them with the `CODEGRAPH_MCP_TOOLS` environment variable (e.g. `CODEGRAPH_MCP_TOOLS=explore,node,search,callers,impact`), or use their CLI equivalents (`codegraph callees` / `impact` / `files` / `status`).
537
+
538
+ In a workspace with no `.codegraph/` index, the server announces itself inactive and lists **no** tools โ€” agents work normally with their built-in tools, and indexing stays your decision.
495
539
 
496
540
  ---
497
541
 
@@ -562,6 +606,23 @@ add a negation โ€” `!vendor/`. The defaults apply uniformly, so committing a
562
606
  dependency or build directory doesn't force it into the graph; the `.gitignore`
563
607
  negation is the explicit opt-in.
564
608
 
609
+ ## Telemetry
610
+
611
+ CodeGraph collects **anonymous usage statistics** โ€” which tools and commands get
612
+ used, which languages get indexed โ€” to guide where language and agent support
613
+ work goes. **Never** any code, paths, file or symbol names, queries, or IP
614
+ addresses; usage is aggregated locally into daily totals before anything is
615
+ sent, and the ingest endpoint is [public code in this repo](telemetry-worker/)
616
+ that enforces the documented field list. The installer asks up front; turn it
617
+ off any time:
618
+
619
+ ```bash
620
+ codegraph telemetry off # or: CODEGRAPH_TELEMETRY=0, or DO_NOT_TRACK=1
621
+ ```
622
+
623
+ [`TELEMETRY.md`](TELEMETRY.md) lists every field, with the off-switches and the
624
+ full data-handling story.
625
+
565
626
  ## Supported Platforms
566
627
 
567
628
  Every release ships a self-contained build (bundled Node runtime โ€” nothing to
@@ -612,11 +673,44 @@ is written):
612
673
  | Dart | `.dart` | Full support |
613
674
  | Svelte | `.svelte` | Full support (script extraction, Svelte 5 runes, SvelteKit routes) |
614
675
  | Vue | `.vue` | Full support (script + script-setup extraction, Nuxt page/API/middleware routes) |
676
+ | Astro | `.astro` | Full support (frontmatter + script extraction, template component/call references, `src/pages/` routes) |
615
677
  | Liquid | `.liquid` | Full support |
616
678
  | Pascal / Delphi | `.pas`, `.dpr`, `.dpk`, `.lpr` | Full support (classes, records, interfaces, enums, DFM/FMX form files) |
617
679
  | Lua | `.lua` | Full support (functions, methods with receivers, local variables, `require` imports, call edges) |
680
+ | R | `.R` `.r` | Full support (functions in every assignment form, S4/R5/R6 classes with methods, `library`/`require` imports, `source()` file references, call edges) |
618
681
  | Luau | `.luau` | Full support (everything in Lua, plus `type`/`export type` aliases, typed signatures, and Roblox instance-path `require`) |
619
682
 
683
+ ## Measured cross-file coverage
684
+
685
+ Impact and blast-radius queries are only as good as the dependency graph behind them, so coverage is measured rather than asserted. **Fair coverage** = the share of symbol-bearing source files that have at least one *resolved cross-file dependent* โ€” something that imports, calls, references, or (through a framework convention) routes to them โ€” on a real-world benchmark repo per language. The residual is always a genuine static-analysis frontier (runtime dynamic dispatch, reflection / DI containers, framework-convention entry points, vendored third-party code), never hidden by gaming the denominator.
686
+
687
+ | Language | Benchmark repo | Coverage |
688
+ |---|---|---|
689
+ | TypeScript / JavaScript | this repo | 95.8% |
690
+ | Python | psf/requests | 100% |
691
+ | Go | gin-gonic/gin | 96.6% |
692
+ | Rust | BurntSushi/ripgrep | 86.7% |
693
+ | Java | google/gson | 93.3% |
694
+ | C# | jbogard/MediatR | 85.2% |
695
+ | PHP | guzzle/guzzle | 100% |
696
+ | Ruby | sidekiq/sidekiq | 100% |
697
+ | C | redis/redis | 92.2% |
698
+ | C++ | google/leveldb | 94.8% |
699
+ | Objective-C | SDWebImage | 91.6% |
700
+ | Swift | Alamofire | 95.3% |
701
+ | Kotlin | square/okhttp | 96.2% |
702
+ | Scala | gatling/gatling | 91.2% |
703
+ | Dart | flutter/packages | 92.4% |
704
+ | Svelte / SvelteKit | sveltejs/realworld | 100% |
705
+ | Vue / Nuxt | nuxt/movies | 93.5% |
706
+ | Astro | xingwangzhe/stalux | 93.0% |
707
+ | Lua | nvim-telescope/telescope.nvim | 84.2% |
708
+ | Luau | dphfox/Fusion | 92.2% |
709
+ | Liquid | Shopify/dawn | 73.8% |
710
+ | Pascal / Delphi | PascalCoin | 77.4% |
711
+
712
+ Framework routing is validated the same way, on a canonical app per framework: Express 100%, FastAPI 98%, Flask 100%, NestJS 96.8%, Gin 96.5%, Axum 100%, Rocket 93.8%, Vapor 100%, Laravel 92%, Rails 89.6%, React Router 100% โ€” and the convention/reflection-heavy ones at their honest static-analysis ceiling: ASP.NET 83.9%, Spring 83.3%, Drupal 78.9%, Play 76.3%, Django 74.1%. SvelteKit, Vue/Nuxt, and Astro use file-based routing, so their page/endpoint coverage is the Svelte/SvelteKit (100%), Vue/Nuxt (93.5%), and Astro (93.0% โ€” every `src/pages/` file maps to a route node on the two validation repos) figures in the table above.
713
+
620
714
  ## Troubleshooting
621
715
 
622
716
  **"CodeGraph not initialized"** โ€” Run `codegraph init` in your project directory first.
@@ -628,10 +722,12 @@ is written):
628
722
  - **You're on an old (pre-0.9) install.** Reinstall to get the bundled runtime โ€” `curl -fsSL https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.sh | sh` (macOS/Linux), `irm https://raw.githubusercontent.com/colbymchenry/codegraph/main/install.ps1 | iex` (Windows), or `npm i -g @colbymchenry/codegraph@latest`.
629
723
  - **`codegraph status` shows `Journal:` other than `wal`** โ€” WAL couldn't be enabled on this filesystem (common on network shares and WSL2 `/mnt`), so reads can block on writes. Move the project (with its `.codegraph/` folder) onto a local disk.
630
724
 
631
- **MCP server not connecting** โ€” Ensure the project is initialized/indexed, verify the path in your MCP config, and check that `codegraph serve --mcp` works from the command line.
725
+ **MCP server not connecting** โ€” Your agent starts the server itself, so you don't launch it by hand. Make sure the project is initialized and indexed (`codegraph status`) and that the path in your MCP config is correct. If it still won't connect, re-run `codegraph install` to rewrite the config.
632
726
 
633
727
  **Missing symbols** โ€” The MCP server auto-syncs on save (wait a couple seconds). Run `codegraph sync` manually if needed. Check that the file's language is supported and isn't inside a `.gitignore`d or default-excluded directory (e.g. `node_modules`, `dist`).
634
728
 
729
+ **Sharing one checkout between Windows and WSL** โ€” Don't point both at the same `.codegraph/`: the background-server lock and the SQLite index are tied to the OS that wrote them, and SQLite locking across the WSL2/Windows filesystem boundary is unreliable. Give each side its own index in the same tree by setting `CODEGRAPH_DIR` to a distinct name on one of them โ€” e.g. `CODEGRAPH_DIR=.codegraph-win` on Windows, leaving WSL on the default `.codegraph`. CodeGraph skips any sibling `.codegraph-*` directory when indexing and watching, so the two never trip over each other.
730
+
635
731
  ## Star History
636
732
 
637
733
  <a href="https://www.star-history.com/?repos=colbymchenry%2Fcodegraph&type=date&legend=top-left">
@@ -20,6 +20,7 @@
20
20
  * codegraph callees <symbol> Find what a function/method calls
21
21
  * codegraph impact <symbol> Analyze what code is affected by changing a symbol
22
22
  * codegraph affected [files] Find test files affected by changes
23
+ * codegraph upgrade [version] Update CodeGraph to the latest release
23
24
  */
24
25
  export {};
25
26
  //# sourceMappingURL=codegraph.d.ts.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Render an uncaught value for the last-resort log WITHOUT triggering stack
3
+ * formatting. Pure and total โ€” never throws, never touches `.stack`.
4
+ */
5
+ export declare function describeFatal(value: unknown): string;
6
+ /** Injectable seams so the wiring is testable without registering real handlers. */
7
+ export interface FatalHandlerDeps {
8
+ /** Event target to attach to. Defaults to `process`. */
9
+ target?: NodeJS.EventEmitter;
10
+ /** How to terminate. Defaults to `process.exit`. */
11
+ exit?: (code: number) => void;
12
+ /** How to emit the bounded line. Defaults to a synchronous fd-2 write. */
13
+ write?: (line: string) => void;
14
+ }
15
+ /**
16
+ * Install the uncaught-exception / unhandled-rejection handlers. Both log a
17
+ * bounded line and then exit non-zero (Node's default fatal semantics).
18
+ */
19
+ export declare function installFatalHandlers(deps?: FatalHandlerDeps): void;
20
+ //# sourceMappingURL=fatal-handler.d.ts.map
@@ -7,7 +7,7 @@ import { SqliteDatabase } from './sqlite-adapter';
7
7
  /**
8
8
  * Current schema version
9
9
  */
10
- export declare const CURRENT_SCHEMA_VERSION = 4;
10
+ export declare const CURRENT_SCHEMA_VERSION = 5;
11
11
  /**
12
12
  * Migration definition
13
13
  */
@@ -10,10 +10,16 @@ import { Node, Edge, FileRecord, UnresolvedReference, NodeKind, EdgeKind, GraphS
10
10
  */
11
11
  export declare class QueryBuilder {
12
12
  private db;
13
+ private projectNameTokens;
13
14
  private nodeCache;
14
15
  private readonly maxCacheSize;
15
16
  private stmts;
16
17
  constructor(db: SqliteDatabase);
18
+ /** Set the normalized project-name tokens used to down-weight non-discriminative
19
+ * query words in path scoring (#720). Called once when the project opens. */
20
+ setProjectNameTokens(tokens: Set<string>): void;
21
+ /** The normalized project-name tokens (#720); empty if none were derived. */
22
+ getProjectNameTokens(): Set<string>;
17
23
  /**
18
24
  * Insert a new node
19
25
  */
@@ -134,6 +140,14 @@ export declare class QueryBuilder {
134
140
  * Get all nodes of a specific kind
135
141
  */
136
142
  getNodesByKind(kind: NodeKind): Node[];
143
+ /**
144
+ * Stream every node of a kind one at a time (lazy) instead of materializing
145
+ * them all like {@link getNodesByKind}. For unbounded kinds (`function`,
146
+ * `method`) on a symbol-dense project the full array is gigabytes; the
147
+ * dynamic-edge synthesizers only scan-and-filter, so they iterate to keep
148
+ * memory O(1) in the node count rather than O(nodes) (#610).
149
+ */
150
+ iterateNodesByKind(kind: NodeKind): IterableIterator<Node>;
137
151
  /**
138
152
  * Get all nodes in the database
139
153
  */
@@ -230,6 +244,30 @@ export declare class QueryBuilder {
230
244
  * Useful for recovering inter-node connectivity after BFS.
231
245
  */
232
246
  findEdgesBetweenNodes(nodeIds: string[], kinds?: EdgeKind[]): Edge[];
247
+ /**
248
+ * Distinct file paths that DEPEND ON `filePath`: every file containing a
249
+ * symbol with a cross-file edge (any kind except `contains`) into a symbol
250
+ * of this file. This is the file-level projection of the symbol dependency
251
+ * graph and the basis for blast-radius / `affected` test selection.
252
+ *
253
+ * It deliberately does NOT restrict to `imports` edges. In this graph an
254
+ * `imports` edge connects a file to its own local import declarations
255
+ * (it is always same-file), so an imports-only lookup returns zero
256
+ * cross-file dependents for every file. The real cross-file dependency
257
+ * signal is the resolved call/reference graph โ€” calls, references,
258
+ * instantiates, extends, implements, overrides, type_of, returns,
259
+ * decorates โ€” exactly what {@link GraphTraverser.getImpactRadius} traverses.
260
+ * `contains` is excluded: a parent containing a symbol does not *depend* on
261
+ * it. One indexed query (idx_nodes_file_path + idx_edges_target_kind).
262
+ */
263
+ getDependentFilePaths(filePath: string): string[];
264
+ /**
265
+ * Distinct file paths that `filePath` DEPENDS ON โ€” the inverse of
266
+ * {@link getDependentFilePaths}: every file containing a symbol that a
267
+ * symbol of this file has a cross-file edge into. Same edge-kind rules
268
+ * (all kinds except `contains`); same reason imports-only is insufficient.
269
+ */
270
+ getDependencyFilePaths(filePath: string): string[];
233
271
  /**
234
272
  * Insert or update a file record
235
273
  */
@@ -246,6 +284,11 @@ export declare class QueryBuilder {
246
284
  * Get all tracked files
247
285
  */
248
286
  getAllFiles(): FileRecord[];
287
+ /**
288
+ * Most recent index timestamp (ms since epoch) across all tracked files, or
289
+ * null when nothing is indexed yet. One indexed aggregate, no per-row scan. (#329)
290
+ */
291
+ getLastIndexedAt(): number | null;
249
292
  /**
250
293
  * Get files that need re-indexing (hash changed)
251
294
  */
@@ -16,6 +16,13 @@ export interface SqliteStatement {
16
16
  };
17
17
  get(...params: any[]): any;
18
18
  all(...params: any[]): any[];
19
+ /**
20
+ * Lazily yield result rows one at a time instead of materializing the whole
21
+ * set with `all()`. Use for unbounded scans (e.g. every function/method node)
22
+ * so memory stays O(1) in the row count rather than O(rows) โ€” see #610, where
23
+ * `all()`-ing every symbol on a dense project spiked the heap into an OOM.
24
+ */
25
+ iterate(...params: any[]): IterableIterator<any>;
19
26
  }
20
27
  export interface SqliteDatabase {
21
28
  prepare(sql: string): SqliteStatement;
@@ -4,9 +4,41 @@
4
4
  * Manages the .codegraph/ directory structure for CodeGraph data.
5
5
  */
6
6
  /**
7
- * CodeGraph directory name
7
+ * Resolve the per-project data directory name, honoring the `CODEGRAPH_DIR`
8
+ * environment override (default `.codegraph`). The override is a single path
9
+ * segment that lives in the project root.
10
+ *
11
+ * Why this exists: two environments that share one working tree must NOT share
12
+ * one `.codegraph/` โ€” most concretely Windows-native and WSL (issue #636). The
13
+ * daemon lockfile (`.codegraph/daemon.pid`) records a platform-specific pid and
14
+ * socket path (a Windows named pipe vs a WSL Unix socket), and SQLite file
15
+ * locking across the WSL2 โ†” Windows filesystem boundary is unreliable, so two
16
+ * daemons sharing one index risks corruption. Setting `CODEGRAPH_DIR=.codegraph-win`
17
+ * on one side gives each environment its own index in the same tree.
18
+ *
19
+ * Read live (not captured at load) so it is both process-accurate and testable.
20
+ * An override that isn't a plain directory name โ€” empty, containing a path
21
+ * separator, `.`, `..`/traversal, or absolute โ€” is ignored (we keep the
22
+ * default) rather than risk writing the index outside the project or into the
23
+ * project root itself; we warn once to stderr so the misconfiguration is seen.
24
+ */
25
+ export declare function codeGraphDirName(): string;
26
+ /**
27
+ * CodeGraph directory name โ€” a load-time snapshot of {@link codeGraphDirName}.
28
+ * A running process's environment is fixed, so this equals the live value;
29
+ * it's kept as a stable string export for backward compatibility. Internal code
30
+ * resolves the name through {@link codeGraphDirName} / {@link getCodeGraphDir}
31
+ * so the `CODEGRAPH_DIR` override always applies.
32
+ */
33
+ export declare const CODEGRAPH_DIR: string;
34
+ /**
35
+ * Is `name` (a single path segment) a CodeGraph data directory? Matches the
36
+ * default `.codegraph`, the active `CODEGRAPH_DIR` override, and any
37
+ * `.codegraph-*` sibling. File-watching and the indexer skip ALL of these, so
38
+ * when two environments share one working tree (Windows + WSL, issue #636)
39
+ * neither indexes or watches the other's index directory.
8
40
  */
9
- export declare const CODEGRAPH_DIR = ".codegraph";
41
+ export declare function isCodeGraphDataDir(name: string): boolean;
10
42
  /**
11
43
  * Get the .codegraph directory path for a project
12
44
  */
@@ -25,6 +57,21 @@ export declare function isInitialized(projectRoot: string): boolean;
25
57
  * @param startPath - Directory to start searching from
26
58
  * @returns The project root containing .codegraph/, or null if not found
27
59
  */
60
+ /**
61
+ * Reason a directory is unsafe to use as an index ROOT, or null when it's fine.
62
+ *
63
+ * Indexing your home directory or a filesystem root drags in caches, `Library`,
64
+ * every other project, etc. โ€” a multi-GB index, constant file-watcher churn, and
65
+ * (pre-1.0 on macOS) a file-descriptor blowup that exhausted `kern.maxfiles` and
66
+ * took unrelated apps / the whole machine down (#845). The classic trigger:
67
+ * running the installer or `codegraph init` from `$HOME`, which auto-indexes the
68
+ * current directory. These are never intended project roots, so the installer
69
+ * and `init`/`index` refuse them (overridable with `--force`).
70
+ *
71
+ * Pure-ish (reads only `os.homedir()` + realpath) so it's easy to unit-test.
72
+ * The returned string is a human phrase that slots into "โ€ฆ looks like {reason}".
73
+ */
74
+ export declare function unsafeIndexRootReason(projectRoot: string): string | null;
28
75
  export declare function findNearestCodeGraphRoot(startPath: string): string | null;
29
76
  /**
30
77
  * Create the .codegraph directory structure
@@ -0,0 +1,79 @@
1
+ import { ExtractionResult } from '../types';
2
+ /**
3
+ * AstroExtractor - Extracts code relationships from Astro component files
4
+ *
5
+ * Astro files are multi-language: a TypeScript frontmatter block fenced by
6
+ * `---` lines, a JSX-like HTML template, and optional <script>/<style> blocks.
7
+ * Rather than parsing a full Astro grammar, we extract the frontmatter and
8
+ * <script> contents and delegate them to the TypeScript TreeSitterExtractor
9
+ * (Astro processes both as TypeScript by default โ€” no `lang` attr needed).
10
+ *
11
+ * Also extracts function calls from template expressions (`{fn(...)}`) and
12
+ * component usages (`<PascalCase>`) so cross-file edges are captured even
13
+ * when the only reference lives in markup.
14
+ *
15
+ * Every .astro file produces a component node (Astro components are always
16
+ * importable).
17
+ */
18
+ export declare class AstroExtractor {
19
+ private filePath;
20
+ private source;
21
+ private nodes;
22
+ private edges;
23
+ private unresolvedReferences;
24
+ private errors;
25
+ constructor(filePath: string, source: string);
26
+ /**
27
+ * Extract from Astro source
28
+ */
29
+ extract(): ExtractionResult;
30
+ /**
31
+ * Create a component node for the .astro file
32
+ */
33
+ private createComponentNode;
34
+ /**
35
+ * Extract the frontmatter block: the content between the opening `---`
36
+ * fence (first non-blank line of the file) and the closing `---` fence.
37
+ * An unclosed fence is treated as "no frontmatter" rather than swallowing
38
+ * the whole template as TypeScript.
39
+ *
40
+ * Returns the content plus its 0-indexed start line, or null.
41
+ */
42
+ private extractFrontmatter;
43
+ /**
44
+ * Extract <script> blocks from the template portion
45
+ */
46
+ private extractScriptBlocks;
47
+ /**
48
+ * Process frontmatter / script content by delegating to TreeSitterExtractor.
49
+ * Astro treats both as TypeScript by default.
50
+ */
51
+ private processScriptContent;
52
+ /**
53
+ * Line ranges (0-indexed, inclusive) the template scans must skip:
54
+ * the frontmatter block and <script>/<style> blocks.
55
+ */
56
+ private getCoveredRanges;
57
+ /**
58
+ * Extract function calls from Astro template expressions.
59
+ *
60
+ * Astro templates embed JSX-like expressions (`{formatDate(post.date)}`,
61
+ * `class:list={cn(...)}`), so calls frequently live in markup rather than
62
+ * the frontmatter. We scan template lines for `{expression}` groups and
63
+ * extract call patterns from them. A `{` group left open at end-of-line
64
+ * (the pervasive `{posts.map((post) => (` pattern) contributes the calls
65
+ * on its opening line.
66
+ */
67
+ private extractTemplateCalls;
68
+ /**
69
+ * Extract component usages from the Astro template.
70
+ *
71
+ * PascalCase tags like <Layout>, <PostCard /> represent component
72
+ * instantiations โ€” analogous to function calls in imperative code.
73
+ * Lowercase tags are native HTML (Astro does not register kebab-case
74
+ * components the way Vue does, so those are real custom elements and
75
+ * are skipped).
76
+ */
77
+ private extractTemplateComponents;
78
+ }
79
+ //# sourceMappingURL=astro-extractor.d.ts.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Extraction version
3
+ *
4
+ * A monotonically-increasing integer that identifies the *shape and depth* of
5
+ * what the extractor writes into the graph. Unlike `CURRENT_SCHEMA_VERSION`
6
+ * (which tracks the SQLite table layout and is migrated in place), this tracks
7
+ * the EXTRACTED CONTENT โ€” node kinds, edges, synthesizers, resolver coverage.
8
+ *
9
+ * When an index was built by an older engine whose `EXTRACTION_VERSION` is
10
+ * below the running engine's, the data on disk is structurally fine but
11
+ * *stale*: it's missing whatever a newer extractor would now produce. A schema
12
+ * migration can't backfill that โ€” only a re-index can. So this is the signal
13
+ * `codegraph status` uses to recommend a re-index, and the reason `codegraph
14
+ * upgrade` reminds users to refresh their projects.
15
+ *
16
+ * BUMP THIS when a release changes extraction output enough that existing
17
+ * indexes should be rebuilt to benefit โ€” e.g. a new language/framework
18
+ * extractor, a new dynamic-dispatch synthesizer, a new node/edge kind, or a
19
+ * resolver fix that materially changes which edges exist. Do NOT bump for
20
+ * pure bug fixes, CLI/UX changes, or schema-only migrations. Over-bumping
21
+ * turns the re-index hint into noise โ€” keep it honest (see CLAUDE.md, "Honesty
22
+ * in the product is load-bearing").
23
+ */
24
+ export declare const EXTRACTION_VERSION = 24;
25
+ //# sourceMappingURL=extraction-version.d.ts.map