From 6dafb43c43927f25842b93f7f4ac1f04a0ad4def Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sat, 23 May 2026 02:59:53 +0100 Subject: [PATCH] feat(opencode): adapter with opencode.jsonc render + AGENTS.md --- internal/adapters/crush/crush_test.go | 4 ++-- internal/adapters/crush/import.go | 22 +++++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/internal/adapters/crush/crush_test.go b/internal/adapters/crush/crush_test.go index 824b1dd..fbab747 100644 --- a/internal/adapters/crush/crush_test.go +++ b/internal/adapters/crush/crush_test.go @@ -46,7 +46,7 @@ func TestCrushRenderProducesExpectedTargets(t *testing.T) { func TestCrushImportRoundtrip(t *testing.T) { home := t.TempDir() base := filepath.Join(home, ".config", "crush") - require.NoError(t, os.MkdirAll(base, 0o755)) + require.NoError(t, os.MkdirAll(base, 0o750)) // Minimal crush.json cfg := map[string]any{ @@ -55,7 +55,7 @@ func TestCrushImportRoundtrip(t *testing.T) { }, } 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)) res, err := ad.Import(home) diff --git a/internal/adapters/crush/import.go b/internal/adapters/crush/import.go index 48e0a78..34ce751 100644 --- a/internal/adapters/crush/import.go +++ b/internal/adapters/crush/import.go @@ -9,6 +9,18 @@ import ( "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) { cfgPath := filepath.Join(home, ".config", "crush", "crush.json") body, err := os.ReadFile(cfgPath) @@ -19,15 +31,7 @@ func importFrom(home string) (*adapter.ImportResult, error) { return nil, err } - var doc struct { - 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"` - } + var doc crushConfig _ = json.Unmarshal(body, &doc) res := &adapter.ImportResult{}