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
MCP
blame on this site's /mcp
CLI
abso blame client/test/install.test.ts --json
JSON
/christopher/abso-core/blame/client/test/install.test.ts?format=json
525 linesFirst import 73% · speed 14% · pinch 7% · review 7%Last change pinch in version 293,

525 lines from 14 changes in 9 versions.

init0Start the project1// Installing a mod (src/install.ts, #29): a staged copy that passed its check
2// goes in file by file with renames, plugin.json last; what it replaces is
3// kept for a rollback; a failed check or a failed rename leaves the mod as it
4// was. Every install here goes into a scratch folder. And which client this
5// is (src/version.ts): the commit, read from .git the way git reads it.
6
7import assert from "node:assert/strict";
8import { spawnSync } from "node:child_process";
9import {
10 copyFileSync,
11 existsSync,
12 mkdirSync,
13 mkdtempSync,
14 readdirSync,
15 readFileSync,
16 renameSync,
17 rmSync,
18 statSync,
19 utimesSync,
20 writeFileSync,
21} from "node:fs";
22import { tmpdir } from "node:os";
23import { dirname, join, relative } from "node:path";
24import { after, describe, it } from "node:test";
25import { Api } from "../src/api.ts";
26import { clientVersion, headCommit } from "../src/client-version.ts";
review40Mods: the hooks mod is abso-hooks and the view mod abso-view; an install moves the old skills/avcs and skills/avcs-view folders to ~/.abso/retired-mods (moved, not deleted); the hook stands down for either name; status checks either. Tests cover the move.Compare27import {
28 AVCS_MOD,
pinch293Local projects: the abso mod hands their edits to abso hook. The installer stamps the mod with the command that runs its checkout's abso hook (node, client/abso.ts); in a local project's folder the mod runs it with the edit, as Claude Code's command hook would, and passes its news to the chat. A mod installed before this one still skips local folders, and init says so.Compare29 hookCommand,
pinch281Client fixes from the judge dry run: help with today's names, a mod installer hint that runs, a failed init or join takes back what it wrote, a refused 401 names the credential that went, and reply --file - help: abso.json, ABSO_ADMIN_TOKEN, ABSO_ADMIN_SERVERS, ABSO_BOX and .abso/shots/ in place of the old names, and the missing full stop. abso shot saves under .abso/shots/ as help says. - --version, init, join and status name the mod installer by its full path, and on a Node that can't run .ts files say it needs Node 22.18 or later. A built copy, which has no installer, says abso record sends the edits. - A failed init removes the .absoignore and abso.json it wrote. A failed join removes its .abso/ folder; a key already there, or one made for this join, stays. - A 401 names what was sent (this folder's key, ABSO_TOKEN, a pipeline run's key, the token file) instead of always a folder key. - reply takes --file <path> or --file - (stdin), like ask and answer. - The mod-behind tests no longer depend on which mods the machine has. Tests: install, body-files, failed-start (new), doctor, help, lost-pull pass; tsc clean.Compare30 installerCommand,
review40Mods: the hooks mod is abso-hooks and the view mod abso-view; an install moves the old skills/avcs and skills/avcs-view folders to ~/.abso/retired-mods (moved, not deleted); the hook stands down for either name; status checks either. Tests cover the move.Compare31 installMod,
speed43status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't runCompare32 keptModCommit,
review40Mods: the hooks mod is abso-hooks and the view mod abso-view; an install moves the old skills/avcs and skills/avcs-view folders to ~/.abso/retired-mods (moved, not deleted); the hook stands down for either name; status checks either. Tests cover the move.Compare33 type ModSpec,
34 modsBehindText,
35 retireOldMod,
36 rollbackMod,
37 versionFor,
38 versionReport,
39} from "../src/install.ts";
init0Start the project40import { main } from "../src/main.ts";
42const hasGit = spawnSync("git", ["--version"]).status === 0;
43const dirs: string[] = [];
44after(() => {
45 for (const d of dirs) rmSync(d, { recursive: true, force: true, maxRetries: 5 });
46});
48function temp(): string {
49 const d = mkdtempSync(join(tmpdir(), "avcs-install-test-"));
50 dirs.push(d);
51 return d;
54const FILES = ["src/core.ts", "hooks/stamp.ts", "hooks/register.ts", "hooks/hooks.json", ".claude-plugin/plugin.json"];
55const pass = () => undefined;
56const at = (dir: string, rel: string) => join(dir, ...rel.split("/"));
57const read = (dir: string, rel: string) => readFileSync(at(dir, rel), "utf8");
58const write = (dir: string, rel: string, text: string) => {
59 mkdirSync(dirname(at(dir, rel)), { recursive: true });
60 writeFileSync(at(dir, rel), text);
61};
63/** A mod's source folder: a small mod shaped like avcs, with these texts in place of the defaults. */
64function source(texts: Record<string, string> = {}): ModSpec {
65 const from = temp();
66 const all: Record<string, string> = {
67 "src/core.ts": "export const core = 1\n",
68 "hooks/stamp.ts": "// Which mod this is.\nexport const STAMP: string | undefined = undefined\n",
69 "hooks/register.ts": "import { core } from '../src/core.ts'\n",
70 "hooks/hooks.json": '{ "modules": ["./register.ts"] }\n',
71 ".claude-plugin/plugin.json": '{ "name": "avcs", "version": "0.1.0", "description": "a mod" }\n',
72 ...texts,
73 };
74 for (const [rel, text] of Object.entries(all)) write(from, rel, text);
75 return { name: "avcs", from, files: FILES };
78/** Every file under dir, relative and sorted. */
79function tree(dir: string): string[] {
80 return readdirSync(dir, { recursive: true, withFileTypes: true })
81 .filter((e) => e.isFile())
82 .map((e) => relative(dir, join(e.parentPath, e.name)).replace(/\\/g, "/"))
83 .sort();
86const contents = (dir: string) => Object.fromEntries(tree(dir).map((rel) => [rel, read(dir, rel)]));
87const record = (dir: string) =>
88 JSON.parse(read(dir, ".avcs-install.json")) as {
89 version: string;
90 files: string[];
91 prev?: { version: string; files: string[] };
92 moving?: string;
93 };
95describe("installing a mod", () => {
96 it("stamps the version into plugin.json and stamp.ts, and leaves nothing staged behind", () => {
97 const spec = source();
98 const target = join(temp(), "avcs");
99 const r = installMod(spec, { target, check: pass, commit: "702c616" });
100 assert.deepEqual(r, { changed: true, version: "0.1.0+702c616", previous: undefined, files: 5 });
101 assert.deepEqual(JSON.parse(read(target, ".claude-plugin/plugin.json")), {
102 name: "avcs",
103 version: "0.1.0+702c616",
104 description: "a mod",
105 });
106 assert.equal(
107 read(target, "hooks/stamp.ts"),
108 "// Which mod this is.\nexport const STAMP: string | undefined = '0.1.0+702c616'\n",
109 );
110 assert.equal(read(target, "src/core.ts"), "export const core = 1\n");
111 assert.deepEqual(tree(target), [".avcs-install.json", ...FILES].sort());
112 assert.deepEqual(
113 { ...record(target), at: undefined, from: undefined },
114 { mod: "avcs", version: "0.1.0+702c616", files: FILES, at: undefined, from: undefined },
115 );
116 });
pinch293Local projects: the abso mod hands their edits to abso hook. The installer stamps the mod with the command that runs its checkout's abso hook (node, client/abso.ts); in a local project's folder the mod runs it with the edit, as Claude Code's command hook would, and passes its news to the chat. A mod installed before this one still skips local folders, and init says so.Compare118 it("stamps the command that runs this client's abso hook, where stamp.ts has a HOOK_COMMAND line", () => {
119 const spec = source({
120 "hooks/stamp.ts":
121 "export const STAMP: string | undefined = undefined\nexport const HOOK_COMMAND: readonly string[] | undefined = undefined\n",
122 });
123 const target = join(temp(), "avcs");
124 installMod(spec, {
125 target,
126 check: pass,
127 commit: "702c616",
128 hookCommand: ["C:\\node.exe", "C:\\abso\\client\\abso.ts", "hook"],
129 });
130 assert.equal(
131 read(target, "hooks/stamp.ts"),
132 "export const STAMP: string | undefined = '0.1.0+702c616'\n" +
133 'export const HOOK_COMMAND: readonly string[] | undefined = ["C:\\\\node.exe","C:\\\\abso\\\\client\\\\abso.ts","hook"]\n',
134 );
135 // By default, this checkout's own: the node running it and client/abso.ts.
136 assert.deepEqual(hookCommand().slice(0, 1), [process.execPath]);
137 assert.match(hookCommand()[1]!, /client[\\/]abso\.ts$/);
138 });
init0Start the project140 it("moves the files in by rename, what the hook imports first and plugin.json last", () => {
141 const spec = source();
142 const target = join(temp(), "avcs");
143 installMod(spec, { target, check: pass, commit: "aaaaaaa" });
144 write(spec.from, "src/core.ts", "export const core = 2\n");
145 const order: string[] = [];
146 installMod(spec, {
147 target,
148 check: pass,
149 commit: "bbbbbbb",
150 rename: (from, to) => {
151 assert.ok(from.endsWith(".next"));
152 order.push(relative(target, to).replace(/\\/g, "/"));
153 renameSync(from, to);
154 },
155 });
156 assert.deepEqual(order, FILES);
157 });
159 it("checks the staged copy, stamped, and when the check fails changes nothing", () => {
160 const spec = source();
161 const target = join(temp(), "avcs");
162 installMod(spec, { target, check: pass, commit: "aaaaaaa" });
163 const before = contents(target);
164 write(spec.from, "src/core.ts", "export const core = 2\n");
165 let staged = "";
166 const failing = (dir: string) => {
167 staged = read(dir, "hooks/stamp.ts") + read(dir, "src/core.ts");
168 return "2 tests failed";
169 };
170 assert.throws(
171 () => installMod(spec, { target, check: failing, commit: "bbbbbbb" }),
172 /failed its check, so nothing was changed:\n2 tests failed/,
173 );
174 assert.match(staged, /'0\.1\.0\+bbbbbbb'[\s\S]*core = 2/);
175 assert.deepEqual(contents(target), before);
176 });
178 it("leaves no folder behind when a first install fails its check", () => {
179 const target = join(temp(), "avcs");
180 assert.throws(() => installMod(source(), { target, check: () => "no", commit: "aaaaaaa" }), /nothing was changed/);
181 assert.equal(existsSync(target), false);
182 });
184 it("changes nothing, and checks nothing, when the same files are installed again", () => {
185 const spec = source();
186 const target = join(temp(), "avcs");
187 installMod(spec, { target, check: pass, commit: "aaaaaaa" });
188 const mtime = statSync(at(target, "hooks/register.ts")).mtimeMs;
189 let checked = false;
190 const again = installMod(spec, { target, check: () => ((checked = true), undefined), commit: "aaaaaaa" });
191 assert.equal(again.changed, false);
192 assert.equal(checked, false);
193 assert.equal(statSync(at(target, "hooks/register.ts")).mtimeMs, mtime);
194 });
196 it("keeps what it replaces; a rollback puts it back, and a second rollback undoes the first", () => {
197 const spec = source();
198 const target = join(temp(), "avcs");
199 installMod(spec, { target, check: pass, commit: "aaaaaaa" });
200 write(spec.from, "src/core.ts", "export const core = 2\n");
201 const r = installMod(spec, { target, check: pass, commit: "bbbbbbb" });
202 assert.equal(r.previous, "0.1.0+aaaaaaa");
203 assert.equal(read(target, "src/core.ts.prev"), "export const core = 1\n");
205 const back = rollbackMod(spec, { target });
206 assert.deepEqual(back, { changed: true, version: "0.1.0+aaaaaaa", previous: "0.1.0+bbbbbbb", files: 5 });
207 assert.equal(read(target, "src/core.ts"), "export const core = 1\n");
208 assert.equal(JSON.parse(read(target, ".claude-plugin/plugin.json")).version, "0.1.0+aaaaaaa");
209 assert.match(read(target, "hooks/stamp.ts"), /'0\.1\.0\+aaaaaaa'/);
211 const forward = rollbackMod(spec, { target });
212 assert.equal(forward.version, "0.1.0+bbbbbbb");
213 assert.equal(read(target, "src/core.ts"), "export const core = 2\n");
214 assert.equal(record(target).prev?.version, "0.1.0+aaaaaaa");
215 });
217 it("puts back the files already moved when a rename fails midway", () => {
218 const spec = source();
219 const target = join(temp(), "avcs");
220 installMod(spec, { target, check: pass, commit: "aaaaaaa" });
221 const before = Object.fromEntries(FILES.map((rel) => [rel, read(target, rel)]));
222 write(spec.from, "src/core.ts", "export const core = 2\n");
223 write(spec.from, "hooks/register.ts", "import { core } from '../src/core.ts'\nexport const two = core\n");
224 let n = 0;
225 const flaky = (from: string, to: string) => {
226 if (++n === 3) throw Object.assign(new Error("EPERM: operation not permitted, rename"), { code: "EPERM" });
227 renameSync(from, to);
228 };
229 assert.throws(() => installMod(spec, { target, check: pass, commit: "bbbbbbb", rename: flaky }), /EPERM/);
230 assert.deepEqual(Object.fromEntries(FILES.map((rel) => [rel, read(target, rel)])), before);
231 assert.deepEqual(
232 tree(target).filter((f) => f.endsWith(".next")),
233 [],
234 );
235 assert.equal(record(target).version, "0.1.0+aaaaaaa");
236 assert.equal(record(target).moving, undefined);
237 });
239 it("keeps a mod installed before .avcs-install.json for a rollback", () => {
240 const spec = source();
241 const target = join(temp(), "avcs");
242 // The old installer copied four files and wrote nothing else.
243 for (const rel of FILES.filter((f) => f !== "hooks/stamp.ts")) {
244 mkdirSync(dirname(at(target, rel)), { recursive: true });
245 copyFileSync(at(spec.from, rel), at(target, rel));
246 }
247 const r = installMod(spec, { target, check: pass, commit: "bbbbbbb" });
248 assert.equal(r.previous, "0.1.0");
249 const back = rollbackMod(spec, { target });
250 assert.equal(back.version, "0.1.0");
251 assert.equal(JSON.parse(read(target, ".claude-plugin/plugin.json")).version, "0.1.0");
252 assert.equal(existsSync(at(target, "hooks/stamp.ts")), false);
253 });
255 it("after an install that stopped midway, keeps the last whole install for a rollback", () => {
256 const spec = source();
257 const target = join(temp(), "avcs");
258 installMod(spec, { target, check: pass, commit: "aaaaaaa" });
259 write(spec.from, "src/core.ts", "export const core = 2\n");
260 installMod(spec, { target, check: pass, commit: "bbbbbbb" });
261 // An install of ccccccc that died after its first rename: core.ts is new, the rest is bbbbbbb.
262 for (const rel of FILES) copyFileSync(at(target, rel), at(target, `${rel}.prev`));
263 writeFileSync(
264 at(target, ".avcs-install.json"),
265 JSON.stringify({ ...record(target), prev: { ...record(target), prev: undefined }, moving: "0.1.0+ccccccc" }),
266 );
267 write(target, "src/core.ts", "export const core = 3\n");
269 write(spec.from, "src/core.ts", "export const core = 4\n");
270 const r = installMod(spec, { target, check: pass, commit: "ddddddd" });
271 assert.equal(r.previous, "0.1.0+bbbbbbb");
272 assert.equal(read(target, "src/core.ts.prev"), "export const core = 2\n");
273 rollbackMod(spec, { target });
274 assert.equal(read(target, "src/core.ts"), "export const core = 2\n");
275 });
277 it("refuses while another install holds the lock, and takes over a lock left by one that died", () => {
278 const spec = source();
279 const target = join(temp(), "avcs");
280 installMod(spec, { target, check: pass, commit: "aaaaaaa" });
281 write(spec.from, "src/core.ts", "export const core = 2\n");
282 const lock = at(target, ".avcs-install.lock");
283 writeFileSync(lock, "");
284 assert.throws(() => installMod(spec, { target, check: pass, commit: "bbbbbbb" }), /another install is running/);
285 assert.throws(() => rollbackMod(spec, { target }), /another install is running/);
286 const old = new Date(Date.now() - 11 * 60_000);
287 utimesSync(lock, old, old);
288 assert.equal(installMod(spec, { target, check: pass, commit: "bbbbbbb" }).changed, true);
289 assert.equal(existsSync(lock), false);
290 });
292 it("says so when there is nothing to roll back to", () => {
293 const spec = source();
294 const target = join(temp(), "avcs");
295 assert.throws(() => rollbackMod(spec, { target }), /nothing is installed/);
296 installMod(spec, { target, check: pass, commit: "aaaaaaa" });
297 assert.throws(() => rollbackMod(spec, { target }), /no earlier install is kept/);
298 });
300 it("stamps plugin.json's version plus the last commit that changed the mod's files, and .dirty when they differ from it", {
301 skip: !hasGit,
302 }, () => {
303 const spec = source();
304 const git = (...args: string[]) =>
305 spawnSync("git", ["-c", "user.name=t", "-c", "user.email=t@t", "-C", spec.from, ...args], {
306 encoding: "utf8",
307 }).stdout.trim();
308 git("init", "-q");
309 git("add", ".");
310 git("commit", "-q", "-m", "mod");
311 const mod = git("rev-parse", "--short=7", "HEAD");
312 assert.equal(versionFor(spec), `0.1.0+${mod}`);
313 // A commit that changes none of the mod's files leaves the stamp, so a reinstall changes nothing.
314 write(spec.from, "README.md", "not part of the mod\n");
315 assert.equal(versionFor(spec), `0.1.0+${mod}`);
316 git("add", ".");
317 git("commit", "-q", "-m", "docs");
318 assert.equal(versionFor(spec), `0.1.0+${mod}`);
319 const target = join(temp(), "avcs");
320 installMod(spec, { target, check: pass });
321 assert.equal(installMod(spec, { target, check: pass }).changed, false);
322 write(spec.from, "src/core.ts", "export const core = 2\n");
323 assert.equal(versionFor(spec), `0.1.0+${mod}.dirty`);
324 git("commit", "-q", "-am", "core");
325 assert.equal(versionFor(spec), `0.1.0+${git("rev-parse", "--short=7", "HEAD")}`);
326 // Outside a git checkout there is no commit to add.
327 assert.equal(versionFor(spec, null), "0.1.0");
328 });
speed43status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't runCompare329
330 it("keeps the mod's commit between runs, and asks git again when the checkout or a file moves, or a file is too new to trust", {
331 skip: !hasGit,
332 }, () => {
333 const spec = source();
334 const home = temp();
335 const kept = join(home, ".abso", "mod-commits.json");
336 const git = (...args: string[]) =>
337 spawnSync("git", ["-c", "user.name=t", "-c", "user.email=t@t", "-C", spec.from, ...args], {
338 encoding: "utf8",
339 }).stdout.trim();
speed45Test fix: the mod-commit test set the same 'a minute ago' time twice within a second, which git's index (compared by the second) took as unchanged on Linux; each step now sets its own earlier minuteCompare340 // Every mod file minutes old, so a kept answer can be trusted. Each call sets a whole minute earlier
341 // than the last: git's own index compares times by the second, and a same-size edit given the time
342 // git last saw would look unchanged to git itself.
343 let minutes = 0;
speed43status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't runCompare344 const age = () => {
speed45Test fix: the mod-commit test set the same 'a minute ago' time twice within a second, which git's index (compared by the second) took as unchanged on Linux; each step now sets its own earlier minuteCompare345 minutes += 1;
346 const old = new Date(Date.now() - minutes * 60_000);
speed43status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't runCompare347 for (const rel of FILES) utimesSync(at(spec.from, rel), old, old);
348 };
349 // Swaps every kept answer for a made-up one: what comes back says whether git ran.
350 const plant = () => {
351 const file = JSON.parse(readFileSync(kept, "utf8"));
352 for (const k of Object.keys(file.mods)) file.mods[k].commit = "fffffff";
353 writeFileSync(kept, JSON.stringify(file));
354 };
355 // Not a git checkout yet: no commit, and nothing kept.
356 assert.equal(keptModCommit(spec, home), null);
357 assert.equal(existsSync(kept), false);
358 git("init", "-q");
359 git("add", ".");
360 git("commit", "-q", "-m", "mod");
361 const mod = git("rev-parse", "--short=7", "HEAD");
362 age();
363 assert.equal(keptModCommit(spec, home), mod);
364 plant();
365 assert.equal(keptModCommit(spec, home), "fffffff", "a kept answer is used while nothing moved");
367 // A file changed in the same moment the answer was kept is never trusted, even when its size and time match.
speed44status: skip reading files found unchanged before. A record in the folder's state dir (clean.json) keeps, per file, the size, time and inode of the file and its known copy, taken before reading; only status's unrecorded and line-ending checks use it, record always reads every file. Files changed too recently to trust are read; an unknown format or client version reads everything. The state dir is found once per walk. The mod-commit test no longer depends on how long it takes.Compare368 // A time a minute ahead stays too new however long the run takes.
speed43status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't runCompare369 write(spec.from, "src/core.ts", "export const core = 2\n");
speed44status: skip reading files found unchanged before. A record in the folder's state dir (clean.json) keeps, per file, the size, time and inode of the file and its known copy, taken before reading; only status's unrecorded and line-ending checks use it, record always reads every file. Files changed too recently to trust are read; an unknown format or client version reads everything. The state dir is found once per walk. The mod-commit test no longer depends on how long it takes.Compare370 const soon = new Date(Date.now() + 60_000);
371 utimesSync(at(spec.from, "src/core.ts"), soon, soon);
speed43status: keep each mod's commit between runs (~/.abso/mod-commits.json), keyed on the checkout's commit read from .git and each mod file's size, time and inode, so status runs no git while nothing moved; files changed too recently to trust are asked again; outside a git checkout git isn't runCompare372 assert.equal(keptModCommit(spec, home), `${mod}.dirty`);
373 plant();
374 assert.equal(keptModCommit(spec, home), `${mod}.dirty`, "too new to trust: git runs again");
376 // An edit that keeps the size, with its time set back a minute, still isn't the time that was kept.
377 age();
378 assert.equal(keptModCommit(spec, home), `${mod}.dirty`);
379 plant();
380 write(spec.from, "src/core.ts", "export const core = 3\n");
381 age();
382 assert.equal(keptModCommit(spec, home), `${mod}.dirty`);
384 // A commit moves the checkout.
385 git("commit", "-q", "-am", "core");
386 age();
387 const next = git("rev-parse", "--short=7", "HEAD");
388 assert.equal(keptModCommit(spec, home), next);
389 plant();
390 git("commit", "-q", "--allow-empty", "-m", "empty");
391 assert.equal(keptModCommit(spec, home), next, "a new commit asks git again");
393 // A file it can't read, or doesn't know the format of, is the same as none.
394 plant();
395 writeFileSync(kept, JSON.stringify({ format: 2, mods: JSON.parse(readFileSync(kept, "utf8")).mods }));
396 assert.equal(keptModCommit(spec, home), next);
397 writeFileSync(kept, "not json");
398 assert.equal(keptModCommit(spec, home), next);
399 });
init0Start the project400});
402describe("which client this is", () => {
403 const git = (cwd: string, ...args: string[]) =>
404 spawnSync(
405 "git",
406 ["-c", "user.name=t", "-c", "user.email=t@t", "-c", "init.defaultBranch=main", "-C", cwd, ...args],
407 { encoding: "utf8" },
408 ).stdout.trim();
410 it("reads the commit from .git as git does: a branch, a packed branch, a detached head, a worktree", {
411 skip: !hasGit,
412 }, () => {
413 const repo = temp();
414 git(repo, "init", "-q");
415 write(repo, "a/b/file.txt", "one\n");
416 git(repo, "add", ".");
417 git(repo, "commit", "-q", "-m", "one");
418 assert.equal(headCommit(join(repo, "a", "b")), git(repo, "rev-parse", "--short=7", "HEAD"));
419 write(repo, "a/b/file.txt", "two\n");
420 git(repo, "commit", "-q", "-am", "two");
421 git(repo, "pack-refs", "--all");
422 assert.equal(existsSync(join(repo, ".git", "refs", "heads", "main")), false);
423 assert.equal(headCommit(repo), git(repo, "rev-parse", "--short=7", "HEAD"));
424 const first = git(repo, "rev-parse", "--short=7", "HEAD~1");
425 git(repo, "checkout", "-q", "--detach", "HEAD~1");
426 assert.equal(headCommit(repo), first);
427 const wt = join(temp(), "wt");
428 git(repo, "worktree", "add", "-q", "-b", "side", wt, "main");
429 write(wt, "a/b/file.txt", "three\n");
430 git(wt, "commit", "-q", "-am", "three");
431 assert.equal(headCommit(join(wt, "a")), git(wt, "rev-parse", "--short=7", "HEAD"));
432 assert.notEqual(headCommit(wt), headCommit(repo));
433 });
435 it("has no commit outside a repository", () => {
436 assert.equal(headCommit(temp()), undefined);
437 });
439 it("avcs --version names this client's version and the mods installed, and which are from another commit", async () => {
440 const config = temp();
441 const spec = source();
442 installMod(spec, {
review40Mods: the hooks mod is abso-hooks and the view mod abso-view; an install moves the old skills/avcs and skills/avcs-view folders to ~/.abso/retired-mods (moved, not deleted); the hook stands down for either name; status checks either. Tests cover the move.Compare443 target: join(config, "skills", "abso-hooks"),
init0Start the project444 check: pass,
445 commit: "aaaaaaa",
446 now: new Date("2026-10-05T04:30:00Z"),
447 });
448 const out = await main(["--version"], { cwd: config, env: { CLAUDE_CONFIG_DIR: config }, write: () => {} });
449 const [client, mod, view] = out.stdout.trimEnd().split("\n");
450 assert.equal(out.exit, 0);
451 assert.equal(client, `abso ${clientVersion()} (${dirname(import.meta.dirname)})`);
452 assert.match(
453 mod!,
pinch281Client fixes from the judge dry run: help with today's names, a mod installer hint that runs, a failed init or join takes back what it wrote, a refused 401 names the credential that went, and reply --file - help: abso.json, ABSO_ADMIN_TOKEN, ABSO_ADMIN_SERVERS, ABSO_BOX and .abso/shots/ in place of the old names, and the missing full stop. abso shot saves under .abso/shots/ as help says. - --version, init, join and status name the mod installer by its full path, and on a Node that can't run .ts files say it needs Node 22.18 or later. A built copy, which has no installer, says abso record sends the edits. - A failed init removes the .absoignore and abso.json it wrote. A failed join removes its .abso/ folder; a key already there, or one made for this join, stays. - A 401 names what was sent (this folder's key, ABSO_TOKEN, a pipeline run's key, the token file) instead of always a folder key. - reply takes --file <path> or --file - (stdin), like ask and answer. - The mod-behind tests no longer depend on which mods the machine has. Tests: install, body-files, failed-start (new), doctor, help, lost-pull pass; tsc clean.Compare454 /^the abso-hooks mod: 0\.1\.0\+aaaaaaa in .*skills[\\/]abso-hooks, installed 2026-10-05 04:30 UTC; this client has 0.2.0(\+[0-9a-f]{7}(\.dirty)?)?: /,
init0Start the project455 );
pinch281Client fixes from the judge dry run: help with today's names, a mod installer hint that runs, a failed init or join takes back what it wrote, a refused 401 names the credential that went, and reply --file - help: abso.json, ABSO_ADMIN_TOKEN, ABSO_ADMIN_SERVERS, ABSO_BOX and .abso/shots/ in place of the old names, and the missing full stop. abso shot saves under .abso/shots/ as help says. - --version, init, join and status name the mod installer by its full path, and on a Node that can't run .ts files say it needs Node 22.18 or later. A built copy, which has no installer, says abso record sends the edits. - A failed init removes the .absoignore and abso.json it wrote. A failed join removes its .abso/ folder; a key already there, or one made for this join, stays. - A 401 names what was sent (this folder's key, ABSO_TOKEN, a pipeline run's key, the token file) instead of always a folder key. - reply takes --file <path> or --file - (stdin), like ask and answer. - The mod-behind tests no longer depend on which mods the machine has. Tests: install, body-files, failed-start (new), doctor, help, lost-pull pass; tsc clean.Compare456 assert.ok(mod!.endsWith(`: ${installerCommand("install-mod.ts")} installs it`), mod);
457 assert.equal(view, `the abso-view mod: not installed (${installerCommand("install-view.ts")})`);
init0Start the project458 const json = JSON.parse(
459 (await main(["--version", "--json"], { cwd: config, env: { CLAUDE_CONFIG_DIR: config }, write: () => {} }))
460 .stdout,
461 );
462 assert.equal(json.client, clientVersion());
463 assert.equal(json.mods[0].version, "0.1.0+aaaaaaa");
464 });
review40Mods: the hooks mod is abso-hooks and the view mod abso-view; an install moves the old skills/avcs and skills/avcs-view folders to ~/.abso/retired-mods (moved, not deleted); the hook stands down for either name; status checks either. Tests cover the move.Compare466 it("moves the old avcs mod folder out of the skills folder, not deleting it, once abso-hooks is in", () => {
467 const config = temp();
468 const old = join(config, "skills", "avcs");
469 write(old, ".claude-plugin/plugin.json", '{"name":"avcs","version":"0.1.0"}');
470 const home = temp();
471 const was = process.env.USERPROFILE;
472 const was2 = process.env.HOME;
473 process.env.USERPROFILE = home;
474 process.env.HOME = home;
475 try {
476 const to = retireOldMod(AVCS_MOD, { CLAUDE_CONFIG_DIR: config });
477 assert.ok(to?.startsWith(join(home, ".abso", "retired-mods")));
478 assert.equal(existsSync(old), false);
479 assert.equal(existsSync(join(to!, ".claude-plugin", "plugin.json")), true);
480 assert.equal(retireOldMod(AVCS_MOD, { CLAUDE_CONFIG_DIR: config }), undefined);
481 } finally {
482 if (was === undefined) delete process.env.USERPROFILE;
483 else process.env.USERPROFILE = was;
484 if (was2 === undefined) delete process.env.HOME;
485 else process.env.HOME = was2;
486 }
487 });
init0Start the project489 it("status says when an installed mod is behind this client, where the client knows its commit (abso issue 41)", () => {
490 const config = temp();
491 const env = { CLAUDE_CONFIG_DIR: config };
492 assert.deepEqual(modsBehindText(env), [], "nothing installed, nothing to say");
493 installMod(source(), {
review40Mods: the hooks mod is abso-hooks and the view mod abso-view; an install moves the old skills/avcs and skills/avcs-view folders to ~/.abso/retired-mods (moved, not deleted); the hook stands down for either name; status checks either. Tests cover the move.Compare494 target: join(config, "skills", "abso-hooks"),
init0Start the project495 check: pass,
496 commit: "aaaaaaa",
497 now: new Date("2026-10-05T04:30:00Z"),
498 });
499 const current = (versionReport(env).json.mods as { current: string }[])[0]!.current;
500 if (/\+[0-9a-f]{7}$/.test(current))
501 assert.deepEqual(modsBehindText(env), [
pinch281Client fixes from the judge dry run: help with today's names, a mod installer hint that runs, a failed init or join takes back what it wrote, a refused 401 names the credential that went, and reply --file - help: abso.json, ABSO_ADMIN_TOKEN, ABSO_ADMIN_SERVERS, ABSO_BOX and .abso/shots/ in place of the old names, and the missing full stop. abso shot saves under .abso/shots/ as help says. - --version, init, join and status name the mod installer by its full path, and on a Node that can't run .ts files say it needs Node 22.18 or later. A built copy, which has no installer, says abso record sends the edits. - A failed init removes the .absoignore and abso.json it wrote. A failed join removes its .abso/ folder; a key already there, or one made for this join, stays. - A 401 names what was sent (this folder's key, ABSO_TOKEN, a pipeline run's key, the token file) instead of always a folder key. - reply takes --file <path> or --file - (stdin), like ask and answer. - The mod-behind tests no longer depend on which mods the machine has. Tests: install, body-files, failed-start (new), doctor, help, lost-pull pass; tsc clean.Compare502 `The ${AVCS_MOD.name} mod installed on this machine is 0.1.0+aaaaaaa, and this client has ${current}: ${installerCommand("install-mod.ts")} installs it (new chats load it).`,
init0Start the project503 ]);
504 // A client outside git (an abso folder, a box) can't tell, so it says nothing.
505 else assert.deepEqual(modsBehindText(env), []);
506 });
508 it("the command-line client says which client it is with every call", () => {
509 const headers = new Api({
510 server: "https://avcs.test",
511 project: "p",
512 agent: "a",
513 token: "t",
514 } as ConstructorParameters<typeof Api>[0]).headers("application/json");
pinch54The client and the edit mods send and read X-Abso-* headers only (Client, Name, Run-Key, Kind, Admin; Run, Box, Prep from answers). Servers have read X-Abso-* beside the old names for a while and answer under both, so this works with any current server.Compare515 assert.equal(headers["x-abso-client"], `abso-cli/${clientVersion()}`);
init0Start the project516 assert.match(clientVersion(), /^\d+\.\d+\.\d+(\+[0-9a-f]{7})?$/);
517 });
pinch59The client reports an npm package's version: a build that sets __ABSO_PACKAGE_VERSION__ gets it from abso --version and in its client header, and a built copy (the npm package or a downloaded abso.mjs) reports the installed mods without pointing at install scripts it doesn't haveCompare518
519 it("the npm package's client gives the package's version", () => {
520 const url = new URL("../src/client-version.ts", import.meta.url).href;
521 const script = `globalThis.__ABSO_PACKAGE_VERSION__ = "0.58.0"; const m = await import(${JSON.stringify(url)}); console.log(m.clientVersion());`;
522 const r = spawnSync(process.execPath, ["--input-type=module", "-e", script], { encoding: "utf8" });
523 assert.equal(r.stdout.trim(), "0.58.0", r.stderr);
524 });
init0Start the project525});