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:
2026-05-23 03:23:02 +01:00
parent a18cb1a4b7
commit 63bd976f4b
25 changed files with 1557 additions and 58 deletions
+14 -15
View File
@@ -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 = "crush"
@@ -49,6 +48,8 @@ func (a *Adapter) Detect() bool {
}
// Render produces the FileSet that applies the canonical bundle to crush.
// crush.json is MERGED so user-managed keys ($schema, lsp, options, permissions) are preserved.
// MCP key is "mcp" (not "mcpServers"); entries include a "type" field.
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
fs := adapter.NewFileSet()
base := filepath.Join(a.home, ".config", "crush")
@@ -59,30 +60,28 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
SymlinkTarget: filepath.Join(b.Root, "skills"),
})
cfg, err := renderConfig(b)
cfgPath := filepath.Join(base, "crush.json")
existing, _ := os.ReadFile(cfgPath)
overlay := map[string]any{
"providers": common.BuildProviders(&b.Profile),
"default_model": b.Profile.Gateway.DefaultModel,
}
if mcp := common.BuildMCPMapStyled(&b.MCP, common.MCPCrushStyle); 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, "crush.json"),
Dest: cfgPath,
Kind: adapter.RenderedFile,
Content: cfg,
Content: merged,
})
return fs, nil
}
func renderConfig(b *canonical.Bundle) ([]byte, error) {
out := map[string]any{
"providers": common.BuildProviders(&b.Profile),
"default_model": b.Profile.Gateway.DefaultModel,
}
if mcp := common.BuildMCPMap(&b.MCP); len(mcp) > 0 {
out["mcpServers"] = mcp
}
return render.JSON(out)
}
// Import reads crush config from home and returns a canonical ImportResult.
func (a *Adapter) Import(home string) (*adapter.ImportResult, error) {
return importFrom(home)