Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.
agent: connecting Kiro Crew connects the harness it is set to (wuping9525)
yetonea7072926d645
diff --git a/docs/reference.md b/docs/reference.mdindex e5ec56e73..8df47a86e 100644--- a/docs/reference.md+++ b/docs/reference.md@@ -141,7 +141,7 @@ line; agents connected to magpie lose it when it quits.| WorkBuddy AI | `~/.workbuddy-ai/models.json` (the international build) | provider (magpie's models in WorkBuddy AI's picker) || CodeBuddy Code | `~/.codebuddy/models.json` (`$CODEBUDDY_CONFIG_DIR`), `settings.json` | model (magpie's models in its list; the session model) || Raycast | `~/.config/raycast/ai/providers.yaml` in the user's folder, on Mac and Windows | provider (a `magpie` entry in Raycast AI's Custom Providers, magpie's models in its model picker; Raycast Pro; the user's providers, `tools` and comments kept) |-| Kiro Crew | `~/.kiro/crew/config.json` (`$KIROCREW_HOME`; `config.local.json` over it is left alone) | provider, harness (`agent.acp_backend`, and `agent.member_acp_backend` for a harness that can dispatch: an agent already connected to magpie, so its models are magpie's; the user's value is put back on Disconnect) |+| Kiro Crew | `~/.kiro/crew/config.json` (`$KIROCREW_HOME`; `config.local.json` over it is left alone) | provider, harness (`agent.acp_backend`, and `agent.member_acp_backend` for a harness that can dispatch: an agent connected to magpie, so its models are magpie's: the one Crew is set to is connected along with it when it isn't yet, and disconnected with it again; the user's value is put back on Disconnect) || OpenPencil | `openpencil/settings.json` in the config folder: `~/Library/Application Support` (macOS), `$XDG_CONFIG_HOME` or `~/.config` (Linux), `%APPDATA%` (Windows) | provider (a `magpie` entry in its `builtin_agents`, magpie's models in its chat's model picker; the user's entries and settings kept; refused while OpenPencil runs, as it writes the file back when it quits) || T3 Code | `~/.t3/userdata/settings.json` (`$T3CODE_HOME/userdata`) | provider (a `magpie` provider instance on Claude Code, magpie's models as its custom models) || OpenHanako | `~/.hanako/provider-catalog.json` + `agents/<id>/config.yaml` (`$HANA_HOME`; its local API while it runs) | model (the primary agent's; magpie's models as a provider) |diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.mdindex 89ecafd14..6f8e975cc 100644--- a/docs/subsystems/agent-wiring.md+++ b/docs/subsystems/agent-wiring.md@@ -67,7 +67,7 @@ something else shows up as drift.- AstrBot keeps its providers in `data/cmd_config.json` under its root (`$ASTRBOT_ROOT`, else `~/.astrbot`, the desktop app's, else `~/astrbot`), written with a UTF-8 BOM, which magpie keeps (`astrbot` in [`astrbot.go`](../../internal/agent/astrbot.go)). magpie adds a `magpie` entry to `provider_sources` and one `magpie/<model>` entry per model to `provider`, keeps the user's own entries byte for byte and keeps what the user changes in magpie's (timeout, proxy, enable), and sets the default chat model (`agent_runner.config.model.provider_id`, or `provider_settings.default_provider_id` before the agent runner), putting back what it found there. A pick the user makes while magpie is wired is theirs and stands. The first connect copies the file to `cmd_config.json.before-magpie`. AstrBot reads the file only at start-up and its WebUI writes it back whole on save, so the agent's notice says to restart AstrBot before saving in the WebUI. A Docker install's root is inside its container, which magpie doesn't reach.- jcode keeps its settings in `config.toml` in `$JCODE_HOME`, else `~/.jcode` (`jcode` in [`jcode.go`](../../internal/agent/jcode.go)). magpie adds a named profile, `[providers.magpie]`, as `jcode provider add` writes one: `type = "openai-compatible"`, the gateway's `/v1`, an inline `api_key` naming jcode (jcode sends nothing else that tells it apart) and `requires_api_key = true`, since jcode sends no key to a loopback URL without it. Its `models` list has one entry per model, with `context_window`, `input` and `reasoning` for a model with effort levels. A `reasoning_effort` the user set on one stays while the model has that level. The model jcode starts on is `[provider] default_provider = "magpie"` and `default_model`. What was there is stashed and put back on Disconnect. A model of jcode's own picked while it is on magpie takes magpie out. Each key is set alone, so the user's other keys and tables stay, and the `[[providers.magpie.models]]` tables jcode writes when it saves the file itself are replaced by the one list. A sync with nothing to change doesn't write. Disconnect drops the profile whole, its sub-tables included. jcode reads the file when it starts, so the notice says to restart open sessions.- Raycast AI reads Custom Providers from `~/.config/raycast/ai/providers.yaml` in the user's folder, on Mac and Windows alike (`raycast` in [`raycast.go`](../../internal/agent/raycast.go); manual.raycast.com/ai/custom-providers). magpie adds one entry to its `providers` list, `id: magpie`, at the gateway's `/v1` with an `api_keys` alias holding a key that names Raycast (its User-Agent isn't known), and one model per catalog model with `context` and all five `abilities` said, since Raycast assumes tools and vision off when one isn't. The list is edited as a node (`EditYAMLNode`), so the user's other entries, the `tools` block (anchors too) and comments stay. A key the user adds to magpie's entry or to one of its models (`include_user_email`, a `description`) is kept on a sync (`mergeYAMLKept`), and a sync with nothing to change doesn't write. Disconnect takes the entry out, the list when it was the only one, and a file left with nothing in it. Raycast watches the file, so there is no restart notice. The model is picked in Raycast, so the field is whether magpie is in its picker (`ListsModels`). Detected by `Raycast.app` on a Mac or the `~/.config/raycast` folder.-- Kiro Crew (AWS's persistent agent: KiroCrew.app, the `kirocrew` CLI, its Gateway on :5476) has no model setting of its own: it runs every session on a harness over ACP, chosen by `agent.acp_backend` in `$KIROCREW_HOME/config.json` (default `~/.kiro/crew`; `""` is kiro-cli), and dispatched members by `agent.member_acp_backend` (`kirocrew` in [`kirocrew.go`](../../internal/agent/kirocrew.go); github.com/kirodotdev/KiroCrew v0.9.0, `src/kiro_crew/` `config/paths.py`, `config/loader.py`, `config/sections.py`, `agent_sdk/backends.py`). Connecting it sets both to an agent already connected to magpie (Codex, Claude Code, OpenCode, Pi or Goose; Pi can't take dispatch, so only the first key for it), preferring the one whose ACP adapter is installed (codex-acp, claude-agent-acp, pi-acp; looked for, never installed, and named in the notice when missing). With none connected it refuses and says which to connect. `config.local.json` is merged over `config.json` and wins, so a harness set there is the user's: magpie neither writes nor reads past it, and the row says so. The previous values are stashed and put back on Disconnect, only while each key still holds what magpie wrote; a file magpie made is removed when it is left empty. The row reads as connected only while the harness it names is still wired to magpie. Open sessions keep their harness; new ones take it.+- Kiro Crew (AWS's persistent agent: KiroCrew.app, the `kirocrew` CLI, its Gateway on :5476) has no model setting of its own: it runs every session on a harness over ACP, chosen by `agent.acp_backend` in `$KIROCREW_HOME/config.json` (default `~/.kiro/crew`; `""` is kiro-cli), and dispatched members by `agent.member_acp_backend` (`kirocrew` in [`kirocrew.go`](../../internal/agent/kirocrew.go); github.com/kirodotdev/KiroCrew v0.9.0, `src/kiro_crew/` `config/paths.py`, `config/loader.py`, `config/sections.py`, `agent_sdk/backends.py`). Connecting it sets both to an agent already connected to magpie (Codex, Claude Code, OpenCode, Pi or Goose; Pi can't take dispatch, so only the first key for it), preferring the one whose ACP adapter is installed (codex-acp, claude-agent-acp, pi-acp; looked for, never installed, and named in the notice when missing). When `agent.acp_backend` already names one of those five and that agent is installed but not connected, connecting Kiro Crew connects that agent too, in the same action, and runs Crew on it (wuping9525 on Windows: Crew on Claude Code, Claude Code not connected); the stash's `kirocrew.joined` records it, and Kiro Crew's Disconnect disconnects it again, unless the user disconnected it themselves since (`kiroCrewUserLeft` in `Agent.Disconnect`), and a disconnect the user had made before stays theirs. Otherwise, with none connected it refuses and says which to connect. On Windows the app is found by `~\.kirocrew-app\.venv\Scripts\kirocrew.exe` and an adapter also by npm's `.cmd`/`.exe` shim names. `config.local.json` is merged over `config.json` and wins, so a harness set there is the user's: magpie neither writes nor reads past it, and the row says so. The previous values are stashed and put back on Disconnect, only while each key still holds what magpie wrote; a file magpie made is removed when it is left empty. The row reads as connected only while the harness it names is still wired to magpie. Open sessions keep their harness; new ones take it.- OpenPencil (ZSeven-W/openpencil, the `openpencil-desktop` app) keeps the builtin agents its chat runs on in `settings.json` in Rust's `dirs::config_dir()` joined with `openpencil`: `~/Library/Application Support/openpencil` on a Mac, `$XDG_CONFIG_HOME` or `~/.config` on Linux, `%APPDATA%` on Windows (`openPencil` in [`openpencil.go`](../../internal/agent/openpencil.go); its `settings_io.rs` and `settings_payload.rs`). magpie adds one entry to `builtin_agents`, `id: magpie`, `kind: openai-compat` at the gateway's `/v1` with a key naming OpenPencil (its User-Agent isn't known), `preset: custom`, the picked models as OpenPencil writes a list: the first as `model`, `models` only for two or more, at most 64 (v0.8.4 reads `model` alone). The user's other entries and settings stay, and so do the `display_name` and `enabled` they give magpie's entry; a sync with nothing to change doesn't write. OpenPencil needs `"version": 1` (a file without it is set aside as corrupt and saving stops), so magpie writes it in a file it makes and leaves a file with any other version, or none, alone. Disconnect takes the entry out, and the file when only the version and an empty list are left. OpenPencil reads the file once at start and writes it back whole when it quits, so a change is refused while `openpencil-desktop` runs (Windows can't be asked, so the notice says to quit it first). The model is picked in OpenPencil's chat, so the field is whether magpie is in its picker (`ListsModels`). Detected by its settings folder, `~/.openpencil` (its CLI's), `OpenPencil.app` (`com.zseven-w.openpencil`), or `%ProgramFiles%\OpenPencil`. open-pencil/open-pencil, the other app of the name, keeps its providers in its webview's localStorage, so it is not a row: it reaches magpie through Pi or an ACP agent magpie wires.- DevEco Code (Huawei's OpenCode fork, #1885) is wired as OpenCode is (`deveco` in [`agents.go`](../../internal/agent/agents.go)): magpie's provider goes into the first of `deveco.jsonc`, `deveco.json` and `config.json` in `~/.config/deveco` (the one DevEco merges last, so the one that wins), or in `$DEVECO_CONFIG_DIR` when that is absolute, read after them. 0.2.3 sends `deveco/0.2.3 ai-sdk/…` to a provider of its config, but much of the OpenCode code it keeps still sends OpenCode's own User-Agent (`opencode/<version>`), so its provider's key is `magpie-deveco` (`openCodeKeyAt`), not the plain `magpie` OpenCode and MiMo Code send, and Check asks for that key. Its npm package has no Linux binary, so no install command is offered there (`cliSpec.only`).- Grok App (RongleCat/grok-app, a desktop front end that starts Grok Build over ACP) keeps its provider channels in `agent-home/config.toml` under its data folder: `$GROK_APP_HOME`, else where its `directories` crate puts it, or its `~/.grok-app` fallback when that is the one there (`grokApp` in [`grokapp.go`](../../internal/agent/grokapp.go)). Its composer lists only Grok Build's official catalog, never the `[model."magpie/…"]` tables of Grok Build's row, so magpie adds itself as a channel, `[model.magpie]`, with the keys the App's Providers page writes: the gateway's `/v1`, a key naming Grok App, `api_backend = "chat_completions"`, `app_provider_mode = "generic"`, and `app_models`, a JSON list of magpie's models with `contextWindow`, `supportsVision` and their effort levels (no `none`; a default the user marks in the App stays, else medium). The picked model's `context_window` (a bare integer) and `supports_reasoning_effort` (a bare bool, Grok Build's gate for `--reasoning-effort`) are on the channel, as the App puts them there when a model is picked in its composer. `[models] default` is the route, and magpie does not set it: setting it to `"magpie"` makes the App drop its own sign-in (`ensure_independent_for_custom_route`). The route stays whatever the App had. Pressing Use on magpie under Accounts is what switches it. A magpie that already set the route puts the old one back once, on the next sync or connect (`grokAppReleased`); a Use after that stays. Disconnect drops only the channel, and puts the route back only when it is still `"magpie"`: the one stashed at connect, else the one `connect.was` holds. One of the App's own routes picked in magpie's model field is written as the route and takes magpie's channel out, as picking another provider does elsewhere. A sync with no channel and a route other than `"magpie"` writes nothing, magpie's stash included, and Check says so when the route is `"magpie"` with the channel gone. A model picked in the App's composer since is the user's and stays through a sync, and a sync with nothing to change doesn't write. Shared mode keeps `GROK_HOME` at `~/.grok` (Grok Build's library row). Independent mode, which Use turns on, reads agent-home: the Library writes `AGENTS.md`, `[mcp_servers]` in the same `config.toml`, and `skills/` there, and Grok App also reads `~/.agents/skills`. RTK has no Grok hook, so the Library lists Grok App with the switch off. The notice, while the App runs, says magpie is a custom provider in Settings › Account, a chat can pick its models in the model picker, and the App stays on its current route until Use.diff --git a/internal/agent/applied.go b/internal/agent/applied.goindex 23fdc0ce2..feffc2701 100644--- a/internal/agent/applied.go+++ b/internal/agent/applied.go@@ -736,6 +736,8 @@ func (a *Agent) Disconnect() error {// by itself (a start's Sync, Codex's account failover) puts magpie back// in, this Disconnect's own writes included (paynezhuang on Discord)stash(map[string]string{a.ID + disconnectedKey: "1"})+ // the user's own say over a harness Kiro Crew's connect put on+ kiroCrewUserLeft(a.ID)before, rec := a.Values(), appliedOf(a.ID)if a.Unwire != nil {if err := a.Unwire(); err != nil {diff --git a/internal/agent/kirocrew.go b/internal/agent/kirocrew.goindex f231f2827..b311677e3 100644--- a/internal/agent/kirocrew.go+++ b/internal/agent/kirocrew.go@@ -33,10 +33,17 @@ package agent// (agent_sdk/backend_install.py); magpie looks for it where Crew does and// says how to install it when it isn't there, and installs nothing.//-// Connecting picks the first harness connected to magpie (Codex, Claude-// Code, OpenCode, Pi, Goose), one whose adapter is here first, and keeps-// what the two keys said before, which Disconnect puts back. A harness set-// in config.local.json is the user's: magpie writes none over it.+// Connecting keeps the harness Kiro Crew is set to when it is one of+// these, and connects that agent to magpie too when it isn't yet (Crew's+// first run picks one, Claude Code on a Windows without kiro-cli: wuping9525+// on Discord had to connect it by hand first). Disconnect takes that agent+// off magpie again only when this connect is what put it on, and the user+// hasn't disconnected it since. On a harness magpie doesn't wire (KAS,+// kiro-cli, deepseek) it picks the first harness connected to magpie+// (Codex, Claude Code, OpenCode, Pi, Goose), one whose adapter is here+// first. It keeps what the two keys said before, which Disconnect puts+// back. A harness set in config.local.json is the user's: magpie writes+// none over it.import ("encoding/json"@@ -50,6 +57,10 @@ import ("github.com/yetone/magpie/internal/edit")+// kiroCrewOS is the system Kiro Crew's files are looked for as; a var so+// a test on a Mac can say Windows.+var kiroCrewOS = runtime.GOOS+// kiroCrewApp is Kiro Crew's macOS bundle.var kiroCrewApp = desktopApp{id: "com.amazon.kiro.crew", names: []string{"KiroCrew.app", "Kiro Crew.app"}}@@ -90,12 +101,16 @@ const (// magpie wrote (there while magpie has set the harness)kiroCrewWasKey = "kirocrew.was"kiroCrewWroteKey = "kirocrew.wrote"+ // the harness agent magpie connected along with Kiro Crew, for+ // Disconnect to take off again (kiroCrewJoin)+ kiroCrewJoinedKey = "kirocrew.joined")var (noticeKiroCrew = newNotice("Kiro Crew takes the new harness for new sessions; sessions already open keep theirs.")noticeKiroCrewAdapter = newNotice("Kiro Crew runs {harness} through {adapter}, which magpie didn't find here: install it with {install}, then start a new session.")noticeKiroCrewPinned = newNotice("Kiro Crew's config.local.json sets its harness (agent.acp_backend), and that wins over config.json, so magpie leaves it alone: set it there to a harness connected to magpie.")+ noticeKiroCrewJoined = newNotice("Kiro Crew runs on {harness}, so magpie connected {harness} too; turning Kiro Crew off disconnects it again."))// the provider's note: how magpie is its provider, or that its harness is@@ -111,26 +126,89 @@ var (errKiroCrewHarness = errors.New("that harness isn't connected to magpie: connect it first"))-// kiroCrewWired says whether the magpie agent id is connected to magpie;-// a var so tests can say.-var kiroCrewWired = func(id string) bool {+// kiroCrewAgent is the magpie agent of a harness, nil for none.+func kiroCrewAgent(id string) *Agent {home, cfg := homes()- var a *Agentswitch id {case "codex":- a = codex(home)+ return codex(home)case "claude":- a = claude(home)+ return claude(home)case "opencode":- a = opencode(home, cfg)+ return opencode(home, cfg)case "pi":- a = pi(home)+ return pi(home)case "goose":- a = goose(home, cfg)- default:- return false+ return goose(home, cfg)+ }+ return nil+}++// kiroCrewWired says whether the magpie agent id is connected to magpie;+// a var so tests can say.+var kiroCrewWired = func(id string) bool {+ a := kiroCrewAgent(id)+ return a != nil && a.Wired()+}++// kiroCrewJoined is the harness agent magpie connected along with Kiro+// Crew, and whether the user had disconnected it before that.+type kiroCrewJoined struct {+ Agent string `json:"agent"`+ Off bool `json:"off,omitempty"`+}++func kiroCrewJoinedNow() (kiroCrewJoined, bool) {+ var j kiroCrewJoined+ s := stashLoad()[kiroCrewJoinedKey]+ return j, s != "" && json.Unmarshal([]byte(s), &j) == nil && j.Agent != ""+}++// kiroCrewJoin connects the harness agent id to magpie for Kiro Crew, and+// says whether it could: false, with no error, for one not installed here.+var kiroCrewJoin = func(id string) (bool, error) {+ a := kiroCrewAgent(id)+ if a == nil || !a.Detected() {+ return false, nil+ }+ off := a.Disconnected()+ if _, err := a.ConnectHow(); err != nil {+ return false, err+ }+ b, _ := json.Marshal(kiroCrewJoined{Agent: id, Off: off})+ stash(map[string]string{kiroCrewJoinedKey: string(b)})+ return true, nil+}++// kiroCrewLeave takes the harness agent magpie connected along with Kiro+// Crew off magpie again, the user's own disconnect of it, from before,+// kept as it was.+var kiroCrewLeave = func() error {+ j, ok := kiroCrewJoinedNow()+ forget(kiroCrewJoinedKey)+ if !ok {+ return nil+ }+ a := kiroCrewAgent(j.Agent)+ if a == nil || !a.Wired() {+ return nil+ }+ if err := a.Disconnect(); err != nil {+ return err+ }+ if !j.Off {+ forget(a.ID + disconnectedKey)+ }+ return nil+}++// kiroCrewUserLeft forgets that magpie connected the agent id along with+// Kiro Crew once the user disconnects it themselves: connected again+// after, it is theirs, and Kiro Crew's Disconnect leaves it on.+func kiroCrewUserLeft(id string) {+ if j, ok := kiroCrewJoinedNow(); ok && j.Agent == id {+ forget(kiroCrewJoinedKey)}- return a.Wired()}// kiroCrewHasAdapter says whether Crew would find harness h's adapter; a@@ -173,7 +251,7 @@ func kiroCrewFinds(h kiroCrewHarness, home string, getenv func(string) string) bfilepath.Join(mise, "shims"),filepath.Join(home, ".volta", "bin"),}- if runtime.GOOS != "windows" {+ if kiroCrewOS != "windows" {dirs = append(dirs, "/opt/homebrew/bin", "/usr/local/bin")}or := func(v, d string) string {@@ -192,9 +270,17 @@ func kiroCrewFinds(h kiroCrewHarness, home string, getenv func(string) string) bm, _ := filepath.Glob(g)dirs = append(dirs, m...)}+ // on Windows npm's shim is the name with .cmd, as Crew's shutil.which+ // finds it through PATHEXT+ names := []string{bin}+ if kiroCrewOS == "windows" {+ names = []string{bin + ".cmd", bin + ".exe", bin + ".bat", bin}+ }for _, d := range dirs {- if isFile(filepath.Join(d, bin)) {- return true+ for _, n := range names {+ if isFile(filepath.Join(d, n)) {+ return true+ }}}return false@@ -225,7 +311,7 @@ func kiroCrewUnsafe(p string) bool {if filepath.Dir(p) == p {return true}- if runtime.GOOS == "windows" {+ if kiroCrewOS == "windows" {return false}for _, d := range []string{"/usr", "/System", "/etc", "/private/etc"} {@@ -396,19 +482,34 @@ func kiroCrew(home string) *Agent {}}forget(kiroCrewWasKey, kiroCrewWroteKey)- return nil+ return kiroCrewLeave()}- pick := func() (kiroCrewHarness, error) {+ // pick is the harness to run: the one Kiro Crew is set to, when it is+ // one of magpie's, connected to magpie now if it isn't yet (joined);+ // else the first connected to magpie+ pick := func() (h kiroCrewHarness, joined bool, err error) {+ if h, ok := kiroCrewHarnessOf(backend()); ok {+ if kiroCrewWired(h.agent) {+ return h, false, nil+ }+ ok, err := kiroCrewJoin(h.agent)+ if err != nil {+ return h, false, err+ }+ if ok {+ return h, true, nil+ }+ }hs := connected()if len(hs) == 0 {- return kiroCrewHarness{}, errKiroCrewNoHarness+ return kiroCrewHarness{}, false, errKiroCrewNoHarness}for _, h := range hs {if kiroCrewHasAdapter(h) {- return h, nil+ return h, false, nil}}- return hs[0], nil+ return hs[0], false, nil}return atomic(&Agent{ID: "kirocrew", Name: "Kiro Crew", Icon: "generic", Aliases: []string{"kiro-crew", "crew"},@@ -417,7 +518,8 @@ func kiroCrew(home string) *Agent {// ~/.kiro alone, which is Kiro's and kiro-cli'sdetect: func() bool {return isFile(path) || macBundle(kiroCrewApp) || binAt("kirocrew") != "" ||- isFile(filepath.Join(home, ".kirocrew-app", ".venv", "bin", "kirocrew"))+ isFile(filepath.Join(home, ".kirocrew-app", ".venv", "bin", "kirocrew")) ||+ kiroCrewOS == "windows" && isFile(filepath.Join(home, ".kirocrew-app", ".venv", "Scripts", "kirocrew.exe"))},Notice: func() string {id := on()@@ -428,6 +530,11 @@ func kiroCrew(home string) *Agent {return ""}notes := []string{noticeKiroCrew.String()}+ if j, ok := kiroCrewJoinedNow(); ok {+ if h, ok := kiroCrewHarnessOf(id); ok && h.agent == j.Agent {+ notes = append(notes, noticeKiroCrewJoined.say("harness", h.name))+ }+ }if h, _ := kiroCrewHarnessOf(id); h.adapter != "" && !kiroCrewHasAdapter(h) {notes = append(notes, noticeKiroCrewAdapter.say("harness", h.name, "adapter", h.adapter, "install", "npm i -g "+h.npm))}@@ -452,11 +559,17 @@ func kiroCrew(home string) *Agent {if id := on(); id != "" {return nil}- h, err := pick()+ h, joined, err := pick()if err != nil {return err}- return write(h)+ if err := write(h); err != nil {+ if joined {+ kiroCrewLeave()+ }+ return err+ }+ return nil},Options: func(map[string]string) []Option {note := kiroCrewNotediff --git a/internal/agent/kirocrew_test.go b/internal/agent/kirocrew_test.goindex 31a857c88..d9b96f585 100644--- a/internal/agent/kirocrew_test.go+++ b/internal/agent/kirocrew_test.go@@ -36,9 +36,11 @@ func kiroCrewSandbox(t *testing.T, wired []string, found []string) (home string,if err := provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k", Models: []string{"pro", "flash"}}); err != nil {t.Fatal(err)}- w, h := kiroCrewWired, kiroCrewHasAdapter- t.Cleanup(func() { kiroCrewWired, kiroCrewHasAdapter = w, h })+ w, h, j := kiroCrewWired, kiroCrewHasAdapter, kiroCrewJoin+ t.Cleanup(func() { kiroCrewWired, kiroCrewHasAdapter, kiroCrewJoin = w, h, j })kiroCrewWired = func(id string) bool { return slices.Contains(wired, id) }+ // none of the harnesses is installed here, so none is connected along+ kiroCrewJoin = func(string) (bool, error) { return false, nil }kiroCrewHasAdapter = func(h kiroCrewHarness) bool { return slices.Contains(found, h.id) }a = kiroCrew(home)if err := os.MkdirAll(a.Dir, 0o700); err != nil {@@ -487,6 +489,201 @@ func TestKiroCrewOnRealCodexWiring(t *testing.T) {}}+// kiroCrewOnClaude is a sandbox HOME with Claude Code installed but not+// connected to magpie, nothing else, and Kiro Crew's config.json set to+// run on Claude Code, as wuping9525's Windows had it.+func kiroCrewOnClaude(t *testing.T) (a, cc *Agent, before []byte) {+ t.Helper()+ home := syncHome(t)+ t.Setenv("KIROCREW_HOME", "")+ t.Setenv("PATH", t.TempDir())+ if err := provider.Save(provider.Provider{ID: "deepseek", Name: "DeepSeek", Chat: "https://api.deepseek.com/v1", Key: "k", Models: []string{"pro", "flash"}}); err != nil {+ t.Fatal(err)+ }+ h := kiroCrewHasAdapter+ t.Cleanup(func() { kiroCrewHasAdapter = h })+ kiroCrewHasAdapter = func(kiroCrewHarness) bool { return true }+ cc = claude(home)+ if err := os.MkdirAll(cc.Dir, 0o755); err != nil {+ t.Fatal(err)+ }+ os.WriteFile(cc.Path, []byte("{\"theme\": \"dark\"}\n"), 0o600)+ if !cc.Detected() || cc.Wired() {+ t.Fatalf("Claude Code detected %v, wired %v", cc.Detected(), cc.Wired())+ }+ a = kiroCrew(home)+ os.MkdirAll(a.Dir, 0o700)+ before = []byte(strings.Replace(kiroCrewUser, `"default_agent": "kirocrew",`, `"acp_backend": "claude",+ "default_agent": "kirocrew",`, 1))+ if err := os.WriteFile(a.Path, before, 0o600); err != nil {+ t.Fatal(err)+ }+ return a, cc, before+}++// wuping9525: Kiro Crew set to Claude Code, Claude Code installed and not+// connected to magpie. Connecting Kiro Crew connects Claude Code too, in+// the one step, and runs Crew on it; Disconnect takes both off again and+// leaves the files as they were.+func TestKiroCrewConnectsItsHarness(t *testing.T) {+ a, cc, before := kiroCrewOnClaude(t)+ ccBefore, _ := os.ReadFile(cc.Path)+ if _, err := a.ConnectHow(); err != nil {+ t.Fatalf("connect: %v", err)+ }+ if !cc.Wired() {+ t.Fatal("Claude Code not connected along with Kiro Crew")+ }+ if v := a.Values(); v["provider"] != magpieID || v["harness"] != "claude" {+ t.Errorf("values %v", v)+ }+ if n := a.Notice(); !strings.Contains(n, "magpie connected Claude Code too") {+ t.Errorf("notice %q", n)+ }+ if err := a.Disconnect(); err != nil {+ t.Fatal(err)+ }+ if cc.Wired() {+ t.Error("Claude Code still connected after Kiro Crew's Disconnect")+ }+ if cc.Disconnected() {+ t.Error("Claude Code recorded as the user's own disconnect")+ }+ if b, _ := os.ReadFile(a.Path); string(b) != string(before) {+ t.Errorf("config.json\n%s\nwant\n%s", b, before)+ }+ // as Claude Code's own Disconnect leaves it: the user's settings kept,+ // nothing of magpie's+ if b, _ := os.ReadFile(cc.Path); !strings.Contains(string(b), `"theme": "dark"`) || strings.Contains(string(b), "ANTHROPIC") || strings.Contains(string(b), "magpie") {+ t.Errorf("Claude Code's settings.json\n%s\nwas\n%s", b, ccBefore)+ }+ if _, ok := stashLoad()[kiroCrewJoinedKey]; ok {+ t.Error("joined mark left")+ }+}++// A harness the user connected before is theirs: Kiro Crew runs on it and+// its Disconnect leaves it on. So is one the user disconnected and+// connected again themselves after Kiro Crew's connect.+func TestKiroCrewLeavesTheUsersHarness(t *testing.T) {+ t.Run("connected before", func(t *testing.T) {+ a, cc, _ := kiroCrewOnClaude(t)+ if _, err := cc.ConnectHow(); err != nil {+ t.Fatal(err)+ }+ if _, err := a.ConnectHow(); err != nil {+ t.Fatal(err)+ }+ if strings.Contains(a.Notice(), "magpie connected") {+ t.Errorf("notice %q", a.Notice())+ }+ if err := a.Disconnect(); err != nil {+ t.Fatal(err)+ }+ if !cc.Wired() {+ t.Error("the user's Claude Code taken off")+ }+ })+ t.Run("taken back after", func(t *testing.T) {+ a, cc, _ := kiroCrewOnClaude(t)+ if _, err := a.ConnectHow(); err != nil {+ t.Fatal(err)+ }+ if err := cc.Disconnect(); err != nil {+ t.Fatal(err)+ }+ if _, err := cc.ConnectHow(); err != nil {+ t.Fatal(err)+ }+ if _, err := a.ConnectHow(); err != nil {+ t.Fatal(err)+ }+ if err := a.Disconnect(); err != nil {+ t.Fatal(err)+ }+ if !cc.Wired() {+ t.Error("Claude Code the user connected again taken off")+ }+ })+ t.Run("off before", func(t *testing.T) {+ // the user's disconnect from before stays theirs once Kiro Crew is off+ a, cc, _ := kiroCrewOnClaude(t)+ if _, err := cc.ConnectHow(); err != nil {+ t.Fatal(err)+ }+ if err := cc.Disconnect(); err != nil {+ t.Fatal(err)+ }+ if _, err := a.ConnectHow(); err != nil {+ t.Fatal(err)+ }+ if !cc.Wired() {+ t.Fatal("Claude Code not connected along with Kiro Crew")+ }+ if err := a.Disconnect(); err != nil {+ t.Fatal(err)+ }+ if cc.Wired() || !cc.Disconnected() {+ t.Errorf("Claude Code wired %v, the user's disconnect %v", cc.Wired(), cc.Disconnected())+ }+ })+}++// Set to a harness that isn't installed here, Kiro Crew runs on one that+// is connected, as before; with none, it still says to connect one.+func TestKiroCrewHarnessNotHere(t *testing.T) {+ a, cc, _ := kiroCrewOnClaude(t)+ os.RemoveAll(cc.Dir)+ if cc.Detected() {+ t.Skip("Claude Code found here anyway")+ }+ if _, err := a.ConnectHow(); !errors.Is(err, errKiroCrewNoHarness) {+ t.Fatalf("connect: %v", err)+ }+ if cc.Wired() {+ t.Error("Claude Code connected while not installed")+ }+}++// On Windows Kiro Crew's home is under the user's profile the same way,+// its app is found by its venv's kirocrew.exe, and an adapter npm put in+// as a .cmd shim is found where Crew's which finds it.+func TestKiroCrewOnWindows(t *testing.T) {+ was := kiroCrewOS+ t.Cleanup(func() { kiroCrewOS = was })+ kiroCrewOS = "windows"+ home := syncHome(t)+ t.Setenv("KIROCREW_HOME", "")+ t.Setenv("PATH", t.TempDir())+ env := map[string]string{"USERPROFILE": home, "APPDATA": filepath.Join(home, "AppData", "Roaming"), "LOCALAPPDATA": filepath.Join(home, "AppData", "Local")}+ getenv := func(k string) string { return env[k] }+ put := func(p string) {+ t.Helper()+ if err := mkFile(p); err != nil {+ t.Fatal(err)+ }+ }+ a := kiroCrew(home)+ if a.Path != filepath.Join(home, ".kiro", "crew", "config.json") {+ t.Errorf("path %s", a.Path)+ }+ if a.Detected() {+ t.Fatal("detected with nothing here")+ }+ put(filepath.Join(home, ".kirocrew-app", ".venv", "Scripts", "kirocrew.exe"))+ if !a.Detected() {+ t.Error("Kiro Crew's app not detected by its venv's kirocrew.exe")+ }+ cl, _ := kiroCrewHarnessOf("claude")+ if kiroCrewFinds(cl, home, getenv) {+ t.Fatal("found with none")+ }+ put(filepath.Join(home, ".npm-global", "bin", "claude-agent-acp.cmd"))+ if !kiroCrewFinds(cl, home, getenv) {+ t.Error("claude-agent-acp.cmd not found")+ }+}+// setJSONFile sets dotted keys in a JSON file, as a user's editor would.func setJSONFile(path string, kv map[string]any) error {b, err := os.ReadFile(path)@@ -516,3 +713,11 @@ func setJSONFile(path string, kv map[string]any) error {}return os.WriteFile(path, out, 0o600)}++// mkFile makes an empty file and its folders.+func mkFile(p string) error {+ if err := os.MkdirAll(filepath.Dir(p), 0o755); err != nil {+ return err+ }+ return os.WriteFile(p, nil, 0o755)+}diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.jsindex 8607e2043..3c6c34faf 100644--- a/internal/gui/assets/i18n.js+++ b/internal/gui/assets/i18n.js@@ -3779,6 +3779,7 @@ const I18N = {"DeepSeek Harness Desktop hasn't been opened yet: it starts on this the first time it opens.": "DeepSeek Harness 桌面版还没打开过:第一次打开时就会使用这项设置。","OpenChamber takes the new model for new sessions; sessions already open keep theirs.": "OpenChamber 的新会话会使用新模型;已打开的会话保留原来的模型。","Kiro Crew takes the new harness for new sessions; sessions already open keep theirs.": "Kiro Crew 的新会话会使用新的 harness;已打开的会话保留原来的。",+ "Kiro Crew runs on {harness}, so magpie connected {harness} too; turning Kiro Crew off disconnects it again.": "Kiro Crew 运行在 {harness} 上,所以 magpie 也一并接入了 {harness};关闭 Kiro Crew 时会把它一起断开。","Kiro Crew runs {harness} through {adapter}, which magpie didn't find here: install it with {install}, then start a new session.": "Kiro Crew 通过 {adapter} 运行 {harness},但 magpie 在这台电脑上没找到它:请用 {install} 安装,然后新开一个会话。","Kiro Crew's config.local.json sets its harness (agent.acp_backend), and that wins over config.json, so magpie leaves it alone: set it there to a harness connected to magpie.": "Kiro Crew 的 config.local.json 设置了它的 harness(agent.acp_backend),并且优先于 config.json,所以 magpie 不会改动它:请在那里把它设为一个已接入 magpie 的 harness。","Kiro Crew runs on a harness: connect Codex, Claude Code, OpenCode, Pi or Goose to magpie first, then connect Kiro Crew": "Kiro Crew 运行在一个 harness 上:请先把 Codex、Claude Code、OpenCode、Pi 或 Goose 接入 magpie,再接入 Kiro Crew",@@ -7737,6 +7738,7 @@ const I18N = {"DeepSeek Harness Desktop hasn't been opened yet: it starts on this the first time it opens.": "DeepSeek Harness 桌面版還沒開啟過:第一次開啟時就會使用這項設定。","OpenChamber takes the new model for new sessions; sessions already open keep theirs.": "OpenChamber 的新會話會使用新模型;已打開的會話保留原來的模型。","Kiro Crew takes the new harness for new sessions; sessions already open keep theirs.": "Kiro Crew 的新工作階段會使用新的 harness;已開啟的工作階段保留原本的。",+ "Kiro Crew runs on {harness}, so magpie connected {harness} too; turning Kiro Crew off disconnects it again.": "Kiro Crew 執行在 {harness} 上,所以 magpie 也一併接入了 {harness};關閉 Kiro Crew 時會把它一起中斷。","Kiro Crew runs {harness} through {adapter}, which magpie didn't find here: install it with {install}, then start a new session.": "Kiro Crew 透過 {adapter} 執行 {harness},但 magpie 在這台電腦上找不到它:請用 {install} 安裝,然後開一個新的工作階段。","Kiro Crew's config.local.json sets its harness (agent.acp_backend), and that wins over config.json, so magpie leaves it alone: set it there to a harness connected to magpie.": "Kiro Crew 的 config.local.json 設定了它的 harness(agent.acp_backend),且優先於 config.json,所以 magpie 不會更動它:請在那裡把它設為一個已接入 magpie 的 harness。","Kiro Crew runs on a harness: connect Codex, Claude Code, OpenCode, Pi or Goose to magpie first, then connect Kiro Crew": "Kiro Crew 執行在一個 harness 上:請先把 Codex、Claude Code、OpenCode、Pi 或 Goose 接入 magpie,再接入 Kiro Crew",@@ -11697,6 +11699,7 @@ const I18N = {"DeepSeek Harness Desktop hasn't been opened yet: it starts on this the first time it opens.": "DeepSeek Harness デスクトップ版はまだ一度も開かれていません。初めて開いたときからこの設定で始まります。","OpenChamber takes the new model for new sessions; sessions already open keep theirs.": "OpenChamber は新しいセッションで新しいモデルを使います。開いているセッションは今のモデルのままです。","Kiro Crew takes the new harness for new sessions; sessions already open keep theirs.": "Kiro Crew は新しいセッションから新しいハーネスを使います。開いているセッションは元のままです。",+ "Kiro Crew runs on {harness}, so magpie connected {harness} too; turning Kiro Crew off disconnects it again.": "Kiro Crew は {harness} 上で動くため、magpie は {harness} も接続しました。Kiro Crew をオフにすると、こちらも切断します。","Kiro Crew runs {harness} through {adapter}, which magpie didn't find here: install it with {install}, then start a new session.": "Kiro Crew は {harness} を {adapter} 経由で動かしますが、magpie はこのマシンで見つけられませんでした:{install} でインストールしてから、新しいセッションを始めてください。","Kiro Crew's config.local.json sets its harness (agent.acp_backend), and that wins over config.json, so magpie leaves it alone: set it there to a harness connected to magpie.": "Kiro Crew の config.local.json がハーネス(agent.acp_backend)を設定しており、config.json より優先されるため、magpie は変更しません:そこで magpie に接続済みのハーネスに設定してください。","Kiro Crew runs on a harness: connect Codex, Claude Code, OpenCode, Pi or Goose to magpie first, then connect Kiro Crew": "Kiro Crew はハーネス上で動きます:先に Codex、Claude Code、OpenCode、Pi または Goose を magpie に接続してから、Kiro Crew を接続してください",@@ -15657,6 +15660,7 @@ const I18N = {"DeepSeek Harness Desktop hasn't been opened yet: it starts on this the first time it opens.": "DeepSeek Harness Desktop wurde noch nie geöffnet: Beim ersten Öffnen startet es mit dieser Einstellung.","OpenChamber takes the new model for new sessions; sessions already open keep theirs.": "OpenChamber nimmt das neue Modell für neue Sitzungen; bereits offene behalten ihres.","Kiro Crew takes the new harness for new sessions; sessions already open keep theirs.": "Kiro Crew nutzt den neuen Harness für neue Sitzungen; bereits offene Sitzungen behalten ihren.",+ "Kiro Crew runs on {harness}, so magpie connected {harness} too; turning Kiro Crew off disconnects it again.": "Kiro Crew läuft auf {harness}, daher hat magpie {harness} gleich mit verbunden; schaltest du Kiro Crew aus, wird es wieder getrennt.","Kiro Crew runs {harness} through {adapter}, which magpie didn't find here: install it with {install}, then start a new session.": "Kiro Crew startet {harness} über {adapter}, das magpie hier nicht gefunden hat: installiere es mit {install} und starte dann eine neue Sitzung.","Kiro Crew's config.local.json sets its harness (agent.acp_backend), and that wins over config.json, so magpie leaves it alone: set it there to a harness connected to magpie.": "Die config.local.json von Kiro Crew legt seinen Harness fest (agent.acp_backend) und hat Vorrang vor config.json, daher lässt magpie sie unverändert: Stelle dort einen mit magpie verbundenen Harness ein.","Kiro Crew runs on a harness: connect Codex, Claude Code, OpenCode, Pi or Goose to magpie first, then connect Kiro Crew": "Kiro Crew läuft auf einem Harness: Verbinde zuerst Codex, Claude Code, OpenCode, Pi oder Goose mit magpie, dann Kiro Crew",@@ -15897,6 +15901,7 @@ const NOTICES = ["DeepSeek Harness Desktop hasn't been opened yet: it starts on this the first time it opens.","OpenChamber takes the new model for new sessions; sessions already open keep theirs.","Kiro Crew takes the new harness for new sessions; sessions already open keep theirs.",+ "Kiro Crew runs on {harness}, so magpie connected {harness} too; turning Kiro Crew off disconnects it again.","Kiro Crew runs {harness} through {adapter}, which magpie didn't find here: install it with {install}, then start a new session.","Kiro Crew's config.local.json sets its harness (agent.acp_backend), and that wins over config.json, so magpie leaves it alone: set it there to a harness connected to magpie.","OpenChamber's project {project} has a default model of its own ({model}), which it uses there instead.",diff --git a/internal/gui/tests/agent-kiro-crew-lang.test.cjs b/internal/gui/tests/agent-kiro-crew-lang.test.cjsindex 06d6b4c4d..8001ae8fd 100644--- a/internal/gui/tests/agent-kiro-crew-lang.test.cjs+++ b/internal/gui/tests/agent-kiro-crew-lang.test.cjs@@ -3,7 +3,8 @@// magpie. Connecting it with none connected, or with its harness set in// its config.local.json, is refused, and the refusal reads in the// window's language; connected, the notice that new sessions take the new-// harness does too. In every language, in Chromium and WebKit, at a wide+// harness does too, and so does the one that magpie connected the harness+// Crew is set to along with it (wuping9525: Claude Code, not connected). In every language, in Chromium and WebKit, at a wide// and a narrow window. No backend: the API is faked.const assert = require("node:assert/strict");const fs = require("node:fs/promises");@@ -15,6 +16,8 @@ const assets = path.resolve(__dirname, "../assets");const NO_HARNESS = "Kiro Crew runs on a harness: connect Codex, Claude Code, OpenCode, Pi or Goose to magpie first, then connect Kiro Crew";const PINNED = "Kiro Crew's config.local.json sets its harness, and that wins over config.json: magpie leaves it alone. Change agent.acp_backend there, or take it out, then connect again";const NEW_SESSIONS = "Kiro Crew takes the new harness for new sessions; sessions already open keep theirs.";+const JOINED = "Kiro Crew runs on {harness}, so magpie connected {harness} too; turning Kiro Crew off disconnects it again.";+const CONNECTED = NEW_SESSIONS + " " + JOINED.replaceAll("{harness}", "Claude Code");const NOTE = "its harness, an agent connected to magpie, runs on magpie's models";const crew = (on) => ({id: "kirocrew", name: "Kiro Crew", icon: "generic", path: "/test/kiro/crew/config.json", wired: on,@@ -36,7 +39,7 @@ function server(lang, answers) {const a = answers.shift();if (a) return route.fulfill({ status: 400, json: { error: a } });on = true;- return route.fulfill({ json: { ...st(), connected: { how: "magpie" }, notice: NEW_SESSIONS } });+ return route.fulfill({ json: { ...st(), connected: { how: "magpie" }, notice: CONNECTED } });}if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });@@ -69,7 +72,7 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",const sw = page.locator('.row.agent[data-id="kirocrew"] .ag-conn');await sw.waitFor();// each word is said in this language, not English- const words = await page.evaluate((ws) => ws.map((w) => [w, t(w)]), [NO_HARNESS, PINNED, NEW_SESSIONS, NOTE, "harness"]);+ const words = await page.evaluate((ws) => ws.map((w) => [w, t(w)]), [NO_HARNESS, PINNED, NEW_SESSIONS, JOINED, NOTE, "harness"]);for (const [en, said] of words) if (lang !== "en" && en !== "harness" || lang === "de" && en === "harness") assert.notEqual(said, en, `${lang}: ${en}`);for (const refusal of [NO_HARNESS, PINNED]) {const want = await page.evaluate((w) => t(w), refusal);@@ -83,9 +86,10 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",await page.waitForFunction(() => document.querySelector('.row.agent[data-id="kirocrew"] .ag-conn')?.getAttribute("aria-checked") === "true", null, { timeout: 30000 });await page.waitForFunction(() => document.querySelector("#status")?.textContent.trim(), null, { timeout: 30000 });const said = (await page.locator("#status").textContent()).trim();- const want = await page.evaluate((n) => tNotice(n), NEW_SESSIONS);+ const want = await page.evaluate((n) => tNotice(n), CONNECTED);assert.ok(said.endsWith(want), said);- if (lang !== "en") assert.ok(!said.includes("sessions already open"), said);+ if (lang !== "en") assert.ok(!said.includes("sessions already open") && !said.includes("magpie connected"), said);+ assert.ok(said.includes("Claude Code") && !said.includes("{harness}"), said);const fits = await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth);assert.ok(fits, "the page runs past the window");});