fix(skill): eagerly build description for preloaded skills
This commit is contained in:
@@ -101,7 +101,7 @@ describe("skill tool - synchronous description", () => {
|
|||||||
const tool = createSkillTool({ skills: [] })
|
const tool = createSkillTool({ skills: [] })
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(tool.description).toContain("No skills are currently available")
|
expect(tool.description).toContain("No skills or commands are currently available")
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -171,10 +171,13 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
|||||||
return cachedDescription
|
return cachedDescription
|
||||||
}
|
}
|
||||||
|
|
||||||
// Eagerly build description if possible
|
// Eagerly build description when callers pre-provide skills/commands.
|
||||||
if (options.skills && options.commands !== undefined) {
|
if (options.skills !== undefined) {
|
||||||
const skillInfos = options.skills.map(loadedSkillToInfo)
|
const skillInfos = options.skills.map(loadedSkillToInfo)
|
||||||
cachedDescription = formatCombinedDescription(skillInfos, options.commands)
|
const commandsForDescription = options.commands ?? []
|
||||||
|
cachedDescription = formatCombinedDescription(skillInfos, commandsForDescription)
|
||||||
|
} else if (options.commands !== undefined) {
|
||||||
|
cachedDescription = formatCombinedDescription([], options.commands)
|
||||||
} else {
|
} else {
|
||||||
void buildDescription()
|
void buildDescription()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user