import { readFileSync } from "node:fs"; import { fileURLToPath } from "node:url"; import { afterEach, describe, expect, it } from "vitest"; import { createTestSession, type TestSession } from "../../../test/harness"; import btwExtension from "../index.ts"; let t: TestSession | undefined; function extensionPath(): string { return fileURLToPath(new URL("../index.ts", import.meta.url)); } afterEach(() => { t?.dispose(); t = undefined; }); describe("btw", () => { it("loads in real Pi extension runtime and registers /btw", async () => { t = await createTestSession({ extensionFactories: [btwExtension] }); expect(t.session.extensionRunner.extensions[0].commands.has("btw")).toBe( true, ); }); it("documents and enforces read-only side tools", () => { const source = readFileSync(extensionPath(), "utf8"); expect(source).toContain('const SIDE_TOOLS = ["read", "bash"] as const;'); expect(source).not.toContain('tools: ["read", "bash", "edit", "write"]'); }); });