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

Compare

+48 −10 in 6 places
Lines 3–20 at 318 (were 3–13 at 2)
33// two ways: in the agent's own view (what its folder shows), and in shared's
44// numbering (the shared lines it changes, or the shared line its new lines
55// follow), so agents can compare where they are against one common text.
6−import type { AtomId, LineId } from "../../src/engine/index.ts";
6+import { type AtomId, type LineId, type ReadView, seqOf } from "../../src/engine/index.ts";
77import type { Project } from "./project.ts";
88
99type Range = [number, number];
1010
11+/** A view's reads by line number (View has them; another ReadView may not). */
12+type ByNumber = ReadView & {
13+ fileOfNumber?(n: number): string;
14+ lineNumberOf?(path: string, n: number): number;
15+ visibleWriters?(path: string): readonly number[];
16+};
1118function ranges(ns: number[]): Range[] {
1219 const out: Range[] = [];
1320 for (const n of [...new Set(ns)].sort((a, b) => a - b)) {
Lines 37–54 at 318 (were 30–39 at 2)
3037
3138export function where(project: Project) {
3239 const graph = project.graph;
33− const shared = project.sharedView();
34− const sharedNumber = (file: string, id: LineId): number | undefined => {
40+ let shared: ByNumber | undefined;
41+ // By the file's index of visible lines (abso Capacity): finding it in lines() built every line of the file again
42+ // whenever the file changed, per line asked.
43+ const sharedNumber = (file: string, line: LineId | number): number | undefined => {
44+ shared ??= project.sharedView() as ByNumber;
3545 if (!shared.hasFile(file)) return undefined;
36− const i = shared.lines(file).findIndex((l) => l.id === id);
46+ const i =
47+ typeof line === "string"
48+ ? shared.lineNumber(file, line)
49+ : shared.lineNumberOf
50+ ? shared.lineNumberOf(file, line)
51+ : shared.lineNumber(file, graph.lineIdOf(line));
3752 return i >= 0 ? i + 1 : undefined;
3853 };
3954 const files: Record<string, Spot[]> = {};
Lines 56–65 at 318 (were 41–46 at 2)
4156 const draft = project.draftOf(agent);
4257 if (!draft || draft.atoms.length === 0) continue;
4358 const mine = new Set<AtomId>(draft.atoms);
59+ // Once per agent (abso Capacity): each read of draft.view asks the project's view cache, which weighs every
60+ // view it holds.
61+ const view = draft.view as ByNumber;
62+ const fileOfNumber = view.fileOfNumber?.bind(view);
4463 const perFile = new Map<string, { view: number[]; shared: number[]; changes: Set<AtomId>; last: number }>();
4564 const at = (file: string) => {
4665 let s = perFile.get(file);
Lines 70–76 at 318 (were 51–57 at 2)
5170 const atom = graph.atom(id);
5271 for (const run of atom.inserts) {
5372 // A line moved by someone (#28) is in the file the draft's view puts it in.
54− const file = run.parent.startsWith("^") ? run.file : draft.view.fileOf(run.parent);
73+ const file = run.parent.startsWith("^") ? run.file : view.fileOf(run.parent);
5574 const s = at(file);
5675 s.changes.add(id);
5776 s.last = Math.max(s.last, atom.time);
Lines 78–100 at 318 (were 59–68 at 2)
5978 const anchor = run.parent.startsWith("^") ? 0 : sharedNumber(file, run.parent);
6079 if (anchor !== undefined) s.shared.push(Math.max(anchor, 1));
6180 }
81+ // By number where the view can (abso Capacity): a draft deleting a big generated file read every line's text
82+ // to check it exists, and looked up each line's id.
83+ if (fileOfNumber) {
84+ for (const line of graph.deletedNumbers(id)) {
85+ const file = fileOfNumber(line);
86+ const s = at(file);
87+ s.changes.add(id);
88+ s.last = Math.max(s.last, atom.time);
89+ const n = sharedNumber(file, line);
90+ if (n !== undefined) s.shared.push(n);
91+ }
92+ continue;
93+ }
6294 for (const lineId of atom.deletes) {
6395 const info = graph.line(lineId);
6496 if (!info) continue;
65− const file = draft.view.fileOf(lineId);
97+ const file = view.fileOf(lineId);
6698 const s = at(file);
6799 s.changes.add(id);
68100 s.last = Math.max(s.last, atom.time);
Lines 103–118 at 318 (were 71–80 at 2)
71103 }
72104 }
73105 for (const [file, s] of perFile) {
74− if (draft.view.hasFile(file)) {
75− draft.view.lines(file).forEach((l, i) => {
76− if (mine.has(l.atom)) s.view.push(i + 1);
77− });
106+ if (view.hasFile(file)) {
107+ if (view.visibleWriters) {
108+ const seqs = new Set(draft.atoms.map(seqOf));
109+ view.visibleWriters(file).forEach((seq, i) => {
110+ if (seqs.has(seq)) s.view.push(i + 1);
111+ });
112+ } else
113+ view.lines(file).forEach((l, i) => {
114+ if (mine.has(l.atom)) s.view.push(i + 1);
115+ });
78116 }
79117 (files[file] ??= []).push({
80118 agent,
MCP
compare on this site's /mcp
CLI
abso diff 2 318 worker/project/where.ts --json
JSON
/christopher/abso-core/compare/2..318?file=worker%2Fproject%2Fwhere.ts&format=json