From e528aeb3ce4a603991e1824ef11f8eb7e9f15047 Mon Sep 17 00:00:00 2001 From: yetone Date: Tue, 13 Oct 2026 10:57:25 +0800 Subject: [PATCH] agent: DevEco Code, Huawei's OpenCode, as an agent (#1885) foobra asked for DevEco Code (npm @deveco/deveco-code), Huawei's HarmonyOS coding agent. It is OpenCode underneath, so it joins through openCodeLike as MiMo Code did (03a01a548): - Config in ~/.config/deveco. magpie writes the first of deveco.jsonc, deveco.json, config.json there (the one DevEco reads last wins its merge), or DEVECO_CONFIG_DIR when that is an absolute folder; agentenv carries DEVECO_CONFIG_DIR. Auth at ~/.local/share/deveco/auth.json. - Its provider block carries the key magpie-deveco, not the plain one. 0.2.3 sends "deveco/0.2.3 ai-sdk/provider-utils/4.0.23 runtime/bun/1.4.2" on chat, but parts of its code still send opencode/, so the key keeps its usage DevEco's whichever it sends. Check flags the plain key, and Sync writes DevEco's back. OpenCode's own key is unchanged. - The user's own provider, small_model, $schema and comments stay; the model they were on comes back on Disconnect. - Library: AGENTS.md instructions (with the "reads Claude Code's CLAUDE.md" note, as OpenCode and MiMo Code), MCP in OpenCode's shape, skills. No WSL folder. - Install/update: npm @deveco/deveco-code on macOS and Windows only, as the package has no Linux binary (new cliSpec.only); the self installer under ~/.local/share/deveco/versions updates with `deveco upgrade`. - Icon: DevEco's own logo, byte for byte from its IntelliJ plugin's pluginIcon.svg. Model picker /models. Route hue, READMEs (en, zh), site agent lists (en, zh, ja), docs/reference.md, subsystem pages, CLI help. What was run - gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows. - go test -tags nogui: internal/library, agentenv, proc, cli, gui, usage pass; internal/agent passes in 559s with -timeout 40m; its first run, at the default 10m with load average ~40 from other sessions, was cut off by the timeout (no test had failed). - New deveco_test.go: config lookup and DEVECO_CONFIG_DIR, the key, and Connect/Check/Sync/Disconnect against a deveco.jsonc holding the user's own model, provider, small_model, $schema and a comment. Made openCodeKeyAt return the plain key by hand: TestDevEcoKeyNamesIt and TestDevEcoConnectKeepsTheUsersOwn go red. - GUI: new library-deveco.test.cjs (the note in en, zh, zh-TW, ja, de, and the icon draws), chromium and webkit; red with deveco taken out of library.js's note. library-instr-sets, library-instr-busy, panel-routing, agent-connect, library-desktop-skills, getting-started, filter-ime, routing-account-identity pass in both engines. - Real use, sandbox HOME: npm-installed @deveco/deveco-code 0.2.3, `deveco auth consent --accept` (sandbox only, no Huawei sign-in). magpie serve on 127.0.0.1:3592 with a fake upstream; `magpie deveco fake/fake-1` wrote provider magpie (magpie-deveco, http://127.0.0.1:3592/v1) beside the user's own and kept the file's comment; `deveco run "Reply with one word: ping"` answered from the fake, and `magpie usage today` counted it under DevEco Code. The User-Agent above is what it sent. Not tried - Windows, and DevEco Studio's plugin mode; a Huawei-signed-in DevEco. - `magpie deveco ` then `magpie deveco default` doesn't bring back the model the user was on before: the CLI set path doesn't stash. It is the same for OpenCode today; Connect/Disconnect in the GUI does. Reported-by: foobra --- README.md | 2 +- README.zh-CN.md | 2 +- docs/reference.md | 3 +- docs/subsystems/agent-wiring.md | 1 + docs/subsystems/library.md | 2 +- internal/agent/agents.go | 41 +++++- internal/agent/cliupdate.go | 16 +++ internal/agent/cliupdate_test.go | 6 + internal/agent/codex_route_test.go | 1 + internal/agent/connectinfo.go | 2 +- internal/agent/deveco_test.go | 143 +++++++++++++++++++++ internal/agent/effort_test.go | 1 + internal/agent/install.go | 3 + internal/agent/install_test.go | 3 + internal/agent/spelled_test.go | 2 +- internal/agent/sync_test.go | 1 + internal/agent/useragent_test.go | 3 +- internal/agent/wsl_more_test.go | 2 +- internal/agentenv/agentenv.go | 2 + internal/cli/main.go | 2 +- internal/gui/assets/app.js | 2 +- internal/gui/assets/icons/deveco-color.svg | 12 ++ internal/gui/assets/library.js | 2 +- internal/gui/assets/routing.js | 2 +- internal/gui/tests/library-deveco.test.cjs | 88 +++++++++++++ internal/library/library_test.go | 4 +- internal/library/targets.go | 8 +- site/public/docs/ja/start.html | 4 +- site/public/docs/start.html | 4 +- site/public/docs/zh/start.html | 4 +- site/public/icons/deveco-color.svg | 12 ++ site/public/index.html | 1 + 32 files changed, 357 insertions(+), 24 deletions(-) create mode 100644 internal/agent/deveco_test.go create mode 100644 internal/gui/assets/icons/deveco-color.svg create mode 100644 internal/gui/tests/library-deveco.test.cjs create mode 100644 site/public/icons/deveco-color.svg diff --git a/README.md b/README.md index 643b6bce0..215425d46 100644 --- a/README.md +++ b/README.md @@ -75,7 +75,7 @@ magpie finds the subscriptions your agents are signed in to by reading their sig
-Claude Code · Claude Desktop · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · Pi · oh-my-pi · StepCode · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · 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 · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Ante · AstrBot +Claude Code · Claude Desktop · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · 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 · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Ante · AstrBot
diff --git a/README.zh-CN.md b/README.zh-CN.md index 1a1c4bb18..02a228343 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -75,7 +75,7 @@ magpie 通过读取智能体的登录信息(Claude Code 和 Codex 的文件、
-Claude Code · Claude Desktop · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · Pi · oh-my-pi · StepCode · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · 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 · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Ante · AstrBot +Claude Code · Claude Desktop · Codex · Gemini CLI · Antigravity CLI · OpenCode · OpenChamber · MiMo Code · DevEco Code · Pi · oh-my-pi · StepCode · Aside · OmO · Prime Agent · Goose · Cursor CLI · Cursor Private Inference · Zed · VS Code Chat · VS Code Insiders · VSCodium Chat · 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 · T3 Code · OpenHanako · AtomCode · Snow CLI · Alma · Cindy · Ante · AstrBot
diff --git a/docs/reference.md b/docs/reference.md index ad93ab375..18776a7fb 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -93,6 +93,7 @@ line; agents connected to magpie lose it when it quits. | OpenCode | `~/.config/opencode/opencode.json(c)` (`$OPENCODE_CONFIG_DIR`) | model, small | | OpenChamber | `~/.config/openchamber/preferences.json` (`$OPENCHAMBER_DATA_DIR`; magpie's provider in OpenCode's config) | model, small (its own defaults, over OpenCode's) | | MiMo Code | `~/.config/mimocode/mimocode.json(c)` | model, small | +| DevEco Code | `~/.config/deveco/deveco.json(c)` (`$DEVECO_CONFIG_DIR`; its key is `magpie-deveco`, as parts of it send OpenCode's User-Agent) | model, small | | Pi | `~/.pi/agent/settings.json` | model | | StepCode | `~/.stepcode/config.toml` (+ `models.json`; `$STEP_CODING_AGENT_DIR`, `$STEPCODE_CONFIG_DIR`) | model | | Aside | `~/.aside/u/0/settings.json` (+ `models.json`; the first account, the only one magpie wires) | model, effort, fast, standard, deep, visual, image | @@ -140,7 +141,7 @@ line; agents connected to magpie lose it when it quits. | Snow CLI | `~/.snow/profiles/magpie.json` (`$SNOW_CONFIG_DIR`), made the active profile and copied to `config.json` | model (the user's other profiles' models too; Snow App takes the profile in with "Sync Snow CLI API config") | | Alma | Alma's local API (`localhost:23001`, while Alma runs; alma-server's data in `$ALMA_DATA_DIR`, `$XDG_DATA_HOME/alma` or `~/.local/share/alma` on Linux) | model (Alma's default; magpie's models as a provider), and Image Generation's model when it is Auto: the one magpie draws with | -Provider-scoped agents (OpenCode, MiMo Code, Pi, OmO, StepCode, Aside, Goose, Crush, omp, Hermes Agent) take `provider/model`. +Provider-scoped agents (OpenCode, MiMo Code, DevEco Code, Pi, OmO, StepCode, Aside, Goose, Crush, omp, Hermes Agent) take `provider/model`. Only agents that are installed or configured are shown. ### Notes on some agents diff --git a/docs/subsystems/agent-wiring.md b/docs/subsystems/agent-wiring.md index 444a76da5..eba783611 100644 --- a/docs/subsystems/agent-wiring.md +++ b/docs/subsystems/agent-wiring.md @@ -44,6 +44,7 @@ something else shows up as drift. - Ante's `catalog.json` keeps user-added fields in `providers.magpie` the same way (`ante` in [`ante.go`](../../internal/agent/ante.go)); its `auth`, `http_headers`, `extra_body` and `stream_idle_timeout_secs` are what a gateway shared on the local network or reached from WSL needs to send a key. Ante starts a session on the `provider` and `model` of `settings.json`, not on what its catalog holds (#1210), so magpie sets that pair and puts back what it found there; a pick the user makes in Ante while magpie is wired is theirs and stands. - 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/` 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. +- 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/`), 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. - JSON/JSONC config edits and their previews reject malformed input rather than editing a partially parsed document. Object edits and VS Code's model-group array edits leave the original file untouched on a parse error; valid comments and trailing commas remain supported (`internal/edit`). - A config that starts with a UTF-8 byte order mark (a Windows `settings.json` or `config.toml` saved by PowerShell, Notepad or a channel switcher, #1534) is read without it (`edit.Read`), and a write keeps it (`keepBOM` in `WriteAtomic`): the user's file keeps the encoding it was saved in. That covers every format `internal/edit` writes (JSON/JSONC and its arrays, TOML, YAML, env); Codex reads a TOML file through a BOM too, so magpie no longer refuses one. A file read some other way trims it with `edit.TrimBOM` (the Claude Code and CC Switch imports). A line an edit takes out of a CRLF file goes with its `\r\n`. diff --git a/docs/subsystems/library.md b/docs/subsystems/library.md index 8fcaecf47..bcc481bc9 100644 --- a/docs/subsystems/library.md +++ b/docs/subsystems/library.md @@ -49,7 +49,7 @@ agents RTK, a CLI that cuts shell output down before the model reads it. - Hermes Agent: `tools.exclude` in the server's entry, the original names (`tools/mcp_tool_registration.py`, `mcp-config-reference.md`, NousResearch/hermes-agent c5733167). `tools.include`, `prompts` and `resources` beside it are the user's. - Claude Code: a rule `mcp____` in `permissions.deny` of its settings.json (`Target.Settings`, beside `.claude.json`; for a WSL distro the distro's). A bare tool name in deny takes the tool out of Claude's context (code.claude.com/docs/en/permissions). Both names are spelt as Claude Code 2.1.296 spells them, each character but a letter, a digit, `_` and `-` an `_`. - OpenCode: `"_": false` in the top-level `tools` of opencode.json (opencode.ai/docs/mcp-servers, "Manage"), the names spelt as `name()` in `packages/core/src/tool/mcp.ts` does; `migrateTools` in `packages/core/src/config/normalize.ts` makes each a deny rule (sst/opencode 0d61729b). - - Every other agent (Cursor, Copilot and Goose, whose lists are allow-lists only, Zed, Kimi, Pi, Grok, Devin, Antigravity, Alma, dsh, omp, ZCode, Command Code, Cline, WorkBuddy, CodeBuddy, Droid, Claude Desktop, MiMo Code, a plugin's agent) gets the server whole. `AgentView.ToolsOff` is false for it, and the open list of tools names those given the server as unable to turn off single tools. A project's file and Copy config… carry no tools turned off either. + - Every other agent (Cursor, Copilot and Goose, whose lists are allow-lists only, Zed, Kimi, Pi, Grok, Devin, Antigravity, Alma, dsh, omp, ZCode, Command Code, Cline, WorkBuddy, CodeBuddy, Droid, Claude Desktop, MiMo Code, DevEco Code, a plugin's agent) gets the server whole. `AgentView.ToolsOff` is false for it, and the open list of tools names those given the server as unable to turn off single tools. A project's file and Copy config… carry no tools turned off either. magpie records what it added (`Applied.ToolsOff` per server for a list in an entry, `Applied.ToolRules` for Claude Code's rules and OpenCode's keys) and takes back only that (`offList`): a name, rule or key the user had already is theirs and stays when the tool is turned on again, and an OpenCode key the user set to `true` is never written over. A list or `permissions.deny` that isn't a list of names is a problem, never taken as empty, and the file is left as it is. The key, and Claude Code's `permissions` or OpenCode's `tools`, goes when magpie's were the last in it. The editor's save sends no tools, so `SaveServer` keeps those turned off. - magpie's own MCP server (`magpie-image`, and any `mcp …` run by a program named magpie) runs this computer's magpie (#1439). `InstallServer` gives it magpie by full path (`update.Program`: the AppImage, not its mount; Homebrew's opt link, not the Cellar), and that path is right only on this computer. When the library is read, and after every change, `heal` points such a server whose program isn't on this computer (another system's path, a magpie moved out of Downloads, a bare `magpie`) at this magpie, so the agents and `CheckServers` get it; a magpie program that is here (another build) and a server run by any other program stay as they are. A carried library (`Collect`, for a backup or a WebDAV or S3 sync) names it as plain `magpie`, so two computers carry the same bundle and a sync doesn't write one's path over the other's; `Put` then reads it as that computer's magpie. [`self_here.go`](../../internal/library/self_here.go) - A carried library (`Collect`) has every file of each skill, its templates and other binaries included, up to `maxCarried` (16 MiB) a file and `maxCarriedAll` (32 MiB) in all, chosen smallest first across the skills (`readSkills`), so every skill's text goes before any big file. The total keeps a sealed backup under the 64 MiB a sync reads: the files are base64 twice in it. What is left out is named in `Left`, and `Put` keeps this computer's copy of such a file in the skill it puts (`keepLeft`). [`carry.go`](../../internal/library/carry.go) diff --git a/internal/agent/agents.go b/internal/agent/agents.go index f6edde483..49052d90a 100644 --- a/internal/agent/agents.go +++ b/internal/agent/agents.go @@ -91,6 +91,7 @@ func builtins(home, cfg string) []*Agent { opencode(home, cfg), openChamber(home, cfg), mimocode(home, cfg), + deveco(home, cfg), pi(home), stepcode(home), aside(home), @@ -370,7 +371,7 @@ func magpieProviderJSONAt(shape, catalog, gw string) any { ms[m.ID] = e } return map[string]any{"npm": "@ai-sdk/openai-compatible", "name": "magpie", - "options": map[string]any{"baseURL": gw + "/v1", "apiKey": keyAt(gw)}, "models": ms} + "options": map[string]any{"baseURL": gw + "/v1", "apiKey": openCodeKeyAt(catalog, gw)}, "models": ms} case "crush": var ms []map[string]any for _, m := range models { @@ -675,7 +676,7 @@ func openCodeLike(at place, id, name, icon, bin, dir, auth string, ua []string, return "" } return wiringOff(name, path, func(k string) (string, bool) { return edit.GetJSON(path, "provider."+magpieID+".options."+k) }, - "baseURL", at.v1(), "apiKey", at.gwKey()) + "baseURL", at.v1(), "apiKey", openCodeKeyAt(id, at.gw())) }, Sync: func() error { // a model of magpie's chosen, but its provider gone from the @@ -692,6 +693,17 @@ func openCodeLike(at place, id, name, icon, bin, dir, auth string, ua []string, } } +// openCodeKeyAt is the key an OpenCode-shaped agent (id) sends the gateway +// at gw: the gateway's own, which OpenCode and MiMo Code are told apart by +// their User-Agents with, or for DevEco Code, parts of whose code still +// send OpenCode's User-Agent, one that names it. +func openCodeKeyAt(id, gw string) string { + if id == "deveco" { + return agentKeyAt(id, gw) + } + return keyAt(gw) +} + // openCodeRef is the value that makes the OpenCode config at path (agent // id's, whose catalog magpie's provider there lists) send model v. One of // magpie's goes to a provider of the file's own that already sends it to @@ -807,6 +819,31 @@ func mimocode(home, cfg string) *Agent { []string{"mimocode"}, "mimo") } +// deveco is DevEco Code, Huawei's fork of OpenCode for HarmonyOS apps +// (openharmony-sig/deveco-code, #1885). It keeps OpenCode's config shape +// in its own folder, $XDG_CONFIG_HOME/deveco, merging config.json, +// deveco.json and deveco.jsonc there (packages/opencode/src/config, +// loadGlobal); DEVECO_CONFIG_DIR adds a folder read after it, as +// OPENCODE_CONFIG_DIR does OpenCode's, so what magpie writes there wins. +// Its auth is xdg-basedir's data folder's, ~/.local/share/deveco. 0.2.3's +// requests to a provider of the config's say "deveco/0.2.3 ai-sdk/…", but +// much of the OpenCode code it keeps still sends OpenCode's own User-Agent +// (opencode/), so its key names it as well (openCodeKeyAt). +func deveco(home, cfg string) *Agent { + return openCodeLike(here(home), "deveco", "DevEco Code", "deveco-color", "deveco", + devecoDir(cfg), filepath.Join(home, ".local", "share", "deveco", "auth.json"), []string{"deveco"}) +} + +// devecoDir is the folder DevEco Code reads its user config from: +// $DEVECO_CONFIG_DIR when set to an absolute folder, else +// $XDG_CONFIG_HOME/deveco (cfg). +func devecoDir(cfg string) string { + if d := strings.TrimSpace(appdir.Getenv("DEVECO_CONFIG_DIR")); filepath.IsAbs(d) { + return d + } + return filepath.Join(cfg, "deveco") +} + func pi(home string) *Agent { return piIn(here(home)) } // piIn is Pi as it lives at a place: this machine's home, or a WSL diff --git a/internal/agent/cliupdate.go b/internal/agent/cliupdate.go index 90e83f191..47e2d1305 100644 --- a/internal/agent/cliupdate.go +++ b/internal/agent/cliupdate.go @@ -79,6 +79,9 @@ type cliSpec struct { // latest is the newest version its own updater would install, for one // not published on npm latest func() string + // only are the systems (GOOS) its vendor builds it for, when not all: + // on any other its package installs nothing that runs + only []string } var cliSpecs = map[string]cliSpec{ @@ -102,6 +105,19 @@ var cliSpecs = map[string]cliSpec{ return nil }}, "gemini": {npm: []string{"@google/gemini-cli"}, brew: []string{"gemini-cli"}}, + // DevEco Code: npm's @deveco/deveco-code, or its own installer's + // ~/.local/bin/deveco → ~/.local/share/deveco/versions//deveco + // (install), deveco.exe in ~\.local\bin on Windows (install.ps1), + // both of which deveco upgrade replaces + // Its npm package carries macOS and Windows binaries only (and + // OpenHarmony's), none for Linux. + "deveco": {npm: []string{"@deveco/deveco-code"}, only: []string{"darwin", "windows"}, + self: func(bin, real string) []string { + if strings.Contains(real, "/.local/share/deveco/versions/") || strings.HasSuffix(strings.ToLower(real), "/.local/bin/deveco.exe") { + return []string{bin, "upgrade"} + } + return nil + }}, "opencode": {npm: []string{"opencode-ai"}, brew: []string{"opencode"}, self: func(bin, real string) []string { if strings.Contains(real, "/.opencode/bin/") { diff --git a/internal/agent/cliupdate_test.go b/internal/agent/cliupdate_test.go index 7554b12a2..f9d9cd83e 100644 --- a/internal/agent/cliupdate_test.go +++ b/internal/agent/cliupdate_test.go @@ -230,6 +230,12 @@ func TestHowInstalled(t *testing.T) { if u := howInstalled(cliSpecs["opencode"], oc); u == nil || u.shown() != "opencode upgrade" { t.Errorf("opencode's installer: %+v", u) } + // DevEco Code's install: ~/.local/bin/deveco → its versions folder + file(t, filepath.Join(home, ".local/share/deveco/versions/0.2.3/deveco"), "") + deveco := link(t, filepath.Join(home, ".local/share/deveco/versions/0.2.3/deveco"), filepath.Join(home, ".local/bin/deveco")) + if u := howInstalled(cliSpecs["deveco"], deveco); u == nil || u.via != "self" || u.pkg != "@deveco/deveco-code" || !reflect.DeepEqual(u.cmd, []string{deveco, "upgrade"}) { + t.Errorf("deveco's installer: %+v", u) + } // a binary that says nothing of how it got there: the version only if u := howInstalled(cliSpecs["claude"], file(t, filepath.Join(tmp, "opt/bin/claude"), "\x7fELF")); u != nil { diff --git a/internal/agent/codex_route_test.go b/internal/agent/codex_route_test.go index d7657729f..cdd8d2b9d 100644 --- a/internal/agent/codex_route_test.go +++ b/internal/agent/codex_route_test.go @@ -25,6 +25,7 @@ func codexHome(t *testing.T, auth, config string) (home string, read func() stri t.Setenv("OPENCODE_CONFIG_DIR", "") t.Setenv("OPENCHAMBER_DATA_DIR", "") t.Setenv("MIMOCODE_HOME", "") + t.Setenv("DEVECO_CONFIG_DIR", "") t.Setenv("MINIMAX_DATA_DIR", "") // Windows' own folders too: Claude Desktop's are in LOCALAPPDATA t.Setenv("APPDATA", filepath.Join(home, "AppData", "Roaming")) diff --git a/internal/agent/connectinfo.go b/internal/agent/connectinfo.go index 2765ab133..a01996cd7 100644 --- a/internal/agent/connectinfo.go +++ b/internal/agent/connectinfo.go @@ -64,7 +64,7 @@ func (a *Agent) Source() string { if v, _ := edit.GetJSON(filepath.Join(dir, "auth.json"), "OPENAI_API_KEY"); v != "" { return "key" } - case "opencode", "mimocode": + case "opencode", "mimocode", "deveco": // the providers in its config, and those signed in through it n := map[string]bool{} var cfg map[string]json.RawMessage diff --git a/internal/agent/deveco_test.go b/internal/agent/deveco_test.go new file mode 100644 index 000000000..715690e1c --- /dev/null +++ b/internal/agent/deveco_test.go @@ -0,0 +1,143 @@ +package agent + +import ( + "path/filepath" + "strings" + "testing" + + "github.com/yetone/magpie/internal/edit" + "github.com/yetone/magpie/internal/gateway" +) + +// DevEco Code (#1885) keeps OpenCode's config shape in ~/.config/deveco: +// the first of deveco.jsonc, deveco.json and config.json there is the one +// it reads last, so the one magpie writes; DEVECO_CONFIG_DIR, read after +// all of them, when set to an absolute folder. +func TestDevEcoConfigAsItFindsIt(t *testing.T) { + home := syncHome(t) + cfg := filepath.Join(home, ".config") + dir := filepath.Join(cfg, "deveco") + if a := deveco(home, cfg); a.Path != filepath.Join(dir, "deveco.json") { + t.Fatalf("with no config, %s", a.Path) + } + writeFile(t, filepath.Join(dir, "config.json"), `{}`) + if a := deveco(home, cfg); a.Path != filepath.Join(dir, "config.json") { + t.Fatalf("with config.json only, %s", a.Path) + } + // the one DevEco Code makes on its first start, which wins its merge + writeFile(t, filepath.Join(dir, "deveco.jsonc"), `{"$schema":"https://opencode.ai/config.json"}`) + if a := deveco(home, cfg); a.Path != filepath.Join(dir, "deveco.jsonc") { + t.Fatalf("with deveco.jsonc, %s", a.Path) + } + + moved := filepath.Join(home, "deveco-cfg") + t.Setenv("DEVECO_CONFIG_DIR", moved) + if a := deveco(home, cfg); a.Path != filepath.Join(moved, "deveco.json") { + t.Fatalf("with DEVECO_CONFIG_DIR, config at %s", a.Path) + } + t.Setenv("DEVECO_CONFIG_DIR", "deveco-cfg") + if a := deveco(home, cfg); a.Path != filepath.Join(dir, "deveco.jsonc") { + t.Fatalf("with a relative DEVECO_CONFIG_DIR, config at %s", a.Path) + } +} + +// Parts of DevEco Code's code still send OpenCode's own User-Agent +// (opencode/), so the key magpie writes for it names it: its usage +// is DevEco Code's, not OpenCode's, whichever it sends. OpenCode's own +// stays the gateway's plain key. +func TestDevEcoKeyNamesIt(t *testing.T) { + syncHome(t) + key := func(id string) any { + return magpieProviderJSONFor("opencode", id).(map[string]any)["options"].(map[string]any)["apiKey"] + } + if got := key("deveco"); got != gateway.TokenFor("deveco") { + t.Errorf("deveco's key %v", got) + } + if got := key("opencode"); got != gateway.Token { + t.Errorf("opencode's key %v", got) + } +} + +// Connected, magpie's provider goes in beside the user's own, with +// DevEco Code's own key; its built-in provider, the user's own provider, +// their small model and the file's $schema stay as they were. Disconnected, +// the model they were on comes back. +func TestDevEcoConnectKeepsTheUsersOwn(t *testing.T) { + home := syncHome(t) + cfg := filepath.Join(home, ".config", "deveco", "deveco.jsonc") + writeFile(t, cfg, `{ + "$schema": "https://opencode.ai/config.json", + // mine + "model": "deveco/glm-5", + "small_model": "mine/x", + "provider": {"mine": {"name": "mine", "options": {"baseURL": "http://127.0.0.1:9/v1", "apiKey": "sk-own"}}} +}`) + a, err := Find("deveco") + if err != nil { + t.Fatal(err) + } + if a.Path != cfg { + t.Fatalf("config at %s", a.Path) + } + if a.Wired() { + t.Fatal("wired before connecting") + } + if err := a.Connect(); err != nil { + t.Fatal(err) + } + get := func(k string) string { v, _ := edit.GetJSON(cfg, k); return v } + if m := get("model"); !strings.HasPrefix(m, magpieID+"/") { + t.Fatalf("model %q after connecting", m) + } + if k := get("provider.magpie.options.apiKey"); k != gateway.TokenFor("deveco") { + t.Fatalf("apiKey %q", k) + } + if u := get("provider.magpie.options.baseURL"); u != gateway.URL()+"/v1" { + t.Fatalf("baseURL %q", u) + } + if k := get("provider.mine.options.apiKey"); k != "sk-own" { + t.Fatalf("own provider %q", k) + } + if s := get("small_model"); s != "mine/x" { + t.Fatalf("small_model %q", s) + } + if s := get("$schema"); s != "https://opencode.ai/config.json" { + t.Fatalf("$schema %q", s) + } + if !a.Wired() { + t.Fatal("not wired after connecting") + } + if c := a.Check(); c != "" { + t.Fatalf("check after connecting: %s", c) + } + // a key that isn't DevEco Code's is told as off + if err := edit.SetJSON(cfg, edit.KV{Path: "provider.magpie.options.apiKey", Value: gateway.Token}); err != nil { + t.Fatal(err) + } + if a.Check() == "" { + t.Fatal("check passes the plain key") + } + // and a sync puts DevEco Code's back + if err := a.Sync(); err != nil { + t.Fatal(err) + } + if k := get("provider.magpie.options.apiKey"); k != gateway.TokenFor("deveco") { + t.Fatalf("apiKey %q after a sync", k) + } + + if err := a.Disconnect(); err != nil { + t.Fatal(err) + } + if m := get("model"); m != "deveco/glm-5" { + t.Fatalf("model %q after disconnecting", m) + } + if s := get("small_model"); s != "mine/x" { + t.Fatalf("small_model %q after disconnecting", s) + } + if k := get("provider.mine.options.apiKey"); k != "sk-own" { + t.Fatalf("own provider %q after disconnecting", k) + } + if _, ok := edit.GetJSON(cfg, "provider.magpie"); ok { + t.Fatalf("magpie's provider left: %s", readFile(cfg)) + } +} diff --git a/internal/agent/effort_test.go b/internal/agent/effort_test.go index 09d7b65c7..217862bc5 100644 --- a/internal/agent/effort_test.go +++ b/internal/agent/effort_test.go @@ -27,6 +27,7 @@ func effortHome(t *testing.T) string { t.Setenv("LOCALAPPDATA", filepath.Join(home, "AppData", "Local")) t.Setenv("HERMES_HOME", "") t.Setenv("MIMOCODE_HOME", "") + t.Setenv("DEVECO_CONFIG_DIR", "") t.Setenv("HANA_HOME", "") t.Setenv("DSH_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 { diff --git a/internal/agent/install.go b/internal/agent/install.go index 5e9c4cd2b..703943889 100644 --- a/internal/agent/install.go +++ b/internal/agent/install.go @@ -94,6 +94,9 @@ var vendorInstall = map[string]func(goos string) []InstallCmd{ // magpie knows no command for. func installCommands(id, goos string, node bool) []InstallCmd { var out []InstallCmd + if only := cliSpecs[id].only; len(only) > 0 && !slices.Contains(only, goos) { + return nil + } if f := vendorInstall[id]; f != nil { out = append(out, f(goos)...) } diff --git a/internal/agent/install_test.go b/internal/agent/install_test.go index f34dc8c4e..d02d802ea 100644 --- a/internal/agent/install_test.go +++ b/internal/agent/install_test.go @@ -35,6 +35,9 @@ func TestInstallCommands(t *testing.T) { {"gemini", "windows", []string{"npm: npm install -g @google/gemini-cli"}}, {"opencode", "darwin", []string{"script: curl -fsSL https://opencode.ai/install | bash", "npm: npm install -g opencode-ai"}}, {"opencode", "windows", []string{"npm: npm install -g opencode-ai"}}, + {"deveco", "darwin", []string{"npm: npm install -g @deveco/deveco-code"}}, + {"deveco", "windows", []string{"npm: npm install -g @deveco/deveco-code"}}, + {"deveco", "linux", nil}, // no Linux build in its package {"pi", "linux", []string{"npm: npm install -g @earendil-works/pi-coding-agent"}}, {"cursor", "darwin", nil}, // no command magpie knows } { diff --git a/internal/agent/spelled_test.go b/internal/agent/spelled_test.go index 42f3fcb64..76ea8130d 100644 --- a/internal/agent/spelled_test.go +++ b/internal/agent/spelled_test.go @@ -12,7 +12,7 @@ import ( // leaving the row connected on the model it went back to (#835, OpenHanako's // own deepseek/deepseek-v4-pro). func TestOwnProviderNamedAsMagpies(t *testing.T) { - ids := []string{"agy", "opencode", "openchamber", "mimocode", "pi", "aside", "omo", "prime-agent", "goose", "zed", "vscode", + ids := []string{"agy", "opencode", "openchamber", "mimocode", "deveco", "pi", "aside", "omo", "prime-agent", "goose", "zed", "vscode", "crush", "dsh", "commandcode", "fx", "omp", "hermes", "morph", "kimi", "empryo", "minimax-code", "droid", "qoder", "qoder-cn", "grok", "atomcode", "cline", "snow"} for _, id := range ids { diff --git a/internal/agent/sync_test.go b/internal/agent/sync_test.go index f62abf1c0..e750d4383 100644 --- a/internal/agent/sync_test.go +++ b/internal/agent/sync_test.go @@ -34,6 +34,7 @@ func syncHome(t *testing.T) string { t.Setenv("CLAUDE_CONFIG_DIR", filepath.Join(home, ".claude")) t.Setenv("HERMES_HOME", "") t.Setenv("MIMOCODE_HOME", "") + t.Setenv("DEVECO_CONFIG_DIR", "") t.Setenv("HANA_HOME", "") t.Setenv("DSH_HOME", "") t.Setenv("OMO_CODING_AGENT_DIR", "") diff --git a/internal/agent/useragent_test.go b/internal/agent/useragent_test.go index 8ad541d26..0549fd3da 100644 --- a/internal/agent/useragent_test.go +++ b/internal/agent/useragent_test.go @@ -14,6 +14,7 @@ func TestAgentOf(t *testing.T) { "GeminiCLI/0.9.0 (darwin; arm64)": "gemini", "opencode/1.2.3": "opencode", "mimocode/1.2.3": "mimocode", + "deveco/0.2.3 ai-sdk/provider-utils/4.0": "deveco", // 0.2.3 sends ai-sdk/provider-utils/4.0.23 "curl/8.4.0": "curl", "oh-my-pi/1.0": "omp", "command-code/2.0": "commandcode", @@ -49,7 +50,7 @@ func TestEveryAgentNamedByItsKey(t *testing.T) { t.Errorf("%s's key names %q", a.ID, got) } } - for _, id := range []string{"minimax-code", "stepcode", "jcode", "prime-agent", "snow"} { + for _, id := range []string{"minimax-code", "stepcode", "jcode", "prime-agent", "snow", "deveco"} { if !seen[id] { t.Errorf("%s isn't among the agents usage knows", id) } diff --git a/internal/agent/wsl_more_test.go b/internal/agent/wsl_more_test.go index dd41e15f8..d57f6f005 100644 --- a/internal/agent/wsl_more_test.go +++ b/internal/agent/wsl_more_test.go @@ -66,7 +66,7 @@ func wslFinds(k wslKind) (probe string, has map[string]bool, versions map[string func moveHostDirs(t *testing.T) string { t.Helper() moved := t.TempDir() - for _, v := range []string{"OPENCODE_CONFIG_DIR", "MIMOCODE_HOME", "KIMI_CODE_HOME", "KIMI_SHARE_DIR", "PI_CODING_AGENT_DIR", + for _, v := range []string{"OPENCODE_CONFIG_DIR", "MIMOCODE_HOME", "DEVECO_CONFIG_DIR", "KIMI_CODE_HOME", "KIMI_SHARE_DIR", "PI_CODING_AGENT_DIR", "HERMES_HOME", "GROK_HOME", "FACTORY_HOME_OVERRIDE", "MINIMAX_DATA_DIR", "QODER_CONFIG_DIR", "QODERCN_CONFIG_DIR", "DSH_HOME", "MISTER_MORPH_CONFIG", "CODEBUDDY_CONFIG_DIR", "CLINE_DIR", "CLINE_DATA_DIR", "ATOMCODE_HOME", "REASONIX_HOME", "SNOW_CONFIG_DIR", "APPDATA"} { t.Setenv(v, filepath.Join(moved, v)) diff --git a/internal/agentenv/agentenv.go b/internal/agentenv/agentenv.go index 6f3ae5413..5de6df99c 100644 --- a/internal/agentenv/agentenv.go +++ b/internal/agentenv/agentenv.go @@ -67,6 +67,8 @@ var Vars = []string{ // MiMo Code, MiniMax Code, OpenHanako, Hermes, dsh, WorkBuddy, CodeBuddy Code "MIMOCODE_HOME", "MINIMAX_DATA_DIR", "HANA_HOME", "HERMES_HOME", "DSH_HOME", "WORKBUDDY_CONFIG_DIR", "CODEBUDDY_CONFIG_DIR", + // DevEco Code's extra config folder, read after ~/.config/deveco + "DEVECO_CONFIG_DIR", // alma-server's data folder (Alma without a desktop, on Linux) "ALMA_DATA_DIR", // Reasonix Studio and its native CLI share this config home diff --git a/internal/cli/main.go b/internal/cli/main.go index e6bedab9b..daaf32468 100644 --- a/internal/cli/main.go +++ b/internal/cli/main.go @@ -125,7 +125,7 @@ const usage = `magpie — one place to pick every agent's model magpie update mirror [|off] the mirror every update, the app's own too, is downloaded through magpie update auto [on|off] [30m|1h|6h|24h] whether the app looks for updates by itself, and how often (6h) -agents: claude (cc), codex, gemini, opencode (oc), mimocode, pi, goose, cursor, zed, copilot, crush, aside +agents: claude (cc), codex, gemini, opencode (oc), mimocode, deveco, pi, goose, cursor, zed, copilot, crush, aside ` var ( diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index cdfafa494..2d922caed 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -998,7 +998,7 @@ function connectable(a) { } // PICKS_IN is where an agent picks a model itself, for the words under it. -const PICKS_IN = { codex: "/model", claude: "/model", opencode: "/models", pi: "/model", droid: "/model", kimi: "/model", grok: "/model", "minimax-code": "/model", dsh: "/model", crush: "ctrl+p", omp: "/model", qwen: "/model", mimocode: "/model" }; +const PICKS_IN = { codex: "/model", claude: "/model", opencode: "/models", pi: "/model", droid: "/model", kimi: "/model", grok: "/model", "minimax-code": "/model", dsh: "/model", crush: "ctrl+p", omp: "/model", qwen: "/model", mimocode: "/model", deveco: "/models" }; function connectSaid(a) { if (!a.wired) return t("Not connected · {agent} uses its own settings", { agent: a.name }); diff --git a/internal/gui/assets/icons/deveco-color.svg b/internal/gui/assets/icons/deveco-color.svg new file mode 100644 index 000000000..dcf6b99db --- /dev/null +++ b/internal/gui/assets/icons/deveco-color.svg @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/internal/gui/assets/library.js b/internal/gui/assets/library.js index d7fcc929e..38e4fef19 100644 --- a/internal/gui/assets/library.js +++ b/internal/gui/assets/library.js @@ -1252,7 +1252,7 @@ w.append(el("span", "", t("{agent} reads {file} instead of this file while it has anything in it.", { agent: a.name, file: tilde(a.override) }) + " "), pathLink(a.override)); det.append(w); } - if (a.agent === "opencode" || a.agent === "mimocode") det.append(el("p", "lib-aside", t("{agent} reads Claude Code's CLAUDE.md when it has no AGENTS.md of its own.", { agent: a.name }))); + if (a.agent === "opencode" || a.agent === "mimocode" || a.agent === "deveco") det.append(el("p", "lib-aside", t("{agent} reads Claude Code's CLAUDE.md when it has no AGENTS.md of its own.", { agent: a.name }))); if (a.agent === "agy") det.append(el("p", "lib-aside", t("Antigravity reads Gemini CLI's ~/.gemini/GEMINI.md as well as this file, so text given to both is read twice."))); const lab = el("label", "lib-lab", t("Only for {agent}, after the shared text", { agent: a.name })); const ta = el("textarea", "lib-text small"); diff --git a/internal/gui/assets/routing.js b/internal/gui/assets/routing.js index 0cc4b1ffa..751ffbd28 100644 --- a/internal/gui/assets/routing.js +++ b/internal/gui/assets/routing.js @@ -1126,7 +1126,7 @@ const HUES = { claude: "#d97757", codex: "#6366f1", gemini: "#0ea5e9", copilot: "#a855f7", cursor: "#14b8a6", opencode: "#eab308", crush: "#ec4899", goose: "#84cc16", pi: "#10b981", omp: "#f43f5e", omo: "#7c3aed", dsh: "#06b6d4", commandcode: "#f97316", - mimocode: "#3b82f6", + mimocode: "#3b82f6", deveco: "#3c99cc", }; const SPARE = ["#8b5cf6", "#22c55e", "#e11d48", "#0891b2", "#ca8a04", "#db2777", "#2563eb", "#65a30d"]; function hueOf(id) { diff --git a/internal/gui/tests/library-deveco.test.cjs b/internal/gui/tests/library-deveco.test.cjs new file mode 100644 index 000000000..357a33623 --- /dev/null +++ b/internal/gui/tests/library-deveco.test.cjs @@ -0,0 +1,88 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// DevEco Code (#1885) is OpenCode underneath: with no AGENTS.md of its own +// it reads Claude Code's CLAUDE.md, and the Library says so on its +// instructions row, as it does for OpenCode and MiMo Code. Its icon is the +// official logo and draws. Chromium and WebKit, every language; no backend, +// the API is faked here. +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 HOME = "/Users/foobra"; +const library = { + dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME, + agents: [{ id: "deveco", name: "DevEco Code", icon: "deveco-color", instructions: `${HOME}/.config/deveco/AGENTS.md` }], + instructions: { + shared: "Be brief.", + sets: [{ id: "default", name: "", active: true, text: "Be brief." }], + agents: [{ agent: "deveco", name: "DevEco Code", icon: "deveco-color", path: `${HOME}/.config/deveco/AGENTS.md`, on: true, extra: "" }], + }, + foundServers: [], projects: [], foundSkills: [], skills: [], servers: [], +}; + +function server(lang) { + 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: { agents: [], profiles: [], settings: { lang, theme: "light" } } }); + if (url.pathname === "/api/plugins") return route.fulfill({ json: { plugins: [] } }); + if (url.pathname === "/api/library") return route.fulfill({ json: library }); + if (url.pathname === "/api/usage/quotas") return route.fulfill({ json: [] }); + if (url.pathname === "/api/groups") return route.fulfill({ json: { groups: [] } }); + if (url.pathname === "/api/providers") return route.fulfill({ json: { providers: [], 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 }); + }; +} + +const view = "#view-library"; +const note = { + en: "DevEco Code reads Claude Code's CLAUDE.md when it has no AGENTS.md of its own.", + zh: "DevEco Code 在没有自己的 AGENTS.md 时会读取 Claude Code 的 CLAUDE.md。", + "zh-TW": "DevEco Code 在沒有自己的 AGENTS.md 時會讀取 Claude Code 的 CLAUDE.md。", + ja: "DevEco Code は独自の AGENTS.md がないとき、Claude Code の CLAUDE.md を読み込みます。", + de: "DevEco Code liest die CLAUDE.md von Claude Code, wenn es keine eigene AGENTS.md hat.", +}; + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + test(engine + ": DevEco Code's instructions row says it reads CLAUDE.md, and its icon draws", async (t) => { + assert(["chromium", "webkit"].includes(engine), "BROWSER must be chromium or webkit"); + 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 Object.keys(note)) { + await t.test(lang, async () => { + const ctx = await browser.newContext({ viewport: { width: 980, height: 860 }, reducedMotion: "reduce" }); + await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "instructions"); } catch {} }); + const page = await ctx.newPage(); + page.setDefaultTimeout(5000); + page.on("pageerror", (e) => errors.push(e.message)); + await page.route("**/*", server(lang)); + await page.goto("http://magpie.test/"); + await page.locator('button[data-view="library"]').click(); + const row = page.locator(`${view} .lib-row`, { hasText: "DevEco Code" }); + await row.first().click(); + await page.locator(`${view} p.lib-aside`, { hasText: note[lang] }).waitFor(); + // the icon as the GUI draws a -color one: an of icons/deveco-color.svg + const drawn = await page.evaluate(async () => { + const img = new Image(); + img.src = "icons/deveco-color.svg"; + try { await img.decode(); } catch { return 0; } + return img.naturalWidth; + }); + assert(drawn > 0, "icons/deveco-color.svg doesn't draw"); + assert.deepEqual(errors, []); + await ctx.close(); + }); + } + }); +} diff --git a/internal/library/library_test.go b/internal/library/library_test.go index 751b67453..4ac2e4ced 100644 --- a/internal/library/library_test.go +++ b/internal/library/library_test.go @@ -55,7 +55,7 @@ func sandbox(t *testing.T) string { } for _, f := range []string{ ".claude/settings.json", ".codex/config.toml", ".gemini/settings.json", - ".config/opencode/opencode.json", ".config/mimocode/mimocode.json", ".pi/agent/settings.json", ".config/goose/config.yaml", + ".config/opencode/opencode.json", ".config/mimocode/mimocode.json", ".config/deveco/deveco.jsonc", ".pi/agent/settings.json", ".config/goose/config.yaml", ".cursor/cli-config.json", ".copilot/settings.json", ".config/crush/crush.json", ".dsh/profiles/web/cordis.patch.yml", } { write(t, filepath.Join(h, f), "") @@ -107,7 +107,7 @@ func ids(ts []*Target) []string { func TestTargets(t *testing.T) { sandbox(t) got := ids(Targets()) - for _, id := range []string{"claude", "codex", "gemini", "opencode", "mimocode", "pi", "goose", "cursor", "copilot", "crush", "dsh"} { + for _, id := range []string{"claude", "codex", "gemini", "opencode", "mimocode", "deveco", "pi", "goose", "cursor", "copilot", "crush", "dsh"} { if !slices.Contains(got, id) { t.Errorf("%s not a target: %v", id, got) } diff --git a/internal/library/targets.go b/internal/library/targets.go index 06335c75f..e473056a6 100644 --- a/internal/library/targets.go +++ b/internal/library/targets.go @@ -113,7 +113,11 @@ func targetOf(a *agent.Agent) *Target { t.Instructions = filepath.Join(d, "GEMINI.md") t.MCP = &mcpFile{Path: filepath.Join(d, "mcp_config.json"), Format: fmtAntigravity} t.Skills = filepath.Join(d, "skills") - case "opencode": + case "opencode", "deveco": + // DevEco Code is OpenCode's fork and reads as it does: AGENTS.md + // in its config folder, else Claude Code's CLAUDE.md, skills there + // and under ~/.claude and ~/.agents (packages/opencode/src/session + // /instruction.ts, skill/index.ts) d := filepath.Dir(a.Path) t.Instructions = filepath.Join(d, "AGENTS.md") t.Note = "opencode-claude" @@ -533,7 +537,7 @@ func Targets() []*Target { // readsShared are the agents that read ~/.agents/skills as well as their // own folder (each one's docs or source). -var readsShared = []string{"codex", "gemini", "opencode", "crush", "dsh", "commandcode", "devin", "droid", "cline", "grok", "grok-app", "fx", "alma"} +var readsShared = []string{"codex", "gemini", "opencode", "deveco", "crush", "dsh", "commandcode", "devin", "droid", "cline", "grok", "grok-app", "fx", "alma"} // readsWith adds to each agent's SkillsAlso the agents whose folder it // reads skills from too: one that is the very same folder (Kimi Code's, diff --git a/site/public/docs/ja/start.html b/site/public/docs/ja/start.html index 5ede53028..e11e46c6f 100644 --- a/site/public/docs/ja/start.html +++ b/site/public/docs/ja/start.html @@ -128,7 +128,7 @@

キーは ~/.config/magpie/providers.json に保存され、あなただけが読めます。magpie はシェルの環境変数からキーを読みません。追加したものだけが使われます。

2 · エージェントごとにモデルを選ぶ

-

Agents タブには、このマシンにインストールまたは設定されているエージェントごとに行があります。magpie が対応しているのは Claude Code、Codex、Gemini CLI、OpenCode、MiMo Code、Pi、Goose、Cursor、Copilot CLI、Crush、DeepSeek Harness、Command Code、omp、OmO、Devin、Hermes Agent、MiniMax Code、Grok Build、ZCode、OpenHanako、Alma です。

+

Agents タブには、このマシンにインストールまたは設定されているエージェントごとに行があります。magpie が対応しているのは Claude Code、Codex、Gemini CLI、OpenCode、MiMo Code、DevEco Code、Pi、Goose、Cursor、Copilot CLI、Crush、DeepSeek Harness、Command Code、omp、OmO、Devin、Hermes Agent、MiniMax Code、Grok Build、ZCode、OpenHanako、Alma です。

エージェントタブ:エージェントごとに使用中のモデルを示す行と、下部に保存済みのプロファイル @@ -145,7 +145,7 @@ エージェントmagpie 経由のモデルで書き込まれる内容 Claude Code~/.claude/settings.json:env ブロック内の ANTHROPIC_BASE_URL、ANTHROPIC_AUTH_TOKEN とモデル関連の変数 Codex~/.codex/config.toml:[model_providers.magpie] テーブルとモデル、一覧は magpie-models.json。ChatGPT のサインインには手を加えません - OpenCode、MiMo Code、Pi、Crushmagpie プロバイダのエントリと magpie/provider/model + OpenCode、MiMo Code、DevEco Code、Pi、Crushmagpie プロバイダのエントリと magpie/provider/model AtomCode~/.atomcode/config.toml:magpie プロバイダアカウントと、カタログ内の各モデルのエントリ Snow CLI~/.snow/profiles/magpie.json:magpie プロファイルを作り、使用中のプロファイルにする(Snow App は「Sync Snow CLI API config」で取り込む) Gemini CLIゲートウェイを指す GOOGLE_GEMINI_BASE_URL、API キー認証、そしてモデル diff --git a/site/public/docs/start.html b/site/public/docs/start.html index 79e0bd684..bae8769ad 100644 --- a/site/public/docs/start.html +++ b/site/public/docs/start.html @@ -128,7 +128,7 @@

Keys live in ~/.config/magpie/providers.json, readable by you alone. magpie never reads keys from your shell environment: what you add is what it uses.

2 · Pick a model for each agent

-

The Agents tab has a row for each agent installed or configured on this machine. magpie knows Claude Code, Codex, Gemini CLI, OpenCode, MiMo Code, Pi, Goose, Cursor, Copilot CLI, Crush, DeepSeek Harness, Command Code, omp, OmO, Devin, Hermes Agent, MiniMax Code, Grok Build, ZCode, OpenHanako and Alma.

+

The Agents tab has a row for each agent installed or configured on this machine. magpie knows Claude Code, Codex, Gemini CLI, OpenCode, MiMo Code, DevEco Code, Pi, Goose, Cursor, Copilot CLI, Crush, DeepSeek Harness, Command Code, omp, OmO, Devin, Hermes Agent, MiniMax Code, Grok Build, ZCode, OpenHanako and Alma.

The Agents tab: one row per agent with the model it uses, and saved profiles at the bottom @@ -145,7 +145,7 @@ AgentWhat a model through magpie writes Claude Code~/.claude/settings.json: ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN and the model variables in its env block Codex~/.codex/config.toml: a [model_providers.magpie] table and the model, with the list in magpie-models.json. Your ChatGPT sign-in is left alone - OpenCode, MiMo Code, Pi, CrushA magpie provider entry, and magpie/provider/model + OpenCode, MiMo Code, DevEco Code, Pi, CrushA magpie provider entry, and magpie/provider/model AtomCode~/.atomcode/config.toml: a magpie provider account and one model entry per catalog model Snow CLI~/.snow/profiles/magpie.json: a magpie profile, made the active one (Snow App takes it in with "Sync Snow CLI API config") Gemini CLIGOOGLE_GEMINI_BASE_URL pointed at the gateway, API-key auth, and the model diff --git a/site/public/docs/zh/start.html b/site/public/docs/zh/start.html index d18adf0a6..77d3a6383 100644 --- a/site/public/docs/zh/start.html +++ b/site/public/docs/zh/start.html @@ -128,7 +128,7 @@

密钥保存在 ~/.config/magpie/providers.json,只有你自己可读。magpie 从不读取 shell 环境变量里的密钥:你添加什么,它就用什么。

2 · 给每个 Agent 选模型

-

Agent 标签页里,本机装了或配置过的每个 Agent 各占一行。magpie 支持 Claude Code、Codex、Gemini CLI、OpenCode、MiMo Code、Pi、Goose、Cursor、Copilot CLI、Crush、DeepSeek Harness、Command Code、omp、OmO、Devin、Hermes Agent、MiniMax Code、Grok Build、ZCode、OpenHanako 和 Alma。

+

Agent 标签页里,本机装了或配置过的每个 Agent 各占一行。magpie 支持 Claude Code、Codex、Gemini CLI、OpenCode、MiMo Code、DevEco Code、Pi、Goose、Cursor、Copilot CLI、Crush、DeepSeek Harness、Command Code、omp、OmO、Devin、Hermes Agent、MiniMax Code、Grok Build、ZCode、OpenHanako 和 Alma。

Agent 页:每个 Agent 一行,显示当前模型,底部是保存的方案 @@ -145,7 +145,7 @@ Agent通过 magpie 选模型时写入什么 Claude Code~/.claude/settings.json:env 里的 ANTHROPIC_BASE_URL、ANTHROPIC_AUTH_TOKEN 和模型变量 Codex~/.codex/config.toml:一个 [model_providers.magpie] 表和模型,模型列表写在 magpie-models.json。你的 ChatGPT 登录不受影响 - OpenCode、MiMo Code、Pi、Crush一个 magpie 供应商条目,以及 magpie/provider/model + OpenCode、MiMo Code、DevEco Code、Pi、Crush一个 magpie 供应商条目,以及 magpie/provider/model AtomCode~/.atomcode/config.toml:一个 magpie 供应商账号,以及目录中每个模型各自的条目 Snow CLI~/.snow/profiles/magpie.json:一个 magpie 配置文件,并设为当前配置(Snow App 用“同步 Snow CLI API 配置”导入) Gemini CLIGOOGLE_GEMINI_BASE_URL 指向网关、API 密钥认证,以及模型 diff --git a/site/public/icons/deveco-color.svg b/site/public/icons/deveco-color.svg new file mode 100644 index 000000000..dcf6b99db --- /dev/null +++ b/site/public/icons/deveco-color.svg @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/site/public/index.html b/site/public/index.html index df0fe7208..364e5ebe6 100644 --- a/site/public/index.html +++ b/site/public/index.html @@ -466,6 +466,7 @@ footer a:hover { color: var(--ink); }
  • Gemini CLI
  • OpenCode
  • MiMo Code
  • +
  • DevEco Code
  • Pi
  • Goose
  • Cursor CLI