Skip to content

feat(opencode): add support for --variant flag#123

Merged
subsy merged 6 commits intosubsy:mainfrom
manascb1344:feature/issue-122-opencode-variant-support
Jan 17, 2026
Merged

feat(opencode): add support for --variant flag#123
subsy merged 6 commits intosubsy:mainfrom
manascb1344:feature/issue-122-opencode-variant-support

Conversation

@manascb1344
Copy link
Contributor

@manascb1344 manascb1344 commented Jan 17, 2026

Summary

Adds support for the --variant flag to the OpenCode agent plugin, enabling users to control model reasoning effort (e.g., high, max, minimal) for supported providers like Google Gemini.

Changes

  • Plugin: Updated OpenCodeAgentPlugin to accept a variant configuration option
  • CLI: Modified argument builder to pass --variant <value> to the opencode CLI
  • Tests: Added unit tests to verify variant configuration is accepted
  • Docs: Updated documentation with usage examples and configuration reference

Usage

CLI

ralph-tui run --agent opencode --model google/gemini-2.5-pro --variant high

Config

[agentOptions]
provider = "google"
model = "gemini-2.5-pro"
variant = "max"

Verification

  • Added new unit test for variant configuration
  • Ran all tests: 1008/1008 passed
  • Ran bun run lint: Clean
  • Ran bun run typecheck: Success
  • Ran bun run build: Success

Related Issue

Fixes #122

Summary by CodeRabbit

  • New Features

    • Add model variant support across the run flow: CLI --variant, runtime option and agent configuration propagation to control reasoning effort (e.g., minimal, high, max).
  • Documentation

    • Update OpenCode docs with "Select a Variant" step, examples, options reference and guidance on model variants.
  • Tests

    • Add tests validating variant handling, parsing and acceptance of multiple variant values.

✏️ Tip: You can customize this high-level summary in your review settings.

- Introduced a new 'variant' configuration option for specifying provider-specific reasoning effort (high, max, minimal).
- Updated initialization logic to accept and set the variant.
- Enhanced argument parsing to include the model variant when specified.
- Added a test case to verify the acceptance of the variant configuration.
@vercel
Copy link

vercel bot commented Jan 17, 2026

@manascb1344 is attempting to deploy a commit to the plgeek Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 17, 2026

Walkthrough

Adds CLI and config support for a model "variant" (e.g., minimal, high, max). The variant is captured during run parsing, merged into agent runtime options, stored in the OpenCode agent plugin, and passed as a --variant flag to the underlying OpenCode CLI. Tests and docs updated.

Changes

Cohort / File(s) Summary
Plugin Implementation
src/plugins/agents/builtin/opencode.ts
Adds private variant field; captures config.variant during setup; appends --variant <value> to opencode run args when configured.
CLI run command & parsing
src/commands/run.tsx, tests/commands/run.test.ts
Adds --variant parsing in run command, stores value on runtime options (ExtendedRuntimeOptions.variant?), updates help text; tests added/updated to assert parsing and help output.
Runtime config propagation
src/config/index.ts, src/config/types.ts
Propagates CLI options.variant into each agent's merged options; adds variant?: string to RuntimeOptions type.
Tests — plugin behavior
tests/plugins/opencode-agent.test.ts
Adds tests validating plugin initialisation with various variant values and that validateSetup accepts multiple variant strings (including custom values).
Documentation & examples
website/content/docs/plugins/agents/opencode.mdx
Adds "Select a Variant" step, sample config with variant = "high", options reference entry for variant, and a "Model Variants" guidance section.
Website type path fix
website/next-env.d.ts
Adjusted import path for Next.js route type definitions to ./.next/dev/types/routes.d.ts.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI
  participant ConfigLoader as Config/Runtime
  participant AgentPlugin as OpenCodeAgentPlugin
  participant OpencodeCLI as OpenCode CLI

  User->>CLI: run --agent opencode --variant high ...
  CLI->>ConfigLoader: parse args -> options.variant = "high"
  CLI->>ConfigLoader: load/merge agent options
  ConfigLoader->>AgentPlugin: initialize(config with options.variant)
  AgentPlugin->>AgentPlugin: store variant
  CLI->>AgentPlugin: request command args
  AgentPlugin->>OpencodeCLI: spawn `opencode run ... --variant high`
  OpencodeCLI->>User: execute external CLI with variant
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble on code and hop with delight,
A variant tucked in, set just right,
From flag to config, the pathway is clear,
Opencode now listens — huzzah, cheer! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning One out-of-scope change detected: website/next-env.d.ts import path modification unrelated to --variant flag support. Remove the unrelated import path change in website/next-env.d.ts or address it in a separate PR focused on Next.js configuration updates.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding --variant flag support to the OpenCode agent plugin, which is the primary objective of this PR.
Linked Issues check ✅ Passed All primary objectives from issue #122 are met: variant property added to plugin, config file support implemented, CLI flag support added, passing --variant to opencode run, and documentation provided.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

AI Agent and others added 3 commits January 17, 2026 17:45
- Add validation for variant values (minimal, high, max) in initialize()
- Add variant validation in validateSetup() for setup wizard
- Add --variant CLI flag to run command
- Pass variant from CLI to agentOptions in config building
- Add comprehensive tests for variant functionality:
  - CLI parsing tests for --variant flag
  - Initialization tests for all valid variants
  - Validation tests for invalid variants
  - Help text verification

Co-authored-by: manascb1344 <[email protected]>
Different models support different variant values (e.g., Gemini uses
minimal/high/max, other models may use different values). Validation
should be delegated to the OpenCode CLI, which knows what each model
supports.

- Remove strict validation of variant values in initialize()
- Remove variant validation in validateSetup()
- Update docs to clarify variants are model-specific
- Update tests to reflect the delegated validation approach
@manascb1344
Copy link
Contributor Author

@subsy Are the changes appropriate?

@codecov
Copy link

codecov bot commented Jan 17, 2026

Codecov Report

❌ Patch coverage is 57.14286% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.73%. Comparing base (6d64a50) to head (a942fa4).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/plugins/agents/builtin/opencode.ts 44.44% 5 Missing ⚠️
src/config/index.ts 33.33% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   46.72%   46.73%   +0.01%     
==========================================
  Files          58       58              
  Lines       12947    12968      +21     
==========================================
+ Hits         6049     6061      +12     
- Misses       6898     6907       +9     
Files with missing lines Coverage Δ
src/commands/run.tsx 9.96% <100.00%> (+0.41%) ⬆️
src/config/types.ts 100.00% <ø> (ø)
src/config/index.ts 67.15% <33.33%> (-0.43%) ⬇️
src/plugins/agents/builtin/opencode.ts 42.69% <44.44%> (+0.04%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@subsy
Copy link
Owner

subsy commented Jan 17, 2026

Hey @manascb1344, thanks for this PR! 🙌

I've pushed some additions to your branch:

  • Added --variant CLI flag support: ralph-tui run --variant high
  • Added tests for CLI parsing
  • Clarified in docs that variant values are model-specific (delegated to OpenCode CLI for validation, just like provider)

PS for future PRs, please include tests, and (if applicable) docs.

@vercel
Copy link

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
ralph-tui Ready Ready Preview, Comment Jan 17, 2026 6:08pm

Request Review

@subsy subsy merged commit efc0df0 into subsy:main Jan 17, 2026
9 checks passed
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
…ode-variant-support

feat(opencode): add support for --variant flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add --variant flag support to OpenCode agent plugin

2 participants

Comments