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 174 to 175

Compare

+30 −17 in 8 places
Lines 1–12 at 175 (were 1–10 at 174)
1+import { diffLineSymbols } from "../../src/engine/text.ts";
2+import { recordFileChanges } from "./record-file.ts";
13// Moves (#28): within one agent's unpublished draft, a line that leaves one place and the same
24// text that arrives somewhere else is the same line. Before a publish, those matches become move
35// atoms so the lines keep their ids. Writes go through ExpressMovesHost; today the host is Project.
46
57import type { AtomId, AttrSet, EditInput, Graph, LineId, MoveInput, ReadView } from "../../src/engine/index.ts";
68import { differenceSet, StableOverlaySet } from "../../src/engine/state-source.ts";
7−import { PLAIN_LINE } from "./collisions.ts";
9+import { MoveLineText } from "./move-line-text.ts";
810import type { AgentState, Entry, Meta, Mode } from "./project-types.ts";
1012/** The most moved blocks one publish expresses: the longest ones, when there are more. */
Lines 61–67 at 175 (were 59–64 at 174)
5961 if (draft.length === 0) return;
6062 const g = host.graph;
6163 const mine = new Set(draft);
64+ const text = new MoveLineText(g);
6265 const after = host.agentView(agent);
6366 const before = host.beforeDraft
6467 ? host.beforeDraft(agent, draft)
Lines 74–98 at 175 (were 71–95 at 174)
7174 readonly file: string;
7275 readonly start: number;
7376 readonly ids: LineId[];
74− readonly texts: string[];
77+ readonly texts: number[];
7578 }
7679 const gone: Block[] = [];
7780 const written: Block[] = [];
7881 for (const file of [...touched].toSorted()) {
7982 let cur: Block | undefined;
80− before.lines(file).forEach((l, i) => {
83+ before.buildLines(file).forEach((l, i) => {
8184 if (g.deletersOf(l.id).some((d) => mine.has(d))) {
8285 if (!cur) gone.push((cur = { file, start: i, ids: [], texts: [] }));
8386 cur.ids.push(l.id);
84− cur.texts.push(l.text);
87+ cur.texts.push(text.intern(l.id));
8588 } else cur = undefined;
8689 });
8790 cur = undefined;
88− after.lines(file).forEach((l, i) => {
91+ after.buildLines(file).forEach((l, i) => {
8992 if (mine.has(l.atom)) {
9093 if (!cur) written.push((cur = { file, start: i, ids: [], texts: [] }));
9194 cur.ids.push(l.id);
92− cur.texts.push(l.text);
95+ cur.texts.push(text.intern(l.id));
9396 } else cur = undefined;
9497 });
9598 }
Lines 111–117 at 175 (were 108–114 at 174)
108111 // Where each deleted text starts a candidate, in block and line order (abso issue 158): a stretch
109112 // can only start where the texts are equal, so each written line looks only there, not at
110113 // every deleted line. A text deleted more than MATCH_STARTS times keeps its first ones.
111− const starts = new Map<string, { block: Block; q: number }[]>();
114+ const starts = new Map<number, { block: Block; q: number }[]>();
112115 for (const block of gone)
113116 block.texts.forEach((t, q) => {
114117 const list = starts.get(t);
Lines 134–140 at 175 (were 131–137 at 174)
131134 }
132135 if (len > 0 && (!best || len > best.len)) best = { block, q, len };
133136 }
134− if (best?.block.texts.slice(best.q, best.q + best.len).some((t) => !PLAIN_LINE.test(t))) {
137+ if (best?.block.texts.slice(best.q, best.q + best.len).some((t) => !text.plain[t])) {
135138 const ids = best.block.ids.slice(best.q, best.q + best.len);
136139 for (const id of ids) used.add(id);
137140 matches.push({ from: best.block.file, ids, to: run.file, at: run.start + p });
Lines 148–154 at 175 (were 145–151 at 174)
145148 // passed Workers' CPU limit. So the longest blocks move first, up to MOVE_LIMIT of them and
146149 // MOVE_BUDGET lines laid out in all; the rest are a delete and a fresh write, as an unmatched block
147150 // always is.
148− const length = (path: string) => (after.hasFile(path) ? after.lines(path).length : 0);
151+ const length = (path: string) => (after.hasFile(path) ? after.buildLines(path).length : 0);
149152 const cost = (m: Match) => length(m.from) + (m.to === m.from ? 0 : length(m.to));
150153 const keep = new Set<Match>();
151154 let spent = 0;
Lines 188–194 at 175 (were 185–191 at 174)
185188 const start = view.lineNumber(m.from, m.ids[0]!);
186189 if (start < 0 || m.ids.some((id, k) => view.lineNumber(m.from, id) !== start + k)) continue;
187190 // Land after the nearest line above it in the final text that is already there.
188− const finalLines = host.agentView(finalAgent).lines(m.to);
191+ const finalLines = host.agentView(finalAgent).buildLines(m.to);
189192 let at = 0;
190193 for (let i = m.at - 1; i >= 0; i--) {
191194 const n = view.lineNumber(m.to, finalLines[i]!.id);
Lines 210–237 at 175 (were 207–224 at 174)
207210 for (const path of [...involved].toSorted()) {
208211 const finalView = host.agentView(finalAgent);
209212 const was = finalView.attrs(path);
210− host.recordFile(
213+ const view = host.agentView(agent);
214+ const target = finalView.buildLines(path);
215+ const symbols = new MoveLineText(g);
216+ const previous = view.buildLines(path).map((line) => symbols.intern(line.id));
217+ const next = target.map((line) => symbols.intern(line.id));
218+ const edits = diffLineSymbols(previous, next).map((hunk) => ({
219+ file: path,
220+ start: hunk.start,
221+ end: hunk.end,
222+ lines: hunk.lines.map((symbol) => symbols.text(symbol)),
223+ }));
224+ recordFileChanges(
225+ host,
211226 agent,
212− host.agentView(agent),
227+ view,
213228 path,
214− finalView.hasFile(path) ? finalView.text(path) : null,
229+ !finalView.hasFile(path) ? "missing" : target.length === 0 ? "empty" : "present",
230+ edits,
215231 time,
216232 {},
217233 entries,
218− {
219− exec: was.exec,
220− link: was.link,
221− },
234+ { exec: was.exec, link: was.link },
222235 );
223236 }
224237}
MCP
compare on this site's /mcp
CLI
abso diff 174 175 worker/project/express-moves.ts --json
JSON
/christopher/abso-core/compare/174..175?file=worker%2Fproject%2Fexpress-moves.ts&format=json