OpenCode Engine

The original multi-model AI coding engine. OpenCode runs as a local HTTP/SSE server and powers QuantumReef's foundational session management, tool calls, and model routing.

Overview

OpenCode is the reference engine in QuantumReef and the most feature-complete integration available. It ships as a standalone CLI binary that exposes a local HTTP server with Server-Sent Events (SSE) for real-time streaming. QuantumReef connects to it via the OpenCodeClient adapter, which implements the full EngineClient interface.

OpenCode supports every major model provider — Anthropic Claude, OpenAI GPT-4o, Google Gemini, AWS Bedrock, and local Ollama models — through a unified session API. All tool calls, permission prompts, and message streaming flow through a single consistent interface regardless of the underlying provider.

Default Engine

OpenCode is selected as the default engine when you first launch QuantumReef. You can change the active engine per-workspace in Settings → Engine or via the CLI.

How It Works

When QuantumReef starts an OpenCode session, it spawns (or attaches to) the opencode process on a configurable port (default 4096). The process serves:

  • GET /v1/session — list all sessions
  • POST /v1/session — create a new session
  • GET /v1/session/:id/message — retrieve message history
  • POST /v1/session/:id/message — send a prompt (streams via SSE)
  • DELETE /v1/session/:id — abort a running session
  • GET /v1/events — global event bus (SSE)

QuantumReef subscribes to GET /v1/events immediately on connection, receiving a live stream of all session state changes, tool executions, and permission requests across the entire OpenCode process — even sessions started from the terminal CLI.

Installation & Setup

Install OpenCode

bash
# Install via npm (recommended)
npm install -g opencode-ai

# Or via Homebrew on macOS
brew install opencode

# Verify installation
opencode --version

Configure in QuantumReef

Open Settings → Engines → OpenCode and set:

SettingDefaultDescription
Host127.0.0.1The address OpenCode listens on
Port4096The HTTP port. Change if another service conflicts.
Auto-starttrueQuantumReef spawns opencode if not already running
Working Directory~Root directory passed to the opencode process
Modelclaude-opus-4-5Default model for new sessions

You can also set these via environment variables — useful for CI or headless deployments:

bash
QUANTUMREEF_OPENCODE_HOST=127.0.0.1
QUANTUMREEF_OPENCODE_PORT=4096
QUANTUMREEF_OPENCODE_AUTOSTART=true

Provider API Keys

OpenCode reads model provider credentials from your environment. Set the relevant key before launching:

bash
# Anthropic Claude (default)
export ANTHROPIC_API_KEY=sk-ant-...

# OpenAI GPT-4o
export OPENAI_API_KEY=sk-...

# Google Gemini
export GEMINI_API_KEY=AIza...

# Local Ollama (no key needed)
export OPENCODE_MODEL=ollama/qwen2.5-coder:32b

Session Management

QuantumReef maintains a session registry that mirrors the OpenCode process state. Sessions created from the terminal CLI, from another QuantumReef window, or from a mobile companion app are all discovered automatically via the SSE event bus.

Session Lifecycle

StateDescription
idleSession exists but no prompt is running
runningA prompt is currently being processed; tools may be executing
completedThe last prompt finished successfully
errorThe session encountered a non-recoverable error

Session Persistence

OpenCode stores session data in ~/.opencode/opencode.db (SQLite). QuantumReef reads this database to restore session history after a restart, even if the opencode process was not running when QuantumReef launched.

Cross-platform sessions

Sessions sync across all QuantumReef surfaces (desktop, mobile, CLI) because all of them read from the same OpenCode process or database file. Mount your home directory over a network share for true multi-machine continuity.

Configuration File

Fine-grained OpenCode configuration lives in ~/.config/opencode/config.json(or the path set by OPENCODE_CONFIG). QuantumReef merges per-workspace overrides on top of this global config.

~/.config/opencode/config.json
{
  "model": "claude-opus-4-5",
  "autoshare": false,
  "theme": "dark",
  "keybinds": {
    "leader": "ctrl+a"
  },
  "mcp": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/home/user"]
    }
  },
  "providers": {
    "anthropic": {
      "apiKey": "${ANTHROPIC_API_KEY}"
    }
  }
}

Strengths & Best Use Cases

StrengthDetail
Broadest model support12+ providers including local Ollama — switch models per-session
MCP ecosystemNative Model Context Protocol support; use any published MCP server
Stable SSE APIVersioned REST + SSE API; integrations never break between releases
Git-aware diffsBuilt-in diff viewer shows file changes before applying them
Tool call transparencyEvery tool call is visible in the QuantumReef MCP Tools Panel
Active communityLargest user base; most community plugins and skills

When to choose OpenCode

Choose OpenCode when you want maximum model flexibility, access to the broadest MCP tool ecosystem, or when you need the most battle-tested session API. It is the safest default for teams onboarding to QuantumReef.