feat: CLI parity with MCP — 15 commands, shared core extraction#16
Merged
feat: CLI parity with MCP — 15 commands, shared core extraction#16
Conversation
Add 10 new CLI subcommands (dependents, modules, forces, dead-exports, groups, symbol, impact, rename, processes, clusters) giving the CLI full feature parity with all 15 MCP tools. Extract 8 compute functions into src/core/index.ts and refactor both MCP handlers and CLI to use the shared core — eliminating ~200 lines of duplicated logic. Add 22 integration tests for new compute functions. Update all docs (cli-reference, AGENTS.md, llms.txt, llms-full.txt). CI now runs on push to main with Node 18+22 matrix.
Use --no-file-parallelism for coverage runs in CI to prevent "Timeout calling onTaskUpdate" errors caused by v8 coverage instrumentation overwhelming worker IPC on single-core runners. Also add teardownTimeout to vitest config.
The default threads pool causes "Timeout calling onTaskUpdate" when v8 coverage instrumentation slows worker IPC. Forks pool uses separate processes with more robust communication.
Set VITEST_WORKER_TIMEOUT=120000 (2min) to prevent onTaskUpdate timeout during v8 coverage collection on CI runners. Default 30s is too short for coverage instrumentation on resource-constrained GitHub Actions runners.
Tests run on both Node 18 and 22 and must pass. Coverage runs separately with continue-on-error since vitest v3 + v8 coverage has a known worker timeout issue on GitHub Actions runners. All 286 tests pass and thresholds are met — the timeout only occurs during post-test teardown.
- Pre-build nodeById and reverseAdjacency maps to eliminate O(N*E) lookups in computeDependents, computeModuleStructure, computeDeadExports - Fix BFS pathSoFar to track per-node parent chains instead of accumulating entire levels - Use null separator for cross-module dep keys to avoid path collisions - Count totalDeadExports before slicing for accurate totals - Fix "Blast radius:" output spacing in CLI - Read MCP server version from package.json instead of hardcoded "0.1.0" - Add explanatory comment for CI coverage continue-on-error
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.
Overview
Adds full CLI parity with the MCP interface. All 15 MCP tools now have equivalent CLI commands with both human-readable and
--jsonoutput.Extracts shared computation into
src/core/index.ts, eliminating duplicated logic between CLI and MCP handlers.What changed
New CLI commands (10):
dependents,modules,forces,dead-exports,groups,symbol,impact,rename,processes,clustersShared core module: 13 compute functions extracted to
src/core/index.ts, consumed by bothsrc/mcp/index.tsandsrc/cli.ts. This removed ~200 lines of duplicated logic from MCP handlers.Performance: Pre-built lookup maps (
nodeById,reverseAdjacency) replace O(N) linear scans in hot paths like BFS traversal and cross-module dependency detection.Files
src/core/index.tssrc/cli.tssrc/mcp/index.tstests/cli-commands.test.tsdocs/cli-reference.md.github/workflows/ci.ymlAGENTS.md,llms.txt,llms-full.txtCLI usage
codebase-intelligence overview ./src codebase-intelligence hotspots ./src --metric coupling codebase-intelligence file ./src parser/index.ts codebase-intelligence search ./src "auth" codebase-intelligence changes ./src --json codebase-intelligence dependents ./src types.ts --depth 3 codebase-intelligence modules ./src codebase-intelligence forces ./src codebase-intelligence dead-exports ./src codebase-intelligence groups ./src codebase-intelligence symbol ./src parseCodebase codebase-intelligence impact ./src getUserById codebase-intelligence rename ./src oldName newName codebase-intelligence processes ./src --entry main codebase-intelligence clusters ./src --min-files 3All commands support
--jsonfor machine-readable output and--forceto re-index.Testing