import { useState } from "react"; import { del, get, post, put } from "../../api"; import { confirmDialog, promptDialog, toast } from "../../dialogs"; import { useFetch } from "../../hooks"; import { useT } from "../../i18n"; import { Icon } from "../Icon"; import { Spinner } from "../Activity"; interface SkillInfo { name: string; description: string; files: string[]; } interface SkillFile { path: string; content: string; } const TEMPLATE = `--- name: my-skill description: When to use this skill, in one or two sentences --- # Instructions Describe what the agent should do. `; /** The user's own skills: SKILL.md plus further files; created here or imported from GitHub. */ export function Skills() { const t = useT(); const { data, reload } = useFetch<{ skills: SkillInfo[] }>("/skills"); const [editing, setEditing] = useState<{ name: string; isNew: boolean }>(); const [importing, setImporting] = useState(false); const [filter, setFilter] = useState(""); const list = (data?.skills ?? []).filter((s) => !filter.trim() || `${s.name} ${s.description}`.toLowerCase().includes(filter.trim().toLowerCase())); const remove = async (s: SkillInfo) => { if (!(await confirmDialog({ message: t("skills.confirmDelete", { name: s.name }), danger: true }))) return; try { await del(`/skills/${s.name}`); reload(); } catch (e: any) { toast(e.message); } }; return (
{s.name}
{s.files.length > 0 && {t("skills.files", { n: s.files.length })}}