* Parse paths frontmatter from a skill, using the same format as CLAUDE.md rules. * Returns undefined if no paths are specified or if all patterns are match-all.
(frontmatter: FrontmatterData)
| 157 | * Returns undefined if no paths are specified or if all patterns are match-all. |
| 158 | */ |
| 159 | function parseSkillPaths(frontmatter: FrontmatterData): string[] | undefined { |
| 160 | if (!frontmatter.paths) { |
| 161 | return undefined |
| 162 | } |
| 163 | |
| 164 | const patterns = splitPathInFrontmatter(frontmatter.paths) |
| 165 | .map(pattern => { |
| 166 | // Remove /** suffix - ignore library treats 'path' as matching both |
| 167 | // the path itself and everything inside it |
| 168 | return pattern.endsWith('/**') ? pattern.slice(0, -3) : pattern |
| 169 | }) |
| 170 | .filter((p: string) => p.length > 0) |
| 171 | |
| 172 | // If all patterns are ** (match-all), treat as no paths (undefined) |
| 173 | if (patterns.length === 0 || patterns.every((p: string) => p === '**')) { |
| 174 | return undefined |
| 175 | } |
| 176 | |
| 177 | return patterns |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Parses all skill frontmatter fields that are shared between file-based and |
no test coverage detected