/** * Abstract one-line prompt. `ask(question)` writes the question to the output * stream and resolves with the user's reply (without trailing newline). * * Production: `StdinPrompter` over `readline/promises`. Tests: `ScriptedPrompter`. */ export interface Prompter { ask(question: string): Promise; close?(): Promise | void; } export interface StdinPrompterOptions { input?: NodeJS.ReadableStream & { isTTY?: boolean; }; output?: NodeJS.WritableStream; } /** * Real prompter backed by stdin/stdout. Refuses to construct when the input * stream is not a TTY (CI, piped invocations) — the caller must bypass via * `--no-interactive` or fall through to other gates. */ export declare class StdinPrompter implements Prompter { private readonly rl; constructor(opts?: StdinPrompterOptions); ask(question: string): Promise; close(): void; } /** * Deterministic prompter for tests. Returns pre-seeded answers in order; * throws on exhaustion so tests fail fast when the prompt count drifts. */ export declare class ScriptedPrompter implements Prompter { private readonly answers; private cursor; constructor(answers: string[]); ask(_question: string): Promise; /** Indexed for assertions. */ get used(): number; } /** * Shared prompter factory: `CADENCE_PROMPTER_SCRIPT` (newline-separated * answers) selects a deterministic `ScriptedPrompter` for tests/automation; * otherwise a real `StdinPrompter` (which itself throws off a non-TTY). * Phase 174: extracted from two previously-independent, near-identical * copies — an inline closure in `settle.ts`'s `prompter.create` and * `handoff/run-resume.ts`'s private `buildPrompter()` (which was already * commented "mirrors settle.ts's seam exactly") — into the one place that * already owns `Prompter`/`ScriptedPrompter`/`StdinPrompter`, so a third * caller (the retro issue offer) doesn't need a fourth copy. * * Known limitation (Phase 174 whole-branch review): each call builds a * brand-new `ScriptedPrompter` starting at answer-list position 0. A single * `cadence settle` run can now call this twice — once for the * interactive-verdict gate (`gates/interactive.ts`, when the active gate set * includes it, e.g. `strict` profile), once for the post-commit retro issue * offer (`services/retro.ts`'s `runRetroOffer`) — and under * `CADENCE_PROMPTER_SCRIPT`, the second call does NOT continue from where * the first left off; it re-reads from the start. Real `StdinPrompter` usage * (an actual human at an actual terminal) is unaffected — this only bites * the scripted/test-automation seam. The failure mode is fail-safe: a * mismatched scripted answer just exhausts `askRetroIssueVerdict`'s retries * and defaults to a quiet decline, never a crash or a wrongly-filed issue. * A real fix (one memoized `Prompter` shared across a whole settle run) * needs matching close()-lifecycle changes in every existing caller * (`gates/approve.ts`, `gates/interactive.ts` already call `.close()` after * their own use) and was judged out of this phase's scope — a scripted test * or CI script driving both an interactive-verdict gate AND a friction- * having retro offer in the same run must currently script the SAME * expected answer twice (once for each independent call), not two * sequential distinct answers. */ export declare function createDefaultPrompter(): Prompter; //# sourceMappingURL=prompter.d.ts.map