//#region src/core/schema/prompt.d.ts /** * Prompt type definitions for interactive flag resolution. * * Prompt configuration is stored on `FlagSchema.prompt` and consumed by the * resolution chain (v0.3+) when a flag value is missing after CLI/env/config * resolution. The prompt engine reads this config to present the appropriate * UI to the user. * * @module dreamcli/core/schema/prompt */ /** All prompt kind discriminators as a runtime array. */ declare const PROMPT_KINDS: readonly ["confirm", "input", "select", "multiselect"]; /** * The kind of interactive prompt to present. * * - `'confirm'` — yes/no boolean question * - `'input'` — free-text string input * - `'select'` — single selection from a list * - `'multiselect'` — multiple selections from a list */ type PromptKind = (typeof PROMPT_KINDS)[number]; /** Shared fields across all prompt kinds. */ interface PromptConfigBase { /** The question displayed to the user. */ readonly message: string; } /** Yes/no confirmation prompt — maps to `boolean` flags. Part of {@link PromptConfig}. */ interface ConfirmPromptConfig extends PromptConfigBase { /** Discriminator identifying this as a yes/no confirmation prompt. */ readonly kind: 'confirm'; /** * Value used when the user submits an empty line (presses Enter). Also * drives the displayed hint: `true` → `(Y/n)`, `false` → `(y/N)`. * @defaultValue `true` */ readonly default?: boolean; } /** Free-text input prompt — maps to `string` and `number` flags. Part of {@link PromptConfig}. */ interface InputPromptConfig extends PromptConfigBase { /** Discriminator identifying this as a free-text input prompt. */ readonly kind: 'input'; /** Placeholder text shown before user types (informational only). */ readonly placeholder?: string; /** * Value used when the user submits an empty line (presses Enter), shown in * the hint as `(default: )`. When set, an empty submission resolves * to this value without running {@link InputPromptConfig.validate | validate}. * When omitted, an empty submission is treated as "no answer" so resolution * falls through to the flag's `.default()`. * @defaultValue `undefined` */ readonly default?: string; /** * Inline validation function. Return `true` if valid, or a string * error message if invalid. Called before coercion to flag kind. */ readonly validate?: (value: string) => true | string; } /** Single-selection prompt — maps to `enum` flags or any flag with {@link SelectChoice choices}. Part of {@link PromptConfig}. */ interface SelectPromptConfig extends PromptConfigBase { /** Discriminator identifying this as a single-selection prompt. */ readonly kind: 'select'; /** * Available choices. When omitted for `enum` flags, the enum values * from the flag schema are used automatically. */ readonly choices?: readonly SelectChoice[]; } /** * Multi-selection prompt — maps to `array` flags. * Returns an array of selected {@link SelectChoice} values. Part of {@link PromptConfig}. */ interface MultiselectPromptConfig extends PromptConfigBase { /** Discriminator identifying this as a multi-selection prompt. */ readonly kind: 'multiselect'; /** * Available choices. When omitted for `array` flags with enum elements, * the enum values from the element schema are used automatically. */ readonly choices?: readonly SelectChoice[]; /** * Minimum number of selections required. * @defaultValue `0` */ readonly min?: number; /** * Maximum number of selections allowed. * @defaultValue `Infinity` */ readonly max?: number; } /** A selectable option for {@link SelectPromptConfig} and {@link MultiselectPromptConfig} prompts. */ interface SelectChoice { /** The value returned when this choice is selected. */ readonly value: string; /** * Display label shown to the user. * @defaultValue {@link SelectChoice.value | value} */ readonly label?: string; /** Optional description shown alongside the choice. */ readonly description?: string; } /** * Discriminated union of all prompt configurations. * * Use the `kind` field to narrow: * ```ts * if (config.kind === 'select') { * config.choices // readonly SelectChoice[] | undefined * } * ``` */ type PromptConfig = ConfirmPromptConfig | InputPromptConfig | SelectPromptConfig | MultiselectPromptConfig; /** * The raw result returned by a prompt engine for a single prompt. * * - `answered: true` — user provided a value * - `answered: false` — user cancelled/aborted (Ctrl+C, ESC, etc.) * * Coercion to the flag's kind is the resolver's responsibility, not the * prompt engine's. */ type PromptResult = { /** User provided a value. */ readonly answered: true; /** The raw value from the prompt engine (not yet coerced). */ readonly value: unknown; } | { /** User cancelled or aborted (Ctrl+C, ESC, etc.). */ readonly answered: false; }; //#endregion export { type ConfirmPromptConfig, type InputPromptConfig, type MultiselectPromptConfig, PROMPT_KINDS, type PromptConfig, type PromptConfigBase, type PromptKind, type PromptResult, type SelectChoice, type SelectPromptConfig };