From b9dc1d0beb43e2c9b2ae62d26c757b01cb1b2d72 Mon Sep 17 00:00:00 2001 From: yetone Date: Fri, 20 Nov 2026 17:35:32 +0800 Subject: [PATCH] library: a skill in ~/.agents/skills can be removed with no copy kept too (Eternalfate__ on X) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v0.1.4585 (6a0afc38a) put a tick, "Keep a copy in magpie's backups", on the sheets that remove skills. The same reader, on v0.1.4594, saw it on no sheet. It shows only when a folder of magpie's own would be deleted, and most users have no such skill: - a skill brought in from the agents (most of a library) has Put back, not Remove: it goes back to them, nothing kept or deleted; - one linked from ~/.agents/skills (npx skills, Codex) only loses the link; - an agent's own skill with its folder in ~/.agents/skills, where most skills are, always went to the backups, and its sheet had no tick (inSharedDir). That sheet says "Its entry in ~/.agents/skills goes to the backups too", so the reader saw backups promised and no way out. The TUI's D said it deleted such a folder and kept it all the same. The entry leaves ~/.agents/skills either way (setAside moves it out), so the other tools reading that folder lose it either way; kept, it only sat in the backups, which are never pruned when they hold skills. Now it is deleted like any other folder when the tick is off, and its sheet (one skill, and the picked ones) has the tick, saying "Its entry in … is deleted too" when unticked. Never deleted, as before: a link's target. An entry in ~/.agents/skills that is a link only goes, and its sheet says "Its link in … goes too" (it said the entry went to the backups). Remove all / the picked library skills counted one brought in from the agents as a folder moved to the backups (or, linked, as only unlinked), and showed the tick for it. It goes back to them (putBack): it is said so, "{n} go back to the agents they were brought in from, as they were", and counts for neither, nor for the tick. Four new strings in zh, zh-TW, ja and de. docs/subsystems/library.md says what changed. Run (mote, this tree at base 5754fea43, origin/main when fetched): - go test ./internal/library -run 'WithoutBackup|Found|Shared': ok. - broken by hand: skills.go at HEAD (the inSharedDir guard back) with the new test: TestRemoveFoundSkillWithoutBackup red, the shared entry in the backups. skill-remove-nobackup.test.cjs at an origin/main 5754fea43 copy: all 20 subtests red in chromium and webkit (Remove all said "1 folders are moved … 2 linked from folders of your own are only unlinked" for one brought in). - GUI, chromium and webkit: skill-remove-nobackup (en, zh, zh-TW, ja, de at 980 and 440px: shared entry ticked and unticked, its post, a shared link with no tick, Remove all with one brought in, with and without a folder of magpie's, nothing sideways), found-skill-pick- remove, library-bar-more, library-found-hooks, library-hooks, library-pick-remove, library-servers-bulk, remove-all-skills, remove-found-server, remove-found-skill, shared-skills, skill-put-back, i18n-en-no-cjk, i18n-keys: 176 pass, 12 red. Red: found-skill-pick- remove at 420px (#5013) and library-bar-more in chromium (#7326), both red at the origin/main 5754fea43 copy too. - go test ./internal/library ./internal/tui ./internal/cli ./internal/gui -timeout 45m: library, tui, cli ok. gui: TestBuiltinsTranslated (#7257) and TestSettingsSaveKeepsWhatItDoesNotSend (#7240) red, both open and about other pages. GOOS=linux go vet -tags nogui and GOOS=windows go vet of library and gui: ok. - gofmt -l internal/: nothing. Not run: the full go test ./... and the whole GUI suite. Not tried in the real app, nor on Windows or Linux; deleting goes through the same os.RemoveAll as a folder in an agent's own skills folder. Not changed: Put back still has no Remove; a skill brought in goes back to the agents, where it can be removed (now with the tick). --- docs/subsystems/library.md | 2 +- internal/gui/assets/plugins/library/client.js | 35 ++++++---- internal/gui/assets/plugins/library/i18n.js | 16 +++++ .../gui/tests/skill-remove-nobackup.test.cjs | 67 +++++++++++++++++-- internal/library/skill_no_backup_test.go | 37 +++++++--- internal/library/skills.go | 16 ++--- 6 files changed, 132 insertions(+), 41 deletions(-) diff --git a/docs/subsystems/library.md b/docs/subsystems/library.md index ff8faf010..69ba82134 100644 --- a/docs/subsystems/library.md +++ b/docs/subsystems/library.md @@ -101,7 +101,7 @@ Pi's extensions and packages. - The CLI sets a server's headers, env and startup timeout (#6111, Abandon332 on X): `magpie library mcp add header=K=V env=K=V timeout=SECS agents=…`, `mcp set header=K=V|header-=K|env=K=V|env-=K|timeout=SECS` (the rest of the server kept) and `mcp show ` (JSON). `SplitServerWords` takes those words out of the line before `--`; words after `--` are the program's own, and a word that looks like a setting magpie doesn't know (`headers=`, `envs=`) is refused rather than passed on as an argument. `header=` on a command or `env=` on a URL is an error. (`TestSplitServerWords`, `TestLibraryMCPHeadersEnvTimeout`) [`mcp_options.go`](../../internal/library/mcp_options.go) - A skill brought in from a link into a folder an app keeps per version (ego lite's framework `Versions/`, #2635) is linked through the app's own steady link, or through `Versions/Current` when Current is that version (`linkVia`, `currentVersion`; `TestImportedSkillFollowsAppUpdate`, `TestImportedSkillThroughVersionsCurrent`). One brought in before that links straight to `Versions/`, which the app's update deletes (tjhhhh on Discord). Every read of the page (looking at each link once, `readParts`, and starting that over when a link was mended) and the first step of every sync mend such links (`followMovedSkills`): a library skill that is a link, whose target isn't there, and whose first missing part is named like a version (`versionName`) is linked to the same place under that folder's `Current`, `current` or `latest` link, else under the highest version beside it that has a `SKILL.md` there (`movedVersion`, `versionLess`); one whose target is in `Versions/` while the bundle's `Versions/Current` is a link to another version with the same skill is linked through Current (`laterCurrent`). `Source.Dir` follows. Only the library's link is replaced (`os.Remove` of the link, then `dirLink`; put back as it was when the new link can't be made). A folder of the library's own, a link to a folder the user deleted that isn't a version (shown missing as before) and the app's old version folder are left as they are (`TestOldImportFollowsDeletedVersion`, `TestOldImportFollowsVersionsCurrent`, `TestOldImportFollowsHighestVersion`, `TestMovedSkillsLeaveTheRest`). The app's own steady link can be left naming the version its update deleted (ego's `active_version_dir` still at 0.6.2.5 with only 0.6.2.7 on disk, tjhhhh again): the app's links are its own and never written to. When the library's link dangles and its target isn't in a version folder, the links on the way are followed as far as they are there (`linkedEnd`) and `movedVersion` is asked of where they end; the library links to the folder found, and keeps the steady link as `Source.Via`. Once the steady link leads to a `SKILL.md` again, the library links through it once more and `Via` is cleared (`TestSteadyLinkLeftOnDeletedVersion`, `TestSteadyLinkLeftOnDeletedVersionNoOther`). [`skill_moved.go`](../../internal/library/skill_moved.go) - A skill brought in from the agents ("In your agents", `ImportSkill`) goes back to them when it leaves the library (BeiWeiji on X). The import records where it was (`Skill.Home`, this computer's own, kept by `Put` for the same source and never carried by a sync): the folder moved in (`Home.Dir`, which `handOver` points at its shared `~/.agents/skills` place) and each agent's entry, a link with its own text or a copy (`HomeEntry`). `RemoveSkill` (and `RemoveSkills`) puts it back (`putBack`): the library's folder is moved back to `Home.Dir` with what was changed there, or the library's link is taken away, and each agent's link is made again as it was and each copy copied back; it is then in "In your agents" again and nothing goes to the backups. An agent entry the user replaced since is left as it is, and when `Home.Dir` is taken the skill is removed as any other, its folder to the backups. The view's `back` lists the agents (`canPutBack`), and the page shows Put back in their place of the trash, with a sheet saying where it goes (`confirmPutBack`). A skill brought in before `Home` was kept has none: removed, its folder goes to the backups as before, where it can be taken back by hand (`TestRemovedImportGoesBackToTheAgents`, `TestRemovedLinkedImportGoesBack`, `TestPutBackLeavesTheUsersNewFolder`, `skill-put-back.test.cjs`). [`skills.go`](../../internal/library/skills.go) -- A skill can be removed with no copy kept (@Eternalfate__ on X: removing one always left its folder in `~/.magpie/backups`, and `pruneBackups` never prunes a backup holding skills, `holdsSkills`, so they piled up). `RemoveSkillsHow`, `RemoveGoneSkillsHow` and `RemoveFoundSkillsHow` take `keep`; `RemoveSkill(s)`, `RemoveGoneSkills` and `RemoveFoundSkill(s)` are those with `keep` true, as before. Without it, `removeSkill` deletes the library's own folder (`os.RemoveAll`, which takes a link inside it away without following it) and `removeFound` an agent's own folder or copy. What was never deleted still isn't: a link (a skill linked from a folder of the user's, `~/.agents/skills` among them) only loses the link, a skill brought in from the agents still goes back to them (`putBack`), and an agent's own skill with its folder in `~/.agents/skills` (`inSharedDir`, which other tools read too) still goes to the backups. The page's sheets (one skill's trash, an agent's own skill's, Remove all, the picked ones, the ones gone from their source) carry one tick, Keep a copy in magpie's backups, shown only when some folder would be deleted, ticked unless this browser unticked it last (`keepLines`, `magpie.libSkillBackup`); unticked, what the sheet says changes and the change posts `noBackup: true` (`skills/remove`, `remove-all`, `remove-gone`, `remove-found`, `remove-found-some`). CLI: `magpie library skill rm --no-backup`, and `--no-backup` on `rm --all` and `rm --gone`. TUI: d, then D in place of the second d, on a row whose folder would be kept. Backups made before stay in `~/.magpie/backups/