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
code on this site's /mcp
CLI
none: the JSON below is the answer
JSON
/christopher/abso-core/files/client/src/install.ts?draft=login-timeout&format=json
581 linesFirst import 84% · speed 10% · review 5% · pinch 1%0 versions changed it
1// Installing a mod without breaking the sessions that run it (#29). The avcs
2// mod and avcs-view are folders in Claude Code's skills folder, which every
3// session on the machine loads when it starts (an open chat keeps the mod it
4// started with, #37). So an install (client/install-mod.ts, client/install-view.ts):
5//
6// 1. Stages the new files in a temp folder. plugin.json's version gets the
7// last commit that changed the mod's own files (0.1.0+702c616, or
8// 0.1.0+702c616.dirty when they differ from it), and hooks/stamp.ts says
9// the same, so the mod sends it with each call to the server
10// (X-Abso-Client). A commit that changes none of them changes nothing to
11// install, and nothing to restart for.
12// 2. Checks the staged copy: `claude plugin validate`, then the mod's own
13// tests in Claude Code's plugin test kit. If either fails, nothing in the
14// installed folder changes.
15// 3. Keeps each installed file as <file>.prev, then moves each new file into
16// place with a rename, so no session reads a half-written file: what the
17// hook imports first, plugin.json last. If a rename fails, the files
18// already moved are put back.
19//
20// The renames follow each other within a few milliseconds, but a session can
21// still start between two of them. With what the hook imports going in
22// first, a new hook never loads without its imports; a core.ts that drops an
23// export the old hook uses can fail that one start, and a restart after the
24// install brings the whole new mod.
25//
26// A rollback swaps the .prev files back in, and the files it replaces become
27// the .prev ones, so a second rollback undoes the first. .avcs-install.json
28// in the mod's folder says what is installed and what the .prev files hold.
29// `avcs --version` reports the installed mods (versionReport).
31import { spawnSync } from "node:child_process";
32import {
33 closeSync,
34 copyFileSync,
35 existsSync,
36 mkdirSync,
37 mkdtempSync,
38 openSync,
39 readFileSync,
40 renameSync,
41 rmdirSync,
42 rmSync,
43 statSync,
44 writeFileSync,
45} from "node:fs";
46import { homedir, tmpdir } from "node:os";
47import { dirname, join, resolve } from "node:path";
48import { CLIENT_DIR, clientPlace, clientVersion, headCommit } from "./client-version.ts";
50export interface ModSpec {
51 /** The mod's name, as its plugin.json has it. */
52 readonly name: string;
53 /** The folder its files come from. */
54 readonly from: string;
55 /** Its files, relative to `from`, in the order they go into place: what the hook imports first, plugin.json last. */
56 readonly files: readonly string[];
57 /** Its tests for the plugin test kit, relative to `from`: staged for the check, never installed. */
58 readonly test?: string;
61/** One install, as .avcs-install.json records it. */
62export interface Install {
63 readonly version: string;
64 /** In the order they went into place. */
65 readonly files: readonly string[];
66 readonly from: string;
67 readonly at: string;
70export interface InstallRecord extends Install {
71 readonly mod: string;
72 /** What the .prev files hold. */
73 readonly prev?: Install;
74 /** Set while files are being moved into place; still set means an install stopped midway. */
75 readonly moving?: string;
78export interface Installed {
79 /** False when the folder already had exactly these files. */
80 readonly changed: boolean;
81 readonly version: string;
82 /** The version the .prev files now hold. */
83 readonly previous: string | undefined;
84 readonly files: number;
87export interface InstallOptions {
88 /** The mod's folder: in the skills folder, or a scratch folder. */
89 readonly target: string;
90 /** Checks a staged copy of the mod: undefined when it passes, else why not. */
91 readonly check: (dir: string) => string | undefined;
92 /** For tests: the commit to stamp (null: none), instead of asking git. */
93 readonly commit?: string | null;
94 /** For tests: the rename that moves each file into place. */
95 readonly rename?: (from: string, to: string) => void;
96 readonly now?: Date;
99const RECORD = ".avcs-install.json";
100const LOCK = ".avcs-install.lock";
101const MANIFEST = ".claude-plugin/plugin.json";
102const STAMP_FILE = "hooks/stamp.ts";
103/** A lock older than this was left by an install that died. */
104const STALE_LOCK_MS = 10 * 60_000;
106const at = (dir: string, rel: string, suffix = "") => join(dir, ...rel.split("/")) + suffix;
108/** The abso mod: what the hook imports first, plugin.json last. src/core.ts is the only client file it imports. */
109export const AVCS_MOD: ModSpec = {
110 name: "abso-hooks",
111 from: CLIENT_DIR,
112 files: ["src/core.ts", "hooks/stamp.ts", "hooks/register.ts", "hooks/hooks.json", ".claude-plugin/plugin.json"],
113 test: "hooks/register.test.ts",
114};
116/** The abso-view mod (#12), from client/view. */
117export const VIEW_MOD: ModSpec = {
118 name: "abso-view",
119 from: join(CLIENT_DIR, "view"),
120 files: ["types/index.d.ts", "hooks/stamp.ts", "hooks/register.tsx", "hooks/hooks.json", ".claude-plugin/plugin.json"],
121 test: "hooks/register.test.ts",
122};
124/** The skills folders the mods had before the rename; an install moves them out of the way (see retireOldMod). */
125export const OLD_MOD_NAMES: Readonly<Record<string, string>> = { "abso-hooks": "avcs", "abso-view": "avcs-view" };
127/** Where Claude Code's skills folder keeps a mod. */
128export const skillsFolder = (name: string, env: Readonly<Record<string, string | undefined>> = process.env) =>
129 join(env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude"), "skills", name);
131export const modInstalled = (env: Readonly<Record<string, string | undefined>> = process.env) =>
132 existsSync(at(skillsFolder(AVCS_MOD.name, env), MANIFEST)) ||
133 existsSync(at(skillsFolder(OLD_MOD_NAMES[AVCS_MOD.name]!, env), MANIFEST));
135/**
136 * After the new mod is in, the folder it replaces (skills/avcs, skills/avcs-view) would load beside it, so it
137 * is moved, not deleted, to ~/.abso/retired-mods/<name>-<stamp>. Returns where it went, or undefined when there was none.
138 */
139export function retireOldMod(
140 spec: ModSpec,
141 env: Readonly<Record<string, string | undefined>> = process.env,
142 now: Date = new Date(),
143): string | undefined {
144 const old = OLD_MOD_NAMES[spec.name];
145 if (old === undefined) return undefined;
146 const from = skillsFolder(old, env);
147 if (!existsSync(from)) return undefined;
148 const to = join(homedir(), ".abso", "retired-mods", `${old}-${now.toISOString().replace(/[:.]/g, "-")}`);
149 mkdirSync(dirname(to), { recursive: true });
150 renameRetrying(from, to);
151 return to;
154/** The version an install of `spec` gets: plugin.json's, plus the last commit that changed its files (and .dirty when they differ from it). */
155export function versionFor(spec: ModSpec, commit?: string | null): string {
156 const manifest = JSON.parse(readFileSync(at(spec.from, MANIFEST), "utf8")) as { version?: unknown };
157 const base = String(manifest.version ?? "0.0.0").split("+")[0]!;
158 const c = commit === undefined ? modCommit(spec) : commit;
159 return c ? `${base}+${c}` : base;
162function modCommit(spec: ModSpec): string | null {
163 const git = (...args: string[]) => spawnSync("git", ["-C", spec.from, ...args], { encoding: "utf8" });
164 const last = git("log", "-1", "--format=%H", "--", ...spec.files);
165 if (last.status !== 0 || !/^[0-9a-f]{40}/.test(last.stdout)) return null;
166 const changed = git("status", "--porcelain", "--", ...spec.files).stdout.trim() !== "";
167 return `${last.stdout.slice(0, 7)}${changed ? ".dirty" : ""}`;
170/** A file changed this close to when an answer was kept can't be told apart from one changed just after it. */
171const RACY_MS = 2_000;
173interface KeptModCommit {
174 readonly head: string;
175 readonly files: readonly string[];
176 readonly at: number;
177 readonly commit: string | null;
180/**
181 * modCommit for the version report, which `abso status` asks on every run: it runs git twice per mod, so
182 * the answer is kept in ~/.abso/mod-commits.json. A kept answer holds while the checkout's commit (read
183 * from .git, without git) and each of the mod's files (size, modified time, inode) are as they were, and
184 * every file was changed clearly before the answer was kept; anything else asks git again. Outside a git
185 * checkout there is no commit, and git isn't run at all.
186 */
187export function keptModCommit(spec: ModSpec, home: string = homedir()): string | null {
188 const head = headCommit(spec.from);
189 if (head === undefined) return null;
190 const at = Date.now();
191 const files = spec.files.map((rel) => {
192 try {
193 const s = statSync(join(spec.from, ...rel.split("/")));
194 return `${s.size}:${s.mtimeMs}:${s.ino}`;
195 } catch {
196 return "-";
197 }
198 });
199 const newest = Math.max(...files.map((f) => (f === "-" ? 0 : Number(f.split(":")[1]))));
200 const path = join(home, ".abso", "mod-commits.json");
201 const key = `${resolve(spec.from)}|${spec.files.join("|")}`;
202 let kept: Record<string, KeptModCommit> = {};
203 try {
204 const parsed = JSON.parse(readFileSync(path, "utf8")) as { format?: unknown; mods?: unknown };
205 if (parsed.format === 1 && typeof parsed.mods === "object" && parsed.mods !== null)
206 kept = parsed.mods as Record<string, KeptModCommit>;
207 } catch {}
208 const was = kept[key];
209 if (
210 was !== undefined &&
211 was.head === head &&
212 Array.isArray(was.files) &&
213 was.files.join() === files.join() &&
214 newest < was.at - RACY_MS
215 )
216 return was.commit;
217 const commit = modCommit(spec);
218 try {
219 mkdirSync(dirname(path), { recursive: true });
220 const next = `${path}.${process.pid}.tmp`;
221 writeFileSync(next, JSON.stringify({ format: 1, mods: { ...kept, [key]: { head, files, at, commit } } }));
222 renameSync(next, path);
223 } catch {
224 // Best effort: the next run asks git again.
225 }
226 return commit;
229/** The files to install, stamped with `version`, in install order. */
230function filesFor(spec: ModSpec, version: string): Map<string, Buffer> {
231 if (!/^[\w.+-]+$/.test(version)) throw new Error(`can't stamp the version ${JSON.stringify(version)}`);
232 const out = new Map<string, Buffer>();
233 for (const rel of spec.files) {
234 let data = readFileSync(at(spec.from, rel));
235 if (rel === MANIFEST) {
236 const manifest = JSON.parse(data.toString("utf8")) as Record<string, unknown>;
237 data = Buffer.from(`${JSON.stringify({ ...manifest, version }, null, 2)}\n`);
238 } else if (rel === STAMP_FILE) {
239 const text = data.toString("utf8");
240 const stamped = text.replace(/(STAMP[^=\n]*=\s*)undefined/, `$1'${version}'`);
241 if (stamped === text) throw new Error(`${rel} has no "STAMP ... = undefined" line to stamp`);
242 data = Buffer.from(stamped);
243 }
244 out.set(rel, data);
245 }
246 return out;
249function readRecord(target: string): InstallRecord | undefined {
250 try {
251 return JSON.parse(readFileSync(join(target, RECORD), "utf8")) as InstallRecord;
252 } catch {
253 return undefined;
254 }
257function writeRecord(target: string, record: InstallRecord): void {
258 writeFileSync(join(target, `${RECORD}.next`), `${JSON.stringify(record, null, 2)}\n`);
259 renameRetrying(join(target, `${RECORD}.next`), join(target, RECORD));
262/** What is installed now. A folder from before .avcs-install.json: the spec's files that are there. */
263function installedNow(spec: ModSpec, target: string, record: InstallRecord | undefined): Install | undefined {
264 const files = (record?.files ?? spec.files).filter((rel) => existsSync(at(target, rel)));
265 if (files.length === 0) return undefined;
266 if (record) return { version: record.version, files, from: record.from, at: record.at };
267 let version = "unknown";
268 try {
269 version = String(
270 (JSON.parse(readFileSync(at(target, MANIFEST), "utf8")) as { version?: unknown }).version ?? version,
271 );
272 } catch {}
273 return { version, files, from: "unknown", at: "unknown" };
276/** Sleeps without an event loop, between tries of a rename. */
277function pause(ms: number): void {
278 Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
281/** A rename, tried for about a second while Windows says another process has the file open. */
282function renameRetrying(from: string, to: string): void {
283 for (let i = 0; ; i++) {
284 try {
285 renameSync(from, to);
286 return;
287 } catch (err) {
288 const code = (err as NodeJS.ErrnoException).code ?? "";
289 if (i >= 20 || !["EPERM", "EBUSY", "EACCES"].includes(code)) throw err;
290 pause(50);
291 }
292 }
295/** Holds the mod folder's lock while fn runs. */
296function locked<T>(target: string, fn: () => T): T {
297 const file = join(target, LOCK);
298 try {
299 if (Date.now() - statSync(file).mtimeMs > STALE_LOCK_MS) rmSync(file, { force: true });
300 } catch {}
301 try {
302 closeSync(openSync(file, "wx"));
303 } catch {
304 throw new Error(`another install is running in ${target} (it holds ${LOCK}; if none is, delete that file)`);
305 }
306 try {
307 return fn();
308 } finally {
309 rmSync(file, { force: true });
310 }
313/**
314 * Moves `next` into place in the mod's folder, keeping the files that were
315 * there as .prev files. Each file goes in with a rename, in `next`'s order;
316 * if one fails, the ones already moved are put back and the error is thrown.
317 */
318function moveIn(
319 spec: ModSpec,
320 target: string,
321 next: ReadonlyMap<string, Buffer>,
322 install: Install,
323 rename: (from: string, to: string) => void,
324): Install | undefined {
325 const record = readRecord(target);
326 const current = installedNow(spec, target, record);
327 // After an install that stopped midway, the folder is a mix and the .prev files still hold the last whole install.
328 const prev = record?.moving ? record.prev : current;
329 if (!record?.moving) {
330 for (const rel of new Set([...(record?.prev?.files ?? []), ...(current?.files ?? [])]))
331 rmSync(at(target, rel, ".prev"), { force: true });
332 for (const rel of current?.files ?? []) copyFileSync(at(target, rel), at(target, rel, ".prev"));
333 }
334 const before: InstallRecord = { mod: spec.name, ...(current ?? install), ...(prev ? { prev } : {}) };
335 writeRecord(target, { ...before, moving: install.version });
337 const moved: string[] = [];
338 try {
339 for (const [rel, data] of next) {
340 mkdirSync(dirname(at(target, rel)), { recursive: true });
341 writeFileSync(at(target, rel, ".next"), data);
342 }
343 for (const rel of next.keys()) {
344 rename(at(target, rel, ".next"), at(target, rel));
345 moved.push(rel);
346 }
347 } catch (err) {
348 for (const rel of moved.reverse()) {
349 if (prev?.files.includes(rel)) {
350 copyFileSync(at(target, rel, ".prev"), at(target, rel, ".next"));
351 renameRetrying(at(target, rel, ".next"), at(target, rel));
352 } else {
353 rmSync(at(target, rel), { force: true });
354 }
355 }
356 for (const rel of next.keys()) rmSync(at(target, rel, ".next"), { force: true });
357 if (current) writeRecord(target, before);
358 else rmSync(join(target, RECORD), { force: true });
359 throw err;
360 }
361 // Files the old install had and this one doesn't.
362 for (const rel of current?.files ?? []) if (!next.has(rel)) rmSync(at(target, rel), { force: true });
363 writeRecord(target, { mod: spec.name, ...install, ...(prev ? { prev } : {}) });
364 return prev;
367/** Whether the folder holds exactly `next`. */
368function holds(target: string, files: readonly string[], next: ReadonlyMap<string, Buffer>): boolean {
369 return (
370 files.length === next.size && files.every((rel) => next.get(rel)?.equals(readFileSync(at(target, rel))) ?? false)
371 );
374/** Removes the folders a first install made, if they are empty. */
375function removeEmpty(target: string, files: Iterable<string>): void {
376 const dirs = new Set<string>();
377 for (const rel of files) for (let d = dirname(at(target, rel)); d.length > target.length; d = dirname(d)) dirs.add(d);
378 for (const d of [...dirs, target].sort((a, b) => b.length - a.length)) {
379 try {
380 rmdirSync(d);
381 } catch {}
382 }
385/** Installs the mod from `spec.from` into `options.target` (see the top of this file). */
386export function installMod(spec: ModSpec, options: InstallOptions): Installed {
387 const target = resolve(options.target);
388 const version = versionFor(spec, options.commit);
389 const next = filesFor(spec, version);
390 const existed = existsSync(target);
391 mkdirSync(target, { recursive: true });
392 try {
393 return locked(target, () => {
394 const record = readRecord(target);
395 const current = installedNow(spec, target, record);
396 if (!record?.moving && current && holds(target, current.files, next)) {
397 return { changed: false, version, previous: record?.prev?.version, files: next.size };
398 }
399 const staged = mkdtempSync(join(tmpdir(), `${spec.name}-install-`));
400 try {
401 for (const [rel, data] of next) {
402 mkdirSync(dirname(at(staged, rel)), { recursive: true });
403 writeFileSync(at(staged, rel), data);
404 }
405 const why = options.check(staged);
406 if (why !== undefined) throw new Error(`the staged copy failed its check, so nothing was changed:\n${why}`);
407 } finally {
408 rmSync(staged, { recursive: true, force: true });
409 }
410 const install: Install = {
411 version,
412 files: [...next.keys()],
413 from: spec.from,
414 at: (options.now ?? new Date()).toISOString(),
415 };
416 const prev = moveIn(spec, target, next, install, options.rename ?? renameRetrying);
417 return { changed: true, version, previous: prev?.version, files: next.size };
418 });
419 } catch (err) {
420 // A first install that didn't happen leaves no folder behind.
421 if (!existed) removeEmpty(target, next.keys());
422 throw err;
423 }
426/** Puts the install kept in the .prev files back; the one it replaces becomes the .prev one. */
427export function rollbackMod(spec: ModSpec, options: Pick<InstallOptions, "target" | "rename" | "now">): Installed {
428 const target = resolve(options.target);
429 if (!existsSync(target)) throw new Error(`nothing is installed in ${target}`);
430 return locked(target, () => {
431 const record = readRecord(target);
432 const prev = record?.prev;
433 if (!prev) throw new Error(`no earlier install is kept in ${target}`);
434 const missing = prev.files.filter((rel) => !existsSync(at(target, rel, ".prev")));
435 if (missing.length > 0)
436 throw new Error(
437 `the earlier install's ${missing.join(", ")} ${missing.length === 1 ? "is" : "are"} missing from ${target}`,
438 );
439 const next = new Map(prev.files.map((rel) => [rel, readFileSync(at(target, rel, ".prev"))]));
440 const kept = moveIn(spec, target, next, prev, options.rename ?? renameRetrying);
441 return { changed: true, version: prev.version, previous: kept?.version, files: next.size };
442 });
445/** `claude plugin validate`, then the mod's own tests in Claude Code's plugin test kit, on a staged copy. */
446export function checkWithClaude(spec: ModSpec): (dir: string) => string | undefined {
447 // claude is a .cmd on Windows, so it runs through the shell; the folder is quoted.
448 const claude = (what: string, dir: string) =>
449 spawnSync(`claude plugin ${what} "${dir}"`, { shell: true, encoding: "utf8", timeout: 180_000 });
450 const tail = (r: { stdout: string; stderr: string }) =>
451 `${r.stdout ?? ""}${r.stderr ?? ""}`.trim().split("\n").slice(-15).join("\n");
452 return (dir) => {
453 const valid = claude("validate", dir);
454 if (valid.status !== 0) return `claude plugin validate failed (--unchecked skips the check):\n${tail(valid)}`;
455 if (spec.test === undefined) return undefined;
456 copyFileSync(at(spec.from, spec.test), at(dir, spec.test));
457 const tests = claude("test", dir);
458 if (tests.status !== 0) return `the mod's tests failed on the staged copy:\n${tail(tests)}`;
459 return undefined;
460 };
463/** The installers' command line: [folder] [--rollback] [--unchecked]. */
464export function runInstaller(
465 spec: ModSpec,
466 script: string,
467 defaultTarget: string,
468 argv: readonly string[] = process.argv.slice(2),
469): void {
470 const options = argv.filter((a) => a.startsWith("--"));
471 const folders = argv.filter((a) => !a.startsWith("--"));
472 const unknown = options.find((o) => o !== "--rollback" && o !== "--unchecked");
473 if (unknown !== undefined || folders.length > 1) {
474 console.error(
475 `usage: node client/${script} [folder] [--rollback] [--unchecked]${unknown ? ` (unknown option ${unknown})` : ""}`,
476 );
477 process.exit(2);
478 }
479 const target = resolve(folders[0] ?? defaultTarget);
480 try {
481 if (options.includes("--rollback")) {
482 const r = rollbackMod(spec, { target });
483 console.log(
484 `Rolled the ${spec.name} mod back to ${r.version} in ${target}. ${r.previous ? `${r.previous} is kept; --rollback again puts it back. ` : ""}Restart open chats to load it.`,
485 );
486 return;
487 }
488 const unchecked = options.includes("--unchecked");
489 const r = installMod(spec, { target, check: unchecked ? () => undefined : checkWithClaude(spec) });
490 // Only for the real skills folder: an install to another folder leaves the old mod alone.
491 const retired = target === resolve(skillsFolder(spec.name)) ? retireOldMod(spec) : undefined;
492 if (retired) console.log(`Moved the old ${OLD_MOD_NAMES[spec.name]} mod out of the skills folder, to ${retired}.`);
493 if (!r.changed) {
494 console.log(`The ${spec.name} mod ${r.version} is already installed in ${target}; nothing changed.`);
495 return;
496 }
497 const kept = r.previous ? ` The one it replaced (${r.previous}) is kept; --rollback puts it back.` : "";
498 console.log(
499 `Installed the ${spec.name} mod ${r.version} in ${target} (${r.files} files${unchecked ? ", unchecked" : ", validated and tested first"}).${kept} New chats load it; restart open ones to load it.`,
500 );
501 } catch (err) {
502 console.error(
503 `The ${spec.name} mod was not ${options.includes("--rollback") ? "rolled back" : "installed"}: ${(err as Error).message}`,
504 );
505 process.exit(1);
506 }
509export interface ModInstall {
510 readonly name: string;
511 readonly folder: string;
512 /** Undefined when it isn't installed. */
513 readonly version: string | undefined;
514 /** When it was installed (mods installed before .avcs-install.json have none). */
515 readonly at: string | undefined;
516 /** What an install from this client would stamp now. */
517 readonly current: string;
520/** `avcs --version`: this client, and the mods installed on this machine, compared with this client's. */
521export function versionReport(env: Readonly<Record<string, string | undefined>>): {
522 text: string;
523 json: Record<string, unknown>;
524} {
525 const client = clientVersion();
526 const lines = [`abso ${client} (${clientPlace()})`];
527 const mods: ModInstall[] = [];
528 for (const [spec, installer] of [
529 [AVCS_MOD, "install-mod.ts"],
530 [VIEW_MOD, "install-view.ts"],
531 ] as const) {
532 const folder = skillsFolder(spec.name, env);
533 const field = (rel: string, key: string): string | undefined => {
534 try {
535 const value = (JSON.parse(readFileSync(at(folder, rel), "utf8")) as Record<string, unknown>)[key];
536 return typeof value === "string" ? value : undefined;
537 } catch {
538 return undefined;
539 }
540 };
541 const m: ModInstall = {
542 name: spec.name,
543 folder,
544 version: field(MANIFEST, "version"),
545 at: field(RECORD, "at"),
546 current: (() => {
547 try {
548 return versionFor(spec, keptModCommit(spec));
549 } catch {
550 return "not in this copy";
551 }
552 })(),
553 };
554 mods.push(m);
555 if (m.version === undefined) {
556 lines.push(`the ${m.name} mod: not installed (node client/${installer})`);
557 continue;
558 }
559 const when = m.at ? `, installed ${m.at.slice(0, 16).replace("T", " ")} UTC` : "";
560 const behind =
561 m.version === m.current ? "" : `; this client has ${m.current}: node client/${installer} installs it`;
562 lines.push(`the ${m.name} mod: ${m.version} in ${m.folder}${when}${behind}`);
563 }
564 return { text: lines.join("\n"), json: { client, folder: CLIENT_DIR, mods } };
567/**
568 * For `abso status` (abso issue 41: every chat ran a mod a day behind main,
569 * and only `--version` would have said so): each installed mod this client
570 * would install differently. Says nothing unless this client knows its mod's
571 * commit (a git checkout, as the shared one is) and the installed one has one.
572 */
573export function modsBehindText(env: Readonly<Record<string, string | undefined>>): string[] {
574 const installers: Record<string, string> = { [AVCS_MOD.name]: "install-mod.ts", [VIEW_MOD.name]: "install-view.ts" };
575 return (versionReport(env).json.mods as ModInstall[])
576 .filter((m) => m.version?.includes("+") && /\+[0-9a-f]{7}$/.test(m.current) && m.version !== m.current)
577 .map(
578 (m) =>
579 `The ${m.name} mod installed on this machine is ${m.version}, and this client has ${m.current}: node client/${installers[m.name]} installs it (new chats load it).`,
580 );