{"draft":null,"from":7,"to":318,"files":[{"path":"client/src/box-commands.ts","added":49,"removed":47,"diff":"--- a/client/src/box-commands.ts\n+++ b/client/src/box-commands.ts\n@@ -10,10 +10,12 @@\n import { type Env, EXIT, type Output, open, plural } from \"./command-env.ts\";\n import { LISTED, recordFolder } from \"./commands.ts\";\n import { findRoot } from \"./config.ts\";\n+import { fromEnv, withOldNames } from \"./env-names.ts\";\n import { fetchedText, fetchFromBox } from \"./fetch.ts\";\n import { absolute, isLocalOnly, loadIgnore, readText, walk, writeFileAtomic } from \"./folder.ts\";\n import { onDisk, PLAIN, readKnownModes } from \"./modes.ts\";\n import { unsafePath } from \"./safety.ts\";\n+import { stateDir } from \"./state-dir.ts\";\n import { type TarEntry, tarGz } from \"./tar.ts\";\n \n /** One word for the box's shell (POSIX sh), quoted only when it needs it. */\n@@ -70,7 +72,7 @@\n \n /**\n  * abso run --with <box path>=<local path>[,...]: files for one run only (#37,\n- * Builder 6's A/B runs), sent with the folder and never written to it or\n+ * for A/B runs), sent with the folder and never written to it or\n  * recorded. A local folder sends every file under it. Text goes with LF line\n  * endings, as the folder's files do.\n  */\n@@ -87,7 +89,7 @@\n \t\t\t);\n \t\tconst box = pair.slice(0, eq).replace(/\\\\/g, \"/\").replace(/^\\.\\//, \"\").replace(/\\/+$/, \"\");\n \t\tconst local = resolve(cwd, pair.slice(eq + 1));\n-\t\tconst why = unsafePath(box) ?? (isLocalOnly(box) ? \"it is under .git, .claude, .avcs or node_modules\" : undefined);\n+\t\tconst why = unsafePath(box) ?? (isLocalOnly(box) ? \"it is under .git, .claude, .abso or node_modules\" : undefined);\n \t\tif (why !== undefined) throw new UsageError(`--with can't put a file at ${JSON.stringify(box)}: ${why}`);\n \t\tlet st;\n \t\ttry {\n@@ -104,8 +106,7 @@\n \t\t\t: [[box, local] as const];\n \t\tfor (const [path, from] of files) {\n \t\t\tconst text = readText(from);\n-\t\t\tconst data =\n-\t\t\t\ttext !== undefined && text.includes(\"\\r\") ? Buffer.from(text.replace(/\\r\\n?/g, \"\\n\")) : readFileSync(from);\n+\t\t\tconst data = text?.includes(\"\\r\") ? Buffer.from(text.replace(/\\r\\n?/g, \"\\n\")) : readFileSync(from);\n \t\t\tconst exec = (statSync(from).mode & 0o111) !== 0 || (data[0] === 0x23 && data[1] === 0x21);\n \t\t\tout.push({ path, data, ...(exec ? { mode: 0o755 } : {}) });\n \t\t}\n@@ -175,7 +176,7 @@\n \n /**\n  * abso bisect [--good N] [--bad N] -- <check>: the first version of the folder's\n- * space where the check fails (#37, Builders 1 and 6). Each step is an abso run\n+ * space where the check fails (#37). Each step is an abso run\n  * --at in the box. Without --good it walks back from --bad (newest by default)\n  * in doubling steps until a version passes, then halves the gap.\n  */\n@@ -289,7 +290,7 @@\n export async function runRun(args: Parsed, env: Env, as: \"run\" | \"prep\" = \"run\"): Promise<Output> {\n \tif (args.positionals.length === 0)\n \t\tthrow new UsageError(\"give the command to run: abso run <command>, or abso run -- <program> <arg...>\");\n-\t// 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\"\n+\t// A glob before -- next to a list flag is a second value given the wrong way (#37: --fetch 'a' 'b' -- cmd ran \"b\"\n \t// as the command, joined with the words after --, which lost their quoting).\n \t// Once a plain word comes, run keeps the rest as typed, -- included; so the words before a literal -- are the suspects.\n \tconst before = args.dashed !== undefined ? args.dashed : args.positionals.indexOf(\"--\");\n@@ -304,15 +305,15 @@\n \t\t\t);\n \t\t}\n \t}\n-\t// avcs's own lines (on stderr); --quiet drops them, and the box's stdout and stderr stay as they are (#37, Builder 3).\n+\t// avcs's own lines (on stderr); --quiet drops them, and the box's stdout and stderr stay as they are (#37).\n \tconst notice = bool(args, \"quiet\") ? (_text: string): void => {} : (env.writeErr ?? env.write);\n-\t// What the box said about its prep (X-Avcs-Prep): null when it has none.\n+\t// What the box said about its prep (X-Abso-Prep): null when it has none.\n \tlet prepState: string | null | undefined;\n \tconst posix = undoGitBashPaths(args.positionals, env.env);\n \tif (posix.undone.length > 0) {\n \t\targs = { ...args, positionals: posix.words };\n \t\tnotice(\n-\t\t\t`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`,\n+\t\t\t`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`,\n \t\t);\n \t}\n \tconst command = runCommand(args);\n@@ -323,7 +324,7 @@\n \t\t(/\\\\/.test(command) || (/'/.test(command) && /\"/.test(command)))\n \t) {\n \t\tnotice(\n-\t\t\t\"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\",\n+\t\t\t\"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\",\n \t\t);\n \t}\n \t// What the run log and --detach call it: the commands, not the script that runs them.\n@@ -361,8 +362,8 @@\n \t\t\tentries.push({ path: rel, data: new Uint8Array(0), link: d.link });\n \t\t\tcontinue;\n \t\t}\n-\t\t// Text goes as abso records it, with LF line endings: a CRLF script fails in the box's sh (#37, Builder 2).\n-\t\tconst lf = d.text !== undefined && d.text.includes(\"\\r\") ? Buffer.from(d.text.replace(/\\r\\n?/g, \"\\n\")) : undefined;\n+\t\t// Text goes as abso records it, with LF line endings: a CRLF script fails in the box's sh (#37).\n+\t\tconst lf = d.text?.includes(\"\\r\") ? Buffer.from(d.text.replace(/\\r\\n?/g, \"\\n\")) : undefined;\n \t\tif (lf !== undefined) toLf.push(rel);\n \t\tconst data = lf ?? readFileSync(path);\n \t\t// The bit from the disk, or (on Windows) from the server; a script with \"#!\" runs either way.\n@@ -373,30 +374,30 @@\n \t\tconst named =\n \t\t\ttoLf.length <= LISTED ? toLf.join(\", \") : `${toLf.slice(0, LISTED).join(\", \")}, and ${toLf.length - LISTED} more`;\n \t\tnotice(\n-\t\t\t`avcs: sent ${plural(toLf.length, \"file\")} with LF line endings, as abso records them; your folder has CRLF: ${named}.\\n`,\n+\t\t\t`abso: sent ${plural(toLf.length, \"file\")} with LF line endings, as abso records them; your folder has CRLF: ${named}.\\n`,\n \t\t);\n \t}\n \tif (at !== undefined) {\n \t\t// A past version in the box; the folder's files stay as they are (Backtracker's bisect).\n \t\tconst snap = await snapshotAt(root, api, at);\n-\t\tconst space = stamp.AVCS_SPACE === \"shared\" ? \"shared\" : `draft ${stamp.AVCS_SPACE}`;\n+\t\tconst space = stamp.ABSO_SPACE === \"shared\" ? \"shared\" : `draft ${stamp.ABSO_SPACE}`;\n \t\tif (filesGlob === undefined) {\n \t\t\tentries = await snapshotEntries(api, snap);\n-\t\t\tstamp = { ...stamp, AVCS_VERSION: String(at), AVCS_DRAFT: \"0\", AVCS_DRAFT_HASH: \"\", AVCS_AT: String(at) };\n+\t\t\tstamp = { ...stamp, ABSO_VERSION: String(at), ABSO_DRAFT: \"0\", ABSO_DRAFT_HASH: \"\", ABSO_AT: String(at) };\n \t\t\tnotice(\n-\t\t\t\t`avcs: running version ${at} of ${space} in the box (${plural(entries.length, \"file\")}); your folder is untouched.\\n`,\n+\t\t\t\t`abso: running version ${at} of ${space} in the box (${plural(entries.length, \"file\")}); your folder is untouched.\\n`,\n \t\t\t);\n \t\t} else {\n \t\t\tconst pick = globTest(filesGlob);\n \t\t\tconst old = await snapshotEntries(api, snap, pick);\n \t\t\tconst gone = entries.filter((e) => pick(e.path) && !old.some((o) => o.path === e.path)).map((e) => e.path);\n \t\t\tentries = [...entries.filter((e) => !pick(e.path)), ...old].sort((a, b) => a.path.localeCompare(b.path));\n-\t\t\tstamp = { ...stamp, AVCS_AT: `${at} files ${filesGlob}` };\n+\t\t\tstamp = { ...stamp, ABSO_AT: `${at} files ${filesGlob}` };\n \t\t\tconst said =\n \t\t\t\told.length === 0 && gone.length === 0\n \t\t\t\t\t? `no file matches ${filesGlob} in your folder or at version ${at}`\n \t\t\t\t\t: `${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(\", \")}` : \"\"}`;\n-\t\t\tnotice(`avcs: running your folder with ${said}. Your folder is untouched.\\n`);\n+\t\t\tnotice(`abso: running your folder with ${said}. Your folder is untouched.\\n`);\n \t\t}\n \t}\n \tconst withSpec = str(args, \"with\");\n@@ -412,13 +413,13 @@\n \t\t\t\t\t\t.map((e) => e.path)\n \t\t\t\t\t\t.join(\", \")}, and ${extra.length - LISTED} more`;\n \t\tnotice(\n-\t\t\t`avcs: adding ${plural(extra.length, \"file\")} for this run only: ${named}. They are not in your folder and are not recorded.\\n`,\n+\t\t\t`abso: adding ${plural(extra.length, \"file\")} for this run only: ${named}. They are not in your folder and are not recorded.\\n`,\n \t\t);\n \t}\n \tif (as === \"prep\") {\n \t\t// The box keeps what the command leaves (node_modules, ~/.cache, /tmp) as what it starts from (#37).\n \t\tnotice(\n-\t\t\t\"avcs: preparing the box from a fresh image: this takes as long as the command, then a few seconds to save.\\n\",\n+\t\t\t\"abso: preparing the box from a fresh image: this takes as long as the command, then a few seconds to save.\\n\",\n \t\t);\n \t\tconst p = await api.prep(command, tarGz(entries));\n \t\tif (p.saved !== true) {\n@@ -443,15 +444,15 @@\n \t\t\tjson: { ...p },\n \t\t};\n \t}\n-\t// A broken stream reconnects to the run quietly; .avcs/run.log says when and why.\n+\t// A broken stream reconnects to the run quietly; .abso/run.log says when and why.\n \t// (Tests shorten the waits with these.)\n \tconst delays = (name: string) =>\n-\t\tenv.env[name]\n+\t\tfromEnv(env.env, name)\n \t\t\t?.split(\",\")\n \t\t\t.map(Number)\n \t\t\t.filter((n) => Number.isFinite(n) && n >= 0);\n-\tconst reconnect = delays(\"AVCS_RUN_RECONNECT_MS\");\n-\tconst retry = delays(\"AVCS_RUN_RETRY_MS\");\n+\tconst reconnect = delays(\"RUN_RECONNECT_MS\");\n+\tconst retry = delays(\"RUN_RETRY_MS\");\n \tconst runner =\n \t\treconnect?.length || retry?.length\n \t\t\t? new Api(api.config, api.timeoutMs, reconnect?.length ? reconnect : undefined, retry?.length ? retry : undefined)\n@@ -460,7 +461,7 @@\n \trunner.box = api.box;\n \tconst log = (what: string, why: string): void => {\n \t\ttry {\n-\t\t\tappendFileSync(join(root, \".avcs\", \"run.log\"), `${new Date().toISOString()}\\t${what}: ${named}\\t${why}\\n`);\n+\t\t\tappendFileSync(join(stateDir(root), \"run.log\"), `${new Date().toISOString()}\\t${what}: ${named}\\t${why}\\n`);\n \t\t} catch {\n \t\t\t// The log is a convenience.\n \t\t}\n@@ -490,13 +491,13 @@\n \t\t\tconst say = notice;\n \t\t\tif (cold && prep === \"used\")\n \t\t\t\tsay(\n-\t\t\t\t\t\"avcs: fresh box, started from your prep (abso prep): node_modules, ~/.cache and /tmp are as the prep left them.\\n\",\n+\t\t\t\t\t\"abso: fresh box, started from your prep (abso prep): node_modules, ~/.cache and /tmp are as the prep left them.\\n\",\n \t\t\t\t);\n \t\t\telse if (cold)\n \t\t\t\tsay(\n-\t\t\t\t\t\"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\",\n+\t\t\t\t\t\"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\",\n \t\t\t\t);\n-\t\t\tif (prep !== undefined && prep !== \"used\") say(`avcs: prep ${prep}.\\n`);\n+\t\t\tif (prep !== undefined && prep !== \"used\") say(`abso: prep ${prep}.\\n`);\n \t\t},\n \t});\n \tif (fetchGlobs.length > 0) {\n@@ -511,17 +512,17 @@\n /** abso fetch <glob...>: files the box made, written into the folder where abso ignores them. */\n /**\n  * Which of the agent's boxes run, logs and fetch use (#37): --box <name>, else\n- * AVCS_BOX, else the agent's own. A lead can give each subagent its own box\n- * (AVCS_BOX=2 in its environment), so their runs don't wait on each other.\n+ * ABSO_BOX (or the older AVCS_BOX), else the agent's own. A lead can give each subagent its own box\n+ * (ABSO_BOX=2 in its environment), so their runs don't wait on each other.\n  */\n /**\n- * What this folder last heard about a box's prep: a run's X-Avcs-Prep, or\n+ * What this folder last heard about a box's prep: a run's X-Abso-Prep, or\n  * abso prep and prep --forget. null means no prep; undefined, never heard. So\n  * publish --check can refuse before running a check that can't be trusted\n- * (#37, Artist 1: a 40 s suite ran, then was refused).\n+ * (#37: a 40 s suite ran, then was refused).\n  */\n function prepFile(root: string): string {\n-\treturn join(root, \".avcs\", \"box-prep.json\");\n+\treturn join(stateDir(root), \"box-prep.json\");\n }\n export function knownPrep(root: string, box: string | undefined): string | null | undefined {\n \ttry {\n@@ -548,7 +549,7 @@\n }\n \n export function boxOf(args: Parsed, env: Env): string | undefined {\n-\tconst box = str(args, \"box\") ?? (env.env.AVCS_BOX || undefined);\n+\tconst box = str(args, \"box\") ?? fromEnv(env.env, \"BOX\");\n \tif (box !== undefined && !/^[A-Za-z0-9_-]{1,24}$/.test(box))\n \t\tthrow new UsageError(`a box name is 1-24 letters, digits, - or _ (got ${JSON.stringify(box)})`);\n \treturn box;\n@@ -567,7 +568,7 @@\n \t\tonReconnect: (why, attempt) => {\n \t\t\ttry {\n \t\t\t\tappendFileSync(\n-\t\t\t\t\tjoin(root, \".avcs\", \"run.log\"),\n+\t\t\t\t\tjoin(stateDir(root), \"run.log\"),\n \t\t\t\t\t`${new Date().toISOString()}\\treconnecting (try ${attempt}) to run ${id}\\t${why}\\n`,\n \t\t\t\t);\n \t\t\t} catch {\n@@ -580,17 +581,17 @@\n \n /** What `abso run` tells the command about the code it runs, as environment variables. */\n export interface RunStamp {\n-\treadonly AVCS_AGENT: string;\n+\treadonly ABSO_AGENT: string;\n \t/** shared, or the named draft. */\n-\treadonly AVCS_SPACE: string;\n+\treadonly ABSO_SPACE: string;\n \t/** The version of that space the draft builds on. */\n-\treadonly AVCS_VERSION: string;\n+\treadonly ABSO_VERSION: string;\n \t/** How many unpublished changes the draft holds (0: the run is exactly that version). */\n-\treadonly AVCS_DRAFT: string;\n+\treadonly ABSO_DRAFT: string;\n \t/** A short hash of the draft's files as they are, \"\" when the draft is empty. */\n-\treadonly AVCS_DRAFT_HASH: string;\n+\treadonly ABSO_DRAFT_HASH: string;\n \t/** With abso run --at: the version run (\"12\"), or the files taken from it (\"12 files src/*.ts\"). */\n-\treadonly AVCS_AT?: string;\n+\treadonly ABSO_AT?: string;\n }\n \n async function runStamp(root: string, agent: string, api: Api): Promise<RunStamp> {\n@@ -604,18 +605,19 @@\n \t\thash = h.digest(\"hex\").slice(0, 12);\n \t}\n \treturn {\n-\t\tAVCS_AGENT: agent,\n-\t\tAVCS_SPACE: me?.draft ?? \"shared\",\n-\t\tAVCS_VERSION: String(me?.base ?? status.version),\n-\t\tAVCS_DRAFT: String(me?.draftChanges ?? 0),\n-\t\tAVCS_DRAFT_HASH: hash,\n+\t\tABSO_AGENT: agent,\n+\t\tABSO_SPACE: me?.draft ?? \"shared\",\n+\t\tABSO_VERSION: String(me?.base ?? status.version),\n+\t\tABSO_DRAFT: String(me?.draftChanges ?? 0),\n+\t\tABSO_DRAFT_HASH: hash,\n \t};\n }\n \n /** `export A='x' B='y'; `: on every part of a compound command, unlike a bare assignment prefix. */\n function stampPrefix(stamp: RunStamp): string {\n \tconst quote = (v: string) => `'${v.replace(/'/g, `'''`)}'`;\n-\treturn `export ${Object.entries(stamp)\n+\treturn `export ${Object.entries(withOldNames({ ...stamp }))\n+\t\t.filter((e): e is [string, string] => e[1] !== undefined)\n \t\t.map(([k, v]) => `${k}=${quote(v)}`)\n \t\t.join(\" \")}; `;\n }"}],"unmatched":[]}