From a68fedd4a6bc3c71577ff38f20679a6183605bcf Mon Sep 17 00:00:00 2001 From: Aiden Cline <63023139+rekram1-node@users.noreply.github.com> Date: Tue, 3 Feb 2026 16:33:36 -0600 Subject: [PATCH] chore: adjust way skill dirs are whitelisted (#12026) --- packages/opencode/src/skill/skill.ts | 7 +-- packages/opencode/test/skill/skill.test.ts | 60 ++++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/skill/skill.ts b/packages/opencode/src/skill/skill.ts index d8fdd22a4..b4f4acd52 100644 --- a/packages/opencode/src/skill/skill.ts +++ b/packages/opencode/src/skill/skill.ts @@ -50,6 +50,7 @@ export namespace Skill { export const state = Instance.state(async () => { const skills: Record = {} + const dirs = new Set() 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), } }) diff --git a/packages/opencode/test/skill/skill.test.ts b/packages/opencode/test/skill/skill.test.ts index 552cb932e..c310256c5 100644 --- a/packages/opencode/test/skill/skill.test.ts +++ b/packages/opencode/test/skill/skill.test.ts @@ -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) + }, + }) +})