Lines 26–35 at 318 (were 26–32 at 41)
2626import { clientVersion, headCommit } from "../src/client-version.ts"; Lines 115–142 at 318 (were 112–117 at 41)
118+ it("stamps the command that runs this client's abso hook, where stamp.ts has a HOOK_COMMAND line", () => { 119+ const spec = source({ 121+ "export const STAMP: string | undefined = undefined\nexport const HOOK_COMMAND: readonly string[] | undefined = undefined\n", 123+ const target = join(temp(), "avcs"); 128+ hookCommand: ["C:\\node.exe", "C:\\abso\\client\\abso.ts", "hook"], 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', 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$/); 115140 it("moves the files in by rename, what the hook imports first and plugin.json last", () => { 116141 const spec = source(); 117142 const target = join(temp(), "avcs"); Lines 326–402 at 318 (were 301–306 at 41)
301326 // Outside a git checkout there is no commit to add. 302327 assert.equal(versionFor(spec, null), "0.1.0"); 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", { 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], { 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. 346+ const old = new Date(Date.now() - minutes * 60_000); 347+ for (const rel of FILES) utimesSync(at(spec.from, rel), old, old); 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)); 355+ // Not a git checkout yet: no commit, and nothing kept. 356+ assert.equal(keptModCommit(spec, home), null); 357+ assert.equal(existsSync(kept), false); 360+ git("commit", "-q", "-m", "mod"); 361+ const mod = git("rev-parse", "--short=7", "HEAD"); 363+ assert.equal(keptModCommit(spec, home), mod); 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`); 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. 378+ assert.equal(keptModCommit(spec, home), `${mod}.dirty`); 380+ write(spec.from, "src/core.ts", "export const core = 3\n"); 382+ assert.equal(keptModCommit(spec, home), `${mod}.dirty`); 384+ // A commit moves the checkout. 385+ git("commit", "-q", "-am", "core"); 387+ const next = git("rev-parse", "--short=7", "HEAD"); 388+ assert.equal(keptModCommit(spec, home), next); 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. 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); 306402describe("which client this is", () => { Lines 451–460 at 318 (were 355–363 at 41)
355451 assert.equal(client, `abso ${clientVersion()} (${dirname(import.meta.dirname)})`); 358− /^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)?)?: 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)?)?: /, 360− assert.equal(view, "the abso-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")})`); 361458 const json = JSON.parse( 362459 (await main(["--version", "--json"], { cwd: config, env: { CLAUDE_CONFIG_DIR: config }, write: () => {} })) Lines 499–505 at 318 (were 402–408 at 41)
402499 const current = (versionReport(env).json.mods as { current: string }[])[0]!.current; 403500 if (/\+[0-9a-f]{7}$/.test(current)) 404501 assert.deepEqual(modsBehindText(env), [ 405− `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).`, 407504 // A client outside git (an abso folder, a box) can't tell, so it says nothing. 408505 else assert.deepEqual(modsBehindText(env), []); Lines 512–525 at 318 (were 415–421 at 41)
417514 } as ConstructorParameters<typeof Api>[0]).headers("application/json"); 418− assert.equal(headers["x-avcs-client"], `abso-cli/${clientVersion()}`);
515+ assert.equal(headers["x-abso-client"], `abso-cli/${clientVersion()}`); 419516 assert.match(clientVersion(), /^\d+\.\d+\.\d+(\+[0-9a-f]{7})?$/); 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);