fix(testkit): honor CLI-level --json in argv and run prompt validate - #53
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
🚫 Excluded labels (none allowed) (2)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR fixes two testkit behaviours. First, Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Test as Test code
participant runCommand
participant Parse as stripBeforeSeparator
participant executeCommand
Test->>runCommand: runCommand(cmd, argv, options)
runCommand->>Parse: detect & strip pre-separator --json
Parse-->>runCommand: effectiveArgv, jsonMode
runCommand->>executeCommand: executeCommand(cmd, effectiveArgv, effectiveOptions)
executeCommand-->>runCommand: result
runCommand-->>Test: result
sequenceDiagram
participant Test as Test code
participant TestPrompter as createTestPrompter
participant Validate as config.validate
Test->>TestPrompter: promptOne(config)
TestPrompter->>Validate: validate(queuedAnswer)
Validate-->>TestPrompter: true / false
TestPrompter-->>Test: { answered: true, value } or { answered: false }
Possibly related issues
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 9 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (9 passed)
📋 Issue PlannerLet us write the prompt for your AI agent so you can ship faster (with fewer bugs). Comment |
commit: |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
dreamcli | 374af42 | Commit Preview URL Branch Preview URL |
Jun 30 2026, 11:40 AM |
--json in argv and run prompt validate
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
`runCommand` now mirrors the real root: `--json` before `--` enables JSON mode and is stripped before parse, while a literal `--json` after `--` still reaches the command. `createTestPrompter` runs the prompt's `validate` on queued input answers so prompt validation is integration- testable. Adds the `stripBeforeSeparator` parse helper (used by the testkit root-flag layer) plus tests, including one locking that a command's own `--json` flag stays reserved by the root. The planner-side use of `stripBeforeSeparator` is intentionally dropped: #54's root-head scan needs the pre-separator `filteredHead` distinct from the full `filteredArgv`, which the single helper cannot provide.
dd216fb to
13b75ba
Compare
Fixes two testkit gaps where
runCommanddiverges from the real CLI root.#33 —
runCommandrejects CLI-level--jsonin argvrunCommandexecuted commands in isolation with no root-flag layer, so a--jsoninargvwas parsed against the command's own schema and rejected asUnknown flag --json(exit 2). JSON mode was only reachable via the separate{ jsonMode: true }option, so copying a realmycli --json …invocation intoa test failed verbatim.
runCommandnow mirrorsCLIBuilder.execute():--jsonbefore the--separator (includesBeforeSeparator),parseso the command schema never sees it.A literal
--jsonafter--still reaches the command unchanged (#28 parity).The existing
{ jsonMode: true }option keeps working — either source enablesJSON mode. The separator-aware strip is extracted as
stripBeforeSeparator(sibling of
includesBeforeSeparator) and the planner now reuses it instead ofinlining the same logic.
#36 —
createTestPrompterbypasses promptvalidatecreateTestPrompter'spromptOnedropped the promptconfig, so aninputprompt's
validatewas dead code from the testkit's perspective: an invalidscripted answer was injected verbatim as the resolved value, and prompt
validation could not be integration-tested.
promptOnenow receivesconfigand runsconfig.validateon string answersto
inputprompts, mirroring the terminal prompter. A failing answer isrejected as a cancellation (
{ answered: false }) — exactly as the terminalprompter behaves when it exhausts its retries — so the resolution pipeline
surfaces it as a required-flag error or default fallback instead of accepting
the invalid value. Non-string answers stay verbatim so downstream coercion
paths remain testable.
Tests / docs
testkit-json.test.ts: argv--jsonenables JSON mode, isn't rejected asunknown, redirects
log()to stderr, composes with the option, renderserrors as JSON, and a post-
--literal--jsonreaches the command.testkit-prompt.test.ts: a queued answer passingvalidateresolves; onefailing
validateis rejected (required → exit 2) or falls back to default.createTestPrompter/TestAnswerTSDoc andprompt/AGENTS.mdfor thenew validate contract.
Full suite green: 2557 tests across 76 files; typecheck, lint, and format all
pass.
Closes #33
Closes #36