Skip to content

Commit ce73339

Browse files
fix(cli): mirror skills into every installed agent on Windows (#5367)
* fix(cli): mirror skills into every installed agent on Windows * fix(cli): motion shots can overwrite their previous png on Windows
1 parent ce359d9 commit ce73339

4 files changed

Lines changed: 57 additions & 5 deletions

File tree

‎packages/cli/src/commands/motionShot.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ function pathsReferToSameFile(firstPath: string, secondPath: string): boolean {
4343
const second = resolve(secondPath);
4444
if (first === second) return true;
4545
try {
46-
const firstStat = statSync(first);
47-
const secondStat = statSync(second);
46+
const firstStat = statSync(first, { bigint: true });
47+
const secondStat = statSync(second, { bigint: true });
4848
return firstStat.dev === secondStat.dev && firstStat.ino === secondStat.ino;
4949
} catch {
5050
return false;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { afterEach, describe, expect, it, vi } from "vitest";
2+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3+
import { tmpdir } from "node:os";
4+
import { join } from "node:path";
5+
6+
// Number-mode stats report one identity for every path, as Windows file ids above 2^53 can.
7+
vi.mock("node:fs", async (importOriginal) => {
8+
const actual = await importOriginal<typeof import("node:fs")>();
9+
const statSync = ((path: string, options?: { bigint?: boolean }) =>
10+
options?.bigint
11+
? actual.statSync(path, options as never)
12+
: { ...actual.statSync(path), dev: 1, ino: 2 ** 53 }) as typeof actual.statSync;
13+
return { ...actual, statSync };
14+
});
15+
16+
const { mirrorGlobalSkills } = await import("./utils/skillsMirror.js");
17+
const { ensureShotOutputDir } = await import("./commands/motionShot.js");
18+
19+
const homes: string[] = [];
20+
afterEach(() => {
21+
for (const home of homes.splice(0)) rmSync(home, { recursive: true, force: true });
22+
});
23+
24+
describe("same-file checks on colliding number inodes", () => {
25+
it("still mirrors an agent whose dir only collides with the store in number precision", () => {
26+
const home = mkdtempSync(join(tmpdir(), "mirror-ino-"));
27+
homes.push(home);
28+
mkdirSync(join(home, ".claude", "skills", "hyperframes"), { recursive: true });
29+
writeFileSync(join(home, ".claude", "skills", "hyperframes", "SKILL.md"), "# hf\n");
30+
mkdirSync(join(home, ".config", "goose"), { recursive: true });
31+
32+
const { mirrored, skipped } = mirrorGlobalSkills({
33+
skills: ["hyperframes"],
34+
home,
35+
platform: "linux",
36+
env: {},
37+
});
38+
expect(skipped).toEqual([]);
39+
expect(mirrored.map((m) => m.agent)).toContain("goose");
40+
});
41+
42+
it("lets a rerun overwrite its previous shot next to the composition", () => {
43+
const home = mkdtempSync(join(tmpdir(), "shot-ino-"));
44+
homes.push(home);
45+
writeFileSync(join(home, "index.html"), "<html></html>");
46+
writeFileSync(join(home, "shot.png"), "png");
47+
expect(() =>
48+
ensureShotOutputDir(join(home, "shot.png"), join(home, "index.html")),
49+
).not.toThrow();
50+
});
51+
});

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,13 @@ describe("mirrorGlobalSkills", () => {
132132
installMarker(home, ".config/goose"); // goose present (XDG base)
133133
// windsurf NOT installed (no ~/.codeium/windsurf)
134134

135-
const { mirrored } = mirrorGlobalSkills({
135+
const { mirrored, skipped } = mirrorGlobalSkills({
136136
skills: ["hyperframes", "hyperframes-core"],
137137
home,
138138
platform: "linux",
139139
env: ENV,
140140
});
141+
expect(skipped).toEqual([]);
141142
const agents = mirrored.map((m) => m.agent);
142143
expect(agents).toContain("cursor");
143144
expect(agents).toContain("bob");

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ function pathsOverlap(left: string, right: string): boolean {
106106

107107
function sameExistingNode(left: string, right: string): boolean {
108108
try {
109-
const leftStat = statSync(left);
110-
const rightStat = statSync(right);
109+
const leftStat = statSync(left, { bigint: true });
110+
const rightStat = statSync(right, { bigint: true });
111111
return leftStat.dev === rightStat.dev && leftStat.ino === rightStat.ino;
112112
} catch {
113113
return false;

0 commit comments

Comments
 (0)