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 worker/project/http.ts --version 244 --json
JSON
/christopher/abso-core/blame/worker/project/http.ts?version=244&format=json
631 linesFirst import 94% · engine 3% · candidates 2% · pinch 1% · rename 1% · capacity 1% · Last change capacity in version 243,

631 lines from 8 changes in 8 versions.

init0Start the project1// The JSON routes of the contract (docs/v2-slice1.md), as a pure function of
2// the project calls, so they can be tested in Node without a Worker.
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare3
init0Start the project4import type { EditBody, ProjectCalls, ProjectHistory } from "./project-api.ts";
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare5import { unseenError } from "./unseen.ts";
init0Start the project6
7export interface Answer {
8 status: number;
9 body: unknown;
12const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$/;
14export function validName(name: string | undefined): name is string {
15 return name !== undefined && NAME.test(name);
18/**
19 * The call's answer, or undefined when `ms` passes or the call fails.
20 * The call keeps running either way: this only bounds how long the caller waits.
21 */
22export function within<T>(work: Promise<T>, ms: number): Promise<T | undefined> {
23 return new Promise((resolve) => {
24 const timer = setTimeout(() => resolve(undefined), ms);
25 work.then(
26 (value) => {
27 clearTimeout(timer);
28 resolve(value);
29 },
30 () => {
31 clearTimeout(timer);
32 resolve(undefined);
33 },
34 );
35 });
38const fail = (status: number, error: string): Answer => ({ status, body: { error } });
40/**
41 * Agents that read everything and record nothing (#37, Reporter). Kept by the
42 * caller outside the log: a refused call writes nothing, so replay never
43 * needs it, and an older Worker can still load the log.
44 */
45export interface Readers {
46 has(agent: string): boolean;
47 set(agent: string, reader: boolean): void;
48 list(): string[];
51/**
52 * What a reader may not do. Edits and records (which old edit mods send on
53 * their own) and publishes answer 200 {ok: false, reason}, so a mod only logs
54 * it; the rest are refused outright.
55 */
56const NOT_FOR_READERS: Record<string, "answer" | "refuse"> = {
57 edit: "answer",
58 record: "answer",
59 publish: "answer",
60 land: "answer",
61 pluck: "answer",
62 "draft-sync": "refuse",
63 drop: "refuse",
64 amend: "refuse",
65 label: "refuse",
66 starting: "refuse",
67 move: "refuse",
68};
70/** A path the project won't hold: .avcs/ is each folder's own settings. */
pinch18New folders keep .avcs/ for now; the server keeps both state folders out of a project Version 17 made new folders with .abso/. An edit mod or Cursor hook installed before the rename looks only for .avcs/config.json, so in a .abso/ folder it would stop recording edits, and nothing would say so. Until installs can say which mods know .abso/, a new folder is made with .avcs/ again (NEW_FOLDER_DIR in client/src/state-dir.ts). Reading is unchanged: a folder with .abso/ works exactly as one with .avcs/, and neither is ever half-moved. The user's files still go to ~/.abso/, since an older client that can't find them says so. The server refused only paths under .avcs/, and the test server only .abso/. Both now refuse both, so a folder's state never becomes part of a project, whichever name it has. Tests: new folders get .avcs/; a folder moved to .abso/ records and isn't moved back; the tests that assumed .abso/ for a new folder now use .avcs/.Compare71/** A path under a folder's state folder (.abso/, or .avcs/ from before the rename), which never leaves it. */
init0Start the project72function localPath(paths: string[]): string | undefined {
pinch18New folders keep .avcs/ for now; the server keeps both state folders out of a project Version 17 made new folders with .abso/. An edit mod or Cursor hook installed before the rename looks only for .avcs/config.json, so in a .abso/ folder it would stop recording edits, and nothing would say so. Until installs can say which mods know .abso/, a new folder is made with .avcs/ again (NEW_FOLDER_DIR in client/src/state-dir.ts). Reading is unchanged: a folder with .abso/ works exactly as one with .avcs/, and neither is ever half-moved. The user's files still go to ~/.abso/, since an older client that can't find them says so. The server refused only paths under .avcs/, and the test server only .abso/. Both now refuse both, so a folder's state never becomes part of a project, whichever name it has. Tests: new folders get .avcs/; a folder moved to .abso/ records and isn't moved back; the tests that assumed .abso/ for a new folder now use .avcs/.Compare73 return paths.find((p) => [".abso", ".avcs"].some((d) => p === d || p.startsWith(`${d}/`) || p.startsWith(`./${d}/`)));
init0Start the project74}
pinch18New folders keep .avcs/ for now; the server keeps both state folders out of a project Version 17 made new folders with .abso/. An edit mod or Cursor hook installed before the rename looks only for .avcs/config.json, so in a .abso/ folder it would stop recording edits, and nothing would say so. Until installs can say which mods know .abso/, a new folder is made with .avcs/ again (NEW_FOLDER_DIR in client/src/state-dir.ts). Reading is unchanged: a folder with .abso/ works exactly as one with .avcs/, and neither is ever half-moved. The user's files still go to ~/.abso/, since an older client that can't find them says so. The server refused only paths under .avcs/, and the test server only .abso/. Both now refuse both, so a folder's state never becomes part of a project, whichever name it has. Tests: new folders get .avcs/; a folder moved to .abso/ records and isn't moved back; the tests that assumed .abso/ for a new folder now use .avcs/.Compare75const LOCAL = (p: string) =>
76 fail(400, `${p} is under ${p.replace(/^\.\//, "").split("/")[0]}/, which stays in the agent's folder`);
init0Start the project77
78/**
79 * The reader rules (#37, Reporter), for one agent call: the answer to
80 * `reader {reader}`, or the refusal of something a reader may not do, or
81 * undefined when the call goes ahead. An agent holding unpublished work
82 * can't become a reader.
83 */
84export function readerAnswer(
85 project: { status(): unknown },
86 op: string,
87 agent: string,
88 body: unknown,
89 readers: Readers,
90): Answer | undefined {
91 if (op === "reader") {
92 const on = (body as { reader?: unknown } | undefined)?.reader;
93 if (typeof on !== "boolean") return fail(400, "reader needs {reader: true} or {reader: false}");
94 if (on) {
95 const me = (
96 project.status() as { agents?: { agent: string; draftChanges: number; parked?: unknown[] }[] }
97 ).agents?.find((a) => a.agent === agent);
98 if (me && (me.draftChanges > 0 || (me.parked?.length ?? 0) > 0)) {
99 return fail(
100 409,
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare101 `${agent} has unpushed changes; push or restore them (abso restore --all) before it becomes a reader`,
init0Start the project102 );
103 }
104 }
105 readers.set(agent, on);
106 return { status: 200, body: { agent, reader: on } };
107 }
108 const barred = readers.has(agent) ? NOT_FOR_READERS[op] : undefined;
109 if (!barred) return undefined;
110 const reason = `agent ${agent} is a reader: it records nothing (abso join --reader)`;
111 if (barred === "refuse") return fail(403, reason);
112 return { status: 200, body: { ok: false, reason, ...(op === "edit" || op === "record" ? {} : { collisions: [] }) } };
115/** The status answer with readers marked on their agent entries and listed (#37). */
116export function statusWithReaders(status: unknown, readers: Readers | undefined): unknown {
117 const s = status as { agents?: { agent: string }[] };
118 if (!readers || readers.list().length === 0) return s;
119 return {
120 ...s,
121 agents: (s.agents ?? []).map((a) => (readers.has(a.agent) ? { ...a, reader: true } : a)),
122 readers: readers.list(),
123 };
126/** op is "init", "status", or an agent op ("edit", "record", "publish", "sync"). */
127export function answer(
128 project: ProjectCalls,
129 op: string,
130 agent: string | undefined,
131 body: unknown,
132 readers?: Readers,
133 how?: string,
134): Answer {
135 try {
136 if (op === "init") {
137 const files = (body as { files?: Record<string, string> })?.files;
138 if (!files || typeof files !== "object") return fail(400, "init needs {files: {path: text}}");
139 if (project.exists()) return fail(409, "the project already exists");
140 const bad = localPath(Object.keys(files));
141 if (bad) return LOCAL(bad);
142 const modes = (body as { modes?: unknown })?.modes;
143 if (modes !== undefined && (typeof modes !== "object" || modes === null))
144 return fail(400, "modes must be {path: {exec, link}}");
145 const blobs = (body as { blobs?: unknown })?.blobs;
146 if (blobs !== undefined && (typeof blobs !== "object" || blobs === null))
147 return fail(400, "blobs must be {path: sha256}");
148 if (blobs && localPath(Object.keys(blobs))) return LOCAL(localPath(Object.keys(blobs))!);
149 return {
150 status: 200,
151 body: project.init(
152 files,
153 modes as Record<string, { exec?: boolean; link?: string | null }> | undefined,
154 blobs as Record<string, string> | undefined,
155 ),
156 };
157 }
158 if (!project.exists()) return fail(404, "no such project; run init first");
159 // Readers (#37): marked on their agent entries, and listed even before their first sync.
160 // Reads for the website (#41): ?at=<log position> replays status and where as they stood then.
161 const atOf = (): number | undefined => {
162 const at = (body as { at?: string } | undefined)?.at;
163 return at !== undefined && at !== "" && Number.isInteger(Number(at)) && Number(at) >= 0 ? Number(at) : undefined;
164 };
165 if (op === "status" && agent === undefined) {
166 const at = atOf();
167 const history = project as ProjectCalls & Partial<ProjectHistory>;
168 if (at !== undefined)
169 return history.statusAt
170 ? { status: 200, body: history.statusAt(at) }
171 : fail(501, "status at a log position needs the engine");
172 return { status: 200, body: statusWithReaders(project.status(), readers) };
173 }
174 if (op === "where") {
175 const history = project as ProjectCalls & Partial<ProjectHistory>;
176 if (!history.where) return fail(501, "where needs the engine");
177 const at = atOf();
178 if (at !== undefined)
179 return history.whereAt
180 ? { status: 200, body: history.whereAt(at) }
181 : fail(501, "where at a log position needs the engine");
182 return { status: 200, body: history.where() };
183 }
184 if (op === "changes" || op.startsWith("change/")) {
185 const history = project as ProjectCalls & Partial<ProjectHistory>;
186 if (!history.change || !history.changes) return fail(501, `${op} needs the engine`);
187 const q = (body ?? {}) as Record<string, string | undefined>;
188 if (op !== "changes") return { status: 200, body: history.change(Number(op.slice("change/".length))) };
189 const since = q.since === undefined || q.since === "" ? 0 : Number(q.since);
190 const limit = q.limit === undefined || q.limit === "" ? 50 : Number(q.limit);
191 if (!Number.isInteger(since) || since < 0) return fail(400, "changes needs ?since=<log position>");
192 if (!Number.isInteger(limit) || limit < 1 || limit > 200) return fail(400, "limit is 1-200");
193 const before = q.before === undefined || q.before === "" ? undefined : Number(q.before);
194 if (before !== undefined && (!Number.isInteger(before) || before < 0))
195 return fail(400, "before must be a log position");
196 // ?issue= (#54): the changes whose start note named that issue.
197 if (q.issue !== undefined && q.issue !== "" && !/^[1-9]\d{0,9}$/.test(q.issue))
198 return fail(400, "issue must be an issue number");
199 return { status: 200, body: history.changes(since, limit, before, q.issue ? Number(q.issue) : undefined) };
200 }
201 if (op === "notes") {
202 const history = project as ProjectCalls & Partial<ProjectHistory>;
203 if (!history.notes) return fail(501, "notes needs the engine");
204 const q = (body ?? {}) as Record<string, string | undefined>;
205 if (q.change !== undefined && !/^\d+$/.test(q.change)) return fail(400, "change must be a change id");
206 return {
207 status: 200,
208 body: history.notes({
209 ...(q.file ? { file: q.file } : {}),
210 ...(q.change ? { change: Number(q.change) } : {}),
211 ...(q.open === "1" || q.open === "true" ? { open: true } : {}),
212 }),
213 };
214 }
215 if (op === "position") {
216 const history = project as ProjectCalls & Partial<ProjectHistory>;
217 if (!history.position) return fail(501, "position needs the engine");
218 const q = (body ?? {}) as Record<string, string | undefined>;
219 if (q.version !== undefined && q.version !== "") {
220 if (!/^\d+$/.test(q.version)) return fail(400, "version must be a version number");
221 return { status: 200, body: history.position({ version: Number(q.version) }) };
222 }
223 if (q.time === undefined || q.time === "")
224 return fail(400, "position needs ?time=<ISO time or ms since 1970> or ?version=<n>");
225 const time = /^\d+$/.test(q.time) ? Number(q.time) : Date.parse(q.time);
226 if (!Number.isFinite(time)) return fail(400, "time is an ISO time or ms since 1970");
227 return { status: 200, body: history.position({ time }) };
228 }
229 if (op === "ribbon") {
230 const history = project as ProjectCalls & Partial<ProjectHistory>;
231 if (!history.ribbon) return fail(501, "ribbon needs the engine");
232 return { status: 200, body: history.ribbon() };
233 }
234 if (op === "feed" || op === "drafts" || (op === "diff" && agent === undefined)) {
235 const q = (body ?? {}) as Record<string, string | undefined>;
236 const history = project as ProjectCalls & Partial<ProjectHistory>;
237 if (!history.feed || !history.drafts || !history.diffOf) return fail(501, `${op} needs the engine`);
238 if (op === "drafts") return { status: 200, body: history.drafts() };
239 if (op === "diff") {
240 if (!q.agent) return fail(400, "diff needs ?agent=<name>");
241 return { status: 200, body: history.diffOf(q.agent) };
242 }
243 const from = q.from === undefined || q.from === "" ? 0 : Number(q.from);
244 const limit = q.limit === undefined || q.limit === "" ? 500 : Number(q.limit);
245 if (!Number.isInteger(from) || from < 0) return fail(400, "feed needs ?from=<log position>");
246 if (!Number.isInteger(limit) || limit < 1 || limit > 2000) return fail(400, "limit is 1-2000");
247 return { status: 200, body: history.feed(from, limit) };
248 }
249 if (op === "draft-state") {
250 // A named draft's state in one read (#41, the Drafts page): base, behind, versions, first edit, collisions.
251 const history = project as ProjectCalls & Partial<ProjectHistory>;
252 if (!history.draftState) return fail(501, "draft-state needs the engine");
253 const q = (body ?? {}) as Record<string, string | undefined>;
254 if (!q.name) return fail(400, "draft-state needs ?name=<draft>");
255 return { status: 200, body: history.draftState(q.name) };
256 }
257 if (
258 op === "tree" ||
259 op === "path" ||
260 op === "follow" ||
261 op === "collisions" ||
262 (op === "blame" && (body as { folder?: unknown } | undefined)?.folder !== undefined)
263 ) {
264 // Reads for the Files pages (#41): GETs, the body is the query string.
265 const q = (body ?? {}) as Record<string, string | undefined>;
266 const history = project as ProjectCalls & Partial<ProjectHistory>;
267 if (!history.tree || !history.pathLife || !history.follow || !history.collisions || !history.folderBlame)
268 return fail(501, `${op} needs the engine`);
269 const int = (s: string | undefined): number | undefined | null =>
270 s === undefined || s === "" ? undefined : /^\d+$/.test(s) ? Number(s) : null;
271 const version = int(q.version);
272 if (version === null) return fail(400, "version must be a version number");
273 const draft = q.draft || null;
274 if (op === "blame")
275 return {
276 status: 200,
277 body: history.folderBlame(q.folder ?? "", version, q.draft || undefined, q.agent || undefined),
278 };
279 // agent= (#41, F25): the folder as that agent has it; authors=1 (F33): each entry's authors in the same read.
280 if (op === "tree") {
281 if (q.authors !== undefined && q.authors !== "" && q.authors !== "1")
282 return fail(400, "authors is 1 or left out");
283 return {
284 status: 200,
285 body: history.tree(q.folder ?? "", version, draft, q.agent || undefined, q.authors === "1"),
286 };
287 }
288 if (op === "collisions")
289 return { status: 200, body: history.collisions(q.file || undefined, q.folder || undefined) };
290 if (!q.path) return fail(400, `${op} needs ?path=<path>`);
291 if (op === "path") return { status: 200, body: history.pathLife(q.path, version, draft) };
292 const from = int(q.from);
293 const to = int(q.to) ?? from;
294 const at = int(q.at);
295 if (
296 version === undefined ||
297 from === undefined ||
298 from === null ||
299 to === null ||
300 to === undefined ||
301 at === null
302 )
303 return fail(400, "follow needs ?path=&version=&from=, and ?to= and ?at= if wanted");
304 return { status: 200, body: history.follow(q.path, version, from, to, at, draft) };
305 }
306 if (op === "blame" || op === "why") {
307 // GETs: the body is the query string as {file, from, to, line}.
308 const q = (body ?? {}) as Record<string, string | undefined>;
309 const history = project as ProjectCalls & Partial<ProjectHistory>;
310 if (!q.file) return fail(400, `${op} needs ?file=<path>, or blame ?folder=<path> ("" for the whole project)`);
311 if (!history.blame || !history.why) return fail(501, `${op} needs the engine`);
312 const num = (s: string | undefined) => (s === undefined || s === "" ? undefined : Number(s));
313 const draft = q.draft || undefined;
314 const who = q.agent || undefined;
315 if (op === "blame")
316 return { status: 200, body: history.blame(q.file, num(q.from), num(q.to), num(q.version), draft, who) };
317 const line = num(q.line);
318 if (!line || !Number.isInteger(line)) return fail(400, "why needs ?line=<number>");
whytrail193abso why follows a line back past formatting to its reason, and names git commits why now lists a line's earlier changes, newest first, with what the line read before each. A change that rewrote a line left the line it replaced in the file's history; why pairs the two (same code formatted differently, the same code rewrapped, or the most similar line) and follows the pairs back. A change that only touched formatting (whitespace, line wrapping, quotes, trailing commas, line-end semicolons, parentheses around a lone arrow parameter) is skipped by default, and why names it: 'Skipped 1 formatting change since: version 366'. --all shows those too. --at <version> reads the line as it was at that version. A push imported from git (client/scripts/import-git.ts, or a plain git push) names its commit and author in why and blame. import-git.ts now also records where the repository's issues are, from origin on GitHub or GitLab or --issues, and why says which issue #N in an imported message or line means. A project imported before this can say it once in abso.json: "gitIssues": "https://github.com/owner/repo/issues". Closes issues 20 and 21's tool side.Compare319 return { status: 200, body: history.why(q.file, line, draft, who, num(q.version)) };
init0Start the project320 }
321 if (op === "announce" && agent === undefined) {
322 // The sender comes from the route, like every other agent op, not from
infra-split37Comments and test names give each reason in plain words, without naming who raised it Notes like "(#37, Builder 5)" or "(AVCS - Security)" become "(#37)" or go, and a private commit hash after a name goes with it. Issue numbers and references such as git's CVE-2019-1353 stay. Only comments and test names change; no behavior changes.Compare323 // a body field anyone can fill in (#31).
init0Start the project324 return fail(400, "announce from your own agent: POST /p/:project/a/<you>/announce {text, to?}");
325 }
326 if (op === "files" && agent === undefined) {
327 // GET ?version=&draft=: the paths in shared (or a named draft) at a version.
328 const q = (body ?? {}) as Record<string, string | undefined>;
329 const history = project as ProjectCalls & Partial<ProjectHistory>;
330 // ?agent=: the files as an agent has them (#41, F25), read only, so an unknown agent is 404.
331 if (q.agent !== undefined) {
332 if (!history.pathsOf) return fail(501, "files?agent= needs the engine");
333 return { status: 200, body: history.pathsOf(q.agent) };
334 }
335 if (!history.pathsAt) return fail(501, "files needs the engine");
336 const version = q.version !== undefined && q.version !== "" ? Number(q.version) : undefined;
337 if (version !== undefined && !Number.isInteger(version)) return fail(400, "version must be a number");
338 return { status: 200, body: history.pathsAt(version, q.draft || null) };
339 }
340 if (op === "labels") {
341 const history = project as ProjectCalls & Partial<ProjectHistory>;
342 if (!history.labels) return fail(501, "labels needs the engine");
343 return { status: 200, body: history.labels() };
344 }
345 if (op === "refusals") {
346 // GET ?agent=<name>&limit=<n>: refused publishes and lands, newest first, and counts.
347 const q = (body ?? {}) as Record<string, string | undefined>;
348 const history = project as ProjectCalls & Partial<ProjectHistory>;
349 if (!history.refusals) return fail(501, "refusals needs the engine");
350 const limit = q.limit !== undefined && Number.isInteger(Number(q.limit)) ? Number(q.limit) : undefined;
351 return { status: 200, body: history.refusals(q.agent || undefined, limit) };
352 }
candidates186Read a version of shared without some earlier versions: abso show <N> --without A,B shows what differs and abso export <dir> --version N --without A,B writes the files. The server's GET without?version=&versions= checks the set left exactly as asked: when a version it keeps builds on one left out, it refuses with that chain, the files and the wider set that works, and never widens it. Atoms keep their ids and authors; shared and its log don't change; the same ask gives the same tree hash.Compare353 if (op === "without") {
354 // GET ?version=<n>&versions=<n,n>: version n of shared with those versions left out (without.ts).
355 const q = (body ?? {}) as Record<string, string | undefined>;
356 const history = project as ProjectCalls & Partial<ProjectHistory>;
357 if (!history.without) return fail(501, "without needs the engine");
358 const version = q.version !== undefined && /^\d+$/.test(q.version) ? Number(q.version) : undefined;
359 const versions = (q.versions ?? "").split(",").filter((s) => s.trim() !== "");
360 if (version === undefined || versions.length === 0 || versions.some((s) => !/^\s*\d+\s*$/.test(s)))
361 return fail(400, "without needs ?version=<number>&versions=<number,number>");
362 return { status: 200, body: history.without(version, versions.map(Number)) };
363 }
init0Start the project364 if (op === "log" || op === "show" || op === "file" || op === "compare") {
365 // GETs: ?draft=<name> (shared when absent); log ?limit, ?path; show ?version; file ?path, ?version; compare ?from, ?to.
366 const q = (body ?? {}) as Record<string, string | undefined>;
367 const history = project as ProjectCalls & Partial<ProjectHistory>;
368 if (!history.log || !history.show || !history.fileAt || !history.compare)
369 return fail(501, `${op} needs the engine`);
370 const draft = q.draft ? q.draft : null;
371 const int = (s: string | undefined): number | undefined =>
372 s !== undefined && s !== "" && Number.isInteger(Number(s)) ? Number(s) : undefined;
373 const who = q.agent || undefined;
374 if (op === "log")
375 return {
376 status: 200,
377 body: history.log(
378 draft,
379 int(q.limit),
380 q.path || undefined,
381 who,
382 int(q.before),
383 q.follow === "1" || q.follow === "true",
384 ),
385 };
386 if (op === "file") {
387 const version = int(q.version);
388 if (!q.path || version === undefined) return fail(400, "file needs ?path=<path>&version=<number>");
389 return { status: 200, body: history.fileAt(q.path, version, draft, who) };
390 }
391 if (op === "compare") {
392 const from = int(q.from);
393 const to = int(q.to);
394 if (from === undefined || to === undefined) return fail(400, "compare needs ?from=<number>&to=<number>");
capacity243compare's summary: each changed file's size and SHA-256 instead of its texts (abso issue 680; disk-first 2; abso Capacity). compare 612 to 1224 on abso answers 13.2 MB: the full before and after text of about 3,000 changed files. Read Speed's shape lets the site ask for a summary and fetch a file's texts when it opens it. - view-changes.ts summariesBetween: the files changesBetween would list, each side as {size, sha256} for text (UTF-8 bytes, SHA-256 of the text), {blob} for a binary file (its hash; the Worker adds its size from the blob store), or null when absent; mode and blob as in the full answer. Each text is read, summed up and let go. - version-log compare takes summary and answers {from, to, summary: true, files}. ProjectHistory.compare and both engine-project.ts implementations take a fifth argument, summary; http.ts passes ?summary=1. The full answer is unchanged. On abso adopted fresh: the summary for 612 to 1224 is 174 KB instead of 13.2 MB, with heap after at 38 MB. The time is the same (about 20 s cold): it still lays the files out to hash them. Stored per-version sizes and hashes would remove that; they're proposed with the author totals table. New test compare-summary: on an in-memory and a writer-backed project, the summary lists the files the full compare does, with sizes and SHA-256s of its texts, blob hashes for a binary file, and no text. Every engine test (292 of 292), every worker/project test (342 of 342); tsc (worker and server) and biome clean.Compare395 // summary=1: each file's size and SHA-256, not its texts (abso issue 680).
396 return { status: 200, body: history.compare(from, to, draft, who, q.summary === "1") };
init0Start the project397 }
398 const version = Number(q.version);
399 if (q.version === undefined || !Number.isInteger(version)) return fail(400, "show needs ?version=<number>");
400 return { status: 200, body: history.show(version, draft, who) };
401 }
402 if (!validName(agent)) return fail(400, "agent names use letters, digits, '.', '_' and '-'");
403 if (op === "reader" && !readers) return fail(501, "reader needs the Worker");
404 const gated = readers ? readerAnswer(project, op, agent, body, readers) : undefined;
405 if (gated) return gated;
406 switch (op) {
407 case "edit": {
408 const b = body as EditBody;
409 if (!b || typeof b.file !== "string")
410 return fail(400, "edit needs {file, old, new}, {file, content} or {file, edits}");
411 if (localPath([b.file])) return LOCAL(b.file);
412 return { status: 200, body: project.edit(agent, b) };
413 }
414 case "record": {
415 const files = (body as { files?: Record<string, string | null> })?.files;
416 if (!files || typeof files !== "object") return fail(400, "record needs {files: {path: text or null}}");
417 const bad = localPath(Object.keys(files));
418 if (bad) return LOCAL(bad);
419 const modes = (body as { modes?: unknown })?.modes;
420 if (modes !== undefined && (typeof modes !== "object" || modes === null))
421 return fail(400, "modes must be {path: {exec, link}}");
422 const blobs = (body as { blobs?: unknown })?.blobs;
423 if (blobs !== undefined && (typeof blobs !== "object" || blobs === null))
424 return fail(400, "blobs must be {path: sha256}");
425 if (blobs && localPath(Object.keys(blobs))) return LOCAL(localPath(Object.keys(blobs))!);
426 const who = body as { session?: unknown; subagent?: unknown; client?: unknown };
427 const meta = {
428 ...(typeof who.session === "string" ? { session: who.session } : {}),
429 ...(typeof who.subagent === "string" ? { subagent: who.subagent } : {}),
430 ...(typeof who.client === "string" ? { client: who.client } : {}),
431 };
432 return {
433 status: 200,
434 body: project.record(
435 agent,
436 files,
437 modes as Record<string, { exec?: boolean; link?: string | null }> | undefined,
438 blobs as Record<string, string> | undefined,
439 meta,
440 ),
441 };
442 }
443 case "publish": {
444 const message = (body as { message?: string })?.message;
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare445 if (typeof message !== "string" || !message.trim()) return fail(400, "push needs {message} saying why");
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare446 const unseen = unseenError("the message", message);
447 if (unseen) return fail(400, unseen);
init0Start the project448 // asIs (#37): publish even with collided lines untouched since the sync, both sides kept.
449 return { status: 200, body: project.publish(agent, message, (body as { asIs?: unknown }).asIs === true) };
450 }
451 case "sync": {
452 // {label}: follow a label (#10), syncing to the newest version of shared that carries it.
453 const label = (body as { label?: unknown } | undefined)?.label;
454 if ((body as { full?: unknown } | undefined)?.full === true) {
455 // {full: true}: every file in the agent's view, as a first sync answers (#37).
456 const history = project as ProjectCalls & Partial<ProjectHistory>;
rename100abso publish is now abso push, abso sync is now abso pull (abso 427) Commands, help, flags, messages, MCP tool names and descriptions, hook text, README, SKILL.md and tests say push and pull; "shared" stays the noun ("Pushed version N"). No aliases, no notices. A queued push that was "pulled" is now "turned back", so pull means one thing. push -f/--force/-u/--all/--tags and pull --rebase/--ff-only/--squash refuse with one plain line naming the abso way; push and pull take no remote or branch. Kept as stored: log entry kinds (publish, sync, pulled), HTTP route paths, the pipeline trigger on: publish, the yours (unpublished) marker, npm-publish.Compare457 if (!history.syncFull) return fail(501, "a full pull needs the engine");
init0Start the project458 if (label !== undefined && typeof label !== "string") return fail(400, "label must be a label name");
459 return { status: 200, body: history.syncFull(agent, label as string | undefined) };
460 }
461 if (label === undefined) return { status: 200, body: project.sync(agent) };
462 if (typeof label !== "string") return fail(400, "label must be a label name");
463 const history = project as ProjectCalls & Partial<ProjectHistory>;
464 if (!history.syncTo) return fail(501, "following a label needs the engine");
465 return { status: 200, body: history.syncTo(agent, label) };
466 }
467 case "label": {
468 const history = project as ProjectCalls & Partial<ProjectHistory>;
469 if (!history.label) return fail(501, "label needs the engine");
470 const b = (body ?? {}) as { name?: unknown; version?: unknown; remove?: unknown };
471 if (typeof b.name !== "string") return fail(400, "label needs {name}, and {version} unless it's the newest");
472 if (b.version !== undefined && !Number.isInteger(b.version)) return fail(400, "version must be a number");
473 return { status: 200, body: history.label(agent, b.name, b.version as number | undefined, b.remove === true) };
474 }
475 // Named drafts (#10).
476 case "draft": {
477 const name = (body as { name?: unknown })?.name;
478 if (name !== null && typeof name !== "string")
479 return fail(400, "draft needs {name}, or {name: null} for shared");
480 return { status: 200, body: project.switchTo(agent, name, (body as { carry?: unknown }).carry === true) };
481 }
482 case "land": {
483 const message = (body as { message?: string })?.message;
484 if (typeof message !== "string" || !message.trim()) return fail(400, "land needs {message} saying why");
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare485 const unseen = unseenError("the message", message);
486 if (unseen) return fail(400, unseen);
init0Start the project487 return { status: 200, body: project.land(agent, message) };
488 }
489 case "draft-sync":
490 return { status: 200, body: project.syncDraft(agent) };
491 // The paths in the agent's view (#37): what its folder should hold. A GET; changes nothing.
492 case "files": {
493 const history = project as ProjectCalls & Partial<ProjectHistory>;
494 if (!history.agentPaths) return fail(501, "files needs the engine");
495 return { status: 200, body: history.agentPaths(agent) };
496 }
497 // abso status in one trip (abso issue 80): the project's status and the agent's paths.
498 case "status": {
499 const history = project as ProjectCalls & Partial<ProjectHistory>;
500 if (!history.agentPaths) return fail(501, "status needs the engine");
501 return {
502 status: 200,
503 body: { ...(statusWithReaders(project.status(), readers) as object), files: history.agentPaths(agent) },
504 };
505 }
506 // Amend (#27): correct the message of the agent's newest publish.
507 case "amend": {
508 const history = project as ProjectCalls & Partial<ProjectHistory>;
509 if (!history.amend) return fail(501, "amend needs the engine");
510 const message = (body as { message?: unknown } | undefined)?.message;
511 if (typeof message !== "string" || !message.trim()) return fail(400, "amend needs {message}");
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare512 const unseen = unseenError("the message", message);
513 if (unseen) return fail(400, unseen);
init0Start the project514 return { status: 200, body: history.amend(agent, message) };
515 }
516 // Pluck (#27): take some versions of a named draft into shared.
517 case "pluck": {
518 const history = project as ProjectCalls & Partial<ProjectHistory>;
519 if (!history.pluck) return fail(501, "pluck needs the engine");
520 const b = (body ?? {}) as {
521 draft?: unknown;
522 versions?: unknown;
523 message?: unknown;
524 withDependencies?: unknown;
525 };
526 if (typeof b.draft !== "string") return fail(400, "pluck needs {draft, versions: [number], message}");
527 if (!Array.isArray(b.versions) || b.versions.length === 0 || !b.versions.every((v) => Number.isInteger(v)))
528 return fail(400, "pluck needs {versions: [number]}");
529 if (typeof b.message !== "string" || !b.message.trim()) return fail(400, "pluck needs {message} saying why");
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare530 const unseen = unseenError("the message", b.message);
531 if (unseen) return fail(400, unseen);
init0Start the project532 return {
533 status: 200,
534 body: history.pluck(agent, b.draft, b.versions as number[], b.message, b.withDependencies === true),
535 };
536 }
537 // Drop (#10): take published versions out of shared.
538 case "drop": {
539 const history = project as ProjectCalls & Partial<ProjectHistory>;
540 if (!history.drop) return fail(501, "drop needs the engine");
541 const b = (body ?? {}) as { versions?: unknown; message?: unknown; withDependents?: unknown };
542 if (!Array.isArray(b.versions) || b.versions.length === 0 || !b.versions.every((v) => Number.isInteger(v)))
543 return fail(400, "drop needs {versions: [number], message}");
544 if (typeof b.message !== "string" || !b.message.trim()) return fail(400, "drop needs {message} saying why");
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare545 const unseen = unseenError("the message", b.message);
546 if (unseen) return fail(400, unseen);
init0Start the project547 return { status: 200, body: history.drop(agent, b.versions as number[], b.message, b.withDependents === true) };
548 }
549 // Announcements, and news without an edit.
550 case "move": {
551 const history = project as ProjectCalls & Partial<ProjectHistory>;
552 if (!history.move) return fail(501, "move needs the engine");
553 const b = (body ?? {}) as { from?: unknown; to?: unknown };
554 if (typeof b.from !== "string" || typeof b.to !== "string") return fail(400, "move needs {from, to}");
555 if (localPath([b.from, b.to])) return LOCAL(localPath([b.from, b.to])!);
556 return { status: 200, body: history.move(agent, b.from, b.to) };
557 }
558 case "note":
559 case "note-close": {
560 const history = project as ProjectCalls & Partial<ProjectHistory>;
561 if (!history.note || !history.closeNote) return fail(501, `${op} needs the engine`);
562 const b = (body ?? {}) as Record<string, unknown>;
563 if (op === "note-close") return { status: 200, body: history.closeNote(agent, b.id as number, b.how) };
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare564 const unseen = unseenError("the note", b.text);
565 if (unseen) return fail(400, unseen);
init0Start the project566 return { status: 200, body: history.note(agent, b) };
567 }
568 case "announce":
569 case "news": {
570 const history = project as ProjectCalls & Partial<ProjectHistory>;
571 if (!history.announce || !history.news) return fail(501, `${op} needs the engine`);
572 if (op === "news") return { status: 200, body: history.news(agent) };
573 const b = (body ?? {}) as { text?: unknown; to?: unknown };
574 if (typeof b.text !== "string" || !b.text.trim()) return fail(400, "announce needs {text}");
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare575 const unseen = unseenError("the text", b.text);
576 if (unseen) return fail(400, unseen);
init0Start the project577 if (b.to !== undefined && (!Array.isArray(b.to) || !b.to.every((a) => typeof a === "string")))
578 return fail(400, "to must be a list of agent names");
579 return { status: 200, body: history.announce(agent, b.text, b.to as string[] | undefined, how) };
580 }
581 // What the agent is starting on (#37, #13): {text, files?}, or {text: null} to take it back.
582 case "starting": {
583 const history = project as ProjectCalls & Partial<ProjectHistory>;
584 if (!history.starting) return fail(501, "starting needs the engine");
585 const b = (body ?? {}) as { text?: unknown; files?: unknown; issue?: unknown; done?: unknown };
586 if (b.text !== null && (typeof b.text !== "string" || !b.text.trim()))
587 return fail(400, "starting needs {text}, or {text: null} to take it back");
engine73Messages and notes can't hold characters a reader can't see: publish, land, amend, pluck and drop messages, starting notes, line notes and announcements are refused when they hold control characters other than tab and newline (CRLF passes), or zero-width, bidirectional or tag characters. It's the same list the website's announcements and Issues use.Compare588 const unseen = unseenError("the note", b.text);
589 if (unseen) return fail(400, unseen);
init0Start the project590 if (b.files !== undefined && (!Array.isArray(b.files) || !b.files.every((f) => typeof f === "string")))
591 return fail(400, "files must be a list of paths");
592 // issue (#54): the issue the note works on; done: a take-back because the work is finished, closing it.
593 return {
594 status: 200,
595 body: history.starting(agent, b.text as string | null, b.files as string[] | undefined, {
596 ...(b.issue !== undefined ? { issue: b.issue } : {}),
597 ...(b.done !== undefined ? { done: b.done } : {}),
598 }),
599 };
600 }
601 // Everyday commands (#27).
602 case "diff":
603 case "restore": {
604 const history = project as ProjectCalls & Partial<ProjectHistory>;
605 if (!history.diff || !history.restore) return fail(501, `${op} needs the engine`);
606 if (op === "diff") return { status: 200, body: history.diff(agent) };
607 const b = (body ?? {}) as { files?: unknown; all?: unknown };
608 if (b.all === true) return { status: 200, body: history.restore(agent, null) };
609 if (!Array.isArray(b.files) || !b.files.every((f) => typeof f === "string")) {
610 return fail(400, "restore needs {files: [path]} or {all: true}");
611 }
612 return { status: 200, body: history.restore(agent, b.files as string[]) };
613 }
614 }
615 return fail(404, `no such operation: ${op}`);
616 } catch (e) {
617 // The engine throws ProjectError with a code; anything else is ours.
618 const code = (e as { code?: string }).code;
619 const status =
620 code === "not-implemented"
621 ? 501
622 : code === "not-initialized" || code === "not-found"
623 ? 404
624 : code === "already-initialized" || code === "conflict"
625 ? 409
626 : code === "bad-request" || code === "bad-agent"
627 ? 400
628 : 500;
629 return fail(status, e instanceof Error ? e.message : String(e));
630 }