magpie icon indicating copy to clipboard operation
magpie copied to clipboard

plugins: the "Serves" chip cannot name a vendor magpie never had as a built-in

Open MYCF711 opened this issue 1 month ago • 2 comments

What happens

A plugin's row says Serves X, Y only when the plugin has taken over a built-in subscription. magpie-magicrew-auth signs in to two sites of one vendor (letsmagic.cn and magicrew.ai) and serves two providers; its row says nothing about what it carries, while @magpie-community/opencode-qoder-auth's row does — because qoder and qoder-cn used to be built-ins.

Why

internal/gui/plugins.go fills the chip from provider.MovedOnto(e.Spec):

j.Moved = provider.MovedOnto(e.Spec)

and MovedOnto (internal/provider/migrate.go) walks OnPlugins(), which only holds ids that are in the movers map — the built-ins being retired. A vendor magpie never shipped has no entry there, so the chip has nothing to name, and nothing in package.json can change that: the chip's data has one source.

A gap, next to a deliberate decision

As a migration marker this is right. As a description it leaves the row empty exactly where a plugin most needs to explain itself: one package, two clouds of the same vendor, two providers side by side in Providers. The row is the only place that says what a plugin is for.

One way to fill it

The package names what it carries, in package.json's magpie section — the same place icon and maxConcurrency live:

"magpie": {
  "icon": "…",
  "carries": ["超级麦吉 (letsmagic.cn)", "MagiCrew (magicrew.ai)"]
}

I have this working in a local commit (5 files, +156). It is not a PR: MYCF711/magpie is archived, so there is no branch to push it to.

file change
internal/plugin/carries.go (new) Carries(target string) []string — at most 8 names, each at most 48 runes, blanks dropped; a missing folder, an unparsable package and no field all say nothing rather than an empty name
internal/gui/plugins.go pluginEntryJSON.Carries []string \json:"carries,omitempty"`, filled from plugin.Carries(plugin.Target(e.Spec))`
internal/gui/assets/plugins.js the same pm-chip moved chip when e.carries is non-empty, reusing t("Serves {names}")
internal/gui/assets/i18n.js one new title key, zh / zh-TW / ja / de
internal/plugin/carries_test.go (new) two tests

The field is not called served: that already means the model count in /api/state and the model that answered in a gateway trace, and served.json holds account-served times.

What I ran

go1.27.3, windows/amd64:

  • go test ./internal/plugin -run TestCarries -count=1 — ok
  • with Carries reduced to return nil, both tests FAIL (two sites: [], count: 0, want 8 ([])), and pass again restored
  • gofmt -l on the five files — prints nothing
  • node --check on plugins.js and i18n.js — both pass
  • go build -tags production -trimpath — builds; the new i18n string is in the binary and is not in the build before it

What I did not run

Acceptance check 4 in docs/code-standards.md is not met:

  • the GUI Playwright suite (make test-ui) in Chromium and WebKit, and the shell in zh, en, zh-TW, ja and de — no Playwright browsers are installed on this machine
  • go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...
  • go test -tags nogui ./... in full. go test ./internal/plugin has 4 failures that are red on the base commit without this change too, for the machine's own reasons: a symlink without the privilege (TestWindowPageStaysInside), and bun add / git push under a GOTMPDIR outside the system temp (TestEnsurePi, TestGitPlugin, TestGitPluginUpdateOnlyWhenItsRepositoryMoved)

So: a proposal with a working Go side and an unverified page.

Which way, if any

  1. A field, as above — the package names what it carries; works for any plugin, not only a multi-site one.
  2. Derive it — plugin.Providers already lists what a plugin signs in to; the chip could name those when there is no moved built-in. Less precise (provider names, not vendor + site), and no package change at all.
  3. Leave it — the chip stays a migration marker, and a multi-site plugin's row says nothing about what it carries.

A scaffold for third-party plugins has a draft PR waiting on this answer (MYCF711/magpie-plugin-scaffold#1): it documents the field and checks its shape, and says plainly that a magpie which doesn't know the field ignores it.

MYCF711 avatar Oct 27 '26 11:10 MYCF711

Thanks for the analysis. We went with option 2 (derive it), with no new package.json field. Shipped in 766356cd3, released as v0.1.1744.

  • /api/plugins now sends serves for each plugin. It holds the names of the providers the plugin registers, the same list the row's "Signs in to" names come from. Each name appears once, and moved built-ins are left out because the page still names those as the built-in.
  • The chip shows when the plugin has a moved built-in or registers two or more providers. A plugin with a single provider gets no chip, since its title already says what it serves. For magpie-magicrew-auth the chip reads "Serves 超级麦吉, MagiCrew".
  • The tooltip "… runs on this plugin in place of the built-in" stays only on chips that name a moved built-in.

The names are the plugin's provider names, so pick them to read well, e.g. "MagiCrew (magicrew.ai)". We haven't tried it with a real install of magpie-magicrew-auth yet, so this stays open until you confirm it works for you.

yetone avatar Oct 27 '26 15:10 yetone

Confirmed on a real install — closing from my side.

magpie v0.1.1744, windows/amd64, built from 766356cd (-tags nogui -trimpath -X main.version=v0.1.1744), run against a portable data folder of its own so my running 0.1.1740 was left alone. magpie-magicrew-auth installed into it, page opened in a browser, /api/plugins:

{"spec":"...\\magpie-magicrew-auth","providers":["超级麦吉","MagiCrew"],
 "moved":[],"serves":["超级麦吉","MagiCrew"]}

The row reads 承载 超级麦吉、MagiCrew — one pm-chip moved, and its title is null, so nothing claims "in place of the built-in". That is exactly the shape you described.

Two things worth recording:

  • The old sketch field is dead, confirmed the hard way. 0.3.8 of the package still had "carries": ["超级麦吉 (letsmagic.cn)", "MagiCrew (magicrew.ai)"] in package.json, and the chip came out with the provider names only — the domain-qualified name from that field never appeared. 0.3.9 deletes the field; same chip.
  • Names. We kept ours as they are: 超级麦吉 and MagiCrew are the two brands' own names, so the chip reads without the sites. If a package ever has two sites under one brand, the site belongs in the provider name — that is what Qoder 国际版 (qoder.com) does, and what I wrote into the scaffold.

Not covered: installing by the GitHub spec never got as far as magpie here (bun add → UNABLE_TO_GET_ISSUER_CERT_LOCALLY on the tarball, this sandbox's CA store), so the install above is a folder one; and the plugin was never signed in, so serves is the config hook's providers only, as intended.

I also fixed the scaffold that recommended the field — MYCF711/magpie-plugin-scaffold#1 is superseded by 0.1.8 on main: it documents the derivation (servesBeside, when the chip appears, the tooltip only on moved), and scripts/check.mjs now warns if a package still declares magpie.carries.

MYCF711 avatar Oct 27 '26 16:10 MYCF711