Commit Graph
2 Commits
Author SHA1 Message Date
yetone e7fbbaab9f plugin: an author's own listing is kept, for a search to find (plugins#479)
On magpie-community/plugins#479 the owner ruled that registry.json
entries for packages published from their author's own repository
rightly leave out "community": true, and are shown under the
publisher's name, to a search alone. parseMarket dropped every entry
without the flag, so PinK (YuchenWell, plugins#617), and WispTerm,
CiteBox and Wisp Science (hoptoper) couldn't be found in magpie at
all.

What changed:
- parseMarket keeps a listing without the flag; Listing.Community
  says which it is. The new plugin.Community(l) picks the community's.
- Every reader of the market was re-derived:
  - plugins.js already browses community listings alone, matches a
    search over every listing (name, package, summary, providers, npm
    publisher), and shows a non-community card and page under its npm
    publisher, without the magpie community badge. Unchanged.
  - plugin.resolve (a short name like "river") reads the community's
    alone: an author's "pink" stays npm's own name "pink".
  - pluginAgents (/api/plugins/agents, the Agents page's suggestions)
    reads the community's alone, as Discover's Agents section does.
  - plugin.Icon's fallback by provider id reads the community's alone;
    its exact-package match reads all, so PinK's own icon shows.
  - pluginListings and pluginMarketState pass every listing on.
- Docs (en, zh, ja plugins.html) say such a package isn't browsed and
  is found by a search, under its publisher.

Tests:
- TestMarketKeepsAuthorsOwnListings parses registry.json's River and
  PinK entries as they are at plugins 486a68a5 (#617's base, lines
  126-130, PinK without the flag; testdata/registry-pink.json). PinK is
  kept, not community, with its kind, summary and icon; resolve("pink")
  is "pink" and resolve("river") the community's package.
- TestMarketSources now expects the non-community entry kept.
- plugin-authors-listing.test.cjs: PinK isn't browsed (Agents shows
  Kilo, no PinK anywhere), a search by name or publisher shows one PinK
  card under "zhouzhenzhou" with no badge, its page reads
  "zhouzhenzhou · magpie-plugin-pink" with no badge, River keeps its
  badge. en, zh, zh-TW, ja, de; 980 and 420 wide; chromium and webkit.

Broken by hand, each red, then put back:
- parseMarket's `&& l.Community` restored: TestMarketSources and
  TestMarketKeepsAuthorsOwnListings red.
- resolve without Community(): TestMarketKeepsAuthorsOwnListings red
  (pink resolved to magpie-plugin-pink).
- pluginAgents without Community(): TestPluginAgentsNotInstalled red.
- plugins.js Agents without the l.community filter, and the badge shown
  for every agent: plugin-authors-listing 0/22 each.

Run on mote at this head (rebased on a4916aec1; i18n-keys and plugin-authors-listing ran again there, both engines):
- gofmt -l: clean. GOOS=linux go vet -tags nogui and GOOS=windows go
  vet of internal/plugin and internal/gui: ok.
- go test -timeout 45m internal/plugin, internal/provider: ok.
  internal/gui: ok but TestMainWindowCorners/macOS_26_SDK (#3949,
  mote's macOS 27, nothing here touches it).
- At 3086c650b (rebased on 541102eba; the rebase since touched
  host.js, a gateway test and a provider test only): agent, agentplug,
  backup, davsync, library, middleware, usage and plugins/...: ok.
  cli: TestEveryRouteHasACommandOrIsNamed (#4826); gateway:
  TestCodexPoolSaysTheClientsVersion (#4807). Both filed, untouched
  here.
- node --test site/*.test.mjs: 80/80.
- GUI, every file that reaches the Plugins page (agent-plugin-agents,
  i18n-keys, market-*, plugin*; 1078 tests, both engines): 1074 pass,
  plugin-authors-listing 22/22. The 4 reds are plugin-move-unserved's
  "Try again takes the models unticked" (#4410, models folded behind
  "Show the other"), not reached here. The whole GUI suite wasn't run:
  mote held two other sessions' full suites for over an hour, and this
  changes no app.js, plugins.js, layout or API call. That run was at
  f5c956b84; after the rebase on a1f56720c (i18n.js and caller keys
  moved), plugin-authors-listing, i18n-keys, plugin-market and
  plugin-registry ran again: webkit's plugin-authors-listing and
  plugin-market timed out at mote load ~250 from other sessions' suites
  (#4125), and both passed 14/14 alone right after.

Not tried: a real magpie window against the live registry.json (the
listings come from a fixture and a faked API); the Icon fallback's
community-only rule has no test that goes red without it.
2026-11-02 14:12:20 +08:00
yetone a2ff7e6cab plugin: add takes a community plugin's name (WorkBuddy, think-tags, qoder-cn)
Atlas on Discord (#help, 10-25, Linux): `magpie plugin add WorkBuddy`
said "isn't an npm package name". Worse, a bare `workbuddy` passed the
npm-name check and installed npm's unscoped workbuddy@latest, not
@magpie-community/opencode-workbuddy-auth.

plugin.Add, which the CLI, the Plugins page's field (/api/plugins/add)
and the movers all go through, now resolves a bare name first
(internal/plugin/resolve.go). Case aside, a name one community listing
goes by is its package, at the version given: the package or its bare
name, the short name (workbuddy, think-tags), the shown name (WorkBuddy,
Command Code), a provider id it serves or the subscription it replaces,
and a retired subscription's id through its mover (qoder-cn; provider
sets plugin.SubscriptionPlugin = MovePackage). The CLI says which
package it picked. A name two listings go by, or none that isn't an npm
name, is refused with the community plugins listed. A name no listing
goes by is npm's own package (opencode-gemini-auth keeps working), but
only when the list was fetched within the six hours: when the fetch
fails, the copy kept or built in may not name a newer plugin, so the
name is refused with why, and npm:<name> installs npm's package as
written. market() now says whether its list is a fresh fetch (marketErr).
Scoped names, paths and git specs are unchanged. A backup's or a sync's
plugins go in by their own spec (plugin.AddExact via addPluginExact),
never resolved, so a restore isn't held by GitHub being unreachable.
Update, Upgrade and InstallMissing use add with stored specs, unchanged.

Tests (fake registry over httptest, fake bun; no network):
TestResolveCommunityNames, TestResolveRefusesWhatItCantName,
TestResolveListUnread, TestAddByCommunityName. TestUpdateAllUpdatesAPinnedPlugin
adds an unscoped third-party name, so it now serves a registry.

Broken by hand: Add without resolve -> TestAddByCommunityName red with
the reporter's own error ("WorkBuddy" isn't an npm package name) and
workbuddy -> workbuddy@latest. The unread-list rule turned off (valid
name goes to npm regardless) -> TestResolveListUnread red.

Real use, sandbox HOME, built binary, real npm and GitHub:
`plugin add WorkBuddy` -> installed @magpie-community/opencode-workbuddy-auth@latest,
listed workbuddy and workbuddy-ai; `think-tags` -> middleware-think-tags;
`opencode-gemini-auth` -> npm's, google-plugin listed; `qoder-cn` with
MAGPIE_PLUGIN_MARKET=off -> opencode-qoder-auth; "Work Buddy Pro" ->
refused with the 38 community plugins listed; `twinz` with the list off
or at a dead URL -> refused, saying why and npm:twinz.

Run at this head (rebased on origin/main 42976f9a0): gofmt -l clean;
go vet (darwin) and GOOS=linux / GOOS=windows -tags nogui vet of
plugin, provider, cli, backup, gui clean; go test -timeout 45m
./internal/plugin ok (120s, after the pinned-update fix),
./internal/provider ./internal/cli ./internal/backup ./internal/gui ok.

Not tried: the full ./... suite; Windows and Linux runs of the tests.
No GUI JS changed: the Plugins page's field goes through the same Add,
and its status still says "<typed name> is installed" rather than the
package picked; the installed list shows the package.
2026-10-25 11:52:02 +08:00