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 22 to 23

Compare

+115 −2 in 3 places
Lines 12–18 at 23 (were 12–18 at 22)
1212import { tmpdir } from "node:os";
1313import { join } from "node:path";
1414import { after, before, describe, it } from "node:test";
15−import { readMachineServers } from "../src/config.ts";
15+import { readConfig, readMachineServers } from "../src/config.ts";
1616import { issuesServerFor, tokenGoesTo } from "../src/core.ts";
1717import { searchLines } from "../src/issues.ts";
1818import { main } from "../src/main.ts";
Lines 26–70 at 23 (were 26–38 at 22)
2626let issuesUrl: string;
2727/** Every call the stand-in Issues server took. */
2828const seen: string[] = [];
29+/** The bodies of the copy requests it took. */
30+const copies: Record<string, unknown>[] = [];
2931const dirs: string[] = [];
3032
3133before(async () => {
3234 fake = await startFake(0, TOKEN);
3335 issues = createServer((req, res) => {
3436 seen.push(`${req.method} ${req.url}`);
35− res.writeHead(500, { "content-type": "application/json" }).end(JSON.stringify({ error: "a stand-in" }));
37+ const send = (status: number, body: unknown) =>
38+ res.writeHead(status, { "content-type": "application/json" }).end(JSON.stringify(body));
39+ if (req.method === "POST" && /\/copy$/.test(req.url ?? "")) {
40+ let raw = "";
41+ req.on("data", (c: Buffer) => (raw += c.toString("utf8")));
42+ req.on("end", () => {
43+ const body = JSON.parse(raw) as Record<string, unknown>;
44+ copies.push(body);
45+ // Issue 403 stands for a live server refusing an agent's copy.
46+ if (body.issue === 403 && body.dryRun !== true)
47+ return send(403, { error: "copying an issue out of its project takes an owner of that project" });
48+ const skipped = { comments: [4], asks: [2] };
49+ if (body.dryRun === true)
50+ return send(200, {
51+ dryRun: true,
52+ plan: {
53+ from: { project: body.from, issue: body.issue },
54+ title: "Sync is slow",
55+ edited: ["description"],
56+ labels: ["client"],
57+ closed: { how: "done" },
58+ comments: [{ edited: false }, { edited: true }],
59+ asks: [{ edited: false }],
60+ skipped,
61+ },
62+ });
63+ send(200, { ok: true, id: 31, from: { project: body.from, issue: body.issue }, skipped });
64+ });
65+ return;
66+ }
67+ send(500, { error: "a stand-in" });
3668 });
3769 await new Promise<void>((ok) => issues.listen(0, "127.0.0.1", ok));
3870 issuesUrl = `http://127.0.0.1:${(issues.address() as AddressInfo).port}`;
Lines 198–281 at 23 (were 166–168 at 22)
166198 assert.match(posts[0]!, /^POST \/p\/issues\d+\/a\/erin\/withdraw\/3$/);
167199 });
168200});
202+describe("abso issue <N> --copy-to <project>", () => {
203+ const text = async (cwd: string, argv: string[]) => {
204+ const r = await main(argv, { cwd, env: ENV(), write: () => {} });
205+ return { exit: r.exit, out: r.stdout + r.stderr };
206+ };
208+ it("a dry run asks the other project's copy route for the plan, and says nothing was written", async () => {
209+ const gil = await folder("gil");
210+ const before = seen.length;
211+ const r = await text(gil, ["issue", "12", "--copy-to", "core", "--dry-run"]);
212+ assert.equal(r.exit, 0, r.out);
213+ assert.deepEqual(seen.slice(before), ["POST /p/core/a/gil/copy"]);
214+ const from = (copies.at(-1) as { from: string }).from;
215+ assert.match(from, /^issues\d+$/);
216+ assert.deepEqual(copies.at(-1), { from, issue: 12, dryRun: true });
217+ assert.equal(
218+ r.out.trimEnd(),
219+ [
220+ `A dry run: nothing was written. Copying ${from} issue 12 into core would make:`,
221+ ` "Sync is slow", done (description edited when copied)`,
222+ " 2 comments (1 edited), 1 answered ask, labelled client",
223+ " not copied: comments 4; asks 2 (open asks, and what --clean left out)",
224+ "Run it again without --dry-run to copy it.",
225+ ].join("\n"),
226+ );
227+ });
229+ it("copies with the cleaned texts --clean gives, by source id", async () => {
230+ const gil = await folder("gil");
231+ writeFileSync(
232+ join(gil, "clean.json"),
233+ JSON.stringify({ description: "Cleaned.", comments: [{ id: 1 }, { id: 3, text: "Cleaned too." }] }),
234+ );
235+ const r = await text(gil, ["issue", "12", "--copy-to", "core", "--clean", "clean.json"]);
236+ assert.equal(r.exit, 0, r.out);
237+ const from = (copies.at(-1) as { from: string }).from;
238+ assert.deepEqual(copies.at(-1), {
239+ description: "Cleaned.",
240+ comments: [{ id: 1 }, { id: 3, text: "Cleaned too." }],
241+ from,
242+ issue: 12,
243+ });
244+ assert.match(
245+ r.out,
246+ new RegExp(`^Copied ${from} issue 12 to core issue 31\\. Its comments and asks keep their authors`),
247+ );
248+ });
250+ it("says a dry run still works when the server refuses the copy", async () => {
251+ const gil = await folder("gil");
252+ const r = await text(gil, ["issue", "403", "--copy-to", "core"]);
253+ assert.equal(r.exit, 1, r.out);
254+ assert.match(r.out, /takes an owner of that project\. --dry-run still shows what would go\./);
255+ });
257+ it("refuses mistakes before any call", async () => {
258+ const gil = await folder("gil");
259+ writeFileSync(join(gil, "bad.json"), JSON.stringify({ from: "elsewhere" }));
260+ const before = seen.length;
261+ for (const [argv, why] of [
262+ [["issue", "12", "--copy-to", "core", "--comment", "x"], /--copy-to goes alone .* not with --comment/],
263+ [["issue", "12", "--dry-run"], /--clean and --dry-run go with --copy-to <project>/],
264+ [["issue", "12", "--copy-to", "core", "--clean", "nope.json"], /--clean nope\.json: no such file/],
265+ [
266+ ["issue", "12", "--copy-to", "core", "--clean", "bad.json"],
267+ /from isn't one of title, description, comments, asks/,
268+ ],
269+ ] as const) {
270+ const r = await text(gil, [...argv]);
271+ assert.notEqual(r.exit, 0, argv.join(" "));
272+ assert.match(r.out, why);
273+ }
274+ const { project } = readConfig(gil);
275+ assert.match(
276+ (await text(gil, ["issue", "12", "--copy-to", project])).out,
277+ /issue 12 is already in issues\d+; --copy-to names another project/,
278+ );
279+ assert.equal(seen.length, before, "nothing reached the Issues server");
280+ });
281+});
MCP
compare on this site's /mcp
CLI
abso diff 22 23 client/test/issues.test.ts --json
JSON
/christopher/abso-core/compare/22..23?file=client%2Ftest%2Fissues.test.ts&format=json