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 177 to 178

Compare

+106 −14 in 10 places
Lines 2–18 at 178 (were 2–13 at 177)
22// project's Artifacts repo, read back for project.ingest. Every commit the
33// Worker pushes ends "abso-version: N" ("avcs-version: N" before the rename); the commits above the newest such
44// commit that haven't been taken in yet are the person's, and N is their base.
5−import git from "isomorphic-git";
6−import http from "isomorphic-git/http/web";
5+import git, { type HttpClient } from "isomorphic-git";
76import type { FileModes } from "../../worker/project/project-api.ts";
7+import type { SqliteStorage } from "./engine-project.ts";
8+import { gitBlobText, InvalidGitUtf8 } from "./git-blob-text.ts";
9+import { GitDiskIntake } from "./git-disk-intake.ts";
10+import { gitHttp } from "./git-http.ts";
811import { MemoryFS } from "./memory-fs.ts";
912import { repoName } from "./push.ts";
1013
14+const http = gitHttp();
1116const EXEC = 0o100755;
1217const LINK = 0o120000;
1318
Lines 45–54 at 178 (were 40–46 at 177)
4045async function readAccess(
4146 artifacts: Artifacts,
4247 project: string,
43−): Promise<{ url: string; onAuth: () => { username: string; password: string } } | null> {
48+): Promise<{
49+ url: string;
50+ onAuth: () => { username: string; password: string };
51+} | null> {
4452 let repo: Awaited<ReturnType<Artifacts["get"]>>;
4553 try {
4654 repo = await artifacts.get(repoName(project));
Lines 65–76 at 178 (were 57–63 at 177)
5765export async function remoteHead(artifacts: Artifacts, project: string): Promise<string | null> {
5866 const access = await readAccess(artifacts, project);
5967 if (!access) return null;
60− const refs = await git.listServerRefs({ http, url: access.url, onAuth: access.onAuth, prefix: "refs/heads/main" });
68+ const refs = await git.listServerRefs({
69+ http,
70+ url: access.url,
71+ onAuth: access.onAuth,
72+ prefix: "refs/heads/main",
73+ });
6174 return refs.find((r) => r.ref === "refs/heads/main")?.oid ?? null;
6275}
6376
Lines 80–91 at 178 (were 67–72 at 177)
6780 */
6881/** Stores a binary file's bytes and answers their SHA-256, or null when they're over the limit. */
6982export type StoreBlob = (bytes: Uint8Array) => Promise<string | null>;
83+export type RetainFileChunks = (
84+ files: Record<string, string>,
85+ path: string,
86+ chunks: Iterable<string>,
87+ oid: string,
88+) => void;
7089
7190/**
7291 * `oldBlob` gives shared's blob for a path: a binary file over the limit
Lines 97–131 at 178 (were 78–91 at 177)
7897 seen: string | undefined,
7998 storeBlob?: StoreBlob,
8099 oldBlob: (path: string) => string | undefined = () => undefined,
100+ retainFile: (files: Record<string, string>, path: string, body: string, oid?: string) => void = (
101+ files,
102+ path,
103+ body,
104+ ) => {
105+ files[path] = body;
106+ },
107+ disk?: {
108+ storage: SqliteStorage;
109+ maxPackBytes: number;
110+ maxObjectBytes: number;
111+ maxDecodedBytes?: number;
112+ http?: HttpClient;
113+ retainFileChunks?: RetainFileChunks;
114+ },
81115): Promise<PushedCommits | null> {
82116 const access = await readAccess(artifacts, project);
83117 if (!access) return null;
84118 const fs = new MemoryFS();
85119 const dir = "/repo";
120+ using intake = disk
121+ ? new GitDiskIntake(disk.storage, disk.maxPackBytes, disk.maxObjectBytes, disk.maxDecodedBytes)
122+ : undefined;
123+ const cache = disk ? {} : undefined;
124+ if (intake && cache) intake.attach(cache);
86125 await git.clone({
87126 fs,
88− http,
127+ cache,
128+ http: disk?.http ?? http,
89129 dir,
90130 url: access.url,
91131 onAuth: access.onAuth,
Lines 134–141 at 178 (were 94–100 at 177)
94134 depth: DEPTH,
95135 noCheckout: true,
96136 });
97− const log = await git.log({ fs, dir, ref: "main", depth: DEPTH });
137+ intake?.assertReady();
138+ const log = await git.log({ fs, dir, cache, ref: "main", depth: DEPTH });
98139 if (log.length === 0) return null;
99140 const head = log[0]!.oid;
100141 const fresh: typeof log = [];
Lines 154–179 at 178 (were 113–121 at 177)
113154 commits.push({
114155 sha: c.oid,
115156 message: c.commit.message.trim(),
116− ...(await treeText(fs, dir, c.oid, storeBlob, tooBig, oldBlob)),
157+ ...(await treeText(
158+ fs,
159+ dir,
160+ c.oid,
161+ storeBlob,
162+ tooBig,
163+ oldBlob,
164+ retainFile,
165+ cache,
166+ intake,
167+ disk?.retainFileChunks,
168+ )),
117169 });
118− return { head, author: fresh.at(-1)?.commit.author.name ?? "git", base, commits, tooBig: [...tooBig] };
170+ return {
171+ head,
172+ author: fresh.at(-1)?.commit.author.name ?? "git",
173+ base,
174+ commits,
175+ tooBig: [...tooBig],
176+ };
119177}
120178
121179/**
Lines 181–239 at 178 (were 123–146 at 177)
123181 * a link (120000) is "" with its target in modes. Files that aren't UTF-8
124182 * are left out.
125183 */
126−async function treeText(
184+export async function treeText(
127185 fs: MemoryFS,
128186 dir: string,
129187 oid: string,
130188 storeBlob: StoreBlob | undefined,
131189 tooBig: Set<string>,
132190 oldBlob: (path: string) => string | undefined,
133−): Promise<{ files: Record<string, string>; modes: FileModes; blobs: Record<string, string> }> {
191+ retainFile: (files: Record<string, string>, path: string, body: string, oid?: string) => void,
192+ cache: object = {},
193+ intake?: GitDiskIntake,
194+ retainFileChunks?: RetainFileChunks,
195+): Promise<{
196+ files: Record<string, string>;
197+ modes: FileModes;
198+ blobs: Record<string, string>;
199+}> {
134200 const files: Record<string, string> = {};
135201 const modes: FileModes = {};
136202 const blobs: Record<string, string> = {};
137203 await git.walk({
138204 fs,
205+ cache,
139206 dir,
140207 trees: [git.TREE({ ref: oid })],
208+ iterate: async (walk, children) => {
209+ for (const child of children) await walk(child);
210+ return [];
211+ },
212+ reduce: async () => undefined,
141213 map: async (path, [entry]) => {
142214 if (!entry || path === ".") return true;
143215 if ((await entry.type()) !== "blob") return true;
216+ const mode = await entry.mode();
217+ const blobOid = await entry.oid();
218+ if (intake && retainFileChunks && mode !== LINK) {
219+ const stored = intake.bytes(blobOid);
220+ if (stored?.type !== "blob") throw Error("Git intake blob is missing");
221+ let valid = true;
222+ try {
223+ // Validate before retaining: a late invalid byte must take the binary path.
224+ for (const _ of gitBlobText(stored)) {
225+ /* Retain no decoded text. */
226+ }
227+ } catch (error) {
228+ if (!(error instanceof InvalidGitUtf8)) throw error;
229+ valid = false;
230+ }
231+ if (valid) {
232+ retainFileChunks(files, path, gitBlobText(stored), blobOid);
233+ modes[path] = { exec: mode === EXEC, link: null };
234+ return true;
235+ }
236+ }
144237 const bytes = await entry.content();
145238 if (!bytes) return true;
146239 let body: string;
Lines 244–250 at 178 (were 151–157 at 177)
151244 const sha = storeBlob ? await storeBlob(bytes) : null;
152245 if (sha) {
153246 blobs[path] = sha;
154− modes[path] = { exec: (await entry.mode()) === EXEC, link: null };
247+ modes[path] = { exec: mode === EXEC, link: null };
155248 } else if (storeBlob) {
156249 tooBig.add(path);
157250 const kept = oldBlob(path);
Lines 252–262 at 178 (were 159–170 at 177)
159252 }
160253 return true;
161254 }
162− const mode = await entry.mode();
163255 if (mode === LINK) {
164− files[path] = "";
256+ retainFile(files, path, "");
165257 modes[path] = { exec: false, link: body };
166258 } else {
167− files[path] = body;
259+ retainFile(files, path, body, blobOid);
168260 modes[path] = { exec: mode === EXEC, link: null };
169261 }
170262 return true;
MCP
compare on this site's /mcp
CLI
abso diff 177 178 server/src/ingest.ts --json
JSON
/christopher/abso-core/compare/177..178?file=server%2Fsrc%2Fingest.ts&format=json