Look for assets in subdirectories

Fixes #503.

When running `npm start` the README.skills.md file will be updated to
include any newly-added skills. This includes the name and description
from the skill's frontmatter, but also a list of assets in the skill--
that is, files other than SKILL.md.

However, the code in yaml-parser.mjs to enumerate the asset files only
looks in the immediate skill directory, not any subdirectories. Those
files will be missing from README.skills.md.

Here we update yaml-parser.mjs to recurse through the subdirectories as
well.
This commit is contained in:
Tom Meschter (from Dev Box)
2025-12-19 13:25:18 -08:00
parent c3913bc6db
commit d688be1b0b

View File

@@ -161,14 +161,26 @@ function parseSkillMetadata(skillPath) {
return null; return null;
} }
// List bundled assets (all files except SKILL.md) // List bundled assets (all files except SKILL.md), recursing through subdirectories
const assets = fs const getAllFiles = (dirPath, arrayOfFiles = []) => {
.readdirSync(skillPath) const files = fs.readdirSync(dirPath);
.filter((file) => {
const filePath = path.join(skillPath, file); files.forEach((file) => {
return file !== "SKILL.md" && fs.statSync(filePath).isFile(); const filePath = path.join(dirPath, file);
}) if (fs.statSync(filePath).isDirectory()) {
.sort(); arrayOfFiles = getAllFiles(filePath, arrayOfFiles);
} else {
const relativePath = path.relative(skillPath, filePath);
if (relativePath !== "SKILL.md") {
arrayOfFiles.push(relativePath);
}
}
});
return arrayOfFiles;
};
const assets = getAllFiles(skillPath).sort();
return { return {
name: frontmatter.name, name: frontmatter.name,