Commit Graph
22 Commits
Author SHA1 Message Date
yetone 9be72c9480 zcode: a level's thinking carries its budget, and the user's own level options stay (#3852)
Review of d7e1e284f, two things it changed beyond its case:

- Every level that thinks was written as {"thinking":{"type":"enabled"}}
  with no budget_tokens. ZCode puts a level's options in the request, so
  a Claude before 4.6 (Sonnet 4.5, Haiku 4.5, a relay's) asked through
  magpie at any level would be sent "enabled" without the budget
  Anthropic's Messages API requires with it, a 400 it didn't get before.
  Each level now carries the budget the gateway reads that effort as
  (gateway.ThinkingBudget, budgetOf: low 4096 ... max 32000). The
  gateway already makes it adaptive for Claude 4.6 and later
  (adaptiveThinking; ZCode's output_config.effort wins over the budget)
  and fits it under max_tokens (maxoutput.go).
- providerOptionsByLevel was written over on every sync. A user who put
  their own there (the workaround for this very bug) lost it. A level's
  options already in config.json now stay; no magpie before #3852
  wrote any, so whatever is there is the user's.

Tests: TestZCodeOutputAndReasoning expects the budgets;
TestZCodeKeepsTheUsersLevelOptions keeps a hand-written high level and
fills the others.

Run on mote: go test -run TestZCode ./internal/agent, ok. Broken by
hand: the kept options ignored and the budget left out, and those two
tests fail.
Not tried: a real ZCode 3.x (this Mac has Z Code 0.9.1, a different
app; mote has none), so ZCode putting the options in the body is the
reporter's and the author's reading of zcode.cjs, not seen here.

Batch record (gua's #2833 #3052 #3205 #3867 #4107 #4247 #4245 #4113
#3852 and the three review follow-ups; #4106 left out, its test isn't
red without its fix, see the issue):
- Full run on mote before the rebase (base fa4704f06): gofmt -l clean;
  go vet on darwin, GOOS=linux -tags nogui and GOOS=windows clean;
  go test -count=1 -timeout 45m ./...: 85 packages ok, internal/gui red
  in TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
  TestMainWindowCorners/macOS_26_SDK (#3949), both already filed, and
  neither in a file this batch touches.
- Rebased on origin/main 9162277b9, at this tree, on mote: gofmt clean;
  go test -count=1 -timeout 45m ./internal/gateway/... ./internal/agent
  ./internal/library ./internal/handoff ./internal/routes, all ok
  (and ./internal/redact ok at the base before, b2145eac1). Then
  rebased again on ccb75030a (#4371, fastjson.go only) and
  ./internal/gateway/... run again at that tree: ok (636s). Pushed on 8ac1c7a56 (internal/catalog
  only), where catalog, handoff and library ran whole and the batch's
  gateway (Bili, TestRuleCompact, Kimi, TestClaudeMem, the two stall
  tests) and agent (TestZCode) tests ran: all ok. The whole gateway
  package was not run again on top of 8ac1c7a56.
- Windows (win-run): -run TestClaudeMem ./internal/gateway ok; with
  claude_room.go put back, TestClaudeMemRunsFromTheCgroup hangs in
  readLimit to the 5m timeout.
- Linux (wsl-run): ./internal/handoff ./internal/library ok; with the
  fixes put back, TestGiveKeepsTheListenerNonblocking,
  TestSaveDropsEmptyApplied and TestSyncAloneLeavesNoEmptyApplied fail.
Not tried: real Kimi, ZCode 3.x, Alma or bili accounts; #4245 is a
test-only change and was not reproduced red.
2026-11-01 10:26:42 +08:00
ggbdpq bc7d833916 zcode: the reasoning keys ZCode reads, not OpenCode's (#3852)
magpie's ZCode takeover wrote a model's reasoning as
{"enabled":true,"variants":[…],"defaultVariant":…} — OpenCode's
shape, which ZCode's config.json provider entry is loosely modeled
on. ZCode's own schema for it is
{enabled?, levels?, defaultLevel?, providerOptionsByLevel?}
(resources/glm/zcode.cjs, same in the 3.12.3 the issue reports and
in the 3.16.3 checked on this machine; "defaultVariant" has no
occurrence in the 3.16.3 runtime at all). Its .passthrough() keeps
the unknown keys and ignores them, so ZCode picked a level, sent
output_config.effort and never a thinking field — and an
always-thinking upstream model (Kimi Code's kimi/k3.1-pro, for one)
refused every request with 400.

magpie now writes the keys ZCode reads: levels and defaultLevel it
had all along, plus providerOptionsByLevel with thinking on for
every level and off for the one named "disabled". The kept default
a sync reads back now looks for defaultLevel, falling back to the
defaultVariant an older magpie wrote (a key ZCode never read, only
magpie) so a user's choice survives the first sync after the
upgrade. The provider_config.json rule side is untouched: its
optionSpecs.reasoningLevel.values is already a key ZCode reads.

The OpenCode family keeps variants/defaultVariant: there those are
the keys the app reads.

Fixes #3852

Generated-by: GLM-5.3-Flash (ZCode)
2026-11-01 10:22:57 +08:00
yetone bb478f0e50 agent: a look that only ranges over magpie's models reads the list kept
magpieModels gives each caller its own copy of the list it keeps per
agent. Most callers only range over it, or count it, and a range copies
each model anyway, so the copy guarded nothing for them (the models'
own lists were shared before too: the copy was shallow). sharedModels
is the list kept, read only; every `range magpieModels(` and
`len(magpieModels(` in internal/agent (39 files) takes it. Callers that
keep the list, append to it or hand it on still get their copy.

Real accounts (sandbox copy of the owner's HOME, network blocked), 40
polls of /api/state, /api/providers and drift, pprof alloc_space
between two heap snapshots, 616405061 (mrows) vs this (mshare):
  stampedLists.get's slices.Clone 36.7 MB -> gone (under pprof's cut);
  most of it was piOffered (22.5 MB) and claudeViaMagpie (13.7 MB)
  total 637 MB -> 584 MB (runs vary +-25 MB)
  /api/state and drift bodies byte-identical, /api/providers equal but
  for `fetched` and `lapsed` (a refused refresh in the blocked sandbox)

TestModelReadersShareTheList: sharedModels gives the kept array, not a
copy, and no non-test file in internal/agent ranges over or counts
magpieModels(. Broken by hand on mote: sharedModels through get fails
"a shared look copies the kept list"; one `range magpieModels("kimi")`
put back fails naming kimi.go.

Run on mote at this tree (before rebase): gofmt; go vet for darwin,
windows and linux; the new test with TestMagpieModelsKeptWhileCatalogStays,
TestKeptListSharedWithoutACopy and TestViaMagpieKept 3/3 ok;
go test ./internal/agent ok (201s); go test ./internal/gui: only the
known reds TestSettingsSaveKeepsWhatItDoesNotSend (#4514) and
TestMainWindowCorners (#3949).
Not run: the full ./... suite.
2026-11-01 06:09:56 +08:00
yetone 6712e367e8 agent: a look at the stash shares one read of it
Each /api/state and /api/drift poll asked the stash (stash.json) for one
value hundreds of times, through Detected, Drift and the agents' wiring
checks, and each ask read the file and parsed it again. In a real-account
heap profile (20 rounds of drift, state and providers) stashLoad was
24-34 MB of what was allocated.

stashShared reads it through filememo.Read, so every look shares one
parse until the file changes, by magpie or by another process. Every
read-only caller uses it now, the 24 files here and QwenPaw's
unstashPeek. stashLoad, which callers change and write back, still gives
each its own map, cloned from the same parse.

Real use: the owner's real-account sandbox, offline (proxy to :9),
20 warm rounds of /api/drift, /api/state and /api/providers:
- allocated 477 MB (d307aa648) -> 411 MB; stashLoad is out of the
  profile.
- /api/state and /api/drift bytes identical to d307aa648's (cmp).

Run on mote (mote-run, Go 1.26.8), at this head rebased on d307aa648:
- gofmt clean; go vet ok, also GOOS=windows and GOOS=linux.
- TestStashLooksShareOneRead alone, 3 times: ok.
- Broken by hand (stashShared reading through stashLoad): red, "a look
  at the stash read and parsed it again".
- go test -timeout 45m ./internal/agent ./internal/gateway: ok (263s,
  691s).
2026-11-01 05:32:29 +08:00
yetone c358e76607 zcode: on Windows, write where ZCode reads, %HOME% before %USERPROFILE%
Gearclickist on Discord: magpie connects ZCode without an error, but
ZCode on Windows never lists magpie as a provider; on a Mac it does.

ZCode 3.14.3 (the same JS in the Mac and Windows builds, diff -rq of the
extracted app.asar) picks its data folder from setting.json's dataBaseDir,
then ZCODE_DATA_BASE_DIR, then process.env.HOME, and only then
os.homedir() (USERPROFILE). magpie used Go's home, which on Windows is
USERPROFILE. With HOME set (Git Bash, MSYS2, Emacs and the like), ZCode
reads %HOME%\.zcode\v2\provider_config.json and magpie wrote
%USERPROFILE%\.zcode\v2\..., a folder ZCode never opens. On a Mac HOME is
Go's home too, so the two always met.

appdir.ZCodeHome gives %HOME% on Windows when it is set, absolute, and
the folder asked about is USERPROFILE (a folder given on purpose is
kept). The agent target, the ZCode credential and team readers and the
library target use it. ZCode's CLI database stays under USERPROFILE (seen
on Windows below), so the sessions reader is unchanged; its comment says
why.

Run:
- go test ./internal/agent/ -run TestZCode; the new
  TestZCodeOnWindowsUsesTheHomeZCodeReads forces zcodeOS=windows with
  HOME and USERPROFILE apart. Broken by hand (ZCodeDataIn(home) back in
  zcode()): red, "ZCode's folder on Windows with HOME set: .../001/.zcode
  ... want .../003/.zcode".
- gofmt -l; go vet for darwin, linux (-tags nogui) and windows.
- Windows box, sandbox folders only, HOME and USERPROFILE set apart:
  ZCode 3.14.3 for Windows, extracted and started there, kept its logs,
  workspace and provider_config.json under HOME\.zcode\v2 and only
  cli\db under USERPROFILE. The old magpie.exe's `zcode provider magpie`
  wrote profile\.zcode\v2\{config,provider_config}.json (the bug); this
  build's wrote home\.zcode\v2\..., beside ZCode's own files, and nothing
  under the profile.
- Full suite (go test -timeout 45m ./..., one at a time on the box):
  68 packages ok, exit 0, at d87be7f13 and again after rebasing onto
  b00c82acf (tree of this commit).

Not tried: the reporter's own machine (their HOME is inferred, not
confirmed); ZCode's picker on the Windows box (it ran over ssh, without
a desktop, and exited with the session), so "lists magpie" is read from
where ZCode keeps its files, not seen; the provider and library siblings
have no forced-OS test of their own; ZCODE_DATA_BASE_DIR and
ZCODE_DESKTOP_HOME_DIR are not followed.
2026-10-22 04:32:46 +08:00
yetone e4ac5e8712 zcode: models magpie writes have native web search on, and a model the user unticked stays off (Gearclickist on Discord)
Gearclickist (#help, 10-19): every model magpie writes into ZCode came
without web search, and each had to be ticked by hand in its settings.

ZCode 3.14 keeps the switch ("原生联网搜索") as
config.properties.supportsNativeWebSearch on a model rule in
provider_config.json (read from ZCode.app's own bundle). It only works
with an anthropic-messages provider, where ZCode sends a
web_search_20260209 tool, which the gateway already serves; on other
formats ZCode's WebSearch throws. Unticking writes nothing: ZCode drops
the key from magpie's rule because false is its default.

zcodeRules now:
- turns it on for each model magpie lists, on Anthropic Messages only,
  including rules an older magpie wrote without the key;
- remembers which models it turned on in the stash (zcode.web_search),
  so a model whose key went missing was unticked by the user and stays
  off on every later sync;
- keeps any value already in the rule, true or false;
- leaves manualProviderModelRules alone and drops those ids from the list;
- on another format takes back only its own true;
- turns nothing on when stash.json can't be read or parsed (unknown);
- forgets the list on disconnect.
config.json (pre-3.14 shape) has no such field and is unchanged.

Known gap, not fixed here: other edits a user makes in ZCode to a model
magpie lists (JSON output, mid-conversation system, context window) land
in the same rule and are still rewritten on sync.

Run at this head:
- TestZCodeWebSearch (new) fails on the old zcode.go ("first sync: pro is
  <nil>, want true"). Broken by hand, it goes red at each guard: the
  untick check removed ("unticked: flash is true"), the take-back on
  another format removed ("chat completions: pro is true"), and an
  unreadable stash read as empty ("unreadable stash: flash is true").
- go test -run TestZCode ./internal/agent/: ok.
- gofmt -l .: clean. go vet ./... on darwin, GOOS=linux -tags nogui,
  GOOS=windows: clean.
- set -o pipefail; go test -timeout 45m ./... (sandbox HOME, at 94df23926
  + this change, load average ~180 from six other sessions' suites): 63
  packages ok; internal/agent hit the 45m timeout, stacks show
  TestClaudeBehindLocalProxyKeepsIt running for 15s, no hang (the known
  #2723/#2544). Rerun alone: go test -timeout 45m ./internal/agent/ ok,
  1633s.

Not tried: the real ZCode app (no live config touched); the sync was
run only against provider_config.json files written in a sandbox HOME
in the shape ZCode 3.14 writes.
2026-10-20 00:45:12 +08:00
yetone 0ad9661b60 agent: a Max output the user set reaches VS Code, Copilot JetBrains, ZCode, WorkBuddy and CodeBuddy as set (#2064)
DeepSeek V4.1 Flash with Max output 384k set in magpie reached VS Code
as 250000 (its context/4 trim) and WorkBuddy, CodeBuddy and ZCode as
128000 (zcodeOutput), so the number typed in magpie looked ignored.
Those trims are for a vendor's figure; a value the user set
(settings ModelOutputs, per model or per provider) is now carried as
provider.Entry.OutputSet -> catalog.Model.OutputSet, and outputOr hands
it on as it is (still within the window, as maxTokens keeps it). A
model nothing was set on gets the same numbers as before.

buddyModel no longer trims inside: the trim moved to its caller with
the others, so TestWorkBuddyEfforts' direct call now sees 500000.

Run: gofmt -l (clean); go vet for darwin, GOOS=linux -tags nogui and
GOOS=windows ./... (clean); go test -tags nogui ./internal/agent/
(-timeout 40m under load 200+; the first run hit the default 10m),
./internal/provider/ ./internal/catalog/ ./internal/gui/
./internal/codexcat/, all ok. New TestAgentsTakeTheUsersMaxOutput
checks every agent's written file with nothing set (old numbers) and
with 384000 set on the provider; with outputOr reverted it fails
("384k set, vscode-oai-in: 750000").

Not tried: real VS Code, CodeBuddy, WorkBuddy and ZCode reading the
files; whether Command Code's API serves max_tokens over 200000 (the
probe key was refused, UNAUTHORIZED).
2026-10-14 15:23:05 +08:00
yetone 2eee900dc9 agent: eight more syncs keep what the user set on magpie's block (#2030's siblings)
1e654d8ce fixed T3 Code's sync, which rewrote magpie's provider instance
whole. The same shape lost user-set keys in eight more agents. On every
Sync and every pick, each one rewrote magpie's own block in the agent's
config whole. Each app's schema was taken from its own source, never
guessed:

- Qoder 1.1.70 (@qoder-ai/qodercli bundle): providers.magpie lost routing
  (the compact and subagent models), firstPayloadTimeoutMs,
  streamIdleTimeoutMs, type, authType, anthropic and a displayName.
- fx (vercel-labs/fx configured_provider.zig): reviewer_model was lost,
  and a tool_choice_mode of "omit" went back to "send". auth stays
  magpie's whole, since fx refuses an env beside type none.
- Hermes (hermes_cli/config_providers.py): `hermes model` itself writes
  default_model into providers.magpie. That was lost, as were key_cmd,
  the timeouts, extra_body, a name and extra headers. This held in every
  profile spread() writes.
- omp (models-config-schema-bundle.ts): modelOverrides, discovery,
  disableStrictTools, headers and compat flags were lost. auth and
  apiKey stay magpie's, or go, so a loopback's auth: none never sits
  beside a WSL key.
- Kimi Code (configSection.ts ProviderConfig): SetTOMLTable replaced
  [providers.magpie], losing inline custom_headers, env and
  default_model. Its three keys are now set in place.
- Cline (local-provider-registry.ts): models.json lost the provider's
  other keys, and the per-model overrides that the VS Code model editor
  writes. A model magpie no longer lists still goes.
- Goose (declarative.rs): the custom provider file was rewritten whole,
  losing display_name, timeout_seconds, toolshim, other headers and the
  like. Goose's own editor carries those keys over.
- ZCode (provider-data-schema.ts, strict): the provider rule lost
  providerName, logo, visibility, api.headers and
  access.apiKeyManagementUrl. Only keys already in the file, which ZCode
  accepted, are kept.

Each merge lays magpie's block over what is there. magpie's parts (the
address, the key, the format and the model list) are named, and a key
magpie stops writing goes with them. The JSON ones use theirsKept or
mergeKept. A new yamlKept does the same for Hermes and omp.
agent-wiring.md lists what each one keeps.

Tests: Test{Qoder,Fx,Hermes,Omp,Kimi,Cline,Goose,ZCode}KeepsTheUsersSettings.
Each one:
- connects;
- sets the user's keys the way the app writes them, plus a stale
  address and a stale model;
- adds a provider, then syncs 3 times and picks again;
- checks that the user's keys stay, that magpie's parts are rewritten,
  and that the stale model is gone.

All eight fail on origin/main's agent code (each reports "the user's
settings not kept") and pass with this change.

Run, in a sandbox HOME, with GOCACHE in the scratchpad and Go 1.26.8:
- gofmt -l on the changed files: clean.
- go vet ./... (darwin), GOOS=linux go vet -tags nogui ./... and
  GOOS=windows go vet ./...: clean.
- go test -tags nogui -timeout 45m ./internal/agent: ok, 805s.
- go test -tags nogui -timeout 45m ./...: all ok.

Not tried: none of these apps was run against a real config written by
this change. Their schemas come from their source (Qoder's npm bundle,
fx, Hermes, oh-my-pi, kimi-code, cline, goose and ZCode at their current
heads), not from a live install.
2026-10-14 09:21:18 +08:00
yetone 41972b25fc zcode: magpie's provider reaches a ZCode whose data was moved to another folder in its settings (flower on Discord)
What changed: ZCode 3.14 has a 数据存储路径 (data storage path) setting.
Changing it copies ~/.zcode/v2 to <folder>/.zcode/v2, and from the next
start ZCode reads its providers (provider_config.json, config.json),
credentials.json and runtime/provider from there. The choice stays in the
home folder's .zcode/v2/setting.json as dataBaseDir, which ZCode's main
process reads first (readBootstrapDataBaseDirFromDisk, then setDataBaseDir;
getDataBaseDir is that, else ZCODE_DATA_BASE_DIR, else HOME). magpie always
wrote ~/.zcode/v2, so for such a user it said ZCode was connected while
ZCode's 模型设置 showed only BigModel and Start Plan and no magpie.
appdir.ZCodeDataIn reads dataBaseDir the way ZCode does (trimmed, ignored
when empty or relative); the ZCode agent target, the ZCode subscription's
credentials.json and its zcode-builtin.json glob use it. Skills, AGENTS.md
and the CLI's cli/config.json stay under the home folder: ZCode reads
those from HOME/USERPROFILE (getUserZcodeSkillRoot, the MCP config path),
so internal/library is unchanged. ZCode's session database
(internal/sessions) is not changed here: where ZCode's CLI keeps it under a
moved folder was not checked.

Read from ZCode 3.14.3's app.asar (copied to the scratchpad):
out/main/index.js (bootstrap, setDataBaseDir, buildHostProcessEnv passing
ZCODE_DATA_BASE_DIR), out/host/chunk-*.js (getAppConfigDir =
<base>/.zcode/v2) and out/host/index.js (provider_config.json under it).
flower hasn't said they moved the folder; this is the one way found in
ZCode's code for "magpie says connected, ZCode has no magpie" with a
provider_config.json magpie wrote. That file, and the one this build
writes, decode with ZCode's own decodeProviderConfigFile (run from a copy
of glm/zcode.cjs): providers ["magpie"].

What was run:
- TestZCodeMovedDataFolder (new): with dataBaseDir set, Set("magpie")
  writes both files under the moved folder and none in ~/.zcode/v2; an
  empty, blank or relative dataBaseDir keeps ~/.zcode. On the old
  zcode.go it fails: "no magpie in the moved folder's
  provider_config.json".
- Sandbox, built binary: HOME=<sandbox>, setting.json dataBaseDir=<sandbox>/D,
  `magpie zcode magpie` wrote D/.zcode/v2/{config,provider_config}.json
  and nothing under the home folder's .zcode/v2 but setting.json.
- go test -tags nogui ./internal/agent ./internal/appdir ./internal/provider
  under a temp HOME; gofmt -l; GOOS=linux and GOOS=windows go vet -tags
  nogui on the three packages.
- Not run: the ZCode app itself with a moved folder (not launched against
  any config), and Windows.
2026-10-13 16:21:56 +08:00
yetone bc320e249f agent: T3 Code, Air, OpenChamber and the rest send the LAN key to a gateway pinned beyond loopback (#1647, ggbdpq)
The gateway takes gateway.Token, and the keys that name an agent
(gateway.TokenFor), only from loopback. When MAGPIE_ADDR pins the
gateway to an address beyond loopback and sharing is on, keyAt gives the
LAN sharing key, and most writers use it. T3 Code's instance still wrote
gateway.Token, so every call it made got 401. Air's and OpenChamber's
Checks compared against gateway.Token, so they said the wiring Sync had
just written was off.

The same mistake was in every writer that pairs gateway.URL() or
gatewayV1() with a fixed token:
- agy, Alma, Cindy, Claude Desktop, Copilot for JetBrains, Cursor's
  local agent, OpenHanako, Pencil, VS Code / Insiders / VSCodium,
  WorkBuddy-family models.json, ZCode (both files), Zed's credential,
  Aside's provider, and the legacy Claude token rename.
- Fix: these now take agentKey(agent) or hereKey(), which are keyAt and
  agentKeyAt for gateway.URL(). On loopback they are unchanged.
- Alma re-keys a provider that holds any of magpie's keys other than the
  one it should have now.
- WorkBuddy and Aside also count the new key as theirs.
- ZCode treats a saved address equal to the pinned gateway as this
  machine's, not another magpie's.

What was run:
- New tests: TestT3CodeKeyBeyondLoopback and
  TestAirAndOpenChamberChecksTakeTheKeyForTheGateway (from the
  reporter's patch), and TestPinnedGatewayKeyForEveryWriter, which covers
  the other writers.
- With the product files reverted, all three are red. The T3 token reads
  "magpie", and each of the 11 writers shows its old key. They are green
  with the fix.
- go test -tags nogui ./internal/agent/ is green.
- gofmt -l and go vet are clean on darwin, linux and windows.

Not tried with a real T3 Code, Air, OpenChamber or a real pinned
MAGPIE_ADDR on a second machine.
2026-10-12 00:44:47 +08:00
yetone ede1e32aec agent, gui: ZCode's row picks which of magpie's models its picker lists, as Pencil's, T3 Code's, WorkBuddy's and Copilot in JetBrains' do now (#1508, NovaTrailX)
settings.hiddenModels had no "zcode", and ZCode's ~/.zcode/v2/config.json
and provider_config.json listed every model. The files magpie writes for
ZCode already leave out what is hidden for it (magpieModels(id) reads
provider.CatalogFor), but its row had no list to hide one in: ZCode's only
field puts magpie in its own picker, with no option among the catalog, and
the Agents page gives a models line and menu only to an agent that has
one (takesCatalog) or ListsModels (Cursor Private Inference).

Audit of every agent row: each agent with a field among the catalog
(viaMagpie) already had the list. Those whose only field puts magpie's
models in their own picker had none: zcode, pencil, t3code, workbuddy,
workbuddy-ai and copilot-jetbrains. They now set ListsModels; Claude
Desktop's tier pickers list the catalog once connected, and cursor-local
had it already.

- agent: ListsModels on those six, its doc says when it applies.
- gui/api.go: the row's JSON says menu (ListsModels), so app.js gives it
  the models button as it does Claude Desktop's and Cursor's, rather than
  a hard-coded set of ids.

Tests:
- TestEveryPickerOfMagpiesModelsCanBeNarrowed: any built-in agent that
  puts magpie in a picker with no option among the catalog and no
  ListsModels fails, so a new agent can't miss it.
- TestZCodeListsOnlyThePicked: from a config the user edited by hand (own
  providers, theme, rules, a manual rule for one of magpie's models, ui
  lang), hiding one model takes it out of both files at the next sync and
  showing it puts it back; the user's entries stay at every step.
- TestZCodeModelList: through the GUI handlers: connect, the row has
  menu and 2/2, hide one, settings.hiddenModels.zcode is set, the row
  reads 1/2, and after SyncCatalog both files list only the other.
- tests/zcode-models.test.cjs: ZCode's row in en, zh, zh-TW, ja, de, in
  the window (1100px) and the tray panel (420px), Chromium and WebKit:
  the line, the menu button, unticking one posts it and the count drops,
  ticking it back; no scroll, no <select>, no overflow. 20/20.
Without ZCode's ListsModels, the first and third fail (tried); without
a.menu in app.js, all 20 GUI cases fail (tried). All in a sandbox HOME;
the live ~/.zcode was never touched.

Run: go test -tags nogui ./internal/agent ./internal/gui; gofmt -l;
GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent
./internal/gui; node --test on zcode-models, agent-model*, agent-models-*,
agent-notice-lang, click-scroll, cursor-local-*, gui-de/ja/zh-tw and
i18n-keys, both engines: all pass (three load timeouts under a machine
load of ~140 passed rerun alone).

go test -tags nogui -timeout 40m ./... on the rebased tree: every package
ok but internal/gateway, whose TestQueuedStreamKeptAliveForTheMinute hit
its 1.5s read deadline at a machine load of ~130; it passes -count=3 run
alone, and this change touches nothing it runs.
2026-10-11 02:34:30 +08:00
yetone 20582866a5 agent, gui: an agent's advice after a change reads in the window's language (#1508, NovaTrailX)
A Chinese window said "ZCode 已接入 magpie. ZCode reads its providers at
start-up — restart ZCode …": the notice an agent gives after a change
(state.notice) was English text written in place in each agent's file, and
i18n.js had no entry for any of them.

What changed:
- internal/agent/notice.go: a notice is a template registered with
  newNotice ("Restart {agent} to …"), filled with say(kv...); Notices()
  lists every one. All the agents' notices (claude, codex daemon, zcode,
  agy, cursor-local, wsl, AstrBot's added today, …) are now such templates, the issue's list
  being a sample of them.
- i18n.js: every template has a zh, zh-TW, ja and de translation, and
  NOTICES lists them. tNotice() reads a notice of several joined: longest
  template first, a {slot} never runs over a sentence's end, and a notice
  with any part that has no template (a plugin's own) reads as given
  rather than half in each language. withNotice() joins the status line
  and the notice with 。 in zh/ja.
- app.js: the six places that showed state.notice use withNotice.

Tests:
- TestEveryNoticeIsTranslated: every Notices() template is in NOTICES and
  in each language table, with the same slots. Fails with the zh ZCode
  line deleted from i18n.js (tried).
- TestNoticesAreTemplates: an AST scan for English written in place as a
  Notice. Fails with zcode.go's literal put back (tried).
- tests/agent-notice-lang.test.cjs: every template, filled, alone and
  joined, plus a plugin's notice, and connecting ZCode as the reporter
  did; en, zh, zh-TW, ja, de at 1100 and 420px, Chromium and WebKit:
  22/22. Its zh subtests fail without the zh line.

Run: go test -tags nogui ./internal/agent ./internal/gui; gofmt -l;
GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent
./internal/gui; the full GUI suite (node --test, both engines, -concurrency 6,
machine load ~140): 5130/5195, 64 failing in 22 files. Rerun alone, 16
files pass; mobile-web, old-webkit, panel-usage and routing-context/
group/keys-fold fail the same on the base commit, b6a263b9.

go test -tags nogui -timeout 40m ./... on the rebased tree: every package
ok but internal/gateway, whose TestQueuedStreamKeptAliveForTheMinute hit
its 1.5s read deadline at a machine load of ~130; it passes -count=3 run
alone, and this change touches nothing it runs.
2026-10-11 02:34:30 +08:00
yetone d9bf7c1ccf zcode: the API format the user picks for magpie's provider in ZCode's settings stays theirs; a sync no longer puts Anthropic Messages back on every start (杰多夫 on Discord)
What changed: zcodeRules wrote api.type "anthropic-messages" into
provider_config.json, and zcodeProviderJSON wrote kind "anthropic" into
config.json, on every sync (magpie's start, any catalog change). A user who
switched the provider to OpenAI Chat Completions or Responses in ZCode had it
switched back the next time magpie started. zcodeFormat now reads the format
already there and keeps it, in both files: provider_config.json's api.type
(ZCode 3.14 on) or config.json's kind (older ZCode), the one written last
where they differ, mapped as ZCode maps them (anthropic-messages/anthropic,
openai-chat-completions/openai-compatible, openai-responses/openai). A new
provider, or a format ZCode doesn't have, is Anthropic Messages as before.

Why it's safe: magpie's gateway answers all three at the same base address.
Checked with ZCode 0.16.9's own agent CLI (glm/zcode.cjs -p, run from a
copy under a sandbox HOME, never ~/.zcode) against a sandbox gateway with
the DeepSeek provider: anthropic-messages asks /v1/messages,
openai-chat-completions /chat/completions, openai-responses /responses, and
a tool-using turn (Read a.txt) answered 200 on each, to deepseek-flash.

What was run:
- TestZCodeKeepsUserFormat (new): a format picked in provider_config.json,
  for each of the three, survives two syncs and is carried to config.json's
  kind; one picked in config.json is carried to provider_config.json; an
  unknown one isn't kept. On the old zcode.go it fails: "picked
  openai-chat-completions: kind "anthropic", api "anthropic-messages"".
- Sandbox, real binaries: provider_config.json set to openai-responses,
  then `magpie zcode magpie`: the old build wrote anthropic-messages back,
  this one kept openai-responses (config.json kind openai). Then
  openai-chat-completions, resynced, and the real ZCode CLI ran a turn on the
  file magpie wrote, served over /chat/completions.
- gofmt -l; GOOS=linux and GOOS=windows go vet -tags nogui ./internal/agent;
  go test -tags nogui ./internal/agent under a temp HOME: ok.

The "bcww: Field required" 400 on Anthropic Messages is not part of this
commit: ZCode's real requests (captured from its CLI, plain and with web
search) to deepseek/deepseek-flash through magpie returned 200, and DeepSeek
answers schema errors in serde's words, not "Field required".
2026-10-10 09:58:30 +08:00
yetone 54c3cb06fc agent: the default thinking effort set on one of magpie's models in WorkBuddy stays through a sync, as it does in CodeBuddy Code, ZCode, Kimi Code and MiniMax Code (悠悠哥 on Discord: 供应商能设置模型默认的思考强度吗,我的workbuddy每次手动设置了思考强度,还是会被更新覆盖掉)
WorkBuddy's Settings > Models saves an edited custom model whole into
~/.workbuddy/models.json: reasoning.defaultEffort (absent for its Auto), and
the vendor of the provider it matches, which for magpie's entries is the
"Custom" provider's (WorkBuddy 5.x app.asar: inferProviderIdFromLocalCustomModel,
the form's save in ui-docs-viewer). buddyWrite knew its entries by vendor
"magpie" only, so a sync kept the edited entry as the user's and added
magpie's own with the same id and magpie's default effort; one set by hand
under vendor magpie was simply rewritten.

buddyWrite (WorkBuddy and CodeBuddy Code) now also knows magpie's entries by
their key (magpie-<agent>, or a NAS magpie's key already on its entries),
and keeps each model's defaultEffort (or the older reasoning.effort) while
the model still offers that level; WorkBuddy's Auto stays Auto. A new model
gets magpie's default; a model magpie no longer has is taken out, the edited
one included. The same rule (keptEffort) keeps a hand-set default in ZCode's
config.json (defaultVariant), Kimi Code's config.toml (default_effort) and
MiniMax Code's config.yaml (thinking.defaultEffort), which a sync rewrote too.
The composer's own effort pick is WorkBuddy's localStorage
(cb-effort:by-model), which magpie never touched.

Verified: kept_effort_test.go (TestWorkBuddy/CodeBuddy/ZCode/Kimi/MiniMax
KeepsTheUsersDefault*) fail on the old writers, WorkBuddy's with
"think/wide twice" and the rest with magpie's default back; pass with this,
-race -count=3. go test -tags nogui ./... green under a temp HOME; go vet,
GOOS=linux and GOOS=windows builds. Not tried in the real WorkBuddy app: the
fixture follows its save code, not a file it wrote.
2026-10-07 01:44:03 +08:00
yetone 63f83bf1e1 agent: a ZCode pointed at another machine's magpie in either of its files stays there in both (悠悠哥 on Discord: ZCode wired to the magpie on a NAS kept being switched back to the local one) — v0.1.812 kept a remote address per file only, but ZCode's own settings write provider_config.json alone, so a sync rewrote config.json to this machine's gateway and ZCode could take the provider back from it. A sync now reads magpie's provider in both files (zcodeKept): an address on another machine in either one is written to both, with its key; otherwise the gateway's. TestZCodeKeepsRemoteAddress edits each file alone to a NAS address and syncs; it fails on the old code (config http://127.0.0.1:3425, rules the NAS). Check chain under a temp HOME passes. 2026-10-05 00:52:06 +08:00
yetone 04d4bae323 agent: ZCode's magpie provider pointed at a magpie on another machine keeps that address and key when magpie syncs its models (Discord, 悠悠哥: ZCode connected in a local magpie for its model list, then its base URL and API key changed by hand in ZCode to a magpie deployed on a NAS, kept going back to the local gateway's, they guessed on each update) — ZCode's Sync, which runs whenever magpie's models change and brings the provider in ~/.zcode/v2/config.json and the rule in provider_config.json up to date, wrote options.baseURL/apiKey and config.api.baseUrl/access.apiKey as gateway.URL() and gateway.Token every time. A sync now keeps an address the provider holds whose host isn't this machine's loopback (onAnotherMachine: an http(s) URL with a host other than localhost, a loopback or unspecified IP), with its key (magpie's token where it has none), and refreshes only the models; one on loopback still follows the gateway, so a magpie on another port keeps rewiring it. Picking magpie in the agent's provider field (Set) points it at this magpie as before. TestZCodeKeepsRemoteAddress: a NAS address kept by a sync in both files while a new model arrives, a loopback one moved to the gateway, connecting in magpie resets a NAS one, and onAnotherMachine's cases. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass. Not tried in ZCode itself with the reporter's NAS; the models listed are this magpie's, so one the NAS's magpie doesn't serve is refused there. 2026-10-04 11:45:08 +08:00
cyxer000 f3b45634a3 agents: Droid, Qoder, OpenHanako, WorkBuddy, OpenCode and ZCode no longer get an output limit above the model's context window (#347) 2026-10-01 00:27:00 +08:00
yetone c0b296b300 agent(zcode): a magpie model tells ZCode how long a reply may be and how hard it can think — ZCode's model dialog showed 32000 max output tokens and thinking only on or off for every magpie model. config.json's models now carry limit.output and reasoning {enabled, variants, defaultVariant} (medium where the model has it, else its middle level; none is ZCode's disabled), and provider_config.json's rules, which ZCode 3.14 reads, carry optionSpecs {maxOutputTokens.max, reasoningLevel.values}, as ZCode's own rules do. An output over 128000 is capped: some vendors report their window there (grok's 500000). Asked on Discord 2026-09-26 23:04:38 +08:00
yetone 5dbd28c39e zcode: what you choose in ZCode for magpie stays — the provider turned off stays off, its rule stays where you moved it, and a rule you removed isn't put back on the next sync. gateway: a model that always thinks (GLM-5.3 answers 1210 to thinking turned off) is asked again with thinking left to it, rather than failing. Asked on Discord 2026-09-26 18:45:49 +08:00
yetone 73be42eca8 models: each agent can be shown only some of them — a provider or group gets a family (magpie provider set relay-x family=relay), and magpie visible zcode relay shows zcode only that family's models (or named providers and groups): in the files magpie writes for it and in what /v1/models answers it, told apart by its User-Agent; magpie models zcode lists what it is shown and what is kept from it, and magpie visible zcode all shows it everything again. A model kept from an agent is still served when asked for by name. Asked for on Discord 2026-09-26 16:02:29 +08:00
yetone 1de4bbc715 agent(zcode): magpie's models reach ZCode 3.14 — it moved its providers to ~/.zcode/v2/provider_config.json and reads config.json's only once, to import them, so a magpie provider set up since never showed in its picker; magpie now writes its provider rule (standard-personal, api-key access, anthropic-messages at the gateway) and a model rule per model (context window, images) there too, keeps every other rule and a model the user set by hand in ZCode, and leaves a provider turned off in ZCode off. Checked against ZCode's own schemas 2026-09-26 01:27:54 +08:00
yetone c0cbf90eeb agent(zcode): ZCode is an agent — its provider field puts every magpie model in ZCode's own model picker, as a provider named magpie in ~/.zcode/v2/config.json (kind anthropic, asked at the gateway's /v1/messages), kept in step with the catalog like OpenCode's list, and taken out again when cleared; its requests are known by the ZCode/ User-Agent (#72) 2026-09-25 23:53:59 +08:00