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:
60
templates/agents/opencode-models.json
Normal file
60
templates/agents/opencode-models.json
Normal file
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"version": 1,
|
||||
"description": "OpenCode model presets with recommended delay settings for gastown integration",
|
||||
"usage": "Use ready_delay_ms values when configuring runtime.tmux.ready_delay_ms in agents.json",
|
||||
"models_api": "https://models.dev/api.json",
|
||||
"models_api_note": "LLMs should fetch current model list from models_api. The 'models' below are fallback examples with gastown-specific delay recommendations.",
|
||||
"models": {
|
||||
"openai": {
|
||||
"gpt-5.2": {
|
||||
"description": "GPT-5.2 chat model",
|
||||
"ready_delay_ms": 5000
|
||||
},
|
||||
"gpt-5.2-codex": {
|
||||
"description": "GPT-5.2 Codex for code tasks",
|
||||
"ready_delay_ms": 8000
|
||||
},
|
||||
"codex-1": {
|
||||
"description": "Codex-1 extended context",
|
||||
"ready_delay_ms": 10000
|
||||
}
|
||||
},
|
||||
"google": {
|
||||
"gemini-3-pro-high": {
|
||||
"description": "Gemini 3 Pro High quality",
|
||||
"ready_delay_ms": 6000
|
||||
}
|
||||
},
|
||||
"xai": {
|
||||
"grok-code-fast-1": {
|
||||
"description": "Grok Code Fast",
|
||||
"ready_delay_ms": 4000
|
||||
}
|
||||
},
|
||||
"github-copilot": {
|
||||
"gpt-5.2-codex": {
|
||||
"description": "GitHub Copilot GPT-5.2 Codex",
|
||||
"ready_delay_ms": 8000
|
||||
}
|
||||
},
|
||||
"opencode": {
|
||||
"glm-4.7-free": {
|
||||
"description": "GLM 4.7 Free tier (may timeout, needs longer delay)",
|
||||
"ready_delay_ms": 15000
|
||||
},
|
||||
"minimax-m2.1-free": {
|
||||
"description": "MiniMax M2.1 Free tier",
|
||||
"ready_delay_ms": 10000
|
||||
},
|
||||
"big-pickle": {
|
||||
"description": "Big Pickle experimental",
|
||||
"ready_delay_ms": 12000
|
||||
}
|
||||
}
|
||||
},
|
||||
"notes": {
|
||||
"why_delay_based": "OpenCode TUI uses box-drawing characters that break prompt prefix matching. Delay-based detection is required.",
|
||||
"free_tier_warning": "Free tier models may have longer cold start times. Increase delay if timeout errors occur.",
|
||||
"default_delay": 8000
|
||||
}
|
||||
}
|
||||
24
templates/agents/opencode.json.tmpl
Normal file
24
templates/agents/opencode.json.tmpl
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"$schema": "https://gastown.dev/schemas/agent-template-v1.json",
|
||||
"_models_api": "https://models.dev/api.json",
|
||||
"_note": "LLMs: fetch available models from _models_api to get current provider/model options",
|
||||
"name": "opencode-{{.Model}}",
|
||||
"description": "OpenCode agent using {{.Provider}}/{{.Model}}",
|
||||
"command": "{{.OpenCodePath | default \"opencode\"}}",
|
||||
"args": ["-m", "{{.Provider}}/{{.Model}}"],
|
||||
"non_interactive": {
|
||||
"subcommand": "run",
|
||||
"output_flag": "--format json"
|
||||
},
|
||||
"runtime": {
|
||||
"provider": "opencode",
|
||||
"tmux": {
|
||||
"ready_prompt_prefix": "",
|
||||
"ready_delay_ms": {{.ReadyDelayMs | default 8000}},
|
||||
"process_names": ["opencode", "node"]
|
||||
}
|
||||
},
|
||||
"hooks": {
|
||||
"provider": "opencode"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user