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/