feat: add OpenCode as a preset agent - #365
Conversation
Docs carried an OpenCode custom-agent recipe with id "opencode"; without absorption those customs get renamed to "opencode-2" at load while pins and saved sessions silently retarget a fresh default preset.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughOpenCode is registered as a built-in preset, with migration from matching custom-agent settings during settings loading. English and Japanese documentation now describe installation, authentication, verification, navigation, and OpenCode support. ChangesOpenCode preset support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant AgentClient
participant OpenCode
participant Settings
User->>AgentClient: Select OpenCode
AgentClient->>Settings: Load preset configuration
AgentClient->>OpenCode: Start opencode acp
OpenCode-->>AgentClient: ACP connection
User->>OpenCode: Authenticate with /connect
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Description
PR4 of the preset-agents overhaul (#348–#351 shipped the registry, enable/disable, collapsible settings, and the "Preset agents" naming): OpenCode becomes a preset agent, and the custom-agent recipe our docs used to carry for it migrates automatically.
Registry entry (
feat(agents)): onePRESET_AGENTSentry — commandopencode, args["acp"], install hintcurl -fsSL https://opencode.ai/install | bash(npm on native Windows). Settings storage, enumeration, and the settings UI are all registry-driven, so no per-agent code exists elsewhere. OpenCode has no API key wiring: authentication is CLI-managed (run/connectin the OpenCode TUI; credentials live in~/.local/share/opencode/auth.jsonand are read by theopencode acpprocess we spawn). There is no officialOPENCODE_API_KEY, and OpenCode is multi-provider, so a single env var would be wrong — verified against opencode.ai/docs on 2026-07-16.Absorption migration (
feat(settings)): these docs historically advised registering OpenCode as a custom agent with idopencode. Without migration, the existing load-time collision rename would move that custom toopencode-2while fence pins, saved sessions, anddefaultAgentIdsilently retarget a fresh default preset. Instead, a new registry declaration (absorbsCustomAgentId) lets the pureabsorbCustomAgentshelper adopt the custom's settings (command/args/env/displayName/enabled) as the preset's raw source before custom normalization runs, remove the leftover custom, notify once, and persist — the saved preset entry makes the migration run-once. Deliberately not a genericcustom.id == presetIdrule: customs colliding with the original four preset ids are dead weight under preset-first resolution and must not overwrite live preset settings. Kiro (PR5) will reuse the same mechanism with a one-line declaration.Docs (
docs(opencode)): new setup page (install,/connectauthentication, migration note), sidebar entry, and the full enumeration sweep (index/quick-start tables, FAQ, troubleshooting, ACP support, context files —AGENTS.mdwithCLAUDE.mdfallback — READMEs, agents lists). The custom-agents page keeps Qwen Code and Kiro as examples and points OpenCode to the preset page.Tests: 188 passing (6 new absorption tests: adoption, skip-when-present, no-op, original-ids-excluded, save-round-trip idempotency, args backfill). An adversarial multi-lens review ran post-implementation; the two doc leftovers it found are fixed in this PR, and the accepted low-severity limitation (downgrade/re-upgrade chain around the one-shot migration) is recorded in the plan document.
Related issue
None (part of the preset overhaul plan; PR5 = Kiro follows).
Type of change
Checklist
npm run lintpasses ("Use sentence case for UI text" warnings are acceptable for brand names)npm run buildpassesTesting environment
opencode acpand chats; hand-crafted data.json migration (customopencodeabsorbed with displayName/env preserved, Notice shown exactly once, no re-fire on reload);agent: opencodepins and saved sessions keep resolving after migration; preset-entry-present + custom collision falls to the existingopencode-2rename; existing four presets, custom agents, default-agent selection, and agent switching unaffectedScreenshots
N/A
Summary by CodeRabbit