@optave/codegraph 2.6.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,19 +31,24 @@
31
31
 
32
32
  ## The Problem
33
33
 
34
- AI coding assistants are incredible until your codebase gets big enough. Then they get lost.
34
+ Large codebases are opaque. The structure lives in people's heads, not in tools.
35
35
 
36
- On a large codebase, a great portion of your AI budget isn't going toward solving tasks. It's going toward the AI re-orienting itself in your code. Every session. Over and over. It burns tokens on tool calls `grep`, `find`, `cat` just to figure out what calls what. It loses context. It hallucinates dependencies. It modifies a function without realizing 14 callers across 9 files depend on it.
36
+ A developer inherits a project and spends days grepping to understand what calls what. An AI agent burns half its token budget on `grep`, `find`, `cat` re-discovering the same structure every session. An architect draws boundary rules on a whiteboard that erode within weeks because nothing enforces them. A CI pipeline catches test failures but can't tell you _"this change silently affects 14 callers across 9 files."_
37
37
 
38
- When the AI catches these mistakes, you waste time and tokens on corrections. When it doesn't catch them, your codebase starts degrading with silent bugs until things stop working.
39
-
40
- And when you hit `/clear` or run out of context? It starts from scratch.
38
+ The information exists it's in the code itself. But without a structured map, everyone is navigating blind: developers guess, AI agents hallucinate, and architecture degrades one unreviewed change at a time.
41
39
 
42
40
  ## What Codegraph Does
43
41
 
