diff options
| author | Jesse Vincent <jesse@fsck.com> | 2025-11-22 12:41:58 -0800 |
|---|---|---|
| committer | Jesse Vincent <jesse@fsck.com> | 2025-11-22 12:41:58 -0800 |
| commit | 4eab16380b65cd4aef0e586556e7a41999b7284a (patch) | |
| tree | 8a0ae37fac7b276ff83d07bd270925d0a4040718 /.opencode/plugin | |
| parent | 7ffff619650a83b4994f64fd452cd69636fc85c0 (diff) | |
refactor: extract frontmatter stripping to shared helper function
Diffstat (limited to '.opencode/plugin')
| -rw-r--r-- | .opencode/plugin/superpowers.js | 47 |
1 files changed, 2 insertions, 45 deletions
diff --git a/.opencode/plugin/superpowers.js b/.opencode/plugin/superpowers.js index fb28ed3..ee4353f 100644 --- a/.opencode/plugin/superpowers.js +++ b/.opencode/plugin/superpowers.js @@ -34,29 +34,7 @@ module.exports = async ({ project, client, $, directory, worktree }) => { const fullContent = fs.readFileSync(resolved.skillFile, 'utf8'); const { name, description } = skillsCore.extractFrontmatter(resolved.skillFile); - - // Extract content after frontmatter - const lines = fullContent.split('\n'); - let inFrontmatter = false; - let frontmatterEnded = false; - const contentLines = []; - - for (const line of lines) { - if (line.trim() === '---') { - if (inFrontmatter) { - frontmatterEnded = true; - continue; - } - inFrontmatter = true; - continue; - } - - if (frontmatterEnded || !inFrontmatter) { - contentLines.push(line); - } - } - - const content = contentLines.join('\n').trim(); + const content = skillsCore.stripFrontmatter(fullContent); const skillDirectory = path.dirname(resolved.skillFile); return `# ${name || skill_name} @@ -104,28 +82,7 @@ ${content}`; let usingSuperpowersContent = ''; if (usingSuperpowersPath) { const fullContent = fs.readFileSync(usingSuperpowersPath.skillFile, 'utf8'); - // Strip frontmatter - const lines = fullContent.split('\n'); - let inFrontmatter = false; - let frontmatterEnded = false; - const contentLines = []; - - for (const line of lines) { - if (line.trim() === '---') { - if (inFrontmatter) { - frontmatterEnded = true; - continue; - } - inFrontmatter = true; - continue; - } - - if (frontmatterEnded || !inFrontmatter) { - contentLines.push(line); - } - } - - usingSuperpowersContent = contentLines.join('\n').trim(); + usingSuperpowersContent = skillsCore.stripFrontmatter(fullContent); } const toolMapping = ` |
