mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-12 00:45:22 +00:00
fix(adapters): ground native schemas, merge-not-replace, add goose/cagent/zed
- common/mcp.go: MCPStyle enum + BuildMCPMapStyled for claude/crush/opencode/zed dialects - common/jsonmerge.go: MergeJSONKeys (JSON-first, JSONC fallback) preserves user keys; fix: try plain json.Unmarshal before StripJSONComments to avoid mangling URLs with // - common/yamlmerge.go: MergeYAMLKeys for YAML configs (goose) - common/blocks.go: add ProvidersAsMap for opencode map-shaped provider key - claudecode: merge settings.json (preserves hooks/permissions/env); MCPClaudeStyle (no type field) - crush: fix mcp key (was mcpServers); MCPCrushStyle entries include type field; merge crush.json; fix import key mcp - kilo: drop providers key (kilo has none); MCPOpencodeStyle (local/remote); merge kilo.json - opencode: fix provider (singular map) + model (not default_model); MCPOpencodeStyle; merge jsonc; fix import key mcp - goose: new adapter — YAML merge, extensions map, splitProviderModel, import reconstructs MCP from extensions - cagent: new adapter — renders starter default.yaml, import returns empty - zed: new adapter — merge settings.json, context_servers (MCPZedStyle) + agent.default_model - docs: append Grounded harness schemas section to design spec
This commit is contained in:
@@ -8,7 +8,6 @@ import (
|
||||
"github.com/lukaszraczylo/harness-sync/internal/adapter"
|
||||
"github.com/lukaszraczylo/harness-sync/internal/adapter/common"
|
||||
"github.com/lukaszraczylo/harness-sync/internal/canonical"
|
||||
"github.com/lukaszraczylo/harness-sync/internal/render"
|
||||
)
|
||||
|
||||
const name = "kilo"
|
||||
@@ -51,6 +50,10 @@ func (a *Adapter) Detect() bool {
|
||||
}
|
||||
|
||||
// Render produces the FileSet that applies the canonical bundle to kilo.
|
||||
// kilo.json is MERGED to preserve user-managed keys ($schema, small_model,
|
||||
// instructions, permission, compaction, watcher, formatter, skills).
|
||||
// Key "model" is a plain string; MCP uses "mcp" with local/remote type entries.
|
||||
// No "providers" key — kilo has no such concept.
|
||||
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
fs := adapter.NewFileSet()
|
||||
base := filepath.Join(a.home, ".config", "kilo")
|
||||
@@ -61,30 +64,27 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
SymlinkTarget: filepath.Join(b.Root, "agents"),
|
||||
})
|
||||
|
||||
cfg, err := renderConfig(b)
|
||||
cfgPath := filepath.Join(base, "kilo.json")
|
||||
existing, _ := os.ReadFile(cfgPath)
|
||||
overlay := map[string]any{
|
||||
"model": b.Profile.Gateway.DefaultModel,
|
||||
}
|
||||
if mcp := common.BuildMCPMapStyled(&b.MCP, common.MCPOpencodeStyle); len(mcp) > 0 {
|
||||
overlay["mcp"] = mcp
|
||||
}
|
||||
merged, err := common.MergeJSONKeys(existing, overlay)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fs.Add(adapter.File{
|
||||
Dest: filepath.Join(base, "kilo.json"),
|
||||
Dest: cfgPath,
|
||||
Kind: adapter.RenderedFile,
|
||||
Content: cfg,
|
||||
Content: merged,
|
||||
})
|
||||
|
||||
return fs, nil
|
||||
}
|
||||
|
||||
func renderConfig(b *canonical.Bundle) ([]byte, error) {
|
||||
out := map[string]any{
|
||||
"model": b.Profile.Gateway.DefaultModel,
|
||||
"providers": common.BuildProviders(&b.Profile),
|
||||
}
|
||||
if mcp := common.BuildMCPMap(&b.MCP); len(mcp) > 0 {
|
||||
out["mcp"] = mcp
|
||||
}
|
||||
return render.JSON(out)
|
||||
}
|
||||
|
||||
// Import reads kilo config from home and returns a canonical ImportResult.
|
||||
func (a *Adapter) Import(home string) (*adapter.ImportResult, error) {
|
||||
return importFrom(home)
|
||||
|
||||
@@ -46,8 +46,50 @@ func TestKiloRender(t *testing.T) {
|
||||
assert.Contains(t, parsed, "mcp")
|
||||
assert.NotContains(t, parsed, "default_model")
|
||||
assert.NotContains(t, parsed, "mcpServers")
|
||||
// kilo has no "providers" concept.
|
||||
assert.NotContains(t, parsed, "providers")
|
||||
// MCP entries use local/remote type (MCPOpencodeStyle).
|
||||
mcp := parsed["mcp"].(map[string]any)
|
||||
fp := mcp["filepuff"].(map[string]any)
|
||||
assert.Equal(t, "local", fp["type"])
|
||||
cmd, _ := fp["command"].([]any)
|
||||
assert.Equal(t, "/bin/filepuff", cmd[0])
|
||||
}
|
||||
|
||||
func TestKiloRenderMergesExistingKeys(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
base := filepath.Join(home, ".config", "kilo")
|
||||
require.NoError(t, os.MkdirAll(base, 0o750))
|
||||
|
||||
existing := map[string]any{
|
||||
"$schema": "https://kilo.schema/v1",
|
||||
"small_model": "claude-haiku",
|
||||
"compaction": map[string]any{"enabled": true},
|
||||
}
|
||||
body, _ := json.Marshal(existing)
|
||||
require.NoError(t, os.WriteFile(filepath.Join(base, "kilo.json"), body, 0o600))
|
||||
|
||||
ad := New(WithHome(home))
|
||||
b := &canonical.Bundle{
|
||||
Profile: canonical.Profile{
|
||||
Gateway: canonical.Gateway{DefaultModel: "sonnet"},
|
||||
},
|
||||
}
|
||||
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(base, "kilo.json")
|
||||
var parsed map[string]any
|
||||
require.NoError(t, json.Unmarshal(seen[cfgDest].Content, &parsed))
|
||||
// User keys preserved.
|
||||
assert.Equal(t, "https://kilo.schema/v1", parsed["$schema"])
|
||||
assert.Equal(t, "claude-haiku", parsed["small_model"])
|
||||
assert.Contains(t, parsed, "compaction")
|
||||
// Model updated.
|
||||
assert.Equal(t, "sonnet", parsed["model"])
|
||||
}
|
||||
func TestKiloImport(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
base := filepath.Join(home, ".config", "kilo")
|
||||
|
||||
Reference in New Issue
Block a user