Commit Graph
13 Commits
Author SHA1 Message Date
yetone 06808ad308 agent: an agent's npm package that needs its install script gets it run on npm 12, bun and pnpm
npm 12 runs a package's install script only when told to
(--allow-scripts=<pkg>), and bun (--trust) and pnpm 10 (--allow-build)
do the same. A package whose postinstall puts its binary in place then
installs a stub: @opencode/cli 2.2.5 from npm 12.2.2 or bun 1.4.2 without
the flag prints "@opencode/cli's postinstall script was not run" and
exits 1 (mote, sandbox HOME). OpenCode's own v2 updater passes the same
flags.

cliSpec.scripts marks the agents whose npm package has an install
script: `npm view <pkg> scripts` on 2026-11-05 named one for claude,
cline, crush, deveco, mothx, omo, opencode and snow, and none for the
rest. Their install command, their npm/bun/pnpm update and the mend
hint now carry the manager's flag. npm 10 and 11 run scripts anyway and
take --allow-scripts as an unknown config.

Run (mote): gofmt -l, go vet ./internal/agent, go test ./internal/agent
-run 'Install|UpdateCLI|HowInstalled|Mend|Npm|Bun|Pnpm|Shim|Scripts|CLI|
OpenCode|Air' ok, and GOOS=linux/windows go vet ok. Real: on mote, npm
10.9.4, 11.21.2 and 12.2.2 with --allow-scripts=@opencode/cli each gave
a working opencode v2.2.5; npm 12 without it and bun without --trust the
stub; bun with --trust a working one.
Broken by hand: withScripts never adding the flag turns
TestInstallLetsScriptsRun, TestUpdateLetsScriptsRun and
TestUpdateCLIChecksItRuns red.
Not tried: pnpm and yarn for real (mote has neither), the other seven
agents' packages on npm 12.
2026-11-05 11:50:13 +08:00
ggbdpqandyetone 95ef45fda4 agent: a curl-installed opencode's update passes the version its row promised, so it never asks GitHub's API (#2837, ggbdpq)
What changed: an opencode 1.19.0 that its own installer put at
~/.opencode/bin/opencode (method curl) asks GitHub's API
GET /repos/anomalyco/opencode/releases/latest for the newest release before
installing. That request carries no token, so it spends the 60 an hour GitHub
answers an address without one. Once those are spent the answer is a 403 and
the update stops before its installer runs (ggbdpq: "opencode upgrade: ...
403 GET https://api.github.com/repos/anomalyco/opencode/releases/latest").

cliSpec gains target, for a CLI whose own updater takes the version to
install, and opencode sets it. When opencode's own updater is what runs
(via "self"), UpdateCLI appends the version it already knows, the row's
Latest from npm's opencode-ai, if that is newer than the installed one.
The run is then "opencode upgrade 1.19.3". In opencode's source
(packages/cli/src/commands/handlers/upgrade.ts) a given target skips
latest(), and the curl method passes it to the installer as --version. A
stale npm answer appends nothing (Newer), so an update can never become a
downgrade. When the lookup fails, the command stays "opencode upgrade".

Changed in review: the patch as sent appended the version for every
install method. An opencode installed by npm, bun, pnpm or brew then ran
`npm install -g --prefix P opencode-ai@latest 1.19.3`, which also asks npm
to install a package named "1.19.3", or `brew upgrade opencode 1.19.3`.
The append is now limited to via "self". TestUpdateCLIOpenCodeByNpmTakesNoVersion
(npm prefix install) guards it. The target comment no longer says 1.19.3
asks npm: opencode's current source asks opencode.ai.

Run:
- Breaks: without the via guard (the patch as sent),
  TestUpdateCLIOpenCodeByNpmTakesNoVersion fails with "ran [[.../npm install
  -g --prefix ... opencode-ai@latest 1.19.3]]". Without the target block,
  TestUpdateCLIOpenCodeTakesVersion fails at cliupdate_test.go:411 with
  `ran [[".../bin/opencode" "upgrade"]]`. Both pass restored.
- gofmt -l clean; go vet darwin, linux (nogui) and windows ok; go build
  for all three ok.