44
- Codegraph gives your AI a pre-built, always-current map of your entire codebase — every function, every caller, every dependency — so it stops guessing and starts knowing.
42
+ Codegraph builds a function-level dependency graph of your entire codebase — every function, every caller, every dependency — and keeps it current with sub-second incremental rebuilds.
43
+
44
+ It parses your code with [tree-sitter](https://tree-sitter.github.io/) (native Rust or WASM), stores the graph in SQLite, and gives you multiple ways to consume it:
45
+
46
+ - **CLI** — developers explore, query, and audit their code from the terminal
47
+ - **MCP server** — AI agents query the graph directly through 30 tools
48
+ - **CI gates** — `check` and `manifesto` commands enforce quality thresholds with exit codes
49
+ - **Programmatic API** — embed codegraph in your own tools via `npm install`
45
50
 
46
- It parses your code with [tree-sitter](https://tree-sitter.github.io/) (native Rust or WASM), builds a function-level dependency graph in SQLite, and keeps it current with sub-second incremental rebuilds. Your AI gets answers like _"this function has 14 callers across 9 files"_ instantly, instead of spending 30 tool calls to maybe discover half of them.
51
+ Instead of 30 tool calls to maybe discover half your dependencies, you get _"this function has 14 callers across 9 files"_ instantly. Instead of hoping architecture rules are followed, you enforce them. Instead of finding breakage in production, `diff-impact --staged` catches it before you commit.
47
52
 
48
53
  **Free. Open source. Fully local.** Zero network calls, zero telemetry. Your code stays on your machine. When you want deeper intelligence, bring your own LLM provider — your code only goes where you choose to send it.
49
54
 
@@ -55,21 +60,22 @@ cd your-project
55
60
  codegraph build
56
61
  ```
57
62
 
58
- That's it. No config files, no Docker, no JVM, no API keys, no accounts. The graph is ready to query. Add `codegraph mcp` to your AI agent's config and it has full access to your dependency graph through 30 MCP tools (31 in multi-repo mode).
63
+ That's it. No config files, no Docker, no JVM, no API keys, no accounts. The graph is ready to query.
59
64
 
60
65
  ### Why it matters
61
66
 
62
- | Without codegraph | With codegraph |
63
- |---|---|
64
- | AI spends 20+ tool calls per session re-discovering your code structure | AI gets full dependency context in one call |
65
- | Modifies `parseConfig()` without knowing 9 files import it | `fn-impact parseConfig` shows every caller before the edit |
66
- | Hallucinates that `auth.js` imports from `db.js` | `deps src/auth.js` shows the real import graph |
67
- | After `/clear`, starts from scratch | Graph persists next session picks up where this one left off |
68
- | Suggests renaming a function, breaks 14 call sites silently | `diff-impact --staged` catches the breakage before you commit |
67
+ | | Without codegraph | With codegraph |
68
+ |---|---|---|
69
+ | **AI agents** | Spend 20+ tool calls per session re-discovering code structure | Get full dependency context in one MCP call |
70
+ | **AI agents** | Modify `parseConfig()` without knowing 9 files import it | `fn-impact parseConfig` shows every caller before the edit |
71
+ | **Developers** | Inherit a codebase and grep for hours to understand what calls what | `context handleAuth -T` gives source, deps, callers, and tests in one command |
72
+ | **Developers** | Rename a function, break 14 call sites silently | `diff-impact --staged` catches breakage before you commit |
73
+ | **CI pipelines** | Catch test failures but miss structural degradation | `check --staged` fails the build when blast radius or complexity thresholds are exceeded |
74
+ | **Architects** | Draw boundary rules that erode within weeks | `manifesto` and `boundaries` enforce architecture rules on every commit |
69
75
 
70
76
  ### Feature comparison
71
77
 
72
- <sub>Comparison last verified: March 2026. Full analysis: <a href="generated/COMPETITIVE_ANALYSIS.md">COMPETITIVE_ANALYSIS.md</a></sub>
78
+ <sub>Comparison last verified: March 2026. Full analysis: <a href="generated/competitive/COMPETITIVE_ANALYSIS.md">COMPETITIVE_ANALYSIS.md</a></sub>
73
79
 
74
80
  | Capability | codegraph | [joern](https://github.com/joernio/joern) | [narsil-mcp](https://github.com/postrv/narsil-mcp) | [code-graph-rag](https://github.com/vitali87/code-graph-rag) | [cpg](https://github.com/Fraunhofer-AISEC/cpg) | [GitNexus](https://github.com/abhigyanpatwari/GitNexus) | [CodeMCP](https://github.com/SimplyLiz/CodeMCP) | [axon](https://github.com/harshkedia177/axon) |
75
81
  |---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
@@ -94,6 +100,12 @@ That's it. No config files, no Docker, no JVM, no API keys, no accounts. The gra
94
100
  | Zero config | **Yes** | — | **Yes** | — | — | **Yes** | — | **Yes** |
95
101
  | Embeddable JS library (`npm install`) | **Yes** | — | — | — | — | — | — | — |
96
102
  | LLM-optional (works without API keys) | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** |
103
+ | Dataflow analysis | **Yes** | **Yes** | — | — | **Yes** | — | — | — |
104
+ | Control flow graph (CFG) | **Yes** | **Yes** | — | — | **Yes** | — | — | — |
105
+ | AST node querying | **Yes** | **Yes** | — | — | **Yes** | — | — | — |
106
+ | Expanded node/edge types | **Yes** | **Yes** | — | — | **Yes** | — | — | — |
107
+ | GraphML / Neo4j export | **Yes** | **Yes** | — | — | — | — | — | — |
108
+ | Interactive graph viewer | **Yes** | — | — | — | — | — | — | — |
97
109
  | Commercial use allowed | **Yes** | **Yes** | **Yes** | **Yes** | **Yes** | No | Paid | **Yes** |
98
110
  | Open source | **Yes** | Yes | Yes | Yes | Yes | No | No | Yes |
99
111
 
@@ -109,6 +121,7 @@ That's it. No config files, no Docker, no JVM, no API keys, no accounts. The gra
109
121
  | **🌐** | **Multi-language, one CLI** | JS/TS + Python + Go + Rust + Java + C# + PHP + Ruby + HCL in a single graph |
110
122
  | **💥** | **Git diff impact** | `codegraph diff-impact` shows changed functions, their callers, and full blast radius — enriched with historically coupled files from git co-change analysis. Ships with a GitHub Actions workflow |
111
123
  | **🧠** | **Hybrid search** | BM25 keyword + semantic embeddings fused via RRF — `hybrid` (default), `semantic`, or `keyword` mode; multi-query via `"auth; token; JWT"` |
124
+ | **🔬** | **Dataflow + CFG** | Track how data flows through functions (`flows_to`, `returns`, `mutates`) and visualize intraprocedural control flow graphs for all 11 languages |
112
125
 
113
126
  ---
114
127
 
@@ -169,7 +182,7 @@ Full agent setup: [AI Agent Guide](docs/guides/ai-agent-guide.md) &middot; [CLAU
169
182
  | 📁 | **File dependencies** | See what a file imports and what imports it |
170
183
  | 💥 | **Impact analysis** | Trace every file affected by a change (transitive) |
171
184
  | 🧬 | **Function-level tracing** | Call chains, caller trees, function-level impact, and A→B pathfinding with qualified call resolution |
172
- | 🎯 | **Deep context** | `context` gives AI agents source, deps, callers, signature, and tests for a function in one call; `explain` gives structural summaries of files or functions |
185
+ | 🎯 | **Deep context** | `context` gives AI agents source, deps, callers, signature, and tests for a function in one call; `audit --quick` gives structural summaries of files or functions |
173
186
  | 📍 | **Fast lookup** | `where` shows exactly where a symbol is defined and used — minimal, fast |
174
187
  | 📊 | **Diff impact** | Parse `git diff`, find overlapping functions, trace their callers |
175
188
  | 🔗 | **Co-change analysis** | Analyze git history for files that always change together — surfaces hidden coupling the static graph can't see; enriches `diff-impact` with historically coupled files |
@@ -177,14 +190,14 @@ Full agent setup: [AI Agent Guide](docs/guides/ai-agent-guide.md) &middot; [CLAU
177
190
  | 🏗️ | **Structure & hotspots** | Directory cohesion scores, fan-in/fan-out hotspot detection, module boundaries |
178
191
  | 🏷️ | **Node role classification** | Every symbol auto-tagged as `entry`/`core`/`utility`/`adapter`/`dead`/`leaf` based on connectivity patterns — agents instantly know architectural role |
179
192
  | 🔄 | **Cycle detection** | Find circular dependencies at file or function level |
180
- | 📤 | **Export** | DOT (Graphviz), Mermaid, and JSON graph export |
193
+ | 📤 | **Export** | DOT, Mermaid, JSON, GraphML, GraphSON, and Neo4j CSV graph export |
181
194
  | 🧠 | **Semantic search** | Embeddings-powered natural language search with multi-query RRF ranking |
182
195
  | 👀 | **Watch mode** | Incrementally update the graph as files change |
183
196
  | 🤖 | **MCP server** | 30-tool MCP server for AI assistants; single-repo by default, opt-in multi-repo |
184
197
  | ⚡ | **Always fresh** | Three-tier incremental detection — sub-second rebuilds even on large codebases |
185
198
  | 🧮 | **Complexity metrics** | Cognitive, cyclomatic, nesting depth, Halstead, and Maintainability Index per function |
186
199
  | 🏘️ | **Community detection** | Louvain clustering to discover natural module boundaries and architectural drift |
187
- | 📜 | **Manifesto rule engine** | Configurable pass/fail rules with warn/fail thresholds for CI gates (exit code 1 on fail) |
200
+ | 📜 | **Manifesto rule engine** | Configurable pass/fail rules with warn/fail thresholds for CI gates via `check` (exit code 1 on fail) |
188
201
  | 👥 | **CODEOWNERS integration** | Map graph nodes to CODEOWNERS entries — see who owns each function, ownership boundaries in `diff-impact` |
189
202
  | 💾 | **Graph snapshots** | `snapshot save`/`restore` for instant DB backup and rollback — checkpoint before refactoring, restore without rebuilding |
190
203
  | 🔎 | **Hybrid BM25 + semantic search** | FTS5 keyword search + embedding-based semantic search fused via Reciprocal Rank Fusion — `hybrid`, `semantic`, or `keyword` modes |
@@ -195,6 +208,13 @@ Full agent setup: [AI Agent Guide](docs/guides/ai-agent-guide.md) &middot; [CLAU
195
208
  | 📋 | **Composite audit** | Single `audit` command combining explain + impact + health metrics per function — one call instead of 3-4 |
196
209
  | 🚦 | **Triage queue** | `triage` merges connectivity, hotspots, roles, and complexity into a ranked audit priority queue |
197
210
  | 📦 | **Batch querying** | Accept a list of targets and return all results in one JSON payload — enables multi-agent parallel dispatch |
211
+ | 🔬 | **Dataflow analysis** | Track how data moves through functions with `flows_to`, `returns`, and `mutates` edges — opt-in via `build --dataflow` (JS/TS) |
212
+ | 🧩 | **Control flow graph** | Intraprocedural CFG construction for all 11 languages — `cfg` command with text/DOT/Mermaid output, opt-in via `build --cfg` |
213
+ | 🔎 | **AST node querying** | Stored queryable AST nodes (calls, `new`, string, regex, throw, await) — `ast` command with SQL GLOB pattern matching |
214
+ | 🧬 | **Expanded node/edge types** | `parameter`, `property`, `constant` node kinds with `parent_id` for sub-declaration queries; `contains`, `parameter_of`, `receiver` edge kinds |
215
+ | 📊 | **Exports analysis** | `exports <file>` shows all exported symbols with per-symbol consumers, re-export detection, and counts |
216
+ | 📈 | **Interactive viewer** | `codegraph plot` generates an interactive HTML graph viewer with hierarchical/force/radial layouts, complexity overlays, and drill-down |
217
+ | 🏷️ | **Stable JSON schema** | `normalizeSymbol` utility ensures consistent 7-field output (name, kind, file, line, endLine, role, fileHash) across all commands |
198
218
 
199
219
  See [docs/examples](docs/examples) for real-world CLI and MCP usage examples.
200
220
 
@@ -222,6 +242,8 @@ codegraph stats # Graph health: nodes, edges, languages, quality
222
242
  codegraph roles # Node role classification (entry, core, utility, adapter, dead, leaf)
223
243
  codegraph roles --role dead -T # Find dead code (unreferenced, non-exported symbols)
224
244
  codegraph roles --role core --file src/ # Core symbols in src/
245
+ codegraph exports src/queries.js # Per-symbol consumer analysis (who calls each export)
246
+ codegraph children <name> # List parameters, properties, constants of a symbol
225
247
  ```
226
248
 
227
249
  ### Deep Context (AI-Optimized)
@@ -229,20 +251,20 @@ codegraph roles --role core --file src/ # Core symbols in src/
229
251
  ```bash
230
252
  codegraph context <name> # Full context: source, deps, callers, signature, tests
231
253
  codegraph context <name> --depth 2 --no-tests # Include callee source 2 levels deep
232
- codegraph explain <file> # Structural summary: public API, internals, data flow
233
- codegraph explain <function> # Function summary: signature, calls, callers, tests
254
+ codegraph audit <file> --quick # Structural summary: public API, internals, data flow
255
+ codegraph audit <function> --quick # Function summary: signature, calls, callers, tests
234
256
  ```
235
257
 
236
258
  ### Impact Analysis
237
259
 
238
260
  ```bash
239
261
  codegraph impact <file> # Transitive reverse dependency trace
240
- codegraph fn <name> # Function-level: callers, callees, call chain
241
- codegraph fn <name> --no-tests --depth 5
262
+ codegraph query <name> # Function-level: callers, callees, call chain
263
+ codegraph query <name> --no-tests --depth 5
242
264
  codegraph fn-impact <name> # What functions break if this one changes
243
- codegraph path <from> <to> # Shortest path between two symbols (A calls...calls B)
265
+ codegraph path <from> <to> # Shortest path between two symbols (A calls...calls B)
244
266
  codegraph path <from> <to> --reverse # Follow edges backward
245
- codegraph path <from> <to> --max-depth 5 --kinds calls,imports
267
+ codegraph path <from> <to> --depth 5 --kinds calls,imports
246
268
  codegraph diff-impact # Impact of unstaged git changes
247
269
  codegraph diff-impact --staged # Impact of staged changes
248
270
  codegraph diff-impact HEAD~3 # Impact vs a specific ref
@@ -273,8 +295,8 @@ Co-change data also enriches `diff-impact` — historically coupled files appear
273
295
 
274
296
  ```bash
275
297
  codegraph structure # Directory overview with cohesion scores
276
- codegraph hotspots # Files with extreme fan-in, fan-out, or density
277
- codegraph hotspots --metric coupling --level directory --no-tests
298
+ codegraph triage --level file # Files with extreme fan-in, fan-out, or density
299
+ codegraph triage --level directory --sort coupling --no-tests
278
300
  ```
279
301
 
280
302
  ### Code Health & Architecture
@@ -287,19 +309,38 @@ codegraph complexity --above-threshold -T # Only functions exceeding warn thres
287
309
  codegraph communities # Louvain community detection — natural module boundaries
288
310
  codegraph communities --drift -T # Drift analysis only — split/merge candidates
289
311
  codegraph communities --functions # Function-level community detection
290
- codegraph manifesto # Pass/fail rule engine (exit code 1 on fail)
291
- codegraph manifesto -T # Exclude test files from rule evaluation
312
+ codegraph check # Pass/fail rule engine (exit code 1 on fail)
313
+ codegraph check -T # Exclude test files from rule evaluation
292
314
  ```
293
315
 
316
+ ### Dataflow, CFG & AST
317
+
318
+ ```bash
319
+ codegraph dataflow <name> # Data flow edges for a function (flows_to, returns, mutates)
320
+ codegraph dataflow <name> --impact # Transitive data-dependent blast radius
321
+ codegraph cfg <name> # Control flow graph (text format)
322
+ codegraph cfg <name> --format dot # CFG as Graphviz DOT
323
+ codegraph cfg <name> --format mermaid # CFG as Mermaid diagram
324
+ codegraph ast # List all stored AST nodes
325
+ codegraph ast "handleAuth" # Search AST nodes by pattern (GLOB)
326
+ codegraph ast -k call # Filter by kind: call, new, string, regex, throw, await
327
+ codegraph ast -k throw --file src/ # Combine kind and file filters
328
+ ```
329
+
330
+ > **Note:** Dataflow requires `codegraph build --dataflow` (JS/TS only). CFG requires `codegraph build --cfg`. Both are opt-in to keep default builds fast.
331
+
294
332
  ### Audit, Triage & Batch
295
333
 
296
334
  Composite commands for risk-driven workflows and multi-agent dispatch.
297
335
 
298
336
  ```bash
299
- codegraph audit <file-or-function> # Combined explain + impact + health in one report
337
+ codegraph audit <file-or-function> # Combined structural summary + impact + health in one report
338
+ codegraph audit <target> --quick # Structural summary only (skip impact and health)
300
339
  codegraph audit src/queries.js -T # Audit all functions in a file
301
340
  codegraph triage # Ranked audit priority queue (connectivity + hotspots + roles)
302
341
  codegraph triage -T --limit 20 # Top 20 riskiest functions, excluding tests
342
+ codegraph triage --level file -T # File-level hotspot analysis
343
+ codegraph triage --level directory -T # Directory-level hotspot analysis
303
344
  codegraph batch target1 target2 ... # Batch query multiple targets in one call
304
345
  codegraph batch --json targets.json # Batch from a JSON file
305
346
  ```
@@ -309,7 +350,9 @@ codegraph batch --json targets.json # Batch from a JSON file
309
350
  `codegraph check` provides configurable pass/fail predicates for CI gates and state machines. Exit code 0 = pass, 1 = fail.
310
351
 
311
352
  ```bash
312
- codegraph check --staged # Check staged changes
353
+ codegraph check # Run manifesto rules on whole codebase
354
+ codegraph check --staged # Check staged changes (diff predicates)
355
+ codegraph check --staged --rules # Run both diff predicates AND manifesto rules
313
356
  codegraph check --no-new-cycles # Fail if staged changes introduce cycles
314
357
  codegraph check --max-complexity 30 # Fail if any function exceeds complexity threshold
315
358
  codegraph check --max-blast-radius 50 # Fail if blast radius exceeds limit
@@ -347,7 +390,11 @@ codegraph snapshot delete before-refactor # Delete a snapshot
347
390
  codegraph export -f dot # Graphviz DOT format
348
391
  codegraph export -f mermaid # Mermaid diagram
349
392
  codegraph export -f json # JSON graph
393
+ codegraph export -f graphml # GraphML (XML standard)
394
+ codegraph export -f graphson # GraphSON (TinkerPop v3 / Gremlin)
395
+ codegraph export -f neo4j # Neo4j CSV (bulk import, separate nodes/relationships files)
350
396
  codegraph export --functions -o graph.dot # Function-level, write to file
397
+ codegraph plot # Interactive HTML viewer with force/hierarchical/radial layouts
351
398
  codegraph cycles # Detect circular dependencies
352
399
  codegraph cycles --functions # Function-level cycles
353
400
  ```
@@ -413,12 +460,12 @@ codegraph registry remove <name> # Unregister
413
460
  | Flag | Description |
414
461
  |---|---|
415
462
  | `-d, --db <path>` | Custom path to `graph.db` |
416
- | `-T, --no-tests` | Exclude `.test.`, `.spec.`, `__test__` files (available on `fn`, `fn-impact`, `path`, `context`, `explain`, `where`, `diff-impact`, `search`, `map`, `hotspots`, `roles`, `co-change`, `deps`, `impact`, `complexity`, `communities`, `manifesto`, `branch-compare`, `audit`, `triage`, `check`) |
463
+ | `-T, --no-tests` | Exclude `.test.`, `.spec.`, `__test__` files (available on most query commands including `query`, `fn-impact`, `path`, `context`, `where`, `diff-impact`, `search`, `map`, `roles`, `co-change`, `deps`, `impact`, `complexity`, `communities`, `branch-compare`, `audit`, `triage`, `check`, `dataflow`, `cfg`, `ast`, `exports`, `children`) |
417
464
  | `--depth <n>` | Transitive trace depth (default varies by command) |
418
465
  | `-j, --json` | Output as JSON |
419
466
  | `-v, --verbose` | Enable debug output |
420
467
  | `--engine <engine>` | Parser engine: `native`, `wasm`, or `auto` (default: `auto`) |
421
- | `-k, --kind <kind>` | Filter by kind: `function`, `method`, `class`, `struct`, `enum`, `trait`, `record`, `module` (`fn`, `context`, `search`) |
468
+ | `-k, --kind <kind>` | Filter by kind: `function`, `method`, `class`, `interface`, `type`, `struct`, `enum`, `trait`, `record`, `module`, `parameter`, `property`, `constant` |
422
469
  | `-f, --file <path>` | Scope to a specific file (`fn`, `context`, `where`) |
423
470
  | `--mode <mode>` | Search mode: `hybrid` (default), `semantic`, or `keyword` (`search`) |
424
471
  | `--ndjson` | Output as newline-delimited JSON (one object per line) |
@@ -456,10 +503,11 @@ codegraph registry remove <name> # Unregister
456
503
  ```
457
504
 
458
505
  1. **Parse** — tree-sitter parses every source file into an AST (native Rust engine or WASM fallback)
459
- 2. **Extract** — Functions, classes, methods, interfaces, imports, exports, and call sites are extracted
506
+ 2. **Extract** — Functions, classes, methods, interfaces, imports, exports, call sites, parameters, properties, and constants are extracted
460
507
  3. **Resolve** — Imports are resolved to actual files (handles ESM conventions, `tsconfig.json` path aliases, `baseUrl`)
461
- 4. **Store** — Everything goes into SQLite as nodes + edges with tree-sitter node boundaries
462
- 5. **Query** — All queries run locally against the SQLite DB typically under 100ms
508
+ 4. **Store** — Everything goes into SQLite as nodes + edges with tree-sitter node boundaries, plus structural edges (`contains`, `parameter_of`, `receiver`)
509
+ 5. **Analyze** (opt-in) Complexity metrics, control flow graphs (`--cfg`), dataflow edges (`--dataflow`), and AST node storage
510
+ 6. **Query** — All queries run locally against the SQLite DB — typically under 100ms
463
511
 
464
512
  ### Incremental Rebuilds
465
513
 
@@ -505,12 +553,12 @@ Self-measured on every release via CI ([build benchmarks](generated/benchmarks/B
505
553
  | Metric | Latest |
506
554
  |---|---|
507
555
  | Build speed (native) | **1.9 ms/file** |
508
- | Build speed (WASM) | **7.8 ms/file** |
509
- | Query time | **2ms** |
510
- | No-op rebuild (native) | **3ms** |
511
- | 1-file rebuild (native) | **93ms** |
512
- | Query: fn-deps | **1.8ms** |
513
- | Query: path | **1ms** |
556
+ | Build speed (WASM) | **8.3 ms/file** |
557
+ | Query time | **3ms** |
558
+ | No-op rebuild (native) | **4ms** |
559
+ | 1-file rebuild (native) | **124ms** |
560
+ | Query: fn-deps | **1.4ms** |
561
+ | Query: path | **1.4ms** |
514
562
  | ~50,000 files (est.) | **~95.0s build** |
515
563
 
516
564
  Metrics are normalized per file for cross-version comparability. Times above are for a full initial build — incremental rebuilds only re-parse changed files.
@@ -556,7 +604,7 @@ This project uses codegraph. The database is at `.codegraph/graph.db`.
556
604
 
557
605
  ### Before modifying code, always:
558
606
  1. `codegraph where <name>` — find where the symbol lives
559
- 2. `codegraph explain <file-or-function>` — understand the structure
607
+ 2. `codegraph audit <file-or-function> --quick` — understand the structure
560
608
  3. `codegraph context <name> -T` — get full context (source, deps, callers)
561
609
  4. `codegraph fn-impact <name> -T` — check blast radius before editing
562
610
 
@@ -566,7 +614,7 @@ This project uses codegraph. The database is at `.codegraph/graph.db`.
566
614
  ### Other useful commands
567
615
  - `codegraph build .` — rebuild the graph (incremental by default)
568
616
  - `codegraph map` — module overview
569
- - `codegraph fn <name> -T` — function call chain
617
+ - `codegraph query <name> -T` — function call chain (callers + callees)
570
618
  - `codegraph path <from> <to> -T` — shortest call path between two symbols
571
619
  - `codegraph deps <file>` — file-level dependencies
572
620
  - `codegraph roles --role dead -T` — find dead code (unreferenced symbols)
@@ -574,14 +622,21 @@ This project uses codegraph. The database is at `.codegraph/graph.db`.
574
622
  - `codegraph co-change <file>` — files that historically change together
575
623
  - `codegraph complexity -T` — per-function complexity metrics (cognitive, cyclomatic, MI)
576
624
  - `codegraph communities --drift -T` — module boundary drift analysis
577
- - `codegraph manifesto -T` — pass/fail rule check (CI gate, exit code 1 on fail)
578
- - `codegraph audit <target> -T` — combined explain + impact + health in one report
625
+ - `codegraph check -T` — pass/fail rule check (CI gate, exit code 1 on fail)
626
+ - `codegraph audit <target> -T` — combined structural summary + impact + health in one report
579
627
  - `codegraph triage -T` — ranked audit priority queue
628
+ - `codegraph triage --level file -T` — file-level hotspot analysis
580
629
  - `codegraph check --staged` — CI validation predicates (exit code 0/1)
581
630
  - `codegraph batch target1 target2` — batch query multiple targets at once
582
631
  - `codegraph owners [target]` — CODEOWNERS mapping for symbols
583
632
  - `codegraph snapshot save <name>` — checkpoint the graph DB before refactoring
584
633
  - `codegraph branch-compare main HEAD -T` — structural diff between two refs (added/removed/changed symbols)
634
+ - `codegraph exports <file>` — per-symbol consumer analysis (who calls each export)
635
+ - `codegraph children <name>` — list parameters, properties, constants of a symbol
636
+ - `codegraph dataflow <name>` — data flow edges (flows_to, returns, mutates)
637
+ - `codegraph cfg <name>` — intraprocedural control flow graph
638
+ - `codegraph ast <pattern>` — search stored AST nodes (calls, new, string, regex, throw, await)
639
+ - `codegraph plot` — interactive HTML dependency graph viewer
585
640
  - `codegraph search "<query>"` — hybrid search (requires `codegraph embed`)
586
641
  - `codegraph search "<query>" --mode keyword` — BM25 keyword search
587
642
  - `codegraph cycles` — check for circular dependencies
@@ -665,7 +720,7 @@ Create a `.codegraphrc.json` in your project root to customize behavior:
665
720
 
666
721
  ### Manifesto rules
667
722
 
668
- Configure pass/fail thresholds for `codegraph manifesto`:
723
+ Configure pass/fail thresholds for `codegraph check` (manifesto mode):
669
724
 
670
725
  ```json
671
726
  {
@@ -681,7 +736,7 @@ Configure pass/fail thresholds for `codegraph manifesto`:
681
736
  }
682
737
  ```
683
738
 
684
- When any function exceeds a `fail` threshold, `codegraph manifesto` exits with code 1 — perfect for CI gates.
739
+ When any function exceeds a `fail` threshold, `codegraph check` exits with code 1 — perfect for CI gates.
685
740
 
686
741
  ### LLM credentials
687
742
 
@@ -705,13 +760,14 @@ Works with any secret manager: 1Password CLI (`op`), Bitwarden (`bw`), `pass`, H
705
760
  Codegraph also exports a full API for use in your own tools:
706
761
 
707
762
  ```js
708
- import { buildGraph, queryNameData, findCycles, exportDOT } from '@optave/codegraph';
763
+ import { buildGraph, queryNameData, findCycles, exportDOT, normalizeSymbol } from '@optave/codegraph';
709
764
 
710
765
  // Build the graph
711
766
  buildGraph('/path/to/project');
712
767
 
713
768
  // Query programmatically
714
769
  const results = queryNameData('myFunction', '/path/to/.codegraph/graph.db');
770
+ // All query results use normalizeSymbol for a stable 7-field schema
715
771
  ```
716
772
 
717
773
  ```js
@@ -748,6 +804,7 @@ const { results: fused } = await multiSearchData(
748
804
  - **No full type inference** — parses `.d.ts` interfaces but doesn't use TypeScript's type checker for overload resolution
749
805
  - **Dynamic calls are best-effort** — complex computed property access and `eval` patterns are not resolved
750
806
  - **Python imports** — resolves relative imports but doesn't follow `sys.path` or virtual environment packages
807
+ - **Dataflow analysis** — currently JS/TS only; intraprocedural (single-function scope), not interprocedural
751
808
 
752
809
  ## 🗺️ Roadmap
753
810
 
@@ -755,12 +812,12 @@ See **[ROADMAP.md](docs/roadmap/ROADMAP.md)** for the full development roadmap a
755
812
 
756
813
  1. ~~**Rust Core**~~ — **Complete** (v1.3.0) — native tree-sitter parsing via napi-rs, parallel multi-core parsing, incremental re-parsing, import resolution & cycle detection in Rust
757
814
  2. ~~**Foundation Hardening**~~ — **Complete** (v1.4.0) — parser registry, 12-tool MCP server with multi-repo support, test coverage 62%→75%, `apiKeyCommand` secret resolution, global repo registry
758
- 3. **Architectural Refactoring** — parser plugin system, repository pattern, pipeline builder, engine strategy, domain errors, curated API
759
- 4. **Intelligent Embeddings** — LLM-generated descriptions, hybrid search
815
+ 3. ~~**Deep Analysis**~~ — **Complete** (v3.0.0) dataflow analysis (flows_to, returns, mutates), intraprocedural CFG for all 11 languages, stored AST nodes, expanded node/edge types (parameter, property, constant, contains, parameter_of, receiver), GraphML/GraphSON/Neo4j CSV export, interactive HTML viewer, CLI consolidation, stable JSON schema
816
+ 4. **Architectural Refactoring** — parser plugin system, repository pattern, pipeline builder, engine strategy, domain errors, curated API
760
817
  5. **Natural Language Queries** — `codegraph ask` command, conversational sessions
761
818
  6. **Expanded Language Support** — 8 new languages (12 → 20)
762
819
  7. **GitHub Integration & CI** — reusable GitHub Action, PR review, SARIF output
763
- 8. **Visualization & Advanced** — web UI, monorepo support, agentic search
820
+ 8. **TypeScript Migration** — gradual migration from JS to TypeScript
764
821
 
765
822
  ## 🤝 Contributing
766
823
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optave/codegraph",
3
- "version": "2.6.0",
3
+ "version": "3.0.0",
4
4
  "description": "Local code graph CLI — parse codebases with tree-sitter, build dependency graphs, query them",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -71,10 +71,10 @@
71
71
  },
72
72
  "optionalDependencies": {
73
73
  "@modelcontextprotocol/sdk": "^1.0.0",
74
- "@optave/codegraph-darwin-arm64": "2.6.0",
75
- "@optave/codegraph-darwin-x64": "2.6.0",
76
- "@optave/codegraph-linux-x64-gnu": "2.6.0",
77
- "@optave/codegraph-win32-x64-msvc": "2.6.0"
74
+ "@optave/codegraph-darwin-arm64": "3.0.0",
75
+ "@optave/codegraph-darwin-x64": "3.0.0",
76
+ "@optave/codegraph-linux-x64-gnu": "3.0.0",
77
+ "@optave/codegraph-win32-x64-msvc": "3.0.0"
78
78
  },
79
79
  "devDependencies": {
80
80
  "@biomejs/biome": "^2.4.4",