Skip to content

Commit 3f1d2e1

Browse files
committed
perf: hoist skill file counting function
1 parent 05ccbe8 commit 3f1d2e1

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

server/utils/skills.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,14 @@ export function findSkillDirs(tree: PackageFileTree[]): SkillDirInfo[] {
8888
.map(child => ({ name: child.name, children: child.children || [] }))
8989
}
9090

91+
const countFilesRecursive = (nodes: PackageFileTree[]): number =>
92+
nodes.reduce((acc, n) => acc + (n.type === 'file' ? 1 : countFilesRecursive(n.children || [])), 0)
93+
9194
/**
9295
* Count files in skill subdirectories (scripts, references, assets).
9396
*/
9497
export function countSkillFiles(children: PackageFileTree[]): SkillFileCounts | undefined {
9598
const counts: SkillFileCounts = {}
96-
const countFilesRecursive = (nodes: PackageFileTree[]): number =>
97-
nodes.reduce(
98-
(acc, n) => acc + (n.type === 'file' ? 1 : countFilesRecursive(n.children || [])),
99-
0,
100-
)
10199

102100
for (const child of children) {
103101
if (child.type !== 'directory') continue

0 commit comments

Comments
 (0)