feat: CLI-first expansion — 10 subcommands + CommonJS require() parsing#95
Conversation
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
Update: Shared post-processing pipeline (addresses #93)After reviewing PR #98's approach to fixing #93, I've adopted the same architectural pattern in this PR — but went further: What changed (commit
|
| Aspect | This PR (#95) | PR #98 |
|---|---|---|
Shared postprocessing.py |
✅ | ✅ |
tools/build.py refactored |
✅ (-62 lines) | ✅ (-68 lines) |
watch callback |
✅ | ✅ |
| 10 CLI subcommands | ✅ | ❌ |
| CommonJS require() parsing | ✅ | ❌ |
sys.exit(1) on missing graph |
✅ | ❌ |
| IndexError fix | ✅ | ❌ |
| Callable type annotation | ✅ | ❌ |
| Tests for post-processing | ✅ (9 tests) | ✅ (18 tests) |
If #98 merges first, rebasing this PR is straightforward — just drop the postprocessing.py creation and keep everything else.
Test results
574 passed, 5 skipped, 2 xpassed (full suite)
9 passed (new postprocessing tests)
ruff: 0 errors
|
@murilloimparavel add some more tests, and would suggest to keep a bug fix separate from the feature you are adding. |
tirth8205
left a comment
There was a problem hiding this comment.
Large feature PR — 10 CLI subcommands + CommonJS require() parsing. The CommonJS piece is unique value.
A few notes:
Review: PR #95 — feat: CLI-first expansion and CommonJS require() parsingGood feature work. The 10 new CLI subcommands directly expose the 22 MCP tool functions and CommonJS require() parsing is independently valuable. Merge order dependency: The owner confirmed this should merge AFTER #98 (which handles the post-processing extraction more cleanly). Once #98 merges, this PR needs a rebase to avoid duplicating the postprocessing.py creation — as the author noted, 'rebasing this PR is straightforward — just drop the postprocessing.py creation and keep everything else.' Code review findings:
Verdict: Rebase after #98 merges, resolve post-processing duplication, then this is ready. |
|
Merge conflict detected. This PR has merge conflicts with main (mergeStateStatus: DIRTY). This is expected given the large cli.py changes and the post-processing overlap. Please rebase on main after PR #94 and #98 merge (as the owner instructed). The rebase strategy: keep the 10 new CLI subcommands and CommonJS parsing, drop the postprocessing.py creation (it will already exist from #98). |
…rsing Adds 10 new CLI subcommands that expose MCP tool functions directly, enabling CLI-first workflows without requiring the MCP server: query, impact, search, flows, flow, communities, community, architecture, large-functions, refactor Also adds CLI post-processing after build/update (fixes tirth8205#93): - Signature computation - FTS5 index rebuild - Execution flow detection - Community detection CommonJS require() parsing (parser.py): - `_js_get_require_target()`: extracts module paths from require(), path.join(), path.resolve(), template literals, dynamic import() - `_extract_js_require_constructs()`: creates IMPORTS_FROM edges - `_collect_js_require_names()`: populates import map for call resolution - Empty-string guards at all call sites - Depth-limited recursion (max_depth=50) for nested require walks Results on test monorepo (14.5K files): - IMPORTS_FROM edges increased 4x (525 → 2,075) - Flows detected: 1,185 - Communities: 605 - FTS indexed: 7,766 nodes CLI UX improvements: - Updated banner and docstring with all new commands - "Graph not built" warning when DB is missing - Argparse validation for flow/community (require --id or --name) - Argparse validation for refactor rename (require --old-name/--new-name) - DELEGATED_COMMANDS skip redundant GraphStore creation Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Rebased on latest main and resolved merge conflicts:
|
dd6b639 to
b437ba9
Compare
|
Skipping auto-merge: after updating against current ruff (4 errors):
mypy (9 errors, all in cli.py:217–251): the new subcommand dispatch uses Please run |
Summary
Exposes all 22 MCP tool functions as direct CLI subcommands, enabling CLI-first workflows without requiring the MCP server. Also adds CommonJS
require()parsing for JavaScript codebases that use dynamic imports.New CLI subcommands
query <pattern> <target>impact [--files] [--depth]search <query> [--kind]flows [--sort] [--limit]flow [--id | --name]communities [--sort]community [--id | --name]architecturelarge-functions [--min-lines]refactor <mode>CLI post-processing (fixes #93)
buildandupdatecommands now run the same post-processing as the MCP tool:CommonJS require() parsing
Three new methods in
parser.py:_js_get_require_target(): extracts module paths fromrequire(),path.join(),path.resolve(), template literals,dynamic import()_extract_js_require_constructs(): createsIMPORTS_FROMedges for CommonJS patterns_collect_js_require_names(): populates import map for call resolutionResults on test monorepo (14.5K files):
CLI UX improvements
flow/communityrequire--idor--namerefactor renamerequires--old-name/--new-nameDELEGATED_COMMANDSset skips redundant GraphStore creationTest plan
require('')andrequire()handled gracefully (no crash, no empty edges)bin/crg repos,bin/crg --version,bin/crg --helpwork without--repo🤖 Generated with Claude Code