ac4af582301a4e8a29245dbba767eba31334ddf9
31
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fc8e98ba47 |
edit: Codex's thousands of [projects] tables are left out of the reads that don't want them (#2278)
Codex writes a [projects."…"] table for every project it is trusted in;
the owner's config.toml has 10,933 of them in 1.5 MB. go-toml's decoder
checks each table against its siblings one at a time, so every decode
of the file cost ~0.3s of CPU, and six readers decoded it again each
time Codex wrote it, plus a whole-file check before each write magpie
made to it.
- edit.TOMLWithout drops [projects…] tables in a single unstable.Parser
pass. The agent's codexTopOf, sessions' readCodexConfig, provider's
readCodexStoreSetting, library's rtk sandbox, hooks rekey and MCP
entries read through it. None of them reads projects. A file that
doesn't parse is passed through unchanged, so it still fails.
- validateTOML checks definitions with the rest of the file and the
projects decoded apart, 128 projects to a decode. A bare [projects]
table, a dotted projects.… key outside the tables, or any error
decodes the whole file, so the error is the one it gives.
Run on mote (M5 Pro):
- BenchmarkCodexConfigDecode (10,933 projects): 283ms -> 7.6ms a decode.
- BenchmarkValidateCodexConfig: 52ms (the whole decode was 283ms).
- Startup CPU profile, first 70s, the real-account copy (the real
1,524,099-byte config.toml): 2.76s -> 2.26s of samples; go-toml
0.32s -> none sampled.
- go test ./internal/edit ./internal/sessions ./internal/provider
./internal/library ./internal/agent: all ok.
- go vet of the same five on darwin, GOOS=linux and GOOS=windows; gofmt -l clean.
Broken by hand:
- Decoding the batches into struct{} instead of a map:
TestValidateTOMLDefinitionsInGroups went red ("a key twice", "a
subtable then its key"), so the check keeps maps.
Not tried:
- the whole suite. Only the five packages that read the file were run.
- Now that projects is left out, a project table defined twice no longer
fails these readers' decode. Codex itself refuses such a file.
|
||
|
|
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 |
||
|
|
50816ce024 |
library: turning RTK off matches the hook Claude's settings actually holds (#2879)
What changed: taking RTK out of Claude Code now drops its hook entries
from hooks.PostToolUse and hooks.SessionStart in ~/.claude/settings.json
beside hooks.PreToolUse, matching the same "rtk hook claude" mark.
Why: magpie says Claude Code has RTK by searching the settings file
whole for "rtk hook claude", but its remover only looked under
hooks.PreToolUse. rtk 1.0.1's installer writes that command under
hooks.PostToolUse too, when the user's rtk pipeline has after_tool rules
(rtk:posthook; src/hooks/init/claude.rs), and rtk's own uninstaller
sweeps PreToolUse, PostToolUse and SessionStart alike. With an entry
under another event, switching RTK off in the Library removed the
PreToolUse entry, found the command still in the file, and failed with
"rtk's hook is still in Claude" — the reported bug: the row stayed on
and the hook had to be taken out by hand. The user's own hooks under
those events are kept, as the PreToolUse ones already were.
Run: go test ./internal/library/ (ok, 75.6s); the new
TestRTKRemoveClaudeOtherEvents fails on the base with "rtk's hook is
still in Claude Code" and passes with the fix; gofmt -l clean; go vet
clean on darwin, linux and windows; the package builds on all three.
Review (magpie): checked against rtk v1.0.1's own claude.rs, which
writes and sweeps PreToolUse, PostToolUse and SessionStart; the other
agents' single key is unchanged. Run on the Mac mini: go test
./internal/library -count=1 ok; TestRTK* on the Windows box ok. Broken
by hand: rtk.go at the base - TestRTKRemoveClaudeOtherEvents red
("rtk's hook is still in Claude Code"). Not tried: the reporter's ask
to roll the switch back in the UI when a removal fails.
Generated-by: GLM-5.3-Flash (ZCode)
|
||
|
|
48edbcb674 |
library: RTK covers Droid, and lists Qoder, Cline and Kimi Code with why
lml0664 on Discord: Library > RTK offered a fixed few agents, even on the
latest magpie. RTK 1.1.0 (rtk-ai/rtk, Latest, 2026-10-25) has `rtk init`
agents claude, cursor, trae, windsurf, cline, kilocode, antigravity, kimi,
pi, hermes, droid, vibe, omp, plus --codex/--gemini/--opencode/--copilot.
Every one with a global hook that magpie has an agent for was already on
the page except Factory's Droid, which is added now:
- droid: rtk's own `rtk init -g --agent droid`, given Droid's folder as
FACTORY_HOME_OVERRIDE (magpie's droid agent honours it). rtk writes its
Execute group (`rtk hook droid`) into the root hooks.json, or into
settings.json's hooks.PreToolUse when Droid's hooks already live there
(src/hooks/init/droid.rs), so ReadRTK and switching off look at all
three files rtk may use (hooks.json, hooks/hooks.json, settings.json)
and leave the user's own hooks and settings. rtk before 0.44 has no
Droid agent, so it is blocked with "needs RTK 0.44 or newer".
- dropHook no longer slices key[:-1] for a top-level key (hooks.json's
"PreToolUse"); before, it would have panicked.
Listed with the switch off and their own reason (rtkNoHook and the page's
rtkNoHookWhy, in zh, zh-TW, ja and de too):
- Qoder, Qoder CN: rtk 1.1.0 has no Qoder agent (`--agent qoder` is an
invalid value), rtk-ai/rtk#1327 (PR #1721 open).
- Cline: `rtk init --agent cline` only writes a .clinerules in the
current project asking the model to type rtk, no hook (#3841).
- Kimi Code: Kimi's hooks can't rewrite a command; rtk writes only one
project's AGENTS.md and refuses -g ("Kimi AI is project-scoped").
RTK's Trae, Windsurf, Kilo Code and Mistral Vibe have no magpie agent.
Run:
- go test -tags nogui ./internal/library -run TestRTK on mote: ok
(TestRTKDroid home/override, TestRTKDroidSettingsHooks,
TestRTKNoHookQoderClineKimi new, sandbox HOME, fake rtk).
- Red on old code: rtk.go at HEAD^ -> TestRTKDroid, ...SettingsHooks and
...NoHookQoderClineKimi red. Broken by hand: version gate at 0.43, the
settings.json entry dropped -> red; FACTORY_HOME_OVERRIDE not passed ->
TestRTKDroid/home red. client.js at HEAD^ -> library-rtk-nohook red
(Qoder's reason was the generic one).
- Real rtk 1.1.0 (release tarball, sha256 checked against checksums.txt)
on mote in a sandbox HOME through SetRTK/ReadRTK: plain ~/.factory,
settings.json with the user's own Execute hook (kept, rtk's taken out)
and FACTORY_HOME_OVERRIDE: on, seen on, off, seen off. Real rtk also
refuses --agent qoder and -g --agent kimi, and cline writes .clinerules.
- Full suite on mote, go test -count=1 -timeout 45m ./...: 80 packages
ok; internal/gui red only in its 10 real-window AppKit tests (#4125).
- GOOS=linux and GOOS=windows go vet ./internal/library: ok. gofmt clean.
- GUI on the WSL box (mote's browsers crash at launch, #4125):
library-rtk-nohook (chromium+webkit, en+zh) and i18n-keys 10/10; all 45
library-*.test.cjs files 810/824, the 14 reds (library-chip-fan webkit,
library-items webkit, library-mcp-tools chromium ja 420) are the same
at origin/main
|
||
|
|
3ce2a9819f |
library: RTK for agents in WSL, with the distro's own rtk (lex on Discord)
lex: Claude Code and other agents in WSL couldn't use the RTK of magpie
on Windows. rtkAgents looked an agent up in rtkSpecs by its whole id, so
claude@wsl:Ubuntu never matched and WSL agents weren't on the RTK page at
all. Even matched, the specs read this machine's home, and Windows' rtk.exe
is no command inside the distro, where the hook runs.
Now an agent is looked up by its kind (rtkKind). One in WSL:
- has its files read and written under the distro's home as magpie opens
it (rtkClaudeDir, rtkCodexDir, rtkHome), with blocked/version checks
against the distro's rtk and OpenCode;
- uses the distro's own rtk: rtkDistroOf asks the distro (wsl.exe -d <d>
-e sh -lc) where rtk is on its shells' PATH, else in ~/.local/bin or
~/.cargo/bin (offPath), kept 15s; ReadRTK lists one RTKDistro per distro;
- switching on runs that rtk there (rtk init -g ..., its folder on PATH);
- Install RTK in WSL <distro> (POST /api/library/rtk/install {distro},
magpie library rtk install <distro>) runs RTK's own Linux installer in
the distro (curl, or wget).
A distro that isn't running is never started (#3896): its agents are
listed asleep with the switch off, and switching or installing says to
start it. The page has a card per distro (install, off-PATH, asleep) and
uses the distro's rtk for each WSL row's tags and switch; strings in zh,
zh-TW, ja and de. The install route now refuses a body it can't read
instead of installing on this computer.
Run:
- mote (macOS 27), at origin/main
|
||
|
|
053d0d37f8 |
library: Install RTK uses brew only when Homebrew has rtk's bottle, and keeps why it failed on the card (Scott__D on X)
Scott__D on X: "Magpie 里的这个 RTK 安装一直都不成功". The RTK card sat on
"Installing RTK… this can take a minute." over `brew install rtk`.
Cause: Homebrew bottles rtk only for Apple silicon on the newest macOS
(arm64_sequoia, arm64_tahoe, arm64_golden_gate, and Linux). On an Intel Mac
or macOS 14 and older, `brew install rtk` builds rtk from source, and first
the 19 formulae it builds with, rust, llvm and python among them: hours.
InstallRTK gives the installer five minutes, so each try was ended, said so
in a status line gone after ten seconds, and the next try started over.
Reproduced on mote with a sandbox Homebrew (HOME and prefix of its own)
and HOMEBREW_FAKE_MACOS=14.7: brew info rtk says "stable 1.1.0, HEAD" with
no "(bottled)", brew install rtk lists 19 dependencies to build, and
magpie's InstallRTK spent 3m43s in it before failing.
Fix:
- rtkInstaller asks `brew info rtk` and uses brew only when it says
"(bottled)", brew's own word for pouring the bottle here. Otherwise, and
when brew fails or doesn't answer in 30s, it is rtk's own script
(install.sh from rtk-ai/rtk's README, which downloads rtk's release for
darwin x86_64/aarch64 and Linux). The answer is kept an hour per brew,
since ReadRTK asks on every read while rtk isn't installed.
- A failed brew says Homebrew's first Error: line and what it says to do,
not the support-tier notice its output ends with.
- The card keeps "The install failed: {why}" beside Get RTK until the
next try (as the upgrade's error already did), in every language.
- The five-minute bound on the installer was already there and stays.
Run on mote (macOS 27.2, arm64):
- real InstallRTK, sandbox HOME, sandbox Homebrew, HOMEBREW_FAKE_MACOS=14.7:
chose rtk's script, installed rtk 1.1.0 into the sandbox ~/.local/bin in
12.2s (`rtk --version`: rtk 1.1.0); the card then offers Put RTK on PATH.
- real InstallRTK, same sandbox, macOS 27 as it is: chose brew (bottled),
installed rtk 1.1.0 in 10.7s.
- go test ./internal/library (TestRTK*): ok. New tests:
TestRTKInstallsWithBrewOnlyFromItsBottle (brew info output read from the
real brew, bottled and not), TestRTKBrewInfoThatHangs,
TestRTKBrewInstallSaysBrewsError (brew's real output on mote).
- GUI: library-rtk-install.test.cjs, 5 languages x 1100/420, Chromium and
WebKit: 22/22. All library-*, gui-de/ja/zh-tw and i18n-keys files: 770 of
771; the one red is i18n-keys "a plugin's words are its own" on
plugins/routing "masking…", red on origin/main too (#4053).
- gofmt -l: nothing. go vet ./internal/library ./internal/gui;
GOOS=linux and GOOS=windows go vet ./internal/library: ok.
- Full suite on mote, go test -tags nogui -count=1 -timeout 45m ./...
at base
|
||
|
|
e4552cca9f |
library: a cargo RTK upgrades on Windows, and says why when it can't
新v学员 (Discord #feedback, 10-27): upgrading an RTK installed with cargo
failed silently on Windows. Four causes, each fixed:
- No cargo on magpie's PATH (magpie started before Rust was installed,
or from a shortcut whose PATH rustup never touched): rtkUpgrader gave
no upgrade, so Upgrade was greyed with only a tooltip, which a click
never shows. Now the cargo rustup put beside rtk is run by its path;
with no cargo anywhere, the card (and the CLI) says it was installed
with cargo, to install Rust from rustup.rs or run the command shown
(RTKView.NoUpgrade, Manual), and UpgradeRTK's error says the same.
- CARGO_HOME (D:\Rust\.cargo is common) moved cargo's folder: an rtk
there wasn't cargo's to magpie. cargoBins reads it, for finding rtk
and for the upgrade; on Windows the folder matches whatever its case.
- cargo install --git built rtk-ai/rtk's default branch, develop, whose
Cargo.toml says 0.49.0 while v1.1.0 is out from master: the upgrade
left rtk as it was, or older, on every OS. It now names --branch
master, as rtk's own installation guide does.
- Windows refuses cargo's move over a running rtk.exe ("failed to move
… (os error 5)", exit 101, after the whole build), and an agent runs
rtk for every command. On that refusal the rtk is renamed aside
(rtk.exe.old-<pid>, which Windows allows), a copy put in its place,
and cargo run again; its build is kept in magpie's CARGO_TARGET_DIR,
so the retry builds nothing. Old copies are removed on the next
upgrade.
A failed cargo now says its first error with the cause, and what to do
for the common ones (rtk in use, link.exe/dlltool missing, GitHub
unreachable), not its last three lines, which only said the build
failed and where its files were left.
Run:
- Real Windows (10.0.0.132, sandbox CARGO_HOME/RUSTUP_HOME/USERPROFILE,
rustup + cargo 1.99.1, removed after): plain cargo install over a
running rtk.exe fails with "拒绝访问。 (os error 5)" exit 101; a
Windows build of this package's tests (GOOS=windows go test -c, a
scratch test calling ReadRTK/UpgradeRTK, not committed) with no cargo
anywhere gave NoUpgrade "cargo" and the new error; with cargo only
beside rtk (not on PATH) and the old rtk.exe running, UpgradeRTK
built rtk-ai/rtk master and went 1.0.0 -> 1.1.0 in 3m26s, the running
rtk kept running, rtk.exe.old-<pid> was left and removed once it
exited. The build used the gnullvm toolchain with llvm-mingw; the
gnu toolchain failed with "error calling dlltool" and lld's missing
-lgcc_eh, which is the output the tests use.
- New tests (rtk_cargo_test.go) and the updated
TestRTKUpgradeCargoNamesThePackage are red on origin/main
(
|
||
|
|
b91bcf2606 |
library: a standalone Windows rtk gets rtk's own upgrade action (#2006, Edward4226; LoKi)
An rtk.exe that no package manager installed (rtk's own Windows release unzipped into %USERPROFILE%\.local\bin, say) had no upgrader, so the Library page showed RTK's update with no usable Upgrade. LoKi (lokic7123-star) hit it on v0.1.1285 and again on 0.1.1320; Edward4226 reproduced it and wrote this patch (his bc2056804, author kept). rtkUpgrader now gives such an rtk.exe the rtk-windows-release action (shown as "rtk's own Windows release"): on amd64, when winget's folders, cargo's folder and winget's own records/winget list didn't claim it. UpgradeRTK then takes RTKLatest's version, downloads checksums.txt and rtk-x86_64-pc-windows-msvc.zip from rtk-ai/rtk's release through source.DoOfficial, checks the zip's SHA-256 against checksums.txt, takes rtk.exe out of it, writes it beside the old one and swaps it in with steady.Rename, putting the old one back if the swap fails. Changed from Edward's patch in review: - The action no longer names a version: it read rtkLatest under the lock RTKLatest holds while it asks GitHub (up to ~16s), so ReadRTK, a page draw, would wait on it. UpgradeRTK already falls back to the last known version through RTKLatest. - A winget that couldn't say whether it owns the rtk (timed out, failed, couldn't run) is no answer, not "not winget's": askWingetOwns now returns (yes, known); only winget missing, exit 0 without rtk-ai.rtk, or 0x8A150014 (no package) count as known-no. The winget arm above is unchanged (yes only when winget listed it). Without this, a winget timeout handed a possibly winget-owned rtk to the standalone path. - Only a zip member named rtk.exe is taken (no "any .exe" fallback, which could pick rtk-proxy's), and an oversized one is refused rather than cut short. - An aside (rtk.exe.old-<pid>) an earlier upgrade couldn't remove, because an agent was running that rtk, is removed on the next upgrade. - The arch is a var (rtkArch) so the upgrader test runs on arm64 hosts instead of skipping; the redundant winget/cargo folder checks are gone (the switch's earlier cases already return for those). - Two of the patch's tests failed as written on macOS (ReplacesBinary counted VERSION as a leftover; UpgradeRunsTheInstall compared the script rtkPath finds there with rtk.exe's text); both fixed. - New tests: TestRTKWindowsStandaloneAsksWinget (no winget / unlisted / listed / failed / hung), TestRTKWindowsReleaseZipNeedsRTKExe, the arm64 case, and a stale aside in TestRTKWindowsReleaseSwapsTheFile. Run at the cherry-pick on origin/main |
||
|
|
7916045591 |
library: RTK's tag for Grok Build and Grok App gives their own reason and rtk-ai/rtk#2136, not DeepSeek Harness's (新v学员 on Discord)
Every agent RTK has no hook for got dsh's tooltip on the RTK tab: "{agent}'s
hooks can only allow or deny a command, not change it" with
rtk-ai/rtk#3847 ("FR: Support DSH"). For Grok Build that is wrong twice:
the issue is dsh's, and Grok's PreToolUse hooks can rewrite a command
(updatedInput, shown on rtk-ai/rtk#1890). What holds is that rtk init has
no Grok agent (src/hooks/init in rtk v1.0.1 has none), and
rtk-ai/rtk#2136 is the open request for Grok Build (#4513 was closed as
its duplicate). Each link was checked with gh issue view; the others in
rtk.go (#3847, #3934, #4311, #3898, #4187, #3404) are right.
rtkNoHookWhy in plugins/library/client.js gives each agent its own reason:
dsh keeps its text and #3847, Grok Build and Grok App cite #2136 (Grok App
runs Grok Build), and an agent with no entry gets a reason with no link.
New strings in zh, zh-TW, ja and de. rtk.go's grok and grok-app reasons,
which the CLI shows, cite #2136 too.
TestRTKNoHookIssuesAreEachAgents fails when an rtkNoHook agent has no page
reason (or the reverse), when the page and rtk.go cite different issues,
when two agents cite the same issues without a reason in sharedRTKIssues,
or when the fallback carries a link. library-rtk-nohook.test.cjs checks
Grok Build's tag says #2136 and never #3847, DeepSeek or "hook".
Run in a worktree rebased on origin/main
|
||
|
|
3c921835d0 |
library: RTK switches on for OpenCode 2 with rtk 0.52 or newer, not "Not for OpenCode 2" (#2295, witt-bit)
The RTK tab blocked OpenCode 2 whatever rtk was installed: rtk's
OpenCode plugin used to be written for OpenCode 1 only, which OpenCode 2
refuses ("Plugin must export a default definition with an id and an
effect or setup function", rtk-ai/rtk#4311). rtk-ai/rtk#4187 (merged
10-12, first released in rtk 0.52.0, also in 1.0.0 and 1.0.1, the
reporter's) writes one default object with OpenCode 2's id and setup()
beside OpenCode 1's server(). Checked with gh: 0.52.0's and 1.0.1's
hooks/opencode/rtk.ts are byte-identical, 0.51.0's is the old named
export.
- openCodeBlocked: with OpenCode 2, blocked only when rtk is older than
0.52 or doesn't say its version; the reason now says to update RTK.
OpenCode 1 is unchanged with any rtk.
- openCodeHas: under OpenCode 2, an old plugin (no setup()) left from
before an rtk update counts as off once the rtk here is 0.52+, so
switching it on runs rtk init, which writes the new one over it. With
an older rtk it still counts as on, so it can be switched off.
- GUI: the OpenCode row's tag is "Update RTK" with OpenCode 2 reasons
(on: refuses this plugin, update or switch off; off: needs 0.52), in
en, zh, zh-TW, ja, de; the "Not for OpenCode 2" strings are gone.
- docs/subsystems/library.md says the same.
What was run:
- Real binaries in a sandbox HOME (throwaway test, not committed):
rtk 1.0.1 and 0.51.0 (aarch64-apple-darwin release tarballs) with the
real OpenCode 2.0.25 on PATH. rtk 1.0.1: row not blocked, SetRTK on
wrote an 8425-byte plugin with setup(), off took it out. rtk 0.51.0:
blocked "OpenCode 2.0.25 needs RTK 0.52 or newer, and this RTK is
0.51.0 …", SetRTK on refused, nothing written.
- Real OpenCode 2.0.25 in a sandbox HOME (its own service, stopped
after): rtk 1.0.1's plugin logs "loading plugin" with no error;
0.51.0's logs "failed to load plugin … Plugin must export a default
definition with an id and an effect or setup function".
- TestRTKOpenCode2 rewritten (fake rtk writes each version's real
plugin shape). Broken by hand three ways, each a FAIL: old rtk.go
(blocked: "RTK doesn't support OpenCode 2 yet …"), stale-plugin rule
dropped ("OpenCode 1's plugin under OpenCode 2 is listed as on"), gate
at 1.0 ("rtk 0.52.0 blocked for OpenCode 2").
- New GUI test library-rtk-opencode2.test.cjs: every language, 1100
and 420, on and off rows, Chromium and WebKit 21/21 each; red on the
old client.js/i18n.js. gui-de, gui-ja, gui-zh-tw, i18n-keys and all
library-*.test.cjs: 286/286 in Chromium and in WebKit.
- gofmt -l clean; go vet, GOOS=linux and GOOS=windows go vet -tags
nogui ./internal/library; go test -tags nogui ./internal/library
under a temp HOME with pinned caches, on the rebased head.
Full suite: SUITE_LINE
|
||
|
|
e413512d8e |
library: an agent whose CLI is gone (only its config folder left) is no Library write target, and nothing it already has is removed (#2254, ggbdpq)
After an agent is uninstalled, the Agents page shows "CLI not found"
(
|
||
|
|
0c0231b80f |
library: the RTK page lists Antigravity CLI and gives it rtk 0.51's plugin, not leaving agy out (#2202, Chichengmo)
rtk 0.51.0 installs a global hook for Antigravity CLI: `rtk init -g --agent
antigravity` writes ~/.gemini/config/plugins/rtk/{plugin.json, hooks.json,
rules/AGENTS.md}, a PreToolUse hook on run_command that runs `rtk hook
antigravity` (src/hooks/init/antigravity.rs at v0.51.0). The RTK page had
no agy row, so magpie never offered it.
- rtkSpecs gets "agy": installs through rtk's own -g --agent antigravity
(no --auto-patch; that branch ignores it), reads it as on when its
hooks.json holds `rtk hook antigravity`, and switching off removes
plugins/rtk only, never a user's other plugins next to it.
- agyBlocked: rtk 0.50 knows Antigravity only per project and exits 1 on
-g ("Antigravity is project-scoped"), so an older rtk isn't run for it.
The row says "Update RTK" with its own reason (installs it only per
project), not Codex's @RTK.md one; en, zh, zh-TW, ja, de.
- docs/subsystems/library.md says so.
Run (worktree off origin/main
|
||
|
|
e0a3b8c60a |
library, plugins: the RTK page and the Installed plugin list open without waiting on the package manager or the plugins' vendors (#1178)
The Library's RTK page took ~3.9s to open and the Plugins page's Installed list ~2.2s, every time. - Installed named each plugin's subscriptions from plugin.Providers, the whole providers RPC: each plugin in turn fetching its vendor's model list. The page uses only the names, which plugin.Cached keeps without starting the host (refreshed in the background when a sign-in or the plugins change). It now reads those: 2.2s to 13ms with seven plugins. A plugin added a moment ago has no names yet, so its row no longer claims it "signs in to nothing magpie can use" until the plugins have answered (plugin.Answered, the row's named). - ReadRTK waited up to 3s for GitHub and the package manager; winget show refreshes its sources and takes ~7.7s, so every open waited the full 3s and #1025's "waiting for winget" tag never came from it. GitHub stays on the first read; the package manager is asked in the background, its answer kept 6 hours as before. 3.9s to 1.6s. - ReadRTK and SetRTK detected the agents twice per call; once now. wizzy-yang's PR head 12342aa3, which conflicted with main: plugins.go keeps main's clash rows (plugin.Clashes) with the names from Cached, idName filled from Cached too; plugins.js keeps main's middleware/agent and clash branches ahead of the PR's named one; providers.go keeps main's Told and Settle beside the PR's Answered. Run: see the next commit. |
||
|
|
1f0ff81dfc |
agent: Grok App's own route picked in magpie is taken, and Disconnect can put one back; a sync that isn't connected writes nothing (#1625)
Follow-up to fjrtdk's commit before this one, which this keeps: magpie never names itself as Grok App's route. - Set refused every own route (errGrokAppRoute) while Options still offered them, so the picker showed choices that only errored. It also broke Disconnect: when unwire leaves no route (Use set it to magpie, nothing stashed), Disconnect sets connect.was's route back through Set, got the error and stopped half done. An own route now takes magpie's channel out and is written as [models] default, the way picking another provider leaves magpie on other agents. That route can't be magpie, so the App's sign-in is never touched. - Sync ran rememberRoute/releaseRoute before checking for the channel, so every user with Grok App installed but not connected got stash entries. Now it returns before them unless the channel is there or the route is still magpie (an older magpie's takeover to put back). - Check again warns when the route is magpie and the channel is gone, which that commit dropped. - The notice uses the App's own labels (Settings › Account, Use; ja 「使う」, de Einstellungen › Konto / Verwenden, from grok-app 0.2.40's settings.nav.account and prov.useThis) and says a chat can pick magpie's models in its model picker (composer_prefs_set, which doesn't move the route). - Sibling: rtk init has no grok agent for Grok Build either (rtk 311ebcb agents: claude codex copilot cursor droid gemini hermes opencode pi trae vibe antigravity), so Grok Build is in rtkNoHook too. Run: gofmt -l clean; go vet ./... on darwin, GOOS=linux -tags nogui and GOOS=windows clean; go test ./internal/gateway ./internal/agent ./internal/library -count=1 pass; node --test i18n-keys and agent-notice-lang pass. Broken by hand: that commit's grokapp.go fails TestGrokAppOwnRouteStays, TestGrokAppDisconnectPutsTheRouteBack and TestGrokAppSyncUnconnected; dropping the Check branch fails TestGrokAppSyncUnconnected; dropping rtkNoHook["grok"] fails TestRTKNoHookGrokBuild. Not tried: the Grok App GUI itself; the config format and behaviour are from grok-app 0.2.40's source. Co-authored-by: fjrtdk <fjrtdk@gmail.com> |
||
|
|
ea3d480edf | agent: Grok App keeps its own route; magpie is a custom provider under Accounts, and the Library writes instructions, MCP and skills on agent-home (#1625) | ||
|
|
e08902e79d |
agent, library: Hermes Agent's folder is %LOCALAPPDATA%\hermes on Windows, and rtk's installer is told it (新v学员 on Discord)
新v学员 runs magpie on native Windows. Library -> RTK -> Hermes Agent
failed with "rtk's installer didn't add its hook to Hermes Agent:
Config: C:\Users\admin\AppData\Local\hermes\config.yaml ...". magpie
hard-coded ~/.hermes. Hermes' own default
(hermes_constants._get_platform_default_hermes_home) is
$LOCALAPPDATA\hermes on win32 (~/AppData/Local/hermes when LOCALAPPDATA
is empty) and ~/.hermes elsewhere, with $HERMES_HOME overriding it.
rtk 0.51's resolve_hermes_home knows only $HERMES_HOME and ~/.hermes,
on every OS.
What changed:
- appdir.HermesHome / HermesHomeIn / HermesDefaultIn: $HERMES_HOME,
else Hermes' per-OS default. This is the one place that resolves it.
- agent: hermesIn (Agents-page model wiring) and hermesProfiles use it
through place.hermesHome / hermesDefault. A WSL distro keeps
~/.hermes (Linux paths, Windows env not read). The Agents-page wiring
was wrong on native Windows too: without HERMES_HOME it wrote
%USERPROFILE%\.hermes\config.yaml, which Hermes never reads.
- sessions.HermesDir uses it, so Windows sessions are found.
- library/rtk: the hermes spec reads and writes the agent's own folder
(a.Dir), and rtkSpec.env passes HERMES_HOME=<that folder> to
`rtk init -g --agent hermes --auto-patch`.
- Tests resolve the folder through appdir instead of home/.hermes. New
TestHermesDefault/TestHermesHome (appdir), TestHermesFolder (agent:
Windows default, profiles under it, WSL unchanged), and
TestRTKHermesHome (library, a fake rtk that behaves like 0.51).
- docs/reference.md and docs/subsystems/library.md describe the
Windows folder and the env.
Run:
- gofmt -l clean. go vet ./... on darwin, GOOS=linux -tags nogui and
GOOS=windows.
- darwin: go test ./internal/appdir ./internal/library
./internal/sessions ./internal/agent ./internal/tui.
- TestRTKHermesHome against the old rtk.go fails with the reporter's
exact message ("didn't add its hook ... AppData/Local/hermes/
config.yaml"), and its default subtest fails with HERMES_HOME="".
- Windows box (cross-compiled test binaries, testenv sandbox
USERPROFILE/LOCALAPPDATA): appdir Hermes tests, agent
Hermes|Reseat|Effort (incl. TestHermesFolder) and library Hermes|RTK
pass. TestRTKHermesHome skips there (shell fake). The sessions binary
failed only TestHermesMessageVisibility, because its testdata wasn't
copied to the box.
- Real rtk.exe 0.51.0 on the Windows box: with
HERMES_HOME=<sandbox>\AppData\Local\hermes it wrote the plugin there
and patched that config.yaml. Without HERMES_HOME it wrote
C:\Users\<user>\.hermes, ignoring a sandbox USERPROFILE (rtk asks
Windows for the home folder). That confirms the cause and the fix.
The stray folder it made on the test box was removed.
Not run: real Hermes on Windows (no install, and running hermes under
a temp HERMES_HOME rewrites the live launcher); the GUI suite; the full
go test ./... ; the reporter's own machine.
|
||
|
|
8bfe33f1f4 |
agent, proc: where each command is on PATH is looked up once while its folders are unchanged, so a Windows page doesn't stat PATH per agent and per session (#1771)
oxyuan profiled every page's first load on Windows at seconds (4-7s), and Sessions, Usage → Sessions and Context at 26-45s: 96-98% of the samples were os.Stat under exec.LookPath and proc.FindTool. A failed lookup stats every PATHEXT candidate in every PATH folder (111ms there), and the pages asked once per known agent (Detected → binAt) and once per Pi session (sessions.carries → ompThere) on every request. proc.Look (new, look.go) is exec.LookPath with its answers kept. The proc.LookPath that |
||
|
|
9300b2a126 |
library: a visit to the Library no longer parses Codex's config.toml again when it hasn't changed (#1665, laowangba233)
laowangba233 saw magpie's CPU jump on each switch to a Library page. Profiled in a sandbox HOME with a copy of a real Codex config.toml (1.5 MB, 10,927 [projects."<dir>"] tables, one per folder Codex was ever opened in): 69% of GET /api/library's CPU was go-toml parsing that file through foundServersOf -> mcpFile.entries. go-toml's SeenTracker looks each table name up among every sibling before it, so the parse is quadratic in the number of projects, ~0.2 s of CPU each time, and the Library parsed it on every visit (edit.Read already kept the bytes, not the parse). mcpFile.entries now keeps what it parsed through filememo, keyed by the file's size and time (and, written in the last two seconds, its bytes), and hands each caller a deep copy of the servers it found, so a caller changing an entry doesn't change the next caller's. The RTK page's codexSandbox (Windows, Codex with rtk on) parsed the same file the same way on each visit and is kept the same way. Measured (sandbox HOME, the copied config and library, macOS, 10 warm GET /api/library after start): 2.67 s of CPU before, 0.55 s after (~0.27 s -> ~0.055 s a visit). TestCodexEntriesParsedOncePerChange: a config with 2000 projects read four times parses once, a caller's change to the entries doesn't reach the next, a change to the file is read, a file gone is no servers. It fails with the memo undone (entries parsing edit.Read's bytes each time) and with the copy undone. go test -tags nogui ./internal/library ./internal/filememo pass; TestCodexSandbox passes. The RTK memo has no test of its own (Windows only); filememo's own tests cover the keep. |
||
|
|
6876125a19 |
agent, library: an npm agent or winget's RTK under Program Files updates after Windows' administrator prompt, and says why when it can't (新v学员 on Discord)
On Windows the official Node.js installer leaves npm's global prefix at C:\Program Files\nodejs, which only an administrator can change. magpie runs as the user, and writable() on Windows always said true, so the Agents page offered the update and npm failed with EPERM (mkdir ...\node_modules\@scope), with nothing saying why. The same user then reported RTK and other actions needing elevation all failing, and asked for a setting to run magpie as administrator. There is no such setting: an elevated magpie would write the agents' configs as the administrator, couldn't start with Windows without a UAC prompt at each login, and widens what can go wrong. Instead each action that needs an administrator asks Windows for one, alone. - agent: writable() on Windows makes and removes a file in the folder (update.Writable) instead of always saying yes. An npm CLI in a folder the user can't write in is still offered on Windows, marked Admin, and its update runs through update.RunElevated, never as the user. Elsewhere (/usr/lib, would want sudo) nothing is offered, as before. - update: RunElevated (Windows) runs the command through ShellExecuteEx "runas" on a .cmd script that sets the env that differs from an elevated process's own plus PATH, cds to the folder, and sends output to a log read back; the exit code comes from GetExitCodeProcess (a non-zero one is update.ExitError, for its code). A declined prompt is ErrCanceled; no prompt to be had is the new ErrNoAdmin. Other systems: CanRunElevated false. - library: RTK installed by winget for every user (under Program Files) is upgraded through the same prompt when only an administrator can change rtk's folder; the card's Upgrade title says Windows asks first. Install, and an upgrade whose folder looked writable, run winget as the user and go through the prompt only when winget answers 0x8A150019 (command requires admin). winget's codes from the elevated run are read as before (0x8A15002B: no newer RTK, no failure). - A declined or impossible prompt is agent.AdminError (Via npm or winget); the GUI answers it with code needs_admin and says, in the reader's language, what needs an administrator and what to do: try again and allow it, or run the command in a terminal opened as administrator, and for npm also moving npm's prefix (npm config set prefix "%APPDATA%\npm") and reinstalling. - Install another agent: its npm commands note when npm's prefix (npm prefix -g, memoized) is such a folder. - Checked, not changed: autostart uses HKCU's Run key, no admin needed; magpie never runs npm uninstall; plugins install into magpie's own folder with bun; agent CLIs update only on a click; RTK's PATH fix writes HKCU's Environment and rtk init -g the user's own agent folders; the library's only other exec is the MCP server check. Run: - go test -tags nogui ./internal/agent ./internal/update ./internal/library (and the full ./... under the lock). TestNPMUpdateNeedsAdmin fails with the admin branch removed and with runAdmin bypassed; TestRTKUpgradeAsksForAdmin and TestRTKInstallRetriesAsAdmin fail with runRTKInstaller never elevating (checked by hand). - gofmt -l; go vet (darwin), GOOS=linux and GOOS=windows go vet. - GUI, Chromium and WebKit: cli-update-admin (en, zh), library-rtk-admin (en, zh exact; ja, de, zh-TW translated, no npm advice; fails with the old Upgrade title), library-rtk-upgrade/-path/-nohook/-gain, gui-ja, gui-de, gui-zh-tw, cli-update, i18n-keys. - Windows box (10.0.0.132): TestWritableSeesDeniedFolder passes, and fails on the old writable(). A portable Node 22 with Program Files' ACL (Users RX, Administrators F): as a non-elevated token (runas /trustlevel:0x20000) npm install -g failed with the reporter's EPERM, Writable said false, and dsh's CLI() said Via npm, Admin true; elevated it said Admin false. RunElevated from the elevated ssh session installed @deepseek-ai/dsh into that folder for real, and a missing version came back as exit status 1 with npm's ETARGET output. The library's RTK tests ran there too (TestRTKInstallRetriesAsAdmin passes; the shell-fake ones skip on Windows). - Not tried: the UAC prompt itself, allowing or declining it, as nobody sits at the box; the ErrNoAdmin path on a real system; a real machine-scope winget RTK (none is installed on the box). |
||
|
|
aad799eae6 |
library: an RTK release winget or Homebrew doesn't have yet says "v0.51.0 is out · waiting for winget" with no Upgrade, until it does (#1025, Fermin214)
On Windows, RTK installed by winget was 0.50.0 and GitHub had 0.51.0, which winget didn't yet. Library → RTK showed "v0.51.0 可升级" with Upgrade; Upgrade ran winget upgrade, which rightly said "winget's RTK is 0.50.0 so far…", and the card went back to "可升级" with Upgrade. The card compared rtk's version only with GitHub's latest release, never with what the package manager that installed it has, and the upgrade's answer was forgotten as soon as the card was read again.
RTKView.CheckLatest now also asks, when the latest release is newer than this rtk and it was installed by winget or Homebrew, what that package manager has: winget show --id rtk-ai.rtk --exact (the version is the first one after the line naming the package, as winget's labels are in the system's language), and brew info --json=v2 rtk without auto-update, as the Agents page's CLI updates read Homebrew. An upgrade through either records the version it left as the newest that package manager has. The answer is kept six hours (a failure fifteen minutes) and is asked again after that. When it has nothing newer than this rtk, the view says waiting (winget or Homebrew) and waitingHas. The card then shows "v{v} is out · waiting for {via}" (zh "v{v} 已发布 · 等待 {via}", ja, de), with a tooltip saying what it has, and no Upgrade button. Once it has the release, Upgrade is back. A package manager that can't be asked, or doesn't say, leaves Upgrade offered as before. GET /api/library/rtk runs the whole check within its 3s budget. magpie library rtk prints the same. Cargo (built from rtk's repository) and rtk's own script (its GitHub releases) can't lag, so they are unchanged. The Agents page's CLI updates already compare with the installing channel's own latest (Homebrew's or npm's), so they don't have this bug. The Japanese "v{v} is out" is shortened to "v{v} 公開済み", because with Upgrade beside it the card head overflowed at 440px.
TestRTKWaitsForWinget (a fake winget whose show prints Chinese labels: unaskable leaves Upgrade; asked, it waits; the reporter's upgrade waits with the "so far" note, and so does the card read again; winget given 0.51.0 and asked again, Upgrade is back and works) and the extended TestRTKUpgradeBrew (Homebrew's 0.49.0 after brew upgrade waits, on the card read again too) fail without the change (waiting <nil>) and pass. TestRTKChannelVersion covers winget show in English, German and Chinese with spinner frames, no package, and brew info's JSON. -race -count=10 on them. library-rtk-upgrade.test.cjs's new test (Upgrade finds winget behind: the waiting tag, no button, the note; a reload still waits; winget has it: Upgrade back; card head and page fit at 440px) fails without the library.js change and passes on Chromium and WebKit in en, zh, ja and de. i18n-keys, gui-ja, gui-de and the library-rtk-* tests pass on both engines. go test -tags nogui ./internal/..., go vet, gofmt -l, darwin, linux (nogui) and windows builds pass. Not tried with a real winget or on Windows: winget show's output is taken from its documented format, and the version line is assumed to follow the package line in every language.
|
||
|
|
4c170cbad6 | library, gui: DeepSeek Harness is listed under Library › RTK with why RTK has no hook for it, not left out (lc on Discord) — RTK rewrites the shell command an agent is about to run, and dsh's hooks can only allow or deny one (its Claude Code bridge drops updatedInput; deepseek-harness's pre-tool-input-rewrite is only proposed), and rtk 0.51's init has no --agent dsh (rtk-ai/rtk#3847; the open #3934 only adds AGENTS.md text, which rewrites nothing). So the RTK tab left dsh out and it read as magpie not seeing it. rtkNoHook names it with the reason: the row has a No RTK hook tag (zh/ja/de) and a switch that can't be turned on, magpie library rtk prints the reason, and on/off for dsh answer it instead of "rtk has no hook for dsh". TestRTKNoHookListed and library-rtk-nohook.test.cjs (Chromium, WebKit, en/zh) are new and fail without the change. go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass (TestProvidersAnswerWhileListsComeIn and TestUserPath failed once under the full run's load and pass on their own). | ||
|
|
21702d01ff |
Add German translation; harden paths against unset env vars (#770)
* Add German translation and harden paths against unset env vars Add a German locale to the GUI, tray menu, usage alerts and website home page, and refuse to start when the home folder is unset or relative so nothing is written under the working folder; the pi plugin no longer adopts the user's PI_CODING_AGENT_DIR, and an inherited APPIMAGE no longer selects portable mode. Scripts refuse to run from the wrong folder or empty a shared out folder, and a new internal/testenv sandboxes every test package from the user's real files, which also fixes the Claude picker and Termux installer tests on Windows. * Makefile: know magpie's folder by its go.mod, so paths with spaces work The check compared $(CURDIR) with $(dir $(abspath …)), which make splits on spaces, so a checkout under 'My Projects' or 'John Doe' refused every target. It now reads go.mod relative to the working folder and wants magpie's module there: make -C and a symlinked Makefile work, make -f from another folder still stops before any recipe runs. * i18n: German for the strings main added since, with a parity test 75 strings main added (group order, patterns, slow-start wait, usage caps, RTK savings …) get their German, and two that main dropped go. gui-de.test.cjs checks, as gui-ja does, that de has every zh string with its placeholders and tags, and that the window reads in German when picked or on a German system. * appdir: ignore relative folder variables when reading, keep them for children CheckEnv no longer unsets anything. magpie reads the XDG folders, APPDATA/LOCALAPPDATA and every agent's folder variable through appdir.Getenv/LookupEnv, which pass over a relative value; the environment stays as it is, so the agents magpie starts get the variable as the user set it. That covers what proc.UserPath lends from the login shell too, which is set after main's check and reached the desktop app unchecked. On Windows a path rooted on the current drive (\Users\x, Git Bash's /c/x) counts as usable, and magpie version and help answer without a home, before run makes any folder. * Sandbox the tests main added since internal/wslrun gets testenv's TestMain, and four tests main added that set HOME alone set their home with testenv.SetHome, so on Windows they don't read the runner's profile through USERPROFILE. * agentenv: PI_CONFIG_DIR and OPENCODE_DB take relative names on purpose omp puts $PI_CONFIG_DIR under the home and OpenCode a relative $OPENCODE_DB in its data folder, so neither depends on the working folder: appdir no longer passes them over. * i18n: German for the Library's multi-select and System One's decision API The 19 strings main added since (#791's skill multi-select, the decision API snippets) get their German; the one main replaced (four APIs → five APIs) goes. * appdir: tidy the import into magpie's group; say what Go makes of /c/x The appdir import joins the group of magpie's own imports where a file has one. rooted's comment now says that Go takes a Git Bash path like /c/x as \c\x on the current drive, not C:\x. |
||
|
|
680ca5508f |
library: RTK's savings are read from rtk gain's stdout alone, a count rtk couldn't give says why instead of "Nothing saved yet", and the page says whose commands the count is (#741 part 2, on Windows with magpie 0.1.807, RTK 0.51.0 and Codex: the RTK card said 还没有节省记录 while rtk gain in a terminal listed savings) — ReadRTK ran rtk gain --daily --format json with CombinedOutput and json.Unmarshal'd the lot, and took any error, from rtk or from the JSON, for nothing saved. rtk writes warnings to stderr with the JSON on stdout — on Windows the console code page it has no decoder for (warn_unmapped_codepage), a command it couldn't resolve, a history table it found damaged — and any of them in front of the "{" made the output unreadable, so the card said nothing was saved however much was. rtkGain now runs it with stdout and stderr apart (stdin closed, 30s at most), parses stdout from its first "{" to its last "}" (a notice printed ahead of it is passed over), and when rtk fails or prints no summary it can read, gainErr says so with what rtk said ("rtk gain: <last lines>", "rtk gain printed no summary magpie can read: …"), shown on the card as "magpie couldn't read what RTK saved: <why>" and by magpie library as "what rtk saved isn't known". magpie counts no agent itself: the figure is rtk gain's, global, every command any agent or terminal ran through RTK on this computer, and the card now says that after it, so an empty one isn't read as magpie counting only some agents. On Windows, Codex with its Windows sandbox on (config.toml's [windows] sandbox = "elevated"/"unelevated", or the older elevated_windows_sandbox / experimental_windows_sandbox features, and not danger-full-access) runs its commands as its CodexSandbox account, whose own %LOCALAPPDATA%\rtk\history.db keeps what RTK saved there, or with a restricted token that can't write the user's — either way not in the rtk gain the user runs; ReadRTK reports that as codexSandbox, and the card (and magpie library) says why what Codex saves isn't counted. The count is read again each time the RTK tab is opened, so commands run since show without restarting magpie. TestRTKGainRead uses a fake rtk: a code-page warning on stderr with JSON on stdout (read — the old CombinedOutput code says nothing saved), a notice line before the JSON, zero commands, an rtk that exits 1, and one that prints no JSON, with the exact gainErr; TestCodexSandbox covers each config form. library-rtk-gain.test.cjs (webkit) checks the reason and the scope line, the Codex sandbox note, and that reopening the tab re-reads the count, in English and Chinese. go vet, builds (darwin, GOOS=linux -tags nogui, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass, as do the Library and click-scroll GUI tests. Not tried on the reporter's machine: which stderr line broke it there isn't known (the card now shows it if it's still there), and the Codex sandbox account's separate history is from Codex's and RTK's source, not seen on a real Windows Codex.
|
||
|
|
9848a9062a | library: RTK says when rtk isn't on the PATH the agents get, and puts it there when asked (#601, Moody-Sin: magpie好像没有正确安装RTK — Pi said "RTK disabled: rtk binary not found in PATH" while the Library showed RTK working) — rtk's hooks run it by name (Pi's extension probes rtk --version and turns itself off when that fails; Claude Code's and Codex's are rtk hook …; the commands they rewrite to are rtk git status and so on), but magpie looked for rtk in more places than an agent's PATH: ~/.local/bin and ~/.cargo/bin, which the app adds to its own PATH whether the user's shell has them or not (rtk's own install.sh puts it in ~/.local/bin and only warns when that isn't on PATH), and WinGet\Links on Windows, which winget doesn't always link into. So rtk was "installed", the agents were switched on with it by its whole path, and none of them could run it. Now the PATH a terminal opened now has is read — the login shell's (proc.LoginPath, the one UserPath already asks for, kept a minute) or on Windows the registry's (moved from provider's registryPath) — and when rtk isn't in it the RTK card says so, with what Put RTK on PATH will do, and each agent that has rtk is tagged Not on PATH (不在 PATH 中). Put RTK on PATH (magpie library rtk path) links rtk into the first of ~/.local/bin, ~/bin, /opt/homebrew/bin, /usr/local/bin, linuxbrew's bin, ~/.cargo/bin that is on that PATH and writable, or on Windows adds rtk's own folder to the user's PATH in the registry (a link needs Developer Mode, and a copy is left behind when winget upgrades rtk; winget's package folder doesn't change across upgrades) and tells Explorer; with no such folder it says which folder to add to PATH in the shell profile — shell profiles are never edited. rtk is also found in winget's package folder (WinGet\Packages\rtk-ai.rtk_*), and rtk's script upgrades a linked rtk where the link points, not over the link. TestRTKOffPath and library-rtk-path.test.cjs (en, zh) fail without the change. go vet ./internal/..., go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build and vet, go test -tags nogui -count=1 ./... under a temp HOME pass but the known TestFXInState flake. The Windows registry path is built, not run on Windows. | ||
|
|
ec4ee5a3a4 |
fix(proc): end what a CLI probe started, on its timeout and when magpie exits (#414)
* fix(proc): end what a CLI probe started, on its timeout and when magpie exits The probes that ask an agent's CLI something (claude auth status, cursor-agent about/models/status, the --version checks) ran through proc.CommandContext, which on its timeout kills only the command itself. A CLI that is a script (a version manager's wrapper, a shim) left what it had started running, adopted by init; and a probe still asking when magpie exited (a one-shot command, an update, a restart) was left whole, with nothing to end it. With Omarchy's mise wrappers stuck in their exec loop (omacom/omarchy#7234) that was five processes holding about half a core each for up to six hours. proc.ProbeContext gives such a probe a session of its own on Unix, as StartTree does, and its context ending kills the whole group. Probes still running are listed, and proc.EndProbes kills them when magpie exits (after run in main) or puts a new version in its place (update.Reexec). On Windows a probe is killed alone, as before, a job being joined only once the command has started. TestProbeTimeoutEndsWhatItStarted and TestEndProbes fail without the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(proc): end probes on a terminal's signals and on a Mac's quit Review of the first change: a probe leading its own session no longer gets the Ctrl+C, hang-up or SIGTERM sent to magpie's terminal or service, and magpie ending on the signal never reached EndProbes, so the probe was left to init where before it died with magpie. main now catches SIGINT, SIGTERM and SIGHUP, ends the probes and exits as the signal would have (128+n). A signal magpie was started ignoring (nohup, a background job) stays ignored. The account sign-in and plugin commands, which end themselves on Ctrl+C, go through interruptContext and are left to do so. On a Mac the desktop app's quit ([NSApp terminate:], also the restart to update) exits without returning to main, so OnShutdown ends the probes. TestProbeTimeoutEndsWhatItStarted ended its probe on a 500ms timeout, which on a Mac could come before the script had written its child's pid (6 of 10 runs failed in review). It now ends the context once that pid is read, the same Cancel path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: let the app and the TUI quit on a signal their own way Review of the signal handling: endProbesOnSignal exited ahead of Wails and bubbletea, which quit on SIGINT and SIGTERM themselves. `magpie tray` exited 143 without OnShutdown (no downloaded update installed, and sessions.Saved skipped in main), and `magpie tui` left the terminal on its alternate screen with the cursor hidden. The app's and the TUI's entry points now hand the signals back (ownSignals): the app's OnShutdown ends the probes, and the TUI comes back to main, which ends them too. A one-shot command keeps the handler. TestOwnSignalsHandsThemBack fails without the change (magpie exited 143 before the command could quit its own way); TestSignalExits keeps the one-shot behavior. childPid waited 3s for a script just written to start its child, which a busy Mac can exceed (2 of 3 full runs failed in review). It waits 30s now and, should the probe end first, says the probe's error rather than "the script started nothing". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: keep SIGHUP for the app and the TUI, and die of the signal ownSignals handed SIGHUP back along with SIGINT and SIGTERM, but neither Wails nor bubbletea handles it: the terminal closing under the TUI or an app started from a shell ended magpie on the spot, and its probes, in a session of their own, out of the hang-up's reach, kept running (before this PR they were in the terminal's group and ended with it). SIGHUP now stays with endProbesOnSignal. A tray under a pty whose terminal closes left 2 processes before, none now. The handler asked whether a command was ending itself on Ctrl+C only after EndProbes, which can take up to a second; a sign-in done in the meantime got magpie ended in the middle of its own cleanup. It is asked first. It exited 128+n, which a shell takes for a child that handled the signal: a loop running magpie went on to the next run on Ctrl+C. It now dies of the signal (handling reset, the signal sent again); Windows, which can't send one, still exits with the code. agentProbe and agentCommand share withProxy; the Windows probeGroup comment no longer says EndProbes ends what a shim started. TestOwnSignalsKeepsHangUp and TestInterruptWhileEndingProbes fail without the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: hand signals to the TUI and the app only once they listen Review: runTUI handed SIGINT and SIGTERM back before tui.Run, whose newModel asks agents' CLIs (claude auth status, up to 5s) before bubbletea listens for signals. Ctrl+C, SIGTERM or SIGINT while it loaded ended magpie by Go's default and left the probe and its child running. tui.Run now takes ready, called once the model is made, and runTUI passes ownSignals. The app had the same window: runGUI handed them back before gui.Run, which starts the backend (probes included) before Wails' Run starts listening. ownSignals is now gui.Started, called on ApplicationStarted, which Wails emits after its signal handler is set up. A tray sent SIGTERM 0.05s after starting, a probe under way, left 2 processes before and none now; one sent it once started still quits through OnShutdown (exit 0). TestTUIKeepsSignalsWhileLoading fails without the change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> |
||
|
|
8124d3f927 | edit: a config kept as a symlink stays one when magpie saves or clears it (#323, jigaowan) — WriteAtomic wrote a temp file beside the path and renamed it over it, so a linked library.json, instructions.md, CLAUDE.md, settings.json or config.toml became a file of its own and the dotfiles target kept its old text; clearing instructions.md removed the link. Now a write goes to the file at the end of the links (the one it names when nothing is there yet, an error for a loop of links), keeping its mode, and clearing a linked file empties its target and keeps the link (Pi's migrated mcp.json stays as {}); a plain file is removed as before. Sign-ins and the Kiro/StepFun files magpie writes privately follow links the same way, and a failed edit rolled back deletes only what it made behind a link to nothing. TestWriteAtomicFollowsSymlink, TestRemoveKeepsSymlink, TestAtomicallyKeepsSymlink, TestLinkedFilesStayLinked and TestPrivateWritesKeepSymlink fail without the change. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build, go test -tags nogui ./... pass. | ||
|
|
5b43bdd61c | library: RTK's version is kept up to date from magpie, and what it saved is drawn day by day (这里要能够管理RTK的版本,比如给它升级,以及能够看到RTK省token的趋势) — the RTK card shows its latest release beside the installed one (read from where github.com/rtk-ai/rtk/releases/latest redirects, as RTK's install.sh does, the API as fallback; kept six hours) and, when newer, an Upgrade button that brings it up the way it was installed: brew upgrade rtk for Homebrew's (in a Cellar; Homebrew updated first), winget upgrade on Windows, cargo install --git again for cargo's, and RTK's own script again, into the same folder (RTK_INSTALL_DIR), for one it put elsewhere; when Homebrew's formula is still behind the release, that is said. Also magpie library rtk upgrade. Under the totals, a chart of what RTK saved each day (week by week past 92 days) over 30 days, 90 days or all it has recorded: each bar the commands' whole output, the part saved above what still went to the model, the range's own total beside it — from rtk gain --daily --format json (RTK 0.28 on), which carries the summary too. Tested with a fake Homebrew rtk behind its release and a fake script install, and against the real rtk 0.28.2 and its history in a sandbox magpie (GitHub says 0.50.0); the upgrade itself not run on this machine | ||
|
|
c8d7a995d1 | rtk: Codex isn't given an rtk older than 0.50 (LeeHom: rtk's installer didn't add its hook to Codex) — rtk has a hook for Codex (rtk hook codex in hooks.json) from 0.50.0 on; an older rtk init -g --codex only puts @RTK.md in AGENTS.md, which rewrites no command, so switching Codex on ran it and then said the hook wasn't there. With an rtk before 0.50 the Library shows Codex with "Update RTK" (需更新 RTK), its switch off, the tooltip and magpie library rtk saying to update it (brew upgrade rtk, or its installer again) first | ||
|
|
b990735823 | agent: RTK isn't given to OpenCode 2 — rtk init --opencode writes a plugin shaped for OpenCode 1 (a named export, no default {id, effect|setup}), which OpenCode 2 refuses to load with 'Plugin must export a default definition with an id and an effect or setup function' (rtk-ai/rtk#4311, still so in rtk 0.50.0); with opencode --version at 2 or later the Library shows 'Not for OpenCode 2' and won't switch it on, while a plugin already there can still be switched off and taken out (ARNO) | ||
|
|
0218eeb5ca | rtk: an agent left with the hook of an rtk that isn't installed (never was, or removed since) is shown with RTK missing — its shell commands fail — and can still be switched off: magpie takes out just what rtk's installer put in (the hook in settings.json / hooks.json, RTK.md and the @RTK.md line, Gemini's hook script, Copilot's instructions block, the OpenCode / Pi / OMP extension, Hermes' plugin) itself, needing no rtk, the files kept aside first; rtk's own uninstaller is no longer used, which deleted Gemini's GEMINI.md whole and took Claude Code, OpenCode and Cursor away together. Gemini is given rtk hook-only, so the user's GEMINI.md isn't written over. Install RTK on the page (and magpie library rtk install) installs rtk with Homebrew, winget on Windows, or rtk's own script into ~/.local/bin, only when clicked | ||
|
|
631e4c3096 | library: RTK (rtk-ai.app) can be switched on per agent — a Library tab lists the agents RTK has a hook for (Claude Code, Codex, Gemini CLI, OpenCode, Cursor, Copilot, Pi, OMP, Hermes), each with a switch that runs RTK's own installer (rtk init -g …) for it, keeping the files it edits aside first; which have it is read from their files, and the tab says RTK's version and the tokens it saved. RTK's installers for OpenCode and Cursor give it to Claude Code too, and its uninstaller for Claude Code or OpenCode takes all three: magpie keeps each switch to its own agent. magpie library rtk [on|off <agent>] does it from the CLI. Asked on X |