ralphy writes in one of three modes — pretty, JSON, or auto — plus a quiet variant that suppresses chatter regardless of mode. The resolution order is fixed, the JSON shape is stable, and pretty output is just-readable enough that an agent can scrape it if it has to. Default behavior is right for both terminals and pipes; you only set a flag when you want to override.
Resolution order
ThepreAction hook in cli/index.ts runs once before every verb:
--json→ mode isjson. Pretty primitives are silenced;out()emits canonical JSON.--pretty→ mode ispretty. TTY check is bypassed; tables and spinners always render.- Otherwise → mode is
auto. Pretty whenprocess.stdout.isTTYis true, JSON when piped.
--quiet is orthogonal. It suppresses progress, spinners, and ok/info/warn lines — the final result still prints, errors still print on stderr.
--no-color strips ANSI codes. Compose it with --pretty for layout without colors.
JSON mode
Every verb’s success path writes a single JSON object (or array) to stdout. Errors go to stderr as{ "error": { "code": "E_...", "message": "...", "hint": "..." } }.
jq without filtering noise.
Pretty mode
Pretty renders withcli/lib/ui.ts: a 256-color palette, Unicode icons (✓, ✖, ▸, ★), cli-table3 for tables, ora spinners, sectioned key/value blocks.
- Pretty
- JSON
--json when scripting — the shape is more stable across versions.
NDJSON event streams
Long-running verbs (generate video, generate music, render, assets install) emit structured events while they run, in addition to the terminal summary. The stream uses one JSON object per line — Node’s CommandStream helper (cli/lib/stream/command.ts) handles serialization.
Example events from ralphy render <id>:
Quiet mode
-q/--quiet suppresses everything except the final result:
isQuietMode() in cli/lib/ui.ts is what each ok/info/warn call checks. Errors on stderr always print regardless.
—no-color
Disableschalk color output. Pretty mode still uses Unicode icons and tables, just without ANSI codes. The CLI also honors the NO_COLOR env var (informally — chalk handles it automatically).
Piping recipes
Stderr is structured too
Errors always write a structured payload on stderr — even in pretty mode the JSON form still appears (formatted) so an agent can parse both:Related
- CLI overview — global flags + resolution order
- Error catalog — the stderr shape
- cli/lib/ui.ts — pretty primitives
- cli/lib/output.ts —
out()anderr()source