fix: install standalone .md skills by wrapping in a directory

Standalone .md skills (e.g. doc_explanation.md) were copied as plain
files, then saveSkillMetadata tried to write .skillkit.json inside
them causing ENOTDIR. Now detects file sources via statSync and
creates a directory with SKILL.md inside instead.
This commit is contained in:
Rohit Ghumare
2026-04-10 21:44:02 +01:00
parent 16d00a8ec9
commit 7160dfddf2
+8 -1
View File
@@ -4,6 +4,7 @@ import {
cpSync,
rmSync,
symlinkSync,
statSync,
readFileSync,
writeFileSync,
} from "node:fs";
@@ -499,7 +500,13 @@ export class InstallCommand extends Command {
if (useSymlink && primaryPath) {
symlinkSync(primaryPath, targetPath, "dir");
} else {
cpSync(sourcePath, targetPath, { recursive: true, dereference: true });
const isStandaloneFile = statSync(sourcePath).isFile();
if (isStandaloneFile) {
mkdirSync(targetPath, { recursive: true });
cpSync(sourcePath, join(targetPath, "SKILL.md"));
} else {
cpSync(sourcePath, targetPath, { recursive: true, dereference: true });
}
if (isSymlinkMode && primaryPath === null) {
primaryPath = targetPath;
}