Commit Graph
7986 Commits
Author SHA1 Message Date
yetone 72facf72e2 memory: a search or save can name its project, and every answer says whose and where (Norethcy on X, #6392)
The memory tools had no target-project argument and no way to see the
caller context they resolved, so a scoped migration run from one project
couldn't keep memories for another or check where they went.

- memory_search and memory_save take `project`: a folder on this
  computer (absolute, or relative to the caller's own folder), or the key
  of a project memory knows (github.com/owner/repo, with or without
  project:, or a project's one name). A project named goes with scope
  project (a save's default then) or a search's all; global or agent with
  a project is refused, and an unknown project says which ones memory
  knows.
- Answers name what was used: a memory reads "this project (<key>)" and
  "only for you (<agent>)", and a search ends "(looked in: everywhere,
  project <key>, agent <id>)".
- New read-only memory_context: the agent the server takes the caller
  for and how it was found (router _meta, magpie mcp memory's initialize,
  key/User-Agent, the session's initialize), the project with its folder
  and source, the scopes a search looks in and the server version, as
  text and structuredContent. Given `project`, it shows that one.
- HTTP and stdio are the same server (magpie mcp memory relays), and
  OwnMCPTools lists memory_context with the others.

Run (mote, -tags nogui unless noted):
- TestMemoryMCPProjectArgumentAndContext (new): folder, key and relative
  folder; the caller's own project untouched; refusals; memory_context's
  text and structuredContent; tools/list. Red with the project argument
  ignored by hand.
- TestMemoryBridgeContextAndProject (new): the real gateway behind
  magpie mcp memory over stdio, initialized as codex as in the report.
- go test ./internal/browsermcp ./internal/cli ./internal/library: ok;
  go test -run 'Memory|OwnMCP|Hub|RootDirs|Tool' ./internal/gateway: ok.
- Windows (xiaomi-gpu, win-run): the new gateway, browsermcp and cli
  tests ok (a test's own unquoted Windows path was fixed on the way).
- go vet darwin, linux nogui, windows for the four packages; gofmt.
Not tried: Codex desktop itself over /mcp/run/magpie-memory; the full
suite runs after the tag.
2026-11-13 12:29:04 +08:00
yetone e39b9d5df7 cli: magpie tool reads an event-stream answer and names its folder (Norethcy on X, #6049, #6392)
`magpie tool memory_search --scope project --json` exited 1 with "isn't
JSON-RPC: is it magpie? (invalid character 'e' ...)", and memory_save said
the same after it had saved. The CLI sent no X-Magpie-Cwd, so the memory
server asked it roots/list on the call's own event stream (it accepts
text/event-stream), waited 3s for an answer that never came, and sent the
result as a second SSE event; rpc() then read the whole stream as one JSON
body.

Now magpie tool sends the folder it runs in (X-Magpie-Cwd), as `magpie mcp
memory` does, so --scope project is that folder's project and no roots are
asked. rpc() also reads a text/event-stream answer: it takes the data event
whose id is the call's, answers a server's roots/list with its folder and
refuses any other ask at once, so no server's question breaks the CLI or
makes it wait.

Run (mote, -tags nogui):
- TestToolMemoryThroughTheGateway (real gateway, sandbox HOME, a git repo
  as cwd): red on the old code with the reporter's exact error; green now,
  both calls under 2.5s.
- TestToolReadsAnEventStreamAndAnswersTheServer: red on the old code.
- go test ./internal/cli: ok.
Broken by hand: without the header, the event-stream test is red (no
folder named); with stream reading off, it is red with the reporter's
error.
Not tried: the reporter's macOS app build itself; Windows.
2026-11-13 12:29:04 +08:00
yetone e630c003cd usage: Devin CLI's own calls are read from its sessions (aohan0905 on X)
Usage counted none of Devin CLI's requests. Devin's CLI (3000.11.234,
run for real in a sandbox HOME) keeps its sessions in
<data>/devin/cli: sessions.db (SQLite: sessions, and message_nodes with
each chat_message), or with DEVIN_SESSION_STORE=files a folder per
session (log.jsonl + meta.json), whose first run copies the database's
sessions in and leaves the database. Each assistant message names its
call: request_id, generation_model (swe-2-high, effort and all),
created_at and metrics (input/output/cache read/cache write tokens,
ttft_ms, total_time_ms), written as two nodes per reply.

- sessions: calls_devin.go lists both stores (a session in both once,
  from the store written last), reads each session whole, one call per
  request_id (Msg devin:<id>), with the cwd. Registered in callSources
  and wholeCallReaders; Found lists "devin" for the consent page.
- provider: DevinModelEffort splits a variant id into model and effort
  (claude-haiku-5-5-low -> claude-haiku-5-5, low), so the catalog prices
  it. swe-2 has no catalog price and shows as unpriced.
- agentenv clears DEVIN_SESSIONS_DIR in test sandboxes.

Fixtures are the real runs' files: 3 sessions in sessions.sql (schema
verbatim, triggers dropped, assistant and user rows only), one session
only in the folder store and one in both, project folder renamed.

Run (mica): go test ./internal/sessions ./internal/provider
./internal/agentenv ./internal/usage ./internal/usageapi ./internal/cli
./internal/gui ok; go vet darwin, linux -tags nogui, windows on the
touched packages ok; gofmt clean. win-run: the Devin tests ok. A built
binary's `magpie usage all` / `--csv all` in a sandbox HOME holding the
real Devin data: 5 calls under Devin, the two claude-haiku-5-5 calls
priced from the catalog ($0.000277, $0.000986), swe-2 unpriced.

Broken by hand: devinCallFiles out of callSources (TestDevinCalls and
TestDevinDBReadAgain red, 0 calls); a session in both stores listed
twice (TestDevinSessionListedOnce red, 9 calls); the per-request dedupe
off (red, a request counted twice); DevinModelEffort returning the id
whole (TestDevinCalls and TestDevinModelEffort red).

Not tried: Devin's folder on Windows (taken as %APPDATA%\devin\cli, as
its credentials.toml; not seen on a real Windows install); a long real
session or subagents; DEVIN_SESSIONS_DIR set (read from the CLI's
behaviour in the sandbox, not from a GUI-started magpie's environment).
2026-11-13 12:26:43 +08:00
yetone 54b6d4d397 gui tests: editor-thumbs-batched checks the thumbs shown, then Advanced opened (#5886)
editor-thumbs-batched went red on main from b03a37476 on (found by
bisecting 117f56c70..2abfe2b64 with the chromium half of the test):
three controls, off|on and off|week|all, with a thumb of width 0 two
pixels left of the option. b03a37476 moved Claude's warm-up and lean
lists into the provider editor's Advanced, which is closed when the
editor opens. Chromium answers offsetWidth inside a closed <details>
(its content is content-visibility: hidden and the read lays it out),
so the test's `on.offsetWidth` took those controls for shown ones,
while their ResizeObserver, rightly, had nothing to report yet.

Nothing is wrong in the page: the thumbs are put when Advanced opens.
The test now checks the thumbs whose option checkVisibility() says is
shown, then opens every closed <details> in the editor, waits two
frames, and checks every thumb again. That second check is what a user
opening Advanced sees.

WebKit's slow-read count was red too, on main as well (origin/main
70f4593e6: 208 at 40 accounts, 244 at 160; this branch 188/213). The
reads that differ were all holdModal's few a frame and the frames' own:
the open at 40 sometimes ends ~5 frames sooner. That is frame jitter,
not a read an account (+120 here), so the room for slow reads is 60,
not 24; the forced-layout room stays 24.

Run (mote, at the pushed base): editor-thumbs-batched, Chromium and
WebKit, en/zh/zh-TW/ja/de, 10/10 green three times in a row.

Broken by hand: thumbFit's callback made a no-op (the thumbs put only
when drawn) is red 5/5 in Chromium, on "opened off|on: option
655.8+38.0, thumb 653.8+0.0" and "opened off|week|all", the controls
in Advanced; the "shown" check stays green there, as it should.

Broken by hand: an offsetTop read for every account a frame after the
list is drawn is red in WebKit en and zh (278 at 40, 538 at 160).

Not tried: the WebKit half of the broken-by-hand run.
2026-11-13 12:20:29 +08:00
yetone 6bba0572d6 gui: an open editor's readings redraw its accounts list, not the page (#5310)
When a provider editor opens, its accounts' readings load after it
(loginUsageOf), and their arrival called renderProviders(true): every
Providers row and the whole editor drawn again. With 600 accounts that
was a second full draw of the editor. redrawAccounts now draws only the
editor's accounts list again and puts it where the old one was. A full
draw is kept for the cases it was there for: another provider being
edited, a rename or a focused field (left alone, as before), and an
arrangement in progress or no open list (drawn in full).

What a full draw did, the in-place redraw does too:
- the list's inputs are named and described as field() names them;
  that part of field() is now fieldInputs(label, control), shared;
- the focus goes back to the same control of the same account, matched
  by tag and first class (a pressed refresh is "busy", so the whole
  className is not the same after), not its index in the list, which
  the readings' new controls move;
- that focus is given back, not pressed (modalRefocus), so the dialog
  keeps holding the pressed element where it was;
- the body's scroll is put back after the swap: the focused element
  taken out moved it by scroll anchoring (120 to 124 in
  editor-quota-quiet).

The full draw also hid a gap it no longer covers: the provider editor's
folds learn the labels' column from their own size (edAlign's
ResizeObserver), and the prefs fields (Resets, Warm up, Check in,
Claude Code) shown after the prefs load widen that column without
changing a fold's size. The readings' full draw made new folds that
measured it again. mountProvPrefs now aligns the editor's folds after
showing its fields (edAlignAt, the observer's body made a function).

Measured before (mote, 600 Claude accounts): the in-place redraw saves
~45ms in WebKit and ~30ms in Chromium of the editor's open. The rest
of the ~1s is the first layout of 600 rows.

Tests:
- editor-readings-in-place (new): 12 accounts, readings held until the
  editor is open and the 3rd account's first button focused. After
  they arrive the Providers row and the editor's head are the nodes
  drawn before, the focus is that same button, and the list's labels
  match a full renderProviders(true). Chromium and WebKit,
  en/zh/zh-TW/ja/de: 10/10 green.
- editor-quota-quiet's "redrawn" watch also counts the accounts list
  replaced alone; before, it waited for a new .ebody and failed
  "never came, so this tested nothing".

Broken by hand:
- the readings back to renderProviders(true): editor-readings-in-place
  10/10 red on "the provider's row is the one drawn before".
- the focus matched by the whole className: account-refresh-holds
  red in Chromium, "the focus stays on the pressed refresh" (null).
- the refocus without modalRefocus: account-refresh-holds red, "the
  pressed refresh moved 186.875px".
- without the scroll put back: editor-quota-quiet red 8/8, "the body
  keeps its scroll" (124, 120).
- without mountProvPrefs' edAlignAt: editor-advanced-align red in
  Chromium, "en 1000: Advanced starts at 284.765625, its fields at
  349.265625".

Run (mote, load 25-45, other sessions' runs beside):
- account-refresh-holds, claude-quota-onboarding, editor-advanced-align,
  editor-hints, editor-quota-quiet, editor-thumbs-batched, one at a
  time, on this change and on origin/main 2abfe2b64: the same reds on
  both but those this commit fixes, and editor-thumbs-batched (red on
  main, #5886, the next commit). The shared reds are filed:
  account-refresh-holds' rising sheet (#5814), account-arrange (#6010),
  claude-quota-onboarding (#6179), editor-hints in WebKit (#6156).
- the 149 GUI files this reaches, on mote: 2601 pass, 124 fail of 2725.
  Every red is in 16 files, and the same 16 run alone at origin/main
  2abfe2b64 on mote fail the same tests (126 there, the two more being
  signin-proxy at 380px, #5866). Filed: provider-many-keys and
  provider-max-output #6209, key-switch #5835, plugin-signin-no-url #5938,
  plugin-signed-out-account #5998, reset-providers #6196, old-webkit
  #6030/#5919, mobile-web #3952, plugin-move-unserved #4392, key-import
  #6416, account-refresh-holds #5814, account-arrange #6010,
  claude-quota-onboarding #6179, editor-hints #6156. restart-app's
  chromium 420 zh was 1px off once in the full run and green alone on
  both trees (#6417).
- go test ./internal/gui -run 'Budget|I18n|Keys|Words' on mica: ok
  (TestCoreScriptBudget with the previous commit: -89 code bytes over
  both).

At origin/main 70f4593e6 (rebased over 27 commits,
several in app.js): go test ./internal/gui -run
'Budget|I18n|Keys|Words' ok on mote; editor-readings-in-place,
editor-quota-quiet, editor-thumbs-batched, editor-advanced-align,
account-refresh-holds, claude-quota-onboarding, i18n-keys,
signin-proxy, reset-providers and key-import: every red one that is
red on origin/main too, but editor-thumbs-batched's WebKit read
count, which the next commit gives room (red on main as well).
editor-advanced-align was red once in both engines in that set at
--test-concurrency=2 under load, then green alone on this head and on
main, and 58/58 green in the same set again (#6421).

Not tried: the real app with 600 real accounts; Linux WebKitGTK.
2026-11-13 12:20:29 +08:00
yetone 468102b721 gui: a move's done line, a sign-in page's open and the other-ways row each written once
Three pieces of app.js were written out more than once, word for word:

- movedSay(p): "{name} now runs on its plugin — {accounts}, {models}."
  and the state read after it, in unmovedLine and renderMove.
- signInPage(url, id): open the sign-in page, and on a failure keep its
  message on the sign-in still shown, in startSignIn, followSignIn and
  startPluginSignIn.
- acts(): the sign-in's row of other ways, made when the first goes in,
  five times in one function.

No behaviour changes. This pays TestCoreScriptBudget for the next
commit, the readings redrawing an open editor's accounts in place
(#5310); main was at the budget to the byte. Code bytes, as the budget
counts them: -1043.

Run: see the next commit, whose runs include this one.
2026-11-13 12:20:29 +08:00
yetone c2fd48782b Put back what 1f05c311d took out of main by mistake
1f05c311d was committed with its worktree's older tree on top of a
fresh origin/main (git reset --soft), so beside the memory fix it
undid every file 610ae1f54..c1312ac15 changed (45 files: key balance,
import links, project subagents, uninstall, site, LESSONS.md and
more). This commit restores each of them to c1312ac15 byte for byte;
the tree is now c1312ac15 plus the memory fix alone
(git diff --stat c1312ac15 HEAD: the 4 files of the fix).
2026-11-13 12:18:23 +08:00
yetone 1f05c311d9 library: an open memory holds still while the Memory tab polls (Nietzsche_Li on X)
"资源库-记忆中,被展开的记忆的表单会定时抖动". While search by meaning
still has memories to read (read < of, which can last up to a minute
between memembed.Keep's reads) or a learn-from-conversations run goes,
the Memory tab reads its row again every 2s, and each read drew the
whole page anew. The open editor was a new .lib-detail each time and
played its content-in entrance (opacity .5, 2px slide) every 2s.

- semWatch/distWatch draw nothing when the read changed nothing, and
  redraw only their own row (redrawRow) when it did; the whole tab only
  when the memories changed.
- render() marks a .lib-detail open before it (same data-detail) as kept,
  so it doesn't replay its entrance. This covers every render of an
  open editor in the Library: memories, instruction sets and agents'
  files (the siblings; no other Library tab polls into render()).
- A new memory's text no longer takes the focus back on every render.

Run (mote): library-memory-steady.test.cjs, all 5 languages, 980/420,
chromium + webkit: green 4 of 4 whole-file runs after the last change
(webkit alone 2 of 2 before it). Broken by hand: the same test against
origin/main's client.js and library.css: 22 of 22 red ("the editor
played its entrance again"). One webkit de 420 red was the test's own
first row click intercepted by the header at 420px while the page
settled; the test now opens rows with a DOM click.
Also run, both engines, every language, 980/420: library-memory, library-memory-select, library-memory-suggest, memory-icon, library-instr-busy, library-instr-sets, library-linked-set, library-follow-server: all green. No Go code changed, so no go test or vet.
Not tried: the real app on a real memory store mid-read.
2026-11-13 12:17:43 +08:00
yetone c1312ac151 lessons: 11-13, the eager-regexp guard red twice more
1ca2c62c4 and d52e2feaf each added a package-level regexp and ran only
their own package; the root guard caught both (19fd0dfb8, 6a506e283).

Run: none (text only).
2026-11-13 12:13:30 +08:00
yetone 6a506e2834 agent: pi-magpie's source pattern compiles on first use (TestNoEagerPackageRegexps)
d52e2feaf added piMagpieExt as a package-level regexp.MustCompile, so
TestNoEagerPackageRegexps in the root package was red on main
("internal/agent/pimagpie.go:13:19: a package-level regexp is compiled
at launch; use lazyre.New"). It is lazyre.New now, as the rest of
internal/agent's patterns are.

Run on mica: go test -run TestNoEagerPackageRegexps . ok (red before,
in the full suite at 70f4593e6); go test -run Pi ./internal/agent ok;
go vet ./internal/agent ok; gofmt clean.
2026-11-13 12:10:08 +08:00
yetone 5e51e241c2 site: a release's attestations are asked of GitHub once, not once a file (ArcticLampyrid on X)
wrangler tail of the 04:05 run: "API rate limit exceeded for 172.71.158.37",
so v0.1.3982, v0.1.3981 and v0.1.3978 got no attestations.jsonl. The worker
has no GITHUB_TOKEN secret, and unsigned the API allows 60 requests an hour
to an IP the worker shares with other workers; asking once per file (15 a
release, every five minutes until whole) spent that fast. Release CI signs
every file in one statement, so the cron now reads the subjects of the
bundles it got and asks only for a file none of them names: one request a
release. A GITHUB_TOKEN secret (read-only, public repos) would lift the
shared limit; that is the owner's to add.

Checked on the real v0.1.3979 bundle from R2: subjects() lists all 17 files,
the CLI's digest among them.
Run (mote): node --test site/*.test.mjs 120/120.
New test: one statement signing every file is asked for once.
Broken by hand: not adding the subjects to the covered set turns it red.
2026-11-13 12:10:01 +08:00
yetone 70f4593e62 provider: a key's typed balance can refill each day (Kelen_Yc on X)
A key's balance typed by hand refilled each month or each week. A relay
key with a daily allowance had no way to say so. Now it can refill each
day, at local midnight, like the others:

- provider: Refill{Every: "day", Day: 0} (RefillDay). Last is today's
  midnight in now's location, Next tomorrow's. check takes it with day 0
  only; ParseRefill reads daily/day/d (daily:1 refused); String is
  "daily". A magpie before this drops such a refill on read, as one
  written by hand that isn't one, and counts from when it was typed.
- CLI: `magpie provider key-balance <id> <key> --refill daily`; usage
  lines updated.
- GUI: the pill's menu has "Refills each day" after "Refills each
  week…", posting {every: day, day: 0} at once (no day to pick, so no
  ellipsis), with its toast; en, zh, zh-TW, ja, de.
- docs/subsystems/providers-accounts.md names it.

Tests: TestRefillDays gains daily rows (midday, exactly midnight, a
month's and a year's end, Asia/Shanghai). New
TestTypedBalanceRefillsDaily holds the clock in Pacific/Kiritimati
(UTC+14), Pacific/Pago_Pago (UTC-11) and UTC: a minute before local
midnight the spend counts from when it was typed, a minute after it
counts from local midnight and the next refill is the following one.
TestOwnBalanceParsedInYuanAndRefill and TestTypedBalanceRefills cover
parsing, the bad {day, 1}, and read-back; TestKeyBalanceCmd sets
--refill daily. key-own-balance.test.cjs picks Refills each day in
every language, both engines, 900 and 400px, checks the post and that
the menu then shows it picked.

Run on mica at 889758605 + this: go test -count=1
./internal/provider ./internal/cli ./internal/gui ok; go vet darwin,
GOOS=linux -tags nogui, GOOS=windows ok; gofmt clean; GUI
key-own-balance, i18n-keys, i18n-en-no-cjk, key-balance-expiring in
chromium and webkit ok (48/48). Rebased on c5adcbaab (library, site;
nothing of this change's files), then at the pushed head: go test
./internal/gui, ./internal/provider -run Refill|TypedBalance|OwnBalance|
KeyOwnBalance|Budget ok, i18n-keys and i18n-en-no-cjk ok. key-balance-card is red in de at 560px
(view-usage 635>560) in both engines on the clean base 889758605 too:
#6414.

Broken by hand: daily Last taken from UTC's midnight instead of local:
TestRefillDays and TestTypedBalanceRefillsDaily (Kiritimati) red.

Not tried: the real app with a real relay key; the full suite (started
after the tag).
2026-11-13 11:59:54 +08:00
yetone a095e40279 usage: a start doesn't hash every session file's rows again for the heatmap's key (#2278)
The heatmap's settled days are named by a digest of each session file's
chunk of rows (sourceDigest). The digests were kept in memory only, so
every start unpacked and hashed every chunk again: 0.14-0.16 s of CPU in
the first 40 s of a start on a real history (startpg profile, w50v).

A chunk's serial names its file as read under one root and meta
(sourceSerial: root, meta, path, size, mtime), the same in every run, so
the digests are now kept in heat-digests.bin next to heat-v1.json, by
serial, under requestDiskBinary()'s key of the code that makes the rows:
another build's rows are hashed again. A file that can't be read, was
cut short or names other code is nothing kept. It is written as
heat-v1.json is (temp file renamed over it), only when a digest was made,
with this run's digests first and then those kept it hasn't met, at most
two turns' worth (2 x 65536 x 40 bytes), sorted by serial. The file is
kept as read and searched in place: a map of its 17k entries beside
sourceDigests' own cost 1.4 MB of live heap in a first try (w51v).

Measured on mote with the real-account sandbox (acctp, 17k chunks), a
start with the page opened, second start of each build:
- CPU profile, first 40 s: 2.00 s (w50v, v0.1.3978) -> 1.54 s (w52v);
  sourceDigest/heatSettledKey 0.12-0.13 s -> gone
- pageheap at the mark: CPU 2.48 s -> 2.12 s, Footprint 134 -> 131 MB,
  liveHeap 79.1 -> 79.4 MB

Run (mote, Go 1.26.8):
- go test -count=1 -timeout 45m ./internal/usage: ok
- GOOS=windows and GOOS=linux go vet ./internal/usage: ok; gofmt clean
- TestSourceDigestsKeptAcrossStarts (new): a second start hashes 0 of 2
  chunks with the same key; a start of one file keeps the other's; a new
  file hashes 1; other row code hashes again; a cut file hashes again.
- Broken by hand (the disk lookup ignored): the new test goes red,
  "started again, hashed 2 chunks".
2026-11-13 11:57:46 +08:00
yetone c5adcbaab5 site: llms-full.txt carries the ccswitch:// import line
889758605 added a line to docs/import.html without regenerating
llms-full.txt, so worker.test's "llms-full.txt is current" was red on main.
Regenerated with node llms-full.mjs. Run (mote): node --test site/*.test.mjs 119/119.
2026-11-13 11:53:34 +08:00
yetone 728f3de407 site: a release the feed named for one run still gets its attestations on R2 (ArcticLampyrid on X)
52830b077 asked for a release's bundles only while the feeds named it, and
only after its files were copied inside the run's budget. Tags came minutes
apart today: v0.1.3978 was the newest for the 03:40 run alone, which copied
its 15 files, and by 03:45 v0.1.3979 had replaced it, so v0.1.3978's files
are on R2 with no attestations.jsonl beside them. After pruning, the cron
now also fills in the bundles of every tag it keeps (the four newest the
feeds don't name), from the files and hashes R2 holds of it. A tag that
never had files on R2 (v0.1.3977, newest for under a minute) is served by
GitHub, bundles included, as before.

Seen live: wrangler tail of the 03:45 run copied v0.1.3979/attestations.jsonl,
and usemagpie.ai/files/v0.1.3979/attestations.jsonl answers 200.

Run (mote): node --test site/files.test.mjs 10/10; site/*.test.mjs 118/119,
the red is worker.test's "llms-full.txt is current", stale since 889758605
on origin/main, regenerated in the next commit.
New test: a kept release the feeds no longer name gets its bundles.
Broken by hand: the kept-tags loop emptied turns it red.
2026-11-13 11:53:34 +08:00
yetone 4431e31f7c library: a project gets subagents of its own, per agent (jinpwng on X)
The Subagents tab now lists the projects as Skills and MCP do. Opening
a project shows each library subagent with chips for the agents that
read a project's own subagent folder: Claude Code (.claude/agents),
Codex (.codex/agents, TOML), OpenCode, Gemini CLI, Qwen Code, Droid
(.factory/droids), Cursor and Copilot (.github/agents/*.agent.md). A
tick writes the subagent into that project only, in the agent's own
format; the agent's global folder and other projects are untouched.

Each file is recorded by its hash and rewritten or removed only while
it is exactly as magpie wrote it, so a same-name file of the user's is
left alone. A rename in the library follows into each project. The
files are kept out of git by the project's info/exclude block, and
follow the repository's other worktrees (syncTrees now copies
Subagents, and clears it for a worktree let go).

POST /api/library/projects/subagents {dir, name|names, agents}. No CLI
yet, like project servers. Hooks, instructions and Claude plugins have
no project scope yet (filed separately).

Run (mica / mote via mica-run, mote-run):
- go test -count=1 ./internal/library ./internal/gui: ok
- node --test, chromium + webkit: project-subagents, project-scope,
  project-servers, project-skills-pick, project-skills-groups,
  project-remove-keep, library-subagents, library-all, library-items,
  i18n-keys, i18n-en-no-cjk, claude-subagents-pick,
  codex-subagents-lead, subagent-effort: 150/150 pass
- gofmt -l clean; go vet darwin, linux -tags nogui, windows on
  internal/library and internal/gui: ok

Broken by hand: dropping Subagents from syncTrees' copy made
TestProjectSubagentsFollowWorktrees red ("the worktree hasn't the
project's subagent"); the earlier session broke the fix by hand and
saw the new library tests go red.

Not tried: a real Claude Code/Codex session picking up the project
subagent; the full go suite (started after the tag); Windows/Linux
runs of the GUI.
2026-11-13 11:51:50 +08:00
yetone 889758605f import: open CC Switch's ccswitch:// provider links (coder_shaun on X)
A relay's one-click ccswitch://v1/import?resource=provider&app=…&name=…
&endpoint=…&apiKey=… link now opens magpie's own import confirmation. The
format is read from CC Switch's source (src-tauri/src/deeplink/parser.rs and
provider.rs at 3c76d3b): host v1, path /import, resource=provider only,
app, name, endpoint, apiKey, apiFormat, model/haiku/sonnet/opusModel,
homepage, iconUrl, and the base64 config (claude env, codex auth + config.toml
provider table, gemini env) filling what the URL leaves out. The link is
translated into a magpie://import's parameters and goes through the same
checks (https only, key shape, id rules, balance host) and the same
confirmation; usage scripts, configUrl, enabled and notes are never taken, a
codex env_key is refused.

Registration, so as not to take CC Switch's links: Linux writes a separate
magpie-ccswitch.desktop and sets the default only when `xdg-mime query
default` is empty or already it; Windows writes HKCU ccswitch only when
HKCR has no live handler of another program; uninstall and install.sh remove
them only while they are ours. macOS declares the scheme in Info.plist
(static), so with CC Switch installed too the system picks.

Run: provider, gui (macOS mote; Linux gtk3 on WSL for the scheme tests),
uninstall, cli, update packages; vet darwin, windows, linux nogui. The test
parses CC Switch's own 11 provider examples (testdata/ccswitch_links.txt,
copied from its repo) and refuses the other resources. Broken by hand: claude's
default endpoint kind (4 reds) and the Linux "another app has it" check
(TestRegisterSchemeLeavesCCSwitchItsLinks red).
Not tried: Windows registry (vet only), a real CC Switch installed beside
magpie, a browser click on a real relay's button.

Rebased on 610ae1f54 and run again there (mica): provider, gui, uninstall,
cli, update ok; GUI import-link-balance, import-link-gemini,
import-collision, import-opencode 80/80 in chromium and webkit; vet darwin,
linux nogui, windows ok; gofmt clean. Reviewed against CC Switch db7a0e7
(no deeplink change since 3c76d3b). Broken by hand again: the config's key
no longer filling an empty apiKey (TestCCSwitchOwnExamples, 3 reds).
Pushed on 48afb27b0, which adds only the library plugins GUI files
(client.js, library.css, library-plugins.test.cjs) to that base.
Not tried either: macOS with CC Switch installed too, where Launch Services
picks which app opens ccswitch:// links.
2026-11-13 11:46:50 +08:00
yetone 48afb27b0f library: Claude plugin rows show counts, the dialog keeps its width and folds the parts (jinpwng on X, #6309)
The plugin dialog's description, part lists and source line sat in the
editor grid's 132px label column, so even Plannotator (3 hooks) read as a
narrow column: the Hooks heading landed in the right column, the names
under it on the left and the GitHub line in the middle. Description, parts
and hints now span the grid. The list row showed every skill name (PStack
lists a hundred); it shows "Skills 12 · Hooks 3", and the dialog lists each
part's names in a fold, closed by default.

Run at this head (rebased on 610ae1f54), on mica, Chromium and WebKit, en,
zh, zh-TW, ja, de, 420 and 1100: library-plugins, library-subagents,
library-all, library-row-open-scroll, library-open-again, i18n-keys,
i18n-en-no-cjk: 82 of 82 pass. gui-zh-tw passes; gui-de and gui-ja's
"has every zh string" are red on main already ({agent} placeholder, #6234).

Broken by hand: with the span rule cut back to the <p> only, the test fails
with "a part or the source is squeezed" (parts 116/433 of 600px, source
116px), the reporter's alternating layout. With the old CSS it fails "the
description is squeezed: {p:132,d:600}".

No Go files changed, so no gofmt/vet. Not tried: the real app with a real
PStack or Plannotator.
2026-11-13 11:43:59 +08:00
yetone 610ae1f541 library: handing skills over turns off the all-in-~/.agents/skills setting and takes magpie's links out (ConatusMoon2222 on X)
Put skills in "~/.agents/skills" (SharedSkills) gives every agent that reads
that folder every skill, so it cannot go with choosing agents per skill,
which is what "Manage in magpie" (HandOverSkills) is for. With the setting
on, a handed-over skill's entry was taken away and the next sync linked it
back there, so the link stayed (reproduced in a sandbox HOME). Handing over
now turns the setting off in the same write; the sync then removes magpie's
own links there (sweepShared: only ours, never the user's entries). The
confirm sheet says so, only while the setting is on. The Put skills in note
says the skill router lists nothing while every skill is in
~/.agents/skills (the "none" the reporter met), only when both are on.
Strings in zh, zh-TW, ja, de.

Run (on mote, at this tree):
- TestHandOverWithSharedSetting: red with the l.SharedSkills = false line
  commented out ("a link is left in ~/.agents/skills"), green with it.
- go test ./internal/library ok; go vet darwin, GOOS=windows, linux nogui
  on internal/library ok; gofmt -l clean.
- GUI: skill-handover, shared-skills, i18n-keys, i18n-en-no-cjk in chromium
  and webkit, 23/23 each.
Not run: the full GUI suite and go test ./... before the tag; a real
account's Library; WebKitGTK.
2026-11-13 11:28:51 +08:00
yetone 52830b077b site: the build attestations are kept on R2 beside the release files (ArcticLampyrid on X)
The SLSA attestations live behind GitHub's API only, so with GitHub down
they could not be fetched while the mirrored files could. The five-minute
cron now also asks api.github.com/.../attestations/sha256:<digest> for every
file of a release from v0.1.3891 on and, once every file has one, writes
<tag>/attestations.jsonl to R2 (a Sigstore bundle per line, deduped), served
at usemagpie.ai/files/<tag>/attestations.jsonl. It is written only whole, so
a file with no attestation yet is asked again next run, and it is pruned
with its tag. `gh attestation verify <file> -R yetone/magpie-releases
--bundle attestations.jsonl` checks a download with it. It is not a release
asset: the GitHub release keeps its 17 assets and release CI is unchanged.
start (en, zh, ja), llms-full.txt and reference.md say where it is and how to
verify. The updater does not read it yet.

Run (mote): node --test site/*.test.mjs 118/118; gofmt n/a.
New tests: bundles land once and only whole; pre-0.1.3891 release not asked.
Broken by hand: ATTESTED set to 9.9.9 turns the bundles test red.
Not tried yet: the real cron run and the file on R2 (after deploy), the
updater reading it from R2, gh --bundle on a real downloaded file.
2026-11-13 11:23:30 +08:00
yetone d9a2277ea7 LESSONS: 11-13, a budget raised by what was over and records that point elsewhere
2f34649a6 measured 1,266,040 against 1,265,712 (budget.py over git show),
and dd9b2bcef raised the budget to what was left after packing. Docs only.
2026-11-13 11:20:05 +08:00
yetone e979553ba1 sessions: a start doesn't read Claude Code forks' uuids again to judge them (#2278)
Each start judged every group of Claude Code files that start alike
(ccFamily), then read what each copy or branch holds that its keeper
doesn't (ccRest). Both read every file's message uuids through
scanThin, and what they found was kept in memory only: ~0.2-0.25 s of
CPU on each start for a real history with forks, and a uuid set held
for each file.

What a group came to depends only on its files, so it is kept in
cc-families.json next to sessions.json, by a hash of each member's key,
path, size, change time, first and last message and start; a group none
of whose files changed is not read. A copy's or branch's rest is kept
in cc-rest.json by both files' path, size and change time, encoded the
way the parses are (encodeCache), so another time zone, cache version
or parser version reads it again. Both are written behind mu through a
temp file renamed over the last, in order; Saved and Reset wait for
them. Groups unused for 30 days are dropped.

Run (mote, at this tree):
- go test ./internal/sessions ./internal/usage ./internal/gui: ok
  (128 s, 64 s, 151 s); GOOS=windows and linux go vet
  ./internal/sessions: ok; gofmt clean.
- New TestClaudeFamilyKeptAcrossStarts: a start after one that judged
  the group reads no file's uuids, and a copy that went on with a turn
  is judged again (a branch). TestClaudeBranchRestKeptAcrossStarts: two
  starts count the same 80 tokens in and read no uuids.
- Broken by hand: ccFamilyKept always nil -> the first test red ("read
  the uuids of 3 files"); ccRestLoad never reading -> the second red
  ("start 0 read the uuids of 1 files"). Dropping size and mod from the
  group's hash left the first test green: the changed copy's last
  message changes the hash anyway; size and mod are there for a file
  rewritten in the middle.
- Real accounts (acctp sandbox, pprof of the first 40 s of a start with
  the page open): sessions.Warm 0.78/0.79 s -> 0.52/0.57 s, statsKept
  0.39/0.43 -> 0.18/0.21 s, ccFamily/ccUUIDsOf gone from the profile;
  pageheap: CPU at mark 2.84 -> 2.65 s, Footprint 132 -> 127 MB,
  liveHeap 80.2 -> 78.4 MB. The first start of the new build reads and
  writes them once (2.70 s at 40 s, as before).

Not tried: Windows and Linux real starts; the files are plain JSON in
the cache folder.
2026-11-13 11:18:30 +08:00
yetone dc356402ab memory: Codex's earlier agent memories (kept as codex-mcp-client) are still found (#6392)
Follows c9c10b960: Codex's MCP client name now reads as codex, so a search as Codex also looks in agent:codex-mcp-client. TestMemoryMCPSharedAcrossAgents now expects codex. Ran on mica: -run 'TestMemory|TestRun' ./internal/gateway ok; gateway+library+browsermcp full run: library and browsermcp ok, gateway cut at the 10m default timeout under load (suite follows the tag). Windows/linux-nogui/darwin vet clean on gateway and library.
2026-11-13 11:11:33 +08:00
yetone 8f82e08b4f memory: Codex over HTTP is known as Codex (Norethcy on X, #6392)
Codex reaches Magpie Memory at /mcp/run/magpie-memory, which starts `magpie mcp memory` per Codex session. A session magpie never saw start (Codex keeps its session id across a magpie restart) started the server with the default initialize, client "magpie", so memory_save scope=agent said it couldn't tell which agent called. Now: such a session (and an initialize naming no client) is started as the request's agent, Codex on this route; the direct HTTP route keeps the client an initialize named under its Mcp-Session-Id; every codex* client name (codex-mcp-client, codex-tui) is Codex.

Ran on mica: new tests (red on the old code with the reporter's error text), internal/gateway, internal/library, internal/browsermcp (see below). Not tried: a real Codex Desktop.
2026-11-13 11:11:33 +08:00
yetone 4f72725e39 gateway: a drawn SVG is served under a CSP that runs nothing
The image server's files (b2ccfe25d keeps them an hour, behind a link
with a token) were served with the vendor's type and nosniff only. A
Recraft SVG opened from its link is a document on the gateway's own
origin, and a page there is same-origin to the gateway, which a local
request reaches without a key: script in the SVG could have asked
/v1/chat/completions on the user's subscriptions. An SVG is now served
with "default-src 'none'; style-src 'unsafe-inline'; sandbox", as the
GUI's SVG icons already are (library.go, providers.go). Other types
are unchanged, so a video still plays in its own page.

Run: go test -run TestImageMCP ./internal/gateway ok (mote).
Broken by hand: with the header line removed,
TestImageMCPSVGRunsNothing is red (mica).
Not tried: a real Recraft SVG in a browser.
2026-11-13 11:08:44 +08:00
yetone dd9b2bcef5 gui: the new sign-in row and sentences within the core script budget, +296 (Wing8Aqua on X)
No page left to move them to; the row is packed to its shortest form.
Budget raised by exactly the 296 bytes over.

Record for this stack (Wing8Aqua's three reports: cap toggle wording,
Smart is not load balancing, Sign in on another computer), run on mica at
this head's content (rebased on 861a0442c):
- go test ./internal/gui: ok; gofmt clean; go vet darwin, windows,
  linux nogui: clean.
- GUI: pool-ends, signin-another-computer (new), signin-link-only,
  i18n-keys, routing-save: 122 pass, 0 fail, chromium and webkit, en zh
  zh-TW ja de where the file has them. Earlier wider run (signin-*,
  i18n, routing-save/advanced/smart-intent/manual/mode-goes, account-cap):
  418 of 425; the 7 reds were the Japanese 420px cap label wrapping a
  line (fixed, shorter label), one load timeout each in signin-again and
  signin-codex-device (green on rerun) and signin-proxy 380px, which is
  red on origin/main too (#5866).
- Broke by hand: without the linkOnly post the new test is 0 of 16.
Not tried: a real Claude sign-in from another machine; Windows and Linux
webviews; plugin sign-ins and the Routing page's own Smart tooltip
(plugins/routing/client.js) keep their old text.
2026-11-13 11:07:02 +08:00
yetone 4b34020354 gui: shorter Japanese cap toggle label, so it stays on its line at 420px (Wing8Aqua on X) 2026-11-13 11:02:15 +08:00
yetone 2f34649a6e gui: Claude and Codex accounts get "Sign in on another computer…", the link alone (Wing8Aqua on X)
Adding an account opened the local browser, the only way not to being a
Privacy setting nobody finds. The ideal sign-in is often another machine
(another region). Under Claude's and Codex's accounts a row starts the
sign-in kept to its link: /api/signin takes linkOnly, opens nothing here
and the window shows the link with Copy and Open in browser (f4f104d1c)
and the paste-back field for the address the other browser ends on. The
setting and the default are unchanged; other subscriptions are not given
the row (plugin sign-ins are not touched).

Run: see push notes.
2026-11-13 11:02:15 +08:00
yetone de0a237693 gui: Smart routing says it is not load balancing and where to pick it (Wing8Aqua on X)
Smart sends requests to one account at a time (the soonest to renew) and moves on at 90% or on failure, by design: spending what would be lost and keeping the prompt cache. The hint now says so and names In turn and Least used first for an even spread, in en, zh, zh-TW, ja, de.
2026-11-13 11:02:15 +08:00
yetone 0ae77bad59 gui: the cap toggle says what it does: off, fallbacks take over at the cap (Wing8Aqua on X)
"Stop when every account is at its cap" read as if off meant not stopping
at all. Off, requests go on to the provider's fallbacks; on, they get 429.
Renamed "Don't go to fallbacks when every account is at its cap", with a
tooltip naming both states, in en, zh, zh-TW, ja and de. The field
(capStop) and its behaviour are unchanged.

Run: pool-ends GUI test updated to the new labels (see push notes).
2026-11-13 11:02:15 +08:00
yetone 861a0442c1 agent: Codex in a running WSL distro is connected once Codex on Windows is (@not_4O4 on X)
The Codex app's work mode on a project whose run environment is WSL starts
its app-server inside the distro, on the distro's ~/.codex (the app resolves
CODEX_HOME there with `bash -lc 'printf %s "${CODEX_HOME:-$HOME/.codex}"'`).
magpie wired Codex on Windows and, as a separate Agents row, the distro's
twin (codex@wsl:<distro>) only when the user connected that too, so the
picker listed OpenAI's models alone there.

ConnectCodexTwins, run at the start of each SyncCatalog, connects the twin
of each running distro once while Windows' Codex is connected. It leaves a
twin alone that is connected or disconnected already, whose config names a
provider or base URL of the user's own, or whose distro is stopped (asking
one starts it). A stash mark (<id>.autoconnected) keeps it to once, so a
later Disconnect stands. docs/subsystems/agent-wiring.md says so.

Run: TestConnectCodexTwins and TestConnectCodexTwinsKeepsOwnProvider; go
test ./internal/agent on mote (ok, 305s); TestWSL* and the new tests on the
Windows box (ok); gofmt; go vet darwin, linux and windows (nogui).
Broken by hand: Windows-connected check removed (red), own-provider check
removed (red). The Disconnected check is covered by the mark alone.
Not tried: the Codex app itself with a WSL project (read its bundle for the
CODEX_HOME resolution only); the reporter's distro and networking.
2026-11-13 11:01:27 +08:00
yetone 092a86ad22 gateway: Mistral's API gets a stable per-session x-affinity (daoche_wuzui on X)
Mistral routes a conversation to the server holding its KV cache by the
x-affinity header. Checked against the sources: mistral-vibe's CHANGELOG
("KV cache warming via x-affinity in count tokens"), its
_runtime_config.py request_headers (sets x-affinity every turn), and
pi-ai's buildMistralHeaders (earendil-works/pi, mistral-conversations.ts:
sessionId unless the model's or call's headers name one).

forwardOnce now sets x-affinity for a Mistral API key provider
(mistralAffinity): the client's own value as sent, else a hash of the
session or conversation, never the id itself, the same every turn. Other
vendors, accounts and plugins get none; the user's own provider headers
are put on after it. Every route (relayed, translated, count_tokens)
goes through forwardOnce.

Run: go vet on darwin, linux nogui and windows for internal/gateway, and
go test -count=1 ./internal/gateway at the branch head via mote-run, ok
(1370s). New: TestMistralAffinityHeader.
Broken by hand: header setter off, red ("affinity \"\" \"\" \"\""); the
isMistral scope removed, red ("another vendor got x-affinity").
Not tried: a real Mistral key, so whether Mistral's cache hit rate
changes is unmeasured. Full ./... not run.
2026-11-13 10:54:56 +08:00
yetone cba704d5f0 library: with the skill router on, the page says when no skill is listed for an agent and when its own skills stay in its prompt (ConatusMoon2222 on X)
ConatusMoon2222 turned the Skill router on and reported it "does not take
effect". Reproduced in a sandbox HOME: the router lists only the library's
skills ticked for an agent. An agent with nothing ticked, or each skill kept
direct, got no magpie-skills, yet its row said "on"; and skills in an
agent's own folder that the library lacks stay in its prompt with no word
on the page.

AgentView.SkillRouter is now "none" for an agent whose folder takes the
router but has nothing listed (Applied.Router false), and the Skills tab
names those agents, and the agents that have skills of their own the
library lacks, under the switch (.lib-hub-why data-why none / found). Four
languages (zh, zh-TW, ja, de). docs/subsystems/skill-router.md updated.

Run on mote: go test -tags nogui ./internal/library (ok, 260s);
skill-router.test.cjs in chromium and webkit, all four languages, narrow
and wide (22 pass, with the new found line asserted); go test ./internal/gui
Asset/Budget/Script ok; gofmt clean; go vet nogui darwin/linux/windows clean.
Broken by hand: sync.go back to the parent, TestSkillRouterLastSkillUnticked
goes red ("nothing listed, the view says on").
GUI i18n-*, library-*, skill-* files: all green except skill-fold-all and
skill-manual, red on origin/main from the window's /api/update/using POST
(#5982, not this change).
Not tried: a real agent on Windows; the reporter gave no agent, OS or
version, so the cause for their machine is inferred, not confirmed.
2026-11-13 10:53:40 +08:00
yetone 5d93f6b3d9 gateway: a day's history is gzipped a route at a time and capped in size (tsingchao on X)
gzipFile read the day's whole file (and its .gz) into memory, so a 7.25 GB
day took a 1.6 GiB host down in a restart loop. It now streams: the file's
routes are remembered by an 8-byte hash, the new .gz goes to a temp file
beside the old one (the old .gz copied raw, the new routes a gzip member
after it) and is renamed over it; any failure leaves the file and the .gz
as they were.

Nothing bounded a plain day either. A day now goes on in a numbered file
(DAY.1.jsonl) past 256 MB, and today's files past 1 GiB in all lose their
oldest. History, HistoryRoute and the Context tab's stamp read the numbered
files too.

Run (mote): gofmt, go vet gateway+gui on darwin, windows, linux nogui;
gateway and gui packages. TestGzipFileHoldsNoWholeDay (64 MB day, with a
.gz to dedupe against) allocated 149 MB on the old code, now under 24 MB.
Broke dayAppendPath by hand: TestDayGoesOnInANumberedFile went red.
Not tried: a real 7 GB file; full ./... suite (run after the tag).
2026-11-13 10:48:07 +08:00
yetone 364e4946ae LESSONS: 11-13, a patch on #5948 waited three days until CI went red on it
Records the case under the moved rule "a red's issue is read to its
last comment, and a patch on it is taken first". Docs only.
2026-11-13 10:47:45 +08:00
yinwu01 ff865b47a1 gateway: the TTFT and reasoning speed tests wait until the agent has each event (#5948)
TestGroupFailoverTimesEachTry went red on a loaded box with TTFT equal
to FirstText: "ttft_test.go:260: the answering try: {... Millis:304
TTFT:233 FirstText:233 ...}". The paced vendor kept its reasoning and
its text 80ms apart on the wire, and a gateway that read late got both
in one read and timed them as one. TestUsageKeepsTimeToFirstToken had
the same gap and was fixed for #2575 with paced's heard hook: the gap
before each marked event starts only once the agent has been sent the
one before. The failover test now posts with that hearing agent and
gives the answering vendor its heard, so the text comes a gap after the
agent had the reasoning, and the end a gap after it had the text.

The same gap stands under four more tests, which get the same hook.
TestCodexBackendTimesFirstToken, in the same file, checks u.Millis >
u.FirstText across the text and the end (its request is now built by
codexServe, which codexPost uses too). In reasoning_speed_test.go,
TestReasoningSpeedThroughGateway and TestSpeedEndsWithTheReply need
their thoughts read apart, 100ms at least (TestReasoningPacingEdges),
for a speed; the fixture's gap is 150ms. TestSpeedEndsWithTheReply's
first thought is now marked too, so the gap after it is guarded as
well (a first marked event is sent at once). In
reasoning_uncounted_test.go, TestStreamedReasoningWithoutCount's Chat
cases, paced 80ms apart, get it for their three thoughts; its
Anthropic cases replay DeepSeek's 33 deltas and are left as they were.

What was run (tree d6c1100b, on origin/main db0f2f20, go1.26.8,
linux/amd64, Linux 5.15), outside graftcp, umask 077 (these packages
don't run Bun; Bun 1.4.2 on PATH for the final runs, 1.3.11 for some
old-code runs):
- The five tests with the change, -count=5: ok. None waited out
  heard's 10s.
- With 240ms slept by hand in holdWriter.Write on the vendor's first
  event (fallback.go, a gateway passing it on late): the old failover
  test red 3 of 3 at :260, "TTFT:242 FirstText:242".
- With 240ms slept by hand in the Codex backend's read loop once the
  reasoning came (codex_backend.go): the old Codex test red 3 of 3 at
  :337, "Millis:322 TTFT:322 FirstText:322". The new one: ok 3 of 3.
- With 400ms slept by hand in holdWriter.Write on the first thought:
  the old TestReasoningSpeedThroughGateway red 2 of 2 at :76 on each of
  its paths ("streamed reasoning missing"), and the old
  TestSpeedEndsWithTheReply 2 of 2 at :133 ("a reply that came at its
  pace tells no speed: 0/0").
- With 400ms slept by hand in holdWriter.Write on the first thought
  ("We..."): the old TestStreamedReasoningWithoutCount red 2 of 2 in
  its "chat tool, counted" case at :94 ("speed 0/0 ms; want
  told=true"), its other cases ok. With the same holds, the new
  failover, the two reasoning speed tests and this one: ok 2 of 2 each.
  None of these reds was reproduced without an injected delay.
- go test -count=1 -timeout 45m -v ./internal/gateway: 4009 tests ok
  (15664 with subtests), 14 skipped, red in two,
  TestClientPathCoversHandler and TestReadOnlyKeyEveryRoute (the CA
  route /magpie-ca.crt in neither route list), red on origin/main
  db0f2f20 too (#5993).
- gofmt -l clean. go vet -tags nogui for linux and windows, go vet for
  windows, go build -tags nogui for linux and darwin and go build for
  windows: exit 0 each. GOOS=darwin go vet -tags nogui: exit 1 at
  internal/gui/traywindows_darwin_test.go, as on origin/main (#5263).
  go vet and go build without the tag on linux: exit 1 (no libsoup-3.0
  or gio-unix-2.0 pkg-config here).
- The full suite: see the comment on the issue.

Not changed: TestResponsesToolWithoutReasoningStillTimed, whose old
version stayed ok 2 of 2 with a 400ms hold on its first piece in
holdWriter.Write.

Not tried: a Mac or Windows, or the red under real load.

(cherry picked from commit 86e12bbdeb466a2cc4e3f8718c23d7a1236d77b2)

Landed for #5948 after it came back on CI at dbb2e5dd2 (run 43342362373,
macos-latest) as a second shape of the same gap: ttft_test.go:264, usage
Millis:450 == FirstText:450, the text and the end read at once.
Run at this commit on 422f90e80 (mica, macOS, load ~19):
- the six TTFT and reasoning speed tests, -count=5: ok.
- Broken by hand: a 240ms hold in holdWriter.Write after the reasoning;
  the old TestGroupFailoverTimesEachTry red 3 of 3 at :264, as on CI, the
  new one ok 3 of 3 with the same hold.
- go test -count=1 -timeout 45m ./internal/gateway: ok 854s.
- gofmt -l internal/gateway: clean.
Not tried: Windows; the full ./... suite (test-only change in one package).
2026-11-13 10:47:17 +08:00
yetone 46e338923b copilot gemini: unions fold to one object, $ref branches resolve, a nullable keeps no type, a bare array gets items (Novello42 on X)
DaVinci42's four cases on #4374 (v0.1.3925), fixed in the Copilot Gemini
tool-schema translation only:

- copilotGeminiToolUnions renamed a disjoint object anyOf to oneOf, which
  Copilot's Gemini takes with 200 but strips of its branches, so the model
  sent a string. The rename is gone; copilotGeminiToolShapes folds the
  branches into the one object (same-named properties join their enums, so
  a discriminator keeps "project" and "none").
- a union of local $ref branches is resolved against $defs/definitions
  (a copy; a target that refers on is not followed) before it is judged,
  instead of being dropped to an untyped string.
- a type written beside a nullable single-branch anyOf is removed (400).
- an array with no items gets items {} (typed after by geminiTypes) (400).

Run (mote, -tags nogui): TestCopilotGeminiFoldsCodexUnions,
TestCopilotGeminiReporterSchemas (the reporter's four schemas verbatim),
TestCopilotGeminiShapesLeaveOthersAlone (claude / no agent: body unchanged),
and the TestCopilot*/TestGeminiTypes*/TestAntigravity* set pass. With the
three changed non-test files put back to origin/main the first two go red
(all four reporter subtests). gofmt clean; go vet darwin/linux/windows and
the gateway package run: see the next commit/tag notes.
Not tried: a live Copilot account (the fake refuses by the reporter's
recorded rules).
2026-11-13 10:40:26 +08:00
yetone d52e2feaff pi: with the pi-magpie extension installed, magpie's models.json block goes (KenyonCode on X)
pi-magpie (npm, tinysnake) serves provider "magpie" from the live catalog
and warns at every start while models.json still names providers.magpie
(one baseUrl for every model, a frozen list). magpie wrote that block
itself, so the user was told to delete it by hand.

When Pi's settings.json "packages" lists pi-magpie, Pi's Sync and model
pick now drop magpie's own block (only one pointing at this gateway with
magpie's key; a block the user wrote stays) after keeping
models.json.before-pi-magpie, through the atomic JSON delete, the rest of
the file untouched. Check no longer calls the missing block a broken
wiring. Without the extension nothing changes.

Run: TestPiMagpieExtensionTakesOverTheBlock (sandbox HOME) and ./internal/agent
on mote, vet darwin/linux nogui/windows. Broken by hand: viaExt forced false
-> the test goes red with the block still there.
Not tried: a real Pi with the extension installed.
2026-11-13 10:37:44 +08:00
yetone b2ccfe25dd gateway: a drawn image is kept on disk for its hour, and the reply it came in is let go (tnt12231 on X)
The image MCP server kept every drawing, and every video, in memory for an
hour (up to 256 MB), and swept them only when another image arrived. A
drawing also held its reply, the base64 strings parsed from it and the decoded
bytes at once. Now:
- imageMCPKeepFile writes the image to <config>/image-mcp (emptied at the
  first use in a run) and the file URL serves it from there; only the
  metadata is in memory. A timer removes it at its hour. If it can't be
  written the bytes stay in memory, as before.
- imageMCPDrawn drops the recorded reply and each b64 string as it is decoded;
  the stdio server (internal/imagemcp) clears each b64 once decoded.
- both hand the heap back (debug.FreeOSMemory) when a drawing is done: the
  Go scavenger gives it back slowly, and Task Manager showed it as
  magpie's.

The foreground/background numbers in the report (WebView2 processes a few MB
when hidden) are WebView2 suspending, not a leak.

Run: TestImageMCPKeepsDrawingsOffTheHeap (new; 6 x 12 MB drawings kept):
heap +71 MB on the old code, +0 after. internal/imagemcp and the gateway's
Image/Video/MCP/Browser/Record tests, gofmt, and vet for darwin, linux
and windows on mote. Broke it by hand: the old image_mcp.go with the new
test is red. Not run: the full suite, a real vendor's drawing, Windows.
2026-11-13 10:36:05 +08:00
yetone 2abfe2b644 codex: the editor extension's bundled Codex version is read, so the threshold is written (HermanHongbb on X)
The background-compaction table is written only when every Codex that
reads the config is known to be new enough. The openai.chatgpt extension's
reader was always made with no version, so any machine with the extension
installed counted as "unknown" and the table, with the threshold, was
held out: Codex compacted at its own 65%.

The extension ships bin/<target>/codex-package.json beside its codex
(checked in the real Open VSX packages of chatgpt 26.51111.21308, Linux
x64 and Windows x64: "version": "0.169.0-alpha.11.1"). It is read now, one
reader per installed copy, in every dot folder's extensions (VS Code,
VS Code Server, Cursor, Windsurf, VSCodium, ...); copies in .obsolete are
skipped. A version that can't be read stays unknown, not old. Settings'
existing note (codexAsyncHeld) names the editor extension and its version
when it is what holds the threshold back.

Run: TestExtensionCodexVersionRead (new; red with the version read turned
off by hand: got map[:4]), go vet darwin/linux/windows, gofmt, and go test
./internal/agent on mote, ok.
Not tried: a live VS Code with the extension; the full suite before the tag.
The macOS extension layout is the same package (darwin vsix not unpacked).
2026-11-13 10:29:39 +08:00
yetone 382c8c0bdf proc: magpie serve reaps the processes it adopts (Kling__Lab on X)
254 <defunct> children of `magpie serve` after 7 days, growing ~9 an hour
(magpie, uv, node, npm, magpie-bun, code-review-graph), only a restart
cleared them. Every command magpie starts is waited for (the AST guard
TestEveryStartedCommandIsWaited holds, and I read each Start site and
Output/StartTree/StartReaped by hand: none is missed). The zombies are the
grandchildren: an agent CLI's MCP servers whose parent ended are adopted by
magpie where it is PID 1 (a container) or a child subreaper, and nothing
waits for a process it never started.

proc.KeepReaping (Linux, from serve) does nothing unless magpie adopts
(PID 1 or PR_GET_CHILD_SUBREAPER), and then reaps a child of its own that
was a zombie at two looks 5s apart. Not tried: the reporter's container;
the cause (PID 1 / subreaper) is inferred from the report, not seen.

Run: TestAdoptedOrphansAreReaped (subreaper test process, 6 orphans) and
the proc package through wsl-run on magpie-desktop: ok. Broken by hand
(KeepReaping returning at once): 6 adopted zombies left, red.
2026-11-13 10:29:07 +08:00
yetone 422f90e80b davsync: WebDAV answers a Digest challenge, MD5 and SHA-256 (caelum1990 on X)
Sync signed in with Basic only, so a server that takes Digest only (Apache
mod_auth_digest, some NAS and nginx setups) answered 401 and magpie said
the password was wrong. digestTransport (RFC 7616, qop=auth, -sess too)
wraps the dav client: a 401 with a Digest challenge is sent again with a
Digest header made from the same user name and password, SHA-256 chosen
over MD5 when both are offered, and the challenge is kept, so the
requests after it carry Digest with a rising nc and Basic is not sent to
that server again. A PUT's body is made again from GetBody. A Basic
server is untouched.

Run: go test ./internal/davsync under mote-run, ok; vet darwin, linux
nogui and windows on the package. New: TestDAVDigest (MD5, SHA-256 against
a fake Digest-only server that checks response, nc replay, opaque, uri and
the PUT body), TestDAVDigestWrongPassword (still reads as a wrong
password; a Basic server is left alone).
Broken by hand: newDAV without the transport, TestDAVDigest red with
"refused the user name or password (HTTP 401)".
Not tried: a real Digest server (only the fake, built from the RFC's
formula); auth-int and SHA-512-256 are not answered. The first request of
a connection still carries Basic, as before, so a Digest-only server over
plain http sees the password once; nothing else was changed in that path.
2026-11-13 10:23:47 +08:00
yetone efc3e1e56b remote quotas: a Remote with no picks tells every card, a usage-only provider's included (fcooji on X)
On 0.1.3959 Claude Code set to usage only on the remote magpie showed no
usage on the local magpie that added it as a Remote. A usage-only provider
lists no model there, so a Remote with nothing picked here exposes only
what the remote lists, and cfd49e36a/93b855d90's filter by enabled models
dropped the Claude card. Only the user's own picks (Provider.Models) narrow
cards now; no picks, or Select none, tells all of them.

Run (mote): TestRemoteUsageOnlyProviderStillShowsItsCard is red with the
new rule turned off by hand (map[office/codex:true]), green with it;
-run 'Remote|Quota|Card' in internal/provider and internal/gateway ok; go vet
darwin/linux/windows of internal/provider ok; gofmt clean.
Not tried: two real magpies in sandbox HOMEs (a fake peer and list server in
the test), the GUI suite (Go only), the full Go suite (started after the tag).
2026-11-13 10:22:01 +08:00
yetone e6eaf4d69c site: a mirrors page in en, zh and ja
/docs/mirrors says how magpie downloads from China: the Plugins page's
Mirrors in China switch (npm at registry.npmmirror.com, Bun at
npmmirror's binary mirror, the plugin list at jsDelivr, bun add pointed
at npmmirror unless a registry is set), --proxy and --mirror for the
installer and magpie update, magpie update mirror and Settings' Download
source, the MAGPIE_MIRRORS fallback with MAGPIE_NPM_REGISTRY and
MAGPIE_GITHUB_MIRROR, and what is checked: update files against
usemagpie.ai's SHA-256, Bun's zip and npm integrity, credentialed
requests never mirrored. Every claim is from docs/reference.md (Mirrors,
the install and update section), internal/source/source.go and
internal/cli/update_cli.go, with the labels' zh and ja from i18n.js.
Linked from each language's troubleshooting page; in the sitemap,
llms.txt and llms-full.txt.

Run: the three pages' JSON-LD parsed with node; llms-full.mjs rebuilt;
node --test site/*.test.mjs on the WSL box (magpie-desktop, wsl-run):
116 pass, 0 fail.
Not tried: a download through the mirrors from China for this page; it
names only what magpie's reference and source say.
2026-11-13 10:15:28 +08:00
yetone 2ae8e61a4f usage: an upgrade reads session files again only when the code of their rows changed (#2278)
requests-v1.bin and log-v1.bin were keyed on a hash of every .go file in
internal/usage, so nearly every release that touched the package threw
both away. The first start after such an upgrade read all ~24k call
shards again: on the owner's real accounts (mote, acctp sandbox) that is
13.8s of CPU and ~3.4GB allocated before the page settles, against 2.4s
warm.

Each file now keys on the source its rows are made, written and read
through: rowSource (15 files) and logSource (23 files), embedded by name.
The row pricer and a file's chunk builder are lifted out of
readRequestBlocks (sessionRowPricer, sessionChunk) so they can be roots.
TestRequestDiskNamesTheCodeOfItsRows type-checks the package and walks
every declaration reached from those roots (uses, package vars assigned
elsewhere, interface calls, encoding/String/sort methods); it fails when
a reached file is not embedded or an embedded one is not reached.
Of the last six usage-changing releases, four (3962, 3958, 3941, 3908)
would have kept the cache.

Run:
- go test -count=1 ./internal/usage on mote: ok 51.9s.
- go vet ./internal/usage for darwin, windows, linux on mica: ok.
- Broken by hand: session_provider.go left out of rowSource's embed ->
  "rowSource: session_provider.go is reached but isn't in its go:embed",
  FAIL; restored.
- Real accounts on mote (pageheap.sh, page open, CPU at mark):
  w47v first start after an older binary 13.80s, numGC 217 (rebuild,
  expected); w47v again 2.45s; w48v (w47v plus a live init() in
  effort_split.go, a different binary) 2.59s, numGC 56; back to w47v
  2.43s. Before, the same swap cost ~14s.
Not tried: Windows or Linux real start.
2026-11-13 10:09:27 +08:00
yetone 1f4f1874b5 site: a sync page in en, zh and ja
/docs/sync says how magpie keeps computers in sync: what the sealed file
holds (providers and keys, settings, profiles, agents' models, the
library, npm and git plugins, gateway keys) and what it doesn't
(subscriptions' sign-ins), WebDAV (坚果云, Nextcloud, Synology), S3
(R2, B2, MinIO, path-style, OSS without conditional writes) and private
GitHub repos, every 3 minutes with merged conditional writes, Kept on
this computer and Follow the others, and the one-off magpie backup and
restore with AES-256-GCM and PBKDF2-SHA256. Every claim is from
docs/reference.md (Moving to another machine, Keeping machines in sync),
with the labels' zh and ja from i18n.js and the commands checked in
internal/cli/main.go. Linked from each language's start page; in the
sitemap, llms.txt and llms-full.txt.

Run: the three pages' JSON-LD parsed with node; llms-full.mjs rebuilt;
node --test site/*.test.mjs on the WSL box (magpie-desktop, wsl-run):
116 pass, 0 fail.
Not tried: a real WebDAV, S3 or GitHub sync for this page; it names
only what magpie's reference says.
2026-11-13 09:40:15 +08:00
yetone dbb2e5dd29 site: an OpenCode Go and ClinePass page in en, zh and ja
/docs/coding-plans says how magpie serves the two monthly plans for
open coding models in any agent: OpenCode Go's three endpoints as Go's
docs give them, each model sent on the protocol Go serves it on as
OpenCode does (no more "Model does not support this protocol"), old
addresses moved, and its 5-hour, 7-day and monthly windows on Quota;
ClinePass at api.cline.bot with the plan's and Cline's free models from
the list Cline's clients use, the free ones apart from the plan's quota
and asked with the desktop app's headers. Every claim is from
internal/provider (presets.go, opencode_endpoints.go, planquota.go,
cline.go, models.go), with the labels' zh and ja from i18n.js. Linked
from each language's opencode-models page; in the sitemap, llms.txt and
llms-full.txt.

Run: the three pages' JSON-LD parsed with node; llms-full.mjs rebuilt;
node --test site/*.test.mjs on the WSL box (magpie-desktop, wsl-run):
116 pass, 0 fail.
Not tried: a real OpenCode Go or ClinePass key for this page; it names
only what magpie's source says.
2026-11-13 09:06:26 +08:00
yetoneandvincent 363adb3528 plugin: the auth-lock test checks the loop ran while the lock was held, not how often a timer ticked (#5271)
TestAuthLockWaitDoesNotFreezeTheHost counted a 20ms setInterval over a
300ms sleep and wanted 8 ticks. A loaded runner fires the timer late and
counts fewer while the loop is free all the same: 7 of 8 on mote (#5271),
6 on ubuntu CI at f28787b39 (run 43328831902). It measured the scheduler,
not the freeze it is named for.

Ported from skygunner's fork commit 94d8550c8 (on #5271): a setImmediate
registered before changeAuth checks, from the event loop itself, that the
other host's lock is still there and the change not yet written, then lets
the lock go; the test awaits that and the change. A host that waits with
Atomics.wait (#5112) never reaches the check while the lock is held. The
300/600ms sleeps, the tick count and the 5s bound go; the 20 concurrent
changes and the stale-lock takeover are kept as they were.

Run at this tree (origin/main 1e2ce2463 plus this):
- Linux (wsl-run): go vet ./internal/plugin; -count=20 -run of the test: ok.
- macOS (mote-run): the same, ok.
- gofmt -l: nothing.

Broken by hand on Linux: host.js's sleep made a blocking Atomics.wait. The
test went red at 10.1s, "the event loop ran while the other host still
held the lock"; host.js put back.

Not run: the full suite, and Windows.

Co-authored-by: vincent <webmaster@palmit.com.au>
2026-11-13 08:52:12 +08:00
yetone 6af6ae9885 usage: a log of MCP calls and probes keeps its blocks on disk too (#2278)
log-v1.bin was written only once a gateway block had filled. A log of
MCP tool calls and probes has none (the real-account sandbox's 8.3 MB
log is 25,223 MCP lines and 2,539 probes, 54 probe blocks, 0 gateway
blocks), so full.n stayed 0, the file was never written, and every
start parsed all 27k lines again: readLogSnapshot took 60 MB of the
start's allocations. The probes that were kept went as JSON and were
parsed back a record at a time.

A full point is now marked too when a probe block fills while no
gateway row stands after the full blocks, and it records how many probe
blocks were full there (logFull.probes). Those go to the file as binary
entries, as the gateway blocks do, read from its mapped pages; only the
probes after them, up to the full point, still go as records. The file
is written again when its full point reaches further (by offset, not
the gateway block count). The magic is magpie-log-v2, so a v1 file is
parsed over once.

Run:
- go vet ./internal/usage; go test ./internal/usage ./internal/gateway
  (mica, -timeout 45m): ok usage 31s, ok gateway 859s.
- TestStartReadsKeptProbeBlocks (new): an MCP-only log of 3 blocks + 100
  is kept, a start reads 3 blocks from the file, and reads as a whole
  parse. Broken by hand (no probe full point): red, "a log of probes
  wasn't kept".
- Real-account sandbox on mote (acctp, page open 2.5 min, version
  0.1.3961 builds): log-v1.bin written on the first start (645 KB);
  warm starts, w45v (v0.1.3961) against this:
    CPU at mark  3.21s, 3.00s  ->  2.50s, 2.39s
    allocated    701 MB        ->  646 MB, 629 MB
    readLogSnapshot cum 60 MB  ->  2.6 MB
    numGC        66            ->  56
  Footprint 128-133 MB -> 132-135 MB, liveHeap ~80 MB both: the same
  within noise.

Not tried: a log with both gateway and probe blocks across a v1 -> v2
start on a real account (the unit test's mixed log covers the format).
2026-11-13 08:51:24 +08:00
yetone 1e2ce24631 site: a free models page in en, zh and ja
/docs/free-models says how magpie serves free models: OpenCode Zen's
-free models and big-pickle with no key, asked for as OpenCode asks;
Kilo Gateway's :free models with no key, anonymous by IP at 200 requests
an hour, a key for the rest; the free mark in pickers (PricedFree: that
provider's $0 price on every count, not a maker's free tier or a plan's
list, a price the user set wins); free models first in a routing group;
and a deprecated model leaving the lists until answered or a week.
Every claim is from internal/provider (presets.go, kilo.go, models.go)
and docs/reference.md, with the label's zh and ja from i18n.js. Linked
from each language's nvidia page; in the sitemap, llms.txt and
llms-full.txt.

Run: the three pages' JSON-LD parsed with node; llms-full.mjs rebuilt;
node --test site/*.test.mjs on the WSL box (magpie-desktop, wsl-run):
116 pass, 0 fail.
Not tried: a real OpenCode Zen or Kilo request for this page; it names
only what magpie's source says.
2026-11-13 08:32:42 +08:00