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
show on this site's /mcp
CLI
abso show 35 --json
JSON
/christopher/abso-core/versions/35?format=json

Client: files on asks and answers. abso ask and abso answer take --attach (uploaded first, as on issues; not with --withdraw); an ask lists its question's files under it and its answer's under the answer; abso issue N --save-attachments takes them too. An Issues server from before asks carried files keeps the words and drops the files: abso says so (notKept in --json) instead of losing them quietly. Wire: Ask.attachments and answer.attachments, optional. Client tests 286/286, tsc and biome clean.

of shared·pinch··Not checked

Version 34 · Files at version 35

5 files, 172 lines added, 21 removed.

--- a/client/src/api.ts
+++ b/client/src/api.ts
@@ -613,13 +613,14 @@
613613 due?: string;
614614 blocks?: number[];
615615 options?: string[];
616− }): Promise<{ id: number; news?: IssueNews }> {
616+ attachments?: string[];
617+ }): Promise<{ id: number; news?: IssueNews; attachments?: string[] }> {
617618 return this.#issues("POST", this.agentPath("ask"), body);
618619 }
619620
620621 answer(
621622 id: number,
622− body: { words?: string; option?: number | string; note?: string; done?: boolean },
623+ body: { words?: string; option?: number | string; note?: string; done?: boolean; attachments?: string[] },
623624 ): Promise<{ ask: Ask; news?: IssueNews }> {
624625 return this.#issues("POST", this.agentPath(`answer/${id}`), body);
625626 }
--- a/client/src/issues-wire.ts
+++ b/client/src/issues-wire.ts
@@ -68,6 +68,8 @@
6868 of: string;
6969 kind: "question" | "task";
7070 question: string;
71+ /** Files the question carries; absent when none, and from older servers. */
72+ attachments?: Attachment[];
7173 review: boolean;
7274 due: string | null;
7375 recommendation: { text: string; by: string } | null;
@@ -76,7 +78,7 @@
7678 blocks: number[];
7779 at: number;
7880 /** Its answer; for a withdrawn ask, the asker's note on why, with the asker as `by`. */
79− answer: { by: string; words: string; at: number } | null;
81+ answer: { by: string; words: string; at: number; attachments?: Attachment[] } | null;
8082 /** When waiting first listed it to the one it's asked of; null until then (abso issue 124). */
8183 seen: number | null;
8284 /** "withdrawn" when the asker took it back; absent for an open or answered ask, and from older servers. */
--- a/client/src/issues.ts
+++ b/client/src/issues.ts
@@ -69,7 +69,7 @@
6969 return ` ${String(i.id).padStart(3)} ${i.status.padEnd(11)} ${q(i.title)}${detail.length > 0 ? ` (${detail.join("; ")})` : ""}`;
7070}
7171
72−function askLine(a: Ask & { title?: string | null }): string {
72+function askLine(a: Ask & { title?: string | null }, api?: Pick<Api, "attachmentUrl">): string {
7373 const what = a.review ? "a review" : a.kind === "task" ? "a task" : "a question";
7474 const where = a.issue === null ? "" : ` on issue ${a.issue}${a.title ? ` (${q(a.title)})` : ""}`;
7575 const extra = [
@@ -82,12 +82,13 @@
8282 a.blocks.length > 0 ? `blocks ${a.blocks.join(", ")}` : "",
8383 ].filter((x) => x !== "");
8484 const head = ` ask ${a.id}: ${a.by}, ${shortWhen(a.at)}, asks ${a.of} ${what}${where}${extra.length > 0 ? ` (${extra.join("; ")})` : ""}: ${q(a.question)}`;
85− const lines = [head];
85+ const lines = [head, ...attachmentLines(api, a.attachments, " ")];
8686 if (a.options.length > 0) lines.push(` options: ${a.options.map((o, i) => `${i + 1}. ${q(o)}`).join(", ")}`);
8787 if (a.recommendation) lines.push(` ${a.recommendation.by} recommends: ${q(a.recommendation.text)}`);
8888 if (a.answer && a.outcome === "withdrawn") {
8989 if (a.answer.words !== "") lines.push(` why: ${q(a.answer.words)}`);
90− } else if (a.answer) lines.push(` answer: ${q(a.answer.words)}`);
90+ } else if (a.answer)
91+ lines.push(` answer: ${q(a.answer.words)}`, ...attachmentLines(api, a.answer.attachments, " "));
9192 return lines.join("\n");
9293}
9394
@@ -128,6 +129,20 @@
128129 .filter((v) => v !== "");
129130}
130131
132+/** " with 2 attachments (a…, a…)" after a write that carried some; nothing otherwise. */
133+function withFiles(ids: readonly string[]): string {
134+ return ids.length > 0 ? ` with ${plural(ids.length, "attachment")} (${ids.join(", ")})` : "";
135+}
137+/**
138+ * What to say when a write sent files the server didn't keep: an Issues server from before asks carried
139+ * attachments takes the words and leaves the files out. Nothing to say when it kept them, or none were sent.
140+ */
141+function notKept(sent: readonly string[], kept: readonly string[] | undefined, what: string): string | undefined {
142+ if (sent.length === 0 || (kept !== undefined && sent.every((id) => kept.includes(id)))) return undefined;
143+ return `The Issues server didn't keep the ${sent.length === 1 ? "file" : "files"} on ${what}: it is older than this client. The words went; the ${sent.length === 1 ? "file goes" : "files go"} on a comment instead (abso issue <N> --comment "..." --attach ...).`;
144+}
131146/** The most one attachment may be: the Issues Worker's cap, checked here before sending (abso issue 171). */
132147const ATTACH_MAX = 10 * 1024 * 1024;
133148
@@ -184,8 +199,8 @@
184199}
185200
186201/**
187− * abso issue N --save-attachments <folder>: every attachment on the issue and
188− * its comments, written to that folder as <id>-<name>; an svg's own file
202+ * abso issue N --save-attachments <folder>: every attachment on the issue, its
203+ * comments and its asks and answers, written to that folder as <id>-<name>; an svg's own file
189204 * beside the png drawn from it. Not into the abso folder unless abso leaves
190205 * that place out, or the images would be recorded as edits.
191206 */
@@ -197,9 +212,11 @@
197212 `${dir} is inside this abso folder, so abso would record the images as your edits. Save them outside the folder, or into a folder .absoignore leaves out`,
198213 );
199214 const seen = new Set<string>();
200− const all = [...(page.issue.attachments ?? []), ...page.comments.flatMap((c) => c.attachments ?? [])].filter(
201− (a) => !seen.has(a.id) && seen.add(a.id),
202− );
215+ const all = [
216+ ...(page.issue.attachments ?? []),
217+ ...page.comments.flatMap((c) => c.attachments ?? []),
218+ ...page.asks.flatMap((a) => [...(a.attachments ?? []), ...(a.answer?.attachments ?? [])]),
219+ ].filter((a) => !seen.has(a.id) && seen.add(a.id));
203220 if (all.length === 0)
204221 return {
205222 text: `Issue ${page.issue.id} has no attachments.`,
@@ -247,7 +264,7 @@
247264 ...(i.lines ? [`From ${i.lines.file} lines ${i.lines.from}-${i.lines.to} at version ${i.lines.version}.`] : []),
248265 ...(i.description !== "" ? ["", ...i.description.split("\n").map((l) => ` ${l}`)] : []),
249266 ...attachmentLines(api, i.attachments, " "),
250− ...(p.asks.length > 0 ? ["", "Asks:", ...p.asks.map(askLine)] : []),
267+ ...(p.asks.length > 0 ? ["", "Asks:", ...p.asks.map((a) => askLine(a, api))] : []),
251268 ...(p.comments.length > 0
252269 ? [
253270 "",
@@ -602,6 +619,7 @@
602619 const issue = str(args, "issue");
603620 const blocks = str(args, "blocks");
604621 const options = str(args, "options");
622+ const attachments = await uploadAttachments(api, env.cwd, str(args, "attach"));
605623 const r = await api.ask({
606624 of,
607625 question: words.join(" "),
@@ -618,13 +636,18 @@
618636 .filter((o) => o !== ""),
619637 }
620638 : {}),
639+ ...(attachments.length > 0 ? { attachments } : {}),
621640 });
622− return { text: `Asked ${of} (ask ${r.id}). They hear it; abso waiting shows what's open.`, json: { id: r.id } };
641+ const lost = notKept(attachments, r.attachments, `ask ${r.id}`);
642+ return {
643+ text: `Asked ${of} (ask ${r.id})${withFiles(attachments)}. They hear it; abso waiting shows what's open.${lost ? ` ${lost}` : ""}`,
644+ json: { id: r.id, ...(attachments.length > 0 ? { attachments } : {}), ...(lost ? { notKept: lost } : {}) },
645+ };
623646}
624647
625648/** abso ask --withdraw <ask> [--note "why"]: the asker takes an ask back. It closes like an answer, and the one asked hears it. */
626649async function withdrawAsk(args: Parsed, env: Env, word: string): Promise<Output> {
627− const others = ["issue", "due", "blocks", "options"].filter((f) => str(args, f) !== undefined);
650+ const others = ["issue", "due", "blocks", "options", "attach"].filter((f) => str(args, f) !== undefined);
628651 if (args.positionals.length > 0 || others.length > 0 || bool(args, "review") || bool(args, "task"))
629652 throw new UsageError('abso ask --withdraw <ask> [--note "why"] takes nothing else: it takes back an ask you made');
630653 const id = issueNumber(word, "the ask number");
@@ -682,7 +705,7 @@
682705 ? `Nothing is waiting${of ? ` on ${of}` : ""}.`
683706 : [
684707 `${plural(asks.length, "open ask")}${of ? ` of ${of}` : ""}, soonest due first:`,
685− ...asks.map(askLine),
708+ ...asks.map((a) => askLine(a, api)),
686709 'abso answer <ask> "..." answers one asked of you.',
687710 ].join("\n"),
688711 json: { asks },
@@ -698,11 +721,21 @@
698721 throw new UsageError('abso answer <ask> "<words>" | --option <N> [--note "..."] | --done [--note "..."]');
699722 const { api } = openIssues(env);
700723 const note = str(args, "note");
724+ const attachments = await uploadAttachments(api, env.cwd, str(args, "attach"));
701725 const r = await api.answer(id, {
702726 ...(words.length > 0 ? { words: words.join(" ") } : {}),
703727 ...(option !== undefined ? { option: /^\d+$/.test(option) ? Number(option) - 1 : option } : {}),
704728 ...(done ? { done: true } : {}),
705729 ...(note !== undefined ? { note } : {}),
730+ ...(attachments.length > 0 ? { attachments } : {}),
706731 });
707− return { text: `Answered ask ${id}. ${r.ask.by} hears it.`, json: { ask: r.ask } };
732+ const lost = notKept(
733+ attachments,
734+ r.ask.answer?.attachments?.map((a) => a.id),
735+ `your answer to ask ${id}`,
736+ );
737+ return {
738+ text: `Answered ask ${id}${withFiles(attachments)}. ${r.ask.by} hears it.${lost ? ` ${lost}` : ""}`,
739+ json: { ask: r.ask, ...(lost ? { notKept: lost } : {}) },
740+ };
708741}
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -437,11 +437,12 @@
437437 options: "string",
438438 withdraw: "string",
439439 note: "string",
440+ attach: "string",
440441 },
441442 usage:
442− 'abso ask <who> "<question>" [--issue <N>] [--review | --task] [--due <YYYY-MM-DD>] [--blocks <N,N>] [--options "A|B|C"] | abso ask --withdraw <ask> [--note "why"]',
443+ 'abso ask <who> "<question>" [--issue <N>] [--review | --task] [--due <YYYY-MM-DD>] [--blocks <N,N>] [--options "A|B|C"] [--attach <file,file>] | abso ask --withdraw <ask> [--note "why"]',
443444 about:
444− "Ask an agent, or a person (person:<id>), something; they hear it. On an issue, it holds the issue at Blocked (In review for --review) until answered. --task asks for something done instead of an answer; --options gives the choices; --blocks names the issues waiting on it. --withdraw takes back an ask you made that no longer needs an answer: it leaves their waiting list, stops holding the issue, keeps your --note as why, and they hear it.",
445+ "Ask an agent, or a person (person:<id>), something; they hear it. On an issue, it holds the issue at Blocked (In review for --review) until answered. --task asks for something done instead of an answer; --options gives the choices; --blocks names the issues waiting on it. --attach sends files with the question, as on an issue. --withdraw takes back an ask you made that no longer needs an answer: it leaves their waiting list, stops holding the issue, keeps your --note as why, and they hear it.",
445446 run: runAsk,
446447 },
447448 search: {
@@ -458,11 +459,11 @@
458459 run: runWaiting,
459460 },
460461 answer: {
461− flags: { option: "string", note: "string", done: "boolean" },
462+ flags: { option: "string", note: "string", done: "boolean", attach: "string" },
462463 usage:
463− 'abso answer <ask> "<words>" | abso answer <ask> --option <N> [--note "..."] | abso answer <ask> --done [--note "..."]',
464+ 'abso answer <ask> "<words>" | abso answer <ask> --option <N> [--note "..."] | abso answer <ask> --done [--note "..."], each with [--attach <file,file>]',
464465 about:
465− "Answer an ask of you, in your own words, by picking an option (by number or text), or, for a task, with --done. The asker hears it.",
466+ "Answer an ask of you, in your own words, by picking an option (by number or text), or, for a task, with --done. --attach sends files with the answer. The asker hears it.",
466467 run: runAnswer,
467468 },
468469 unqueue: {
--- a/client/test/attach.test.ts
+++ b/client/test/attach.test.ts
@@ -43,6 +43,32 @@
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!))
@@ -179,6 +205,65 @@
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: {
@@ -238,5 +323,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});