{"version":35,"agent":"pinch","message":"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.","time":1791544592629,"timeIso":"2026-10-09T11:16:32.629Z","changes":7,"change":415,"files":["client/src/api.ts","client/src/issues-wire.ts","client/src/issues.ts","client/src/main.ts","client/test/attach.test.ts"],"draft":null,"diff":[{"path":"client/src/api.ts","added":3,"removed":2,"diff":"--- a/client/src/api.ts\n+++ b/client/src/api.ts\n@@ -613,13 +613,14 @@\n \t\tdue?: string;\n \t\tblocks?: number[];\n \t\toptions?: string[];\n-\t}): Promise<{ id: number; news?: IssueNews }> {\n+\t\tattachments?: string[];\n+\t}): Promise<{ id: number; news?: IssueNews; attachments?: string[] }> {\n \t\treturn this.#issues(\"POST\", this.agentPath(\"ask\"), body);\n \t}\n \n \tanswer(\n \t\tid: number,\n-\t\tbody: { words?: string; option?: number | string; note?: string; done?: boolean },\n+\t\tbody: { words?: string; option?: number | string; note?: string; done?: boolean; attachments?: string[] },\n \t): Promise<{ ask: Ask; news?: IssueNews }> {\n \t\treturn this.#issues(\"POST\", this.agentPath(`answer/${id}`), body);\n \t}"},{"path":"client/src/issues-wire.ts","added":3,"removed":1,"diff":"--- a/client/src/issues-wire.ts\n+++ b/client/src/issues-wire.ts\n@@ -68,6 +68,8 @@\n \tof: string;\n \tkind: \"question\" | \"task\";\n \tquestion: string;\n+\t/** Files the question carries; absent when none, and from older servers. */\n+\tattachments?: Attachment[];\n \treview: boolean;\n \tdue: string | null;\n \trecommendation: { text: string; by: string } | null;\n@@ -76,7 +78,7 @@\n \tblocks: number[];\n \tat: number;\n \t/** Its answer; for a withdrawn ask, the asker's note on why, with the asker as `by`. */\n-\tanswer: { by: string; words: string; at: number } | null;\n+\tanswer: { by: string; words: string; at: number; attachments?: Attachment[] } | null;\n \t/** When waiting first listed it to the one it's asked of; null until then (abso issue 124). */\n \tseen: number | null;\n \t/** \"withdrawn\" when the asker took it back; absent for an open or answered ask, and from older servers. */"},{"path":"client/src/issues.ts","added":46,"removed":13,"diff":"--- a/client/src/issues.ts\n+++ b/client/src/issues.ts\n@@ -69,7 +69,7 @@\n \treturn `  ${String(i.id).padStart(3)}  ${i.status.padEnd(11)}  ${q(i.title)}${detail.length > 0 ? ` (${detail.join(\"; \")})` : \"\"}`;\n }\n \n-function askLine(a: Ask & { title?: string | null }): string {\n+function askLine(a: Ask & { title?: string | null }, api?: Pick<Api, \"attachmentUrl\">): string {\n \tconst what = a.review ? \"a review\" : a.kind === \"task\" ? \"a task\" : \"a question\";\n \tconst where = a.issue === null ? \"\" : ` on issue ${a.issue}${a.title ? ` (${q(a.title)})` : \"\"}`;\n \tconst extra = [\n@@ -82,12 +82,13 @@\n \t\ta.blocks.length > 0 ? `blocks ${a.blocks.join(\", \")}` : \"\",\n \t].filter((x) => x !== \"\");\n \tconst head = `  ask ${a.id}: ${a.by}, ${shortWhen(a.at)}, asks ${a.of} ${what}${where}${extra.length > 0 ? ` (${extra.join(\"; \")})` : \"\"}: ${q(a.question)}`;\n-\tconst lines = [head];\n+\tconst lines = [head, ...attachmentLines(api, a.attachments, \"    \")];\n \tif (a.options.length > 0) lines.push(`    options: ${a.options.map((o, i) => `${i + 1}. ${q(o)}`).join(\", \")}`);\n \tif (a.recommendation) lines.push(`    ${a.recommendation.by} recommends: ${q(a.recommendation.text)}`);\n \tif (a.answer && a.outcome === \"withdrawn\") {\n \t\tif (a.answer.words !== \"\") lines.push(`    why: ${q(a.answer.words)}`);\n-\t} else if (a.answer) lines.push(`    answer: ${q(a.answer.words)}`);\n+\t} else if (a.answer)\n+\t\tlines.push(`    answer: ${q(a.answer.words)}`, ...attachmentLines(api, a.answer.attachments, \"      \"));\n \treturn lines.join(\"\\n\");\n }\n \n@@ -128,6 +129,20 @@\n \t\t\t\t.filter((v) => v !== \"\");\n }\n \n+/** \" with 2 attachments (a…, a…)\" after a write that carried some; nothing otherwise. */\n+function withFiles(ids: readonly string[]): string {\n+\treturn ids.length > 0 ? ` with ${plural(ids.length, \"attachment\")} (${ids.join(\", \")})` : \"\";\n+}\n+\n+/**\n+ * What to say when a write sent files the server didn't keep: an Issues server from before asks carried\n+ * attachments takes the words and leaves the files out. Nothing to say when it kept them, or none were sent.\n+ */\n+function notKept(sent: readonly string[], kept: readonly string[] | undefined, what: string): string | undefined {\n+\tif (sent.length === 0 || (kept !== undefined && sent.every((id) => kept.includes(id)))) return undefined;\n+\treturn `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 ...).`;\n+}\n+\n /** The most one attachment may be: the Issues Worker's cap, checked here before sending (abso issue 171). */\n const ATTACH_MAX = 10 * 1024 * 1024;\n \n@@ -184,8 +199,8 @@\n }\n \n /**\n- * abso issue N --save-attachments <folder>: every attachment on the issue and\n- * its comments, written to that folder as <id>-<name>; an svg's own file\n+ * abso issue N --save-attachments <folder>: every attachment on the issue, its\n+ * comments and its asks and answers, written to that folder as <id>-<name>; an svg's own file\n  * beside the png drawn from it. Not into the abso folder unless abso leaves\n  * that place out, or the images would be recorded as edits.\n  */\n@@ -197,9 +212,11 @@\n \t\t\t`${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`,\n \t\t);\n \tconst seen = new Set<string>();\n-\tconst all = [...(page.issue.attachments ?? []), ...page.comments.flatMap((c) => c.attachments ?? [])].filter(\n-\t\t(a) => !seen.has(a.id) && seen.add(a.id),\n-\t);\n+\tconst all = [\n+\t\t...(page.issue.attachments ?? []),\n+\t\t...page.comments.flatMap((c) => c.attachments ?? []),\n+\t\t...page.asks.flatMap((a) => [...(a.attachments ?? []), ...(a.answer?.attachments ?? [])]),\n+\t].filter((a) => !seen.has(a.id) && seen.add(a.id));\n \tif (all.length === 0)\n \t\treturn {\n \t\t\ttext: `Issue ${page.issue.id} has no attachments.`,\n@@ -247,7 +264,7 @@\n \t\t...(i.lines ? [`From ${i.lines.file} lines ${i.lines.from}-${i.lines.to} at version ${i.lines.version}.`] : []),\n \t\t...(i.description !== \"\" ? [\"\", ...i.description.split(\"\\n\").map((l) => `  ${l}`)] : []),\n \t\t...attachmentLines(api, i.attachments, \"  \"),\n-\t\t...(p.asks.length > 0 ? [\"\", \"Asks:\", ...p.asks.map(askLine)] : []),\n+\t\t...(p.asks.length > 0 ? [\"\", \"Asks:\", ...p.asks.map((a) => askLine(a, api))] : []),\n \t\t...(p.comments.length > 0\n \t\t\t? [\n \t\t\t\t\t\"\",\n@@ -602,6 +619,7 @@\n \tconst issue = str(args, \"issue\");\n \tconst blocks = str(args, \"blocks\");\n \tconst options = str(args, \"options\");\n+\tconst attachments = await uploadAttachments(api, env.cwd, str(args, \"attach\"));\n \tconst r = await api.ask({\n \t\tof,\n \t\tquestion: words.join(\" \"),\n@@ -618,13 +636,18 @@\n \t\t\t\t\t\t.filter((o) => o !== \"\"),\n \t\t\t\t}\n \t\t\t: {}),\n+\t\t...(attachments.length > 0 ? { attachments } : {}),\n \t});\n-\treturn { text: `Asked ${of} (ask ${r.id}). They hear it; abso waiting shows what's open.`, json: { id: r.id } };\n+\tconst lost = notKept(attachments, r.attachments, `ask ${r.id}`);\n+\treturn {\n+\t\ttext: `Asked ${of} (ask ${r.id})${withFiles(attachments)}. They hear it; abso waiting shows what's open.${lost ? ` ${lost}` : \"\"}`,\n+\t\tjson: { id: r.id, ...(attachments.length > 0 ? { attachments } : {}), ...(lost ? { notKept: lost } : {}) },\n+\t};\n }\n \n /** abso ask --withdraw <ask> [--note \"why\"]: the asker takes an ask back. It closes like an answer, and the one asked hears it. */\n async function withdrawAsk(args: Parsed, env: Env, word: string): Promise<Output> {\n-\tconst others = [\"issue\", \"due\", \"blocks\", \"options\"].filter((f) => str(args, f) !== undefined);\n+\tconst others = [\"issue\", \"due\", \"blocks\", \"options\", \"attach\"].filter((f) => str(args, f) !== undefined);\n \tif (args.positionals.length > 0 || others.length > 0 || bool(args, \"review\") || bool(args, \"task\"))\n \t\tthrow new UsageError('abso ask --withdraw <ask> [--note \"why\"] takes nothing else: it takes back an ask you made');\n \tconst id = issueNumber(word, \"the ask number\");\n@@ -682,7 +705,7 @@\n \t\t\t\t? `Nothing is waiting${of ? ` on ${of}` : \"\"}.`\n \t\t\t\t: [\n \t\t\t\t\t\t`${plural(asks.length, \"open ask\")}${of ? ` of ${of}` : \"\"}, soonest due first:`,\n-\t\t\t\t\t\t...asks.map(askLine),\n+\t\t\t\t\t\t...asks.map((a) => askLine(a, api)),\n \t\t\t\t\t\t'abso answer <ask> \"...\" answers one asked of you.',\n \t\t\t\t\t].join(\"\\n\"),\n \t\tjson: { asks },\n@@ -698,11 +721,21 @@\n \t\tthrow new UsageError('abso answer <ask> \"<words>\" | --option <N> [--note \"...\"] | --done [--note \"...\"]');\n \tconst { api } = openIssues(env);\n \tconst note = str(args, \"note\");\n+\tconst attachments = await uploadAttachments(api, env.cwd, str(args, \"attach\"));\n \tconst r = await api.answer(id, {\n \t\t...(words.length > 0 ? { words: words.join(\" \") } : {}),\n \t\t...(option !== undefined ? { option: /^\\d+$/.test(option) ? Number(option) - 1 : option } : {}),\n \t\t...(done ? { done: true } : {}),\n \t\t...(note !== undefined ? { note } : {}),\n+\t\t...(attachments.length > 0 ? { attachments } : {}),\n \t});\n-\treturn { text: `Answered ask ${id}. ${r.ask.by} hears it.`, json: { ask: r.ask } };\n+\tconst lost = notKept(\n+\t\tattachments,\n+\t\tr.ask.answer?.attachments?.map((a) => a.id),\n+\t\t`your answer to ask ${id}`,\n+\t);\n+\treturn {\n+\t\ttext: `Answered ask ${id}${withFiles(attachments)}. ${r.ask.by} hears it.${lost ? ` ${lost}` : \"\"}`,\n+\t\tjson: { ask: r.ask, ...(lost ? { notKept: lost } : {}) },\n+\t};\n }"},{"path":"client/src/main.ts","added":6,"removed":5,"diff":"--- a/client/src/main.ts\n+++ b/client/src/main.ts\n@@ -437,11 +437,12 @@\n \t\t\toptions: \"string\",\n \t\t\twithdraw: \"string\",\n \t\t\tnote: \"string\",\n+\t\t\tattach: \"string\",\n \t\t},\n \t\tusage:\n-\t\t\t'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\"]',\n+\t\t\t'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\"]',\n \t\tabout:\n-\t\t\t\"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.\",\n+\t\t\t\"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.\",\n \t\trun: runAsk,\n \t},\n \tsearch: {\n@@ -458,11 +459,11 @@\n \t\trun: runWaiting,\n \t},\n \tanswer: {\n-\t\tflags: { option: \"string\", note: \"string\", done: \"boolean\" },\n+\t\tflags: { option: \"string\", note: \"string\", done: \"boolean\", attach: \"string\" },\n \t\tusage:\n-\t\t\t'abso answer <ask> \"<words>\" | abso answer <ask> --option <N> [--note \"...\"] | abso answer <ask> --done [--note \"...\"]',\n+\t\t\t'abso answer <ask> \"<words>\" | abso answer <ask> --option <N> [--note \"...\"] | abso answer <ask> --done [--note \"...\"], each with [--attach <file,file>]',\n \t\tabout:\n-\t\t\t\"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.\",\n+\t\t\t\"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.\",\n \t\trun: runAnswer,\n \t},\n \tunqueue: {"},{"path":"client/test/attach.test.ts","added":114,"removed":0,"diff":"--- a/client/test/attach.test.ts\n+++ b/client/test/attach.test.ts\n@@ -43,6 +43,32 @@\n \t\t\t\t});\n \t\t\tif (req.url!.endsWith(\"/issue\")) return json({ id: 7 });\n \t\t\tif (/\\/issue\\/\\d+\\/comment$/.test(req.url!)) return json({ id: 3 });\n+\t\t\t// An older Issues server keeps no files on asks: it answers without them (project \"keepless\").\n+\t\t\tconst older = req.url!.includes(\"/p/keepless/\");\n+\t\t\tif (req.url!.endsWith(\"/ask\")) {\n+\t\t\t\tconst sent = (JSON.parse(body.toString()) as { attachments?: string[] }).attachments;\n+\t\t\t\treturn json({ id: 9, ...(sent && !older ? { attachments: sent } : {}) });\n+\t\t\t}\n+\t\t\tif (/\\/answer\\/\\d+$/.test(req.url!)) {\n+\t\t\t\tconst sent = (JSON.parse(body.toString()) as { attachments?: string[] }).attachments ?? [];\n+\t\t\t\tconst files = older ? [] : sent.map((id) => ({ id, name: \"x\", type: \"image/png\", size: 1 }));\n+\t\t\t\treturn json({ ask: { by: \"bob\", answer: { by: \"ann\", words: \"w\", at: 0, attachments: files } } });\n+\t\t\t}\n+\t\t\t// Issue 9's ask carries a file on its question and one on its answer.\n+\t\t\tif (req.method === \"GET\" && /\\/issue\\/9$/.test(req.url!))\n+\t\t\t\treturn json({\n+\t\t\t\t\tissue: { id: 9 },\n+\t\t\t\t\tcomments: [],\n+\t\t\t\t\tedits: [],\n+\t\t\t\t\tasks: [\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tattachments: [{ id: \"a00000000000d\", name: \"question.png\", type: \"image/png\", size: 13 }],\n+\t\t\t\t\t\t\tanswer: { attachments: [{ id: \"a00000000000e\", name: \"answer.png\", type: \"image/png\", size: 13 }] },\n+\t\t\t\t\t\t},\n+\t\t\t\t\t],\n+\t\t\t\t\tclaims: [],\n+\t\t\t\t\tchildren: [],\n+\t\t\t\t});\n \t\t\t// Issue 8 carries an svg-drawn image on itself and again on a comment, plus one more on the comment.\n \t\t\tconst logo = { id: \"a00000000000b\", name: \"../shot one.png\", type: \"image/png\", size: 13 };\n \t\t\tif (req.method === \"GET\" && /\\/issue\\/8$/.test(req.url!))\n@@ -179,6 +205,65 @@\n \t\tassert.match(mixed.out, /--save-attachments goes alone/);\n \t});\n \n+\tit(\"goes on an ask and on an answer, and not on a withdrawal\", async () => {\n+\t\tconst dir = await folder();\n+\t\tlet from = seen.length;\n+\t\tconst asked = await avcs(dir, [\n+\t\t\t\"ask\",\n+\t\t\t\"bob\",\n+\t\t\t\"Which looks right?\",\n+\t\t\t\"--issue\",\n+\t\t\t\"7\",\n+\t\t\t\"--attach\",\n+\t\t\t\"shot.png,after.png\",\n+\t\t]);\n+\t\tassert.equal(asked.exit, 0, asked.out);\n+\t\tassert.deepEqual(\n+\t\t\tseen.slice(from).map((c) => `${c.method} ${c.url.replace(/^\\/p\\/[^/]+/, \"\")}`),\n+\t\t\t[\"POST /a/ann/attachments\", \"POST /a/ann/attachments\", \"POST /a/ann/ask\"],\n+\t\t);\n+\t\tconst ask = JSON.parse(seen.at(-1)!.body.toString()) as { question: string; attachments: string[] };\n+\t\tassert.equal(ask.question, \"Which looks right?\");\n+\t\tassert.equal(ask.attachments.length, 2);\n+\t\tassert.deepEqual((asked.json as { attachments: string[] }).attachments, ask.attachments);\n+\t\tfrom = seen.length;\n+\t\tconst answered = await avcs(dir, [\"answer\", \"9\", \"This one\", \"--attach\", \"after.png\"]);\n+\t\tassert.equal(answered.exit, 0, answered.out);\n+\t\tconst answer = JSON.parse(seen.at(-1)!.body.toString()) as { words: string; attachments: string[] };\n+\t\tassert.equal(answer.words, \"This one\");\n+\t\tassert.equal(answer.attachments.length, 1);\n+\t\tassert.equal(seen.length - from, 2);\n+\t\tfrom = seen.length;\n+\t\tconst withdrawn = await avcs(dir, [\"ask\", \"--withdraw\", \"9\", \"--attach\", \"shot.png\"]);\n+\t\tassert.equal(withdrawn.exit, 1);\n+\t\tassert.equal(seen.length, from, \"nothing was sent\");\n+\t});\n+\n+\tit(\"says so when an older Issues server keeps an ask's words but not its files\", async () => {\n+\t\tconst dir = mkdtempSync(join(tmpdir(), \"abso-attach-\"));\n+\t\tdirs.push(dir);\n+\t\tconst init = await avcs(dir, [\"init\", \"--server\", fake.url, \"--project\", \"keepless\", \"--agent\", \"ann\"]);\n+\t\tassert.equal(init.exit, 0, init.out);\n+\t\twriteFileSync(join(dir, \"shot.png\"), Buffer.from([0x89, 0x50, 0x4e, 0x47, 1]));\n+\t\tconst asked = await avcs(dir, [\"ask\", \"bob\", \"Which?\", \"--attach\", \"shot.png\"]);\n+\t\tassert.equal(asked.exit, 0, asked.out);\n+\t\tassert.match(asked.out, /didn't keep the file on ask 9: it is older than this client/);\n+\t\tconst answered = await avcs(dir, [\"answer\", \"9\", \"This\", \"--attach\", \"shot.png\"]);\n+\t\tassert.match(answered.out, /didn't keep the file on your answer to ask 9/);\n+\t\t// A server that keeps them says nothing of the kind.\n+\t\tconst kept = await avcs(await folder(), [\"ask\", \"bob\", \"Which?\", \"--attach\", \"shot.png\"]);\n+\t\tassert.doesNotMatch(kept.out, /didn't keep/);\n+\t});\n+\n+\tit(\"--save-attachments takes the files on an issue's asks and answers too\", async () => {\n+\t\tconst dir = await folder();\n+\t\tconst out = mkdtempSync(join(tmpdir(), \"abso-saved-\"));\n+\t\tdirs.push(out);\n+\t\tconst r = await avcs(dir, [\"issue\", \"9\", \"--save-attachments\", out]);\n+\t\tassert.equal(r.exit, 0, r.out);\n+\t\tassert.deepEqual(readdirSync(out).sort(), [\"a00000000000d-question.png\", \"a00000000000e-answer.png\"]);\n+\t});\n+\n \tit(\"an issue's page lists its attachments and each comment's, with links\", () => {\n \t\tconst page = {\n \t\t\tissue: {\n@@ -238,5 +323,34 @@\n \t\t\ttext,\n \t\t\t/\\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/,\n \t\t);\n+\t\t// An ask lists its question's files under it, and its answer's under the answer.\n+\t\tconst file = (id: string, name: string) => ({ id, name, type: \"image/png\", size: 1024 });\n+\t\tconst asked = {\n+\t\t\t...page,\n+\t\t\tasks: [\n+\t\t\t\t{\n+\t\t\t\t\tid: 4,\n+\t\t\t\t\tissue: 7,\n+\t\t\t\t\tby: \"ann\",\n+\t\t\t\t\tof: \"bob\",\n+\t\t\t\t\tkind: \"question\",\n+\t\t\t\t\tquestion: \"Which?\",\n+\t\t\t\t\tattachments: [file(\"a00000000000d\", \"a.png\")],\n+\t\t\t\t\treview: false,\n+\t\t\t\t\tdue: null,\n+\t\t\t\t\trecommendation: null,\n+\t\t\t\t\toptions: [],\n+\t\t\t\t\tblocks: [],\n+\t\t\t\t\tat: 0,\n+\t\t\t\t\tanswer: { by: \"bob\", words: \"This\", at: 0, attachments: [file(\"a00000000000e\", \"b.png\")] },\n+\t\t\t\t\tseen: null,\n+\t\t\t\t},\n+\t\t\t],\n+\t\t} as unknown as IssuePage;\n+\t\tconst asks = issuePage(asked, { attachmentUrl: (id: string) => `https://i.example/${id}` }).join(\"\\n\");\n+\t\tassert.match(\n+\t\t\tasks,\n+\t\t\t/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/,\n+\t\t);\n \t});\n });"}],"ci":null}