Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

agent: Kiro Crew runs on a harness connected to magpie

yetoneb5d46acbed4e
diff --git a/README.md b/README.md
index 2a5c603f9..8f035cda0 100644
--- a/README.md
+++ b/README.md
@@ -76,7 +76,7 @@ magpie finds the subscriptions your agents are signed in to by reading their sig
<table>
<tr><td>
-Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · OpenPencil · Raycast · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · Ante · AstrBot
+Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · OpenPencil · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · Ante · AstrBot
</td></tr>
</table>
diff --git a/README.zh-CN.md b/README.zh-CN.md
index 17bce1c63..04a610977 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -76,7 +76,7 @@ magpie 通过读取智能体的登录信息(Claude Code 和 Codex 的文件、
<table>
<tr><td>
-Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · OpenPencil · Raycast · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · Ante · AstrBot
+Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Copilot (JetBrains) · Copilot CLI · Crush · DeepSeek Harness · Reasonix Studio · Command Code · fx · Devin · Hermes Agent · Mister Morph · Kimi Code · jcode · Qwen Code · Muse Code · Empryo · MiniMax Code · Droid · Cline · Qoder · Qoder CN · Grok Build · Grok App · ZCode · WorkBuddy · WorkBuddy AI · CodeBuddy Code · Pencil · OpenPencil · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · Ante · AstrBot
</td></tr>
</table>
diff --git a/docs/reference.md b/docs/reference.md
index ad7d47038..675a2b246 100644
--- a/docs/reference.md
+++ b/docs/reference.md
@@ -141,6 +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) |
| 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.md
index 7fb2e02b2..c35f3d36b 100644
--- a/docs/subsystems/agent-wiring.md
+++ b/docs/subsystems/agent-wiring.md
@@ -66,6 +66,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.
- 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.
@@ -133,6 +134,7 @@ go test -tags nogui ./internal/agent -run '^TestAnte'
go test -tags nogui ./internal/agent -run '^TestAstrBot'
go test -tags nogui ./internal/agent -run '^TestJcode'
go test -tags nogui ./internal/agent -run '^TestRaycast'
+go test -tags nogui ./internal/agent -run '^TestKiroCrew'
go test -tags nogui ./internal/agent -run '^TestOpenPencil'
go test -tags nogui ./internal/agent -run '^TestGrokApp'
go test -tags nogui ./internal/agent -run 'ClaudeScience'
diff --git a/internal/agent/agents.go b/internal/agent/agents.go
index 4a4d1e26a..64a6f165c 100644
--- a/internal/agent/agents.go
+++ b/internal/agent/agents.go
@@ -145,6 +145,7 @@ func builtins(home, cfg string) []*Agent {
pencil(home),
openPencil(home, cfg),
raycast(home),
+ kiroCrew(home),
t3code(home),
hanako(home),
atomcode(home),
diff --git a/internal/agent/kirocrew.go b/internal/agent/kirocrew.go
new file mode 100644
index 000000000..f231f2827
--- /dev/null
+++ b/internal/agent/kirocrew.go
@@ -0,0 +1,497 @@
+package agent
+
+// Kiro Crew (kirodotdev/KiroCrew, v0.9.0: the KiroCrew.app desktop app, the
+// kirocrew CLI, its web dashboard and the Gateway they share; Vincent on
+// Discord) is a persistent agent that runs each session on a harness: an
+// ACP agent it starts and talks to. It has no model provider of its own
+// to point at magpie; its models are its harness's. So what magpie sets is
+// which harness it runs: one already connected to magpie, whose own config
+// then sends its requests to the gateway.
+//
+// Its settings are one JSON file in its home, $KIROCREW_HOME (made
+// absolute; a root, /usr, /System or /etc is refused and the default used)
+// or ~/.kiro/crew, the desktop app's too (config/paths.py config_dir,
+// _valid_override_home). config.local.json beside it is merged over it
+// key by key and wins (config/loader.py). The keys (config/sections.py):
+//
+// {"agent": {"acp_backend": "codex", // "" is kiro-cli, the default
+// "member_acp_backend": "codex"}} // crew members', default "kas"
+//
+// acp_backend is one of "", kas, claude, codex, opencode, pi, goose and
+// deepseek; member_acp_backend one that can dispatch (claude, kas, codex,
+// opencode, goose: ACP_BACKENDS_MEMBER_DISPATCH in agent_sdk/backends.py).
+// The Gateway reloads the files when they change; a session already open
+// keeps its harness.
+//
+// The harnesses magpie offers are those it wires itself, through the files
+// the harness reads under Crew too: Codex (codex-acp reads ~/.codex, or
+// CODEX_HOME), Claude Code (claude-agent-acp runs the user's claude, which
+// reads ~/.claude), OpenCode (opencode acp), Pi (pi-acp runs pi) and Goose
+// (goose acp). Not deepseek: Crew runs it as dsh --profile acp, a profile
+// of its own that magpie's dsh wiring doesn't reach. Codex, Claude Code
+// and Pi are reached through an npm adapter Crew doesn't ship
+// (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.
+
+import (
+ "encoding/json"
+ "errors"
+ "os"
+ "path/filepath"
+ "runtime"
+ "strings"
+
+ "github.com/yetone/magpie/internal/appdir"
+ "github.com/yetone/magpie/internal/edit"
+)
+
+// kiroCrewApp is Kiro Crew's macOS bundle.
+var kiroCrewApp = desktopApp{id: "com.amazon.kiro.crew", names: []string{"KiroCrew.app", "Kiro Crew.app"}}
+
+// kiroCrewHarness is one harness magpie can set: Crew's backend id, the
+// magpie agent that is it, and the adapter Crew runs it through, with the
+// variable that names the adapter's path and the npm package it comes in
+// ("" for one that is the agent's own binary).
+type kiroCrewHarness struct {
+ id, agent, name, icon string
+ adapter, env string
+ npm string
+ dispatch bool // can run crew members (member_acp_backend)
+}
+
+// kiroCrewHarnesses are the harnesses magpie offers, in the order it picks
+// one by itself.
+var kiroCrewHarnesses = []kiroCrewHarness{
+ {id: "codex", agent: "codex", name: "Codex", icon: "codex-color", adapter: "codex-acp", env: "CODEX_ACP_BIN", npm: "@agentclientprotocol/codex-acp", dispatch: true},
+ {id: "claude", agent: "claude", name: "Claude Code", icon: "claudecode-color", adapter: "claude-agent-acp", env: "CLAUDE_AGENT_ACP_BIN", npm: "@agentclientprotocol/claude-agent-acp", dispatch: true},
+ {id: "opencode", agent: "opencode", name: "OpenCode", icon: "opencode", dispatch: true},
+ {id: "pi", agent: "pi", name: "Pi", icon: "pi", adapter: "pi-acp", env: "PI_ACP_BIN", npm: "pi-acp"},
+ {id: "goose", agent: "goose", name: "Goose", icon: "goose", dispatch: true},
+}
+
+func kiroCrewHarnessOf(id string) (kiroCrewHarness, bool) {
+ for _, h := range kiroCrewHarnesses {
+ if h.id == id {
+ return h, true
+ }
+ }
+ return kiroCrewHarness{}, false
+}
+
+const (
+ kiroCrewBackend = "agent.acp_backend"
+ kiroCrewMember = "agent.member_acp_backend"
+ // the stash: what the two keys said before magpie set them, and what
+ // magpie wrote (there while magpie has set the harness)
+ kiroCrewWasKey = "kirocrew.was"
+ kiroCrewWroteKey = "kirocrew.wrote"
+)
+
+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.")
+)
+
+// the provider's note: how magpie is its provider, or that its harness is
+// the user's in config.local.json
+const (
+ kiroCrewNote = "its harness, an agent connected to magpie, runs on magpie's models"
+ kiroCrewPinnedNote = "its harness is set in config.local.json, which magpie leaves alone"
+)
+
+var (
+ errKiroCrewNoHarness = errors.New("Kiro Crew runs on a harness: connect Codex, Claude Code, OpenCode, Pi or Goose to magpie first, then connect Kiro Crew")
+ errKiroCrewPinned = errors.New("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")
+ 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 {
+ home, cfg := homes()
+ var a *Agent
+ switch id {
+ case "codex":
+ a = codex(home)
+ case "claude":
+ a = claude(home)
+ case "opencode":
+ a = opencode(home, cfg)
+ case "pi":
+ a = pi(home)
+ case "goose":
+ a = goose(home, cfg)
+ default:
+ return false
+ }
+ return a.Wired()
+}
+
+// kiroCrewHasAdapter says whether Crew would find harness h's adapter; a
+// var so tests can say.
+var kiroCrewHasAdapter = func(h kiroCrewHarness) bool {
+ home, _ := os.UserHomeDir()
+ return kiroCrewFinds(h, home, appdir.Getenv)
+}
+
+// kiroCrewFinds looks for h's adapter where Crew looks for it
+// (acp/launch.py, env.py augmented_path): the path its variable names,
+// magpie's PATH, the folders Crew adds to its own (~/.local/bin, npm's,
+// mise's shims, Volta's, Homebrew's), and every node version mise, asdf,
+// nvm and fnm keep. A harness with no adapter is its own binary.
+func kiroCrewFinds(h kiroCrewHarness, home string, getenv func(string) string) bool {
+ bin := h.adapter
+ if bin == "" {
+ bin = h.agent
+ }
+ if h.env != "" {
+ if p := getenv(h.env); p != "" && isFile(p) {
+ return true
+ }
+ }
+ if binAt(bin) != "" {
+ return true
+ }
+ mise := getenv("MISE_DATA_DIR")
+ if mise == "" {
+ if x := getenv("XDG_DATA_HOME"); x != "" {
+ mise = filepath.Join(x, "mise")
+ } else {
+ mise = filepath.Join(home, ".local", "share", "mise")
+ }
+ }
+ dirs := []string{
+ filepath.Join(home, ".local", "bin"),
+ filepath.Join(home, ".npm-packages", "bin"),
+ filepath.Join(home, ".npm-global", "bin"),
+ filepath.Join(mise, "shims"),
+ filepath.Join(home, ".volta", "bin"),
+ }
+ if runtime.GOOS != "windows" {
+ dirs = append(dirs, "/opt/homebrew/bin", "/usr/local/bin")
+ }
+ or := func(v, d string) string {
+ if p := getenv(v); p != "" {
+ return p
+ }
+ return d
+ }
+ for _, g := range []string{
+ filepath.Join(mise, "installs", "node", "*", "bin"),
+ filepath.Join(home, ".asdf", "installs", "nodejs", "*", "bin"),
+ filepath.Join(or("NVM_DIR", filepath.Join(home, ".nvm")), "versions", "node", "*", "bin"),
+ filepath.Join(or("FNM_DIR", filepath.Join(home, ".local", "share", "fnm")), "node-versions", "*", "installation", "bin"),
+ filepath.Join(home, "Library", "Application Support", "fnm", "node-versions", "*", "installation", "bin"),
+ } {
+ m, _ := filepath.Glob(g)
+ dirs = append(dirs, m...)
+ }
+ for _, d := range dirs {
+ if isFile(filepath.Join(d, bin)) {
+ return true
+ }
+ }
+ return false
+}
+
+// kiroCrewHome is Kiro Crew's home, as config_dir finds it.
+func kiroCrewHome(home string, getenv func(string) string) string {
+ if o := getenv("KIROCREW_HOME"); o != "" {
+ if strings.HasPrefix(o, "~") && (len(o) == 1 || o[1] == '/' || o[1] == filepath.Separator) {
+ o = filepath.Join(home, o[1:])
+ }
+ if p, err := filepath.Abs(o); err == nil {
+ if r, err := filepath.EvalSymlinks(p); err == nil {
+ p = r
+ }
+ if !kiroCrewUnsafe(p) {
+ return p
+ }
+ }
+ }
+ return filepath.Join(home, ".kiro", "crew")
+}
+
+// kiroCrewUnsafe is a home Kiro Crew refuses (_is_unsafe_home): a root, or
+// a folder in /usr, /System or /etc (/private/etc, as a Mac resolves it).
+func kiroCrewUnsafe(p string) bool {
+ p = filepath.Clean(p)
+ if filepath.Dir(p) == p {
+ return true
+ }
+ if runtime.GOOS == "windows" {
+ return false
+ }
+ for _, d := range []string{"/usr", "/System", "/etc", "/private/etc"} {
+ if p == d || strings.HasPrefix(p, d+"/") {
+ return true
+ }
+ }
+ return false
+}
+
+// kiroCrewWas is what a key said before magpie set it: whether it was
+// there, and its JSON as written.
+type kiroCrewWas struct {
+ Set bool `json:"set"`
+ Raw json.RawMessage `json:"raw,omitempty"`
+}
+
+type kiroCrewStash struct {
+ Backend kiroCrewWas `json:"backend"`
+ Member kiroCrewWas `json:"member"`
+ Made bool `json:"made,omitempty"` // magpie made config.json
+}
+
+// kiroCrewWrote is what magpie last wrote in the two keys ("" for a key it
+// left alone).
+type kiroCrewWrote struct {
+ Backend string `json:"backend"`
+ Member string `json:"member,omitempty"`
+}
+
+func kiroCrewWroteNow() (kiroCrewWrote, bool) {
+ var w kiroCrewWrote
+ s := stashLoad()[kiroCrewWroteKey]
+ return w, s != "" && json.Unmarshal([]byte(s), &w) == nil && w.Backend != ""
+}
+
+func kiroCrewWasOf(path, key string) kiroCrewWas {
+ raw, ok := edit.GetJSONRaw(path, key)
+ if !ok {
+ return kiroCrewWas{}
+ }
+ return kiroCrewWas{Set: true, Raw: json.RawMessage(raw)}
+}
+
+func kiroCrew(home string) *Agent {
+ dir := kiroCrewHome(home, appdir.Getenv)
+ path := filepath.Join(dir, "config.json")
+ local := filepath.Join(dir, "config.local.json")
+ // the harness it runs: config.local.json's, else config.json's
+ backend := func() string {
+ if v, ok := edit.GetJSON(local, kiroCrewBackend); ok {
+ return v
+ }
+ v, _ := edit.GetJSON(path, kiroCrewBackend)
+ return v
+ }
+ pinned := func() bool {
+ _, ok := edit.GetJSON(local, kiroCrewBackend)
+ return ok
+ }
+ // connected: magpie set the harness, and the one it runs is connected
+ // to magpie
+ on := func() string {
+ if _, ok := kiroCrewWroteNow(); !ok {
+ return ""
+ }
+ h, ok := kiroCrewHarnessOf(backend())
+ if !ok || !kiroCrewWired(h.agent) {
+ return ""
+ }
+ return h.id
+ }
+ connected := func() []kiroCrewHarness {
+ var out []kiroCrewHarness
+ for _, h := range kiroCrewHarnesses {
+ if kiroCrewWired(h.agent) {
+ out = append(out, h)
+ }
+ }
+ return out
+ }
+ // write sets the harness to h, the keys' values before kept the first
+ // time
+ write := func(h kiroCrewHarness) error {
+ if pinned() {
+ return errKiroCrewPinned
+ }
+ cur, _ := edit.GetJSON(path, kiroCrewBackend)
+ w, had := kiroCrewWroteNow()
+ // a stash from a harness the user has since changed to one of their
+ // own is stale: what is there now is theirs
+ if had {
+ if _, ours := kiroCrewHarnessOf(cur); !ours {
+ had = false
+ }
+ }
+ if !had {
+ s := kiroCrewStash{Backend: kiroCrewWasOf(path, kiroCrewBackend), Member: kiroCrewWasOf(path, kiroCrewMember), Made: !isFile(path)}
+ b, _ := json.Marshal(s)
+ stash(map[string]string{kiroCrewWasKey: string(b)})
+ w = kiroCrewWrote{}
+ }
+ kvs := []edit.KV{{Path: kiroCrewBackend, Value: h.id}}
+ w.Backend = h.id
+ if h.dispatch {
+ kvs = append(kvs, edit.KV{Path: kiroCrewMember, Value: h.id})
+ w.Member = h.id
+ }
+ if err := os.MkdirAll(dir, 0o700); err != nil {
+ return err
+ }
+ if err := edit.SetJSON(path, kvs...); err != nil {
+ return err
+ }
+ b, _ := json.Marshal(w)
+ stash(map[string]string{kiroCrewWroteKey: string(b)})
+ return nil
+ }
+ // unwire puts back what the keys said before magpie set them, a key the
+ // user has changed since left as they set it
+ unwire := func() error {
+ w, ok := kiroCrewWroteNow()
+ if !ok {
+ return nil
+ }
+ var s kiroCrewStash
+ json.Unmarshal([]byte(stashLoad()[kiroCrewWasKey]), &s)
+ var set []edit.KV
+ var del []string
+ put := func(key string, was kiroCrewWas, ours bool) {
+ if !ours {
+ return
+ }
+ if was.Set {
+ set = append(set, edit.KV{Path: key, Value: was.Raw})
+ } else {
+ del = append(del, key)
+ }
+ }
+ cur, _ := edit.GetJSON(path, kiroCrewBackend)
+ _, ours := kiroCrewHarnessOf(cur)
+ put(kiroCrewBackend, s.Backend, ours)
+ if w.Member != "" {
+ m, _ := edit.GetJSON(path, kiroCrewMember)
+ put(kiroCrewMember, s.Member, m == w.Member)
+ }
+ if isFile(path) {
+ if len(set) > 0 {
+ if err := edit.SetJSON(path, set...); err != nil {
+ return err
+ }
+ }
+ if len(del) > 0 {
+ if err := edit.DelJSON(path, del...); err != nil {
+ return err
+ }
+ }
+ // a file magpie made that holds nothing else now
+ if s.Made {
+ if raw, ok := edit.GetJSONRaw(path, "agent"); ok && strings.TrimSpace(strings.Join(strings.Fields(raw), "")) == "{}" {
+ if err := edit.DelJSON(path, "agent"); err != nil {
+ return err
+ }
+ }
+ if b, err := edit.Read(path); err == nil && strings.Join(strings.Fields(string(b)), "") == "{}" {
+ os.Remove(path)
+ }
+ }
+ }
+ forget(kiroCrewWasKey, kiroCrewWroteKey)
+ return nil
+ }
+ pick := func() (kiroCrewHarness, error) {
+ hs := connected()
+ if len(hs) == 0 {
+ return kiroCrewHarness{}, errKiroCrewNoHarness
+ }
+ for _, h := range hs {
+ if kiroCrewHasAdapter(h) {
+ return h, nil
+ }
+ }
+ return hs[0], nil
+ }
+ return atomic(&Agent{
+ ID: "kirocrew", Name: "Kiro Crew", Icon: "generic", Aliases: []string{"kiro-crew", "crew"},
+ Dir: dir, Path: path,
+ // its app, its command, or its home with its settings in it; never
+ // ~/.kiro alone, which is Kiro's and kiro-cli's
+ detect: func() bool {
+ return isFile(path) || macBundle(kiroCrewApp) || binAt("kirocrew") != "" ||
+ isFile(filepath.Join(home, ".kirocrew-app", ".venv", "bin", "kirocrew"))
+ },
+ Notice: func() string {
+ id := on()
+ if id == "" {
+ if pinned() {
+ return noticeKiroCrewPinned.String()
+ }
+ return ""
+ }
+ notes := []string{noticeKiroCrew.String()}
+ 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))
+ }
+ return strings.Join(notes, " ")
+ },
+ Fields: []Field{{
+ Key: "provider", Label: "provider",
+ Get: func() string {
+ if on() != "" {
+ return magpieID
+ }
+ return ""
+ },
+ Set: func(v string) error {
+ if v == "" {
+ return unwire()
+ }
+ if pinned() {
+ return errKiroCrewPinned
+ }
+ // on a harness of magpie's already: it stays
+ if id := on(); id != "" {
+ return nil
+ }
+ h, err := pick()
+ if err != nil {
+ return err
+ }
+ return write(h)
+ },
+ Options: func(map[string]string) []Option {
+ note := kiroCrewNote
+ if pinned() && on() == "" {
+ note = kiroCrewPinnedNote
+ }
+ return []Option{{Value: magpieID, Label: "magpie", Icon: "magpie", Note: note}}
+ },
+ }, {
+ Key: "harness", Label: "harness", Quiet: true,
+ Get: on,
+ Set: func(v string) error {
+ if v == "" {
+ return unwire()
+ }
+ h, ok := kiroCrewHarnessOf(v)
+ if !ok || !kiroCrewWired(h.agent) {
+ return errKiroCrewHarness
+ }
+ if on() == v {
+ return nil
+ }
+ return write(h)
+ },
+ Options: func(map[string]string) []Option {
+ var out []Option
+ for _, h := range connected() {
+ o := Option{Value: h.id, Label: h.name, Icon: h.icon}
+ if h.adapter != "" && !kiroCrewHasAdapter(h) {
+ o.Note = "npm i -g " + h.npm
+ }
+ out = append(out, o)
+ }
+ return out
+ },
+ }},
+ }, path)
+}
diff --git a/internal/agent/kirocrew_test.go b/internal/agent/kirocrew_test.go
new file mode 100644
index 000000000..31a857c88
--- /dev/null
+++ b/internal/agent/kirocrew_test.go
@@ -0,0 +1,518 @@
+package agent
+
+import (
+ "encoding/json"
+ "errors"
+ "os"
+ "path/filepath"
+ "runtime"
+ "slices"
+ "strings"
+ "testing"
+
+ "github.com/yetone/magpie/internal/provider"
+)
+
+// kiroCrewUser is config.json as Kiro Crew's dashboard saves it: the
+// user's own settings beside the agent section, and the harness the user
+// chose for crew members.
+const kiroCrewUser = `{
+ "agent": {
+ "default_agent": "kirocrew",
+ "member_acp_backend": "kas",
+ "model": "auto"
+ },
+ "gateway": {"port": 5476},
+ "ui": {"theme": "dark"}
+}
+`
+
+// kiroCrewSandbox is a sandbox HOME with Kiro Crew's home in it, the
+// harnesses connected to magpie as wired says and the adapters as found.
+func kiroCrewSandbox(t *testing.T, wired []string, found []string) (home string, a *Agent) {
+ t.Helper()
+ home = syncHome(t)
+ t.Setenv("KIROCREW_HOME", "")
+ 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 })
+ kiroCrewWired = func(id string) bool { return slices.Contains(wired, id) }
+ kiroCrewHasAdapter = func(h kiroCrewHarness) bool { return slices.Contains(found, h.id) }
+ a = kiroCrew(home)
+ if err := os.MkdirAll(a.Dir, 0o700); err != nil {
+ t.Fatal(err)
+ }
+ return home, a
+}
+
+func kiroCrewKey(t *testing.T, path, key string) (any, bool) {
+ t.Helper()
+ b, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var m map[string]any
+ if err := json.Unmarshal(b, &m); err != nil {
+ t.Fatalf("%s: %v", b, err)
+ }
+ var cur any = m
+ for _, k := range strings.Split(key, ".") {
+ o, ok := cur.(map[string]any)
+ if !ok {
+ return nil, false
+ }
+ if cur, ok = o[k]; !ok {
+ return nil, false
+ }
+ }
+ return cur, true
+}
+
+// Connecting Kiro Crew runs it on Codex, connected to magpie, and its crew
+// members too; Disconnect puts back what the user had, byte for byte, and
+// every other setting stays.
+func TestKiroCrewConnect(t *testing.T) {
+ _, a := kiroCrewSandbox(t, []string{"codex", "claude"}, []string{"codex", "claude"})
+ if !slices.ContainsFunc(All(), func(x *Agent) bool { return x.ID == "kirocrew" && x.Name == "Kiro Crew" }) {
+ t.Fatal("Kiro Crew is not among the agents")
+ }
+ if a.Detected() {
+ t.Fatal("found with no settings, app or command")
+ }
+ os.WriteFile(a.Path, []byte(kiroCrewUser), 0o600)
+ if !a.Detected() {
+ t.Fatal("not found with its config.json")
+ }
+ if a.Wired() {
+ t.Fatal("wired before connecting")
+ }
+ c, err := a.ConnectHow()
+ if err != nil {
+ t.Fatal(err)
+ }
+ if c.How != "magpie" || !a.Wired() {
+ t.Fatalf("connect: %+v, wired %v", c, a.Wired())
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewBackend); v != "codex" {
+ t.Errorf("acp_backend %v", v)
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewMember); v != "codex" {
+ t.Errorf("member_acp_backend %v", v)
+ }
+ if v := a.Values(); v["provider"] != magpieID || v["harness"] != "codex" {
+ t.Errorf("values %v", v)
+ }
+ if n := a.Notice(); n != noticeKiroCrew.String() {
+ t.Errorf("notice %q", n)
+ }
+ for _, k := range []string{"agent.default_agent", "agent.model", "gateway.port", "ui.theme"} {
+ if _, ok := kiroCrewKey(t, a.Path, k); !ok {
+ t.Errorf("%s is gone", k)
+ }
+ }
+ // connecting again changes nothing
+ b1, _ := os.ReadFile(a.Path)
+ if err := a.Field("provider").Set(magpieID); err != nil {
+ t.Fatal(err)
+ }
+ if b2, _ := os.ReadFile(a.Path); string(b1) != string(b2) {
+ t.Errorf("set again rewrote it:\n%s", b2)
+ }
+
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if a.Wired() {
+ t.Fatal("wired after disconnecting")
+ }
+ var was, now map[string]any
+ json.Unmarshal([]byte(kiroCrewUser), &was)
+ b, _ := os.ReadFile(a.Path)
+ json.Unmarshal(b, &now)
+ if !sameJSON(string(b), was) {
+ t.Errorf("after disconnect:\n%s\nwant\n%s", b, kiroCrewUser)
+ }
+ if s := stashLoad(); s[kiroCrewWasKey] != "" || s[kiroCrewWroteKey] != "" {
+ t.Errorf("stash kept: %v", s)
+ }
+}
+
+// With no harness connected to magpie, connecting says to connect one and
+// writes nothing; the harness picked by itself is Codex, then Claude Code,
+// one whose adapter is here before one whose isn't, and a harness with no
+// adapter's install says how to install it.
+func TestKiroCrewPicksAHarness(t *testing.T) {
+ _, a := kiroCrewSandbox(t, nil, nil)
+ os.WriteFile(a.Path, []byte(kiroCrewUser), 0o600)
+ if _, err := a.ConnectHow(); !errors.Is(err, errKiroCrewNoHarness) {
+ t.Fatalf("no harness: %v", err)
+ }
+ if b, _ := os.ReadFile(a.Path); string(b) != kiroCrewUser {
+ t.Errorf("written with no harness:\n%s", b)
+ }
+ if len(a.Field("harness").Options(nil)) != 0 {
+ t.Errorf("harnesses offered with none connected: %v", a.Field("harness").Options(nil))
+ }
+
+ for _, c := range []struct {
+ wired, found []string
+ want string
+ member any
+ notice string
+ }{
+ {wired: []string{"claude", "codex", "goose"}, found: []string{"claude", "codex"}, want: "codex", member: "codex"},
+ {wired: []string{"claude", "codex"}, found: []string{"claude"}, want: "claude", member: "claude"},
+ {wired: []string{"opencode", "pi"}, found: []string{"opencode", "pi"}, want: "opencode", member: "opencode"},
+ // Pi can't run crew members: theirs stays the user's
+ {wired: []string{"pi"}, found: []string{"pi"}, want: "pi", member: "kas"},
+ {wired: []string{"codex"}, want: "codex", member: "codex",
+ notice: "Kiro Crew runs Codex through codex-acp, which magpie didn't find here: install it with npm i -g @agentclientprotocol/codex-acp, then start a new session."},
+ // deepseek is no harness of magpie's
+ {wired: []string{"dsh", "deepseek"}},
+ } {
+ _, a := kiroCrewSandbox(t, c.wired, c.found)
+ os.WriteFile(a.Path, []byte(kiroCrewUser), 0o600)
+ _, err := a.ConnectHow()
+ if c.want == "" {
+ if !errors.Is(err, errKiroCrewNoHarness) {
+ t.Errorf("%v: %v", c.wired, err)
+ }
+ continue
+ }
+ if err != nil {
+ t.Fatalf("%v: %v", c.wired, err)
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewBackend); v != c.want {
+ t.Errorf("%v %v: picked %v, want %s", c.wired, c.found, v, c.want)
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewMember); v != c.member {
+ t.Errorf("%v: member %v, want %v", c.wired, v, c.member)
+ }
+ var opts []string
+ for _, o := range a.Field("harness").Options(nil) {
+ opts = append(opts, o.Value)
+ }
+ var want []string
+ for _, h := range kiroCrewHarnesses {
+ if slices.Contains(c.wired, h.id) {
+ want = append(want, h.id)
+ }
+ }
+ if !slices.Equal(opts, want) {
+ t.Errorf("%v: offered %v", c.wired, opts)
+ }
+ n := a.Notice()
+ if c.notice != "" && !strings.Contains(n, c.notice) || c.notice == "" && n != noticeKiroCrew.String() {
+ t.Errorf("%v: notice %q", c.wired, n)
+ }
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if b, _ := os.ReadFile(a.Path); !sameJSON(string(b), json.RawMessage(kiroCrewUser)) {
+ t.Errorf("%v: after disconnect:\n%s", c.wired, b)
+ }
+ }
+}
+
+// The harness picked on the row is written, its crew members' with it;
+// one not connected to magpie is refused. Disconnect after a pick puts
+// back the user's, and the pick comes back on connecting again.
+func TestKiroCrewHarnessPick(t *testing.T) {
+ _, a := kiroCrewSandbox(t, []string{"codex", "claude", "pi"}, []string{"codex", "claude", "pi"})
+ os.WriteFile(a.Path, []byte(`{"agent":{"acp_backend":"kas","member_acp_backend":"kas"}}`), 0o600)
+ if err := a.Pick("harness", "goose"); !errors.Is(err, errKiroCrewHarness) {
+ t.Errorf("goose, not connected: %v", err)
+ }
+ if err := a.Pick("harness", "deepseek"); !errors.Is(err, errKiroCrewHarness) {
+ t.Errorf("deepseek: %v", err)
+ }
+ if err := a.Pick("harness", "claude"); err != nil {
+ t.Fatal(err)
+ }
+ if v := a.Values(); v["provider"] != magpieID || v["harness"] != "claude" {
+ t.Fatalf("values %v", v)
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewMember); v != "claude" {
+ t.Errorf("member %v", v)
+ }
+ // Pi runs no crew members: theirs stays magpie's Claude Code
+ if err := a.Pick("harness", "pi"); err != nil {
+ t.Fatal(err)
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewBackend); v != "pi" {
+ t.Errorf("backend %v", v)
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewMember); v != "claude" {
+ t.Errorf("member %v", v)
+ }
+ if err := a.Pick("harness", "claude"); err != nil {
+ t.Fatal(err)
+ }
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ b, _ := os.ReadFile(a.Path)
+ if !sameJSON(string(b), json.RawMessage(`{"agent":{"acp_backend":"kas","member_acp_backend":"kas"}}`)) {
+ t.Errorf("after disconnect: %s", b)
+ }
+ if _, err := a.ConnectHow(); err != nil {
+ t.Fatal(err)
+ }
+ if v := a.Values()["harness"]; v != "claude" {
+ t.Errorf("reconnected on %q, not the harness picked before", v)
+ }
+}
+
+// A harness set in config.local.json wins over config.json, so magpie
+// writes none: connecting is refused and says so, nothing is written, and
+// the row's note and notice say why.
+func TestKiroCrewLocalPin(t *testing.T) {
+ _, a := kiroCrewSandbox(t, []string{"codex"}, []string{"codex"})
+ os.WriteFile(a.Path, []byte(kiroCrewUser), 0o600)
+ local := filepath.Join(a.Dir, "config.local.json")
+ os.WriteFile(local, []byte(`{"agent":{"acp_backend":""}}`), 0o600)
+ if _, err := a.ConnectHow(); !errors.Is(err, errKiroCrewPinned) {
+ t.Fatalf("pinned: %v", err)
+ }
+ if b, _ := os.ReadFile(a.Path); string(b) != kiroCrewUser {
+ t.Errorf("config.json written:\n%s", b)
+ }
+ if b, _ := os.ReadFile(local); string(b) != `{"agent":{"acp_backend":""}}` {
+ t.Errorf("config.local.json written: %s", b)
+ }
+ if a.Wired() {
+ t.Error("wired")
+ }
+ if n := a.Notice(); n != noticeKiroCrewPinned.String() {
+ t.Errorf("notice %q", n)
+ }
+ if o := a.Field("provider").Options(nil); o[0].Note != kiroCrewPinnedNote {
+ t.Errorf("note %q", o[0].Note)
+ }
+ // set there after magpie connected it: what Kiro Crew runs is the
+ // user's, and magpie isn't said to be its provider
+ os.Remove(local)
+ if _, err := a.ConnectHow(); err != nil {
+ t.Fatal(err)
+ }
+ os.WriteFile(local, []byte(`{"agent":{"acp_backend":"kas"}}`), 0o600)
+ if a.Wired() {
+ t.Error("wired with the local pin on kas")
+ }
+ // on a harness of magpie's: connected
+ os.WriteFile(local, []byte(`{"agent":{"acp_backend":"codex"}}`), 0o600)
+ if !a.Wired() {
+ t.Error("not wired with the local pin on Codex")
+ }
+}
+
+// A harness no longer connected to magpie leaves Kiro Crew not connected,
+// and a harness the user set in Kiro Crew since is kept by Disconnect.
+func TestKiroCrewFollowsItsHarness(t *testing.T) {
+ _, a := kiroCrewSandbox(t, []string{"codex"}, []string{"codex"})
+ os.WriteFile(a.Path, []byte(kiroCrewUser), 0o600)
+ if _, err := a.ConnectHow(); err != nil {
+ t.Fatal(err)
+ }
+ kiroCrewWired = func(string) bool { return false }
+ if a.Wired() {
+ t.Error("wired with Codex off magpie")
+ }
+ kiroCrewWired = func(id string) bool { return id == "codex" }
+ // the user moves it to kiro-cli and its members to Claude in Kiro Crew
+ if err := setJSONFile(a.Path, map[string]any{kiroCrewBackend: "", kiroCrewMember: "claude"}); err != nil {
+ t.Fatal(err)
+ }
+ if a.Wired() {
+ t.Error("wired on kiro-cli")
+ }
+ if err := a.Field("provider").Set(""); err != nil {
+ t.Fatal(err)
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewBackend); v != "" {
+ t.Errorf("backend %v, the user's \"\" written over", v)
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewMember); v != "claude" {
+ t.Errorf("member %v, the user's claude written over", v)
+ }
+}
+
+// config.json not there yet (the app installed, never started): magpie
+// makes it with the one key, and takes it out again on Disconnect.
+func TestKiroCrewMakesItsFile(t *testing.T) {
+ _, a := kiroCrewSandbox(t, []string{"opencode"}, []string{"opencode"})
+ if _, err := a.ConnectHow(); err != nil {
+ t.Fatal(err)
+ }
+ if v, _ := kiroCrewKey(t, a.Path, kiroCrewBackend); v != "opencode" {
+ t.Errorf("backend %v", v)
+ }
+ if err := a.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := os.Stat(a.Path); !os.IsNotExist(err) {
+ b, _ := os.ReadFile(a.Path)
+ t.Errorf("config.json magpie made is still there: %s", b)
+ }
+}
+
+// A config.json that isn't JSON is left alone.
+func TestKiroCrewLeavesBrokenAlone(t *testing.T) {
+ _, a := kiroCrewSandbox(t, []string{"codex"}, []string{"codex"})
+ bad := `{"agent": {"acp_backend": "kas",`
+ os.WriteFile(a.Path, []byte(bad), 0o600)
+ if _, err := a.ConnectHow(); err == nil {
+ t.Error("connected over a broken config.json")
+ }
+ if b, _ := os.ReadFile(a.Path); string(b) != bad {
+ t.Errorf("written: %s", b)
+ }
+}
+
+// Kiro Crew's home is KIROCREW_HOME, ~ and a relative path made absolute,
+// unless it is one Kiro Crew refuses; else ~/.kiro/crew.
+func TestKiroCrewHome(t *testing.T) {
+ home := t.TempDir()
+ env := func(v string) func(string) string {
+ return func(k string) string {
+ if k == "KIROCREW_HOME" {
+ return v
+ }
+ return ""
+ }
+ }
+ def := filepath.Join(home, ".kiro", "crew")
+ if got := kiroCrewHome(home, env("")); got != def {
+ t.Errorf("default %s", got)
+ }
+ own := filepath.Join(home, "crew-two")
+ os.MkdirAll(own, 0o700)
+ own, _ = filepath.EvalSymlinks(own)
+ if got := kiroCrewHome(home, env(own)); got != own {
+ t.Errorf("KIROCREW_HOME %s", got)
+ }
+ if got, want := kiroCrewHome(home, env("~/x")), filepath.Join(home, "x"); got != want {
+ t.Errorf("~/x: %s, want %s", got, want)
+ }
+ if runtime.GOOS != "windows" {
+ for _, bad := range []string{"/", "/usr/local/crew", "/etc", "/System/x"} {
+ if got := kiroCrewHome(home, env(bad)); got != def {
+ t.Errorf("%s: %s, want the default", bad, got)
+ }
+ }
+ }
+ t.Setenv("HOME", home)
+ t.Setenv("KIROCREW_HOME", own)
+ if a := kiroCrew(home); a.Path != filepath.Join(own, "config.json") {
+ t.Errorf("path %s", a.Path)
+ }
+}
+
+// The adapter is found where Kiro Crew looks: the variable naming it, a
+// Node version's bin, Crew's own folders; never one of another name.
+func TestKiroCrewFindsAdapters(t *testing.T) {
+ home := t.TempDir()
+ t.Setenv("PATH", t.TempDir())
+ codex, _ := kiroCrewHarnessOf("codex")
+ env := map[string]string{}
+ getenv := func(k string) string { return env[k] }
+ if kiroCrewFinds(codex, home, getenv) {
+ t.Fatal("found with none")
+ }
+ put := func(p string) {
+ os.MkdirAll(filepath.Dir(p), 0o755)
+ os.WriteFile(p, []byte("#!/bin/sh\n"), 0o755)
+ }
+ put(filepath.Join(home, ".nvm", "versions", "node", "v22.1.0", "bin", "claude-agent-acp"))
+ if kiroCrewFinds(codex, home, getenv) {
+ t.Error("codex-acp found as claude-agent-acp")
+ }
+ claude, _ := kiroCrewHarnessOf("claude")
+ if !kiroCrewFinds(claude, home, getenv) {
+ t.Error("claude-agent-acp under nvm not found")
+ }
+ put(filepath.Join(home, ".local", "share", "mise", "installs", "node", "24.0.0", "bin", "codex-acp"))
+ if !kiroCrewFinds(codex, home, getenv) {
+ t.Error("codex-acp under mise not found")
+ }
+ pi, _ := kiroCrewHarnessOf("pi")
+ env["PI_ACP_BIN"] = filepath.Join(home, "elsewhere", "pi-acp")
+ if kiroCrewFinds(pi, home, getenv) {
+ t.Error("PI_ACP_BIN found with no file there")
+ }
+ put(env["PI_ACP_BIN"])
+ if !kiroCrewFinds(pi, home, getenv) {
+ t.Error("PI_ACP_BIN not found")
+ }
+}
+
+// End to end, with magpie's own Codex wiring in the sandbox: Kiro Crew is
+// offered Codex only once Codex is connected to magpie.
+func TestKiroCrewOnRealCodexWiring(t *testing.T) {
+ home := syncHome(t)
+ t.Setenv("KIROCREW_HOME", "")
+ 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 }
+ a := kiroCrew(home)
+ os.MkdirAll(a.Dir, 0o700)
+ os.WriteFile(a.Path, []byte(kiroCrewUser), 0o600)
+ if _, err := a.ConnectHow(); !errors.Is(err, errKiroCrewNoHarness) {
+ t.Fatalf("before Codex: %v", err)
+ }
+ cx := codex(home)
+ os.MkdirAll(cx.Dir, 0o755)
+ if _, err := cx.ConnectHow(); err != nil {
+ t.Fatal(err)
+ }
+ if !cx.Wired() {
+ t.Fatal("Codex not wired")
+ }
+ if _, err := a.ConnectHow(); err != nil {
+ t.Fatal(err)
+ }
+ if v := a.Values(); v["provider"] != magpieID || v["harness"] != "codex" {
+ t.Errorf("values %v", v)
+ }
+ if err := cx.Disconnect(); err != nil {
+ t.Fatal(err)
+ }
+ if a.Wired() {
+ t.Error("Kiro Crew still connected with Codex off magpie")
+ }
+}
+
+// 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)
+ if err != nil {
+ return err
+ }
+ var m map[string]any
+ if err := json.Unmarshal(b, &m); err != nil {
+ return err
+ }
+ for k, v := range kv {
+ o := m
+ parts := strings.Split(k, ".")
+ for _, p := range parts[:len(parts)-1] {
+ n, ok := o[p].(map[string]any)
+ if !ok {
+ n = map[string]any{}
+ o[p] = n
+ }
+ o = n
+ }
+ o[parts[len(parts)-1]] = v
+ }
+ out, err := json.MarshalIndent(m, "", " ")
+ if err != nil {
+ return err
+ }
+ return os.WriteFile(path, out, 0o600)
+}
diff --git a/internal/agent/lists_models_test.go b/internal/agent/lists_models_test.go
index 4a298a8cc..b74558da5 100644
--- a/internal/agent/lists_models_test.go
+++ b/internal/agent/lists_models_test.go
@@ -49,6 +49,9 @@ func TestEveryPickerOfMagpiesModelsCanBeNarrowed(t *testing.T) {
// Claude Desktop's tier pickers list the catalog once it is
// connected (desktopTierFields), and the sandbox has no Desktop
case refs, a.ID == "claude-desktop":
+ // Kiro Crew's models are its harness's: the agent it runs (Codex,
+ // Claude Code…), whose own row narrows them
+ case a.ID == "kirocrew":
case a.ListsModels:
menus = append(menus, a.ID)
case magpie:
diff --git a/internal/agentenv/agentenv.go b/internal/agentenv/agentenv.go
index d32f1eb90..9048f1e7f 100644
--- a/internal/agentenv/agentenv.go
+++ b/internal/agentenv/agentenv.go
@@ -94,6 +94,9 @@ var Vars = []string{
"CURSOR_CONFIG_DIR", "CURSOR_DATA_DIR",
// OpenCode and OpenChamber
"OPENCODE_CONFIG_DIR", "OPENCODE_DB", "OPENCHAMBER_DATA_DIR",
+ // Kiro Crew's home, and the adapters it runs Codex, Claude Code and Pi
+ // through
+ "KIROCREW_HOME", "CODEX_ACP_BIN", "CLAUDE_AGENT_ACP_BIN", "PI_ACP_BIN",
// Droid's home, Windsurf's API server, ZCode's credential seed: what
// makes an account or an installation visible that the test didn't make
"FACTORY_HOME_OVERRIDE", "WINDSURF_API_SERVER_URL", "ZCODE_CREDENTIAL_SECRET",
diff --git a/internal/gui/assets/i18n.js b/internal/gui/assets/i18n.js
index 826a8d59a..14d0b66cc 100644
--- a/internal/gui/assets/i18n.js
+++ b/internal/gui/assets/i18n.js
@@ -3731,6 +3731,15 @@ const I18N = {
"New dsh sessions start on this. A session made before keeps its model, open now or reopened later, until you pick another in it with /model or the model button by its message box. A dsh started with -p or in a terminal reads it at start-up.": "新的 dsh 会话会使用这项设置。之前建的会话,无论现在开着还是以后再打开,都保留原来的模型,直到你在其中用 /model 或输入框旁的模型按钮另选一个。用 -p 或在终端里启动的 dsh 在启动时读取它。",
"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 {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",
+ "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": "Kiro Crew 的 config.local.json 设置了它的 harness,并且优先于 config.json:magpie 不会改动它。请在那里修改 agent.acp_backend 或删掉它,然后再接入",
+ "that harness isn't connected to magpie: connect it first": "这个 harness 还没有接入 magpie:请先接入它",
+ "its harness, an agent connected to magpie, runs on magpie's models": "它的 harness(一个已接入 magpie 的 agent)使用 magpie 的模型",
+ "its harness is set in config.local.json, which magpie leaves alone": "它的 harness 在 config.local.json 中设置,magpie 不会改动",
+ "harness": "harness",
"OpenChamber's project {project} has a default model of its own ({model}), which it uses there instead.": "OpenChamber 的项目 {project} 有自己的默认模型({model}),在该项目里会改用它。",
"OpenPencil reads its settings when it starts and writes them all back when it quits — quit OpenPencil before changing this, then open it and pick a magpie model in its chat's model picker.": "OpenPencil 启动时读取设置、退出时把设置全部写回 —— 请先退出 OpenPencil 再更改这里,然后打开它,在聊天的模型选择器中选一个 magpie 的模型。",
"Pencil reads its custom models at start-up — restart Pencil to see magpie's models in its model picker.": "Pencil 启动时读取自定义模型,需重启 Pencil 才能在它的模型选择器中看到 magpie 的模型。",
@@ -7633,6 +7642,15 @@ const I18N = {
"New dsh sessions start on this. A session made before keeps its model, open now or reopened later, until you pick another in it with /model or the model button by its message box. A dsh started with -p or in a terminal reads it at start-up.": "新的 dsh 會話會使用這項設定。之前建立的會話,無論現在開著還是以後再打開,都保留原來的模型,直到你在其中用 /model 或輸入框旁的模型按鈕另選一個。用 -p 或在終端裡啟動的 dsh 在啟動時讀取它。",
"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 {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",
+ "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": "Kiro Crew 的 config.local.json 設定了它的 harness,且優先於 config.json:magpie 不會更動它。請在那裡修改 agent.acp_backend 或刪除它,然後再接入",
+ "that harness isn't connected to magpie: connect it first": "這個 harness 還沒有接入 magpie:請先接入它",
+ "its harness, an agent connected to magpie, runs on magpie's models": "它的 harness(一個已接入 magpie 的 agent)使用 magpie 的模型",
+ "its harness is set in config.local.json, which magpie leaves alone": "它的 harness 在 config.local.json 中設定,magpie 不會更動",
+ "harness": "harness",
"OpenChamber's project {project} has a default model of its own ({model}), which it uses there instead.": "OpenChamber 的專案 {project} 有自己的預設模型({model}),在該專案裡會改用它。",
"OpenPencil reads its settings when it starts and writes them all back when it quits — quit OpenPencil before changing this, then open it and pick a magpie model in its chat's model picker.": "OpenPencil 啟動時讀取設定、結束時把設定全部寫回 —— 請先結束 OpenPencil 再變更這裡,然後開啟它,在聊天的模型選擇器中選一個 magpie 的模型。",
"Pencil reads its custom models at start-up — restart Pencil to see magpie's models in its model picker.": "Pencil 啟動時讀取自訂模型,需重啟 Pencil 才能在它的模型選擇器中看到 magpie 的模型。",
@@ -11537,6 +11555,15 @@ const I18N = {
"New dsh sessions start on this. A session made before keeps its model, open now or reopened later, until you pick another in it with /model or the model button by its message box. A dsh started with -p or in a terminal reads it at start-up.": "新しい dsh セッションはこれで始まります。以前に作ったセッションは、今開いていても後で開き直しても、その中で /model か入力欄の横のモデルボタンで別のモデルを選ぶまで今のモデルのままです。-p 付きやターミナルで起動した dsh は起動時に読み込みます。",
"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 {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 を接続してください",
+ "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": "Kiro Crew の config.local.json がハーネスを設定しており、config.json より優先されます:magpie は変更しません。そこで agent.acp_backend を変更するか削除してから、もう一度接続してください",
+ "that harness isn't connected to magpie: connect it first": "そのハーネスは magpie に接続されていません:先に接続してください",
+ "its harness, an agent connected to magpie, runs on magpie's models": "ハーネス(magpie に接続済みのエージェント)が magpie のモデルで動きます",
+ "its harness is set in config.local.json, which magpie leaves alone": "ハーネスは config.local.json で設定されており、magpie は変更しません",
+ "harness": "ハーネス",
"OpenChamber's project {project} has a default model of its own ({model}), which it uses there instead.": "OpenChamber のプロジェクト {project} には独自のデフォルトモデル({model})があり、そこではそちらが使われます。",
"OpenPencil reads its settings when it starts and writes them all back when it quits — quit OpenPencil before changing this, then open it and pick a magpie model in its chat's model picker.": "OpenPencil は起動時に設定を読み込み、終了時に設定をすべて書き戻します。ここを変更する前に OpenPencil を終了し、その後開いてチャットのモデル選択で magpie のモデルを選んでください。",
"Pencil reads its custom models at start-up — restart Pencil to see magpie's models in its model picker.": "Pencil は起動時にカスタムモデルを読み込みます。モデル選択に magpie のモデルを表示するには Pencil を再起動してください。",
@@ -15441,6 +15468,15 @@ const I18N = {
"New dsh sessions start on this. A session made before keeps its model, open now or reopened later, until you pick another in it with /model or the model button by its message box. A dsh started with -p or in a terminal reads it at start-up.": "Neue dsh-Sitzungen starten damit. Eine vorher angelegte Sitzung behält ihr Modell, ob jetzt offen oder später wieder geöffnet, bis Sie darin mit /model oder der Modell-Schaltfläche neben dem Eingabefeld ein anderes wählen. Ein mit -p oder im Terminal gestartetes dsh liest es beim Start.",
"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 {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",
+ "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": "Die config.local.json von Kiro Crew legt seinen Harness fest und hat Vorrang vor config.json: magpie lässt sie unverändert. Ändere agent.acp_backend dort oder entferne es, dann verbinde erneut",
+ "that harness isn't connected to magpie: connect it first": "Dieser Harness ist nicht mit magpie verbunden: Verbinde ihn zuerst",
+ "its harness, an agent connected to magpie, runs on magpie's models": "sein Harness, ein mit magpie verbundener Agent, läuft auf magpie-Modellen",
+ "its harness is set in config.local.json, which magpie leaves alone": "sein Harness ist in config.local.json festgelegt, die magpie unverändert lässt",
+ "harness": "Harness",
"OpenChamber's project {project} has a default model of its own ({model}), which it uses there instead.": "Das OpenChamber-Projekt {project} hat ein eigenes Standardmodell ({model}), das dort stattdessen genutzt wird.",
"OpenPencil reads its settings when it starts and writes them all back when it quits — quit OpenPencil before changing this, then open it and pick a magpie model in its chat's model picker.": "OpenPencil liest seine Einstellungen beim Start und schreibt sie beim Beenden alle zurück – OpenPencil vor dieser Änderung beenden, dann öffnen und in der Modellauswahl seines Chats ein magpie-Modell wählen.",
"Pencil reads its custom models at start-up — restart Pencil to see magpie's models in its model picker.": "Pencil liest seine eigenen Modelle beim Start – Pencil neu starten, um magpies Modelle in seiner Modellauswahl zu sehen.",
@@ -15672,6 +15708,9 @@ const NOTICES = [
"New dsh sessions start on this. A session made before keeps its model, open now or reopened later, until you pick another in it with /model or the model button by its message box. A dsh started with -p or in a terminal reads it at start-up.",
"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 {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.",
"OpenPencil reads its settings when it starts and writes them all back when it quits — quit OpenPencil before changing this, then open it and pick a magpie model in its chat's model picker.",
"Pencil reads its custom models at start-up — restart Pencil to see magpie's models in its model picker.",
diff --git a/internal/gui/tests/agent-kiro-crew-lang.test.cjs b/internal/gui/tests/agent-kiro-crew-lang.test.cjs
new file mode 100644
index 000000000..06d6b4c4d
--- /dev/null
+++ b/internal/gui/tests/agent-kiro-crew-lang.test.cjs
@@ -0,0 +1,96 @@
+// Run with Node's test runner and Playwright on the module path; see README.md.
+// Kiro Crew (Vincent on Discord) runs on a harness, an agent connected to
+// 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
+// and a narrow window. No backend: the API is faked.
+const assert = require("node:assert/strict");
+const fs = require("node:fs/promises");
+const path = require("node:path");
+const { test } = require("node:test");
+const { chromium, webkit } = require("playwright");
+
+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 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,
+ fields: [
+ { key: "provider", label: "provider", value: on ? "magpie" : "", options: [{ value: "magpie", label: "magpie", icon: "magpie", note: NOTE }] },
+ { key: "harness", label: "harness", value: on ? "codex" : "", quiet: true, options: [{ value: "codex", label: "Codex", icon: "codex-color" }] },
+ ],
+});
+
+function server(lang, answers) {
+ let on = false;
+ const st = () => ({ agents: [crew(on)], profiles: [], settings: { lang, theme: "light" } });
+ return async (route) => {
+ const url = new URL(route.request().url());
+ if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` });
+ if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" });
+ if (url.pathname === "/api/state") return route.fulfill({ json: st() });
+ if (url.pathname === "/api/agents/connect/kirocrew") {
+ 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 } });
+ }
+ if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] });
+ if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } });
+ if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } });
+ if (url.pathname === "/api/agents/cli") return route.fulfill({ json: { agents: {}, pending: false } });
+ if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], presets: [], excluded: [], gateway: { running: true } } });
+ if (url.pathname.startsWith("/api/")) return route.fulfill({ json: {} });
+ const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname);
+ const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)];
+ await route.fulfill({ body: await fs.readFile(file), contentType });
+ };
+}
+
+for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
+ test(engine + ": Kiro Crew's refusals and notice read in the window's language", async (t) => {
+ const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
+ const errors = [];
+ t.after(async () => {
+ if (errors.length) console.log(errors);
+ await browser.close();
+ });
+ for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
+ for (const width of [1100, 420]) {
+ await t.test(`${lang} at ${width}px`, async () => {
+ const page = await (await browser.newContext({ viewport: { width, height: 900 }, reducedMotion: "reduce" })).newPage();
+ page.setDefaultTimeout(5000);
+ page.on("pageerror", (e) => errors.push(e.message));
+ await page.route("**/*", server(lang, [NO_HARNESS, PINNED]));
+ await page.goto("http://magpie.test/?view=agents");
+ 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"]);
+ 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);
+ await page.evaluate(() => (document.querySelector("#status").textContent = ""));
+ await sw.click();
+ await page.waitForFunction((w) => document.querySelector("#status")?.textContent.includes(w), want);
+ assert.equal(await sw.getAttribute("aria-checked"), "false", "the switch goes back off");
+ }
+ await page.evaluate(() => (document.querySelector("#status").textContent = ""));
+ await sw.click();
+ 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);
+ assert.ok(said.endsWith(want), said);
+ if (lang !== "en") assert.ok(!said.includes("sessions already open"), said);
+ const fits = await page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth);
+ assert.ok(fits, "the page runs past the window");
+ });
+ }
+ }
+ assert.deepEqual(errors, []);
+ });
+}