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 96 --json
JSON
/christopher/abso-core/versions/96?format=json

Issue comments over 4000 characters go up in parts: abso issue N --comment (or --comment-file) splits at paragraph breaks, else line breaks or spaces, marks each part (1/3), (2/3)..., never ends a part inside a code block it doesn't close, and puts attachments on the first part. An objection over the limit is refused before anything is sent. The help names the limit.

of shared·pinch··Not checked

Version 95 · Files at version 96

3 files, 140 lines added, 4 removed.

--- a/client/src/issues.ts
+++ b/client/src/issues.ts
@@ -604,11 +604,27 @@
604604 if (str(args, "attach") !== undefined && comment === undefined && object === undefined)
605605 throw new UsageError("--attach goes with abso issue new or --comment (or --object)");
606606 if (comment !== undefined || object !== undefined) {
607+ // Refused before anything goes up: an objection is one comment, and a part of one would read as a whole.
608+ if (object !== undefined && object.length > COMMENT_MAX)
609+ throw new UsageError(
610+ `an objection holds up to ${COMMENT_MAX} characters, and this one has ${object.length}: say it shorter, and put the rest in a --comment`,
611+ );
612+ const parts = object !== undefined ? [object] : commentParts(comment!);
607613 const attachments = await uploadAttachments(api, env.cwd, str(args, "attach"));
608− const r = await api.issueComment(id, (comment ?? object)!, object !== undefined, attachments);
614+ const ids: number[] = [];
615+ for (const [i, part] of parts.entries()) {
616+ // The attachments go on the first part, which the rest follow.
617+ ids.push((await api.issueComment(id, part, object !== undefined, i === 0 ? attachments : [])).id);
618+ }
619+ const inParts = parts.length > 1 ? ` in ${parts.length} parts (comments ${ids.join(", ")})` : "";
609620 return {
610− text: `${object !== undefined ? "Objected" : "Commented"} on issue ${id}${attachments.length > 0 ? ` with ${plural(attachments.length, "attachment")} (${attachments.join(", ")})` : ""}. Its agents hear it.`,
611− json: { id: r.id, issue: id, ...(attachments.length > 0 ? { attachments } : {}) },
621+ text: `${object !== undefined ? "Objected" : "Commented"} on issue ${id}${inParts}${attachments.length > 0 ? ` with ${plural(attachments.length, "attachment")} (${attachments.join(", ")})` : ""}. Its agents hear it.`,
622+ json: {
623+ id: ids[0],
624+ issue: id,
625+ ...(parts.length > 1 ? { parts: ids } : {}),
626+ ...(attachments.length > 0 ? { attachments } : {}),
627+ },
612628 };
613629 }
614630 if (bool(args, "drop")) {
@@ -877,3 +893,66 @@
877893 json: { ask: r.ask, ...(lost ? { notKept: lost } : {}) },
878894 };
879895}
897+/** What the Issues Worker takes in one comment (its LIMITS.text). */
898+export const COMMENT_MAX = 4000;
900+/** Room a part keeps for its "(i/n)" line and blank line, and for closing a code block it ends inside. */
901+const PART_MARK = 12;
902+const FENCE_CLOSE = 5;
904+/**
905+ * A comment too long for one, as parts that each fit, each starting with "(i/n)". A part ends at the last
906+ * paragraph break that fits, else the last line break, else the last space, else at the limit. A part that
907+ * would end inside a fenced code block closes it, and the next part opens it again with the same fence line.
908+ */
909+export function commentParts(text: string, max = COMMENT_MAX): string[] {
910+ if (text.length <= max) return [text];
911+ const bodies: string[] = [];
912+ let rest = text;
913+ let reopen = "";
914+ while (rest !== "") {
915+ const room = max - PART_MARK - FENCE_CLOSE - reopen.length;
916+ let body: string;
917+ if (reopen.length + rest.length <= max - PART_MARK) {
918+ body = rest;
919+ rest = "";
920+ } else {
921+ const cut = cutAt(rest, room);
922+ body = rest.slice(0, cut).trimEnd();
923+ // A space cut at goes with neither part; the line breaks between paragraphs go too.
924+ rest = rest.slice(rest[cut] === " " ? cut + 1 : cut).replace(/^\n+/, "");
925+ if (rest.trim() === "") rest = "";
926+ }
927+ let part = reopen + body;
928+ const fence = openFence(part);
929+ if (fence && rest !== "") {
930+ part += `\n${fence.marker}`;
931+ reopen = `${fence.line}\n`;
932+ } else reopen = "";
933+ bodies.push(part);
934+ }
935+ return bodies.map((b, i) => `(${i + 1}/${bodies.length})\n\n${b}`);
936+}
938+/** Where to end a part of at most `room` characters of `text`: a paragraph break, a line break, a space, or the limit. */
939+function cutAt(text: string, room: number): number {
940+ const head = text.slice(0, room);
941+ const floor = room / 4;
942+ for (const at of [head.lastIndexOf("\n\n"), head.lastIndexOf("\n"), head.lastIndexOf(" ")]) if (at > floor) return at;
943+ // Not between the two halves of a character outside the Basic Multilingual Plane.
944+ const code = text.charCodeAt(room - 1);
945+ return code >= 0xd800 && code <= 0xdbff ? room - 1 : room;
946+}
948+/** The fence line of a code block still open at the end of `text`, and the marker that closes it, or undefined. */
949+function openFence(text: string): { line: string; marker: string } | undefined {
950+ let open: { line: string; marker: string } | undefined;
951+ for (const line of text.split("\n")) {
952+ const m = /^\s*(`{3,}|~{3,})/.exec(line);
953+ if (!m) continue;
954+ if (!open) open = { line, marker: m[1]! };
955+ else if (m[1]!.startsWith(open.marker) && line.trim() === m[1]) open = undefined;
956+ }
957+ return open;
958+}
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -457,7 +457,7 @@
457457 usage:
458458 'abso issue <N> --save-attachments <folder> | abso issue <N> --copy-to <project> [--clean <file>] [--dry-run] | abso issue <N> [--comment "..." [--attach <file,file>] | --object "..." | --drop | --reopen | --done [--done-by <version>]] | abso issue <N> [--title "..."] [--description "..."] [--parent <N|none>] [--agent <agent|none>] [--blocked-by <N,N|none>] [--label <l,l>] [--unlabel <l,l>] [--notify <who,who> | --quiet] | abso issue new "<title>" [--description "..."] [--parent <N>] [--lines <file>:<from>-<to>@<version>] [--agent <agent>] [--blocked-by <N,N>] [--notify <who,who>] [--label <l,l>] [--attach <file,file>]',
459459 about:
460− "One issue: its description, Agent, Blocked by, labels, asks, comments, edits, sub-issues and watchers. --comment comments on it and --object objects; its agents hear either. --drop drops it. --reopen opens a dropped issue again. --done marks it done by hand, and --done-by <version> names the published version that did it. publish --done still marks it done too. --title, --description, --parent, --agent and --blocked-by edit it, and the edit tells its watchers (who opened it, its Agent and agents, its Reviewer, whoever was named in Notify, and whoever commented); --notify tells more people, --quiet tells nobody. --label adds labels and --unlabel takes them off (friction, area:client: lower-case letters, digits and - _ . :); a label-only edit tells nobody unless --notify names people. An issue is Blocked until each issue it's blocked by is Done. abso issue new opens one; --lines ties it to lines at a version of shared, --agent says who it's for, --notify tells people now, and --label labels it. --attach shot.png,after.png puts images on a new issue or a comment (png, jpeg, gif or webp, 10 MB each; the server checks the type by the bytes and takes out metadata such as where a photo was taken. An svg, up to 1 MB, is drawn as a png, and its own file is kept as a download, on servers that take svg), and prints each one's id for the text to point at; the issue's page lists them with a link, and --save-attachments <folder> saves every one on the issue and its comments there as <id>-<name> (an svg's own file too), outside the abso folder or where abso leaves files out. --copy-to <project> copies the issue into another project, with its comments, answered asks and labels, each keeping its author and time; --dry-run shows what would go and writes nothing, and --clean <file> gives cleaned texts by source id as JSON ({title, description, comments: [{id, text}], asks: [{id, question, answer}]}; a comment left out of a given list isn't copied). Copying out of a project on a live server takes an owner of that project. abso issue draft \"<title>\" [the same fields] saves a draft instead: yours alone, with no number and no news; abso issue draft <D> [fields] changes it, --open opens it as an issue, --delete deletes it.",
460+ "One issue: its description, Agent, Blocked by, labels, asks, comments, edits, sub-issues and watchers. --comment comments on it and --object objects; its agents hear either. A comment holds up to 4000 characters: a longer --comment (or --comment-file) goes up in parts, split at paragraph breaks and each starting (1/3), (2/3) and so on, and a longer --object is refused before anything is sent. --drop drops it. --reopen opens a dropped issue again. --done marks it done by hand, and --done-by <version> names the published version that did it. publish --done still marks it done too. --title, --description, --parent, --agent and --blocked-by edit it, and the edit tells its watchers (who opened it, its Agent and agents, its Reviewer, whoever was named in Notify, and whoever commented); --notify tells more people, --quiet tells nobody. --label adds labels and --unlabel takes them off (friction, area:client: lower-case letters, digits and - _ . :); a label-only edit tells nobody unless --notify names people. An issue is Blocked until each issue it's blocked by is Done. abso issue new opens one; --lines ties it to lines at a version of shared, --agent says who it's for, --notify tells people now, and --label labels it. --attach shot.png,after.png puts images on a new issue or a comment (png, jpeg, gif or webp, 10 MB each; the server checks the type by the bytes and takes out metadata such as where a photo was taken. An svg, up to 1 MB, is drawn as a png, and its own file is kept as a download, on servers that take svg), and prints each one's id for the text to point at; the issue's page lists them with a link, and --save-attachments <folder> saves every one on the issue and its comments there as <id>-<name> (an svg's own file too), outside the abso folder or where abso leaves files out. --copy-to <project> copies the issue into another project, with its comments, answered asks and labels, each keeping its author and time; --dry-run shows what would go and writes nothing, and --clean <file> gives cleaned texts by source id as JSON ({title, description, comments: [{id, text}], asks: [{id, question, answer}]}; a comment left out of a given list isn't copied). Copying out of a project on a live server takes an owner of that project. abso issue draft \"<title>\" [the same fields] saves a draft instead: yours alone, with no number and no news; abso issue draft <D> [fields] changes it, --open opens it as an issue, --delete deletes it.",
461461 run: runIssue,
462462 },
463463 ask: {
--- /dev/null
+++ b/client/test/comment-parts.test.ts
@@ -0,0 +1,57 @@
1+// A comment too long for the Issues Worker goes up in parts (abso issue 394): each fits, each says which part it
2+// is, and none ends inside a code block it doesn't close.
3+
4+import assert from "node:assert/strict";
5+import { test } from "node:test";
6+import { COMMENT_MAX, commentParts } from "../src/issues.ts";
7+
8+const paragraph = (n: number) => `Paragraph ${n}. ${"words go here ".repeat(40).trim()}`;
9+
10+test("a comment that fits goes up as it is, with no part marks", () => {
11+ const text = "x".repeat(COMMENT_MAX);
12+ assert.deepEqual(commentParts(text), [text]);
13+});
15+test("a longer one is cut at paragraph breaks, each part fits and says which it is, and nothing is lost", () => {
16+ const text = Array.from({ length: 20 }, (_, i) => paragraph(i + 1)).join("\n\n");
17+ const parts = commentParts(text);
18+ assert.ok(parts.length >= 2);
19+ for (const [i, p] of parts.entries()) {
20+ assert.ok(p.length <= COMMENT_MAX, `part ${i + 1} has ${p.length}`);
21+ assert.ok(p.startsWith(`(${i + 1}/${parts.length})\n\n`));
22+ // Each part after its mark starts a paragraph.
23+ assert.match(p.split("\n\n")[1]!, /^Paragraph \d+\./);
24+ }
25+ const rejoined = parts.map((p) => p.replace(/^\(\d+\/\d+\)\n\n/, "")).join("\n\n");
26+ assert.equal(rejoined, text);
27+});
29+test("text with no breaks is cut at spaces, and text with no spaces at the limit", () => {
30+ for (const text of ["word ".repeat(2000).trim(), "y".repeat(9000)]) {
31+ const parts = commentParts(text);
32+ for (const p of parts) assert.ok(p.length <= COMMENT_MAX);
33+ const body = parts.map((p) => p.replace(/^\(\d+\/\d+\)\n\n/, ""));
34+ assert.equal(body.join(text.includes(" ") ? " " : ""), text);
35+ }
36+});
38+test("a part that would end inside a code block closes it, and the next part opens it again", () => {
39+ const code = Array.from({ length: 400 }, (_, i) => `const line${i} = ${i};`).join("\n");
40+ const text = `Before.\n\n\`\`\`ts\n${code}\n\`\`\`\n\nAfter.`;
41+ const parts = commentParts(text);
42+ assert.ok(parts.length >= 2);
43+ for (const p of parts) {
44+ assert.ok(p.length <= COMMENT_MAX);
45+ const fences = p.split("\n").filter((l) => l.startsWith("```")).length;
46+ assert.equal(fences % 2, 0, `a part leaves a code block open:\n${p.slice(-80)}`);
47+ }
48+ assert.match(parts[1]!, /^\(2\/\d+\)\n\n```ts\n/);
49+});
51+test("a character outside the Basic Multilingual Plane is never split in two", () => {
52+ const text = "😀".repeat(3000);
53+ for (const p of commentParts(text)) {
54+ assert.ok(p.length <= COMMENT_MAX);
55+ assert.doesNotMatch(p, /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/);
56+ }
57+});