mirror of
https://github.com/lukaszraczylo/harness-sync.git
synced 2026-10-12 00:45:22 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e01f3419ea | ||
|
|
5704ede5c7 | ||
|
|
a7338e91dc | ||
|
|
ae44e31abd | ||
|
|
2eaa4ff825 | ||
|
|
0e35af67b6 | ||
|
|
6483eb8044 |
@@ -15,6 +15,6 @@ jobs:
|
||||
autoupdate:
|
||||
uses: lukaszraczylo/shared-actions/.github/workflows/go-autoupdate.yaml@main
|
||||
with:
|
||||
go-version: ">=1.24"
|
||||
go-version: ">=1.25"
|
||||
release-workflow: "release.yaml"
|
||||
secrets: inherit
|
||||
|
||||
@@ -18,6 +18,6 @@ jobs:
|
||||
release:
|
||||
uses: lukaszraczylo/shared-actions/.github/workflows/go-release.yaml@main
|
||||
with:
|
||||
go-version: ">=1.24"
|
||||
go-version: ">=1.25"
|
||||
rolling-release-tag: "v1"
|
||||
secrets: inherit
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
module github.com/lukaszraczylo/harness-sync
|
||||
|
||||
go 1.25
|
||||
go 1.25.0
|
||||
|
||||
require (
|
||||
github.com/charmbracelet/huh v1.0.0
|
||||
github.com/pelletier/go-toml/v2 v2.2.3
|
||||
github.com/lukaszraczylo/oss-telemetry v0.2.3
|
||||
github.com/pelletier/go-toml/v2 v2.3.1
|
||||
github.com/spf13/afero v1.15.0
|
||||
github.com/spf13/cobra v1.8.1
|
||||
github.com/spf13/cobra v1.10.2
|
||||
github.com/stretchr/testify v1.9.0
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
)
|
||||
@@ -15,32 +16,32 @@ require (
|
||||
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 v0.21.1-0.20250623103423-23b8fd6302d7 // indirect
|
||||
github.com/charmbracelet/bubbletea v1.3.6 // indirect
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // 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.9.3 // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
|
||||
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
|
||||
github.com/charmbracelet/x/term v0.2.1 // indirect
|
||||
github.com/charmbracelet/x/ansi v0.11.7 // indirect
|
||||
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
|
||||
github.com/charmbracelet/x/exp/strings v0.1.0 // indirect
|
||||
github.com/charmbracelet/x/term 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/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
|
||||
github.com/lukaszraczylo/oss-telemetry v0.2.1 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // 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.16 // indirect
|
||||
github.com/mattn/go-runewidth v0.0.24 // 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.5 // indirect
|
||||
github.com/spf13/pflag v1.0.10 // indirect
|
||||
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
|
||||
golang.org/x/sync v0.16.0 // indirect
|
||||
golang.org/x/sys v0.33.0 // indirect
|
||||
golang.org/x/text v0.28.0 // indirect
|
||||
golang.org/x/sys v0.45.0 // indirect
|
||||
golang.org/x/text v0.37.0 // indirect
|
||||
)
|
||||
|
||||
@@ -8,35 +8,39 @@ github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3v
|
||||
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
|
||||
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 v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws=
|
||||
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw=
|
||||
github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU=
|
||||
github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
|
||||
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
|
||||
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.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0=
|
||||
github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k=
|
||||
github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
|
||||
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/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/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4=
|
||||
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
|
||||
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
|
||||
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
|
||||
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/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
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=
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||
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=
|
||||
@@ -47,16 +51,16 @@ github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6
|
||||
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/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
|
||||
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/lukaszraczylo/oss-telemetry v0.2.1 h1:6ULyfzXplpdmIY/i01OPM1jeod9+L1RAhI0jtbVnJI0=
|
||||
github.com/lukaszraczylo/oss-telemetry v0.2.1/go.mod h1:+Cn78qZo8rc3T9eZt0v3oICYRdd75wORtSidc8lNjDQ=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
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.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||
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/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=
|
||||
@@ -65,34 +69,32 @@ 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/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.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
||||
github.com/pelletier/go-toml/v2 v2.3.1 h1:MYEvvGnQjeNkRF1qUuGolNtNExTDwct51yp7olPtrEc=
|
||||
github.com/pelletier/go-toml/v2 v2.3.1/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/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
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=
|
||||
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
|
||||
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
|
||||
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
|
||||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU=
|
||||
github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4=
|
||||
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=
|
||||
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/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
|
||||
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
|
||||
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
|
||||
golang.org/x/sys v0.45.0 h1:dO4czNzziLiiXplLQgBCEpCvXQ3dnkn0SdaZSYdQ+FY=
|
||||
golang.org/x/sys v0.45.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/text v0.37.0 h1:Cqjiwd9eSg8e0QAkyCaQTNHFIIzWtidPahFWR83rTrc=
|
||||
golang.org/x/text v0.37.0/go.mod h1:a5sjxXGs9hsn/AJVwuElvCAo9v8QYLzvavO5z2PiM38=
|
||||
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=
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package adapter
|
||||
|
||||
import "github.com/lukaszraczylo/harness-sync/internal/adapter/common"
|
||||
|
||||
// Base holds the cross-adapter defaults (currently just the home directory
|
||||
// used to compute target paths). Embed it in each adapter struct to inherit
|
||||
// the WithHome/New constructor pattern without re-implementing it.
|
||||
type Base struct {
|
||||
Home string
|
||||
}
|
||||
|
||||
// BaseOption configures a Base. Returned by WithHome and consumed by NewBase.
|
||||
type BaseOption func(*Base)
|
||||
|
||||
// WithHome overrides the home directory used for target paths. Defaults to
|
||||
// common.DefaultHome() (current $HOME) when no option is supplied.
|
||||
func WithHome(h string) BaseOption {
|
||||
return func(b *Base) { b.Home = h }
|
||||
}
|
||||
|
||||
// NewBase returns a Base populated from opts, with Home defaulting to the
|
||||
// current user's home directory.
|
||||
func NewBase(opts ...BaseOption) *Base {
|
||||
b := &Base{Home: common.DefaultHome()}
|
||||
for _, o := range opts {
|
||||
o(b)
|
||||
}
|
||||
return b
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package adapter_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/lukaszraczylo/harness-sync/internal/adapter"
|
||||
)
|
||||
|
||||
func TestNewBaseDefaultsHomeFromEnv(t *testing.T) {
|
||||
b := adapter.NewBase()
|
||||
// DefaultHome returns either $HOME or "". We only assert that the
|
||||
// helper does not panic and that Home is a string (Go zero value is "").
|
||||
// Environment-dependence: skip if HOME is unset (CI minimal envs).
|
||||
if b.Home == "" {
|
||||
t.Skip("HOME unset in test env; cannot verify default")
|
||||
}
|
||||
assert.NotEmpty(t, b.Home)
|
||||
}
|
||||
|
||||
func TestNewBaseWithHomeOverrides(t *testing.T) {
|
||||
b := adapter.NewBase(adapter.WithHome("/custom/home/path"))
|
||||
assert.Equal(t, "/custom/home/path", b.Home)
|
||||
}
|
||||
|
||||
func TestNewBaseOptionsApplyInOrder(t *testing.T) {
|
||||
// Last write wins — covers the basic Apply loop in NewBase.
|
||||
b := adapter.NewBase(
|
||||
adapter.WithHome("/first"),
|
||||
adapter.WithHome("/second"),
|
||||
)
|
||||
assert.Equal(t, "/second", b.Home)
|
||||
}
|
||||
|
||||
func TestBaseOptionTypedCorrectly(t *testing.T) {
|
||||
// adapter.BaseOption is the public type; WithHome must return it.
|
||||
opt := adapter.WithHome("/x")
|
||||
require.NotNil(t, opt)
|
||||
|
||||
// Apply it manually to confirm signature.
|
||||
var b adapter.Base
|
||||
opt(&b)
|
||||
assert.Equal(t, "/x", b.Home)
|
||||
}
|
||||
@@ -11,10 +11,6 @@ import (
|
||||
|
||||
const fallbackGatewayProviderID = "harness-sync-gateway"
|
||||
|
||||
// GatewayProviderID is the canonical provider key used across all adapters.
|
||||
// Deprecated: prefer GatewayProviderKey(gatewayURL) for a stable URL-derived key.
|
||||
const GatewayProviderID = fallbackGatewayProviderID
|
||||
|
||||
// GatewayProviderKey returns a stable provider key derived from the gateway URL.
|
||||
// Format: "hs-<hostname>" with dots and special chars normalised to dashes.
|
||||
// Falls back to "harness-sync-gateway" when the URL is empty or unparseable.
|
||||
@@ -34,52 +30,6 @@ func GatewayProviderKey(gatewayURL string) string {
|
||||
return "hs-" + r.Replace(host)
|
||||
}
|
||||
|
||||
// ProviderEntry is a generic provider record. Adapters may massage further.
|
||||
type ProviderEntry = map[string]any
|
||||
|
||||
// BuildProviders returns the canonical-to-generic provider list: gateway first
|
||||
// (if configured), then any upstreams. Each entry has id, name, base_url,
|
||||
// api_key, and (for the gateway) a models list.
|
||||
func BuildProviders(p *canonical.Profile) []ProviderEntry {
|
||||
out := make([]ProviderEntry, 0, len(p.Upstreams)+1)
|
||||
if p.Gateway.URL != "" {
|
||||
key := GatewayProviderKey(p.Gateway.URL)
|
||||
gw := ProviderEntry{
|
||||
"id": key,
|
||||
"name": "harness-sync gateway",
|
||||
"base_url": p.Gateway.URL,
|
||||
"api_key": p.Gateway.Token,
|
||||
}
|
||||
if models := buildModels(p.Models); len(models) > 0 {
|
||||
gw["models"] = models
|
||||
}
|
||||
out = append(out, gw)
|
||||
}
|
||||
for _, up := range p.Upstreams {
|
||||
e := ProviderEntry{"id": up.Name, "name": up.Name}
|
||||
if up.BaseURL != "" {
|
||||
e["base_url"] = up.BaseURL
|
||||
}
|
||||
if up.APIKey != "" {
|
||||
e["api_key"] = up.APIKey
|
||||
}
|
||||
out = append(out, e)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func buildModels(models []canonical.Model) []map[string]any {
|
||||
out := make([]map[string]any, 0, len(models))
|
||||
for _, m := range models {
|
||||
e := map[string]any{"id": m.ID}
|
||||
if m.Alias != "" {
|
||||
e["alias"] = m.Alias
|
||||
}
|
||||
out = append(out, e)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// crushModel builds a 10-field model entry required by the crush schema.
|
||||
func crushModel(id string) map[string]any {
|
||||
return map[string]any{
|
||||
@@ -209,40 +159,6 @@ func ProvidersAsCagentMap(p *canonical.Profile) map[string]any {
|
||||
return out
|
||||
}
|
||||
|
||||
// ZedLanguageModels returns the language_models.openai block for Zed when a
|
||||
// gateway URL is configured.
|
||||
func ZedLanguageModels(p *canonical.Profile) map[string]any {
|
||||
if p.Gateway.URL == "" {
|
||||
return map[string]any{}
|
||||
}
|
||||
models := make([]map[string]any, 0)
|
||||
for _, m := range p.Models {
|
||||
models = append(models, map[string]any{
|
||||
"name": m.ID,
|
||||
"display_name": func() string {
|
||||
if m.Alias != "" {
|
||||
return m.Alias
|
||||
}
|
||||
return m.ID
|
||||
}(),
|
||||
"max_tokens": 8192,
|
||||
})
|
||||
}
|
||||
if len(models) == 0 && p.Gateway.DefaultModel != "" {
|
||||
models = append(models, map[string]any{
|
||||
"name": p.Gateway.DefaultModel,
|
||||
"display_name": p.Gateway.DefaultModel,
|
||||
"max_tokens": 8192,
|
||||
})
|
||||
}
|
||||
return map[string]any{
|
||||
"openai": map[string]any{
|
||||
"api_url": p.Gateway.URL,
|
||||
"available_models": models,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// GooseCustomProviderFile returns the JSON body and provider ID for the goose
|
||||
// custom_providers/<id>.json file. Returns nil body when Gateway.URL is empty.
|
||||
func GooseCustomProviderFile(p *canonical.Profile) ([]byte, string) {
|
||||
|
||||
@@ -9,32 +9,6 @@ import (
|
||||
"github.com/lukaszraczylo/harness-sync/internal/canonical"
|
||||
)
|
||||
|
||||
func TestBuildProvidersGatewayFirst(t *testing.T) {
|
||||
p := &canonical.Profile{
|
||||
Gateway: canonical.Gateway{URL: "https://gw", Token: "t", DefaultModel: "x"},
|
||||
Models: []canonical.Model{{ID: "m1", Alias: "a1"}},
|
||||
Upstreams: []canonical.Upstream{
|
||||
{Name: "anthropic", APIKey: "k", BaseURL: "https://api.anthropic.com"},
|
||||
},
|
||||
}
|
||||
out := BuildProviders(p)
|
||||
require.Len(t, out, 2)
|
||||
assert.Equal(t, "hs-gw", out[0]["id"])
|
||||
assert.Equal(t, "anthropic", out[1]["id"])
|
||||
assert.NotNil(t, out[0]["models"])
|
||||
}
|
||||
|
||||
func TestBuildProvidersNoGateway(t *testing.T) {
|
||||
p := &canonical.Profile{
|
||||
Upstreams: []canonical.Upstream{
|
||||
{Name: "anthropic", APIKey: "k"},
|
||||
},
|
||||
}
|
||||
out := BuildProviders(p)
|
||||
require.Len(t, out, 1)
|
||||
assert.Equal(t, "anthropic", out[0]["id"])
|
||||
}
|
||||
|
||||
func TestBuildMCPMap(t *testing.T) {
|
||||
reg := &canonical.MCPRegistry{Servers: []canonical.MCPServer{
|
||||
{Name: "filepuff", Command: "/bin/x", Transport: "stdio"},
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package common
|
||||
|
||||
import "os"
|
||||
|
||||
// DefaultHome returns the current user's home directory, or "" on error.
|
||||
func DefaultHome() string {
|
||||
h, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return h
|
||||
}
|
||||
@@ -29,6 +29,19 @@ func ReadIfExists(path string) (string, error) {
|
||||
return ReadIfExistsFS(fsx.OS(), path)
|
||||
}
|
||||
|
||||
// ReadExistingFile returns the file body or (nil, nil) when missing.
|
||||
// Other errors (permission denied, I/O failure) are returned verbatim so
|
||||
// read-modify-write callers can distinguish a fresh first-run state from a
|
||||
// broken read. Treating every error as "file is empty" silently overwrites
|
||||
// the user's on-disk edits during apply.
|
||||
func ReadExistingFile(path string) ([]byte, error) {
|
||||
b, err := os.ReadFile(path) //nolint:gosec // caller-controlled path
|
||||
if err != nil && os.IsNotExist(err) {
|
||||
return nil, nil
|
||||
}
|
||||
return b, err
|
||||
}
|
||||
|
||||
// DirExistsFS reports whether path is an existing directory on fs.
|
||||
func DirExistsFS(fs fsx.FS, path string) bool {
|
||||
info, err := fs.Stat(path)
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package common_test
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/lukaszraczylo/harness-sync/internal/adapter/common"
|
||||
)
|
||||
|
||||
// ReadExistingFile: missing file returns (nil, nil). Permission errors and
|
||||
// other I/O failures must NOT be silently swallowed — those would let
|
||||
// read-modify-write code clobber the user's on-disk state.
|
||||
|
||||
func TestReadExistingFileMissing(t *testing.T) {
|
||||
got, err := common.ReadExistingFile(filepath.Join(t.TempDir(), "absent"))
|
||||
require.NoError(t, err)
|
||||
assert.Nil(t, got)
|
||||
}
|
||||
|
||||
func TestReadExistingFileContent(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
path := filepath.Join(dir, "ok.txt")
|
||||
require.NoError(t, os.WriteFile(path, []byte("body\n"), 0o600))
|
||||
|
||||
got, err := common.ReadExistingFile(path)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, []byte("body\n"), got)
|
||||
}
|
||||
|
||||
func TestReadExistingFilePropagatesError(t *testing.T) {
|
||||
// Create a directory the OS will refuse us read access to.
|
||||
if os.Geteuid() == 0 {
|
||||
t.Skip("running as root; cannot test permission denial")
|
||||
}
|
||||
dir := t.TempDir()
|
||||
require.NoError(t, os.Mkdir(filepath.Join(dir, "locked"), 0o000))
|
||||
t.Cleanup(func() { _ = os.Chmod(filepath.Join(dir, "locked"), 0o755) })
|
||||
|
||||
_, err := common.ReadExistingFile(filepath.Join(dir, "locked", "file"))
|
||||
require.Error(t, err)
|
||||
assert.False(t, os.IsNotExist(err), "permission denied must not be reported as not-exist")
|
||||
assert.True(t, errors.Is(err, os.ErrPermission) || isPermission(err),
|
||||
"expected permission error, got %v", err)
|
||||
}
|
||||
|
||||
func isPermission(err error) bool {
|
||||
// Some platforms wrap the error in *os.PathError. Check the string too
|
||||
// for portability — it's a coarse signal but adequate here.
|
||||
return err != nil && (contains(err.Error(), "permission") || contains(err.Error(), "access denied"))
|
||||
}
|
||||
|
||||
func contains(s, sub string) bool {
|
||||
for i := 0; i+len(sub) <= len(s); i++ {
|
||||
if s[i:i+len(sub)] == sub {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -31,32 +31,7 @@ func BuildMCPMapStyled(reg *canonical.MCPRegistry, style MCPStyle) map[string]an
|
||||
func mcpEntry(s canonical.MCPServer, style MCPStyle) map[string]any {
|
||||
e := map[string]any{}
|
||||
switch style {
|
||||
case MCPClaudeStyle:
|
||||
// Claude Code's actual entry shape uses "type" (not "transport").
|
||||
// Default to stdio when no URL is set.
|
||||
t := s.Transport
|
||||
if s.URL != "" {
|
||||
if t == "" {
|
||||
t = "http"
|
||||
}
|
||||
e["type"] = t
|
||||
e["url"] = s.URL
|
||||
} else {
|
||||
if t == "" {
|
||||
t = "stdio"
|
||||
}
|
||||
e["type"] = t
|
||||
if s.Command != "" {
|
||||
e["command"] = s.Command
|
||||
}
|
||||
if len(s.Args) > 0 {
|
||||
e["args"] = s.Args
|
||||
}
|
||||
if len(s.Env) > 0 {
|
||||
e["env"] = s.Env
|
||||
}
|
||||
}
|
||||
case MCPCrushStyle:
|
||||
case MCPClaudeStyle, MCPCrushStyle:
|
||||
if s.URL != "" {
|
||||
t := s.Transport
|
||||
if t == "" {
|
||||
@@ -65,7 +40,12 @@ func mcpEntry(s canonical.MCPServer, style MCPStyle) map[string]any {
|
||||
e["type"] = t
|
||||
e["url"] = s.URL
|
||||
} else {
|
||||
e["type"] = "stdio"
|
||||
// Claude honours Transport field; Crush always uses "stdio".
|
||||
t := "stdio"
|
||||
if style == MCPClaudeStyle && s.Transport != "" {
|
||||
t = s.Transport
|
||||
}
|
||||
e["type"] = t
|
||||
if s.Command != "" {
|
||||
e["command"] = s.Command
|
||||
}
|
||||
|
||||
@@ -19,29 +19,16 @@ import (
|
||||
const name = "cagent"
|
||||
|
||||
// Adapter implements adapter.Adapter for the cagent harness.
|
||||
type Adapter struct{ home string }
|
||||
|
||||
// Option configures an Adapter.
|
||||
type Option func(*Adapter)
|
||||
|
||||
// WithHome overrides the home directory (defaults to os.UserHomeDir).
|
||||
func WithHome(h string) Option { return func(a *Adapter) { a.home = h } }
|
||||
|
||||
// New returns a new Adapter with the given options applied.
|
||||
func New(opts ...Option) *Adapter {
|
||||
a := &Adapter{home: defaultHome()}
|
||||
for _, o := range opts {
|
||||
o(a)
|
||||
}
|
||||
return a
|
||||
type Adapter struct {
|
||||
*adapter.Base
|
||||
}
|
||||
|
||||
func defaultHome() string {
|
||||
h, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return h
|
||||
// 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.
|
||||
@@ -61,14 +48,14 @@ func (a *Adapter) Capabilities() adapter.HarnessCapabilities {
|
||||
|
||||
// Detect returns true when ~/.config/cagent/ exists.
|
||||
func (a *Adapter) Detect() bool {
|
||||
_, err := os.Stat(filepath.Join(a.home, ".config", "cagent"))
|
||||
_, err := os.Stat(filepath.Join(a.Home, ".config", "cagent"))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// Render produces a starter default.yaml for cagent.
|
||||
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
fs := adapter.NewFileSet()
|
||||
cfgPath := filepath.Join(a.home, ".config", "cagent", "default.yaml")
|
||||
cfgPath := filepath.Join(a.Home, ".config", "cagent", "default.yaml")
|
||||
|
||||
instructions := b.Instructions.Global
|
||||
if override, ok := b.Instructions.PerHarness[name]; ok && override != "" {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package claudecode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -14,30 +15,15 @@ const name = "claude-code"
|
||||
|
||||
// Adapter implements adapter.Adapter for the claude-code harness.
|
||||
type Adapter struct {
|
||||
home string
|
||||
*adapter.Base
|
||||
}
|
||||
|
||||
// Option configures an Adapter.
|
||||
type Option func(*Adapter)
|
||||
|
||||
// WithHome overrides the home directory (defaults to os.UserHomeDir).
|
||||
func WithHome(h string) Option { return func(a *Adapter) { a.home = h } }
|
||||
// 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 ...Option) *Adapter {
|
||||
a := &Adapter{home: defaultHome()}
|
||||
for _, o := range opts {
|
||||
o(a)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func defaultHome() string {
|
||||
h, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return h
|
||||
func New(opts ...adapter.BaseOption) *Adapter {
|
||||
return &Adapter{Base: adapter.NewBase(opts...)}
|
||||
}
|
||||
|
||||
// Name returns the harness identifier.
|
||||
@@ -58,7 +44,7 @@ func (a *Adapter) Capabilities() adapter.HarnessCapabilities {
|
||||
|
||||
// Detect returns true when ~/.claude exists.
|
||||
func (a *Adapter) Detect() bool {
|
||||
_, err := os.Stat(filepath.Join(a.home, ".claude"))
|
||||
_, err := os.Stat(filepath.Join(a.Home, ".claude"))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -67,7 +53,7 @@ func (a *Adapter) Detect() bool {
|
||||
// only manages skills/agents symlinks, CLAUDE.md, and MCP servers.
|
||||
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
fs := adapter.NewFileSet()
|
||||
base := filepath.Join(a.home, ".claude")
|
||||
base := filepath.Join(a.Home, ".claude")
|
||||
|
||||
fs.Add(adapter.File{
|
||||
Dest: filepath.Join(base, "skills"),
|
||||
@@ -100,7 +86,10 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
overlay := map[string]any{"mcpServers": mcpMap}
|
||||
|
||||
dedicatedPath := filepath.Join(base, "mcp_servers.json")
|
||||
dedicatedExisting, _ := os.ReadFile(dedicatedPath)
|
||||
dedicatedExisting, err := common.ReadExistingFile(dedicatedPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %s: %w", dedicatedPath, err)
|
||||
}
|
||||
dedicatedMerged, err := common.MergeJSONKeys(dedicatedExisting, overlay)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -111,9 +100,12 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
Content: dedicatedMerged,
|
||||
})
|
||||
|
||||
livePath := filepath.Join(a.home, ".claude.json")
|
||||
livePath := filepath.Join(a.Home, ".claude.json")
|
||||
if _, err := os.Stat(livePath); err == nil {
|
||||
liveExisting, _ := os.ReadFile(livePath)
|
||||
liveExisting, err := common.ReadExistingFile(livePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %s: %w", livePath, err)
|
||||
}
|
||||
liveMerged, err := common.MergeJSONKeys(liveExisting, overlay)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package crush
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -13,29 +14,16 @@ import (
|
||||
const name = "crush"
|
||||
|
||||
// Adapter implements adapter.Adapter for the crush harness.
|
||||
type Adapter struct{ home string }
|
||||
|
||||
// Option configures an Adapter.
|
||||
type Option func(*Adapter)
|
||||
|
||||
// WithHome overrides the home directory (defaults to os.UserHomeDir).
|
||||
func WithHome(h string) Option { return func(a *Adapter) { a.home = h } }
|
||||
|
||||
// New returns a new Adapter with the given options applied.
|
||||
func New(opts ...Option) *Adapter {
|
||||
a := &Adapter{home: defaultHome()}
|
||||
for _, o := range opts {
|
||||
o(a)
|
||||
}
|
||||
return a
|
||||
type Adapter struct {
|
||||
*adapter.Base
|
||||
}
|
||||
|
||||
func defaultHome() string {
|
||||
h, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return h
|
||||
// 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.
|
||||
@@ -55,7 +43,7 @@ func (a *Adapter) Capabilities() adapter.HarnessCapabilities {
|
||||
|
||||
// Detect returns true when ~/.config/crush exists.
|
||||
func (a *Adapter) Detect() bool {
|
||||
_, err := os.Stat(filepath.Join(a.home, ".config", "crush"))
|
||||
_, err := os.Stat(filepath.Join(a.Home, ".config", "crush"))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -64,7 +52,7 @@ func (a *Adapter) Detect() bool {
|
||||
// MCP key is "mcp" (not "mcpServers"); entries include a "type" field.
|
||||
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
fs := adapter.NewFileSet()
|
||||
base := filepath.Join(a.home, ".config", "crush")
|
||||
base := filepath.Join(a.Home, ".config", "crush")
|
||||
|
||||
fs.Add(adapter.File{
|
||||
Dest: filepath.Join(base, "skills"),
|
||||
@@ -73,7 +61,10 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
})
|
||||
|
||||
cfgPath := filepath.Join(base, "crush.json")
|
||||
existing, _ := os.ReadFile(cfgPath)
|
||||
existing, err := common.ReadExistingFile(cfgPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %s: %w", cfgPath, err)
|
||||
}
|
||||
overlay := map[string]any{}
|
||||
if providers := common.ProvidersAsCrushMap(&b.Profile); len(providers) > 0 {
|
||||
overlay["providers"] = providers
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
package goose
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -22,29 +23,16 @@ import (
|
||||
const name = "goose"
|
||||
|
||||
// Adapter implements adapter.Adapter for the Goose harness.
|
||||
type Adapter struct{ home string }
|
||||
|
||||
// Option configures an Adapter.
|
||||
type Option func(*Adapter)
|
||||
|
||||
// WithHome overrides the home directory (defaults to os.UserHomeDir).
|
||||
func WithHome(h string) Option { return func(a *Adapter) { a.home = h } }
|
||||
|
||||
// New returns a new Adapter with the given options applied.
|
||||
func New(opts ...Option) *Adapter {
|
||||
a := &Adapter{home: defaultHome()}
|
||||
for _, o := range opts {
|
||||
o(a)
|
||||
}
|
||||
return a
|
||||
type Adapter struct {
|
||||
*adapter.Base
|
||||
}
|
||||
|
||||
func defaultHome() string {
|
||||
h, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return h
|
||||
// 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.
|
||||
@@ -64,7 +52,7 @@ func (a *Adapter) Capabilities() adapter.HarnessCapabilities {
|
||||
|
||||
// Detect returns true when ~/.config/goose/ exists.
|
||||
func (a *Adapter) Detect() bool {
|
||||
_, err := os.Stat(filepath.Join(a.home, ".config", "goose"))
|
||||
_, err := os.Stat(filepath.Join(a.Home, ".config", "goose"))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -75,23 +63,26 @@ func (a *Adapter) Detect() bool {
|
||||
// also added to the FileSet so goose can load the provider on first run.
|
||||
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
fs := adapter.NewFileSet()
|
||||
cfgPath := filepath.Join(a.home, ".config", "goose", "config.yaml")
|
||||
cfgPath := filepath.Join(a.Home, ".config", "goose", "config.yaml")
|
||||
|
||||
// goose reads skills from ~/.agents/skills/<name>/SKILL.md (open Agent Skills spec)
|
||||
fs.Add(adapter.File{
|
||||
Dest: filepath.Join(a.home, ".agents", "skills"),
|
||||
Dest: filepath.Join(a.Home, ".agents", "skills"),
|
||||
Kind: adapter.SymlinkDir,
|
||||
SymlinkTarget: filepath.Join(b.Root, "skills"),
|
||||
})
|
||||
|
||||
existing, _ := os.ReadFile(cfgPath)
|
||||
existing, err := common.ReadExistingFile(cfgPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %s: %w", cfgPath, err)
|
||||
}
|
||||
|
||||
provider, model := splitProviderModel(b.Profile.Gateway.DefaultModel)
|
||||
if b.Profile.Gateway.URL != "" {
|
||||
// Emit the custom provider JSON file.
|
||||
body, providerName := common.GooseCustomProviderFile(&b.Profile)
|
||||
if body != nil {
|
||||
cpDir := filepath.Join(a.home, ".config", "goose", "custom_providers")
|
||||
cpDir := filepath.Join(a.Home, ".config", "goose", "custom_providers")
|
||||
fs.Add(adapter.File{
|
||||
Dest: filepath.Join(cpDir, providerName+".json"),
|
||||
Kind: adapter.RenderedFile,
|
||||
@@ -152,8 +143,8 @@ func buildExtensions(servers []canonical.MCPServer) map[string]any {
|
||||
// splitProviderModel splits "provider/model" into its parts.
|
||||
// If no slash, provider is "anthropic" and the whole string is the model.
|
||||
func splitProviderModel(s string) (string, string) {
|
||||
if idx := strings.IndexByte(s, '/'); idx >= 0 {
|
||||
return s[:idx], s[idx+1:]
|
||||
if p, m, ok := strings.Cut(s, "/"); ok {
|
||||
return p, m
|
||||
}
|
||||
return "anthropic", s
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package kilo
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -16,30 +17,15 @@ const name = "kilo"
|
||||
|
||||
// Adapter implements adapter.Adapter for the kilo harness.
|
||||
type Adapter struct {
|
||||
home string
|
||||
*adapter.Base
|
||||
}
|
||||
|
||||
// Option configures an Adapter.
|
||||
type Option func(*Adapter)
|
||||
|
||||
// WithHome overrides the home directory (defaults to os.UserHomeDir).
|
||||
func WithHome(h string) Option { return func(a *Adapter) { a.home = h } }
|
||||
// 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 ...Option) *Adapter {
|
||||
a := &Adapter{home: defaultHome()}
|
||||
for _, o := range opts {
|
||||
o(a)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func defaultHome() string {
|
||||
h, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return h
|
||||
func New(opts ...adapter.BaseOption) *Adapter {
|
||||
return &Adapter{Base: adapter.NewBase(opts...)}
|
||||
}
|
||||
|
||||
// Name returns the harness identifier.
|
||||
@@ -59,7 +45,7 @@ func (a *Adapter) Capabilities() adapter.HarnessCapabilities {
|
||||
|
||||
// Detect returns true when ~/.config/kilo exists.
|
||||
func (a *Adapter) Detect() bool {
|
||||
_, err := os.Stat(filepath.Join(a.home, ".config", "kilo"))
|
||||
_, err := os.Stat(filepath.Join(a.Home, ".config", "kilo"))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -70,7 +56,7 @@ func (a *Adapter) Detect() bool {
|
||||
// No "providers" key — kilo has no such concept.
|
||||
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
fs := adapter.NewFileSet()
|
||||
base := filepath.Join(a.home, ".config", "kilo")
|
||||
base := filepath.Join(a.Home, ".config", "kilo")
|
||||
|
||||
fs.Add(adapter.File{
|
||||
Dest: filepath.Join(base, "agent"),
|
||||
@@ -79,13 +65,16 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
})
|
||||
// kilo reads skills from ~/.kilo/skills/<name>/SKILL.md
|
||||
fs.Add(adapter.File{
|
||||
Dest: filepath.Join(a.home, ".kilo", "skills"),
|
||||
Dest: filepath.Join(a.Home, ".kilo", "skills"),
|
||||
Kind: adapter.SymlinkDir,
|
||||
SymlinkTarget: filepath.Join(b.Root, "skills"),
|
||||
})
|
||||
|
||||
cfgPath := filepath.Join(base, "kilo.json")
|
||||
existing, _ := os.ReadFile(cfgPath)
|
||||
existing, err := common.ReadExistingFile(cfgPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %s: %w", cfgPath, err)
|
||||
}
|
||||
modelStr := common.KiloModelString(&b.Profile)
|
||||
overlay := map[string]any{}
|
||||
if providers := common.ProvidersAsMap(&b.Profile); len(providers) > 0 {
|
||||
@@ -110,50 +99,15 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
|
||||
// Also merge into opencode.jsonc when present — kilo reads it as its
|
||||
// primary config. Delete the enabled_providers filter so our provider is
|
||||
// visible alongside user-defined providers. Deep-merge the provider map
|
||||
// so existing providers (e.g. "llmgw") are preserved.
|
||||
// visible alongside user-defined providers.
|
||||
ocPath := filepath.Join(base, "opencode.jsonc")
|
||||
if ocRaw, readErr := os.ReadFile(ocPath); readErr == nil {
|
||||
// Parse existing content (supports JSONC comments internally).
|
||||
var ocBase map[string]any
|
||||
clean := common.StripJSONComments(string(ocRaw))
|
||||
_ = json.Unmarshal([]byte(clean), &ocBase)
|
||||
if ocBase == nil {
|
||||
ocBase = map[string]any{}
|
||||
}
|
||||
|
||||
ocOverlay := map[string]any{
|
||||
"enabled_providers": nil, // delete filter
|
||||
}
|
||||
|
||||
// Deep-merge provider: add our entries INTO the existing provider map,
|
||||
// then absorb any duplicate providers that share the same gateway URL.
|
||||
if newProv, ok := overlay["provider"].(map[string]any); ok && len(newProv) > 0 {
|
||||
existingProv, _ := ocBase["provider"].(map[string]any)
|
||||
if existingProv == nil {
|
||||
existingProv = map[string]any{}
|
||||
}
|
||||
maps.Copy(existingProv, newProv)
|
||||
// Absorb providers at the same URL into harness-sync-gateway,
|
||||
// preserving user-crafted display names and custom limits.
|
||||
merged := common.AbsorbDuplicateProviders(existingProv, common.GatewayProviderKey(b.Profile.Gateway.URL), b.Profile.Gateway.URL)
|
||||
ocOverlay["provider"] = merged
|
||||
}
|
||||
// Copy model/small_model/mcp from the kilo.json overlay.
|
||||
for _, k := range []string{"model", "small_model", "mcp"} {
|
||||
if v, ok := overlay[k]; ok {
|
||||
ocOverlay[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
ocMerged, mergeErr := common.MergeJSONKeys([]byte(clean), ocOverlay)
|
||||
if mergeErr != nil {
|
||||
return nil, mergeErr
|
||||
}
|
||||
if ocContent, mergeErr := mergeOpenCodeJSONC(ocPath, overlay, b.Profile.Gateway.URL); mergeErr != nil {
|
||||
return nil, mergeErr
|
||||
} else if ocContent != nil {
|
||||
fs.Add(adapter.File{
|
||||
Dest: ocPath,
|
||||
Kind: adapter.RenderedFile,
|
||||
Content: ocMerged,
|
||||
Content: ocContent,
|
||||
NoMerge: true,
|
||||
})
|
||||
}
|
||||
@@ -161,6 +115,41 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
return fs, nil
|
||||
}
|
||||
|
||||
// mergeOpenCodeJSONC deep-merges our overlay into the existing opencode.jsonc
|
||||
// file, deleting the enabled_providers filter and deduplicating gateway providers.
|
||||
// Returns nil content (no error) when the file does not exist.
|
||||
func mergeOpenCodeJSONC(path string, overlay map[string]any, gatewayURL string) ([]byte, error) {
|
||||
ocRaw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, nil //nolint:nilerr // file absent is not an error
|
||||
}
|
||||
|
||||
var ocBase map[string]any
|
||||
clean := common.StripJSONComments(string(ocRaw))
|
||||
_ = json.Unmarshal([]byte(clean), &ocBase)
|
||||
if ocBase == nil {
|
||||
ocBase = map[string]any{}
|
||||
}
|
||||
|
||||
ocOverlay := map[string]any{"enabled_providers": nil}
|
||||
|
||||
if newProv, ok := overlay["provider"].(map[string]any); ok && len(newProv) > 0 {
|
||||
existingProv, _ := ocBase["provider"].(map[string]any)
|
||||
if existingProv == nil {
|
||||
existingProv = map[string]any{}
|
||||
}
|
||||
maps.Copy(existingProv, newProv)
|
||||
ocOverlay["provider"] = common.AbsorbDuplicateProviders(existingProv, common.GatewayProviderKey(gatewayURL), gatewayURL)
|
||||
}
|
||||
for _, k := range []string{"model", "small_model", "mcp"} {
|
||||
if v, ok := overlay[k]; ok {
|
||||
ocOverlay[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
return common.MergeJSONKeys([]byte(clean), ocOverlay)
|
||||
}
|
||||
|
||||
// Import reads kilo config from home and returns a canonical ImportResult.
|
||||
func (a *Adapter) Import(home string) (*adapter.ImportResult, error) {
|
||||
return importFrom(home)
|
||||
|
||||
@@ -3,6 +3,7 @@ package opencode
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -14,29 +15,16 @@ import (
|
||||
const name = "opencode"
|
||||
|
||||
// Adapter implements adapter.Adapter for the opencode harness.
|
||||
type Adapter struct{ home string }
|
||||
|
||||
// Option configures an Adapter.
|
||||
type Option func(*Adapter)
|
||||
|
||||
// WithHome overrides the home directory (defaults to os.UserHomeDir).
|
||||
func WithHome(h string) Option { return func(a *Adapter) { a.home = h } }
|
||||
|
||||
// New returns a new Adapter with the given options applied.
|
||||
func New(opts ...Option) *Adapter {
|
||||
a := &Adapter{home: defaultHome()}
|
||||
for _, o := range opts {
|
||||
o(a)
|
||||
}
|
||||
return a
|
||||
type Adapter struct {
|
||||
*adapter.Base
|
||||
}
|
||||
|
||||
func defaultHome() string {
|
||||
h, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return h
|
||||
// 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.
|
||||
@@ -56,7 +44,7 @@ func (a *Adapter) Capabilities() adapter.HarnessCapabilities {
|
||||
|
||||
// Detect returns true when ~/.config/opencode exists.
|
||||
func (a *Adapter) Detect() bool {
|
||||
_, err := os.Stat(filepath.Join(a.home, ".config", "opencode"))
|
||||
_, err := os.Stat(filepath.Join(a.Home, ".config", "opencode"))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -66,7 +54,7 @@ func (a *Adapter) Detect() bool {
|
||||
// "mcp" (map with type: local|remote entries).
|
||||
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
fs := adapter.NewFileSet()
|
||||
base := filepath.Join(a.home, ".config", "opencode")
|
||||
base := filepath.Join(a.Home, ".config", "opencode")
|
||||
|
||||
// opencode reads skills from ~/.config/opencode/skills/<name>/SKILL.md
|
||||
fs.Add(adapter.File{
|
||||
@@ -76,7 +64,10 @@ func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
})
|
||||
|
||||
cfgPath := filepath.Join(base, "opencode.jsonc")
|
||||
existing, _ := os.ReadFile(cfgPath)
|
||||
existing, err := common.ReadExistingFile(cfgPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %s: %w", cfgPath, err)
|
||||
}
|
||||
|
||||
// Build the provider map, then absorb any existing providers at the same
|
||||
// gateway URL so duplicates don't accumulate across apply runs.
|
||||
|
||||
@@ -7,6 +7,7 @@ package zed
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -18,29 +19,16 @@ import (
|
||||
const name = "zed"
|
||||
|
||||
// Adapter implements adapter.Adapter for the Zed harness.
|
||||
type Adapter struct{ home string }
|
||||
|
||||
// Option configures an Adapter.
|
||||
type Option func(*Adapter)
|
||||
|
||||
// WithHome overrides the home directory (defaults to os.UserHomeDir).
|
||||
func WithHome(h string) Option { return func(a *Adapter) { a.home = h } }
|
||||
|
||||
// New returns a new Adapter with the given options applied.
|
||||
func New(opts ...Option) *Adapter {
|
||||
a := &Adapter{home: defaultHome()}
|
||||
for _, o := range opts {
|
||||
o(a)
|
||||
}
|
||||
return a
|
||||
type Adapter struct {
|
||||
*adapter.Base
|
||||
}
|
||||
|
||||
func defaultHome() string {
|
||||
h, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return h
|
||||
// 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.
|
||||
@@ -61,7 +49,7 @@ func (a *Adapter) Capabilities() adapter.HarnessCapabilities {
|
||||
|
||||
// Detect returns true when ~/.config/zed/ exists.
|
||||
func (a *Adapter) Detect() bool {
|
||||
_, err := os.Stat(filepath.Join(a.home, ".config", "zed"))
|
||||
_, err := os.Stat(filepath.Join(a.Home, ".config", "zed"))
|
||||
return err == nil
|
||||
}
|
||||
|
||||
@@ -76,8 +64,11 @@ func (a *Adapter) Detect() bool {
|
||||
// pre-existing parse errors from user-configured entries.
|
||||
func (a *Adapter) Render(b *canonical.Bundle) (*adapter.FileSet, error) {
|
||||
fs := adapter.NewFileSet()
|
||||
cfgPath := filepath.Join(a.home, ".config", "zed", "settings.json")
|
||||
existing, _ := os.ReadFile(cfgPath)
|
||||
cfgPath := filepath.Join(a.Home, ".config", "zed", "settings.json")
|
||||
existing, err := common.ReadExistingFile(cfgPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read %s: %w", cfgPath, err)
|
||||
}
|
||||
|
||||
// Set context_servers to nil so MergeJSONKeys removes the key entirely,
|
||||
// clearing any entries that trigger the serde ContextServerSettingsContent bug.
|
||||
|
||||
+38
-9
@@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/lukaszraczylo/harness-sync/internal/adapter"
|
||||
"github.com/lukaszraczylo/harness-sync/internal/adapter/common"
|
||||
"github.com/lukaszraczylo/harness-sync/internal/canonical"
|
||||
"github.com/lukaszraczylo/harness-sync/internal/gitx"
|
||||
"github.com/lukaszraczylo/harness-sync/internal/merge"
|
||||
@@ -42,6 +43,11 @@ type Action struct {
|
||||
// Run renders all adapters and writes their FileSets to disk.
|
||||
// Conflicts are recorded as <dest>.rej files; processing continues past conflicts.
|
||||
//
|
||||
// When Options.Repo is nil the canonical repo is auto-opened from Bundle.Root.
|
||||
// If that directory is not a git repository the commit step is silently
|
||||
// skipped — useful for one-off renders (CI smoke tests, dry-runs) where
|
||||
// initialising a repo would be more surprising than useful.
|
||||
//
|
||||
// IMPORTANT: harness-sync intentionally does NOT resolve ${VAR} references in
|
||||
// canonical configs. Every supported harness performs its own env-var
|
||||
// expansion at MCP launch / config-load time, so resolving here would only
|
||||
@@ -66,13 +72,30 @@ func Run(opt Options) (*Report, error) {
|
||||
return rep, renderErr
|
||||
}
|
||||
}
|
||||
if !opt.DryRun && rep.Written > 0 && opt.Repo != nil {
|
||||
if err := opt.Repo.AddAll(); err != nil {
|
||||
return rep, err
|
||||
}
|
||||
if err := opt.Repo.Commit(fmt.Sprintf("apply: %d files, %d conflicts", rep.Written, rep.Conflicts)); err != nil {
|
||||
return rep, err
|
||||
}
|
||||
if opt.DryRun || rep.Written == 0 {
|
||||
return rep, nil
|
||||
}
|
||||
repo := opt.Repo
|
||||
if repo == nil {
|
||||
repo = gitx.New(opt.Bundle.Root)
|
||||
}
|
||||
if !repo.IsRepo() {
|
||||
return rep, nil
|
||||
}
|
||||
if err := repo.AddAll(); err != nil {
|
||||
return rep, err
|
||||
}
|
||||
dirty, err := repo.HasStagedChanges()
|
||||
if err != nil {
|
||||
return rep, err
|
||||
}
|
||||
if !dirty {
|
||||
// Nothing changed inside the canonical repo (writes were outside it,
|
||||
// e.g. symlinks to temp dirs in tests). Skip the no-op commit.
|
||||
return rep, nil
|
||||
}
|
||||
if err := repo.Commit(fmt.Sprintf("apply: %d files, %d conflicts", rep.Written, rep.Conflicts)); err != nil {
|
||||
return rep, err
|
||||
}
|
||||
return rep, nil
|
||||
}
|
||||
@@ -93,8 +116,14 @@ func statePath(root, adapterName, dest string) string {
|
||||
|
||||
func handleRendered(opt Options, adapterName string, f adapter.File, rep *Report) error {
|
||||
sp := statePath(opt.Bundle.Root, adapterName, f.Dest)
|
||||
base, _ := os.ReadFile(sp)
|
||||
current, _ := os.ReadFile(f.Dest)
|
||||
base, readErr := common.ReadExistingFile(sp)
|
||||
if readErr != nil {
|
||||
return fmt.Errorf("read state %s: %w", sp, readErr)
|
||||
}
|
||||
current, readErr := common.ReadExistingFile(f.Dest)
|
||||
if readErr != nil {
|
||||
return fmt.Errorf("read target %s: %w", f.Dest, readErr)
|
||||
}
|
||||
|
||||
if string(current) == string(f.Content) {
|
||||
rep.Skipped++
|
||||
|
||||
@@ -584,6 +584,160 @@ func TestApplyUnknownFileKind(t *testing.T) {
|
||||
assert.Contains(t, err.Error(), "unknown file kind")
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TestApplyPropagatesReadErrors — regression for the silent-read footgun.
|
||||
// A target file in a directory we can no longer read must surface as an
|
||||
// error from Run, not as a fast-forward overwrite.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func TestApplyPropagatesReadErrors(t *testing.T) {
|
||||
if os.Geteuid() == 0 {
|
||||
t.Skip("running as root; cannot test permission denial")
|
||||
}
|
||||
root := t.TempDir()
|
||||
targetDir := t.TempDir()
|
||||
target := filepath.Join(targetDir, "out.txt")
|
||||
require.NoError(t, os.WriteFile(target, []byte("user-content\n"), 0o600))
|
||||
require.NoError(t, initCanonical(root))
|
||||
|
||||
// Strip read perms on the target's parent so os.ReadFile fails.
|
||||
require.NoError(t, os.Chmod(targetDir, 0o000))
|
||||
t.Cleanup(func() { _ = os.Chmod(targetDir, 0o755) })
|
||||
|
||||
ad := &stubAdapter{name: "stub", files: []adapter.File{
|
||||
{Dest: target, Kind: adapter.RenderedFile, Content: []byte("new-render\n")},
|
||||
}}
|
||||
_, err := Run(Options{
|
||||
Bundle: &canonical.Bundle{Root: root},
|
||||
Adapters: []adapter.Adapter{ad},
|
||||
Repo: gitx.New(root),
|
||||
})
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "read target")
|
||||
|
||||
// User's on-disk file must be untouched.
|
||||
_ = os.Chmod(targetDir, 0o755)
|
||||
body, rerr := os.ReadFile(target)
|
||||
require.NoError(t, rerr)
|
||||
assert.Equal(t, "user-content\n", string(body),
|
||||
"target must not be overwritten when read fails")
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TestApplyAutoOpensRepoFromBundleRoot — regression: callers no longer need
|
||||
// to pre-construct a *gitx.Repo. Run opens one from Bundle.Root, skips
|
||||
// commit gracefully when the root is not a git repo, and commits when it is.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func TestApplyAutoOpensRepoFromBundleRoot(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
target := filepath.Join(t.TempDir(), "out.txt")
|
||||
require.NoError(t, initCanonical(root))
|
||||
|
||||
ad := &stubAdapter{name: "stub", files: []adapter.File{
|
||||
{Dest: target, Kind: adapter.RenderedFile, Content: []byte("auto\n")},
|
||||
}}
|
||||
// Intentionally pass Repo: nil — the new behaviour should open one itself.
|
||||
rep, err := Run(Options{
|
||||
Bundle: &canonical.Bundle{Root: root},
|
||||
Adapters: []adapter.Adapter{ad},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, rep.Written)
|
||||
|
||||
// git log should have a new commit from apply, on top of the init one.
|
||||
out, gitErr := runGit(root, "log", "--oneline")
|
||||
require.NoError(t, gitErr)
|
||||
assert.GreaterOrEqual(t, countLines(out), 2)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TestApplyNoRepoSkipsCommit — when Bundle.Root isn't a git repo, Run must
|
||||
// still succeed (no error, no commit attempt). One-off renders / dry-runs.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func TestApplyNoRepoSkipsCommit(t *testing.T) {
|
||||
root := t.TempDir() // NOT initCanonical — no .git
|
||||
target := filepath.Join(t.TempDir(), "out.txt")
|
||||
|
||||
ad := &stubAdapter{name: "stub", files: []adapter.File{
|
||||
{Dest: target, Kind: adapter.RenderedFile, Content: []byte("x\n")},
|
||||
}}
|
||||
rep, err := Run(Options{
|
||||
Bundle: &canonical.Bundle{Root: root},
|
||||
Adapters: []adapter.Adapter{ad},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, rep.Written)
|
||||
body, rerr := os.ReadFile(target)
|
||||
require.NoError(t, rerr)
|
||||
assert.Equal(t, "x\n", string(body))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TestApplySkipsNoOpCommit — symlinks at a path outside the canonical repo
|
||||
// do not write a state snapshot inside the repo (handleSymlink has no
|
||||
// state-tracking), so git has nothing to commit. apply.Run must detect
|
||||
// "no staged changes" and skip the commit instead of failing with
|
||||
// "nothing to commit" from git itself.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func TestApplySkipsNoOpCommit(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
require.NoError(t, initCanonical(root))
|
||||
targetDir := t.TempDir()
|
||||
target := filepath.Join(targetDir, "outside-link")
|
||||
real := filepath.Join(targetDir, "real.txt")
|
||||
require.NoError(t, os.WriteFile(real, []byte("real\n"), 0o600))
|
||||
|
||||
ad := &stubAdapter{name: "stub", files: []adapter.File{
|
||||
{Dest: target, Kind: adapter.SymlinkFile, SymlinkTarget: real},
|
||||
}}
|
||||
rep, err := Run(Options{
|
||||
Bundle: &canonical.Bundle{Root: root},
|
||||
Adapters: []adapter.Adapter{ad},
|
||||
// Repo: nil — auto-open from Bundle.Root (which IS a git repo).
|
||||
})
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 1, rep.Written)
|
||||
|
||||
// Symlink exists on disk.
|
||||
got, lerr := os.Readlink(target)
|
||||
require.NoError(t, lerr)
|
||||
assert.Equal(t, real, got)
|
||||
|
||||
// No extra commit — still just the init commit. A failed "nothing to
|
||||
// commit" would surface here as an error from Run.
|
||||
out, gitErr := runGit(root, "log", "--oneline")
|
||||
require.NoError(t, gitErr)
|
||||
assert.Equal(t, 1, countLines(out),
|
||||
"expected only the init commit; symlink outside canonical root should not create one")
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// TestApplyCommitMessageHasCounts — commit message includes the file and
|
||||
// conflict counts so the rollback story is auditable from git log alone.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
func TestApplyCommitMessageHasCounts(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
target := filepath.Join(t.TempDir(), "msg.txt")
|
||||
require.NoError(t, initCanonical(root))
|
||||
|
||||
ad := &stubAdapter{name: "stub", files: []adapter.File{
|
||||
{Dest: target, Kind: adapter.RenderedFile, Content: []byte("m\n")},
|
||||
}}
|
||||
_, err := Run(Options{
|
||||
Bundle: &canonical.Bundle{Root: root},
|
||||
Adapters: []adapter.Adapter{ad},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
out, gitErr := runGit(root, "log", "-1", "--pretty=%s")
|
||||
require.NoError(t, gitErr)
|
||||
assert.Contains(t, out, "apply: 1 files, 0 conflicts")
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// helpers
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -71,6 +71,17 @@ func (r *Repo) IsRepo() bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// HasStagedChanges reports whether the index currently differs from HEAD.
|
||||
// Used by callers that want to skip a no-op `git commit` (commit exits 1
|
||||
// when there is nothing to commit, which is the wrong signal to propagate).
|
||||
func (r *Repo) HasStagedChanges() (bool, error) {
|
||||
b, err := r.run("status", "--porcelain")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return len(bytes.TrimSpace(b)) > 0, nil
|
||||
}
|
||||
|
||||
// Revert undoes the last N commits with `git revert --no-edit HEAD~N..HEAD`.
|
||||
// n must be >= 1.
|
||||
func (r *Repo) Revert(n int) error {
|
||||
|
||||
@@ -41,3 +41,33 @@ func TestShowFileAtHead(t *testing.T) {
|
||||
_, err = r.ShowFileAtHead("nope.txt")
|
||||
assert.Error(t, err)
|
||||
}
|
||||
|
||||
func TestHasStagedChangesEmptyAfterInit(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
r := New(dir)
|
||||
require.NoError(t, r.Init())
|
||||
require.NoError(t, r.Configure("nobody", "[email protected]"))
|
||||
// No commits yet, working tree clean.
|
||||
dirty, err := r.HasStagedChanges()
|
||||
require.NoError(t, err)
|
||||
assert.False(t, dirty)
|
||||
}
|
||||
|
||||
func TestHasStagedChangesAfterAdd(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
r := New(dir)
|
||||
require.NoError(t, r.Init())
|
||||
require.NoError(t, r.Configure("nobody", "[email protected]"))
|
||||
require.NoError(t, os.WriteFile(filepath.Join(dir, "a.txt"), []byte("x"), 0o600))
|
||||
require.NoError(t, r.AddAll())
|
||||
|
||||
dirty, err := r.HasStagedChanges()
|
||||
require.NoError(t, err)
|
||||
assert.True(t, dirty)
|
||||
|
||||
// After commit, index matches HEAD again → no staged changes.
|
||||
require.NoError(t, r.Commit("c"))
|
||||
dirty, err = r.HasStagedChanges()
|
||||
require.NoError(t, err)
|
||||
assert.False(t, dirty)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user