Compare commits

...
22 Commits
Author SHA1 Message Date
lukaszraczylo 5f1d9c1b72 fix(deps): migrate huh to charm.land/huh/v2
The module path moved to charm.land/huh/v2. Update the import in the ui
prompts and refresh go.mod and go.sum. No API changes were needed.
2026-10-04 10:12:32 +01:00
github-actions[bot]andGitHub 89c9b60dac chore(deps): update module github.com/stretchr/testify to v1.12.1
Automated dependency update. All tests passed.
2026-10-04 04:21:05 +00:00
lukaszraczylo 9ae011ac62 ci(deps): update dependencies with Renovate [skip ci] 2026-10-03 18:44:37 +01:00
lukaszraczyloandGitHub 18919ca926 Update go.mod and go.sum (#29) 2026-10-03 04:27:45 +01:00
lukaszraczylo 12e448ca39 fix(deps): require Go 1.26.8
Go 1.26.0 carries 17 standard library vulnerabilities that govulncheck reports. The security workflow takes its toolchain from go.mod, so the scan failed. Go 1.26.8 clears them.
2026-10-02 16:18:05 +01:00
lukaszraczylo 0865c405fb feat(pi): emit model context and output limits when set
The pi adapter writes contextWindow and maxTokens to models.json only
when the profile sets them. Pi keeps its own defaults for every other
model. Tests cover both cases.
2026-10-02 05:11:46 +01:00
lukaszraczylo b6bd5303e0 ci(security): resolve latest Go patch in govulncheck job
The govulncheck job fails on 17 standard library findings. The runner
uses an outdated Go toolchain. Set check-latest so setup-go installs
the newest patch release.
2026-10-02 05:10:31 +01:00
lukaszraczyloandGitHub f81492eb46 Update go.mod and go.sum (#28) 2026-09-19 04:18:26 +01:00
lukaszraczyloandGitHub 76ac377b5d Update go.mod and go.sum (#27) 2026-09-14 04:22:09 +01:00
lukaszraczyloandGitHub 2e661fb526 Update go.mod and go.sum (#26) 2026-09-11 04:19:54 +01:00
lukaszraczyloandGitHub c4f1b0fa1d Update go.mod and go.sum (#25) 2026-09-09 04:19:47 +01:00
lukaszraczyloandGitHub bf7be9d9c5 Update go.mod and go.sum (#24) 2026-09-02 04:19:26 +01:00
lukaszraczyloandGitHub c5707acfd3 Update go.mod and go.sum (#23) 2026-08-18 04:20:33 +01:00
lukaszraczyloandGitHub 3e3c78725e Update go.mod and go.sum (#22) 2026-08-12 04:47:48 +01:00
lukaszraczyloandGitHub 82e1de9773 Update go.mod and go.sum (#21) 2026-08-11 04:36:13 +01:00
lukaszraczyloandGitHub 565d72768b Update go.mod and go.sum (#20) 2026-08-03 07:28:07 +01:00
lukaszraczyloandGitHub 4701b45a12 Update go.mod and go.sum (#19) 2026-07-24 06:53:40 +01:00
lukaszraczyloandGitHub 8e3ec78e2b Update go.mod and go.sum (#18) 2026-07-23 07:05:08 +01:00
lukaszraczylo 62debbfcda fixup! Add pi support 2026-07-22 11:00:04 +01:00
lukaszraczylo b5e3bcd301 Add pi support 2026-06-28 00:51:34 +01:00
lukaszraczyloandGitHub fd6519eed1 Update go.mod and go.sum (#13) 2026-06-24 05:30:56 +01:00
lukaszraczyloandGitHub bca4a4be1a Update go.mod and go.sum (#12) 2026-06-23 05:28:57 +01:00
19 changed files with 525 additions and 101 deletions
+2
View File
@@ -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: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"}
+3
View File
@@ -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":[]}]}
+7 -7
View File
@@ -1,4 +1,4 @@
name: Autoupdate go.mod and go.sum
name: Update dependencies
on:
workflow_dispatch:
@@ -6,15 +6,15 @@ on:
- cron: "0 3 * * *"
permissions:
contents: write
actions: write
contents: write
issues: write
pull-requests: write
security-events: write
jobs:
autoupdate:
uses: lukaszraczylo/shared-actions/.github/workflows/go-autoupdate.yaml@main
update:
uses: lukaszraczylo/shared-actions/.github/workflows/renovate-autoupdate.yaml@main
with:
go-version: ">=1.25"
release-workflow: "release.yaml"
secrets: inherit
node: false
release-workflow: release.yaml
+1
View File
@@ -31,6 +31,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
cache: true
- name: Install govulncheck
+3
View File
@@ -0,0 +1,3 @@
{
"history": []
}
+2
View File
@@ -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/` |
| **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/` |
| **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/` |
| **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` | — |
@@ -156,6 +157,7 @@ Skills paths are grounded in each harness's official documentation (kilo.ai, ope
| **crush** | — | ✓ | ✓ | ✓ | ✓ | — | ✓ᶠ | ✓ᶠ |
| **kilo** | — | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ᶠ | ✓ᶠ |
| **opencode** | — | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ᶠ | ✓ |
| **pi** | — | ✓ | ✓ | — | ✓ | — | ✓ᶠ | ✓ᶠ |
| **goose** | — | ✓ | ✓ | ✓ | ✓ | — | ✓ᶠ | ✓ᶠ |
| **cagent** | — | ✓ | ✓ | ✓ | — | — | ✓ᶠ | ✓ |
| **zed** | — | ✓ | ✓ | — | — | — | ✓ᶠ | ✓ᶠ |
+2
View File
@@ -12,6 +12,7 @@ import (
"github.com/lukaszraczylo/harness-sync/internal/adapters/goose"
"github.com/lukaszraczylo/harness-sync/internal/adapters/kilo"
"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/cli"
"github.com/lukaszraczylo/oss-telemetry"
@@ -28,6 +29,7 @@ func main() {
reg.Register(crush.New())
reg.Register(kilo.New())
reg.Register(opencode.New())
reg.Register(pi.New())
reg.Register(goose.New())
reg.Register(cagent.New())
reg.Register(zed.New())
+21 -24
View File
@@ -1,47 +1,44 @@
module github.com/lukaszraczylo/harness-sync
go 1.25.0
go 1.26.8
require (
github.com/charmbracelet/huh v1.0.0
github.com/lukaszraczylo/oss-telemetry v0.2.3
github.com/pelletier/go-toml/v2 v2.4.0
charm.land/huh/v2 v2.0.3
github.com/lukaszraczylo/oss-telemetry v0.2.5
github.com/pelletier/go-toml/v2 v2.4.3
github.com/spf13/afero v1.15.0
github.com/spf13/cobra v1.10.2
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.12.1
gopkg.in/yaml.v3 v3.0.1
)
require (
charm.land/bubbles/v2 v2.0.0 // indirect
charm.land/bubbletea/v2 v2.0.2 // indirect
charm.land/lipgloss/v2 v2.0.1 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/catppuccin/go v0.3.0 // indirect
github.com/charmbracelet/bubbles v1.0.0 // indirect
github.com/charmbracelet/bubbletea v1.3.10 // indirect
github.com/charmbracelet/colorprofile v0.4.3 // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/x/ansi v0.11.7 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8 // indirect
github.com/charmbracelet/x/ansi v0.11.8 // indirect
github.com/charmbracelet/x/exp/ordered 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/termios v0.1.1 // indirect
github.com/charmbracelet/x/windows v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.11.0 // indirect
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/dustin/go-humanize v1.1.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.22 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.24 // indirect
github.com/lucasb-eyer/go-colorful v1.4.1 // indirect
github.com/mattn/go-runewidth v0.0.30 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sys v0.46.0 // indirect
golang.org/x/text v0.38.0 // indirect
github.com/xo/terminfo v1.2.0 // indirect
go.yaml.in/yaml/v3 v3.0.5 // indirect
golang.org/x/sync v0.23.0 // indirect
golang.org/x/sys v0.48.0 // indirect
golang.org/x/text v0.42.0 // indirect
)
+46 -57
View File
@@ -1,41 +1,43 @@
charm.land/bubbles/v2 v2.0.0 h1:tE3eK/pHjmtrDiRdoC9uGNLgpopOd8fjhEe31B/ai5s=
charm.land/bubbles/v2 v2.0.0/go.mod h1:rCHoleP2XhU8um45NTuOWBPNVHxnkXKTiZqcclL/qOI=
charm.land/bubbletea/v2 v2.0.2 h1:4CRtRnuZOdFDTWSff9r8QFt/9+z6Emubz3aDMnf/dx0=
charm.land/bubbletea/v2 v2.0.2/go.mod h1:3LRff2U4WIYXy7MTxfbAQ+AdfM3D8Xuvz2wbsOD9OHQ=
charm.land/huh/v2 v2.0.3 h1:2cJsMqEPwSywGHvdlKsJyQKPtSJLVnFKyFbsYZTlLkU=
charm.land/huh/v2 v2.0.3/go.mod h1:93eEveeeqn47MwiC3tf+2atZ2l7Is88rAtmZNZ8x9Wc=
charm.land/lipgloss/v2 v2.0.1 h1:6Xzrn49+Py1Um5q/wZG1gWgER2+7dUyZ9XMEufqPSys=
charm.land/lipgloss/v2 v2.0.1/go.mod h1:KjPle2Qd3YmvP1KL5OMHiHysGcNwq6u83MUjYkFvEkM=
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY=
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
github.com/aymanbagabas/go-udiff v0.4.1 h1:OEIrQ8maEeDBXQDoGCbbTTXYJMYRCRO1fnodZ12Gv5o=
github.com/aymanbagabas/go-udiff v0.4.1/go.mod h1:0L9PGwj20lrtmEMeyw4WKJ/TMyDtvAoK9bf2u/mNo3w=
github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY=
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
github.com/charmbracelet/bubbles v1.0.0 h1:12J8/ak/uCZEMQ6KU7pcfwceyjLlWsDLAxB5fXonfvc=
github.com/charmbracelet/bubbles v1.0.0/go.mod h1:9d/Zd5GdnauMI5ivUIVisuEm3ave1XwXtD1ckyV6r3E=
github.com/charmbracelet/bubbletea v1.3.10 h1:otUDHWMMzQSB0Pkc87rm691KZ3SWa4KUlvF9nRvCICw=
github.com/charmbracelet/bubbletea v1.3.10/go.mod h1:ORQfo0fk8U+po9VaNvnV95UPWA1BitP1E0N6xJPlHr4=
github.com/charmbracelet/colorprofile v0.4.3 h1:QPa1IWkYI+AOB+fE+mg/5/4HRMZcaXex9t5KX76i20Q=
github.com/charmbracelet/colorprofile v0.4.3/go.mod h1:/zT4BhpD5aGFpqQQqw7a+VtHCzu+zrQtt1zhMt9mR4Q=
github.com/charmbracelet/huh v1.0.0 h1:wOnedH8G4qzJbmhftTqrpppyqHakl/zbbNdXIWJyIxw=
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/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
github.com/charmbracelet/x/ansi v0.11.7 h1:kzv1kJvjg2S3r9KHo8hDdHFQLEqn4RBCb39dAYC84jI=
github.com/charmbracelet/x/ansi v0.11.7/go.mod h1:9qGpnAVYz+8ACONkZBUWPtL7lulP9No6p1epAihUZwQ=
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/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U=
github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ=
github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8 h1:eyFRbAmexyt43hVfeyBofiGSEmJ7krjLOYt/9CF5NKA=
github.com/charmbracelet/ultraviolet v0.0.0-20260205113103-524a6607adb8/go.mod h1:SQpCTRNBtzJkwku5ye4S3HEuthAlGy2n9VXZnWkEW98=
github.com/charmbracelet/x/ansi v0.11.8 h1:JMFwp0CgDC2+jcOB162HH5k7I3FVbgFSMMYg7dSPBQQ=
github.com/charmbracelet/x/ansi v0.11.8/go.mod h1:ZNN+3mXny/516oTQPLMPIBeSINvNJJQ8uQXDgbeJxY0=
github.com/charmbracelet/x/conpty v0.1.1 h1:s1bUxjoi7EpqiXysVtC+a8RrvPPNcNvAjfi4jxsAuEs=
github.com/charmbracelet/x/conpty v0.1.1/go.mod h1:OmtR77VODEFbiTzGE9G1XiRJAga6011PIm4u5fTNZpk=
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA=
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f h1:pk6gmGpCE7F3FcjaOEKYriCvpmIN4+6OS/RD0vm4uIA=
github.com/charmbracelet/x/exp/golden v0.0.0-20250806222409-83e3a29d542f/go.mod h1:IfZAMTHB6XkZSeXUqriemErjAWCCzT0LwjKFYCZyw0I=
github.com/charmbracelet/x/exp/ordered v0.1.0 h1:55/qLwjIh0gL0Vni+QAWk7T/qRVP6sBf+2agPBgnOFE=
github.com/charmbracelet/x/exp/ordered v0.1.0/go.mod h1:5UHwmG+is5THxMyCJHNPCn2/ecI07aKNrW+LcResjJ8=
github.com/charmbracelet/x/exp/strings v0.1.0 h1:i69S2XI7uG1u4NLGeJPSYU++Nmjvpo9nwd6aoEm7gkA=
github.com/charmbracelet/x/exp/strings v0.1.0/go.mod h1:/ehtMPNh9K4odGFkqYJKpIYyePhdp1hLBRvyY4bWkH8=
github.com/charmbracelet/x/term v0.2.2 h1:xVRT/S2ZcKdhhOuSP4t5cLi5o+JxklsoEObBSgfgZRk=
github.com/charmbracelet/x/term v0.2.2/go.mod h1:kF8CY5RddLWrsgVwpw4kAa6TESp6EB5y3uxGLeCqzAI=
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
github.com/charmbracelet/x/xpty v0.1.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGlqCbtI=
github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4=
github.com/charmbracelet/x/windows v0.2.2 h1:IofanmuvaxnKHuV04sC0eBy/smG6kIKrWG2/jYn2GuM=
github.com/charmbracelet/x/windows v0.2.2/go.mod h1:/8XtdKZzedat74NQFn0NGlGL4soHB0YQZrETF96h75k=
github.com/charmbracelet/x/xpty v0.1.3 h1:eGSitii4suhzrISYH50ZfufV3v085BXQwIytcOdFSsw=
github.com/charmbracelet/x/xpty v0.1.3/go.mod h1:poPYpWuLDBFCKmKLDnhBp51ATa0ooD8FhypRwEFtH3Y=
github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSEFgwIwO+UVM8=
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
@@ -43,36 +45,22 @@ github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJ
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
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/dustin/go-humanize v1.1.0 h1:dbKTrvD0klcbBV/h4AWJdMuZogJACoMlvWIWZ5b2xWg=
github.com/dustin/go-humanize v1.1.0/go.mod h1:hc1CvRkJMsgxqjmjMQF3QNRAZBwY8AXBAzKYoSX9sFI=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
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.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/lukaszraczylo/oss-telemetry v0.2.3 h1:xoDtBqeZGmXj7IteiE1M5WMuzeoqag58qEleI0Cf2Ms=
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.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4=
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-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU=
github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
github.com/lucasb-eyer/go-colorful v1.4.1 h1:1EO+WB73+EH8EVbzlrG3KLAfEypQWVHIBqlTf+2hNss=
github.com/lucasb-eyer/go-colorful v1.4.1/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/lukaszraczylo/oss-telemetry v0.2.5 h1:W6Qgwp7IY4yBRO361MmnEAmM59motdQpbAFAx8v6fJM=
github.com/lukaszraczylo/oss-telemetry v0.2.5/go.mod h1:+Cn78qZo8rc3T9eZt0v3oICYRdd75wORtSidc8lNjDQ=
github.com/mattn/go-runewidth v0.0.30 h1:+KUuiDA4fF0R1p5FeueHefjDm+GIM+kWfFnDjybOPgk=
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/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/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
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/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.0/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/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
@@ -83,18 +71,19 @@ github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiT
github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk=
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/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
github.com/xo/terminfo v1.2.0 h1:d0ZTOCpuGE0lwSAOs0zcJjwz3jWQyqcRt9XbGJpCOl4=
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=
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.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw=
golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE=
golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4=
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
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/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+10 -10
View File
@@ -31,16 +31,16 @@ func GatewayProviderKey(gatewayURL string) string {
}
// 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{
"id": id,
"name": id,
"id": m.ID,
"name": m.ID,
"cost_per_1m_in": 0,
"cost_per_1m_out": 0,
"cost_per_1m_in_cached": 0,
"cost_per_1m_out_cached": 0,
"context_window": 200000,
"default_max_tokens": 8192,
"context_window": m.ContextLimit(),
"default_max_tokens": m.OutputLimit(),
"can_reason": false,
"supports_attachments": true,
}
@@ -56,10 +56,10 @@ func ProvidersAsCrushMap(p *canonical.Profile) map[string]any {
}
models := make([]map[string]any, 0)
for _, m := range p.Models {
models = append(models, crushModel(m.ID))
models = append(models, crushModel(m))
}
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{
"type": "openai-compat",
@@ -101,7 +101,7 @@ func ProvidersAsMap(p *canonical.Profile) map[string]any {
}
models[m.ID] = map[string]any{
"name": displayName,
"limit": map[string]any{"context": 200000, "output": 8192},
"limit": map[string]any{"context": m.ContextLimit(), "output": m.OutputLimit()},
}
}
entry := map[string]any{
@@ -172,7 +172,7 @@ func GooseCustomProviderFile(p *canonical.Profile) ([]byte, string) {
for _, m := range p.Models {
models = append(models, map[string]any{
"name": m.ID,
"context_limit": 200000,
"context_limit": m.ContextLimit(),
})
}
if len(models) == 0 && p.Gateway.DefaultModel != "" {
@@ -183,7 +183,7 @@ func GooseCustomProviderFile(p *canonical.Profile) ([]byte, string) {
}
models = append(models, map[string]any{
"name": modelID,
"context_limit": 200000,
"context_limit": canonical.DefaultContextLimit,
})
}
+50
View File
@@ -1,6 +1,7 @@
package common
import (
"encoding/json"
"testing"
"github.com/stretchr/testify/assert"
@@ -64,3 +65,52 @@ func TestParseMCPFromJSONMissingKey(t *testing.T) {
require.NoError(t, err)
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")
}
+21
View File
@@ -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
}
+159
View File
@@ -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)
}
+149
View File
@@ -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)
}
+1 -1
View File
@@ -122,7 +122,7 @@ func zedLanguageModels(p *canonical.Profile) map[string]any {
for _, m := range p.Models {
me := map[string]any{
"name": m.ID,
"max_tokens": 200000,
"max_tokens": m.ContextLimit(),
"capabilities": map[string]any{
"tools": true,
"images": false,
+19
View File
@@ -63,6 +63,25 @@ func TestZedRenderProducesExpectedTargets(t *testing.T) {
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) {
home := t.TempDir()
base := filepath.Join(home, ".config", "zed")
+27
View File
@@ -35,6 +35,33 @@ type Upstream struct {
type Model struct {
ID string `yaml:"id"`
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 {
+1 -1
View File
@@ -5,7 +5,7 @@ package ui
import (
"fmt"
"github.com/charmbracelet/huh"
"charm.land/huh/v2"
)
type msOpts struct {
+1 -1
View File
@@ -90,7 +90,7 @@ func TestDetectListsAllAdapters(t *testing.T) {
// None should be detected in an empty HOME
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, "not detected")