From 3ba999ba1fce0758e37b2e1ea4b398ce5ecddebf Mon Sep 17 00:00:00 2001 From: zerone0x Date: Sun, 15 Feb 2026 12:45:26 +0100 Subject: [PATCH] fix: remove existing skill directory before overwrite to prevent EEXIST error When user confirms overwriting an existing skill, cpSync fails with EEXIST because the destination directory already exists. This fix removes the existing directory before copying in all three install paths: - installSingleLocalSkill - installSpecificSkill - installFromRepo Fixes #73 Co-Authored-By: Claude --- src/commands/install.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/commands/install.ts b/src/commands/install.ts index b4c015e..d0b0bed 100644 --- a/src/commands/install.ts +++ b/src/commands/install.ts @@ -259,6 +259,10 @@ async function installSingleLocalSkill( process.exit(1); } + // Remove existing skill directory before copying (handles overwrite case) + if (existsSync(targetPath)) { + rmSync(targetPath, { recursive: true, force: true }); + } cpSync(skillDir, targetPath, { recursive: true, dereference: true }); writeSkillMetadata(targetPath, buildLocalMetadata(sourceInfo, skillDir)); @@ -308,6 +312,10 @@ async function installSpecificSkill( console.error(chalk.red(`Security error: Installation path outside target directory`)); process.exit(1); } + // Remove existing skill directory before copying (handles overwrite case) + if (existsSync(targetPath)) { + rmSync(targetPath, { recursive: true, force: true }); + } cpSync(skillDir, targetPath, { recursive: true, dereference: true }); writeSkillMetadata(targetPath, buildGitMetadata(sourceInfo, skillSubpath)); @@ -472,6 +480,10 @@ async function installFromRepo( console.error(chalk.red(`Security error: Installation path outside target directory`)); continue; } + // Remove existing skill directory before copying (handles overwrite case) + if (existsSync(info.targetPath)) { + rmSync(info.targetPath, { recursive: true, force: true }); + } cpSync(info.skillDir, info.targetPath, { recursive: true, dereference: true }); writeSkillMetadata(info.targetPath, buildMetadataFromSource(sourceInfo, info.skillDir, repoDir));