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 71 to 72

Compare

+103 −6 in 9 places
Lines 27–33 at 72 (were 27–32 at 71)
2727import { fromEnv } from "./env-names.ts";
2828import { ignoredHere } from "./fetch.ts";
2929import { loadIgnore, relativeTo } from "./folder.ts";
30+import type { AskReply } from "./issues-wire.ts";
3031import { queuedLines, standing } from "./queue.ts";
3132import { seenText, shortWhen } from "./times.ts";
3233
Lines 71–105 at 72 (were 70–85 at 71)
7071 return ` ${String(i.id).padStart(3)} ${i.status.padEnd(11)} ${q(i.title)}${detail.length > 0 ? ` (${detail.join("; ")})` : ""}`;
7172}
7273
73−function askLine(a: Ask & { title?: string | null }, api?: Pick<Api, "attachmentUrl">): string {
74+/** The first line of a reply, for lists; abso ask <N> shows it whole. */
75+const firstLine = (text: string): string => {
76+ const line = text.split("\n")[0]!;
77+ return line.length < text.length ? `${line} ...` : line;
78+};
80+/** One reply in an ask's thread. */
81+function replyLine(r: AskReply, indent: string, whole: boolean): string {
82+ return `${indent}${r.by}, ${shortWhen(r.at)}${r.question ? ", a question" : ""}: ${q(whole ? r.text : firstLine(r.text))}`;
83+}
85+/**
86+ * An ask: its head line, its files and options, then, in a list, its newest reply, or with `thread`, every
87+ * reply, oldest first; then its answer. Older servers send no thread, only the one asked's acknowledgement.
88+ */
89+function askLine(a: Ask & { title?: string | null }, api?: Pick<Api, "attachmentUrl">, thread = false): string {
7490 const what = a.review ? "a review" : a.kind === "task" ? "a task" : "a question";
7591 const where = a.issue === null ? "" : ` on issue ${a.issue}${a.title ? ` (${q(a.title)})` : ""}`;
92+ const replies = a.replies;
7693 const extra = [
7794 // Who answered, and when, on the ask's own line, so a handled ask can't pass for an open one.
7895 a.answer
7996 ? `${a.outcome === "withdrawn" ? "withdrawn" : "answered"} by ${a.answer.by}, ${shortWhen(a.answer.at)}`
8097 : "",
81− !a.answer && a.ack ? `acknowledged ${shortWhen(a.ack.at)}, not answered yet` : "",
98+ !a.answer && a.ack && replies === undefined ? `acknowledged ${shortWhen(a.ack.at)}, not answered yet` : "",
8299 !a.answer && !a.ack && a.seen !== undefined ? seenText(a.seen) : "",
100+ replies && replies.length > 0 ? (replies.length === 1 ? "1 reply" : `${replies.length} replies`) : "",
101+ // Whose turn it is, when it isn't the one asked's: they asked something back.
102+ !a.answer && a.waitingOn && a.waitingOn !== a.of ? `waiting on ${a.waitingOn}` : "",
83103 a.due ? `due ${a.due}` : "",
84104 a.blocks.length > 0 ? `blocks ${a.blocks.join(", ")}` : "",
85105 ].filter((x) => x !== "");
Lines 107–116 at 72 (were 87–93 at 71)
87107 const lines = [head, ...attachmentLines(api, a.attachments, " ")];
88108 if (a.options.length > 0) lines.push(` options: ${a.options.map((o, i) => `${i + 1}. ${q(o)}`).join(", ")}`);
89109 if (a.recommendation) lines.push(` ${a.recommendation.by} recommends: ${q(a.recommendation.text)}`);
90− if (!a.answer && a.ack && a.ack.note !== "") lines.push(` ${a.of} acknowledged: ${q(a.ack.note)}`);
110+ if (replies === undefined) {
111+ if (!a.answer && a.ack && a.ack.note !== "") lines.push(` ${a.of} acknowledged: ${q(a.ack.note)}`);
112+ } else if (thread) lines.push(...replies.map((r) => replyLine(r, " ", true)));
113+ else if (replies.length > 0) lines.push(replyLine(replies[replies.length - 1]!, " last: ", false));
91114 if (a.answer && a.outcome === "withdrawn") {
92115 if (a.answer.words !== "") lines.push(` why: ${q(a.answer.words)}`);
93116 } else if (a.answer)
Lines 647–653 at 72 (were 624–629 at 71)
624647 if (str(args, "note") !== undefined)
625648 throw new UsageError('--note goes with --withdraw: abso ask --withdraw <ask> --note "why"');
626649 const [of, ...words] = args.positionals;
650+ if (of !== undefined && words.length === 0 && /^\d+$/.test(of)) return showAsk(args, env, of);
627651 if (of === undefined || words.length === 0)
628652 throw new UsageError(
629653 'abso ask <who> "<question>" [--issue <N>] [--review | --task] [--due <YYYY-MM-DD>] [--blocks <N,N>] [--options "A|B|C"]; who is an agent, or person:<id>',
Lines 683–731 at 72 (were 659–664 at 71)
659683 };
660684}
661685
686+/** abso ask <N>: one ask, open or closed, with its whole thread, its answer and whose turn it is. */
687+async function showAsk(args: Parsed, env: Env, word: string): Promise<Output> {
688+ const others = ["issue", "due", "blocks", "options", "attach"].filter((f) => str(args, f) !== undefined);
689+ if (others.length > 0 || bool(args, "review") || bool(args, "task"))
690+ throw new UsageError('abso ask <N> shows ask N; to ask, say who and what: abso ask <who> "<question>"');
691+ const id = issueNumber(word, "the ask number");
692+ const { api, config } = openIssues(env);
693+ const { ask } = await api.askThread(id);
694+ const side = ask.of === config.agent || ask.by === config.agent;
695+ const turn = ask.waitingOn === config.agent ? "you" : ask.waitingOn;
696+ const steps = !side
697+ ? ""
698+ : ask.answer
699+ ? `abso reply ${id} "..." still adds to it.`
700+ : ask.of === config.agent
701+ ? `abso reply ${id} "..." adds to it; abso answer ${id} "..." answers and closes it.`
702+ : `abso reply ${id} "..." adds to it.`;
703+ const next = [!ask.answer && turn ? `It waits on ${turn}.` : "", steps].join(" ");
704+ return {
705+ text: [askLine(ask, api, true), next.trim()].filter((l) => l !== "").join("\n"),
706+ json: { ask },
707+ };
708+}
710+/** abso reply <ask> "<words>" [--question]: add to an ask's thread, as its asker or the one asked. */
711+export async function runReply(args: Parsed, env: Env): Promise<Output> {
712+ const [first, ...words] = args.positionals;
713+ const id = issueNumber(first, "the ask number");
714+ if (words.length === 0)
715+ throw new UsageError(
716+ `abso reply <ask> "<words>" [--question]: adds to an ask's thread, as its asker or the one asked`,
717+ );
718+ const { api, config } = openIssues(env);
719+ const question = bool(args, "question");
720+ const r = await api.reply(id, { text: words.join(" "), ...(question ? { question: true } : {}) });
721+ const other = r.ask.by === config.agent ? r.ask.of : r.ask.by;
722+ const turn =
723+ !r.ask.answer && r.ask.waitingOn
724+ ? ` It waits on ${r.ask.waitingOn === config.agent ? "you" : r.ask.waitingOn}.`
725+ : "";
726+ return { text: `Replied on ask ${id}. ${other} hears it.${turn}`, json: { ask: r.ask } };
727+}
662729/** abso ask --withdraw <ask> [--note "why"]: the asker takes an ask back. It closes like an answer, and the one asked hears it. */
663730async function withdrawAsk(args: Parsed, env: Env, word: string): Promise<Output> {
664731 const others = ["issue", "due", "blocks", "options", "attach"].filter((f) => str(args, f) !== undefined);
Lines 775–782 at 72 (were 708–714 at 71)
708775
709776export async function runWaiting(args: Parsed, env: Env): Promise<Output> {
710777 if (args.positionals.length > 0)
711− throw new UsageError("waiting takes no words: abso waiting [--of <agent or person:id>] [--mine]");
778+ throw new UsageError("waiting takes no words: abso waiting [--of <agent or person:id>] [--mine] [--asked]");
779+ if (bool(args, "asked")) return askedOf(args, env);
712780 const { api, config } = openIssues(env);
713781 const mine = bool(args, "mine") || str(args, "of") === config.agent;
714782 const of = mine ? config.agent : str(args, "of");
Lines 796–802 at 72 (were 728–734 at 71)
728796 : [
729797 `${plural(asks.length, "open ask")}${of ? ` of ${of}` : ""}, soonest due first:`,
730798 ...asks.map((a) => askLine(a, api)),
731− 'abso answer <ask> "..." answers one asked of you.',
799+ 'abso ask <N> shows one with its thread; abso reply <N> "..." adds to it; abso answer <N> "..." answers one asked of you.',
732800 ]),
733801 ].join("\n"),
734802 json: {
Lines 808–842 at 72 (were 740–745 at 71)
740808 };
741809}
742810
811+/** abso waiting --asked: the asks you sent, open ones first, then the latest answered, each with its newest reply. */
812+async function askedOf(args: Parsed, env: Env): Promise<Output> {
813+ if (bool(args, "mine") || str(args, "of") !== undefined)
814+ throw new UsageError("--asked lists the asks you sent; it takes no --mine or --of");
815+ const { api, config } = openIssues(env);
816+ const { asks } = await api.asked();
817+ const open = asks.filter((a) => !a.answer);
818+ const closed = asks.filter((a) => a.answer);
819+ return {
820+ text: [
821+ ...(asks.length === 0
822+ ? [`${config.agent} hasn't asked anything yet.`]
823+ : [
824+ ...(open.length > 0
825+ ? [`${plural(open.length, "open ask")} you sent:`, ...open.map((a) => askLine(a, api))]
826+ : []),
827+ ...(closed.length > 0
828+ ? [
829+ `${closed.length === 1 ? "The latest answered" : `The latest ${closed.length} answered`}:`,
830+ ...closed.map((a) => askLine(a, api)),
831+ ]
832+ : []),
833+ "abso ask <N> shows one with its whole thread.",
834+ ]),
835+ ].join("\n"),
836+ json: { asks },
837+ };
838+}
743840/** abso ack <ask> ["note"]: tell the asker you have it, and answer later. The ask stays open until abso answer. */
744841export async function runAck(args: Parsed, env: Env): Promise<Output> {
745842 const [first, ...words] = args.positionals;
Lines 845–851 at 72 (were 748–754 at 71)
748845 const note = words.join(" ");
749846 const r = await api.ack(id, note !== "" ? { note } : {});
750847 return {
751− text: `Acknowledged ask ${id}. ${r.ask.by} hears it; the ask stays open until abso answer ${id} "...".`,
848+ text: `Acknowledged ask ${id}. ${r.ask.by} hears it; abso reply ${id} "..." adds more as you go, and the ask stays open until abso answer ${id} "...".`,
752849 json: { ask: r.ask },
753850 };
754851}
MCP
compare on this site's /mcp
CLI
abso diff 71 72 client/src/issues.ts --json
JSON
/christopher/abso-core/compare/71..72?file=client%2Fsrc%2Fissues.ts&format=json