fix: skill discovery path doubling and pattern/name matching

Three related bugs that prevent agent skills from loading:

1. **Doubled "skills/" prefix in discovery** (skills-adapter.ts)
   `discoverSkills()` unconditionally prepends "skills/" to the relative
   path, but `baseDir` points to the parent of the skills directory
   (e.g. `~/.fusion/agent`), so `relative()` already returns a path
   starting with "skills/". Result: IDs like
   `auto::skills/skills/web-research/SKILL.md` instead of
   `auto::skills/web-research/SKILL.md`.

   Fix: only prepend "skills/" when the relative path does not already
   start with it.

2. **normalizeAgentSkills does not extract name from full ID**
   (session-skill-context.ts)
   The dashboard saves full skill IDs (e.g.
   `"auto::skills/web-research/SKILL.md"`) into agent
   `metadata.skills`. The runtime matches these against
   `skill.name` (e.g. `"web-research/SKILL.md"`) — they never match,
   so agent skills silently fail to load.

   Fix: when an entry contains "::", parse out the skill name (last
   two path segments) before matching.

3. **Pattern matching uses absolute filePath instead of skill name**
   (skill-resolver.ts)
   Settings patterns written by `toggleExecutionSkill()` are relative
   (e.g. `"web-research/SKILL.md"`), but the resolver compares them
   against `skill.filePath` which is absolute. Patterns can never
   match, producing spurious "not found in discovered skills" warnings.

   Fix: match patterns against `skill.name` (case-insensitive) with
   fallback to exact `skill.filePath` match for backward compatibility.
This commit is contained in:
Harry Cordewener
2026-05-03 01:15:56 -05:00
parent 6bc2de9aa4
commit f2afc7f0c4
3 changed files with 48 additions and 19 deletions

View File

@@ -101,10 +101,22 @@ export function normalizeAgentSkills(
}
}
// Skip invalid/empty entries and deduplicate
if (name && name.length > 0 && !seen.has(name)) {
seen.add(name);
result.push(name);
// Skip invalid/empty entries and deduplicate.
// If the entry is a full skill ID ("source::path"), extract just the
// skill name (last two path segments) so it matches the discovered
// skill.name produced by extractSkillName().
if (name && name.length > 0) {
if (name.includes("::")) {
const idPath = name.split("::").pop()!;
const parts = idPath.replace(/\\/g, "/").split("/").filter(Boolean);
if (parts.length >= 2) {
name = parts.slice(-2).join("/");
}
}
if (!seen.has(name)) {
seen.add(name);
result.push(name);
}
}
}