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 175 to 318

Compare

+94 −0 in 1 place
new file, 94 lines
1+import { createHash } from "node:crypto";
2+import { readFileSync, writeFileSync } from "node:fs";
3+import { join } from "node:path";
4+
5+const root = "capacity-git-dependency-sandbox/node_modules/isomorphic-git";
6+const hashes = {
7+ "index.js": "66c20b7d890a6d48819f0be5f7bb1c5aab69937e6318ec912295c501028a5084",
8+ "index.cjs": "b2142bba9e651fce83d6c1d266d32fc5eefa748544c452f9f22fada4e33dc367",
9+};
10+const patched = {
11+ "index.js": "0bd051b1a38bf8d593bf37b5acf9ee453ddab33d48950c84e2c2c3f3ec449fc8",
12+ "index.cjs": "6c9f6eab37a10c9311f2b7aa8d24b0772d4ba2703d848525a0519e1454d016e7",
13+};
14+if (JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version !== "1.44.2")
15+ throw Error("Unsupported Git version");
16+const installed = Object.fromEntries(
17+ Object.keys(hashes).map((file) => [
18+ file,
19+ createHash("sha256")
20+ .update(readFileSync(join(root, file)))
21+ .digest("hex"),
22+ ]),
23+);
24+if (Object.keys(patched).every((file) => installed[file] === patched[file])) {
25+ console.log(JSON.stringify({ verified: true, version: "1.44.2", bundles: installed }));
26+ process.exit(0);
27+}
28+if (process.argv.includes("--check")) throw Error("Git runtime patch is absent or modified");
29+function replaceOnce(source, before, after) {
30+ if (source.split(before).length !== 2) throw Error("Patch anchor mismatch");
31+ return source.replace(before, after);
32+}
33+const outputs = [];
34+for (const [file, expected] of Object.entries(hashes)) {
35+ const original = readFileSync(join(root, file), "utf8");
36+ if (createHash("sha256").update(original).digest("hex") !== expected) throw Error(`Unrecognized source: ${file}`);
37+ const start = original.indexOf("async function _pack({");
38+ const end = original.indexOf("\n// @ts-check", start);
39+ if (start < 0 || end < 0) throw Error("Missing pack implementation");
40+ const old = original.slice(start, end);
41+ let streamed = replaceOnce(old, "async function _pack({", "async function* _packStream({");
42+ streamed = replaceOnce(
43+ streamed,
44+ " for (const oid of oids) {",
45+ " yield* outputStream;\n outputStream.length = 0;\n for (const oid of oids) {",
46+ );
47+ streamed = replaceOnce(
48+ streamed,
49+ " await writeObject({ write, object, stype: type });",
50+ " await writeObject({ write, object, stype: type });\n yield* outputStream;\n outputStream.length = 0;",
51+ );
52+ streamed = replaceOnce(streamed, " outputStream.push(digest);\n return outputStream", " yield digest;");
53+ let result =
54+ original.slice(0, start) +
55+ streamed +
56+ "\nasync function _pack(options) {\n const output = [];\n for await (const chunk of _packStream(options)) output.push(chunk);\n return output;\n}\n" +
57+ original.slice(end);
58+ const begin = result.indexOf(" const packstream2 = _delete");
59+ const finish = result.indexOf(" const res = await GitRemoteHTTP.connect({", begin);
60+ if (begin < 0 || finish < 0) throw Error("Missing push implementation");
61+ result =
62+ result.slice(0, begin) +
63+ ` const packoids = [...objects];
64+ // Recreate the stream for every authentication retry; never retain a whole pack.
65+ const packbody = {
66+ async *[Symbol.asyncIterator]() {
67+ yield* packstream1;
68+ if (!_delete) yield* _packStream({ fs, cache, gitdir, oids: packoids });
69+ }
70+ };
71+` +
72+ result.slice(finish);
73+ result = replaceOnce(result, " body: [...packstream1, ...packstream2],", " body: packbody,");
74+ const sha256 = createHash("sha256").update(result).digest("hex");
75+ if (sha256 !== patched[file]) throw Error(`Unexpected patch output: ${file}`);
76+ outputs.push({ file, result, sha256 });
77+}
78+// Validate every input before changing either runtime bundle.
79+for (const output of outputs) writeFileSync(join(root, output.file), output.result);
80+writeFileSync(
81+ "capacity-git-push-patch-manifest.json",
82+ JSON.stringify(
83+ outputs.map(({ file, sha256 }) => ({ file, sha256 })),
84+ null,
85+ 2,
86+ ),
87+);
88+console.log(
89+ JSON.stringify({
90+ version: "1.44.2",
91+ patched: outputs.map(({ file, sha256 }) => ({ file, sha256 })),
92+ scope: "Isolated push patch; fetch and install integration incomplete",
93+ }),
94+);
MCP
compare on this site's /mcp
CLI
abso diff 175 318 server/scripts/capacity-patch-git-push.mjs --json
JSON
/christopher/abso-core/compare/175..318?file=server%2Fscripts%2Fcapacity-patch-git-push.mjs&format=json