agent: Air in JetBrains IDEs gets magpie's Magpie agent in ~/.jetbrains/acp.json (Jumy on Discord)

Jumy asked for the "air-plugin" new in IntelliJ IDEA 2026.3 (Settings ›
AI › Air). magpie's air agent wrote the Air app's acp.json, in
~/Library/Application Support/JetBrains/Air, which the IDE plugin never
reads: the plugin (com.intellij.air, air-plugin-262.8665.521-mac-arm64
from JetBrains Marketplace) loads its custom ACP agents in
AcpConfigurationLoader (intellij.air.backend.acp.runtime) from
user.home/.jetbrains/acp.json on every system, the file AI Assistant's
custom agents use too; AgentServerConfig takes command, args, env,
use_idea_mcp and use_custom_mcp. The standalone app (Air-262.1037.14,
Fleet-based) reads acp.json from its own configs folder
(genericAcpConfigPath), so the two are separate files.

Air's own agents have no base URL: JetBrains AI, the agent's own login,
or an Anthropic, OpenAI, Gemini or OpenRouter key under AI › Air ›
Accounts. So the IDE gets the same route as the app: a new air-ide agent
("Air (JetBrains IDEs)", aliases air-plugin, air-in-ides) writes a
Magpie entry (opencode acp, OPENCODE_CONFIG naming magpie-opencode.json
beside acp.json) and nothing else; the user's agents and
default_mcp_settings stay, and disconnecting takes out that entry and
that file. air and air-ide share airAt. air-ide shows for an IDE config
folder of 2026.2 or later (the plugin is bundled from 2026.3), or with
its entry already in acp.json. Notice in en, zh, zh-TW, ja, de; README,
reference and agent-wiring rows.

Run at this head (rebased on ed978e560), on mote:
- go test -tags nogui ./internal/agent ./internal/gui: ok.
  ./internal/cli: TestEveryRouteHasACommandOrIsNamed red, the
  checkin-account route, #4826, not this change.
- go vet darwin, GOOS=linux, GOOS=windows (agent, gui); gofmt -l clean.
- -run Air on Windows (win-run) and Linux (wsl-run): ok.
- GUI i18n-keys, agent-notice-lang, about-notices, agents-last-known in
  chromium and webkit: all pass.
