mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-12 00:45:22 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
12e448ca39 | ||
|
|
0865c405fb | ||
|
|
b6bd5303e0 | ||
|
|
f81492eb46 | ||
|
|
76ac377b5d | ||
|
|
2e661fb526 | ||
|
|
c4f1b0fa1d | ||
|
|
bf7be9d9c5 | ||
|
|
c5707acfd3 | ||
|
|
3e3c78725e | ||
|
|
82e1de9773 | ||
|
|
565d72768b | ||
|
|
4701b45a12 | ||
|
|
8e3ec78e2b | ||
|
|
62debbfcda | ||
|
|
b5e3bcd301 | ||
|
|
fd6519eed1 | ||
|
|
bca4a4be1a |
@@ -1,2 +1,4 @@
|
|||||||
{"action":"prune","keep":10,"kept":[],"removed":[],"auditedAt":"2026-05-23T19:08:40.613Z"}
|
{"action":"prune","keep":10,"kept":[],"removed":[],"auditedAt":"2026-05-23T19:08:40.613Z"}
|
||||||
{"action":"prune","keep":10,"kept":[],"removed":[],"auditedAt":"2026-05-23T19:55:51.755Z"}
|
{"action":"prune","keep":10,"kept":[],"removed":[],"auditedAt":"2026-05-23T19:55:51.755Z"}
|
||||||
|
{"action":"prune","keep":10,"kept":[],"removed":[],"auditedAt":"2026-06-27T23:46:20.411Z"}
|
||||||
|
{"action":"prune","keep":10,"kept":[],"removed":[],"auditedAt":"2026-06-27T23:48:27.473Z"}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{"exportedAt":"2026-06-27T23:47:20.367Z","snapshots":[{"type":"counter","name":"crew.run.count","description":"Total runs by status","values":[]},{"type":"counter","name":"crew.task.count","description":"Total tasks by status","values":[]},{"type":"counter","name":"crew.subagent.count","description":"Total subagent records by status","values":[]},{"type":"counter","name":"crew.mailbox.count","description":"Total mailbox messages by direction","values":[]},{"type":"counter","name":"crew.task.retry_attempt_total","description":"Retry attempts by run and task","values":[]},{"type":"counter","name":"crew.task.deadletter_total","description":"Deadletter triggers by reason","values":[]},{"type":"counter","name":"crew.task.overflow_phase_total","description":"Overflow recovery phase transitions","values":[]},{"type":"counter","name":"crew.task.supervisor_contact_total","description":"Supervisor contact requests by reason","values":[]},{"type":"gauge","name":"crew.heartbeat.staleness_ms","description":"Heartbeat elapsed since last seen, milliseconds","values":[]},{"type":"histogram","name":"crew.run.duration_ms","description":"Run end-to-end duration, milliseconds","values":[]},{"type":"histogram","name":"crew.task.duration_ms","description":"Task duration, milliseconds","values":[]},{"type":"histogram","name":"crew.task.retry_count","description":"Retries per task","values":[]},{"type":"histogram","name":"crew.task.tokens_total","description":"Token usage per task","values":[]}]}
|
||||||
|
{"exportedAt":"2026-06-27T23:48:20.367Z","snapshots":[{"type":"counter","name":"crew.run.count","description":"Total runs by status","values":[]},{"type":"counter","name":"crew.task.count","description":"Total tasks by status","values":[]},{"type":"counter","name":"crew.subagent.count","description":"Total subagent records by status","values":[]},{"type":"counter","name":"crew.mailbox.count","description":"Total mailbox messages by direction","values":[]},{"type":"counter","name":"crew.task.retry_attempt_total","description":"Retry attempts by run and task","values":[]},{"type":"counter","name":"crew.task.deadletter_total","description":"Deadletter triggers by reason","values":[]},{"type":"counter","name":"crew.task.overflow_phase_total","description":"Overflow recovery phase transitions","values":[]},{"type":"counter","name":"crew.task.supervisor_contact_total","description":"Supervisor contact requests by reason","values":[]},{"type":"gauge","name":"crew.heartbeat.staleness_ms","description":"Heartbeat elapsed since last seen, milliseconds","values":[]},{"type":"histogram","name":"crew.run.duration_ms","description":"Run end-to-end duration, milliseconds","values":[]},{"type":"histogram","name":"crew.task.duration_ms","description":"Task duration, milliseconds","values":[]},{"type":"histogram","name":"crew.task.retry_count","description":"Retries per task","values":[]},{"type":"histogram","name":"crew.task.tokens_total","description":"Token usage per task","values":[]}]}
|
||||||
|
{"exportedAt":"2026-06-27T23:49:20.368Z","snapshots":[{"type":"counter","name":"crew.run.count","description":"Total runs by status","values":[]},{"type":"counter","name":"crew.task.count","description":"Total tasks by status","values":[]},{"type":"counter","name":"crew.subagent.count","description":"Total subagent records by status","values":[]},{"type":"counter","name":"crew.mailbox.count","description":"Total mailbox messages by direction","values":[]},{"type":"counter","name":"crew.task.retry_attempt_total","description":"Retry attempts by run and task","values":[]},{"type":"counter","name":"crew.task.deadletter_total","description":"Deadletter triggers by reason","values":[]},{"type":"counter","name":"crew.task.overflow_phase_total","description":"Overflow recovery phase transitions","values":[]},{"type":"counter","name":"crew.task.supervisor_contact_total","description":"Supervisor contact requests by reason","values":[]},{"type":"gauge","name":"crew.heartbeat.staleness_ms","description":"Heartbeat elapsed since last seen, milliseconds","values":[]},{"type":"histogram","name":"crew.run.duration_ms","description":"Run end-to-end duration, milliseconds","values":[]},{"type":"histogram","name":"crew.task.duration_ms","description":"Task duration, milliseconds","values":[]},{"type":"histogram","name":"crew.task.retry_count","description":"Retries per task","values":[]},{"type":"histogram","name":"crew.task.tokens_total","description":"Token usage per task","values":[]}]}
|
||||||
@@ -31,6 +31,7 @@ jobs:
|
|||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: go.mod
|
go-version-file: go.mod
|
||||||
|
check-latest: true
|
||||||
cache: true
|
cache: true
|
||||||
|
|
||||||
- name: Install govulncheck
|
- name: Install govulncheck
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"history": []
|
||||||
|
}
|
||||||
@@ -140,6 +140,7 @@ harness-sync goes out of its way to avoid.
|
|||||||
| **crush** | `~/.config/crush/crush.json` (merged) | `mcp` (`type: stdio`/`http`/`sse`) | `providers` map + `default_model` | `~/.config/crush/skills/` |
|
| **crush** | `~/.config/crush/crush.json` (merged) | `mcp` (`type: stdio`/`http`/`sse`) | `providers` map + `default_model` | `~/.config/crush/skills/` |
|
||||||
| **kilo** | `~/.config/kilo/kilo.json` (merged) | `mcp` (`type: local`/`remote`) | `provider` map + `model` + `small_model` | `~/.kilo/skills/` |
|
| **kilo** | `~/.config/kilo/kilo.json` (merged) | `mcp` (`type: local`/`remote`) | `provider` map + `model` + `small_model` | `~/.kilo/skills/` |
|
||||||
| **opencode** | `~/.config/opencode/opencode.jsonc` (merged) | `mcp` (`type: local`/`remote`) | `provider` map + `model` | `~/.config/opencode/skills/` |
|
| **opencode** | `~/.config/opencode/opencode.jsonc` (merged) | `mcp` (`type: local`/`remote`) | `provider` map + `model` | `~/.config/opencode/skills/` |
|
||||||
|
| **pi** | `~/.pi/agent/settings.json` (merged) + `~/.pi/agent/models.json` | — | `defaultProvider` + `defaultModel` + `models.json` provider | `~/.pi/agent/skills/` |
|
||||||
| **goose** | `~/.config/goose/config.yaml` (merged) + `custom_providers/<name>.json` | `extensions` map (`type: stdio`) | `GOOSE_PROVIDER` + `GOOSE_MODEL` | `~/.agents/skills/` |
|
| **goose** | `~/.config/goose/config.yaml` (merged) + `custom_providers/<name>.json` | `extensions` map (`type: stdio`) | `GOOSE_PROVIDER` + `GOOSE_MODEL` | `~/.agents/skills/` |
|
||||||
| **cagent** | `~/.config/cagent/default.yaml` (starter) | `mcps` | `providers` map + per-agent `model:` | — |
|
| **cagent** | `~/.config/cagent/default.yaml` (starter) | `mcps` | `providers` map + per-agent `model:` | — |
|
||||||
| **zed** | `~/.config/zed/settings.json` (merged) | `context_servers` | `language_models.openai.{api_url, available_models}` + `agent.default_model` | — |
|
| **zed** | `~/.config/zed/settings.json` (merged) | `context_servers` | `language_models.openai.{api_url, available_models}` + `agent.default_model` | — |
|
||||||
@@ -156,6 +157,7 @@ Skills paths are grounded in each harness's official documentation (kilo.ai, ope
|
|||||||
| **crush** | — | ✓ | ✓ | ✓ | ✓ | — | ✓ᶠ | ✓ᶠ |
|
| **crush** | — | ✓ | ✓ | ✓ | ✓ | — | ✓ᶠ | ✓ᶠ |
|
||||||
| **kilo** | — | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ᶠ | ✓ᶠ |
|
| **kilo** | — | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ᶠ | ✓ᶠ |
|
||||||
| **opencode** | — | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ᶠ | ✓ |
|
| **opencode** | — | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ᶠ | ✓ |
|
||||||
|
| **pi** | — | ✓ | ✓ | — | ✓ | — | ✓ᶠ | ✓ᶠ |
|
||||||
| **goose** | — | ✓ | ✓ | ✓ | ✓ | — | ✓ᶠ | ✓ᶠ |
|
| **goose** | — | ✓ | ✓ | ✓ | ✓ | — | ✓ᶠ | ✓ᶠ |
|
||||||
| **cagent** | — | ✓ | ✓ | ✓ | — | — | ✓ᶠ | ✓ |
|
| **cagent** | — | ✓ | ✓ | ✓ | — | — | ✓ᶠ | ✓ |
|
||||||
| **zed** | — | ✓ | ✓ | — | — | — | ✓ᶠ | ✓ᶠ |
|
| **zed** | — | ✓ | ✓ | — | — | — | ✓ᶠ | ✓ᶠ |
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/lukaszraczylo/harness-sync/internal/adapters/goose"
|
"github.com/lukaszraczylo/harness-sync/internal/adapters/goose"
|
||||||
"github.com/lukaszraczylo/harness-sync/internal/adapters/kilo"
|
"github.com/lukaszraczylo/harness-sync/internal/adapters/kilo"
|
||||||
"github.com/lukaszraczylo/harness-sync/internal/adapters/opencode"
|
"github.com/lukaszraczylo/harness-sync/internal/adapters/opencode"
|
||||||
|
"github.com/lukaszraczylo/harness-sync/internal/adapters/pi"
|
||||||
"github.com/lukaszraczylo/harness-sync/internal/adapters/zed"
|
"github.com/lukaszraczylo/harness-sync/internal/adapters/zed"
|
||||||
"github.com/lukaszraczylo/harness-sync/internal/cli"
|
"github.com/lukaszraczylo/harness-sync/internal/cli"
|
||||||
"github.com/lukaszraczylo/oss-telemetry"
|
"github.com/lukaszraczylo/oss-telemetry"
|
||||||
@@ -28,6 +29,7 @@ func main() {
|
|||||||
reg.Register(crush.New())
|
reg.Register(crush.New())
|
||||||
reg.Register(kilo.New())
|
reg.Register(kilo.New())
|
||||||
reg.Register(opencode.New())
|
reg.Register(opencode.New())
|
||||||
|
reg.Register(pi.New())
|
||||||
reg.Register(goose.New())
|
reg.Register(goose.New())
|
||||||
reg.Register(cagent.New())
|
reg.Register(cagent.New())
|
||||||
reg.Register(zed.New())
|
reg.Register(zed.New())
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
module github.com/lukaszraczylo/harness-sync
|
module github.com/lukaszraczylo/harness-sync
|
||||||
|
|
||||||
go 1.25.0
|
go 1.26.8
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/charmbracelet/huh v1.0.0
|
github.com/charmbracelet/huh v1.0.0
|
||||||
github.com/lukaszraczylo/oss-telemetry v0.2.3
|
github.com/lukaszraczylo/oss-telemetry v0.2.3
|
||||||
github.com/pelletier/go-toml/v2 v2.4.0
|
github.com/pelletier/go-toml/v2 v2.4.3
|
||||||
github.com/spf13/afero v1.15.0
|
github.com/spf13/afero v1.15.0
|
||||||
github.com/spf13/cobra v1.10.2
|
github.com/spf13/cobra v1.10.2
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
@@ -20,20 +20,20 @@ require (
|
|||||||
github.com/charmbracelet/bubbletea v1.3.10 // indirect
|
github.com/charmbracelet/bubbletea v1.3.10 // indirect
|
||||||
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
github.com/charmbracelet/colorprofile v0.4.3 // indirect
|
||||||
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
github.com/charmbracelet/lipgloss v1.1.0 // indirect
|
||||||
github.com/charmbracelet/x/ansi v0.11.7 // indirect
|
github.com/charmbracelet/x/ansi v0.11.8 // indirect
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
|
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
|
||||||
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
||||||
github.com/charmbracelet/x/term v0.2.2 // indirect
|
github.com/charmbracelet/x/term v0.2.2 // indirect
|
||||||
github.com/clipperhouse/displaywidth v0.11.0 // indirect
|
github.com/clipperhouse/displaywidth v0.11.0 // indirect
|
||||||
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
github.com/dustin/go-humanize v1.1.0 // indirect
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
|
github.com/lucasb-eyer/go-colorful v1.4.1 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.22 // indirect
|
github.com/mattn/go-isatty v0.0.24 // indirect
|
||||||
github.com/mattn/go-localereader v0.0.1 // indirect
|
github.com/mattn/go-localereader v0.0.1 // indirect
|
||||||
github.com/mattn/go-runewidth v0.0.24 // indirect
|
github.com/mattn/go-runewidth v0.0.30 // indirect
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
|
||||||
github.com/muesli/cancelreader v0.2.2 // indirect
|
github.com/muesli/cancelreader v0.2.2 // indirect
|
||||||
@@ -41,7 +41,7 @@ require (
|
|||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/spf13/pflag v1.0.10 // indirect
|
github.com/spf13/pflag v1.0.10 // indirect
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
github.com/xo/terminfo v1.2.0 // indirect
|
||||||
golang.org/x/sys v0.46.0 // indirect
|
golang.org/x/sys v0.48.0 // indirect
|
||||||
golang.org/x/text v0.38.0 // indirect
|
golang.org/x/text v0.42.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ github.com/charmbracelet/huh v1.0.0 h1:wOnedH8G4qzJbmhftTqrpppyqHakl/zbbNdXIWJyI
|
|||||||
github.com/charmbracelet/huh v1.0.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
|
github.com/charmbracelet/huh v1.0.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
|
||||||
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
|
||||||
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
|
||||||
github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI=
|
github.com/charmbracelet/x/ansi v0.11.8 h1:JMFwp0CgDC2+jcOB162HH5k7I3FVbgFSMMYg7dSPBQQ=
|
||||||
github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ=
|
github.com/charmbracelet/x/ansi v0.11.8/go.mod h1:ZNN+3mXny/516oTQPLMPIBeSINvNJJQ8uQXDgbeJxY0=
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
|
github.com/charmbracelet/x/cellbuf v0.0.15 h1:ur3pZy0o6z/R7EylET877CBxaiE1Sp1GMxoFPAIztPI=
|
||||||
github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
|
github.com/charmbracelet/x/cellbuf v0.0.15/go.mod h1:J1YVbR7MUuEGIFPCaaZ96KDl5NoS0DAWkskup+mOY+Q=
|
||||||
github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U=
|
github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U=
|
||||||
@@ -45,22 +45,22 @@ github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
|
|||||||
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
|
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
github.com/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
|
||||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
|
||||||
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
|
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4=
|
github.com/lucasb-eyer/go-colorful v1.4.1 h1:1EO+WB73+EH8EVbzlrG3KLAfEypQWVHIBqlTf+2hNss=
|
||||||
github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.4.1/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/lukaszraczylo/oss-telemetry v0.2.3 h1:xoDtBqeZGmXj7IteiE1M5WMuzeoqag58qEleI0Cf2Ms=
|
github.com/lukaszraczylo/oss-telemetry v0.2.3 h1:xoDtBqeZGmXj7IteiE1M5WMuzeoqag58qEleI0Cf2Ms=
|
||||||
github.com/lukaszraczylo/oss-telemetry v0.2.3/go.mod h1:+Cn78qZo8rc3T9eZt0v3oICYRdd75wORtSidc8lNjDQ=
|
github.com/lukaszraczylo/oss-telemetry v0.2.3/go.mod h1:+Cn78qZo8rc3T9eZt0v3oICYRdd75wORtSidc8lNjDQ=
|
||||||
github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4=
|
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||||
github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
|
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||||
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
|
||||||
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
|
||||||
github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU=
|
github.com/mattn/go-runewidth v0.0.30 h1:+KUuiDA4fF0R1p5FeueHefjDm+GIM+kWfFnDjybOPgk=
|
||||||
github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
github.com/mattn/go-runewidth v0.0.30/go.mod h1:3qAiGCV4Koz/yuveO58qUefmUTRm8r0IGEXZ9jeHp/8=
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
|
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
|
||||||
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
|
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
|
||||||
@@ -69,8 +69,8 @@ github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELU
|
|||||||
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
|
||||||
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
|
||||||
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
|
||||||
github.com/pelletier/go-toml/v2 v2.4.0 h1:Mwu0mAkUKbittDs3/ADDWXqMmq3EOK2VHiuCkV00Row=
|
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
|
||||||
github.com/pelletier/go-toml/v2 v2.4.0/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
@@ -85,16 +85,14 @@ github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
|
|||||||
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
|
github.com/xo/terminfo v1.2.0 h1:d0ZTOCpuGE0lwSAOs0zcJjwz3jWQyqcRt9XbGJpCOl4=
|
||||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
|
github.com/xo/terminfo v1.2.0/go.mod h1:lGzkSo8Fe7IRh/w+Gqz7n5mDog4FVXCj3gy/DYTBqio=
|
||||||
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
|
||||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
|
|
||||||
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
|
|
||||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
|
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||||
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||||
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
|
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||||
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
|
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
|||||||
@@ -31,16 +31,16 @@ func GatewayProviderKey(gatewayURL string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// crushModel builds a 10-field model entry required by the crush schema.
|
// crushModel builds a 10-field model entry required by the crush schema.
|
||||||
func crushModel(id string) map[string]any {
|
func crushModel(m canonical.Model) map[string]any {
|
||||||
return map[string]any{
|
return map[string]any{
|
||||||
"id": id,
|
"id": m.ID,
|
||||||
"name": id,
|
"name": m.ID,
|
||||||
"cost_per_1m_in": 0,
|
"cost_per_1m_in": 0,
|
||||||
"cost_per_1m_out": 0,
|
"cost_per_1m_out": 0,
|
||||||
"cost_per_1m_in_cached": 0,
|
"cost_per_1m_in_cached": 0,
|
||||||
"cost_per_1m_out_cached": 0,
|
"cost_per_1m_out_cached": 0,
|
||||||
"context_window": 200000,
|
"context_window": m.ContextLimit(),
|
||||||
"default_max_tokens": 8192,
|
"default_max_tokens": m.OutputLimit(),
|
||||||
"can_reason": false,
|
"can_reason": false,
|
||||||
"supports_attachments": true,
|
"supports_attachments": true,
|
||||||
}
|
}
|
||||||
@@ -56,10 +56,10 @@ func ProvidersAsCrushMap(p *canonical.Profile) map[string]any {
|
|||||||
}
|
}
|
||||||
models := make([]map[string]any, 0)
|
models := make([]map[string]any, 0)
|
||||||
for _, m := range p.Models {
|
for _, m := range p.Models {
|
||||||
models = append(models, crushModel(m.ID))
|
models = append(models, crushModel(m))
|
||||||
}
|
}
|
||||||
if len(models) == 0 && p.Gateway.DefaultModel != "" {
|
if len(models) == 0 && p.Gateway.DefaultModel != "" {
|
||||||
models = append(models, crushModel(p.Gateway.DefaultModel))
|
models = append(models, crushModel(canonical.Model{ID: p.Gateway.DefaultModel}))
|
||||||
}
|
}
|
||||||
out[GatewayProviderKey(p.Gateway.URL)] = map[string]any{
|
out[GatewayProviderKey(p.Gateway.URL)] = map[string]any{
|
||||||
"type": "openai-compat",
|
"type": "openai-compat",
|
||||||
@@ -101,7 +101,7 @@ func ProvidersAsMap(p *canonical.Profile) map[string]any {
|
|||||||
}
|
}
|
||||||
models[m.ID] = map[string]any{
|
models[m.ID] = map[string]any{
|
||||||
"name": displayName,
|
"name": displayName,
|
||||||
"limit": map[string]any{"context": 200000, "output": 8192},
|
"limit": map[string]any{"context": m.ContextLimit(), "output": m.OutputLimit()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entry := map[string]any{
|
entry := map[string]any{
|
||||||
@@ -172,7 +172,7 @@ func GooseCustomProviderFile(p *canonical.Profile) ([]byte, string) {
|
|||||||
for _, m := range p.Models {
|
for _, m := range p.Models {
|
||||||
models = append(models, map[string]any{
|
models = append(models, map[string]any{
|
||||||
"name": m.ID,
|
"name": m.ID,
|
||||||
"context_limit": 200000,
|
"context_limit": m.ContextLimit(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if len(models) == 0 && p.Gateway.DefaultModel != "" {
|
if len(models) == 0 && p.Gateway.DefaultModel != "" {
|
||||||
@@ -183,7 +183,7 @@ func GooseCustomProviderFile(p *canonical.Profile) ([]byte, string) {
|
|||||||
}
|
}
|
||||||
models = append(models, map[string]any{
|
models = append(models, map[string]any{
|
||||||
"name": modelID,
|
"name": modelID,
|
||||||
"context_limit": 200000,
|
"context_limit": canonical.DefaultContextLimit,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
@@ -64,3 +65,52 @@ func TestParseMCPFromJSONMissingKey(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
assert.Nil(t, servers)
|
assert.Nil(t, servers)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestProvidersAsMapHonorsPerModelLimits(t *testing.T) {
|
||||||
|
p := &canonical.Profile{
|
||||||
|
Gateway: canonical.Gateway{URL: "https://gw.example.com/v1", Token: "t"},
|
||||||
|
Models: []canonical.Model{
|
||||||
|
{ID: "prov/big", Context: 262144, Output: 65536},
|
||||||
|
{ID: "prov/default"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
models := ProvidersAsMap(p)[GatewayProviderKey(p.Gateway.URL)].(map[string]any)["models"].(map[string]any)
|
||||||
|
|
||||||
|
big := models["prov/big"].(map[string]any)["limit"].(map[string]any)
|
||||||
|
assert.Equal(t, 262144, big["context"], "explicit context override should win")
|
||||||
|
assert.Equal(t, 65536, big["output"], "explicit output override should win")
|
||||||
|
|
||||||
|
def := models["prov/default"].(map[string]any)["limit"].(map[string]any)
|
||||||
|
assert.Equal(t, 200000, def["context"], "unset model falls back to default context")
|
||||||
|
assert.Equal(t, 8192, def["output"], "unset model falls back to default output")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestProvidersAsCrushMapHonorsPerModelLimits(t *testing.T) {
|
||||||
|
p := &canonical.Profile{
|
||||||
|
Gateway: canonical.Gateway{URL: "https://gw.example.com/v1", Token: "t"},
|
||||||
|
Models: []canonical.Model{
|
||||||
|
{ID: "prov/big", Context: 262144, Output: 65536},
|
||||||
|
{ID: "prov/default"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
models := ProvidersAsCrushMap(p)[GatewayProviderKey(p.Gateway.URL)].(map[string]any)["models"].([]map[string]any)
|
||||||
|
|
||||||
|
assert.Equal(t, 262144, models[0]["context_window"], "explicit context override should win")
|
||||||
|
assert.Equal(t, 65536, models[0]["default_max_tokens"], "explicit output override should win")
|
||||||
|
assert.Equal(t, 200000, models[1]["context_window"], "unset model falls back to default context")
|
||||||
|
assert.Equal(t, 8192, models[1]["default_max_tokens"], "unset model falls back to default output")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGooseCustomProviderFileHonorsPerModelContext(t *testing.T) {
|
||||||
|
p := &canonical.Profile{
|
||||||
|
Gateway: canonical.Gateway{URL: "https://gw.example.com/v1", Token: "t"},
|
||||||
|
Models: []canonical.Model{{ID: "big", Context: 262144}, {ID: "default"}},
|
||||||
|
}
|
||||||
|
body, _ := GooseCustomProviderFile(p)
|
||||||
|
var entry map[string]any
|
||||||
|
require.NoError(t, json.Unmarshal(body, &entry))
|
||||||
|
models := entry["models"].([]any)
|
||||||
|
|
||||||
|
assert.Equal(t, float64(262144), models[0].(map[string]any)["context_limit"], "explicit context override should win")
|
||||||
|
assert.Equal(t, float64(200000), models[1].(map[string]any)["context_limit"], "unset model falls back to default context")
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package pi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/lukaszraczylo/harness-sync/internal/adapter"
|
||||||
|
)
|
||||||
|
|
||||||
|
func importFrom(home string) (*adapter.ImportResult, error) {
|
||||||
|
base := filepath.Join(home, ".pi", "agent")
|
||||||
|
res := &adapter.ImportResult{}
|
||||||
|
|
||||||
|
if body, err := os.ReadFile(filepath.Join(base, "AGENTS.md")); err == nil {
|
||||||
|
res.Instructions = string(body)
|
||||||
|
} else if !os.IsNotExist(err) {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
// Package pi is the Pi coding agent harness adapter.
|
||||||
|
package pi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/lukaszraczylo/harness-sync/internal/adapter"
|
||||||
|
"github.com/lukaszraczylo/harness-sync/internal/adapter/common"
|
||||||
|
"github.com/lukaszraczylo/harness-sync/internal/canonical"
|
||||||
|
)
|
||||||
|
|
||||||
|
const name = "pi"
|
||||||
|
|
||||||
|
// Adapter implements adapter.Adapter for the Pi coding agent harness.
|
||||||
|
type Adapter struct {
|
||||||
|
*adapter.Base
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithHome overrides the home directory used to resolve target paths.
|
||||||
|
func WithHome(h string) adapter.BaseOption { return func(b *adapter.Base) { b.Home = h } }
|
||||||
|
|
||||||
|
// New returns a new Adapter with the given options applied.
|
||||||
|
func New(opts ...adapter.BaseOption) *Adapter {
|
||||||
|
return &Adapter{Base: adapter.NewBase(opts...)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Name returns the harness identifier.
|
||||||
|
func (a *Adapter) Name() string { return name }
|
||||||
|
|
||||||
|
// Capabilities declares what pi harness-sync manages.
|
||||||
|
func (a *Adapter) Capabilities() adapter.HarnessCapabilities {
|
||||||
|
return adapter.HarnessCapabilities{
|
||||||
|
ManagesProviders: true,
|
||||||
|
ManagesModels: true,
|
||||||
|
ManagesMCP: false,
|
||||||
|
ManagesSkills: true,
|
||||||
|
ManagesAgents: false,
|
||||||
|
ManagesRules: true,
|
||||||
|
ManagesInstructions: true,
|
||||||
|
HasBuiltInSub: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Detect returns true when ~/.pi/agent exists.
|
||||||
|
func (a *Adapter) Detect() bool {
|
||||||
|
_, err := os.Stat(filepath.Join(a.Home, ".pi", "agent"))
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Render produces the FileSet that applies the canonical bundle to Pi.
|
||||||
|
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||||
|
fs := adapter.NewFileSet()
|
||||||
|
base := filepath.Join(a.Home, ".pi", "agent")
|
||||||
|
|
||||||
|
fs.Add(adapter.File{
|
||||||
|
Dest: filepath.Join(base, "skills"),
|
||||||
|
Kind: adapter.SymlinkDir,
|
||||||
|
SymlinkTarget: filepath.Join(b.Root, "skills"),
|
||||||
|
})
|
||||||
|
|
||||||
|
if instr := b.InstructionTextWithRules(name); instr != "" {
|
||||||
|
fs.Add(adapter.File{
|
||||||
|
Dest: filepath.Join(base, "AGENTS.md"),
|
||||||
|
Kind: adapter.RenderedFile,
|
||||||
|
Content: []byte(instr),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
cfgPath := filepath.Join(base, "settings.json")
|
||||||
|
existing, err := common.ReadExistingFile(cfgPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("read %s: %w", cfgPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
overlay := map[string]any{}
|
||||||
|
if b.Profile.Gateway.DefaultModel != "" {
|
||||||
|
overlay["defaultProvider"] = common.GatewayProviderKey(b.Profile.Gateway.URL)
|
||||||
|
overlay["defaultModel"] = b.Profile.Gateway.DefaultModel
|
||||||
|
}
|
||||||
|
if len(overlay) > 0 {
|
||||||
|
merged, err := common.MergeJSONKeys(existing, overlay)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
fs.Add(adapter.File{
|
||||||
|
Dest: cfgPath,
|
||||||
|
Kind: adapter.RenderedFile,
|
||||||
|
Content: merged,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if modelsContent, err := piModelsJSON(b); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else if len(modelsContent) > 0 {
|
||||||
|
fs.Add(adapter.File{
|
||||||
|
Dest: filepath.Join(base, "models.json"),
|
||||||
|
Kind: adapter.RenderedFile,
|
||||||
|
Content: modelsContent,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return fs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func piModelsJSON(b *canonical.Bundle) ([]byte, error) {
|
||||||
|
if b.Profile.Gateway.URL == "" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
modelEntries := make([]map[string]any, 0, len(b.Profile.Models))
|
||||||
|
for _, m := range b.Profile.Models {
|
||||||
|
entry := map[string]any{"id": m.ID}
|
||||||
|
if m.Alias != "" {
|
||||||
|
entry["name"] = m.Alias
|
||||||
|
}
|
||||||
|
// Emit limits only when the profile sets them explicitly. Pi applies
|
||||||
|
// its own defaults (contextWindow 128000, maxTokens 16384) to a model
|
||||||
|
// definition that omits them, so writing ContextLimit()/OutputLimit()
|
||||||
|
// unconditionally would push canonical's defaults onto every model
|
||||||
|
// that never asked for them.
|
||||||
|
if m.Context > 0 {
|
||||||
|
entry["contextWindow"] = m.Context
|
||||||
|
}
|
||||||
|
if m.Output > 0 {
|
||||||
|
entry["maxTokens"] = m.Output
|
||||||
|
}
|
||||||
|
modelEntries = append(modelEntries, entry)
|
||||||
|
}
|
||||||
|
if len(modelEntries) == 0 && b.Profile.Gateway.DefaultModel != "" {
|
||||||
|
modelEntries = append(modelEntries, map[string]any{"id": b.Profile.Gateway.DefaultModel})
|
||||||
|
}
|
||||||
|
|
||||||
|
provider := map[string]any{
|
||||||
|
"baseUrl": b.Profile.Gateway.URL,
|
||||||
|
"api": "openai-completions",
|
||||||
|
"apiKey": b.Profile.Gateway.Token,
|
||||||
|
}
|
||||||
|
if len(modelEntries) > 0 {
|
||||||
|
provider["models"] = modelEntries
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := json.MarshalIndent(map[string]any{
|
||||||
|
"providers": map[string]any{
|
||||||
|
common.GatewayProviderKey(b.Profile.Gateway.URL): provider,
|
||||||
|
},
|
||||||
|
}, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return append(body, '\n'), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Import reads Pi config from home and returns a canonical ImportResult.
|
||||||
|
func (a *Adapter) Import(home string) (*adapter.ImportResult, error) {
|
||||||
|
return importFrom(home)
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
package pi
|
||||||
|
|
||||||
|
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 TestPiRender(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 })
|
||||||
|
|
||||||
|
skillsDest := filepath.Join(home, ".pi", "agent", "skills")
|
||||||
|
assert.Equal(t, adapter.SymlinkDir, seen[skillsDest].Kind)
|
||||||
|
assert.Equal(t, "/canon/skills", seen[skillsDest].SymlinkTarget)
|
||||||
|
|
||||||
|
agentsDest := filepath.Join(home, ".pi", "agent", "AGENTS.md")
|
||||||
|
assert.Equal(t, adapter.RenderedFile, seen[agentsDest].Kind)
|
||||||
|
assert.Contains(t, string(seen[agentsDest].Content), "# global")
|
||||||
|
|
||||||
|
settingsDest := filepath.Join(home, ".pi", "agent", "settings.json")
|
||||||
|
var settings map[string]any
|
||||||
|
require.NoError(t, json.Unmarshal(seen[settingsDest].Content, &settings))
|
||||||
|
assert.Equal(t, "hs-gw", settings["defaultProvider"])
|
||||||
|
assert.Equal(t, "sonnet", settings["defaultModel"])
|
||||||
|
|
||||||
|
modelsDest := filepath.Join(home, ".pi", "agent", "models.json")
|
||||||
|
var models map[string]any
|
||||||
|
require.NoError(t, json.Unmarshal(seen[modelsDest].Content, &models))
|
||||||
|
providers := models["providers"].(map[string]any)
|
||||||
|
gw := providers["hs-gw"].(map[string]any)
|
||||||
|
assert.Equal(t, "https://gw", gw["baseUrl"])
|
||||||
|
assert.Equal(t, "openai-completions", gw["api"])
|
||||||
|
assert.Equal(t, "dummy", gw["apiKey"])
|
||||||
|
modelList := gw["models"].([]any)
|
||||||
|
first := modelList[0].(map[string]any)
|
||||||
|
assert.Equal(t, "claude-sonnet-4-6", first["id"])
|
||||||
|
assert.Equal(t, "Sonnet", first["name"])
|
||||||
|
// A model with no explicit limits must carry none, so pi keeps applying
|
||||||
|
// its own defaults rather than inheriting canonical's.
|
||||||
|
assert.NotContains(t, first, "contextWindow")
|
||||||
|
assert.NotContains(t, first, "maxTokens")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPiRenderEmitsExplicitModelLimits(t *testing.T) {
|
||||||
|
home := t.TempDir()
|
||||||
|
ad := New(WithHome(home))
|
||||||
|
b := &canonical.Bundle{
|
||||||
|
Profile: canonical.Profile{
|
||||||
|
Gateway: canonical.Gateway{URL: "https://gw", Token: "dummy"},
|
||||||
|
Models: []canonical.Model{
|
||||||
|
{ID: "local/current-model", Alias: "Local", Context: 1048576, Output: 32768},
|
||||||
|
{ID: "bare/model"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
fs, err := ad.Render(b)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
seen := map[string]adapter.File{}
|
||||||
|
fs.ForEach(func(f adapter.File) { seen[f.Dest] = f })
|
||||||
|
|
||||||
|
var models map[string]any
|
||||||
|
require.NoError(t, json.Unmarshal(seen[filepath.Join(home, ".pi", "agent", "models.json")].Content, &models))
|
||||||
|
list := models["providers"].(map[string]any)["hs-gw"].(map[string]any)["models"].([]any)
|
||||||
|
|
||||||
|
withLimits := list[0].(map[string]any)
|
||||||
|
assert.InDelta(t, float64(1048576), withLimits["contextWindow"], 0)
|
||||||
|
assert.InDelta(t, float64(32768), withLimits["maxTokens"], 0)
|
||||||
|
|
||||||
|
withoutLimits := list[1].(map[string]any)
|
||||||
|
assert.NotContains(t, withoutLimits, "contextWindow")
|
||||||
|
assert.NotContains(t, withoutLimits, "maxTokens")
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPiRenderMergesExistingSettings(t *testing.T) {
|
||||||
|
home := t.TempDir()
|
||||||
|
base := filepath.Join(home, ".pi", "agent")
|
||||||
|
require.NoError(t, os.MkdirAll(base, 0o750))
|
||||||
|
|
||||||
|
existing := map[string]any{
|
||||||
|
"theme": "light",
|
||||||
|
"defaultThinkingLevel": "high",
|
||||||
|
}
|
||||||
|
body, _ := json.Marshal(existing)
|
||||||
|
require.NoError(t, os.WriteFile(filepath.Join(base, "settings.json"), body, 0o600))
|
||||||
|
|
||||||
|
ad := New(WithHome(home))
|
||||||
|
b := &canonical.Bundle{Profile: canonical.Profile{Gateway: canonical.Gateway{URL: "https://gw", 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 })
|
||||||
|
|
||||||
|
var parsed map[string]any
|
||||||
|
require.NoError(t, json.Unmarshal(seen[filepath.Join(base, "settings.json")].Content, &parsed))
|
||||||
|
assert.Equal(t, "light", parsed["theme"])
|
||||||
|
assert.Equal(t, "high", parsed["defaultThinkingLevel"])
|
||||||
|
assert.Equal(t, "hs-gw", parsed["defaultProvider"])
|
||||||
|
assert.Equal(t, "sonnet", parsed["defaultModel"])
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPiRenderWithoutGatewaySkipsProviderFiles(t *testing.T) {
|
||||||
|
home := t.TempDir()
|
||||||
|
ad := New(WithHome(home))
|
||||||
|
b := &canonical.Bundle{Root: "/canon"}
|
||||||
|
fs, err := ad.Render(b)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
seen := map[string]adapter.File{}
|
||||||
|
fs.ForEach(func(f adapter.File) { seen[f.Dest] = f })
|
||||||
|
|
||||||
|
assert.Contains(t, seen, filepath.Join(home, ".pi", "agent", "skills"))
|
||||||
|
assert.NotContains(t, seen, filepath.Join(home, ".pi", "agent", "settings.json"))
|
||||||
|
assert.NotContains(t, seen, filepath.Join(home, ".pi", "agent", "models.json"))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPiImport(t *testing.T) {
|
||||||
|
home := t.TempDir()
|
||||||
|
base := filepath.Join(home, ".pi", "agent")
|
||||||
|
require.NoError(t, os.MkdirAll(base, 0o750))
|
||||||
|
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)
|
||||||
|
}
|
||||||
@@ -122,7 +122,7 @@ func zedLanguageModels(p *canonical.Profile) map[string]any {
|
|||||||
for _, m := range p.Models {
|
for _, m := range p.Models {
|
||||||
me := map[string]any{
|
me := map[string]any{
|
||||||
"name": m.ID,
|
"name": m.ID,
|
||||||
"max_tokens": 200000,
|
"max_tokens": m.ContextLimit(),
|
||||||
"capabilities": map[string]any{
|
"capabilities": map[string]any{
|
||||||
"tools": true,
|
"tools": true,
|
||||||
"images": false,
|
"images": false,
|
||||||
|
|||||||
@@ -63,6 +63,25 @@ func TestZedRenderProducesExpectedTargets(t *testing.T) {
|
|||||||
assert.NotContains(t, parsed, "context_servers")
|
assert.NotContains(t, parsed, "context_servers")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestZedRenderHonorsPerModelContext(t *testing.T) {
|
||||||
|
home := t.TempDir()
|
||||||
|
b := bundle()
|
||||||
|
b.Profile.Models = []canonical.Model{{ID: "big", Context: 262144}}
|
||||||
|
|
||||||
|
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 })
|
||||||
|
cfgDest := filepath.Join(home, ".config", "zed", "settings.json")
|
||||||
|
require.Contains(t, seen, cfgDest)
|
||||||
|
|
||||||
|
var parsed map[string]any
|
||||||
|
require.NoError(t, json.Unmarshal(seen[cfgDest].Content, &parsed))
|
||||||
|
models := parsed["language_models"].(map[string]any)["openai_compatible"].(map[string]any)["hs-llmgw-example-com"].(map[string]any)["available_models"].([]any)
|
||||||
|
assert.Equal(t, float64(262144), models[0].(map[string]any)["max_tokens"], "explicit context override should win")
|
||||||
|
}
|
||||||
|
|
||||||
func TestZedRenderMergesExistingKeys(t *testing.T) {
|
func TestZedRenderMergesExistingKeys(t *testing.T) {
|
||||||
home := t.TempDir()
|
home := t.TempDir()
|
||||||
base := filepath.Join(home, ".config", "zed")
|
base := filepath.Join(home, ".config", "zed")
|
||||||
|
|||||||
@@ -35,6 +35,33 @@ type Upstream struct {
|
|||||||
type Model struct {
|
type Model struct {
|
||||||
ID string `yaml:"id"`
|
ID string `yaml:"id"`
|
||||||
Alias string `yaml:"alias,omitempty"`
|
Alias string `yaml:"alias,omitempty"`
|
||||||
|
// Context and Output are optional per-model limit overrides (tokens). When
|
||||||
|
// unset (0), harnesses fall back to DefaultContextLimit / DefaultOutputLimit.
|
||||||
|
Context int `yaml:"context,omitempty"`
|
||||||
|
Output int `yaml:"output,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default per-model limits, applied by harnesses that surface context/output
|
||||||
|
// limits when a Model doesn't specify its own.
|
||||||
|
const (
|
||||||
|
DefaultContextLimit = 200000
|
||||||
|
DefaultOutputLimit = 8192
|
||||||
|
)
|
||||||
|
|
||||||
|
// ContextLimit returns the model's context window, or DefaultContextLimit if unset.
|
||||||
|
func (m Model) ContextLimit() int {
|
||||||
|
if m.Context > 0 {
|
||||||
|
return m.Context
|
||||||
|
}
|
||||||
|
return DefaultContextLimit
|
||||||
|
}
|
||||||
|
|
||||||
|
// OutputLimit returns the model's max output tokens, or DefaultOutputLimit if unset.
|
||||||
|
func (m Model) OutputLimit() int {
|
||||||
|
if m.Output > 0 {
|
||||||
|
return m.Output
|
||||||
|
}
|
||||||
|
return DefaultOutputLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
type MCPRegistry struct {
|
type MCPRegistry struct {
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ func TestDetectListsAllAdapters(t *testing.T) {
|
|||||||
|
|
||||||
// None should be detected in an empty HOME
|
// None should be detected in an empty HOME
|
||||||
s := string(out)
|
s := string(out)
|
||||||
for _, name := range []string{"claude-code", "crush", "kilo", "opencode", "goose", "cagent", "zed"} {
|
for _, name := range []string{"claude-code", "crush", "kilo", "opencode", "pi", "goose", "cagent", "zed"} {
|
||||||
assert.Contains(t, s, name)
|
assert.Contains(t, s, name)
|
||||||
}
|
}
|
||||||
assert.Contains(t, s, "not detected")
|
assert.Contains(t, s, "not detected")
|
||||||
|
|||||||
Reference in New Issue
Block a user