import { createIndex, search, synthesizeAnswer, type PortfolioDocument } from "../src/core"; const docs: PortfolioDocument[] = [ { id: "a", title: "Acme MCP Server", summary: "Remote MCP server with 4 tools.", category: "Project", tags: ["mcp", "cloudflare workers"], facts: ["Ships 4 MCP tools on Cloudflare Workers."] }, { id: "b", title: "Shop Redesign", summary: "Shopify checkout redesign.", category: "Client", tags: ["shopify", "cro"], facts: ["Checkout path cut from 5 to 3 clicks."] }, ]; const index = createIndex(docs); const hits = search(index, "mcp workers"); if (hits[0]?.doc.id !== "a") throw new Error("search failed"); const ans = synthesizeAnswer(index, "What MCP work is there?", { subject: "Acme" }); if (!ans.citations.length || !ans.answer.includes("[1]")) throw new Error("answer failed"); const none = synthesizeAnswer(index, "quantum knitting", { subject: "Acme" }); if (none.citations.length) throw new Error("should not answer"); console.log("ok", hits.length, ans.answer, "|", none.answer);