Files
harness-sync/internal/adapter/adapter.go
T
lukaszraczylo f30c0f65a6 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).
2026-06-16 21:32:12 +01:00

56 lines
1.6 KiB
Go

// Package adapter defines the harness adapter interface and FileSet.
package adapter
import "github.com/lukaszraczylo/harness-sync/internal/canonical"
type Kind int
const (
RenderedFile Kind = iota
SymlinkFile
SymlinkDir
)
func (k Kind) String() string {
switch k {
case RenderedFile:
return "rendered"
case SymlinkFile:
return "symlink-file"
case SymlinkDir:
return "symlink-dir"
}
return "unknown"
}
// HarnessCapabilities declares what an adapter manages.
// HasBuiltInSub means the harness has its own AI subscription (e.g. Claude Max)
// and harness-sync should not write provider/model/endpoint config for it.
type HarnessCapabilities struct {
ManagesProviders bool // writes provider/gateway endpoint config
ManagesModels bool // writes model selection config
ManagesMCP bool // writes MCP server config
ManagesSkills bool // writes skills symlink or equivalent
ManagesAgents bool // writes agents symlink or equivalent
ManagesRules bool // delivers rules (native rules dir, or folded into instructions)
ManagesInstructions bool // writes instructions file (CLAUDE.md, AGENTS.md, etc.)
HasBuiltInSub bool // has its own subscription; provider/model config is skipped
}
type Adapter interface {
Name() string
Detect() bool
Capabilities() HarnessCapabilities
Render(b *canonical.Bundle) (*FileSet, error)
Import(home string) (*ImportResult, error)
}
type ImportResult struct {
Instructions string
Skills []canonical.Skill
Agents []canonical.Agent
Rules []canonical.Rule
MCP []canonical.MCPServer
Profiles []canonical.Profile
}