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 17 to 318

Compare

+87 −14 in 13 places
Lines 28–39 at 318 (were 28–38 at 17)
2828import { byWhom } from "./history-answers.ts";
2929import { applyMode, PLAIN, readKnownModes, writeKnownModes } from "./modes.ts";
3030import { refusedText, screenAnswer } from "./safety.ts";
31+import { refusalText, withoutArg, withoutHeading } from "./without.ts";
3132
32−/** The space to read: --draft (where "shared" means shared), else the one this agent is in. */
33+/** The space to read: --draft (where "shared" means shared), else the one this agent is in (shared, in a folder with no agent). */
3334function space(args: Parsed, agent: string): Where {
3435 const named = str(args, "draft");
35− if (named === undefined) return { agent };
36+ if (named === undefined) return agent === "" ? { draft: null } : { agent };
3637 return { draft: named === "shared" ? null : named };
3738}
3839
Lines 88–94 at 318 (were 87–93 at 17)
8788 return {
8889 text: [
8990 mine
90− ? `Your view holds ${what}: ${spaceName(answer.draft)} at version ${answer.version}, with your unpublished changes.${missing.size > 0 ? ` ${missing.size} of them ${missing.size === 1 ? "is" : "are"} missing from this folder (abso sync --full writes them).` : ""}`
91+ ? `Your view holds ${what}: ${spaceName(answer.draft)} at version ${answer.version}, with your unpushed changes.${missing.size > 0 ? ` ${missing.size} of them ${missing.size === 1 ? "is" : "are"} missing from this folder (abso pull --full writes them).` : ""}`
9192 : `${spaceName(answer.draft)} at version ${answer.version} holds ${what}.`,
9293 ...files.map((f) => (missing.has(f) ? `${f} (missing from this folder)` : f)),
9394 ].join("\n"),
Lines 142–166 at 318 (were 141–146 at 17)
141142 .filter((p) => only.length > 1 || !existsHere(root, p))
142143 .map((p) => nothingAt(root, p));
143144
145+ // --agent: someone else's draft, to review it. What they've recorded, not their folder; nothing here is recorded.
146+ const other = str(args, "agent");
147+ if (other !== undefined) {
148+ if (between || str(args, "draft") !== undefined)
149+ throw new UsageError("--agent shows that agent's unpushed changes: abso diff [file...] --agent <name>");
150+ const answer = await api.diffOf(other);
151+ const files = pick(answer.files);
152+ const d = diffs(files);
153+ const where = `${spaceName(answer.draft)}${answer.base === null ? "" : ` (on version ${answer.base})`}`;
154+ const head =
155+ files.length === 0
156+ ? `${other} has no recorded, unpushed changes${inPaths(only, "to")} in ${where}.`
157+ : `${other}'s recorded, unpushed changes${inPaths(only, "to")} in ${where}: ${totals(files)}.`;
158+ return {
159+ text: [head, ...d.text].join("\n"),
160+ json: { agent: other, draft: answer.draft, base: answer.base, files: d.json, unmatched: unmatched(files) },
161+ };
162+ }
144164 if (between) {
145165 const from = version(words[0]!);
146166 const to = version(words[1]!);
Lines 180–186 at 318 (were 160–166 at 17)
160180
161181 if (str(args, "draft") !== undefined)
162182 throw new UsageError(
163− "--draft goes with two versions (abso diff <from> <to>); abso diff alone shows your own unpublished changes",
183+ "--draft goes with two versions (abso diff <from> <to>); abso diff alone shows your own unpushed changes",
164184 );
165185 // Folder-only edits count as unpublished changes too.
166186 const recorded = await recordFolder(root, api);
Lines 190–197 at 318 (were 170–177 at 17)
170190 const where = `${spaceName(answer.draft)}${answer.base === null ? "" : ` (on version ${answer.base})`}`;
171191 const head =
172192 files.length === 0
173− ? `No unpublished changes${inPaths(only, "to")} in ${where}.`
174− : `Your unpublished changes${inPaths(only, "to")} in ${where}: ${totals(files)}.`;
193+ ? `No unpushed changes${inPaths(only, "to")} in ${where}.`
194+ : `Your unpushed changes${inPaths(only, "to")} in ${where}: ${totals(files)}.`;
175195 const pre = recordedFirst(recorded);
176196 return {
177197 text: [...pre, head, ...notes(files), ...d.text].join("\n"),
Lines 288–294 at 318 (were 268–274 at 17)
268288 if (v.drops && v.drops.length > 0)
269289 out.push(` drops ${v.drops.length === 1 ? "version" : "versions"} ${v.drops.join(", ")}`);
270290 if (v.droppedIn !== undefined) out.push(` dropped in version ${v.droppedIn}: shared no longer has these changes`);
271− if (v.originalMessage !== undefined) out.push(` amended; first published as: ${v.originalMessage}`);
291+ if (v.originalMessage !== undefined) out.push(` amended; first pushed as: ${v.originalMessage}`);
272292 return out;
273293}
274294
Lines 331–338 at 318 (were 311–316 at 17)
311331 const rawLimit = str(args, "limit");
312332 const limit = rawLimit === undefined ? undefined : version(rawLimit, "-n");
313333 if (limit === 0) throw new UsageError("-n is how many versions to show; give 1 or more");
334+ const rawBefore = str(args, "before");
335+ const before = rawBefore === undefined ? undefined : version(rawBefore, "--before");
314336 // The server filters by one file; a folder (or the whole folder) is filtered here, from a longer log.
315337 const folder = path !== undefined && (path === "" || /[/]$/.test(typed!) || isFolder(root, path));
316338 // --since, --by and --count (#37, Reporter's progress reports) filter here, from a longer log.
Lines 354–360 at 318 (were 332–337 at 17)
332354 space(args, config.agent),
333355 folder || filtering ? FOLDER_LOG : limit,
334356 folder ? undefined : path,
357+ before,
335358 );
336359 const found = folder
337360 ? {
Lines 415–474 at 318 (were 392–403 at 17)
392415 ]),
393416 ];
394417 const oldest = answer.versions[answer.versions.length - 1];
395− if (path === undefined && !filtering && oldest !== undefined && oldest.version > 0)
396− lines.push(`Older versions: abso log -n ${answer.versions.length + 50}`);
418+ if (!filtering && !folder && raw.next !== undefined && oldest !== undefined)
419+ lines.push(`Older versions: abso log${typed === undefined ? "" : ` ${typed}`} --before ${oldest.version}`);
397420 if (filtering && answer.versions.length === 0) lines.push("No version matches.");
421+ // A filter or a folder reads the newest FOLDER_LOG versions; say so when older ones were left unread.
422+ if ((filtering || folder) && raw.next !== undefined)
423+ lines.push(
424+ `Only the newest ${FOLDER_LOG} versions${before === undefined ? "" : ` below ${before}`} were read; --before ${raw.next} reads older ones.`,
425+ );
398426 return { text: lines.join("\n"), json: { ...answer } };
399427}
400428
429+/** abso show <version>[:<file>] --without <versions>: what differs with them left out, or that file then. */
430+async function showWithout(
431+ api: Api,
432+ root: string,
433+ cwd: string,
434+ word: string,
435+ where: Where,
436+ leave: readonly number[],
437+): Promise<Output> {
438+ if ("draft" in where && where.draft !== null) throw new UsageError("--without reads shared, not a named draft");
439+ const colon = word.indexOf(":");
440+ const v = version(colon >= 0 ? word.slice(0, colon) : word);
441+ const path = colon >= 0 ? fileArg(root, cwd, word.slice(colon + 1)) : undefined;
442+ const answer = await api.without(v, leave);
443+ if (!answer.ok)
444+ return {
445+ exit: EXIT.refused,
446+ text: refusalText(answer, (vs) => `abso show ${word} --without ${vs.join(",")}`),
447+ json: { ...answer },
448+ };
449+ if (path !== undefined) {
450+ const file = answer.files.find((f) => f.path === path);
451+ if (file === undefined) {
452+ const same = await api.fileAt(path, v, { draft: null });
453+ if (same.text !== null) return { text: same.text, json: { ...same, without: answer.without } };
454+ } else if (file.after !== null) return { text: file.after, json: { ...file, without: answer.without } };
455+ return {
456+ exit: EXIT.error,
457+ text: `${path} isn't in version ${v} of shared without them.`,
458+ json: { path, version: v, without: answer.without },
459+ };
460+ }
461+ const changed = pairRenames(answer.files);
462+ const d = diffs(changed);
463+ const lines = [
464+ ...withoutHeading(answer),
465+ changed.length === 0 ? `No file differs from version ${v}.` : `Compared with version ${v}: ${totals(changed)}.`,
466+ `The files hash to ${answer.tree}; the same ask gives the same hash. Shared doesn't change.`,
467+ ...d.text,
468+ ];
469+ return { text: lines.join("\n"), json: { ...answer, files: d.json } };
470+}
401472export async function runShow(args: Parsed, env: Env): Promise<Output> {
402473 if (args.positionals.length !== 1)
403474 throw new UsageError("show takes one version: abso show <version> or abso show <version>:<file>");
Lines 476–483 at 318 (were 405–410 at 17)
405476 const word = args.positionals[0]!;
406477 const colon = word.indexOf(":");
407478 const where = space(args, config.agent);
479+ const leave = withoutArg(args);
480+ if (leave !== undefined) return showWithout(api, root, env.cwd, word, where, leave);
408481
409482 if (colon >= 0) {
410483 const v = version(word.slice(0, colon));
Lines 507–513 at 318 (were 434–440 at 17)
434507/**
435508 * A file's text with the draft's hunks that touch lines `from`-`to` (of the
436509 * file as it is now, as abso diff numbers them) put back as they were at the
437− * base; the other hunks stay (#37, Builder 2: drop my copy of a teammate's
510+ * base; the other hunks stay (#37: drop my copy of a teammate's
438511 * half and keep the rest). A hunk that only deleted lines touches the line
439512 * where they were.
440513 */
Lines 563–569 at 318 (were 490–496 at 17)
490563 // Folder-only edits go to the server first, so they are discarded with the rest.
491564 await recordFolder(root, api);
492565 if (ranged.length > 0) {
493− // Some lines of a file: put those hunks back here, then record the file (#37, Builder 2).
566+ // Some lines of a file: put those hunks back here, then record the file (#37).
494567 const diff = await api.diff();
495568 const lines: string[] = [];
496569 for (const r of ranged) {
Lines 644–655 at 318 (were 571–582 at 17)
571644 );
572645 const lines = [
573646 restored.length + deleted.length === 0
574− ? "Nothing to restore: no unpublished changes there."
575− : `Discarded your unpublished changes to ${plural(restored.length + deleted.length, "file")}:`,
647+ ? "Nothing to restore: no unpushed changes there."
648+ : `Discarded your unpushed changes to ${plural(restored.length + deleted.length, "file")}:`,
576649 ...restored.map((f) => ` restored ${f}`),
577650 ...deleted.map((f) => ` deleted ${f} (it is new in your draft)`),
578651 ...(untouched.length > 0 && restored.length + deleted.length > 0
579− ? [`No unpublished changes to: ${untouched.join(", ")}`]
652+ ? [`No unpushed changes to: ${untouched.join(", ")}`]
580653 : []),
581654 ...refusedText(refused),
582655 ];
MCP
compare on this site's /mcp
CLI
abso diff 17 318 client/src/changes.ts --json
JSON
/christopher/abso-core/compare/17..318?file=client%2Fsrc%2Fchanges.ts&format=json