import { request } from '../client' export type SkillSource = 'builtin' | 'hub' | 'local' export interface SkillInfo { name: string description: string enabled?: boolean source?: SkillSource modified?: boolean patchCount?: number useCount?: number viewCount?: number pinned?: boolean } export interface SkillCategory { name: string description: string skills: SkillInfo[] } export interface SkillListResponse { categories: SkillCategory[] archived: SkillInfo[] } export interface SkillFileEntry { path: string name: string isDir: boolean } export interface MemoryData { memory: string user: string soul: string memory_mtime: number | null user_mtime: number | null soul_mtime: number | null } export interface SkillsData { categories: SkillCategory[] archived: SkillInfo[] } export async function fetchSkills(): Promise { const res = await request('/api/hermes/skills') return { categories: res.categories, archived: res.archived ?? [] } } export async function fetchSkillContent(skillPath: string): Promise { const res = await request<{ content: string }>(`/api/hermes/skills/${skillPath}`) return res.content } export async function fetchSkillFiles(category: string, skill: string): Promise { const res = await request<{ files: SkillFileEntry[] }>(`/api/hermes/skills/${category}/${skill}/files`) return res.files } export async function fetchMemory(): Promise { return request('/api/hermes/memory') } export async function saveMemory(section: 'memory' | 'user' | 'soul', content: string): Promise { await request('/api/hermes/memory', { method: 'POST', body: JSON.stringify({ section, content }), }) } export async function toggleSkill(name: string, enabled: boolean): Promise { await request('/api/hermes/skills/toggle', { method: 'PUT', body: JSON.stringify({ name, enabled }), }) } export async function pinSkillApi(name: string, pinned: boolean): Promise { await request('/api/hermes/skills/pin', { method: 'PUT', body: JSON.stringify({ name, pinned }), }) }