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 149 to 150

Compare

+68 −0 in 1 place
new file, 68 lines
1+import assert from "node:assert/strict";
2+import { describe, it } from "node:test";
3+import git from "isomorphic-git";
4+import { absoVersion } from "../src/ingest.ts";
5+import { MemoryFS } from "../src/memory-fs.ts";
6+import { commitShared, projectOfRepo, readTreeFiles, repoName } from "../src/push.ts";
7+
8+describe("repo names", () => {
9+ it("names a project's Artifacts repo abso-<project>, and back", () => {
10+ assert.equal(repoName("game"), "abso-game");
11+ assert.equal(repoName("my.site_2"), "abso-my.site_2");
12+ assert.equal(projectOfRepo("abso-game"), "game");
13+ assert.equal(projectOfRepo("avcs-game"), null);
14+ assert.equal(projectOfRepo("abso-"), null);
15+ });
17+ it("reads the version a pushed commit carries, under either name", () => {
18+ assert.equal(absoVersion("Fix it\n\nabso-version: 12\n"), 12);
19+ assert.equal(absoVersion("Fix it\n\navcs-version: 7\n"), 7);
20+ assert.equal(absoVersion("a person's own commit"), undefined);
21+ });
22+});
24+describe("commitShared", () => {
25+ it("writes shared as a commit with its modes, then only what changed", async () => {
26+ const fs = new MemoryFS();
27+ const dir = "/repo";
28+ await git.init({ fs, dir, defaultBranch: "main" });
29+ const noBlobs = () => null;
30+ const first = await commitShared(
31+ fs,
32+ dir,
33+ null,
34+ {
35+ version: 0,
36+ files: { "a.txt": "one\n", "run.sh": "echo hi\n", link: "" },
37+ modes: { "run.sh": { exec: true }, link: { link: "a.txt" } },
38+ },
39+ noBlobs,
40+ );
41+ assert.equal(first.changed, 3);
42+ const commit = (await git.readCommit({ fs, dir, oid: first.commit })).commit;
43+ assert.match(commit.message, /^Start the project\n\nabso-version: 0\n$/);
44+ const { files } = await readTreeFiles(fs, dir, commit.tree);
45+ assert.deepEqual(Object.fromEntries([...files].map(([p, f]) => [p, f.mode])), {
46+ "a.txt": "100644",
47+ link: "120000",
48+ "run.sh": "100755",
49+ });
50+ const second = await commitShared(
51+ fs,
52+ dir,
53+ first.commit,
54+ {
55+ version: 1,
56+ files: { "a.txt": "one\ntwo\n", "run.sh": "echo hi\n", link: "" },
57+ modes: { "run.sh": { exec: true }, link: { link: "a.txt" } },
58+ last: { agent: "alice", message: "Add two" },
59+ },
60+ noBlobs,
61+ );
62+ assert.equal(second.changed, 1);
63+ const next = (await git.readCommit({ fs, dir, oid: second.commit })).commit;
64+ assert.equal(next.author.name, "alice");
65+ assert.deepEqual(next.parent, [first.commit]);
66+ assert.equal(absoVersion(next.message), 1);
67+ });
68+});
MCP
compare on this site's /mcp
CLI
abso diff 149 150 server/test/push.test.ts --json
JSON
/christopher/abso-core/compare/149..150?file=server%2Ftest%2Fpush.test.ts&format=json