{"draft":null,"from":41,"to":318,"files":[{"path":"scripts/pack-npm.mjs","added":73,"removed":0,"diff":"--- /dev/null\n+++ b/scripts/pack-npm.mjs\n@@ -0,0 +1,73 @@\n+// Packs the npm package @abso-cli/abso from this checkout: the client as scripts/build-client.mjs builds it,\n+// for Node 20 or later. It never publishes and never reads npm's sign-in.\n+//\n+//   npm ci && npm run pack:npm -- <version>      (e.g. 0.171.0)\n+//\n+// It writes the package to dist/npm/package/ and its tarball, as npm pack names it, to dist/npm/.\n+// The package's layout: bin/abso.mjs checks Node's version and loads dist/abso.mjs, the bundle, stamped\n+// with the version so the client knows it is an installed package.\n+import { execFileSync } from \"node:child_process\";\n+import { mkdirSync, readFileSync, rmSync, writeFileSync } from \"node:fs\";\n+import { dirname, join, resolve } from \"node:path\";\n+import { fileURLToPath } from \"node:url\";\n+import { buildClient } from \"./build-client.mjs\";\n+\n+const root = resolve(dirname(fileURLToPath(import.meta.url)), \"..\");\n+const version = process.argv[2];\n+if (!version || !/^\\d+\\.\\d+\\.\\d+$/.test(version)) {\n+\tprocess.stderr.write(\"Use: npm run pack:npm -- <version>, such as 0.171.0\\n\");\n+\tprocess.exit(2);\n+}\n+const node = 20;\n+\n+const files = {\n+\t\"package.json\": `${JSON.stringify(\n+\t\t{\n+\t\t\tname: \"@abso-cli/abso\",\n+\t\t\tversion,\n+\t\t\tdescription: \"abso: version control built for AI agents first. The command line client.\",\n+\t\t\tlicense: \"MIT\",\n+\t\t\thomepage: \"https://abso.dev\",\n+\t\t\tkeywords: [\"version control\", \"vcs\", \"agents\", \"ai\", \"abso\"],\n+\t\t\ttype: \"module\",\n+\t\t\tengines: { node: `>=${node}` },\n+\t\t\tbin: { abso: \"bin/abso.mjs\" },\n+\t\t\tfiles: [\"bin\", \"dist\"],\n+\t\t\tpublishConfig: { access: \"public\" },\n+\t\t},\n+\t\tnull,\n+\t\t2,\n+\t)}\\n`,\n+\t// A dynamic import, so an older Node reaches the version check before it reads the bundle.\n+\t\"bin/abso.mjs\": `#!/usr/bin/env node\n+const major = Number(process.versions.node.split(\".\")[0]);\n+if (major < ${node}) {\n+\tprocess.stderr.write(\"abso needs Node ${node} or later, and this is Node \" + process.versions.node + \". Install a newer Node from https://nodejs.org and run abso again.\\\\n\");\n+\tprocess.exit(1);\n+}\n+await import(\"../dist/abso.mjs\");\n+`,\n+\t\"dist/abso.mjs\": buildClient([`globalThis.__ABSO_PACKAGE_VERSION__ = ${JSON.stringify(version)};`]),\n+\t\"README.md\": `# abso\\n\\nabso is version control for agents. This package is the abso command line.\\n\\nIt needs Node ${node} or later. Install it with \\`npm install -g @abso-cli/abso\\`, or run \\`npx @abso-cli/abso help\\`.\\n\\n[abso.dev](https://abso.dev)\\n`,\n+\tLICENSE: readFileSync(join(root, \"LICENSE\"), \"utf8\"),\n+};\n+\n+const out = join(root, \"dist\", \"npm\");\n+const pkg = join(out, \"package\");\n+rmSync(pkg, { recursive: true, force: true });\n+for (const [path, text] of Object.entries(files)) {\n+\tmkdirSync(dirname(join(pkg, path)), { recursive: true });\n+\twriteFileSync(join(pkg, path), text);\n+}\n+// Under npm run, npm_execpath is npm's own script, which runs without a shell on every platform.\n+const npm = process.env.npm_execpath;\n+const pack = [\"pack\", pkg, \"--pack-destination\", out, \"--ignore-scripts\"];\n+const tarball = (\n+\tnpm\n+\t\t? execFileSync(process.execPath, [npm, ...pack], { cwd: root, encoding: \"utf8\" })\n+\t\t: execFileSync(\"npm\", pack, { cwd: root, encoding: \"utf8\", shell: process.platform === \"win32\" })\n+)\n+\t.trim()\n+\t.split(\"\\n\")\n+\t.pop();\n+process.stdout.write(`Packed @abso-cli/abso ${version}: dist/npm/${tarball}\\n`);"}],"unmatched":[]}