1ccacad63281094de8a3372d5a507d38f9969e5c
7
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
47d5839397 |
library: sync and backup files carry the hooks
VincentChan on Discord (v0.1.3005) said part of the Library doesn't reach his other computer through sync. Checked kind by kind what the library part of a bundle carries: instructions (each set's text, a linked set's file text, the agents ticked, each agent's own addition), MCP servers, skills and subagents all go. Hooks didn't: library.Bundle had no field for them, so a hook made on one computer never reached the other, by WebDAV/S3/GitHub sync or a backup file. - library.Bundle.Hooks (*[]*Hook): name, description, event, matcher, command, timeout, agents ticked. Collect always sets it, empty too. Applied.Hooks (the entries magpie wrote into each agent here) stays out: each computer writes them on the sync Put runs, beside the user's own hooks, and records its own entries, so an entry the user edited there stays theirs. - Put replaces the hooks with the bundle's, so one taken out on one computer goes from the others. A nil list (a bundle from a magpie before this) keeps this computer's. - check refuses a hook with no name, no command, or named twice. The event and agents are carried as they come: an event a newer magpie knows is a problem on the agent here, not a refused library. - davsync: an empty list hashes as before the field, so upgrading with no hooks syncs nothing. - The CLI's backup line counts hooks; the GUI's sync/export/import ticks say "instructions, MCP servers, skills, hooks and subagents" in every language. - library.md and sync-backup.md updated, and they now name what stays this computer's own: projects, skill groups, CopySkills/SkillHow, SharedSkills, MCPHub. Instructions: two sandbox computers through the fake DAV server carried a named set and a change to it, a set linked to ~/.agents/AGENTS.md and a hand edit of that file, both computers having their own text first, an agent's own addition, and an agent installed after the first sync. All reached the second computer's CLAUDE.md/AGENTS.md (exploration tests, not kept). So no instructions change here; what VincentChan saw is not reproduced yet. Run (worktree at 0e55a7593; origin/main bf60ea596's two commits touch none of these files): - mote: go test -tags nogui ./internal/backup ./internal/davsync ./internal/cli ./internal/library ok; go vet -tags nogui for darwin, GOOS=linux and GOOS=windows on the four packages ok; gofmt -l clean; go test ./internal/gui -run 'TestCoreScriptBudget|Words|I18n|Builtins' ok - GUI (wsl-run, Linux): i18n-keys, github-sync, s3-sync, sync-*, webdav-settings-refresh, library-backups-top, gui-de, gui-ja, gui-zh-tw: 187/187 Broken by hand: with Collect not setting Hooks, Put ignoring them and the hash not dropping an empty list (the old code), TestCarryHooks, TestCarryOldBundleKeepsHooks, TestCarryNewerHooks, TestBackupFileCarriesHooks, TestSyncHooks and TestNoHooksHashAsBefore went red. Not tried: a real WebDAV/S3/GitHub remote between two real computers; Windows and Linux runs of the Go packages. |
||
|
|
900ae0fa51 |
backup, sync: sign-ins go too when picked, sealed, never over a later renewal
qianxunji (#feedback) and curtinp118 on Discord: a VPS restored from a backup, or a new computer joining sync, had to sign in to every subscription again. Sign-ins (subscription accounts in logins.json, Codex's auth.json, plugins' sign-ins in plugin-auth.json) can now go too, in each place only when picked; all are off by default, so an upgrade carries nothing new. - Sync (WebDAV, S3, GitHub): a "Sign-ins" tick in the form, with a line saying anyone with the passphrase and the server's file can use the accounts, and that an account on two computers can be signed out on one when the other renews it. CLI: `magpie webdav|s3|github set sign-ins=yes`. - Export: "With the sign-ins", off; ticked, the passphrase hint says the file holds them. CLI: `magpie backup --sign-ins`. - Import: "Bring in the sign-ins too, when the file has them", on. CLI: `magpie restore --no-sign-ins` leaves them out. - Back up by itself: "Sign-ins in backups", Off/On. On asks for a passphrase (twice) that seals the sign-ins alone (the rest of an automatic backup stays unsealed, as before); it is kept in autobackup.json (0600), never sent in the view. A backup whose sign-ins another passphrase sealed restores without them and says so. What goes (provider.CollectSignIns, plugin.CarriedAuth): magpie's own copies only, not an agent's own account, an agent-home row, a hidden or plugin: row, or a retired built-in. Each record is keyed by agent + email + org (or the account key); ids two rows share go on neither side. Restore/import (RestoreSignIns) adds what is missing and updates only when the incoming copy was renewed later; nothing here is removed. Before writing over a row it counts every row that could be the same account (same login, same refresh token, same id): none adds, several keeps all, one is kept when it isn't magpie's own copy, is held, or is the agent's live account. Codex's auth.json is written temp-and-rename, 0600, only where Codex is signed out. Sync merges per record against the last sync's hashes (MergeSignIns): the later renewal wins; a removal crosses only when the other side still had it as of the last sync; ApplySignIns re-checks each row's hash before writing so a renewal in between is kept. A computer with the tick off sends none, so others remove nothing for it; turning it off, a Restore, or a replaced server file clears the last-sync record. Export's and Import's forms moved out of app.js into syncfiles.js, imported when one opens (as autobackup.js is), so the core is 3.2KB under its budget with no raise (app.js 3.2KB smaller than before). docs/subsystems/sync-backup.md has a "Sign-ins, when picked" section; subscription_signin_test.go's header now says it pins the default. Run at the pushed head (678d28cba on origin/main |
||
|
|
07a3312c53 |
library: sync and backup files carry the subagents
xixi_Sean_ on X asked why Sync leaves the Library's subagents out. There
was no reason: the library part of a bundle now carries them.
- library.Bundle.Subagents (*[]*Subagent): name, description, prompt,
the skills and MCP servers named, the agents ticked. Collect always
sets it, empty too. Applied.Subagents (which files magpie wrote here
and their hashes) stays out: each computer writes the files into its
own agents on the sync Put runs and records its own, so a file the
user edited there, or one of theirs by the same name, stays theirs.
- Put replaces the subagents with the bundle's, so one taken out on one
computer goes from the others. A nil list (a bundle from a magpie
before this) is unknown and keeps this computer's.
- check refuses a subagent whose name isn't one (it is a file name in
every agent) or comes twice; agent ids are carried as they come, so a
newer magpie's tick for an agent this one can't give subagents to
stays and writes nothing here.
- davsync: an empty list hashes as before the field, so upgrading with
no subagents syncs nothing.
- backup files go through the same Collect/Put; the CLI's backup line
counts subagents. The GUI's sync/export/import ticks say "instructions,
MCP servers, skills and subagents" in every language.
- webdav-settings-refresh's "Agents" tick locator also matched the
library tick's "subagents": it now asks for "Agents' models".
- library.md and sync-backup.md updated. Hooks still aren't carried.
Run (rebased on 0bf5adb11; Go runs at e0c57ffe2, same diff):
- mote: go test -tags nogui ./internal/backup ./internal/davsync
./internal/cli ok; ./internal/library -run 'TestCarry|TestSubagent|
TestLocalServer|TestPutKeeps|TestPutSame|TestRestoreKeeps' ok
- wsl-run (Linux): ./internal/library ./internal/backup ./internal/davsync
whole packages ok
- win-run (Windows): the same three, -run 'Subagent|TestCarry|TestLibrary|
TestSyncLibrary' ok
- go vet -tags nogui for darwin, GOOS=linux and GOOS=windows on the four
packages ok; gofmt -l clean
- GUI (wsl-run, Chromium + WebKit, every language): i18n-keys,
github-sync, s3-sync, sync-auto-restore, sync-not-backup,
sync-other-kind, sync-sign-in, sync-spin, sync-usage-error,
webdav-settings-refresh, library-backups-top, gui-de, gui-ja,
gui-zh-tw, settings-search, settings-sections: 170/173, then
webdav-settings-refresh green after the locator fix. The one red left,
i18n-keys "a plugin's words are its own" ("Unmarked" in
plugins/routing/i18n.js), is on main already: #4524.
mote ran five other GUI suites at load 18, where every WebKit
github-sync case timed out at launch, so the GUI run moved to Linux.
Broken by hand: with Collect not setting Subagents and Put ignoring
them, TestCarrySubagents, TestCarrySubagentKeepsUsersFiles,
TestCarryNewerSubagents, TestBackupFileCarriesSubagents,
TestSyncSubagents and TestNoSubagentsHashAsBefore went red; with Put
treating a missing list as empty, TestCarryOldBundleKeepsSubagents and
TestBackupFileCarriesSubagents went red.
Not tried: a real WebDAV/S3/GitHub remote between two real computers;
the fake DAV server carries it between two sandbox HOMEs.
|
||
|
|
9298d2a7c3 |
cli: prompts read the stdin Windows' console init reopens, not the one package init saw
tom047784 (Discord, Windows desktop build): `magpie plugin login` in a
terminal failed with "read /dev/stdin: The handle is invalid". The
desktop build is a GUI-subsystem binary; console_windows.go's init
attaches the parent console and reopens CONIN$/CONOUT$ into os.Stdin,
os.Stdout and os.Stderr. But `var stdin = bufio.NewReader(os.Stdin)` in
backup_cmd.go is a package variable, set before any init runs, so it
kept the invalid handle.
That one reader serves every CLI prompt, so all of them broke the same
way: plugin login (askPrompt, askNumber, the code and pasted callback
lines), backup/WebDAV passphrases and passwords piped in (secret), the
library and quota confirmations. stdin is now a func that makes the
reader over os.Stdin as it is when read, and remakes it if os.Stdin
changed; one reader still serves a run, so a second piped secret is
still the second line.
Sibling of the same class: lipgloss's default renderer (termenv's
default output) is made over os.Stdout at its package init, before the
reattach, so the desktop build's CLI printed every style without colour.
The init now points that renderer at CONOUT$ in place; the styles made
at package init hold it. A grep for package-level os.Stdin/os.Stdout/
os.Stderr found no other one in the repo (writers like fmt.Println and
json.NewEncoder(os.Stdout) inside functions resolve at use time).
webdav_cli_test's piped() swapped both os.Stdin and the reader, which is
why no test caught this; it now swaps os.Stdin only.
Run (at this tree, worktree off origin/main
|
||
|
|
fad96ea0fe |
gui, cli: sync and backup say the synced settings use a subscription not signed in here, and that one not used here needs nothing (悠悠哥 on Discord)
悠悠哥 asked why the sync card said ChatGPT wasn't signed in. The line was
right (the synced settings carry ChatGPT's picks, and this computer has
no ChatGPT account; sync carries no sign-in) but didn't say why ChatGPT
was named or that it can be left alone. It now reads "Your synced
settings use {names}, which isn't signed in on this computer. Sync
carries settings, not sign-ins: to use it here, sign in in Providers →
Add a provider; if you don't, nothing needs doing." The backup import's
sibling says the same of the backup, in en, zh, zh-TW, ja and de, and
the CLI's `magpie webdav` status and `magpie backup import` lines say it
too. Which subscriptions are named is unchanged.
Run:
- sync-sign-in.test.cjs, now with zh-TW and widths 1100/900/440/420:
chromium + webkit, 40/40; screenshots of zh at 420 looked at.
- go test ./internal/cli: ok. go test ./internal/gui: ok except
TestMainWindowCorners killed at its 40s deadline (load average ~180),
which is #1936; alone it passes (36s).
- gofmt -l clean; go vet darwin, windows, linux -tags nogui on cli.
Not tried: the real app with a real WebDAV sync.
|
||
|
|
b8e23db45a |
backup, davsync: an import or a sync installs the plugins and names the subscriptions to sign in to (yapechan)
yapechan on Discord (Windows, Synology WebDAV): after an import or a WebDAV
sync no providers showed on the other computer; adding the same provider by
hand made the synced settings and usage apply. No error, a restart didn't
help.
Cause. A backup and a sync carry providers.json as stored. For a
subscription that is its model picks and settings alone (no endpoint, no
key), and sign-ins are never carried by design; allProviders lists such an
entry only once an account is signed in here. plugins.json was not carried
at all, so a provider served by a plugin (every moved subscription, any
plugin provider) had nothing to come from on the other side. The import
said "N added" and "Needs a key: , " (the picks entries have no name and no
key), and the sync said nothing. API-key providers do come over: tried with
a nogui build in two sandbox HOMEs (DeepSeek, a custom relay, Kimi Code all
listed after `magpie restore`). No Windows-only path issue found.
What changed:
- provider.Carried(keys): the plugins added from npm or git, on/off and
their options (without keys, options whose names look like a key are left
out, as secret headers are). Folder plugins and plugin-auth.json stay.
- backup.Bundle.Plugins (nil from an older magpie). Restore installs the
ones not here through provider.AddPlugins (plugin.Add, then Off and
Options, then HandOver once); it never removes or changes one already
here. A failed install is reported, not a failed restore.
- Result.SignIn / provider.NotSignedIn: the subscriptions brought with no
account here. NeedKey no longer lists picks-only entries (provider.OnlyPicks).
- davsync: the providers part's hash covers the plugins (unchanged for a
setup without any), take/bring carry them, bring installs (logged on
failure), and Status().SignIn names what to sign in to.
- CLI restore and `magpie webdav`/`s3` status print both; the GUI's import
result and the sync row show them (en, zh, zh-TW, ja, de).
- docs/reference.md says what a backup carries now.
Run:
- go test -tags nogui ./internal/provider ./internal/backup ./internal/davsync
./internal/cli ./internal/gui in a sandbox HOME.
- New tests fail with the change broken by hand: TestPluginsCarried
(installed-skip and the HandOver guard), TestNotSignedIn,
TestRestorePluginsAndSignIn ("Needs a key: [ Acme]" without OnlyPicks),
TestSyncPluginsAndSignIn (bring not installing, Status not naming),
sync-sign-in.test.cjs (the lines removed).
- sync-sign-in.test.cjs: Chromium and WebKit, en/zh/ja/de, 900 and 440px,
16/16; it also caught subNames throwing while providers was still null.
sync-*.test.cjs, s3-sync, i18n-keys, gui-ja, gui-de pass.
- gofmt -l, go vet, GOOS=linux and GOOS=windows go vet -tags nogui on the
touched packages.
Not tried: a real plugin install from a real sync (the installs are stubbed
in tests); a real Synology server.
|
||
|
|
23e764d0e0 |
cli: magpie's commands move from the root into internal/cli; the root keeps only main.go
The root held 89 .go files (30 commands, 59 tests). They move as they are to internal/cli (package cli), with git mv so history follows them. The only code change is main() becoming cli.Main(version): the root's new main.go keeps `var version` in package main, so -ldflags "-X main.version=…" in the Makefile, the Dockerfile and magpie-releases, and every workflow, work unchanged. go-winres's rsrc_windows_*.syso still land next to package main in the root. Tests that read testdata by a root-relative path now go up one level (../plugin/testdata/fake, ../sessions/testdata). Five subsystem doc links point at internal/cli/. Run: - go build ./..., gofmt -l, go vet on darwin, linux and windows (nogui) - builds with tags production, dev, "production nogui"; windows -H windowsgui; linux CGO_ENABLED=0 - make release-cli TARGETS="darwin/arm64 linux/amd64 windows/amd64 android/arm64" VERSION=9.9.9-tidy: all four built, binary prints "magpie 9.9.9-tidy" - docker build --build-arg VERSION=7.7.7-tidy: container prints "magpie 7.7.7-tidy" - go test ./internal/cli (default and nogui): 152 tests, the same count as the root on main - go test ./...: all packages pass (agent, gateway, library, provider timed out at 10m under other sessions' load and passed rerun alone with -timeout 40m; none of them changed) - the built binary in a sandbox HOME: version, help, ls, providers, claude, and an unknown command's error |