Skip to content

Commit 3067196

Browse files
riku99Riku KurosawaLadyBluenotes
authored
Fix/discover nested skills without parent skillmd (#109)
* fix(intent): discover skills under intermediate dirs without SKILL.md The recursive walk in discoverSkills only descended into directories that contained a SKILL.md, so skills nested under grouping directories (dirs without their own SKILL.md) were silently skipped. Move the walk(childDir) call outside the SKILL.md existence check so the traversal always recurses into subdirectories. * chore: add changeset for nested skill discovery fix --------- Co-authored-by: Riku Kurosawa <riku@RikunoMacBook-Pro.local> Co-authored-by: Sarah Gerrard <gerrardsarah@gmail.com>
1 parent b2164ff commit 3067196

5 files changed

Lines changed: 54 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/intent': patch
3+
---
4+
5+
Fix skill discovery so skills nested under intermediate grouping directories (directories without their own SKILL.md) are found by the scanner.

packages/intent/src/library-scanner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,10 @@ function discoverSkills(skillsDir: string): Array<SkillEntry> {
9393
framework:
9494
typeof fm?.framework === 'string' ? fm.framework : undefined,
9595
})
96-
walk(childDir)
9796
}
97+
// Always recurse into subdirectories so skills nested under
98+
// intermediate grouping directories (dirs without SKILL.md) are found.
99+
walk(childDir)
98100
}
99101
}
100102

packages/intent/src/scanner.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,10 @@ function discoverSkills(
170170
framework:
171171
typeof fm?.framework === 'string' ? fm.framework : undefined,
172172
})
173-
// Recurse for sub-skills
174-
walk(childDir)
175173
}
174+
// Always recurse into subdirectories so skills nested under
175+
// intermediate grouping directories (dirs without SKILL.md) are found.
176+
walk(childDir)
176177
}
177178
}
178179

packages/intent/tests/library-scanner.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,28 @@ describe('scanLibrary', () => {
310310
expect(names).toContain('routing/nested-routes')
311311
})
312312

313+
it('discovers skills nested under intermediate dirs without SKILL.md', () => {
314+
const pkgDir = createDir(root, 'node_modules', '@tanstack', 'router')
315+
writeJson(join(pkgDir, 'package.json'), {
316+
name: '@tanstack/router',
317+
version: '1.0.0',
318+
keywords: ['tanstack-intent'],
319+
})
320+
// intermediate directory has no SKILL.md
321+
const groupDir = createDir(pkgDir, 'skills', 'group')
322+
const nestedDir = createDir(groupDir, 'nested-skill')
323+
writeSkillMd(nestedDir, {
324+
name: 'group/nested-skill',
325+
description: 'A nested skill under a grouping dir',
326+
})
327+
328+
const result = scanLibrary(scriptPath(pkgDir), root)
329+
330+
const skills = result.packages[0]!.skills
331+
expect(skills).toHaveLength(1)
332+
expect(skills[0]!.name).toBe('group/nested-skill')
333+
})
334+
313335
it('handles missing package name without producing double slashes in paths', () => {
314336
const pkgDir = createDir(root, 'node_modules', 'no-name-pkg')
315337
writeJson(join(pkgDir, 'package.json'), {

packages/intent/tests/scanner.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,27 @@ describe('scanForIntents', () => {
186186
expect(names).toContain('db-core/live-queries')
187187
})
188188

189+
it('discovers skills nested under intermediate dirs without SKILL.md', () => {
190+
const pkgDir = createDir(root, 'node_modules', '@tanstack', 'db')
191+
writeJson(join(pkgDir, 'package.json'), {
192+
name: '@tanstack/db',
193+
version: '0.5.2',
194+
intent: { version: 1, repo: 'TanStack/db', docs: 'docs/' },
195+
})
196+
// intermediate directory has no SKILL.md
197+
const groupDir = createDir(pkgDir, 'skills', 'group')
198+
const nestedDir = createDir(groupDir, 'nested-skill')
199+
writeSkillMd(nestedDir, {
200+
name: 'group/nested-skill',
201+
description: 'A nested skill under a grouping dir',
202+
})
203+
204+
const result = scanForIntents(root)
205+
expect(result.packages).toHaveLength(1)
206+
expect(result.packages[0]!.skills).toHaveLength(1)
207+
expect(result.packages[0]!.skills[0]!.name).toBe('group/nested-skill')
208+
})
209+
189210
it('warns on skills/ dir without valid intent field', () => {
190211
const pkgDir = createDir(root, 'node_modules', 'bad-pkg')
191212
writeJson(join(pkgDir, 'package.json'), {

0 commit comments

Comments
 (0)