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

Compare

+61 −0 in 1 place
new file, 61 lines
1+import { execFileSync } from "node:child_process";
2+import { createHash } from "node:crypto";
3+import { copyFileSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
4+import { tmpdir } from "node:os";
5+import { basename, dirname, join, resolve } from "node:path";
6+import { fileURLToPath } from "node:url";
7+
8+const scripts = dirname(fileURLToPath(import.meta.url));
9+const rootIndex = process.argv.indexOf("--root");
10+if (rootIndex < 0 || !process.argv[rootIndex + 1])
11+ throw Error("Pass --root with the exact isomorphic-git package directory");
12+const root = resolve(process.argv[rootIndex + 1]);
13+const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");
14+const original = {
15+ "index.js": "66c20b7d890a6d48819f0be5f7bb1c5aab69937e6318ec912295c501028a5084",
16+ "index.cjs": "b2142bba9e651fce83d6c1d266d32fc5eefa748544c452f9f22fada4e33dc367",
17+};
18+const expected = {
19+ "index.js": "50ada141b506bff7cced797098f5ea70a6e40cda859884cc25b0dea985b10592",
20+ "index.cjs": "3b8a78b7145330038cf56e057f7726004a78d0af9a55845b685cf1f65443bae0",
21+};
22+if (JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version !== "1.44.2")
23+ throw Error("Unsupported Git version");
24+const installed = Object.fromEntries(Object.keys(original).map((file) => [file, readFileSync(join(root, file))]));
25+if (Object.entries(expected).every(([file, digest]) => hash(installed[file]) === digest)) {
26+ console.log("Verified the complete Git capacity runtime patch.");
27+ process.exit(0);
28+}
29+if (process.argv.includes("--check")) throw Error("Complete Git capacity runtime patch is absent or modified");
30+for (const [file, digest] of Object.entries(original)) {
31+ if (hash(installed[file]) !== digest) throw Error(`Unrecognized or partially patched Git bundle: ${file}`);
32+}
33+const temporary = mkdtempSync(join(tmpdir(), "abso-git-patch-"));
34+if (dirname(resolve(temporary)) !== resolve(tmpdir()) || !basename(temporary).startsWith("abso-git-patch-"))
35+ throw Error("Unexpected temporary cleanup path");
36+try {
37+ const staged = join(temporary, "capacity-git-dependency-sandbox/node_modules/isomorphic-git");
38+ mkdirSync(staged, { recursive: true });
39+ copyFileSync(join(root, "package.json"), join(staged, "package.json"));
40+ for (const [file, bytes] of Object.entries(installed)) writeFileSync(join(staged, file), bytes);
41+ copyFileSync(join(scripts, "capacity-git-bounded-fifo.mjs"), join(temporary, "capacity-git-bounded-fifo.mjs"));
42+ for (const stage of ["push", "fetch", "sideband", "progress", "pump"]) {
43+ execFileSync(process.execPath, [join(scripts, `capacity-patch-git-${stage}.mjs`)], {
44+ cwd: temporary,
45+ stdio: "pipe",
46+ });
47+ }
48+ const outputs = Object.fromEntries(Object.keys(expected).map((file) => [file, readFileSync(join(staged, file))]));
49+ for (const [file, digest] of Object.entries(expected)) {
50+ if (hash(outputs[file]) !== digest) throw Error(`Unexpected complete Git patch: ${file}`);
51+ }
52+ // All stages and both final hashes pass before touching the installed package.
53+ for (const [file, bytes] of Object.entries(outputs)) writeFileSync(join(root, file), bytes);
54+ console.log("Installed and verified the complete Git capacity runtime patch.");
55+} finally {
56+ try {
57+ rmSync(temporary, { recursive: true, force: true });
58+ } catch {
59+ console.warn("Could not remove the Git patch staging directory.");
60+ }
61+}
MCP
compare on this site's /mcp
CLI
abso diff 164 318 server/scripts/capacity-install-git-runtime.mjs --json
JSON
/christopher/abso-core/compare/164..318?file=server%2Fscripts%2Fcapacity-install-git-runtime.mjs&format=json