feat: CLI-first expansion — 10 subcommands + CommonJS require() parsing#95
Open
murilloimparavel wants to merge 1 commit intotirth8205:mainfrom
Open
Conversation
…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>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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