Skip to content

OpenCode Provider Integration — Tracking Issue #1422

@coygeek

Description

@coygeek

Overview

OpenCode is being added as a community AI assistant provider for Archon. This issue tracks the implementation progress and serves as a central reference for the two open PRs.

Related PRs

Motivation

Users have requested the ability to use OpenCode as an alternative to Claude Code within Archon workflows (see closed issue #1151). The adapters pattern allows Archon to remain CLI-agnostic while keeping Claude Code as the default.

Architecture (from PR #1372 design doc)

OpenCode is a client/server AI coding agent (unlike Claude Code/Codex which are monolithic CLIs). The provider:

  1. Lazy-starts an OpenCode Server (opencode serve) on first use with lifecycle management
  2. Connects via @opencode-ai/sdk using createOpencodeClient
  3. Bridges SSE events to Archon's MessageChunk async generator contract
  4. Manages session lifecycle (create/resume/abort) via SDK

Key files

packages/providers/src/community/opencode/
├── provider.ts              # OpenCodeProvider class
├── capabilities.ts          # OPENCODE_CAPABILITIES
├── config.ts                # parseOpencodeConfig
├── server-manager.ts        # OpenCode Server lifecycle
├── event-bridge.ts          # SSE Event → MessageChunk
├── registration.ts          # registerOpencodeProvider()
├── index.ts                 # Public exports
├── provider.test.ts         # Tests
└── config.test.ts           # Config tests

Event Bridge Mapping

OpenCode Event Archon MessageChunk
message.part.updated (text delta) assistant
message.part.updated (reasoning) thinking
message.part.updated (tool call) tool
message.part.updated (tool result) tool_result
message.updated (assistant complete) result (with tokens)
session.error result (isError: true)

What's Implemented

Capability Status Notes
sessionResume Session IDs persisted by OpenCode Server
mcp Native MCP support via OpenCode
skills Injected via systemPrompt
toolRestrictions allowed_tools / denied_tools mapped to SDK
structuredOutput SDK-native JSON Schema support
envInjection Per-request env vars
effortControl Via reasoning effort
thinkingControl Via reasoning toggle
agents ✅ (via #1384)
hooks Archon hooks ≠ OpenCode plugins
costControl No cost limit API
fallbackModel No automatic fallback
sandbox No sandbox support

Configuration

# .archon/config.yaml
assistants:
  opencode:
    model: anthropic/claude-sonnet-4
    hostname: 127.0.0.1
    port: 4096
    autoStartServer: true

Reference: OpenCode Repo Structure

The OpenCode provider connects to anomalyco/opencode which has:

  • SDK: packages/sdk/js/createOpencodeClient factory, v2 client
  • Provider system: packages/opencode/src/provider/ — auth, models, schema
  • ACP (Agent Communication Protocol): packages/opencode/src/acp/ — agent, session, types
  • MCP server support, skill system, and agent interface already built in

Next Steps

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium priority - Backlog, when time permitsarea: clientsAI assistant clientseffort/highCross-cutting changes, multiple domains, requires design decisionsfeatureNew functionality (planned)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions