Skip to content

Commit 95e1ac9

Browse files
fix(skills): skip mirror fan-out to agents that read the universal store (#3325)
1 parent 2ca578f commit 95e1ac9

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎packages/cli/src/utils/skillsMirror.test.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,30 @@ describe("mirrorGlobalSkills", () => {
177177
const link = join(home, ".cursor", "skills", "hyperframes");
178178
expect(realpathSync(link)).toBe(realpathSync(join(home, ".claude", "skills", "hyperframes")));
179179
});
180+
181+
// Pi natively discovers BOTH ~/.pi/agent/skills and the universal
182+
// ~/.agents/skills (pi's packages/coding-agent/docs/skills.md#locations).
183+
// A mirrored per-agent copy collides with the universal one and Pi skips
184+
// the universal entry on name conflict (#3294), so the mirror must not fan
185+
// out to it.
186+
it("skips agents that natively read the universal store (pi, #3294)", () => {
187+
const home = makeHome();
188+
seedStore(home, ["hyperframes"]);
189+
installMarker(home, ".pi/agent"); // Pi present
190+
installMarker(home, ".cursor"); // a regular per-dir agent, for contrast
191+
192+
const { mirrored } = mirrorGlobalSkills({
193+
skills: ["hyperframes"],
194+
home,
195+
platform: "linux",
196+
env: ENV,
197+
});
198+
const agents = mirrored.map((m) => m.agent);
199+
expect(agents).not.toContain("pi");
200+
expect(agents).toContain("cursor");
201+
// no per-agent copy created where the universal store already serves Pi
202+
expect(existsSync(join(home, ".pi", "agent", "skills", "hyperframes"))).toBe(false);
203+
});
180204
});
181205

182206
describe("AGENT_GLOBAL_DIRS (generated table)", () => {

‎packages/cli/src/utils/skillsMirror.ts‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
// populate.
1010
//
1111
// So we mirror the canonical Claude store into each of those per-agent dirs, but
12-
// only for agents the machine actually has (their marker dir exists). On Unix
12+
// only for agents the machine actually has (their marker dir exists). Agents
13+
// that already consume the universal ~/.agents/skills store globally (Pi) are
14+
// skipped: their universal copy is authoritative and a per-agent copy would
15+
// collide with it (#3294). On Unix
1316
// each skill is a relative symlink back into the store (one source of truth,
1417
// near-zero size, auto-fresh on update); on Windows it's a copy, because
1518
// symlinks there need admin / Developer Mode and otherwise silently dangle —
@@ -24,6 +27,22 @@ import { homedir } from "node:os";
2427
import { dirname, isAbsolute, join, relative } from "node:path";
2528
import { AGENT_GLOBAL_DIRS, type AgentDirBase } from "./agentDirs.generated.js";
2629

30+
/**
31+
* Agents that natively discover the universal `~/.agents/skills` store globally
32+
* in ADDITION to their own agent-specific directory. Mirroring into their own
33+
* dir makes every skill discoverable twice.
34+
*
35+
* Pi is the known case (earendil-works/pi): it reads both `~/.pi/agent/skills/`
36+
* and `~/.agents/skills/` as global locations (pi's packages/coding-agent/docs/
37+
* skills.md#locations), so a mirrored entry collides with the universal copy
38+
* and Pi skips the universal one on name conflict (#3294).
39+
*
40+
* The generated table cannot carry this capability — it is a plain
41+
* (agent, base, sub) list synced from vercel-labs/skills — so the set lives
42+
* here next to the mirror logic that needs it.
43+
*/
44+
const UNIVERSAL_STORE_READERS = new Set(["pi"]);
45+
2746
export interface MirrorResult {
2847
/** The store mirrored from, or null when no global Claude store was found. */
2948
source: string | null;
@@ -128,6 +147,7 @@ export function mirrorGlobalSkills(opts: {
128147
for (const { agent, base, sub } of AGENT_GLOBAL_DIRS) {
129148
const targetDir = join(bases[base], ...sub.split("/").filter(Boolean));
130149
if (targetDir === source || targetDir === universalStore) continue; // install-owned
150+
if (UNIVERSAL_STORE_READERS.has(agent)) continue; // already reads the universal store (#3294)
131151
if (!existsSync(dirname(targetDir))) continue; // agent not installed (no marker)
132152
if (mirrorInto(targetDir, source, skills, platform)) mirrored.push({ agent, dir: targetDir });
133153
}

0 commit comments

Comments
 (0)