Fix: factory transformer was not copying skill scripts to dist

The refactored factory.js transformer dropped script file support that
existed in the old shared.js version. Scripts were read from source
but never written to dist/, so npx skills installed skills without the
cleanup-deprecated.mjs script, causing errors on first load.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Paul Bakaus
2026-04-10 09:43:50 -07:00
co-authored by Claude Opus 4.6
parent 68ae6235ce
commit c2b72b9d44
23 changed files with 2382 additions and 12 deletions
+17 -1
View File
@@ -67,6 +67,7 @@ export function createTransformer(config) {
.map((s) => `${prefix}${s.name}`);
let refCount = 0;
let scriptCount = 0;
for (const skill of skills) {
const skillName = `${prefix}${skill.name}`;
@@ -89,6 +90,10 @@ export function createTransformer(config) {
// Build body
const cmdPrefix = (PROVIDER_PLACEHOLDERS[placeholderKey] || {}).command_prefix || '/';
let skillBody = replacePlaceholders(skill.body, placeholderKey, commandNames, allSkillNames);
// Replace {{scripts_path}} with provider-aware path to skill's scripts directory
const scriptsPath = `${configDir}/skills/${skillName}/scripts`;
skillBody = skillBody.replace(/\{\{scripts_path\}\}/g, scriptsPath);
if (prefix) skillBody = prefixSkillReferences(skillBody, prefix, allSkillNames, cmdPrefix);
if (bodyTransform) skillBody = bodyTransform(skillBody, skill);
@@ -105,11 +110,22 @@ export function createTransformer(config) {
refCount++;
}
}
// Copy script files
if (skill.scripts && skill.scripts.length > 0) {
const scriptsOutDir = path.join(skillDir, 'scripts');
ensureDir(scriptsOutDir);
for (const script of skill.scripts) {
writeFile(path.join(scriptsOutDir, script.name), script.content);
scriptCount++;
}
}
}
const userInvocableCount = skills.filter((s) => s.userInvocable).length;
const refInfo = refCount > 0 ? ` (${refCount} reference files)` : '';
const scriptInfo = scriptCount > 0 ? ` (${scriptCount} script files)` : '';
const prefixInfo = prefix ? ` [${prefix}prefixed]` : '';
console.log(`${displayName}${prefixInfo}: ${skills.length} skills (${userInvocableCount} user-invocable)${refInfo}`);
console.log(`${displayName}${prefixInfo}: ${skills.length} skills (${userInvocableCount} user-invocable)${refInfo}${scriptInfo}`);
};
}