Skip to content

feat(providers): add OpenCode as a built-in provider#1616

Closed
aatchison wants to merge 1 commit into
coleam00:mainfrom
aatchison:feat/opencode-provider
Closed

feat(providers): add OpenCode as a built-in provider#1616
aatchison wants to merge 1 commit into
coleam00:mainfrom
aatchison:feat/opencode-provider

Conversation

@aatchison

Copy link
Copy Markdown

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.tsOpenCodeProvider class implementing IAgentProvider. Spawns the local opencode binary with bun.spawn, decodes stdout chunks, and yields them as assistant MessageChunks. Supports --session for resume and --model overrides.
  • packages/providers/src/registry.ts — registers opencode as 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.
  • CI lint + full test suite.
  • Smoke-test running a workflow with assistant: opencode end-to-end.

⚠️ Known issues — please review before merge

This PR is opened as a draft because two things should land before it merges:

  1. Hardcoded binaryPath. provider.ts currently hardcodes '/home/aatchison/.opencode/bin/opencode'. This needs to follow the same pattern as claude/binary-resolver.ts and codex/binary-resolver.ts — i.e. honor OPENCODE_BIN_PATH, then assistants.opencode.opencodeBinaryPath from .archon/config.yaml, then a sensible autodetect path under ~/.opencode/bin/ or $PATH. Otherwise the provider only runs on a single developer's machine.
  2. No OpenCodeProvider-specific tests. The existing registry tests cover wiring, but there is no test for sendQuery itself — spawn shape, stdout streaming, resumeSessionId arg pass-through, --model arg pass-through, or the kill-on-early-exit branch in the finally.

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.

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>
@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 14650d5f-0598-4320-924c-b248a5600b39

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@aatchison aatchison marked this pull request as ready for review May 8, 2026 20:32
@aatchison

Copy link
Copy Markdown
Author

Moving this to the aatchison/Archon fork — wasn't ready to PR upstream yet. Will reopen there.

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.

1 participant