Files
gastown/templates/agents/opencode.json.tmpl
Steve Yegge f00b0254f2 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>
2026-01-21 17:20:57 -08:00

25 lines
754 B
Cheetah

{
"$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"
}
}