* Count files in a skill folder (excluding hidden files)
(skillPath: string)
| 113 | * Count files in a skill folder (excluding hidden files) |
| 114 | */ |
| 115 | function countFiles(skillPath: string): { count: number; files: string[] } { |
| 116 | try { |
| 117 | const files: string[] = []; |
| 118 | |
| 119 | function scanDir(dir: string, prefix: string = '') { |
| 120 | const entries = fs.readdirSync(dir, { withFileTypes: true }); |
| 121 | for (const entry of entries) { |
| 122 | if (entry.name.startsWith('.')) continue; |
| 123 | const relativePath = prefix ? `${prefix}/${entry.name}` : entry.name; |
| 124 | if (entry.isDirectory()) { |
| 125 | scanDir(path.join(dir, entry.name), relativePath); |
| 126 | } else { |
| 127 | files.push(relativePath); |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | scanDir(skillPath); |
| 133 | return { count: files.length, files }; |
| 134 | } catch { |
| 135 | return { count: 0, files: [] }; |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Parse a single skill from its directory |