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

Compare

+44 −0 in 2 places
Lines 1–4 at 318 (were 1–3 at 232)
1+import { createHash } from "node:crypto";
12import type { ReadView } from "../../src/engine/index.ts";
23import { ProjectError } from "./project-error.ts";
34import type { FileChange, Mode, Modes } from "./project-types.ts";
Lines 19–67 at 318 (were 18–23 at 232)
1819 return out;
1920}
2021
22+/** A changed file's text or blob, summed up: its size in UTF-8 bytes and its SHA-256, or a blob's hash. */
23+export type FileSummary = { size: number; sha256: string } | { blob: string };
25+/**
26+ * changesBetween without the texts (abso issue 680, compare's summary): each changed file before and after as its size
27+ * and SHA-256, or its blob's hash for a binary file. Each text is read, summed up and let go, so a compare of thousands
28+ * of files never holds them all.
29+ */
30+export function summariesBetween(
31+ before: ReadView,
32+ after: ReadView,
33+ files: Iterable<string>,
34+): {
35+ path: string;
36+ before: FileSummary | null;
37+ after: FileSummary | null;
38+ mode?: { before: Mode; after: Mode };
39+ blob?: { before: string | null; after: string | null };
40+}[] {
41+ const sum = (view: ReadView, path: string): FileSummary | null => {
42+ if (!view.hasFile(path)) return null;
43+ const blob = view.attrs(path).blob;
44+ if (blob !== null) return { blob };
45+ const text = view.text(path);
46+ return { size: Buffer.byteLength(text, "utf8"), sha256: createHash("sha256").update(text, "utf8").digest("hex") };
47+ };
48+ const out: ReturnType<typeof summariesBetween> = [];
49+ for (const path of [...new Set(files)].toSorted()) {
50+ if (!differs(before, after, path)) continue;
51+ const mode = modeChange(before, after, path);
52+ const bb = before.attrs(path).blob;
53+ const ab = after.attrs(path).blob;
54+ out.push({
55+ path,
56+ before: sum(before, path),
57+ after: sum(after, path),
58+ ...(mode ? { mode } : {}),
59+ ...(bb !== ab ? { blob: { before: bb, after: ab } } : {}),
60+ });
61+ }
62+ return out;
63+}
2165/** Whether a file differs between two views: its text, its mode, or its blob (what changesBetween lists). */
2266export function differs(before: ReadView, after: ReadView, path: string): boolean {
2367 const had = before.hasFile(path);
MCP
compare on this site's /mcp
CLI
abso diff 232 318 worker/project/view-changes.ts --json
JSON
/christopher/abso-core/compare/232..318?file=worker%2Fproject%2Fview-changes.ts&format=json