1ccacad63281094de8a3372d5a507d38f9969e5c
21
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
e4197144a8 |
perf: every package's package-level regexps compile on first use
v0.1.3516 made gateway's and redact's patterns lazy. The other 299 package-level regexp.MustCompile calls, in 148 files across agent, provider, gui, library, codexcat, sessions, usage, plugin and the rest, now go through lazyre.New too, so a launch that never reaches them (`magpie statusline`, run by Claude Code on every message) doesn't compile them. Fields, maps and params that held them are *lazyre.RE. Measured on mote (M5 Pro), sandbox HOME, v0.1.3516-equivalent build (t42) against this one (t43): - GODEBUG=inittrace=1 sum: 7.39 MB / 69,837 allocs -> 4.62 MB / 46,765 - `magpie statusline`, 3 runs each: instructions retired ~212M -> ~176M, peak memory footprint 19.2-19.4 MB -> 16.8-17.0 MB Run: go vet ./... (darwin) ok; GOOS=windows go vet on each of the 30 changed packages ok; GOOS=linux go vet ok except ., internal/cli and internal/gui, which stop in wails v3's cgo files when cross-compiled (the same at main). New TestAllLazyPatternsCompile at the root compiles all 574 registered patterns (ok), so a bad pattern fails a test rather than a first use. Not run before push: the changed packages' own test suites; they run on mote after it. |
||
|
|
4bfac12683 |
plugins: downloads take a proxy of their own, apart from the vendors' (JonahFu on X)
JonahFu on X: GitHub is unreachable without a proxy, while API requests may go direct, so plugin downloads' proxy should be set apart from the one model requests take. Before: plugin downloads already followed the global proxy (fetches through http.DefaultClient and netproxy.Func, bun add and git through netproxy.Env), so nothing ignored it; there was only no way to give them a different one. Now Settings › Network has a Plugin downloads row under Proxy: Same as above (the default, unset: downloads follow the global proxy as before), Direct, or Custom with its login, remembered as pluginProxyCustom as Proxy's Custom is. The CLI takes it as `magpie settings set pluginProxy <url|direct|"">`. It covers the plugins list and Discover's lists (fetchJSONFrom), a user's own npm registry (fetchRegistry), Bun's download (getURLFrom), bun add/update/remove and the git commands of GitHub-installed plugins (dlEnv). The plugin host (bun run) keeps the global proxy: its requests are the vendors'. Both fields belong to this computer (KeepOwn) and are left out of auto-backups, since a proxy URL may hold a password. Settings' Proxy row and the new one are drawn by one helper (proxyRow); the core's script budget is met by cutting the proxy rows' comments, no raise. Run (mote, through mote-run): gofmt -l clean; go vet of the touched packages (darwin), GOOS=linux -tags nogui ./..., GOOS=windows of the touched packages; go test -count=1 internal/settings, settingsapi, backup, netproxy, plugin, gui, cli all ok (gui after the comment cut; its first run had TestCoreScriptBudget 1,352 bytes over). GUI, chromium and webkit: settings-plugin-proxy (new, 5 languages x 2 widths), settings-proxy-remember, settings-proxy-auth, proxy-test, settings-sections, proxy-login-fields and the i18n files: 102 pass, 0 fail. plugin-proxy-page, proxy-own-wording, account-proxy, provider-proxy, routing-proxy, provider-many-keys-proxy and signin-proxy: 104 pass, 2 fail, both signin-proxy's "a subscription with no proxy offers the global one" at 380px in Chromium, red the same way on origin/main |
||
|
|
e484b4ff26 |
update: a slow download still moving is never ended by a total time; Bun, Claude Code and pf-serve too
#5572: since |
||
|
|
1fd0bb9670 |
update: a download whose HTTP/2 transfer broke off tries again over HTTP/1.1
biubiu8802 on X (tweet 2118719081872540038): behind their proxy every
update failed with "download broke off, a network problem", while the
same proxy carried ordinary downloads. Confirmed in the code: download()
retried up to 5 times with Range, but each try went through
netproxy.Dispatch over HTTP/2 again; Dispatch moves a host to HTTP/1.1
only on a TLS record error (recordError: bad record MAC and kin), and
"unexpected EOF" or a stream reset is not one. So a proxy that cuts
HTTP/2 streams part way cut every try the same way.
- netproxy: OverHTTP1(ctx) sends every request under ctx through
Dispatch's HTTP/1.1 copy (route.h1), kept through With.
BrokeOff(err) says a transfer broke off (net.Error, unexpected EOF,
HTTP/2 stream error / GOAWAY / lost connection, a reset; not a
context that ended). AgainOverHTTP1 runs a download once more over
HTTP/1.1 after such a failure.
- update: the tries after a broken one go over HTTP/1.1, and still
resume with Range from the bytes kept.
- Siblings, the other big downloads through Dispatch's client: the
masking model and pf-serve (pii.fetch, one more try over HTTP/1.1
from what is on the .part file), Bun's zip (plugin getURLFrom),
Claude Code's binary (claudecode.download) and the Grok CLI
(grokDownload) each try once more over HTTP/1.1.
- docs/subsystems/providers-accounts.md names it.
Run (mote, Go 1.26.8, at this tree, base
|
||
|
|
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
|
||
|
|
5b32b7ea80 |
plugins: a Bun Windows can't load (0xc0000139, before 10 1809 / Server 2019) says so and what to do (zgcwkj on Discord)
zgcwkj runs magpie-cli-windows-amd64.exe as a Windows service (nssm) and every plugin install failed with "bun add …: exit status 0xc0000139: (and from the community repo's dist branch: bun add ./dist/….tgz: exit status 0xc0000139: )". Why: 0xc0000139 is STATUS_ENTRYPOINT_NOT_FOUND, the loader refusing the exe before it runs. Reading the PE imports (debug/pe) of Bun's windows-x64(-baseline) zips: 1.3.14 and later, so magpie's floor 1.4.2 and the latest 1.4.4, import kernel32's CreatePseudoConsole, ClosePseudoConsole and ResizePseudoConsole, which Windows has from 10 1809 (build 17763) / Server 2019 on. 1.3.13 doesn't. Bun's docs say "Windows 10 version 1809 or later" (bun.com/docs/installation). So Windows Server 2016 and Windows 10 1507 to 1803 (LTSB 2015/2016) can't run any Bun magpie uses. 1.4.2's pinned SHA-256 matches the asset. What changes: - wontLoad (internal/plugin/bun.go) reads an exit of 0xc0000139 as "this Windows" and 0xc000001d or SIGILL as "this processor" (Bun's x64 build targets SSE4.2), as a *BunUnstartableError whose message says which, the versions Bun needs, and MAGPIE_BUN. - bun add, bun update, cantStart and whyDied (the host's start) wrap it. - An install no longer tries the dist branch after it: that bun add can't start either, and its error read as the dist branch's. - The GUI's fail() answers it with code bun_unstartable, bunWhy and said, an i18n.js key (bunSaid in api.go), which api() in app.js puts through t(): en, zh, zh-TW, ja, de, in the window and in magpie web. The sentences live in Go so app.js grows one line: with both in app.js, TestCoreScriptBudget was 128 bytes over app.js's budget and 487 over the core's, and no budget is raised here. TestBunSaidIsTranslated fails when a language lacks one. The CLI prints the English message. - No fallback to an older Bun: 1.3.13 is below BunVersion and Bun doesn't support that Windows, and the -baseline assets are now the same binary. - docs/subsystems/provider-plugins.md says all this. Run: - New tests: TestWontLoadSaysWindowsOrCPU (injected NTSTATUS exits, a real kill -ILL), TestInstallOnUnstartableBunSaysWhyAndSkipsDist (0 dist requests), TestHostOnUnstartableBunSaysWhy, TestFailSaysBun Unstartable, TestBunSaidIsTranslated, plugin-bun-unstartable.test.cjs (chromium and webkit, every language, window and web). - Real Windows (10.0.26200 box, a sandbox dir of its own): a windows/amd64 nogui magpie-cli.exe with a fake magpie-bun.exe that exits 0xc0000139, `plugin add @magpie-community/opencode-raccoon-auth` printed the new message, and no dist folder was made. - gofmt -l; go vet darwin, linux -tags nogui, windows; builds of all three. - Full suite (go test -tags nogui -timeout 45m ./..., through suite-lock, at |
||
|
|
0f044e9447 |
plugins: a GITHUB_TOKEN GitHub refuses is dropped for anonymous requests, not shown as an error (till on Discord)
till's Plugins page said "无法连接 GitHub: GitHub refused GITHUB_TOKEN (no GitHub token is set in Settings → Network and sharing)". ghtoken.Token falls back to the environment's GITHUB_TOKEN / GH_TOKEN, and a stale one there made every GitHub read fail, though GitHub serves the same reads without a token. ghtoken.Do now sends a GitHub API request with the token. When the token came from the environment and GitHub answers 401, it remembers that token as refused for the rest of the process (Token() skips it, so GH_TOKEN is still tried after a refused GITHUB_TOKEN, and Settings no longer shows it) and asks once more without Authorization, returning that answer. A token set in Settings is never dropped: its 401 is still Refused()'s error. An anonymous rate limit after the drop is said by LimitedBy as before. Every caller goes through it: plugin fetchJSONFrom (tagged-repo search, git plugin checks, githubHead) and getURLFrom (Bun), and library apiGet, skills fetch, skilltree fetchBlob and latestRTK via doGitHub. internal/davsync/github.go stays strict: its token is the one the user gave sync to write a private repo, outside ghtoken, and an anonymous retry can't write there, so it would only hide why sync failed. Tests (httptest only): ghtoken_test covers an env token refused then asked again without, not sent again (and GH_TOKEN tried next), a Settings token refused stays an error, an env token refused then an anonymous rate limit is reported, and another host untouched. plugin TestTaggedReposStaleEnvTokenDropped is till's case: TaggedRepos with GITHUB_TOKEN=stale-till lists 7 repos, no error. github_token_test and library TestGitHubRateLimitSaid now expect the env token dropped and the Settings token still refused. Broken by hand, each red: (a) no anonymous retry: every new env test, the plugin and library tests red, and TestTaggedReposStaleEnvTokenDropped shows till's exact error; (b) no memory of the refusal: NotSentAgain, the plugin and library tests red; (c) a Settings token also retried: SettingsTokenRefusedStaysAnError, the plugin and library tests red. Run on the commit before the rebase (base |
||
|
|
a257319963 |
plugin: an install takes the versions no longer installed out of Bun's cache (#1988)
Bun keeps every package version it ever fetched in its install cache
(~/.cache/magpie/bun/install-cache) and never takes one out. Each
release of a moved subscription's plugin that keepMovedCurrent or the
hourly updates installed added one more: the owner's Mac had 131
versions of the community plugins there, 10M, and it only grows.
After a successful install (beside pruneDist), the cache's
name@version@@registry folders whose version isn't the one in
plugins/node_modules are removed, then the links left to nothing in
each package's folder of links. A package whose installed
package.json can't be read or parsed keeps its versions (unknown, not
"not installed"). @T@ tarball entries and .npm manifests are left as
they are. What is installed is a copy, so a version taken out is only
fetched again if it is asked for again.
Measured on a copy of the live install cache with the live
plugins/node_modules package.json files:
before: 10M, 131 entries under @magpie-community
after: 1.0M, 18 entries (9 packages, the installed version each)
Run:
- TestInstallPrunesBunsCache (Bun's real layout, through install with
the fake bun). With the pruneInstallCache() call commented out:
installcache_test.go:62: opencode-grok-auth@0.1.16@@registry.npmjs.org@@@1 left in Bun's cache, not installed: <nil>
installcache_test.go:62: opencode-kiro-auth@0.1.5@@registry.npmjs.org@@@1 left in Bun's cache, not installed: <nil>
installcache_test.go:72: the link to the version taken out left: <nil>
--- FAIL: TestInstallPrunesBunsCache (1.51s)
With it: PASS. Also PASS on the Windows box (windows/amd64 binary).
- macOS, sandbox HOME: go test -count=1 -timeout 45m ./internal/plugin/
-> ok internal/plugin 2214.050s (load ~250)
- gofmt -l clean; go vet ./internal/plugin; GOOS=linux and
GOOS=windows go vet -tags nogui ./... clean.
|
||
|
|
4e9335c96c |
plugin: Windows on ARM downloads Bun's native windows-aarch64 build and runs plugins, not "Bun has no build for windows/arm64" (#2183, EdwinDigital)
bunTargetFor turned windows/arm64 away, so magpie-windows-arm64.exe listed a plugin as on while its host never started, and its providers never showed. Bun publishes bun-windows-aarch64.zip (1.4.2 and later), so windows/arm64 now maps to it, with no baseline suffix (arm64 has no baseline build). Its SHA-256 a7a16b87…0cfd is added to bunSums, taken from Bun 1.4.2's SHASUMS256.txt, so the download is still checked and can come through a mirror. The provider-plugins page says so. What was run (macOS arm64, sandbox HOME, private GOCACHE): - TestWindowsOnArmGetsNativeBun (new): with windows/arm64 stubbed, Bun() downloads bun-windows-aarch64.zip from an httptest release and runs it; the checksum is the official one. Old bun.go: FAIL "bunTarget = "", Bun has no build for windows/arm64". - TestBunTargetForMusl gains windows/arm64 and now checks every target has a checksum; TestBunDefaultSums and TestBunTarget list bun-windows-aarch64. Both FAIL on the old code. - go test ./internal/plugin/ ok; gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows clean; GOOS=windows GOARCH=arm64 go build ok. - Downloaded the real bun-v1.4.2/bun-windows-aarch64.zip: SHA-256 matches, it holds bun-windows-aarch64/bun.exe, a PE32+ Aarch64 binary. Not tried: a real Windows ARM64 machine (the Windows box is x64), so the plugin host starting on that bun is not verified. |
||
|
|
334bb182e9 |
plugin: Bun's release check asks GitHub's API with the GitHub token from Settings too (#1942, bingqilinweimaotai)
What changed: an audit of every request magpie makes to GitHub's API after the git-plugin fix. The library's skill checks, private-repo probes and RTK's release check already carried the token; the Plugins page's git-plugin check and topic search got it in the previous commit. The one left was Bun's newest-release check (bunLatest), asked of api.github.com/repos/oven-sh/bun/releases/latest anonymously through getURL. getURLFrom now has a request to GitHub's API's host carry the token (ghtoken.Authorize), and bunLatest asks githubAPI so tests can move it. Bun's zips (github.com, npmmirror) are other hosts and never get it. With a token set, that one request isn't sent to the MAGPIE_MIRRORS fallback (source.Do sends nothing with Authorization to a mirror), the same as the library's API requests. Left as they are: Copilot's api.github.com requests carry the user's Copilot sign-in, not this token; raw.githubusercontent.com and codeload aren't the rate-limited REST API; site/worker.js is the website's. What was run: - TestBunReleaseCheckCarriesGitHubToken (new): bunLatest is asked with "Bearer github-env", a download from another host with none. With the Authorize call removed it fails: "Bun's release was asked of GitHub's API with Authorization """. - go test -tags nogui -run 'Bun' ./internal/plugin: ok. - gofmt -l clean; go vet -tags nogui darwin, GOOS=linux, GOOS=windows on internal/plugin: clean. |
||
|
|
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. |
||
|
|
93e118a578 |
testenv: a test that runs plugins on a bun older than 1.4.2 is skipped, saying which bun and to install 1.4.2 or newer, not failed on Bun's own differences (#1600, justrun1983)
justrun1983 saw TestPluginModelListThroughAccountProxy fail on main with "fake-not the list: http://models.invalid:80/list" among the models. The plugin tests run the bun on PATH (testenv.Bun), and Bun 1.3 names the default port in a proxy's request line: GET http://models.invalid:80/list, which Go reads as r.URL.Host "models.invalid:80", so the test's proxy answered 400 and the fake plugin took the error text as a model. Bun 1.4 sends GET http://models.invalid/list. It wasn't the offline environment: the test already clears every *_PROXY variable and reaches nothing real. magpie itself never runs plugins on a Bun older than plugin.BunVersion (1.4.2, the one it downloads and the floor CheckBun keeps), and CI pins 1.4.2, so an older bun on a developer's PATH tests something no user runs. On Bun 1.3.0 internal/plugin's TestPluginSOCKSProxy ("vendor vendor.invalid:80"), TestPluginProxy (the proxy saw http://vendor.invalid:80/...) and TestPluginHTTP2TakesTheProxy (Bun 1.3's node:http2 answers status 0, and the host quits) failed the same way. testenv.Bun now runs `bun --version` once (it already ran it to warm the binary) and skips with a message naming the bun when it is older than testenv.MinBun. testenv can't import internal/plugin (whose own tests use it), so MinBun is a copy, and TestMinBunIsBunVersion fails when it and plugin.BunVersion differ; BunVersion's comment names it and test.yml's bun-version. Run (bun 1.3.0 from npm's @oven/bun-darwin-aarch64 first on PATH, temp HOME): - before: gateway TestPluginModelListThroughAccountProxy FAIL with the reporter's exact text; plugin TestPluginSOCKSProxy, TestPluginProxy, TestPluginHTTP2TakesTheProxy FAIL. - after: all skipped, packages ok. A probe of the request line a proxy receives: 1.3.0 sends http://models.invalid:80/list, 1.4.2 and 1.4.3 http://models.invalid/list. TestBunOlderThanMinSkips (fake bun printing 1.3.0, 1.4.1, 0.9.9, 1.4.2, 1.4.3-canary, 1.10.0, 2.0.0, nothing) goes red with the skip removed by hand. With bun 1.4.2: go test -tags nogui ./internal/testenv, ./internal/plugin, ./internal/gateway pass; gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags nogui on testenv and plugin pass. Not run: the full ./... suite, nor the fake-bun test on Windows (it skips there: the fake is a shell script). |
||
|
|
3691c2047d |
plugin, agent: bun is given a SOCKS proxy through the bridge, so a plugin installs with only a SOCKS system proxy (#1409)
With only a SOCKS system proxy on macOS (127.0.0.1:4401), every plugin
install failed: netproxy.Env put socks5://… in bun add's *_PROXY, and Bun
takes only http:// and https:// proxies, so it stopped with
"UnsupportedProxyProtocol downloading package manifest". The plugin
host's own fetches already went through netproxy.Bridge (hostEnv), but
bunCommand, which runs bun add, update and remove, did not.
- netproxy.EnvForBun rewrites a SOCKS5 HTTPS_PROXY/HTTP_PROXY/ALL_PROXY
(any case) to the loopback HTTP bridge in front of it; others as they are.
- bunCommand uses it, so add, update, remove and the host's run all get it.
- Sibling: an agent CLI installed with bun is updated by `bun add -g`
with the same env (updateEnv in cliupdate.go); npm is left as it is.
- provider-plugins.md says so.
Run:
- TestInstallThroughSOCKSProxy (real bun 1.4.2, fake registry, SOCKS
proxy only): on the old bunCommand it fails with the reporter's exact
"error: UnsupportedProxyProtocol downloading package manifest"; passes
with the fix, through the SOCKS proxy.
- TestEnvForBunBridgesSystemSOCKS (system SOCKS proxy via Env) and
TestUpdateWithBunBridgesSOCKS fail with EnvForBun / the bun branch
broken ("bun is given …socks5://…"), pass with it.
- Real use: a throwaway test with a real SOCKS5 server and only
*_PROXY=socks5://… installed @magpie-community/opencode-cursor-auth
0.2.2 from registry.npmjs.org through it; on the old code the same
failed as UnsupportedProxyProtocol. Scratch HOME, not committed.
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
GOOS=windows go vet ./...; go build; GOOS=linux go build -tags nogui;
GOOS=windows go build; go test -tags nogui ./... (scratch HOME) all ok.
|
||
|
|
6d830a3c95 |
plugin: Bun on Windows is given an ASCII way to the system's roots, so a user folder with a Chinese name no longer fails bun add with UNABLE_TO_VERIFY_LEAF_SIGNATURE (#1232)
Bun 1.4.2 on Windows reads NODE_EXTRA_CA_CERTS as ANSI and takes it as UTF-8: C:\Users\<中文>\.cache\magpie\bun\system-ca-*.pem became "锟斤拷" and "load failed: No such file or directory". An 8.3 short name doesn't help (Windows gives 测试 none). Bun opens a relative path from where it runs, which is under the same user folder, so the path is given relative to Bun's dir when it isn't ASCII. Tried on the Windows box with Bun 1.4.2 and a local HTTPS server signed by a test root, from a cwd under 测试: absolute path -> warn + FAIL UNABLE_TO_VERIFY_LEAF_SIGNATURE; relative path -> 200. The new test's Windows cases ran there (windows/amd64 test binary): PASS. |
||
|
|
05683637d5 |
plugins: the Bun the plugin host runs on is kept as magpie-bun, so a proxy app's PROCESS-NAME rule can route the requests plugins (Cursor and the other moved subscriptions) make (#1048)
magpie downloads its own Bun into ~/.cache/magpie/bun/<version>/. It is now written there as magpie-bun (magpie-bun.exe on Windows), and a Bun downloaded before is renamed in place the first time it is looked for, so nothing is downloaded again and no second copy takes disk. The host, bun add and bun update all run it, so all of their traffic carries the one name. A $MAGPIE_BUN the user set is run as it is. Verified: TestBunDownloadedAsMagpieBun, TestBunDownloadedBeforeTakesTheName and TestHostRunsAsMagpieBun fail without the change (the Bun is .../bun, the host runs .../bun). TestHostRunsAsMagpieBun starts the real host on a copy of Bun 1.4.2 and `ps -o comm=` names it magpie-bun on macOS. On the Windows box the three tests pass with the Windows build of Bun 1.4.2, a running bun.exe renames to magpie-bun.exe, and Get-Process/Win32_Process name it magpie-bun. Linux not run here (CI's ubuntu job runs the test with Bun on PATH). go test -tags nogui ./... green; -race -count=10 on the new tests green. |
||
|
|
564033d044 | plugin: Bun is given the roots the system trusts — installing @magpie-community/opencode-kiro-auth failed with "error: UNABLE_TO_VERIFY_LEAF_SIGNATURE downloading package manifest" (chenyyi001 on X): Bun checks TLS against the roots it ships, not the system's, so behind a box that re-signs HTTPS with a root the user installed (a company proxy, a VPN, Surge's or Proxyman's MITM) magpie gets through and bun add, and a plugin's own requests, don't. bunCommand, which starts every bun (installs and the host), now sets NODE_EXTRA_CA_CERTS to the system's roots unless the user set it: on macOS the certificates in the System and login keychains the user or an admin marked as trusted (security trust-settings-export; one denied, or only kept in a keychain, stays out; Apple's own aren't added), written once a run beside Bun's cache; on Linux the distribution's CA bundle (SSL_CERT_FILE first); on Windows the ROOT store. NODE_USE_SYSTEM_CA does nothing for bun 1.4.2's installs. Reproduced with a local registry behind a re-signing proxy: bun add through bunCommand fails with the reporter's error on the old code and installs opencode-kiro-auth@0.1.7 with the proxy's root trusted; TestBunIsGivenTheSystemsRoots fails on the old code and passes, TestTrustedIn and TestSystemRootsAreTheTrustedOnes cover the trust settings. Not tried: a real keychain-trusted root (changing trust settings is left to the user), and the Windows store on a Windows machine (the test box was unreachable; it builds). go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui of internal/plugin and internal/proc under a temp HOME pass. | ||
|
|
860ed6618d | plugins: a 「国内镜像」 switch on the Plugins page downloads the list, plugins and Bun from mirrors in China first (Discord, akic404: GitHub/npm are slow from the mainland; asked for ghproxy) — Plugins › Mirrors in China, off by default, kept in settings (chinaMirror). On, source asks a copy of the very file before its official address: npm's registry (packages, versions, search) at registry.npmmirror.com, Bun's release zips at registry.npmmirror.com/-/binary/bun, and the community registry.json at cdn.jsdelivr.net/gh/magpie-community/plugins@<branch>; bun add gets BUN_CONFIG_REGISTRY=npmmirror unless the environment names a registry. No proxy: gh-proxy (MAGPIE_MIRRORS' GitHub fallback) handles nothing the switch sends, since a proxy could hand back other code. A mirror asked first that can't answer (404/403/5xx, e.g. a version it hasn't synced) falls through to the official address; npm's weekly downloads stay api.npmjs.org's (npmmirror counts its own). Checked by hand: npmmirror's bun-v1.4.2 darwin-aarch64 zip has the SHA-256 pinned in bun.go, jsDelivr's registry.json is byte-identical to raw.githubusercontent's, and bun 1.4.2 add through npmmirror locks the same sha512 integrity npmjs gives. TestChinaFirst, TestChinaComesFirst, TestChinaMirrorAnswers, TestChinaMirrorsMissIsAskedOfficially, TestDoFaithful, TestBunInstallsFromChinaMirror and TestPluginsMirrorSwitch cover it. A live run with the switch on fetched the list from jsDelivr, npm info from npmmirror and Bun from npmmirror (checksum passed); a sandbox magpie web showed the switch in the Plugins head, saved it, kept it after a reload, and a click didn't move the page. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried from inside mainland China. | ||
|
|
69368007b0 |
termux: support Android builds and installation (#644)
* termux: build natively and run plugins on Bun 1.4.2 Select nogui for Android builds, open browser and OAuth links with termux-open-url, and write an executable Termux:Boot script that starts the gateway with shell-quoted paths. Bun 1.3 has no official Android build. Upgrade the default plugin runtime to 1.4.2, add the official Android arm64 and amd64 download targets, and update SHA-256 checksums for every supported platform. Document Termux installation, startup and source updates. Validation on Termux arm64: - Native build and go vet pass. - A fresh config downloads and verifies Android Bun 1.4.2 and loads a test plugin. - Boot startup can be enabled and disabled. - The Web page, authenticated state API, unauthenticated API rejection, gateway healthcheck and Web quit action work. - Browser argument preservation, boot path quoting and permissions, and plugin tests pass. Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989 * site: install Android builds in Termux Detect Termux through TERMUX_VERSION or its PREFIX and select the Android CLI asset instead of a Linux binary. Install into PREFIX/bin by default, keep MAGPIE_BIN_DIR overrides, and suggest the Web or terminal interface without Linux desktop setup instructions. When the release has no Android asset, explain how to build from source. Add android/arm64 to release-cli and stop the build loop on failure. Document the installer and its release-asset requirement. Shell syntax and all 11 site tests pass, covering platform selection, custom paths, missing assets, checksum rejection and existing Linux installation paths. The Android arm64 release build succeeds on Termux; with a simulated release feed, the installer verifies and installs that binary into PREFIX/bin and the installed command runs successfully. Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989 Co-authored-by: Amp <amp@ampcode.com> * ci: check Android releases and the installer Build both linux/amd64 and android/arm64 through make release-cli in the CLI test matrix. Run the site and installer tests in the Linux job with Node 22, and check the installer's shell syntax. The release workflow in yetone/magpie-releases already calls the source Makefile's release-cli target, uploads dist/magpie-cli-*, and generates checksums for every artifact. The Android target added to TARGETS is therefore included without changing that workflow. Replace the full Termux README section with a short platform note beside the Linux and Windows installation requirements, removing duplicate commands, the fork URL and temporary release availability details. Both CLI release builds, all 11 site tests, shell syntax checks and actionlint validation pass locally. Amp-Thread-ID: https://ampcode.com/threads/T-01a10014-56c1-73d3-b3ee-2ea569713989 Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Amp <amp@ampcode.com> |
||
|
|
cb82822f3d | source: add opt-in China mirror fallback (#566) | ||
|
|
c3197ac217 |
plugins: magpie keeps the Bun plugins run on up to date by itself (the user: 我们能否自动去管理一个bun的版本?去自动的下载并维护这个bun的版本到最新版) — plugins ran on the one Bun magpie pinned, or on whatever $MAGPIE_BUN pointed at. Every six hours (first two minutes after start), while there are plugins, magpie now asks GitHub for Bun's newest release and takes it once it has been out two days: downloaded, its SHA-256 checked against Bun's SHASUMS, tried (it says its version, and runs a script with AsyncLocalStorage, fetch and fs), then switched to, the host restarted gracefully so a streaming reply finishes on the old one. BunVersion is the floor; the Bun before stays on disk, and a new one whose try fails, or that the host won't start on, is set aside for the one before and never taken again (bun/state.json). $MAGPIE_BUN is left alone. Plugins' page and magpie plugins show the version in use. TestCheckBunTakesASettledRelease, TestCheckBunWaitsAndKeepsTheFloor, TestCheckBunSetsAsideOneThatFailsItsTry, TestTryBunOnRealBun and TestHostFallsBackWhenTheNewBunDies pass on macOS, Linux and Windows; a real run from 1.3.14 to GitHub's 1.4.2 started the host on all three. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass (TestFetchNewLeavesListedPlugins failed once under load, passes alone).
|
||
|
|
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. |