- MCP
- blame on this site's /mcp
- CLI
- abso blame client/test/help.test.ts --json
- JSON
- /christopher/abso-core/blame/client/test/help.test.ts?format=json
46 linespinch 100%Last change pinch in version 79,
46 lines from 1 change in 1 version.
pinch79abso help --json: every command help shows, with its usage, about and flags, as data, so a command reference can be built from the client itself. And the terminal filter drops SGR 8 (conceal), which could hide text, keeping 8 where it's a color (38;5;8).Compare1// abso help --json: every command help shows, as data, for a command reference built from the client.
3import assert from "node:assert/strict";
4import { describe, it } from "node:test";
5import { commandTable, main } from "../src/main.ts";
7interface HelpJson {
8 ok: boolean;
9 command: string;
10 version: string;
11 intro: string;
12 note: string;
13 commands: { name: string; usage: string; about: string; flags: Record<string, string> }[];
14}
16describe("abso help --json", () => {
17 it("lists every command help shows, with its usage, about and flags", async () => {
18 const out = await main(["help", "--json"], { cwd: process.cwd(), env: {}, write: () => {} });
19 assert.equal(out.exit, 0);
20 const data = JSON.parse(out.stdout) as HelpJson;
21 assert.deepEqual(out.data, data);
22 assert.equal(data.ok, true);
23 assert.equal(data.command, "help");
24 assert.match(data.version, /\S/);
25 const names = data.commands.map((c) => c.name);
26 assert.deepEqual(names, [...Object.keys(commandTable()), "hook", "mcp", "--version"]);
27 const join = data.commands.find((c) => c.name === "join")!;
28 assert.equal(join.usage, commandTable().join!.usage);
29 assert.equal(join.flags.reader, "boolean");
30 assert.equal(join.flags.agent, "string");
31 for (const c of data.commands) {
32 assert.match(c.usage, /^abso /, c.name);
33 assert.ok(c.about.length > 0, c.name);
34 }
35 });
37 it("help without --json says the same, as text", async () => {
38 const text = (await main(["help"], { cwd: process.cwd(), env: {}, write: () => {} })).stdout;
39 const data = JSON.parse(
40 (await main(["--help", "--json"], { cwd: process.cwd(), env: {}, write: () => {} })).stdout,
41 ) as HelpJson;
42 assert.ok(text.startsWith(`${data.intro}\n`));
43 assert.ok(text.endsWith(`${data.note}\n`));
44 for (const c of data.commands) assert.ok(text.includes(` ${c.usage}\n ${c.about}\n`), c.name);
45 });
46});