feat(kilo): adapter with kilo.json render + agent symlink

This commit is contained in:
2026-05-23 02:59:50 +01:00
parent fe9206716e
commit 7013bada1c
9 changed files with 779 additions and 0 deletions
@@ -0,0 +1,61 @@
package opencode
import (
"encoding/json"
"os"
"path/filepath"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/lukaszraczylo/harness-sync/internal/adapter"
"github.com/lukaszraczylo/harness-sync/internal/canonical"
)
func TestOpencodeRender(t *testing.T) {
home := t.TempDir()
ad := New(WithHome(home))
b := &canonical.Bundle{
Root: "/canon",
Profile: canonical.Profile{
Gateway: canonical.Gateway{URL: "https://gw", Token: "dummy", DefaultModel: "sonnet"},
Models: []canonical.Model{{ID: "claude-sonnet-4-6", Alias: "sonnet"}},
},
Instructions: canonical.Instructions{Global: "# global"},
}
fs, err := ad.Render(b)
require.NoError(t, err)
seen := map[string]adapter.File{}
fs.ForEach(func(f adapter.File) { seen[f.Dest] = f })
cfgDest := filepath.Join(home, ".config", "opencode", "opencode.jsonc")
assert.Equal(t, adapter.RenderedFile, seen[cfgDest].Kind)
var parsed map[string]any
require.NoError(t, json.Unmarshal(seen[cfgDest].Content, &parsed))
agentsDest := filepath.Join(home, ".config", "opencode", "AGENTS.md")
assert.Equal(t, adapter.RenderedFile, seen[agentsDest].Kind)
assert.Contains(t, string(seen[agentsDest].Content), "# global")
}
func TestOpencodeImportStripsComments(t *testing.T) {
home := t.TempDir()
base := filepath.Join(home, ".config", "opencode")
require.NoError(t, os.MkdirAll(base, 0o750))
jsonc := `// header comment
{
"providers": [{"id": "anthropic"}], // trailing
/* block
comment */
"default_model": "sonnet"
}`
require.NoError(t, os.WriteFile(filepath.Join(base, "opencode.jsonc"), []byte(jsonc), 0o600))
require.NoError(t, os.WriteFile(filepath.Join(base, "AGENTS.md"), []byte("# global"), 0o600))
ad := New(WithHome(home))
res, err := ad.Import(home)
require.NoError(t, err)
assert.Equal(t, "# global", res.Instructions)
}