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=170&format=json
95 linesspeed 72% · codex-capacity-chair 28%Last change codex-capacity-chair in version 166, 2 versions changed it

You're reading version 170. The newest is 318, and 2 versions 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 { commitShared, projectOfRepo, readTreeFiles, repoName } from "../src/push.ts";
7
8describe("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});
24describe("commitShared", () => {
25 it("reads one lazy file at a time and does not read symlink placeholder text", async (t) => {
26 const fs = new MemoryFS();
27 const dir = "/repo";
28 await git.init({ fs, dir, defaultBranch: "main" });
29 let writes = 0;
30 const writeBlob = git.writeBlob;
31 t.mock.method(git, "writeBlob", async (options: Parameters<typeof writeBlob>[0]) => {
32 const result = await writeBlob(options);
33 writes++;
34 return result;
35 });
36 const files = {
37 get a() {
38 assert.equal(writes, 0);
39 return "first";
40 },
41 get b() {
42 assert.equal(writes, 1);
43 return "second";
44 },
45 get link(): string {
46 throw Error("symlink placeholder text must not be read");
47 },
48 };
49 await commitShared(fs, dir, null, { version: 0, files, modes: { link: { link: "a" } } }, () => null);
50 assert.equal(writes, 3);
51 });
52 it("writes shared as a commit with its modes, then only what changed", async () => {
53 const fs = new MemoryFS();
54 const dir = "/repo";
55 await git.init({ fs, dir, defaultBranch: "main" });
56 const noBlobs = () => null;
57 const first = await commitShared(
58 fs,
59 dir,
60 null,
61 {
62 version: 0,
63 files: { "a.txt": "one\n", "run.sh": "echo hi\n", link: "" },
64 modes: { "run.sh": { exec: true }, link: { link: "a.txt" } },
65 },
66 noBlobs,
67 );
68 assert.equal(first.changed, 3);
69 const commit = (await git.readCommit({ fs, dir, oid: first.commit })).commit;
70 assert.match(commit.message, /^Start the project\n\nabso-version: 0\n$/);
71 const { files } = await readTreeFiles(fs, dir, commit.tree);
72 assert.deepEqual(Object.fromEntries([...files].map(([p, f]) => [p, f.mode])), {
73 "a.txt": "100644",
74 link: "120000",
75 "run.sh": "100755",
76 });
77 const second = await commitShared(
78 fs,
79 dir,
80 first.commit,
81 {
82 version: 1,
83 files: { "a.txt": "one\ntwo\n", "run.sh": "echo hi\n", link: "" },
84 modes: { "run.sh": { exec: true }, link: { link: "a.txt" } },
85 last: { agent: "alice", message: "Add two" },
86 },
87 noBlobs,
88 );
89 assert.equal(second.changed, 1);
90 const next = (await git.readCommit({ fs, dir, oid: second.commit })).commit;
91 assert.equal(next.author.name, "alice");
92 assert.deepEqual(next.parent, [first.commit]);
93 assert.equal(absoVersion(next.message), 1);
94 });
95});