feat(config): add OpenCode as built-in agent preset (#861)

Add AgentOpenCode as a first-class built-in agent preset, similar to
Claude, Gemini, Codex, Cursor, Auggie, and AMP.

OpenCode preset configuration:
- Command: "opencode"
- Args: [] (uses Env for YOLO mode, no CLI flags needed)
- Env: OPENCODE_PERMISSION='{"*":"allow"}' for auto-approve
- ProcessNames: ["opencode", "node"] (runs as Node.js)
- SupportsHooks: true (uses .opencode/plugin/gastown.js)
- NonInteractive: run subcommand with --format json

Runtime defaults for opencode provider:
- ready_delay_ms: 8000 (delay-based detection for TUI)
- process_names: [opencode, node]
- instructions_file: AGENTS.md

This allows users to simply configure:
  role_agents:
    refinery: "opencode"

Instead of manually configuring agents.json and runtime settings.

Test coverage:
- TestOpenCodeAgentPreset: comprehensive preset validation
- TestOpenCodeProviderDefaults: runtime config defaults
- TestOpenCodeRuntimeConfigFromPreset: Env copying
- TestIsKnownPreset: includes opencode
- TestGetAgentPresetByName: opencode returns preset

Templates added:
- templates/agents/opencode.json.tmpl: agent config template
- templates/agents/opencode-models.json: model delay presets

Co-authored-by: Avyukth <subhrajit.makur@hotmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2026-01-21 17:20:57 -08:00
committed by GitHub
parent e12aa45dd6
commit f00b0254f2
5 changed files with 235 additions and 3 deletions

View File

@@ -575,6 +575,11 @@ func defaultProcessNames(provider, command string) []string {
if provider == "claude" {
return []string{"node"}
}
if provider == "opencode" {
// OpenCode runs as Node.js process, need both for IsAgentRunning detection.
// tmux pane_current_command may show "node" or "opencode" depending on how invoked.
return []string{"opencode", "node"}
}
if command != "" {
return []string{filepath.Base(command)}
}
@@ -596,6 +601,12 @@ func defaultReadyDelayMs(provider string) int {
if provider == "codex" {
return 3000
}
if provider == "opencode" {
// OpenCode requires delay-based detection because its TUI uses
// box-drawing characters (┃) that break prompt prefix matching.
// 8000ms provides reliable startup detection across models.
return 8000
}
return 0
}