Summary
Implement an AgentAdapter for OpenCode, an open-source terminal-based AI coding assistant, allowing CodeFrame to delegate code writing to OpenCode as a subprocess.
Parent issue: #408
Motivation
OpenCode is a fast, terminal-native AI coding tool with multi-model support and strong file editing. It provides a different execution profile from Claude Code and can work with multiple LLM providers (OpenAI, Anthropic, etc.), giving CodeFrame users flexibility in which underlying model powers their coding agent.
Scope
New module: core/engines/opencode.py
OpenCodeAdapter implementing AgentAdapter:
class OpenCodeAdapter:
name = "opencode"
requires_api_key = {} # OpenCode manages its own API keys/config
def execute(self, task_prompt, workspace_path, context, timeout_ms):
# 1. Build task prompt from context packager
# 2. Launch opencode in non-interactive/script mode
# with cwd=workspace_path
# 3. Capture output
# 4. Parse results into AgentResult
...
-
OpenCode CLI invocation:
- Research OpenCode's non-interactive/scripting mode
- Pass task prompt via appropriate mechanism (stdin, flag, or file)
- Set
cwd to workspace path
- Disable auto-commits (CodeFrame owns git workflow)
-
Output parsing:
- Detect modified files via git diff after execution
- Parse success/failure from exit code and output
- Extract summary from completion output
-
Configuration:
opencode_path: path to opencode binary (default: opencode)
opencode_model: LLM model override (optional)
opencode_flags: additional CLI flags
Acceptance Criteria
Dependencies
Summary
Implement an
AgentAdapterfor OpenCode, an open-source terminal-based AI coding assistant, allowing CodeFrame to delegate code writing to OpenCode as a subprocess.Parent issue: #408
Motivation
OpenCode is a fast, terminal-native AI coding tool with multi-model support and strong file editing. It provides a different execution profile from Claude Code and can work with multiple LLM providers (OpenAI, Anthropic, etc.), giving CodeFrame users flexibility in which underlying model powers their coding agent.
Scope
New module:
core/engines/opencode.pyOpenCodeAdapterimplementingAgentAdapter:OpenCode CLI invocation:
cwdto workspace pathOutput parsing:
Configuration:
opencode_path: path to opencode binary (default:opencode)opencode_model: LLM model override (optional)opencode_flags: additional CLI flagsAcceptance Criteria
OpenCodeAdapterimplementsAgentAdapterprotocolcf work start <id> --execute --engine opencodeDependencies