Normalize output-format parsing and rendering across builtin commands - #190
Conversation
… webcmd-usage skill
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. This review is advisory and does not block merging. |
|
Thanks for the PR! A few changes I'd like before this lands:
Nits
The tests look well targeted. I especially liked inverting the existing |
Validate -f/--format in the hosted list, profile, and plugin search command surfaces through the shared parseOutputFormat, matching the local CLI. Unsupported values now fail with a usage error (exit code 2) instead of silently rendering a table, and aliases/case are normalized the same way everywhere. BREAKING CHANGE: `-f/--format` values other than `table`, `plain`, `json`, `yaml`, `md`, or `csv` now fail with a usage error (exit code 2) instead of silently rendering a table. This applies to builtin commands, adapter commands, and is now enforced consistently by hosted `list`, `profile`, and `plugin search` too.
Pass the explicit-format source through to the webcmd list renderer for consistency with the other list handlers; table output never reaches the renderer, but this closes the remaining handler that omitted fmtExplicit.
Document that plugin list always renders its human-friendly grouped listing when the effective format is table (default or explicit, TTY or not), recommend -f json/-f yaml for machine-readable output, and note the unsupported-format usage error.
|
Thanks for the thorough review — all the feedback has been addressed. On the squash request, I'd like to keep the branch as-is if that's acceptable; the commits are already logically separated (feature, per-family fixes, tests, docs) and the review comments are covered by four small follow-ups. If you'd prefer a single commit in Point-by-point:
Nits:
Tests: |
Part of agentrhq#175. `validate`, `verify`, `doctor`, bare `skills`, `daemon status`, and `profile list` returned stable data internally but rejected `-f/--format` and printed hand-written text only. Each now routes through the shared `resolveOutputFormat` + `render` path introduced in agentrhq#190. `adapter status` already gained `-f` in agentrhq#190, so it needed no change here. Each command keeps its human-readable report as the `table` rendering, which remains the default, and returns the underlying result object under any other format. Following the `convention-audit` precedent, the human text is chosen on the raw format rather than the TTY-resolved one, so no existing implicit behavior changes. `daemon status` gains a machine-readable projection that mirrors the text rendering, reporting `{ running: false }` when no daemon is reachable. `profile list` returns one row per profile covering both connected profiles and saved-but-disconnected aliases, aligning it with the hosted profile-list row set. Daemon guidance for those two goes to stderr under structured formats so stdout stays parseable. Bare `skills` and `skills list` now share one renderer instead of duplicating the row set with a hardcoded format. Browser read commands are intentionally left for a follow-up: they go through the session/bridge layer and need separate care around the streaming and JSONL-follow exclusions the issue calls out. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CVuD882dJuEwWKWBLaf7bs
What
Fixes #172: unify
-f/--formatparsing and rendering so every builtin command accepts and honors the same set of output formats, rejects unsupported values, and emits consistent structured output.Single source of truth
src/command-surface.tsnow owns the canonical formats (table,plain,json,yaml,md,csv), the aliasesyml → yamlandmarkdown → md, the shared help text, and theparseOutputFormat/resolveOutputFormatvalidators (case-insensitive).-f/--formatflags (builtin commands,auth status/refresh, adapter/hosted surfaces) advertise the same format list.Behavior fixes
plugin list -f yamlnow emits real YAML (previously a table); emptyplugin list -f jsonemits[]instead of human guidance.skills list,external list,plugin catalog list/add,plugin search,convention-audit, andauth status/refreshnow honor all six formats with the correct explicit/implicit semantics (table in TTY, YAML outside TTY unless-fis given).webcmd list,skills list,convention-audit, plugin commands, andauthreject unsupported formats (e.g.-f xml) with a usage error (exit 2) instead of silently rendering a table.yml,markdown) and case (-f YAML) are accepted and normalized everywhere.plugin listnoteplugin listintentionally keeps its human-friendly grouped listing as itstablerendering — whenever the effective format istable(the default or an explicit-f table), and regardless of TTY. Use-f jsonor-f yamlfor machine-readable output. This is documented indocs/cli-reference.mdxandskills/webcmd-usage/SKILL.md.Hosted mode
Hosted
list,profile, andplugin searchnow validate and normalize-f/--formatthrough the sameparseOutputFormatpath as the local CLI, so unknown formats fail with a usage error and aliases/case are handled consistently there too.Breaking change
-f/--formatvalues other thantable,plain,json,yaml,md, orcsvnow fail with a usage error (exit code 2) instead of silently rendering a table. This applies to builtin commands and adapter commands (e.g.webcmd hackernews top -f xml), and now also to hostedlist,profile, andplugin search. The PR commit carries aBREAKING CHANGE:footer so release-please emits the changelog entry automatically.Docs
docs/cli-reference.mdxandskills/webcmd-usage/SKILL.mdupdated to reflect the shared format behavior, theplugin listtable rendering, rejection of unknown formats, aliases, andplugin list -f json→[].Testing
npm test: 5195 passed, 1 skipped (16 new tests).npm run buildOK;check:hosted-contractcontract bytes unchanged;check:typed-error-lint0 new;check:silent-column-drop0 new.