library: a skill in ~/.agents/skills can be removed with no copy kept too (Eternalfate__ on X)
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 base5754fea43, 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/main5754fea43copy: 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/main5754fea43copy 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).
This commit is contained in:
@@ -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 <name> <url|command args…> header=K=V env=K=V timeout=SECS agents=…`, `mcp set <name> header=K=V|header-=K|env=K=V|env-=K|timeout=SECS` (the rest of the server kept) and `mcp show <name>` (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/<v>`, #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/<old>`, 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/<v>` 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 <name> --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/<time>/skills/` until the user deletes them (the Library's Backups opens the folder) (`TestRemoveSkillWithoutBackup`, `TestRemoveFoundSkillWithoutBackup`, `TestLibrarySkillRmNoBackup`, `TestLibraryDeleteWithoutBackup`, `skill-remove-nobackup.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 a link in `~/.agents/skills` only goes too. An agent's own skill with its folder in `~/.agents/skills` is deleted like any other folder (the same reader on v0.1.4594 saw no tick on any sheet: most skills are there, and the first change kept them in the backups regardless; the entry leaves that folder either way, so other tools lose it either way). 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 (Remove all counts one brought in from the agents as going back to them, neither kept nor 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 <name> --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/<time>/skills/` until the user deletes them (the Library's Backups opens the folder) (`TestRemoveSkillWithoutBackup`, `TestRemoveFoundSkillWithoutBackup`, `TestLibrarySkillRmNoBackup`, `TestLibraryDeleteWithoutBackup`, `skill-remove-nobackup.test.cjs`). [`skills.go`](../../internal/library/skills.go)
|
||||
- A skill kept in `~/.agents/skills` is handed over to the library on the user's click (`HandOverSkills`, `POST /api/library/skills/hand-over` with `names`; the row's Manage in magpie in its source line, Manage {n} in magpie in the skills' heading, each asking first; `magpie library skill hand-over <name…>|--all`; tnt1223 on Discord). "Kept there" is `sharedEntry`: the entry in that folder that is the library skill's own folder, by its name or, for a library link into it under another folder's name, by that folder's (`SkillView.Shared`; `SharedElsewhere` when the entry only links to a folder kept elsewhere). Every reader of `sharedHas`/`sharedEntry` follows: `Always`, `syncSkills`' `inShared`, and the shared folder's own target (Goose, Kimi Code, Cindy), which is given no second link beside such an entry (`TestSharedUnderAnotherName`). Handed over, a folder in `~/.agents/skills` moves into the library's skills folder (`moveIn`: renamed, or copied, read back the same with `sameTree` and only then set aside with the backups; a failure leaves it where it was and the library's link as it was, `TestHandOverFailureKeepsOriginal`), and an entry that only links elsewhere is taken away while the library links past it to that folder. The user's own links to it in agents' folders, which would point at nothing, go too. Every agent here that read it (`readsSharedHere`, and the agent of each such link) is ticked, so each keeps it, now from the library, till it is unticked or turned off here. A skill found there and not in the library yet is brought in first. One that can't be handed over is left as it was, in `Result.Unmoved`, and the others are handed over all the same. `HandBackSkill` (`magpie library skill hand-back <name>`, CLI only; the sheet names it) moves the folder back and links the library to it, its ticks as they are. Not covered: another computer whose skill is still in its own `~/.agents/skills` gets the library's copy from a sync beside its own, until it is handed over there too; and the skills CLI's lock (`npx skills update`) may put the entry back (`TestHandOverSharedFolder`, `TestHandOverSharedLink`, `TestHandOverFound`, `TestHandOverWithGoose`, `TestLibrarySkillHandOver`, `skill-handover.test.cjs`). [`skill_handover.go`](../../internal/library/skill_handover.go) It also turns off `SharedSkills` (Put skills in, `skills_shared.go`): with every skill kept in `~/.agents/skills` every reader has every skill and the sync would link the handed-over one back there, which can't go with choosing agents; the sync then takes out magpie's own links there and never the user's entries (`TestHandOverWithSharedSetting`; the sheet says so when the setting is on; ConatusMoon2222 on X). The skill router lists nothing for an agent while that setting is on, which the Put skills in note says when both are on.
|
||||
- The agents that read `~/.agents/skills` themselves are `readsShared` (Codex, Gemini CLI, OpenCode, DevEco Code, Crush, dsh, Command Code, Devin, Droid, Cline, Grok Build, Grok App, fx, Alma, Kimi Code, ZCode and OmO) and, from the version that started to, `Target.SharedToo`: Pi from 0.54.0 (its CHANGELOG; `userAgentsSkillsDir` in package-manager.js) and omp from 11.0.0 (`discovery/agents.ts`; 10.6.2 doesn't). OmO runs on senpi, whose oldest version on npm (0.74.0) already reads it. A Pi or omp whose version isn't known is taken as older, as before. Every reader goes through `Target.readsSharedDir`: `Always` (the row's lock), `syncSkills`' `inShared` (no second link in its own folder) and `readsSharedHere` for a handover (usrname1833 on Discord; `TestPiReadsSharedSkillsFromItsVersion`). A user's own skill in `~/.agents/skills` by the library skill's name (another installer's, such as the skills CLI's, or copied by hand: not magpie's link or marked copy, not the library's own folder) counts too, under that folder name or another whose `SKILL.md` gives the name (`readSharedOwn`, `sharedOwn.rival`), since Pi 1.4.0 knows a skill by that name and drops one read twice only when both paths are one file (`realPathSet` in dist/core/skills.js): it warned of a collision for the two trees. Such a reader gets nothing in its own folder, and magpie's link or marked copy there, an older magpie's too, goes on the next sync. When it holds the library's very files (`sameTree`) the reader has the library's already. When it holds other files the reader has a skill of its own by that name, an `Own` problem settled as one in its own folder: Keep {agent}'s unticks it, Use the library's sets the shared entry aside with the backups (every other reader of the folder loses it too) and gives the library's (math_milian on Discord; `TestSharedCopyNotGivenTwice`, `TestSharedCopyOtherFolderName`, `TestSharedOwnSettled`). The user's entry is otherwise never touched. Not covered: a library skill that is a link to the agent's own folder (brought in from there) beside such a copy keeps both, since that folder is the library's; OpenCode reads Claude Code's folder and the shared one into one map by name, so it finds Claude Code's link and the user's copy as one skill; and a Pi or omp of unknown version is given its own as before.
|
||||
- Put skills in (`Library.SharedSkills`; `SetSkillsWhere`, `POST /api/library/skills/where` with `how` `agents` or `shared`; `magpie library skill where agents|shared`; the Skills tab's bar under How, `skillWhereBar` in plugins/library/client.js; usrname1833 on Discord). Off, the default and what a library.json from before reads as, each agent gets the skills ticked for it in its own folder. On, every library skill on here (`keepsShared`: not `OffHere`, its folder there) also gets magpie's link in `~/.agents/skills` (`syncShared`, run after `sweepShared`), so every agent and tool that reads that folder has it, ticked or not, and is in its `Always`. The files stay in the library, so updates, checks, edit tracking and Off here work as before, and nothing is moved when it is turned on: existing skills just get links. An entry of the user's own by a skill's name is left alone, silently, and the agents ticked for the library's skill still get it in their own folders, unless they read the folder themselves (`sharedOwn.rival`, above). A sync leaves an existing link as it is. A skill given to the folder's own agent (Kimi Code, Goose, Cindy) is that agent's sync's. Turned off, `sweepShared` takes out magpie's links there and nothing else, and each agent's own links come back. It is this computer's: `Collect` never carries it (`TestSkillsWhereShared`, `TestSkillsWhereSharedWithKimi`, `skill-where.test.cjs`). Not covered: on Windows without the right to make links the entry is a marked copy; a stale one is set aside and copied again, but `takeEdits` doesn't take edits made in that copy into the library, so they go to the backups when the setting is turned off or the skill changes (#4958). [`skills_shared.go`](../../internal/library/skills_shared.go)
|
||||
|
||||
@@ -8172,10 +8172,14 @@ magpie.plugin("library", (ctx) => {
|
||||
// every skill, or those picked (#1852)
|
||||
function confirmRemoveEverySkill(some) {
|
||||
const skills = (some || lib.skills).slice(), names = skills.map((s) => s.name), n = names.length;
|
||||
const linked = skills.filter((s) => s.kind === "folder").length, kept = n - linked;
|
||||
// brought in from the agents: they go back to them (putBack), nothing
|
||||
// of theirs kept or deleted, so they count for neither, nor the tick
|
||||
const back = skills.filter((s) => s.back?.length).length;
|
||||
const linked = skills.filter((s) => s.kind === "folder" && !s.back?.length).length, kept = n - linked - back;
|
||||
const projects = (lib.projects || []).filter((p) => names.some((x) => p.skills?.[x]?.length)).length;
|
||||
const where = (keep) => {
|
||||
const w = [];
|
||||
if (back) w.push(t("{n} go back to the agents they were brought in from, as they were.", { n: back }));
|
||||
if (kept) w.push(keep ? t("{n} folders are moved to magpie's backups (Backups, at the top of the Library), not deleted.", { n: kept })
|
||||
: t("{n} folders are deleted, with no copy kept.", { n: kept }));
|
||||
if (linked) w.push(t("{n} linked from folders of your own are only unlinked: those folders stay where they are.", { n: linked }));
|
||||
@@ -9102,25 +9106,25 @@ magpie.plugin("library", (ctx) => {
|
||||
const head = el("div", "ehead");
|
||||
head.append(glyph(GLYPH.trash), el("b", "", n === 1 ? t("Remove {name}?", { name: names[0] }) : t("Remove {n} skills?", { n })));
|
||||
ed.append(head);
|
||||
// own: folders deleted when no copy is kept; one with an entry in the
|
||||
// shared folder (other tools' too) goes to the backups either way
|
||||
const linked = some.filter((f) => f.link).length, kept = n - linked, own = some.filter((f) => !f.link && !f.shared).length;
|
||||
// kept: folders moved to the backups, or deleted when no copy is kept,
|
||||
// an entry in ~/.agents/skills too: it leaves that folder either way
|
||||
// (@Eternalfate__ on X: most skills are there, and had no tick)
|
||||
const linked = some.filter((f) => f.link).length, kept = n - linked;
|
||||
const keep = keepLines(ed, (keep) => n === 1 ? foundSaid(some[0], keep) : (() => {
|
||||
const lines = [];
|
||||
const agents = [...new Set(some.flatMap((f) => [...f.agents, ...(f.copies || [])]))].map(nameOf).filter(Boolean);
|
||||
if (agents.length) lines.push(t("They are taken out of {agents}.", { agents: agents.join(", ") }));
|
||||
const shared = some.filter((f) => f.shared).length;
|
||||
const shared = some.filter((f) => f.shared && !f.link).length;
|
||||
const where = [];
|
||||
if (keep ? kept : own) where.push(keep ? t("{n} folders are moved to magpie's backups (Backups, at the top of the Library), not deleted.", { n: kept })
|
||||
: t("{n} folders are deleted, with no copy kept.", { n: own }));
|
||||
if (kept) where.push(keep ? t("{n} folders are moved to magpie's backups (Backups, at the top of the Library), not deleted.", { n: kept })
|
||||
: t("{n} folders are deleted, with no copy kept.", { n: kept }));
|
||||
if (linked) where.push(t("{n} linked from folders of your own are only unlinked: those folders stay where they are.", { n: linked }));
|
||||
lines.push(where.join(" "));
|
||||
// magpie never deletes in the shared folder, other tools' too: an
|
||||
// entry there goes to the backups either way (removeFound)
|
||||
if (shared) lines.push(t("{n} have an entry in the shared skills folder, which goes to the backups too, so no agent reads them from there.", { n: shared }));
|
||||
if (shared) lines.push(keep ? t("{n} have an entry in the shared skills folder, which goes to the backups too, so no agent reads them from there.", { n: shared })
|
||||
: t("{n} have an entry in the shared skills folder, which is deleted too, so no agent reads them from there.", { n: shared }));
|
||||
if (some.some((f) => f.others?.length)) lines.push(t("Another agent's own skill by one of these names stays."));
|
||||
return lines;
|
||||
})(), own > 0);
|
||||
})(), kept > 0);
|
||||
const bar = el("div", "bar");
|
||||
const go = button(n === 1 ? t("Remove") : t("Remove {n}", { n }), "primary danger-fill", async () => { go.disabled = true; if (await removeFoundSome(names, !keep())) closeLibModal(true); else go.disabled = false; });
|
||||
bar.append(el("span", "grow"), button(t("Cancel"), "", closeLibModal), go);
|
||||
@@ -9165,8 +9169,11 @@ magpie.plugin("library", (ctx) => {
|
||||
: f.link ? t("It is taken out of {agents}. The folder it was linked from stays where it is.", { agents: agents.join(", ") })
|
||||
: keep ? t("It is taken out of {agents}, and its folder is moved to magpie's backups.", { agents: agents.join(", ") })
|
||||
: t("It is taken out of {agents}, and its folder is deleted, with no copy kept.", { agents: agents.join(", ") }),
|
||||
// never deleted, as the shared folder is other tools' too (removeFound)
|
||||
f.shared && t("Its entry in {path} goes to the backups too, so no agent reads it from there.", { path: f.shared }),
|
||||
// its entry in ~/.agents/skills leaves it either way, deleted with
|
||||
// its folder when no copy is kept; a link there only goes
|
||||
f.shared && (f.link ? t("Its link in {path} goes too, so no agent reads it from there.", { path: f.shared })
|
||||
: keep ? t("Its entry in {path} goes to the backups too, so no agent reads it from there.", { path: f.shared })
|
||||
: t("Its entry in {path} is deleted too, so no agent reads it from there.", { path: f.shared })),
|
||||
f.others?.length && t("{agents} has another skill by this name; that one stays.", { agents: f.others.map(nameOf).join(", ") }),
|
||||
];
|
||||
}
|
||||
@@ -9176,7 +9183,7 @@ magpie.plugin("library", (ctx) => {
|
||||
const head = el("div", "ehead");
|
||||
head.append(glyph(GLYPH.trash), el("b", "", t("Remove {name}?", { name: f.name })));
|
||||
ed.append(head);
|
||||
const keep = keepLines(ed, (keep) => foundSaid(f, keep), !f.link && !f.shared);
|
||||
const keep = keepLines(ed, (keep) => foundSaid(f, keep), !f.link);
|
||||
const bar = el("div", "bar");
|
||||
const go = button(t("Remove"), "primary danger-fill", async () => { if (await change("skills/remove-found", keep() ? { name: f.name } : { name: f.name, noBackup: true }, t("{name} removed", { name: f.name }))) closeLibModal(true); });
|
||||
bar.append(el("span", "grow"), button(t("Cancel"), "", closeLibModal), go);
|
||||
|
||||
@@ -985,6 +985,10 @@ magpie.strings({
|
||||
"It is taken out of every agent it was given to, and its folder is deleted, with no copy kept.": "将从所有已启用的 Agent 中移除,文件夹直接删除,不保留备份。",
|
||||
"Its folder is deleted, with no copy kept.": "文件夹将直接删除,不保留备份。",
|
||||
"It is taken out of {agents}, and its folder is deleted, with no copy kept.": "将从 {agents} 中移除,文件夹直接删除,不保留备份。",
|
||||
"Its entry in {path} is deleted too, so no agent reads it from there.": "它在 {path} 中的条目也会被删除,不会再有 Agent 从那里读取。",
|
||||
"{n} have an entry in the shared skills folder, which is deleted too, so no agent reads them from there.": "其中 {n} 个在共享技能文件夹中的条目也会被删除,不会再有 Agent 从那里读取。",
|
||||
"Its link in {path} goes too, so no agent reads it from there.": "它在 {path} 中的链接也会移除,不会再有 Agent 从那里读取。",
|
||||
"{n} go back to the agents they were brought in from, as they were.": "{n} 个按导入前的样子放回原来的 Agent。",
|
||||
"It is taken out of the MCP settings of {agents}. Each file is copied to magpie's backups before it changes.": "将从 {agents} 的 MCP 配置中移除。每个文件改动前都会先复制到 magpie 的备份。",
|
||||
"{agents} has another server by this name; that one stays.": "{agents} 中有另一个同名服务器,那个保持不动。",
|
||||
"{agents} has another skill by this name; that one stays.": "{agents} 中有另一个同名 Skill,那个保持不动。",
|
||||
@@ -2159,6 +2163,10 @@ magpie.strings({
|
||||
"It is taken out of every agent it was given to, and its folder is deleted, with no copy kept.": "將從所有已啟用的 Agent 中移除,資料夾直接刪除,不保留備份。",
|
||||
"Its folder is deleted, with no copy kept.": "資料夾將直接刪除,不保留備份。",
|
||||
"It is taken out of {agents}, and its folder is deleted, with no copy kept.": "將從 {agents} 中移除,資料夾直接刪除,不保留備份。",
|
||||
"Its entry in {path} is deleted too, so no agent reads it from there.": "它在 {path} 中的項目也會被刪除,不會再有 Agent 從那裡讀取。",
|
||||
"{n} have an entry in the shared skills folder, which is deleted too, so no agent reads them from there.": "其中 {n} 個在共用技能資料夾中的項目也會被刪除,不會再有 Agent 從那裡讀取。",
|
||||
"Its link in {path} goes too, so no agent reads it from there.": "它在 {path} 中的連結也會移除,不會再有 Agent 從那裡讀取。",
|
||||
"{n} go back to the agents they were brought in from, as they were.": "{n} 個依匯入前的樣子放回原來的 Agent。",
|
||||
"It is taken out of the MCP settings of {agents}. Each file is copied to magpie's backups before it changes.": "將從 {agents} 的 MCP 設定中移除。每個檔案改動前都會先複製到 magpie 的備份。",
|
||||
"{agents} has another server by this name; that one stays.": "{agents} 中有另一個同名伺服器,那個保持不動。",
|
||||
"{agents} has another skill by this name; that one stays.": "{agents} 中有另一個同名 Skill,那個保持不動。",
|
||||
@@ -3332,6 +3340,10 @@ magpie.strings({
|
||||
"It is taken out of every agent it was given to, and its folder is deleted, with no copy kept.": "渡していたすべてのエージェントから外され、フォルダは削除されます。コピーは残りません。",
|
||||
"Its folder is deleted, with no copy kept.": "フォルダは削除され、コピーは残りません。",
|
||||
"It is taken out of {agents}, and its folder is deleted, with no copy kept.": "{agents} から外され、フォルダは削除されます。コピーは残りません。",
|
||||
"Its entry in {path} is deleted too, so no agent reads it from there.": "{path} にあるエントリも削除され、どのエージェントもそこから読まなくなります。",
|
||||
"{n} have an entry in the shared skills folder, which is deleted too, so no agent reads them from there.": "うち {n} 個は共有スキルフォルダのエントリも削除され、どのエージェントもそこから読まなくなります。",
|
||||
"Its link in {path} goes too, so no agent reads it from there.": "{path} にあるリンクも外され、どのエージェントもそこから読まなくなります。",
|
||||
"{n} go back to the agents they were brought in from, as they were.": "{n} 個は取り込む前の状態で元のエージェントに戻ります。",
|
||||
"It is taken out of the MCP settings of {agents}. Each file is copied to magpie's backups before it changes.": "{agents} の MCP 設定から外されます。各ファイルは変更前に magpie のバックアップにコピーされます。",
|
||||
"{agents} has another server by this name; that one stays.": "{agents} には同じ名前の別のサーバーがあり、そちらはそのまま残ります。",
|
||||
"{agents} has another skill by this name; that one stays.": "{agents} には同じ名前の別のスキルがあり、そちらはそのまま残ります。",
|
||||
@@ -4506,6 +4518,10 @@ magpie.strings({
|
||||
"It is taken out of every agent it was given to, and its folder is deleted, with no copy kept.": "Er wird aus jedem Agenten entfernt, dem er gegeben wurde, und sein Ordner wird gelöscht, ohne eine Kopie zu behalten.",
|
||||
"Its folder is deleted, with no copy kept.": "Sein Ordner wird gelöscht, ohne eine Kopie zu behalten.",
|
||||
"It is taken out of {agents}, and its folder is deleted, with no copy kept.": "Er wird aus {agents} entfernt, und sein Ordner wird gelöscht, ohne eine Kopie zu behalten.",
|
||||
"Its entry in {path} is deleted too, so no agent reads it from there.": "Sein Eintrag in {path} wird ebenfalls gelöscht, sodass kein Agent ihn mehr von dort liest.",
|
||||
"{n} have an entry in the shared skills folder, which is deleted too, so no agent reads them from there.": "{n} haben einen Eintrag im gemeinsamen Skills-Ordner, der ebenfalls gelöscht wird, sodass kein Agent sie mehr von dort liest.",
|
||||
"Its link in {path} goes too, so no agent reads it from there.": "Sein Link in {path} wird ebenfalls entfernt, sodass kein Agent ihn mehr von dort liest.",
|
||||
"{n} go back to the agents they were brought in from, as they were.": "{n} kommen so zu den Agents zurück, aus denen sie übernommen wurden, wie sie waren.",
|
||||
"It is taken out of the MCP settings of {agents}. Each file is copied to magpie's backups before it changes.": "Er wird aus den MCP-Einstellungen von {agents} entfernt. Jede Datei wird vorher in die Backups von magpie kopiert.",
|
||||
"{agents} has another server by this name; that one stays.": "{agents} hat einen anderen Server mit diesem Namen; dieser bleibt.",
|
||||
"{agents} has another skill by this name; that one stays.": "{agents} hat einen anderen Skill mit diesem Namen; dieser bleibt.",
|
||||
|
||||
@@ -4,10 +4,15 @@
|
||||
// copy in magpie's backups", ticked unless the reader unticked it last time
|
||||
// (remembered in this browser). Unticked, what the sheet says changes to
|
||||
// the folder being deleted, and Remove posts noBackup: true; ticked, it
|
||||
// posts what it did before. A skill linked from a folder of the user's,
|
||||
// and an agent's own skill with an entry in ~/.agents/skills, have no tick:
|
||||
// nothing of theirs is deleted either way. Chromium and WebKit, 980px and
|
||||
// 440px, in en, zh, zh-TW, ja and de; nothing runs off the page sideways.
|
||||
// posts what it did before. A skill linked from a folder of the user's
|
||||
// has no tick: only the link goes. An agent's own skill with its folder in
|
||||
// ~/.agents/skills, where most users' skills are, has the tick (the same
|
||||
// reader saw none on any sheet, v0.1.4594): it leaves that folder either
|
||||
// way, deleted or kept in the backups as the tick says; one there that is
|
||||
// a link has none. Remove all counts a skill brought in from the agents as
|
||||
// going back to them, not as a folder kept or deleted, and with only such
|
||||
// and linked ones has no tick. Chromium and WebKit, 980px and 440px, in
|
||||
// en, zh, zh-TW, ja and de; nothing runs off the page sideways.
|
||||
// No backend: the API is faked here.
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs/promises");
|
||||
@@ -87,10 +92,12 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
skills: [
|
||||
{ name: "notes", kind: "", description: "Notes", agents: ["claude"] },
|
||||
{ name: "lint", kind: "folder", description: "Lint", source: `${HOME}/.agents/skills/lint`, agents: ["claude"] },
|
||||
{ name: "brought", kind: "folder", description: "Brought in", source: `${HOME}/.agents/skills/brought`, agents: ["codex"], back: ["codex"] },
|
||||
],
|
||||
found: [
|
||||
{ name: "old", description: "Not wanted", agents: ["claude"] },
|
||||
{ name: "grilling", description: "Grill a plan", agents: ["goose"], shared: `${HOME}/.agents/skills/grilling` },
|
||||
{ name: "web", description: "Web", agents: ["claude"], link: `${HOME}/src/web`, shared: `${HOME}/.agents/skills/web` },
|
||||
],
|
||||
};
|
||||
const posts = [], errors = [];
|
||||
@@ -118,6 +125,22 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await sheet.locator(".bar button:not(.primary)").click();
|
||||
await sheet.waitFor({ state: "detached" });
|
||||
};
|
||||
const removeAll = async () => {
|
||||
await page.locator("#view-library .lib-skillshead .lib-barmore").click();
|
||||
await page.locator(".row-menu .rm-item.lib-everyrm").click();
|
||||
await sheet.waitFor();
|
||||
};
|
||||
|
||||
// Remove all: the one brought in goes back, only notes' folder is
|
||||
// kept, so the tick is for that one
|
||||
await removeAll();
|
||||
assert.equal(await box.count(), 1, "no tick with a folder of magpie's");
|
||||
assert.equal((await lines()).at(-1), [
|
||||
w("{n} go back to the agents they were brought in from, as they were.", { n: 1 }),
|
||||
w("{n} folders are moved to magpie's backups (Backups, at the top of the Library), not deleted.", { n: 1 }),
|
||||
w("{n} linked from folders of your own are only unlinked: those folders stay where they are.", { n: 1 }),
|
||||
].join(" "));
|
||||
await cancel();
|
||||
|
||||
// the library's own folder: ticked at first, as it always was
|
||||
await ask("notes");
|
||||
@@ -140,6 +163,15 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(posts.shift(), { what: "skills/remove", body: { name: "notes", noBackup: true } });
|
||||
await row("notes").waitFor({ state: "detached" });
|
||||
|
||||
// Remove all with only a linked one and one brought in: no tick
|
||||
await removeAll();
|
||||
assert.equal(await box.count(), 0, "a tick with nothing to keep or delete");
|
||||
assert.equal((await lines()).at(-1), [
|
||||
w("{n} go back to the agents they were brought in from, as they were.", { n: 1 }),
|
||||
w("{n} linked from folders of your own are only unlinked: those folders stay where they are.", { n: 1 }),
|
||||
].join(" "));
|
||||
await cancel();
|
||||
|
||||
// linked from a folder of the user's: no tick, its folder stays
|
||||
await ask("lint");
|
||||
assert.equal(await box.count(), 0, "a linked skill has the tick");
|
||||
@@ -156,9 +188,32 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await sheet.waitFor({ state: "detached" });
|
||||
assert.deepEqual(posts.shift(), { what: "skills/remove-found", body: { name: "old" } });
|
||||
|
||||
// one in ~/.agents/skills: never deleted, so no tick
|
||||
// one in ~/.agents/skills, as most are: the same tick
|
||||
const at = `${HOME}/.agents/skills/grilling`;
|
||||
await ask("grilling");
|
||||
assert.equal(await box.count(), 0, "a shared skill has the tick");
|
||||
assert.equal(await box.count(), 1, "a skill in ~/.agents/skills has no tick");
|
||||
assert.equal(await box.isChecked(), true);
|
||||
assert.deepEqual(await lines(), [
|
||||
w("It is taken out of {agents}, and its folder is moved to magpie's backups.", { agents: "Goose" }),
|
||||
w("Its entry in {path} goes to the backups too, so no agent reads it from there.", { path: at }),
|
||||
]);
|
||||
await sheet.locator("label.lib-keepbox").click();
|
||||
assert.deepEqual(await lines(), [
|
||||
w("It is taken out of {agents}, and its folder is deleted, with no copy kept.", { agents: "Goose" }),
|
||||
w("Its entry in {path} is deleted too, so no agent reads it from there.", { path: at }),
|
||||
]);
|
||||
assert.deepEqual(await sideways(page), [], "sideways with the tick");
|
||||
await sheet.locator(".bar button.primary").click();
|
||||
await sheet.waitFor({ state: "detached" });
|
||||
assert.deepEqual(posts.shift(), { what: "skills/remove-found", body: { name: "grilling", noBackup: true } });
|
||||
|
||||
// a link there to a folder of the user's: only the link goes, no tick
|
||||
await ask("web");
|
||||
assert.equal(await box.count(), 0, "a linked skill has the tick");
|
||||
assert.deepEqual(await lines(), [
|
||||
w("It is taken out of {agents}. The folder it was linked from stays where it is.", { agents: "Claude Code" }),
|
||||
w("Its link in {path} goes too, so no agent reads it from there.", { path: `${HOME}/.agents/skills/web` }),
|
||||
]);
|
||||
await cancel();
|
||||
assert.deepEqual(posts, []);
|
||||
assert.deepEqual(errors, []);
|
||||
|
||||
@@ -45,9 +45,10 @@ func TestRemoveSkillWithoutBackup(t *testing.T) {
|
||||
}
|
||||
|
||||
// The same for a skill an agent has of its own: removed without a backup
|
||||
// its folders are deleted; a link only unlinked, its folder kept; and an
|
||||
// entry in ~/.agents/skills, which other tools read, still goes to the
|
||||
// backups, never deleted.
|
||||
// its folders are deleted, its entry in ~/.agents/skills too (it leaves
|
||||
// that folder either way: kept, it only sat in the backups, and most
|
||||
// users' skills are there, @Eternalfate__ on X); a link only unlinked,
|
||||
// its folder kept, a link in ~/.agents/skills too.
|
||||
func TestRemoveFoundSkillWithoutBackup(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
claude := filepath.Join(h, ".claude/skills")
|
||||
@@ -63,20 +64,36 @@ func TestRemoveFoundSkillWithoutBackup(t *testing.T) {
|
||||
if err := os.Symlink(dev, filepath.Join(claude, "dev")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// an entry in ~/.agents/skills that is a link to a folder of the
|
||||
// user's: only the link goes
|
||||
work := filepath.Join(h, "src/work")
|
||||
skill(t, work, "work", "Mine, elsewhere")
|
||||
if err := os.Symlink(work, filepath.Join(h, ".agents/skills/work")); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ok(t)(RemoveFoundSkillsHow([]string{"notes", "pdf", "dev"}, false))
|
||||
for _, p := range []string{filepath.Join(claude, "notes"), filepath.Join(h, ".codex/skills/notes"), filepath.Join(claude, "pdf"), filepath.Join(claude, "dev")} {
|
||||
ok(t)(RemoveFoundSkillsHow([]string{"notes", "pdf", "dev", "work"}, false))
|
||||
for _, p := range []string{filepath.Join(claude, "notes"), filepath.Join(h, ".codex/skills/notes"), filepath.Join(claude, "pdf"), filepath.Join(claude, "dev"),
|
||||
shared, filepath.Join(h, ".agents/skills/work")} {
|
||||
if _, err := os.Lstat(p); !os.IsNotExist(err) {
|
||||
t.Errorf("%s is still there", p)
|
||||
}
|
||||
}
|
||||
if m, _ := filepath.Glob(filepath.Join(BackupDir(), "*", "*", "skills", "notes")); len(m) != 0 {
|
||||
t.Errorf("notes kept with the backups, though not asked: %v", m)
|
||||
}
|
||||
if m, _ := filepath.Glob(filepath.Join(BackupDir(), "*", "*", "skills", "pdf", "SKILL.md")); len(m) != 1 {
|
||||
t.Errorf("the shared entry wasn't kept with the backups: %v", m)
|
||||
if m, _ := filepath.Glob(filepath.Join(BackupDir(), "*", "*", "skills", "*")); len(m) != 0 {
|
||||
t.Errorf("kept with the backups, though not asked: %v", m)
|
||||
}
|
||||
if read(t, filepath.Join(dev, "SKILL.md")) == "" {
|
||||
t.Error("the folder Claude Code linked to is gone")
|
||||
}
|
||||
if read(t, filepath.Join(work, "SKILL.md")) == "" {
|
||||
t.Error("the folder ~/.agents/skills linked to is gone")
|
||||
}
|
||||
|
||||
// kept, as by default, the shared entry goes to the backups
|
||||
again := filepath.Join(h, ".agents/skills/again")
|
||||
skill(t, again, "again", "Again")
|
||||
ok(t)(RemoveFoundSkill("again"))
|
||||
if m, _ := filepath.Glob(filepath.Join(BackupDir(), "*", "*", "skills", "again", "SKILL.md")); len(m) != 1 {
|
||||
t.Errorf("the shared entry wasn't kept with the backups: %v", m)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -607,13 +607,6 @@ func linked(p string) bool {
|
||||
// Goose, Cindy): one link there, whichever of them it's for.
|
||||
func sharedSkillsDir() string { return filepath.Join(home(), ".agents", "skills") }
|
||||
|
||||
// inSharedDir is whether p is an entry of ~/.agents/skills, however its
|
||||
// folder is reached: the user's own, which other tools read too, that
|
||||
// magpie never deletes.
|
||||
func inSharedDir(p string) bool {
|
||||
return realDir(filepath.Dir(p)) == realDir(sharedSkillsDir())
|
||||
}
|
||||
|
||||
// sharedHas is whether the library's skill by that name is kept in
|
||||
// ~/.agents/skills, so every agent that reads the shared folder has it,
|
||||
// whatever the library gives (sharedEntry).
|
||||
@@ -2930,10 +2923,13 @@ func removeFound(found []FoundSkill, name string, keep bool) error {
|
||||
}
|
||||
continue
|
||||
}
|
||||
if !keep && !inSharedDir(e.p) {
|
||||
if !keep {
|
||||
// not a link (above): the skill's own folder, deleted as asked.
|
||||
// One in ~/.agents/skills, which other tools read too, is never
|
||||
// deleted: it goes to the backups as ever
|
||||
// One in ~/.agents/skills too (@Eternalfate__ on X: most skills
|
||||
// are there, so the sheet never had the tick): it leaves that
|
||||
// folder either way, and the other tools reading it lose it
|
||||
// either way; kept, it only sat in the backups. A folder the
|
||||
// entry links to is never reached here (above)
|
||||
if err := os.RemoveAll(e.p); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user