fix(tools/skill): harden description pipeline against empty skill list after lazy factory

This commit is contained in:
Sisyphus
2026-04-18 14:57:44 +09:00
parent 0e1a946c1d
commit 8e3f4cc63c
3 changed files with 120 additions and 60 deletions
+7 -4
View File
@@ -38,14 +38,17 @@ function formatSlashCommand(command: CommandInfo): string {
return lines.join("\n")
}
export function formatCombinedDescription(skills: SkillInfo[], commands: CommandInfo[]): string {
if (skills.length === 0 && commands.length === 0) {
export function formatCombinedDescription(skills?: SkillInfo[], commands?: CommandInfo[]): string {
const availableSkills = skills ?? []
const availableCommands = commands ?? []
if (availableSkills.length === 0 && availableCommands.length === 0) {
return TOOL_DESCRIPTION_NO_SKILLS
}
const availableItems = [
...sortByScopePriority(skills).map(formatSkillCommand),
...sortByScopePriority(commands).map(formatSlashCommand),
...sortByScopePriority(availableSkills).map(formatSkillCommand),
...sortByScopePriority(availableCommands).map(formatSlashCommand),
]
if (availableItems.length === 0) {