{"version":59,"agent":"pinch","message":"The client reports an npm package's version: a build that sets __ABSO_PACKAGE_VERSION__ gets it from abso --version and in its client header, and a built copy (the npm package or a downloaded abso.mjs) reports the installed mods without pointing at install scripts it doesn't have","time":1791600223045,"timeIso":"2026-10-10T02:43:43.045Z","changes":3,"change":781,"files":["client/src/client-version.ts","client/src/install.ts","client/test/install.test.ts"],"draft":null,"diff":[{"path":"client/src/client-version.ts","added":11,"removed":1,"diff":"--- a/client/src/client-version.ts\n+++ b/client/src/client-version.ts\n@@ -65,6 +65,15 @@\n \treturn typeof stamp === \"string\" && /^[0-9a-f]{7,64}$/.test(stamp) ? stamp.slice(0, 7) : undefined;\n }\n \n+/** Set by the npm package build: the package's version, such as 0.58.0. Absent everywhere else. */\n+function packageVersion(): string | undefined {\n+\tconst stamp = (globalThis as { __ABSO_PACKAGE_VERSION__?: unknown }).__ABSO_PACKAGE_VERSION__;\n+\treturn typeof stamp === \"string\" && /^\\d+\\.\\d+\\.\\d+$/.test(stamp) ? stamp : undefined;\n+}\n+\n+/** A built copy (the npm package or a downloaded abso.mjs), which has no mods to install from, rather than a checkout. */\n+export const builtCopy = (): boolean => packageVersion() !== undefined || bundledCommit() !== undefined;\n+\n let version: string | undefined;\n \n /**\n@@ -86,8 +95,9 @@\n \t}\n }\n \n-/** This client's version: 0.1.0+ed45dad, or plugin.json's alone outside a git checkout. */\n+/** This client's version: the npm package's (0.58.0), else 0.1.0+ed45dad, or plugin.json's alone outside a git checkout. */\n export function clientVersion(): string {\n+\tversion ??= packageVersion();\n \tif (version === undefined) {\n \t\tlet base = \"0.0.0\";\n \t\ttry {"},{"path":"client/src/install.ts","added":6,"removed":3,"diff":"--- a/client/src/install.ts\n+++ b/client/src/install.ts\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, headCommit } 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@@ -552,13 +552,16 @@\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() ? \"\" : ` (node client/${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}: node client/${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 } };"},{"path":"client/test/install.test.ts","added":7,"removed":0,"diff":"--- a/client/test/install.test.ts\n+++ b/client/test/install.test.ts\n@@ -490,4 +490,11 @@\n \t\tassert.equal(headers[\"x-abso-client\"], `abso-cli/${clientVersion()}`);\n \t\tassert.match(clientVersion(), /^\\d+\\.\\d+\\.\\d+(\\+[0-9a-f]{7})?$/);\n \t});\n+\n+\tit(\"the npm package's client gives the package's version\", () => {\n+\t\tconst url = new URL(\"../src/client-version.ts\", import.meta.url).href;\n+\t\tconst script = `globalThis.__ABSO_PACKAGE_VERSION__ = \"0.58.0\"; const m = await import(${JSON.stringify(url)}); console.log(m.clientVersion());`;\n+\t\tconst r = spawnSync(process.execPath, [\"--input-type=module\", \"-e\", script], { encoding: \"utf8\" });\n+\t\tassert.equal(r.stdout.trim(), \"0.58.0\", r.stderr);\n+\t});\n });"}],"ci":null}