(filePath: string)
| 132 | } |
| 133 | |
| 134 | function 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 | |
| 158 | function readFrontmatterField(frontmatter: string, field: string): string | null { |
| 159 | const lines = frontmatter.split(/\r?\n/); |
no test coverage detected