Commit Graph
12 Commits
Author SHA1 Message Date
yetone 6acf5ee5c3 providers: StepFun's logo is the current mark, five squares in a circle (zzstar101 on X)
magpie drew StepFun's old stepped-S in blue. StepFun's own sources show
the new mark: stepfun.com's favicon (step_favicon.svg), the Hugging Face
org avatar of stepfun-ai (the step-5-preview card), and lobe-icons'
`stepfun` (mono). lobe's `stepfun-color` is still the old mark, so there is
no colour one to take; the mark is one tone, so it is stored as the mono
icons are (icons/stepfun.svg, currentColor, drawn as a mask that follows
light and dark). The presets (StepFun, StepFun China), the "step" model-maker
rule (IconForCatalog's table) and Step Code use "stepfun". A provider saved
with "stepfun-color" keeps working: that file now holds the same new mark
in black, which the one-tone check draws as a mask too.

Run (mote): go test of internal/provider and internal/agent ok; go test
-tags nogui ./internal/gui ok; GUI files stepfun-per-provider, icon-one-tone,
mono-icon-redraw, models-add-and-icons, icon-tile, nav-sub-icons ok in
chromium and webkit; a screenshot of the Providers list in chromium and
webkit, light and dark, shows the new mark for both icon names.
usage-cards-hide's "de 560" sideways scroll is red in chromium and
webkit, and the same on origin/main aa744b9ed without this change
(#6294). Broken by hand: the old mark in stepfun.svg makes
TestStepFunLogoIsTheCurrentMark red.
Not tried: the Linux WebKitGTK window; the full suite before the tag.
2026-11-13 00:11:37 +08:00
yetone cdfdb62c69 agent: a model field's list is joined with the catalog once while neither changed
Each agent's model field returned append(its own models,
viaMagpieShared(...)...), a copy of the whole catalog's options for
each field of each agent on every poll: Picks was 94.7 MB of 496 MB
over forty polls of the Agents page with real accounts. withVia keeps
the joined list per agent and prefix while the own models read the same
(sameOption, field by field) and the catalog's list is the very one
kept (same array), and joins it again when either changed. The list is
read only and clipped, as viaMagpieShared's is; every caller of a
field's Options reads it, Picks clones it before it drops anything.
The 52 `return append(own, viaMagpieShared(...)...)` sites call it.
omp's and Reasonix's planner edit the joined list after the append, and
Grok's writes Same into its copy, so they keep their own copies.

TestWithViaKeepsTheJoinedList: the same own models give the same array,
own models changed in a value or only an icon are joined anew, a
provider saved since is listed, and nothing joined is the catalog's own
list. TestSameOptionReadsEveryField sets each field of Option alone and
fails when sameOption doesn't see it. Broken by hand: never answering
from the kept list ("the same own models joined the catalog again"),
and FastFor left out of sameOption ("sameOption doesn't read
Option.FastFor").

Run on mote: both tests alone 3 of 3; internal/agent, internal/tui and
internal/cli ok; internal/gui red only on TestSettingsSaveKeepsWhatItDoesNotSend
(#4514) and TestMainWindowCorners (#3949); gofmt, vet and GOOS=windows
and linux vet clean. Real accounts in a sandbox HOME, forty polls:
Picks 94.7 MB -> 51.2 MB, state 190.8 MB -> 154.0 MB, state and drift
replies byte for byte the same as before. Footprint peak 136 MB.
2026-11-01 07:54:54 +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 dd7442f283 agent: a look at the via-magpie options shares the kept list
viaMagpie handed every caller its own copy of the options list it keeps
per stamp, and a window poll asks for it from most agents' fields and
pickers. In a real-account sandbox (abr.sh, 20 polls of drift, state and
providers on v0.1.2463) those copies were 33.7 MB of slices.Clone, plus
~8 MB more on the way, of the 713 MB the polls allocated.

viaMagpieShared returns the kept list itself, clipped, so an append
makes the caller's own array. The 58 callers that only read it, or
append onto it, now take it; viaMagpie (a copy) stays for the ones that
change it.

TestKeptListSharedWithoutACopy checks that 20 shared looks return the
kept array, and that an append onto a shared look and a write into
get's copy leave the kept list as it was.

Run on mote at this tree:
- gofmt, go vet (darwin, GOOS=windows, GOOS=linux with gateway),
  go build ./...: ok.
- Broken by hand (shared returns slices.Clone): the test is red, "a
  shared look copies the kept list".
- go test -count=1 ./internal/agent: ok (480s).

Not run: internal/gateway and internal/gui packages on this tree.
2026-11-01 04:25:59 +08:00
yetone 73a12e8bf6 wsl: a distro's agent folder that is a link is opened where it leads (#4502)
On Windows, adding a skill or switching RTK on for an agent in WSL failed
with `mkdir \\wsl.localhost\<distro>\root\.codex: Cannot create a file
when that file already exists` (linusxiong). In the distro ~/.codex is a
link to /mnt/c/Users/<user>/.codex. Through \\wsl.localhost Windows can't
follow a link the distro has: a mkdir of it says it exists, and nothing
below it can be made, written, read or listed. ggbdpq found and explained
the link (thanks); their patch, which takes that EEXIST as "there", wasn't
used: the writes below the link fail next (its test passed because a
symlink here is followed).

The fix, for every agent folder and every writer through \\wsl.localhost:
- The WSL probe asks `readlink -f` in the distro where each agent folder,
  its skills folder and the folders beside them lead (wslLinkPaths ->
  distro.Links; a $HOME that is itself through a link is left alone), and
  which drive each Windows mount is (win:/mnt/c C: -> distro.Drives).
- distro.open opens a path at or below a link where it leads: on a Windows
  drive, the drive's own path (C:\Users\<user>\.codex); elsewhere in the
  distro, through \\wsl.localhost again. native spells it back through
  the link, so the agent is told its own path.
- A link readlink couldn't resolve is never guessed at: distro.open
  errors, and the agent is unreached (Agent.Unreached: its notice says
  why; every field Set and Sync returns it).
- Writers: the agents' own files (place.join/place.open, every
  filepath.Join(at.home, ...) in internal/agent), the library's WSL
  targets (wslOpen/wslOpened; one "wsl" problem per agent and nothing
  written), RTK (rtkAt, rtkInstall checks agent.WSLOpen before its mkdir),
  the Sessions page's WSL reads (sessions.WSLHome.Open) and the Copilot
  CLI sign-in read (provider.CopilotWSLHomes -> CopilotWSLDirs).
- Not changed: magpie's image MCP server opens arbitrary paths an agent
  in WSL gives it the same way; filed as #4578. Links deeper than the
  probed paths (other than <agent dir>/skills) aren't resolved. A distro
  probed by an older magpie has no Links until probed again (each run).

Run:
- Real Windows box (xiaomi-gpu, distro magpie-desktop, sandbox
  /tmp/x4502/home with .codex -> /mnt/c/Users/yeton/runs/x4502-target/.codex,
  .claude -> /tmp/x4502/data/claude, .pi -> a missing folder), a throwaway
  Windows test running the real probe with that HOME: probe said
  link:.codex /mnt/c/..., link:.claude /tmp/x4502/data/claude, link:.pi,
  win:/mnt/c C:, win:/mnt/d D:. The old way, MkdirAll(\\wsl.localhost\
  magpie-desktop\tmp\x4502\home\.codex\skills\pdf) = "Cannot create a file
  when that file already exists" (the report's error). distro.open wrote
  SKILL.md to C:\Users\yeton\runs\x4502-target\.codex\skills\pdf and to
  \\wsl.localhost\magpie-desktop\tmp\x4502\data\claude\skills\pdf, both
  read back with cat in the distro through the links; .pi said "~/.pi in
  WSL magpie-desktop is a link magpie couldn't follow". Sandbox and target
  removed after.
- New tests with a fake distro whose ~/.codex and ~/.claude are links to
  /mnt/c/... that don't exist here, so, as through \\wsl.localhost,
  nothing below them can be made: TestWSLFolderIsALinkToC,
  TestWSLFolderLinkUnresolved, TestRTKWSLFolderIsALink,
  TestRTKWSLFolderLinkUnresolved (library); TestWSLProbeLinks (runs the
  probe script), TestWSLOpenThroughLinks, TestWSLAgentFolderIsALink
  (config and a Claude session read on C:), TestWSLAgentFolderLinkUnresolved
  (agent).
- Broken by hand: the library tests on the base (with a no-op
  FakeWSLDrives) fail with "mkdir .../home/me/.codex: file exists", the
  report's error; with ggbdpq's patch applied they still fail (the skill
  mkdir, and RTK's hook not written).
- mote: go build ./...; go vet of agent, library, sessions, provider for
  darwin, GOOS=windows (and linux for agent, library); gofmt -l clean;
  go test -timeout 45m ./internal/agent ./internal/library
  ./internal/sessions ./internal/provider: all ok.
- Windows (win-run): the same four packages. The new tests pass (the
  RTK ones skip: the fake distro runs sh). 32 tests are red, all already
  red at the base c63c2136b run on the same box, and filed (#4115, #2808:
  Hermes profiles, Codex keychain, Agy, desktop entries, ...); the Hermes
  ones fail alike on base and branch with -count=3.

- Rebased on origin/main 3ecc02b78 (it changed internal/agent): at this
  head on mote, go build ./..., go vet of the four packages for darwin,
  windows and linux, gofmt -l, go test ./internal/agent ./internal/library:
  ok.

Not tried: the full ./... suite; the GUI (no GUI change; the unreached
notice uses the existing Notice); a real Codex/Claude Code run against
the moved files in the distro.
2026-10-31 21:29:22 +08:00
yetone 2f5a3f1c0b agent: Pi's models.json keeps a Gemini model on Chat, as Raft runs Pi's SDK on it with a fetch of its own (yunfei9958 on X)
Since 7eb7fa540 (#3282, v0.1.2042) a model served on Gemini's API,
an Antigravity sign-in's gemini-3.8-flash among them, was written into
Pi's models.json as api "google-generative-ai" at the gateway's /v1beta.
Raft (slock, @botiverse/raft-daemon 1.0.17) runs Pi's SDK, pi-ai 0.83.0,
on Pi's own agent folder (PI_CODING_AGENT_DIR, else ~/.pi/agent:
ModelRuntime.create's modelsPath) and gives every request its own fetch
(installProviderHttpClient). pi-ai's Google adapter throws before
sending when a fetch is given ("Custom fetch is not supported by the
Google Generative AI adapter", api/google-generative-ai.js; the same in
pi-ai 1.4.0), so every Gemini model failed in Raft.

Per-request fetch is a feature of Pi's SDK, so the file Pi's folder holds
can't count on google-generative-ai. piAsked now drops the Gemini API for
"pi" as it did for StepCode, whose rule moves there from stepcodeProvider:
the model stays on the provider's openai-completions, which the gateway
translates, as before v0.1.2042. piOffered reads the same entry, so Pi
offers the levels Chat has. OmO's and Prime Agent's folders are their own
and keep google-generative-ai. A sync rewrites magpie's model list, so
files written since v0.1.2042 are corrected without the user editing them.

Run (mote, at this tree on origin/main 8f0d21a00):
- go test -tags nogui ./internal/agent -run
  'TestPiGoogle|TestPiFolder|TestPrimeAgent|TestStepcode|TestStepCode|TestAside'
  -count=1: ok.
- Broken by hand (piAsked back to StepCode alone):
  TestPiGooglePluginModels/pi and TestPiFolderKeepsGeminiOnChatForRaft red.
- Raft's pi-ai 0.83.0 from npm, a request with a fetch of its own (as
  Raft's daemon gives) against a local fake gateway: the old entry
  (google-generative-ai, /v1beta) ends "Custom fetch is not supported by
  the Google Generative AI adapter", the reporter's error; the new one
  (openai-completions, /v1) reaches /v1/chat/completions and gets the
  reply.
- 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.
- Full suite (go test -tags nogui ./... -timeout 45m): started on mote
  at this tree; pushed before it ends, per the owner's ship-at-once rule.
  Its result goes on the commit's thread when it ends.

Not tried: the real Raft app (it needs a slock account), and a real
Antigravity account through it. Aside also runs Pi's SDK, on a folder
of its own; its source isn't public, so whether it passes a fetch is
not known, and it keeps google-generative-ai.
2026-10-30 17:30:23 +08:00
yetoneandskygunner 7eb7fa5407 agent: Pi, OmO and Prime Agent ask a Gemini model on google-generative-ai at the gateway's /v1beta (#3282)
A model served on Google's Gemini API (a custom provider's gemini=, a
Google sign-in's Code Assist, a plugin model declaring @ai-sdk/google)
was written into Pi's models.json with no api, so it inherited the
provider's openai-completions and the gateway translated Chat to Gemini.
magpieModels now gives such a model the Gemini API when no Chat,
Responses or Messages API was chosen for it, and piModelJSON writes it as
api "google-generative-ai" with baseUrl <gateway>/v1beta. A model whose
user picked Chat for it, routing groups and Pencil stay as they were.
Sync rewrites magpie's own model list, so files written before get it.

The patch is skygunner's (279e9bd1 on fix/pi-google-api in their fork).
Changed here:
- StepCode keeps such a model on Chat. Step-Code at 90a57820 registers
  only anthropic-messages, openai-completions and openai-responses
  (packages/providers/src/compat.ts BUILTIN_APIS); its docs list
  google-generative-ai but nothing streams it, so the patch would have
  broken every Gemini model there.
- On google-generative-ai, pi-ai's resolveGoogleThinkingLevel maps a level
  through thinkingLevelMap and throws on anything but minimal, low,
  medium or high, so a level the model names otherwise (xhigh, max) is
  set to null there and Pi doesn't offer it.

Checked against each client's source: pi-ai 1.4.0 and OmO's senpi-ai
2026.10.27-1 set apiVersion "" when baseUrl is given ("baseUrl already
includes version path"); Prime Agent's pa-ai providers/google.rs takes a
model baseUrl in place of host and version, and pa-core models/custom.rs
reads a per-model api and baseUrl.

Run (mote, at this tree rebased on 96a703a59, then again on adc618bbf):
- go test -tags nogui ./internal/agent -count=1 -timeout 45m: ok (385s).
- go test -tags nogui ./internal/gateway -count=1 -timeout 45m: ok (744s,
  load ~20 from other sessions). A first run of both packages together
  exited 1 after agent's ok; its log was deleted from the shared
  scratchpad by another session before the red could be read, so it is
  unnamed. The rerun of gateway alone at the same tree passed.
- Rebased on adc618bbf (#3279's plugin text filter, fake plugin
  changes): internal/agent -timeout 45m ok (252s); internal/gateway
  -run 'TestPlugin|TestCustomGemini' ok (43s).
- Pushed on fa2332976: the three commits since adc618bbf (fc43c69e5,
  750bd1bb6, fa2332976) change gateway code this change doesn't touch;
  not run again on them.
- Red without the fix (origin/main with these tests): TestPiModelsAsked-
  OnTheirNativeAPI (gem/ and hybrid/gemini-3-flash api <nil>),
  TestPiGooglePluginModels for pi, omo, prime-agent, and
  TestPiGoogleThinkingLevelsAreGeminis. TestPluginProvider's new /v1beta
  part passes there too: it guards that the plugin's sign-in and fetch
  still serve the route, which already worked.
- Broken by hand: with the null-out of non-Gemini levels turned off and
  the StepCode exception removed, TestPiGoogleThinkingLevelsAreGeminis
  (xhigh, max kept) and TestPiGooglePluginModels/stepcode go red.
- Real Pi 1.4.0 (@earendil-works/pi-coding-agent) in a sandbox HOME on
  mote: a custom provider gemini=http://127.0.0.1:18761/v1beta (a local
  fake), magpie serve on 127.0.0.1:18762, `magpie pi
  magpie/gemfake/gemini-3-flash`. models.json had the model at
  google-generative-ai, <gw>/v1beta; `pi -p "say hi"` printed the fake's
  reply, its session recorded api google-generative-ai, and the fake got
  /v1beta/models/gemini-3-flash:streamGenerateContent?alt=sse.

Not tried: a real Google account or plugin sign-in, real OmO and Prime
Agent binaries (checked by their source only), Windows and Linux.

Co-authored-by: skygunner <84759+skygunner@users.noreply.github.com>
2026-10-29 18:34:21 +08:00
yetone 579de3baa0 agent: enabledModels lose a deselected model's entries after the catalog sync (#2055)
misaka9981: models deselected in a provider's editor left magpie's
provider in Pi's models.json, but their magpie/<provider>/<model>
entries stayed in settings.json's enabledModels, and Pi warned "No
models match pattern" for each at every start. Pi's resolver
(model-resolver.js resolveModelScope, 1.1.0) only warns, never prunes.

After the sync writes magpie's provider block, an enabledModels entry
that names one of magpie's models outright (no glob; a thinking level
read off) whose model the block no longer has is taken out. As the
entry may be the user's own, it is remembered in stash.json
(<agent>.scope.gone) and goes back on the list's end once the model is
offered again; a provider rename moves the remembered entries too and a
disconnect forgets them. Globs, entries on other providers and on
models still offered stay, in order, comments kept. A list left with
nothing is removed (never written []) and made again when its entries
come back, with the model picked meanwhile; a list the user removed
isn't made again. When the agent's model list can't be read, nothing
is taken out.

The same holds for the siblings with such a list: OmO and Prime Agent
(piLike), StepCode (config.toml; its wiring state's last scope follows,
so a disconnect still puts the user's list back) and omp (config.yml's
plain entries; folder-scoped entries are left alone).

Run:
- TestPiEnabledModelsLoseDeselected (pi, omo, prime-agent) with the
  reporter's provider and four models, beside the user's own entries
  (another provider at a level, a magpie glob, a model still offered
  at a level): deselect, select again, rename.
  TestPiEnabledModelsEmptiedAndBack: emptied and back; removed by the
  user stays removed; other providers' and globs' file byte for byte;
  an unreadable models.json prunes nothing.
  TestStepCodeAndOmpEnabledModelsLoseDeselected, StepCode's disconnect
  putting the original list back included.
- TestPiEnabledModelsFollowRename and TestStepCodeEnabledModelsFollowRename
  keep a magpie/deepseekx/flash entry to show a rename leaves a name
  sharing a prefix alone; deepseekx is now a real provider there, as the
  sync would otherwise (rightly) take an entry naming nothing out.
- Broken by hand, each red: Pi's, StepCode's and omp's Sync hook off;
  the put-back off; the rename of remembered entries off.
- Real Pi 1.1.0 (@earendil-works/pi-coding-agent) under a sandbox
  HOME, `pi -p`: the stale exact entries gave the reporter's warnings;
  the list as pruned gave none.
- gofmt -l clean; go vet darwin, linux -tags nogui, windows;
  go test -tags nogui ./... green on origin/main 7d15df78a. Rebased again
  over 2eee900dc (omp's Sync now keeps the user's keys, ompProvider(models);
  the conflict is that one line), then vets and ./internal/agent/ and
  ./internal/cli/ again: green but for TestReasonixCLI*, whose fixture
  build read a go1.26.8 toolchain another session was unpacking into the
  shared module cache ("internal/oserror is not in std"); both pass run
  alone right after.

Not tried: the GUI's provider editor end to end with a real Pi session,
real omp and StepCode binaries, WSL. A magpie glob that matches nothing
still gets Pi's warning: it is the user's pattern and stays.
2026-10-14 13:33:28 +08:00
yetone cb003877f3 agent: a renamed provider's models follow it in Pi's, OmO's and Prime Agent's enabledModels (#1828, #1919)
The sibling of the StepCode fix before this, and of omp's (e6753190).
Renaming a provider moved Pi's defaultModel and appended the new ref to
settings.json's enabledModels (piScopeWith), but left the magpie/<old>/
entries, which name nothing after the rename; Pi then leaves those models
out of Ctrl+P. piLikeKeyed, which Pi, OmO and Prime Agent are all built
from, now has a RenameRefs hook: magpie/<old>/ entries are renamed, a
glob or a :level kept, and the copy the move just appended is dropped so
the model stays where the user had it. The user's own entries and a name
that only shares a prefix (magpie/deepseekx/...) stay; a list naming none
of the provider's models isn't rewritten. Pi keeps no scope stash of its
own (Disconnect's before-magpie copy is from before magpie wrote), so
there is nothing else to rename.

StepCode's rename helpers move to rename.go as renameRef/renameRefList
so both use one list rule.

Run:
- TestPiEnabledModelsFollowRename (new), for pi, omo and prime-agent:
  red with the hook returning early (old entries kept, magpie/ds/pro
  appended beside magpie/deepseek/pro), green with it.
- go test -tags nogui -count=1 -timeout 80m ./internal/agent on this
  tree (StepCode commit + this): ok, 999s, under a temp HOME. Load
  average ~120 from other sessions; the earlier run of the StepCode
  commit alone hit the default 10m timeout for that reason, not a hang.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows.
2026-10-13 15:50:20 +08:00
yetoneandggbdpq 90ac1f0385 agent: a renamed provider's models follow it in StepCode's enabledModels (#1919, ggbdpq)
Renaming a provider moved StepCode's defaultModel to the new id and
appended it to enabledModels, but the list kept magpie/<old>/ entries
(the model it was on, others the user listed, a glob), which name nothing
after the rename. StepCode now has a RenameRefs hook, as omp has
(e6753190): it renames magpie/<old>/ entries in config.toml's
enabledModels, drops the copy the move just appended, and renames the
scopes kept for Disconnect (OrigScope, LastScope, AppendedScope), so a
reset neither puts the old id back nor leaves the appended one. An entry
that only shares a prefix (magpie/deepseekx/...) and the user's own
entries stay; a list naming none of the provider's models is not
rewritten.

ggbdpq's patch from #1919, taken as written.

Run:
- go test -tags nogui -count=1 -run 'TestStepCode' ./internal/agent: ok.
- With only the RenameRefs hook removed, TestStepCodeEnabledModelsFollowRename
  fails with the scope the issue quotes; TestStepCodeRenameLeavesUserScope
  is a guard and passes on the old code too.
- -race -count=5 on the two new tests: ok.
- gofmt -l clean; go vet darwin, GOOS=linux -tags nogui, GOOS=windows: ok.
- The full ./internal/agent package timed out at the default 10m on a
  machine at load ~120 (many sessions testing at once); the run with
  this and the Pi sibling together is in the next commit's body.

Co-authored-by: ggbdpq <ggbdpq@gmail.com>
2026-10-13 15:50:19 +08:00
yetone 270b52573a agent: stash.json is changed under a lock and written whole, and one that doesn't parse is kept aside, not written over as no stash
stash.json holds every agent's config from before magpie wired it. stash,
forget and unstash read it, changed it and wrote it back with
os.WriteFile, with no lock, and a read that didn't parse came back empty.
Two changes at once (Connect all, a gateway move setting each agent again)
could leave the file half written, and the next change read that as no
stash and wrote it back: every agent's originals gone, so Disconnect had
nothing to put back. Now each change runs under stashMu and is written
with edit.WriteAtomic; a file that doesn't parse is copied to
stash.json.bad-<time> first; a new file is made 0600, since it holds keys.
rewire.go's stashPut and StepCode's stepcodeStoreState go through the same
stashWrite (StepCode keeps its own strict read).

TestStashKeepsChangesMadeAtOnce runs 40 stashes at once;
TestUnreadStashKeptAside stashes over a half-written file.

Ran: both new tests on origin/main's stash.go (red: "0 of 40 agents'
originals kept", "kept aside: []") and with the change (green); go vet on
darwin, GOOS=linux and GOOS=windows for internal/agent; go test -count=1
./internal/agent/ (ok, 278s); go test -race -count=3 on the stash and
StepCode tests (ok).
2026-10-11 04:28:31 +08:00
yetoneandBUKOWSKIREAL 8b393938f5 agent: StepCode can be connected to magpie, and Disconnect puts back its own model (#1526, BUKOWSKIREAL)
StepCode (StepFun's coding CLI, `step`) is a Pi fork that keeps Pi's
settings as TOML in ~/.stepcode/config.toml and Pi's models.json beside
it. It is now an agent target: Connect sets defaultProvider/defaultModel
to magpie, appends the magpie pattern to enabledModels when the user
scopes models, and writes providers.magpie into models.json with the
per-agent key. Disconnect puts back the user's own provider, model and
scope (only the patterns magpie added are taken out if the user changed
the scope since), restores or removes providers.magpie, and removes a
models.json magpie created. STEP_CODING_AGENT_DIR and STEPCODE_CONFIG_DIR
move the folder as StepCode's own resolveStepConfigRoot does; WSL is
covered.

The patch is BUKOWSKIREAL's (7cc88463 in their fork), reviewed line by
line: no network, telemetry or credential reads, writes only to the two
StepCode files and magpie's stash. Added here: a test that StepCode's
real User-Agent, "step (darwin 25.2.0; arm64)", counts as StepCode, and
the real-CLI test now looks for a "magpie" row in `step --list-models`
rather than the word anywhere (the docs path step prints can contain it).

Run:
- Config format checked against stepfun-ai/Step-Code at 3d70bae5 and the
  official 0.1.3 darwin-arm64 binary (sha256 matches latest.json):
  `step config path --json` names ~/.stepcode/config.toml and models.json.
- Sandbox HOME, sandbox gateway on 127.0.0.1:3647: a user config with
  defaultProvider "step", step-3.7-flash, thinking high, two scoped
  models, telemetry off. `magpie stepcode magpie/deepseek/deepseek-flash`,
  then `step -p` answered PONG through the gateway (usage record: agent
  stepcode, deepseek-flash, 200). `magpie stepcode default` put
  config.toml back value for value, removed models.json, and
  `step --list-models` no longer listed magpie.
- The same round trip from the real web page (sandbox `magpie web`),
  switch on, then off through the disconnect preview, which listed the
  three values it puts back; config.toml came back byte-identical. The
  row and icon checked in Chromium and WebKit, en and zh; no GUI assets
  change.
- Broke the guarantee: with unwire never restoring the defaults,
  TestStepCodeLifecycle, ...NativeChangedAndPreexisting and
  ...StrictValidationAndRollback go red. Without the "step" alias the
  new UA check goes red.
- MAGPIE_TEST_STEPCODE_BIN=<0.1.3> go test -run TestStepCodeRealCLISandbox
  passes (it failed before the row check above).
- go test -tags nogui ./... ; gofmt -l; go vet (darwin, GOOS=linux,
  GOOS=windows) on internal/agent and internal/agentenv; go build for
  darwin, linux (nogui) and windows.
Not tried on a real Windows, Linux or WSL machine.

Co-authored-by: BUKOWSKIREAL <233685554+BUKOWSKIREAL@users.noreply.github.com>
2026-10-11 04:03:29 +08:00