mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-17 01:17:35 +00:00
feat: sync rules across all harnesses + agents to opencode/kilo
Add Rule as a first-class canonical kind (rules/<name>.md, loaded like agents) and propagate it the way each harness actually loads it: - claude-code: native ~/.claude/rules directory symlink (preserves rule path-scoping frontmatter); rules NOT folded into CLAUDE.md. - opencode/kilo/zed/crush: fold rule bodies into the global AGENTS.md always-on instructions file (frontmatter stripped). crush has no global instructions file, so register the absolute AGENTS.md path in options.context_paths (defaults are re-prepended at load, so nothing is clobbered). - goose: fold into ~/.config/goose/.goosehints. - cagent: fold into the per-agent instruction. Also: - Wire markdown agents to opencode (~/.config/opencode/agents) and fix the kilo agents symlink: plural ~/.config/kilo/agents (singular "agent" is a silent no-op on current Kilo CLI). - Add ManagesAgents/ManagesRules to HarnessCapabilities + ImportResult.Rules; claude-code/opencode import rules/agents round-trip. - Centralize instruction selection in Bundle.InstructionText / InstructionTextWithRules (replaces per-adapter override duplication). - init scaffolds + imports rules; README capability matrix gains Agents/Rules columns with native-vs-folded footnotes. Grounded each harness's sink against official docs + config source this session. Gate: gofmt, go vet, go test -race ./..., golangci-lint (0), govulncheck (clean).
This commit is contained in:
@@ -38,7 +38,9 @@ func (a *Adapter) Capabilities() adapter.HarnessCapabilities {
|
||||
ManagesModels: true,
|
||||
ManagesMCP: true,
|
||||
ManagesSkills: true,
|
||||
ManagesInstructions: false,
|
||||
ManagesAgents: true,
|
||||
ManagesRules: true,
|
||||
ManagesInstructions: true,
|
||||
HasBuiltInSub: false,
|
||||
}
|
||||
}
|
||||
@@ -58,8 +60,11 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
fs := adapter.NewFileSet()
|
||||
base := filepath.Join(a.Home, ".config", "kilo")
|
||||
|
||||
// Kilo CLI reads global markdown subagents from ~/.config/kilo/agents/<name>.md
|
||||
// (PLURAL — the singular "agent/" used by older OpenCode-fork builds is a
|
||||
// silent no-op on current Kilo).
|
||||
fs.Add(adapter.File{
|
||||
Dest: filepath.Join(base, "agent"),
|
||||
Dest: filepath.Join(base, "agents"),
|
||||
Kind: adapter.SymlinkDir,
|
||||
SymlinkTarget: filepath.Join(b.Root, "agents"),
|
||||
})
|
||||
@@ -69,6 +74,13 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
Kind: adapter.SymlinkDir,
|
||||
SymlinkTarget: filepath.Join(b.Root, "skills"),
|
||||
})
|
||||
// kilo has no global rules directory; ~/.config/kilo/AGENTS.md is the
|
||||
// always-on global instructions file, so fold rules into it.
|
||||
fs.Add(adapter.File{
|
||||
Dest: filepath.Join(base, "AGENTS.md"),
|
||||
Kind: adapter.RenderedFile,
|
||||
Content: []byte(b.InstructionTextWithRules(name)),
|
||||
})
|
||||
|
||||
cfgPath := filepath.Join(base, "kilo.json")
|
||||
existing, err := common.ReadExistingFile(cfgPath)
|
||||
|
||||
@@ -33,7 +33,8 @@ func TestKiloRender(t *testing.T) {
|
||||
seen := map[string]adapter.File{}
|
||||
fs.ForEach(func(f adapter.File) { seen[f.Dest] = f })
|
||||
|
||||
agentDest := filepath.Join(home, ".config", "kilo", "agent")
|
||||
// Global markdown subagents dir is PLURAL "agents" on current Kilo CLI.
|
||||
agentDest := filepath.Join(home, ".config", "kilo", "agents")
|
||||
assert.Equal(t, adapter.SymlinkDir, seen[agentDest].Kind)
|
||||
assert.Equal(t, "/canon/agents", seen[agentDest].SymlinkTarget)
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package kilo
|
||||
|
||||
import (
|
||||
"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 TestKiloFoldsRulesIntoAGENTS(t *testing.T) {
|
||||
home := t.TempDir()
|
||||
b := &canonical.Bundle{
|
||||
Root: "/canon",
|
||||
Instructions: canonical.Instructions{Global: "# global"},
|
||||
Rules: []canonical.Rule{{Name: "py", Body: "# Py\n\ntype hints"}},
|
||||
}
|
||||
fs, err := New(WithHome(home)).Render(b)
|
||||
require.NoError(t, err)
|
||||
seen := map[string]adapter.File{}
|
||||
fs.ForEach(func(f adapter.File) { seen[f.Dest] = f })
|
||||
|
||||
agentsMD := filepath.Join(home, ".config", "kilo", "AGENTS.md")
|
||||
require.Contains(t, seen, agentsMD)
|
||||
assert.Equal(t, adapter.RenderedFile, seen[agentsMD].Kind)
|
||||
body := string(seen[agentsMD].Content)
|
||||
assert.Contains(t, body, "# global")
|
||||
assert.Contains(t, body, "type hints")
|
||||
}
|
||||
Reference in New Issue
Block a user