Commit Graph
2680 Commits
Author SHA1 Message Date
yetone ac456d819f library: a plugin's tag shows only what that plugin brought (#7280)
Skills, Hooks and Subagents tag a part a Claude plugin brought "In
<plugin>", but nothing on those tabs could narrow to a plugin: typing
its name in the skills' filter found nothing (jinpwng).

- On Skills, Hooks and Subagents the tag is now a button. It shows only
  that plugin's items, under a bar naming it ("Only what code-kit
  brings") with Show all. The pick is per tab and in memory only;
  nothing is written. It clears itself once the plugin brings none of
  the tab's items. MCP keeps the plain tag.
- The skills' filter matches a skill's plugin name too.
- A clickable tag on a library row wraps under a long name instead of
  being cut off by the name's ellipsis. At 420px in zh, zh-TW, ja and
  de the tag was clipped and could not be clicked. This also covers
  "Update available".
- New string in zh, zh-TW, ja and de.

Run (mote, load ~30-45 from other sessions' suites): node --test
library-plugin-filter (new: each tab, tag to bar to Show all, the skills
filter by plugin name, no write, no dialog, no page error; en, zh,
zh-TW, ja and de at 420 and 1100, chromium and webkit), skill-where,
skill-auto-update, skill-update-edited, skill-update-feedback,
phone-no-sideways and library-plugin-parts: 210 of 210 ok. Before the
wrap rule, library-plugins, library-hooks, library-subagents(-import),
skill-groups, skill-parts and i18n-keys were run too. Only
library-plugin-filter's 420 non-English cases failed there (the clipped
tag, now fixed), plus one webkit skill-where "ResizeObserver loop" page
error that passed on the rerun.
Broken by hand: with the tag's onclick setting nothing,
library-plugin-filter is 0 of 62.
Not tried: a real Claude plugin in the app; the faked API has one.
2026-11-20 12:06:44 +08:00
yetone 57c90f9f27 library: a project's claudePlugins and pi read in another build's shapes (#7282)
A library.json whose project had "pi": {"npm:example": ["pi"]} or
"claudePlugins": {"demo@local": true}, as another build of magpie wrote
them, failed the whole library's read ("cannot unmarshal array … pi …
type string"): `magpie library project --json` exited 1, /api/library
answered 400, and no change could be made (jinpwng, v0.1.4573).

- Project.UnmarshalJSON reads claudePlugins as a list or as a map of id
  to on: true is in the list, false is left out, since magpie only turns
  a plugin on and writes nothing for one off. pi is read as source to
  "on"/"off", or to the agents it is for (some: on, none: off), or to a
  boolean.
- A read changes nothing. The first write after such a read keeps the
  file's bytes as library.json.before-reshape (reshapedCopy, never over
  an existing copy; one that can't be made stops the write), then writes
  magpie's shape.
- Any other shape still fails the read, and nothing is written over it.

Run (mote): go test ./internal/library -run
'TestProjectReadsOtherShapes|TestProjectExportApply|TestProjectPi|TestProjectClaudePlugin'
-count=1: ok; the full suite is in the push record.
Broken by hand (mica): with UnmarshalJSON renamed away,
TestProjectReadsOtherShapes is red with the reporter's own error, "json:
cannot unmarshal array into Go struct field Project.projects.pi of type
string".
Not tried: the reporter's own r11 file; a preview of the conversion
before it is written (the kept copy is the way back).
2026-11-20 12:06:44 +08:00
yetone 06db81530e library: a project's choices exported from the CLI and applied at another folder (#7278)
jinpwng asked to carry one project's Library choices, with what they
need, to a new path (a new checkout, another machine) from the CLI.

- `magpie library project export <dir> [file|-]` writes ExportProject's
  JSON (kind magpie-project, version 1): the project's skills, servers,
  subagents, hooks and plugins by agent, its Claude Code plugins, Pi
  packages, servers and skills turned off, and its instructions, plus
  need: each hook's and subagent's definition, each skill's and plugin's
  remote source; a plugin's own hooks and subagents go by their plugin.
  No ownership record (Placed, HookRecs, AgentFiles, PiRecs, ClaudeWrote,
  InstrFiles), key, sign-in or other project goes in; a server goes by
  name only, since its settings can hold a key. The file is 0600.
- `apply <file|-> <dir>` (also `import`) makes the folder a project,
  saves a hook or subagent the library here lacks from the export (for no
  agent of its own), and gives each choice through the setters the page
  uses: the agents the folder has for it kept, the export's added, so a
  second apply changes nothing and the folder's own entries stay. A Claude
  plugin or Pi package the folder has already is left as it is;
  instructions only when it has none. What this library lacks (a skill,
  server or plugin) is named with its source and exits 1; nothing is
  fetched.

Run (mote): go test ./internal/library -run 'TestProjectExportApply'
-count=1: ok; the full suite is in the push record.
Real CLI (built binary, two sandbox HOMEs with stub claude and pi on
PATH): in A, project add, hook bark and subagent checker for claude, Pi
npm:pi-demo, export; A deleted; in B (its own "echo mine" Stop hook in
.claude/settings.local.json) apply saved bark and checker and printed
"has what the export has", a second import printed the same and added
nothing; B's settings.local.json held SessionStart "echo bark" beside
"echo mine", .claude/agents/checker.md was written and .pi/settings.json
listed npm:pi-demo.
Broken by hand: with the hook save in ApplyProject skipped,
TestProjectExportApply is red.
Not tried: the reporter's own projects; a Windows path in an export.
2026-11-20 12:06:44 +08:00
yetone bbac3b5a60 library: Claude Code's own plugins list their skills, hooks and subagents (#7266)
A plugin installed with `claude plugin install` showed nowhere in the
Library's Skills, Hooks or Subagents, and a project's whole-plugin choice
(Library > Projects, Claude Code plugins) named it with nothing of what it
brings (jinpwng, v0.1.4572). ReadNative had readers for Codex and Pi only.

- claudeNative reads Claude Code's installed_plugins.json (v2): every
  record whose installPath is there, user scope as the user's, project and
  local scope with their projectPath. Enabled comes from enabledPlugins in
  the scope's own settings (settings.json, the project's
  .claude/settings.json or settings.local.json); unknown stays unknown.
