1ccacad63281094de8a3372d5a507d38f9969e5c
6
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. |
||
|
|
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
|
||
|
|
7d1f2ecba3 |
claudecode: magpie keeps the Claude Code it downloaded at the newest release
alextjy on Discord runs magpie in Docker with Claude Code from `magpie claude-code install`, and asked whether a magpie update touches it and how it updates. The download lives in <cache>/claude-code (/config/cache, on the volume), so a new image keeps it. But nothing ever updated it: every run magpie starts sets DISABLE_AUTOUPDATER, so it stayed at the version first installed until the user ran install again. claudecode.KeepCurrent now runs while magpie serves (a WhileServing loop): a minute after start and every six hours it asks downloads.claude.ai for the latest release and downloads a newer one, checked against the manifest's SHA-256 and size as install does. The version it replaced is removed on the next look rather than at once, since a run being started may hold its path (Install, the CLI's, still removes it at once; a folder with a .part download in it is left alone). It does nothing when magpie downloaded none, when the machine has its own `claude` (that one is run and updates itself), or when DISABLE_AUTOUPDATER is set for magpie, Claude Code's own way to hold a version. A failed look keeps the download and is logged. It never downgrades. The status line of `magpie claude-code`, the Docker docs (en, zh, ja) and the bridge's subsystem page say so. Run: - wsl-run (Ubuntu 24.04, Go 1.26.8): go vet, then go test -race -v ./internal/claudecode/ -run 'Keep|Install|Find': all pass. - Broken by hand on WSL, each red: no newer() check (UpdatesMagpiesDownload, LeavesWhatIsntMagpiesToUpdate), no own() check (the_machine's_own), pruning at install (UpdatesMagpiesDownload), no prune on the next look (UpdatesMagpiesDownload). - Real use on WSL, sandbox HOME and XDG_CACHE_HOME: a throwaway program with a fake 2.1.1 download ran KeepCurrent against the real downloads.claude.ai. After 1m34s it logged "updated from 2.1.1 to 2.1.316", the kept binary's --version said "2.1.316 (Claude Code)", 2.1.1 was still there for the next look, and the loop ended with its context. - mote, at this tree: GOOS=windows and GOOS=linux go vet -tags nogui of both packages, go vet ./internal/claudecode/, go build ., then go test -tags nogui ./internal/claudecode/ ./internal/cli/ -timeout 45m: VET-OK; claudecode ok 0.680s, cli ok 56.673s. - gofmt -l clean. Not tried: the Docker image itself (no docker on the test boxes), and a Windows run whose replaced binary is still in use (prune leaves what it can't remove for the next look). Full suite not run: the change is the claudecode package, one WhileServing line and one CLI status line. A WSL run of ./internal/cli/ at the default 10m timeout timed out while the box ran other sessions' full suites; the 45m run above replaces it. |
||
|
|
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. |
||
|
|
3ee97def30 |
claude: a server or container without Claude Code can have magpie download Anthropic's own build, asked first and checked against its manifest (Jorben)
A Claude subscription signs in and answers through the local `claude`, so
on a server or in the Docker image, which has none, it couldn't be used
(Jorben on Discord: could it be downloaded on first use, as Bun is).
- internal/claudecode: Anthropic's native build, as claude.ai/install.sh
takes it: downloads.claude.ai/claude-code-releases/latest names the
version, its manifest.json the platform's SHA-256 and size (linux
glibc/musl, darwin, win32). A build that doesn't match both is not kept.
It goes to <cache>/claude-code/<version>/claude, one version kept. Find
takes the machine's own claude first, then the download.
- magpie claude-code [install [--yes]|remove]: says the version, platform,
size, the URL it comes from, where it goes, that its checksum is checked
and that it is Anthropic's software under Anthropic's terms, then asks
[y/N]. magpie accounts add claude offers it when there is no Claude Code
(not on Windows, where one in WSL may be the one).
- the gateway's claudeBinary and the sign-in's claudeExecutable take
claudecode.Find; their "not installed" errors name the command.
- Docker docs (en, zh, ja): Claude sign-in needs `docker exec -it magpie
magpie claude-code install` first; kept in /config/cache.
The Dockerfile is unchanged: distroless cc-debian12 has glibc.
Run:
- go test -tags nogui ./... under a temp HOME with pinned caches: all ok
- gofmt -l: none; go vet (darwin), GOOS=linux and GOOS=windows go vet
-tags nogui ./...: clean; darwin, linux, windows builds
- TestClaudeSubscriptionRunsTheDownloadedClaudeCode fails on the old
proc.FindTool lookup ("Claude Code is not installed"); taking the
checksum compare out fails TestInstallRefusesABuildTheManifestDoesntName
- real: magpie claude-code install --yes downloaded Claude Code 2.1.296
darwin-arm64 (230 MB) into a sandbox HOME, checked; it ran --version
- real, in gcr.io/distroless/cc-debian12:nonroot with the image's /config
layout: install downloaded 2.1.296 linux-arm64 (245 MB) to
/config/cache/magpie/claude-code, it ran `2.1.296 (Claude Code)` there,
and magpie accounts add claude went on to print the claude.ai sign-in
link and ask for the pasted address
- the claudecode tests built for linux/arm64 pass in debian:12-slim
|