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 192 to 193

Compare

+63 −1 in 3 places
Lines 2–15 at 193 (were 2–12 at 192)
22// A line's id names the atom that inserted it, so blame is a lookup per line:
33// that change's author and message, and the publish that brought it into
44// shared, with its message. Why adds the change's reasons, what it settled,
5−// and the reasons other changes give that point at it.
5+// and the reasons other changes give that point at it, and the line's
6+// earlier changes (trail.ts).
67import { type Atom, type AtomId, type LineId, type ReadView, View } from "../../src/engine/index.ts";
78import { blocksIn, isMarkerLine } from "./markers.ts";
89import { pathKey } from "./pathkey.ts";
910import type { Project } from "./project.ts";
11+import { projectFileIn } from "./project-helpers.ts";
12+import { trail } from "./trail.ts";
1013
1114export interface BlameLine {
1215 n: number;
Lines 228–241 at 193 (were 225–235 at 192)
225228 settled.length > 0
226229 ? heldPush(project, settle, file, Math.max(0, ...settled.map((s) => s.publish?.time ?? 0)))
227230 : undefined;
231+ const gitIssues = gitIssuesOf(project.sharedView());
228232 return {
229233 file,
230234 line: n,
235+ version: where.agent !== undefined ? null : (where.version ?? project.lastVersion(where.draft ?? null)),
231236 text: line.text,
232237 id: line.id,
238+ ...(gitIssues !== undefined ? { gitIssues } : {}),
233239 change: {
234240 atom: atom.id,
235241 author: atom.author,
Lines 251–316 at 193 (were 245–254 at 192)
245251 ...(kept ? { settledBy: { atom: kept.id, author: kept.author, publish: publishOf(project, kept.id) } } : {}),
246252 ...(held ? { held } : {}),
247253 builtOn,
254+ ...lineTrail(project, view, file, line.id),
248255 };
249256}
250257
251258/**
259+ * The line's changes, newest first (abso-core issue 20), its own change
260+ * first: each change that rewrote it, with the line's text after it, and
261+ * whether it only changed formatting. Several changes in one push count as
262+ * one, formatting only if all of them were.
263+ */
264+function lineTrail(project: Project, view: ReadView, file: string, line: LineId) {
265+ const graph = project.graph;
266+ const { steps, more } = trail(graph, view, file, line);
267+ const out: {
268+ atom: AtomId;
269+ author: string;
270+ message: string;
271+ time: number;
272+ text: string;
273+ formatting: boolean;
274+ publish: Publish | null;
275+ }[] = [];
276+ for (const s of steps) {
277+ const a = graph.atom(s.atom);
278+ const publish = publishOf(project, a.id);
279+ const prev = out[out.length - 1];
280+ if (prev && samePublish(prev.publish, publish) && (publish !== null || prev.author === a.author)) {
281+ prev.formatting &&= s.formatting;
282+ continue;
283+ }
284+ out.push({
285+ atom: a.id,
286+ author: a.author,
287+ message: a.message,
288+ time: a.time,
289+ text: s.text,
290+ formatting: s.formatting,
291+ publish,
292+ });
293+ }
294+ return { trail: out, ...(more ? { trailMore: true as const } : {}) };
295+}
297+/** Where "#N" in history imported from git points (abso.json's "gitIssues"), when shared's project file says. */
298+function gitIssuesOf(view: ReadView): string | undefined {
299+ const file = projectFileIn(view);
300+ if (!file) return undefined;
301+ try {
302+ const url = (JSON.parse(file.text) as { gitIssues?: unknown }).gitIssues;
303+ return typeof url === "string" ? url : undefined;
304+ } catch {
305+ return undefined;
306+ }
307+}
309+function samePublish(a: Publish | null, b: Publish | null): boolean {
310+ return a === null || b === null ? a === b : a.draft === b.draft && a.version === b.version;
311+}
313+/**
252314 * Who wrote a folder (#41, F33): every line of every file under it (the
253315 * whole project for ""), counted by the agent that wrote it, most first.
254316 * Binary files and files kept whole have no lines, so they count as files
MCP
compare on this site's /mcp
CLI
abso diff 192 193 worker/project/blame.ts --json
JSON
/christopher/abso-core/compare/192..193?file=worker%2Fproject%2Fblame.ts&format=json