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 95 to 96

Compare

+82 −3 in 2 places
Lines 604–630 at 96 (were 604–614 at 95)
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")) {
Lines 893–958 at 96 (were 877–879 at 95)
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+}
MCP
compare on this site's /mcp
CLI
abso diff 95 96 client/src/issues.ts --json
JSON
/christopher/abso-core/compare/95..96?file=client%2Fsrc%2Fissues.ts&format=json