Skip to content

Persist default OpenCode model and agent settings#59

Merged
JohnnyVicious merged 2 commits intomainfrom
issue-20-defaults
Apr 13, 2026
Merged

Persist default OpenCode model and agent settings#59
JohnnyVicious merged 2 commits intomainfrom
issue-20-defaults

Conversation

@JohnnyVicious
Copy link
Copy Markdown
Owner

Summary

  • add /opencode:setup --default-model <provider/model|off> and --default-agent <build|plan|off> backed by state.config.defaults
  • apply the saved default model to review, adversarial-review, and rescue/task when no --model or --free flag is supplied
  • apply the saved default agent to rescue/task when no --agent flag is supplied; review commands continue using the bundled read-only review agent to preserve current review behavior
  • update README, slash-command docs, rescue agent/runtime docs, setup rendering, and safe-command forwarding

Closes #20.

Test plan

  • npm test (182 passing)
  • git diff --check
  • node --check plugins/opencode/scripts/opencode-companion.mjs
  • node --check plugins/opencode/scripts/lib/defaults.mjs
  • node --check plugins/opencode/scripts/safe-command.mjs

@JohnnyVicious JohnnyVicious requested a review from Copilot April 13, 2026 08:06
@JohnnyVicious
Copy link
Copy Markdown
Owner Author

@codex review this PR

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 under state.config.defaults.
  • Applies saved default model to review, adversarial-review, and task when neither --model nor --free is provided; applies saved default agent to task when --agent is 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 JohnnyVicious merged commit 80d4b03 into main Apr 13, 2026
1 check passed
@JohnnyVicious JohnnyVicious deleted the issue-20-defaults branch April 13, 2026 18:03
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.
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.

Feature: persist default model/agent via /opencode:setup

2 participants