# 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 | |---|---|---| | [commandcode](packages/commandcode) | Command Code plans (Pro, GOAT, Max, Ultra, Go, Teams Pro) | `commandcode-plan` | | [factory](packages/factory) | Factory (Droid) subscription | `factory` | | [grok](packages/grok) | Grok (SuperGrok / X Premium+), through the Grok Build CLI's sign-in | `grok` | | [mimo](packages/mimo) | Xiaomi MiMo, with a Xiaomi account | `mimo-app` | | [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` | ## Use magpie: ```sh magpie plugin add @magpie-community/opencode--auth magpie plugin login ``` The same actions are in the app: Settings → Plugins, then Add provider → From plugins. OpenCode, in `opencode.json`: ```json { "plugin": ["@magpie-community/opencode--auth"] } ``` then `opencode auth login`. ## Writing a package Each package is a folder under `packages//`: - **`package.json`** - name: `@magpie-community/opencode--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[] = { 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 `-plugin`. Once the built-in is gone, it takes over the same id, so an agent set to `/` keeps working. ## Checking a package ```sh bun scripts/check.mjs [] # loads each plugin and checks its hooks; signs in to nothing MAGPIE=/path/to/magpie scripts/try.sh [login | provider test -plugin] ``` `try.sh` runs magpie in a sandbox HOME (`.sandbox/`), so your own magpie, agents and sign-ins are left alone. ## License MIT