/**
 * Paperclip skills — listing + sync actions.
 *
 * Skills live in Paperclip's database (separate from the main legal-ai DB)
 * and are exposed via /api/admin/skills. The UI just needs read access for
 * Phase 5; install/sync/delete mutations can follow in Phase 6.
 */

import { useQuery } from "@tanstack/react-query";
import { apiRequest } from "./client";

export type Skill = {
  slug: string;
  name: string;
  db_markdown_chars: number;
  file_inventory: Array<{ path: string; size?: number }> | null;
  updated_at: string | null;
  disk_exists: boolean;
  disk_skill_md_bytes: number | null;
  not_in_db?: boolean;
};

export function useSkills() {
  return useQuery({
    queryKey: ["skills", "list"] as const,
    queryFn: ({ signal }) =>
      apiRequest<Skill[]>("/api/admin/skills", { signal }),
    staleTime: 30_000,
  });
}
