88b4c00ea11c8653cada22e11edf20ab1594de43
21
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a0ebe0032d |
plugin: a listed plugin whose package is gone is installed again, and bun's installs run one at a time (#2002)
anganing (Windows 11, v0.1.1229): after an auto-update, every switched-on plugin said "no such plugin: …\node_modules\@magpie-community\opencode-grok-auth" at each start. For the github: plugins the path was the spec itself (node_modules\github:owner\repo), so package.json no longer listed them. Removing a plugin and adding it again was the only way out. - InstallMissing installs again each listed plugin (switched off or not) whose package isn't in plugins/, from its own spec. KeepUpdated runs it 30s after start and then hourly, before CheckUpdates. Nothing did this before: CheckUpdates skips a plugin with no installed version. - installMu serialises every bun command that changes plugins/: install (including the first package.json it writes), reinstall's bun update, and Remove's and add's bun remove. At start KeepUpdated (30s) and keepMovedCurrent (20s) each run bun add with no lock. On the Windows box, three concurrent bun add runs (Bun 1.4.3) in one folder kept only one writer's package.json change. A git plugin's dependency dropped that way leaves Name() unresolved, which is the reporter's github rows. The exact sequence that emptied the reporter's node_modules wasn't reproduced. Bun 1.4.2 -> 1.4.3, magpie v0.1.1205 -> v0.1.1227 with the same plugins, and a package.json reset all left the folders in place. So this repairs the state and closes the one race found. It isn't proven to be the trigger. Run: - go test ./internal/plugin ./internal/provider -count=1: ok. - The new tests -count=3 on macOS, and on the Windows box as a cross-built test binary: ok. - Broke each fix by hand (lock a no-op; InstallMissing returns early): TestBunCommandsOneAtATime fails with "another bun is running here", and TestMissingPluginsInstalledAgain gets 0, want 2. - Real use on the Windows box, sandbox HOME, port 3561, real Bun 1.4.3: deleted opencode-grok-auth and opencode-qoder-auth from node_modules and started serve built from this commit. The host logged the reporter's exact "no such plugin" for both. At +30s it logged "installed 1 missing plugins again" and both folders were back. After the restart, no plugin failed to load. - gofmt -l internal/: clean. go vet for darwin, linux -tags nogui and windows (plugin, provider, gateway), and GOOS=windows go build ./...: ok. |
||
|
|
1d8134605a |
plugin: a plugin pinned to a version, or turned off, keeps both throu… (#1076)
* plugin: a mover installs the version its user pinned, not @latest
plugin.Add installs the spec it is given and appends @latest to a bare
package name, so installPlugin — the mover's installer, for
keepMovedCurrent, Move and HandOver — handing it a bare name quietly
replaced <pkg>@1.2.3 with <pkg>@latest in plugins.json. The pin was the
user's choice, and it was destroyed behind their back every time the
mover's min was raised.
installPlugin now hands Add the entry's own spec when the user has one.
A pin older than the move needs is left pinned and reported by the check
that was already there below it ("%s %s is installed; moving needs %s
or newer"), whose remedy is to unpin it; a pin that satisfies min still
returns early and is not reinstalled. A user with no entry for the
package keeps the bare name, which is a first install and there is no
pin to keep. A plugin the user turned off is still refused before any of
this, as it was.
TestInstallPluginKeepsTheUsersPin pins fake@0.1.5 with the move needing
0.2.0 and writes the version plugin.Version reads into the plugins folder
it is read from. It asks Add for fake@0.1.5 — against installPlugin as it
handed over the bare name it fails with "asked Add for [fake], want the
pinned fake@0.1.5" — and gets "needs 0.2.0 or newer" back rather than a
silent install of @latest. It also checks that a plugin the user turned
off is refused and not asked for at all. addPlugin is a var beside
pluginProviders and removePlugin so the test can read the spec handed
over without the Bun that Add runs.
Rebased on main as of
|
||
|
|
23c6e865a7 |
plugin: a musl Linux (Alpine) runs plugins on Bun's musl build, kept apart from the glibc one (#1877)
emptyteeth found it: bunTarget picked Bun's build from GOOS/GOARCH alone, so Alpine got bun-linux-x64-baseline, a glibc build whose interpreter (/lib64/ld-linux-x86-64.so.2) Alpine lacks. exec then said "fork/exec …/bun/1.4.2/magpie-bun: no such file or directory", which reads as a missing file, and no plugin could be added or run. - bunTarget: a musl Linux gets bun-linux-x64-musl-baseline or bun-linux-aarch64-musl. The musl check moves out of internal/claudecode into internal/libc (libc.Musl, unchanged rule: Anthropic's installer's /lib/libc.musl-*.so.1), which claudecode, the plugin host and the CLI test that skipped on musl now share. - bunSums: the two musl builds' checksums, checked against Bun v1.4.2's own SHASUMS256.txt (downloaded from the GitHub release; they match the issue's numbers). - Cache: a musl Linux keeps its Buns and state.json under bun/musl, so a machine whose C library changed never runs the other build, nor takes its state, whose Bad may list versions only the glibc build failed (CheckBun on Alpine set aside every newer Bun). glibc, macOS and Windows stay in bun/<v>, so a Bun downloaded before is used as it is, with no new download. - A bun on disk that exec can't start with ENOENT says it is a build for another C library and names MAGPIE_BUN (cantStart), for the host's start and for bun add/bun update. The same for a $MAGPIE_BUN. - Bun's musl build needs libstdc++ and libgcc, which a bare Alpine lacks: the loader then prints "Error loading shared library libstdc++.so.6" above ~40 "Error relocating" lines, and bun add cut it off. bun add, bun update and a host that died starting now say which library is missing and `apk add libstdc++ libgcc` (missingLibs, whyDied). Decided: a Bun that can't be started at all is not counted as crashed. The fallback goes to the version before, which is the same build for this system and fails the same way, and setting the current one aside would mark a good version bad for good. The libc check happens before the download instead (the target), so Alpine never fetches the glibc build. Run: - docker alpine:3.20 (arm64, and amd64 under emulation), sandbox HOME in the container, linux nogui builds. origin/main's binary reproduces the report: "bun add …: fork/exec /sbx/.cache/magpie/bun/1.4.2/magpie-bun: no such file or directory". This one on bare Alpine downloads bun/musl/1.4.2 and says "this system lacks libstdc++.so.6 … apk add libstdc++ libgcc"; after apk add, `magpie plugin add @magpie-community/opencode-cursor-auth` adds it and `plugin list` starts the host and lists cursor (arm64 and amd64), with the old glibc bun/1.4.2 left beside it unused. With libstdc++ removed again, plugin list says the library; MAGPIE_BUN pointed at the glibc build gives the C library message. - New tests (bunmusl_test.go, libc_test.go), each broken by hand and seen red: no musl branch (TestBunTargetForMusl, TestMuslBunKeptApartFromGlibc), no bun/musl root (TestMuslBunKeptApartFromGlibc), cantStart returning the error as is (TestCantStartSaysCLibrary, TestHostOnUnstartableBunSaysCLibrary, which fails with the reporter's exact message), host.go without it, no musl sum (TestBunDefaultSums), no hint in bun add (TestMissingLibsNamesThem) or in the host's start (TestHostOnBunLackingLibsSaysWhich), muslAt always false (TestMuslAt). -race -count=20 on them: green. - gofmt -l; go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows; go build for darwin, linux nogui, windows; go test -tags nogui for internal/plugin, libc, claudecode, cli in a sandbox HOME, and go test -tags nogui ./... (all green). One earlier run of internal/plugin with the other three packages went red, and its output was lost to a tail; four reruns of it, alone and together, were green, and the new tests were green under -race -count=20, so which test it was isn't known. Not tried: a glibc Linux end to end after the change (the unit test covers that its Bun stays at bun/<v>); a musl Linux other than Alpine (the detection is unchanged and looks for Alpine's libc.musl-*.so.1). The old glibc bun/<v> on an Alpine machine stays on disk (~90 MB); it isn't removed, as a volume shared with a glibc container could be using it. |
||
|
|
49b6e87b41 |
plugin, cli: on Windows, a plugin added from a folder is found by its short name too (magpie plugin off/on/rm/options zz-tags) (#1827)
ShortName cut a plugin's name at its last "/". A plugin added from a
folder is named by its path, and on Windows that path has only
backslashes, so its short name was the whole path: `magpie plugin off
zz-tags` said there was no plugin "zz-tags", and so did on, rm, options
and plugin.SetOptions. It now cuts at the last "/" or "\". npm names
have no backslash, so they are unchanged.
TestPluginOnOffRmShortName was one of the 26 Windows failures listed in
#1827 (CaramelizedCUDA). TestSetOptionsShortName now also checks a
Windows path, so the case fails on every OS without the fix.
Run:
- without the fix, macOS: TestSetOptionsShortName fails, ShortName
("C:\\Users\\me\\plugins\\middleware-zz-tags") = the whole path, want
"zz-tags"; with it, passes.
- Windows 11 box (windows/amd64 test binaries, sandbox USERPROFILE and
APPDATA): at
|
||
|
|
89271cd4e8 |
provider, plugin, settings: accounts left all zero by a crash are read from their last good copy, and every state file is flushed before it is renamed in (#1505, Zhangwier)
Zhangwier's Windows machine went down hard, and logins.json (10783 bytes)
and plugin-auth.json (29926 bytes) came back at full length with every byte
0x00. Every account was gone. The rename had reached the disk before the
data. magpie then read "no accounts", and its next write would have made
that final.
What changed:
- Flushed before rename: steady.WriteFile writes a temp file, fsyncs it,
then renames it in. A failed write or flush removes the temp file and
leaves the old file as it was. edit.WriteAtomic, Kiro's writer, the
Codex session rewrite and the plugin host's writeDurable (host.js)
flush the same way. So do writePrivate (providers, logins, migrations),
settings, profiles, plugins.json, plugin-auth.json and mcp-signins.json.
- A last good generation: before each write, lastgood.Keep keeps the
valid file there as <file>.bak. A file that isn't valid is copied aside
as <file>.bad-<time>, with -2, -3 when two land in one second (O_EXCL),
and is never overwritten before that copy exists. The .bak lags one
write behind on purpose, since a crash zeroes the latest write.
- A failed read is unknown, never empty. On a cold start, logins.json,
providers.json, migrations.json, settings.json, profiles.json,
plugins.json, plugin-auth.json (Go and the host) and mcp-signins.json
are read from their .bak when they don't read. The recovery is logged
and listed in /api/state's recovered, and the window says it once in
every language. With no good .bak, a sign-out leaves plugin-auth.json
and mcp-signins.json as they are (the host's changeAuth no longer
writes {} over them). magpie's own sign-out returns the error, and a
sign-in copies the bad file aside before writing.
- caller-keys.json is flushed but never read from a .bak. A key revoked
in the last write would come back, so a store that doesn't read still
refuses every key, as its tests require.
ggbdpq's patch (f230bcae) is where the fsync-before-rename in
writePrivate, writeWhole and writeAuth came from. This change puts it in
one shared helper and reaches every other writer of magpie's state. The
JS write cleans up its temp file. The .bak recovery, the .bad copies and
the GUI notice are added here.
What was run:
- New tests, built from the literal case (10783 and 29926 zero bytes):
- internal/lastgood
- provider: TestZeroedLogins*, TestZeroedMigrations*,
TestZeroedProviders*, TestWritePrivateSyncsBeforeRename
- plugin: TestZeroedPluginAuth* against the real bun host,
TestPluginAuthSyncedBeforeRename with a plugin that makes fsync fail,
TestZeroedPluginList*
- TestZeroedSettings*, TestZeroedProfiles*, TestZeroedMCPSignIns*
- steady TestWriteFileSyncsBeforeRename, edit
TestWriteAtomicSyncsBeforeRename
- gui recovered-file.test.cjs (en/zh/zh-TW/ja/de, Chromium and WebKit)
- Broken by hand, each going red:
- Without the sync: the steady, edit, writePrivate and host fsync tests.
- Without the .bak fallback: every TestZeroed* test.
- The old changeAuth writes "{}\n" over the zeros.
- The old readLogins default.
- KeepBad without suffixes fails the one-second test.
- Without recoveredOnce, the GUI test fails 5/5.
- macOS: go test -tags nogui ./... in a sandbox HOME. The only failures
were the two access tests (then fixed by not recovering caller keys) and
TestProvidersCmdSaysUnreadable, which now removes the .bak to test the
no-backup case. Both packages were rerun and pass. gofmt -l prints
nothing. go vet, and GOOS=linux and GOOS=windows go vet -tags nogui, are
clean on the touched packages.
- GUI: recovered-file, whats-new, click-scroll, gui-de, gui-ja,
gui-zh-tw and i18n-keys pass.
- Windows box (cross-compiled test exes, sandboxed USERPROFILE/APPDATA):
lastgood, steady, provider, plugin (real bun host), settings, mcpauth,
edit and access pass. In profile, TestProfileSwitchesModelList and
TestOldProfileKeepsModelList fail the same on origin/main (filed as
#1517).
Reported-by: Zhangwier
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
|
||
|
|
cb406c8425 |
plugins: a plugin can add an agent magpie has no setup of its own for
Plugins could be subscription providers or gateway middleware. Now a third
kind: an agent plugin, so a user whose agent magpie doesn't ship can still
put it on magpie.
- internal/agentplug: a plugin's magpie.agent module (or a *.agent.js file)
exports agent = {id, name, config, format?, model, prefix?, bin?, dir?,
ua?, icon?, notice?} and an optional connect({gateway, model, models,
agent}) returning the other keys to write. Compiled in moejs, reloaded
when plugins.json or the file changes; why one didn't load is kept.
- internal/jsmod: module compiling (imports kept inside the plugin), moved
out of middleware so both share it.
- internal/agent/plugged.go: each becomes an Agent (Plugin set) after
magpie's own. JSON, YAML and env files are edited key by key, comments
kept; what each key held is stashed typed under plugin:<id>:<path>, and
its own model or Disconnect puts every key back. A built-in id is
refused; a connect that throws writes nothing. Key magpie-<id>; usage
names it by key or ua (usage.PluginAgents).
- GUI Plugins page: an Agent kind chip and glyph, a Discover "Agents"
section (market kind "agent"), and an installed row line "Adds X to
Agents" or why it didn't load. zh, zh-TW, ja, de strings.
- Docs: site Plugins page (en, zh, ja) "Agent plugins", reference.md,
agent-wiring.md, gateway-middleware.md.
Run:
- go test ./... (all ok); gofmt -l clean; GOOS=linux go vet -tags nogui
./... and GOOS=windows go vet ./... clean.
- TestPluggedYAML, TestPluggedJSONUnwire, TestPluggedRefused.
- GUI: plugin-agent.test.cjs 22/22 (en, zh, zh-TW, ja, de; 980 and 420;
chromium and webkit); all plugin-*.test.cjs, i18n-keys,
deprecated-subscriptions, filter-ime: 315 pass, 0 fail.
- Real use, in a sandbox HOME: an Aider plugin (~/.aider.conf.yml, prefix
openai/, connect writes openai-api-base/key) installed in a dev build;
picking DeepSeek V4.1 Flash on the Agents page wired the file keeping the
user's comment and keys; real aider 0.86.2 `--message` answered through
magpie from the real DeepSeek account; usage.jsonl recorded agent aider,
provider deepseek, 200; Disconnect restored the file byte for byte.
|
||
|
|
ba0e2a8aa9 |
plugin: Update all and magpie plugin update bring a plugin pinned to an older version to npm's newest, so the update prompt clears (ARNO on Discord)
ARNO: 非官方插件安装后就算更新到最新版,magpie依然提示有更新. A third-party plugin added as name@1.2.3 is pinned. The Plugins page still counts it under "Update all (n)", its row says "vX out" and the Plugins dot is on. Update all (and `magpie plugin update`) reinstalled the pinned version, reported "Plugins updated", and the prompt stayed. The row's own Update already installs the newest version and unpins the spec (name@latest). Update now does the same for a pinned plugin when npm has a newer version than the one installed: it installs that version through add, which keeps the plugin's options and the provider picked for it. A pinned plugin that is already at npm's newest keeps its pin. Git plugins, folders and plugins npm didn't answer for behave as before. The plugin docs (en, zh, ja) now say that updating a pinned plugin yourself unpins it. Reproduced in a sandbox HOME with the real opencode-gemini-auth from npm (magpie web on a spare port, China mirror switch on and off). Pinned at 1.4.15 with 2.0.1 out: before the fix, Update all and `magpie plugin update` left it at 1.4.15 and /api/plugins/updates still listed it. After the fix it is at 2.0.1 as opencode-gemini-auth@latest, the waiting list is empty and Check for updates reports "current". The row's Update (upgrade) path was checked too: unpinned opencode-gemini-auth, and scoped @gitlab/opencode-gitlab-auth 1.3.1 -> 1.3.3 with the mirror on. Both cleared the prompt before the fix as well. TestUpdateAllUpdatesAPinnedPlugin (real bun, fake registry) fails without the change: "Update all left opencode-someones-auth at 1.0.0, want 2.0.0". gofmt -l, go vet (darwin, GOOS=linux, GOOS=windows) on internal/plugin, and go test -tags nogui of internal/plugin, internal/gui and internal/provider under a temp HOME with pinned caches all pass. |
||
|
|
7d0e415e62 |
plugins: two plugins that sign in to one provider are both listed, each row says which serves it, and Use for picks the other (neiko on Discord)
neiko on Discord installed a third-party plugin beside a plugin of their
own, added by its folder. Only the third-party one could be seen. Both
plugins' auth hooks name the same provider id. The host's auths() keeps
the last plugin in plugins.json for an id, as OpenCode does, so the
user's own plugin silently lost it:
- its row read "Signs in to nothing magpie can use";
- its provider was gone from the Add sheet;
- keepUnloaded could list the id a second time, from the
plugin-providers.json kept before.
A package-name clash and a display-name clash were tried as well. Both
plugins stay visible in those cases, because a folder plugin's name is
its path.
What changed:
- host.js:
- init gives each loaded plugin the ids it signs in to (provides) and,
for each id another plugin serves, that plugin's spec (servedBy).
- auths() honours plugins.json's new prefer map (id -> spec).
- Only the serving plugin's provider.models hook runs for the id.
- plugin:
- Clashes() turns provides and servedBy into {id, by, with} per spec.
- Prefer() records a pick and restarts the host.
- Remove drops the removed plugin's picks.
- Re-adding a plugin under a new spec carries its picks over.
- remove, off, options and prefer find a plugin by its exact spec
before its package name (indexOf), so acting on one plugin never
reaches another of the same package.
- keepUnloaded no longer re-adds a provider from before when another
plugin serves its id now.
- GUI:
- /api/plugins rows carry clashes, with the provider's listed name.
- POST /api/plugins/prefer {spec, provider}.
- The serving row says "{other} signs in to {name} too; this one
serves it".
- The other row says, in amber, "{name} is served by {other}, which
signs in to it too", with a "Use for {name}" button.
- New strings in zh, zh-TW, ja and de.
- CLI: `magpie plugin` prints the same lines, with the command that
fixes it, and `magpie plugin use <name> <provider>` makes the pick.
- Docs: docs/subsystems/provider-plugins.md, docs/reference.md and
site/public/docs/{,zh/,ja/}plugins.html.
What was run:
- Reproduced under a sandbox HOME with magpie web on 3562: a fake npm
plugin and a folder plugin, both on id "acme".
- Old binary: the local row had providers [] and /api/providers
listed acme twice.
- New binary: both rows carry the clash; prefer moves acme to the
folder plugin; remove clears the pick and leaves the other plugin
serving acme.
- New Go tests:
- TestTwoPluginsOneProvider, a real Bun host: Prefer, restart,
off/on and Remove.
- TestClashes, TestPluginNamedExactlyFirst and
TestKeepUnloadedLeavesAServedID.
- TestPluginsClashRows (gui) and TestPluginListSaysClash (CLI).
- Each fails when its piece is broken by hand: prefer ignored in
host.js, the keepUnloaded id check removed, name before exact spec,
Remove keeping picks, no provides, no clashes in the rows, no
prefer route.
- plugin-clash.test.cjs, in Chromium and WebKit, in en, zh, zh-TW, ja
and de, at 1100 and 560px: 22/22 pass. It times out on the old
plugins.js.
- gui-de, gui-ja, gui-zh-tw, i18n-keys and every plugin-*.test.cjs:
248 tests.
- 245 passed in the 4-wide run.
- plugin-moved-signin (webkit) failed once in that run, then passed
3/3 alone and 26/26 in a smaller 4-wide rerun.
- gofmt -l; go vet ./...; GOOS=linux and GOOS=windows go vet -tags
nogui ./...; go build ./...
- The full go test -tags nogui ./... under a temp HOME with the caches
pinned: 44 packages ok, none failed.
- After rebasing onto
|
||
|
|
4b56c8672d |
plugin: an update Bun holds back says why, instead of saying it was made (sweanng424 on Discord)
What: Update, Update all, the hourly auto-update and the move's install ask npm for the plugin's newest version and have bun install that exact version (installAt), then check it is the one installed. When bun won't, the error says why, reason first for the status pill: "<pkg> 0.1.21 isn't installed yet: Bun's minimumReleaseAge (in a .bunfig.toml) holds back versions published less than 2 days ago, and magpie installs it once it is older (bun's own words)". Another bun error (a registry of the user's own without the version) is "<pkg> <v> isn't installed: <bun's error: lines>". Specs stay as they were (name@latest); pinned and git plugins, and npm not answering, install as their spec says, as before. Why: the Factory card stayed at 0.1.18 with 0.1.21 out, through clicking update and restarts. bun add pkg@latest resolves "latest" by bun's own config: a minimumReleaseAge in the user's ~/.bunfig.toml or $XDG_CONFIG_HOME/.bunfig.toml makes it install the newest version older than that and exit 0. 172800s (2 days) gives exactly 0.1.18 (0.1.19-21 were published 10-08). So every update path succeeded with nothing changed, and the page said "updated to v0.1.21". Asked for 0.1.21 itself, bun fails with "blocked by minimum-release-age: 172800 seconds". The same code serves every moved plugin (Cursor, Devin, Kiro, Qoder, ...), so all of them had it. npm view: 0.1.21 is latest; npmmirror has it too. Run: - TestUpdateBunHoldsBackSaysWhy (new): real bun 1.4.2 against a fake registry with 0.1.18 (3 days old) and 0.1.21 (1 hour), a bunfig with minimumReleaseAge = 172800. On the old code it fails: "Update with 0.1.21 held back by Bun: <nil>, want bun's reason (installed 0.1.18)". Breaking Update alone fails at "Update all: <nil>", breaking the hourly update alone at "the hourly update: <nil>". Without the bunfig it installs 0.1.21 and keeps the spec @latest. - Real use: magpie web (nogui build) under a sandbox HOME, real npm, with the bunfig: add factory-auth@0.1.18, spec @latest, POST /api/plugins/upgrade and /update return the reason above, the card stays 0.1.18; bunfig removed, upgrade installs 0.1.21. - Ruled out on macOS and the Windows box: plain upgrade 0.1.18 -> 0.1.21 works there without a bunfig, host running or not. - gofmt -l; go vet (darwin, GOOS=linux, GOOS=windows, -tags nogui) on internal/plugin, internal/provider, internal/gui; go build (darwin), GOOS=linux and GOOS=windows -tags nogui builds; go test -tags nogui ./... under a temp HOME, all ok. |
||
|
|
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> |
||
|
|
2bd49cc545 |
plugin: magpie plugin update in a terminal restarts the app's plugin host (#952, mxzs123) — the running magpie noticed another magpie's plugin change only by plugins.json, which an update leaves as it was (the spec stays, bun installs a newer version), so the app's host went on answering with the old code (0.1.17 after the update to 0.1.18, still 403) until it was killed. The stamp checkList compares now also covers what is installed: Dir()'s package.json and bun's lockfile; and Restart takes the stamp as it is, so this magpie's own install isn't taken for another's and restarted twice. In a sandbox (serve on 3476 under its own HOME, the Factory plugin at 0.1.17, unpinned spec; a request, then magpie plugin update in another process, then a request): on 2d85a086 the host process stayed the same (58657) with 0.1.18 installed; with this change it was replaced (60004 → 60583) and the old one stopped. TestTerminalUpdateRestartsTheHost is new and fails without the change; go vet and go test -race -tags nogui ./internal/plugin/ ./internal/provider/ under a temp HOME pass.
|
||
|
|
3ab27186c9 | cleanup: drop eight functions nothing calls — catalog.ProviderEnv/ProviderAvailable, subscriptionRun.attached, hasTool, kiroSignedIn, SetModelSame (SetModelPrefs calls setModelSame itself; the comments name it), sessions.claudeFiles and plugin.SetConfig. Found with deadcode -test -tags nogui and checked by git grep across .go and .js; the ones only the GUI build or one platform calls stay. vet on darwin, linux, windows; catalog, gateway, provider, sessions and plugin tests pass. | ||
|
|
2f135ed4d5 | plugin, gui, docs: Plugins says which plugins are providers and which are middleware, lists the community's ready-made middleware, and edits a middleware's options in its row (the owner) — the Plugins page still read as if every plugin were a subscription, and nothing showed what a middleware does or let you set its options without editing plugins.json. Every Discover card and Installed row now carries a Provider or Middleware chip (both for a plugin that is both), also for one that is off (isMiddleware/middlewareOnly from the server, read from its files); Discover splits into Subscriptions and Gateway middleware ("runs in magpie's gateway on what every agent sends and gets back, whichever provider serves it"), the latter from market entries with "kind": "middleware" and no providers or icon (the built-in market.json lists the five new @magpie-community/middleware-* packages: param-override, model-map, system-prompt, word-guard, think-tags, mostly New API's channel settings with the same JSON). A middleware row has Options: a JSON editor in the row, starting from the package's magpie.options example when none are set, which validates it is an object, saves (POST /api/plugins/options) for the next request, clears, and cancels with Esc. magpie plugin options takes a short name (model-map for @magpie-community/middleware-model-map; plugin.ShortName, also in SetOptions). en/zh/ja/de. Docs: usemagpie.ai/docs/plugins (en/zh/ja) gains Ready-made middleware and Options and the registry's kind; reference.md, both READMEs and docs/subsystems/gateway-middleware.md likewise. Tested with a real DeepSeek account and real Claude Code through magpie web --gateway in a sandbox HOME, with all five installed and options set by short name: a mapped model named back, max_tokens capped, a prompt appended for claude only, word-guard's 400 and param-override's 403 in the agent's shape, <think> stripped from Chat and Responses streams and a whole Anthropic reply, reasoning_content moved into the text; /api/plugins showed the kinds and the example. TestSetOptionsShortName is new; TestBuiltinMarket checks a middleware entry has no providers or icon and no other kind. plugin-middleware.test.cjs (Chromium and WebKit, en and zh: the chips, Discover's two sections, the options editor with its errors, no select, no scroll, no left border) fails without the change; the other plugin tests and click-scroll pass in WebKit (plugin-market's section name updated; plugin-move fails only under parallel load and passes alone). go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass. | ||
|
|
d62fecd468 | plugin: reuse config parsing and avoid request body string copies (#696) | ||
|
|
1baad0d2d4 | plugin: pi packages are plugins as OpenCode's are — a pi coding agent package (its extensions) adds providers to magpie: their models, their sign-in, renewals and requests (owner: 我希望全面兼容 pi 插件!!!!!!!!!!) — a package is pi's when its package.json has a "pi" manifest, the "pi-package" keyword, or pi-coding-agent among its dependencies (IsPi, mirrored in host.js). Adding or updating one installs @earendil-works/pi-coding-agent beside it, and the plugin host loads every pi package through pi's own loader (pi.js: discoverAndLoadExtensions and ModelRuntime, with the credentials kept in plugin-auth.json), so an extension's registerCommand, registerTool and pi.on are taken and left unused, and its registerProvider calls become magpie providers. A provider's models keep their context, output, images and the reasoning levels their thinkingLevelMap allows; its OAuth login runs as pi runs it, each onPrompt asked in magpie's sign-in in turn, onAuth's page opened, a later prompt being the code pasted back; a provider with apiKey takes a key; magpie renews through refreshToken and saves the result. Requests arrive as Anthropic Messages and go to pi's stream: system and tools, images, tool results, thinking budgets and effort as the nearest level the model has (and the least it allows when it can't turn thinking off: Antigravity's gpt-oss refused requests without one), max_tokens held to the model's; the answer comes back as Messages SSE or JSON with thinking and its signature, redacted thinking, tool calls (their thought signatures kept for the next turn), usage, and a failure before anything is said as the vendor's status with Retry-After. The Plugins page's search also finds pi packages that bring a provider. Tried with the owner's real Antigravity account through pi-antigravity, next to the Grok OpenCode plugin in the same host: 14 models listed, Gemini streaming with usage, Claude Sonnet thinking with signatures, gpt-oss, tool round trips on gemini-3.8-flash, gemini-3.1-pro and claude-sonnet-4-6, a 400 and Antigravity's 429 passed on with their status. A Claude Code turn didn't get through: Antigravity answers 429 to any system prompt with Claude Code's billing header or its "Claude agent" line, through magpie's built-in Antigravity just the same. TestPiPackage (a fake pi package: models, an OAuth login asking twice with a wrong code then a right one, a key, streaming and JSON answers, thinking and tool signatures back, a 429, a renewal) and TestSearchFindsPiPackages pass. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass but TestClaudeRunEndsWhenTheClientLeaves, TestProvidersAnswerWhileListsComeIn and TestSavedButSignedOutClaudeServed, timing tests that pass alone. | ||
|
|
123594489a | plugin: a host stopped mid-renewal saves the new token first, and two hosts never write each other's sign-ins away — a stopped host (quit, plugin update, restart) was killed 2 s after stdin closed even while it renewed a sign-in through auth.refresh, after the vendor had spent the old refresh token, so the account was signed out; and while a host restarts the old one and the new one both rewrote all of plugin-auth.json from what each had read, so one host's save could drop the other's accounts or newer token. host.js now tells magpie how many renewals are under way (event "renewing"), and stop gives a host still renewing after the 2 s up to 15 s in all, until the renewal is saved; with none it stops as fast as before. Every change to plugin-auth.json (setAuth, removeAuth, settle, take, auth.set, a renewal's save, and magpie's SignOut when no host runs) is made under plugin-auth.json.lock (O_EXCL, broken when older than 10 s), reading the file afresh and changing only its own accounts; a renewal's save checks under the lock that the stored sign-in is still the one it renewed, so an older host never writes a stale token over a newer one. TestStopLetsARenewalEnd (a 4 s refresh, the host restarted in the middle: old code kept the spent token) and TestTwoHostsKeepEachOthersSignIns (two hosts saving 40 accounts each at once: old code lost 38 of 80) fail on the old code and pass; TestStopWithoutRenewalIsQuick keeps the quick stop. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass but TestProvidersAnswerWhileListsComeIn and TestClaudeSignedOut, timing tests that pass alone and in their packages rerun. Not tried with real plugin accounts. | ||
|
|
456208945b | plugins: a plugin can be installed from a git repository — github:owner/repo, owner/repo, a GitHub URL or a git+https:// one (Lemon on Discord: can plugins be installed directly from git?) — magpie plugin add and the Plugins field took only an npm name or a path, and turned a git spec away as "isn't an npm package name". A git spec now goes to bun add as given and is kept as given in plugins.json; the package it installs is named by its repository's package.json, which bun records as the dependency whose spec it is, so the plugin is known (list, on/off, rm, its version, its README) by that name or by the spec. update and the row's Update run bun update on it, which fetches the repository's commit now where bun add keeps the one bun.lock has, the spec unchanged; npm is never asked for a newer version of it, nor auto-updates it. Adding the same package from another URL, or from npm, takes its entry's place. The Plugins field says it takes a GitHub repo (en+zh); an installed git plugin shows its package's name, an Update button, and a page with its README, no npm link and a Source link to the repository. Nothing that installed before is turned away. TestGitPlugin (a fake bun fetching from local bare repositories, the real one loading the plugin when on PATH) and plugin-git.test.cjs fail without the change; TestIsGit checks what counts as a git spec. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; plugin-git, plugin-local, plugin-market, plugin-updates, click-scroll, old-webkit pass. | ||
|
|
7dd809002b | accounts: on Linux an account put first is read first at once, and on Windows a file being replaced isn't read as none (goal: 插件订阅 provider 跟内置的所有逻辑都要一模一样, run on Windows and Linux) — the provider tests run on the Windows test box and in WSL found two bugs of magpie's own files. Linux stamps a file's time from a clock a tick (a few milliseconds) coarse, and filememo took same time and size for the same file: two accounts swapped (Devin, Grok, WorkBuddy, ZCode, Claude…) read back in the old order, so magpie kept using the account the user had just moved down, and a moved-back plugin's accounts read as before. A file written within the last two seconds is now also compared by its bytes. On Windows a file being renamed over refuses to open for a moment ("Access is denied"), and one held open refuses to be renamed over: plugin-auth.json, plugins.json and the plugin providers read as nothing (a usage fetch right after a move showed no cards), logins.json failed to save, and host.js, reading plugin-auth.json as {}, would have written the other accounts away on the next sign-in. New internal/steady waits such a read or rename out (half a second at most, Windows only); filememo, edit.WriteAtomic, writePrivate, Kiro's writes and the plugin store go through it, host.js retries its read and rename, and the plugin store writes its files by a rename. Tests: USERPROFILE beside HOME in the test homes, the fake devin (a shell script) skipped on Windows, plugin-auth.json's mode bits unchecked there. TestReadSameSizeSameTick fails on Linux and TestRenameOverAFileHeldOpen/TestReadAFileHeldOpen on Windows without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; on Linux (WSL) the provider and plugin packages pass whole (13 failed before), on Windows the plugin package and the move/plugin/Grok/Devin/usage tests pass 10 times over (TestMoveToPlugin failed one run in a few before); 15 built-in tests that assume Unix (mode bits, Keychain, shell-script CLIs) still fail there, as before. | ||
|
|
30236bf035 | migrate: moving Kiro back with an API key no longer hangs magpie, a move's lock left by a killed magpie frees itself, and plugins changed in a terminal reach the running app (要保证插件订阅 provider 跟内置的订阅 provider所有逻辑都要一模一样) — Kiro's back put the plugin's API key onto the Kiro provider while holding logins.json's lock; saving the provider syncs the agents, which read the accounts and waited on that same lock, so the move back never returned and every request after it hung. The key is now put back once the lock is let go (a mover's settle). A move killed while hung left migrations.json.lock, refusing every move for 15 minutes as "another magpie is moving"; the lock now holds its magpie's pid and one whose magpie is gone is taken. And magpie plugin add, remove or move in a terminal left a running app with the plugins it had loaded (a moved Kiro gone until restart, "magpie knows no model kiro/auto"): a plugins.json changed by another magpie now restarts the host and takes the providers that magpie was told meanwhile. Found walking Qoder, Kiro and Cursor through sandbox moves. TestKiroMover (hangs), TestMoveLockOfDeadMagpie and TestPluginsChangedElsewhere fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. | ||
|
|
3bec6c0e40 | providers: a built-in subscription moves onto its community plugin and back, its accounts with it (the user: 慢慢下掉内置的那些 Subscription Provider…不要让用户一升级完之后,突然发现他的所有服务都不可用了) — eleven built-ins (Zed, Qoder, Factory, MiMo, Devin, Grok, Command Code Plan, Cursor, Kiro, WorkBuddy, ZCode) each get a mover to their @magpie-community package. A move installs the plugin (updated when older than the mover needs), hands it every account in the plugin's shape, checks the plugin lists models for them, and only then lets the plugin serve the same provider id, so agents' model ids don't change; any failure rolls back and the built-in keeps serving. The built-in's accounts are kept as a backup, and "Run built-in again" (magpie plugin move-back <id>) takes the plugin's current sign-ins back, never copying a rotating token: they are taken out of the plugin in one step, and an account the built-in renewed meanwhile keeps its newer token. An account only the plugin can hold (Cursor's browser sign-in) stays with it. The provider editor shows "Runs on" with the button, a failed move's reason, and the CLI has magpie plugin move / move-back. Automatic moves (Retiring) are wired in but the list stays empty until the packages are on npm. Checked with real accounts in a sandbox HOME: Command Code Plan and Devin moved, answered a chat through the gateway on the plugin, moved back and answered again on the built-in. TestMove*, TestPutBackKeepsNewer, the movers' round-trip tests and plugin-move.test.cjs (Chromium, WebKit, en/zh) are new. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass; click-scroll, old-webkit pass. | ||
|
|
a31f97b30d | plugin: OpenCode's provider plugins sign in to subscriptions in magpie — an npm package OpenCode users install for a plan (its auth hook: loader, methods, oauth authorize/callback, api keys, chat.headers) runs in a Bun host magpie downloads the first time a plugin needs it, speaking JSON-RPC over stdio; its sign-ins are kept in plugin-auth.json (0600). A provider a plugin signs in to is a provider like the others: its models the plugin lists, each spoken to on the API its AI SDK package speaks (anthropic → Messages, openai/azure → Responses, google → Gemini, Copilot's GPT-5+ → Responses, else chat completions), its requests carried by the plugin's fetch to the base URL its loader gives; an id magpie already has is <id>-plugin. CLI: magpie plugin [list|add|rm|update|on|off|login|logout]. App: Settings → Plugins adds, updates, switches off and removes them and says why one didn't load; Add provider → From plugins signs in with the plugin's methods, its questions (picks and checked text), the browser and a pasted code or a key, followed as the built-in sign-ins are; removing the account signs out. The built-in subscriptions stay. TestFakePlugin, TestPluginProvider (chat, Anthropic and Gemini models through the gateway) and TestPluginSignIn (a wrong code fails, the right one signs in, removing signs out, a key) run a fake plugin on Bun; plugin-signin.test.cjs (Chromium, WebKit, en/zh) covers the add sheet and Settings. signin-callback, add-sheet, zed-sub, account-proxy, own-signin-remove, routing-signin, click-scroll GUI tests pass; go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestUserPath, TestClaudeSignedOut, TestClaudeAccountNamedAsItsLogin, TestClaudeIdentityServedWhileAsked, known flakes under load, pass alone). Not yet tried with a real plugin and account. |