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
blame on this site's /mcp
CLI
abso blame client/src/queue.ts --version 76 --json
JSON
/christopher/abso-core/blame/client/src/queue.ts?version=76&format=json
179 linesFirst import 88% · pinch 9% · infra-split 1% · review 1%Last change infra-split in version 39,

179 lines from 5 changes in 5 versions.

review28Client: abso.json is the project file (avcs.json still read; a new project gets abso.json unless it has either); new folders get .abso when no installed mod is older than 0.2.0; both mods are 0.2.0 (abso 253, 224)Compare1// The merge queue on the client (#39): with "queue": true in abso.json, a
init0Start the project2// publish to shared waits in the queue until a batch with it passes the
3// project's check, and lands, or is pulled with the check's output. publish
4// waits for that, up to a cap under the chat's 2-minute command limit; status
5// shows the queue; abso unqueue takes a queued publish back.
6
7import { type Api, newsLines, type QueueItem, type QueueState } from "./api.ts";
8import { type Parsed, UsageError } from "./args.ts";
9import { type Env, type Output, open, plural } from "./commands.ts";
10import { logNews } from "./folder.ts";
infra-split39More comments and test names give their reason without naming who raised it The same cleanup as version 37, for notes it missed because they were wrapped or worded differently: "(#37, Playtester 1)" becomes "(#37)", "(#39, agreed with Engine)" becomes "(#39)", and a commit hash after a name goes with the name. Issue numbers stay. No behavior changes.Compare12/** How long publish waits by default: under the 2 minutes a Claude Code shell command gets (#39). */
init0Start the project13export const WAIT_SECONDS = 100;
15/** Exit code for a publish still in the queue when the wait ends (#39). */
16export const STILL_QUEUED = 3;
18export type QueueOutcome =
19 | { readonly kind: "landed"; readonly version: number; readonly news: string[] }
20 | { readonly kind: "pulled"; readonly text: string; readonly news: string[] }
21 /** Out of the queue, but neither the last round nor the news says how (another round ran since, or the news was taken). */
22 | { readonly kind: "gone"; readonly news: string[] }
23 | { readonly kind: "waiting"; readonly state: QueueState | undefined };
25/** Where a queued publish stands: being checked, or how many wait ahead of it. */
26export function standing(items: readonly QueueItem[], id: number): string {
27 const at = items.findIndex((q) => q.id === id);
28 if (at < 0) return "out of the queue";
29 if (items[at]!.checking) {
30 const batch = items.filter((q) => q.checking).length;
31 return batch === 1 ? "being checked" : `being checked in a batch of ${batch}`;
32 }
33 return at === 0 ? "next to be checked" : `waiting, ${at} ${at === 1 ? "publish" : "publishes"} ahead of it`;
36/**
37 * Wait for queued publish `id` to land or be pulled, polling the queue every
38 * `pollMs` until `waitMs` has passed. A failed poll isn't a failed publish:
39 * it tries again until the time is up. The outcome comes from the last
40 * round, else from the news that says it (which is taken, so it's handed back
41 * to print).
42 */
43export async function waitForQueued(
44 api: Api,
45 id: number,
46 waitMs: number,
47 say: (line: string) => void,
48 pollMs = 3000,
49): Promise<QueueOutcome> {
50 const until = Date.now() + waitMs;
51 let state: QueueState | undefined;
52 let said = "";
53 while (Date.now() < until) {
54 await new Promise((ok) => setTimeout(ok, Math.min(pollMs, Math.max(0, until - Date.now()))));
55 try {
56 state = await api.queueState();
57 } catch {
58 continue;
59 }
60 if (!state.items.some((q) => q.id === id)) return outcomeOf(api, id, state);
61 const now = state.paused
62 ? `the queue is paused: ${state.paused.reason}; next try ${state.paused.nextTry.slice(11, 16)} UTC`
63 : standing(state.items, id);
review16The client says abso, not avcs, in everything a person reads: the hints after an issue view and abso issue new, the help for issue, issues, ask, answer and waiting, the 'abso:' prefix on notices from run, publish --check, the queue and serve, the 'News from abso' header, the MCP server's name and the claude mcp add example, and the view mod's status line. Only printed words changed: file and folder names (avcs.json, .avcs/, ~/.avcs/token), environment variables and wire headers are as they were, and the tests were updated to the new words (704 pass, biome ci clean).Compare64 if (now !== said) say(`abso: your publish is ${now}.\n`);
init0Start the project65 said = now;
66 }
67 return { kind: "waiting", state };
70async function outcomeOf(api: Api, id: number, state: QueueState): Promise<QueueOutcome> {
71 const all = await api.news().then(
72 (a) => newsLines(a.news),
73 () => [] as string[],
74 );
75 // The news names the outcome; one publish per agent is the usual case, so the newest such line is ours.
76 // publish says the outcome itself, so that line isn't printed again as news.
77 const said = [...all]
78 .reverse()
79 .find((n) => /^Your queued publish ".*" (landed as version \d+|was pulled: )/s.test(n));
80 const news = all.filter((n) => n !== said);
81 const last = state.last;
82 const landed =
83 last && (last.kind === "landed" || last.kind === "pulled") ? last.versions.find((v) => v.id === id) : undefined;
84 if (landed) return { kind: "landed", version: landed.version, news };
85 const version = said === undefined ? undefined : /landed as version (\d+)\.$/.exec(said)?.[1];
86 if (version !== undefined) return { kind: "landed", version: Number(version), news };
87 if (said !== undefined) return { kind: "pulled", text: said, news };
88 if (last?.kind === "pulled" && last.pulled.includes(id))
89 return {
90 kind: "pulled",
91 text: `Your queued publish was pulled: the project's check failed on it.${last.output ? `\n${last.output.trimEnd()}` : ""}`,
92 news,
93 };
94 return { kind: "gone", news };
97/**
infra-split39More comments and test names give their reason without naming who raised it The same cleanup as version 37, for notes it missed because they were wrapped or worded differently: "(#37, Playtester 1)" becomes "(#37)", "(#39, agreed with Engine)" becomes "(#39)", and a commit hash after a name goes with the name. Issue numbers stay. No behavior changes.Compare98 * A pull, said for the publisher (#39): the check's output
init0Start the project99 * first, then the verdict as the last line, since that's the line an agent
100 * acts on. The engine's news has the output in the middle of its sentence.
101 */
102export function pulledText(news: string): string {
103 const m =
104 /^Your queued publish (".*") was pulled: ([^\n]*?)(?::\n([\s\S]*?))?\.? Its changes are still in your draft\.$/s.exec(
105 news.replace(/\n\. Its changes/, ". Its changes"),
106 );
107 if (!m) return `${news}\nNot published. Fix it, then publish again.`;
108 const output = m[3]?.trimEnd() ?? "";
109 return [
110 ...(output === "" ? [] : ["The check's output ends:", output]),
111 `Not published: your queued publish ${m[1]} was pulled: ${m[2]!.replace(/\.$/, "")}. Its changes are still in your draft; fix them, then publish again.`,
112 ].join("\n");
115/** The lines status shows about the queue: who waits, what is being checked, a pause. Nothing while it's empty. */
116export function queueText(queue: QueueState | null | undefined, me: string): string[] {
117 if (!queue) return [];
118 const lines: string[] = [];
119 if (queue.items.length > 0) {
120 const checking = queue.items.filter((q) => q.checking);
121 const waiting = queue.items.filter((q) => !q.checking);
122 const who = (q: QueueItem) => `${q.agent === me ? `yours (${q.id})` : q.agent}`;
123 lines.push(
124 `Merge queue: ${[
125 checking.length > 0
126 ? `checking ${checking.length === 1 ? who(checking[0]!) : `a batch of ${checking.length} (${checking.map(who).join(", ")})`}`
127 : "",
128 waiting.length > 0 ? `waiting: ${waiting.map(who).join(", ")}` : "",
129 ]
130 .filter((p) => p !== "")
131 .join("; ")}.`,
132 );
133 }
134 if (queue.paused)
135 lines.push(
136 `The merge queue is paused since ${queue.paused.since.slice(11, 16)} UTC: ${queue.paused.reason}; next try ${queue.paused.nextTry.slice(11, 16)} UTC.`,
137 );
138 return lines;
pinch36waiting --mine lists your publishes still in the merge queue: where each stands (being checked, or how many wait ahead of it), whether the queue is paused, and that the outcome comes as news; --json carries them as queued. A server without a queue, or one that can't be read, leaves them out rather than failing the asks.Compare141/**
142 * What abso waiting --mine says about this agent's own publishes in the merge queue: where each stands, whether
143 * the queue is paused, and how the outcome comes. Nothing when none of theirs waits.
144 */
145export function queuedLines(queue: QueueState | null | undefined, me: string): string[] {
146 const items = queue?.items ?? [];
147 const mine = items.filter((q) => q.agent === me);
148 if (mine.length === 0) return [];
149 return [
150 ...mine.map(
151 (q) => `Your publish ${q.id} (${JSON.stringify(q.message)}) is in the merge queue: ${standing(items, q.id)}.`,
152 ),
153 ...(queue?.paused ? [`The merge queue is paused: ${queue.paused.reason}.`] : []),
154 `${mine.length === 1 ? "It lands or is pulled" : "Each lands or is pulled"} once the project's check runs on it; the outcome comes as news, and abso unqueue takes ${mine.length === 1 ? "it" : "them"} back.`,
155 ];
init0Start the project158/** abso unqueue: take this agent's queued publishes back; their changes stay in the draft. */
159export async function runUnqueue(args: Parsed, env: Env): Promise<Output> {
160 if (args.positionals.length > 0)
161 throw new UsageError("unqueue takes no arguments: it takes back every publish of yours still in the merge queue");
162 const { root, api } = open(env);
163 const answer = await api.unqueue();
164 // The engine says it as news too ("you withdrew it"); this command's own text says the same, so it isn't printed twice.
165 const news = await api.news().then(
166 (a) => newsLines(a.news),
167 () => [] as string[],
168 );
169 logNews(root, news);
170 const others = news.filter((n) => !/^Your queued publish ".*" was pulled: you withdrew it\./s.test(n));
171 const ids = answer.pulled;
172 return {
173 text: [
174 `Took back ${ids.length === 1 ? `queued publish ${ids[0]}` : `queued publishes ${ids.join(", ")}`}: ${ids.length === 1 ? "its" : "their"} changes are still in your draft, unpublished.`,
175 ...others.map((n) => ` ${n}`),
176 ].join("\n"),
177 json: { pulled: ids, news: others },
178 };