* Extract first paragraph as description if no front matter description
(body: string)
| 78 | * Extract first paragraph as description if no front matter description |
| 79 | */ |
| 80 | function extractFirstParagraph(body: string): string { |
| 81 | const lines = body.split('\n'); |
| 82 | let inParagraph = false; |
| 83 | let paragraph = ''; |
| 84 | |
| 85 | for (const line of lines) { |
| 86 | const trimmed = line.trim(); |
| 87 | |
| 88 | if (trimmed.startsWith('#')) { |
| 89 | if (inParagraph) break; |
| 90 | continue; |
| 91 | } |
| 92 | |
| 93 | if (!trimmed && !inParagraph) continue; |
| 94 | |
| 95 | if (trimmed && !inParagraph) { |
| 96 | inParagraph = true; |
| 97 | paragraph = trimmed; |
| 98 | continue; |
| 99 | } |
| 100 | |
| 101 | if (trimmed && inParagraph) { |
| 102 | paragraph += ' ' + trimmed; |
| 103 | continue; |
| 104 | } |
| 105 | |
| 106 | if (!trimmed && inParagraph) break; |
| 107 | } |
| 108 | |
| 109 | return paragraph || 'No description available'; |
| 110 | } |
| 111 | |
| 112 | /** |
| 113 | * Count files in a skill folder (excluding hidden files) |