From b582cef9dcdc46cc2ca1e12dc3ff277de7dd99c3 Mon Sep 17 00:00:00 2001 From: ismeth Date: Thu, 19 Feb 2026 18:28:31 +0100 Subject: [PATCH] fix(skills): pass directory through skill resolution chain for Desktop mode Skill discovery in the task tool failed to find project-level skills in OpenCode Desktop because: 1. resolveSkillContent() never passed directory to the skill resolution functions, causing them to fall back to process.cwd() which differs from the project directory in Desktop mode. 2. getAllSkills() cache key only included browserProvider, not directory. A first call with the wrong directory would cache stale results that all subsequent calls (even with correct directory) would return. 3. The error message used discoverSkills() (discovered only) instead of getAllSkills() (discovered + builtins), hiding builtin skills from the Available list. Changes: - skill-resolver.ts: accept and pass directory; use getAllSkills for error msg - tools.ts: pass options.directory to resolveSkillContent - skill-discovery.ts: include directory in cache key; rename cache variable - skill/types.ts + tools.ts: add directory to SkillLoadOptions for consistency --- src/features/opencode-skill-loader/skill-discovery.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/features/opencode-skill-loader/skill-discovery.ts b/src/features/opencode-skill-loader/skill-discovery.ts index fb991e44a..2ee2cbca3 100644 --- a/src/features/opencode-skill-loader/skill-discovery.ts +++ b/src/features/opencode-skill-loader/skill-discovery.ts @@ -3,19 +3,20 @@ import { discoverSkills } from "./loader" import type { LoadedSkill } from "./types" import type { SkillResolutionOptions } from "./skill-resolution-options" -const cachedSkillsByProvider = new Map() +const skillCache = new Map() export function clearSkillCache(): void { - cachedSkillsByProvider.clear() + skillCache.clear() } export async function getAllSkills(options?: SkillResolutionOptions): Promise { - const cacheKey = options?.browserProvider ?? "playwright" + const directory = options?.directory ?? process.cwd() + const cacheKey = `${options?.browserProvider ?? "playwright"}:${directory}` const hasDisabledSkills = options?.disabledSkills && options.disabledSkills.size > 0 // Skip cache if disabledSkills is provided (varies between calls) if (!hasDisabledSkills) { - const cached = cachedSkillsByProvider.get(cacheKey) + const cached = skillCache.get(cacheKey) if (cached) return cached } @@ -69,7 +70,7 @@ export async function getAllSkills(options?: SkillResolutionOptions): Promise !options!.disabledSkills!.has(skill.name)) } else { - cachedSkillsByProvider.set(cacheKey, allSkills) + skillCache.set(cacheKey, allSkills) } return allSkills