import { describe, expect, test } from "bun:test"; import { mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { IndexStore } from "./store"; describe("seed metadata", () => { test("hydrates indexed commands from imported seed descriptions", () => { const root = mkdtempSync(join(tmpdir(), "tool-query-seeds-")); const store = IndexStore.open(join(root, "index.sqlite3")); store.syncCommands({ names: ["agent-browser", "firefox"], commands: [ { name: "agent-browser", resolvedPath: "/usr/bin/agent-browser" }, { name: "firefox", resolvedPath: "/usr/bin/firefox" }, ], }); store.importSeedEntries( [ { name: "agent-browser", description: "CLI for browser automation, page interaction, and screenshots." }, { name: "unknown-tool", description: "Installed command line tool available on this system." }, ], "seed-import", ); expect(store.hydrateSeedMetadata()).toEqual(["agent-browser"]); expect(store.undocumentedCommandNames()).toEqual(["firefox"]); }); test("upgrades fallback seed metadata when richer seed data is imported later", () => { const root = mkdtempSync(join(tmpdir(), "tool-query-seeds-")); const store = IndexStore.open(join(root, "index.sqlite3")); store.syncCommands({ names: ["quota-monitor"], commands: [{ name: "quota-monitor", resolvedPath: "/usr/bin/quota-monitor" }], }); store.importSeedEntries([{ name: "quota-monitor" }], "seed-import"); store.hydrateSeedMetadata(); expect(store.documentedCommands()[0]?.description).toBe( "Installed command line tool available on this system.", ); store.importSeedEntries( [{ name: "quota-monitor", description: "Status utility for monitoring command or token quota usage." }], "seed-import", ); store.hydrateSeedMetadata(); expect(store.documentedCommands()[0]?.description).toBe( "Status utility for monitoring command or token quota usage.", ); }); });