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:
@@ -324,7 +324,19 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
||||
const requestedName = args.name.replace(/^\//, "")
|
||||
|
||||
// Check skills first (exact match, case-insensitive)
|
||||
const matchedSkill = skills.find(s => s.name.toLowerCase() === requestedName.toLowerCase())
|
||||
let matchedSkill = skills.find(s => s.name.toLowerCase() === requestedName.toLowerCase())
|
||||
|
||||
// Fallback: try matching by short name (basename) for namespaced skills
|
||||
// e.g. "systematic-debugging" matches "superpowers/systematic-debugging"
|
||||
if (!matchedSkill) {
|
||||
const shortNameMatches = skills.filter(s => {
|
||||
const parts = s.name.split("/")
|
||||
return parts.length > 1 && parts[parts.length - 1].toLowerCase() === requestedName.toLowerCase()
|
||||
})
|
||||
if (shortNameMatches.length === 1) {
|
||||
matchedSkill = shortNameMatches[0]
|
||||
}
|
||||
}
|
||||
|
||||
if (matchedSkill) {
|
||||
if (matchedSkill.definition.agent && (!ctx?.agent || matchedSkill.definition.agent !== ctx.agent)) {
|
||||
|
||||
Reference in New Issue
Block a user