fix(cli): accept -f/--format and --json on every command - #425
Open
ankitranjan7 wants to merge 1 commit into
Open
fix(cli): accept -f/--format and --json on every command#425ankitranjan7 wants to merge 1 commit into
ankitranjan7 wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
🟠 Maintainer review suggested — low confidenceThe automated review could not reach a fully supported conclusion. Limitations
This review is advisory and does not block merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-f/--formatand--jsonwere registered on roughly half the CLI's commands. An agent that learns--jsononwebcmd plugin listhitserror: unknown option '--json'onwebcmd plugin install, and has no way to predict which side of the line a command falls on. In a recent eval this cost repeated wrong guesses in 4 of 12 scenarios.What changed
ensureOutputFormatOptions(program)walks the finished Commander tree and registers-f, --format <fmt>plus--jsonon every leaf that lacks them. Namespace commands (adapter,plugin, …) are skipped — they only print help — and external-CLI passthrough is skipped so its argv still reaches the wrapped binary.plugin install/uninstall/update/create,profile create/rename/use,adapter path/override/reset,daemon stop/restart,external install/register,browser init, and thesitewrite leaves (note add,endpoint set/stale,field-map add,fixture put,sample add). Shape is a small{ ok, action, … }envelope, consistent across similar commands. Without a flag the human output is byte-identical.browser tabs/bind/close/snapshot/runroute their result through the shared renderer withjsonas the default format, so-f yamlworks and today's JSON bytes are unchanged.browser rungains-f/--formatalongside the--jsonit already had.configureCompletionCommandSurfaceand the plugin install/uninstall/update surfaces gained the flag directly, so hosted mode inherits the same grammar as local — hosted help and structural-error parity tests cover this.webcmd skills add/update/removekeep their existing--jsonenvelope and now also honour-f json.Before / After
Before, on
origin/main:After:
Tests
src/cli-format-contract.test.tswalks the whole Commander tree and asserts every non-namespace, non-passthrough command exposes-f,--formatand--json, so a command added later cannot regress the contract. A second case assertsadapter pathprints the bare path by default and the{ ok, command, path }envelope under--json.src/site-memory/commands.test.tsadds equivalent default-silent / structured-under---jsoncoverage for three write leaves.npm run typecheckclean.npx vitest run --project unit: 2707 passed, 2 failed — both insrc/browser/run/playwright-client-build.test.ts, which cannot readnode_modules/playwright-corethrough this worktree's symlink; the same file passes in a normal checkout and is untouched by this change.🤖 Generated with Claude Code