import test from "node:test"; import assert from "node:assert/strict"; import { mkdtemp, rm } from "node:fs/promises"; import os from "node:os"; import path from "node:path"; import { createCorpusTools } from "yt-dlp-transcript-mcp/callTool"; import { writeDraftCorpus } from "yt-dlp-transcript-common/testing/draft/corpus.mjs"; // Run with: // pnpm -C editor exec tsx --test "app/api/ops/_corpusTools.test.ts" // // The MCP's corpus tools are importable from the editor (release 27 S3, D2): // the package export resolves and the tools answer over a synthetic corpus. // The generation jobs (S6) run them in this process. test("the editor imports the MCP's in-process corpus tools", async () => { const dir = await writeDraftCorpus(await mkdtemp(path.join(os.tmpdir(), "editor-corpus-tools-"))); const corpus = await createCorpusTools({ source: `local:${dir}` }); try { assert.ok(corpus.tools.some((t) => t.name === "search_transcripts")); assert.match(await corpus.call("list_channels"), /synth-kitchen/); } finally { await corpus.close(); await rm(dir, { recursive: true, force: true }); } });