chore: adjust way skill dirs are whitelisted (#12026)

This commit is contained in:
Aiden Cline
2026-02-03 16:33:36 -06:00
committed by GitHub
parent 015cd404e4
commit a68fedd4a6
2 changed files with 64 additions and 3 deletions

View File

@@ -50,6 +50,7 @@ export namespace Skill {
export const state = Instance.state(async () => {
const skills: Record<string, Info> = {}
const dirs = new Set<string>()
const addSkill = async (match: string) => {
const md = await ConfigMarkdown.parse(match).catch((err) => {
@@ -75,6 +76,8 @@ export namespace Skill {
})
}
dirs.add(path.dirname(match))
skills[parsed.data.name] = {
name: parsed.data.name,
description: parsed.data.description,
@@ -148,11 +151,9 @@ export namespace Skill {
}
}
const dirs = Array.from(new Set(Object.values(skills).map((item) => path.dirname(item.location))))
return {
skills,
dirs,
dirs: Array.from(dirs),
}
})

View File

@@ -326,3 +326,63 @@ description: A skill in the .agents/skills directory.
},
})
})
test("properly resolves directories that skills live in", async () => {
await using tmp = await tmpdir({
git: true,
init: async (dir) => {
const opencodeSkillDir = path.join(dir, ".opencode", "skill", "agent-skill")
const opencodeSkillsDir = path.join(dir, ".opencode", "skills", "agent-skill")
const claudeDir = path.join(dir, ".claude", "skills", "claude-skill")
const agentDir = path.join(dir, ".agents", "skills", "agent-skill")
await Bun.write(
path.join(claudeDir, "SKILL.md"),
`---
name: claude-skill
description: A skill in the .claude/skills directory.
---
# Claude Skill
`,
)
await Bun.write(
path.join(agentDir, "SKILL.md"),
`---
name: agent-skill
description: A skill in the .agents/skills directory.
---
# Agent Skill
`,
)
await Bun.write(
path.join(opencodeSkillDir, "SKILL.md"),
`---
name: opencode-skill
description: A skill in the .opencode/skill directory.
---
# OpenCode Skill
`,
)
await Bun.write(
path.join(opencodeSkillsDir, "SKILL.md"),
`---
name: opencode-skill
description: A skill in the .opencode/skills directory.
---
# OpenCode Skill
`,
)
},
})
await Instance.provide({
directory: tmp.path,
fn: async () => {
const dirs = await Skill.dirs()
expect(dirs.length).toBe(4)
},
})
})