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

+115 −14 in 10 places
Lines 2–18 at 318 (were 2–13 at 175)
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 318 (were 40–46 at 175)
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 318 (were 57–63 at 175)
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 318 (were 67–72 at 175)
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–132 at 318 (were 78–91 at 175)
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+ maxBinaryBytes?: number;
113+ http?: HttpClient;
114+ retainFileChunks?: RetainFileChunks;
115+ },
81116): Promise<PushedCommits | null> {
82117 const access = await readAccess(artifacts, project);
83118 if (!access) return null;
84119 const fs = new MemoryFS();
85120 const dir = "/repo";
121+ using intake = disk
122+ ? new GitDiskIntake(disk.storage, disk.maxPackBytes, disk.maxObjectBytes, disk.maxDecodedBytes)
123+ : undefined;
124+ const cache = disk ? {} : undefined;
125+ if (intake && cache) intake.attach(cache);
86126 await git.clone({
87127 fs,
88− http,
128+ cache,
129+ http: disk?.http ?? http,
89130 dir,
90131 url: access.url,
91132 onAuth: access.onAuth,
Lines 135–142 at 318 (were 94–100 at 175)
94135 depth: DEPTH,
95136 noCheckout: true,
96137 });
97− const log = await git.log({ fs, dir, ref: "main", depth: DEPTH });
138+ intake?.assertReady();
139+ const log = await git.log({ fs, dir, cache, ref: "main", depth: DEPTH });
98140 if (log.length === 0) return null;
99141 const head = log[0]!.oid;
100142 const fresh: typeof log = [];
Lines 155–181 at 318 (were 113–121 at 175)
113155 commits.push({
114156 sha: c.oid,
115157 message: c.commit.message.trim(),
116− ...(await treeText(fs, dir, c.oid, storeBlob, tooBig, oldBlob)),
158+ ...(await treeText(
159+ fs,
160+ dir,
161+ c.oid,
162+ storeBlob,
163+ tooBig,
164+ oldBlob,
165+ retainFile,
166+ cache,
167+ intake,
168+ disk?.retainFileChunks,
169+ disk?.maxBinaryBytes,
170+ )),
117171 });
118− return { head, author: fresh.at(-1)?.commit.author.name ?? "git", base, commits, tooBig: [...tooBig] };
172+ return {
173+ head,
174+ author: fresh.at(-1)?.commit.author.name ?? "git",
175+ base,
176+ commits,
177+ tooBig: [...tooBig],
178+ };
119179}
120180
121181/**
Lines 183–248 at 318 (were 123–146 at 175)
123183 * a link (120000) is "" with its target in modes. Files that aren't UTF-8
124184 * are left out.
125185 */
126−async function treeText(
186+export async function treeText(
127187 fs: MemoryFS,
128188 dir: string,
129189 oid: string,
130190 storeBlob: StoreBlob | undefined,
131191 tooBig: Set<string>,
132192 oldBlob: (path: string) => string | undefined,
133−): Promise<{ files: Record<string, string>; modes: FileModes; blobs: Record<string, string> }> {
193+ retainFile: (files: Record<string, string>, path: string, body: string, oid?: string) => void,
194+ cache: object = {},
195+ intake?: GitDiskIntake,
196+ retainFileChunks?: RetainFileChunks,
197+ maxBinaryBytes?: number,
198+): Promise<{
199+ files: Record<string, string>;
200+ modes: FileModes;
201+ blobs: Record<string, string>;
202+}> {
134203 const files: Record<string, string> = {};
135204 const modes: FileModes = {};
136205 const blobs: Record<string, string> = {};
137206 await git.walk({
138207 fs,
208+ cache,
139209 dir,
140210 trees: [git.TREE({ ref: oid })],
211+ iterate: async (walk, children) => {
212+ for (const child of children) await walk(child);
213+ return [];
214+ },
215+ reduce: async () => undefined,
141216 map: async (path, [entry]) => {
142217 if (!entry || path === ".") return true;
143218 if ((await entry.type()) !== "blob") return true;
219+ const mode = await entry.mode();
220+ const blobOid = await entry.oid();
221+ if (intake && retainFileChunks && mode !== LINK) {
222+ const stored = intake.bytes(blobOid);
223+ if (stored?.type !== "blob") throw Error("Git intake blob is missing");
224+ let valid = true;
225+ try {
226+ // Validate before retaining: a late invalid byte must take the binary path.
227+ for (const _ of gitBlobText(stored)) {
228+ /* Retain no decoded text. */
229+ }
230+ } catch (error) {
231+ if (!(error instanceof InvalidGitUtf8)) throw error;
232+ valid = false;
233+ }
234+ if (valid) {
235+ retainFileChunks(files, path, gitBlobText(stored), blobOid);
236+ modes[path] = { exec: mode === EXEC, link: null };
237+ return true;
238+ }
239+ if (storeBlob && maxBinaryBytes !== undefined && stored.byteLength > maxBinaryBytes) {
240+ tooBig.add(path);
241+ const kept = oldBlob(path);
242+ if (kept) blobs[path] = kept;
243+ return true;
244+ }
245+ }
144246 const bytes = await entry.content();
145247 if (!bytes) return true;
146248 let body: string;
Lines 253–259 at 318 (were 151–157 at 175)
151253 const sha = storeBlob ? await storeBlob(bytes) : null;
152254 if (sha) {
153255 blobs[path] = sha;
154− modes[path] = { exec: (await entry.mode()) === EXEC, link: null };
256+ modes[path] = { exec: mode === EXEC, link: null };
155257 } else if (storeBlob) {
156258 tooBig.add(path);
157259 const kept = oldBlob(path);
Lines 261–271 at 318 (were 159–170 at 175)
159261 }
160262 return true;
161263 }
162− const mode = await entry.mode();
163264 if (mode === LINK) {
164− files[path] = "";
265+ retainFile(files, path, "");
165266 modes[path] = { exec: false, link: body };
166267 } else {
167− files[path] = body;
268+ retainFile(files, path, body, blobOid);
168269 modes[path] = { exec: mode === EXEC, link: null };
169270 }
170271 return true;
MCP
compare on this site's /mcp
CLI
abso diff 175 318 server/src/ingest.ts --json
JSON
/christopher/abso-core/compare/175..318?file=server%2Fsrc%2Fingest.ts&format=json