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

Compare

+34 −33 in 14 places
Lines 10–16 at 318 (were 10–15 at 24)
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";
Lines 72–78 at 318 (were 71–77 at 24)
7172
7273/**
7374 * abso run --with <box path>=<local path>[,...]: files for one run only (#37,
74− * 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
7576 * recorded. A local folder sends every file under it. Text goes with LF line
7677 * endings, as the folder's files do.
7778 */
Lines 106–112 at 318 (were 105–112 at 24)
105106 : [[box, local] as const];
106107 for (const [path, from] of files) {
107108 const text = readText(from);
108− const data =
109− 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);
110110 const exec = (statSync(from).mode & 0o111) !== 0 || (data[0] === 0x23 && data[1] === 0x21);
111111 out.push({ path, data, ...(exec ? { mode: 0o755 } : {}) });
112112 }
Lines 176–182 at 318 (were 176–182 at 24)
176176
177177/**
178178 * abso bisect [--good N] [--bad N] -- <check>: the first version of the folder's
179− * 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
180180 * --at in the box. Without --good it walks back from --bad (newest by default)
181181 * in doubling steps until a version passes, then halves the gap.
182182 */
Lines 290–296 at 318 (were 290–296 at 24)
290290export async function runRun(args: Parsed, env: Env, as: "run" | "prep" = "run"): Promise<Output> {
291291 if (args.positionals.length === 0)
292292 throw new UsageError("give the command to run: abso run <command>, or abso run -- <program> <arg...>");
293− // 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"
294294 // as the command, joined with the words after --, which lost their quoting).
295295 // Once a plain word comes, run keeps the rest as typed, -- included; so the words before a literal -- are the suspects.
296296 const before = args.dashed !== undefined ? args.dashed : args.positionals.indexOf("--");
Lines 305–313 at 318 (were 305–313 at 24)
305305 );
306306 }
307307 }
308− // 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).
309309 const notice = bool(args, "quiet") ? (_text: string): void => {} : (env.writeErr ?? env.write);
310− // 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.
311311 let prepState: string | null | undefined;
312312 const posix = undoGitBashPaths(args.positionals, env.env);
313313 if (posix.undone.length > 0) {
Lines 362–369 at 318 (were 362–369 at 24)
362362 entries.push({ path: rel, data: new Uint8Array(0), link: d.link });
363363 continue;
364364 }
365− // Text goes as abso records it, with LF line endings: a CRLF script fails in the box's sh (#37, Builder 2).
366− 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;
367367 if (lf !== undefined) toLf.push(rel);
368368 const data = lf ?? readFileSync(path);
369369 // The bit from the disk, or (on Windows) from the server; a script with "#!" runs either way.
Lines 380–389 at 318 (were 380–389 at 24)
380380 if (at !== undefined) {
381381 // A past version in the box; the folder's files stay as they are (Backtracker's bisect).
382382 const snap = await snapshotAt(root, api, at);
383− const space = stamp.AVCS_SPACE === "shared" ? "shared" : `draft ${stamp.AVCS_SPACE}`;
383+ const space = stamp.ABSO_SPACE === "shared" ? "shared" : `draft ${stamp.ABSO_SPACE}`;
384384 if (filesGlob === undefined) {
385385 entries = await snapshotEntries(api, snap);
386− 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) };
387387 notice(
388388 `abso: running version ${at} of ${space} in the box (${plural(entries.length, "file")}); your folder is untouched.\n`,
389389 );
Lines 392–398 at 318 (were 392–398 at 24)
392392 const old = await snapshotEntries(api, snap, pick);
393393 const gone = entries.filter((e) => pick(e.path) && !old.some((o) => o.path === e.path)).map((e) => e.path);
394394 entries = [...entries.filter((e) => !pick(e.path)), ...old].sort((a, b) => a.path.localeCompare(b.path));
395− stamp = { ...stamp, AVCS_AT: `${at} files ${filesGlob}` };
395+ stamp = { ...stamp, ABSO_AT: `${at} files ${filesGlob}` };
396396 const said =
397397 old.length === 0 && gone.length === 0
398398 ? `no file matches ${filesGlob} in your folder or at version ${at}`
Lines 444–458 at 318 (were 444–458 at 24)
444444 json: { ...p },
445445 };
446446 }
447− // 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.
448448 // (Tests shorten the waits with these.)
449449 const delays = (name: string) =>
450− env.env[name]
450+ fromEnv(env.env, name)
451451 ?.split(",")
452452 .map(Number)
453453 .filter((n) => Number.isFinite(n) && n >= 0);
454− const reconnect = delays("AVCS_RUN_RECONNECT_MS");
455− const retry = delays("AVCS_RUN_RETRY_MS");
454+ const reconnect = delays("RUN_RECONNECT_MS");
455+ const retry = delays("RUN_RETRY_MS");
456456 const runner =
457457 reconnect?.length || retry?.length
458458 ? new Api(api.config, api.timeoutMs, reconnect?.length ? reconnect : undefined, retry?.length ? retry : undefined)
Lines 512–525 at 318 (were 512–525 at 24)
512512/** abso fetch <glob...>: files the box made, written into the folder where abso ignores them. */
513513/**
514514 * Which of the agent's boxes run, logs and fetch use (#37): --box <name>, else
515− * AVCS_BOX, else the agent's own. A lead can give each subagent its own box
516− * (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.
517517 */
518518/**
519− * 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
520520 * abso prep and prep --forget. null means no prep; undefined, never heard. So
521521 * publish --check can refuse before running a check that can't be trusted
522− * (#37, Artist 1: a 40 s suite ran, then was refused).
522+ * (#37: a 40 s suite ran, then was refused).
523523 */
524524function prepFile(root: string): string {
525525 return join(stateDir(root), "box-prep.json");
Lines 549–555 at 318 (were 549–555 at 24)
549549}
550550
551551export function boxOf(args: Parsed, env: Env): string | undefined {
552− const box = str(args, "box") ?? (env.env.AVCS_BOX || undefined);
552+ const box = str(args, "box") ?? fromEnv(env.env, "BOX");
553553 if (box !== undefined && !/^[A-Za-z0-9_-]{1,24}$/.test(box))
554554 throw new UsageError(`a box name is 1-24 letters, digits, - or _ (got ${JSON.stringify(box)})`);
555555 return box;
Lines 581–597 at 318 (were 581–597 at 24)
581581
582582/** What `abso run` tells the command about the code it runs, as environment variables. */
583583export interface RunStamp {
584− readonly AVCS_AGENT: string;
584+ readonly ABSO_AGENT: string;
585585 /** shared, or the named draft. */
586− readonly AVCS_SPACE: string;
586+ readonly ABSO_SPACE: string;
587587 /** The version of that space the draft builds on. */
588− readonly AVCS_VERSION: string;
588+ readonly ABSO_VERSION: string;
589589 /** How many unpublished changes the draft holds (0: the run is exactly that version). */
590− readonly AVCS_DRAFT: string;
590+ readonly ABSO_DRAFT: string;
591591 /** A short hash of the draft's files as they are, "" when the draft is empty. */
592− readonly AVCS_DRAFT_HASH: string;
592+ readonly ABSO_DRAFT_HASH: string;
593593 /** With abso run --at: the version run ("12"), or the files taken from it ("12 files src/*.ts"). */
594− readonly AVCS_AT?: string;
594+ readonly ABSO_AT?: string;
595595}
596596
597597async function runStamp(root: string, agent: string, api: Api): Promise<RunStamp> {
Lines 605–623 at 318 (were 605–622 at 24)
605605 hash = h.digest("hex").slice(0, 12);
606606 }
607607 return {
608− AVCS_AGENT: agent,
609− AVCS_SPACE: me?.draft ?? "shared",
610− AVCS_VERSION: String(me?.base ?? status.version),
611− AVCS_DRAFT: String(me?.draftChanges ?? 0),
612− 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,
613613 };
614614}
615615
616616/** `export A='x' B='y'; `: on every part of a compound command, unlike a bare assignment prefix. */
617617function stampPrefix(stamp: RunStamp): string {
618618 const quote = (v: string) => `'${v.replace(/'/g, `'''`)}'`;
619− return `export ${Object.entries(stamp)
619+ return `export ${Object.entries(withOldNames({ ...stamp }))
620+ .filter((e): e is [string, string] => e[1] !== undefined)
620621 .map(([k, v]) => `${k}=${quote(v)}`)
621622 .join(" ")}; `;
622623}
MCP
compare on this site's /mcp
CLI
abso diff 24 318 client/src/box-commands.ts --json
JSON
/christopher/abso-core/compare/24..318?file=client%2Fsrc%2Fbox-commands.ts&format=json