Commit Graph
16 Commits
Author SHA1 Message Date
JoeyWu-tech 75d63a1545 plugin: Discover no longer keeps a stale read from just after a push (#4067)
The Plugins page's Discover lists the repositories tagged
magpie-plugin, and keeps what each one's package.json, npm and the
file it names made of it by `owner/repo@pushed_at`, so a repository
is read once a push. raw.githubusercontent.com can answer from before
a push for a while after it (its answers, a 404 too, say they stand
five minutes): the package.json or the file it names missing, or the
package.json as it was. A read then was kept for the push, so a
repository read as missing stayed out of the list until magpie
started again or the repository was pushed to again (MengXiangxi
on #3821, #4067).

Now a read less than rawFresh, ten minutes, after the push is shown
as any read is, and read again at the next ask; one rawFresh or more
after the push is kept for the push, as before. When it was read is
what counts: a whole list stands ten minutes, so the next ask is
often past rawFresh, and judged then, a 404 read a minute after the
push would be kept. A read again that comes in after the page stops
waiting is shown at the ask after, as any late read is; one that
gets no answer leaves the repository as it was read. A list is asked
again when its time is up: ten minutes for a whole one, 20 seconds
for one cut short, a minute after a failed search, and at once on
Try again when it isn't whole. So such a repository is read about
once more.

raw's answers have no Age, and their Expires is each answer's own
date plus five minutes, but they carry Source-Age, how long raw's
cache has held them, a 404's too: 2s after a push, raw's 404 had
Source-Age 20, cached before the push (below). This reads no headers
(fetchJSON keeps none) and goes by the time since the push.

What was run (tree 00637ea4, on origin/main 174250b2, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, the Go tests at umask 077:
- raw.githubusercontent.com, on a branch of JoeyWu-tech/magpie made
  for it and deleted after, twice: at a commit without a file, the
  file read 404, x-cache MISS, then HIT; the branch pushed on to a
  commit that has the file, raw still answered 404 (x-cache HIT) 1s
  or 2s and 23s after the push, and 200 (MISS) at 48s and 49s. The
  second time kept Source-Age: 0, 6 and 13 for the 404s before the
  push, 20 and 41 for those after it, 0 for the 200. An earlier try
  stopped at its first read after the push: 404, HIT, 2s after.
- TestTaggedReadSoonAfterAPushIsReadAgain, new: GitHub's search, raw
  and npm faked, someone/fresh pushed a minute ago and someone/old an
  hour ago, each with word-guard's files (a middleware alone), npm
  having neither. Six asks, each with the list's ten minutes run out:
  with raw's 404 for fresh's package.json, then for the middleware
  file it names, fresh is left out; with both there, the next ask has
  it at 0.1.1; with its package.json at 0.1.2, the next has 0.1.2.
  rawFresh then set under the minute since the push, as ten minutes
  on, the next reads it again and has 0.1.3, and the one after keeps
  0.1.3 with 0.1.4 on raw. old's package.json is read once in six.
- TestTaggedLateReadSoonAfterAPushIsShown, new: the same fakes, old
  read first, taggedWait at 2s. fresh's package.json held, the page
  stops waiting with one missing; once that read is in, the next ask,
  raw answering 503 for fresh at once, has fresh at 0.1.1 with no
  error; the next, its package.json at 0.1.2 and held again, has 0.1.1
  still, with no error; once that read is in, the next has 0.1.2 with
  no error. old's package.json is read once in five.
- Both at -count=20: 20 of 20 each.
- Broken by hand, each red, then put back: a read shown and never
  read again, as on main: the first test red at its third ask, and in
  the late test 0.1.2 is never read; soon judged when asked, not when
  read: red at the fifth ask, 0.1.2 not read again; a read that found
  the repository kept at once: red at the fourth ask, 0.1.1, and in
  the late test 0.1.2 is never read; no read kept for good: red at the
  sixth ask, 0.1.4, and the late test reads old's package.json 5
  times; a read that soon after the push not kept: the late test red,
  its late read never kept; a read again with no answer taking the
  place of the one shown: the late test red at its third ask, fresh
  missing (503).
- go test -tags nogui -race -count=20 -run '^TestTagged'
  ./internal/plugin: 160 of 160 pass (the eight TestTagged tests),
  no race reported.
- go test -tags nogui -count=1 -v ./internal/plugin, Bun 1.4.2 first
  on PATH: 228 pass, none red, 2 skip (TestFlowBigReplyProd, opt in;
  TestRenewOtherHost, run by TestRenewOnceAcrossHosts).
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag
  on linux: exit 1 (no libsoup-3.0 or gio-unix-2.0 here).
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2, log kept;
  8m55s, load 31 at its start): 71 packages ok, and 14 tests red in 6
  packages, none in internal/plugin: agent TestInstalledVersion,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141), TestCodexBehindReverseProxy (#3398),
  TestReasonixCLIRequiresSupportedNativeVersion and
  TestReasonixCLIRecoversAfterProbeTimeout (#3641); davsync
  TestSyncTeraCloudStillSeesOtherWrites (#3420); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (#3640, at
  umask 077); gateway TestPluginToldWhereTheAgentWorks (#3675, the
  /tmp/.git); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649).

Not tried: macOS and Windows; a repository tagged magpie-plugin,
pushed to and read by the real Plugins page (a tagged repository is
listed for every user).

Reviewed and run again by the maintainer at the stack's tree 45994757c
(this commit and the six beside it, on origin/main 90518de26), go1.26.8:
- mote (macOS, arm64): gofmt -l clean; go vet and go build for darwin,
  GOOS=linux -tags nogui and GOOS=windows (library, plugin, gui): exit 0.
  go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gui TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  internal/proc TestNoCommandBypassesProc (#4491), both red on main
  from b09349d17 and c59c547c5, in files this stack doesn't touch.
  go test -race -run 'TestWSL|TestTagged|TestPinnedPiCache' for
  library and plugin: ok.
- magpie-desktop (Linux, wsl-run; WebKit hangs on mote), Chromium and
  WebKit: every library-*, sync-*, s3-sync, github-sync and i18n-keys
  file, 4 at a time: 1003 of 1020. The 17 reds are in 6 files no commit here
  touches: i18n-keys ("Unmarked", #4524), library-chip-fan, -items,
  -mcp-health, -mcp-hub (#4483) and -mcp-tools. Those 6 alone, one at a
  time, at load ~60: 74 of 92 here, 77 of 92 at 90518de26 itself. Red
  in both: i18n-keys, -chip-fan and -items in WebKit, -mcp-tools in
  Chromium ja 420; -mcp-health green in both; -mcp-hub's WebKit case
  red here only, the case #4483 has red on main. -chip-fan and -items
  are #3072's and #4501's kind, WebKit under load.
- Broken by hand on mote: with a read just after a push kept as any
  other (`if true || !soon`), TestTaggedReadSoonAfterAPushIsReadAgain
  ("raw has its files now: someone/old@0.1.1") and
  TestTaggedLateReadSoonAfterAPushIsShown ("late read never kept:
  0.1.1, want 0.1.2") are red.
2026-10-31 17:00:14 +08:00
yetone e647a1fd54 plugins: an npm registry of the user's own is used for installs and lookups (timwangdev on X)
timwangdev asked on X for plugins to take a custom npm registry. Zero-config
first: Registry() (internal/plugin/registry.go) takes, in order, the one set
in magpie (settings npmRegistry: `magpie plugin registry <url>|default`, or
Plugins › Discover's new npm registry row), BUN_CONFIG_REGISTRY /
NPM_CONFIG_REGISTRY / npm_config_registry in magpie's environment, then the
login shell's (cached probe only, proc.LoginEnvKnown, never waits on a
shell), install.registry in the plugins folder's or the user's .bunfig.toml,
registry= in the plugins folder's or ~/.npmrc, then the 国内镜像 switch's
npmmirror, then npm's own. The switch no longer puts npmmirror over a
registry the user named: before, bun was handed BUN_CONFIG_REGISTRY=npmmirror
whenever it was on, over the user's .npmrc. bun is told the registry only
where it wouldn't find it itself (magpie's setting, the shell's, the
switch's). magpie's own npm questions (latest version for the market,
Update and the hourly check, README, search) go to the same registry, a
package's @scope:registry= to that scope's, with the .npmrc's
//host/path/:_authToken (${VAR} expanded, longest prefix) sent to that host
alone, dropped on a redirect to another host, never logged or shown.
Download counts stay npm's. Only http(s) with a host, no userinfo, query
or fragment is taken; anything else is refused and not saved, and a bad
value hand-written into settings.json is passed over. /api/plugins says
which registry is in use and where it came from.

The GUI row is in registry.js, imported when Discover draws it, so the
core script budget isn't raised (plugins.js is 292 bytes smaller than
before, one long comment there condensed).

Left out: bunfig [install.scopes] for magpie's own lookups (bun reads them
for installs), .npmrc _auth and username/password, NPM_CONFIG_USERCONFIG
and npm's global npmrc, and internal/agent/cliupdate.go's agent CLI update
lookups, which still ask npm's own.

Run (mote and wsl-run). First at this change on 2ac423f4f:
- go test ./internal/plugin/ ./internal/source/ ./internal/gui/
  ./internal/proc/ ./internal/cli/ ./internal/settings/ -timeout 45m:
  plugin, source, cli, settings ok. gui: only the real-window AppKit tests
  killed at their deadline on mote (dock, panel, titlebar, tray; #2645,
  #4125), TestCoreScriptBudget and TestSettingsSaveKeepsWhatItDoesNotSend
  green after the fixes in this commit. proc: TestNoCommandBypassesProc red
  on origin/main itself (internal/claudetui/tui.go:183), filed as #4491.
- gofmt -l internal: clean. GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: ok.
- GUI (wsl-run, magpie-desktop): plugin-registry.test.cjs in Chromium and
  WebKit, 5 languages each, 980px and 380px; i18n-keys, old-webkit and
  plugin-market (WebKit): 19/19 pass. On mote the browser runs timed out
  launching (#4125).
Again at this tree rebased on fa5e86cf2 (upstream changed app.js and
i18n.js): go build ./...; go test ./internal/gui/ ./internal/cli/
./internal/plugin/ ./internal/settings/: cli, plugin, settings ok, gui only
the same ten AppKit window tests killed on mote (#2645, #4125), the core
budget green; gofmt clean; plugin-registry (Chromium, WebKit), i18n-keys
and old-webkit on WSL: 22/22 pass.
Rebased once more on 45de2ddb9 (app.js and i18n.js again): gofmt clean,
go vet of gui and plugin ok, TestCoreScriptBudget and
TestSettingsSaveKeepsWhatItDoesNotSend ok, i18n-keys 4/4.

Broken by hand, each red, then restored:
- A: old registryEnv (npmmirror whenever the switch is on):
  TestBunTakesTheUsersRegistry red.
- B: lookups always to npm's own: TestLookupsAskTheUsersRegistry red.
- C: no URL check: TestSetRegistryRefusesWhatIsntOne red.
- D: the switch before the user's registry: Precedence, BunTakes and
  Lookups red.
- E: no token sent: Lookups red.
- F: scopes ignored: Lookups red.

Not tried: a real private registry (Verdaccio, GitHub Packages, Nexus) with
a real token; a real bun install through one; Windows (the login shell
probe is a no-op there, so only env, bunfig and .npmrc apply).
2026-10-31 04:24:59 +08:00
JoeyWu-tech ef7f55fe98 plugin: Discover lists a repository of gateway hooks alone, as a request hook (#3821)
MengXiangxi (#3821): a GitHub repository tagged magpie-plugin whose
package.json has magpie.hooks and no main, exports or index.js, a gateway
request hook alone that installs and runs, never showed in the Plugins
page's "Unofficial, on GitHub". readTagged read the magpie block's
middleware, agent and page but not hooks, so such a package was taken for
a provider: the file #1327's check looks for in the repository was its
entry as Bun resolves it, index.js, which it hasn't, and the 404 left it
out without a word. An inert index.js, as the reporter tried, lists it,
as a provider.

readTagged reads magpie.hooks. A package with hooks, no main or exports,
and none of middleware, agent or page is of kind "hooks", and the
file #1327's check looks for is its hooks file, so one whose hooks file
isn't committed (a dist built only to publish) is still left out, as a
middleware's is. The Plugins page picks "hooks" out with middleware, as
both run in the gateway (kindOf), and its chip says Request hook, as an
installed one's row does, through the word kindChip takes since the
previous commit. docs/subsystems/gateway-request-hooks.md says so. Not
changed: a raw 404 that GitHub's cache answers just after a push is
still kept for that push in this process (the reporter's second
point, #4067).

plugins.js grows 51 bytes for it. With the previous commit the core's
scripts are 24 bytes under main's, 1,527,948 of 1,528,076.

What was run (tree 79884772, on origin/main 56602426, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, the Go tests at umask 077:
- TestTaggedHooksAlone, new. IvanXxxxyyuffff/magpie-system-prompt-file's
  package.json as it is (a repository the report names) is kept, of kind
  hooks, with its spec, package and version 0.3.0, and its hooks file is
  the file asked for, never an index.js. someone/hooks-gone, whose hooks
  file is only in a dist it doesn't commit, is left out. With
  TestTaggedRepos*, -count=50: 350 of 350 pass; -race -count=20: 140 of
  140, no race.
- plugin-github-hooks.test.cjs, new. Seven repositories of
  /api/plugins/github's real answer of 2026-10-27 (two providers, three
  middleware, two of hooks alone): each of hooks alone has the gateway's
  chip saying Request hook and is picked out under Middleware, in
  English, Chinese, Traditional Chinese, Japanese and German at 980px and
  420px. Chromium and WebKit, 3 runs: 22 of 22 each run.
- Broken by hand, each red:
  - no kind made of magpie.hooks, as on main: TestTaggedHooksAlone,
    hooks alone not kept.
  - the kind made but the file looked for still the entry, index.js:
    the same.
  - the hooks file not looked for: TestTaggedHooksAlone, the hooks file
    not among the files asked for.
  - kindOf without hooks, so a Provider: plugin-github-hooks 0 of 22.
  - the card's chip not given its word: 0 of 22.
- TestCoreScriptBudget: ok.
- gofmt -l clean. go vet -tags nogui for linux, windows and darwin, go
  vet for windows, go build -tags nogui for linux and darwin and go
  build for windows: exit 0 each. go vet and go build without the tag
  on linux: exit 1 (no libsoup-3.0 or gio-unix-2.0 here).
- The Plugins page's GUI files near the change, 24 with the new one and
  i18n-keys, each run by itself in Chromium and in WebKit: 42 of 48 runs
  green. The other 6 are red the same at 56602426, each file run the
  same way, and none is in what this changes:
  - i18n-keys, both engines: "a plugin's words are its own", for
    plugins/routing/i18n.js "masking…", which internal/masking/masking.go
    says too (#4053).
  - builtins, WebKit: Plugins › Built-in, the Observability switch's
    click times out, the stuck Plugins header (.lib-head.pm-head.stuck)
    over it taking the pointer.
  - plugin-github, WebKit: de 440, a click scrolls #view-plugins, 74 to
    139 (65 to 119 at 56602426; #3218 has the same check red in
    Chromium).
  - plugin-github-wait, Chromium: de 440, Try again moves #view-plugins
    by 2.
  - plugin-release, WebKit: en and zh read "Serves Zed\n" for "Serves
    Zed".
- go test -tags nogui -count=1 -timeout 45m ./... (Bun 1.4.2, log
  kept; 8m48s, load 32 at its start): 71 packages ok, internal/plugin
  among them, and 16 tests red in 6 packages, none of them this
  commit's tests or what they cover (internal/gui's are its gateway
  tests): agent TestCodexDriftReached (#3398); TestInstalledVersion,
  TestHowInstalled, TestCursorFolderFromTheEditorIsNotTheCLI,
  TestCopilotFolderFromAnIDEPluginIsNotTheCLI,
  TestQoderSettingsFromAnIDEPluginIsNotTheCLI, TestOmpDetectedWithPiDir
  and TestZedAppPath (#3141); TestReasonixCLIRequiresSupportedNativeVersion
  and TestReasonixCLIRecoversAfterProbeTimeout (#3641); davsync
  TestSyncTeraCloudStillSeesOtherWrites (#3420); edit
  TestWriteAtomicReadOnlyHardLink and testenv TestProgram (umask
  077, #3640); gateway TestPluginToldWhereTheAgentWorks (the
  /tmp/.git of #3675); gui TestGatewayHeldByAContainer and
  TestGatewayFixQuitsOnlyAMagpie (#3649).

The rest is what was run for 31a99237, at tree 2dd21699 on origin/main
508911e4, the same Go change (github.go has since taken e4ccf67b's
search timeout, in askTagged, not readTagged; 31a99237's plugins.js
named the card's chip by hand, not through kindChip, and had three
lines of comment this leaves out; not this tree):
- Real use: magpie web built at 508911e4 and at that change's code
  (529f07e5, the same but for the new GUI file), each in a sandbox HOME,
  asked real GitHub for /api/plugins/github. 508911e4 listed 163 and left
  IvanXxxxyyuffff/magpie-system-prompt-file out. That change listed 164,
  it and MengXiangxi/magpie-openviking (which now has the inert index.js)
  of kind hooks. cyberElar/magpie-x-search (#1327's, a command only) was
  left out by both.

Not tried: macOS and Windows; the real app's window (no display here, the
page in Playwright's browsers only).

Landed by yetone in a batch of Coffemon's patches from the issues.
What was run, go1.26.8, on origin/main cc81ad4ea, then again at
70a0c387c (gofmt, the three vets, the changed tests, umask 077):
- mote (macOS 27): gofmt -l clean; go vet, GOOS=linux go vet -tags
  nogui and GOOS=windows go vet ./...: ok. edit and testenv at umask
  077; agent, provider, library and gateway with an empty .git above
  TMPDIR; davsync, imagemcp, plugin, library, edit, testenv whole; the
  changed tests in agent, provider, gateway and gui; the timing tests
  -count=10 (gateway, davsync, imagemcp) and -count=5 (agent): all ok.
  TestCoreScriptBudget ok: core 1,536,751 of 1,537,034, app.js
  1,312,975 of 1,315,316, no budget raised.
- Red on the old code: on origin/main, TestWriteAtomicReadOnlyHardLink
  at umask 077 and two Reasonix tests under an empty .git; on Linux
  (wsl-run) TestProgram at umask 077 with the old program.go. With
  each fix's code taken back to main's, the Gemini imageConfig tests,
  TestPluginToldWhereTheAgentWorks, TestSkillRepoTraced,
  TestTaggedHooksAlone, TestMainURL/TestMainView and update-auto,
  plugin-github-hooks, plugins-more-discover, plugin-namesake were
  red. Broken by hand: claudeKeyed always true (both
  OwnEndpointNeverAsked tests red), claudeAsk a no-op
  (TestClaudeFirstWriteAsksTheProxy red), GitAt taking any .git folder
  (the three TestGitOnDisk tests red).
- GUI: 123 files (plugins*, update-*, panel/tray/start/context, i18n,
  gui-zh-tw/ja/de and every file that evals app.js parts) in WebKit on
  Linux (wsl-run). 11 files had reds (click-scroll, panel-fold,
  plugin-card-update, plugin-github, plugin-move*, segs-glide,
  tray-totals, update-*), and run again side by side they fail the
  same on origin/main d80d75f30 (79 pass, 26 fail here; 78 and 27
  there). They are click-scroll guards ("the click must not scroll
  the page"), varying by language from run to run (#4385).
  copilot-ghe's route-after-close red is #1949, seen on main 244d80e23
  too. In Chromium on mote, Chromium segfaulted partway through files
  (#4125): context-map, context-scroll-end and context-tune fail the
  same on origin/main 0911a65e7, so the batch's own files
  (plugin-namesake, update-auto, plugins-more-discover,
  plugin-github-hooks) ran in Chromium on Linux: 62 of 62.
- Full suite (go test -tags nogui -count=1 -timeout 45m ./..., mote)
  at 472a0608f (on 70a0c387c): every package ok but internal/gateway,
  whose five reds were #4362's (Antigravity turned-away and
  TestCodexSpentGrokFailingIsTold), fixed on main in d80d75f30. After
  the rebase on 244d80e23 the five pass, and gofmt, the three vets
  and the targeted runs above were run again: ok. In Linux the
  sign-in, copilot, plugin-github*, plugins-more-discover,
  plugin-namesake, plugin-gateway, update-auto, quota-refresh-order
  and i18n files ran in both engines: 475 pass, 4 fail (copilot-ghe
  #1949, plugin-github's click scroll, both red on main too).
- Rebased again on c7171a256, over its budget fix e94bf7a08: gofmt, vet of
  gui, gateway, provider and plugin, TestCoreScriptBudget (core
  1,536,265 of 1,536,586 with the batch's last commit, statusTErr and settingsErr), the Gemini,
  GitOnDisk and plugin tests, and in Linux both engines i18n-keys,
  update-mirror, plugin-namesake, plugins-more-discover,
  plugin-github-hooks and update-auto (138 of 138): ok.
Not tried: the whole GUI suite (mote's WebKit wouldn't launch and its
Chromium segfaulted, #4125); macOS WebKit; the real app's window.
2026-10-30 15:53:22 +08:00
yetone 5957d45ac1 plugin: a GitHub listing takes package.json's licence when GitHub names none (plugins#468)
GitHub's search gives NOASSERTION for a LICENSE file it can't match to a
licence (MIT's text with a line of credit added) and nothing for none;
magpie drops NOASSERTION, so such a card on Plugins > Discover had no
licence, while the same package from npm shows package.json's.
readTagged keeps package.json's license (a string) as PkgLicense, and
License falls back to it, on a fresh read and across searches (fresh).

Run (mote, at this tree): gofmt -l clean; vet on three OSes; go test
-tags nogui -timeout 45m ./...
(go test -tags nogui -timeout 45m ./... at base 5bfd76cd8: 77 packages ok, none failed (log kept whole). Rebased onto 602ad84ad and run again there: vet on three OSes ok; go test -tags nogui -count=1 ./internal/provider (195s) ./internal/plugin (268s) ./internal/gateway (677s) ok. Rebased onto b5d2858f4 and run again: usage, provider, plugin, gateway ok. Rebased onto 87a983423, the pushed base, and run again at this tree: gofmt -l clean; go vet ./internal/... ok, GOOS=linux and windows go vet of provider, plugin, gateway ok; go test -tags nogui -count=1 ./internal/provider (126s) ./internal/plugin (180s) ./internal/gateway (588s) ./internal/codexcat (1s) ok. Then rebased onto 3ec9babe7 to push; its three commits (WorkBuddy mover min, redact, sessions) share no file with this one, and the same packages are run again at the pushed head after the push).
Broken by hand: on the old github.go TestTaggedRepos is red:
"NOASSERTION, package.json MIT: {... License: ...}".
Not tried: the GUI card against a real NOASSERTION repository (the card
reads r.license as before; no GUI file changed).
2026-10-29 00:52:19 +08:00
yetone e4ccf67b11 plugin: GitHub's search gets 60s a page, and a mirror is asked without the token (#3923)
MYCF711 (#3923) measured a page of GitHub's search from mainland China:
29-36s straight to api.github.com, 3-7s through gh-proxy. The Plugins
page's GitHub list was empty there, for two reasons:

- askTagged's taggedWait (8s) bounded the search pages as well as the
  wait for the repositories' reads. The first page timed out, the ask
  failed whole, and nothing was cached. Each search page now has its own
  taggedSearch (60s). taggedWait starts after the search and bounds only
  the reads, as before. Through a mirror, candidateContext gives the
  official address half of the 60s and the mirror the rest.
- source.Do never used a mirror for a request carrying Authorization,
  and ghtoken sets it on every api.github.com request when a GitHub
  token is set. With a token in Settings, MAGPIE_MIRRORS did nothing.
  A request to a GitHub host whose only credential is Authorization
  (bare) now goes to the official address with the token and to the
  mirror without it. A cookie, a key header, a token in the query, URL
  userinfo, or any other host still keeps the request official. The
  caller's request keeps its header.
- ghtoken.Do now reads who answered from resp.Request: a mirror's answer
  to the bare request doesn't count as carrying the token, and a 401 from
  a mirror doesn't mark the token refused.

Tests:
- TestTaggedReposSlowSearch: a search answering after 3x taggedWait
  still lists; one that never answers fails at taggedSearch.
- TestDoKeepsCredentialsOfficial, rewritten to the new contract: the
  official address gets the token, the mirror gets none, and the
  caller's request is unchanged. Cookie, query token and npm still stay
  official.
- TestMirrorAnswerIsNotTheToken (ghtoken).

Run on mote:
- go test -tags nogui -count=1 ./internal/source ./internal/ghtoken
  ./internal/plugin ./internal/library: all ok.
- Broken by hand: with the old source.go, ghtoken.go and github.go, all
  three tests went red ("requests = [https://api.github.com/repos/o/r]";
  "token=true"; "context deadline exceeded" at taggedWait).
- Locally: gofmt -l clean; go vet for linux and windows on the three
  packages; go build -tags nogui ./...

Not tried:
- The real network from mainland China.
- A live gh-proxy answer to an anonymous api.github.com search.
- Not changed: the mirror for api.github.com still waits for
  MAGPIE_MIRRORS. Without it, the 60s alone covers the ~30s page.
- No GUI file was run: the page's fixtures fake /api/plugins/github, and
  nothing in the window changed.

Reported by MYCF711.
2026-10-28 03:57:51 +08:00
yetone 63c0c354af gui: Discover is quieter: one unofficial mark, one button style, a reason in your language
Kiko03O1 on X asked for a better-looking Plugins › Discover page
("ui 设计能不能好看点"). Five things on it said one thing twice or said
it raw:

- A GitHub card had an "Unofficial" chip. A GitHub card is only ever
  drawn in the 非官方插件 · GitHub section, so the chip repeated the
  section's head on every card. It is gone from the card; the plugin's
  page keeps its full warning.
- Sign in on a card and on an Installed row is tinted like Install,
  not filled. It stays filled only in the plugin's sheet, so each level
  of action has one look.
- The GitHub line said Go's English in the middle of a zh page ("no
  answer in 8s"). internal/plugin's GitHub read now wraps its timeout in
  ErrNoAnswer; /api/plugins/github passes `why`: "slow" for that or any
  timeout, "limited" for GitHub's rate limit (ghtoken.Limited), and the page says "GitHub 响应超时" (zh, zh-TW, ja, de); the raw
  error is the line's hover. The line is smaller and muted, and Retry
  takes the accent colour.
- The second filter row's All had a count. It always equalled
  Installed + Not installed and the first row's picked count, so
  "全部 · N" showed twice side by side. It has no count now.
- Found on the way, same page: the filter box's placeholder was cut off
  in en at 1280/1100/980 and in de at every width but 420. It fits at
  every width now; the filter bar wraps where it did.

Looked at and left alone: the 8px inset on the borderless Signed in,
and the monospace version numbers.

plugins.js nets -25 bytes (the Unofficial chip's code went), so the
core script budget is unchanged: TestCoreScriptBudget passes at the
pushed head with no raise.

What was run, at this change on origin/main 4b9694c34, and again after
the last rebase onto 0df6a3aba: TestCoreScriptBudget, TestTaggedWhyKind,
gofmt, and the four changed GUI files with i18n-keys in both engines
(80 of 80):
- Red without the change: with the old assets, the four changed GUI
  files (plugin-github, plugin-github-wait, plugin-github-filter,
  plugin-market) went 37 red in Chromium; plugin-market expected the
  tinted colour and got the filled one. TestTaggedWhyKind doesn't
  compile without the change.
- Changed and nearby GUI files (those four, i18n-keys,
  plugin-check-github-limit, plugin-kinds-discover, plugin-page), both
  engines: 124 of 124 pass.
- gofmt clean. go vet clean on darwin, linux (-tags nogui) and windows;
  all three build. go test internal/gui and internal/plugin: plugin ok;
  gui ok on its own, one red in the package run,
  TestMainWindowCorners/macOS_15_SDK killed at its 40s deadline at load
  ~85 (#2645), which passes alone.
- The whole GUI suite (858 files, both engines, concurrency 3) was
  started at 628e18987 and ended early when the disk filled (ENOSPC):
  ~350 files ran, 3108 passed. Its five reds from before the disk
  filled are off the Plugins page, pass alone, and are filed:
  agent-models (#3468), cli-update (#3473), context-picks (#3483),
  deprecated-subscriptions (#3484). The rest failed launching a browser
  with ENOSPC.
- Rerun after space was freed, at d7ad3f2a3 plus this change: every
  library-* file, every plugin-* file, login-import, menu-input-scroll,
  mobile-web, name-suffix-saved and i18n-keys (94 files, both engines):
  1414 of 1426 pass. The 12 reds are all red on an origin/main
  118486258 worktree too, and filed: library-mcp-health-wsl ja (#3350),
  menu-input-scroll (#3402, 0 of 4 on main), plugin-card-update webkit
  (#3079, 0-1 of 3 on main over three runs, same Update-button wait),
  plugin-github chromium de 440 scrolled 1px (#3218, 18 of 18 alone).
- The two files after name-suffix-saved outside plugin-* that open the
  Plugins page, settings-tabs-stick and title-bar-tools, both engines:
  42 of 42 pass.
- Not run: the other ~440 GUI files after name-suffix-saved, and
  go test ./... .

Screenshots, before and after, zh dark and en light, were checked by
eye at 1280.
2026-10-24 22:31:59 +08:00
yetone fb101b0d57 plugins: a GitHub list that couldn't be read says why with Try again, instead of the section vanishing (till on Discord)
till (Windows, v0.1.1293, Belarus network) saw no "Unofficial plugins ·
GitHub" section in Plugins › Discover; a magpie in Japan shows it. On
v0.1.1293 the section shows its loading skeleton and then disappears
whenever GitHub can't be read: plugin.TaggedRepos returned the last list
(or nothing) with no error when the topic search failed, and an empty
list with no error when the search answered but every package.json read
from raw.githubusercontent.com failed or timed out. /api/plugins/github
answered 200 {repos:[]}, and the page showed ghFailed only on an HTTP
error, never in a search, and never once a list had been had.

Now:
- TaggedRepos returns the error with what it has. A failed search keeps
  the last list and says why (held a minute, like before); repositories
  the search found but that couldn't be read come back as a
  *TaggedMissing with their count and the last read error.
- /api/plugins/github sends error and missing beside repos; ?again asks
  GitHub again at once when the last answer had an error.
- The page shows the reason and Try again: in place of the section when
  nothing could be read (in Discover and in a search), and as a line over
  the cards when some were read or an older list is kept. Try again keeps
  the cards while it asks. zh, zh-TW, ja and de strings added.

No Windows-only cause was found in the code: the fetch goes through the
same netproxy on every OS (a PAC-only system proxy isn't read anywhere).
The likely cause is the network reaching api.github.com or
raw.githubusercontent.com, or the unauthenticated search limit; the page
now names which.

Run (worktree on ef655acb4, sandbox HOME):
- gofmt -l clean; go vet darwin, linux -tags nogui, windows ok; builds ok.
- go test ./internal/plugin ./internal/gui: ok. Broken by hand (failure
  path returning nil error; missing ignored): TestTaggedRepos ("down:
  <nil>") and TestTaggedReposUnreadable go red; restored, green.
- plugin-github-wait.test.cjs: 18/18 in chromium and webkit, every
  language and width; against the old assets it times out waiting for
  the reason (red). After the rebase: once 16/18 and once 17/18 with
  page.goto's 5s load timing out at load average ~280, then 18/18.
- Whole GUI suite, both engines: all pass except codex-predictions at
  420 (7 cases: Settings' stuck search head takes the click), already
  #2624, untouched by this change.
- set -o pipefail; go test -timeout 45m ./...: every package ok except
  internal/agent, which hit the 45m timeout at load average ~200 with
  other sessions' suites (2769s). Rerun after the rebase with
  internal/plugin and internal/gui: plugin ok (973s), gui ok (550s),
  agent timed out again (2704s, load ~400). Recorded on #2723; this
  change touches nothing in internal/agent.

Not tried on Windows or from the reporter's network.
2026-10-20 02:35:14 +08:00
yetone ba132d68b6 plugin: the GitHub plugin list reads every page of the search, not the top 50 (@HoGee_xxl on X)
@HoGee_xxl on X: the Plugins page's GitHub list showed 50 repositories
while the opencode-plugin topic held 59. askTagged asked GitHub's search
for one page of 50 and stopped, so every repository past the 50th by
stars never showed. It now reads pages of 100 until a short page or
total_count, up to the 1000 GitHub's search answers, and a repository
that moves between two pages (starred in between) is listed once.

Run:
- TestTaggedReposEveryPage (new): a fake search of 7 repositories served
  2 a page; all 7 listed, in order, once. Red with the page loop broken by
  hand (stop after page 1): only the first 2 listed.
- Full suite at 63be47717 plus this change, `go test -p 2 -tags nogui
  -count=1 -timeout 45m ./...` (load average 230-270): 63 packages ok;
  internal/agent and internal/gateway timed out at 45m with no test
  failed; internal/gui's TestSetAnswersWhileDevinAndProvidersHang red
  under load (a set took 22s), the open #1375 - output and cause
  commented there. internal/gui and internal/plugin then run alone:
  both ok (343s, 416s).
- gofmt -l empty; GOOS=linux and GOOS=windows go vet -tags nogui ./...
  exit 0.
Not tried against the real GitHub API in the app.
2026-10-16 19:43:37 +08:00
yetone b6533893a7 plugins: Discover lists tools and page plugins, and the intro links to the plugin docs
Every kind of plugin magpie runs now has its place on the Plugins page, so
someone looking to extend magpie finds what exists and how to write one:

- Discover has "Tools for agents" (market kind "tools") and "Pages" (kind
  "page") sections beside Subscriptions, Gateway middleware and Agents,
  each card with its own chip (a new Tools chip, the Page chip). Before,
  both kinds fell under Subscriptions as Providers.
- A GitHub repository tagged magpie-plugin whose package.json has
  magpie.page.file is a Page, and that file must be committed, as a
  provider's entry must (TaggedRepos).
- An installed plugin that only gives tools wears the Tools chip.
- The intro says what a plugin can be (provider, gateway middleware,
  routing strategy, tools, an agent, a page) and its "Write a plugin" link
  opens usemagpie.ai/docs/plugins in the window's language (zh and zh-TW
  to zh/, ja to ja/), outside the window.
- The docs' Publishing section lists the "tools", "page" and "agent"
  registry kinds and the community package names for each, in en, zh, ja.

Run at the reviewed head (on origin/main cf21b71ff):
- go test ./internal/plugin: ok. Broken by hand: without the page case,
  and with the page's entry not checked, TestTaggedRepos goes red.
- plugin-kinds-discover.test.cjs (new): 5 languages x 980/420 x chromium
  and webkit, green. Broken by hand, each red: the old plugins.js (11/11
  fail), no "tools" kind (11/11), no ja/zh-TW docs link (3), no Tools chip
  on an installed row (11/11).
- plugin-middleware.test.cjs's intro test now checks the new copy and link;
  it still checks the click scrolls nothing.
- Every plugin*.test.cjs and i18n*.test.cjs, both engines: 505 pass, 0 fail.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: 0.
- go test -timeout 45m ./...: all 66 packages ok (full=0).
2026-10-16 01:48:45 +08:00
yetone 48e59c5b89 plugin: the unofficial plugins on GitHub aren't cut short through a slow proxy, and a list cut short is asked again in 20s, not kept ten minutes (larchsis on X)
larchsis (Windows, no system proxy, magpie's own proxy on) saw no
unofficial plugins on the Plugins page, and saw them with the system
proxy on and magpie's set to automatic.

No request bypasses magpie's proxy. Every listing and install read
(market.json, npm info and search, GitHub's search, package.json and
README, Bun's download, plugin icons) goes through http.DefaultClient or
DefaultTransport, which netproxy.Install routes through settings.Proxy,
else the environment, else the system proxy (HKCU Internet Settings on
Windows). Checked with a counting CONNECT proxy in a sandbox magpie on
macOS and on the Windows box: every connection to api.github.com,
raw.githubusercontent.com and registry.npmjs.org went through it, and
lsof / Get-NetTCPConnection showed none going direct.

The cause is timing. askTagged gave the whole listing 8s, six package.json
reads at once, each bounded by that same 8s, and a repository whose read
hadn't finished was left out. The cut list was then kept ten minutes, and
on disk for a restart. Through a sandbox proxy that adds latency per
chunk: no delay 29 repos, 150ms 21, 300ms 6. A slow proxy loses most of
"Unofficial, on GitHub", and when it loses all of them the section is gone.
The two setups differ in latency and in what was cached, not in proxy
handling.

Now:
- Reads go on past the page's wait (taggedEach 20s each, 12 at once), on a
  context detached from the request. They are kept by repository and push,
  as before, so the next ask has them.
- A repository whose read didn't come in time is as the last list had it
  (in memory, else on disk), with the search's current stars and
  description.
- A list that left one out is asked again after 20s, not ten minutes. Its
  copy on disk is dated so that a restarted magpie asks again too.

Run:
- TestTaggedReposSlowRead (new) holds word-guard's package.json past a
  300ms wait. It fails on the old code (5 repos, word-guard missing). It
  also fails with each part broken by hand: no fallback to the last list,
  a partial list kept 10 minutes, reads cancelled at the wait, and the disk
  copy not aged back.
- Sandbox magpie web (own HOME, own ports, proxy 127.0.0.1:3481 with
  injected latency), no cache: at 300ms 11 repos at 8s, then all 29 25s
  later (the old code kept 6 for ten minutes). At 1s none at first, all 29
  25s later.
- go test ./... on 5e7efce3b (origin/main): green. go test -race -count=5
  on the tagged tests. gofmt -l clean. go vet on darwin, GOOS=windows
  ./..., GOOS=linux -tags nogui ./internal/plugin.
- Windows box: plugin.test.exe with the tagged tests, 3 of 3. In the full
  package run only TestMarketIconsAreBundled failed, because it reads
  ../gui/assets, which wasn't copied over.
2026-10-12 17:45:54 +08:00
yetone cc2092a4b0 plugin, gui: a market plugin's card wears the picture its package gives (magpie.icon from npm) when the market gives none
yetone: 这里的 agent plugin 为什么没有 logo. Aider's card in Discover › Agent
showed the generic agent glyph: the registry entry has no icon, and the
card only read the registry's, which is one of magpie's icon names. A
GitHub-tagged plugin's card already read package.json's magpie.icon; a
listed one didn't.

- plugin: npm's /latest answer carries package.json, so NPM.Icon is its
  magpie.icon, an https URL or data:image URI only (ownIcon, now shared
  with the GitHub listing's check).
- gui: listings, market and /api/plugins/npm keep that picture as an
  installed plugin's is (provider.RepoIcons) and send the page a file:
  icon, never the data URI or the remote URL.
- plugins.js: card, plugin page and installed row use l.icon, then
  l.npm.icon.
- Registry icons stay names, so older magpies aren't handed a URL they
  would draw as a broken mask.
- docs: magpie.icon also shows on the Discover card (en, zh, ja).

agent-aider 0.1.1 (magpie-community/plugins bcc94e5) gives aider.chat's
icon as magpie.icon and agent.icon.

Ran:
- go test ./internal/plugin ./internal/gui; go test ./internal/provider
  alone (504s, pass); go test ./... otherwise ok.
- gofmt -l; vet linux/windows ./internal/plugin.
- internal/gui/tests/plugin*.test.cjs in chromium+webkit; plugin-agent's
  new check goes red (11 fail) with the card reading l.icon only.
- Sandbox HOME with the real npm package 0.1.1: the Discover card,
  Installed row and Agents row all show Aider's icon, in chromium and
  webkit at 1100 and 420.
2026-10-10 23:57:56 +08:00
yetone 61c40b80bb plugin: a GitHub-tagged agent plugin is listed as an agent, not left out
TaggedRepos knew a package.json's magpie.middleware but not magpie.agent
(cb406c84's new kind). An agent package has no main and no index.js, so it
was looked for at index.js, not found, and dropped from Plugins › Discover.
It is now kind "agent", its entry checked at magpie.agent, and the GUI's
kindOf already shows it under Agents.

Fixture: someone/agent-aider, the bytes of magpie-community's
packages/aider package.json and aider.agent.js.

Run: go test -tags nogui ./internal/plugin ./internal/gui ok;
TestTaggedRepos fails on the old github.go (agent-aider missing); gofmt;
GOOS=linux/windows go vet ./internal/plugin.
2026-10-10 23:05:16 +08:00
yetone a3a8e25792 plugins: a repository tagged magpie-plugin shows the icon its package.json gives (yetone: 非官方的插件能否支持 icon)
magpie.icon, an https URL or a data:image URI, is read with the rest of
package.json and kept through pluginOwnIcon as an installed plugin's is;
the card shows it, else the puzzle piece.

Ran: go test ./internal/plugin ./internal/gui ./internal/provider; the
plugin GUI tests in Chromium and WebKit (en/zh/ja/de, 980 and 440).
2026-10-10 00:42:37 +08:00
yetoneandClaude cdf325f178 plugins: a package that is only a command (an MCP server like magpie-x-search) isn't listed under Unreviewed, isn't added as a plugin, and one added before says what it is instead of a host stack (#1327, congee949)
A repository tagged magpie-plugin whose npm copy (from that repository)
names no file to load (no main, no exports) was listed and installed from
npm without the entry check the GitHub route has; it then failed every
host start with "has no entry" and a stack. Now:

- the Unreviewed list checks npm's copy the same way: one that names no
  file needs the index.js the repository's own route needs (askTagged);
- `magpie plugin add` / the Plugins page refuse a package that names no
  file, has no index file and is neither pi's nor a middleware, take the
  package just installed for it out again, and say it isn't an OpenCode
  or magpie plugin, and, for one with a bin, to add an MCP server under
  Library → MCP servers (notPlugin);
- the host says the same, without a stack, for one already on the list.

Run: TestCommandOnlyPackageIsNoPlugin (magpie-x-search 1.2.0's real
package.json) fails without the change (Add = <nil>; with only host.js
reverted, the stack message), TestTaggedRepos with the real GitHub
package.json and npm latest of cyberElar/magpie-x-search fails without it
(listed), both pass with it; TestNotPluginKeepsPlugins (index.mjs, main,
exports, middleware, pi, a file stay plugins). go test -tags nogui
./internal/plugin under a temp HOME ok; go vet -tags nogui for darwin,
linux, windows. The built binary in a sandbox HOME: `magpie plugin add
magpie-x-search@latest` from real npm prints the new error, and
plugins/package.json no longer lists it.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-08 23:09:25 +08:00
yetone a12f6fc13a plugins: a repository tagged magpie-plugin shows within ten minutes, not up to six hours later (lee04052822 on X: tagged it, and magpie didn't show it)
GitHub's search was asked at most every six hours. An author who had opened
the Plugins page before tagging their repository, as lee04052822 had,
didn't see it until the six hours were up. It is now asked at most every
ten minutes. A search is one request of the ten a minute that GitHub allows
without a token. What each repository's package.json, npm and entry file
said is kept while its last push stays the same, so asking again costs one
request, not three per repository. An answer GitHub or npm didn't give (a
503 for the entry, say) isn't kept, and is asked again next time.

Against real GitHub: the topic has two repositories,
mu-zi-lee/magpie-doubao-translate and SadWood/magpie-gaccode. Both are
listed as github: installs, the first time in 3.8s and in 0.2s once the ten
minutes are up. Both installed and loaded in a sandbox magpie, giving the
Doubao Translation and GACCode providers. TestTaggedRepos checks that
asking again after ten minutes reads only flaky-entry again, and it fails
with 21 reads when the per-repository cache is turned off. go test -race
-count=2 ./internal/plugin and go vet pass.
2026-10-07 22:09:45 +08:00
yetone f6f960e42c plugins: a GitHub repository tagged magpie-plugin shows on the Plugins page under Discover, as an unofficial plugin nobody at magpie has reviewed
GitHub's search for topic:magpie-plugin (not archived, not a fork, not
magpie-community's own, which the market lists) is asked at most every six
hours and kept on disk, so a restart or GitHub being down shows what it said
last. Each repository is read from its package.json on the default branch.
When npm has that package published from the same repository, it is
installed from npm, because a repository often builds its dist only to
publish and Bun runs no build for a git install. Otherwise it is installed as
github:owner/repo, and only if the file it loads (exports, main or
magpie.middleware) is in the repository. Its page warns that it is
unofficial, says whether npm or the repository is what gets installed, and
shows the repository's README until it is installed. MAGPIE_PLUGIN_MARKET=off
asks GitHub nothing.

Checked against real GitHub with the topic set to opencode-plugin in a
sandbox: 43 repositories came back, and 32 were kept (30 from npm, 2 from
git). github:ndom91/open-plan-annotator, one of the git ones, really
installed and loaded. alfaoz/opencode-see-image, whose dist isn't in its
repository, failed to load before the entry check and is now left out. The
test fixtures are GitHub's and npm's real answers.

Ran: go test -race -count=3 ./internal/plugin, go test ./internal/gui, go
vet, and plugin-github.test.cjs (Chromium and WebKit, 980/440, en/zh/ja/de,
18/18). The full GUI suite passed 3343 of 3348. The 5 failures were WebKit
number-units, purpose-filter and routing-failed-open, which pass 3/3 on
their own and don't touch the Plugins page.
2026-10-07 10:13:20 +08:00