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

Versions 0 to 318

Compare

+85 −18 in 8 places
Lines 2–16 at 318 (were 2–15 at 0)
22// command, run by the same code as the command line and answering with the
33// same text, so the CLI and the tools can't drift apart and an agent learns
44// one set of words. The folder and the token come from where the server runs,
5−// as for the CLI: .avcs/config.json, and AVCS_TOKEN or ~/.avcs/token.
5+// as for the CLI: .avcs/config.json, and ABSO_TOKEN or ~/.abso/token.
66//
7−// claude mcp add avcs -- node <repo>/client/avcs.ts mcp
7+// claude mcp add abso -- abso mcp
88//
99// The protocol is JSON-RPC 2.0, one message per line, with no library: the
1010// client uses nothing outside Node.
1111
12−import { resolve } from "node:path";
12+import { realpathSync } from "node:fs";
13+import { isAbsolute, relative, resolve, sep } from "node:path";
1314import { clientVersion } from "./client-version.ts";
1415import { commandTable, main } from "./main.ts";
1516
Lines 35–42 at 318 (were 34–41 at 0)
3435 "announce",
3536 "start",
3637 "record",
37− "sync",
38− "publish",
38+ "pull",
39+ "push",
3940 "unqueue",
4041 "restore",
4142 "settle",
Lines 48–65 at 318 (were 47–55 at 0)
4748 "notes",
4849 "issues",
4950 "issue",
51+ "search",
5052 "ask",
5153 "waiting",
5254 "answer",
55+ "ack",
56+ "reply",
57+ "groups",
58+ "group",
59+ "orgs",
60+ "org",
61+ "whoami",
62+ "doctor",
5363] as const;
5464
5565const PROTOCOLS = ["2025-06-18", "2025-03-26", "2024-11-05"];
Lines 78–96 at 318 (were 68–82 at 0)
6878 return MCP_COMMANDS.map((command) => {
6979 const def = table[command]!;
7080 const flags = Object.fromEntries(
71− Object.entries(def.flags).map(([flag, kind]) => [
72− flag,
73− kind === "boolean"
74− ? { type: "boolean", description: `--${flag}` }
75− : {
76− type: "string",
77− description: kind === "optional" ? `--${flag} "<value>"; "" gives --${flag} alone` : `--${flag} <value>`,
78− },
79− ]),
81+ // No --token-file: a tool signs in with its folder's key, never this machine's token file.
82+ Object.entries(def.flags)
83+ .filter(([flag]) => flag !== "token-file")
84+ .map(([flag, kind]) => [
85+ flag,
86+ kind === "boolean"
87+ ? { type: "boolean", description: `--${flag}` }
88+ : {
89+ type: "string",
90+ description:
91+ kind === "optional" ? `--${flag} "<value>"; "" gives --${flag} alone` : `--${flag} <value>`,
92+ },
93+ ]),
8094 );
8195 return {
8296 name: toolName(command),
Lines 105–112 at 318 (were 91–97 at 0)
91105 },
92106 folder: {
93107 type: "string",
94− description: "The abso folder to run in (default: the folder this server started in).",
108+ description:
109+ "The abso folder to run in: the folder this server started in (the default), or one inside it.",
95110 },
96111 json: { type: "boolean", description: "Answer with the command's JSON (as --json) instead of its text." },
97112 ...flags,
Lines 117–172 at 318 (were 102–107 at 0)
102117 });
103118}
104119
120+/** A path as it really is (through links), or as given when it doesn't exist. */
121+function real(path: string): string {
122+ try {
123+ return realpathSync.native(path);
124+ } catch {
125+ return path;
126+ }
127+}
129+/** Whether `path` is `start` or inside it, after links are followed. */
130+function inside(start: string, path: string): boolean {
131+ const rel = relative(real(start), real(path));
132+ return rel === "" || (rel !== ".." && !rel.startsWith(`..${sep}`) && !isAbsolute(rel));
133+}
135+/** The tool inputs that name files or folders on this machine to read or write, comma-separated: each is confined like the folder. */
136+export const FILE_INPUTS = ["attach", "clean", "save-attachments"] as const;
138+/**
139+ * Where a tool call runs, and what it may read: its folder and
140+ * every file a FILE_INPUTS input names stay inside the folder the server
141+ * started in. A relative path that climbs out (..), an absolute one elsewhere,
142+ * or a link out is refused, so no tool reads a file outside the project.
143+ * Answers the folder, or why the call is refused.
144+ */
145+export function confineCall(
146+ start: string,
147+ input: Readonly<Record<string, unknown>>,
148+): { folder: string } | { refused: string } {
149+ const named = typeof input.folder === "string" && input.folder !== "" ? input.folder : undefined;
150+ const folder = named === undefined ? start : resolve(start, named);
151+ if (!inside(start, folder))
152+ return {
153+ refused: `folder ${JSON.stringify(named)} is outside ${start}, the folder this server started in; tools run there or below`,
154+ };
155+ for (const flag of FILE_INPUTS) {
156+ const value = input[flag];
157+ if (typeof value !== "string") continue;
158+ for (const p of value
159+ .split(",")
160+ .map((x) => x.trim())
161+ .filter((x) => x !== ""))
162+ if (!inside(start, resolve(folder, p)))
163+ return {
164+ refused: `--${flag} ${p} is outside ${start}, the folder this server started in; a tool reads and writes files only there or below`,
165+ };
166+ }
167+ return { folder };
168+}
105170/** The command line a tool call stands for: flags as --name=value, then the words after --. */
106171export function argvFor(command: string, input: Readonly<Record<string, unknown>>): string[] {
107172 const def = commandTable()[command]!;
Lines 208–216 at 318 (were 143–151 at 0)
143208 return reply(id, {
144209 protocolVersion: PROTOCOLS.includes(asked) ? asked : PROTOCOLS[0],
145210 capabilities: { tools: {} },
146− serverInfo: { name: "avcs", version: clientVersion() },
211+ serverInfo: { name: "abso", version: clientVersion() },
147212 instructions:
148− "avcs, the agent-first version control client. Each tool is the abso command of the same name and answers with the command line's text. Box runs (abso run, shot, bisect) stay in the shell.",
213+ "abso, the agent-first version control client. Each tool is the abso command of the same name and answers with the command line's text. Box runs (abso run, shot, bisect) stay in the shell.",
149214 });
150215 }
151216 case "ping":
Lines 222–230 at 318 (were 157–163 at 0)
157222 const command = MCP_COMMANDS.find((c) => toolName(c) === name);
158223 if (command === undefined) return fail(id, -32602, `no tool ${JSON.stringify(name)}; tools/list names them`);
159224 const args = (params.arguments ?? {}) as Record<string, unknown>;
160− const folder = typeof args.folder === "string" && args.folder !== "" ? resolve(cwd, args.folder) : cwd;
225+ const where = confineCall(cwd, args);
226+ if ("refused" in where) return reply(id, { content: [{ type: "text", text: where.refused }], isError: true });
227+ const folder = where.folder;
161228 let streamed = "";
162229 const result = await main(argvFor(command, args), {
163230 cwd: folder,
MCP
compare on this site's /mcp
CLI
abso diff 0 318 client/src/mcp.ts --json
JSON
/christopher/abso-core/compare/0..318?file=client%2Fsrc%2Fmcp.ts&format=json