library: handing skills over turns off the all-in-~/.agents/skills setting and takes magpie's links out (ConatusMoon2222 on X)

Put skills in "~/.agents/skills" (SharedSkills) gives every agent that reads
that folder every skill, so it cannot go with choosing agents per skill,
which is what "Manage in magpie" (HandOverSkills) is for. With the setting
on, a handed-over skill's entry was taken away and the next sync linked it
back there, so the link stayed (reproduced in a sandbox HOME). Handing over
now turns the setting off in the same write; the sync then removes magpie's
own links there (sweepShared: only ours, never the user's entries). The
confirm sheet says so, only while the setting is on. The Put skills in note
says the skill router lists nothing while every skill is in
~/.agents/skills (the "none" the reporter met), only when both are on.
Strings in zh, zh-TW, ja, de.

Run (on mote, at this tree):
- TestHandOverWithSharedSetting: red with the l.SharedSkills = false line
  commented out ("a link is left in ~/.agents/skills"), green with it.
- go test ./internal/library ok; go vet darwin, GOOS=windows, linux nogui
  on internal/library ok; gofmt -l clean.
- GUI: skill-handover, shared-skills, i18n-keys, i18n-en-no-cjk in chromium
  and webkit, 23/23 each.
Not run: the full GUI suite and go test ./... before the tag; a real
account's Library; WebKitGTK.
This commit is contained in:
yetone
2026-11-13 11:28:51 +08:00
parent 52830b077b
commit 610ae1f541
6 changed files with 75 additions and 3 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ Pi's extensions and packages.
- An MCP server can be kept to this computer (`Server.Local`; the editor's "Sync to your other computers" switch, off for a local one (it said "This computer only", which bin.90 on Discord read as sharing), the row tagged "Not synced", `magpie library mcp add --local`, `magpie library mcp local <name> on|off`; huhuy72219405 on X). `Collect` never carries it (`carriedServers`), so a sync or a backup file never takes it to another computer, and turning a shared server local takes it out of what is carried: the other computers drop it at their next sync. `Put` (sync, join, Restore, Undo, a backup file) keeps every local server here, with its agents, and clears `Local` on what comes in (`putServers`). Another computer's server by the name of a local one doesn't take its place: it goes to `Library.Away`, given to no agent, not in the router, not checked, and carried on as it came, so a push from here never takes it from the computers that have it. `settleAway` runs on every change: while the name is local here the away copy stays; once no server of that name is left here (removed or renamed) it comes in as a sync would bring it; once a shared server has the name (local turned off) this computer's is the one carried. The router serves local servers like any other, since it runs on this computer. A carried subagent names its servers, a local one too; a computer without that server leaves it out of the agents' files, as any server the library hasn't. The TUI keeps the flag on edit and marks the row. (`TestLocalServerNotCarried`, `TestPutKeepsLocalServer`, `TestPutSameNameAsLocal`, `TestRestoreKeepsLocalServer`, `TestLocalServerThroughSync`, `mcp-local-server.test.cjs`) [`mcp_local.go`](../../internal/library/mcp_local.go), [`carry.go`](../../internal/library/carry.go)
- 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 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)
- 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)
- A skill's files are read and edited in the page (refeccd on Discord: skills handed over from `~/.agents/skills` had nowhere else to be edited). `GET /api/library/skill?name=&file=` answers `ReadSkillFile`: the file (`SKILL.md` when none is named), its text, the skill's folder and `files`, its text files (`skillTextFiles`: UTF-8 with no NUL, up to 1 MB each and 200 in all, `SKILL.md` first, leaving out links, hidden folders, `skipInSkill`'s entries and what installing writes, `fromInstall`). `SaveSkillFile` (`POST /api/library/skills/save` with `name`, `file`, `text` and `was`) goes through `change`: it writes only a regular file already in the skill's folder, never through a link or out of the folder (`skillFilePath`), refuses when the file no longer holds `was`, the text the page opened, keeps a file's CRLF line ends, and writes with `edit.WriteAtomic`. It writes the library's folder, so a linked agent reads it at once and the sync that follows copies it again into each copy; a copy edited in an agent before it is older than the save, so `takeEdits` keeps that edit aside with the backups. A skill from GitHub or git saved here reads as changed here (`editState`), so an update asks before it replaces the edit. The page (`viewSkill`, `rendered` in plugins/library/client.js) draws a Markdown file with the Plugins page's renderer (`window.mdRender`, `markdown` in plugins.js) and its front matter as rows, any other file as its text; Edit swaps in a text box, ⌘S or Save sends it, and the skill's other files are the app's menu under its name (`TestSavedSkillFileReachesEveryAgent`, `TestSkillFileSaveRefusesAChangedFile`, `TestSkillFileStaysInTheSkill`, `TestSkillFileKeepsLineEnds`, `skill-edit.test.cjs`). Not covered: the TUI and CLI have no editor; a new file can't be made, and a file can't be renamed or removed, here. [`skill_file.go`](../../internal/library/skill_file.go)
@@ -6540,7 +6540,9 @@ magpie.plugin("library", (ctx) => {
bar.append(el("span", "label", t("Put skills in")), segs([["agents", t("Each agent's own folder")], ["shared", "~/.agents/skills"]], where, (w) => {
if (w !== where) change("skills/where", { how: w }, w === "shared" ? t("Every skill is in ~/.agents/skills now") : t("Skills go to the agents they're ticked for now"));
}));
bar.append(el("span", "note", where === "shared"
bar.append(el("span", "note", where === "shared" && lib.skillRouter
? t("The skill router lists nothing while every skill is in ~/.agents/skills: choose each agent's own folder.")
: where === "shared"
? t("Every skill on here is linked into ~/.agents/skills too: each agent that reads that folder has every skill, whatever is ticked. The files stay in the library.")
: t("Each agent gets the skills ticked for it, in its own folder.")));
return bar;
@@ -7404,6 +7406,7 @@ magpie.plugin("library", (ctx) => {
if (readers) ed.append(el("p", "lib-confirm", one
? t("{agents} read ~/.agents/skills themselves. They keep it, ticked here, and you can turn it off for any of them, or on this computer only.", { agents: readers })
: t("{agents} read ~/.agents/skills themselves. They keep them, ticked here, and you can turn each off for any of them, or on this computer only.", { agents: readers })));
if (lib.sharedSkills) ed.append(el("p", "lib-confirm", t("Every skill is kept in ~/.agents/skills now, which can't go with choosing agents. That setting goes off: magpie's links there are taken away, your own entries stay.")));
ed.append(el("p", "lib-confirm lib-muted", one
? t("To put it back: {cmd}", { cmd: "magpie library skill hand-back " + s.name })
: t("To put one back: {cmd}", { cmd: "magpie library skill hand-back <name>" })));
@@ -233,6 +233,8 @@ magpie.strings({
"Give an agent its skills its own way": "给某个 Agent 单独设定启用方式",
"Each agent gets a folder of its own, made again when the library's skill changes. An edit made in a copy goes into the library and to the other agents.": "每个 Agent 拿到一份独立的文件夹,资源库里的 Skill 变了就重新复制。在副本里做的修改会收进资源库,再给其他 Agent。",
"Put skills in": "Skills 放在",
"The skill router lists nothing while every skill is in ~/.agents/skills: choose each agent's own folder.": "当所有 Skill 都在 ~/.agents/skills 里时,Skill 路由什么也列不出:请选“各 Agent 自己的目录”。",
"Every skill is kept in ~/.agents/skills now, which can't go with choosing agents. That setting goes off: magpie's links there are taken away, your own entries stay.": "现在所有 Skill 都放在 ~/.agents/skills 里,这与按 Agent 勾选互斥。该设置会关闭:magpie 在那里的链接会被移除,你自己的条目保留。",
"Each agent's own folder": "各 Agent 自己的目录",
"Every skill is in ~/.agents/skills now": "所有 Skill 现在都在 ~/.agents/skills 里了",
"Skills go to the agents they're ticked for now": "Skill 现在只给勾选的 Agent",
@@ -1232,6 +1234,8 @@ magpie.strings({
"Give an agent its skills its own way": "給某個 Agent 單獨設定啟用方式",
"Each agent gets a folder of its own, made again when the library's skill changes. An edit made in a copy goes into the library and to the other agents.": "每個 Agent 拿到一份獨立的資料夾,資源庫裡的 Skill 變了就重新複製。在副本裡做的修改會收進資源庫,再給其他 Agent。",
"Put skills in": "Skills 放在",
"The skill router lists nothing while every skill is in ~/.agents/skills: choose each agent's own folder.": "當所有 Skill 都在 ~/.agents/skills 裡時,Skill 路由什麼也列不出:請選「各 Agent 自己的目錄」。",
"Every skill is kept in ~/.agents/skills now, which can't go with choosing agents. That setting goes off: magpie's links there are taken away, your own entries stay.": "現在所有 Skill 都放在 ~/.agents/skills 裡,這與按 Agent 勾選互斥。該設定會關閉:magpie 在那裡的連結會被移除,你自己的項目保留。",
"Each agent's own folder": "各 Agent 自己的目錄",
"Every skill is in ~/.agents/skills now": "所有 Skill 現在都在 ~/.agents/skills 裡了",
"Skills go to the agents they're ticked for now": "Skill 現在只給勾選的 Agent",
@@ -2223,6 +2227,8 @@ magpie.strings({
"Give an agent its skills its own way": "エージェントごとに渡し方を決める",
"Each agent gets a folder of its own, made again when the library's skill changes. An edit made in a copy goes into the library and to the other agents.": "各エージェントに独立したフォルダを渡し、ライブラリのスキルが変わると作り直します。コピーへの編集はライブラリに取り込み、ほかのエージェントにも渡します。",
"Put skills in": "スキルの置き場所",
"The skill router lists nothing while every skill is in ~/.agents/skills: choose each agent's own folder.": "すべてのスキルが ~/.agents/skills にある間、スキルルーターは何も一覧にしません。「各 Agent 自身のフォルダ」を選んでください。",
"Every skill is kept in ~/.agents/skills now, which can't go with choosing agents. That setting goes off: magpie's links there are taken away, your own entries stay.": "すべてのスキルが ~/.agents/skills に置かれており、Agent ごとの選択とは両立しません。その設定はオフになり、そこにある magpie のリンクは削除され、あなた自身のエントリは残ります。",
"Each agent's own folder": "各エージェントのフォルダ",
"Every skill is in ~/.agents/skills now": "すべてのスキルが ~/.agents/skills に入りました",
"Skills go to the agents they're ticked for now": "スキルはチェックしたエージェントにだけ渡るようになりました",
@@ -3218,6 +3224,8 @@ magpie.strings({
"Give an agent its skills its own way": "Einem Agenten seine Skills auf eigene Art geben",
"Each agent gets a folder of its own, made again when the library's skill changes. An edit made in a copy goes into the library and to the other agents.": "Jeder Agent bekommt einen eigenen Ordner, der neu angelegt wird, wenn sich der Skill der Bibliothek ändert. Eine Änderung an einer Kopie geht in die Bibliothek und an die anderen Agenten.",
"Put skills in": "Skills ablegen in",
"The skill router lists nothing while every skill is in ~/.agents/skills: choose each agent's own folder.": "Der Skill-Router listet nichts, solange jeder Skill in ~/.agents/skills liegt: Wähle den eigenen Ordner jedes Agents.",
"Every skill is kept in ~/.agents/skills now, which can't go with choosing agents. That setting goes off: magpie's links there are taken away, your own entries stay.": "Jeder Skill liegt jetzt in ~/.agents/skills, was sich mit der Auswahl der Agents ausschließt. Diese Einstellung wird ausgeschaltet: magpies Links dort werden entfernt, deine eigenen Einträge bleiben.",
"Each agent's own folder": "Ordner jedes Agenten",
"Every skill is in ~/.agents/skills now": "Jeder Skill liegt jetzt in ~/.agents/skills",
"Skills go to the agents they're ticked for now": "Skills gehen jetzt an die Agenten, für die sie angehakt sind",
@@ -19,6 +19,7 @@ const HOME = "/Users/tnt";
const SH = `${HOME}/.agents/skills`;
const agent = (id, name) => ({ id, name, icon: "", skills: `${HOME}/.${id}/skills` });
const lib = (st) => ({
sharedSkills: !!st.shared,
dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME,
agents: [agent("claude", "Claude Code"), agent("codex", "Codex"), agent("gemini", "Gemini CLI")],
instructions: { agents: [] }, servers: [], foundServers: [], projects: [], foundSkills: [], newSkills: [],
@@ -128,6 +129,25 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
await sheet.locator(".bar button", { hasText: w.cancel }).click();
await sheet.waitFor({ state: "detached" });
// with every skill kept in ~/.agents/skills by the setting (ConatusMoon2222
// on X) the sheet says that setting goes off; without it, it doesn't
assert(!said.includes("~/.agents/skills now"), "the sheet names the setting while it is off");
if (lang === "en") {
st.shared = true;
await page.reload();
await page.locator('button[data-view="library"]').click();
await row("orca").waitFor();
await row("orca").locator(".lib-handover").click();
await sheet.waitFor();
assert.match((await sheet.locator(".lib-confirm").allTextContents()).join(" "), /That setting goes off: magpie's links there are taken away/);
await sheet.locator(".bar button", { hasText: w.cancel }).click();
await sheet.waitFor({ state: "detached" });
st.shared = false;
await page.reload();
await page.locator('button[data-view="library"]').click();
await row("orca").waitFor();
}
// moved: one post, the row's button gone, and said
await one.click();
await sheet.waitFor();
+9 -1
View File
@@ -27,7 +27,8 @@ import (
// it, so each goes on having it, now from the library, till it's unticked.
// A skill not in the library yet (found in ~/.agents/skills) is brought in
// first. One that can't be handed over stays as it was, in Unmoved, and
// the others are handed over all the same. HandBackSkill undoes it.
// the others are handed over all the same. It also turns off the setting
// that keeps every skill in ~/.agents/skills. HandBackSkill undoes it.
func HandOverSkills(names []string) (*Result, error) {
if len(names) == 0 {
return nil, fmt.Errorf("no skills to hand over")
@@ -48,6 +49,13 @@ func HandOverSkills(names []string) (*Result, error) {
if len(failed) == len(names) {
return errors.New(failed[0].Error)
}
// Choosing which agents get a skill and the setting that puts every
// skill in ~/.agents/skills (SetSkillsWhere) can't both hold: with
// it on, every agent reading that folder has every skill and magpie
// links each one back there. It goes off, and the sync takes out
// magpie's own links there, never the user's entries
// (ConatusMoon2222 on X).
l.SharedSkills = false
return nil
})
if res != nil {
+33
View File
@@ -262,3 +262,36 @@ func TestSharedUnderAnotherName(t *testing.T) {
t.Error("goose isn't given the library's")
}
}
// ConatusMoon2222 on X: with every skill kept in ~/.agents/skills by the
// setting, handing skills over left magpie's links there (the sync made
// them again). The setting goes off, magpie's links go, the user's own
// entries stay.
func TestHandOverWithSharedSetting(t *testing.T) {
h := sandbox(t)
noGoose(t, h)
shared := filepath.Join(h, ".agents/skills")
ext := filepath.Join(h, "aimer-skills/grilling")
skill(t, ext, "grilling", "Grill")
symlink(t, ext, filepath.Join(shared, "grilling"))
ok(t)(ImportSkill("grilling"))
ok(t)(SetSkillsWhere(SkillsInShared))
// a skill of the library's the setting linked into the shared folder
ok(t)(CreateSkill("other", "Other", nil))
own := filepath.Join(shared, "handmade")
skill(t, own, "handmade", "Mine")
ok(t)(HandOverSkills([]string{"grilling"}))
if _, err := os.Lstat(filepath.Join(shared, "grilling")); !os.IsNotExist(err) {
t.Fatalf("a link is left in ~/.agents/skills: %v", err)
}
if _, err := os.Lstat(filepath.Join(shared, "other")); !os.IsNotExist(err) {
t.Errorf("magpie's link to another skill is left: %v", err)
}
if !realFolder(own) {
t.Error("the user's own folder went")
}
if v, err := Read(nil); err != nil || v.SharedSkills {
t.Error("the setting is still on")
}
}