This commit is contained in:
梁山河 2026-03-15 10:28:46 +08:00 committed by GitHub
commit d0c6a3e997
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 0 deletions

View File

@ -686,6 +686,24 @@ LOAD and execute from: {project-root}/{{bmadFolderName}}/{{path}}
};
await fs.copy(sourceDir, skillDir, { filter });
// Rewrite relative workflow.md references to use {project-root} absolute paths.
// Some AI tools resolve relative paths from CWD instead of the skill file's
// directory, causing co-located files like workflow.md to not be found.
try {
const skillMdPath = path.join(skillDir, 'SKILL.md');
if (await fs.pathExists(skillMdPath)) {
let skillContent = await fs.readFile(skillMdPath, 'utf8');
const workflowLinkPattern = /\]\((?:\.\/)?workflow\.md\)/g;
if (workflowLinkPattern.test(skillContent)) {
const skillRelativePath = path.relative(projectDir, skillDir).split(path.sep).join('/');
skillContent = skillContent.replaceAll(/\]\((?:\.\/)?workflow\.md\)/g, `]({project-root}/${skillRelativePath}/workflow.md)`);
await fs.writeFile(skillMdPath, skillContent, 'utf8');
}
}
} catch {
// Non-fatal: skip rewrite for this skill and continue installing remaining skills
}
count++;
}