refactor: consolidate CLI by removing 5 redundant commands#280
refactor: consolidate CLI by removing 5 redundant commands#280carlos-alm merged 18 commits intomainfrom
Conversation
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
…se 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
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
…w, 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
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
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
…back Impact: 36 functions changed, 24 affected
- 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.
Greptile SummaryConsolidates CLI by removing 5 redundant commands (
All data functions, MCP tools, and programmatic API remain unchanged. Tests updated to reflect new CLI structure. Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Old CLI Commands] --> B{Command Consolidation}
B -->|batch-query| C[Removed - use batch API]
B -->|hotspots| D[triage --level file/directory]
B -->|manifesto| E[check with no args]
B -->|explain| F[audit --quick]
B -->|query --path| G[path from to]
D --> H[hotspotsData]
E --> I[manifesto]
F --> J[explain]
G --> K[symbolPath]
L[check ref/--staged] --> M{--rules flag?}
M -->|Yes| N[Run check then manifesto]
M -->|No| O[Run check only]
P[query --path] --> Q[Deprecation warning]
Q --> K
style C fill:#ffcccc
style D fill:#ccffcc
style E fill:#ccffcc
style F fill:#ccffcc
style G fill:#ccffcc
Last reviewed commit: 82360a6 |
src/cli.js
Outdated
| .option('--limit <number>', 'Max results to return') | ||
| .option('--offset <number>', 'Skip N results (default: 0)') | ||
| .option('--ndjson', 'Newline-delimited JSON output') |
There was a problem hiding this comment.
--limit, --offset, and --ndjson options are unused. symbolPath finds a single shortest path, so pagination doesn't apply here.
| .option('--limit <number>', 'Max results to return') | |
| .option('--offset <number>', 'Skip N results (default: 0)') | |
| .option('--ndjson', 'Newline-delimited JSON output') | |
| .option('-j, '--json', 'Output as JSON') | |
| .action((from, to, opts) => { |
There was a problem hiding this comment.
Removed , , and \ from the \ command — \ returns a single shortest path so pagination doesn't apply.
There was a problem hiding this comment.
Removed --limit, --offset, and --ndjson from the path command. symbolPath returns a single shortest path so pagination does not apply.
Kept full ast command body from main. Did not restore standalone manifesto command since PR #280 consolidated it into check. Impact: 1 functions changed, 14 affected
Kept full ast command body from main. Did not restore standalone manifesto command since PR #280 consolidated it into check. Impact: 1 functions changed, 14 affected
|
Claude finished @carlos-alm's task —— View job PR Review: CLI Command ConsolidationAnalysis Todo List:
Phase 1 Analysis: ✅ CLEAR PROBLEM SOLVINGProblem Being Solved: CLI command proliferation - the codebase had 5 redundant commands that created confusion and maintenance overhead:
Why This Approach: Legitimate consolidation that maintains all functionality while providing cleaner UX. The approach preserves backward compatibility (e.g., deprecation warning for Risk Assessment: LOW - This is genuine refactoring, not symptom hiding. Phase 2 Analysis: ✅ NO RISKY CONFIG CHANGESConfiguration Files Checked:
Assessment: CLEAN - No configuration changes detected that would lower code quality standards. Phase 3 Analysis: ✅ STRONG TEST INTEGRITYTest Changes Reviewed:
Key Evidence:
Assessment: EXCELLENT - Tests demonstrate the consolidation works correctly, no integrity compromised. Phase 4 Analysis:
|
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).
…m/optave/codegraph into refactor/consolidate-cli-commands Impact: 1 functions changed, 1 affected
|
Claude finished @carlos-alm's task —— View job Claude finished @carlos-alm's task —— View job PR Review: CLI Command ConsolidationAnalysis Todo List:
Phase 1 Analysis: ✅ CLEAR PROBLEM SOLVINGProblem Being Solved: CLI command proliferation - the codebase had 5 redundant commands that created confusion and maintenance overhead:
Why This Approach: Legitimate consolidation that maintains all functionality while providing cleaner UX. The approach preserves backward compatibility (e.g., deprecation warning for Risk Assessment: LOW - This is genuine refactoring, not symptom hiding. Phase 2 Analysis: ✅ NO RISKY CONFIG CHANGESConfiguration Files Checked:
Assessment: CLEAN - No configuration changes detected that would lower code quality standards. Phase 3 Analysis: ✅ STRONG TEST INTEGRITYTest Changes Reviewed:
Key Evidence:
Assessment: EXCELLENT - Tests demonstrate the consolidation works correctly, no integrity compromised. Phase 4 Analysis:
|
36c6468 to
826c3c9
Compare
|
Claude finished @carlos-alm's task —— View job PR Review Todo List:
Phase 1 Analysis: ✅ CLEAR PROBLEM SOLVINGProblem Being Solved: CLI command proliferation - the codebase had 5 redundant commands that created confusion and maintenance overhead:
Why This Approach: Legitimate consolidation that maintains all functionality while providing cleaner UX. The approach preserves backward compatibility (e.g., deprecation warning for Risk Assessment: LOW - This is genuine refactoring, not symptom hiding. Phase 2 Analysis: ✅ NO RISKY CONFIG CHANGESConfiguration Files Checked:
Assessment: CLEAN - No configuration changes detected that would lower code quality standards. Phase 3 Analysis: ✅ STRONG TEST INTEGRITYTest Changes Reviewed:
Key Evidence:
Assessment: EXCELLENT - Tests demonstrate the consolidation works correctly, no integrity compromised. Phase 4 Analysis:
|
Docs updates belong in a separate PR. This reverts commit bd7af72 and the remind-codegraph.sh change from the merge commit.
…m/optave/codegraph into refactor/consolidate-cli-commands
Docs updates moved to separate PR #282.
|
Claude finished @carlos-alm's task —— View job PR Review Todo List:
Phase 1 Analysis: ✅ CLEAR PROBLEM SOLVINGProblem Being Solved: CLI command proliferation - the codebase had 5 redundant commands that created confusion and maintenance overhead:
Why This Approach: Legitimate consolidation that maintains all functionality while providing cleaner UX. The approach preserves backward compatibility (e.g., deprecation warning for Risk Assessment: LOW - This is genuine refactoring, not symptom hiding. Phase 2 Analysis: ✅ NO RISKY CONFIG CHANGESConfiguration Files Checked:
Assessment: CLEAN - No configuration changes detected that would lower code quality standards. Phase 3 Analysis: ✅ STRONG TEST INTEGRITYTest Changes Reviewed:
Key Evidence:
Assessment: EXCELLENT - Tests demonstrate the consolidation works correctly, no integrity compromised. Phase 4 Analysis:
|
24420a1 to
b7883ca
Compare
|
Claude finished @carlos-alm's task —— View job PR Review Todo List:
Phase 1 Analysis: ✅ CLEAR PROBLEM SOLVINGProblem Being Solved: CLI command proliferation - the codebase had 5 redundant commands that created confusion and maintenance overhead:
Why This Approach: Legitimate consolidation that maintains all functionality while providing cleaner UX. The approach preserves backward compatibility (e.g., deprecation warning for Risk Assessment: LOW - This is genuine refactoring, not symptom hiding. Phase 2 Analysis: ✅ NO RISKY CONFIG CHANGESConfiguration Files Checked:
Assessment: CLEAN - No configuration changes detected that would lower code quality standards. Phase 3 Analysis: ✅ STRONG TEST INTEGRITYTest Changes Reviewed:
Key Evidence:
Assessment: EXCELLENT - Tests demonstrate the consolidation works correctly, no integrity compromised. Phase 4 Analysis:
|
|
Claude finished @carlos-alm's task —— View job PR Review Todo List:
Phase 1 Analysis: ✅ CLEAR PROBLEM SOLVINGProblem Being Solved: CLI command proliferation - the codebase had 5 redundant commands that created confusion and maintenance overhead:
Why This Approach: Legitimate consolidation that maintains all functionality while providing cleaner UX. The approach preserves backward compatibility (e.g., deprecation warning for Risk Assessment: LOW - This is genuine refactoring, not symptom hiding. Phase 2 Analysis: ✅ NO RISKY CONFIG CHANGESConfiguration Files Checked:
Assessment: CLEAN - No configuration changes detected that would lower code quality standards. Phase 3 Analysis: ✅ STRONG TEST INTEGRITYTest Changes Reviewed:
Key Evidence:
Assessment: EXCELLENT - Tests demonstrate the consolidation works correctly, no integrity compromised. Phase 4 Analysis:
|
|
Claude finished @carlos-alm's task —— View job PR Review Todo List:
Phase 1 Analysis: ✅ GREPTILE FEEDBACK ADDRESSEDGreptile Issue: Unused Status: ✅ RESOLVED - I verified that the
The problematic pagination options ( Phase 2 Analysis: ✅ EXCELLENT CLI CONSOLIDATIONConsolidation Strategy Verified:
Backward Compatibility: ✅ Deprecation warning properly implemented for Phase 3 Analysis: ✅ COMPREHENSIVE TEST COVERAGETest Updates Verified:
Bug Fix Bonus: ✅ CI Status: ✅ All checks passing - 6 successful runs, 0 failures Phase 4 Analysis: ✅ EXCELLENT CODE QUALITYSecurity Review: ✅ CLEAN - No command injection, SQL injection, or path traversal issues detected Architecture Preservation: ✅ MAINTAINED - All data functions preserved in
Performance: ✅ OPTIMIZED - Consolidation reduces CLI complexity without sacrificing functionality Maintainability: ✅ IMPROVED - Fewer commands to maintain, cleaner user experience, logical grouping Final Recommendation
Why This PR Excels:
Key Strengths:
This is exemplary refactoring work that improves the codebase without sacrificing functionality or introducing risk. |
Keep normalizeSymbol spread usage from feature branch; main had inlined the same fields that normalizeSymbol produces. Impact: 43 functions changed, 42 affected
…se 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 affected

Summary
batch-query— redundant withbatch where t1 t2hotspotsintotriage --level file|directory— delegates tohotspotsData()when level is file/directory, defaults--sort risktofan-inmanifestointocheck—check(no args) runs manifesto rules;check --staged/check <ref>runs diff predicates;check --staged --rulesruns bothexplainwithaudit --quick—audit --quickcallsexplain()directly, skipping impact/healthpath <from> <to>— dedicated shortest-path command;query --pathstill works but prints deprecation warning to stderrAll data functions, MCP tools, and programmatic API (
index.js) are unchanged.Test plan
npm run lintpasses (pre-existing warning only)triage --level file -Tworks (washotspots)triage --level directory -Tworks (washotspots --level directory)check -Truns manifesto rules (wasmanifesto)check --staged -Truns diff predicates (unchanged)audit src/builder.js --quick -Tworks (wasexplain)path buildGraph openDb -Tworks (new command)query buildGraph --path openDb -Tprints deprecation warning