/** * Shared output helpers for the hand-authored, server-facing CLI commands. * * Centralizes color detection (TTY + `NO_COLOR`/`FORCE_COLOR`), human-friendly * duration and timestamp rendering, NDJSON serialization, and destructive-action * confirmation. Every noun-verb command consumes these helpers so the DX * conventions (table on a TTY, NDJSON under `--json`, prompts before destructive * operations) stay consistent across the surface. * * @module cli/output */ /** Returns true when ANSI color should be emitted for the given stream. */ export declare function supportsColor(stream?: { isTTY?: boolean; } | undefined): boolean; /** ANSI color helpers gated by {@link supportsColor}. */ export declare const color: { green: (text: string) => string; yellow: (text: string) => string; red: (text: string) => string; cyan: (text: string) => string; dim: (text: string) => string; bold: (text: string) => string; }; /** * Serialize an array of values as NDJSON: one compact JSON object per line. * Entries that `JSON.stringify` cannot encode (e.g. `undefined`, functions) * are skipped so the output is always valid NDJSON. */ export declare function ndjson(values: readonly unknown[]): string; /** * Pretty-print a single value as indented JSON for non-list `--json` output. * Returns `'null'` when `JSON.stringify` yields `undefined` (e.g. for void * results) so the contract of returning a valid JSON string is always upheld. */ export declare function prettyJson(value: unknown): string; /** Render a Unix-millisecond timestamp as an ISO string, or `-` when absent. */ export declare function formatTimestamp(value: unknown): string; /** * Render a millisecond duration as a compact human string (e.g. `1.5s`, `2m 3s`, * `1h 4m`). Sub-second durations render in milliseconds. */ export declare function formatDuration(milliseconds: number): string; /** * Truncate a string to fit a terminal column width, appending an ellipsis when * the value is clipped. A non-positive or non-finite width returns the value * unchanged so non-TTY output is never lossy. */ export declare function truncateToWidth(value: string, width: number): string; /** * Confirmation gate for destructive operations. * * - `assumeYes` (the `--yes`/`-y` flag) bypasses the prompt entirely and returns `'confirmed'`. * - On a non-interactive stdin without `--yes`, returns `'non-interactive'` so the caller * can exit 1 with a clear message rather than hanging on a prompt. * - On a TTY, prints `prompt` and reads a line; defaults to No unless the reply * starts with `y`/`Y`. Returns `'confirmed'` or `'denied'` accordingly. */ export declare function confirmDestructive(options: { readonly prompt: string; readonly assumeYes: boolean; readonly isTty?: boolean; readonly readLine?: () => Promise; }): Promise<'confirmed' | 'denied' | 'non-interactive'>; /** Extract a human-readable message from an unknown error value. */ export declare function messageOf(error: unknown): string;