Add OpenCode as a built-in TypeSection recipe that injects a beads
workflow section into AGENTS.md, following the same pattern as the
existing factory and codex recipes.
- Register 'opencode' in BuiltinRecipes (internal/recipes/recipes.go)
- Add cmd/bd/setup/opencode.go with Install/Check/Remove functions
- Wire up 'bd setup opencode' subcommand in cmd/bd/setup.go
- Add tests for install and check modes
Supports: bd setup opencode, bd setup opencode --check,
bd setup opencode --remove
Fixes steveyegge/beads#1321
Amp-Thread-ID: https://ampcode.com/threads/T-019cb569-6bbd-73fd-85a8-167984100b35
Co-authored-by: Amp <amp@ampcode.com>
36 lines
899 B
Go
36 lines
899 B
Go
package setup
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func stubOpenCodeEnvProvider(t *testing.T, env agentsEnv) {
|
|
t.Helper()
|
|
orig := opencodeEnvProvider
|
|
opencodeEnvProvider = func() agentsEnv {
|
|
return env
|
|
}
|
|
t.Cleanup(func() { opencodeEnvProvider = orig })
|
|
}
|
|
|
|
func TestInstallOpenCodeCreatesNewFile(t *testing.T) {
|
|
env, stdout, _ := newFactoryTestEnv(t)
|
|
if err := installOpenCode(env); err != nil {
|
|
t.Fatalf("installOpenCode returned error: %v", err)
|
|
}
|
|
if !strings.Contains(stdout.String(), "OpenCode integration installed") {
|
|
t.Error("expected OpenCode install success message")
|
|
}
|
|
}
|
|
|
|
func TestCheckOpenCodeMissingFile(t *testing.T) {
|
|
env, stdout, _ := newFactoryTestEnv(t)
|
|
err := checkOpenCode(env)
|
|
if err == nil {
|
|
t.Fatal("expected error for missing AGENTS.md")
|
|
}
|
|
if !strings.Contains(stdout.String(), "bd setup opencode") {
|
|
t.Error("expected setup guidance for opencode")
|
|
}
|
|
}
|