- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/client/src/main.ts?version=294&format=json
1,174 linesFirst import 57% · pinch 15% · speed 7% · approvals-page 6% · rename 4% · groups 3% · Last change pinch in version 287, 56 versions changed it
You're reading version 294. The newest is 318, and 3 versions since then changed this file.
1// The command table and the dispatcher. main() returns what to print and the
2// exit code instead of printing, so tests can call it directly.
4import { existsSync, readFileSync } from "node:fs";
5import { join, resolve } from "node:path";
6import { runAnnounce, runNews, runStart } from "./announce.ts";
7import { ApiError } from "./api.ts";
8import { bool, type FlagSpec, type Parsed, parseArgs, str, UsageError } from "./args.ts";
9import { runAutosettle } from "./autosettle-commands.ts";
10import { bodyFilesHelp, readBodyFiles, withBodyFiles } from "./body-files.ts";
11import { boxName, boxPublic, boxText, login, loginRequest, logout, originOf, readBox } from "./box.ts";
12import { runDiff, runFiles, runLog, runRestore, runShow } from "./changes.ts";
13import { runCheckIgnore } from "./check-ignore.ts";
14import { runCi } from "./ci.ts";
15import { clientVersion } from "./client-version.ts";
16import {
17 type Env,
18 EXIT,
19 type Output,
20 runBisect,
21 runFetch,
22 runFixEol,
23 runInit,
24 runJoin,
25 runLogs,
26 runMv,
27 runPause,
28 runPrep,
29 runPublish,
30 runReader,
31 runRecord,
32 runResume,
33 runRun,
34 runServe,
35 runSettle,
36 runShot,
37 runStatus,
38 runSync,
39 takeNews,
40} from "./commands.ts";
41import { configPath, findRoot, installKey, isVisitor, readConfig, runKey, tokenFile } from "./config.ts";
42import { newsBlockLines, newsShown } from "./core.ts";
43import { doctor, doctorText, plainError, realProbe, whoami } from "./doctor.ts";
44import { runDraftSync, runLand, runSwitch } from "./drafts.ts";
45import { fromEnv } from "./env-names.ts";
46import { runExport } from "./export.ts";
47import { runFlag } from "./flag-commands.ts";
48import { runGroup, runGroups } from "./group-commands.ts";
49import { runBlame, runWhere, runWho, runWhy } from "./history.ts";
50import {
51 openIssues,
52 runAck,
53 runAnswer,
54 runAsk,
55 runIssue,
56 runIssues,
57 runReply,
58 runSearch,
59 runWaiting,
60} from "./issues.ts";
61import { adminToken, adminTokenWords, issuedPublic, keyList, keyListText, keyNew, keyRevoke } from "./key-admin.ts";
62import { closeLocalStores } from "./local-store.ts";
63import { browserSkip, openInBrowser } from "./open-browser.ts";
64import { runOrg, runOrgs } from "./orgs.ts";
65import { runUnqueue } from "./queue.ts";
66import { runNote, runNotes, runReview } from "./review.ts";
67import {
68 checkFolderServer,
69 chooseServer,
70 localRefusal,
71 SERVER_ORDER,
72 serverFlag,
73 serverHelp,
74 serverUse,
75} from "./server-choice.ts";
76import { installSkill, SKILL, skillPath } from "./skill.ts";
77import { stateDir } from "./state-dir.ts";
78import { colorsPass, terminalText } from "./terminal-text.ts";
79import { runAmend, runDrop, runFollow, runLabel, runLabels, runPluck } from "./versions.ts";
80import { runVisibility } from "./visibility-commands.ts";
81import { checkVisitor } from "./visitor.ts";
83interface CommandDef {
84 readonly flags: FlagSpec;
85 readonly usage: string;
86 readonly about: string;
87 /** Stop reading options at the first word (for `run <command...>`). */
88 readonly rest?: boolean;
89 readonly run: (args: Parsed, env: Env) => Promise<Output>;
90}
92/** The server login, box, logout, orgs, org, whoami and doctor act on, in the order every command picks one (server-choice.ts). */
93export function boxServer(args: Parsed, env: Pick<Env, "cwd" | "env">): string {
94 return chooseServer(serverFlag(args), env.cwd, env.env);
95}
97async function runKeyInstall(args: Parsed, env: Env): Promise<Output> {
98 // With --server, the folder is the one named (or here), before it is joined: findRoot
99 // could find a parent agent's folder and pin the key there.
100 const server = str(args, "server");
101 const root = server ? resolve(env.cwd, str(args, "dir") ?? ".") : findRoot(env.cwd);
102 if (!root)
103 throw new UsageError("abso key install runs inside an agent's folder, or takes --server <url> before abso join");
104 const stdin = await new Promise<string>((done, reject) => {
105 const chunks: Buffer[] = [];
106 process.stdin.on("data", (c) => chunks.push(c as Buffer));
107 process.stdin.on("end", () => done(Buffer.concat(chunks).toString("utf8")));
108 process.stdin.on("error", reject);
109 });
110 const { id } = installKey(root, stdin, server);
111 return { text: `Installed agent key ${id}.`, json: { installed: id } };
112}
114const COMMANDS: Readonly<Record<string, CommandDef>> = {
115 init: {
116 flags: {
117 server: "string",
118 project: "string",
119 agent: "string",
120 "as-is": "boolean",
121 org: "string",
122 public: "boolean",
123 private: "boolean",
124 "token-file": "boolean",
125 local: "boolean",
126 store: "string",
127 },
128 usage:
129 "abso init [folder] --project <name> [--agent <name>] [--as-is] [--org <org>] [--public|--private] [--token-file] | abso init [folder] --local --project <name> [--agent <name>] [--store <folder>] [--as-is]",
130 about:
131 "Create a project on the server from a folder's text files. The folder becomes that agent's folder. It writes a starting .absoignore, and, when the folder has no abso.json and package.json gives a check or a build to guess, an abso.json (setup, check, build and out): what the server's CI runs on each new version of shared. Without one, CI runs what it can guess itself, or nothing. --as-is writes neither: the folder goes up exactly as it is (an import). On a server this box is signed in to (abso login, approving all your projects), the project is made as you, the way the website's New project makes it: you own it, it's private unless you say --public, and the folder joins it at once with its own key (--agent names it; else the box's name). --org <org> makes it that organization's project. Elsewhere it needs --agent and a token: ABSO_TOKEN, or with --token-file this machine's ~/.abso/token, which is never used unasked. Before it makes anything, it says what it signs in with. --local makes a local project instead: its history is kept on this machine, in a store folder, and no server, sign-in or network is needed (Node 22.13 or later). The store is --store <folder> (kept in the folder's settings; inside the folder, .absoignore leaves it out), else ABSO_STORE, else this user's data folder (%LOCALAPPDATA%\\abso\\store, ~/Library/Application Support/abso/store, or $XDG_DATA_HOME/abso/store). The agent is --agent, else this computer's name.",
132 run: (args, env) => runInit(args, env),
133 },
134 key: {
135 flags: {
136 server: "string",
137 dir: "string",
138 project: "string",
139 agent: "string",
140 expires: "string",
141 role: "string",
142 print: "boolean",
143 },
144 usage:
145 "abso key install [--server <url> [--dir <folder>]] | abso key new <agent> [--server <url> [--dir <folder>]] [--project <name>] [--expires <Nd>] [--role owner|writer|reader] [--print] | abso key list [--agent <name>] [--project <name>] | abso key revoke <id> [--project <name>]",
146 about:
147 "install reads {key, id} from stdin into .abso/key. With --server, it writes it into a folder not joined yet, so abso join there signs in with the key. new writes the key into that folder and prints only the id; its role is writer unless --role says otherwise (a reader only reads; a writer writes on its own agent's routes; an owner also skips or revokes CI, resumes the queue, syncs git and exports); --print writes the key to stdout instead. list and revoke never print a key. These three read the admin token from ABSO_ADMIN_TOKEN or ~/.abso/admin-token and send it only to a server named in ABSO_ADMIN_SERVERS. An agent does not run them unless a person on the project says so.",
148 run: async (args, env) => {
149 const sub = args.positionals[0];
150 if (sub === "install" && args.positionals.length === 1) return runKeyInstall(args, env);
151 const serverFlag = str(args, "server");
152 const root = serverFlag ? resolve(env.cwd, str(args, "dir") ?? ".") : findRoot(env.cwd);
153 if (!root) throw new UsageError("abso key runs inside an agent's folder, or takes --server <url>");
154 let config: ReturnType<typeof readConfig>;
155 try {
156 config = readConfig(root, env.env, env.tokenFile === true);
157 } catch {
158 config = {
159 server: serverFlag ?? "",
160 project: str(args, "project") ?? "",
161 agent: "admin",
162 token: fromEnv(env.env, "TOKEN")?.trim() || (env.tokenFile ? tokenFile() : undefined),
163 };
164 }
165 if (serverFlag) config = { ...config, server: serverFlag };
166 const admin = adminToken(env.env);
167 (env.writeErr ?? env.write)(`${adminTokenWords(env.env)}\n`);
168 if (sub === "new" && args.positionals.length === 2) {
169 const server = str(args, "server") ?? config.server;
170 const project = str(args, "project") ?? config.project;
171 const expires = str(args, "expires");
172 const role = str(args, "role");
173 if (role !== undefined && role !== "owner" && role !== "writer" && role !== "reader")
174 throw new UsageError("--role is owner, writer or reader");
175 const issued = await keyNew({ ...config, server }, admin, args.positionals[1]!, project, expires, role);
176 const print = bool(args, "print");
177 const shown = issuedPublic(issued, print);
178 if (!print) {
179 const dir = str(args, "server") ? resolve(env.cwd, str(args, "dir") ?? ".") : root;
180 installKey(dir, JSON.stringify({ key: issued.key, id: issued.id }), server);
181 }
182 return {
183 text: print ? `${JSON.stringify({ key: issued.key, id: issued.id })}\n` : `Made ${issued.id}.\n`,
184 json: shown,
185 };
186 }
187 if (sub === "list" && args.positionals.length === 1) {
188 const agent = str(args, "agent");
189 const project = str(args, "project") ?? config.project;
190 const keys = await keyList({ ...config, server: str(args, "server") ?? config.server }, admin, agent, project);
191 return { text: `${keyListText(keys)}\n`, json: { keys } };
192 }
193 if (sub === "revoke" && args.positionals.length === 2) {
194 const project = str(args, "project") ?? config.project;
195 const id = args.positionals[1]!;
196 const revoked = await keyRevoke(
197 { ...config, server: str(args, "server") ?? config.server },
198 admin,
199 id,
200 project,
201 );
202 return { text: revoked ? `Revoked ${id}.\n` : `No key ${id}.\n`, json: { id, revoked } };
203 }
204 throw new UsageError("abso key install | abso key new <agent> | abso key list | abso key revoke <id>");
205 },
206 },
207 login: {
208 flags: {
209 server: "string",
210 "no-browser": "boolean",
211 "no-ask": "boolean",
212 projects: "string",
213 role: "string",
214 days: "string",
215 },
216 usage:
217 "abso login [--no-browser] [--no-ask] [--projects <name,name>] [--role <reader|writer|owner>] [--days <1-90>]",
218 about:
219 "Sign this box in once: it opens the approve page in your browser with the code filled in, prints the link and the code too, and waits while a person approves the code on the website, choosing the projects, the highest role and how long. Then abso join in any of those projects gives each agent its own key, with no approval. The box's sign-in is kept in your user folder, never in a project folder, and is never printed. No browser opens with --no-browser or ABSO_NO_BROWSER, over SSH, under CI, or on Linux without a display. In an agent's folder on the same server, it also asks a person in that project to approve it (the person who approved the agent's box, else the project's owners), as an abso ask, so nobody has to relay the code; the box can then be granted that project at no more than the agent's own role. --no-ask shows the code only.",
220 run: async (args, env) => {
221 const server = boxServer(args, env);
222 const open =
223 bool(args, "no-browser") || browserSkip(env.env, process.platform) !== null
224 ? undefined
225 : (url: string) => openInBrowser(url);
226 const record = await login(server, {
227 ask: bool(args, "no-ask") ? undefined : loginAsk(server, env),
228 request: loginRequest(args),
229 say: (line) => process.stderr.write(terminalText(`${line}\n`, colorsPass(process.stderr, env.env))),
230 open,
231 });
232 return {
233 text: `This box is signed in. ${boxText(record, server).split("\n").slice(1).join(" ")}`,
234 json: { box: boxPublic(record) },
235 };
236 },
237 },
238 box: {
239 flags: { server: "string" },
240 usage: "abso box",
241 about:
242 "What this box's sign-in allows: its projects, the highest role its agents may have, how many agents it has made and may make, and when it expires. Never the credential.",
243 run: async (args, env) => {
244 const server = boxServer(args, env);
245 const record = readBox(server);
246 return { text: boxText(record, server), json: { box: boxPublic(record) } };
247 },
248 },
249 whoami: {
250 flags: { server: "string" },
251 usage: "abso whoami",
252 about:
253 "Who and where you're signed in: this box's sign-in, as the server sees it (so a revoked one shows), its projects, roles and expiry, and this folder's project, agent and kind of key. Never a credential.",
254 run: async (args, env) => {
255 const out = await whoami(boxServer(args, env), env.cwd, env.env, realProbe());
256 return { text: out.text, json: out.json };
257 },
258 },
259 doctor: {
260 flags: { server: "string" },
261 usage: "abso doctor",
262 about:
263 "Checks what commands need, one line each: Node's version, that the server answers, this box's sign-in (present, unexpired, accepted), and this folder's key against its project. A failed check says what to do next, and the exit is 1. Never prints a credential.",
264 run: async (args, env) => {
265 const checks = await doctor(boxServer(args, env), env.cwd, env.env, realProbe());
266 const failed = checks.some((c) => c.result === "fail");
267 return { text: doctorText(checks), json: { checks }, ...(failed ? { exit: EXIT.error } : {}) };
268 },
269 },
270 logout: {
271 flags: { server: "string" },
272 usage: "abso logout",
273 about:
274 "End this box's sign-in on the server and forget it here. Keys its agents already have stop working with it.",
275 run: async (args, env) => {
276 const server = boxServer(args, env);
277 const record = readBox(server);
278 if (!record) return { text: `This box isn't signed in to ${server}.`, json: { loggedOut: false } };
279 const ended = await logout(record);
280 return {
281 text: ended
282 ? `Signed this box out of ${record.server}.`
283 : `Forgot this box's sign-in here, but ${record.server} couldn't be reached to end it. Revoke the box on the website.`,
284 json: { loggedOut: true, ended },
285 };
286 },
287 },
288 orgs: {
289 flags: { server: "string" },
290 usage: "abso orgs",
291 about:
292 "Your organizations and your role in each, and invitations waiting for you. It reads as the person who approved this box's sign-in (abso login).",
293 run: (args, env) => runOrgs(boxServer(args, env)),
294 },
295 org: {
296 flags: {
297 server: "string",
298 name: "string",
299 invite: "string",
300 as: "string",
301 role: "string",
302 remove: "string",
303 leave: "boolean",
304 members: "string",
305 "projects-by": "string",
306 },
307 usage:
308 "abso org <name> [--invite <person>|link [--as owner] | --role <person>=owner|member | --remove <person> | --leave | --members read|write | --projects-by members|owners] | abso org new <name> [--name <shown name>]",
309 about:
310 "An organization: its projects, people, open invites and settings, as the person who approved this box's sign-in sees them (people and settings only to members). One change at a time. abso org new makes one as that person, from a box approved for all their projects; other changes are made on the website, and abso says where.",
311 run: (args, env) => runOrg(args, boxServer(args, env)),
312 },
313 skill: {
314 flags: { dir: "string" },
315 usage: "abso skill install [--dir <skills folder>] | abso skill show",
316 about:
317 "The abso skill for Claude Code: how to work in an abso folder, and what never to share. install writes it to ~/.claude/skills/abso/SKILL.md (--dir names another skills folder) and changes no settings; run it again after updating abso. show prints it.",
318 run: async (args, env) => {
319 const [verb, ...more] = args.positionals;
320 if (verb === "show" && more.length === 0) return { text: SKILL, json: { skill: SKILL } };
321 if (verb !== "install" || more.length > 0)
322 throw new UsageError("abso skill install [--dir <skills folder>] | abso skill show");
323 const path = skillPath(str(args, "dir"), env.cwd);
324 const done = installSkill(path);
325 const said = { installed: "Installed", updated: "Updated", current: "Already current:" }[done];
326 return {
327 text: `${said} the abso skill at ${path}. New Claude Code sessions load it.`,
328 json: { path, done },
329 };
330 },
331 },
332 join: {
333 flags: {
334 server: "string",
335 agent: "string",
336 dir: "string",
337 reader: "boolean",
338 "token-file": "boolean",
339 local: "boolean",
340 store: "string",
341 },
342 usage:
343 "abso join <project> [--agent <name>] [--dir <folder>] [--reader] [--token-file] | abso join <project> --local [--agent <name>] [--store <folder>] [--dir <folder>]",
344 about:
345 "Join a project as a new agent and write its shared files into a folder: --dir, else here when this folder is empty, else ./<project> (which has to be new or empty). Without --agent the agent is named after this box (the name abso login gave it, lower-cased), or the next free <name>-2, <name>-3; that needs the box signed in with abso login. --reader joins as a reader: it reads everything and records nothing, and the server refuses its edits, records and pushes. With --reader and no sign-in, a public project is joined to read signed out: the folder holds only its settings, sends no sign-in, and runs status, log, show, files, blame, why, where, issues, issue and search; every other command is refused. It says what it signs in with: a new key from this box's sign-in, the folder's key, or ABSO_TOKEN; this machine's ~/.abso/token only with --token-file, never unasked. --local joins a local project (abso init --local) from the same store: --store, else ABSO_STORE, else this user's data folder; the agent is --agent, else this computer's name.",
346 run: runJoin,
347 },
348 record: {
349 flags: { all: "boolean", binary: "string" },
350 usage: "abso record [--all]",
351 about:
352 "Send every file that changed since the server last heard about it (--all: every file). For edits the hook did not see.",
353 run: runRecord,
354 },
355 push: {
356 flags: {
357 message: "string",
358 binary: "string",
359 "as-is": "boolean",
360 check: "optional",
361 box: "string",
362 wait: "string",
363 "no-wait": "boolean",
364 done: "boolean",
365 },
366 usage: 'abso push -m "<why>" [--as-is] [--check ["<command>"]] [--wait <seconds> | --no-wait] [--done]',
367 about:
368 'Record, then add your draft to shared. Refused when it collides with work pushed since your last pull, or when lines a pull showed changed on both sides are still untouched (--as-is pushes both sides\' lines anyway). --check "<command>" (e.g. --check "npm run typecheck") first pulls, then runs the command in your box on your draft with newest shared, and pushes only if it exits 0, so two changes that each pass alone can\'t turn shared red. --check alone runs the "build" and then the "check" in the project\'s abso.json (your draft\'s copy), as the server does on each new version. With the merge queue on ("queue": true in abso.json), a push to shared is queued and lands only once the project\'s check passes on shared with it on top: push waits up to 100 s for that (--wait <seconds> changes it, --no-wait returns at once), then says it landed (exit 0), was turned back with the check\'s output (exit 2, its changes still in your draft), or is still queued (exit 3; the outcome comes as news). --check alone is skipped then, since the queue runs the check. --done takes your start note back once it\'s pushed: this push finishes that work.',
369 run: runPublish,
370 },
371 bisect: {
372 flags: { good: "string", bad: "string", box: "string" },
373 usage: "abso bisect [--good <version>] [--bad <version>] -- <program> <arg...>",
374 about:
375 "The first version where a check fails: runs it in your box at versions of your folder's space (as abso run --at does) and prints that version, its author and message. --bad is the newest by default; without --good it steps back in doubling steps until one passes, then halves the gap. A run that exits 0 passes; exit 125 means it can't be tested (as in git bisect run), so that version is skipped, and if skips leave the answer open it names the range. About log2(versions) runs; your folder is never touched.",
376 rest: true,
377 run: runBisect,
378 },
379 reader: {
380 flags: {},
381 usage: "abso reader on|off",
382 about:
383 "Make this folder's agent a reader, which reads everything and records nothing (the server refuses its edits, records and pushes), or a writer again. Refused while it has unpushed or parked work.",
384 run: runReader,
385 },
386 settle: {
387 flags: { yours: "boolean", theirs: "boolean", both: "boolean" },
388 usage: "abso settle <file...> --yours|--theirs|--both",
389 about:
390 "Settle the collisions a pull marked in these files: each marker block becomes your lines, theirs, or both (yours first), then it records. abso status lists the files with markers.",
391 run: runSettle,
392 },
393 pull: {
394 flags: { verbose: "boolean", full: "boolean" },
395 usage: "abso pull [--full]",
396 about:
397 "Record, then bring shared's new work into the folder. Lines changed on both sides are listed as collisions to settle. --full writes any file of yours the folder is missing, not only what changed since your last pull.",
398 run: runSync,
399 },
400 run: {
401 flags: {
402 detach: "boolean",
403 replace: "boolean",
404 fresh: "boolean",
405 parallel: "boolean",
406 at: "string",
407 files: "string",
408 fetch: "string",
409 box: "string",
410 with: "string",
411 quiet: "boolean",
412 },
413 usage:
414 'abso run [--detach] [--replace] [--fresh] [--box <name>] [--at <version> [--files <glob>]] <command...> | abso run ... -- <program> <arg...> | abso run --parallel "<command>" "<command>"...',
415 about:
416 "Send the folder to this agent's box, run the command there, and stream its output back. Exits with the command's code. After --, each word goes to the program exactly as typed (quotes, backslashes, regex text); without --, the words are one shell command. The box's stderr comes out on stderr. --detach starts it and prints its id without waiting. While a run is still going in the box, a new one is refused (409, naming it), since it would replace the files under it; --replace stops the old one first. --parallel runs each quoted command at once in the box (one upload), labels each line [1], [2], ..., ends with each one's exit code, and exits with the worst. --at <version> runs that version of the folder's space instead of the folder (for bisecting); with --files <glob>, only the matching files are taken from that version. The folder is never touched. --fetch <glob>[,<glob>...] brings matching files from the box's /w back after the run (see abso fetch); several globs go in one argument, comma-separated (--fetch 'shots/*.png,out/*.json'), as for --files and --with. The box's /w is replaced by your folder on every run; the rest of the box (/tmp, ~/.cache, /w/node_modules) lasts between runs until the box stops (idle 30 minutes, or restarted). abso's own notices go to stderr, apart from the command's output; --quiet drops them (the command's own stderr still comes through). --with <box path>=<local path>[,...] adds files (or a folder's files) for this run only: they go to the box and are never written to your folder or recorded, for an A/B run that leaves the project alone. --box <name> (or ABSO_BOX=<name>) runs in another box of yours, with its own /w and state, so a subagent's runs and yours don't wait on each other; logs and fetch take --box too. After abso prep, a fresh box starts from the prep; --fresh starts this run from the plain image instead.",
417 rest: true,
418 run: runRun,
419 },
420 serve: {
421 flags: { version: "string", build: "string", out: "string" },
422 usage: 'abso serve [--version <n>] [--build "<command>"] [--out <folder>]',
423 about:
424 "A preview of one version of shared (the newest by default) at a stable URL that needs no token, for playing a fixed build in a browser with no local server and no sound on this machine. The server builds it once per version (npm ci, then vite build --base ./ into dist; --build and --out change that) and keeps the newest 10 builds. Asking again for a built version answers at once.",
425 run: runServe,
426 },
427 mv: {
428 flags: {},
429 usage: "abso mv <from> <to>",
430 about:
431 "Move a file in your draft, its lines keeping their history (as git mv), recorded as a move rather than guessed from the folder. The way to change a file's case: README.md and readme.md are one file in abso, and a write under another spelling goes to the existing one, with a warning that names abso mv. It reaches shared with your next push.",
432 run: runMv,
433 },
434 review: {
435 flags: { since: "string" },
436 usage: "abso review [<id> | v<version> | <agent>] [--since <position|2h>]",
437 about:
438 "Review is reading what landed. With no change: the changes with anything new since you last looked, newest first (a change is one start note's work, a named draft's, or a lone push), and the mark moves on; --since 2h (or a log position) looks further back without moving it. With a change id, v<version> (the change holding that version of shared) or an agent (its newest change): that change's page, with what it set out to do, its versions, what it settled, its reviewers and its notes.",
439 run: runReview,
440 },
441 note: {
442 flags: {
443 object: "boolean",
444 read: "boolean",
445 draft: "string",
446 at: "string",
447 reply: "string",
448 close: "string",
449 resolved: "boolean",
450 withdrawn: "boolean",
451 },
452 usage:
453 'abso note <file>:<line>[-<line>] "<text>" [--object | --read] [--draft <agent> | --at <version>] | abso note --reply <id> "<text>" | abso note --close <id> --resolved|--withdrawn',
454 about:
455 "A note on lines: it sits on those lines and follows them as the file changes. The lines' authors and the change's agent hear it as news. The line numbers are as your folder shows the file (it records first); --draft <agent> notes their unpushed work as their draft shows it, --at <version> a version of shared. --object asks for a fix (it shows as addressed once all its lines change); --read says you read it, telling nobody. --reply answers a note; --close closes one of yours.",
456 run: runNote,
457 },
458 notes: {
459 flags: { change: "string", all: "boolean" },
460 usage: "abso notes [file] [--change <id>] [--all]",
461 about:
462 "The open notes, on a file or a change, with their replies and where their lines are now. --all includes closed, addressed and outdated ones.",
463 run: runNotes,
464 },
465 issues: {
466 flags: {
467 open: "boolean",
468 status: "string",
469 agent: "string",
470 parent: "string",
471 label: "string",
472 labels: "boolean",
473 drafts: "boolean",
474 },
475 usage:
476 "abso issues [--open] [--status <status>] [--agent <agent>] [--parent <N>] [--label <l,l>] | abso issues --labels",
477 about:
478 "The project's issues, most recently updated first, each with its status, agents, labels, versions and who it waits on. --label keeps the issues with every label named (friction, say); --labels lists the labels in use, with how many issues are open under each; --drafts lists your drafts. A status comes from the work: abso start --issue N puts an issue In progress, an open ask makes it Blocked (or In review, for a review), and push --done closes it.",
479 run: runIssues,
480 },
481 issue: {
482 flags: {
483 comment: "string",
484 object: "string",
485 drop: "boolean",
486 reopen: "boolean",
487 done: "boolean",
488 "done-by": "string",
489 title: "string",
490 description: "string",
491 parent: "string",
492 lines: "string",
493 agent: "string",
494 "blocked-by": "string",
495 notify: "string",
496 quiet: "boolean",
497 label: "string",
498 unlabel: "string",
499 open: "boolean",
500 delete: "boolean",
501 attach: "string",
502 "copy-to": "string",
503 clean: "string",
504 "dry-run": "boolean",
505 "save-attachments": "string",
506 },
507 usage:
508 'abso issue <N> --save-attachments <folder> | abso issue <N> --copy-to <project> [--clean <file>] [--dry-run] | abso issue <N> [--comment "..." [--attach <file,file>] | --object "..." | --drop | --reopen | --done [--done-by <version>]] | abso issue <N> [--title "..."] [--description "..."] [--parent <N|none>] [--agent <agent|none>] [--blocked-by <N,N|none>] [--label <l,l>] [--unlabel <l,l>] [--notify <who,who> | --quiet] | abso issue new "<title>" [--description "..."] [--parent <N>] [--lines <file>:<from>-<to>@<version>] [--agent <agent>] [--blocked-by <N,N>] [--notify <who,who>] [--label <l,l>] [--attach <file,file>]',
509 about:
510 "One issue: its description, Agent, Blocked by, labels, asks, comments, edits, sub-issues and watchers. --comment comments on it and --object objects; its agents hear either. A comment holds up to 4000 characters: a longer --comment (or --comment-file) goes up in parts, split at paragraph breaks and each starting (1/3), (2/3) and so on, and a longer --object is refused before anything is sent. --drop drops it. --reopen opens a dropped issue again. --done marks it done by hand, and --done-by <version> names the pushed version that did it. push --done still marks it done too. --title, --description, --parent, --agent and --blocked-by edit it, and the edit tells its watchers (who opened it, its Agent and agents, its Reviewer, whoever was named in Notify, and whoever commented); --notify tells more people, --quiet tells nobody. --label adds labels and --unlabel takes them off (friction, area:client: lower-case letters, digits and - _ . :); a label-only edit tells nobody unless --notify names people. An issue is Blocked until each issue it's blocked by is Done. abso issue new opens one; --lines ties it to lines at a version of shared, --agent says who it's for, --notify tells people now, and --label labels it. --attach shot.png,after.png puts images on a new issue or a comment (png, jpeg, gif or webp, 10 MB each; the server checks the type by the bytes and takes out metadata such as where a photo was taken. An svg, up to 1 MB, is drawn as a png, and its own file is kept as a download, on servers that take svg), and prints each one's id for the text to point at; the issue's page lists them with a link, and --save-attachments <folder> saves every one on the issue and its comments there as <id>-<name> (an svg's own file too), outside the abso folder or where abso leaves files out. --copy-to <project> copies the issue into another project, with its comments, answered asks and labels, each keeping its author and time; --dry-run shows what would go and writes nothing, and --clean <file> gives cleaned texts by source id as JSON ({title, description, comments: [{id, text}], asks: [{id, question, answer}]}; a comment left out of a given list isn't copied). Copying out of a project on a live server takes an owner of that project. abso issue draft \"<title>\" [the same fields] saves a draft instead: yours alone, with no number and no news; abso issue draft <D> [fields] changes it, --open opens it as an issue, --delete deletes it.",
511 run: runIssue,
512 },
513 ask: {
514 flags: {
515 issue: "string",
516 review: "boolean",
517 task: "boolean",
518 due: "string",
519 blocks: "string",
520 options: "string",
521 withdraw: "string",
522 note: "string",
523 attach: "string",
524 },
525 usage:
526 'abso ask <who> "<question>" [--issue <N>] [--review | --task] [--due <YYYY-MM-DD>] [--blocks <N,N>] [--options "A|B|C"] [--attach <file,file>] | abso ask <N> | abso ask --withdraw <ask> [--note "why"]',
527 about:
528 "Ask an agent, or a person (person:<id>), something; they hear it. Who must be one of the project's agents or members; a name that isn't is refused, with the closest one suggested. abso ask <N> shows ask N, open or closed, with its whole thread, its answer and whose turn it is. On an issue, it holds the issue at Blocked (In review for --review) until answered. --task asks for something done instead of an answer; --options gives the choices; --blocks names the issues waiting on it. --attach sends files with the question, as on an issue. --withdraw takes back an ask you made that no longer needs an answer: it leaves their waiting list, stops holding the issue, keeps your --note as why, and they hear it.",
529 run: runAsk,
530 },
531 search: {
532 flags: { limit: "string" },
533 usage: 'abso search "<words>" [--limit <N>]',
534 about:
535 "The project's issues that match, best first: by their words, and by what they mean where the server has meaning search on, so an issue worded differently from your search still turns up. #N or N puts issue N first. Each hit says where it matched; one only meaning search found says by meaning.",
536 run: runSearch,
537 },
538 waiting: {
539 flags: { of: "string", mine: "boolean", asked: "boolean" },
540 usage: "abso waiting [--of <agent or person:id>] [--mine] [--asked]",
541 about:
542 "The open asks, soonest due first: every one, those waiting on someone (--of), or those waiting on you (--mine), each with its newest reply. An ask waits on the one asked until they answer, or on the asker after a reply with --question, until the asker replies. --mine also lists your pushes still in the merge queue and where each stands; the outcome comes as news. --asked lists the asks you sent instead, open ones first, then the latest answered.",
543 run: runWaiting,
544 },
545 answer: {
546 flags: { option: "string", note: "string", done: "boolean", attach: "string" },
547 usage:
548 'abso answer <ask> "<words>" | abso answer <ask> --option <N> [--note "..."] | abso answer <ask> --done [--note "..."], each with [--attach <file,file>]',
549 about:
550 "Answer an ask of you, in your own words, by picking an option (by number or text), or, for a task, with --done. --attach sends files with the answer. The asker hears it.",
551 run: runAnswer,
552 },
553 ack: {
554 flags: {},
555 usage: 'abso ack <ask> ["<note>"]',
556 about:
557 "Acknowledge an ask of you without answering it yet: it's the first reply in its thread. The asker hears it, with your note, and the ask stays open. abso reply adds more; abso answer closes it later.",
558 run: runAck,
559 },
560 reply: {
561 flags: { question: "boolean" },
562 usage: 'abso reply <ask> "<words>" [--question]',
563 about:
564 'Add to an ask\'s thread, as its asker or the one asked, open or closed: "ok, let me check", what you found, a follow-up. The other side hears it, and the ask stays as it is; abso answer still closes it. --question, from the one asked, asks the asker something back: the ask waits on them until they reply. On a public project, anyone can read the thread.',
565 run: runReply,
566 },
567 groups: {
568 flags: {},
569 usage: "abso groups",
570 about:
571 "The project's groups you can see: named sets of agents and people, each with one shared history. A private group shows only to its members and the project's owners. abso group <name> reads one.",
572 run: runGroups,
573 },
574 group: {
575 flags: {
576 post: "string",
577 reply: "string",
578 news: "string",
579 except: "string",
580 join: "boolean",
581 leave: "boolean",
582 add: "string",
583 remove: "string",
584 rename: "string",
585 private: "optional",
586 joinable: "string",
587 closed: "boolean",
588 before: "string",
589 limit: "string",
590 kind: "string",
591 },
592 usage:
593 'abso group <name> [--post "<words>" [--reply <N>] [--news all|none|<names> | --except <names>]] [--join | --leave | --add <who> | --remove <who> | --rename <name> | --private on|off | --joinable on|off] [--before <N>] [--limit <N>] [--kind message|member|settings] | abso group new <name> [--private] [--closed] [--add <names>]',
594 about:
595 "A group: its settings, members and history, newest first (--before reads further back, --kind filters). --post adds a message, with news for every other member unless --news names some, --except leaves some out, or --news none keeps it in the history only. A retry never posts twice. --join and --leave are yours to do any time, for a joinable group; a private one is joined only by its exact name. Its maker and the project's owners add, remove, rename and switch private and joinable. abso group new makes one, with you in it; --closed means members are added rather than joining. A reader may make, join and post in groups too.",
596 run: runGroup,
597 },
598 unqueue: {
599 flags: {},
600 usage: "abso unqueue",
601 about:
602 "Take back your pushes still waiting in the merge queue: their changes stay in your draft, unpushed. Refused while one is being checked; it lands or is turned back within a few minutes (abso drop takes it back after it lands).",
603 run: runUnqueue,
604 },
605 visibility: {
606 flags: { yes: "boolean" },
607 usage: "abso visibility [public|private] [--yes]",
608 about:
609 "Whether the project is public. With no word, says which. public, with --yes, lets anyone read it, signed in or not: files, versions, drafts, notes, Issues, people's names, CI as pass or fail; never keys, CI logs, preview links or boxes. private makes it members-only again. Switching takes the project owner's key (on staging, the shared token works too).",
610 run: runVisibility,
611 },
612 autosettle: {
613 flags: { at: "string" },
614 usage: "abso autosettle [off|advise|settle] [--at 0.3-0.95] | abso autosettle history [<id>]",
615 about:
616 "What the server does with a held push (abso-core 23). With no word, says which. advise: each collision comes back with a model's pick (keep yours, keep theirs, keep both, or leave it to an agent), how sure it is, and why; the agent still settles. settle: when the model is at least --at sure about every collision, your abso settles it and pushes again by itself, saying so in the message; anything less sure stays held, with the advice. off: held pushes come back as they always have. New projects start on advise. Changing it takes the project owner's key (on staging, the shared token works too). ABSO_AUTOSETTLE=off on a machine makes its abso settle nothing by itself. abso autosettle history lists the held pushes the model advised on, newest first, with what it said and what was then kept; history <id> shows one, with its calls to the model (--json has each request and answer).",
617 run: runAutosettle,
618 },
619 flag: {
620 flags: { why: "string", project: "string", person: "string", limit: "string" },
621 usage:
622 'abso flag [list] | abso flag log [--limit N] | abso flag set <flag> <value> --why "..." [--project <name> | --person person:<id>] | abso flag unset <flag> --why "..." [--project <name> | --person person:<id>]',
623 about:
624 "The server's feature flags: switches flipped while it runs, with no deploy. list shows each flag, the values it takes, its safe default, what it gates, and where it's set. set gives it a value for the whole server, or for one --project or --person; unset takes that value away. Each change says --why, and the server keeps who, when, the old and new value, and why; log shows those changes, newest first. A read takes the person's value, then the project's, then the whole server's, then the safe one. The server decides who may: its admin token, read from ABSO_ADMIN_TOKEN or ~/.abso/admin-token and sent only to a server ABSO_ADMIN_SERVERS names, and an owner's key where the server takes one. An agent does not flip a flag unless a person on the project says so.",
625 run: runFlag,
626 },
627 ci: {
628 flags: { version: "string", revoke: "boolean" },
629 usage: "abso ci [<version>] | abso ci --revoke",
630 about:
631 "The project's CI: the server runs abso.json's setup, build and check on each new version of shared, one job at a time on the newest. abso ci says whether shared is green or red (and since which version, by whom, once a bisect finds it), what is being checked, and the preview link of the newest passing build, which needs no token. abso ci <version> shows that version's job: which step failed, its exit code, and the end of its output. status says the same in a line, and log marks each version of shared. --revoke ends every preview link handed out so far and makes a new one.",
632 run: runCi,
633 },
634 shot: {
635 flags: {
636 out: "string",
637 wait: "string",
638 size: "string",
639 box: "string",
640 eval: "string",
641 click: "string",
642 mouse: "string",
643 at: "string",
644 scale: "string",
645 region: "string",
646 text: "boolean",
647 tree: "boolean",
648 interactive: "boolean",
649 depth: "string",
650 find: "string",
651 "max-chars": "string",
652 image: "boolean",
653 },
654 usage:
655 'abso shot ["/<path>?<query>"] [--scale 0.1-1] [--region x0,y0,x1,y1] [--text] [--tree [--interactive] [--depth N]] [--find "<text>"] [--max-chars N] [--image] [--at <version>] [--eval "<js>"] [--click "x,y[@ms];ref_N[@ms]"] [--mouse x,y|ref_N] [--out <file.png>] [--wait <ms>] [--size <w>x<h>]',
656 about:
657 "A look at your folder's game, taken in your box: it runs the project's vite dev server and Playwright on that page (default /, a 1280x720 page). Images cost tokens, so read without one when you can: --text prints the page's visible text, --tree its elements (role, name, a ref like ref_12, and its box in page pixels; --interactive only what can be clicked or typed in; --depth N levels), and --find \"<text>\" the elements matching some text; each is capped at --max-chars (default 5000). With none of those, or with --image, it writes a PNG to .abso/shots/ (never recorded) or --out, and prints its pixel size and about how many tokens reading it costs (width x height / 750). --scale 0.5 halves the width and height (a quarter of the tokens); --region x0,y0,x1,y1 takes part of the page at full detail; they combine. Coordinates are always the page's, whatever the scale or region. To set up a state first, --eval runs JavaScript in the page and --click clicks points (x,y or ref_N; several separated by ;; @ms waits first), in that order, a second after load and two frames after the eval; --mouse x,y or ref_N leaves the pointer there (for hover cards); then it waits --wait ms (default 3000) and looks. It prints --eval's result, page errors and the first 30 console messages. Refs come from --tree or --find on the same page in the same state. --at <version> looks at that version of your folder's space instead of the folder (as abso run --at). Needs vite and playwright in the project's devDependencies; abso prep with npx --no-install playwright install chromium makes it fast.",
658 run: runShot,
659 },
660 prep: {
661 flags: { forget: "boolean", box: "string" },
662 usage: 'abso prep [--box <name>] "<setup command>" | abso prep --forget',
663 about:
664 "Set up your box once and keep it: sends the folder, runs the setup command (npm ci, npx playwright install chromium, a build) in a fresh box of the current image, and saves the box. From then on every fresh box (after a deploy, 30 idle minutes, or a new run's restart) starts from it, with node_modules, ~/.cache and /tmp as the setup left them; /w is still replaced by your folder on each run, apart from node_modules. abso run says when the prep is set aside (a newer box image) or out of date (package-lock.json changed): run abso prep again then. --forget drops it.",
665 rest: true,
666 run: runPrep,
667 },
668 fetch: {
669 flags: { box: "string" },
670 usage: "abso fetch [--box <name>] <glob...>",
671 about:
672 "Files the last run left in the box's /w (bash globs: out/*.png, **/*.log), written into the folder, but only where abso ignores them, so a fetched file never becomes an edit; the rest are named and left alone. /w is replaced on the next run, and everything goes when the box stops.",
673 run: runFetch,
674 },
675 pause: {
676 flags: {},
677 usage: "abso pause",
678 about:
679 "Send nothing from this folder until abso resume: the edit hook skips, abso record refuses, other commands don't record first. For swapping files in by hand (abso run --at usually does it better).",
680 run: runPause,
681 },
682 resume: {
683 flags: {},
684 usage: "abso resume",
685 about: "End abso pause. Changes made while paused go at the next record.",
686 run: runResume,
687 },
688 logs: {
689 flags: { box: "string" },
690 usage: "abso logs [--box <name>] <run id>",
691 about:
692 "A run's output from its start (stdout and stderr apart), for as long as the box keeps it, waiting until it ends. Exits with its code. For abso run --detach, or a run whose connection was lost.",
693 run: runLogs,
694 },
695 status: {
696 flags: { short: "boolean" },
697 usage: "abso status [--short]",
698 about:
699 "The shared version, whether shared is green or red by the project's CI (abso ci has more), who waits in the merge queue, every agent's base and draft, and what in this folder is not yet recorded. --short prints one word for stamping a build: the version this folder is on (214), with the named draft (coast@3), +unpushed when it holds changes not yet pushed, and +queued when a push of yours waits in the merge queue.",
700 run: runStatus,
701 },
702 switch: {
703 flags: { carry: "boolean", verbose: "boolean" },
704 usage: "abso switch <draft> | abso switch -c <new draft> | abso switch shared",
705 about:
706 "Move this folder to a named draft, or back to shared. Your unpushed changes are parked where you leave and come back when you return; -c carries them into a new draft instead.",
707 run: runSwitch,
708 },
709 land: {
710 flags: { message: "string" },
711 usage: 'abso land -m "<why>"',
712 about:
713 "Land your named draft in shared, as one unit. Refused only on a collision with work that landed in shared since the draft began.",
714 run: runLand,
715 },
716 "draft-pull": {
717 flags: {},
718 usage: "abso draft-pull",
719 about: "Move your named draft onto shared's newest version, then bring that into this folder.",
720 run: runDraftSync,
721 },
722 diff: {
723 flags: { draft: "string", agent: "string" },
724 usage: "abso diff [file...] [--agent <name>] | abso diff <from> <to> [file...] [--draft <name>]",
725 about:
726 "Your unpushed changes, line by line, as git prints them (records first). --agent <name>: that agent's recorded, unpushed changes instead, to review them; it changes nothing. With two versions: what changed between them in this space.",
727 run: runDiff,
728 },
729 restore: {
730 flags: { all: "boolean" },
731 usage: "abso restore <file...> | abso restore <file>:<line>[-<line>] | abso restore --all",
732 about:
733 "Discard your unpushed changes to those files (--all: to every file), like git restore. The files go back to how your space has them. <file>:<lines> puts back only the changes that touch those lines (numbered as abso diff shows the file now) and keeps your other changes to it.",
734 run: runRestore,
735 },
736 export: {
737 flags: { version: "string", keep: "string", without: "string" },
738 usage: "abso export <dir> [--version <N>] [--without <version,...>] [--keep <glob>]",
739 about:
740 "Write one pushed version of this folder's space (the newest unless --version) into a folder of its own, for a build that doesn't move. The folder must be empty, an earlier export (which it replaces, keeping node_modules and what --keep names), or one .absoignore leaves out; .avcs-export.json there names the version. --without 37,38 writes the version of shared with those earlier versions left out, and names them there too; shared doesn't change, and it is refused, naming the chain, when a version it keeps builds on one left out.",
741 run: runExport,
742 },
743 files: {
744 flags: { draft: "string", version: "string" },
745 usage: "abso files [glob...] [--draft <name>] [--version <N>]",
746 about:
747 "The files your folder should hold (your view), marking any it's missing. With --draft or --version: that space's files at that version (--draft shared for shared).",
748 run: runFiles,
749 },
750 log: {
751 flags: { limit: "string", before: "string", draft: "string", since: "string", by: "string", count: "boolean" },
752 usage:
753 "abso log [file] [-n <count>] [--before <version>] [--draft <name>] [--since <version|30m|2h|1d|date>] [--by <agent,...>] [--count]",
754 about:
755 "The pushed versions of this folder's space (shared or a named draft), newest first: who, when, why and which files, and for shared, whether the version passed CI's check (abso ci). With a file: only the versions that changed it. --before <version> starts below that version, so any stretch of history can be listed; the end of the list names the --before for the next older ones. --since takes a version (the versions after it), a span back from now (30m, 2h, 1d), a clock time today (20:00) or a date and time; --by keeps one agent's versions (or several, comma-separated); --count prints versions and files per agent instead of the list.",
756 run: runLog,
757 },
758 show: {
759 flags: { draft: "string", without: "string" },
760 usage: "abso show <version> | abso show <version>:<file> [--draft <name>] [--without <version,...>]",
761 about:
762 "One version: who pushed it, why, and its diff. With :<file>, that file's text as it was then. --without 37,38 shows the version of shared with those earlier versions left out: what differs, and with :<file> that file. Shared doesn't change. Refused, naming the chain, when a version it keeps builds on one left out.",
763 run: runShow,
764 },
765 announce: {
766 flags: { to: "string" },
767 usage: "abso announce [--to <agent,agent>] <text>",
768 about:
769 "Tell the project's other agents (or those named) something. Each gets it once, as news on their next edit or the mod's next check.",
770 run: runAnnounce,
771 },
772 start: {
773 flags: { done: "boolean", issue: "string" },
774 usage: 'abso start "<what>" [files...] [--issue <n>] | abso start --done',
775 about:
776 "Say what you are starting on, before your first edit, so abso where shows it to everyone. Names who already has unpushed changes in those files, and tells them. Nothing is locked; pushing ends the note.",
777 run: runStart,
778 },
779 news: {
780 flags: { stream: "boolean", follow: "boolean" },
781 usage: "abso news [--stream | --follow]",
782 about:
783 "The news waiting for you: collisions, changed definitions, moved lines and announcements. Each item comes once. --stream prints a Monitor call that wakes a Claude Code chat the moment news arrives (a ticket that opens the stream once, within a minute); --follow holds the stream itself and prints a line per item until stopped.",
784 run: runNews,
785 },
786 "fix-eol": {
787 flags: {},
788 usage: "abso fix-eol",
789 about:
790 "Rewrite the files that differ from what abso recorded only in line endings (CRLF here) with LF, as recorded. Their text is unchanged, so nothing is recorded; abso status stops listing them.",
791 run: runFixEol,
792 },
793 who: {
794 flags: {},
795 usage: "abso who <file...>",
796 about:
797 "For each file: who last changed it, who has unpushed changes in it (and where), and whose abso start note names it. Ask before you start in someone's file.",
798 run: runWho,
799 },
800 where: {
801 flags: {},
802 usage: "abso where",
803 about: "Who is working where: each file with unpushed changes, whose they are, and which lines.",
804 run: runWhere,
805 },
806 blame: {
807 flags: { from: "string", to: "string", version: "string", draft: "string", mine: "boolean" },
808 usage: "abso blame <file> [--from <n>] [--to <n>] [--version <n>] [--draft <name> | --mine]",
809 about:
810 "Who wrote each line of the file as shared has it (or had it at --version), and the push that brought it in. --draft reads a named draft; --mine reads your own view, marking your unpushed lines with *.",
811 run: runBlame,
812 },
813 why: {
814 flags: { draft: "string", mine: "boolean", at: "string", all: "boolean" },
815 usage: "abso why <file>:<line> [--at <version>] [--all] [--draft <name> | --mine]",
816 about:
817 "Why one line of shared (or of a named draft, or your own view) is the way it is: the newest change to what it does, its push, its reasons, any collision it settled, and the line's earlier changes, newest first. Changes that only touched formatting (whitespace, line wrapping, quotes, trailing commas) are skipped, and why says which; --all shows them too. A line imported from git names its commit, and #N in it names the old repository's issue when abso.json's \"gitIssues\" says where those are. --at <version> reads the line as shared (or the draft) had it then, as blame --version does.",
818 run: runWhy,
819 },
820 drop: {
821 flags: { message: "string", "with-dependents": "boolean" },
822 usage: 'abso drop <version...> -m "<why>" [--with-dependents]',
823 about:
824 "Take pushed versions back out of shared, as a new version: like git revert. History keeps them. Refused when later versions build on them, unless --with-dependents drops those too.",
825 run: runDrop,
826 },
827 pluck: {
828 flags: { message: "string", "with-dependencies": "boolean" },
829 usage: 'abso pluck <draft> <version...> -m "<why>" [--with-dependencies]',
830 about:
831 "Take some versions of a named draft into shared, as one version, leaving the draft as it is: like git cherry-pick. Refused when they build on other versions of the draft, unless --with-dependencies takes those too.",
832 run: runPluck,
833 },
834 amend: {
835 flags: { message: "string" },
836 usage: 'abso amend -m "<new message>"',
837 about:
838 "Correct the message of your newest push in this space. Only the message changes; the log keeps the original.",
839 run: runAmend,
840 },
841 label: {
842 flags: { version: "string", remove: "boolean" },
843 usage: "abso label <name> [--version <n>] [--remove]",
844 about:
845 "Put a label on a version of shared (the newest by default), or take it off: like a git tag. A label can mark more than one version.",
846 run: runLabel,
847 },
848 labels: {
849 flags: {},
850 usage: "abso labels",
851 about: "Every label and the versions it marks.",
852 run: runLabels,
853 },
854 follow: {
855 flags: { none: "boolean" },
856 usage: "abso follow <label> | abso follow --none",
857 about:
858 "Make this folder follow a label: every pull takes it to the newest version of shared with that label, not the newest version. --none goes back to following shared.",
859 run: runFollow,
860 },
861 "check-ignore": {
862 flags: {},
863 usage: "abso check-ignore <path...>",
864 about:
865 "Whether abso leaves each path out, and which line of which ignore file decided (git's rules, for .gitignore and .absoignore).",
866 run: runCheckIgnore,
867 },
868 pipeline: {
869 flags: { on: "string", space: "string", pipeline: "string", every: "string", log: "string" },
870 usage:
871 "abso pipeline check [file] [--on push|draft|green|land|hand|schedule [--space <name>] [--pipeline <name>] [--every <when>]] | abso pipeline runs [<run>] [--log <pipeline.job>]",
872 about:
873 "Read the folder's pipeline file (abso.yml, abso.yaml or abso.json, or the file named) and say what's wrong with it, place by place: a cycle in needs, a job that doesn't exist, secrets a draft could reach, a key it doesn't know. Exits 1 when it has problems. With --on, it says which pipelines that event starts (in shared, or --space), with their jobs in waves that can run side by side, and why each other pipeline doesn't start. It reads only the file. abso pipeline runs asks the server what the project's pipelines did: the runs, newest first; with a run's number, its jobs (state, why, exit, time, an npm or deploy job's phase); with --log <pipeline.job>, that job's output.",
874 // Loaded only here, so the yaml package it needs can't stop every other command
875 // when a checkout lacks it (abso issue 168).
876 run: async (args, env) => {
877 let mod: typeof import("./pipeline-commands.ts");
878 try {
879 mod = await import("./pipeline-commands.ts");
880 } catch (e) {
881 if ((e as { code?: string }).code === "ERR_MODULE_NOT_FOUND")
882 throw new UsageError(
883 `abso pipeline needs a package this copy of abso doesn't have installed (${(e as Error).message.split("\n")[0]}); run npm install where abso is installed`,
884 );
885 throw e;
886 }
887 return mod.runPipeline(args, env);
888 },
889 },
890};
892const HELP_INTRO = "abso: version control for agents. This is its command-line client.";
893const HELP_NOTE =
894 "Every command takes --json. Settings live in .abso/config.json (.avcs/config.json in a folder from before the rename). A folder with a key signs in with that key and nothing else. Without one, the token comes from ABSO_TOKEN; this machine's ~/.abso/token (or ~/.avcs/token from before) is used only by a command given --token-file. " +
895 "Every command that talks to a server takes --server <url>; one that works only on this machine (skill, check-ignore, pause, resume, fix-eol) doesn't. In a joined folder --server must be the folder's own server: another is refused, never swapped in. An explicit --server is used as given, and no setting redirects it. The server is " +
896 SERVER_ORDER +
897 ": which servers this box is signed in to plays no part.";
899/** A command's flags: its own, and --server and --token-file for every command that talks to a server (server-choice.ts). */
900function flagsOf(name: string, def: CommandDef): FlagSpec {
901 return serverUse(name) === "local" ? def.flags : { ...def.flags, server: "string", "token-file": "boolean" };
902}
904/** Every command as help shows it, in order: the table's, then the three it doesn't hold. */
905function helpEntries(): { name: string; usage: string; about: string; flags: FlagSpec; server?: string }[] {
906 return [
907 ...Object.entries(COMMANDS).map(([name, c]) => {
908 const server = serverHelp(name);
909 return { name, usage: c.usage, about: c.about, flags: flagsOf(name, c), ...(server ? { server } : {}) };
910 }),
911 {
912 name: "hook",
913 usage: "abso hook",
914 about: "The Claude Code PostToolUse hook. Reads the hook JSON on stdin; never fails.",
915 flags: {},
916 },
917 {
918 name: "mcp",
919 usage: "abso mcp",
920 about:
921 "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).",
922 flags: {},
923 },
924 {
925 name: "--version",
926 usage: "abso --version",
927 about: "This client's version and commit, and the abso mods installed on this machine.",
928 flags: {},
929 },
930 ];
931}
933function help(): string {
934 const entries = helpEntries().flatMap((c) => [
935 ` ${c.usage}`,
936 ` ${c.about}`,
937 ...(c.server ? [` ${c.server}`] : []),
938 ]);
939 return [HELP_INTRO, "", ...entries, "", HELP_NOTE].join("\n");
940}
942/**
943 * help --json: the same entries as data, for a command reference built from the client itself. A flag is
944 * "string" (takes a value), "boolean" (stands alone) or "optional" (a value that may be left off); every
945 * command also takes --json and --help.
946 */
947function helpJson(): Record<string, unknown> {
948 return {
949 ok: true,
950 command: "help",
951 version: clientVersion(),
952 intro: HELP_INTRO,
953 note: HELP_NOTE,
954 commands: helpEntries(),
955 };
956}
958export interface MainResult {
959 readonly stdout: string;
960 readonly stderr: string;
961 readonly exit: number;
962 /** What --json prints, whether or not it was asked for (abso mcp answers with both). */
963 readonly data?: Record<string, unknown>;
964}
966/** The commands, for abso mcp: each tool is one of them. */
967export function commandTable(): Readonly<
968 Record<string, { readonly flags: FlagSpec; readonly usage: string; readonly about: string }>
969> {
970 return Object.fromEntries(Object.entries(COMMANDS).map(([name, c]) => [name, { ...c, flags: flagsOf(name, c) }]));
971}
973function newsBlock(news: readonly string[]): string[] {
974 return newsBlockLines(news.map((n) => newsShown(n)));
975}
977/** Whether this folder's calls carry a key or token, for how a refusal is worded. False when that can't be told. */
978function credentialSent(env: Env, tokenFileAsked: boolean): string | undefined {
979 try {
980 const root = findRoot(env.cwd);
981 if (root && readConfig(root, env.env, tokenFileAsked).token === undefined) return undefined;
982 if (root && existsSync(join(stateDir(root), "key"))) return "this folder's key";
983 if (fromEnv(env.env, "TOKEN")?.trim()) return "ABSO_TOKEN";
984 if (root && runKey(env.env)) return "this pipeline run's key";
985 return tokenFileAsked && tokenFile() !== undefined ? "the token file, ~/.abso/token" : undefined;
986 } catch {
987 return undefined;
988 }
989}
991/** git's forms of push and pull that abso doesn't have (#427): one plain line naming the abso way. */
992function gitOnlyForm(command: string, words: readonly string[]): string | undefined {
993 const has = (...forms: string[]) => words.some((w) => forms.some((f) => w === f || w.startsWith(`${f}=`)));
994 if (command === "push" && has("-f", "--force", "--force-with-lease", "--force-if-includes"))
995 return "abso push has no --force: nothing overwrites shared. When a push is refused, abso pull brings in the other side and abso settle keeps yours, theirs or both.";
996 if (command === "push" && has("-u", "--set-upstream", "--all", "--tags"))
997 return "abso push has no upstreams, branches or tags: it adds your draft to shared. A named draft is abso switch <name>; a label is abso label.";
998 if (command === "pull" && has("--rebase", "-r", "--no-rebase", "--ff-only", "--ff", "--no-ff", "--squash"))
999 return "abso pull has no --rebase or merge modes: it always brings shared under your draft, and lines changed on both sides are listed for abso settle.";
1000 return undefined;
1001}
1003export async function main(argv: readonly string[], env: Env): Promise<MainResult> {
1004 try {
1005 return await runMain(argv, env);
1006 } finally {
1007 // A local project's store stays open only while its command runs.
1008 closeLocalStores();
1009 }
1010}
1012async function runMain(argv: readonly string[], env: Env): Promise<MainResult> {
1013 const command = argv[0];
1014 const json = argv.includes("--json") && command !== "run" && command !== "logs";
1015 const asked = argv.includes("--token-file");
1016 if (command === undefined || command === "help" || command === "--help" || command === "-h") {
1017 if (json) {
1018 const data = helpJson();
1019 return { stdout: `${JSON.stringify(data, null, 2)}\n`, stderr: "", exit: EXIT.ok, data };
1020 }
1021 return { stdout: `${help()}\n`, stderr: "", exit: EXIT.ok };
1022 }
1023 try {
1024 if (command === "--version") {
1025 // Loaded only here: it runs git, and no other command needs it.
1026 const { versionReport } = await import("./install.ts");
1027 const { newerClientNote } = await import("./client-version.ts");
1028 const report = versionReport(env.env);
1029 const root = findRoot(env.cwd);
1030 let behind: string | undefined;
1031 if (root) {
1032 try {
1033 const server = (JSON.parse(readFileSync(configPath(root), "utf8")) as { server?: string }).server;
1034 if (server) behind = await newerClientNote(server);
1035 } catch {}
1036 }
1037 return {
1038 stdout: json
1039 ? `${JSON.stringify({ ok: true, command: "version", ...report.json, ...(behind ? { serverBehind: behind } : {}) }, null, 2)}\n`
1040 : `${report.text}${behind ? `\n${behind}` : ""}\n`,
1041 stderr: "",
1042 exit: EXIT.ok,
1043 };
1044 }
1045 const def = COMMANDS[command];
1046 if (!def)
1047 throw new UsageError(
1048 `unknown command ${JSON.stringify(command)}; the commands are ${Object.keys(COMMANDS).join(", ")}, hook, mcp`,
1049 );
1050 const gitOnly = gitOnlyForm(command, argv.slice(1));
1051 if (gitOnly) throw new UsageError(gitOnly);
1052 const use = serverUse(command);
1053 const words = argv.includes("--") ? argv.slice(1, argv.indexOf("--")) : argv.slice(1);
1054 if (use === "local" && words.some((w) => w === "--server" || w.startsWith("--server=")))
1055 throw new UsageError(localRefusal(command));
1056 const parsed = parseArgs(command, argv.slice(1), withBodyFiles(command, flagsOf(command, def)), def.rest);
1057 if ((command === "push" || command === "pull") && parsed.positionals.length > 0)
1058 throw new UsageError(
1059 `abso ${command} takes no remote or branch: it ${command === "push" ? "adds your draft to shared" : "brings shared into this folder"}. A named draft is abso switch <name>.`,
1060 );
1061 if (bool(parsed, "help")) {
1062 const files = bodyFilesHelp(command, def.flags);
1063 const server = serverHelp(command);
1064 return {
1065 stdout: `${def.usage}\n ${def.about}\n${server ? ` ${server}\n` : ""}${files ? ` ${files}\n` : ""}`,
1066 stderr: "",
1067 exit: EXIT.ok,
1068 };
1069 }
1070 // --server is checked before anything is read or sent: a bad value, or (for a command on a joined folder)
1071 // a server that isn't the folder's own, is refused here.
1072 const named = use === "local" ? undefined : serverFlag(parsed);
1073 if (named !== undefined && use === "folder") checkFolderServer(command, named, env.cwd);
1074 // A folder that reads signed out runs its reads and nothing else, refused before any call.
1075 const root = findRoot(env.cwd);
1076 if (root !== undefined && isVisitor(root)) checkVisitor(command, parsed, readConfig(root, env.env).project);
1077 const args = readBodyFiles(command, parsed, env.cwd, env.readStdin);
1078 takeNews(); // what an earlier call in this process left (tests run many)
1079 const runEnv: Env = {
1080 ...env,
1081 ...(named === undefined ? {} : { server: named }),
1082 ...(bool(parsed, "token-file") ? { tokenFile: true } : {}),
1083 };
1084 const out = await def.run(args, runEnv);
1085 const exit = out.exit ?? EXIT.ok;
1086 // Every command that took news while recording prints it (#37, News Report).
1087 const news = takeNews();
1088 const data = {
1089 ok: exit === EXIT.ok,
1090 command,
1091 ...out.json,
1092 ...(news.length > 0 && !("news" in out.json) ? { news } : {}),
1093 };
1094 if (json || bool(args, "json")) return { stdout: `${JSON.stringify(data, null, 2)}\n`, stderr: "", exit, data };
1095 // run, logs and bisect: stdout is the box command's, and may be piped; news goes to stderr there (#37).
1096 const boxOut = command === "run" || command === "logs" || command === "bisect";
1097 const text = [...(out.text === "" ? [] : [out.text.replace(/\n$/, "")]), ...(boxOut ? [] : newsBlock(news))].join(
1098 "\n",
1099 );
1100 const errText = boxOut && news.length > 0 ? `${newsBlock(news).join("\n")}\n` : "";
1101 return { stdout: text === "" ? "" : `${text}\n`, stderr: errText, exit, data };
1102 } catch (err) {
1103 const e = err as Error;
1104 const code = err instanceof UsageError ? "usage" : err instanceof ApiError ? "server" : "error";
1105 const message =
1106 plainError(err, credentialSent(env, asked), !asked && tokenFile() !== undefined) ??
1107 (err instanceof UsageError || err instanceof ApiError
1108 ? e.message
1109 : `${e.message}${e.stack ? `\n${e.stack}` : ""}`);
1110 // The server refusing (409) is like a collision: exit 2, not a failure.
1111 const exit = err instanceof ApiError && err.status === 409 ? EXIT.refused : EXIT.error;
1112 // News taken before the failure still shows.
1113 const news = takeNews();
1114 const data = { ok: false, command, error: { code, message }, ...(news.length > 0 ? { news } : {}) };
1115 if (json) return { stdout: `${JSON.stringify(data, null, 2)}\n`, stderr: "", exit, data };
1116 return {
1117 stdout: news.length > 0 ? `${newsBlock(news).join("\n")}\n` : "",
1118 stderr: `abso ${command}: ${message}\n`,
1119 exit,
1120 data,
1121 };
1122 }
1123}
1125/**
1126 * abso 684: in an agent's folder on this same server, the ask `abso login` makes of a person in that project, so nobody
1127 * relays the code. The folder's agent key proves the agent; the device code proves the sign-in is this client's own.
1128 * Null outside such a folder, or when nobody could be asked: login then shows the code alone.
1129 */
1130function loginAsk(server: string, env: Env): NonNullable<Parameters<typeof login>[1]["ask"]> | undefined {
1131 const root = findRoot(env.cwd);
1132 if (root === undefined || isVisitor(root)) return undefined;
1133 const config = readConfig(root, env.env);
1134 if (config.token === undefined || originOf(config.server) !== originOf(server)) return undefined;
1135 return async ({ device, user }) => {
1136 const asked = await fetch(`${originOf(server)}/login/ask`, {
1137 method: "POST",
1138 headers: { "content-type": "application/json", authorization: `Bearer ${config.token}` },
1139 body: JSON.stringify({ project: config.project, agent: config.agent, device_code: device, user_code: user }),
1140 });
1141 const body = (await asked.json().catch(() => ({}))) as {
1142 error?: string;
1143 people?: string[];
1144 expires_at?: string;
1145 request_url?: string;
1146 role?: string;
1147 };
1148 if (!asked.ok || !Array.isArray(body.people) || typeof body.request_url !== "string")
1149 throw new Error(body.error ?? `the server answered ${asked.status}`);
1150 const expiresAt = Date.parse(body.expires_at ?? "");
1151 const { api } = openIssues(env);
1152 const when = new Intl.DateTimeFormat("en-US", { timeZone: "America/Chicago", hour: "numeric", minute: "2-digit" });
1153 const question = `Please sign in my box "${boxName()}" for ${config.project}, as at most ${body.role}. It expires at ${when.format(new Date(expiresAt))} CT. Approve or deny: ${body.request_url}`;
1154 const asks: number[] = [];
1155 for (const of of body.people) asks.push((await api.ask({ of, question })).id);
1156 const first = asks[0];
1157 if (first !== undefined)
1158 await fetch(`${originOf(server)}/login/ask/link`, {
1159 method: "POST",
1160 headers: { "content-type": "application/json" },
1161 body: JSON.stringify({ device_code: device, ask: first }),
1162 });
1163 return {
1164 project: config.project,
1165 who: body.people.length === 1 ? "the person who approved this agent's box" : `the owners of ${config.project}`,
1166 asks,
1167 expiresAt,
1168 role: body.role ?? "writer",
1169 withdraw: async () => {
1170 for (const id of asks) await api.withdraw(id, { note: "The sign-in ran out; nothing was granted." });
1171 },
1172 };
1173 };
1174}