Files
magpie/AGENTS.md
T
yetone 6886da1ca9 provider: Antigravity moves onto @magpie-community/opencode-antigravity-auth
The plugin (plugins e35aa928, 0.1.0 on the dist branch) ports the
built-in's sign-in, project set-up, models and levels, request shaping,
errors and usage pools. This adds its mover, so the hourly MoveRetiring
moves every Antigravity account onto it, with no way back:

- out: each saved antigravity login becomes an oauth sign-in, refresh
  "<refresh token>|<project>", access, expires and the email.
- back: splits the refresh again and writes token, expiry and project
  into the built-in login, clearing Lapsed and Refused.
- antigravity_pool.go says PLUGIN-SERVED. The built-in code stays until
  every account has gone over; Gemini CLI and the agy agent stay built in.
- AGENTS.md lists Antigravity in the moved table.

Run:
- Real move (WSL magpie-desktop, sandbox HOME holding only a copy of the
  owner's live Antigravity login, nogui build of this tree):
  `magpie plugins move antigravity` installed the plugin, wrote state
  "plugin" with the backup; `serve` on 127.0.0.1:3476 listed 11
  antigravity models; gemini-3-flash and claude-sonnet-4-6 answered
  "pong" through the plugin; /v1/magpie/quotas read the plan
  ("Antigravity Starter Quota") and each model's window plus both 7-day
  pools. The copied login was deleted after.
- TestAntigravityMover (out and back, lapsed and own accounts),
  TestMovedBuiltinsSayTheirPlugin: pass on WSL. The test's b-account
  check was red until back cleared Refused.
- go vet -tags nogui ./... and GOOS=windows go vet ./... clean;
  go test -tags nogui -timeout 45m ./... on WSL (no gtk4 there) at this
  head: 92 packages ok, provider/plugin/gateway's own tests included.
  Three reds, none on a path this touches:
  - internal/agent TestGrokInstalled: WSL binfmt interop, red alone at
    0f94acc99 too (#3548).
  - internal/cli timed out in TestGroupMembersFast's PATH lookup (an
    os.Stat stuck ~44m, #5234, commented); passes alone here and on main.
  - internal/gateway TestUnroutedSlowBodyNotCutOff 504 "held 0s" under
    the full run; passes alone here (-count=3) and on main (#5953).
- After rebasing onto 4d95d81ea, at this head: vet (linux nogui and
  windows) clean, internal/provider and internal/plugin ok whole,
  internal/gateway -run 'TestPlugin|TestUnrouted' ok.
- TestPluginToldTheEffort red with host.js's MAGPIE_ONLY entry removed
  by hand (the vendor saw X-Magpie-Effort), green restored.

Not tried: the plugin's browser sign-in end to end (import and the moved
account were); a Mac or Windows run (mote unreachable). The min is 0.1.0
from the dist branch: npm has no version yet, its first publish needs
the owner (no NPM_TOKEN in the plugins repo).
2026-11-10 20:16:44 +08:00

117 lines
6.0 KiB
Markdown

# Notes for coding agents
## Subsystem design and review
Before changing a documented subsystem, read its
[design reference](docs/subsystems/README.md) and verify the linked source.
When preparing or reviewing a PR, follow the same page's documentation update,
semantic change description, and review rules.
## Code standards
Write and review changes against the [code standards](docs/code-standards.md).
## Community PRs
Before reviewing a community PR, read [contributors](docs/contributors.md):
what stops a review for possible harm, what is closed unreviewed, and the
authors whose PRs are closed on sight.
## Lessons
Before changing code, read [LESSONS.md](LESSONS.md): what recent merged
work got wrong and the rule that would have caught it.
## Built-in subscriptions that a plugin serves
These built-in subscriptions are retired. Reaching them can break their
vendors' terms, so they moved out of magpie into community OpenCode plugins,
which keeps magpie itself from being banned. Each one has a plugin that does
the same job:
| Subscription | id | Plugin (npm) | Mover |
| --- | --- | --- | --- |
| Antigravity | `antigravity` | `@magpie-community/opencode-antigravity-auth` | `internal/provider/migrate_antigravity.go` |
| Command Code | `commandcode-plan` | `@magpie-community/opencode-commandcode-auth` | `internal/provider/migrate_side.go` |
| Cursor | `cursor` | `@magpie-community/opencode-cursor-auth` | `internal/provider/migrate_side.go` |
| Devin | `devin` | `@magpie-community/opencode-devin-auth` | `internal/provider/migrate_side.go` |
| Factory | `factory` | `@magpie-community/opencode-factory-auth` | `internal/provider/migrate_factory.go` |
| Grok | `grok` | `@magpie-community/opencode-grok-auth` | `internal/provider/migrate_side.go` |
| Kiro | `kiro` | `@magpie-community/opencode-kiro-auth` | `internal/provider/migrate_kiro.go` |
| Xiaomi MiMo | `mimo-app` | `@magpie-community/opencode-mimo-auth` | `internal/provider/migrate_mimo.go` |
| Qoder, Qoder CN | `qoder`, `qoder-cn` | `@magpie-community/opencode-qoder-auth` | `internal/provider/migrate_qoder.go` |
| WorkBuddy, WorkBuddy AI | `workbuddy`, `workbuddy-ai` | `@magpie-community/opencode-workbuddy-auth` | `internal/provider/migrate_workbuddy.go` |
| ZCode | `zcode` | `@magpie-community/opencode-zcode-auth` | `internal/provider/migrate_zcode.go` |
| Zed | `zed` | `@magpie-community/opencode-zed-auth` | `internal/provider/migrate_zed.go` |
The `movers` map in `internal/provider/migrate*.go` is the source of truth.
`TestMovedBuiltinsSayTheirPlugin` fails when a mover has no notice in its
code.
### Which code actually runs
Two cases decide it:
- **Moved:** the user moved the subscription onto its plugin, from the
editor's "Move to plugin" (or `provider.Adopt`). Its `migrations.json`
state is `plugin` (`provider.Moved(id)`). A new user never sees a
deprecated built-in: the Add sheet leaves one with no account out
(`unusedSub` in app.js), so it is installed from the Plugins page. A user
who installs the plugin themselves is moved too
(`provider.HandOver`): at once when the built-in has no accounts, from the
gateway's hourly loop (`KeepRetiringMoved`) when it has, unless the
plugin is signed in under its own `-plugin` id already. Until
then the Add sheet shows the plugin's tile only (`replacedSub` in app.js).
Since 10-16 the built-ins are being retired: the hourly loop's
`MoveRetiring` moves every subscription with a mover that still has
built-in accounts, a user who moved back included, and there is no way
back. Turning the plugin off turns the subscription off with it; removing
it records `removed` (accounts kept with the plugin's sign-ins), and
installing it again gives the subscription back.
- **Not moved:** the user still has accounts from the built-in: the move
hasn't run yet, or it failed (tried again after six hours). Nothing
serves them until it runs.
- **Retired:** the built-in's code is gone (`retiredBuiltins` in
`internal/provider/migrate.go`; `provider.BuiltinRetired(id)`). The
plugin serves it, moved or not. Accounts not moved yet are served by
nothing; a line over the Providers list says so, with why and a Move
(`providers.unmoved`, `unmovedLine` in app.js). With no row of its own,
the Add sheet leaves it to the Plugins page (`unusedSub`). Every
subscription in the table above is retired (10-17) except Antigravity,
which is moved but whose built-in code is still there until every
account has gone over (11-10); gates ask `provider.PluginServes(id)`
(moved or retired). Gemini CLI (`gemini`) and the agy agent stay built
in.
The plugin does everything: sign-in, refresh, models, requests, usage and
errors. It runs in the plugin host (`internal/plugin`). The built-ins'
sign-in, models, usage and gateway translators are gone. What is left of
them in `internal/provider` (and `internal/qoder/endpoints.go`) reads the
built-in's saved accounts so the mover can carry them over. The gateway
sends every request to the plugin's fetch.
So a bug report about one of these subscriptions is usually about the
plugin:
1. Check whether the user's subscription is moved. A moved provider's row in
`/api/providers` has `move.state == "plugin"`; the provider id is in
`onPlugins`.
2. Fix the plugin in the community repo,
[magpie-community/plugins](https://github.com/magpie-community/plugins)
(`packages/<name>`, provider id = the built-in's id; checked out locally
at `~/workspace/projects/magpie-commuity-plugins`). Publish a new version.
3. Raise the mover's `min` to that version. `keepMovedCurrent` then updates
every moved user's plugin.
This magpie-side code still runs for moved subscriptions:
- the plugin host: `internal/plugin`, `host.js`;
- `internal/provider/plugins.go`, `plugin_usage.go` (`movedCards`) and
`pluginsignin.go`;
- the move itself: `internal/provider/migrate*.go`;
- the GUI's plugin paths in `internal/gui/assets/app.js`: `subOf`,
`pluginSubs` and `startPluginSignIn`.
The parity tests, `internal/gateway/plugin_*_test.go`, hold each plugin to
what its built-in did.