MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / parseSkillMd

Function parseSkillMd

src/skill-manager.ts:134–156  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

132}
133
134function parseSkillMd(filePath: string): InstalledSkill | null {
135 try {
136 const content = fs.readFileSync(filePath, "utf-8");
137 const frontmatterMatch = content.match(/^---\s*\n([\s\S]*?)\n---/);
138 if (!frontmatterMatch) {
139 return null;
140 }
141
142 const frontmatter = frontmatterMatch[1];
143 const name = readFrontmatterField(frontmatter, "name");
144 if (!name) {
145 return null;
146 }
147
148 return {
149 name,
150 description: readFrontmatterField(frontmatter, "description") ?? "",
151 dir: path.dirname(filePath),
152 };
153 } catch {
154 return null;
155 }
156}
157
158function readFrontmatterField(frontmatter: string, field: string): string | null {
159 const lines = frontmatter.split(/\r?\n/);

Callers 1

visitFunction · 0.85

Calls 1

readFrontmatterFieldFunction · 0.85

Tested by

no test coverage detected