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

Compare

+35 −0 in 1 place
new file, 35 lines
1+import type { FileModes } from "../../worker/project/project-api.ts";
2+
3+export interface PushSnapshotMetadata {
4+ version: number;
5+ paths: string[];
6+ modes: FileModes;
7+ blobs: Record<string, string>;
8+ last?: { agent: string; message: string };
9+}
11+/** Construct outside the read scope so detaching metadata never evaluates file text. */
12+export function pushSnapshot(
13+ metadata: PushSnapshotMetadata,
14+ readText: (version: number, path: string) => string,
15+ readBatch?: (version: number, paths: readonly string[]) => Record<string, string>,
16+) {
17+ const { paths, ...shared } = metadata;
18+ const files: Record<string, string> = Object.create(null);
19+ let cache: Record<string, string> = Object.create(null);
20+ for (let index = 0; index < paths.length; index++) {
21+ const path = paths[index]!;
22+ Object.defineProperty(files, path, {
23+ enumerable: true,
24+ get: () => {
25+ if (!readBatch) return readText(shared.version, path);
26+ if (!Object.hasOwn(cache, path)) cache = readBatch(shared.version, paths.slice(index, index + 64));
27+ if (!Object.hasOwn(cache, path)) throw Error("push batch omitted requested file");
28+ const text = cache[path]!;
29+ delete cache[path];
30+ return text;
31+ },
32+ });
33+ }
34+ return { ...shared, files };
35+}
MCP
compare on this site's /mcp
CLI
abso diff 103 318 server/src/push-snapshot.ts --json
JSON
/christopher/abso-core/compare/103..318?file=server%2Fsrc%2Fpush-snapshot.ts&format=json