From 2d04b431bb2c7299808f4dea762afbfd9685218d Mon Sep 17 00:00:00 2001 From: John Siracusa Date: Mon, 16 Nov 2026 19:46:53 -0500 Subject: [PATCH 1/2] fix(core): skip unreadable skills instead of failing the machine scan readAdapterSkills read each SKILL.md and its capsule with no catch, so one refused file aborted importMachine. The desktop onboarding scan hit this on a SKILL.md symlinked outside the Tauri fs scope ("forbidden path"), and an oversized skill capsule throws the same way. Each such skill is now reported in the fragment's skipped list (surfaced in findings) and the scan continues. Co-Authored-By: Claude Opus 5.5 --- .../__tests__/import-unreadable-skill.test.ts | 57 +++++++++++++++++++ packages/core/src/import/read-skills.ts | 28 +++++++-- 2 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 packages/core/__tests__/import-unreadable-skill.test.ts diff --git a/packages/core/__tests__/import-unreadable-skill.test.ts b/packages/core/__tests__/import-unreadable-skill.test.ts new file mode 100644 index 00000000..00e6e7ec --- /dev/null +++ b/packages/core/__tests__/import-unreadable-skill.test.ts @@ -0,0 +1,57 @@ +import { describe, it, expect } from "vitest"; +import { importMachine } from "../src/import/import-project.js"; +import { readAdapterSkills } from "../src/import/read-skills.js"; +import { MockFsProvider } from "./helpers/mock-fs.js"; + +const HOME = "/home/user"; +const BLOCKED = `${HOME}/.claude/skills/linked/SKILL.md`; + +/** + * A reader that refuses one file the way Tauri's fs scope does for a symlinked + * SKILL.md whose target lies outside the capability scope. + */ +class OneForbiddenFile extends MockFsProvider { + async readFile(path: string): Promise { + if (path === BLOCKED) { + throw new Error(`forbidden path: ${path}, maybe it is not allowed on the scope`); + } + return super.readFile(path); + } +} + +function machine(): OneForbiddenFile { + return new OneForbiddenFile( + { + [`${HOME}/CLAUDE.md`]: "# Global instructions\n", + [`${HOME}/.claude/skills/alpha/SKILL.md`]: "---\nname: alpha\n---\nAlpha body\n", + [BLOCKED]: "---\nname: linked\n---\nUnreachable\n", + [`${HOME}/.claude/skills/zeta/SKILL.md`]: "---\nname: zeta\n---\nZeta body\n", + }, + HOME, + HOME, + ); +} + +describe("machine scan with an unreadable skill file", () => { + it("keeps the readable skills and reports the unreadable one as skipped", async () => { + const fragment = await readAdapterSkills(machine(), HOME, "claude-code"); + + expect(fragment?.skills?.skills.map((skill) => skill.name)).toEqual(["alpha", "zeta"]); + expect(fragment?.skipped).toEqual([ + { file: ".claude/skills/linked/SKILL.md", reason: expect.stringContaining("forbidden path") }, + ]); + }); + + it("completes importMachine instead of rejecting, and surfaces the skip in findings", async () => { + const result = await importMachine({ fs: machine() }); + + const claudeCode = result.findings.adapters.find((adapter) => adapter.adapter === "claude-code")!; + expect(claudeCode.skipped).toContainEqual({ + file: ".claude/skills/linked/SKILL.md", + reason: expect.stringContaining("forbidden path"), + }); + expect(result.harnessYaml).toContain("alpha"); + expect(result.harnessYaml).toContain("zeta"); + expect(result.harnessYaml).not.toContain("linked"); + }); +}); diff --git a/packages/core/src/import/read-skills.ts b/packages/core/src/import/read-skills.ts index 86d8fb27..965894d5 100644 --- a/packages/core/src/import/read-skills.ts +++ b/packages/core/src/import/read-skills.ts @@ -68,6 +68,7 @@ export async function readAdapterSkills( adapter: AdapterId, ): Promise { const skills: ImportedSkillRef[] = []; + const skipped: Array<{ file: string; reason: string }> = []; const seen = new Set(); const personal = projectRoot === (await fs.homedir()); const directories = personal ? GLOBAL_SKILL_DIRS[adapter] : PROJECT_SKILL_DIRS[adapter]; @@ -76,11 +77,21 @@ export async function readAdapterSkills( const root = fs.joinPath(projectRoot, directory); if (!(await fs.exists(root))) continue; for (const file of (await findSkillFiles(root, fs, 8)).sort()) { - const content = await fs.readFile(file); const relative = relativeTo(projectRoot, file); + // One unreadable skill must not abort the scan. The desktop fs scope + // refuses a SKILL.md symlinked outside it ("forbidden path"), and a + // capsule over the size limits throws too; report the skill as skipped. + let content: string; + let directoryFiles: Awaited>; + try { + content = await fs.readFile(file); + directoryFiles = await collectCapsuleFiles(fs, dirname(file)); + } catch (error) { + const reason = error instanceof Error ? error.message : String(error); + skipped.push({ file: relative, reason: `could not read skill: ${reason}` }); + continue; + } const name = frontmatterName(content, dirname(relative).split("/").pop() ?? "skill"); - const sourceRoot = dirname(file); - const directoryFiles = await collectCapsuleFiles(fs, sourceRoot); const digest = skillDirectoryDigest(directoryFiles.map((entry) => ({ path: entry.path, digest: computeFileHash(entry.content), @@ -100,7 +111,12 @@ export async function readAdapterSkills( } } - return skills.length - ? { domain: "skills", config: {}, warnings: [], skills: { skills } } - : null; + if (!skills.length && !skipped.length) return null; + return { + domain: "skills", + config: {}, + warnings: [], + ...(skills.length ? { skills: { skills } } : {}), + ...(skipped.length ? { skipped } : {}), + }; } From 0aaf414e7af25a4ae30bd4a8111820e9e655cbff Mon Sep 17 00:00:00 2001 From: John Siracusa Date: Mon, 16 Nov 2026 19:57:58 -0500 Subject: [PATCH 2/2] test(desktop): stop SyncPage palette test racing command registration The AC-21 test read the palette's Preview option synchronously after the directory check rendered; under a loaded run the command registers a tick later and the query failed. vi.clearAllMocks also leaves queued mockResolvedValueOnce values in place, so that one failure fed stale compile results to the next four tests. Await the option and reset the compile and detectPlatforms mocks in beforeEach. Co-Authored-By: Claude Opus 5.5 --- .../src/pages/harness/__tests__/SyncPage.test.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/desktop/src/pages/harness/__tests__/SyncPage.test.tsx b/apps/desktop/src/pages/harness/__tests__/SyncPage.test.tsx index 58674820..b9e07ac9 100644 --- a/apps/desktop/src/pages/harness/__tests__/SyncPage.test.tsx +++ b/apps/desktop/src/pages/harness/__tests__/SyncPage.test.tsx @@ -93,6 +93,11 @@ function renderPage() { describe("SyncPage", () => { beforeEach(() => { vi.clearAllMocks(); + // clearAllMocks keeps queued mock*Once values; a test that fails before + // using its own would hand them to the next test. mockReset drops the + // queue and restores the factory implementation. + vi.mocked(compile).mockReset(); + vi.mocked(detectPlatforms).mockReset(); projectHarness = 'version: "1"'; mockReadHarnessFile.mockResolvedValue({ found: false, content: null, path: null }); mockSyncFileExists.mockResolvedValue(false); @@ -202,7 +207,9 @@ describe("SyncPage", () => { ); const palette = () => within(screen.getByRole("dialog", { name: "Command palette" })); await screen.findByText(/Directory found/i); - const preview = palette().getByRole("option", { name: "Preview compile changes" }); + // SyncPage registers its commands in an effect, which can land after the + // directory check renders. + const preview = await palette().findByRole("option", { name: "Preview compile changes" }); await waitFor(() => expect(preview).not.toHaveAttribute("aria-disabled")); expect(palette().queryByRole("option", { name: /Apply/ })).not.toBeInTheDocument();