fix(skill): support YAML array format for allowed-tools field (#1163)
Fixes #1021 The allowed-tools field in skill frontmatter now supports both formats: - Space-separated string: 'allowed-tools: Read Write Edit Bash' - YAML array: 'allowed-tools: [Read, Write, Edit, Bash]' - Multi-line YAML array format also works Previously, skills using YAML array format would silently fail to parse, causing them to not appear in the <available_skills> list. Changes: - Updated parseAllowedTools() in loader.ts, async-loader.ts, and merger.ts to handle both string and string[] types - Updated SkillMetadata type to accept string | string[] for allowed-tools - Added 4 test cases covering all allowed-tools formats
This commit is contained in:
@@ -50,8 +50,15 @@ async function loadMcpJsonFromDir(skillDir: string): Promise<SkillMcpConfig | un
|
||||
return undefined
|
||||
}
|
||||
|
||||
function parseAllowedTools(allowedTools: string | undefined): string[] | undefined {
|
||||
function parseAllowedTools(allowedTools: string | string[] | undefined): string[] | undefined {
|
||||
if (!allowedTools) return undefined
|
||||
|
||||
// Handle YAML array format: already parsed as string[]
|
||||
if (Array.isArray(allowedTools)) {
|
||||
return allowedTools.map(t => t.trim()).filter(Boolean)
|
||||
}
|
||||
|
||||
// Handle space-separated string format: "Read Write Edit Bash"
|
||||
return allowedTools.split(/\s+/).filter(Boolean)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user