feat(daemon): add opencode as supported agent provider (#341)

* feat(daemon): add opencode as supported agent provider

Add opencode backend alongside claude and codex. The backend spawns
`opencode run --format json`, parses streaming JSON events (text,
tool_use, error, step_start/finish), and supports --prompt for system
prompts. Includes CLI detection, AGENTS.md runtime config, native skill
discovery via .config/opencode/skills/, and 21 tests covering handlers,
JSON parsing, and integration-level processEvents scenarios.

* chore: add .tool-versions to gitignore
This commit is contained in:
Quake Wang 2026-04-02 18:52:07 +09:00 committed by GitHub
parent 09764c5f51
commit 36db325d50
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 1203 additions and 23 deletions

View file

@ -11,9 +11,10 @@ import (
// writeContextFiles renders and writes .agent_context/issue_context.md and
// skills into the appropriate provider-native location.
//
// Claude: skills → {workDir}/.claude/skills/{name}/SKILL.md (native discovery)
// Codex: skills → handled separately in Prepare via codex-home
// Default: skills → {workDir}/.agent_context/skills/{name}/SKILL.md
// Claude: skills → {workDir}/.claude/skills/{name}/SKILL.md (native discovery)
// Codex: skills → handled separately in Prepare via codex-home
// OpenCode: skills → {workDir}/.config/opencode/skills/{name}/SKILL.md (native discovery)
// Default: skills → {workDir}/.agent_context/skills/{name}/SKILL.md
func writeContextFiles(workDir, provider string, ctx TaskContextForEnv) error {
contextDir := filepath.Join(workDir, ".agent_context")
if err := os.MkdirAll(contextDir, 0o755); err != nil {
@ -50,6 +51,9 @@ func resolveSkillsDir(workDir, provider string) (string, error) {
case "claude":
// Claude Code natively discovers skills from .claude/skills/ in the workdir.
skillsDir = filepath.Join(workDir, ".claude", "skills")
case "opencode":
// OpenCode natively discovers skills from .config/opencode/skills/ in the workdir.
skillsDir = filepath.Join(workDir, ".config", "opencode", "skills")
default:
// Fallback: write to .agent_context/skills/ (referenced by meta config).
skillsDir = filepath.Join(workDir, ".agent_context", "skills")