Files
plugins/README.md
T
如是andyetone 42783f0033 trae: one package, two realms — Trae Global folds into packages/trae (#23)
* trae: one package, two realms — Trae Global folds into packages/trae

The review asked for this and it is the right shape: the two deployments
share one implementation. 86 of the 89 top-level names were already the
same code; what differed was a table's worth of values (hosts, client,
versions, usage page, fallback models, error codes) and two realm-only
branches. A separate copy meant every request, stream and tool-call fix
had to be made twice, and it had already drifted (the 0.1.15 Max fix
came back as a bug there).

packages/trae now holds a SITES table with two entries — trae-cn and
trae-global — and makePlugin(site) builds a provider from one. Exported
as TraeCNAuthPlugin and TraeGlobalAuthPlugin. The CN values are moved
verbatim, not re-derived: same hosts, client id, app id, IDE/client
versions, plugin version, brand, functions, fallback models, credits
page, and its own check-in pages. The international entry carries what
only it has: the second (US) deployment and the region that selects it,
the dollar billing's entitlements page, its own model names, and its
extra lapse/quota codes (20101, 4011).

The CN plugin needs the stream fix too (the review's point), so the
AbortController the loader now builds per request, openai()'s abort, and
sse()'s finally are in this one implementation for both realms — as is
the wrong-function retry releasing the read it leaves behind.

fake.mjs takes a realm id, defaulting to CN so every test written before
the fold is unchanged. The global tests move to global.test.mjs, plus
new ones for what only the international realm does: the US/SG routing
of a request and of a saved sign-in, its own error codes and error name,
the dollar usage page, and its fallback model list. chatModel gains the
picker's invisible-entry filter (paygo/auto twins, search agents) and
the config hook names the realm's own provider.

The acceptance test: packages/trae/*.test.mjs' 48 CN tests are untouched
and green — that is the proof the refactor changed no CN behaviour, with
its constants verified line by line against HEAD. bun test: 63 pass
(48 CN + 15 global); bun scripts/check.mjs trae: ok.

registry.json: one entry, providers [trae-cn, trae-global]. README: both
realms, each realm's endpoints, usage page and codes; the verification
range stated honestly (CN never run live; Global on one Free SG account,
no Pro and no US account).

* trae: Trae CN's model lists stay whole; only Global hides is_invisible_to_user

The fold filtered is_invisible_to_user for both realms, which took 40 of
Trae CN's 76 models out of its list. CN is served as before; Global (a
site flag, hidesInvisible) keeps the filter. Also: the unsupported-request
error names the realm, and two duplicated/merged comments are tidied.

---------

Co-authored-by: yetone <yetoneful@gmail.com>
2026-10-05 17:18:12 +08:00

107 lines
5.1 KiB
Markdown

# magpie-community plugins
[OpenCode](https://opencode.ai) provider plugins for coding-plan
subscriptions, maintained by the community. Each package signs in to one
subscription and makes its requests. The packages work in OpenCode and in
[magpie](https://usemagpie.ai), which runs OpenCode's provider plugins.
| Package | Signs in to | Provider id |
|---|---|---|
| [cline](packages/cline) | Cline (cline.bot): usage-billed models, ClinePass's and Cline's free ones, with Cline's device sign-in or an API key | `cline` |
| [commandcode](packages/commandcode) | Command Code plans (Pro, GOAT, Max, Ultra, Go, Teams Pro) | `commandcode-plan` |
| [cursor](packages/cursor) | Cursor subscriptions (Pro, Pro+, Ultra, Teams), on the API cursor-agent talks to | `cursor` |
| [devin](packages/devin) | Devin subscription (the devin CLI's account) | `devin` |
| [factory](packages/factory) | Factory (Droid) subscription | `factory` |
| [grok](packages/grok) | Grok (SuperGrok / X Premium+), through the Grok Build CLI's sign-in | `grok` |
| [kiro](packages/kiro) | Kiro (Free, Pro, Pro+, Power), with Kiro's sign-in, kiro-cli's or the IDE's, or an API key | `kiro` |
| [minimax](packages/minimax) | MiniMax Code (China): account credits and M Plan, with MiniMax Code's device sign-in | `minimax-code` |
| [minimax](packages/minimax) | MiniMax Code (international): account credits and M Plan, with MiniMax Code's device sign-in | `minimax-code-global` |
| [mimo](packages/mimo) | Xiaomi MiMo, with a Xiaomi account | `mimo-app` |
| [qoder](packages/qoder) | Qoder subscription (qoder.com), with Qoder's device sign-in | `qoder` |
| [qoder](packages/qoder) | Qoder CN subscription (qoder.cn), with Qoder CN's device sign-in | `qoder-cn` |
| [trae](packages/trae) | Trae CN (trae.cn) and Trae international (trae.ai), free tier included, with Trae's browser sign-in (experimental) | `trae-cn`, `trae-global` |
| [workbuddy](packages/workbuddy) | WorkBuddy (China build, CodeBuddy plan) | `workbuddy` |
| [workbuddy](packages/workbuddy) | WorkBuddy (international build) | `workbuddy-ai` |
| [zcode](packages/zcode) | ZCode: Z.ai / BigModel (智谱) GLM Coding Plan, team seats, Start Plan | `zcode` |
| [zed](packages/zed) | Zed (Pro, Pro Trial, Student, Business): Anthropic, OpenAI, Google and xAI models hosted by Zed | `zed` |
## Use
magpie:
```sh
magpie plugin add @magpie-community/opencode-<name>-auth
magpie plugin login <provider id>
```
In the app, the Plugins tab lists these packages: install one there, then
sign in.
OpenCode, in `opencode.json`:
```json
{ "plugin": ["@magpie-community/opencode-<name>-auth"] }
```
then `opencode auth login`.
## Writing a package
Each package is a folder under `packages/<name>/`:
- **`package.json`**
- name: `@magpie-community/opencode-<name>-auth`
- `"type": "module"`, `"main": "./index.mjs"`
- version, `"license": "MIT"`
- no runtime dependencies unless one is really needed. Bun's and Node's
`fetch`, `crypto` and `fs` usually cover it.
- **`index.mjs`**
- Exports one async plugin function, as OpenCode's `Plugin` type
describes.
- Returns an `auth` hook: `{ provider, loader, methods }`.
- A browser sign-in is `{ type: "oauth", label, prompts?, authorize }`.
`authorize` returns `{ url, instructions, method: "auto" | "code", callback }`.
- A key is `{ type: "api", label }`.
- `loader(getAuth, provider)` returns what the AI SDK is given:
`baseURL`, `apiKey`, `headers` and a `fetch` that signs each request
and refreshes the token (saving it with `client.auth.set`).
- A provider that models.dev doesn't list is declared in a `config` hook
that sets `config.provider[<id>] = { name, npm, api, models }`. The npm
field names the AI SDK package the models speak:
`@ai-sdk/openai-compatible` (chat completions), `@ai-sdk/openai`
(Responses) or `@ai-sdk/anthropic` (Messages).
- A list the account decides goes in the `provider: { id, models(provider, { auth }) }`
hook.
- **`README.md`**: what the package signs in to, how, where the sign-in is
kept, and the models.
The provider id is the one magpie's built-in subscription has (`grok`,
`zcode`, `workbuddy`, `commandcode-plan`, …). While magpie still has the
built-in, the plugin's provider shows as `<id>-plugin`. Once the built-in
is gone, it takes over the same id, so an agent set to `<id>/<model>` keeps
working.
## Checking a package
```sh
bun scripts/check.mjs [<name>] # loads each plugin and checks its hooks; signs in to nothing
MAGPIE=/path/to/magpie scripts/try.sh <name> [login <id> | provider test <id>-plugin]
```
`try.sh` runs magpie in a sandbox HOME (`.sandbox/<name>`), so your own
magpie, agents and sign-ins are left alone.
## License
MIT
## The market
`registry.json` is the list magpie's Plugins tab shows. The packages here
come first, then other OpenCode provider plugins worth knowing. magpie
fetches it every few hours and keeps a copy built into the app for when
it can't. To list a plugin, add an entry with its npm `package`, a
`name`, `providers` (the provider ids it signs in to), an `icon` and a
`summary` in English and Chinese (`{"en": …, "zh": …}`), and open a pull
request.