fix(cli): format opencode models --verbose as a table - #50522
Open
fede-kamel wants to merge 3 commits into
Open
fede-kamel wants to merge 3 commits into
fede-kamel wants to merge 3 commits into
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
opencode models --verbose printed JSON.stringify(model, null, 2) for every model, which is unreadable once several providers are configured. It now prints one aligned table per provider, with the columns the model catalog already carries: model id, name, base cost per 1M tokens, context and output limits, and capabilities. Default output is unchanged: the same plain provider/model lines on stdout, so existing pipelines keep working.
fede-kamel
force-pushed
the
fix/models-formatting
branch
from
September 22, 2026 04:57
5fe0ea0 to
04717dc
Compare
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
Asserts column alignment, the absence of trailing whitespace, the provider-prefixed model id, cost/limit/capability rendering, and the empty-provider case.
Documents what --verbose prints now, and states that the default output is still one plain provider/model per line so it can be piped.
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.
Issue for this PR
Closes #50513
Type of change
What does this PR do?
opencode models --verboseprintedJSON.stringify(model, null, 2)for every model. With three providers and 80+ models that is several thousand lines of JSON, and the fields you actually want are buried in it.This prints one aligned table per provider instead, using fields the catalog already carries: model id, name, base cost per 1M tokens, context and output limits, and capabilities.
Three things I deliberately did not do:
opencode modelsstill writes the same plainprovider/modellines to stdout, byte for byte, because that is the form scripts pipe intogrepandfzf. Only--verbosechanged.This follows the table already built by
session listinpackages/opencode/src/cli/cmd/session.ts— data-derived widths, a─rule under the header, no colour.packages/web/src/content/docs/cli.mdxgains a short--verboseexample. English only — recent docs PRs (#38395, #33279) touch only the English file and the translated copies are regenerated separately.Two points where I took a narrower line than #50513's bullets, both raised as open questions on the issue for a maintainer to settle: the table is behind
--verboserather than replacing the default output, and it emits no colour. Happy to change either.How did you verify your code works?
bun run --cwd packages/opencode src/index.ts models > after.txtagainst the same binary built fromdev— output is byte-identical, so the scriptable path is unchanged.bun run --cwd packages/opencode src/index.ts models --verboseand… models <provider> --verboseagainst a config with three providers and 80+ models; checked alignment, andcat -Ato confirm no trailing whitespace.opencode models nope --verbosestill exits 1 withProvider not found.bun test test/cli/— the whole CLI suite: 372 pass, 5 skip, 0 fail.bun test test/cli/cmd/models.test.ts— a new unit test covers the formatter: column alignment, no trailing whitespace, the provider-prefixed model id, cost/limit/capability rendering, and a provider with no models. I checked the alignment assertion by dropping thepadEndand confirming it fails.bun turbo typecheck --filter=opencodepasses;oxlinton the file reports the same single pre-existing warning as ondev;prettier --checkis clean.Screenshots / recordings
Output is plain text. The table above is a verbatim paste of a real run, and the one in
cli.mdxwas generated by calling the formatter rather than drawn by hand.Checklist
Previous revision of this PR also changed the TUI
/modelsdialog. CONTRIBUTING requires a design review for UI changes, so that half is dropped from here; it is already tracked in #47600.