{"draft":null,"from":2,"to":318,"files":[{"path":"client/src/install.ts","added":130,"removed":15,"diff":"--- a/client/src/install.ts\n+++ b/client/src/install.ts\n@@ -7,7 +7,7 @@\n //     last commit that changed the mod's own files (0.1.0+702c616, or\n //     0.1.0+702c616.dirty when they differ from it), and hooks/stamp.ts says\n //     the same, so the mod sends it with each call to the server\n-//     (X-Avcs-Client). A commit that changes none of them changes nothing to\n+//     (X-Abso-Client). A commit that changes none of them changes nothing to\n //     install, and nothing to restart for.\n //  2. Checks the staged copy: `claude plugin validate`, then the mod's own\n //     tests in Claude Code's plugin test kit. If either fails, nothing in the\n@@ -45,7 +45,7 @@\n } from \"node:fs\";\n import { homedir, tmpdir } from \"node:os\";\n import { dirname, join, resolve } from \"node:path\";\n-import { CLIENT_DIR, clientPlace, clientVersion } from \"./client-version.ts\";\n+import { builtCopy, CLIENT_DIR, clientPlace, clientVersion, headCommit } from \"./client-version.ts\";\n \n export interface ModSpec {\n \t/** The mod's name, as its plugin.json has it. */\n@@ -94,6 +94,8 @@\n \t/** For tests: the rename that moves each file into place. */\n \treadonly rename?: (from: string, to: string) => void;\n \treadonly now?: Date;\n+\t/** For tests: the command stamped as HOOK_COMMAND, instead of this client's own `abso hook`. */\n+\treadonly hookCommand?: readonly string[];\n }\n \n const RECORD = \".avcs-install.json\";\n@@ -107,27 +109,59 @@\n \n /** The abso mod: what the hook imports first, plugin.json last. src/core.ts is the only client file it imports. */\n export const AVCS_MOD: ModSpec = {\n-\tname: \"avcs\",\n+\tname: \"abso-hooks\",\n \tfrom: CLIENT_DIR,\n \tfiles: [\"src/core.ts\", \"hooks/stamp.ts\", \"hooks/register.ts\", \"hooks/hooks.json\", \".claude-plugin/plugin.json\"],\n \ttest: \"hooks/register.test.ts\",\n };\n \n-/** The avcs-view mod (#12), from client/view. */\n+/** The abso-view mod (#12), from client/view. */\n export const VIEW_MOD: ModSpec = {\n-\tname: \"avcs-view\",\n+\tname: \"abso-view\",\n \tfrom: join(CLIENT_DIR, \"view\"),\n \tfiles: [\"types/index.d.ts\", \"hooks/stamp.ts\", \"hooks/register.tsx\", \"hooks/hooks.json\", \".claude-plugin/plugin.json\"],\n \ttest: \"hooks/register.test.ts\",\n };\n \n+/** The skills folders the mods had before the rename; an install moves them out of the way (see retireOldMod). */\n+export const OLD_MOD_NAMES: Readonly<Record<string, string>> = { \"abso-hooks\": \"avcs\", \"abso-view\": \"avcs-view\" };\n+\n /** Where Claude Code's skills folder keeps a mod. */\n export const skillsFolder = (name: string, env: Readonly<Record<string, string | undefined>> = process.env) =>\n \tjoin(env.CLAUDE_CONFIG_DIR || join(homedir(), \".claude\"), \"skills\", name);\n \n export const modInstalled = (env: Readonly<Record<string, string | undefined>> = process.env) =>\n-\texistsSync(at(skillsFolder(AVCS_MOD.name, env), MANIFEST));\n+\texistsSync(at(skillsFolder(AVCS_MOD.name, env), MANIFEST)) ||\n+\texistsSync(at(skillsFolder(OLD_MOD_NAMES[AVCS_MOD.name]!, env), MANIFEST));\n \n+/** Whether the installed abso mod hands a local project's edits to abso hook: it was installed with a HOOK_COMMAND. */\n+export function modHandsLocal(env: Readonly<Record<string, string | undefined>> = process.env): boolean {\n+\ttry {\n+\t\treturn /HOOK_COMMAND[^=\\n]*=\\s*\\[/.test(readFileSync(at(skillsFolder(AVCS_MOD.name, env), STAMP_FILE), \"utf8\"));\n+\t} catch {\n+\t\treturn false;\n+\t}\n+}\n+\n+/**\n+ * After the new mod is in, the folder it replaces (skills/avcs, skills/avcs-view) would load beside it, so it\n+ * is moved, not deleted, to ~/.abso/retired-mods/<name>-<stamp>. Returns where it went, or undefined when there was none.\n+ */\n+export function retireOldMod(\n+\tspec: ModSpec,\n+\tenv: Readonly<Record<string, string | undefined>> = process.env,\n+\tnow: Date = new Date(),\n+): string | undefined {\n+\tconst old = OLD_MOD_NAMES[spec.name];\n+\tif (old === undefined) return undefined;\n+\tconst from = skillsFolder(old, env);\n+\tif (!existsSync(from)) return undefined;\n+\tconst to = join(homedir(), \".abso\", \"retired-mods\", `${old}-${now.toISOString().replace(/[:.]/g, \"-\")}`);\n+\tmkdirSync(dirname(to), { recursive: true });\n+\trenameRetrying(from, to);\n+\treturn to;\n+}\n+\n /** 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). */\n export function versionFor(spec: ModSpec, commit?: string | null): string {\n \tconst manifest = JSON.parse(readFileSync(at(spec.from, MANIFEST), \"utf8\")) as { version?: unknown };\n@@ -144,8 +178,70 @@\n \treturn `${last.stdout.slice(0, 7)}${changed ? \".dirty\" : \"\"}`;\n }\n \n-/** The files to install, stamped with `version`, in install order. */\n-function filesFor(spec: ModSpec, version: string): Map<string, Buffer> {\n+/** A file changed this close to when an answer was kept can't be told apart from one changed just after it. */\n+const RACY_MS = 2_000;\n+\n+interface KeptModCommit {\n+\treadonly head: string;\n+\treadonly files: readonly string[];\n+\treadonly at: number;\n+\treadonly commit: string | null;\n+}\n+\n+/**\n+ * modCommit for the version report, which `abso status` asks on every run: it runs git twice per mod, so\n+ * the answer is kept in ~/.abso/mod-commits.json. A kept answer holds while the checkout's commit (read\n+ * from .git, without git) and each of the mod's files (size, modified time, inode) are as they were, and\n+ * every file was changed clearly before the answer was kept; anything else asks git again. Outside a git\n+ * checkout there is no commit, and git isn't run at all.\n+ */\n+export function keptModCommit(spec: ModSpec, home: string = homedir()): string | null {\n+\tconst head = headCommit(spec.from);\n+\tif (head === undefined) return null;\n+\tconst at = Date.now();\n+\tconst files = spec.files.map((rel) => {\n+\t\ttry {\n+\t\t\tconst s = statSync(join(spec.from, ...rel.split(\"/\")));\n+\t\t\treturn `${s.size}:${s.mtimeMs}:${s.ino}`;\n+\t\t} catch {\n+\t\t\treturn \"-\";\n+\t\t}\n+\t});\n+\tconst newest = Math.max(...files.map((f) => (f === \"-\" ? 0 : Number(f.split(\":\")[1]))));\n+\tconst path = join(home, \".abso\", \"mod-commits.json\");\n+\tconst key = `${resolve(spec.from)}|${spec.files.join(\"|\")}`;\n+\tlet kept: Record<string, KeptModCommit> = {};\n+\ttry {\n+\t\tconst parsed = JSON.parse(readFileSync(path, \"utf8\")) as { format?: unknown; mods?: unknown };\n+\t\tif (parsed.format === 1 && typeof parsed.mods === \"object\" && parsed.mods !== null)\n+\t\t\tkept = parsed.mods as Record<string, KeptModCommit>;\n+\t} catch {}\n+\tconst was = kept[key];\n+\tif (\n+\t\twas !== undefined &&\n+\t\twas.head === head &&\n+\t\tArray.isArray(was.files) &&\n+\t\twas.files.join() === files.join() &&\n+\t\tnewest < was.at - RACY_MS\n+\t)\n+\t\treturn was.commit;\n+\tconst commit = modCommit(spec);\n+\ttry {\n+\t\tmkdirSync(dirname(path), { recursive: true });\n+\t\tconst next = `${path}.${process.pid}.tmp`;\n+\t\twriteFileSync(next, JSON.stringify({ format: 1, mods: { ...kept, [key]: { head, files, at, commit } } }));\n+\t\trenameSync(next, path);\n+\t} catch {\n+\t\t// Best effort: the next run asks git again.\n+\t}\n+\treturn commit;\n+}\n+\n+/** The command that runs this checkout's `abso hook`: what the mod hands a local project's edits to. */\n+export const hookCommand = (): readonly string[] => [process.execPath, join(CLIENT_DIR, \"abso.ts\"), \"hook\"];\n+\n+/** The files to install, stamped with `version` (and HOOK_COMMAND, where a stamp.ts has it), in install order. */\n+function filesFor(spec: ModSpec, version: string, hook: readonly string[] = hookCommand()): Map<string, Buffer> {\n \tif (!/^[\\w.+-]+$/.test(version)) throw new Error(`can't stamp the version ${JSON.stringify(version)}`);\n \tconst out = new Map<string, Buffer>();\n \tfor (const rel of spec.files) {\n@@ -157,7 +253,9 @@\n \t\t\tconst text = data.toString(\"utf8\");\n \t\t\tconst stamped = text.replace(/(STAMP[^=\\n]*=\\s*)undefined/, `$1'${version}'`);\n \t\t\tif (stamped === text) throw new Error(`${rel} has no \"STAMP ... = undefined\" line to stamp`);\n-\t\t\tdata = Buffer.from(stamped);\n+\t\t\tdata = Buffer.from(\n+\t\t\t\tstamped.replace(/(HOOK_COMMAND[^=\\n]*=\\s*)undefined/, (_, head: string) => head + JSON.stringify(hook)),\n+\t\t\t);\n \t\t}\n \t\tout.set(rel, data);\n \t}\n@@ -304,7 +402,7 @@\n export function installMod(spec: ModSpec, options: InstallOptions): Installed {\n \tconst target = resolve(options.target);\n \tconst version = versionFor(spec, options.commit);\n-\tconst next = filesFor(spec, version);\n+\tconst next = filesFor(spec, version, options.hookCommand);\n \tconst existed = existsSync(target);\n \tmkdirSync(target, { recursive: true });\n \ttry {\n@@ -405,6 +503,9 @@\n \t\t}\n \t\tconst unchecked = options.includes(\"--unchecked\");\n \t\tconst r = installMod(spec, { target, check: unchecked ? () => undefined : checkWithClaude(spec) });\n+\t\t// Only for the real skills folder: an install to another folder leaves the old mod alone.\n+\t\tconst retired = target === resolve(skillsFolder(spec.name)) ? retireOldMod(spec) : undefined;\n+\t\tif (retired) console.log(`Moved the old ${OLD_MOD_NAMES[spec.name]} mod out of the skills folder, to ${retired}.`);\n \t\tif (!r.changed) {\n \t\t\tconsole.log(`The ${spec.name} mod ${r.version} is already installed in ${target}; nothing changed.`);\n \t\t\treturn;\n@@ -432,7 +533,18 @@\n \treadonly current: string;\n }\n \n-/** `avcs --version`: this client, and the mods installed on this machine, compared with this client's. */\n+/**\n+ * The command that runs one of this client's installers (client/install-mod.ts or install-view.ts), by its full\n+ * path. They are .ts files, which Node runs itself from 22.18, so on an older Node it says which one it needs.\n+ */\n+export function installerCommand(installer: string): string {\n+\tconst command = `node ${join(CLIENT_DIR, installer)}`;\n+\treturn (process.features as { typescript?: unknown }).typescript\n+\t\t? command\n+\t\t: `${command} (with Node 22.18 or later, which runs .ts files; this is Node ${process.versions.node})`;\n+}\n+\n+/** `abso --version`: this client, and the mods installed on this machine, compared with this client's. */\n export function versionReport(env: Readonly<Record<string, string | undefined>>): {\n \ttext: string;\n \tjson: Record<string, unknown>;\n@@ -460,20 +572,23 @@\n \t\t\tat: field(RECORD, \"at\"),\n \t\t\tcurrent: (() => {\n \t\t\t\ttry {\n-\t\t\t\t\treturn versionFor(spec);\n+\t\t\t\t\treturn versionFor(spec, keptModCommit(spec));\n \t\t\t\t} catch {\n \t\t\t\t\treturn \"not in this copy\";\n \t\t\t\t}\n \t\t\t})(),\n \t\t};\n \t\tmods.push(m);\n+\t\t// A built copy has no mod files to compare with or install from: it reports what is installed.\n \t\tif (m.version === undefined) {\n-\t\t\tlines.push(`the ${m.name} mod: not installed (node client/${installer})`);\n+\t\t\tlines.push(`the ${m.name} mod: not installed${builtCopy() ? \"\" : ` (${installerCommand(installer)})`}`);\n \t\t\tcontinue;\n \t\t}\n \t\tconst when = m.at ? `, installed ${m.at.slice(0, 16).replace(\"T\", \" \")} UTC` : \"\";\n \t\tconst behind =\n-\t\t\tm.version === m.current ? \"\" : `; this client has ${m.current}: node client/${installer} installs it`;\n+\t\t\tbuiltCopy() || m.version === m.current\n+\t\t\t\t? \"\"\n+\t\t\t\t: `; this client has ${m.current}: ${installerCommand(installer)} installs it`;\n \t\tlines.push(`the ${m.name} mod: ${m.version} in ${m.folder}${when}${behind}`);\n \t}\n \treturn { text: lines.join(\"\\n\"), json: { client, folder: CLIENT_DIR, mods } };\n@@ -491,6 +606,6 @@\n \t\t.filter((m) => m.version?.includes(\"+\") && /\\+[0-9a-f]{7}$/.test(m.current) && m.version !== m.current)\n \t\t.map(\n \t\t\t(m) =>\n-\t\t\t\t`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).`,\n+\t\t\t\t`The ${m.name} mod installed on this machine is ${m.version}, and this client has ${m.current}: ${installerCommand(installers[m.name]!)} installs it (new chats load it).`,\n \t\t);\n }"}],"unmatched":[]}