fix(cli): honour the non-interactive contract in stash init (#600)#605
Conversation
`stash init` advertises that "every prompt has a non-interactive escape hatch, so init never blocks waiting on a TTY (CI, agents, pipes)", but three steps called clack prompts with no interactivity gate. In a non-TTY context each prompt returned a cancel symbol, which the step treated as `CancelledError`, so `init` aborted at the first prompt without acting — and never reached the EQL step that scaffolds `stash.config.ts` (so downstream `stash status` / `eql status` dead-ended on "Could not find stash.config.ts"). Gate the three prompts on `isInteractive()` (the shared `config/tty.ts` helper), matching the existing `resolve-proxy-choice` pattern, and take a safe default in non-interactive contexts: - install-deps: install the packages by default (init is a setup command). - install-eql: install EQL by default — which also runs the config scaffold (`scaffoldConfig: 'ensure'`), closing the missing-`stash.config.ts` gap. - build-schema: keep an existing encryption client (never clobber it unasked). Interactive runs are unchanged. Adds step-level tests covering the interactive / non-interactive / already-satisfied paths for all three.
|
|
Warning Review limit reached
Next review available in: 5 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR fixes stash init so it properly honors the CLI’s documented non-interactive contract (CI/agents/pipes), by preventing clack prompts from aborting the init flow and ensuring the EQL step can still scaffold stash.config.ts.
Changes:
- Gate three previously-unconditional prompts (
install-deps,install-eql,build-schema) onisInteractive()and apply safe non-interactive defaults. - Add step-level Vitest coverage for interactive vs non-interactive behavior (and already-satisfied paths) for the affected steps.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/cli/src/commands/init/steps/install-eql.ts | Avoids blocking prompt in non-interactive contexts; defaults to installing EQL so config scaffolding can proceed. |
| packages/cli/src/commands/init/steps/install-deps.ts | Avoids blocking prompt in non-interactive contexts; defaults to installing required deps. |
| packages/cli/src/commands/init/steps/build-schema.ts | Avoids blocking prompt in non-interactive contexts; defaults to keeping an existing client file to prevent clobbering. |
| packages/cli/src/commands/init/steps/tests/install-eql.test.ts | Adds tests covering interactive prompt vs non-interactive default install + config scaffold behavior. |
| packages/cli/src/commands/init/steps/tests/install-deps.test.ts | Adds tests covering interactive prompt vs non-interactive default install and “already installed” short-circuit. |
| packages/cli/src/commands/init/steps/tests/build-schema.test.ts | Adds tests covering interactive overwrite/keep choice vs non-interactive “keep existing” behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Minor change. Self and AI assisted review. |
Closes #600.
Problem
stash initadvertises (inmanifest --jsonand the command help) that "every prompt has a non-interactive escape hatch, so init never blocks waiting on a TTY (CI, agents, pipes)." In practice, three init steps called clack prompts with no interactivity gate. In a non-TTY context each prompt returns a cancel symbol, which the step treats asCancelledError, soinitaborts at the first prompt without acting.Two consequences:
stash initis unusable from agents / CI / pipes (it stops at the first prompt and exits0without doing anything).stash.config.ts, so downstream read commands dead-end onCould not find stash.config.ts.Fix
Gate the three blocking prompts on the shared
isInteractive()helper (config/tty.ts), matching the existingresolve-proxy-choicepattern, and take a safe default in non-interactive contexts:install-depsinstall-eqlscaffoldConfig: 'ensure'), closing the missing-stash.config.tsgapbuild-schemaInteractive runs are unchanged — the prompts still show in a TTY. The other init steps (
authenticatevia--region/STASH_REGION,resolve-database,resolve-proxy-choice,gather-context, and the final "continue to plan?") were already non-interactive-safe.Tests
Added step-level tests for
install-deps,install-eql, andbuild-schemacovering the interactive / non-interactive / already-satisfied paths (9 tests). Fullsrc/commands/initsuite passes (182 tests);biome checkclean.