Broken by hand: air-ide on the app's folder fails
TestAirIDEAddsMagpieAgent; a version check of > in place of >= fails
TestAirIDEDetectedByIDEVersion on GoLand2026.2.
Not tried: a real IntelliJ IDEA 2026.3 with the plugin listing Magpie
(the plugin's watcher should pick up acp.json; JetBrains' docs say to
restart the IDE, which the notice says); opencode acp itself was checked
under the app's entry in 5a0559d37, the entry is the same here.
This commit is contained in:
yetone
2026-11-02 19:00:29 +08:00
parent ed978e560f
commit 5f0a84a003
8 changed files with 290 additions and 71 deletions
+1 -1
View File
@@ -80,7 +80,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 · PenguinHarness · 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 · Pencil · OpenPencil · OpenBot · NewMax · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Ante · AstrBot · QwenPaw · OpenClaw
Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · PenguinHarness · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Air (JetBrains IDEs) · 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 · Pencil · OpenPencil · OpenBot · NewMax · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Ante · AstrBot · QwenPaw · OpenClaw
</td></tr>
</table>
+1 -1
View File
@@ -80,7 +80,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 · PenguinHarness · 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 · Pencil · OpenPencil · OpenBot · NewMax · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Ante · AstrBot · QwenPaw · OpenClaw
Claude Code · Claude Desktop · Claude Science · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · MothX · PenguinHarness · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · Zoo Code · JetBrains Air · Air (JetBrains IDEs) · 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 · Pencil · OpenPencil · OpenBot · NewMax · Raycast · Kiro Crew · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Lody · AionUi · Ante · AstrBot · QwenPaw · OpenClaw
</td></tr>
</table>
+1
View File
@@ -113,6 +113,7 @@ line; agents connected to magpie lose it when it quits.
| Zoo Code (VS Code) | VS Code's `Code/User/settings.json` (and each profile's): `zoo-code.autoImportSettingsPath` names `globalStorage/zoocodeorganization.zoo-code/settings/magpie-import.json` beside it | model (one provider profile `magpie`, OpenAI Compatible, imported by Zoo Code at start-up) |
| Copilot (JetBrains) | `byok.json` in `~/.config/github-copilot` (`$XDG_CONFIG_HOME/github-copilot` when set, `%USERPROFILE%\AppData\Local\github-copilot` on Windows), the Copilot language server's own file, which Xcode's and Eclipse's Copilot read too | provider (a `magpie` custom endpoint provider beside the user's: every magpie model at the gateway's `/v1/chat/completions`, sent with `magpie-copilot-jetbrains`; a model hidden in Manage Models stays hidden through a sync; off removes magpie's three keys alone). Found by the `github-copilot-intellij` plugin in a JetBrains IDE or Android Studio. Listed after the IDE restarts, and only while Copilot is signed in to GitHub on a plan with Bring Your Own Key (Free, Pro, Pro+; Business and Enterprise when the organisation allows it); the model is picked in Copilot Chat |
| JetBrains Air | `acp.json` in `~/Library/Application Support/JetBrains/Air` (`~/.config/JetBrains/Air` on Linux, `%APPDATA%\JetBrains\Air` on Windows) + `magpie-opencode.json` beside it | model (a `Magpie` ACP agent: OpenCode's `opencode acp` on magpie's provider alone, its models and routing groups in Air's model menu; needs OpenCode installed) |
| Air (JetBrains IDEs) | `~/.jetbrains/acp.json` (`%USERPROFILE%\.jetbrains\acp.json` on Windows; the Air plugin in 2026.2+ IDEs, shared with AI Assistant's custom agents) + `magpie-opencode.json` beside it | model (the same `Magpie` ACP agent as the Air app's, in Air's agent menu in the IDE; needs OpenCode installed) |
| Copilot CLI | `~/.copilot/settings.json` | model |
| Crush | `~/.config/crush/crush.json` | large, small |
| DeepSeek Harness (dsh) | `~/.dsh/profiles/*/cordis.patch.yml` (`$DSH_HOME`; a custom provider, Magpie, its key `MAGPIE_GATEWAY_KEY` in `~/.dsh/.env` and dsh's own key store `~/.dsh/.credentials.yaml`, which the desktop app reads; on one of magpie's models its `web-search-deepseek` row also goes to the gateway, which searches with the model or Settings › Web search, unless dsh has a `DEEPSEEK_API_KEY` or a row of your own), or `~/.dsh/config.yaml` before dsh 0.1.5 | model, effort |
+1
View File
@@ -50,6 +50,7 @@ something else shows up as drift.
- An agent whose `Sync` does nothing but bring a block of magpie's name up to the catalog is `ListOnly` (OpenCode, MiMo Code and the other OpenCode forms, Pi and its forks, Goose, Crush, Air, AtomCode, Command Code, Droid, Fx, jcode, Kimi, MiniMax, Mothx, omp, OpenChamber, OpenClaw, OpenPencil, Penguin, Qwen Code, T3 Code). `SyncCatalog` runs it only while the agent is connected (`Wired`), as its switch on the Agents page says: a custom provider the user named magpie in the agent, with a few models picked by hand, was written over with the whole catalog at every start (yyddbds on Discord, Xiaomi MiMo; `TestCatalogSyncLeavesAHandWrittenMagpieBlock`). A list magpie wrote while connected waits, while the agent runs a model of its own, until a model of magpie's is picked again; a model of magpie's picked by hand on a provider the user wrote doesn't connect it (`handWired`, above). Every `ListOnly` agent magpie connects reads as `Wired` (`TestListOnlyAgentsReadConnected`). Agents whose `Sync` also repairs while not connected (Codex, Claude, Grok, Hermes' bots) are not `ListOnly`. magpie keeps no copy of a list it wrote over before this, so such a list stays full until the user trims it.
- `SyncCatalog` holds the catalog it builds (`provider.Hold`), the plugins' providers and sign-ins among it, for up to a second. Those `catalog.Touched` drops are told in the background, so a plugin change also drops what is held at once (`plugin.OnChangeNow`, [`hold.go`](../../internal/provider/hold.go)): the host's "auth" event is read before its reply to the sign-in that saved it, and a look at the accounts once the sign-in returns sees it (#2449: `magpie plugin login` found no account while a sync ran; `TestHeldGoesWithAPluginChange`).
- JetBrains Air's `magpie-opencode.json` keeps user-added fields in `provider.magpie`, including nested options, on sync and model picks (`air` in [`air.go`](../../internal/agent/air.go), using `theirsKept` in [`sync.go`](../../internal/agent/sync.go)). The gateway fields and complete model list are still replaced, so removed models leave the list.
- Air comes in two forms that read different files, both wired by `airAt` in [`air.go`](../../internal/agent/air.go). The Air app (`air`) reads `acp.json` in its own config folder. The Air plugin in JetBrains IDEs (`air-ide`; bundled from 2026.3, from Marketplace in 2026.2) reads `~/.jetbrains/acp.json` on every system, the file AI Assistant's custom agents are in too (`AcpConfigurationLoader` in the plugin's `intellij.air.backend.acp.runtime`, checked in air-plugin 262.8665.521). Each gets its own Magpie entry and `magpie-opencode.json` beside its `acp.json`. `air-ide` shows for an IDE config folder of 2026.2 or later, or with its entry already there (`TestAirIDEDetectedByIDEVersion`). Neither has a base URL for its own agents (JetBrains AI, the agent's login, or an Anthropic, OpenAI, Gemini or OpenRouter key); JetBrains says an installed agent runs on its existing configuration, so a Codex on its own login would read `~/.codex`, which the Codex agent wires (not tried in an IDE).
- In every OpenCode-shaped config (OpenCode, DevEco, Air, OpenChamber; `openCodeKept` in [`agents.go`](../../internal/agent/agents.go)), a variant the user put on one of magpie's models stays through a sync, and so does one they wrote over under a name of magpie's. A variant exactly as magpie writes it under its name (`openCodeVariant`) is magpie's, so one the model no longer has goes (#2379, `TestOpenCodeCodexFastVariants`).
- magpie's OpenCode provider goes under `provider` (OpenCode 1's key), not OpenCode 2's native `providers`, on purpose. OpenCode 2 reads `provider` and turns it into its own shape in memory without rewriting the file (`migrateProviders` in packages/core/src/config/normalize.ts at v2.2.0; its "Migrate from V1" page calls the V1 format supported and converting optional), while OpenCode 1 ignores `providers` (`ConfigV2Compat.lower` in packages/opencode/src/config/v2-compat.ts at v1.19.5, npm's `latest`), and both read the same opencode.json. A native entry is a different shape too (`package`, `settings.baseURL`, variants as an array). Checked on 10-29 against a fake server: 2.2.0 listed and used magpie's `provider` entry (`#high-fast` sent reasoning_effort high and service_tier priority), and 1.19.5 with the entry under `providers` had no magpie models. OpenCode 2 logs one WARN for each model marked `reasoning`, which only OpenCode 1 reads.
- OpenCode has no `/fast`. A ChatGPT account's own `gpt-*` model, not a routing group (`catalog.Model.CodexFast`, set in `magpieModels`), gets each reasoning level again as `<level>-fast` (or `fast` alone with no levels), asking `service_tier: "priority"` as Codex's `/fast` does. The tier is written twice: as an option, which OpenCode 1's `@ai-sdk/openai-compatible` sends as it is, and in `extraBody`, which OpenCode 2 sends while it drops an option it doesn't know (checked with OpenCode 2.0.25 against a fake server). The gateway drops OpenCode 1's stray `extraBody` field when it rebuilds the request as Responses for the ChatGPT backend (`TestOpenCodeFastVariantReachesCodex`).
+1
View File
@@ -242,6 +242,7 @@ func onMachine(home, cfg string) []*Agent {
zooCode(home, cfg),
copilotJetBrains(home),
air(home, cfg),
airIDE(home, cfg),
copilot(home),
crush(home, cfg),
dsh(home),
+157 -69
View File
@@ -34,7 +34,9 @@ import (
"fmt"
"os"
"path/filepath"
"regexp"
"runtime"
"strconv"
"strings"
"time"
@@ -136,11 +138,100 @@ func acpOpenCode(home, name, goos string) string {
func air(home, cfg string) *Agent {
dir := airDir(home, cfg)
return airAt(home, &Agent{
ID: "air", Name: "JetBrains Air", Icon: "air", Aliases: []string{"jetbrains-air"},
// no Bin: air is other tools' name too (Go's live reloader); its
// requests are its OpenCode's, and counted as OpenCode's
Dir: dir,
}, filepath.Join(dir, "acp.json"), noticeAir2)
}
// airIDE is Air in JetBrains IDEs: the Air plugin, bundled with 2026.3
// IDEs and installed from JetBrains Marketplace in 2026.2 (com.intellij.air;
// Settings › AI › Air). It isn't the standalone app's code: its
// AcpConfigurationLoader (intellij.air.backend.acp.runtime in
// air-plugin-262.8665.521) reads the custom ACP agents from
// user.home/.jetbrains/acp.json on every system, the file AI Assistant's
// "Add Custom Agent" writes too, where the app reads acp.json in its own
// config folder. An entry takes command, args, env, use_idea_mcp and
// use_custom_mcp. Its own agents (Claude Agent, Codex, Junie, …) run on
// JetBrains AI, the agent's own login, or an Anthropic, OpenAI, Gemini or
// OpenRouter key under AI › Air › Accounts, none with a base URL (an
// installed agent on its own login runs on its existing configuration, as
// JetBrains' docs say, so a Codex there would read the ~/.codex magpie's
// Codex wires; not tried in an IDE). So magpie adds the same Magpie agent
// as the app's, with its OpenCode config beside acp.json.
func airIDE(home, cfg string) *Agent {
dir := filepath.Join(home, ".jetbrains")
path := filepath.Join(dir, "acp.json")
return airAt(home, &Agent{
ID: "air-ide", Name: "Air (JetBrains IDEs)", Icon: "air",
Aliases: []string{"air-plugin", "air-in-ides", "jetbrains-acp"},
Dir: dir,
// ~/.jetbrains is there for AI Assistant's agents too: an IDE of
// 2026.2 or later, or magpie's agent already in acp.json, says Air
// can be
detect: func() bool {
if jetBrainsIDESince(home, cfg, 2026, 2) {
return true
}
v, _ := edit.GetJSON(path, "agent_servers."+airAgent+".env.OPENCODE_CONFIG")
return v == filepath.Join(dir, "magpie-opencode.json")
},
}, path, noticeAirIDE)
}
// jetBrainsIDESince reports whether a JetBrains IDE of year.minor or later
// has kept its settings here: a config folder named for the IDE and its
// version (IntelliJIdea2026.3, PyCharm2026.2, …) under JetBrains' folder
// (Library/Application Support on macOS, %APPDATA% on Windows,
// $XDG_CONFIG_HOME on Linux).
func jetBrainsIDESince(home, cfg string, year, minor int) bool {
var base string
switch runtime.GOOS {
case "darwin":
base = filepath.Join(home, "Library", "Application Support", "JetBrains")
case "windows":
d := appdir.Getenv("APPDATA")
if d == "" {
d = filepath.Join(home, "AppData", "Roaming")
}
base = filepath.Join(d, "JetBrains")
default:
base = filepath.Join(cfg, "JetBrains")
}
es, _ := os.ReadDir(base)
for _, e := range es {
if !e.IsDir() {
continue
}
m := jetBrainsVersioned.FindStringSubmatch(e.Name())
if m == nil {
continue
}
y, _ := strconv.Atoi(m[1])
n, _ := strconv.Atoi(m[2])
if y > year || y == year && n >= minor {
return true
}
}
return false
}
// jetBrainsVersioned is an IDE's config folder name: the product, then its
// year and release.
var jetBrainsVersioned = regexp.MustCompile(`^[A-Za-z]+(\d{4})\.(\d+)$`)
// airAt is an Air agent on the acp.json at path: a, with its id, name,
// icon and detection, gets the Magpie entry there and its OpenCode config
// beside it; done is the notice once it is there.
func airAt(home string, a *Agent, path string, done notice) *Agent {
dir := filepath.Dir(path)
// the OpenCode config magpie's agent runs on, magpie's own file
ocPath := filepath.Join(dir, "magpie-opencode.json")
entry := "agent_servers." + airAgent
provider := openCodeKept(ocPath, func() any { return magpieProviderJSONFor("opencode", "air") })
id := a.ID
provider := openCodeKept(ocPath, func() any { return magpieProviderJSONFor("opencode", id) })
// ours: acp.json's Magpie is the agent magpie added, on its file
ours := func() bool {
v, _ := edit.GetJSON(path, entry+".env.OPENCODE_CONFIG")
@@ -150,79 +241,76 @@ func air(home, cfg string) *Agent {
// Magpie gone from acp.json it still reads, for Check to say so and a
// set again to put the entry back
model := func() string { v, _ := edit.GetJSON(ocPath, "model"); return v }
return atomic(&Agent{
ID: "air", Name: "JetBrains Air", Icon: "air", Aliases: []string{"jetbrains-air"},
// no Bin: air is other tools' name too (Go's live reloader); its
// requests are its OpenCode's, and counted as OpenCode's
Dir: dir, Path: path,
Notice: func() string {
if !ours() {
return ""
}
if airOpenCode(home) == "" {
return noticeAir1.String()
}
return noticeAir2.String()
},
Check: func() string {
if !usesMagpie(model()) {
return ""
}
if !ours() {
return "Air's Magpie agent (" + filepath.Base(path) + ") is gone, so Air no longer reaches magpie"
}
return wiringOff("Air", ocPath, func(k string) (string, bool) { return edit.GetJSON(ocPath, "provider."+magpieID+".options."+k) },
"baseURL", gatewayV1(), "apiKey", hereKey())
},
ListOnly: true,
Sync: func() error {
return syncJSONInOrder(ocPath, "provider."+magpieID, provider)
},
Fields: []Field{{
Key: "model", Label: "model",
Get: model,
Set: func(v string) error {
if v == "" {
if err := edit.DelJSON(path, entry); err != nil {
return err
}
if err := edit.Remove(ocPath); err != nil && !os.IsNotExist(err) {
return err
}
return nil
}
ref, ok := strings.CutPrefix(v, magpieID+"/")
if !ok || !isMagpie(ref) {
return fmt.Errorf("Air takes only magpie's models here (its own agents are picked in Air): %s isn't one", v)
}
// each key new to the file goes in at its top: last first,
// so a new file reads $schema, model, …, provider
if err := edit.SetJSON(ocPath,
edit.KV{Path: "provider." + magpieID, Value: provider()},
edit.KV{Path: "enabled_providers", Value: []string{magpieID}},
// titles and summaries too, as the user's own small
// model may be a provider left out here
edit.KV{Path: "small_model", Value: v},
edit.KV{Path: "model", Value: v},
edit.KV{Path: "$schema", Value: "https://opencode.ai/config.json"}); err != nil {
a.Path = path
a.Notice = func() string {
if !ours() {
return ""
}
if airOpenCode(home) == "" {
return noticeAir1.String()
}
return done.String()
}
a.Check = func() string {
if !usesMagpie(model()) {
return ""
}
if !ours() {
return "Air's Magpie agent (" + filepath.Base(path) + ") is gone, so Air no longer reaches magpie"
}
return wiringOff("Air", ocPath, func(k string) (string, bool) { return edit.GetJSON(ocPath, "provider."+magpieID+".options."+k) },
"baseURL", gatewayV1(), "apiKey", hereKey())
}
a.ListOnly = true
a.Sync = func() error {
return syncJSONInOrder(ocPath, "provider."+magpieID, provider)
}
a.Fields = []Field{{
Key: "model", Label: "model",
Get: model,
Set: func(v string) error {
if v == "" {
if err := edit.DelJSON(path, entry); err != nil {
return err
}
bin := airOpenCode(home)
if bin == "" {
bin = "opencode"
if err := edit.Remove(ocPath); err != nil && !os.IsNotExist(err) {
return err
}
return edit.SetJSON(path, edit.KV{Path: entry, Value: map[string]any{
"command": bin, "args": []string{"acp"},
"env": map[string]string{"OPENCODE_CONFIG": ocPath},
}})
},
Options: func(map[string]string) []Option { return viaMagpie("air", magpieID+"/") },
}},
}, path, ocPath)
return nil
}
ref, ok := strings.CutPrefix(v, magpieID+"/")
if !ok || !isMagpie(ref) {
return fmt.Errorf("Air takes only magpie's models here (its own agents are picked in Air): %s isn't one", v)
}
// each key new to the file goes in at its top: last first,
// so a new file reads $schema, model, …, provider
if err := edit.SetJSON(ocPath,
edit.KV{Path: "provider." + magpieID, Value: provider()},
edit.KV{Path: "enabled_providers", Value: []string{magpieID}},
// titles and summaries too, as the user's own small
// model may be a provider left out here
edit.KV{Path: "small_model", Value: v},
edit.KV{Path: "model", Value: v},
edit.KV{Path: "$schema", Value: "https://opencode.ai/config.json"}); err != nil {
return err
}
bin := airOpenCode(home)
if bin == "" {
bin = "opencode"
}
return edit.SetJSON(path, edit.KV{Path: entry, Value: map[string]any{
"command": bin, "args": []string{"acp"},
"env": map[string]string{"OPENCODE_CONFIG": ocPath},
}})
},
Options: func(map[string]string) []Option { return viaMagpie(id, magpieID+"/") },
}}
return atomic(a, path, ocPath)
}
// what air says after a change (notice.go)
var (
noticeAir1 = newNotice("Air runs magpie's models through OpenCode's ACP server, and OpenCode isn't installed here: install OpenCode (npm i -g opencode-ai), then pick Magpie in a new Air task.")
noticeAir2 = newNotice("In Air, start a new task and pick Magpie in its agent menu: magpie's models and routing groups are in its model menu.")
noticeAir1 = newNotice("Air runs magpie's models through OpenCode's ACP server, and OpenCode isn't installed here: install OpenCode (npm i -g opencode-ai), then pick Magpie in a new Air task.")
noticeAir2 = newNotice("In Air, start a new task and pick Magpie in its agent menu: magpie's models and routing groups are in its model menu.")
noticeAirIDE = newNotice("In your JetBrains IDE (2026.3, or 2026.2 with the Air plugin), pick Magpie in Air's agent menu — restart the IDE if it isn't listed yet: magpie's models and routing groups are in its model menu.")
)
+123
View File
@@ -0,0 +1,123 @@
package agent
import (
"os"
"path/filepath"
"runtime"
"strings"
"testing"
"github.com/yetone/magpie/internal/edit"
)
// jetBrainsConfigs is where a JetBrains IDE keeps its config folders on
// this system, under a sandbox home.
func jetBrainsConfigs(home string) string {
switch runtime.GOOS {
case "darwin":
return filepath.Join(home, "Library", "Application Support", "JetBrains")
case "windows":
return filepath.Join(home, "AppData", "Roaming", "JetBrains")
}
return filepath.Join(home, ".config", "JetBrains")
}
// Air in an IDE (the Air plugin, Settings › AI › Air) reads its custom ACP
// agents from ~/.jetbrains/acp.json, not the Air app's folder: magpie adds
// its Magpie agent there, keeps what the IDE and the user put in the file
// (AI Assistant's agents, default_mcp_settings), and taking it off takes
// out that entry and its OpenCode config alone.
func TestAirIDEAddsMagpieAgent(t *testing.T) {
home, appDir := airHome(t, "/opt/bin/opencode")
acp := filepath.Join(home, ".jetbrains", "acp.json")
// the file as AI Assistant's "Add Custom Agent" leaves it, with an
// agent of the user's
user := `{
"default_mcp_settings": {
"use_idea_mcp": true,
"use_custom_mcp": true
},
"agent_servers": {
"Goose": {"command": "/usr/local/bin/goose", "args": ["acp"], "use_idea_mcp": false}
}
}
`
writeFile(t, acp, user)
a := airIDE(home, filepath.Join(home, ".config"))
if a.Path != acp {
t.Fatalf("path %s", a.Path)
}
if err := a.Apply("model", "magpie/fake/m1"); err != nil {
t.Fatal(err)
}
cfg := filepath.Join(home, ".jetbrains", "magpie-opencode.json")
for k, v := range map[string]string{
"default_mcp_settings.use_idea_mcp": "true",
"agent_servers.Goose.command": "/usr/local/bin/goose",
"agent_servers.Goose.use_idea_mcp": "false",
"agent_servers.Magpie.command": "/opt/bin/opencode",
"agent_servers.Magpie.args.0": "acp",
"agent_servers.Magpie.env.OPENCODE_CONFIG": cfg,
} {
if got, _ := edit.GetJSON(acp, k); got != v {
t.Fatalf("%s = %q, want %q\n%s", k, got, v, readFile(acp))
}
}
if v, _ := edit.GetJSON(cfg, "provider.magpie.options.baseURL"); v != gatewayV1() {
t.Fatalf("baseURL = %q\n%s", v, readFile(cfg))
}
if v := a.Field("model").Get(); v != "magpie/fake/m1" {
t.Fatalf("model = %q", v)
}
if !a.Detected() {
t.Fatal("not detected with magpie's agent in acp.json")
}
if n := a.Notice(); !strings.Contains(n, "JetBrains IDE") {
t.Fatalf("notice: %q", n)
}
if d := a.Drift(); d != nil {
t.Fatalf("drift: %+v", d)
}
// the Air app's own acp.json isn't this one, and isn't written
if _, err := os.Stat(filepath.Join(appDir, "acp.json")); !os.IsNotExist(err) {
t.Fatalf("the Air app's acp.json was written: %v", err)
}
if err := a.Apply("model", ""); err != nil {
t.Fatal(err)
}
if _, ok := edit.GetJSON(acp, "agent_servers.Magpie"); ok {
t.Fatalf("Magpie still in acp.json: %s", readFile(acp))
}
for _, k := range []string{"agent_servers.Goose.command", "default_mcp_settings.use_custom_mcp"} {
if _, ok := edit.GetJSON(acp, k); !ok {
t.Fatalf("%s went: %s", k, readFile(acp))
}
}
if _, err := os.Stat(cfg); !os.IsNotExist(err) {
t.Fatalf("magpie's OpenCode config left: %v", err)
}
}
// The Air plugin is bundled from 2026.3 and installable from 2026.2, so an
// IDE config folder of 2026.2 or later shows the agent; an older IDE, the
// Air app's folder or ~/.jetbrains alone (AI Assistant's) don't.
func TestAirIDEDetectedByIDEVersion(t *testing.T) {
home, _ := airHome(t, "/opt/bin/opencode")
cfg := filepath.Join(home, ".config")
base := jetBrainsConfigs(home)
for _, d := range []string{"IntelliJIdea2026.1", "Air", "Toolbox", "PyCharm2025.3"} {
os.MkdirAll(filepath.Join(base, d), 0o755)
}
os.MkdirAll(filepath.Join(home, ".jetbrains"), 0o755)
if airIDE(home, cfg).Detected() {
t.Fatal("detected without an IDE of 2026.2 or later")
}
for _, d := range []string{"IntelliJIdea2026.3", "GoLand2026.2", "PyCharm2027.1"} {
p := filepath.Join(base, d)
os.MkdirAll(p, 0o755)
if !airIDE(home, cfg).Detected() {
t.Fatalf("not detected with %s", d)
}
os.RemoveAll(p)
}
}
+5
View File
@@ -2043,6 +2043,7 @@ const I18N = {
"Restart it to use the new account. Running Codex sessions will be interrupted.": "重启后才会使用新账号,正在运行的 Codex 会话将中断。",
"Restart Zed if it still asks for an API key: magpie has configured its gateway credential in the system credential store.": "若 Zed 仍要求输入 API 密钥,请重启 Zed:网关凭据已写入系统凭据存储。",
"In Air, start a new task and pick Magpie in its agent menu: magpie's models and routing groups are in its model menu.": "在 Air 中新建任务并在智能体菜单选 Magpie:模型菜单中即有 magpie 的模型和路由组。",
"In your JetBrains IDE (2026.3, or 2026.2 with the Air plugin), pick Magpie in Air's agent menu — restart the IDE if it isn't listed yet: magpie's models and routing groups are in its model menu.": "在 JetBrains IDE(2026.3,或装了 Air 插件的 2026.2)中,在 Air 的智能体菜单选 Magpie;若还没列出,请重启 IDE。模型菜单中即有 magpie 的模型和路由组。",
"Air runs magpie's models through OpenCode's ACP server, and OpenCode isn't installed here: install OpenCode (npm i -g opencode-ai), then pick Magpie in a new Air task.": "Air 经 OpenCode 的 ACP 服务使用 magpie 的模型,本机未安装 OpenCode:请先安装(npm i -g opencode-ai),再在 Air 新任务中选 Magpie。",
"magpie's models are in VS Code's Chat model picker, under magpie (VS Code 1.122 or later). If they don't show, run Developer: Reload Window in VS Code.": "magpie 的模型位于 VS Code 聊天模型选择器的 magpie 分组下(需 VS Code 1.122 或更高)。若未出现,请在 VS Code 中运行 Developer: Reload Window。",
"Later": "稍后",
@@ -6449,6 +6450,7 @@ const I18N = {
"Restart it to use the new account. Running Codex sessions will be interrupted.": "重啟後才會使用新帳號,正在執行的 Codex 會話將中斷。",
"Restart Zed if it still asks for an API key: magpie has configured its gateway credential in the system credential store.": "若 Zed 仍要求輸入 API 金鑰,請重啟 Zed:閘道憑據已寫入系統憑據儲存。",
"In Air, start a new task and pick Magpie in its agent menu: magpie's models and routing groups are in its model menu.": "在 Air 中新增任務並在智慧體選單選 Magpie:模型選單中即有 magpie 的模型和路由組。",
"In your JetBrains IDE (2026.3, or 2026.2 with the Air plugin), pick Magpie in Air's agent menu — restart the IDE if it isn't listed yet: magpie's models and routing groups are in its model menu.": "在 JetBrains IDE(2026.3,或裝了 Air 外掛的 2026.2)中,在 Air 的智慧體選單選 Magpie;若還沒列出,請重新啟動 IDE。模型選單中即有 magpie 的模型和路由組。",
"Air runs magpie's models through OpenCode's ACP server, and OpenCode isn't installed here: install OpenCode (npm i -g opencode-ai), then pick Magpie in a new Air task.": "Air 經 OpenCode 的 ACP 服務使用 magpie 的模型,本機未安裝 OpenCode:請先安裝(npm i -g opencode-ai),再在 Air 新任務中選 Magpie。",
"magpie's models are in VS Code's Chat model picker, under magpie (VS Code 1.122 or later). If they don't show, run Developer: Reload Window in VS Code.": "magpie 的模型位於 VS Code 聊天模型選擇器的 magpie 分組下(需 VS Code 1.122 或更高)。若未出現,請在 VS Code 中執行 Developer: Reload Window。",
"Later": "稍後",
@@ -10831,6 +10833,7 @@ const I18N = {
"Restart it to use the new account. Running Codex sessions will be interrupted.": "新しいアカウントを使うには再起動してください。実行中の Codex セッションは中断されます。",
"Restart Zed if it still asks for an API key: magpie has configured its gateway credential in the system credential store.": "Zed がまだ APIキーを求める場合は Zed を再起動してください。magpie はシステムの資格情報ストアにゲートウェイの資格情報を設定済みです。",
"In Air, start a new task and pick Magpie in its agent menu: magpie's models and routing groups are in its model menu.": "Air で新しいタスクを開始し、エージェントメニューで Magpie を選んでください。magpie のモデルとルーティンググループはモデルメニューにあります。",
"In your JetBrains IDE (2026.3, or 2026.2 with the Air plugin), pick Magpie in Air's agent menu — restart the IDE if it isn't listed yet: magpie's models and routing groups are in its model menu.": "JetBrains IDE(2026.3、または Air プラグインを入れた 2026.2)で、Air のエージェントメニューから Magpie を選んでください。まだ表示されない場合は IDE を再起動してください。magpie のモデルとルーティンググループはモデルメニューにあります。",
"Air runs magpie's models through OpenCode's ACP server, and OpenCode isn't installed here: install OpenCode (npm i -g opencode-ai), then pick Magpie in a new Air task.": "Air は OpenCode の ACP サーバーを通じて magpie のモデルを使いますが、OpenCode がインストールされていません。OpenCode をインストール(npm i -g opencode-ai)してから、Air の新しいタスクで Magpie を選んでください。",
"magpie's models are in VS Code's Chat model picker, under magpie (VS Code 1.122 or later). If they don't show, run Developer: Reload Window in VS Code.": "magpie のモデルは VS Code のチャットのモデルピッカーの magpie の下にあります(VS Code 1.122 以降)。表示されない場合は VS Code で Developer: Reload Window を実行してください。",
"Later": "後で",
@@ -15244,6 +15247,7 @@ const I18N = {
"Restart it to use the new account. Running Codex sessions will be interrupted.": "Starten Sie ihn neu, um das neue Konto zu verwenden. Laufende Codex-Sitzungen werden unterbrochen.",
"Restart Zed if it still asks for an API key: magpie has configured its gateway credential in the system credential store.": "Starten Sie Zed neu, falls es weiterhin nach einem API-Schlüssel fragt: magpie hat die Anmeldedaten des Zugangspunkts im Anmeldeinformationsspeicher des Systems hinterlegt.",
"In Air, start a new task and pick Magpie in its agent menu: magpie's models and routing groups are in its model menu.": "Starten Sie in Air eine neue Aufgabe und wählen Sie im Agentenmenü Magpie: Die Modelle und Weiterleitungsgruppen von magpie stehen im Modellmenü.",
"In your JetBrains IDE (2026.3, or 2026.2 with the Air plugin), pick Magpie in Air's agent menu — restart the IDE if it isn't listed yet: magpie's models and routing groups are in its model menu.": "Wählen Sie in Ihrer JetBrains-IDE (2026.3 oder 2026.2 mit dem Air-Plugin) im Agentenmenü von Air Magpie – starten Sie die IDE neu, falls es noch nicht aufgeführt ist: Die Modelle und Weiterleitungsgruppen von magpie stehen im Modellmenü.",
"Air runs magpie's models through OpenCode's ACP server, and OpenCode isn't installed here: install OpenCode (npm i -g opencode-ai), then pick Magpie in a new Air task.": "Air nutzt die Modelle von magpie über den ACP-Server von OpenCode, und OpenCode ist hier nicht installiert: Installieren Sie OpenCode (npm i -g opencode-ai) und wählen Sie dann in einer neuen Air-Aufgabe Magpie.",
"magpie's models are in VS Code's Chat model picker, under magpie (VS Code 1.122 or later). If they don't show, run Developer: Reload Window in VS Code.": "Die Modelle von magpie stehen in der Modellauswahl des VS-Code-Chats unter magpie (VS Code 1.122 oder neuer). Erscheinen sie nicht, führen Sie in VS Code Developer: Reload Window aus.",
"Later": "Später",
@@ -17658,6 +17662,7 @@ const NOTICES = [
"Grok Build reads its settings at start-up — restart open grok sessions to use this.",
"Hermes reads its settings at start-up — restart open Hermes sessions to use this.",
"In Air, start a new task and pick Magpie in its agent menu: magpie's models and routing groups are in its model menu.",
"In your JetBrains IDE (2026.3, or 2026.2 with the Air plugin), pick Magpie in Air's agent menu — restart the IDE if it isn't listed yet: magpie's models and routing groups are in its model menu.",
"Install GitHub Copilot Chat in {agent} to see magpie's models in its Chat.",
"It reads its settings at start-up — restart open Command Code sessions to use this.",
"Kimi Code reads its settings at start-up — restart open kimi sessions to use this.",