fix(cli): resolve SKILL.md not found errors from duplicate path prefixes

When skillPath from the registry had a prefix (e.g., "skills/foo"), fallback
paths were incorrectly generated with duplicate prefixes like
".claude/skills/skills/foo/SKILL.md". Now extracts the leaf skill name to
build correct fallback paths. Also adds raw.githubusercontent.com as a
universal fallback for 404s, improves error messages with actual paths tried,
and skips API results that lack the main instruction file.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
airano
2026-02-13 04:46:22 +03:30
parent 83a3766838
commit 394830280f
2 changed files with 63 additions and 15 deletions

View File

@@ -103,10 +103,16 @@ export async function install(skillId: string, options: InstallOptions): Promise
sourceFormat = cachedFiles.sourceFormat as SourceFormat;
}
// Convert API response to SkillContent format
content = convertCachedFilesToSkillContent(cachedFiles, sourceFormat);
spinner.text = cachedFiles.fromCache
? `Using cached files (${cachedFiles.files.length} files)`
: `Downloaded ${cachedFiles.files.length} files via API`;
const converted = convertCachedFilesToSkillContent(cachedFiles, sourceFormat);
// Only use API result if the main instruction file was found
if (converted.skillMd) {
content = converted;
spinner.text = cachedFiles.fromCache
? `Using cached files (${cachedFiles.files.length} files)`
: `Downloaded ${cachedFiles.files.length} files via API`;
} else {
spinner.text = 'API returned files but main instruction file missing, falling back...';
}
}
} catch {
// API was reachable but file fetch failed (timeout, server error, etc.)