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 34 to 35

Compare

+114 −0 in 3 places
Lines 43–74 at 35 (were 43–48 at 34)
4343 });
4444 if (req.url!.endsWith("/issue")) return json({ id: 7 });
4545 if (/\/issue\/\d+\/comment$/.test(req.url!)) return json({ id: 3 });
46+ // An older Issues server keeps no files on asks: it answers without them (project "keepless").
47+ const older = req.url!.includes("/p/keepless/");
48+ if (req.url!.endsWith("/ask")) {
49+ const sent = (JSON.parse(body.toString()) as { attachments?: string[] }).attachments;
50+ return json({ id: 9, ...(sent && !older ? { attachments: sent } : {}) });
51+ }
52+ if (/\/answer\/\d+$/.test(req.url!)) {
53+ const sent = (JSON.parse(body.toString()) as { attachments?: string[] }).attachments ?? [];
54+ const files = older ? [] : sent.map((id) => ({ id, name: "x", type: "image/png", size: 1 }));
55+ return json({ ask: { by: "bob", answer: { by: "ann", words: "w", at: 0, attachments: files } } });
56+ }
57+ // Issue 9's ask carries a file on its question and one on its answer.
58+ if (req.method === "GET" && /\/issue\/9$/.test(req.url!))
59+ return json({
60+ issue: { id: 9 },
61+ comments: [],
62+ edits: [],
63+ asks: [
64+ {
65+ attachments: [{ id: "a00000000000d", name: "question.png", type: "image/png", size: 13 }],
66+ answer: { attachments: [{ id: "a00000000000e", name: "answer.png", type: "image/png", size: 13 }] },
67+ },
68+ ],
69+ claims: [],
70+ children: [],
71+ });
4672 // Issue 8 carries an svg-drawn image on itself and again on a comment, plus one more on the comment.
4773 const logo = { id: "a00000000000b", name: "../shot one.png", type: "image/png", size: 13 };
4874 if (req.method === "GET" && /\/issue\/8$/.test(req.url!))
Lines 205–269 at 35 (were 179–184 at 34)
179205 assert.match(mixed.out, /--save-attachments goes alone/);
180206 });
181207
208+ it("goes on an ask and on an answer, and not on a withdrawal", async () => {
209+ const dir = await folder();
210+ let from = seen.length;
211+ const asked = await avcs(dir, [
212+ "ask",
213+ "bob",
214+ "Which looks right?",
215+ "--issue",
216+ "7",
217+ "--attach",
218+ "shot.png,after.png",
219+ ]);
220+ assert.equal(asked.exit, 0, asked.out);
221+ assert.deepEqual(
222+ seen.slice(from).map((c) => `${c.method} ${c.url.replace(/^\/p\/[^/]+/, "")}`),
223+ ["POST /a/ann/attachments", "POST /a/ann/attachments", "POST /a/ann/ask"],
224+ );
225+ const ask = JSON.parse(seen.at(-1)!.body.toString()) as { question: string; attachments: string[] };
226+ assert.equal(ask.question, "Which looks right?");
227+ assert.equal(ask.attachments.length, 2);
228+ assert.deepEqual((asked.json as { attachments: string[] }).attachments, ask.attachments);
229+ from = seen.length;
230+ const answered = await avcs(dir, ["answer", "9", "This one", "--attach", "after.png"]);
231+ assert.equal(answered.exit, 0, answered.out);
232+ const answer = JSON.parse(seen.at(-1)!.body.toString()) as { words: string; attachments: string[] };
233+ assert.equal(answer.words, "This one");
234+ assert.equal(answer.attachments.length, 1);
235+ assert.equal(seen.length - from, 2);
236+ from = seen.length;
237+ const withdrawn = await avcs(dir, ["ask", "--withdraw", "9", "--attach", "shot.png"]);
238+ assert.equal(withdrawn.exit, 1);
239+ assert.equal(seen.length, from, "nothing was sent");
240+ });
242+ it("says so when an older Issues server keeps an ask's words but not its files", async () => {
243+ const dir = mkdtempSync(join(tmpdir(), "abso-attach-"));
244+ dirs.push(dir);
245+ const init = await avcs(dir, ["init", "--server", fake.url, "--project", "keepless", "--agent", "ann"]);
246+ assert.equal(init.exit, 0, init.out);
247+ writeFileSync(join(dir, "shot.png"), Buffer.from([0x89, 0x50, 0x4e, 0x47, 1]));
248+ const asked = await avcs(dir, ["ask", "bob", "Which?", "--attach", "shot.png"]);
249+ assert.equal(asked.exit, 0, asked.out);
250+ assert.match(asked.out, /didn't keep the file on ask 9: it is older than this client/);
251+ const answered = await avcs(dir, ["answer", "9", "This", "--attach", "shot.png"]);
252+ assert.match(answered.out, /didn't keep the file on your answer to ask 9/);
253+ // A server that keeps them says nothing of the kind.
254+ const kept = await avcs(await folder(), ["ask", "bob", "Which?", "--attach", "shot.png"]);
255+ assert.doesNotMatch(kept.out, /didn't keep/);
256+ });
258+ it("--save-attachments takes the files on an issue's asks and answers too", async () => {
259+ const dir = await folder();
260+ const out = mkdtempSync(join(tmpdir(), "abso-saved-"));
261+ dirs.push(out);
262+ const r = await avcs(dir, ["issue", "9", "--save-attachments", out]);
263+ assert.equal(r.exit, 0, r.out);
264+ assert.deepEqual(readdirSync(out).sort(), ["a00000000000d-question.png", "a00000000000e-answer.png"]);
265+ });
182267 it("an issue's page lists its attachments and each comment's, with links", () => {
183268 const page = {
184269 issue: {
Lines 323–356 at 35 (were 238–242 at 34)
238323 text,
239324 /\n {4}attached a0000000000aa: "logo.png", 4 KB, \S+\/a0000000000aa\n {6}drawn from "logo.svg", 512 B, https:\/\/issues.example\/p\/x\/attachments\/a0000000000aa\/source/,
240325 );
326+ // An ask lists its question's files under it, and its answer's under the answer.
327+ const file = (id: string, name: string) => ({ id, name, type: "image/png", size: 1024 });
328+ const asked = {
329+ ...page,
330+ asks: [
331+ {
332+ id: 4,
333+ issue: 7,
334+ by: "ann",
335+ of: "bob",
336+ kind: "question",
337+ question: "Which?",
338+ attachments: [file("a00000000000d", "a.png")],
339+ review: false,
340+ due: null,
341+ recommendation: null,
342+ options: [],
343+ blocks: [],
344+ at: 0,
345+ answer: { by: "bob", words: "This", at: 0, attachments: [file("a00000000000e", "b.png")] },
346+ seen: null,
347+ },
348+ ],
349+ } as unknown as IssuePage;
350+ const asks = issuePage(asked, { attachmentUrl: (id: string) => `https://i.example/${id}` }).join("\n");
351+ assert.match(
352+ asks,
353+ /ask 4: .*"Which\?"\n {4}attached a00000000000d: "a.png", 1 KB, https:\/\/i.example\/a00000000000d\n {4}answer: "This"\n {6}attached a00000000000e: "b.png", 1 KB/,
354+ );
241355 });
242356});
MCP
compare on this site's /mcp
CLI
abso diff 34 35 client/test/attach.test.ts --json
JSON
/christopher/abso-core/compare/34..35?file=client%2Ftest%2Fattach.test.ts&format=json