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
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/server/test/push.test.ts?version=180&format=json
101 linesspeed 66% · codex-capacity-chair 34%Last change codex-capacity-chair in version 180, 3 versions changed it

You're reading version 180. The newest is 318, and 1 version since then changed this file. Go to the newestCompare with 318

1import assert from "node:assert/strict";
2import { describe, it } from "node:test";
3import git from "isomorphic-git";
4import { absoVersion } from "../src/ingest.ts";
5import { MemoryFS } from "../src/memory-fs.ts";
6import { blobOid, commitShared, projectOfRepo, readTreeFiles, repoName } from "../src/push.ts";
7
8it("hashes exact Git blob bytes including a nonzero buffer offset", async () => {
9 assert.equal(await blobOid(new Uint8Array()), "e69de29bb2d1d6434b8b29ae775ad8c2e48c5391");
10 const bytes = new TextEncoder().encode("prefixhello\nsuffix");
11 assert.equal(await blobOid(bytes.subarray(6, 12)), "ce013625030ba8dba906f756967f9e9ca394464a");
12});
14describe("repo names", () => {
15 it("names a project's Artifacts repo abso-<project>, and back", () => {
16 assert.equal(repoName("game"), "abso-game");
17 assert.equal(repoName("my.site_2"), "abso-my.site_2");
18 assert.equal(projectOfRepo("abso-game"), "game");
19 assert.equal(projectOfRepo("avcs-game"), null);
20 assert.equal(projectOfRepo("abso-"), null);
21 });
23 it("reads the version a pushed commit carries, under either name", () => {
24 assert.equal(absoVersion("Fix it\n\nabso-version: 12\n"), 12);
25 assert.equal(absoVersion("Fix it\n\navcs-version: 7\n"), 7);
26 assert.equal(absoVersion("a person's own commit"), undefined);
27 });
28});
30describe("commitShared", () => {
31 it("reads one lazy file at a time and does not read symlink placeholder text", async (t) => {
32 const fs = new MemoryFS();
33 const dir = "/repo";
34 await git.init({ fs, dir, defaultBranch: "main" });
35 let writes = 0;
36 const writeBlob = git.writeBlob;
37 t.mock.method(git, "writeBlob", async (options: Parameters<typeof writeBlob>[0]) => {
38 const result = await writeBlob(options);
39 writes++;
40 return result;
41 });
42 const files = {
43 get a() {
44 assert.equal(writes, 0);
45 return "first";
46 },
47 get b() {
48 assert.equal(writes, 1);
49 return "second";
50 },
51 get link(): string {
52 throw Error("symlink placeholder text must not be read");
53 },
54 };
55 await commitShared(fs, dir, null, { version: 0, files, modes: { link: { link: "a" } } }, () => null);
56 assert.equal(writes, 3);
57 });
58 it("writes shared as a commit with its modes, then only what changed", async () => {
59 const fs = new MemoryFS();
60 const dir = "/repo";
61 await git.init({ fs, dir, defaultBranch: "main" });
62 const noBlobs = () => null;
63 const first = await commitShared(
64 fs,
65 dir,
66 null,
67 {
68 version: 0,
69 files: { "a.txt": "one\n", "run.sh": "echo hi\n", link: "" },
70 modes: { "run.sh": { exec: true }, link: { link: "a.txt" } },
71 },
72 noBlobs,
73 );
74 assert.equal(first.changed, 3);
75 const commit = (await git.readCommit({ fs, dir, oid: first.commit })).commit;
76 assert.match(commit.message, /^Start the project\n\nabso-version: 0\n$/);
77 const { files } = await readTreeFiles(fs, dir, commit.tree);
78 assert.deepEqual(Object.fromEntries([...files].map(([p, f]) => [p, f.mode])), {
79 "a.txt": "100644",
80 link: "120000",
81 "run.sh": "100755",
82 });
83 const second = await commitShared(
84 fs,
85 dir,
86 first.commit,
87 {
88 version: 1,
89 files: { "a.txt": "one\ntwo\n", "run.sh": "echo hi\n", link: "" },
90 modes: { "run.sh": { exec: true }, link: { link: "a.txt" } },
91 last: { agent: "alice", message: "Add two" },
92 },
93 noBlobs,
94 );
95 assert.equal(second.changed, 1);
96 const next = (await git.readCommit({ fs, dir, oid: second.commit })).commit;
97 assert.equal(next.author.name, "alice");
98 assert.deepEqual(next.parent, [first.commit]);
99 assert.equal(absoVersion(next.message), 1);
100 });
101});