Skip to content

abso-core

Public

abso is version control for agents: the client, the engine and a server you can run on your own Cloudflare account.

Check passed
MCP
show on this site's /mcp
CLI
abso show 79 --json
JSON
/christopher/abso-core/versions/79?format=json

abso 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).

of shared·pinch··Not checked

Version 78 · Files at version 79

4 files, 127 lines added, 14 removed.

--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -5,6 +5,7 @@
55import { resolve } from "node:path";
66import { runAnnounce, runNews, runStart } from "./announce.ts";
77import { ApiError } from "./api.ts";
8+import { clientVersion } from "./client-version.ts";
89import { bool, type FlagSpec, type Parsed, parseArgs, str, UsageError } from "./args.ts";
910import { bodyFilesHelp, readBodyFiles, withBodyFiles } from "./body-files.ts";
1011import { boxPublic, boxText, login, logout, readBox } from "./box.ts";
@@ -790,22 +791,57 @@
790791 },
791792};
792793
793−function help(): string {
794+const HELP_INTRO = "abso: version control for agents. This is its command-line client.";
795+const HELP_NOTE =
796+ "Every command takes --json. Settings live in .abso/config.json (.avcs/config.json in a folder from before the rename). The token comes from ABSO_TOKEN, or else ~/.abso/token (or ~/.avcs/token from before).";
798+/** Every command as help shows it, in order: the table's, then the three it doesn't hold. */
799+function helpEntries(): { name: string; usage: string; about: string; flags: FlagSpec }[] {
794800 return [
795− "abso: version control for agents. This is its command-line client.",
796− "",
797− ...Object.values(COMMANDS).flatMap((c) => [` ${c.usage}`, ` ${c.about}`]),
798− " abso hook",
799− " The Claude Code PostToolUse hook. Reads the hook JSON on stdin; never fails.",
800− " abso mcp",
801− " An MCP server on stdin and stdout: the reading commands and the everyday writing ones as tools, answering with the same text as here. Add it with claude mcp add abso -- abso mcp (on Windows, claude mcp add abso -- cmd /c abso mcp).",
802− " abso --version",
803− " This client's version and commit, and the abso mods installed on this machine.",
804− "",
805− "Every command takes --json. Settings live in .abso/config.json (.avcs/config.json in a folder from before the rename). The token comes from ABSO_TOKEN, or else ~/.abso/token (or ~/.avcs/token from before).",
806− ].join("\n");
801+ ...Object.entries(COMMANDS).map(([name, c]) => ({ name, usage: c.usage, about: c.about, flags: c.flags })),
802+ {
803+ name: "hook",
804+ usage: "abso hook",
805+ about: "The Claude Code PostToolUse hook. Reads the hook JSON on stdin; never fails.",
806+ flags: {},
807+ },
808+ {
809+ name: "mcp",
810+ usage: "abso mcp",
811+ about:
812+ "An MCP server on stdin and stdout: the reading commands and the everyday writing ones as tools, answering with the same text as here. Add it with claude mcp add abso -- abso mcp (on Windows, claude mcp add abso -- cmd /c abso mcp).",
813+ flags: {},
814+ },
815+ {
816+ name: "--version",
817+ usage: "abso --version",
818+ about: "This client's version and commit, and the abso mods installed on this machine.",
819+ flags: {},
820+ },
821+ ];
807822}
808823
824+function help(): string {
825+ const entries = helpEntries().flatMap((c) => [` ${c.usage}`, ` ${c.about}`]);
826+ return [HELP_INTRO, "", ...entries, "", HELP_NOTE].join("\n");
827+}
829+/**
830+ * help --json: the same entries as data, for a command reference built from the client itself. A flag is
831+ * "string" (takes a value), "boolean" (stands alone) or "optional" (a value that may be left off); every
832+ * command also takes --json and --help.
833+ */
834+function helpJson(): Record<string, unknown> {
835+ return {
836+ ok: true,
837+ command: "help",
838+ version: clientVersion(),
839+ intro: HELP_INTRO,
840+ note: HELP_NOTE,
841+ commands: helpEntries(),
842+ };
843+}
809845export interface MainResult {
810846 readonly stdout: string;
811847 readonly stderr: string;
@@ -839,6 +875,10 @@
839875 const command = argv[0];
840876 const json = argv.includes("--json") && command !== "run" && command !== "logs";
841877 if (command === undefined || command === "help" || command === "--help" || command === "-h") {
878+ if (json) {
879+ const data = helpJson();
880+ return { stdout: `${JSON.stringify(data, null, 2)}\n`, stderr: "", exit: EXIT.ok, data };
881+ }
842882 return { stdout: `${help()}\n`, stderr: "", exit: EXIT.ok };
843883 }
844884 try {
--- a/client/src/terminal-text.ts
+++ b/client/src/terminal-text.ts
@@ -21,6 +21,25 @@
2121 return 0;
2222}
2323
24+/**
25+ * An SGR sequence without parameter 8 (conceal), which would hide the text after it from the reader. The 8 in an
26+ * extended color (38;5;8, 48;2;8;8;8) is a color, so those are copied whole. Nothing is left when 8 was all it said.
27+ */
28+function withoutConceal(sgr: string): string {
29+ const parts = sgr.slice(2, -1).split(";");
30+ const kept: string[] = [];
31+ for (let i = 0; i < parts.length; i++) {
32+ const p = parts[i]!;
33+ if ((p === "38" || p === "48" || p === "58") && (parts[i + 1] === "5" || parts[i + 1] === "2")) {
34+ const n = parts[i + 1] === "5" ? 3 : 5;
35+ kept.push(...parts.slice(i, i + n));
36+ i += n - 1;
37+ } else if (p !== "8") kept.push(p);
38+ }
39+ if (kept.length === parts.length) return sgr;
40+ return kept.length === 0 ? "" : `\x1b[${kept.join(";")}m`;
41+}
2443/** Whether a character code is one the terminal acts on: C0 but tab and newline, DEL, and C1. */
2544const control = (c: number) => (c < 0x20 && c !== 0x09 && c !== 0x0a) || (c >= 0x7f && c <= 0x9f);
2645
@@ -38,7 +57,7 @@
3857 }
3958 const sgr = sgrAt(text, i);
4059 if (sgr > 0) {
41− if (colors) out += text.slice(i, i + sgr);
60+ if (colors) out += withoutConceal(text.slice(i, i + sgr));
4261 i += sgr - 1;
4362 } else if (c === 0x0d && text.charCodeAt(i + 1) === 0x0a) out += "\r";
4463 else out += c < 0x80 ? `\\x${c.toString(16).padStart(2, "0")}` : `\\u${c.toString(16).padStart(4, "0")}`;
--- /dev/null
+++ b/client/test/help.test.ts
@@ -0,0 +1,46 @@
1+// abso help --json: every command help shows, as data, for a command reference built from the client.
2+
3+import assert from "node:assert/strict";
4+import { describe, it } from "node:test";
5+import { commandTable, main } from "../src/main.ts";
6+
7+interface 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+}
16+describe("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+});
--- a/client/test/terminal-text.test.ts
+++ b/client/test/terminal-text.test.ts
@@ -24,6 +24,14 @@
2424 assert.equal(terminalText(red, false), "failed and bold");
2525 });
2626
27+ it("drops conceal (SGR 8), which would hide text, but keeps 8 as a color", () => {
28+ assert.equal(terminalText(`${ESC}[8mhidden${ESC}[0m`, true), `hidden${ESC}[0m`);
29+ assert.equal(terminalText(`${ESC}[1;8;31mx`, true), `${ESC}[1;31mx`);
30+ assert.equal(terminalText(`${ESC}[38;5;8;48;2;8;8;8mx`, true), `${ESC}[38;5;8;48;2;8;8;8mx`);
31+ assert.equal(terminalText(`${ESC}[38;5;8;8mx`, true), `${ESC}[38;5;8mx`);
32+ assert.equal(terminalText(`${ESC}[mx${ESC}[28m`, true), `${ESC}[mx${ESC}[28m`);
33+ });
2735 it("shows OSC 52 (the clipboard) and OSC 8 (links) as text, with or without colors", () => {
2836 const clip = `${ESC}]52;c;ZWNobyBoaQ==\x07`;
2937 assert.equal(terminalText(clip, true), "\\x1b]52;c;ZWNobyBoaQ==\\x07");