An agentic skills framework & software development methodology that works.
feat: add skill discovery function to core module
Jesse Vincent536fd24603bd
diff --git a/lib/skills-core.js b/lib/skills-core.jsindex 886294304..113627a65 100644--- a/lib/skills-core.js+++ b/lib/skills-core.js@@ -1,4 +1,5 @@const fs = require('fs');+const path = require('path');/*** Extract YAML frontmatter from a skill file.@@ -49,6 +50,52 @@ function extractFrontmatter(filePath) {}}+/**+ * Find all SKILL.md files in a directory recursively.+ *+ * @param {string} dir - Directory to search+ * @param {string} sourceType - 'personal' or 'superpowers' for namespacing+ * @param {number} maxDepth - Maximum recursion depth (default: 3)+ * @returns {Array<{path: string, name: string, description: string, sourceType: string}>}+ */+function findSkillsInDir(dir, sourceType, maxDepth = 3) {+ const skills = [];++ if (!fs.existsSync(dir)) return skills;++ function recurse(currentDir, depth) {+ if (depth > maxDepth) return;++ const entries = fs.readdirSync(currentDir, { withFileTypes: true });++ for (const entry of entries) {+ const fullPath = path.join(currentDir, entry.name);++ if (entry.isDirectory()) {+ // Check for SKILL.md in this directory+ const skillFile = path.join(fullPath, 'SKILL.md');+ if (fs.existsSync(skillFile)) {+ const { name, description } = extractFrontmatter(skillFile);+ skills.push({+ path: fullPath,+ skillFile: skillFile,+ name: name || entry.name,+ description: description || '',+ sourceType: sourceType+ });+ }++ // Recurse into subdirectories+ recurse(fullPath, depth + 1);+ }+ }+ }++ recurse(dir, 0);+ return skills;+}+module.exports = {- extractFrontmatter+ extractFrontmatter,+ findSkillsInDir};