ReviewOS

also looking at this

stacks/buddy

test: import the CLI without parsing, and pin its wiring in-process

#1448
Merged glennmichael123 wants to merge test/cli-wiring into main
2 files +145 -2
8 days ago

The last deep-tail item: bin/cli.ts — 3,520 lines, 32 commands, 106 options — called cli.parse() at import time, so nothing could import it and every test had to spawn a subprocess. That's exactly why the audit's flag-shaped drift (defaults shadowing config, documented-but-unwired flags) always lived here: the wiring layer was unreachable by any in-process assertion.

What changes

bin/cli.ts — two lines of substance: cli.parse() moves behind import.meta.main, and cli is exported (with the explicit annotation isolatedDeclarations demands). Direct execution is byte-for-byte unchanged; importing now just registers commands.

test/cli-wiring.test.ts (11 tests) — pins what the subprocess smoke suite can't see:

  • the exact 32-command surface, as a literal list — a renamed or dropped command fails loudly
  • every command and every option carries a description (the docs invariant, enforced)
  • init aliases setup; the global --config is wired
  • no --strategy flag anywhere carries a CAC default — #1441's config-shadowing regression, now guarded in-process — and exactly {check, scan, schedule, update} take the flag
  • real parse(argv, { run: false }) runs: flag values land, --no-respect-latest negates, omitted flags surface their declared defaults, positionals are captured

Coverage

bin/cli.ts enters the measured world for the first time: 0% → its registration surface (9.25% lines — the wiring, which is what these tests are about; action bodies remain subprocess territory). Overall stands at 91.8% functions / 91.0% lines now that the file's 3,520 lines are in the denominator at all.

Full suite 2395 pass / 0 fail across 146 files; the subprocess suite still passes unchanged — the guard didn't alter executed behavior.

🤖 Generated with Claude Code

2 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.