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

Compare

+91 −17 in 15 places
Lines 25–39 at 318 (were 25–37 at 11)
2525 writeKnown,
2626} from "./folder.ts";
2727import { fileArg, when } from "./history.ts";
28+import { byWhom } from "./history-answers.ts";
2829import { applyMode, PLAIN, readKnownModes, writeKnownModes } from "./modes.ts";
2930import { refusedText, screenAnswer } from "./safety.ts";
31+import { refusalText, withoutArg, withoutHeading } from "./without.ts";
3032
31−/** 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). */
3234function space(args: Parsed, agent: string): Where {
3335 const named = str(args, "draft");
34− if (named === undefined) return { agent };
36+ if (named === undefined) return agent === "" ? { draft: null } : { agent };
3537 return { draft: named === "shared" ? null : named };
3638}
3739
Lines 88–94 at 318 (were 86–92 at 11)
8688 return {
8789 text: [
8890 mine
89− ? `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).` : ""}`
9092 : `${spaceName(answer.draft)} at version ${answer.version} holds ${what}.`,
9193 ...files.map((f) => (missing.has(f) ? `${f} (missing from this folder)` : f)),
9294 ].join("\n"),
Lines 142–166 at 318 (were 140–145 at 11)
140142 .filter((p) => only.length > 1 || !existsHere(root, p))
141143 .map((p) => nothingAt(root, p));
142144
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+ }
143164 if (between) {
144165 const from = version(words[0]!);
145166 const to = version(words[1]!);
Lines 180–186 at 318 (were 159–165 at 11)
159180
160181 if (str(args, "draft") !== undefined)
161182 throw new UsageError(
162− "--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",
163184 );
164185 // Folder-only edits count as unpublished changes too.
165186 const recorded = await recordFolder(root, api);
Lines 190–197 at 318 (were 169–176 at 11)
169190 const where = `${spaceName(answer.draft)}${answer.base === null ? "" : ` (on version ${answer.base})`}`;
170191 const head =
171192 files.length === 0
172− ? `No unpublished changes${inPaths(only, "to")} in ${where}.`
173− : `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)}.`;
174195 const pre = recordedFirst(recorded);
175196 return {
176197 text: [...pre, head, ...notes(files), ...d.text].join("\n"),
Lines 235–241 at 318 (were 214–220 at 11)
214235/** The line for a path that matched no changed file. */
215236function nothingAt(root: string, p: string): string {
216237 if (!existsHere(root, p))
217− return ` ${p}: no such file or folder here now (paths are relative to where you run avcs).`;
238+ return ` ${p}: no such file or folder here now (paths are relative to where you run abso).`;
218239 return ` ${p === "" ? "the whole folder" : `${p}${isFolder(root, p) ? "/" : ""}`}: no changes there.`;
219240}
220241
Lines 288–294 at 318 (were 267–273 at 11)
267288 if (v.drops && v.drops.length > 0)
268289 out.push(` drops ${v.drops.length === 1 ? "version" : "versions"} ${v.drops.join(", ")}`);
269290 if (v.droppedIn !== undefined) out.push(` dropped in version ${v.droppedIn}: shared no longer has these changes`);
270− 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}`);
271292 return out;
272293}
273294
Lines 331–338 at 318 (were 310–315 at 11)
310331 const rawLimit = str(args, "limit");
311332 const limit = rawLimit === undefined ? undefined : version(rawLimit, "-n");
312333 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");
313336 // The server filters by one file; a folder (or the whole folder) is filtered here, from a longer log.
314337 const folder = path !== undefined && (path === "" || /[/]$/.test(typed!) || isFolder(root, path));
315338 // --since, --by and --count (#37, Reporter's progress reports) filter here, from a longer log.
Lines 354–360 at 318 (were 331–336 at 11)
331354 space(args, config.agent),
332355 folder || filtering ? FOLDER_LOG : limit,
333356 folder ? undefined : path,
357+ before,
334358 );
335359 const found = folder
336360 ? {
Lines 409–474 at 318 (were 385–402 at 11)
385409 `${spaceName(answer.draft)} is at version ${answer.version}.${path === undefined ? "" : answer.versions.length === 0 ? ` No version changed ${named}.` : ` The versions that changed ${named}, newest first:`}`,
386410 ...(path !== undefined && answer.versions.length === 0 && !existsHere(root, path) ? [nothingAt(root, path)] : []),
387411 ...answer.versions.flatMap((v) => [
388− `version ${v.version} by ${v.agent}, ${when(v.time)}${answer.draft === null ? ciMarkText(v.ci) : ""}: ${v.message}`,
412+ `version ${v.version} by ${byWhom(v)}, ${when(v.time)}${answer.draft === null ? ciMarkText(v.ci) : ""}: ${v.message}`,
389413 ` ${plural(v.files.length, "file")}: ${v.files.slice(0, LOG_FILES).join(", ")}${v.files.length > LOG_FILES ? `, and ${v.files.length - LOG_FILES} more` : ""}`,
390414 ...notes(v),
391415 ]),
392416 ];
393417 const oldest = answer.versions[answer.versions.length - 1];
394− if (path === undefined && !filtering && oldest !== undefined && oldest.version > 0)
395− 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}`);
396420 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+ );
397426 return { text: lines.join("\n"), json: { ...answer } };
398427}
399428
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+}
400472export async function runShow(args: Parsed, env: Env): Promise<Output> {
401473 if (args.positionals.length !== 1)
402474 throw new UsageError("show takes one version: abso show <version> or abso show <version>:<file>");
Lines 476–483 at 318 (were 404–409 at 11)
404476 const word = args.positionals[0]!;
405477 const colon = word.indexOf(":");
406478 const where = space(args, config.agent);
479+ const leave = withoutArg(args);
480+ if (leave !== undefined) return showWithout(api, root, env.cwd, word, where, leave);
407481
408482 if (colon >= 0) {
409483 const v = version(word.slice(0, colon));
Lines 496–502 at 318 (were 422–428 at 11)
422496 const changed = pairRenames(answer.diff);
423497 const d = diffs(changed);
424498 const lines = [
425− `version ${answer.version} of ${spaceName(answer.draft)} by ${answer.agent}, ${when(answer.time)}: ${answer.message}`,
499+ `version ${answer.version} of ${spaceName(answer.draft)} by ${byWhom(answer)}, ${when(answer.time)}: ${answer.message}`,
426500 ...notes(answer),
427501 changed.length === 0 ? "It changed no files." : `${totals(changed)}.`,
428502 ...d.text,
Lines 507–513 at 318 (were 433–439 at 11)
433507/**
434508 * A file's text with the draft's hunks that touch lines `from`-`to` (of the
435509 * file as it is now, as abso diff numbers them) put back as they were at the
436− * 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
437511 * half and keep the rest). A hunk that only deleted lines touches the line
438512 * where they were.
439513 */
Lines 563–569 at 318 (were 489–495 at 11)
489563 // Folder-only edits go to the server first, so they are discarded with the rest.
490564 await recordFolder(root, api);
491565 if (ranged.length > 0) {
492− // 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).
493567 const diff = await api.diff();
494568 const lines: string[] = [];
495569 for (const r of ranged) {
Lines 644–655 at 318 (were 570–581 at 11)
570644 );
571645 const lines = [
572646 restored.length + deleted.length === 0
573− ? "Nothing to restore: no unpublished changes there."
574− : `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")}:`,
575649 ...restored.map((f) => ` restored ${f}`),
576650 ...deleted.map((f) => ` deleted ${f} (it is new in your draft)`),
577651 ...(untouched.length > 0 && restored.length + deleted.length > 0
578− ? [`No unpublished changes to: ${untouched.join(", ")}`]
652+ ? [`No unpushed changes to: ${untouched.join(", ")}`]
579653 : []),
580654 ...refusedText(refused),
581655 ];
MCP
compare on this site's /mcp
CLI
abso diff 11 318 client/src/changes.ts --json
JSON
/christopher/abso-core/compare/11..318?file=client%2Fsrc%2Fchanges.ts&format=json