- Full `go test -tags nogui -timeout 45m ./...` on origin/main d783df46c +
  this: every package ok except internal/agent and internal/gateway, which
  hit 45m mid-test under a load average of about 200, and internal/gui's
  TestSetAnswersWhileDevinAndProvidersHang (10.8s, filed as #1375, output
  added there). Rerun of agent, gateway and gui with -timeout 120m: all
  three ok (4061s, 3393s, 564s). After the comment-only edit, `go test
  ./internal/agent -run TestUpdateCLI` passed again.
Not tried: a real opencode 1.19.0 update against GitHub's rate limit.

Co-authored-by: yetone <yetone@users.noreply.github.com>
2026-10-19 00:57:10 +08:00
yetone 924f62e90d agent: opencode and omp installed with bun on Windows, and omp's own binary install, offer their updates (#2192, xiaozhu1337)
On Windows the Agents page offered no update for opencode 2.0.24 or omp
18.6.1 while newer ones were out (Claude Code's showed). Two causes:

- bun on Windows doesn't link a global's program: it writes an 8 KB
  <name>.exe shim and, beside it, <name>.bunx naming the real program in
  UTF-16LE relative to bun's folder
  (install\global\node_modules\opencode-ai\bin\opencode.exe"). The shim
  names no package, so fromNodeModules gave up and the CLI read as
  installed some unknown way. bunxNames now reads the .bunx (<= 64 KB),
  and a shim whose .bunx names node_modules/<pkg>/ is bun's: updated with
  bun add -g <pkg>@latest, as on macOS and Linux.
- omp's installer (-Binary on Windows, the default in install.sh) puts a
  standalone omp in %LOCALAPPDATA%\omp or ~/.local/bin, which `omp update`
  replaces. omp had no self updater; it has one now for those two places.

Tried for real on the Windows box (Windows 11 x64), in a sandbox
USERPROFILE/APPDATA/LOCALAPPDATA/BUN_INSTALL with bun 1.4.3 and `bun add
-g opencode-ai @oh-my-pi/pi-coding-agent`: a probe built from this commit
calling agent.Find(id).CLI() reports opencode and omp via "bun" with
"bun.exe add -g opencode-ai@latest" / "...pi-coding-agent@latest" and
their latest versions; the same probe built from b9c589ebb reports both
with no via, no latest and no command, as the reporter saw.
TestHowInstalledBunWindowsShim uses the .bunx bytes bun 1.4.3 wrote there;
with bunxNames taken out (or the omp self updater) it fails with 4 errors.

Ran on b9c589ebb plus these commits: gofmt -l; go vet (darwin, GOOS=linux -tags nogui, GOOS=windows);
go test -tags nogui ./... (every package ok but two filed load flakes,
TestMaxRPMWaitsForRoomInTheMinute #1791 and TestCopilotSecretToolUsername
#1627, at load ~200; each passed -count=3 alone).
- rebased onto e98440ae6 (27 more commits on main) and
  run again there: gofmt -l, go vet ./... (darwin, linux nogui, windows),
  go test -tags nogui ./internal/gateway ./internal/proc ./internal/agent.
- then onto af27b70b4 (9 commits; gateway routing.go/gateway.go and agent
  codex.go touched, not these lines): gofmt -l, go vet on the three OSes,
  and the tests named above plus the new remote-magpie and Codex ones.
- the version magpie shows after an update: on the box, `bun add -g
  opencode-ai@1.18.0` then `bun update -g --latest opencode-ai` (and a
  second `bun add -g`) each rewrite bin\opencode.exe and .bunx (new
  mtime), so installedVersion's stamp changes and 1.19.0 is read; nothing
  to change there.
Not tried: omp's own -Binary install on a real machine (only the path
rule is tested), and an update run from magpie's Agents page.
2026-10-15 01:22:13 +08:00
yetone 7a3029db9c agent: Grok Build from Homebrew's grok-build cask is detected, shows its version and updates with brew (#1923, Will)
Will (waitingsnow on Discord) installed Grok Build with
`brew install --cask grok-build`. The cask (formulae.brew.sh/api/cask/
grok-build.json, 1.0.52) links $HOMEBREW_PREFIX/bin/grok to
Caskroom/grok-build/<v>/grok-<v>-macos-<arch> and leaves ~/.grok/bin
empty. magpie only looked at ~/.grok/bin/grok (x.ai's installer), since
`grok` on PATH may be Homebrew's regular-expression formula, so the CLI row
had no version or update, and before grok's first run Grok Build wasn't
detected at all.

- cliSpecs: grok gets brew grok-build, so the cask is updated with
  `brew upgrade --cask grok-build`.
- brewBin: for an agent with no Bin (its command name is other tools'),
  the command on PATH counts only when it leads into one of the agent's
  own formulae or casks. cliBin prefers it (it is what a terminal runs)
  over ~/.grok/bin/grok; Agent.Detected uses it too.
- Grok is the only cliSpec with `at`; the brew siblings (gemini-cli, pi,
  cline formulae) are the previous commit.

Run: go test -tags nogui ./internal/agent -run 'TestHowInstalled|TestGrok'
(ok, new TestGrokBrewCask); full ./internal/agent passed with -timeout 40m
(650s on a loaded Mac). gofmt -l clean; go vet -tags nogui for darwin,
linux and windows. Broke each piece by hand and watched red: no grok-build
in the spec (cask not found/updated), cliBin skipping brewBin, Detected
skipping it, and brewBin taking any brew grok (the regex formula then shows
as Grok Build). Not tried with a real cask install: nothing installed on
the live machine; the fixture follows the cask JSON's binary/target.
2026-10-13 13:06:14 +08:00
yetone 2d06210f93 agent: a Homebrew Node formula (gemini-cli, pi, cline) is updated with brew upgrade, not npm into its keg (#1923)
A Node formula keeps its npm package inside its keg. brew's gemini-cli on
this Mac: bin/gemini -> ../Cellar/gemini-cli/0.35.3/bin/gemini ->
../libexec/bin/gemini -> ../lib/node_modules/@google/gemini-cli/bundle/gemini.js.
howInstalled looked for npm before Homebrew, so it offered
`npm install -g --prefix .../Cellar/gemini-cli/<v>/libexec @google/gemini-cli@latest`,
which rewrites the keg behind brew's back (brew still lists the old version
and its next upgrade throws the npm one away).

- howInstalled: a Cellar/Caskroom path of one of the agent's own formulae
  or casks is Homebrew's before npm's. npm under a keg-only node's Cellar
  (node@20) is still npm's. The brew branch moves into fromBrew.
- cliSpecs: pi gets its pi-coding-agent formula and cline its cline
  formula (formulae.brew.sh: both are the npm packages magpie knows).

Found while fixing #1923 (Grok Build's grok-build cask, next commit), the
same "Homebrew install not handled" shape.

Run: go test -tags nogui ./internal/agent -run 'TestHowInstalled|TestGrok|TestUpdate'
(ok); the full ./internal/agent package passed with -timeout 40m in 650s
(the default 10m timed out once on this Mac with two other sessions'
agent tests running beside it). gofmt -l clean; go vet -tags nogui for
darwin, linux and windows. Broke it by hand (brew check after npm again):
TestHowInstalled goes red with npm --prefix .../Cellar/<formula>/1.0.0/libexec
for gemini, pi and cline. Fixture mirrors the real gemini-cli keg links here;
nothing installed or updated on the machine.
2026-10-13 13:06:14 +08:00
yetone e528aeb3ce agent: DevEco Code, Huawei's OpenCode, as an agent (#1885)
foobra asked for DevEco Code (npm @deveco/deveco-code), Huawei's
HarmonyOS coding agent. It is OpenCode underneath, so it joins through
openCodeLike as MiMo Code did (03a01a548):

- Config in ~/.config/deveco. magpie writes the first of deveco.jsonc,
  deveco.json, config.json there (the one DevEco reads last wins its
  merge), or DEVECO_CONFIG_DIR when that is an absolute folder; agentenv
  carries DEVECO_CONFIG_DIR. Auth at ~/.local/share/deveco/auth.json.
- Its provider block carries the key magpie-deveco, not the plain one.
  0.2.3 sends "deveco/0.2.3 ai-sdk/provider-utils/4.0.23 runtime/bun/1.4.2"
  on chat, but parts of its code still send opencode/<version>, so the key
  keeps its usage DevEco's whichever it sends. Check flags the plain key,
  and Sync writes DevEco's back. OpenCode's own key is unchanged.
- The user's own provider, small_model, $schema and comments stay; the
  model they were on comes back on Disconnect.
- Library: AGENTS.md instructions (with the "reads Claude Code's
  CLAUDE.md" note, as OpenCode and MiMo Code), MCP in OpenCode's shape,
  skills. No WSL folder.
- Install/update: npm @deveco/deveco-code on macOS and Windows only, as the
  package has no Linux binary (new cliSpec.only); the self installer under
  ~/.local/share/deveco/versions updates with `deveco upgrade`.
- Icon: DevEco's own logo, byte for byte from its IntelliJ plugin's
  pluginIcon.svg. Model picker /models. Route hue, READMEs (en, zh), site
  agent lists (en, zh, ja), docs/reference.md, subsystem pages, CLI help.

What was run
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
- go test -tags nogui: internal/library, agentenv, proc, cli, gui, usage
  pass; internal/agent passes in 559s with -timeout 40m;
  its first run, at the default 10m with load average ~40 from other
  sessions, was cut off by the timeout (no test had failed).
- New deveco_test.go: config lookup and DEVECO_CONFIG_DIR, the key, and
  Connect/Check/Sync/Disconnect against a deveco.jsonc holding the user's
  own model, provider, small_model, $schema and a comment. Made
  openCodeKeyAt return the plain key by hand: TestDevEcoKeyNamesIt and
  TestDevEcoConnectKeepsTheUsersOwn go red.
- GUI: new library-deveco.test.cjs (the note in en, zh, zh-TW, ja, de,
  and the icon draws), chromium and webkit; red with deveco taken out of
  library.js's note. library-instr-sets, library-instr-busy,
  panel-routing, agent-connect, library-desktop-skills, getting-started,
  filter-ime, routing-account-identity pass in both engines.
- Real use, sandbox HOME: npm-installed @deveco/deveco-code 0.2.3,
  `deveco auth consent --accept` (sandbox only, no Huawei sign-in). magpie
  serve on 127.0.0.1:3592 with a fake upstream; `magpie deveco fake/fake-1`
  wrote provider magpie (magpie-deveco, http://127.0.0.1:3592/v1) beside
  the user's own and kept the file's comment; `deveco run "Reply with one
  word: ping"` answered from the fake, and `magpie usage today` counted it
  under DevEco Code. The User-Agent above is what it sent.

Not tried
- Windows, and DevEco Studio's plugin mode; a Huawei-signed-in DevEco.
- `magpie deveco <model>` then `magpie deveco default` doesn't bring back
  the model the user was on before: the CLI set path doesn't stash. It is
  the same for OpenCode today; Connect/Disconnect in the GUI does.

Reported-by: foobra
2026-10-13 10:57:32 +08:00
ggbdpqandfactory-droid[bot] 8714abd45d agent: TestUpdateWithBunBridgesSOCKS reads only the proxy variables it sets, so a machine with NO_PROXY or NODE_USE_ENV_PROXY set no longer fails it
The test collected every variable whose name ends in _PROXY from
updateEnv's environment and required each to be a bridged
http://127.0.0.1 URL for bun. updateEnv passes the rest of the
environment through, so a NO_PROXY of the machine running the test
("bun is given localhost,127.0.0.1") or Node's NODE_USE_ENV_PROXY=1
("bun is given 1") made it red, though neither names a proxy. It now
reads the six proxy variables it sets (the ones netproxy.EnvForBun
bridges, in either case). Test-only; updateEnv is unchanged.

What was run: on the old main the test is red with
NO_PROXY=localhost,127.0.0.1 and, separately, with NODE_USE_ENV_PROXY=1
in the environment, green with neither. With this change it is green
with both set. Broken by hand (updateEnv's netproxy.EnvForBun call
removed) it fails with "bun is given socks5://127.0.0.1:4401". gofmt -l
prints nothing; go vet -tags nogui ./... passes for darwin, linux and
windows; go test -tags nogui -count=1 ./... under a temp HOME passes.
Not run on the Windows box.

Reported and fixed by ggbdpq (#1472).

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2026-10-10 15:17:08 +08:00
yetone dec951229c agent: Grok Build installed by xAI's installer shows its newest version and offers grok update, and its version is read again after each update (xiaoxiaofeixz on Discord: Grok at C:\Users\<user>\.grok\bin\grok.exe)
Grok Build had no cliSpec and no Bin (grok is also Homebrew's regex
tool), so the Agents page showed nothing about its CLI: no version, no
newest, no update.

xAI's installers (read from https://x.ai/cli/install.ps1 and install.sh):
- install.ps1 copies grok.exe (and agent.exe) into %USERPROFILE%\.grok\bin
  and puts that on the user PATH; no junction, no versioned folder.
  grok update copies the new grok.exe over it (the running one renamed to
  grok.exe.old), so its size and time change.
- install.sh links ~/.grok/bin/grok to ../downloads/grok-<platform>;
  grok update downloads ../downloads/grok-<version>-<platform> and relinks,
  a new real path per version.
- The newest version of a channel is the body of x.ai/cli/<channel>
  (stable, alpha, enterprise; GCS fallback), the channel kept under [cli]
  in ~/.grok/config.toml.

cliSpec gains `at` (where the vendor installer puts the CLI under home,
read there instead of PATH for an agent with no Bin) and `latest` (the
newest its own updater installs, for a CLI not on npm). grok's spec: at
.grok/bin/grok(.exe), self = grok update for a real path under
.grok/bin or .grok/downloads, latest = grokLatest (channel pointer, 6h
memo per channel).

TestGrokInstalled builds the platform's installer layout under a temp
HOME/USERPROFILE with a fake grok on PATH, a served channel pointer and
fake version/update runs: PATH's grok isn't taken; 1.0.46 shows 1.0.50 and
"grok update" (grok.exe update on Windows); the update reads 1.0.50; grok's
own update outside magpie (auto_update) is read again; the alpha channel's
newest is alpha's. It fails without the grok spec (macOS and the Windows
box: "before: {Version: ...} false") and passes with it.

Real use: macOS, a sandbox HOME with the real grok 1.0.46 in install.sh's
layout: CLI() said 1.0.46 / 1.0.50 / grok update, UpdateCLI ran the real
grok update and read 1.0.50 (~/.grok untouched). Windows box (10.0.0.132,
sandboxed USERPROFILE/APPDATA/LOCALAPPDATA): the real grok-1.0.46 exe at
home\.grok\bin\grok.exe, same result through a real grok update; the real
profile's .grok, LocalAppData\grok and user PATH unchanged. There
TestGrokInstalled, TestCodexInstallPs1Junctions and
TestHowInstalledWindowsShim pass.

Siblings: Claude's install.ps1 lands in ~/.local/bin/claude.exe (already
matched); Cursor's and Qoder's Windows installers make no junctions or
links, and those agents have no cliSpec (not in scope); opencode has no
install.ps1 (404); Factory's refused the fetch (403), droid has no
cliSpec either.

go test -tags nogui ./internal/agent (temp HOME), gofmt -l, go vet, and
GOOS=linux / GOOS=windows go vet -tags nogui ./internal/agent pass.
2026-10-09 22:25:24 +08:00
yetone 3691c2047d plugin, agent: bun is given a SOCKS proxy through the bridge, so a plugin installs with only a SOCKS system proxy (#1409)
With only a SOCKS system proxy on macOS (127.0.0.1:4401), every plugin
install failed: netproxy.Env put socks5://… in bun add's *_PROXY, and Bun
takes only http:// and https:// proxies, so it stopped with
"UnsupportedProxyProtocol downloading package manifest". The plugin
host's own fetches already went through netproxy.Bridge (hostEnv), but
bunCommand, which runs bun add, update and remove, did not.

- netproxy.EnvForBun rewrites a SOCKS5 HTTPS_PROXY/HTTP_PROXY/ALL_PROXY
  (any case) to the loopback HTTP bridge in front of it; others as they are.
- bunCommand uses it, so add, update, remove and the host's run all get it.
- Sibling: an agent CLI installed with bun is updated by `bun add -g`
  with the same env (updateEnv in cliupdate.go); npm is left as it is.
- provider-plugins.md says so.

Run:
- TestInstallThroughSOCKSProxy (real bun 1.4.2, fake registry, SOCKS
  proxy only): on the old bunCommand it fails with the reporter's exact
  "error: UnsupportedProxyProtocol downloading package manifest"; passes
  with the fix, through the SOCKS proxy.
- TestEnvForBunBridgesSystemSOCKS (system SOCKS proxy via Env) and
  TestUpdateWithBunBridgesSOCKS fail with EnvForBun / the bun branch
  broken ("bun is given …socks5://…"), pass with it.
- Real use: a throwaway test with a real SOCKS5 server and only
  *_PROXY=socks5://… installed @magpie-community/opencode-cursor-auth
  0.2.2 from registry.npmjs.org through it; on the old code the same
  failed as UnsupportedProxyProtocol. Scratch HOME, not committed.
- gofmt -l clean; go vet ./...; GOOS=linux go vet -tags nogui ./...;
  GOOS=windows go vet ./...; go build; GOOS=linux go build -tags nogui;
  GOOS=windows go build; go test -tags nogui ./... (scratch HOME) all ok.
2026-10-09 19:35:35 +08:00
yetone 06420a7121 tests: a fake program is a file macOS has already let run (testenv.Program), so a fake's first start no longer eats a test's wait under load
macOS checks a newly written executable before its first exec: 0.27s
alone, 2-5s while other new programs start (a go test ./... starting its
test binaries). The same file again takes 0.009s, and the pass is kept
across a rename and an in-place rewrite. 108852b4 worked round this for one
test with /bin/sh -c; the class was every test that writes a `#!/bin/sh`
fake and times its answer.

testenv.Program(t, path, script) replaces os.WriteFile(path, script, 0o755)
for fakes. On macOS it renames a file that has run once from a pool to path
and writes the script into it in place; at the test's cleanup the file goes
back to the pool (only a path the test created; a stand-in it wrote over
stays). Fakes still end with their tests: nothing about how they are
started or waited on changed. Run (and gateway's TestMain) remove the pool
at the end. TestMain's PATH stand-ins are run once in the background
(testenv.StandIns). Other systems write the file as before.

Converted every `#!/bin/sh` fake written by tests under internal/ (agent,
gateway, gui, library, plugin, proc, provider, update). Windows, binary
and node/bun fakes are unchanged.

Under the same load (3 loops each starting 8 freshly written scripts at a
time), 4 rounds each, before (108852b4 / origin/main) vs after:
- provider TestSavedButSignedOutClaudeServed: 4/4 fail (8.01s) -> 4/4 pass
- provider TestClaudeSignInOverStaleCredentials: 4/4 fail (5.00s) -> 4/4 pass
- provider TestDevinSignedInOnlyInMagpie: 3/4 fail ("CLI's own []") -> 4/4 pass
- gateway TestClaudeRunEndsWhenTheClientLeaves: 4/4 fail -> 4/4 pass
  (and 3/3 fail -> 3/3 pass at a third of that load)
- gateway TestClientGoneRecordedAsCanceled: 4/4 fail -> 4/4 pass
- gui TestProvidersAnswerWhileListsComeIn ("cursor found false" at 3.03s):
  4/4 fail -> 4/4 pass. The same class, not bfe8bcaf's test order.
- proc TestUserPath (login shell's PATH never came, 7.01s): 4/4 fail ->
  4/4 pass
Unloaded, every touched package passes; no pool directory or process is
left after a run.
2026-10-07 03:00:47 +08:00
Leslieandgoogya 8031edc78b agent: AtomCode support — one provider account, one model table per catalog model, as its own sign-in writes (#736)
* agent: AtomCode is wired like its own CodingPlan sign-in — one provider account, one model table per catalog model

AtomCode (atomgit.com/atomgit_atomcode/atomcode, AtomGit's open Rust terminal agent) keeps its settings in ~/.atomcode/config.toml ($ATOMCODE_HOME). Its account schema, what its own CodingPlan sign-in writes, is one [provider_accounts."magpie"] table at the gateway's /v1 (protocol openai, gateway.TokenFor("atomcode") as the key, so a request is its agent's even when the UA is overridden) and one [models."magpie/<provider>/<model>"] table per catalog model: the model string goes to the gateway as it is to resolve, with the model's context window (AtomCode compacts as it nears it; a 128000 one is told when the model's isn't known, and an output above the told window is cut to it), its output limit, vision and reasoning_effort_levels; reasoning_effort rides on the table once the user picks one. Picking a model points default_provider and default_model at it — default_model wins when both are set, as atomcode reads it — and stashes the defaults the user had; stepping out puts them back. The picker offers the user's own model tables and the catalog via magpie; the Library gives AtomCode its ATOMCODE.md, its mcp.json (omp's shape) and skills/; its UA is atomcode/<version>.

Found against a real atomcode 5.2.1: the documented legacy [providers.*] tables work, but its own sign-in writes the account schema, so magpie writes that; reasoning_effort, max_tokens and supports_vision were verified to reach the request from the model table, and default_model to win over default_provider. Verified end to end on a real install: atomcode --provider "magpie/…" answered through the gateway, and the Agents page shows the tile, its picker and the Usage attribution. TestAtomcodeWiring, TestAtomcodeRestoresOwnDefaults and TestAtomcodeSync fail on the old code; TestDriftUnwiredEveryAgent and TestUnsetAgentsReadEmpty cover it from All(). go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./internal/agent ./internal/library ./internal/agentenv pass; the plugin-host and timing failures of the full ./... run fail on main without this change too.

* tweak

* agent: AtomCode's config is matched by its own spellings, and Sync keeps the effort — AtomCode rewrites its config through serde on every /model and /cd, and that writes the account header bare ([provider_accounts.magpie]) where magpie wrote it quoted, so after the first rewrite Check read the wiring as gone, Sync and every pick appended a second account table (edited TOML is invalid: table magpie already exists) and clearing left the unquoted table and its api_key behind. The account is now matched by exact name in its three spellings (quoted, bare, literal — magpie-2 stays out) and the model tables by their decoded keys (kimiModelKey, replacing atomcodeModelName), through a new SetTOMLTablesMatching that takes exact names beside prefixes; SetTOMLTables delegates with none, unchanged. Sync carries each magpie model table's reasoning_effort over when rewriting — it ran at every gateway start and catalog change and dropped both an effort picked in magpie and one picked with AtomCode's /effort, and picking another model cleared every table's. The effort Set validates against the levels AtomCode knows (low, medium, high, xhigh, max — its clamp_effort_to_levels drops none, minimal and ultra), a model without levels offers none now, and the low/medium/high fallback is gone with it. supports_vision is written explicitly false, where AtomCode otherwise guesses from the model name. The user's legacy [providers.*] entries join the picker, a stashed default_model naming one comes back on Disconnect, and picking one sets default_provider and takes default_model out, as the legacy shape reads. site docs (en, zh, ja) list AtomCode. TestAtomcodeSync rewrites the config into the bare and single-quoted spellings before Sync and again before clearing and fails on the old code (drift reported, effort dropped, unquoted table left behind); TestAtomcodeLegacyProvidersArePickableAndRestored and TestAtomcodeEffortLevelsMatchAgentSupport are new. Reported by yetone on #736. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./internal/agent ./internal/edit pass.

* agent: TestAtomcodeWiring picks an effort through the field too — the write side of the validation the last commit added (a level AtomCode knows lands as reasoning_effort on the model table, one it does not know is refused) had no coverage left: the test only read back what AtomCode's own /effort had written. provider.SetModelEfforts gives fake/m1 levels to offer.

* agent: Disconnect puts AtomCode's default_provider back only where AtomCode still has it — the restore checked the stash's value was not magpie's but not that the table it names was still there, so a table the user had deleted in between came back as a dangling default (the account schema's default_provider names a model table, the legacy shape a [providers.*] one; own answers for both). The default_model branch checked already. TestAtomcodeRestoresOwnDefaults deletes the stashed provider's model table before clearing and fails on the old code.

* agent: AtomCode joins the CLI updates — npm @atomgit.com/atomcode, the brew cask atomcode, and the curl script's ~/.local/bin/atomcode updating itself with atomcode upgrade, so the Agents page shows its version and a newer one as the other agents' do (#736). TestHowInstalled covers the npm prefix, the cask and the self-updating installer.

* agent: AtomCode's self-updater waits for its install paths to be confirmed — the branch recognized a binary under ~/.local/bin as `atomcode upgrade`, on a docs page, while the README shows another path and the command has not been driven outside the help text; the reviewer asked for it removed until the standalone command and the script's real default are settled. npm and the brew cask stay, with their tests; a comment marks what is pending.

---------

Co-authored-by: googya <118465+googya@users.noreply.github.com>
2026-10-04 14:11:14 +08:00
yetone be4298b294 library: Pi 0.99's own MCP — with Pi 0.99 or later on PATH and no MCP extension replacing it, MCP servers go in the mcp.json Pi reads itself, in its shape (command/args/env, url/headers, no adapter transport keys; SSE refused, which it has none of) (Discord feedback, 何似在人间: Pi now has native MCP) — Pi 0.99 (extensions/mcp/config.ts) reads mcpServers from <agent dir>/mcp.json, unless pi-mcp-adapter or pi-mcp-extension is installed (now also found in Pi's extensions folder) or settings.json has -builtin:mcp; then the files are as before. Servers magpie or the user had in mcp-adapter.json, which nothing reads now, are moved into mcp.json, the adapter's settings and anything mcp.json has differently left where they are and still found, both files backed up and written together (edit.Atomically). Without an adapter found, mcp.json is no longer moved to mcp-adapter.json, since it may be Pi's own. agent.InstalledVersion asks the CLI on PATH, once per binary. Tested with TestPiMCPNative in a sandbox HOME with a fake pi on PATH: 0.98 writes mcp-adapter.json, 0.99 moves the servers over with the user's fields kept, writes and removes in Pi's shape, SSE refused, the adapter (listed or in extensions) or -builtin:mcp keeps the old file; TestPiNativeVersions, TestInstalledVersion. go vet ./internal/..., go build -tags nogui (and GOOS=linux, GOOS=windows) and go test -tags nogui ./... pass. Not tried with a real Pi 0.99. 2026-09-30 10:14:38 +08:00
yetone fe2269288c agents: each agent's CLI shows its version and updates in one click (#202 JoeyMa-zh: Agents 页面增加"更新 CLI"功能 — 检查各 agent CLI 的版本并一键更新) — the Agents page now puts each CLI's installed version after its name (read with <cli> --version, 10s timeout, no stdin) and, when a newer one is out and magpie can tell how it was installed, a small "Update to x.y.z" pill. How it was installed comes from the resolved binary: the vendor's own installer first (Claude Code's ~/.local/share/claude/versions → claude update, Codex standalone → codex update, ~/.opencode/bin → opencode upgrade), then a global node_modules (bun, pnpm, else npm, run as npm install -g --prefix <prefix> pkg@latest with that prefix's npm, and only where the prefix is writable), then a Homebrew formula or cask allowlisted per agent (brew upgrade [--cask]); anything else shows the version alone, with no button. The latest comes from the npm registry or brew info --json=v2 (no auto-update), cached 6h (15min after a failure); installed versions are cached by the binary's path, size and mtime. GET /api/agents/cli waits at most 3s and says pending, and the page asks again; POST /api/agents/cli/{id} runs the update (one at a time per agent, 10min cap), reads the version again and says so if it did not change, or gives the command's last lines when it fails. The pill goes busy in place and the page never scrolls; not in the tray panel. zh strings added. Tested with a new internal/agent/cliupdate_test.go (version order and parsing; npm/bun/pnpm/brew formula and cask/native installs, a read-only prefix, a local node_modules and unknown binaries in a fake PATH; an update against a fake registry and updater) and a new internal/gui/tests/cli-update.test.cjs in Chromium and WebKit (versions, pills only where magpie can update, row heights, an update with the view scrolled, a failing one, zh). No real update was run. go build (nogui, GOOS=windows, GOOS=linux), go test -tags nogui ./... and the GUI tests pass 2026-09-29 17:56:43 +08:00