feat: add variant support for commands (#7713)
What does this PR do?
Fixes #7713 by the following:
- Adds a variant field to the commands configuration.
- Variant needs to be specified with the model (throws an error if not)
- Invalid variant names show a help message and throw an error (no fuzzy search)
How did you verify your code works?
- Added model and variant fields to the existing
packages/opencode/test/config/config.test.tsfor config parsing. - Performed three manual tests by creating an
opencode.jsonin the root:- Valid: model and variant are specified (used a temporary toast to verify the variant change).
- Without variant: only the model is specified.
- Invalid variant: an invalid variant name was used.
Consideration
When #7156 or #7140 lands, its model-default variant feature might need to be integrated.
Thanks for your contribution!
This PR doesn't have a linked issue. All PRs must reference an existing issue.
Please:
- Open an issue describing the bug/feature (if one doesn't exist)
- Add
Fixes #<number>orCloses #<number>to this PR description
See CONTRIBUTING.md for details.
The following comment was made by an LLM, it may be inaccurate:
I found related PRs that might be relevant to this variant support implementation:
Related PRs (Not exact duplicates, but related features):
-
Add default variant config per agent (#7140) - https://github.com/anomalyco/opencode/pull/7140
- The current PR mentions that when #7140 lands, its model-default variant feature might need to be integrated
-
feat: add variant support for subagents (#7138) [alt of #7140] (#7156) - https://github.com/anomalyco/opencode/pull/7156
- Similar variant support but for subagents; also mentioned in the PR as potentially needing integration
-
feat: Add variant cycle tooltip in session prompt (#7743) - https://github.com/anomalyco/opencode/pull/7743
- Related variant feature, but focuses on UI tooltip display
These are complementary features rather than direct duplicates. The current PR (#7907) specifically adds variant support for commands, while #7140 and #7156 address variant support for agents/subagents. They may need to be coordinated during integration.
No exact duplicate PRs were found for this specific commands variant implementation.