Lines 14–20 at 318 (were 14–20 at 80)
1414// Settled means the block is gone. These helpers also say what an agent kept 1515// once it settled one. 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"; 2020export const YOURS = "<<<<<<< yours (unpublished)"; Lines 181–191 at 318 (were 181–187 at 80)
184−/** Whether `b` reads as `a` reworded: at least half their words in common. */
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. 185189function alike(a: string, b: string): boolean { 186190 if (a === b) return true; 187191 const x = words(a); Lines 193–199 at 318 (were 189–195 at 80)
189193 if (x.size === 0 || y.size === 0) return false; 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; Lines 264–278 at 318 (were 260–269 at 80)
260264 return y === "nothing" && t === "nothing" ? "both" : "rewrote"; 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; 263272/** What the marker reads need from a project. */ 264273export interface MarkerHost { 265274 readonly graph: Graph; 266− agentView(agent: AgentState): View;
275+ agentView(agent: AgentState): ReadView; 267276 draft(agent: AgentState): AtomId[]; 268277 draftFiles(agent: AgentState): Set<string>; Lines 318–324 at 318 (were 309–315 at 80)
311320/** The collided changes behind each block whose marker lines `atom` deletes (#11). */ 312−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[] { 313322 if (agent.marked.length === 0) return []; 314323 const out = new Set<AtomId>(); 315324 const blocksBy = new Map<string, Block[]>(); Lines 352–358 at 318 (were 343–349 at 80)
343352 const out: Collision[] = []; 344353 for (const file of [...host.draftFiles(agent)].toSorted()) { 345354 if (!view.hasFile(file)) continue; 346− const lines = view.lines(file);
355+ const lines = view.buildLines(file); 347356 const added = lines.map((l, i) => (mine.has(l.atom) && isMarkerLine(l.text) ? i : -1)).filter((i) => i >= 0); 348357 if (added.length === 0) continue; 349358 const blocks = blocksIn(lines.map((l) => l.text));