Compare commits

...

2 Commits

Author SHA1 Message Date
梁山河 a07c20a150
Merge fbe43dcdcf into 380a0af24b 2026-03-14 14:08:35 -06:00
leon fbe43dcdcf fix(installer): rewrite relative workflow.md paths in verbatim skills
Some AI tools (e.g., opencode) resolve relative markdown links from the
project root instead of the skill file's directory, causing co-located
workflow.md files to not be found. This patch rewrites (workflow.md)
references in SKILL.md to use {project-root}-prefixed absolute paths
during verbatim skill installation, consistent with template-generated
artifacts.

Fixes #1956

Made-with: Cursor
2026-03-14 15:33:57 +08:00
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++;
}