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:
@@ -27,6 +27,8 @@ const (
|
||||
AgentAuggie AgentPreset = "auggie"
|
||||
// AgentAmp is Sourcegraph AMP.
|
||||
AgentAmp AgentPreset = "amp"
|
||||
// AgentOpenCode is OpenCode multi-model CLI.
|
||||
AgentOpenCode AgentPreset = "opencode"
|
||||
)
|
||||
|
||||
// AgentPresetInfo contains the configuration details for an agent preset.
|
||||
@@ -182,6 +184,25 @@ var builtinPresets = map[AgentPreset]*AgentPresetInfo{
|
||||
SupportsHooks: false,
|
||||
SupportsForkSession: false,
|
||||
},
|
||||
AgentOpenCode: {
|
||||
Name: AgentOpenCode,
|
||||
Command: "opencode",
|
||||
Args: []string{}, // No CLI flags needed, YOLO via OPENCODE_PERMISSION env
|
||||
Env: map[string]string{
|
||||
// Auto-approve all tool calls (equivalent to --dangerously-skip-permissions)
|
||||
"OPENCODE_PERMISSION": `{"*":"allow"}`,
|
||||
},
|
||||
ProcessNames: []string{"opencode", "node"}, // Runs as Node.js
|
||||
SessionIDEnv: "", // OpenCode manages sessions internally
|
||||
ResumeFlag: "", // No resume support yet
|
||||
ResumeStyle: "",
|
||||
SupportsHooks: true, // Uses .opencode/plugin/gastown.js
|
||||
SupportsForkSession: false,
|
||||
NonInteractive: &NonInteractiveConfig{
|
||||
Subcommand: "run",
|
||||
OutputFlag: "--format json",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// Registry state with proper synchronization.
|
||||
|
||||
Reference in New Issue
Block a user