| 67 | * Returns skill names and their children for file counting. |
| 68 | */ |
| 69 | export function findSkillDirs(tree: PackageFileTree[]): SkillDirInfo[] { |
| 70 | const skillsDir = tree.find(node => node.type === 'directory' && node.name === 'skills') |
| 71 | if (!skillsDir?.children) return [] |
| 72 | |
| 73 | return skillsDir.children |
| 74 | .filter( |
| 75 | child => |
| 76 | child.type === 'directory' && |
| 77 | child.children?.some(f => f.type === 'file' && f.name === 'SKILL.md'), |
| 78 | ) |
| 79 | .map(child => ({ name: child.name, children: child.children || [] })) |
| 80 | } |
| 81 | |
| 82 | const countFilesRecursive = (nodes: PackageFileTree[]): number => |
| 83 | nodes.reduce((acc, n) => acc + (n.type === 'file' ? 1 : countFilesRecursive(n.children || [])), 0) |