- MCP
- blame on this site's /mcp
- CLI
- abso blame worker/project/test/news-lines.test.ts --version 309 --json
- JSON
- /christopher/abso-core/blame/worker/project/test/news-lines.test.ts?version=309&format=json
60 linesdf-routing 100%Last change df-routing in version 286,
60 lines from 2 changes in 1 version.
df-routing286Log a line as a publish's news for other agents starts and ends (abso 702), through a new logLine option; nothing is written until a host passes itCompare1// abso 702: a publish's news for other agents writes a line as it starts and
2// one as it ends, through ProjectOptions.logLine, so work that outlives its
3// request still shows in the host's logs.
5import assert from "node:assert/strict";
6import { test } from "node:test";
7import { MemoryStore, Project } from "../project.ts";
9const START = {
10 "src/parse.ts": "export function parsePattern(text: string): string {\n return text;\n}\n",
11 "src/match.ts": 'import { parsePattern } from "./parse.ts";\n\nexport function run(p: string) {\n return p;\n}\n',
12};
14function setup(lines: Record<string, string | number>[]) {
15 const project = new Project(new MemoryStore(), { logLine: (line) => lines.push(line) });
16 project.init(START, 0);
17 project.sync("lib");
18 project.sync("user");
19 return project;
20}
22test("a publish with another agent drafting writes a start line and an end line", () => {
23 const lines: Record<string, string | number>[] = [];
24 const project = setup(lines);
25 project.edit("user", { file: "src/match.ts", old: " return p;\n", new: " return parsePattern(p);\n" }, 1);
26 project.edit(
27 "lib",
28 { file: "src/parse.ts", old: "parsePattern(text: string)", new: "parsePattern(text: string, flags = '')" },
29 2,
30 );
31 assert.equal(project.publish("lib", "parsePattern takes flags", 3).ok, true);
33 const news = lines.filter((l) => l.work === "publishNews");
34 assert.deepEqual(
35 news.map((l) => l.step),
36 ["start", "end"],
37 );
38 assert.equal(news[0]!.publisher, "lib");
39 assert.equal(news[1]!.drafts, 1);
40 assert.equal(news[1]!.changedNames, 1);
41 assert.equal(news[1]!.news, 1);
42});
44test("a publish with nobody else drafting writes nothing", () => {
45 const lines: Record<string, string | number>[] = [];
46 const project = setup(lines);
47 project.edit("lib", { file: "src/parse.ts", old: " return text;\n", new: " return text.trim();\n" }, 1);
48 assert.equal(project.publish("lib", "trim", 2).ok, true);
49 assert.deepEqual(lines, []);
50});
52test("without a logLine option, a publish still works", () => {
53 const project = new Project(new MemoryStore());
54 project.init(START, 0);
55 project.sync("lib");
56 project.sync("user");
57 project.edit("user", { file: "src/match.ts", old: " return p;\n", new: " return parsePattern(p);\n" }, 1);
58 project.edit("lib", { file: "src/parse.ts", old: " return text;\n", new: " return text.trim();\n" }, 2);
59 assert.equal(project.publish("lib", "trim", 3).ok, true);
60});