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
This commit is contained in:
ismeth
2026-02-19 18:28:31 +01:00
committed by YeonGyu-Kim
parent f068494fb9
commit b582cef9dc
@@ -3,19 +3,20 @@ import { discoverSkills } from "./loader"
import type { LoadedSkill } from "./types"
import type { SkillResolutionOptions } from "./skill-resolution-options"
const cachedSkillsByProvider = new Map<string, LoadedSkill[]>()
const skillCache = new Map<string, LoadedSkill[]>()
export function clearSkillCache(): void {
cachedSkillsByProvider.clear()
skillCache.clear()
}
export async function getAllSkills(options?: SkillResolutionOptions): Promise<LoadedSkill[]> {
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<Lo
if (hasDisabledSkills) {
allSkills = allSkills.filter((skill) => !options!.disabledSkills!.has(skill.name))
} else {
cachedSkillsByProvider.set(cacheKey, allSkills)
skillCache.set(cacheKey, allSkills)
}
return allSkills