From 99cfbeb66d7ec8894454ae11bbd7271629e1f2ac Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Mon, 23 Mar 2026 22:29:40 -0700 Subject: [PATCH] fix: skip symlinks in copyDirSync to prevent infinite recursion Adversarial review caught that .claude/skills/gstack may be a symlink back to the repo root, causing copyDirSync to recurse infinitely when copying gitignored artifacts into worktrees. Co-Authored-By: Claude Opus 4.6 --- lib/worktree.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/worktree.ts b/lib/worktree.ts index 07906573..2337399f 100644 --- a/lib/worktree.ts +++ b/lib/worktree.ts @@ -39,6 +39,8 @@ export interface HarvestResult { function copyDirSync(src: string, dest: string): void { fs.mkdirSync(dest, { recursive: true }); for (const entry of fs.readdirSync(src, { withFileTypes: true })) { + // Skip symlinks to avoid infinite recursion (e.g., .claude/skills/gstack → repo root) + if (entry.isSymbolicLink()) continue; const srcPath = path.join(src, entry.name); const destPath = path.join(dest, entry.name); if (entry.isDirectory()) {