feat(opencode): adapter with opencode.jsonc render + AGENTS.md

This commit is contained in:
2026-05-23 02:59:53 +01:00
parent 7013bada1c
commit 6dafb43c43
2 changed files with 15 additions and 11 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ func TestCrushRenderProducesExpectedTargets(t *testing.T) {
func TestCrushImportRoundtrip(t *testing.T) { func TestCrushImportRoundtrip(t *testing.T) {
home := t.TempDir() home := t.TempDir()
base := filepath.Join(home, ".config", "crush") base := filepath.Join(home, ".config", "crush")
require.NoError(t, os.MkdirAll(base, 0o755)) require.NoError(t, os.MkdirAll(base, 0o750))
// Minimal crush.json // Minimal crush.json
cfg := map[string]any{ cfg := map[string]any{
@@ -55,7 +55,7 @@ func TestCrushImportRoundtrip(t *testing.T) {
}, },
} }
body, _ := json.Marshal(cfg) body, _ := json.Marshal(cfg)
require.NoError(t, os.WriteFile(filepath.Join(base, "crush.json"), body, 0o644)) require.NoError(t, os.WriteFile(filepath.Join(base, "crush.json"), body, 0o600))
ad := New(WithHome(home)) ad := New(WithHome(home))
res, err := ad.Import(home) res, err := ad.Import(home)
+13 -9
View File
@@ -9,6 +9,18 @@ import (
"github.com/lukaszraczylo/harness-sync/internal/canonical" "github.com/lukaszraczylo/harness-sync/internal/canonical"
) )
type crushMCPEntry struct { //nolint:govet // fieldalignment: map+slice+3 strings irreducible
Env map[string]string `json:"env"`
Args []string `json:"args"`
Command string `json:"command"`
URL string `json:"url"`
Transport string `json:"transport"`
}
type crushConfig struct {
MCPServers map[string]crushMCPEntry `json:"mcpServers"`
}
func importFrom(home string) (*adapter.ImportResult, error) { func importFrom(home string) (*adapter.ImportResult, error) {
cfgPath := filepath.Join(home, ".config", "crush", "crush.json") cfgPath := filepath.Join(home, ".config", "crush", "crush.json")
body, err := os.ReadFile(cfgPath) body, err := os.ReadFile(cfgPath)
@@ -19,15 +31,7 @@ func importFrom(home string) (*adapter.ImportResult, error) {
return nil, err return nil, err
} }
var doc struct { var doc crushConfig
MCPServers map[string]struct {
Command string `json:"command"`
Args []string `json:"args"`
URL string `json:"url"`
Transport string `json:"transport"`
Env map[string]string `json:"env"`
} `json:"mcpServers"`
}
_ = json.Unmarshal(body, &doc) _ = json.Unmarshal(body, &doc)
res := &adapter.ImportResult{} res := &adapter.ImportResult{}