Persist default OpenCode model and agent settings#59
Merged
JohnnyVicious merged 2 commits intomainfrom Apr 13, 2026
Merged
Conversation
Owner
Author
|
@codex review this PR |
There was a problem hiding this comment.
Pull request overview
Adds persisted, user-configurable defaults for OpenCode model and rescue agent selection via /opencode:setup, and applies those defaults across companion commands when corresponding runtime flags are omitted.
Changes:
- Introduces
/opencode:setup --default-model <provider/model|off>and--default-agent <build|plan|off>persisted understate.config.defaults. - Applies saved default model to
review,adversarial-review, andtaskwhen neither--modelnor--freeis provided; applies saved default agent totaskwhen--agentis omitted. - Updates setup rendering and documentation, and adds a focused unit test suite for the defaulting/precedence behavior.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/render.test.mjs | Extends setup rendering test expectations to include persisted defaults. |
| tests/defaults.test.mjs | Adds coverage for default normalization, parsing, and precedence resolution helpers. |
| tests/companion-cli.test.mjs | Verifies defaults persistence/clearing and safe-command forwarding for setup defaults. |
| README.md | Documents new setup flags and explains when defaults apply. |
| plugins/opencode/skills/opencode-runtime/SKILL.md | Updates runtime guidance to reflect companion-applied defaults when flags are omitted. |
| plugins/opencode/scripts/safe-command.mjs | Allows --default-model / --default-agent to be forwarded for setup. |
| plugins/opencode/scripts/opencode-companion.mjs | Implements persisted defaults reading/writing and applies defaults to model/agent selection logic. |
| plugins/opencode/scripts/lib/render.mjs | Renders default model/agent in setup output. |
| plugins/opencode/scripts/lib/defaults.mjs | Adds centralized helpers for defaults parsing/normalization and precedence rules. |
| plugins/opencode/commands/setup.md | Documents new setup flags and their effects. |
| plugins/opencode/commands/review.md | Clarifies --model overrides saved setup defaults. |
| plugins/opencode/commands/rescue.md | Clarifies runtime flags vs saved defaults for rescue/task. |
| plugins/opencode/commands/adversarial-review.md | Clarifies --model overrides saved setup defaults. |
| plugins/opencode/agents/opencode-rescue.md | Updates forwarding rules to mention companion-applied defaults. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Resolves the conflicts with merged PR #58 (rescue inlining + reaper fix + safe-command.mjs task bridge): - plugins/opencode/agents/opencode-rescue.md: delete-wins. PR #58 intentionally removed this file (the subagent layer is gone); #59's in-file edit about companion-applied defaults is no longer needed. - plugins/opencode/skills/opencode-runtime/SKILL.md: delete-wins, same reason. The skill was scoped entirely to the deleted subagent. - plugins/opencode/commands/rescue.md: took #58's bridge-based rewrite as the base and ported #59's intent into its "Flag handling" section. Added explicit notes to the --model and --agent bullet points that the companion applies saved /opencode:setup defaults when the corresponding runtime flag is omitted. - README.md: combined both sides of the slash-commands bullets so the rescue line keeps #58's bridge description AND picks up #59's "Uses saved default model/agent values" note. review and adversarial-review lines keep their #59 default-model notes. - plugins/opencode/scripts/safe-command.mjs: auto-merged cleanly. The task-branch parseTaskArgs from #58 coexists with the expanded parseSetupArgs from #59 that forwards --default-model and --default-agent for the setup subcommand. All 211 tests pass (182 from #59 + 29 from #58 — 25 safe-command task bridge cases and 4 reaper in-flight guard cases).
JohnnyVicious
added a commit
that referenced
this pull request
Apr 13, 2026
Incorporates PR #58 (rescue inlining + reaper + safe-command task bridge) and PR #59 (persisted command defaults) which both merged while this branch was open. Resolved conflicts: - README.md: merged the rescue slash-command line (combines #58's bridge description, #59's default model/agent note, and #60's --path addition to review and adversarial-review lines). - plugins/opencode/scripts/opencode-companion.mjs: three conflict hunks, all in handleReview and handleAdversarialReview. Combined #59's loadState/normalizeDefaults/applyDefaultModelOptions preamble with #60's paths/effectivePrNumber resolution. The job record now stores model as `requestedModel?.raw ?? modelOptions.model` (from #59) AND pr as `effectivePrNumber` plus paths (from #60), so both features coexist without interference. No code fixes were needed in this merge — all Copilot/Codex review comments on the original PR #60 first commit were already addressed by the second commit (6404d03 "fix(review): harden path review collection") before the merge. 221/221 tests pass.
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.
Summary
/opencode:setup --default-model <provider/model|off>and--default-agent <build|plan|off>backed bystate.config.defaults--modelor--freeflag is supplied--agentflag is supplied; review commands continue using the bundled read-only review agent to preserve current review behaviorCloses #20.
Test plan
npm test(182 passing)git diff --checknode --check plugins/opencode/scripts/opencode-companion.mjsnode --check plugins/opencode/scripts/lib/defaults.mjsnode --check plugins/opencode/scripts/safe-command.mjs