fix(skill): resolve namespaced skills by short name
When a skill has a namespaced name like 'superpowers/systematic-debugging', users see the short name 'systematic-debugging' in the listing but can't invoke it — the resolver only accepts exact full names. Add short-name fallback: if exact match fails, try matching the basename of namespaced skills. Only resolves when unambiguous (single match). - Exact match still takes priority - Ambiguous short names (multiple namespaces) fall through to error - 4 new tests covering all cases Fixes #2971
This commit is contained in:
@@ -670,3 +670,58 @@ describe("skill tool - nativeSkills integration", () => {
|
||||
expect(result).toContain("External plugin skill body")
|
||||
})
|
||||
})
|
||||
|
||||
describe("skill tool - short name resolution", () => {
|
||||
it("resolves namespaced skill by short name when unambiguous", async () => {
|
||||
// given
|
||||
const loadedSkills = [createMockSkill("superpowers/systematic-debugging")]
|
||||
const tool = createSkillTool({ skills: loadedSkills })
|
||||
|
||||
// when
|
||||
const result = await tool.execute({ name: "systematic-debugging" }, mockContext)
|
||||
|
||||
// then
|
||||
expect(result).toContain("superpowers/systematic-debugging")
|
||||
})
|
||||
|
||||
it("still resolves by exact full name", async () => {
|
||||
// given
|
||||
const loadedSkills = [createMockSkill("superpowers/systematic-debugging")]
|
||||
const tool = createSkillTool({ skills: loadedSkills })
|
||||
|
||||
// when
|
||||
const result = await tool.execute({ name: "superpowers/systematic-debugging" }, mockContext)
|
||||
|
||||
// then
|
||||
expect(result).toContain("superpowers/systematic-debugging")
|
||||
})
|
||||
|
||||
it("does not resolve short name when ambiguous (multiple matches)", async () => {
|
||||
// given
|
||||
const loadedSkills = [
|
||||
createMockSkill("superpowers/debugging"),
|
||||
createMockSkill("utils/debugging"),
|
||||
]
|
||||
const tool = createSkillTool({ skills: loadedSkills })
|
||||
|
||||
// when / then — should not resolve (ambiguous), should suggest both
|
||||
await expect(tool.execute({ name: "debugging" }, mockContext)).rejects.toThrow(
|
||||
"not found"
|
||||
)
|
||||
})
|
||||
|
||||
it("prefers exact match over short name match", async () => {
|
||||
// given — "debugging" exists as both exact and as part of a namespace
|
||||
const loadedSkills = [
|
||||
createMockSkill("debugging"),
|
||||
createMockSkill("superpowers/debugging"),
|
||||
]
|
||||
const tool = createSkillTool({ skills: loadedSkills })
|
||||
|
||||
// when
|
||||
const result = await tool.execute({ name: "debugging" }, mockContext)
|
||||
|
||||
// then — should match "debugging" exactly, not "superpowers/debugging"
|
||||
expect(result).toContain("## Skill: debugging")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user