library: the skills sheet says why an agent gets copies (4kT1FohCTP97031 on X)
The report (X, tweet 2123056163587780891): "Claude Code can only copy
skills, never link them; every other agent can use paths." Claude Code
already takes links: real claude 2.1.327 in a sandbox HOME and
CLAUDE_CONFIG_DIR loads a symlinked skill folder and a symlinked
SKILL.md, and reads the files beside it. The row that said 只能用副本
with no reason and no switch was Claude Desktop's (Cowork), which
really does skip a linked skill (Claude Desktop 2.7032; see
desktop_skills.go), so it keeps copies.
- AgentView gains CopyWhy and CopyWith (copyWhy in skill_how.go):
desktop, liveagent, wsl (a WSL agent on a Windows drive), junction
(agy/antigravity/crush on Windows), and shared, for an agent that reads
the same folder as one given copies. A shared agent was shown as
"Gets links" while syncSkills gave it copies (l.copies with sharers);
its How is now copy and the row names whose copies they are.
- The How sheet's row says the reason ("Only ever takes copies: Cowork
skips a linked skill"), in en, zh, zh-TW, ja and de. Without a known
reason it still says "Only ever takes copies".
- docs/subsystems/library.md says so.
Not changed: agy/crush on Windows take copies even where a symlink
could be made (#5107, #6610 decided that); not part of this report.
Tests:
- TestSkillHowSaysWhyCopies: Claude Code link, Claude Desktop
desktop, Codex reading Claude Code's folder as copies -> Claude Code
how copy, shared, ["Codex"], a copy on disk, and links again after.
Red on the old behaviour (fields kept, copyWhy and the How override
dropped): "Claude Desktop: why """ and "Claude Code: how "link"".
- skill-how.test.cjs: the desktop row's reason, a shared row, a bare
must-copy row, and a new all-languages test (en zh zh-TW ja de) at a
phone width. Red on origin/main's plugins/library client.js and
i18n.js in every language (expected the reason, got the bare words).
Run:
- gofmt -l clean. go vet internal/library and (-tags nogui)
internal/gui on Linux, GOOS=windows, GOOS=darwin (wsl-run): ok.
- go test ./internal/library -count=1 at this head (rebased on
origin/main 1e2287758, on mote): ok.
go test -tags nogui -run 'Budget|I18n|Doc' ./internal/gui: ok.
- GUI at this head on mote, chromium and webkit: library-wsl-asleep +
skill-how 53/53 each. On magpie-desktop at load ~78 (another session's
full suite and GUI suite) many files timed out together; skill-how and
skill-name-many-agents alone there: 15/15.
- Before the rebase on magpie-desktop, both engines: skill-how,
library-wsl-asleep, i18n-keys, i18n-en-no-cjk, library-desktop-skills,
library-desktop-twin, skill-router, library-items pass. click-scroll,
library-all and skill-where (webkit) red, and the same red on a clean
origin/main 454f9d023 alone: #4385, #4967, #5154 (commented).
Not run before the push: the full go test ./... and the whole GUI
suite (the coordinator asked to ship on the targeted runs); they run
after on a free machine.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -7393,6 +7393,21 @@ magpie.plugin("library", (ctx) => {
|
||||
return out;
|
||||
}
|
||||
|
||||
// An agent's way in the sheet, with why it gets copies when it didn't
|
||||
// ask for them (copyWhy, 4kT1FohCTP97031 on X: Claude Desktop's
|
||||
// copies-only row said no more than that)
|
||||
const COPY_WHY = {
|
||||
desktop: "Only ever takes copies: Cowork skips a linked skill",
|
||||
liveagent: "Only ever takes copies: LiveAgent refuses a linked skill",
|
||||
wsl: "Only ever takes copies: its skills folder is on a Windows drive, where WSL can't link",
|
||||
junction: "Only ever takes copies: on Windows it skips a linked skill",
|
||||
};
|
||||
function howLine(a) {
|
||||
if (a.copyWhy === "shared") return t("Gets copies: it reads the same folder as {agents}, which gets copies", { agents: (a.copyWith || []).join(", ") });
|
||||
if (a.mustCopy) return t(COPY_WHY[a.copyWhy] || "Only ever takes copies");
|
||||
return a.how === "copy" ? t("Gets copies") : t("Gets links");
|
||||
}
|
||||
|
||||
function openSkillHow() {
|
||||
const ed = el("div", "editor lib-editor lib-byagent-sheet lib-howsheet");
|
||||
const head = el("div", "ehead");
|
||||
@@ -7407,7 +7422,7 @@ magpie.plugin("library", (ctx) => {
|
||||
const row = el("div", "row lib-row lib-byagent-row lib-how-row");
|
||||
row.dataset.agent = a.id;
|
||||
const who = el("div", "who");
|
||||
who.append(el("div", "name", a.name), el("div", "sub", a.mustCopy ? t("Only ever takes copies") : a.how === "copy" ? t("Gets copies") : t("Gets links")));
|
||||
who.append(el("div", "name", a.name), el("div", "sub", howLine(a)));
|
||||
row.append(agentIcon(a.icon), who);
|
||||
if (!a.mustCopy) {
|
||||
row.append(segs([["", t("Library's way")], ["link", t("Links")], ["copy", t("Copies")]], a.howOwn ? a.how : "", async (h) => {
|
||||
|
||||
@@ -279,6 +279,11 @@ magpie.strings({
|
||||
"An agent can have its own way; the others get copies, as the library gives them.": "可以给某个 Agent 单独设定;其余的按资源库的方式,拿副本。",
|
||||
"An agent can have its own way; the others get links, as the library gives them.": "可以给某个 Agent 单独设定;其余的按资源库的方式,用符号链接。",
|
||||
"Only ever takes copies": "只能用副本",
|
||||
"Only ever takes copies: Cowork skips a linked skill": "只能用副本:Cowork 会跳过链接进来的 Skill",
|
||||
"Only ever takes copies: LiveAgent refuses a linked skill": "只能用副本:LiveAgent 不接受链接进来的 Skill",
|
||||
"Only ever takes copies: its skills folder is on a Windows drive, where WSL can't link": "只能用副本:它的 Skills 文件夹在 Windows 盘上,WSL 没法在那里建链接",
|
||||
"Only ever takes copies: on Windows it skips a linked skill": "只能用副本:在 Windows 上它会跳过链接进来的 Skill",
|
||||
"Gets copies: it reads the same folder as {agents}, which gets copies": "用副本:它和 {agents} 读同一个文件夹,而 {agents} 用副本",
|
||||
"Gets copies": "用副本",
|
||||
"Gets links": "用符号链接",
|
||||
"Library's way": "跟随资源库",
|
||||
@@ -1391,6 +1396,11 @@ magpie.strings({
|
||||
"An agent can have its own way; the others get copies, as the library gives them.": "可以給某個 Agent 單獨設定;其餘的按資源庫的方式,拿副本。",
|
||||
"An agent can have its own way; the others get links, as the library gives them.": "可以給某個 Agent 單獨設定;其餘的按資源庫的方式,用符號連結。",
|
||||
"Only ever takes copies": "只能用副本",
|
||||
"Only ever takes copies: Cowork skips a linked skill": "只能用副本:Cowork 會跳過連結進來的 Skill",
|
||||
"Only ever takes copies: LiveAgent refuses a linked skill": "只能用副本:LiveAgent 不接受連結進來的 Skill",
|
||||
"Only ever takes copies: its skills folder is on a Windows drive, where WSL can't link": "只能用副本:它的 Skills 資料夾在 Windows 磁碟上,WSL 沒辦法在那裡建立連結",
|
||||
"Only ever takes copies: on Windows it skips a linked skill": "只能用副本:在 Windows 上它會跳過連結進來的 Skill",
|
||||
"Gets copies: it reads the same folder as {agents}, which gets copies": "用副本:它和 {agents} 讀同一個資料夾,而 {agents} 用副本",
|
||||
"Gets copies": "用副本",
|
||||
"Gets links": "用符號連結",
|
||||
"Library's way": "跟隨資源庫",
|
||||
@@ -2495,6 +2505,11 @@ magpie.strings({
|
||||
"An agent can have its own way; the others get copies, as the library gives them.": "エージェントごとに決められます。ほかはライブラリの設定どおりコピーを受け取ります。",
|
||||
"An agent can have its own way; the others get links, as the library gives them.": "エージェントごとに決められます。ほかはライブラリの設定どおりリンクを受け取ります。",
|
||||
"Only ever takes copies": "コピーのみ",
|
||||
"Only ever takes copies: Cowork skips a linked skill": "コピーのみ:Cowork はリンクされたスキルを読み飛ばします",
|
||||
"Only ever takes copies: LiveAgent refuses a linked skill": "コピーのみ:LiveAgent はリンクされたスキルを受け付けません",
|
||||
"Only ever takes copies: its skills folder is on a Windows drive, where WSL can't link": "コピーのみ:スキルのフォルダーが Windows のドライブにあり、WSL はそこにリンクを作れません",
|
||||
"Only ever takes copies: on Windows it skips a linked skill": "コピーのみ:Windows ではリンクされたスキルを読み飛ばします",
|
||||
"Gets copies: it reads the same folder as {agents}, which gets copies": "コピー:{agents} と同じフォルダーを読み、{agents} がコピーを使うため",
|
||||
"Gets copies": "コピーを受け取る",
|
||||
"Gets links": "リンクを受け取る",
|
||||
"Library's way": "ライブラリに従う",
|
||||
@@ -3603,6 +3618,11 @@ magpie.strings({
|
||||
"An agent can have its own way; the others get copies, as the library gives them.": "Ein Agent kann seine eigene Art haben; die anderen bekommen Kopien, wie die Bibliothek sie gibt.",
|
||||
"An agent can have its own way; the others get links, as the library gives them.": "Ein Agent kann seine eigene Art haben; die anderen bekommen Links, wie die Bibliothek sie gibt.",
|
||||
"Only ever takes copies": "Nimmt nur Kopien",
|
||||
"Only ever takes copies: Cowork skips a linked skill": "Nimmt nur Kopien: Cowork überspringt einen verlinkten Skill",
|
||||
"Only ever takes copies: LiveAgent refuses a linked skill": "Nimmt nur Kopien: LiveAgent lehnt einen verlinkten Skill ab",
|
||||
"Only ever takes copies: its skills folder is on a Windows drive, where WSL can't link": "Nimmt nur Kopien: Sein Skills-Ordner liegt auf einem Windows-Laufwerk, wo WSL nicht verlinken kann",
|
||||
"Only ever takes copies: on Windows it skips a linked skill": "Nimmt nur Kopien: Unter Windows überspringt es einen verlinkten Skill",
|
||||
"Gets copies: it reads the same folder as {agents}, which gets copies": "Bekommt Kopien: Es liest denselben Ordner wie {agents}, das Kopien bekommt",
|
||||
"Gets copies": "Bekommt Kopien",
|
||||
"Gets links": "Bekommt Links",
|
||||
"Library's way": "Wie die Bibliothek",
|
||||
|
||||
@@ -3,8 +3,9 @@
|
||||
// some want each agent to have a copy of its own. The Skills tab says how
|
||||
// they're given, Links or Copies, and switching posts the library's way;
|
||||
// By agent lists the agents that take skills, each with Library's way /
|
||||
// Links / Copies (Claude Desktop only ever takes copies, and has no
|
||||
// switch), and a pick posts that agent's way; a skill whose copy in an
|
||||
// Links / Copies (Claude Desktop only ever takes copies, says why, and
|
||||
// has no switch; one reading the folder of an agent given copies says
|
||||
// so), and a pick posts that agent's way; a skill whose copy in an
|
||||
// agent differs from the library's says so, and a click syncs. No select,
|
||||
// no scroll, no left border, in English and Chinese. No backend: the API
|
||||
// is faked here.
|
||||
@@ -17,13 +18,16 @@ const { chromium, webkit } = require("playwright");
|
||||
const assets = path.resolve(__dirname, "../assets");
|
||||
const HOME = "/Users/ada";
|
||||
|
||||
function server(lang, posts) {
|
||||
const st = { copy: false, own: {}, behind: ["codex"] };
|
||||
function server(lang, posts, own = {}) {
|
||||
const st = { copy: false, own: { ...own }, behind: ["codex"] };
|
||||
const how = (id) => st.own[id] || (st.copy ? "copy" : "link");
|
||||
const agent = (id, name, extra = {}) => ({ id, name, icon: "", skills: `${HOME}/.${id}/skills`, how: how(id), howOwn: !!st.own[id], ...extra });
|
||||
const lib = () => ({
|
||||
dir: `${HOME}/.magpie/library`, backups: `${HOME}/.magpie/backups`, home: HOME, copySkills: st.copy,
|
||||
agents: [agent("claude", "Claude Code"), agent("codex", "Codex"), agent("claude-desktop", "Claude Desktop", { how: "copy", mustCopy: true })],
|
||||
agents: [agent("claude", "Claude Code"), agent("codex", "Codex"), agent("claude-desktop", "Claude Desktop", { how: "copy", mustCopy: true, copyWhy: "desktop" }),
|
||||
// reads Codex's very folder: copies when Codex takes them
|
||||
agent("kimi", "Kimi Code", how("codex") === "copy" && how("kimi") !== "copy" ? { how: "copy", copyWhy: "shared", copyWith: ["Codex"] } : {}),
|
||||
agent("liveagent", "LiveAgent", { how: "copy", mustCopy: true })],
|
||||
instructions: { agents: [] }, servers: [], foundServers: [], projects: [], foundSkills: [],
|
||||
skills: [
|
||||
{ name: "pdf", description: "Read PDFs", kind: "", agents: ["claude", "codex"], behind: st.behind.length ? st.behind : undefined },
|
||||
@@ -83,6 +87,8 @@ const words = {
|
||||
copied: "The agents get copies of their skills now", behind: "Copy out of date", behindTip: "The copy in Codex differs from the library's skill. Click to copy it again.",
|
||||
synced: "Copies updated", sheet: "How each agent gets its skills", libWay: "Library's way", only: "Only ever takes copies", getsCopies: "Gets copies", getsLinks: "Gets links",
|
||||
codexLinks: "Codex gets links to its skills now",
|
||||
desktopOnly: "Only ever takes copies: Cowork skips a linked skill",
|
||||
sharedCodex: "Gets copies: it reads the same folder as Codex, which gets copies",
|
||||
},
|
||||
zh: {
|
||||
label: "Skills 启用方式", links: "符号链接", copies: "副本", byAgent: "按 Agent", byAgentOne: "按 Agent(1)",
|
||||
@@ -91,6 +97,20 @@ const words = {
|
||||
copied: "现在各 Agent 拿到的是 Skills 的副本", behind: "副本已落后", behindTip: "Codex 里的副本和资源库里的 Skill 不一样了。点一下重新复制。",
|
||||
synced: "副本已更新", sheet: "各 Agent 的 Skills 启用方式", libWay: "跟随资源库", only: "只能用副本", getsCopies: "用副本", getsLinks: "用符号链接",
|
||||
codexLinks: "Codex 现在用的是符号链接",
|
||||
desktopOnly: "只能用副本:Cowork 会跳过链接进来的 Skill",
|
||||
sharedCodex: "用副本:它和 Codex 读同一个文件夹,而 Codex 用副本",
|
||||
},
|
||||
"zh-TW": {
|
||||
only: "只能用副本", desktopOnly: "只能用副本:Cowork 會跳過連結進來的 Skill",
|
||||
sharedCodex: "用副本:它和 Codex 讀同一個資料夾,而 Codex 用副本",
|
||||
},
|
||||
ja: {
|
||||
only: "コピーのみ", desktopOnly: "コピーのみ:Cowork はリンクされたスキルを読み飛ばします",
|
||||
sharedCodex: "コピー:Codex と同じフォルダーを読み、Codex がコピーを使うため",
|
||||
},
|
||||
de: {
|
||||
only: "Nimmt nur Kopien", desktopOnly: "Nimmt nur Kopien: Cowork überspringt einen verlinkten Skill",
|
||||
sharedCodex: "Bekommt Kopien: Es liest denselben Ordner wie Codex, das Kopien bekommt",
|
||||
},
|
||||
};
|
||||
|
||||
@@ -162,13 +182,17 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
await sheet.waitFor();
|
||||
assert.equal((await sheet.locator(".ehead b").textContent()).trim(), w.sheet);
|
||||
const rows = sheet.locator(".lib-how-row");
|
||||
assert.deepEqual(await rows.evaluateAll((r) => r.map((x) => x.dataset.agent)), ["claude", "codex", "claude-desktop"]);
|
||||
const codex = rows.nth(1), desktop = rows.nth(2);
|
||||
assert.deepEqual(await rows.evaluateAll((r) => r.map((x) => x.dataset.agent)), ["claude", "codex", "claude-desktop", "kimi", "liveagent"]);
|
||||
const codex = rows.nth(1), desktop = rows.nth(2), kimi = rows.nth(3), live = rows.nth(4);
|
||||
assert.equal((await codex.locator(".sub").textContent()).trim(), w.getsCopies);
|
||||
assert.deepEqual(await codex.locator(".segs .opt").allTextContents(), [w.libWay, w.links, w.copies]);
|
||||
assert.equal((await codex.locator(".segs .opt.on").textContent()).trim(), w.libWay);
|
||||
assert.equal((await desktop.locator(".sub").textContent()).trim(), w.only);
|
||||
assert.equal((await rows.nth(0).locator(".sub").textContent()).trim(), w.getsCopies, "Claude Code takes the library's way");
|
||||
assert.equal(await rows.nth(0).locator(".segs").count(), 1, "Claude Code has a switch");
|
||||
assert.equal((await desktop.locator(".sub").textContent()).trim(), w.desktopOnly, "Claude Desktop says why");
|
||||
assert.equal(await desktop.locator(".segs").count(), 0, "Claude Desktop has no switch");
|
||||
assert.equal((await live.locator(".sub").textContent()).trim(), w.only, "no reason known: the bare words");
|
||||
assert.equal((await kimi.locator(".sub").textContent()).trim(), w.getsCopies, "Codex takes the library's way: no shared copies");
|
||||
await press(page, codex.locator(".segs .opt").nth(1));
|
||||
await page.waitForTimeout(300);
|
||||
assert.deepEqual(posts[2], { path: "how", agent: "codex", how: "link" });
|
||||
@@ -209,3 +233,49 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
// Why an agent gets copies (4kT1FohCTP97031 on X: Claude Desktop's bare
|
||||
// "只能用副本" read as Claude Code's): Claude Desktop's row says Cowork's
|
||||
// reason, an agent reading Codex's folder while Codex takes copies says
|
||||
// so, Claude Code keeps links and its switch, in every language.
|
||||
for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) {
|
||||
test(engine + ": the sheet says why an agent gets copies", async (t) => {
|
||||
const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" }));
|
||||
const errors = [];
|
||||
t.after(async () => {
|
||||
if (errors.length) console.log(errors);
|
||||
await browser.close();
|
||||
});
|
||||
for (const lang of ["en", "zh", "zh-TW", "ja", "de"]) {
|
||||
await t.test(lang, async () => {
|
||||
const w = words[lang];
|
||||
const ctx = await browser.newContext({ viewport: { width: 420, height: 760 } });
|
||||
await ctx.addInitScript(() => { try { localStorage.setItem("magpie.libTab", "skills"); } catch {} });
|
||||
const page = await ctx.newPage();
|
||||
page.setDefaultTimeout(5000);
|
||||
page.setDefaultNavigationTimeout(60000);
|
||||
page.on("pageerror", (e) => errors.push(e.message));
|
||||
await page.route("**/*", server(lang, [], { codex: "copy" }));
|
||||
await page.goto("http://magpie.test/");
|
||||
await page.locator('button[data-view="library"]').click();
|
||||
await page.locator("#view-library .lib-body:not(.lib-skel) .lib-row").first().waitFor();
|
||||
await press(page, page.locator("#lib-skillhow .lib-howagent"));
|
||||
const sheet = page.locator("#modal .lib-howsheet");
|
||||
await sheet.waitFor();
|
||||
const row = (id) => sheet.locator(`.lib-how-row[data-agent="${id}"]`);
|
||||
const sub = async (id) => (await row(id).locator(".sub").textContent()).trim();
|
||||
assert.equal(await row("claude").locator(".segs").count(), 1, "Claude Code has its switch");
|
||||
assert.notEqual(await sub("claude"), w.only);
|
||||
assert.equal(await sub("claude-desktop"), w.desktopOnly);
|
||||
assert.equal(await row("claude-desktop").locator(".segs").count(), 0);
|
||||
assert.equal(await sub("kimi"), w.sharedCodex);
|
||||
assert.equal(await sub("liveagent"), w.only);
|
||||
// the longer line wraps inside the sheet at a phone's width
|
||||
const over = await sheet.evaluate((s) => [...s.querySelectorAll(".lib-how-row .sub")].filter((e) => e.getBoundingClientRect().right > s.getBoundingClientRect().right + 1).length);
|
||||
assert.equal(over, 0, "a reason runs out of the sheet");
|
||||
await ctx.close();
|
||||
});
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,6 +37,60 @@ func (l *Library) copies(t *Target, sharers []string) bool {
|
||||
return slices.ContainsFunc(append([]string{t.Agent.ID}, sharers...), func(id string) bool { return l.howOf(id) == HowCopy })
|
||||
}
|
||||
|
||||
// Why an agent is given copies of its skills while links are its way
|
||||
// (AgentView.CopyWhy), so the page can say so rather than leave a
|
||||
// copy-only row unexplained (4kT1FohCTP97031 on X).
|
||||
const (
|
||||
// Claude Desktop's Cowork leaves out a skill whose entry is a link: it
|
||||
// lstats each one and skips a symbolic link (Claude 2.7032 app.asar),
|
||||
// and it runs a skill in its own sandbox, which can't read past the
|
||||
// plugin's folder (desktop_skills.go)
|
||||
copyDesktop = "desktop"
|
||||
// K-brain refuses a link anywhere in a skill's path (liveagent.go)
|
||||
copyLiveAgent = "liveagent"
|
||||
// an agent in WSL whose skills folder, or the distro's store, is on a
|
||||
// Windows drive, where the distro can't make a link Windows follows
|
||||
// (wslStored)
|
||||
copyWSL = "wsl"
|
||||
// on Windows, an agent that skips a skill behind a junction
|
||||
// (junctionBlind)
|
||||
copyJunction = "junction"
|
||||
// an agent reading the very same folder as one given copies: they
|
||||
// get copies together (copies), CopyWith names the others
|
||||
copyShared = "shared"
|
||||
)
|
||||
|
||||
// copyWhy is why the agent of t gets copies of its skills without its
|
||||
// own way or the library's asking for them, "" when it doesn't; sharers
|
||||
// are the other agents reading the very same folder, and with the names
|
||||
// of those given copies, for copyShared.
|
||||
func (l *Library) copyWhy(t *Target, sharers []*Target) (why string, with []string) {
|
||||
switch {
|
||||
case t.Desktop != nil:
|
||||
return copyDesktop, nil
|
||||
case t.Copy && t.Agent.ID == "liveagent":
|
||||
return copyLiveAgent, nil
|
||||
case t.Copy && t.Agent.WSL != "":
|
||||
return copyWSL, nil
|
||||
case t.Copy && skipsJunctions(t.Agent.ID):
|
||||
return copyJunction, nil
|
||||
case t.Copy:
|
||||
return "", nil
|
||||
}
|
||||
if l.howOf(t.Agent.ID) == HowCopy {
|
||||
return "", nil
|
||||
}
|
||||
for _, o := range sharers {
|
||||
if l.howOf(o.Agent.ID) == HowCopy {
|
||||
with = append(with, o.Agent.Name)
|
||||
}
|
||||
}
|
||||
if len(with) > 0 {
|
||||
return copyShared, with
|
||||
}
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// howOf is the way the agent is given its skills: its own, else the
|
||||
// library's.
|
||||
func (l *Library) howOf(id string) string {
|
||||
|
||||
@@ -186,3 +186,71 @@ func TestSkillRelinkKeepsUnreadableCopy(t *testing.T) {
|
||||
t.Fatalf("the unreadable copy's edits weren't kept: %v", kept)
|
||||
}
|
||||
}
|
||||
|
||||
// The By agent sheet says why an agent gets copies it didn't ask for
|
||||
// (4kT1FohCTP97031 on X read Claude Desktop's bare "Only ever takes
|
||||
// copies" as Claude Code's): Claude Code takes links as every agent
|
||||
// does, Claude Desktop only copies, for Cowork's reason, and an agent
|
||||
// reading the very same folder as one given copies gets copies too, and
|
||||
// says so, rather than claim links.
|
||||
func TestSkillHowSaysWhyCopies(t *testing.T) {
|
||||
h := sandbox(t)
|
||||
p, _ := desktopFiles(t, h)
|
||||
write(t, p, `{}`)
|
||||
desktopAccount(t, filepath.Dir(p), "org1", "acct1", `{"lastUpdated": "2026-10-01T00:00:00.000Z", "skills": []}`)
|
||||
src := filepath.Join(h, "src/skills")
|
||||
skill(t, filepath.Join(src, "pdf"), "pdf", "Read PDFs")
|
||||
ok(t)(InstallSkills(src, []string{"pdf"}, []string{"claude", "claude-desktop"}))
|
||||
|
||||
how := func() map[string]AgentView {
|
||||
t.Helper()
|
||||
v, err := Read(nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m := map[string]AgentView{}
|
||||
for _, a := range v.Agents {
|
||||
m[a.ID] = a
|
||||
}
|
||||
return m
|
||||
}
|
||||
m := how()
|
||||
if a := m["claude"]; a.How != HowLink || a.MustCopy || a.CopyWhy != "" {
|
||||
t.Errorf("Claude Code: how %q, must copy %v, why %q; it takes links", a.How, a.MustCopy, a.CopyWhy)
|
||||
}
|
||||
if !isLink(t, filepath.Join(h, ".claude/skills/pdf")) {
|
||||
t.Error("Claude Code's skill isn't a link")
|
||||
}
|
||||
if a := m["claude-desktop"]; a.How != HowCopy || !a.MustCopy || a.CopyWhy != copyDesktop {
|
||||
t.Errorf("Claude Desktop: how %q, must copy %v, why %q", a.How, a.MustCopy, a.CopyWhy)
|
||||
}
|
||||
|
||||
// Codex reads Claude Code's very folder and is to have copies: both
|
||||
// get copies, and Claude Code's row says whose
|
||||
cx := filepath.Join(h, ".codex/skills")
|
||||
os.RemoveAll(cx)
|
||||
os.MkdirAll(filepath.Dir(cx), 0o755)
|
||||
if err := os.Symlink(filepath.Join(h, ".claude/skills"), cx); err != nil {
|
||||
t.Skipf("no symlink here: %v", err)
|
||||
}
|
||||
ok(t)(SetSkillHow("codex", HowCopy))
|
||||
if isLink(t, filepath.Join(h, ".claude/skills/pdf")) {
|
||||
t.Fatal("the shared folder kept a link while Codex is to have copies")
|
||||
}
|
||||
m = how()
|
||||
if a := m["claude"]; a.How != HowCopy || a.MustCopy || a.CopyWhy != copyShared || !slices.Equal(a.CopyWith, []string{"Codex"}) {
|
||||
t.Errorf("Claude Code: how %q, must copy %v, why %q with %v; it gets copies for Codex", a.How, a.MustCopy, a.CopyWhy, a.CopyWith)
|
||||
}
|
||||
if a := m["codex"]; a.How != HowCopy || a.CopyWhy != "" {
|
||||
t.Errorf("Codex: how %q, why %q; copies are its own way", a.How, a.CopyWhy)
|
||||
}
|
||||
|
||||
// Codex back to links: Claude Code's folder is links again
|
||||
ok(t)(SetSkillHow("codex", ""))
|
||||
if !isLink(t, filepath.Join(h, ".claude/skills/pdf")) {
|
||||
t.Error("not a link again")
|
||||
}
|
||||
if a := how()["claude"]; a.How != HowLink || a.CopyWhy != "" {
|
||||
t.Errorf("Claude Code after: how %q, why %q", a.How, a.CopyWhy)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,10 +446,15 @@ type AgentView struct {
|
||||
SkillRouter string `json:"skillRouter,omitempty"`
|
||||
// How is the way it is given its skills, link or copy, and HowOwn its
|
||||
// own over the library's; MustCopy is one that can only take copies
|
||||
// (in WSL)
|
||||
How string `json:"how,omitempty"`
|
||||
HowOwn bool `json:"howOwn,omitempty"`
|
||||
MustCopy bool `json:"mustCopy,omitempty"`
|
||||
// (in WSL, Claude Desktop, LiveAgent). CopyWhy is why it gets copies
|
||||
// without asking for them (copyWhy): desktop, liveagent, wsl,
|
||||
// junction, or shared with CopyWith, the agents given copies that read
|
||||
// the very same folder
|
||||
How string `json:"how,omitempty"`
|
||||
HowOwn bool `json:"howOwn,omitempty"`
|
||||
MustCopy bool `json:"mustCopy,omitempty"`
|
||||
CopyWhy string `json:"copyWhy,omitempty"`
|
||||
CopyWith []string `json:"copyWith,omitempty"`
|
||||
// Gone: not installed here any more, and listed only for what magpie
|
||||
// gave it to be taken out (held); it is given nothing new
|
||||
Gone bool `json:"gone,omitempty"`
|
||||
@@ -673,6 +678,14 @@ func readView(problems []Problem, glance bool) (*View, error) {
|
||||
// through every agent's folders, in WSL too (#1624)
|
||||
targets, asleep := targetsAsleep(false)
|
||||
v := &View{Agents: []AgentView{}, Servers: []ServerView{}, Skills: []SkillView{}, FoundSkills: []FoundSkill{}, Instructions: l.instructionsView(targets, asleep), Dir: Dir(), Backups: BackupDir(), CopySkills: l.CopySkills, SharedSkills: l.SharedSkills, SharedDir: sharedSkillsDir(), AutoUpdateSkills: l.AutoUpdateSkills, MCPHub: l.MCPHub, SkillRouter: l.SkillRouter, HubPath: gateway.HubMCPPath, HubNote: settings.Shared().RouterNote, HubName: gateway.HostName(), HubAllTools: settings.Shared().RouterAllTools, HubFindsItself: hubFindsItself(), HubOnDemandOver: gateway.HubOnDemandOver, Partial: glance}
|
||||
// each agent's skills folder as it really is, links followed: the
|
||||
// agents reading the same one get copies together (copyWhy)
|
||||
skillsAt := map[*Target]string{}
|
||||
for _, t := range targets {
|
||||
if t.Skills != "" {
|
||||
skillsAt[t] = realDir(t.Skills)
|
||||
}
|
||||
}
|
||||
for _, t := range targets {
|
||||
av := AgentView{ID: t.Agent.ID, Name: t.Agent.Name, Icon: t.Agent.Icon, Instructions: t.Instructions, Skills: t.Skills,
|
||||
SkillsAlso: t.SkillsAlso, Note: t.Note, MCPVia: t.MCPVia, ProjectSkills: ProjectSkillsDir(t.Agent.ID), ProjectMCP: ProjectMCPFile(t.Agent.ID), ProjectSubagents: ProjectSubagentsDir(t.Agent.ID),
|
||||
@@ -682,7 +695,14 @@ func readView(problems []Problem, glance bool) (*View, error) {
|
||||
if t.Skills != "" {
|
||||
_, av.HowOwn = l.SkillHow[t.Agent.ID]
|
||||
av.How, av.MustCopy = l.howOf(t.Agent.ID), t.Copy || t.Desktop != nil
|
||||
if av.MustCopy {
|
||||
var sharers []*Target
|
||||
for _, o := range targets {
|
||||
if o != t && o.Skills != "" && skillsAt[o] == skillsAt[t] {
|
||||
sharers = append(sharers, o)
|
||||
}
|
||||
}
|
||||
av.CopyWhy, av.CopyWith = l.copyWhy(t, sharers)
|
||||
if av.MustCopy || av.CopyWhy == copyShared {
|
||||
av.How = HowCopy
|
||||
}
|
||||
if l.SkillRouter {
|
||||
|
||||
Reference in New Issue
Block a user