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 42 to 43

Compare

+65 −0 in 2 places
Lines 27–33 at 43 (were 27–32 at 42)
2727import {
2828 AVCS_MOD,
2929 installMod,
30+ keptModCommit,
3031 type ModSpec,
3132 modsBehindText,
3233 retireOldMod,
Lines 302–371 at 43 (were 301–306 at 42)
301302 // Outside a git checkout there is no commit to add.
302303 assert.equal(versionFor(spec, null), "0.1.0");
303304 });
306+ 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", {
307+ skip: !hasGit,
308+ }, () => {
309+ const spec = source();
310+ const home = temp();
311+ const kept = join(home, ".abso", "mod-commits.json");
312+ const git = (...args: string[]) =>
313+ spawnSync("git", ["-c", "user.name=t", "-c", "user.email=t@t", "-C", spec.from, ...args], {
314+ encoding: "utf8",
315+ }).stdout.trim();
316+ // Every mod file a minute old, so a kept answer can be trusted.
317+ const age = () => {
318+ const old = new Date(Date.now() - 60_000);
319+ for (const rel of FILES) utimesSync(at(spec.from, rel), old, old);
320+ };
321+ // Swaps every kept answer for a made-up one: what comes back says whether git ran.
322+ const plant = () => {
323+ const file = JSON.parse(readFileSync(kept, "utf8"));
324+ for (const k of Object.keys(file.mods)) file.mods[k].commit = "fffffff";
325+ writeFileSync(kept, JSON.stringify(file));
326+ };
327+ // Not a git checkout yet: no commit, and nothing kept.
328+ assert.equal(keptModCommit(spec, home), null);
329+ assert.equal(existsSync(kept), false);
330+ git("init", "-q");
331+ git("add", ".");
332+ git("commit", "-q", "-m", "mod");
333+ const mod = git("rev-parse", "--short=7", "HEAD");
334+ age();
335+ assert.equal(keptModCommit(spec, home), mod);
336+ plant();
337+ assert.equal(keptModCommit(spec, home), "fffffff", "a kept answer is used while nothing moved");
339+ // A file changed in the same moment the answer was kept is never trusted, even when its size and time match.
340+ write(spec.from, "src/core.ts", "export const core = 2\n");
341+ assert.equal(keptModCommit(spec, home), `${mod}.dirty`);
342+ plant();
343+ assert.equal(keptModCommit(spec, home), `${mod}.dirty`, "too new to trust: git runs again");
345+ // An edit that keeps the size, with its time set back a minute, still isn't the time that was kept.
346+ age();
347+ assert.equal(keptModCommit(spec, home), `${mod}.dirty`);
348+ plant();
349+ write(spec.from, "src/core.ts", "export const core = 3\n");
350+ age();
351+ assert.equal(keptModCommit(spec, home), `${mod}.dirty`);
353+ // A commit moves the checkout.
354+ git("commit", "-q", "-am", "core");
355+ age();
356+ const next = git("rev-parse", "--short=7", "HEAD");
357+ assert.equal(keptModCommit(spec, home), next);
358+ plant();
359+ git("commit", "-q", "--allow-empty", "-m", "empty");
360+ assert.equal(keptModCommit(spec, home), next, "a new commit asks git again");
362+ // A file it can't read, or doesn't know the format of, is the same as none.
363+ plant();
364+ writeFileSync(kept, JSON.stringify({ format: 2, mods: JSON.parse(readFileSync(kept, "utf8")).mods }));
365+ assert.equal(keptModCommit(spec, home), next);
366+ writeFileSync(kept, "not json");
367+ assert.equal(keptModCommit(spec, home), next);
368+ });
304369});
305370
306371describe("which client this is", () => {
MCP
compare on this site's /mcp
CLI
abso diff 42 43 client/test/install.test.ts --json
JSON
/christopher/abso-core/compare/42..43?file=client%2Ftest%2Finstall.test.ts&format=json