From ba09309d5b7ec6c313b250acd966c444ad4a49f4 Mon Sep 17 00:00:00 2001 From: Rohit Ghumare <48523873+rohitg00@users.noreply.github.com> Date: Fri, 10 Apr 2026 21:51:30 +0100 Subject: [PATCH] fix: compute standalone file target path once, use everywhere Move isStandaloneFile detection and .md suffix normalization before the existence/force/symlink checks so all code paths use the same effective target path. Fixes --force not detecting previously installed standalone skills and symlinks pointing to the wrong filename. --- packages/cli/src/commands/install.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/cli/src/commands/install.ts b/packages/cli/src/commands/install.ts index 09166096..f5b223c4 100644 --- a/packages/cli/src/commands/install.ts +++ b/packages/cli/src/commands/install.ts @@ -472,7 +472,10 @@ export class InstallCommand extends Command { mkdirSync(installDir, { recursive: true }); } - const targetPath = join(installDir, skillName); + const isStandaloneFile = statSync(sourcePath).isFile(); + const targetPath = isStandaloneFile + ? join(installDir, skillName.endsWith(".md") ? skillName : `${skillName}.md`) + : join(installDir, skillName); if (existsSync(targetPath) && !this.force) { if (!this.quiet) { @@ -497,21 +500,16 @@ export class InstallCommand extends Command { rmSync(targetPath, { recursive: true, force: true }); } - const isStandaloneFile = statSync(sourcePath).isFile(); - if (useSymlink && primaryPath) { symlinkSync(primaryPath, targetPath, isStandaloneFile ? "file" : "dir"); } else { if (isStandaloneFile) { - const fileDest = targetPath.endsWith(".md") ? targetPath : `${targetPath}.md`; - cpSync(sourcePath, fileDest); + cpSync(sourcePath, targetPath); } else { cpSync(sourcePath, targetPath, { recursive: true, dereference: true }); } if (isSymlinkMode && primaryPath === null) { - primaryPath = isStandaloneFile - ? (targetPath.endsWith(".md") ? targetPath : `${targetPath}.md`) - : targetPath; + primaryPath = targetPath; } if (!isStandaloneFile) {