summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/skills-core.js33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/skills-core.js b/lib/skills-core.js
index ce9c0ef..c77c26f 100644
--- a/lib/skills-core.js
+++ b/lib/skills-core.js
@@ -169,9 +169,40 @@ function checkForUpdates(repoDir) {
}
}
+/**
+ * Strip YAML frontmatter from skill content, returning just the content.
+ *
+ * @param {string} content - Full content including frontmatter
+ * @returns {string} - Content without frontmatter
+ */
+function stripFrontmatter(content) {
+ const lines = content.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);
+ }
+ }
+
+ return contentLines.join('\n').trim();
+}
+
module.exports = {
extractFrontmatter,
findSkillsInDir,
resolveSkillPath,
- checkForUpdates
+ checkForUpdates,
+ stripFrontmatter
};