feat(cli): agent-native output, stdin symbols, and exit-code classes

Phase 1 of docs/DESIGN.md:

- Output format resolves -o > IDX_OUTPUT > general.output > auto; auto
  is a table on a terminal and JSON when stdout is piped or captured.
  `config init` now writes output = "auto".
- JSON is pretty only on a terminal and compact otherwise. New `-o
  jsonl` prints one array item per line with the same key order.
- No ANSI color when stdout is not a terminal (direct owo-colors calls
  now go through output::style).
- `stocks quote -` and `stocks compare -` read symbols from stdin.
- Exit codes by class: 2 invalid input/config, 3 not found or cache
  miss, 4 upstream unavailable, 5 unsupported, 1 other.

Golden changes are limited to those documented kinds and were verified
mechanically: JSON goldens are semantically identical, tables differ
only by removed ANSI codes and the column padding comfy-table had
reserved for them (cell contents identical), exit codes match each
error's class, and help/completions only gain the new --output values.
17 new golden cases cover auto, jsonl, stdin, and the new errors.

tests/cli.rs now pins IDX_OUTPUT=table in its harness (its tests assert
table text and run piped) and parses discover JSON instead of matching
pretty-printed whitespace.

Live A/B against main: 16/16 stocks cases identical; ownership discover
got IDX 403 on both binaries, now exiting 4 instead of 1 as intended.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hermes 2026-10-14 08:52:13 +00:00
commit 22b6dabaeb
119 changed files with 920 additions and 1896 deletions

View file

@ -446,11 +446,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -468,11 +468,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -490,11 +490,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -568,11 +568,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -590,11 +590,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -612,11 +612,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -634,11 +634,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -740,11 +740,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -762,11 +762,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -784,11 +784,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1436,11 +1436,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1466,11 +1466,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1496,11 +1496,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1526,11 +1526,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1556,11 +1556,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1578,11 +1578,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1600,11 +1600,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1630,11 +1630,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1916,11 +1916,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1938,11 +1938,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -1960,11 +1960,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2052,11 +2052,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2074,11 +2074,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2100,11 +2100,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2126,11 +2126,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2152,11 +2152,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2178,11 +2178,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2200,11 +2200,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2222,11 +2222,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2244,11 +2244,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2270,11 +2270,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2292,11 +2292,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2314,11 +2314,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2586,11 +2586,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2608,11 +2608,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2634,11 +2634,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2656,11 +2656,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2678,11 +2678,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2700,11 +2700,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2734,11 +2734,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2756,11 +2756,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2782,11 +2782,11 @@ _idx() {
return 0
;;
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2804,11 +2804,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)
@ -2826,11 +2826,11 @@ _idx() {
fi
case "${prev}" in
--output)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
-o)
COMPREPLY=($(compgen -W "table json" -- "${cur}"))
COMPREPLY=($(compgen -W "auto table json jsonl" -- "${cur}"))
return 0
;;
*)