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

Compare

+94 −20 in 5 places
Lines 1–15 at 318 (were 1–14 at 49)
1+import { View } from "../../src/engine/index.ts";
12// The version list reads: log (versions newest first, or one file's history), ribbon (who published each version),
23// show (one version's changes), fileAt, compare and viewAt. They read through LogHost; today the host is the project
34// in memory.
45
5−import { type AtomId, type Graph, View } from "../../src/engine/index.ts";
6+import type { AtomId, Graph, ReadView } from "../../src/engine/index.ts";
67import { checkReadPath } from "./path-rules.ts";
78import type { PathIndex } from "./pathindex.ts";
89import { ProjectError } from "./project-error.ts";
910import type { FileChange, LogAnswer, LogEntry, ShowAnswer } from "./project-types.ts";
1011import { last, SHARED, type Space } from "./spaces.ts";
11−import { changesBetween } from "./view-changes.ts";
12+import { changesBetween, summariesBetween } from "./view-changes.ts";
1213
1314/** What the version list reads need from a project. */
1415export interface LogHost {
Lines 20–31 at 318 (were 19–30 at 49)
1920 needInit(): void;
2021 spaceFor(options: { draft?: string | null; agent?: string }): Space;
2122 checkVersion(space: Space, version: number): void;
22− viewAt(space: Space, version: number): View;
23− view(set: ReadonlySet<AtomId>): View;
23+ viewAt(space: Space, version: number): ReadView;
24+ view(set: ReadonlySet<AtomId>): ReadView;
2425 at(space: Space, version: number): ReadonlySet<AtomId>;
25− spellingIn(view: View, path: string): string;
26+ spellingIn(view: ReadView, path: string): string;
2627 versionChange(space: Space, version: number): number | undefined;
27− touchedFiles(ids: Iterable<AtomId>, views: readonly View[]): Set<string>;
28+ touchedFiles(ids: Iterable<AtomId>, views: readonly ReadView[]): Set<string>;
2829}
2930
3031/**
Lines 60–83 at 318 (were 59–76 at 49)
5960 // A file's history (#43): only versions whose changes name the file, or a file moves can carry lines from, can have changed it.
6061 const sources = path === undefined ? undefined : new Set(names.flatMap((n) => [...moveSources(host.graph, n.path)]));
6162 const g = host.graph;
62− const views = new Map<number, View>();
63+ const views = new Map<number, ReadView>();
6364 for (; v >= 0 && versions.length < limit; v--) {
6465 if (sources && !host.paths.knowsFiles(space, v)) {
6566 const p = space.versions[v]!;
6667 if (![...p.atoms, ...(p.dropped ?? [])].some((id) => g.filesOf(id).some((f) => sources.has(f)))) continue;
6768 }
69+ // With a path: only the versions that changed that file (its history), under its name then. Their files first, and
70+ // the whole entry (every atom of the version read) only for those (abso Capacity): a file's history read every
71+ // version's atoms down to its twentieth change.
72+ if (path !== undefined && !host.paths.versionFiles(space, v, views).includes(nameAt(v))) {
73+ views.delete(v + 1);
74+ continue;
75+ }
6876 const entry = logEntry(host, space, v, views);
6977 // The walk goes down: a view above this version won't be needed again (#46).
7078 views.delete(v + 1);
71− // With a path: only the versions that changed that file (its history), under its name then.
7279 if (path === undefined) versions.push(entry);
73− else if (entry.files.includes(nameAt(v))) versions.push(nameAt(v) === path ? entry : { ...entry, path: nameAt(v) });
80+ else versions.push(nameAt(v) === path ? entry : { ...entry, path: nameAt(v) });
7481 }
7582 const next = v >= 0 && versions.length > 0 ? versions[versions.length - 1]!.version : undefined;
7683 const movedFrom = names.slice(0, -1).map((n, i) => ({ path: names[i + 1]!.path, version: n.since }));
Lines 186–192 at 318 (were 179–185 at 49)
179186 };
180187}
181188
182−function logEntry(host: LogHost, space: Space, version: number, views?: Map<number, View>): LogEntry {
189+function logEntry(host: LogHost, space: Space, version: number, views?: Map<number, ReadView>): LogEntry {
183190 const p = space.versions[version]!;
184191 let changes = 0;
185192 for (const id of p.atoms) {
Lines 244–345 at 318 (were 237–271 at 49)
237244 };
238245}
239246
240−/** Every file that differs between two versions of shared (or a named draft), before (at `from`) and after (at `to`). */
241−export function compare(
247+/**
248+ * fileAt for exactly this spelling, from the file's own lines (abso Capacity, 2026-10-17): no spelling lookup and no
249+ * list of the version's files. fileAt's hasFile answers from the version's whole path list, folded from version 0
250+ * when nothing's kept, and a spelling it doesn't find reads every known path. A name nothing ever wrote is one read.
251+ * The pipeline's project files (abso.yml and the like) are read this way on every tick.
252+ */
253+export function fileExactAt(
242254 host: LogHost,
255+ path: string,
256+ version: number,
257+ options: { draft?: string | null; agent?: string } = {},
258+): { path: string; version: number; text: string | null; blob?: string } {
259+ host.needInit();
260+ checkReadPath(path);
261+ const space = host.spaceFor(options);
262+ host.checkVersion(space, version);
263+ if (!host.graph.hasAtomsIn(path)) return { path, version, text: null };
264+ const view = host.viewAt(space, version);
265+ const attrs = view.attrs(path);
266+ // hasFile's own test, without its path list: kept while empty, a link, a binary, or a visible line.
267+ const exists = attrs.exists || attrs.link !== null || attrs.blob !== null || view.lines(path).length > 0;
268+ return {
269+ path,
270+ version,
271+ text: exists ? view.text(path) : null,
272+ ...(attrs.blob !== null ? { blob: attrs.blob } : {}),
273+ };
274+}
276+/** The files that may differ between two versions, and both views: compare's and compareSummary's ground. */
277+function compared(
278+ host: LogHost,
243279 from: number,
244280 to: number,
245− options: { draft?: string | null; agent?: string } = {},
246−): { from: number; to: number; files: FileChange[] } {
281+ options: { draft?: string | null; agent?: string },
282+): { before: ReadView; after: ReadView; files: Set<string> } {
247283 host.needInit();
248284 const space = host.spaceFor(options);
249285 host.checkVersion(space, from);
250286 host.checkVersion(space, to);
287+ const before = host.viewAt(space, from);
288+ const after = host.viewAt(space, to);
289+ const files = new Set<string>();
290+ // A stored writer keeps each shared version's changed files (version-files.ts, abso Capacity): every file that
291+ // differs between two versions changed in one between them, so those lists are the candidates, not every atom
292+ // either set holds.
293+ if (space.name === SHARED && host.graph.packedFiles) {
294+ for (let v = Math.min(from, to) + 1; v <= Math.max(from, to); v++)
295+ for (const file of host.paths.versionFiles(space, v)) files.add(file);
296+ return { before, after, files };
297+ }
251298 const a = host.at(space, from);
252299 const b = host.at(space, to);
253− const files = new Set<string>();
254300 for (const [x, y] of [
255301 [a, b],
256302 [b, a],
257303 ] as const) {
258304 for (const file of host.touchedFiles(
259− [...x].filter((id) => !y.has(id)),
260− [host.view(a), host.view(b)],
305+ (function* () {
306+ for (const id of x) if (!y.has(id)) yield id;
307+ })(),
308+ [before, after],
261309 ))
262310 files.add(file);
263311 }
264− return { from, to, files: changesBetween(host.view(a), host.view(b), files) };
312+ return { before, after, files };
265313}
266314
267−/** A version of shared (or of a named draft) as a View, for reading lines (blame at a version). */
268−export function viewAt(host: LogHost, version: number, options: { draft?: string | null; agent?: string } = {}): View {
315+/** Every file that differs between two versions of shared (or a named draft), before (at `from`) and after (at `to`). */
316+export function compare(
317+ host: LogHost,
318+ from: number,
319+ to: number,
320+ options: { draft?: string | null; agent?: string } = {},
321+): { from: number; to: number; files: FileChange[] } {
322+ const { before, after, files } = compared(host, from, to, options);
323+ return { from, to, files: changesBetween(before, after, files) };
324+}
326+/** compare's files as each one's size and SHA-256 before and after, not its texts (abso issue 680). */
327+export function compareSummary(
328+ host: LogHost,
329+ from: number,
330+ to: number,
331+ options: { draft?: string | null; agent?: string } = {},
332+): { from: number; to: number; summary: true; files: ReturnType<typeof summariesBetween> } {
333+ const { before, after, files } = compared(host, from, to, options);
334+ return { from, to, summary: true, files: summariesBetween(before, after, files) };
335+}
337+/** A version of shared (or of a named draft) as a ReadView, for reading lines (blame at a version). */
338+export function viewAt(
339+ host: LogHost,
340+ version: number,
341+ options: { draft?: string | null; agent?: string } = {},
342+): ReadView {
269343 host.needInit();
270344 const space = host.spaceFor(options);
271345 host.checkVersion(space, version);
MCP
compare on this site's /mcp
CLI
abso diff 49 318 worker/project/version-log.ts --json
JSON
/christopher/abso-core/compare/49..318?file=worker%2Fproject%2Fversion-log.ts&format=json