Files
plugins/README.md
T
volcanic 8b4f759455 Cline: usage billing, ClinePass and the free models, with Cline's own device sign-in or an API key (#2)
* Cline: usage-billed models, ClinePass's and Cline's free ones, on your own Cline account — Cline's device sign-in (WorkOS device code, traded at /auth/register) or an API key; chat completions on api.cline.bot with Cline's own client-identity headers (pinned to the current CLI release — what the free models' gate reads), the non-stream data envelope unwrapped, the model list from Cline's recommended-models feed, usage from the account's balance (counted in millionths of a dollar). cline-pass answers 403 ENTITLEMENT_ERROR without the subscription and the message says so; so does an empty balance, with the top-up URL.

* cline 0.1.0: the pinned CLI version and the workos: prefix move to Cline's current client — apps/cli is at 3.0.68, and provider-auth-registry's formatProviderOAuthApiKey lowercases before it startsWith("workos:") so a token stored as WorkOS: is not double-prefixed here either; bearerOf's "once" test fails against 0.1.0.

* cline 0.1.0: the model list is Cline's whole catalog, not just the recommended feed — the title promised usage-billed models but the plugin read only recommended-models (6 paid models), while Cline's own clients also load /api/v1/ai/cline/models (loadCloudModels), so most usage-billed models were missing. The four feed arrays are now read by name instead of walking every value (a tag or description could become a model, and one in both recommended and free lost its "(free)"), clineCloud stays out as the client leaves it out, a raw-id name is prettified, and the bundled snapshot drops gemini-2.5-pro and minimax-m2.5 (not in cline-recommended.generated.ts) and gains the missing cline-pass/* entries; the parseFeed, snapshot and models-merge tests fail against 0.1.0.

* cline 0.1.0: a refresh failure no longer fails a request that still has a good token, and a rotated pair survives a failing auth.set — a 4-minute token plus a 500 from /auth/refresh answered the chat 502 and never sent it, and with auth.set throwing the next request re-spent the old refresh token, got invalid_grant and marked the account expired. fresh now keeps the current token on a transient failure while it is still good (Cline's getValidClineCredentials), failing only once it has expired, and the latest rotated pair is held in memory beside the save (kiro's held), used when getAuth still hands back the spent token; the still-good-token and rotated-pair tests fail against 0.1.0.

* cline 0.1.0: failure() keys on Cline's error codes and whole phrases, not loose substrings — a 403 whose text mentioned "tokens" (max_tokens exceeds…) became "the sign-in lapsed — sign in again" and lost the real message, and any message containing "credit" became a 429 usage limit. The 401/403 token check, the out-of-credits and entitlement checks and the 429 check now match what Cline's client matches (ENTITLEMENT_ERROR, insufficient_credits, SPEND_LIMIT_EXCEEDED, the not-subscribed wording), and a renewed token clears the lapse mark through the error path too as qoder's renewed() does; the codes-and-phrases and renewed-mark tests fail against 0.1.0.

* cline 0.1.0: device polling grows the interval for good and rides out a bad poll — slow_down raised it for one poll only (RFC 8628 and Cline's pollWorkOSTokens do interval += 1 permanently), the minimum was 0.25s where the client clamps to 1s, and a single 5xx, non-JSON reply or network error ended the sign-in with "the token answer had no access token". The poll now keeps polling through those; the slow_down, one-second and bad-poll tests fail against 0.1.0.

* cline 0.1.0: the held pair covers every refresh token this run has spent, not only the last — when auth.set goes on failing (which a store that failed once usually does) getAuth keeps handing back the first pair, and a second rotation overwrote held.from, so the third request refreshed the already-spent r1 again: /auth/refresh went r1, r2, r1 and the chat answered 401 expired. held.from is a Set every rotation adds to now, and the held pair is used whenever the refresh token getAuth hands back is in it; the two-rotation test fails against 0.1.0 (200, 200, 401).

* cline 0.1.0: X-CORE-VERSION moves to 0.0.90 with the CLI release — the header set pinned 3.0.68 beside 0.0.89, but cline@3.0.68 depends on @cline/core 0.0.90 (0.0.89 is what 3.0.67 shipped) and resolveProviderRequestHeaders sends X-CORE-VERSION from that dependency, so the number the comment calls the one that has to match was a release behind; the client-header test pins the pair now and fails against 0.1.0.

* cline 0.1.0: a poll reply that isn't JSON and isn't a 5xx fails the sign-in at once — a body that wouldn't parse was read as WorkOS having a moment, so an HTML 400 (a proxy's error page, say) kept the poll going to the deadline, ten minutes, before failing there anyway. Only a network error and a 5xx are a poll to try again now; a 4xx that isn't JSON is the poll refused. The refusal test fails against 0.1.0.

* cline 0.1.0: a renewal's mark survives a network error on the chat itself — the 502 the fetch throws after a renewal returned without signed(..., renewed(cred)), so the request that never left the machine dropped the mark while the request that came back refused kept it; it is wrapped the way the !res.ok path is. The network-error test fails against 0.1.0.

* cline 0.1.0: the held pair is kept per rotation chain, so no account is sent on another's token — magpie calls ClinePlugin once for the provider and hands every account its own getAuth, so the one `held` pair outlived them: with two accounts, a save failing every time and every token wanting renewal, A, B, A went out as A-jwt1, B-jwt1, B-jwt2 and A's third request refreshed with B's token, spending it and billing B (yetone's two-loader repro, page-for-page the same). A spent refresh token now maps to the newest pair its own chain reached — the token getAuth handed back and the one the refresh spent both point at that chain — so a request offering either finds its own account's pair; the per-chain test fails against 0.1.0 on the third request's Authorization, with the 51 before it passing.
2026-10-02 23:03:54 +08:00

4.9 KiB

magpie-community plugins

OpenCode 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, which runs OpenCode's provider plugins.

Package Signs in to Provider id
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 Command Code plans (Pro, GOAT, Max, Ultra, Go, Teams Pro) commandcode-plan
cursor Cursor subscriptions (Pro, Pro+, Ultra, Teams), on the API cursor-agent talks to cursor
devin Devin subscription (the devin CLI's account) devin
factory Factory (Droid) subscription factory
grok Grok (SuperGrok / X Premium+), through the Grok Build CLI's sign-in grok
kiro Kiro (Free, Pro, Pro+, Power), with Kiro's sign-in, kiro-cli's or the IDE's, or an API key kiro
minimax MiniMax Code (China): account credits and M Plan, with MiniMax Code's device sign-in minimax-code
minimax MiniMax Code (international): account credits and M Plan, with MiniMax Code's device sign-in minimax-code-global
mimo Xiaomi MiMo, with a Xiaomi account mimo-app
qoder Qoder subscription (qoder.com), with Qoder's device sign-in qoder
qoder Qoder CN subscription (qoder.cn), with Qoder CN's device sign-in qoder-cn
workbuddy WorkBuddy (China build, CodeBuddy plan) workbuddy
workbuddy WorkBuddy (international build) workbuddy-ai
zcode ZCode: Z.ai / BigModel (智谱) GLM Coding Plan, team seats, Start Plan zcode
zed Zed (Pro, Pro Trial, Student, Business): Anthropic, OpenAI, Google and xAI models hosted by Zed zed

Use

magpie:

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:

{ "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

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.