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

Compare

+102 −10 in 6 places
Lines 1–5 at 318 (were 1–6 at 151)
11import { startNode } from "../keys.ts";
22import { StableSet } from "../state-source.ts";
3−import { joinLines } from "../text.ts";
43import type { FileAttrs, ReadView, SeqLine, VisibleLine } from "../view.ts";
54import type { ExperimentalMarkerProjection, MarkerState } from "./projection-marker.ts";
65
Lines 22–52 at 318 (were 23–40 at 151)
2322 get set(): ReadonlySet<string> {
2423 this.#assertLive();
2524 const has = (id: string) =>
26− this.graph.has(id) &&
27− (this.#adapter.members.get(this.#state.membership, this.graph.atom(id).seq)?.present ?? false);
25+ this.graph.has(id) && (this.#adapter.members.get(this.#state.membership, Number(id.slice(1)))?.present ?? false);
2826 const assertLive = this.#assertLive;
27+ const members = this.#adapter.members;
28+ const root = this.#state.membership;
29+ const graph = this.graph;
2930 return new (class extends StableSet<string> {
3031 readonly retainedBytes = 64;
3132 has(id: string): boolean {
3233 assertLive();
3334 return has(id);
3435 }
35− values(): SetIterator<string> {
36+ *values(): SetIterator<string> {
3637 assertLive();
37− throw Error("unsupported projected membership enumeration");
38+ const iterator = members.entries(root);
39+ try {
40+ for (;;) {
41+ assertLive();
42+ const item = iterator.next();
43+ if (item.done) return;
44+ const [seq, member] = item.value;
45+ if (member.present) yield graph.idOfSeq(seq);
46+ }
47+ } finally {
48+ iterator.return?.();
49+ }
3850 }
3951 })();
4052 }
Lines 73–86 at 318 (were 61–67 at 151)
6173 }
6274 lineNumber(path: string, line: string): number {
6375 this.#assertLive();
64− return this.lines(path).findIndex((item) => item.id === line);
76+ let index = 0;
77+ for (const id of this.#adapter.lineIds(this.#state, path)) {
78+ this.#assertLive();
79+ if (id === line) return index;
80+ index++;
81+ }
82+ this.#assertLive();
83+ return -1;
6584 }
6685 sameText(path: string, other: ReadView): boolean {
6786 this.#assertLive();
Lines 110–139 at 318 (were 91–96 at 151)
91110 for (const id of this.graph.movers()) if (this.set.has(id)) return true;
92111 return false;
93112 }
113+ *#textChunks(n: number): IterableIterator<string> {
114+ this.#assertLive();
115+ const iterator = this.graph.textChunks(n);
116+ while (true) {
117+ this.#assertLive();
118+ const next = iterator.next();
119+ this.#assertLive();
120+ if (next.done) return;
121+ yield next.value;
122+ }
123+ }
124+ *lineChunks(path: string): IterableIterator<() => Iterable<string>> {
125+ this.#assertLive();
126+ const iterator = this.#adapter.lineIds(this.#state, path);
127+ while (true) {
128+ this.#assertLive();
129+ const next = iterator.next();
130+ this.#assertLive();
131+ if (next.done) return;
132+ const n = this.graph.lineN(next.value);
133+ yield () => this.#textChunks(n);
134+ }
135+ }
94137 *visibleLines(path: string): IterableIterator<VisibleLine> {
95138 this.#assertLive();
96139 const graph = this.#adapter.graph;
Lines 152–185 at 318 (were 109–114 at 151)
109152 this.#assertLive();
110153 return [...this.visibleLines(path)];
111154 }
155+ *#buildingLines(path: string): IterableIterator<VisibleLine> {
156+ this.#assertLive();
157+ const graph = this.#adapter.graph;
158+ const iterator = this.#adapter.lineIds(this.#state, path);
159+ while (true) {
160+ this.#assertLive();
161+ const next = iterator.next();
162+ this.#assertLive();
163+ if (next.done) return;
164+ const id = next.value;
165+ const n = graph.lineN(id);
166+ const assertLive = () => this.#assertLive();
167+ yield {
168+ id,
169+ textChunks: () => this.#textChunks(n),
170+ get text() {
171+ assertLive();
172+ return graph.textOf(n);
173+ },
174+ atom: graph.idOfSeq(graph.writerSeqOf(n)),
175+ };
176+ }
177+ }
178+ buildLines(path: string): readonly VisibleLine[] {
179+ this.#assertLive();
180+ return [...this.#buildingLines(path)];
181+ }
112183 sequence(path: string): readonly SeqLine[] {
113184 this.#assertLive();
114185 const adapter = this.#adapter,
Lines 233–266 at 318 (were 162–174 at 151)
162233 fileOf(line: string): string {
163234 this.#assertLive();
164235 if (line.startsWith("^")) return line.slice(1);
165− const marker = this.#adapter.markers.get(this.#state.locator, this.graph.lineN(line) + 1);
166− if (marker?.kind !== "line") throw Error("missing projected line");
167− return this.#adapter.sequence.fileAt(this.#state.sequence, marker.enter);
236+ let current = line;
237+ while (!current.startsWith("^")) {
238+ const n = this.graph.lineN(current);
239+ if (n < 0) throw Error("unknown projected line");
240+ const marker = this.#adapter.markers.get(this.#state.locator, n + 1);
241+ if (marker?.kind === "line") return this.#adapter.sequence.fileAt(this.#state.sequence, marker.enter);
242+ // A line written outside this view has no marker. Follow canonical ancestry
243+ // until it reaches a line whose placement this view actually contains.
244+ if (marker || this.#adapter.members.get(this.#state.membership, this.graph.writerSeqOf(n))?.present)
245+ throw Error("missing projected line");
246+ const parent = this.graph.lineParent(current);
247+ if (parent === undefined) throw Error("missing projected line parent");
248+ current = parent;
249+ }
250+ return current.slice(1);
168251 }
169252 text(path: string): string {
170253 this.#assertLive();
171− return joinLines([...this.visibleLines(path)].map((line) => line.text));
254+ let text = "",
255+ part = "";
256+ for (const line of this.visibleLines(path)) {
257+ part += `${line.text}\n`;
258+ if (part.length >= 16384) {
259+ text += part;
260+ part = "";
261+ }
262+ }
263+ return text + part;
172264 }
173265 hasFile(path: string): boolean {
174266 this.#assertLive();
MCP
compare on this site's /mcp
CLI
abso diff 151 318 src/engine/experimental/projection-reader.ts --json
JSON
/christopher/abso-core/compare/151..318?file=src%2Fengine%2Fexperimental%2Fprojection-reader.ts&format=json