import { describe, it } from "node:test"; import { expect } from "expect"; import { runCli } from "../helpers/run-cli.js"; const forbiddenCommands = [ "packet", "review", "scan", "doctor", "build", "realize", ]; describe("truthmark CLI", () => { it("lists init and omits the retired config command in top-level help", async () => { const result = await runCli(["--help"]); expect(result.exitCode).toBe(0); expect(result.stdout).not.toContain("\n config "); expect(result.stdout).toContain("init"); expect(result.stdout).toContain("uninstall"); expect(result.stdout).toContain("check"); expect(result.stdout).toContain("index"); expect(result.stdout).toContain("impact"); expect(result.stdout).not.toContain("context"); for (const command of forbiddenCommands) { expect(result.stdout).not.toContain(command); } }); it("shows init help", async () => { const result = await runCli(["init", "--help"]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("Usage: truthmark init"); expect(result.stdout).toContain("--json"); expect(result.stdout).toContain("--platform "); expect(result.stdout).toContain("--clear-platforms"); }); it("rejects the removed config command", async () => { const result = await runCli(["config"]); expect(result.exitCode).not.toBe(0); expect(result.stderr).toContain("unknown command 'config'"); }); it("shows check help", async () => { const result = await runCli(["check", "--help"]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("Usage: truthmark check"); expect(result.stdout).toContain("--json"); expect(result.stdout).not.toContain("--workflow"); }); it("shows uninstall help with JSON and execution mode options", async () => { const result = await runCli(["uninstall", "--help"]); expect(result.exitCode).toBe(0); expect(result.stdout).toContain("Usage: truthmark uninstall"); expect(result.stdout).toContain("--dry-run"); expect(result.stdout).toContain("--apply"); expect(result.stdout).toContain("--json"); }); it("returns valid JSON for check", async () => { const result = await runCli(["check", "--json"]); expect(result.exitCode).toBe(0); const payload = JSON.parse(result.stdout) as { command: string; summary: string; diagnostics: unknown[]; data?: { scorecard?: { schemaVersion?: string; }; }; }; expect(payload.command).toBe("check"); expect(typeof payload.summary).toBe("string"); expect(payload.summary.length).toBeGreaterThan(0); expect(Array.isArray(payload.diagnostics)).toBe(true); expect(payload.data?.scorecard?.schemaVersion).toBe( "truthmark-scorecard/v0", ); }); });