diff options
| author | Jesse Vincent <jesse@fsck.com> | 2025-11-22 12:12:01 -0800 |
|---|---|---|
| committer | Jesse Vincent <jesse@fsck.com> | 2025-11-22 12:12:01 -0800 |
| commit | 5dd31b90eee8bb7008fb5da8b4adb6e14592632d (patch) | |
| tree | 3c7fca5a235c34d1a358be72b7a7034840e80515 | |
| parent | 0fbdfa3c4a6b2992ba2e4e12fbe1a559d21cdf1b (diff) | |
refactor: use shared extractFrontmatter in codex
| -rwxr-xr-x | .codex/superpowers-codex | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/.codex/superpowers-codex b/.codex/superpowers-codex index 501f983..d13c533 100755 --- a/.codex/superpowers-codex +++ b/.codex/superpowers-codex @@ -38,42 +38,6 @@ function checkForUpdates() { } } -function extractFrontmatter(filePath) { - try { - const content = fs.readFileSync(filePath, 'utf8'); - const lines = content.split('\n'); - - let inFrontmatter = false; - let name = ''; - let description = ''; - let whenToUse = ''; - - for (const line of lines) { - if (line.trim() === '---') { - if (inFrontmatter) break; - inFrontmatter = true; - continue; - } - - if (inFrontmatter) { - const match = line.match(/^(\w+):\s*(.*)$/); - if (match) { - const [, key, value] = match; - switch (key) { - case 'name': name = value.trim(); break; - case 'description': description = value.trim(); break; - case 'when_to_use': whenToUse = value.trim(); break; - } - } - } - } - - return { name, description, whenToUse }; - } catch (error) { - return { name: '', description: '', whenToUse: '' }; - } -} - function printSkill(skillPath, sourceType) { const skillFile = path.join(skillPath, 'SKILL.md'); const relPath = sourceType === 'personal' @@ -88,7 +52,7 @@ function printSkill(skillPath, sourceType) { } // Extract and print metadata - const { name, description, whenToUse } = extractFrontmatter(skillFile); + const { name, description, whenToUse } = skillsCore.extractFrontmatter(skillFile); if (description) console.log(` ${description}`); if (whenToUse) console.log(` When to use: ${whenToUse}`); @@ -308,7 +272,7 @@ function runUseSkill(skillName) { let content, frontmatter; try { const fullContent = fs.readFileSync(skillFile, 'utf8'); - const { name, description, whenToUse } = extractFrontmatter(skillFile); + const { name, description, whenToUse } = skillsCore.extractFrontmatter(skillFile); // Extract just the content after frontmatter const lines = fullContent.split('\n'); |
