import { Skill } from '@/types/skills'; import { getSkillPath } from '@/lib/skills-utils'; interface SkillContentResponse { content: string; relativePath?: string; } interface SkillContentError { error: string; } export async function fetchSkillContent(skill: Skill): Promise { const url = getSkillPath(skill); const response = await fetch(url); if (!response.ok) { let message = `Failed to load skill (${response.status})`; try { const body = (await response.json()) as SkillContentError; if (body.error) message = body.error; } catch { // ignore JSON parse errors } throw new Error(message); } const data = (await response.json()) as SkillContentResponse; if (!data.content) { throw new Error('Skill file is empty'); } return data.content; }