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 2 to 318

Compare

+49 −47 in 19 places
Lines 10–21 at 318 (were 10–19 at 2)
1010import { type Env, EXIT, type Output, open, plural } from "./command-env.ts";
1111import { LISTED, recordFolder } from "./commands.ts";
1212import { findRoot } from "./config.ts";
13+import { fromEnv, withOldNames } from "./env-names.ts";
1314import { fetchedText, fetchFromBox } from "./fetch.ts";
1415import { absolute, isLocalOnly, loadIgnore, readText, walk, writeFileAtomic } from "./folder.ts";
1516import { onDisk, PLAIN, readKnownModes } from "./modes.ts";
1617import { unsafePath } from "./safety.ts";
18+import { stateDir } from "./state-dir.ts";
1719import { type TarEntry, tarGz } from "./tar.ts";
1820
1921/** One word for the box's shell (POSIX sh), quoted only when it needs it. */
Lines 72–78 at 318 (were 70–76 at 2)
7072
7173/**
7274 * abso run --with <box path>=<local path>[,...]: files for one run only (#37,
73− * Builder 6's A/B runs), sent with the folder and never written to it or
75+ * for A/B runs), sent with the folder and never written to it or
7476 * recorded. A local folder sends every file under it. Text goes with LF line
7577 * endings, as the folder's files do.
7678 */
Lines 89–95 at 318 (were 87–93 at 2)
8789 );
8890 const box = pair.slice(0, eq).replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
8991 const local = resolve(cwd, pair.slice(eq + 1));
90− const why = unsafePath(box) ?? (isLocalOnly(box) ? "it is under .git, .claude, .avcs or node_modules" : undefined);
92+ const why = unsafePath(box) ?? (isLocalOnly(box) ? "it is under .git, .claude, .abso or node_modules" : undefined);
9193 if (why !== undefined) throw new UsageError(`--with can't put a file at ${JSON.stringify(box)}: ${why}`);
9294 let st;
9395 try {
Lines 106–112 at 318 (were 104–111 at 2)
104106 : [[box, local] as const];
105107 for (const [path, from] of files) {
106108 const text = readText(from);
107− const data =
108− text !== undefined && text.includes("\r") ? Buffer.from(text.replace(/\r\n?/g, "\n")) : readFileSync(from);
109+ const data = text?.includes("\r") ? Buffer.from(text.replace(/\r\n?/g, "\n")) : readFileSync(from);
109110 const exec = (statSync(from).mode & 0o111) !== 0 || (data[0] === 0x23 && data[1] === 0x21);
110111 out.push({ path, data, ...(exec ? { mode: 0o755 } : {}) });
111112 }
Lines 176–182 at 318 (were 175–181 at 2)
175176
176177/**
177178 * abso bisect [--good N] [--bad N] -- <check>: the first version of the folder's
178− * space where the check fails (#37, Builders 1 and 6). Each step is an abso run
179+ * space where the check fails (#37). Each step is an abso run
179180 * --at in the box. Without --good it walks back from --bad (newest by default)
180181 * in doubling steps until a version passes, then halves the gap.
181182 */
Lines 290–296 at 318 (were 289–295 at 2)
289290export async function runRun(args: Parsed, env: Env, as: "run" | "prep" = "run"): Promise<Output> {
290291 if (args.positionals.length === 0)
291292 throw new UsageError("give the command to run: abso run <command>, or abso run -- <program> <arg...>");
292− // A glob before -- next to a list flag is a second value given the wrong way (#37, Builder 5: --fetch 'a' 'b' -- cmd ran "b"
293+ // A glob before -- next to a list flag is a second value given the wrong way (#37: --fetch 'a' 'b' -- cmd ran "b"
293294 // as the command, joined with the words after --, which lost their quoting).
294295 // Once a plain word comes, run keeps the rest as typed, -- included; so the words before a literal -- are the suspects.
295296 const before = args.dashed !== undefined ? args.dashed : args.positionals.indexOf("--");
Lines 305–319 at 318 (were 304–318 at 2)
304305 );
305306 }
306307 }
307− // avcs's own lines (on stderr); --quiet drops them, and the box's stdout and stderr stay as they are (#37, Builder 3).
308+ // avcs's own lines (on stderr); --quiet drops them, and the box's stdout and stderr stay as they are (#37).
308309 const notice = bool(args, "quiet") ? (_text: string): void => {} : (env.writeErr ?? env.write);
309− // What the box said about its prep (X-Avcs-Prep): null when it has none.
310+ // What the box said about its prep (X-Abso-Prep): null when it has none.
310311 let prepState: string | null | undefined;
311312 const posix = undoGitBashPaths(args.positionals, env.env);
312313 if (posix.undone.length > 0) {
313314 args = { ...args, positionals: posix.words };
314315 notice(
315− `avcs: Git Bash rewrote ${posix.undone.map((u) => `${u.to} as ${u.from}`).join(", ")}; sending ${posix.undone.map((u) => u.to).join(", ")} to the box. (MSYS_NO_PATHCONV=1 stops Git Bash rewriting.)\n`,
316+ `abso: Git Bash rewrote ${posix.undone.map((u) => `${u.to} as ${u.from}`).join(", ")}; sending ${posix.undone.map((u) => u.to).join(", ")} to the box. (MSYS_NO_PATHCONV=1 stops Git Bash rewriting.)\n`,
316317 );
317318 }
318319 const command = runCommand(args);
Lines 324–330 at 318 (were 323–329 at 2)
323324 (/\\/.test(command) || (/'/.test(command) && /"/.test(command)))
324325 ) {
325326 notice(
326− "avcs: the box's sh reads this command again; if a \\, $ or quote comes out wrong, use abso run -- <program> <args...>, which passes each word as typed.\n",
327+ "abso: the box's sh reads this command again; if a \\, $ or quote comes out wrong, use abso run -- <program> <args...>, which passes each word as typed.\n",
327328 );
328329 }
329330 // What the run log and --detach call it: the commands, not the script that runs them.
Lines 362–369 at 318 (were 361–368 at 2)
361362 entries.push({ path: rel, data: new Uint8Array(0), link: d.link });
362363 continue;
363364 }
364− // Text goes as abso records it, with LF line endings: a CRLF script fails in the box's sh (#37, Builder 2).
365− const lf = d.text !== undefined && d.text.includes("\r") ? Buffer.from(d.text.replace(/\r\n?/g, "\n")) : undefined;
365+ // Text goes as abso records it, with LF line endings: a CRLF script fails in the box's sh (#37).
366+ const lf = d.text?.includes("\r") ? Buffer.from(d.text.replace(/\r\n?/g, "\n")) : undefined;
366367 if (lf !== undefined) toLf.push(rel);
367368 const data = lf ?? readFileSync(path);
368369 // The bit from the disk, or (on Windows) from the server; a script with "#!" runs either way.
Lines 374–403 at 318 (were 373–402 at 2)
373374 const named =
374375 toLf.length <= LISTED ? toLf.join(", ") : `${toLf.slice(0, LISTED).join(", ")}, and ${toLf.length - LISTED} more`;
375376 notice(
376− `avcs: sent ${plural(toLf.length, "file")} with LF line endings, as abso records them; your folder has CRLF: ${named}.\n`,
377+ `abso: sent ${plural(toLf.length, "file")} with LF line endings, as abso records them; your folder has CRLF: ${named}.\n`,
377378 );
378379 }
379380 if (at !== undefined) {
380381 // A past version in the box; the folder's files stay as they are (Backtracker's bisect).
381382 const snap = await snapshotAt(root, api, at);
382− const space = stamp.AVCS_SPACE === "shared" ? "shared" : `draft ${stamp.AVCS_SPACE}`;
383+ const space = stamp.ABSO_SPACE === "shared" ? "shared" : `draft ${stamp.ABSO_SPACE}`;
383384 if (filesGlob === undefined) {
384385 entries = await snapshotEntries(api, snap);
385− stamp = { ...stamp, AVCS_VERSION: String(at), AVCS_DRAFT: "0", AVCS_DRAFT_HASH: "", AVCS_AT: String(at) };
386+ stamp = { ...stamp, ABSO_VERSION: String(at), ABSO_DRAFT: "0", ABSO_DRAFT_HASH: "", ABSO_AT: String(at) };
386387 notice(
387− `avcs: running version ${at} of ${space} in the box (${plural(entries.length, "file")}); your folder is untouched.\n`,
388+ `abso: running version ${at} of ${space} in the box (${plural(entries.length, "file")}); your folder is untouched.\n`,
388389 );
389390 } else {
390391 const pick = globTest(filesGlob);
391392 const old = await snapshotEntries(api, snap, pick);
392393 const gone = entries.filter((e) => pick(e.path) && !old.some((o) => o.path === e.path)).map((e) => e.path);
393394 entries = [...entries.filter((e) => !pick(e.path)), ...old].sort((a, b) => a.path.localeCompare(b.path));
394− stamp = { ...stamp, AVCS_AT: `${at} files ${filesGlob}` };
395+ stamp = { ...stamp, ABSO_AT: `${at} files ${filesGlob}` };
395396 const said =
396397 old.length === 0 && gone.length === 0
397398 ? `no file matches ${filesGlob} in your folder or at version ${at}`
398399 : `${plural(old.length, "file")} as at version ${at}: ${old.map((e) => e.path).join(", ")}${gone.length > 0 ? `; left out, not there at version ${at}: ${gone.join(", ")}` : ""}`;
399− notice(`avcs: running your folder with ${said}. Your folder is untouched.\n`);
400+ notice(`abso: running your folder with ${said}. Your folder is untouched.\n`);
400401 }
401402 }
402403 const withSpec = str(args, "with");
Lines 413–425 at 318 (were 412–424 at 2)
412413 .map((e) => e.path)
413414 .join(", ")}, and ${extra.length - LISTED} more`;
414415 notice(
415− `avcs: adding ${plural(extra.length, "file")} for this run only: ${named}. They are not in your folder and are not recorded.\n`,
416+ `abso: adding ${plural(extra.length, "file")} for this run only: ${named}. They are not in your folder and are not recorded.\n`,
416417 );
417418 }
418419 if (as === "prep") {
419420 // The box keeps what the command leaves (node_modules, ~/.cache, /tmp) as what it starts from (#37).
420421 notice(
421− "avcs: preparing the box from a fresh image: this takes as long as the command, then a few seconds to save.\n",
422+ "abso: preparing the box from a fresh image: this takes as long as the command, then a few seconds to save.\n",
422423 );
423424 const p = await api.prep(command, tarGz(entries));
424425 if (p.saved !== true) {
Lines 444–458 at 318 (were 443–457 at 2)
443444 json: { ...p },
444445 };
445446 }
446− // A broken stream reconnects to the run quietly; .avcs/run.log says when and why.
447+ // A broken stream reconnects to the run quietly; .abso/run.log says when and why.
447448 // (Tests shorten the waits with these.)
448449 const delays = (name: string) =>
449− env.env[name]
450+ fromEnv(env.env, name)
450451 ?.split(",")
451452 .map(Number)
452453 .filter((n) => Number.isFinite(n) && n >= 0);
453− const reconnect = delays("AVCS_RUN_RECONNECT_MS");
454− const retry = delays("AVCS_RUN_RETRY_MS");
454+ const reconnect = delays("RUN_RECONNECT_MS");
455+ const retry = delays("RUN_RETRY_MS");
455456 const runner =
456457 reconnect?.length || retry?.length
457458 ? new Api(api.config, api.timeoutMs, reconnect?.length ? reconnect : undefined, retry?.length ? retry : undefined)
Lines 461–467 at 318 (were 460–466 at 2)
460461 runner.box = api.box;
461462 const log = (what: string, why: string): void => {
462463 try {
463− appendFileSync(join(root, ".avcs", "run.log"), `${new Date().toISOString()}\t${what}: ${named}\t${why}\n`);
464+ appendFileSync(join(stateDir(root), "run.log"), `${new Date().toISOString()}\t${what}: ${named}\t${why}\n`);
464465 } catch {
465466 // The log is a convenience.
466467 }
Lines 491–503 at 318 (were 490–502 at 2)
490491 const say = notice;
491492 if (cold && prep === "used")
492493 say(
493− "avcs: fresh box, started from your prep (abso prep): node_modules, ~/.cache and /tmp are as the prep left them.\n",
494+ "abso: fresh box, started from your prep (abso prep): node_modules, ~/.cache and /tmp are as the prep left them.\n",
494495 );
495496 else if (cold)
496497 say(
497− "avcs: fresh box: it started for this run (first run, a deploy, a new image, or 30 idle minutes), so nothing earlier runs left outside the folder (/tmp, ~/.cache, node_modules) is in it. abso prep keeps them for every fresh box.\n",
498+ "abso: fresh box: it started for this run (first run, a deploy, a new image, or 30 idle minutes), so nothing earlier runs left outside the folder (/tmp, ~/.cache, node_modules) is in it. abso prep keeps them for every fresh box.\n",
498499 );
499− if (prep !== undefined && prep !== "used") say(`avcs: prep ${prep}.\n`);
500+ if (prep !== undefined && prep !== "used") say(`abso: prep ${prep}.\n`);
500501 },
501502 });
502503 if (fetchGlobs.length > 0) {
Lines 512–528 at 318 (were 511–527 at 2)
511512/** abso fetch <glob...>: files the box made, written into the folder where abso ignores them. */
512513/**
513514 * Which of the agent's boxes run, logs and fetch use (#37): --box <name>, else
514− * AVCS_BOX, else the agent's own. A lead can give each subagent its own box
515− * (AVCS_BOX=2 in its environment), so their runs don't wait on each other.
515+ * ABSO_BOX (or the older AVCS_BOX), else the agent's own. A lead can give each subagent its own box
516+ * (ABSO_BOX=2 in its environment), so their runs don't wait on each other.
516517 */
517518/**
518− * What this folder last heard about a box's prep: a run's X-Avcs-Prep, or
519+ * What this folder last heard about a box's prep: a run's X-Abso-Prep, or
519520 * abso prep and prep --forget. null means no prep; undefined, never heard. So
520521 * publish --check can refuse before running a check that can't be trusted
521− * (#37, Artist 1: a 40 s suite ran, then was refused).
522+ * (#37: a 40 s suite ran, then was refused).
522523 */
523524function prepFile(root: string): string {
524− return join(root, ".avcs", "box-prep.json");
525+ return join(stateDir(root), "box-prep.json");
525526}
526527export function knownPrep(root: string, box: string | undefined): string | null | undefined {
527528 try {
Lines 549–555 at 318 (were 548–554 at 2)
548549}
549550
550551export function boxOf(args: Parsed, env: Env): string | undefined {
551− const box = str(args, "box") ?? (env.env.AVCS_BOX || undefined);
552+ const box = str(args, "box") ?? fromEnv(env.env, "BOX");
552553 if (box !== undefined && !/^[A-Za-z0-9_-]{1,24}$/.test(box))
553554 throw new UsageError(`a box name is 1-24 letters, digits, - or _ (got ${JSON.stringify(box)})`);
554555 return box;
Lines 568–574 at 318 (were 567–573 at 2)
567568 onReconnect: (why, attempt) => {
568569 try {
569570 appendFileSync(
570− join(root, ".avcs", "run.log"),
571+ join(stateDir(root), "run.log"),
571572 `${new Date().toISOString()}\treconnecting (try ${attempt}) to run ${id}\t${why}\n`,
572573 );
573574 } catch {
Lines 581–597 at 318 (were 580–596 at 2)
580581
581582/** What `abso run` tells the command about the code it runs, as environment variables. */
582583export interface RunStamp {
583− readonly AVCS_AGENT: string;
584+ readonly ABSO_AGENT: string;
584585 /** shared, or the named draft. */
585− readonly AVCS_SPACE: string;
586+ readonly ABSO_SPACE: string;
586587 /** The version of that space the draft builds on. */
587− readonly AVCS_VERSION: string;
588+ readonly ABSO_VERSION: string;
588589 /** How many unpublished changes the draft holds (0: the run is exactly that version). */
589− readonly AVCS_DRAFT: string;
590+ readonly ABSO_DRAFT: string;
590591 /** A short hash of the draft's files as they are, "" when the draft is empty. */
591− readonly AVCS_DRAFT_HASH: string;
592+ readonly ABSO_DRAFT_HASH: string;
592593 /** With abso run --at: the version run ("12"), or the files taken from it ("12 files src/*.ts"). */
593− readonly AVCS_AT?: string;
594+ readonly ABSO_AT?: string;
594595}
595596
596597async function runStamp(root: string, agent: string, api: Api): Promise<RunStamp> {
Lines 605–623 at 318 (were 604–621 at 2)
604605 hash = h.digest("hex").slice(0, 12);
605606 }
606607 return {
607− AVCS_AGENT: agent,
608− AVCS_SPACE: me?.draft ?? "shared",
609− AVCS_VERSION: String(me?.base ?? status.version),
610− AVCS_DRAFT: String(me?.draftChanges ?? 0),
611− AVCS_DRAFT_HASH: hash,
608+ ABSO_AGENT: agent,
609+ ABSO_SPACE: me?.draft ?? "shared",
610+ ABSO_VERSION: String(me?.base ?? status.version),
611+ ABSO_DRAFT: String(me?.draftChanges ?? 0),
612+ ABSO_DRAFT_HASH: hash,
612613 };
613614}
614615
615616/** `export A='x' B='y'; `: on every part of a compound command, unlike a bare assignment prefix. */
616617function stampPrefix(stamp: RunStamp): string {
617618 const quote = (v: string) => `'${v.replace(/'/g, `'''`)}'`;
618− return `export ${Object.entries(stamp)
619+ return `export ${Object.entries(withOldNames({ ...stamp }))
620+ .filter((e): e is [string, string] => e[1] !== undefined)
619621 .map(([k, v]) => `${k}=${quote(v)}`)
620622 .join(" ")}; `;
621623}
MCP
compare on this site's /mcp
CLI
abso diff 2 318 client/src/box-commands.ts --json
JSON
/christopher/abso-core/compare/2..318?file=client%2Fsrc%2Fbox-commands.ts&format=json