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
MCP
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/src/engine/test/build-lazy-lines.test.ts?format=json
46 linescodex-capacity-chair 100%Last change codex-capacity-chair in version 175, 1 version changed it
1import assert from "node:assert/strict";
2import { test } from "node:test";
3import { buildAtom } from "../build.ts";
4import { Repo } from "./helpers.ts";
5
6test("splice atom construction reads only the replaced region's text", (t) => {
7 const repo = Repo.init({ "f.txt": `${"unrelated".repeat(10000)}\nold\nlast\n` });
8 const view = repo.view();
9 const input = { author: "writer", message: "replace", edits: [{ file: "f.txt", start: 1, end: 2, lines: ["new"] }] };
10 const expected = buildAtom(view, input);
11 const original = repo.graph.textChunks.bind(repo.graph);
12 const reads: number[] = [];
13 t.mock.method(repo.graph, "textChunks", (n: number) => {
14 reads.push(n);
15 assert.equal(n, 1);
16 return original(n);
17 });
18 assert.deepEqual(buildAtom(repo.view(), input), expected);
19 assert.deepEqual(reads, [1]);
20 reads.length = 0;
21 buildAtom(repo.view(), {
22 author: "writer",
23 message: "insert",
24 edits: [{ file: "f.txt", start: 1, end: 1, lines: ["added"] }],
25 });
26 assert.deepEqual(reads, []);
27});
29test("many splice edits build line handles only once per file", (t) => {
30 const repo = Repo.init({ "f.txt": Array.from({ length: 2000 }, (_, i) => `line ${i}\n`).join("") });
31 const view = repo.view();
32 const read = view.buildLines.bind(view);
33 let calls = 0;
34 t.mock.method(view, "buildLines", (path: string) => {
35 calls++;
36 return read(path);
37 });
38 const edits = Array.from({ length: 400 }, (_, i) => ({
39 file: "f.txt",
40 start: i * 4,
41 end: i * 4 + 1,
42 lines: [`new ${i}`],
43 }));
44 assert.equal(buildAtom(view, { author: "writer", message: "many edits", edits }).deletes.length, 400);
45 assert.equal(calls, 1);
46});