feat(providers): add OpenCode as a built-in provider#1616
Conversation
Adds an OpenCodeProvider that spawns the local opencode CLI as a child process and yields its stdout as MessageChunks. Wires it into the provider registry alongside Claude and Codex with its own capability matrix. Test updates extend the existing registry expectations to include the new builtin (count, error message, ordering). Known follow-ups (not addressed in this PR): - binaryPath is hardcoded; needs config/env resolution like the Claude/Codex providers' binary-resolver pattern. - No unit tests for OpenCodeProvider behavior yet (spawn, stream decoding, session resume). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
Moving this to the aatchison/Archon fork — wasn't ready to PR upstream yet. Will reopen there. |
Summary
Adds OpenCode (https://opencode.ai/) as a third built-in agent provider alongside Claude and Codex.
packages/providers/src/opencode/capabilities.ts— capability matrix for the new provider.packages/providers/src/opencode/provider.ts—OpenCodeProviderclass implementingIAgentProvider. Spawns the localopencodebinary withbun.spawn, decodes stdout chunks, and yields them asassistantMessageChunks. Supports--sessionfor resume and--modeloverrides.packages/providers/src/registry.ts— registersopencodeas a built-in.packages/providers/src/registry.test.ts— extends existing assertions to cover the new builtin (count = 3, ordering, error-message contents).Test plan
bun test packages/providers/src/registry.test.ts— 32/32 pass locally.assistant: opencodeend-to-end.This PR is opened as a draft because two things should land before it merges:
binaryPath.provider.tscurrently hardcodes'/home/aatchison/.opencode/bin/opencode'. This needs to follow the same pattern asclaude/binary-resolver.tsandcodex/binary-resolver.ts— i.e. honorOPENCODE_BIN_PATH, thenassistants.opencode.opencodeBinaryPathfrom.archon/config.yaml, then a sensible autodetect path under~/.opencode/bin/or$PATH. Otherwise the provider only runs on a single developer's machine.OpenCodeProvider-specific tests. The existing registry tests cover wiring, but there is no test forsendQueryitself — spawn shape, stdout streaming,resumeSessionIdarg pass-through,--modelarg pass-through, or the kill-on-early-exit branch in thefinally.Happy to fold both into this PR — flagging them up front so reviewers can decide whether to gate the merge on them or accept this as a minimal first cut.