- MCP
- code on this site's /mcp
- CLI
- none: the JSON below is the answer
- JSON
- /christopher/abso-core/files/server/scripts/capacity-patch-git-fetch.mjs?version=271&format=json
91 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 178, 1 version changed it
You're reading version 271. The newest is 318, and no version since then changed this file.
1import { createHash } from "node:crypto";
2import { readFileSync, writeFileSync } from "node:fs";
3import { join } from "node:path";
5// Extends only the reviewed-version push prototype in this isolated dependency tree.
6const root = "capacity-git-dependency-sandbox/node_modules/isomorphic-git";
7const inputs = {
8 "index.js": "0bd051b1a38bf8d593bf37b5acf9ee453ddab33d48950c84e2c2c3f3ec449fc8",
9 "index.cjs": "6c9f6eab37a10c9311f2b7aa8d24b0772d4ba2703d848525a0519e1454d016e7",
10};
11const hash = (source) => createHash("sha256").update(source).digest("hex");
12const expectedOutputs = {
13 "index.js": "eebe6911fa660d4b95857768ea2308be74435dd5f9a796bb7b2491a31bdd109d",
14 "index.cjs": "33364e3ed7f3a1a6cf17a1ecabbfc5d6de6a8494f31a524d8ac293402ad4e447",
15};
16function once(source, before, after) {
17 if (source.split(before).length !== 2) throw Error("Fetch patch anchor mismatch");
18 return source.replace(before, after);
19}
20if (JSON.parse(readFileSync(join(root, "package.json"), "utf8")).version !== "1.44.2") {
21 throw Error("Unsupported Git version");
22}
23const outputs = [];
24const installed = Object.fromEntries(Object.keys(inputs).map((file) => [file, readFileSync(join(root, file), "utf8")]));
25if (Object.entries(expectedOutputs).every(([file, expected]) => hash(installed[file]) === expected)) {
26 console.log(
27 JSON.stringify({
28 verified: true,
29 scope: "Isolated fetch prototype",
30 bundles: expectedOutputs,
31 }),
32 );
33 process.exit(0);
34}
35for (const [file, expected] of Object.entries(inputs)) {
36 const source = installed[file];
37 if (hash(source) !== expected) throw Error(`Unrecognized input: ${file}`);
38 let result = once(
39 source,
40 " const packfile = Buffer.from(await collect(response.packfile));",
41 ` const diskPack = cache && cache[Symbol.for('abso.git.disk-pack')];
42 if (diskPack) {
43 await diskPack.ingest(response.packfile, () => new pako.Inflate({ chunkSize: 16384 }));
44 if (raw.body.error) throw raw.body.error
45 const result = {
46 defaultBranch: response.HEAD,
47 fetchHead: response.FETCH_HEAD.oid,
48 fetchHeadDescription: response.FETCH_HEAD.description,
49 };
50 if (response.headers) result.headers = response.headers;
51 if (prune) result.pruned = response.pruned;
52 return result
53 }
54 const packfile = Buffer.from(await collect(response.packfile));`,
55 );
56 const readStart = result.indexOf("async function _readObject({");
57 const readEnd = result.indexOf("\nclass AlreadyExistsError", readStart);
58 if (readStart < 0 || readEnd < 0) throw Error("Missing object reader boundary");
59 const readFunction = once(
60 result.slice(readStart, readEnd),
61 " // Curry the current read method so that the packfile un-deltification",
62 ` const diskPack = cache && cache[Symbol.for('abso.git.disk-pack')];
63 if (diskPack && format === 'content') {
64 const stored = await diskPack.read(oid);
65 if (stored) return stored
66 }
68 // Curry the current read method so that the packfile un-deltification`,
69 );
70 result = result.slice(0, readStart) + readFunction + result.slice(readEnd);
71 if (hash(result) !== expectedOutputs[file]) throw Error(`Unexpected fetch patch output: ${file}`);
72 outputs.push({ file, result, sha256: hash(result) });
73}
74// Validate both installed bundles and every anchor before either write.
75if (!process.argv.includes("--check")) {
76 for (const { file, result } of outputs) writeFileSync(join(root, file), result);
77 writeFileSync(
78 "capacity-git-fetch-patch-manifest.json",
79 JSON.stringify(
80 outputs.map(({ file, sha256 }) => ({ file, sha256 })),
81 null,
82 2,
83 ),
84 );
85}
86console.log(
87 JSON.stringify({
88 scope: "Isolated fetch prototype; runtime adapter and transport acceptance still required",
89 outputs: outputs.map(({ file, sha256 }) => ({ file, sha256 })),
90 }),
91);