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

Compare

+143 −7 in 8 places
Lines 24–42 at 318 (were 24–30 at 35)
2424import { after, describe, it } from "node:test";
2525import { Api } from "../src/api.ts";
2626import { clientVersion, headCommit } from "../src/client-version.ts";
27−import { installMod, type ModSpec, modsBehindText, rollbackMod, versionFor, versionReport } from "../src/install.ts";
27+import {
28+ AVCS_MOD,
29+ hookCommand,
30+ installerCommand,
31+ installMod,
32+ keptModCommit,
33+ type ModSpec,
34+ modsBehindText,
35+ retireOldMod,
36+ rollbackMod,
37+ versionFor,
38+ versionReport,
39+} from "../src/install.ts";
2840import { main } from "../src/main.ts";
2941
3042const hasGit = spawnSync("git", ["--version"]).status === 0;
Lines 115–142 at 318 (were 103–108 at 35)
103115 );
104116 });
105117
118+ 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+ });
106140 it("moves the files in by rename, what the hook imports first and plugin.json last", () => {
107141 const spec = source();
108142 const target = join(temp(), "avcs");
Lines 326–402 at 318 (were 292–297 at 35)
292326 // Outside a git checkout there is no commit to add.
293327 assert.equal(versionFor(spec, null), "0.1.0");
294328 });
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();
340+ // 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;
344+ const age = () => {
345+ minutes += 1;
346+ const old = new Date(Date.now() - minutes * 60_000);
347+ 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.
368+ // A time a minute ahead stays too new however long the run takes.
369+ write(spec.from, "src/core.ts", "export const core = 2\n");
370+ const soon = new Date(Date.now() + 60_000);
371+ utimesSync(at(spec.from, "src/core.ts"), soon, soon);
372+ 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+ });
295400});
296401
297402describe("which client this is", () => {
Lines 440–446 at 318 (were 335–341 at 35)
335440 const config = temp();
336441 const spec = source();
337442 installMod(spec, {
338− target: join(config, "skills", "avcs"),
443+ target: join(config, "skills", "abso-hooks"),
339444 check: pass,
340445 commit: "aaaaaaa",
341446 now: new Date("2026-10-05T04:30:00Z"),
Lines 451–460 at 318 (were 346–354 at 35)
346451 assert.equal(client, `abso ${clientVersion()} (${dirname(import.meta.dirname)})`);
347452 assert.match(
348453 mod!,
349− /^the avcs mod: 0\.1\.0\+aaaaaaa in .*skills[\\/]avcs, installed 2026-10-05 04:30 UTC; this client has 0.2.0(\+[0-9a-f]{7}(\.dirty)?)?: node client\/install-mod\.ts installs it$/,
454+ /^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)?)?: /,
350455 );
351− assert.equal(view, "the avcs-view mod: not installed (node client/install-view.ts)");
456+ 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")})`);
352458 const json = JSON.parse(
353459 (await main(["--version", "--json"], { cwd: config, env: { CLAUDE_CONFIG_DIR: config }, write: () => {} }))
354460 .stdout,
Lines 463–497 at 318 (were 357–368 at 35)
357463 assert.equal(json.mods[0].version, "0.1.0+aaaaaaa");
358464 });
359465
466+ 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+ });
360489 it("status says when an installed mod is behind this client, where the client knows its commit (abso issue 41)", () => {
361490 const config = temp();
362491 const env = { CLAUDE_CONFIG_DIR: config };
363492 assert.deepEqual(modsBehindText(env), [], "nothing installed, nothing to say");
364493 installMod(source(), {
365− target: join(config, "skills", "avcs"),
494+ target: join(config, "skills", "abso-hooks"),
366495 check: pass,
367496 commit: "aaaaaaa",
368497 now: new Date("2026-10-05T04:30:00Z"),
Lines 499–505 at 318 (were 370–376 at 35)
370499 const current = (versionReport(env).json.mods as { current: string }[])[0]!.current;
371500 if (/\+[0-9a-f]{7}$/.test(current))
372501 assert.deepEqual(modsBehindText(env), [
373− `The avcs mod installed on this machine is 0.1.0+aaaaaaa, and this client has ${current}: node client/install-mod.ts installs it (new chats load it).`,
502+ `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).`,
374503 ]);
375504 // A client outside git (an abso folder, a box) can't tell, so it says nothing.
376505 else assert.deepEqual(modsBehindText(env), []);
Lines 512–525 at 318 (were 383–389 at 35)
383512 agent: "a",
384513 token: "t",
385514 } as ConstructorParameters<typeof Api>[0]).headers("application/json");
386− assert.equal(headers["x-avcs-client"], `abso-cli/${clientVersion()}`);
515+ assert.equal(headers["x-abso-client"], `abso-cli/${clientVersion()}`);
387516 assert.match(clientVersion(), /^\d+\.\d+\.\d+(\+[0-9a-f]{7})?$/);
388517 });
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+ });
389525});
MCP
compare on this site's /mcp
CLI
abso diff 35 318 client/test/install.test.ts --json
JSON
/christopher/abso-core/compare/35..318?file=client%2Ftest%2Finstall.test.ts&format=json