Commit 4f08082
authored
refactor: consolidate CLI by removing 5 redundant commands (#280)
* feat: add normalizeSymbol utility for stable JSON schema
Add normalizeSymbol(row, db, hashCache) that returns a consistent
7-field symbol shape (name, kind, file, line, endLine, role, fileHash)
across all query and search commands.
Update queryNameData, fnDepsData, fnImpactData, explainFunctionImpl,
listFunctionsData, rolesData, whereSymbolImpl in queries.js and
searchData, multiSearchData, ftsSearchData, hybridSearchData in
embedder.js to use normalizeSymbol. Update SQL in listFunctionsData,
rolesData, iterListFunctions, iterRoles, _prepareSearch, and
ftsSearchData to include end_line and role columns.
Export normalizeSymbol from index.js. Add docs/json-schema.md
documenting the stable schema. Add 8 unit tests and 7 integration
schema conformance tests.
Impact: 13 functions changed, 33 affected
Impact: 14 functions changed, 42 affected
* feat: add expanded edge types — contains, parameter_of, receiver (Phase 2)
Build file→definition and parent→child contains edges, parameter_of
inverse edges, and receiver edges for method-call dispatch. Add
CORE_EDGE_KINDS, STRUCTURAL_EDGE_KINDS, EVERY_EDGE_KIND constants.
Exclude structural edges from moduleMapData coupling counts. Scope
directory contains-edge cleanup to preserve symbol-level edges.
Impact: 3 functions changed, 22 affected
* feat: add intraprocedural control flow graph (CFG) construction
Add opt-in CFG analysis that builds basic-block control flow graphs
from tree-sitter AST for individual functions. Enables complexity-aware
impact analysis and opens the path to dataflow (def-use chains).
- DB migration v12: cfg_blocks + cfg_edges tables
- New src/cfg.js module: CFG_RULES, buildFunctionCFG, buildCFGData,
cfgData, cfgToDOT, cfgToMermaid, cfg CLI printer
- Builder integration: --cfg flag triggers CFG after complexity pass
- CLI: `cfg <name>` command with --format text/dot/mermaid, -j, --ndjson
- MCP: cfg tool with name, format, file, kind, pagination props
- Exports findFunctionNode from complexity.js for reuse
- 24 unit tests + 11 integration tests (35 total)
Phase 1: JS/TS/TSX only. Handles if/else, for/while/do-while, switch,
try/catch/finally, break/continue (with labels), return/throw.
Impact: 27 functions changed, 36 affected
* feat: add stored queryable AST nodes (calls, new, string, regex, throw, await)
Persist selected AST nodes in a dedicated ast_nodes SQLite table during
build, queryable via CLI (codegraph ast), MCP (ast_query), and
programmatic API.
- DB migration v13: ast_nodes table with indexes on kind, name, file,
parent, and (kind,name)
- New src/ast.js module: buildAstNodes (extraction), astQueryData/
astQuery (query), AST_NODE_KINDS constant
- Builder integration: full-rebuild deletion, incremental cleanup,
always-on post-parse extraction (before complexity to preserve _tree)
- CLI: codegraph ast [pattern] with -k, -f, -T, -j, --ndjson,
--limit, --offset options
- MCP: ast_query tool with pattern, kind, file, no_tests, pagination
- JS/TS/TSX Phase 1: full AST walk for new/throw/await/string/regex;
all languages get call nodes from symbols.calls
- Pattern matching uses SQL GLOB with auto-wrapping for substring search
- Parent node resolution via narrowest enclosing definition
Impact: 12 functions changed, 26 affected
* fix: correct misleading comment for break without enclosing loop/switch
The comment incorrectly suggested this code path handled break inside
switch cases. It actually handles break with no enclosing loop/switch
context (invalid syntax) as a no-op.
Impact: 2 functions changed, 9 affected
* feat: add `exports <file>` command for per-symbol consumer analysis
Show all exported symbols of a file with their consumers (who calls
each export from other files), re-export detection, and counts.
Available as CLI command, MCP tool (file_exports), batch command, and
programmatic API (exportsData/fileExports).
Impact: 5 functions changed, 8 affected
* refactor: consolidate CLI by removing 5 redundant commands
- Remove `batch-query` (use `batch where` instead)
- Fold `hotspots` into `triage --level file|directory`
- Merge `manifesto` into `check` (no args = manifesto, --rules for both)
- Replace `explain` with `audit --quick`
- Add standalone `path <from> <to>`, deprecate `query --path`
All data functions, MCP tools, and programmatic API unchanged.
* docs: update all docs to reflect CLI consolidation
Update command references across all documentation:
- `codegraph explain` → `codegraph audit --quick`
- `codegraph hotspots` → `codegraph triage --level`
- `codegraph manifesto` → `codegraph check`
- Add `codegraph path` references
MCP tool references are left unchanged (backward compat).
* revert: remove docs changes from CLI consolidation PR
Docs updates belong in a separate PR. This reverts commit bd7af72
and the remind-codegraph.sh change from the merge commit.
* revert: remove docs changes from CLI consolidation PR
Docs updates moved to separate PR #282.
* fix: remove unused --limit, --offset, --ndjson from path command
* feat: expand node types with parameter, property, constant kinds (Phase 1)
Add sub-declaration node extraction to all 9 WASM language extractors,
enabling structural queries like "which functions take a Request param?"
or "which classes have a userId field?" without reading source code.
Schema: migration v11 adds nullable parent_id column with indexes.
Builder: insertNode links children to parent via parent_id FK.
Extractors: JS/TS, Python, Go, Rust, Java, C#, Ruby, PHP, HCL now
emit children arrays for parameters, properties, and constants.
Queries: new childrenData() function, children in contextData output.
CLI: new `children` command, EVERY_SYMBOL_KIND validation on --kind.
MCP: new `symbol_children` tool, extended kind enum on all kind fields.
Constants: CORE_SYMBOL_KINDS (10), EXTENDED_SYMBOL_KINDS (3),
EVERY_SYMBOL_KIND (13). ALL_SYMBOL_KINDS preserved for backward compat.
Native Rust engine: Definition struct gains children field but actual
extraction is deferred to Phase 2 — WASM fallback handles new kinds.
Impact: 63 functions changed, 62 affected1 parent aa8fb42 commit 4f08082
File tree
4 files changed
+175
-188
lines changed- src
- tests/integration
4 files changed
+175
-188
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
166 | 167 | | |
167 | 168 | | |
168 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
169 | 200 | | |
170 | 201 | | |
171 | 202 | | |
| |||
341 | 372 | | |
342 | 373 | | |
343 | 374 | | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | 375 | | |
367 | 376 | | |
368 | 377 | | |
369 | 378 | | |
370 | | - | |
| 379 | + | |
| 380 | + | |
371 | 381 | | |
372 | 382 | | |
373 | 383 | | |
374 | 384 | | |
375 | 385 | | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
376 | 389 | | |
377 | 390 | | |
378 | 391 | | |
379 | 392 | | |
380 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
381 | 405 | | |
382 | 406 | | |
383 | 407 | | |
| |||
443 | 467 | | |
444 | 468 | | |
445 | 469 | | |
446 | | - | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
447 | 473 | | |
448 | 474 | | |
| 475 | + | |
449 | 476 | | |
450 | 477 | | |
451 | 478 | | |
452 | 479 | | |
453 | 480 | | |
| 481 | + | |
| 482 | + | |
454 | 483 | | |
455 | 484 | | |
456 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
457 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
458 | 512 | | |
459 | 513 | | |
460 | 514 | | |
| |||
467 | 521 | | |
468 | 522 | | |
469 | 523 | | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
470 | 542 | | |
471 | 543 | | |
472 | 544 | | |
| |||
925 | 997 | | |
926 | 998 | | |
927 | 999 | | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | 1000 | | |
961 | 1001 | | |
962 | 1002 | | |
| |||
1226 | 1266 | | |
1227 | 1267 | | |
1228 | 1268 | | |
1229 | | - | |
1230 | | - | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
1252 | | - | |
1253 | | - | |
1254 | | - | |
1255 | | - | |
1256 | | - | |
1257 | | - | |
1258 | 1269 | | |
1259 | 1270 | | |
1260 | 1271 | | |
| |||
1289 | 1300 | | |
1290 | 1301 | | |
1291 | 1302 | | |
1292 | | - | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
1293 | 1313 | | |
1294 | 1314 | | |
1295 | 1315 | | |
| |||
1301 | 1321 | | |
1302 | 1322 | | |
1303 | 1323 | | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
1304 | 1345 | | |
1305 | 1346 | | |
1306 | 1347 | | |
| |||
1513 | 1554 | | |
1514 | 1555 | | |
1515 | 1556 | | |
1516 | | - | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
1521 | | - | |
1522 | | - | |
1523 | | - | |
1524 | | - | |
1525 | | - | |
1526 | | - | |
1527 | | - | |
1528 | | - | |
1529 | | - | |
1530 | | - | |
1531 | | - | |
1532 | | - | |
1533 | | - | |
1534 | | - | |
1535 | | - | |
1536 | | - | |
1537 | | - | |
1538 | | - | |
1539 | | - | |
1540 | | - | |
1541 | | - | |
1542 | | - | |
1543 | | - | |
1544 | | - | |
1545 | | - | |
1546 | | - | |
1547 | | - | |
1548 | | - | |
1549 | | - | |
1550 | | - | |
1551 | | - | |
1552 | | - | |
1553 | | - | |
1554 | | - | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
1566 | | - | |
1567 | | - | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
1571 | | - | |
1572 | | - | |
1573 | | - | |
1574 | 1557 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
810 | 810 | | |
811 | 811 | | |
812 | 812 | | |
| 813 | + | |
813 | 814 | | |
814 | 815 | | |
815 | 816 | | |
816 | 817 | | |
817 | 818 | | |
818 | | - | |
819 | 819 | | |
820 | 820 | | |
821 | 821 | | |
| |||
0 commit comments