Written to: 1 requirement: 1 proved, 0 partly, 0 failing, 0 with no test recorded. 0004-headless-cli FR-006
Questions to the person (commons headless 0004-headless-cliFR-006): ask and confirm write the question to the person and read one line. With no terminal on both ends (a pipe, a timer, a service), or when the run was told never to ask, they ask no one and answer undefined, so that the caller falls back on the governance's decision (decide) instead of waiting on input that will never come. A confirmation is true only for a plain yes; anything else, including nothing, is no.
import { promptOf } from"./prompts.ts";
constp=promptOf({ interactive: false, readLine: async () =>"y", write: () => {} });
await p.confirm("Delete?"); // undefined: there is no one to ask
What a prompt needs: whether a person can be asked, where the question is written (the error stream, so that a report on standard output stays clean), and the input.