Skip to content

feat: CLI parity with MCP — 15 commands, shared core extraction#16

Merged
bntvllnt merged 6 commits intomainfrom
feat/cli-full-parity
Mar 12, 2026
Merged

feat: CLI parity with MCP — 15 commands, shared core extraction#16
bntvllnt merged 6 commits intomainfrom
feat/cli-full-parity

Conversation

@bntvllnt
Copy link
Owner

@bntvllnt bntvllnt commented Mar 11, 2026

Overview

Adds full CLI parity with the MCP interface. All 15 MCP tools now have equivalent CLI commands with both human-readable and --json output.

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, clusters

Shared core module: 13 compute functions extracted to src/core/index.ts, consumed by both src/mcp/index.ts and src/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

File Change
src/core/index.ts New — 13 shared compute functions with typed result interfaces
src/cli.ts 10 new subcommands, each with formatted + JSON output
src/mcp/index.ts Refactored to delegate to core compute functions
tests/cli-commands.test.ts 47 integration tests covering all compute functions
docs/cli-reference.md Full 15-command reference with flags and examples
.github/workflows/ci.yml Node 18+22 matrix, concurrency groups, coverage best-effort
AGENTS.md, llms.txt, llms-full.txt Updated for CLI parity

CLI 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 3

All commands support --json for machine-readable output and --force to re-index.

Testing

  • 286 tests passing (47 new for CLI core functions)
  • Tested against 3 real repositories with manual verification of output correctness
  • All quality gates green: lint, typecheck, build, test

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.
@bntvllnt bntvllnt self-assigned this Mar 11, 2026
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
@bntvllnt bntvllnt changed the title feat: full CLI parity with MCP — 15 commands feat: CLI parity with MCP — 15 commands, shared core extraction Mar 11, 2026
@bntvllnt bntvllnt merged commit d47fd27 into main Mar 12, 2026
2 checks passed
@bntvllnt bntvllnt deleted the feat/cli-full-parity branch March 12, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant