Files
magpie/internal/edit
yetone 5c02be05b8 agent: agy moves onto the community agent-agy plugin
The built-in agy agent (Antigravity CLI) is the first built-in agent a
community agent plugin serves, as the retired subscriptions moved onto
provider plugins. While @magpie-community/agent-agy is installed and on,
magpie's agy is the plugin's: the built-in leaves the list (here and in
WSL), its id and aliases are the plugin's, and what the built-in wired
is handed over. Turned off or removed, the built-in is back. Nothing is
forced yet; the forced install and the built-in's retirement come once
the plugin is on npm and a real run with it is on record.

The plugin (plugins ebcff866, 0.2.0) follows the built-in since
0cc91af3d: its config is magpie's own magpie-settings.json, handed to
agy with --settings, agy's settings.json is only read, and
remote-control runs as agy is.

What an agent plugin can say now (agentplug; docs/reference.md and the
site's plugins pages, en/zh/ja, and llms-full.txt):
- base: the agent's own settings file, read for the user's own model
  and passed to connect and own; needs launch.args with {config}, and
  stepping out removes magpie's config file whole;
- launch {env, model, args, plain}: `magpie start <id>` and the shell
  functions (posix, fish, PowerShell, a WSL distro's) put args before
  the model flag, and run a plain word or flag as the agent is;
- own({config, base, model}), effort, wsl, aliases.

Moving over (plugged_moved.go): agentMovers names agy's package;
agyHandover gives back a settings.json an older built-in wired (Sync),
then makes magpie-settings.json the plugin's stash, so the plugin's
agent reads as connected and stepping out removes the file.

Run (mote, macOS 27, Go 1.26.8) at fe8c05e0c, the base before the last
rebase:
- go test internal/agent (507s), agentplug, sessions, edit, update,
  plugin: ok.
- internal/cli and internal/gui: red only on main's own reds, the same
  at origin/main 8fe720453: TestModelUsageAlignsEveryDescription and
  TestModelUsageLinesUpItsDescriptions (#6104),
  TestSettingsSaveKeepsWhatItDoesNotSend (#6103), TestCoreScriptBudget
  (#6116, filed now).
- GUI, both engines, and site node --test: agy-effort, agy-launch,
  library-rtk-agy, gui-de, gui-zh-tw, i18n-en-no-cjk, i18n-keys,
  plugin-page-foreign-error, site/*.test.mjs: 114 pass.
- vet: macOS, GOOS=windows, Linux in WSL (-tags gtk3); gofmt clean.
- The shell functions with a config path holding a space: bash and zsh
  on mote, PowerShell on Windows (win-run), bash in WSL.
- Broken by hand: TestAgyPlugin red with Args, Plain or the file's
  removal taken out.
At 20d807d92 (rebased on 8fe720453): vet (macOS, windows) ok, agentplug
and internal/agent -run 'Agy|Plugged' ok, agy-launch and i18n-keys
pass; plugin-page-foreign-error is red there and at plain origin/main
8fe720453, from that commit (#6117), not this change.
Plugins repo: bun test packages/agent-agy 4 pass.

Not tried: fish (on none of the machines); a real agy run with the
plugin at 0.2.0 (the 0.1.0 design ran for real in a sandbox HOME, the
settings.json one this replaces); Windows and WSL agy with the plugin;
an install from npm: @magpie-community/agent-agy isn't on npm yet, so
until its first publish no user is moved.
2026-11-11 16:13:19 +08:00
..
test: every package's tests pass on Windows, and none writes outside its sandbox (the user: 把 Windows 上那几个失败的测试修掉) — on a Windows box the suite failed in most packages, and the root package hung for 25 minutes. Tests set HOME, which os.UserHomeDir ignores on Windows (it reads USERPROFILE), so they read and wrote the runner's own home; each now sets USERPROFILE beside HOME, and Devin's, Goose's, Crush's and Claude Desktop's tests set APPDATA/LOCALAPPDATA, where those keep their files there. said() read the command's output only once it returned, and a pipe holds a few KB on Windows, so magpie model --help blocked forever; it reads while the command writes. Unix permission bits (the gateway key store's 0600 too), exec bits and symlinks Windows lacks are checked only off Windows; TOML strings hold Windows paths as literal strings, JSON as marshalled ones; a URL's path is compared as one. The provider and usage packages run in a home of their own (TestMain, as the gateway's already does), since a CLI's identity kept by a refresh still going when its test ended landed in the runner's ~/.config/magpie — and on a Mac in the user's own. Two product fixes came out of it: imagemcp took a file:///C:/… root or image for the path /C:/…, which doesn't exist on Windows, and now makes a Windows path of it (a host for a UNC share); and session discovery could keep a new Cowork session hidden on Linux, where a folder's mtime is a kernel tick and its size doesn't change, so an entry added within the tick of the last listing left both as they were — a listing made within 2s of its folder's last change is read again, as git does for racy files. TestFilePath and TestRacyDirectoryListedAgain fail without the change. On Windows 11 every package passes (32 of 32) and a run of each package in a fresh home leaves nothing in home, APPDATA or LOCALAPPDATA; on Linux (WSL) and macOS go test -tags nogui ./... passes. go vet, go build -tags nogui (darwin, GOOS=linux), GOOS=windows go build pass.
2026-10-01 23:15:07 +08:00
toml: Codex's config.toml with a multi-line array (notify = [ … ]) is edited right, and an edit that fails leaves every file as it was (#253 kerwinliu00001: "edited TOML is invalid: line 2, column 1: incomplete number", config.toml left with model_provider gone and [model_providers.magpie] added but no model) — the top-level key edits (GetTOMLTop, SetTOMLTop, DelTOMLTop) went line by line with regexes: a new key went after the last line that looked like key = …, which for notify = [ was inside the array; key = value lines inside a multi-line string were read as keys and a line starting with [ as a table; replacing or deleting a multi-line value touched only its first line. They now locate the top-level keys with the TOML parser, as the table edits already did, each with its value's whole range however many lines it takes (parseTOMLFile, the unnamed root table beside the tables); SetTOMLTop finds all its keys in the file as read and writes once. A file the parser refuses is still read line by line, so a broken config keeps showing its model, and writes to it are refused untouched. And a pick is several writes (Codex: drop model_provider, add magpie's provider table, set openai_base_url and model), each checked, so one failing left the earlier ones on disk: edit.Atomically(fn, paths…) puts each file back to its bytes and mode, or removes one it created, when fn fails, and every field set and Sync of Codex (config.toml and magpie-models.json, so Codex in WSL too), Kimi and Grok goes through it, as do Codex's MCP server writes (putCodex, delCodex). Tested in temp dirs and a temp HOME: the reporter's file read, set and deleted directly and through Codex's model field (signed in, with model_provider and model above the array, with magpie as the provider), the array's text kept and the TOML valid, and back to a Codex model; nested arrays, trailing commas, comments in arrays, [x] and a = b in strings, an inline table in an array; """ and ''' strings holding model = … and [table] lines not read as keys, new keys after their closing quotes, one deleted whole; a forced failure of Codex's last write leaving config.toml byte-identical; TestAtomically. They fail on main (the Codex ones with the reporter's error). go vet ./internal/..., go build -tags nogui (and GOOS=linux, GOOS=windows) and go test -tags nogui ./... pass. Not tried against a real ~/.codex, in WSL or in the GUI; multi-line inline tables (TOML 1.1) are refused by the parser and so left untouched with an error.
2026-09-30 09:31:59 +08:00
toml: Codex's config.toml with a multi-line array (notify = [ … ]) is edited right, and an edit that fails leaves every file as it was (#253 kerwinliu00001: "edited TOML is invalid: line 2, column 1: incomplete number", config.toml left with model_provider gone and [model_providers.magpie] added but no model) — the top-level key edits (GetTOMLTop, SetTOMLTop, DelTOMLTop) went line by line with regexes: a new key went after the last line that looked like key = …, which for notify = [ was inside the array; key = value lines inside a multi-line string were read as keys and a line starting with [ as a table; replacing or deleting a multi-line value touched only its first line. They now locate the top-level keys with the TOML parser, as the table edits already did, each with its value's whole range however many lines it takes (parseTOMLFile, the unnamed root table beside the tables); SetTOMLTop finds all its keys in the file as read and writes once. A file the parser refuses is still read line by line, so a broken config keeps showing its model, and writes to it are refused untouched. And a pick is several writes (Codex: drop model_provider, add magpie's provider table, set openai_base_url and model), each checked, so one failing left the earlier ones on disk: edit.Atomically(fn, paths…) puts each file back to its bytes and mode, or removes one it created, when fn fails, and every field set and Sync of Codex (config.toml and magpie-models.json, so Codex in WSL too), Kimi and Grok goes through it, as do Codex's MCP server writes (putCodex, delCodex). Tested in temp dirs and a temp HOME: the reporter's file read, set and deleted directly and through Codex's model field (signed in, with model_provider and model above the array, with magpie as the provider), the array's text kept and the TOML valid, and back to a Codex model; nested arrays, trailing commas, comments in arrays, [x] and a = b in strings, an inline table in an array; """ and ''' strings holding model = … and [table] lines not read as keys, new keys after their closing quotes, one deleted whole; a forced failure of Codex's last write leaving config.toml byte-identical; TestAtomically. They fail on main (the Codex ones with the reporter's error). go vet ./internal/..., go build -tags nogui (and GOOS=linux, GOOS=windows) and go test -tags nogui ./... pass. Not tried against a real ~/.codex, in WSL or in the GUI; multi-line inline tables (TOML 1.1) are refused by the parser and so left untouched with an error.
2026-09-30 09:31:59 +08:00
2026-10-04 02:05:10 +08:00