Files
colbymchenry__codegraph/__tests__/cli-context-command.test.ts
Colby McHenry 80ef4b8a3c fix(cli): register the documented context command (#1611)
The usage header has advertised 'codegraph context <task>  Build context for a task' since the first commit, and the ContextBuilder behind the public buildContext API has always shipped in the package — but the command was never registered with commander, so it errored with "unknown command 'context'". External integrations built against the documented contract (Memorix 1.8.1 invokes 'codegraph context --path <root> --format json --max-nodes 8 --no-code <task>') silently fell back to their own heuristics.

Register 'context <task...>' next to the other read commands, mapping flags 1:1 onto BuildContextOptions: --path (resolved like every sibling command), --format markdown|json (validated, default markdown), --max-nodes (positive int, validated), --no-code (includeCode=false). JSON goes to stdout verbatim and unmixed — error()/warnings write to stderr — so the output is machine-parseable. Covered end-to-end against the built binary, including the exact Memorix invocation shape and the uninitialized-project failure path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LxZj6W6Y1SHXwvpT3uwJpK
2026-08-25 10:49:04 -05:00

4.3 KiB