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

+21 −10 in 8 places
Lines 14–20 at 318 (were 14–20 at 2)
1414// Settled means the block is gone. These helpers also say what an agent kept
1515// once it settled one.
1616
17−import { type Atom, type AtomId, diffLines, type Graph, type Hunk, type View } from "../../src/engine/index.ts";
17+import { type Atom, type AtomId, diffLines, type Graph, type Hunk, type ReadView } from "../../src/engine/index.ts";
1818import type { AgentState, AgentStatus, Collision } from "./project-types.ts";
1919
2020export const YOURS = "<<<<<<< yours (unpublished)";
Lines 181–191 at 318 (were 181–187 at 2)
181181 );
182182}
183183
184−/** Whether `b` reads as `a` reworded: at least half their words in common. */
184+/**
185+ * Whether `b` reads as `a` reworded: at least half of `a`'s words are still
186+ * in it. Counted against `a` alone, so a rewording that keeps the line and
187+ * adds to it (a reason, the other side's number) still reads as the line.
188+ */
185189function alike(a: string, b: string): boolean {
186190 if (a === b) return true;
187191 const x = words(a);
Lines 193–203 at 318 (were 189–200 at 2)
189193 if (x.size === 0 || y.size === 0) return false;
190194 let both = 0;
191195 for (const w of x) if (y.has(w)) both++;
192− return both / (x.size + y.size - both) >= 0.5;
196+ return both / x.size >= 0.5;
193197}
194198
195199/**
196− * Lines both sides still had that the settled file has lost (#37, Playtester
197− * 1): neither side deleted them, yet neither side's version, nor the base's,
200+ * Lines both sides still had that the settled file has lost (#37): neither side deleted them, yet neither side's version, nor the base's,
198201 * nor anything reading like a rewording of one, is left. When both sides
199202 * changed line for line, each position is one line in three versions;
200203 * otherwise only lines both sides kept word for word count. Answers each
Lines 226–232 at 318 (were 223–229 at 2)
223226
224227/**
225228 * What a settled region kept, judged from the file as it is now, by each
226− * side's own changes (#37, Builder 2 and Writer 1): the lines it added, and
229+ * side's own changes (#37): the lines it added, and
227230 * the base lines only it removed. A side's block also holds lines it left as
228231 * they were, and an edit to one of those must not hide that its change was
229232 * kept. Lines both sides added alike, and lines with no letters or digits
Lines 264–278 at 318 (were 261–270 at 2)
261264 return y === "nothing" && t === "nothing" ? "both" : "rewrote";
262265}
263266
267+/** The message of the agent's newest held push that named `file`: its side's reason, for the settle to tell. */
268+export function heldMessage(agent: AgentState, file: string): string | undefined {
269+ return agent.held?.findLast((h) => h.message && h.files.includes(file))?.message;
270+}
264272/** What the marker reads need from a project. */
265273export interface MarkerHost {
266274 readonly graph: Graph;
267− agentView(agent: AgentState): View;
275+ agentView(agent: AgentState): ReadView;
268276 draft(agent: AgentState): AtomId[];
269277 draftFiles(agent: AgentState): Set<string>;
270278}
Lines 296–307 at 318 (were 288–296 at 2)
288296
289297/** The blocks of markers still in the agent's files, as collisions (#11): listed by sync and status. */
290298export function markedCollisions(host: MarkerHost, agent: AgentState): Collision[] {
299+ const files = markedFiles(agent);
300+ // No marked files, no view to build: most agents have none.
301+ if (files.length === 0) return [];
291302 const view = host.agentView(agent);
292303 const out: Collision[] = [];
293− for (const file of markedFiles(agent)) {
304+ for (const file of files) {
294305 if (!view.hasFile(file)) continue;
295306 for (const b of blocksIn(view.lines(file).map((l) => l.text))) out.push(blockCollision(file, b));
296307 }
Lines 318–324 at 318 (were 307–313 at 2)
307318}
308319
309320/** The collided changes behind each block whose marker lines `atom` deletes (#11). */
310−export function markersSettled(host: MarkerHost, agent: AgentState, view: View, atom: Atom): AtomId[] {
321+export function markersSettled(host: MarkerHost, agent: AgentState, view: ReadView, atom: Atom): AtomId[] {
311322 if (agent.marked.length === 0) return [];
312323 const out = new Set<AtomId>();
313324 const blocksBy = new Map<string, Block[]>();
Lines 352–358 at 318 (were 341–347 at 2)
341352 const out: Collision[] = [];
342353 for (const file of [...host.draftFiles(agent)].toSorted()) {
343354 if (!view.hasFile(file)) continue;
344− const lines = view.lines(file);
355+ const lines = view.buildLines(file);
345356 const added = lines.map((l, i) => (mine.has(l.atom) && isMarkerLine(l.text) ? i : -1)).filter((i) => i >= 0);
346357 if (added.length === 0) continue;
347358 const blocks = blocksIn(lines.map((l) => l.text));
MCP
compare on this site's /mcp
CLI
abso diff 2 318 worker/project/markers.ts --json
JSON
/christopher/abso-core/compare/2..318?file=worker%2Fproject%2Fmarkers.ts&format=json