{"draft":null,"from":2,"to":318,"files":[{"path":"client/test/help.test.ts","added":46,"removed":0,"diff":"--- /dev/null\n+++ b/client/test/help.test.ts\n@@ -0,0 +1,46 @@\n+// abso help --json: every command help shows, as data, for a command reference built from the client.\n+\n+import assert from \"node:assert/strict\";\n+import { describe, it } from \"node:test\";\n+import { commandTable, main } from \"../src/main.ts\";\n+\n+interface HelpJson {\n+\tok: boolean;\n+\tcommand: string;\n+\tversion: string;\n+\tintro: string;\n+\tnote: string;\n+\tcommands: { name: string; usage: string; about: string; flags: Record<string, string> }[];\n+}\n+\n+describe(\"abso help --json\", () => {\n+\tit(\"lists every command help shows, with its usage, about and flags\", async () => {\n+\t\tconst out = await main([\"help\", \"--json\"], { cwd: process.cwd(), env: {}, write: () => {} });\n+\t\tassert.equal(out.exit, 0);\n+\t\tconst data = JSON.parse(out.stdout) as HelpJson;\n+\t\tassert.deepEqual(out.data, data);\n+\t\tassert.equal(data.ok, true);\n+\t\tassert.equal(data.command, \"help\");\n+\t\tassert.match(data.version, /\\S/);\n+\t\tconst names = data.commands.map((c) => c.name);\n+\t\tassert.deepEqual(names, [...Object.keys(commandTable()), \"hook\", \"mcp\", \"--version\"]);\n+\t\tconst join = data.commands.find((c) => c.name === \"join\")!;\n+\t\tassert.equal(join.usage, commandTable().join!.usage);\n+\t\tassert.equal(join.flags.reader, \"boolean\");\n+\t\tassert.equal(join.flags.agent, \"string\");\n+\t\tfor (const c of data.commands) {\n+\t\t\tassert.match(c.usage, /^abso /, c.name);\n+\t\t\tassert.ok(c.about.length > 0, c.name);\n+\t\t}\n+\t});\n+\n+\tit(\"help without --json says the same, as text\", async () => {\n+\t\tconst text = (await main([\"help\"], { cwd: process.cwd(), env: {}, write: () => {} })).stdout;\n+\t\tconst data = JSON.parse(\n+\t\t\t(await main([\"--help\", \"--json\"], { cwd: process.cwd(), env: {}, write: () => {} })).stdout,\n+\t\t) as HelpJson;\n+\t\tassert.ok(text.startsWith(`${data.intro}\\n`));\n+\t\tassert.ok(text.endsWith(`${data.note}\\n`));\n+\t\tfor (const c of data.commands) assert.ok(text.includes(`  ${c.usage}\\n      ${c.about}\\n`), c.name);\n+\t});\n+});"}],"unmatched":[]}