All three were test fixtures, not magpie writing a bad file.
TestHooksCodexTrustMovesWithTheGroups wrote Codex's [hooks.state."<path>"]
keys itself as basic strings, so on Windows "C:\Users\..." held \U, and
toml read the test's own file as broken ("toml: non-hex character").
Codex doesn't write that. Driving the real `codex app-server`
(0.162.1, config/batchWrite on hooks.state, as its /hooks does) under a
sandbox CODEX_HOME shows its toml_writer spelling: a basic string when
nothing needs escaping, a literal string ('C:\Users\x\...') when a
backslash does, and an escaped basic string ("C:\\Users\\O'Brien\\...")
when the key has an apostrophe too, under a bare [hooks.state] header.
codexKey in the test now spells keys that way, and the test runs for
the default home, a CODEX_HOME with a backslash in it and one with an
apostrophe as well, so macOS and Linux exercise both quoted forms too.
codexRekey already reads both and rewrites only the key's tail, so the
spelling is kept.
Every place magpie writes a path into TOML was checked: edit.tomlString
(every edit.KV string value, model_catalog_json among them),
library/mcp.go tomlString/tomlKey, provider/devin.go tomlString all
escape backslashes; the strconv.Quote writers (grok/kimi/atomcode/jcode/
reasonix/codex reasoning efforts, Grok hook blocks) write model ids,
efforts and commands, where a backslash comes out as \\ too. None writes
an unescaped path, so no writer changes.
TestAgentsSkillsFolders and TestTargetsLeaveGoneAgentsOut wrote Hermes's
config.yaml into ~/.hermes, but Hermes's folder on Windows is
%LOCALAPPDATA%\hermes (appdir.HermesHome). There Hermes wasn't there at
all: its skills folder was the Windows one, and Takes for an agent with
no folder says yes rather than "isn't installed". Both now write into
appdir.HermesHome(), and TestTargetsLeaveGoneAgentsOut first checks
Hermes is detected by that config, so a fixture in the wrong place fails
as that rather than as a Takes result.
Run:
- Windows 11 box, test binaries cross-built (GOOS=windows -tags nogui),
fresh USERPROFILE/HOME/APPDATA/LOCALAPPDATA/TEMP each run, cwd with
internal/library/testdata:
- origin/main 2b0037f41: the three fail as in the issue.
- this change: the whole internal/library package PASS.
- this change with codexRekey's literal-key branch disabled by hand:
TestHooksCodexTrustMovesWithTheGroups/default and /backslash FAIL
("keeps Codex's trust of ... in a way magpie can't move").
- macOS: the same break fails /backslash; restored, all pass.
- real codex 0.162.1 app-server in a sandbox HOME/CODEX_HOME for the
three key spellings above.
- macOS, rebased on origin/main 9d97fd073: gofmt -l prints
nothing; go vet -tags nogui ./internal/library for GOOS=darwin, linux
and windows ok; go test -p 1 -count=1 ./internal/library ok (132s)
in a sandbox HOME/TMPDIR with Go's caches pinned.
- Full suite: SUITE_LINE
ggbdpq found TestTargetsLeaveGoneAgentsOut and TestGoneAgentKeepsWhatItHas
(from e413512d8) red on a Windows machine with the Codex desktop app.
Their patch (ggbdpq/magpie fix-2254-gone-test, ddd44c36) skipped the
tests when HasApp said so, which proves nothing on such machines, and set
a PATH of the test's own. This takes their hermes fixture fix and makes
the rest hermetic instead:
- agent: windowsStorePackages reads none of the machine's AppX registry
in a test binary testenv isolated (proc.Isolated), as SystemDirs already
keeps the machine's folders out. Only agent's own TestMain stood in for
it before, so library's tests (and any other package's) saw a real
Codex app, and codex's CLI was never gone there.
- library: the hermes fixture goes where Hermes reads it
(appdir.HermesHome: %LOCALAPPDATA%\hermes on Windows). In ~/.hermes
hermes was never detected there, and Takes refused nothing.
- library: TestGoneAgentKeepsWhatItHas uses Pi, which goes on every
system. On Windows a ~\.codex whose CLI isn't found is never taken for
a leftover (#1482, by design), so the test with codex failed on every
Windows machine, Codex app or not. The PATH change in the patch made
no difference to that.
- TestRTKLeavesGoneAgentsOut keeps codex; it already skips on Windows
(its fake rtk is a shell script).
Run:
- Windows 11 box, test binaries cross-built (amd64): old main had
TestTargetsLeaveGoneAgentsOut and TestGoneAgentKeepsWhatItHas FAIL
(Takes(hermes) <nil>; codex a target), new both PASS. Full library and
agent packages there: new fails only what old fails too (library:
TestAgentsSkillsFolders, TestHooksCodexTrustMovesWithTheGroups, filed as
#2275; TestCheckKeepsToolNames and agent's 10 are from running a test
.exe away from its source: testdata, ../gui, go and bash not there).
- Broken by hand: TestStorePackagesNotTheMachinesInTests without the
Isolated check reads the box's 152 Store packages and goes red; with
Targets' CLIMissing filter removed, both library tests go red on macOS.
- macOS: go test of agent, proc, library; gofmt -l; go vet -tags nogui
for darwin, linux, windows on the three packages.
Full suite: SUITE_LINE
Co-authored-by: ggbdpq <ggbdpq@gmail.com>
After an agent is uninstalled, the Agents page shows "CLI not found"
(d0fcb8bc), but Library still offered it for skills, MCP servers, shared
instructions and rtk, and a sync wrote into a folder nothing reads.
- library.Targets() leaves out an agent whose CLI is missing
(agent.CLIMissing: false for WSL, plugin and detect agents), so sync,
the read view, market, instructions, skills and found servers all
drop it at their one upstream.
- Takes() refuses a gone agent by name, so `library mcp add ...
agents=hermes` says "Hermes Agent's CLI isn't installed here; nothing
reads its MCP servers until it is installed again" instead of "every
agent already has it".
- The guards that must still see a gone agent's files (projects'
notGlobal for skills and MCP, instructions' own-file check) read
everyTarget(), so a set kept in the agent's own file is still refused.
- rtk: a gone agent isn't offered rtk; one that still has the hook is
listed so the hook can be taken out.
- Nothing a user wrote is removed: sync acts per target, so a gone
agent's skills, servers and AGENTS.md stay as they are, and the client
keeps agent ids it doesn't show.
Run:
- Sandbox HOME, real binaries: old wrote mcp_servers into a gone
~/.hermes/config.yaml; new refuses with the message above, exit 1.
- New tests TestTargetsLeaveGoneAgentsOut, TestGoneAgentKeepsWhatItHas,
TestRTKLeavesGoneAgentsOut; each broken by hand (Targets check,
Takes refusal, everyTarget in instructions, rtk gate) goes red.
- go test -tags nogui ./internal/library ./internal/tui ./internal/cli
./internal/gui: ok. Fixtures that relied on a gone CLI now place one
(holdCLI, TestRTKHermesHome, TestRTKOffPath), and so do profile's
and davsync's sandboxes, whose library syncs to claude and codex
(TestOldProfiles, TestProfileCarriesLibrary, TestSyncLibrary went red
in the full run without them).
- gofmt -l clean; go vet -tags nogui darwin/linux/windows clean.
- go test -tags nogui -p 4 ./... at the pushed head: see the last
commit of this push.
Not tried: the real GUI with an uninstalled agent on a live machine.
Co-authored-by: ggbdpq <ggbdpq@gmail.com>