- Parts come from the plugin's .claude-plugin/plugin.json and Claude's
  default places (skills/, hooks/hooks.json, .mcp.json, agents/*.md), the
  manifest's own paths added; subagents are a new part kind, read with
  the library's subagent reader, a .md with no front matter skipped.
- The GUI lists them read-only on Skills, MCP, Hooks and Subagents with
  plugin id and scope (the project's folder for a project one), and a
  project card's Claude Code plugin row says what the plugin brings.
  magpie writes nothing: Claude Code keeps loading them.
- `magpie library native` names Claude Code too.

Run (mote): go test ./internal/library -run TestNative -count=1: ok.
node --test on 115 GUI files (every library-* and project-* file, plus
builtins, nav, sidebar, phone-no-sideways, i18n-keys and the other files
that reach these tabs), chromium and webkit: 2330 tests, 2320 ok, 10 red. library-open-again is red the same way alone on origin/main 7dc85f26e (#6751); project-pi, library-bili and billion-context were red only under the full run at load ~24 and pass alone.
Real Claude Code 2.1.327 in a sandbox HOME/CLAUDE_CONFIG_DIR: marketplace
add, plugin install at user and at project scope, plugin validate ok;
ReadNative on that record listed both, with their skill, hook and
subagent. Before this change the same record listed nothing for Claude.
Broken by hand: with claudeNative out of ReadNative,
TestNativeClaudePlugins is red; with nativeSection("subagent") and the
parts line out of client.js, library-native and project-claude-plugins
are red (28 fail).
Not tried: the reporter's own plugin.
2026-11-20 12:06:44 +08:00
yetone 4edccb1858 library: an extension-only Pi package is a plugin (#7267)
Library -> Claude plugins -> Look for plugins refused a Pi package whose
package.json declares only pi.extensions ("no plugin"), so a project
couldn't be given it for Pi, while one with a skill imported (jinpwng,
v0.1.4572, Pi 1.5.2).

- readPlugin takes a folder with a Pi package.json, and its name,
  description and version fill what no plugin manifest gives.
- piPackageExtensions resolves pi.extensions as Pi does (a file, a
  folder's index.ts/index.js or each extension in it, a glob, "!" leaving
  one out, nothing outside the package). They count as parts, are kept as
  Plugin.Extensions, and are shown in the probe, the plugin's row and
  dialog, and the project card ("Pi extensions", in zh, zh-TW, ja, de).
- magpie writes nothing for an extension: a project giving the plugin to Pi
  gets the one package entry (#7243's projectPiWanted) and Pi loads it.
  The plugin's user-wide agents give Pi none of it.

Run (mote): go vet ./internal/library; go test ./internal/library
-count=1 -timeout 45m: ok (177s). node --test library-plugins,
project-plugins, i18n-keys, project-pi, library-plugin-parts (chromium
and webkit, en/zh/zh-TW/ja/de, 420 and 1100): 110 pass, 0 fail.
Real Pi: a throwaway test installed the issue's package (extension
registering a command and a no-op session_start) from a folder through
ProbePlugins/InstallPlugins, gave it to a project for Pi, and Pi 1.5.2
--mode rpc --offline --approve listed its command in get_commands.
Broken by hand: with readPlugin's extensions taken out,
TestPiExtensionOnlyPackageIsAPlugin is red (Extensions:0, then no parts to
install). i18n-keys caught "Pi extensions" in a Go error; it says
"extensions for Pi" there.
Not tried: the reporter's own package.
2026-11-20 12:06:44 +08:00
yetone 0e9af21ff3 library: a plugin from a git download keeps one name across updates (#7269)
A plugin at the top of a git or GitHub download was named after the temp
folder it was cloned into (magpie-skill-<random>), so each Update read a new
name and added a second bundle, while the project's .pi/settings.json kept
pointing at the first folder and Pi went on loading v1 (jinpwng, v0.1.4572).

- rootName names the download's top after the repository (file:///x/acme.git
  is "acme", owner/repo is "repo", git@host:a/b.git is "b"); a folder inside
  the download, or a local folder, keeps its own name.
- UpdatePlugin of a one-plugin source installs under the bundle's own name,
  so a bundle a magpie before this named magpie-skill-... is updated in place
  too: same folder, same project assignment, same Pi entry.

Run (mote): go test ./internal/library -run
'TestPluginRootName|TestPiPackageFromGitUpdatesInPlace|TestPluginUpdateKeepsItsName|Plugin'
-count=1 -timeout 45m: ok. Full suite with the batch's last commit.
Real Pi: a throwaway test drove Pi 1.5.2 (npm, --mode rpc --approve) in a
sandbox HOME against a project the Library gave the git package to. With
this change: one bundle "skills" (the repo's name), get_commands acme-v1
before and acme-v2 after Update, settings.json unchanged. Broken by hand:
the same run on origin/main's plugin.go gave bundles
[magpie-skill-332298903 magpie-skill-745278034] and Pi still listed acme-v1
after Update; the two new Go tests were red there too (temp-folder name;
two bundles).
Not tried: the reporter's own repository.
2026-11-20 12:06:44 +08:00
yetone 1ee41113f5 grok: with no size typed, Grok Build compacts at its own 85% of the window (@taktoshilite on X)
@taktoshilite: the Grok config magpie writes says auto_compact_threshold_percent
= 25-something and 50-something, so a 1M model compacts at a quarter of
its window; they asked for ~90%.

Cause: 4f94b8a82 wrote each model's whole window as context_window plus
a percent from Long conversations. Its default is settings.WorkingWindow,
272K (Codex's own window), so a 1M model got 27% and a 524288 one 51%.
Grok Build's own default is 85 (resolve/compaction.rs,
DEFAULT_AUTO_COMPACT_THRESHOLD_PERCENT), 80 for xAI's own models in
default_models.json.

Change: settings.ForAgent("grok") reads magpie's default (no global size,
no Grok entry) as Full window, so no percent is written and Grok Build
uses its own 85% (1M compacts near 850K). A size the user picks still
goes in: a global or Grok-only size writes its percent (900K on a 1M
model = 90), and Grok's own {} entry keeps 272K. A percent typed by hand
in ~/.grok/config.toml is kept as before (grokOwnPercent). The stale 27/51
magpie wrote is dropped on the next sync, since the stash marks it as
magpie's. CLI (`magpie model compact`) and the Grok Build sheet say Grok
compacts at its own threshold; sub text translated into zh, zh-TW, ja, de.
docs/subsystems/agent-wiring.md says so.

Tests:
- TestGrokCompactsAtItsOwnPercentByDefault (internal/agent): catalog
  windows 1M and 524288, an old config with magpie's 27/51; default
  writes none, Grok {} gives 27/51, 900K gives 90, a hand-set 90 stays.
- TestGrokFollowsItsOwnThresholdByDefault (internal/settings).
- grok-compact.test.cjs: Grok sheet shows Full pressed, posts own at on a
  click, 900K shows 900k; Claude's row unchanged; en/zh/zh-TW/ja/de,
  Chromium + WebKit, 900px and 420px.

Run (mote, at e702accf9's tree on origin/main 64ae6e206):
- Red on the old code: with settings.go and model_cli.go from 64ae6e206,
  the agent test fails "magpie's default: big 27%, mid 51%" (the
  reporter's numbers) and the settings test fails at "default".
- go test -count=1 -tags nogui ./internal/settings ./internal/agent
  ./internal/cli ./internal/provider: all ok (agent 288s, provider 170s)
- go vet (those packages), GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: clean
- gofmt -l: clean.
- GUI: grok-compact, agent-compact, i18n-keys, agent-prefs, compact-at
  pass; agent-details-ready 32 of 36 red, the same 32 at 64ae6e206
  alone ("ends ~80px short and jumps", #6373).

Not tried: a real Grok Build conversation compacting at 85% on a 1M
model; the full Go suite (mote and mica were over their cores).
2026-11-20 12:03:55 +08:00
yetone 6d46859c48 provider: a relay key bills at its sub2api group rate times the provider's top-up rate (@YIXIE233 on X)
@YIXIE233 has several sub2api relays. Each reports a key's group rate at
GET /v1/sub2api/billing, and each sells its dollars at its own price (¥1
for $1 at one, ¥7 for $100 at another). Until now every key's rate was
typed by hand and typed again whenever a relay changed its prices.

Now a provider of API keys has a "Top-up rate" under Advanced, next to
Price rate (TopUpRate: above 0 up to 1000, at most four decimals). With
one set, the gateway's KeepKeyRatesRead asks each key's relay for its
rate in the background. It reads at start, every 6h, 30 min after a
failed read, and at once on a save that sets a new top-up rate. It is
never on a request's path. The relay asked is the origin of its sub2api
key query, else of its first base; loopback and vendor hosts are never
asked. Readings go to key-rates.json beside providers.json.

A key then bills at group rate x top-up rate, and that rate reaches both
places a price is used: PriceAt (Cheapest/By price routing) and
BaseKeyPriceIn (the ledger, Usage, spend caps). A group rate of 0 prices
at 0 (zeroRate), not at the list price.

- A key's own KeyPriceRates still wins.
- A key never read, or whose reads all failed, is unknown and bills at the
  provider's PriceRate, never 1x.
- A failed reread keeps the last rate it read.

The Usage caches key on a hash of the rates read, so a reread that finds
the same rates keeps them. /api/providers lists keyGroupRates, which the
editor names under the box. An empty per-key line's placeholder shows
group rate x top-up rate. `magpie provider key-rate` lists both. i18n:
zh, zh-TW, ja, de. Not counted yet: sub2api's peak-hour multiplier
(#7286).

Run (mote, via mote-run):
- At 7dc85f26e, before the rebase: go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet
  ./...: ok. gofmt -l: nothing.
- go test -count=1 ./internal/provider ./internal/cli ./internal/usage:
  ok.
- go test ./internal/gui: two reds, TestBuiltinsTranslated (a Routing
  string in zh/zh-TW/ja/de) and TestSettingsSaveKeepsWhatItDoesNotSend
  (RedactModelDir). This change doesn't touch either; checked against
  origin/main below.
- The box's code lives in the lazy keyrates.js (loaded for a provider of
  keys of its own too, keyRateField's new `on`). The top-up rate rides
  keyPriceRates(ed, body), and keyPriceRates gives undefined when no
  per-key lines were drawn. With that, app.js stays under
  TestCoreScriptBudget with no raise (a first cut was 261 bytes over).
- go test -run 'CoreScriptBudget|TopUpRate|KeyPriceRate|I18n|Translated'
  ./internal/gui at the rebased head (c2924c36d): ok except
  TestBuiltinsTranslated (#7257). That test and
  TestSettingsSaveKeepsWhatItDoesNotSend (#7240) fail the same on an
  archive of origin/main c2924c36d.
- node --test top-up-rate, key-price-rate, provider-price-rate and
  old-webkit .test.cjs (Chromium and WebKit, en/zh/zh-TW/ja/de): 62 pass,
  2 fail. Both fails are old-webkit (guideback.js imported by navpages.js,
  the class of #6570, and Safari 15 styles, #7235), and they fail the same
  on origin/main c2924c36d.

Broken by hand: with readKeyPriceRate turned off and zeroRate dropped
from tariffOf, TestKeyGroupRateTimesTopUpRate, ...FailedReadIsUnknown and
...Zero go red ($1.8 where $0.14 was wanted); green again once restored.

Not tried: a real sub2api relay. The fixtures are sub2api's own reply
shapes from backend/internal/handler/gateway_key_billing.go (schema 1),
served by httptest.
2026-11-20 11:39:44 +08:00
yetone c2924c36d4 gui: Settings left blank after a restart say why and are read again; a view entrance plays out of sight (WaiooT on X)
WaiooT on X, v0.1.4573 on the Mac: after Restart only or Restart to
update the window came back on Settings › About with nothing under the
header and sidebar.

Two ways the page leaves that pane blank, both fixed:
- Every page of Settings is drawn from one read of /api/settings. One
  that failed (a magpie just restarted still starting, or its read
  erring) left them all empty, and only the footer said why, for 8 s;
  nothing read them again. The view now says "Couldn't read the
  settings" with the reason and Try again, and reads them again by
  itself at 2, 4, 8 s up to every 30 s; the line goes once they are
  read. It lives in settingsunread.js, imported only when a read fails,
  so app.js stays under its budget with no raise (TestCoreScriptBudget
  ok). Words in zh, zh-TW, ja and de.
- A page out of sight (the Mac's window hidden, #4293) paused every CSS
  animation, a view's one-shot entrance too, so a view shown then sat at
  its first frame, opacity 0, until the page heard it was back. A view's
  entrance now plays out of sight (app.css), and a page told it is back
  finishes any view entrance still running (playViews).

Run (mote):
- settings-unread.test.cjs (new): 14 pass at this tree, both engines,
  en/zh/ja; on the old app.js, app.css and i18n.js all 14 red (no line,
  About empty; the out-of-sight view's opacity "0").
- settings-*.test.cjs, window-visibility, window-asleep, version-restart,
  i18n-keys, i18n-en-no-cjk, old-webkit, panel-units-follow,
  sidebar-settings-steady and refresh-page, both engines: 510 pass, 2
  red, both old-webkit and both red on the base 76b490576 as well:
  guideback.js unlisted (#6570) and a :has() in app.css (#7235).
- go test ./internal/gui -run 'TestCoreScriptBudget|TestI18n|TestAssets'
  ok.
- A real restart of a built magpie in a sandbox HOME (POST /api/restart,
  the handover, the new window's page reporting back): /api/settings
  answered in ~2 ms and About drew 18 rows, so an empty sandbox config
  didn't reproduce it; the new page's view did read opacity "0" while
  its window was out of sight.

Not tried: a visible window on a real Mac (over ssh the window never
shows), so which of the two the reporter met is not confirmed; the
reporter's own config.
2026-11-20 11:27:11 +08:00
yetone 6e6da86c81 gateway: POST /v1/responses/compact is relayed to a provider whose own API is Responses (#7281)
Pi's Responses compaction extension sends OpenAI's unary
POST /v1/responses/compact. Before this change, the generic route
answered it with the 404 for an unknown path and never reached the
upstream.

/v1/responses/compact and /responses/compact (responses_compact.go)
now go through serveAgent and serve, so the key, account and model
holds apply as they do on /responses. The request is marked unary
compact, and the candidates are cut to a key's provider that asks the
model on Responses (compactsUnary: no account, carriesCompaction).
attempt relays it as it came (keep, never translated), and passthrough
sends it to <Responses base>/responses/compact. The unary
response.compaction object goes back untouched, sealed item included.
compactionWatch records who wrote the sealed item, so a later
/responses that carries it goes back to that provider (#1099). The
call is recorded as KindCompact. When no candidate is left, the client
gets a 400 invalid_request_error: "/responses/compact is not supported
for <model>: ... compact on /responses instead". This follows the
CodexPath wording and gives the client a fallback. handle's
codexCompact branch is not on this path, so an earlier compaction item
in the input stays the client's. protoOfPath shapes key-limit errors
on the route as Responses errors.

Not changed: ChatGPT, Copilot and plugin accounts are refused on this
route until a real account is tried (#7285). Codex's own compact still
goes through CodexPath.

Run (mote, at this tree):
- the new TestResponsesCompactRelayed and
  TestResponsesCompactRefusedOffResponses: red on origin/main 7dc85f26e
  (404 not_found_error, both paths), green here.
- go test ./internal/gateway -run
  'TestResponsesCompact|TestCodexCompactionTriggerOnV1|NativeCompaction|KeyLimit':
  ok.
- go vet ./internal/gateway on darwin, linux and windows: ok. gofmt -l:
  clean.
- go test ./internal/gateway -count=1 -timeout 45m: started at this tree
  and not finished at push. The result will go on #7281.
Not tried: a real Pi compaction against a real Responses upstream.
2026-11-20 11:20:46 +08:00
yetone 76b490576f docker: the image runs on Debian 13, so an npm package's glibc 2.38 binary starts
Passings_z on X: an MCP server in the Library never started in the
Docker image, and the hub tried it again every minute. The server is
arcane-rmcp (dinglebear-ai/rarcane): its npm launcher runs a Rust
binary linked against glibc 2.38, and the image was debian:12-slim with
glibc 2.36, so it died at once with "GLIBC_2.38 not found" and npx
exited 1. The runtime base is now debian:13-slim (glibc 2.41) and Node
is taken from node:24.22.3-trixie-slim to match. ca-certificates, curl,
groupadd/useradd and bash are all in trixie under the same names. The
Docker docs (en, zh, ja) and docs/reference.md say Debian 13; the
search indexes and llms-full.txt are rebuilt (node docs-index.mjs).

The hub already shows the reason: the Library's check reports "exited
(1)" with the server's last stderr line, which here is the GLIBC line,
so nothing there changes.

Run (linux/amd64, podman 4.9.3 in the magpie-desktop WSL distro):
- built the image from this tree; ldd --version says 2.41, Debian 13.7
- `npx -y arcane-rmcp --version` (from npmmirror: npmjs unpublished it
  on 08-03): ghcr.io/yetone/magpie:latest (glibc 2.36) exits 1 with
  "version `GLIBC_2.38' not found"; the new image prints
  "rarcane 0.4.4", exit 0
- docker.yml's smoke steps by hand: serve answers on 3425 (401 for a
  keyless request from the host, as podman's network makes it remote),
  magpie healthcheck ok, node v24.22.3, npm/npx 11.19.1, uv/uvx 0.13.7,
  python3/python/curl on PATH as nonroot (65532), chat/completions 401
  with an error JSON, `provider add` into the volume works
- mote: node --test search/worker/docker-tags (50 pass), go test
  ./internal/testenv (docs-index sums) ok

Not tried: linux/arm64 (no emulation on the Linux box, no docker on
mote or mica); docker.yml builds and smoke-tests it on a native arm
runner. A volume made by the Debian 12 image was not reused across the
upgrade by hand; uid 65532 and the /config layout are unchanged.
2026-11-20 09:55:43 +08:00
yetone 4716a77ff9 library: a plugin that is a Pi package, given to a project for Pi, is one entry of its .pi/settings.json (#7243)
A library plugin whose folder has a package.json with a `pi` object, given
to a project with Pi among its agents, is now a wanted package of the
project (projectPiWanted): its library folder, written as one entry through
the same pipeline as a package given by source (#7249). Applied again it
stays one entry; withdrawn (or the plugin turned off or removed) only the
entry magpie wrote goes. A declaration the project has of the same folder,
filtered or not, is left byte for byte and not reported, as it loads already.

Run (mote): gofmt, go vet, go test ./internal/library (ok); the new
TestProjectPluginPiPackage covers not-for-Pi, reapply, another project
untouched, withdraw, a filtered native entry byte for byte, and withdrawal
beside the project's other packages.
Not tried: a real Pi resolving the package's skills and extension.
2026-11-20 05:57:12 +08:00
yetone 54b9516473 library: a project's Pi packages, on, off or removed, and adopting its own (#7249)
A project now takes Pi packages: entries of its .pi/settings.json
`packages`, matched by piSourceID. A package is on (its source), off but
kept (every filter empty, as `pi config` writes it) or removed. Project.Pi
is what the project wants, PiRecs what magpie wrote; only an entry still as
magpie wrote it is changed or taken out, and a file magpie made goes with
its last entry. An entry the project had is its own: refused with a problem
until adopted, then switched without a rewrite, and put back as it was (never
deleted) when let go; one that picks some resources is refused.

Surfaces: POST /api/library/projects/pi (how on|off|removed|adopt),
`magpie library project pi [list|add|on|off|rm|adopt] <dir> <source...>`,
the project's own packages in Own["pi"], and a Pi packages block on the
Claude plugins tab's project card (switch, remove, Take over, add field) in
en, zh, zh-TW, ja, de. Pi installs a package itself when it next starts.

Run (mote): gofmt, go vet; go test ./internal/library ./internal/cli
./internal/gui (library, cli ok; gui red only in TestBuiltinsTranslated
#7257 and TestSettingsSaveKeepsWhatItDoesNotSend #7240, both filed);
GUI project-pi (new), project-own, project-plugins, project-hooks,
project-claude-plugins, project-servers, i18n-keys in chromium and webkit.
Not tried: a real Pi starting in a project with these packages; the whole
GUI suite; Windows.
2026-11-20 05:46:18 +08:00
yetone cfe006ea0f library: a Codex plugin's manifest is read like a Claude Code one, and its hooks go to Codex (#7255)
A folder with .codex-plugin/plugin.json is a plugin now. Its skills and
mcpServers are read like Claude's manifest fields (Claude's win where both
name one). The hooks it names (a path, a list of paths or inline) are
Codex's own: kept as written as codex:<Event> hooks with their matcher and
given to Codex alone, so .codex/hooks.json gets them and Claude's settings
do not. An event Codex has none called (codexHookSpec's native list, from
codex-rs/hooks) is left out and said. A manifest's mcpServers naming
./.mcp.json no longer reads that file twice. Codex 0.165's binary names
.codex-plugin/plugin.json and resolves plugin.json#hooks; the shape matches
hooks/hooks.json.

Ported in outline from Arobotmaster's 874624ed, not its code: that commit
also changed session-start matchers and put env on script hooks, which are
other goals.

Run on mote: gofmt, go vet ./internal/library, go test ./internal/library
and ./internal/cli (whole packages, ok); new TestPluginCodexManifest (probe
counts, Codex gets the hooks, Claude gets none, remove takes them out).
Not tried: a real Codex plugin from a marketplace (Codex marketplaces are not
read), a plugin with both manifests naming different hooks, Codex actually
running the carried hooks.
2026-11-20 05:28:25 +08:00
yetone 8de4669fb6 library: hooks reach DeepSeek Harness through its Claude Code hooks plugin (eiyuuzaki2333 on X)
DSH was the one Library agent with no Hooks. Its plugin
@deepseek-ai/dsh-hooks-claude-code runs a Claude Code hooks.json on dsh's
interception points, so a hook given to dsh is written to
$DSH_HOME/magpie-hooks.json (Claude shape, dsh tool names bash|pwsh and
write|edit|str_replace_editor, the events the bridge runs). Each profile gets the
plugin and @deepseek-ai/dsh-hook-protocol installed at dsh's own version
(`dsh plugin --profile <name> add`), then one marked magpie-hooks insert row.
No row is written, and any magpie row is taken out, while the plugin isn't
there (a user removed it, or the install failed): dsh leaves out a row whose
plugin is missing, and a deny hook would then allow everything. A user's own
row for the plugin is left alone and said. Failed installs retry after 10 min.

Not supported by dsh, so left off (named in docs/subsystems/library.md):
subagents, slash commands, rules, env, project MCP/hooks, Claude plugins.

Run:
- real dsh 0.2.2-rc.5 on mote, sandbox HOME, fake model server: bash call
  denied through the bridge with the hook's reason shown to the model;
  without @deepseek-ai/dsh-hook-protocol the row fails to import (hence both
  packages are installed).
- mote: go test ./internal/library ./internal/agent -count=1 ok (before the
  removed-plugin fix); go test ./internal/library -run Hook ok after it;
  GOOS=windows, GOOS=linux and native go vet ./internal/library ok; gofmt -l clean.
- GUI library-hooks, project-hooks, library-rtk-nohook (12 tests, each
  covering en/zh/zh-TW/ja/de at 440px) in chromium and webkit: 12/12 both.
- New tests: TestHooksDsh*, red on the old code (dsh was no hook agent).
  The hooks page is driven by hookAgents, so no GUI change was needed.

Not tried: the full magpie sync against real dsh (full sync not run against
real dsh: the row format was written by hand and loaded by real dsh, the
install is faked in tests); Windows and WSL dsh; a dsh older than 0.2.2-rc.5;
session-start narrowing (dsh's source names unknown). Full suites run after
the tag.
2026-11-20 05:10:42 +08:00
yetone 4ff57b8cbf library: a project's own resources are listed apart from what magpie placed, with a source in the CLI's --json (#7245, #7247)
ProjectView.Own reads, per kind, what the folder's own files already give
agents and magpie didn't write: skills in the skills folders, servers in
each agent's project MCP file (name and transport only, never URL, args or
env), hooks in .claude/settings.json, settings.local.json and
.codex/hooks.json (an entry is magpie's when it equals a HookRecs entry),
and subagent files whose hash isn't in AgentFiles. Read-only: a link out of
the folder or a file that can't be read is left out. The cards show them
under "Project's own", no chips. `magpie library project server|hook|subagent
<dir> --json` gains `items`, each with source "magpie" or "project"; the old
maps stay as they were.

Not done: Claude plugins, Pi packages and instructions are not read as the
project's own yet; the cards have no "Assigned by MagPie" heading, the
chips already say it.

Run on mote: gofmt, go vet library, cli, gui; go test ./internal/library and
./internal/cli (whole packages, ok); new TestProjectOwnResources and the CLI
source check; GUI project-own (new), project-hooks, project-servers,
project-skills-*, project-plugins, i18n-keys in both engines, then every
library-* and project-* file once: library-bar-more went red in that run and
green alone (load, not filed: it did not touch this change).
Not tried: a real project with hundreds of skills (the read is on every
state poll of a project folder).
2026-11-20 05:05:17 +08:00
yetone 1e174f8f9f library: a project gets a single hook, for the agents that read a project's hooks file (#7253)
A project had hooks only through the plugins it took. Now the Hooks tab
lists the projects, and a hook can be given to one on its own, per agent
(Claude Code and Codex; Pi, Goose and the rest read no project hooks
file). Project.Hooks feeds projectHooks, so the write and the HookRecs
ownership records are the ones plugins' hooks already use: withdrawing
removes only what magpie wrote, never the user's own entries. Worktrees
follow through syncTrees; renaming or deleting a hook in the library moves
or drops its project entry. CLI: magpie library project hook.

Also fixes the CLI's problem keys (they lacked the kind prefix for mcp and
subagent) and the empty-project count in syncTrees, which now counts
Hooks and ClaudePlugins.

Run on mote: gofmt; go vet library, cli, gui; go test of the TestProject*,
TestHook* and TestLibraryProject* tests in internal/library and
internal/cli; GUI project-hooks (new, chromium and webkit, en and zh),
project-plugins, project-claude-plugins, i18n-keys. 14 other library GUI
files were red on this base with "nativeView is not iterable"; origin/main
has 03ae057b8 for that, rerun after the rebase.
Not tried: a real Codex or Claude session reading the written files.
2026-11-20 04:36:59 +08:00
yetone b6b6ba752e routing: an account's seat on the stage tells every window it has, under its status (YujunT46308 on X)
The stage's seat said one share and drew a bar; the other windows were only
in its tooltip, so the reader went to Usage to see what was left. Under the
status the seat now lists every window the account has, worded by the Usage
page's own winParts (short name, used or left per the quotaLeft setting,
when it starts again; counts such as "355 / 500 credits" come with
quotaText), each with its full reset time on hover. No new colours, no
motion, no new strings: it wraps on a narrow stage.

Honest about unknown: a seat with no card of its own, or whose read failed,
shows no windows (its status already says so); a wallet's balance stays its
status; the window the status already says is not told twice.

Run (mica, tree at this change rebased on origin/main 03ae057b8):
- routing-seat-wins.test.cjs: 22 of 22 in chromium and webkit, 5 languages,
  1100 and 420px. Broken by hand (line returning no windows): 11 red in
  chromium.
- routing-*, panel-routing*, i18n*, ctx-route* GUI files (207 files, both
  engines): reds were routing-mode-goes (stale since 9ec023a46, fixed in the
  next commit) and routing-pin-away (red on origin/main too, #6512).
- go test ./internal/gui -run 'TestCoreScriptBudget|Asset|I18n|Script': ok.
Not run: the whole GUI suite (both machines already had one running, one
suite per machine); WebKitGTK/Linux app; Windows.
2026-11-20 03:59:43 +08:00
yetone 82611c3c9e library: a project turns on a plugin Claude Code installed, in its own settings (#7254)
Plugins Claude Code has installed itself (installed_plugins.json) are listed
on a project's Claude plugins tab, each with one Claude chip. On writes
enabledPlugins.<id> = true into the project's .claude/settings.local.json
through the format-preserving JSON edit (comments and the user's keys stay);
off takes out only a key magpie wrote that is still true. A key the user
already had is neither written nor taken out; a file magpie made goes once
the skill offs, hooks and plugin keys sharing it are all gone. Worktrees
follow through syncTrees; RemoveProject lets go. Written fresh, not ported.

Run (mote-run): go vet library/gui/cli; go test ./internal/library -run
TestProjectClaudePlugin (new, two tests); project-claude-plugins,
project-plugins and i18n-keys GUI files in chromium and webkit, en and zh;
go test ./internal/gui reds only on testenv's docs-index guard
(routing-groups pages newer than the search index, not from this change).
Not tried: a real Claude Code reading the project's enabledPlugins; the
whole GUI suite; a CLI for it; "off" for a plugin the user turned on
user-wide.
2026-11-20 02:49:50 +08:00
yetoneandArobotmaster ab342fa40d library: magpie library project server and subagent add, rm and agents (#7248)
The CLI had project skills and instructions only. `server` and
`subagent` now list, add (agents= or the agents already used, else every
agent here that reads a project's MCP file or subagents folder), take
out and re-point a project's library servers and subagents through
ProjectServer and ProjectSubagents, the calls the Library page makes.
A name the project doesn't have is refused, as is an unknown agent or
flag; a part magpie couldn't place exits 1 with why.

The command shape follows the reference commit in the reporter's fork
(0d3a6de55), rewritten over this tree's calls rather than ported.

Run: mote-run go test ./internal/cli -run TestLibraryProject (the new
TestLibraryProjectServerAndSubagentCmd: the user's own .mcp.json server
survives an add and an rm, Codex's file gets the server, Claude's and
Codex's subagent files come and go with their agents). gofmt and go vet
./internal/cli clean.
Not tried: the whole Go suite; the package run also prints testenv's
docs-index guard (routing-groups pages newer than the search index),
which is not about this change; a real agent reading the files.

Co-authored-by: Arobotmaster <50254754+Arobotmaster@users.noreply.github.com>
2026-11-20 02:40:53 +08:00
yetone 6d153bffca library: list the skills, MCP servers and hooks of plugins installed natively in Codex and Pi (#7244)
The Library now reads Codex's plugin cache (plugins/cache/<marketplace>/<plugin>/<version>,
manifests under .codex-plugin, .claude-plugin or .cursor-plugin; config.toml's
enabled flag) and Pi's packages (settings.json packages, package.json pi.skills,
user and project scope) and lists what they bring on the skills, MCP and hooks
tabs under "Installed in the agents themselves", with origin and scope.
Read-only: nothing is copied, linked or registered; the agent keeps loading it,
load status stays unknown. Paths stay inside the plugin; an unreadable file
means unknown. New GET /api/library/native (lazy, not on the polled
/api/library) and `magpie library native`. Docs row in library.md.

Run (mica, sandbox HOME, nothing of the live ~/.codex or ~/.pi touched):
- go vet darwin; internal/library native tests (6) and the new GUI test
  library-native.test.cjs in chromium and webkit, 5 languages, 980 and 380 px.
- Built binary against a sandbox copy of the real Codex cache manifests (74 files).
- Not tried: Claude native plugins, subagents, Pi MCP and hooks, a live Codex
  or Pi, Windows and WSL Pi. The whole GUI suite and the full Go suite run after the push.
- Not mine: every package using testenv is red on origin/main 9ec023a46 from the
  stale docs index (docs/routing-groups.html and its ja/zh copies; its author is
  regenerating it), so go test of internal/library and internal/gui fails there
  before and after this change. TestEveryRouteHasACommandOrIsNamed named the new
  route; settings_parity_test.go now maps it to `magpie library native`.
2026-11-20 02:34:58 +08:00
yetone 9ec023a46b routing: the default routing is called Quota first, not Smart (@canlee886)
The groups magpie finds on its own (auto/<model>) hold one model served by
several providers, and with no rules they follow their Routing, whose
default was labelled Smart / 智能. @canlee886 read that as "judges how hard
the task is and sends easy ones to a cheap model". It does not: the member
whose allowance renews soonest goes first, ties in list order, the next takes
over on a failure.

A cheap-model rule cannot be a built-in default for these groups: their
members are the same model, so there is no cheaper member to send an easy
request to. The mechanism for hard-to-strong, easy-to-cheap exists (the
"Hard to strong, easy to cheap" template and rules with an intent) but it
needs members of different strength, which the user picks. So the honest fix
is the label.

- The mode is "Quota first" (额度优先, 額度優先, 枠優先, Kontingent zuerst) in
  every picker, chip, tooltip and hint, in all five languages (the English
  key text and each translation).
- The no-rules line now says it does not judge how hard a task is.
- docs/reference.md, gateway-routing.md and the routing-groups site pages
  (en, zh, ja) name it the same. The stored value ("") is unchanged, so no
  saved group or provider changes behaviour and nothing needs migrating.

Run (mica, node --test, chromium and webkit, five languages): 19 GUI files
(routing-rule-example, routing-save, routing-group-strategy, routing-manual,
routing-weight-chip, rotate-figure, account-weight, routing-key-windows,
routing-free-expiring, builtins, i18n-keys, i18n-en-no-cjk and the routing
Smart-text files): 440 of 446 pass. The 6 reds (account-arrange 1 and 2,
key-weight 17 to 20) fail identically on origin/main 87a933e50, filed
separately. The tests assert the new label and hint; run against the old
assets they fail on the old text. Not run: the full Go suite and the full GUI
suite (run after the tag); not tried in the Linux WebKitGTK app.
2026-11-20 01:56:08 +08:00
yetone f534245f1c routing: a group with no rules says how it routes (@canlee886 on X)
The editor said nothing of what a group does with no rules. Without rules
the group goes by its Routing (Smart unless set): the member whose
allowance renews soonest first, ties in the listed order, the next taking
over when one fails. One line under Rules now says so (and names the
routing when another is set); with one model or Manual the existing line
stays. Added in zh, zh-TW, ja, de. Layout unchanged.

Run on mote at the change: routing-rule-example (extended: the line in
every language, Smart and In order, gone once a rule is added; Chromium
and WebKit, 1100 and 390 wide), routing-advanced, routing-rule-ops/
remove/drag/columns/models/effort, routing-entry, routing-intent-entry,
group-editor-fits/align, group-template, i18n-keys: all pass.
Not run: the whole GUI suite, Go (no Go changed), the real app.
2026-11-20 00:27:35 +08:00
yetone f7173c79a3 codexcat: another magpie's ChatGPT model is Codex's own, given this Codex's entry for it
A remote with no Codex cache of its own (a server) builds its entry from
the bundled instructions, so office/codex/gpt-6-astra still lacked the
backend's model_messages and fields. OwnSlug takes an id ending in the
entry's codex/<slug> as Codex's own: entriesAt gives it this computer's
models_cache.json entry, as a local account's codex/<slug> gets, and
OwnIn keeps it in the Codex app's first list (gateway catalog too). A
relay's plain gpt-6-astra is not taken.

Run (mote-run, rebased head): TestRemoteChatGPTModelIsCodexOwn red with
OwnSlug turned off (description "GPT-6-Astra via magpie", OwnIn false),
green now; the codexcat, provider, gateway and gui runs, gofmt and the
three vets in the commit before. e2e with a models_cache.json in the
local CODEX_HOME: description "Frontier intelligence for the most
demanding work." and model_messages present, codex exec FAKE-OK.
Not run: the full suite (next, at the pushed head); a real ChatGPT
account behind a real remote.
2026-11-20 00:12:59 +08:00
yetone 958d4fcaf1 pii: the local models' folder is chosen under Advanced, and Move… moves them (MetalHqa on X)
On Windows both models (Privacy Filter 1.6 GB, AstrLink Guard 39 MB)
went onto the C: drive with no way to choose. Settings > Privacy now has
Advanced > Models folder: Move… picks a folder in the system's picker and
moves what is downloaded there; Move back returns it to magpie's cache.
The default is unchanged.

- settings.RedactModelDir is this computer's own (kept by KeepOwn, never
  set by a settings save).
- pii.Root() is the one place every path is made from (dir, guardRoot,
  so the model, its cache files, pf-serve, the CoreML program).
- pii.MoveTo: a rename on one disk, else a copy checked by sha256 read
  back; the setting switches after it and the old subfolders are deleted
  last (never the picked folder); a failure puts back what it moved and
  keeps the old copy. Refuses a relative path, an unwritable folder and
  one inside what is moved. A picked folder that has gone (disk
  unplugged) is not recreated by a download. Download and Remove wait
  out a move.
- GUI: pmfolder.js, loaded on first draw so the core script is no bigger;
  strings in zh, zh-TW, ja, de. Docs: gateway-routing.md, masking.html
  (en, zh, ja), site index regenerated with docs-index.mjs.

Run (mica; mote had no room, load 35/18 and 29/12):
- go test of internal/pii folder tests, internal/gui TestPrivacyModel*,
  internal/settings and settingsapi keep tests: ok. Each broken by hand
  and red: guardRoot ignoring the folder, no rollback, no missing-folder
  check, KeepOwn line removed, settingsapi line removed, folder action
  not calling MoveTo.
- Windows box (win-run): the move tests ok, TestMoveAcrossDisks on a real
  C: to D: move ok.
- GUI privacy-model.test.cjs, Chromium and WebKit, 5 languages, 1100 and
  640px: 104 of 104.
- go vet on pii, gui, settings, settingsapi for linux (nogui), windows
  and darwin: clean. node --test site/*.test.mjs: 135 of 135.

Not run before this push: the whole GUI suite, go test ./... (both
follow at the pushed head), the size-budget and i18n tests (run after the
rebase), gofmt over the whole tree (touched files only), and a real
Privacy Filter download into a picked folder on a real account.
2026-11-20 00:12:34 +08:00
yetone 83bb079dee gui: the scroll capsule sits above Plugins' install box and the Library's save and pick bars, not over Install (WaiooT on X)
scrollends.js lifted the capsule above only .after-list and .view-foot. Plugins > Discover's .pm-manual (and the Library's .lib-savebar, .lib-pickbar) are held at the window's foot too, so the capsule covered the Install button's right end. They are now in the list it steps over. No layout change.

Run (mica, copy of this tree): new view-ends-install-bar.test.cjs red on the old scrollends.js (390px: capsule over pm-browse, pm-minput and Install, all 12 subtests) and green on the new one (12 of 12: chromium and webkit, en/zh/zh-TW/ja/de, 390/560/980/1280 wide); with only the Library classes removed it is red at lib-savebar. go vet ./internal/gui/... and GOOS=windows go vet, gofmt -l clean. view-ends, view-ends-relayout, routing-editor-foot, plugin-manual-float and i18n-keys: 78 of 80 together; the 2 are webkit view-ends' first subtest (en 440 light) timing out at 8s in that batch, twice, while view-ends.test.cjs alone under BROWSER=webkit is 16 of 16 on this tree and on origin/main.

Not run: the whole GUI suite and go test ./... (mica held by another session's full GUI suite, mote at load 46; to be run at the pushed head), the Library's own bars with real fixtures (stand-in sticky bars of each class are used), the real Linux app.
2026-11-20 00:08:39 +08:00
yetone f288cc61af sessions: a deleted Grok Build session's index rows come back with its restore (#4595)
Follow-up to crayonlu's commit (Grok Build sessions deletable, their
session_search.sqlite rows dropped first). Review of that commit:

Sound: the delete is scoped to the session's own folders (updates.jsonl's
dir, plus its subagents' sibling folders grokFiles already folds in); the
cwd's prompt_history.jsonl and other sessions stay. The index is opened by
a normal connection with a 5 s busy timeout and BEGIN IMMEDIATE, so it
works beside a running Grok Build (WAL, the file's journal mode is left as
it is); a file that can't be opened or read stops the delete before
anything moves (failed read = unknown); no index or no tables deletes as
before. Nothing touches the network, no new dependency, no .github/site.
Checked against Grok Build 1.0.67 itself (its binary's SQL and the index
it wrote on this machine, copied, never opened live): session_docs has
session_id, cwd, updated_at, title, content, content_hash, over
session_docs_fts with the _ai/_ad/_au triggers; there is no
DELETE FROM session_docs in the binary, so Grok has no delete of its own
to match.

Wrong or thin: Restore did not put the index row back, and Grok Build's
bootstrap is stamped in meta.last_bootstrap_at, so nothing says it indexes a
restored folder again; a move that failed after the rows were gone
left the session whole but unindexed. Now grokSearchRowsDrop returns the
rows, every column by name (so a Grok Build that adds a column keeps it),
and Delete keeps them in the trash entry's grok_search.json (not in the
note the Trash page lists). Restore INSERT OR IGNOREs them (a row Grok
wrote again meanwhile wins; an unwritable index doesn't stop a restore),
and a delete that stops after dropping them puts them back.
TestGrokDeleteRestore now checks the rows and FTS entries are back;
TestGrokSearchRowsComeBackWhole checks every column and the kept row.
Broken by hand: Restore without the put is red on "after the restore: 0
rows and 0 found".

Run (mote, worktree of this branch; full suite at rebased 0a37c9368 base,
go test -count=1 -timeout 45m ./..., log kept): every package ok except
internal/gateway (TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes, red on
a pristine origin/main 0a37c9368 too: #7117; a doneHold panic, #6505/#6690)
and internal/gui (TestGatewayPauseRollsBack, TestGatewayPauseFileUnreadable:
TempDir cleanup "directory not empty" only inside the parallel full run,
filed #7232; ./internal/gui alone is ok on origin/main 0a37c9368 (158 s) and
on this branch (174 s)). Neither touches sessions. gofmt -l clean; go vet
(darwin), GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...
clean. The Grok tests also pass on Windows (win-run) and WSL (wsl-run),
real SQLite files in WAL mode in all three. After the last rebase (onto
04e62892e; three library/gateway commits, none in sessions or gui) the
sessions/... (60.8 s) and gui (171.8 s) packages were run again at the
pushed head: ok.

Not tried: a real Grok Build deleting or re-indexing a session itself, and
the real index here was only read from a copy. Still not deletable on the
Sessions page (#4595 stays open for them): Hermes, Alma, OpenCode, ZCode,
Cline, Kimi Code and Claude Desktop (Cowork).
2026-11-20 00:00:52 +08:00
crayon 6671091676 sessions: Grok Build's sessions are deletable, its search index's rows going with them (#3003, #4595)
#3003 (acsfreerun) asked for a Delete on Grok Build's sessions; #4595 kept
them listed with no Delete, because a session is a folder but Grok Build
copies each session's text into $GROK_HOME/sessions/session_search.sqlite,
which a folder delete would leave behind: its search would go on finding a
session Grok Build no longer lists.

Deletable("grok") now says yes, and sessionPaths' "grok" branch moves the
whole folder (updates.jsonl, summary.json, the locks, prompt_context.json,
terminal/, everything else it kept) and its subagents' folders, which
grokFiles folds into the session it ran in. What the cwd's folder holds for
every session there (prompt_history.jsonl), another session's folder and the
index stay. The trash, Restore, Purge, the recent-write ErrActive guard and
WSL handling are the ones Delete already has.

grokSearchRowsDrop (grok_search.go) deletes the deleted session's row in
session_docs, and its subagents', inside one BEGIN IMMEDIATE with a 5 s busy
timeout, so it waits for Grok Build's own write instead of failing; the
session_docs_ad trigger takes the row out of session_docs_fts. It runs before
the first file is moved: a row that can't be taken out (a database that isn't
one, a lock held past the timeout) stops the delete and the session stays
whole, rather than a folder gone from the list and still found by search. No
index file, or one without those tables, deletes as before. Restore brings
the folder back; the index row is not put back, so Grok Build's search finds
a restored session only if Grok Build indexes the folder again.

Tests, in-repo and on fixtures, never on a real ~/.grok: the sessions
package's fixture tree gained a lock file per session, a subagents/ entry, a
terminal/ file and the cwd's prompt_history.jsonl, and a small
session_search.sqlite is built in-test from the real file's schema (v4,
session_docs over FTS5 session_docs_fts with the three triggers).
TestGrokDeleteRestore (delete, folder and row and FTS entry gone, another
session's row kept, ErrActive, Restore, Purge),
TestGrokDeleteLeavesTheSessionWhenItsIndexRowCantGo and
TestGrokSearchRowsDrop; TestGrokSessionDeleteOnThePage drives the page's own
handlers (GET /api/sessions/manage?agent=grok says deletable, POST
/api/sessions/delete moves it, the trash lists it, POST /api/sessions/restore
puts it back).

docs/subsystems/gateway-sessions.md: the delete paragraph, and Grok Build out
of the "sessions magpie cannot delete" list.

Run (mote, this tree, on origin/main 289184a40): gofmt -l clean; go vet -tags
nogui ./... ok (one pre-existing cgo deprecation warning in internal/proc);
go test -count=1 ./internal/sessions/... ok (55.9 s); go test -count=1
./internal/gui -run 'Session|Manage|Forget|Trash|Delete' ok, 63 tests, the
new one among them; go test -tags nogui -count=1 on the same two selections
ok. go test -count=1 ./internal/gui (whole package, 216 s) fails
TestDockReopenKeepsTheWindowsSpace and TestCoveredWindowStaysUp with "timed
out waiting until the window is minimised"; both are red the same way in a
worktree at 289184a40 without this change, so they are this Mac's window
server, not this commit.

Broken by hand: without `"grok"` in Deletable, TestGrokDeleteRestore is red on
"Grok Build's sessions are not deletable"; green with it.

Not tried: a real Grok Build binary deleting one of its own sessions, so
whether it re-indexes a restored folder is unverified (said in the doc).

Isolation: the test binaries put HOME, USERPROFILE, XDG_* and every agent's
own variable (GROK_HOME included) in a temp folder (testenv.Isolate), and the
new tests name GROK_HOME and XDG_CONFIG_HOME themselves. A copy of this
machine's real ~/.grok/sessions (a 14.9 MB session_search.sqlite with 54
rows, one session of 76 files, one parent session of 477 files with two real
subagent folders) was exercised in the scratch folder only: delete, index row
and FTS entry gone, restore to the same file counts, purge; the developer's
own ~/.grok/sessions was snapshotted (every path, size and mtime; the index's
sha256; its session ids) before and after the runs and differs only where the
running Grok Build windows write themselves.
2026-11-19 23:57:01 +08:00
yetone d245951c9f gateway: Antigravity and agy get the hub's tools whole, not find_tools/call_tool
/hub/antigravity wrapped a big tool list in find_tools/call_tool, a second
lazy load on top of Antigravity's own (izhidigua on X, 11-19). agy 1.5.12
loads MCP tools lazily itself: its binary carries "Call a lazy-loaded MCP
tool. Read the tool's schema file", McpToolConfig.enable_lazy_load,
SplitEnabledToolsByEagerLazy and per-tool schema files under
~/.gemini/antigravity-cli/mcp/<server>/. So agy and antigravity join
hubSearchers, like claude, codex, pi, droid and omp. mcp-router.md says so.

enable_lazy_load is a config flag that may be set by the server, not by the
client; an account where it is off would list every tool whole.

Run: TestHubMCPToolsWhole now covers agy and antigravity; with both removed
from hubSearchers it fails ("agy listed [find_tools call_tool]"), with them
it passes. go test -run 'Hub|MCP' ./internal/gateway ./internal/gui ok on
mote; gofmt -l clean; GOOS=linux go vet -tags nogui and GOOS=windows go vet
of internal/gateway ok.
Not run: the full Go suite (mote and mica were both busy with other
sessions' full suites), a real agy session. The Library's agy
mcp_config.json handling is another session's and is untouched.
2026-11-19 23:49:45 +08:00
yetone 0417417e57 library: a project takes a whole Claude plugin, and gives it back (jinpwng on X)
A project can now have a library Claude plugin for chosen agents
(projects/plugin). Its skills, MCP servers and subagents go where the
project's own do (withPlugins adds them for a sync and puts the project's
own sets back after), and its hooks are written entry by entry into
.claude/settings.local.json and .codex/hooks.json (HookRecs). Taking the
plugin out deletes it from Plugins, and only what magpie placed or wrote
comes out; an entry the user changed stays. Removing a plugin from the
library drops it from every project. The Library plugins tab gets a
Project plugins section with per-agent chips, in en, zh, zh-TW, ja, de.

Run, on mote at the pushed head (rebased on origin/main 5d4f9862c):
- go test -count=1 ./internal/library ./internal/gui: both ok
  (204.9s, 181.3s); the same two ok at the earlier base 352b124b3.
- gofmt -l on internal/library and internal/gui: clean.

Not run before this push (mote and mica were both at load 27 to 51 under
other sessions' full suites; pushed at the owner's word to ship at once):
the full go test ./..., Linux and Windows vet, the whole GUI suite in
Chromium and WebKit. They are queued behind those runs and their result
will be filed as an issue per red. Not tried with a real project and a
real plugin outside the tests.
2026-11-19 23:48:47 +08:00
yetone 0a37c93682 library: a skill linked in from ~/.agents/skills whose folder is gone is shown as gone and given to no agent (#7226)
"Bring in all" links a skill of the skills CLI's folder into the library.
After `npx skills remove` its folder is gone: the library entry stayed
listed and every sync linked each ticked agent to the dead link.

markDangling (skill_dangling.go, each read and sync) finds a linked-in skill
whose folder is absent or has no SKILL.md, marks it Gone (the page already
offers to take such a skill out; RemoveGoneSkills only removes the link) and
sets Skill.Dangling, which gives() reads, so no agent, project or shared
folder is given it and magpie's own links to it are taken away. It is cleared
when the source returns. A stat error other than not-exist is unknown and keeps
the entry. Nothing the user owns is deleted. The library's own folders are
never judged.

Run (sandbox HOME, tests only):
- New TestLinkedInSkillWhoseSourceIsGone and TestSourceGoneKinds: red on the
  old code (no Gone, agents keep the link), green after (mica-run).
- Windows junction case TestJunctionToARemovedFolderIsGone, plus the two
  above, via win-run on xiaomi-gpu: ok.
- gofmt -l clean; go vet -tags nogui ./internal/library for GOOS=linux and
  windows: clean.
- Full `go test -tags nogui -timeout 45m ./...` on mote at this head was
  still running when pushed (the first 39 packages ok, no red); shipped
  on the coordinator's word with these targeted runs. No reds named.
Not tried: a real `npx skills remove`, the GUI (no GUI files changed, so the
GUI suite was not run).
2026-11-19 23:44:48 +08:00
yetone 5d4f9862ca library: an agent that is not installed is listed only for what magpie gave it here, not for a synced tick (izhidigua on X)
A library synced from another computer carries each item's agent ticks. held()
counted a tick as a reason to list a not-installed agent, so on a computer
without Claude, Claude Code or Pi the MCP switches (and any row withGone
widens) listed them, while Skills showed only the installed four. Take-it-out
(Target.Gone) is for what magpie wrote into the agent on this computer, which
Applied records and sync never carries; a tick alone gave it nothing to take out.

held() now counts only Applied (skills, MCP, hooks, env, router, router rules).

Run, on mote at this tree: TestGoneAgentWithOnlySyncedTicksIsNotListed (new;
claude-desktop, claude and pi ticked from a sync, none installed, nothing
Applied), red on the old code (all three listed), green now;
TestGoneAgentListedToTakeOut still passes (an Applied agent is listed); go test
./internal/library; gofmt -l; go vet of internal/library for linux, windows and
host.
Not tried: the reporter's two computers; the whole GUI suite (no page file
changed).

Full suite, mote, at 7bb2f5ac0 (this change on bb9c5ae15), log kept whole: go test -count=1 -timeout 45m ./... : internal/library ok; reds elsewhere, none in code this touches: gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117, red on origin/main), gui TestAppReplacesItsOlderGatewayOnceIdle, TestGatewayPauseRollsBack, TestSetPortServesWhenTheOldOneWasTaken (TempDir cleanup, #6297, #7112; ok alone). At the pushed head 6aab35abd the library package ok again.
2026-11-19 23:16:23 +08:00
yetone 7f3b272726 library: the Antigravity app and agy share one MCP file, and magpie's entry in it is magpie's (izhidigua on X)
Antigravity and agy read and write the same ~/.gemini/config/mcp_config.json.
With both ticked and MCP routing switched on, the first one's sync wrote the
"magpie" entry; the second one's hubFor then found a "magpie" entry it had not
written itself and judged it the user's own server by that name (hubOwn): it
kept a direct connection and offered to import it, and switching off left that
side's servers behind.

hubFor now asks sharerWrote: an entry by the hub's name in a file that another
target reading the same path has Applied is magpie's own.

Run, on mote at this tree: TestAntigravitySharedMCPFile (new; two rounds of on
then off, with fs stdio and web http ticked for both, then Read shows no
server direct), red on the old code (the second agent kept its servers direct
and the file kept the foreign entry), green now; go test ./internal/library;
gofmt -l; go vet of internal/library for linux, windows and host.
Not tried: real Antigravity or agy (sandbox HOME only).

Full suite, mote, at 7bb2f5ac0 (this change on bb9c5ae15), log kept whole: go test -count=1 -timeout 45m ./... : internal/library ok; reds elsewhere, none in code this touches: gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117, red on origin/main), gui TestAppReplacesItsOlderGatewayOnceIdle, TestGatewayPauseRollsBack, TestSetPortServesWhenTheOldOneWasTaken (TempDir cleanup, #6297, #7112; ok alone). At the pushed head 6aab35abd the library package ok again.
2026-11-19 23:16:23 +08:00
yetone fa52741ebc agent: omp 18.1.6 and later name themselves; magpie's User-Agent only for an older omp (Zyvaletta on X)
magpie wrote `headers: {User-Agent: omp}` into omp's models.yml for every
omp. A newer omp sends `omp/<version>` itself, and the header put that
version out of sight.

From omp's own source: pi-ai 18.1.6 (CHANGELOG 2026-09-03, "Inference
requests now identify as omp by default") wraps fetch in
withInferenceUserAgent, later transportFetch, which sets User-Agent
omp/<VERSION> only when none is set. Real omp runs against a stand-in
gateway on mote, sandbox HOME, `bun add @oh-my-pi/pi-coding-agent@<v>`,
every API (Chat, Responses, Messages, Gemini):
  16.3.5 and 18.1.5: Bun/1.4.2
  18.1.6 and 18.4.4: omp/<version>
18.15+ needs Bun >= 1.4.4 (mote has 1.4.2); its source (18.15.0,
18.22.2) has the same transportFetch.

Now (ompUserAgent): no header from 18.1.6 on; omp/<installed version>
before; plain omp when the version isn't known. The version comes from
the installed package.json (InstalledVersion), never the network.
ompKept takes a User-Agent of magpie's own (omp, or omp/<version>) for
magpie's, so an old `User-Agent: omp` is replaced or removed on the next
sync, and any other value, under any casing, is the user's and stays
alone. usage.AgentOf cuts at "/", so omp, omp/16.3.5 and omp/18.4.4 all
count as omp; nothing reads omp's version from the UA.

Tests (internal/agent/omp_useragent_test.go): TestOmpUserAgentByVersion,
TestOmpOldMagpieUserAgentSynced, TestOmpUsersOwnUserAgentStays.

Broken by hand: origin's omp.go with a stub ompOwnUserAgent, all three
red; ompKept returning yamlKept's result unchanged, the last two red.

Real omp with the new header (mica, same stand-in): 16.3.5 and 18.1.5
with `User-Agent: omp/<v>` send omp/<v> on all four APIs.

Docs: docs/subsystems/agent-wiring.md row "omp's User-Agent"; site
omp.html en/zh/ja.

Run at this tree (base ed405d1d7, mica):
  gofmt -l on changed files: nothing
  go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./...: ok
  go build, GOOS=linux go build -tags nogui, GOOS=windows go build: ok
  go test -count=1 -timeout 45m ./... (sandbox HOME, mote, at the pre-rebase head): every package ok but
  gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (red on origin/main be400389b too, #7117) and gui
  TestSetPortServesWhenTheOldOneWasTaken (TempDir cleanup race under load 48; 5 of 5 ok alone).
  After the rebase onto 352b124b3..be400389b: internal/agent (45m timeout), fx, usage ok.
No GUI files touched; GUI suite not run.
Not tried: omp 18.15+ run for real (needs Bun >= 1.4.4); a WSL omp.
2026-11-19 23:03:32 +08:00
yetone bb9c5ae154 gateway: an inline image is counted in the context map by its vendor's rule, from its size (paiven_x on X)
@paiven_x on X: a Codex session (gpt-6.1-terra) of a few hundred small
screenshots sent ~42 MB a request, and the context map showed 764K
tokens, 413K of them images, while Codex's own count was about 371K.
Every inline image was taken at a flat 1600 tokens (imageTokens), so
~258 small screenshots read as 413K where OpenAI counts an 800x500
one at 480.

Now an image's width and height are read from its header alone
(image.DecodeConfig over a streaming base64 decoder: a few KB of a PNG,
a JPEG up to its frame header, a lean body's imageRef through
keptImageOf), and counted by the rule of the protocol's vendor
(prompt_image.go):
- Anthropic: 28 px patches, ceil(w/28)*ceil(h/28), after the reference
  resizedSize; 2576 px / 4784 tokens for Claude 4.7 and later, 1568 /
  1568 before.
- OpenAI patch models (GPT-5.2 and after, the minis): 32 px patches
  times the model's multiplier, in the side and patch budget each
  detail sets (low/high/original/auto per model, as the vision guide
  lists them).
- OpenAI tile models (gpt-4o, gpt-4.1, o1/o3, gpt-5/5.1): base plus
  512 px tiles after 2048 and 768 fitting; low is the base.
A link, a file, a document, an unreadable image and a Gemini request
stay at 1600; the vendor's count still scales them all (calibrate).

The 475K Codex never reached is Codex's own: 95% (its
effective_context_window_percent) of the 500K its bundled catalog gives
gpt-6.1-terra. magpie writes no auto_compact_token_limit for Terra
unless the user set one (Working keeps its own 500K). Codex compares
the usage the vendor reported (~381K), which was under it, so nothing
compacted until /compact. No workaround added.

Tests: TestPromptImageTokensByVendor builds real PNG and JPEG bytes
(image/png, image/jpeg Encode) and checks each vendor's own doc
numbers: Terra 800x500 auto 480, 2880x1800 high 2949, gpt-5.5 low 192,
gpt-4o 1024x1024 high 765 and low 85, Claude 1920x1080 2691 (high
tier) and 1560 (Sonnet 4.5), 3840x2160 4784, a JPEG behind a 40 KB
APP1 330, \/-escaped base64 480. TestPromptImageSizeReadsHeaderOnly
reads 2880x1800 from the first 4 KB of the base64 and falls back to
1600 for a link, a file and undecodable bytes.

Broken by hand: imageTokensOf replaced by the constant, all 10 cases
of TestPromptImageTokensByVendor red at 1600.

Run at this head (e67b0f4fa, rebased on origin/main 352b124b3): gofmt -l
clean; GOOS=linux go vet -tags nogui ./... and GOOS=windows go vet ./... ok
(mica); go test -count=1 -timeout 45m ./... on mote: every package ok except
internal/gateway, whose only --- FAIL is
TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes, red on origin/main without
this change (#7117). A recovered "close of closed channel" from doneHold.serve
(continuation_test.go:781) is in the log, filed as #6690 and #6505; it fails
no test. TestCoreScriptBudget is in that run (no GUI file changed).

Not tried: a real Codex session with hundreds of screenshots; the counts are
checked against OpenAI's and Anthropic's documented examples only.
2026-11-19 22:42:27 +08:00
yetone ed405d1d78 gateway: an Azure key that answered before, refused 401, rests suspended till it answers (canlee886 on X)
An Azure subscription with a spending limit (a student's $100 a month,
a trial's) is disabled by Azure when its credit runs out and enabled
again on its own when the credit renews. Meanwhile every request 401s
"Access denied due to invalid subscription key or wrong API endpoint",
the words a wrong key gets. magpie read that as any 401: failOther on
the 1-minute backoff climbing to 10 minutes, never asked in the
background, so the key was asked again by requests for weeks, and the
reporter turned the provider off and on by hand around the reset day.

Now restAfterMarked reads a failOther 401 as failSuspended when
azureSuspended holds: no account, Provider.IsAzure, and the key has
answered a request before (provider.LastServed at provider.ServedID,
served.json, 30 days) or is resting suspended already. It rests
suspendedRest (a day) by "suspended", and probeable takes it whatever
its status: keepProbingRests asks the resource's deployments list with
the key at 1, 2, 5 and then every 10 minutes (refused the same while
the subscription is off) and lifts the rest as soon as the list answers,
or when a request does. Its group's requests go to the next member
meanwhile, Azure not asked.

Product calls (mine to make, delegated):
- One 401 is enough, not "repeated" ones: a 401 is about the credential,
  never the model or the request content. On a key that worked, a
  transient 401 is lifted by the first ask a minute in, the same as the
  old one-minute backoff let it back.
- A bad key stays a bad key: a key 401 from its first request (new,
  mistyped, or edited, its KeyID then another) has no answer on record
  and rests as before, failOther/backoff, shown "401 · failed", never
  asked in the background. served.json unreadable is no answer on
  record too (a failed read is unknown, not "it worked").
- Azure only: a 401 says nothing of why on other vendors, and a list
  that answers without the key (OpenRouter's is public) would lift a key
  its vendor still refuses.
- No "back on day N" setting: the probe finds the day Azure enables the
  subscription, so there is nothing for the user to type in, and no
  Advanced field.

GUI: the key list says "Resting · 401 suspended by the vendor · back
at … · checked in the background, back as soon as it answers"; Routing's
restHow says its key answered before, so the vendor has most likely
suspended it (an Azure subscription out of credit). KEY_FAIL and the
routing plugin's FAIL gain "suspended", in en, zh, zh-TW, ja and de.
keyDead is unchanged, so "Remove failing" doesn't offer a suspended key.
docs/subsystems/gateway-routing.md has the rule beside the rest probe.

Not covered: a 403; a key whose last answer is over 30 days old after a
restart (rests are in memory); the last candidate of a request, which
rests only for quota, credit or a timed rate limit, so a lone Azure
provider is asked again by each request, as before, and answers as soon
as Azure does.

Run on mica (mote had other sessions' full suites), at b4c88d44e
unless named, rebased on 9fc1114d8 before the push:
- go test -tags nogui -run 'TestAzureKey|TestSuspended' ./internal/gateway:
  ok. Broken by hand, each red: azureSuspended always false (3 red:
  ThatAnswered, IsAzureOnly, OutlivesItsLastAnswer); served history
  ignored, every Azure 401 suspended (NeverAnsweredIsABadKey and
  OutlivesItsLastAnswer red); probeable's suspended branch off
  (ThatAnswered, IsAzureOnly red).
- azure-suspended.test.cjs, chromium and webkit, en zh zh-TW ja de,
  1100 and 420px: 40/40; with the base's four GUI assets, 0/40.
- At this head rebased, on mote (mica had another session's GUI suite):
  rest-try-now, key-rest-date, rest-probed, azure-suspended,
  routing-rest-off and i18n-keys, both engines: 146 of 164. All 18 reds
  are rest-try-now's (#4127 "ebody holds", #2564), 18 of 40 at
  origin/main 9fc1114d8 too. At b4c88d44e under load 47 on mica the
  same files had 50 timeouts; at light load only rest-try-now's,
  red on main too, are left.
- go test -count=3 -run 'TestAzureKey|TestSuspended|Probe|Rest'
  ./internal/gateway at this head rebased, on mote: ok.
- go vet ./internal/gateway ./internal/gui, and GOOS=linux and
  GOOS=windows go vet ./internal/gateway: ok.
- go test -timeout 45m ./... in a sandbox HOME: the first run filled
  mica's disk (another session's) and ~300 tests failed "no space left
  on device". The six packages it touched, run again: agent and
  provider ok, sessions ran past -timeout 45m with no test failed
  (TestTitleOfALongPromptAllocatesItsTitle at the deadline, #5451; it
  imports neither gateway nor gui); three reds, each filed and
  none in code this changes:
  - internal/dirent watch tests (#7031), red at origin/main 9fc1114d8
    too.
  - TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117), red at
    9fc1114d8 too.
  - TestGatewayModeListsNoOwnSessions (#7064, the listing race): red
    2 of 3 at b4c88d44e, ok 2 of 2 at 9fc1114d8 and 4 of 4 at this head
    rebased.

Not tried: a real Azure subscription disabled for its credit (none to
hand); the list's 401 while disabled is from Azure's documented
behaviour that the data plane refuses a disabled subscription's key on
every route.
2026-11-19 19:38:31 +08:00
yetone aeca7ae074 usage: a Claude Enterprise seat's 5 hours come from Claude Code's usage rows; a plan with none says so
@andy_chen1997 on X signed a Claude Enterprise account in, and the Usage
card said "Allowance unavailable", with the reason "Claude Code's /usage
is temporarily unavailable". magpie reads Claude usage only from `claude
-p /usage`. Claude Code 2.1.328 draws that text from the usage endpoint's
five_hour, seven_day, seven_day_sonnet and model-scoped weekly rows. When
it draws none of them, the text is just the subscription line, and
parseClaudeUsage read that as a failed read. An Enterprise seat gets there
in two ways:

- its 5 hours come only as a limits[] row (kind "session") in the JSON
  usage_report, with five_hour null. The gateway now adds each session,
  weekly_all and model weekly_scoped row as /usage's own line, and only
  when the text drew no window of its own. The ISO reset is parsed
  (RFC3339Nano). A row of another shape is skipped, and it never loses
  the extra usage line.
- its plan has no meters: limits is [], or the seat is usage-based
  (Claude Code's vmr/fD: oauthAccount seatTier "enterprise_usage_based"
  or billingType "usage_based" in .claude.json). The card now shows
  "5-hour and weekly limits: None on this plan" as a text row, set aside,
  beside its usage credits. This is not an error, so it isn't used up and
  routing holds nothing against it.

A real fetch failure (rate_limits null, or limits null) still says
temporarily unavailable. magpie still never calls /api/oauth/usage
itself.

Our earlier reply ("Enterprise shows only the 5-hour window") holds for
seat-based Enterprise. It was wrong for usage-based seats, which have no
5-hour or weekly limit at all.

The marker line is "Usage report: no meters on this plan", because a
first wording with "usage limits" was read by claudeUsageDenied as an
account error. The new test caught it.

Run on mote. At the pushed head (on origin/main 71718b277): go vet of
gateway, provider, usage and usageapi, plus go test -run Claude of
provider and -run "TestClaudeUsage|Prompt" of gateway: ok. On
origin/main 6ac19f4bc:
- gofmt -l: clean. go vet ./internal/..., plus GOOS=linux (-tags nogui)
  and GOOS=windows vet of provider and gateway: ok. At 975799a06: go vet
  ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go vet ./...
  and go build: ok.
- node --test claude-no-limits (new: webkit and chromium; en, zh, zh-TW,
  ja and de; at 360 and 1000px), i18n-keys and i18n-en-no-cjk: 10 of 10
  ok. At 975799a06 qianfan-credit-packs and usage-no-reading passed too
  (14 of 14).
- go test ./internal/provider ./internal/gateway (whole packages):
  provider ok. In gateway only TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes
  fails, and it fails alone on a fresh origin/main 6ac19f4bc checkout too
  (#7117, open).
- go test -timeout 45m ./... in a sandbox HOME, at the same change on
  origin/main 975799a06: every package ok but gateway (the #7117 test,
  as above) and pii. TestArmWindowsRunsX64Serve/no_AVX2 waited out 3m
  for its fake pf-serve-base under load 30-50. It passes alone at
  6ac19f4bc and with -count=3 here. Filed as #7202.

Broken by hand, and each went red:
- dropping the rows append in claudeExtraUsage (TestClaudeUsageRows);
- dropping the RFC3339 parse (TestClaudeEnterpriseUsage, reset nil);
- dropping the usage-based seat check (TestClaudeUsageBasedSeat);
- dropping the no-limits window (TestClaudeEnterpriseUsage);
- dropping zh-TW's "None on this plan" (claude-no-limits, both engines).

Not tried:
- a real Claude Enterprise or Team account (none at hand). The fixtures
  follow Claude Code 2.1.328's usage_report schema and its own handling,
  read from its bundled source in a fresh directory and never run against
  a live config.
- the whole GUI suite: no app.js, layout or API change, only new i18n
  words.
- a seat-based seat whose usage endpoint keeps failing still reads as
  temporarily unavailable. The text can't tell it apart from another
  failure.
2026-11-19 18:48:46 +08:00
yetone e4e9eb0928 usage: a ZCode call to a provider added by hand at magpie's address is not a local session's (jiangshangmuyun on X)
The Usage page listed one ZCode call as "new-provider · 本地会话" among the
gateway's own rows for the same Trae CN DeepSeek calls. The reporter has one
ZCode window and routes everything through magpie.

Cause: the user added magpie to ZCode by hand as a provider of their own
("new-provider", base URL magpie's gateway), not through magpie's connect,
which writes the id "magpie". ZCode records that id beside each reply, and
readZCodeCalls left out only "magpie"/"dial" (ocGatewayProvider). Its calls
were read from ZCode's database as well as logged by the gateway, and only
hidden again where pairing by session, tokens and end time matched; a call
whose counts didn't agree was listed twice as a "local session".

Fix: zcodeGateway also takes any provider whose base URL, in ZCode's
config.json or provider_config.json, is this machine (loopback, localhost,
0.0.0.0, one of its own addresses) on the gateway's port (MAGPIE_ADDR or the
saved port). Such calls are left out before pairing, as "magpie" ones are.
zcode's call parse version is 4, so cached shards are read again. Like
workbuddyGateway it reads the configuration as it is now. The label itself
is unchanged: a call that did go straight to a vendor is still a local
session's.

Siblings filed, not changed: OpenCode/MiMo (ocGatewayProvider), Pi
(piGateway) and dsh still match the gateway by provider name only (#7193).

Go run on mote at this change on base 9bf5848c1, rebased onto e2e8ea253
(no internal/sessions, usage or GUI file changed between): go test -count=1 ./internal/sessions
./internal/usage ./internal/usageapi (ok); GOOS=darwin/linux/windows go vet of
those packages (clean); gofmt -l clean. Broken by hand: with ocGatewayProvider
back in readZCodeCalls, TestZCodeHandAddedGatewayProvider is red ("a call to a
provider at the gateway's address was read as a local session's").
GUI (no GUI file changed, so as a check of the Usage page that shows these
rows): every usage-*, session-identity and i18n-* file, chromium and webkit,
each language they cover, on mote under load ~40: 1670 of 1777 pass. The 107
reds are in 12 usage files (usage-agents-hide, usage-chart-line,
usage-speed-all-models, usage-upload, usage-ledger and 7 more) and fail the
same at origin/main e2e8ea253 without this change (107 of 308 in those files,
same tests). Filed: #2276, #5834, #6003, #6743, #6790, #6975.
Not tried: the reporter's real ZCode database and config (this computer has
no ZCode); why that one call's tokens didn't pair (no data); the full Go suite.
2026-11-19 17:39:35 +08:00
yetone 992f88d634 usage: a stand-in reading says why the read behind it failed
@tmr11235 on X (tweet 2123334817991520577, magpie v0.1.4520): agy-cli's
card showed "截至 2026/11/15 14:19:19,暂时无法获取最新额度" days later,
with nothing to say why. keepLast stands the last good reading in for a
read that fails with a passing error (timeout, 429, 5xx, network) and
dropped that error, so a stand-in that lasted four days read the same as
one a minute old. The reading now carries the error as readError
(SubscriptionQuota, and Quota for `magpie quota --json` and the gateway
report), and asOfText puts it after the date: "… 暂时无法获取最新额度 ·
agy usage query timed out." A deferred read (not asked) has none, and
the short "As of" line on cards stays short. Every provider's stand-in
gets it, not only agy-cli's.

Run (mote, at origin/main 9bf5848c1 + this commit; again after rebasing
onto c01988e43: vet, the provider/gui quota and budget tests, usage-card-refresh
and i18n-keys, 50 pass):
- gofmt -l clean. go test -count=1 -timeout 45m on internal/provider,
  gui, cli, tui, usage, agent: ok. internal/gateway: one red,
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes, filed as #7117 on
  origin/main before this (an OpenCode env-block test, not quotas); the
  doneHold fake's "close of closed channel" log is #6690/#6505.
- GUI: usage-card-refresh, account-every-reset, balance-parts,
  claude-usage-asked, panel-quota-refresh, i18n-keys: 94 pass, 0 fail
  (chromium + webkit, every language).
- GOOS=linux/windows go vet ./internal/provider/ (after rebase).
- Broken by hand: without the keepLast line, TestQuotaDeferredReadIsNotFailure
  fails (readError = "", want "connection refused"); without the
  asOfText change, usage-card-refresh fails ("a failed read hid why").

Not tried: the reporter's own failing read (which error it is); a real
GUI with a stand-in card (the fixture page only).
2026-11-19 17:38:05 +08:00
yetone c01988e439 routing: a group's Small context first sends a request to the smallest window that holds it
yg6888 on X (tweet 2123308968848379920): in a group routed Smart, Cursor
Plus's Composer and Grok 4.7 were never used. Not a bug: Smart orders by
allowance tier, then soonest renewal, then listed order, and never weighs
the context window, so the 1M members listed ahead always answered. The
small ones were only ever reached as a fallback.

Smart itself is unchanged; changing its order would move every Smart
user's traffic. A group gets a new routing instead, `fit` (Small context
first; 小上下文优先, 小上下文優先, 小さいコンテキスト優先, Kleiner
Kontext zuerst):

- routes.SmallFirst takes Smart's order and sorts it stably by band (a
  provider set to be used first, the rest with room, the all but used up)
  and then by window, the smaller known first, an unknown one last.
- Its strategy sets ByWindow, so weighRouted fills Seat.Window from
  windowIn (the provider's own Contexts, else the catalog's).
- roomy already leaves out every member the request is estimated past, so
  the first left is the smallest that holds it: a small model is never
  asked for a request too long for it, and keeps its last-resort place as
  under every routing.
- The trace's rows carry `context`; the Routing page says "its 200K
  context window is the smallest that holds this request".
- A group's only: provider.normalize already drops it from a provider and
  the CLI refuses it there. GUI menu, hint, why-lines, TUI and CLI
  (`routing=fit`, small-first) carry it; docs/reference.md, the
  gateway-routing and plugin-runtime pages and the en/zh/ja start pages
  say it, with the search index rebuilt (via docs-index.mjs; #7065).

Run first at the tree rebased on origin/main 6e5882109, then at this
head's (on 856423806; search index rebuilt; gateway/routes vet, routes, rotation, ./internal/gui,
the gateway's new tests and routing-small-first, routing-group-strategy
and i18n-keys 42/42 again), mote over its
cores with another session's full suite on it and mica's disk full, so on
the Linux box (wsl-run) and the Windows box:
- go test -tags nogui ./internal/routes ./internal/cli ./internal/tui
  ./plugins/rotation ./internal/gateway -count=1 -timeout 45m: all ok but
  gateway, whose one red was this commit's own new test asserting a single
  group while an auto group for the shared model exists; fixed (FindGroup
  "group/g") and the window/strategy tests rerun ok, both new ones pass.
  ./internal/provider ok (its only FAIL was the stale search index, since
  rebuilt). ./internal/gui -run Budget ok.
- Broken by hand: SmallFirst returning Smart's order makes
  TestSmallFirstOrdersByWindow and the gateway test red ("a short request
  went to big first"); dropping fit from SaveGroup's whitelist makes the
  gateway test red ("the group didn't keep Small context first").
- GUI (Chromium + WebKit, en zh zh-TW ja de): routing-small-first,
  routing-group-strategy, i18n-keys, routing-cheapest-first,
  routing-free-expiring 112/112 before and after the rebase;
  every routing*, group* and builtins* file (253): 4139 of 4198, the 59
  reds in 11 files that fail the same at origin/main 239da9991 run alone
  (57; routing-many-keys moves between languages each run), all filed:
  #7016, #7097, #6520, #5049, #6512, #4711, #3954, #3799, #4082.
- Windows: CGO_ENABLED=0 go vet -tags nogui ./internal/... ./plugins/...
  ok. gofmt -l clean.

Not tried: the full `go test ./...` and darwin vet (mote busy, mica out
of disk); a real Cursor/Grok account in a group (the window comes from
the same windowIn roomy already trusts). Seen on the way: a recovered
"close of closed channel" in continuation_test.go's doneHold fake, no
test failed from it.
2026-11-19 17:34:30 +08:00
yetone 8564238065 remote magpie: a model is asked on the API the remote asks it on best (OoopsHh on X)
With another magpie as the provider, Pi's models.json had only codex/*
on openai-responses; an OpenAI key's openai/* and a routing group's
auto/* went on openai-completions, and effort max was turned away there
while Responses takes it.

Cause: the remote's /v1/models gives native_endpoints, every API the
model goes on as it is, in its provider's speaking order (Chat first),
and nothing for a routing group. Here Provider.Native took the first one
the remote magpie provider speaks: Chat, for every model but a ChatGPT
sign-in's (listed on /v1/responses alone). The remote's own choice
(Native: ResponsesFirst or the Base URL's API; a group's GroupAPI) was
lost on the wire.

Now the remote's list (X-Magpie-Drawers) says magpie_prefers, the path
it asks the model on best (provider.PreferredEndpoint). The local magpie
keeps it as catalog.Model.Prefers and Native takes it first for a remote
magpie (RemotePrefers), so every agent wired one API per model (Pi, omp,
droid, dsh, grok, hermes, liveagent through catalog.Model.APIs) asks it
there, and the gateway's usable translates another API's request to it
once instead of to Chat. A user's own API set on the model still wins;
a remote from before says nothing and stays as it was.

Not changed: a Chat request a client sends itself for such a model is
still relayed as Chat to the remote, which decides as it does for its
own clients.

Run (mote, at this tree):
- TestRemoteMagpiePrefersResponses (gateway: two magpies on one
  gateway, a fake vendor that turns away reasoning_effort max on Chat)
  and TestPiAsksARemoteMagpiesModelWhereItPrefers (agent): green; both
  red with the RemotePrefers check in Native and usable turned off
  (openai/* and group/auto on chat, Pi's api nil, a Messages request
  relayed as Chat).
- Two real magpie serve processes in sandbox HOMEs, a fake vendor, an
  OpenAI key there with its Base URL given as Responses, a group auto
  and the first magpie as the second's Remote magpie: Pi's models.json
  has office/openai/gpt-6.2-astra and office/group/auto on
  openai-responses with max, and /v1/responses effort max reaches the
  vendor's /v1/responses for both. The same script at the base commit
  wrote both with no api (the provider's openai-completions).
- At base 9bf5848c1: go test ./internal/catalog ./internal/provider
  ./internal/agent ./internal/cli: ok. ./internal/gateway: two reds,
  neither this change's. TestKeptBodyIsOnlyItsCallers is fixed on main
  by e2e8ea253 and passes at this head. TestOpenCodeGoOwnFreeModel-
  GetsNothingOfOpenCodes is red the same on origin/main 975799a06, 3 of
  3 (#7117). gofmt -l: nothing. go vet, GOOS=linux go vet -tags nogui
  ./..., GOOS=windows go vet ./...: ok.
- At this head, rebased on 975799a06: the tests above, plus the TestPi,
  TestRemoteMagpie, Native, Prefers, Unique and TestKeptBody runs of
  gateway, agent, catalog and provider: ok.

Not tried: the whole gateway package at this head, the full ./... suite (mote stayed at load 30+ with other
sessions' runs, mica's disk is full), a real OpenAI key, and the
vendor's own Chat refusal of max, which a fake stands in for. Pi
itself was not run; its models.json was read.
2026-11-19 17:28:26 +08:00
yetone 504db2206e kiro: the docs say what the Routing page shows, and the min names the ACTIVE, outlasting trial
The ported change said the Routing page shows "on credits · after the
others"; nothing in the GUI renders Weighed.CreditsLast, so the docs now
say the mark is read by affinity only. The plugin (0.1.41, review
follow-up on plugins#1352) says credits only while an ACTIVE bonus has
credits left that outlast the month's reset; the docs and the mover's
note say so.
2026-11-19 17:25:39 +08:00
StringKE 5a83f0ae6c gateway: a plugin's account on its trial credits is asked after the accounts with plan credits left
A plugin window may say credits: used up, the account goes on past it on credits its vendor spends after the window's. Kiro spends a month's plan credits before a trial's, and the plan's are lost at the month's reset while a trial's last a year, so such an account goes after the provider's accounts with room and before those used up, under every routing but Pick account by hand.

Ported from StringKe's branch (StringKe/magpie kiro-trial-last, 23e084262;
yetone/magpie#7179, with plugins#1352, kiro 0.1.41). Kiro's billing docs
say "Kiro uses your plan credits first, then your trial credits" and that
trial credits last 12 months. Opt-in per plugin window (credits), so a key
or a Codex account routes as before: creditsLast and CodexCreditsFirst
stay Codex-only, behindOthers moves only plugin: accounts, and no other
plugin package sends credits. The Kiro mover's min goes to 0.1.41, on npm
(gitHead 0ae116db1).

Run at this stack's head on mote: go test -timeout 45m ./... with go vet
./...: every package ok but internal/gateway, red on
TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (red 3 of 3 alone on
origin/main 9bf5848c1 too, #7117) and TestKeptBodyIsOnlyItsCallers (fixed
two commits on, a test reading the package's own sources). Broken by
hand: with behindOthers taken out of weigh, TestPluginCreditsAfterTheOthers
goes red.
2026-11-19 17:25:39 +08:00
yetone 9bf5848c1f gateway: a Kubernetes rolling update runs two pods on one volume safely
@justforlxz on X asked for a RollingUpdate (maxSurge 1, maxUnavailable
0) with no request dropped. The docs said strategy: Recreate, because
the work only the serving magpie may do (renewing sign-ins, check-ins,
moves, plugin updates, WhileServing) was kept to one magpie only by the
gateway's port: a second couldn't bind it. Two pods each bind their own
network namespace, so in an overlap both did it, and two renewals of
one refresh token can spend it (a single-use token rotates).

Design: both pods answer requests at once (each refresh and file write
is already locked across processes: filelock, host.js lockRenew); the
serving work is held to whichever gateway holds gateway.serving.lock
(flock on the config folder, serving.go). The new pod retries every
second and takes the work over as the old pod's gateway ends (its drain
lets go first). A file system without locks is read as no other magpie,
as before.

Pods share the volume but not a pid namespace (both run magpie as pid
1), so the locks that judged a holder by its pid now judge it by host:
- host.js lockRenew records host (hostname + pid namespace); a lock of
  another host is stale by age only, never by "pid 1 is alive here".
- lockMoves (migrate.go) the same.
- gateway.json records Host; forgetListening removes only its own, so
  the old pod's end no longer removes the new pod's file (same pid,
  same Started second was enough before).
- temp and run-mark names get a random part (writeDurable, Claude run
  marks, gateway.json's temp file).

While draining (SIGTERM), every reply says Connection: close, on the
gateway and on magpie web's page port, so an agent that kept its
connection to the old pod alive dials the Service again for its next
request. Without it, the real rollout below had one broken pipe per
kept-alive connection, ~5.8s after each SIGTERM, when the drain's end
closed them.

Docs (en/zh/ja docker, reference.md): RollingUpdate maxSurge 1 /
maxUnavailable 0, the readiness probe, a required podAffinity on
kubernetes.io/hostname (a ReadWriteOnce volume mounts on one node), and
one Recreate update from a version before this one, whose old pod
doesn't take the lock.

Run:
- Real overlap, podman 4.9.3 in WSL magpie-desktop: three pods
  (pa -> pb -> pc) on one volume, each its own container (pid 1, own
  hostname and network), a Service proxy over a readiness-probed
  endpoint list (1s probe, endpoint removed 1s after SIGTERM as
  kube-proxy does), 12 agents streaming 3s SSE turns through it, half
  keeping connections alive, no retries. Before Connection: close: 226
  ok, 10 failed (broken pipe, kept-alive). After: 209 ok, 0 failed;
  second run 207 ok, 0 failed. Each new pod logged "another magpie serves", then
  "let go" as the old pod's gateway ended; gateway.json named the last
  pod.
- Broken by hand, each red then green: TestServingWorkWaitsForTheOther-
  Magpie, TestServingWaitEndsWithItsGateway, TestForgetListeningKeeps-
  AnotherPods, TestMoveLockOfAnotherPod, TestRenewLockOfAnotherPodIs-
  WaitedFor, TestDrainingRepliesCloseTheirConnection,
  TestPagePortClosesWhileDraining.
- Full suite, go test -count=1 -timeout 45m ./..., at 85305a82d (this
  change on 2926b7bef): macOS on mote, 102 packages ok; Linux
  (-tags nogui) in WSL magpie-desktop, 101 ok. Reds:
  - TestAuthLockWaitDoesNotFreezeTheHost, both: this change's
    writeDurable called randomUUID, which the test's sandbox of host.js
    doesn't give. It now names the temp file with Math.random; plugin
    then ok on mote and on Linux.
  - Not this change, filed: TestCappedIsSmall (Linux, #5975),
    TestRequestStateKeptAcrossACatalogFetchedAgain (Linux, #6572),
    TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (macOS, #7117).
  - Not a red, filed: the macOS log has a recovered "http: panic
    serving ...: close of closed channel" in the doneHold test fake
    (continuation_test.go:781); no test failed on it. It is #6505
    (also filed as #6339 and #6690).
- go vet ./..., GOOS=linux -tags nogui and GOOS=windows go vet ./... ok
  on mote; go vet -tags nogui ./... ok on Linux; gofmt -l clean.
- At the pushed head (rebased on 6e5882109), on mote: go vet (macOS,
  GOOS=linux -tags nogui, GOOS=windows) of gateway, gui, plugin and
  provider ok; go test -count=1 of gui, plugin, provider ok, gateway
  ok but #7117's TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes;
  site node --test 135 pass, 0 fail.
- New tests on Windows (win-run): gateway, provider, plugin, gui ok.

Not tried: a real Kubernetes cluster and kube-proxy (the podman harness
stands in for both); a real OAuth plugin's renewal across two pods (the
plugin test uses a fake vendor); an RWX/NFS volume's locks. A stream
that began before SIGTERM and outlasts the drain's 20s still ends with
the old pod. Pods exit 2 on SIGTERM as pid 1 (before this change too).
2026-11-19 16:20:34 +08:00
yetone 72f7c1f41a agents: Nowledge Mem's own AI runs on magpie (xiaomaomiloulou on X)
Nowledge Mem asks for "选择一个 AI" on its first page and in Settings >
AI, and Mem 0.10 has a provider type of magpie's own. Picking a magpie
model for the new agent nowledge-mem now sets it up from magpie:

- Mem keeps its providers in remote_llm.json with each key encrypted, so
  the file is only read. Changes go through its backend (nmem-server,
  127.0.0.1:14242, $NMEM_API_URL when it names this computer), as its
  Settings and `nmem config provider` do: POST /remote-llm/config saves
  provider "magpie" at the gateway's /v1 with agentKey("nowledge-mem")
  and the model, which makes it active and turns the AI on.
- Mem puts temperature, max_tokens and timeout back to its defaults
  when a save leaves them out, so every save sends the provider's own.
- What Mem had is stashed once: the active provider, whether the AI was
  on, and a "magpie" provider the user made, which keeps its key and
  gets its model, base and parameters back. Stepping out activates the
  provider Mem had (unless one was picked in Mem since), removes
  magpie's provider and turns the AI off again if it was off.
- Mem has to run to change it (errMemDown); a sync moves the base only
  when the gateway's port moved. Detected by its config folder or the
  installed app (co.nowledge.mem.desktop). Icon from its icon.icns.

Run (mote):
- go test -count=1 -run 'NowledgeMem|TestEveryAgent|TestListOnly|TestSync|Desktop'
  ./internal/agent ./internal/library ./internal/agentenv ok; -run Icon
  ./internal/gui ok.
- GUI: icon-one-tone, icon-tile, routing-client-icons, i18n-keys in
  Chromium and WebKit, 58 of 59; the red is icon-tile's dim-color, red
  on origin/main since 2649d5d72 (#6759), not this icon.
- Real Nowledge Mem 0.10.121 (free tier) in a sandbox HOME on mote, its
  nmem-server on its own port behind a logging proxy, and a sandbox
  magpie (go build of this tree) with a fake OpenAI vendor:
  `magpie nowledge-mem fakeoa/fake-model` made magpie Mem's active
  provider at the sandbox gateway; Mem's own `nmem config provider test`
  answered "Connection OK — magpie/fakeoa/fake-model", the vendor got
  the request, and `magpie usage` counted it under Nowledge Mem.
  `magpie nowledge-mem default` put openai_compatible/u2 back as active,
  removed magpie's provider, and Mem's test passed on it again.
- That run found NMEM_API_URL dropped as "not an absolute path";
  NotPaths has it now (the AGY sibling is the commit before).

- On 681f2ee7f, then rebased onto 6af38c0ee (internal/gui providers
  only, none of these packages): gofmt -l clean; go vet, GOOS=linux
  and GOOS=windows go vet of ./internal/agent ./internal/agentenv
  ./internal/library ok; the tests above again ok.
- Not run: the full go test ./... suite. mote had another session's full
  suite running and mica's disk is full (323 MB free); it runs on mote
  once that one ends, and a red gets its own issue and fix.

Broken by hand: without the check that magpie's provider is still the
active one, TestNowledgeMemKeepsALaterPick is red; without re-sending
temperature, or sending a key over the user's own magpie provider,
TestNowledgeMemKeepsTheUsersMagpie is red; with NMEM_API_URL out of
NotPaths, TestNowledgeMemOnlyOnThisComputer is red.

Not tried: Mem's window itself (the run used its API and CLI), magpie's
GUI connect row clicked, Windows and Linux (config folder per OS is
from Mem's source, not a real install), a paid Mem plan.
2026-11-19 15:44:48 +08:00
yetone 681f2ee7f0 templates: a cheaper small model beside a near flagship is the cheap one (@qinzhidaoa on X)
The reporter's DeepSeek provider has deepseek-v4.1-flash and
deepseek-v4-pro, and the Routing groups page greyed out "Hard to strong,
easy to cheap" and "Cheap first" with "Needs a model cheap beside
DeepSeek-V4-Pro". Both prices are known (models.dev's DeepSeek, as the
bundled catalog has it: V4 Pro $1.98 out, V4.1 Flash $0.60 through its
canonical id), so it was not a missing price. cheapest() took a model as
cheap only at a quarter of the strongest's price or less, and Flash is
3.3 times less. Sonnet beside Haiku (3x) and Gemini Pro beside Flash
(~3.4x) failed the same way.

Now a model is cheap at a quarter of the price, or when it costs less and
its id says small (flash, mini, haiku...) where the strongest's doesn't.
A model that costs as much, or one cheaper with no small id at under a
quarter, is still not taken. With no price on either side, the size
words already decided, unchanged.

Prices for the new ids do reach the templates: deepseek-v4.1-flash is
priced 0.60 at its maker (maker=true) through models.dev's deepseek-flash
canonical, logged by the new test.

Run (mote):
- TestTemplatesCheapBesideACloseFlagship reproduces with the reporter's
  ids (deepseek-v4.1-flash, deepseek-v4-pro on the DeepSeek preset) and
  models.dev's DeepSeek entries from the bundled catalog, written as the
  test's catalog (testdata/models-dev-deepseek-2026-11-10.json). On the
  old cheapest() it is red: smart and thrifty need "cheap" of "DeepSeek V4
  Pro", members [], and Haiku beside Sonnet, Gemini Flash beside Pro, red
  the same. Green with the change; the other template tests pass.
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./..., go build, GOOS=linux go build -tags nogui,
  GOOS=windows go build: ok.
- go test -tags nogui -timeout 45m ./... at 56b3f0780 (this change on
  593ea437d): 103 packages ok, internal/gateway red on
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes alone, which is red
  alone on a just-fetched origin/main 6a46bad34 too and is filed as #7117.
- After the rebase on 6a46bad34: go test -tags nogui ./internal/provider
  ./internal/gui: both ok. On 344253c4e (this head's parent, a Codex
  change in internal/provider): ./internal/provider ok again.

Not run: the GUI suite. No GUI file changed: the page shows the
template's Need as the API gives it, and no API or layout changed. Not
tried in the reporter's real app with a real DeepSeek key.
2026-11-19 15:35:54 +08:00
yetone 344253c4e2 provider: Codex's Ultra on every GPT Sol, Astra and Terra by family, GPT-6.2 Sol and Astra too
forkhouhou on X: on a relay, gpt-6.2-sol and gpt-6.2-astra stopped at max
in Codex while gpt-6-astra and gpt-6.1-terra had ultra. OffersUltra read a
hand list (ultraModels), so each new model lacked Ultra until someone
added it (#4909 did 6.1 Terra); 6.2 was never added.

openai/codex's models-manager/models.json (6c0cee502, "Add GPT-6.2 Sol
and Astra to model catalogs (#62106)") lists ultra on every Sol, Astra
and Terra from GPT-5.6 to 6.2, and on no Luna, GPT-5.5 or older. So the
rule is now the family: catalog.FamilyOf names gpt-sol, gpt-astra or
gpt-terra with a version. It is asked of every spelling the catalog
matches through a new catalog.IsOneLike (found/lookupIn moved onto a
getter, their map forms unchanged), so a provider prefix, :official,
[A], a dated suffix and gpt-6-1-sol keep working, and -fast, -pro and
Luna stay out.

Ultra still goes upstream as the entry's multi_agent_reasoning_effort
or max (fitEffort), and turns Codex's V2 subagents proactive. It
changes no sandbox or approval.

Run:
- Red on the old code (mote): OffersUltra false for gpt-6.2-sol,
  gpt-6.2-astra, relay/gpt-6.2-astra, gpt-6.2-sol-2026-11-17 and
  gpt-6.3-terra; copilot/gpt-6.2-astra's entry stopped at max with
  v2=false. Green after.
- Sandbox HOME e2e (mote, -tags nogui, fake relay, never live
  configs): old code: relay/gpt-6.2-sol and -astra low..max, no v2, in
  /v1/models, /v1/codex/models, `magpie models` and
  ~/.codex/magpie-models.json. New: low..max,ultra with
  multi_agent_version v2 in all four; gpt-6.1-sol unchanged (ultra),
  gpt-6-luna unchanged (none). config.toml's enabled-reasoning-efforts
  has ultra. A POST with effort ultra reached the relay as
  reasoning_effort max.
- GUI: `magpie web` on that sandbox HOME, read with Playwright
  Chromium: /api/state's Codex effort and subagent effort fields on
  relay/gpt-6.2-sol offer low..max,ultra. No GUI code changed.
- Full suite, `go test -tags nogui -timeout 45m ./...` on mote at
  ad3a8b1d3 (this change on 593ea437d): 103 packages ok, one red,
  internal/gateway's TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes.
  It is red 3 of 3 on origin/main 6a46bad34 without this change, and
  filed as #7117. (A first run on mica tested nothing: its disk was
  full.) Rebased on 6a46bad34 (three commits in usage, gateway's Gemini
  billing line and the GUI's Settings search), then at the pushed head:
  internal/provider, internal/catalog and internal/codexcat ok, and
  internal/gateway -run 'Ultra|Effort' ok.
- go vet darwin, GOOS=linux, GOOS=windows on provider and catalog: ok.
  gofmt -l: clean.

Not tried: a real relay or Copilot account sending GPT-6.2 at ultra;
real Codex picking Ultra on it (Codex 0.165 here predates 6.2).
2026-11-19 15:31:25 +08:00
yetone 7f11dfc77f gateway: a Gemini CLI sign-in goes without Claude Code's billing line, so Gemini's cache reads its prefix
Reported on X by @niyezaimenglima: Claude Code on a Gemini model through
magpie showed a cache hit rate of 0.

Cause: Claude Code's first system line, x-anthropic-billing-header, carries
a cch= that changes every turn (#1600). On a Gemini CLI sign-in (Code
Assist, Account.Agent "gemini") magpie kept that line at the head of
systemInstruction, so no two turns shared a prefix and Gemini's implicit
cache never matched. dropsBillingLine now drops it there. forwardTranslated
also built the Code Assist body from req instead of sent, so a dropped line
went out anyway; it builds from sent now, as buildFor does.

Scoped to that one route:
- The built-in Antigravity account's cloak already removes the line, and
  its refusal check (#666) judges the system as written. Unchanged.
- The antigravity, agy-cli and zed plugin cloaks cut the line to its end,
  and Claude Code's identity sentence (joined onto the same line) goes with
  it. Cutting only the fields in magpie, as a first version of this did,
  left "You are Claude Code..." on line 1, and a real Antigravity plugin
  account answered its 429 refusal (400 to Claude Code). Plugins keep the
  line.
- Other vendors: unchanged (dropsBillingLine's non-Code-Assist branch is as
  before).

Measured on a real Antigravity plugin account (sandbox HOME, copied
credentials, antigravity/gemini-3.8-flash-low, three Claude Code-shaped
turns, ~8.3k tokens):
- old code: turn 1 cache_read 0, turns 2 and 3 read 6238/6278 (in ~2084).
- a per-turn changing line near the head of the system (what Gemini CLI's
  kept billing line is): cache_read 0/0/0, in 8297/8331/8381. This is the
  reporter's 0.
- new code on the plugin route, stream and non-stream: 6248/6242/6274, so
  the route is unchanged; usage.jsonl matches the response.
- history in the first user message instead of the system: 6246/6288, so
  conversation content is cached too. The last ~2k tokens are never cached
  (Gemini's chunking).

Tests (both red on the old billing_line.go):
- TestBillingLineLeftOutForCodeAssist: a Gemini CLI login end to end, two
  turns with different cch; neither GenerateContent body has the line and
  systemInstruction is the same in both.
- TestBillingLineCodeAssistOthers: Antigravity built-in and an Antigravity
  plugin keep the line; Gemini CLI drops it.

Run:
- Full suite, go test -timeout 45m ./..., on mote at 72e6f9542 (this change
  on 593ea437d): every package ok except internal/gateway, whose only red is
  TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes, #7117, red on
  origin/main too (3 of 3 alone). mica's disk was full (1.2G), so its run
  tested nothing and was discarded.
- Rebased onto 2926b7bef (one commit, usage-record Wire field, no overlap):
  go test ./internal/gateway -run 'BillingLine|CodeAssist|Antigravity|Gemini'
  ok on mote; GOOS=linux and GOOS=windows go vet ./internal/gateway ok;
  gofmt -l clean.

Not tried: a real Gemini CLI account (Google refuses personal Code Assist
sign-ins here), so the Gemini CLI numbers stand in through the per-turn
line above; an AI Studio API key (that route already drops the line,
whether Google reports cached_tokens there is unverified). Not changed: the
agy-cli plugin runs the local agy CLI with its own session and compaction,
and reports agy's cachedReadTokens; that is agy's or the plugin's.
2026-11-19 14:52:25 +08:00
yetone 2926b7beff usage, routing: the model id a request went out under is kept and shown
daoche_wuzui on X asked how magpie serves Antigravity and whether a
request goes out under a suffixed model: nothing showed the id actually
sent. Antigravity's plugin turns gemini-3.7-flash at high effort into
gemini-3.7-flash-high, and a relay's upstream name (ModelWires) renames
a model too; the ledger and Routing showed only the routed model.

- A plugin's reply may carry X-Magpie-Sent-Model
  (provider.SentModelHeader). forward() reads it from plugin providers
  only (a non-plugin's header is ignored) and deletes it, so it never
  reaches the agent. Without it, provider.SentNameOnIn (the upstream
  name, or Antigravity's variant) is used.
- wireName keeps the id only when it differs from the model. It goes in
  usage.Record.Wire (`wire`, omitempty), the trace's Try.Wire, the
  ledger cache and a last CSV column, sent_model (docs/reference.md).
- Usage › Requests: the Sent cell and the detail show the sent id when
  there is one, with "model → sent id" on hover. Routing: a try sent
  under another id gets one aside line, "Sent to the vendor as {model}"
  (zh, zh-TW, ja, de).
- Antigravity's mover min is 0.2.4: plugins 67fb1258 sets the header on
  every reply (stream, whole and errors); its tgz is on the plugins
  repo's dist branch.

Run at this head (ef997d186 + this), on mote:
- gofmt -l: nothing. go vet ./..., GOOS=linux go vet -tags nogui ./...,
  GOOS=windows go vet ./...: ok.
- go test -tags nogui -count=1 -timeout 45m ./...: every package ok but
  internal/gateway, red only in TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes,
  red 5 of 5 alone at origin/main ef997d186 too (#7117, taken).
- GUI: the 46 files that reach the Usage ledger, Routing's tries and
  i18n (i18n-*, ledger-*, usage-ledger-*, routing-try-fixed, sent-model
  and the files that read the Sent cell or an aside): 230 ok; red only
  aside-native (#6212) and usage-ledger-chart's remembered metric
  (#6790), both red the same way at origin/main ef997d186. The whole
  GUI suite (1609 files) was still running at push; its reds so far are
  in account-arrange and the Codex lone-capped-account files.
- sent-model.test.cjs: 10/10, Chromium and WebKit, en zh zh-TW ja de.
- Plugin: bun test packages/antigravity 136 pass, check.mjs ok.

Rebased onto 593ea437d (three gateway/routing commits) before the push,
then again: gofmt; vet of gateway, usage and provider for darwin, linux
and windows; the new tests with the gateway's Wire, Ultrafast and Prefix
tests; sent-model and i18n-keys (14 pass): ok.

Broken by hand, each red:
- no noteWireModel call: TestPluginSentModelIsKept;
- the IsPlugin check removed: the spoofed-header case;
- no SentNameOnIn fallback: TestUpstreamNameSentIsKept;
- an id equal to the model kept: both tests;
- the old GUI assets: every sent-model case; the old usage page.js
  alone: the Sent cell assertion;
- the plugin's old index.mjs: its new test (31 pass, 1 fail).

Not tried: a real Antigravity account (the plugin's header was tested
with its fake vendor only).
2026-11-19 14:45:14 +08:00
yetone ddc78405cf gateway: a magpie's /v1/models offers Ultrafast where its accounts do
OoopsHh on X: a magpie in Docker could pick Ultrafast on a model, but
another magpie that has it as its Remote magpie provider was offered
Fast alone on that model. The remote's list takes its service tiers from
provider.CodexTiers through codexcat.Entries, and CodexTiers only ever
added "priority". Ultrafast came only from Codex's own catalog, which a
magpie with no Codex beside it (Docker) does not have, and the codexcat
branches for Fast and OwnTier models dropped any tier m.Tiers added.

- CodexTiersWith adds "ultrafast" after Fast where provider.UltraOn says
  the key or account offers it (an OpenAI key's Ultrafast models, a
  provider added by its address on OpenAI's Ultrafast models, a Codex
  account whose live list has it), and on a group where a member does.
  UltraModels is read at most once a list, and only after a model
  already shows Fast.
- codexcat keeps those tiers (withTiers) and names "ultrafast"
  "Ultrafast" when Codex's own catalog doesn't.
- The asking side already sends ultrafast to a Remote magpie
  (RemoteTiers), and the remote already asks a member without it for
  priority (tierMate). Both ends need this version: the remote to list
  it, the local one to read it.

A provider added by its address serving gpt-6.1-sol now lists
Ultrafast in /v1/models, /v1/codex/models and magpie-models.json, as its
editor's CanUltra already said; TestModelsListTiersForEveryClient,
TestRemoteMagpieOffersItsTiers and TestCodexCatalogTiersReachDisk
expect it.

Tests:
- TestRemoteMagpieOffersUltrafast: a relay's gpt-6.2-sol and a group of
  it list "priority ultrafast"; a Remote magpie provider reading that
  list has CanUltra on both, and an ultrafast ask through it reaches the
  vendor as ultrafast. Red on 7d5db0f29 (tiers "priority" alone, no
  CanUltra).
- TestOpenAIKeyUltrafast: an OpenAI key's /v1/models lists ultrafast on
  gpt-6-astra and not on gpt-6-sol, and its trace's order says Ultra
  on the pick (Weighed.Ultra, previous commit).
- tui, codexcat, provider and agent, and gateway's
  'Tier|Ultra|Remote|Fast|Codex' tests: ok on mote.
- go vet ./..., GOOS=linux go vet -tags nogui ./..., GOOS=windows go
  vet ./... and the three builds: ok on mica. gofmt -l clean.

Full suite (both commits; go test -count=1 -timeout 45m ./... on mica,
load ~30 on 12 cores): 99 packages ok. Reds, each filed and none in
code this touches:
- agent TestWSLAgentFolderIsALink (#7150, ~1 in 6 on main);
- dirent's five watch tests (#7031, a busy Mac);
- gateway TestOpenCodeGoOwnFreeModelGetsNothingOfOpenCodes (#7117, red
  on origin/main);
- gui TestGatewayModeListsNoOwnSessions (#7064);
- sessions timed out at 45m in TestWSLAntigravityLinkedHomeOnce under
  that load (#5451). Run alone with -timeout 90m: ok in 2925s on mica,
  ok in 62s on mote (origin/main 3869aee3b: ok in 54s on mote), so the
  time is mica's, not this change's.

The full suite ran on the base 3869aee3b. After a rebase onto ef997d186
(no files in common), at this head on mote: go build ./..., the three
go vets, tui, codexcat, provider, agent, gui's Budget/Group/Fast/Ultra
tests and gateway's Tier/Ultra/Remote/Fast/Codex tests ok;
group-member-fast, routing-ultra-row, routing-service-tier, gui-de,
gui-ja, gui-zh-tw and i18n-* 50 of 51 (gui-ja's "Gets copies" string,
#7144, on main).
2026-11-19 14:02:17 +08:00