Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: give the Node version floor one owner and check it before install (#3863)
[._.]/ Adam Eivy7ca77f327ac1
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 272cc89d7e..0def41f5d5 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -39,4 +39,5 @@- The theme switcher, the media collection picker, and the Shell photo composer now dismiss through the shared click-outside hook instead of three private copies of the same two-ref check, so the rule that a portaled panel counts as "inside" its own trigger lives in one place. Escape still closes each of them.- Collapsible section headers in the canon cards, the character detail editor, and the digital-twin interview analysis card now announce their open/closed state to a screen reader. They were five separate hand-rolled copies of the same header, none of which reported that state, and all five now share one primitive so a layout fix lands in one place instead of three.- The memory list and timeline endpoints now validate their query strings against the Zod schemas that were written for them. Both handlers had been hand-parsing `req.query`, so the declared bounds went unenforced: an unknown memory type, a garbled `limit`, or a nonsense date range was quietly accepted and passed to the database. Both schemas now also accept the comma-separated, string-valued form a query string actually arrives in, and the list `limit` ceiling is 500 — the bound the route has always enforced in practice — rather than the 100 its schema claimed. The timeline endpoint also finally honours an `appId` filter, which both of its backends have always supported but the hand-written parsing never passed along.-- Agents run on an API provider (LM Studio, raw OpenAI/Anthropic — anything with no native filesystem tools) now receive the per-directory `CLAUDE.md` files too, not just the global and repo-root ones. Those agents read nothing off disk on their own, so a convention that lived in `server/CLAUDE.md` or `client/src/CLAUDE.md` reached them as a pointer with no contents — which is how relocating a backup rsync-exclude rule out of the root file silently removed a data-loss guard from that whole class of agent. Nested files are now discovered under the workspace and spliced in after the root one, each labeled with its repo-relative path, bounded to 10 files and 5 levels deep and skipping vendored, generated, and runtime trees.\ No newline at end of file+- Agents run on an API provider (LM Studio, raw OpenAI/Anthropic — anything with no native filesystem tools) now receive the per-directory `CLAUDE.md` files too, not just the global and repo-root ones. Those agents read nothing off disk on their own, so a convention that lived in `server/CLAUDE.md` or `client/src/CLAUDE.md` reached them as a pointer with no contents — which is how relocating a backup rsync-exclude rule out of the root file silently removed a data-loss guard from that whole class of agent. Nested files are now discovered under the workspace and spliced in after the root one, each labeled with its repo-relative path, bounded to 10 files and 5 levels deep and skipping vendored, generated, and runtime trees.+- The Node version PortOS requires is now written down in exactly one place and checked before anything slow runs. The floor was copied into five sites that could drift apart — both setup scripts, `.nvmrc`, the CI workflows and the README — while the install path the README actually documents (`npm run setup`, `npm start`) checked none of them, so an unsupported Node installed happily for several minutes and then failed inside Vite with an error that never named the cause. `scripts/checkNodeVersion.js` now owns the number (22.12), runs first in the root `setup`, `start` and `dev` scripts so an old Node fails in the first second, and a drift test holds the other sites to it — the shell gates and the README to the floor exactly, `.nvmrc` and CI to at-or-above it, since running CI on 24 while supporting 22.12 is a preference rather than a mistake. All four `package.json` files now declare `engines` as well.diff --git a/.npmrc b/.npmrcindex adaf6de7a3..e2b20841e5 100644--- a/.npmrc+++ b/.npmrc@@ -14,3 +14,16 @@# server needs any: node-pty (native PTY addon), sharp (insurance — ships# prebuilt bindings today), and onnxruntime-node / protobufjs (best-effort).ignore-scripts=true++# Deliberately NOT engine-strict (issue #3863). The Node floor lives in+# scripts/checkNodeVersion.js (MIN_NODE) and is mirrored into this workspace's+# `engines` field, but `engine-strict=true` makes npm treat EBADENGINE as fatal+# for *dependencies* too, not just for this project — so one transitive package+# shipping a narrow range breaks `npm install` on a Node the project fully+# supports. That is not hypothetical: jsdom@30 requires+# `^22.22.2 || ^24.15.0 || >=26`, which a supported Node 24.14 fails. PortOS is+# distributed software installed on many machines and Node patch levels, so the+# floor is enforced by `node scripts/checkNodeVersion.js` at the head of the+# root `setup` / `start` / `dev` scripts instead — a check that gates on this+# project's floor and nothing else. `engines` stays for the npm warning and as+# the machine-readable declaration.diff --git a/autofixer/.npmrc b/autofixer/.npmrcindex cec2d7f8e6..8c5481f990 100644--- a/autofixer/.npmrc+++ b/autofixer/.npmrc@@ -4,3 +4,16 @@## No autofixer dependency needs an install script.ignore-scripts=true++# Deliberately NOT engine-strict (issue #3863). The Node floor lives in+# scripts/checkNodeVersion.js (MIN_NODE) and is mirrored into this workspace's+# `engines` field, but `engine-strict=true` makes npm treat EBADENGINE as fatal+# for *dependencies* too, not just for this project — so one transitive package+# shipping a narrow range breaks `npm install` on a Node the project fully+# supports. That is not hypothetical: jsdom@30 requires+# `^22.22.2 || ^24.15.0 || >=26`, which a supported Node 24.14 fails. PortOS is+# distributed software installed on many machines and Node patch levels, so the+# floor is enforced by `node scripts/checkNodeVersion.js` at the head of the+# root `setup` / `start` / `dev` scripts instead — a check that gates on this+# project's floor and nothing else. `engines` stays for the npm warning and as+# the machine-readable declaration.diff --git a/autofixer/package.json b/autofixer/package.jsonindex eac7fad831..1f9ba97cc3 100644--- a/autofixer/package.json+++ b/autofixer/package.json@@ -3,6 +3,9 @@"version": "1.0.0","private": true,"type": "module",+ "engines": {+ "node": ">=22.12.0"+ },"dependencies": {"express": "5.2.1"}diff --git a/client/.npmrc b/client/.npmrcindex 2127b9ef18..c6bb7f64fd 100644--- a/client/.npmrc+++ b/client/.npmrc@@ -11,3 +11,16 @@# No client dependency currently needs an install script, so there is nothing to# rebuild for this workspace (vite 8 dropped the esbuild binary dependency).ignore-scripts=true++# Deliberately NOT engine-strict (issue #3863). The Node floor lives in+# scripts/checkNodeVersion.js (MIN_NODE) and is mirrored into this workspace's+# `engines` field, but `engine-strict=true` makes npm treat EBADENGINE as fatal+# for *dependencies* too, not just for this project — so one transitive package+# shipping a narrow range breaks `npm install` on a Node the project fully+# supports. That is not hypothetical: jsdom@30 requires+# `^22.22.2 || ^24.15.0 || >=26`, which a supported Node 24.14 fails. PortOS is+# distributed software installed on many machines and Node patch levels, so the+# floor is enforced by `node scripts/checkNodeVersion.js` at the head of the+# root `setup` / `start` / `dev` scripts instead — a check that gates on this+# project's floor and nothing else. `engines` stays for the npm warning and as+# the machine-readable declaration.diff --git a/client/package.json b/client/package.jsonindex 0f7388a3c2..65cbc61a50 100644--- a/client/package.json+++ b/client/package.json@@ -3,6 +3,9 @@"version": "1.7.0","private": true,"type": "module",+ "engines": {+ "node": ">=22.12.0"+ },"scripts": {"dev": "vite --host 0.0.0.0 --port 5554","build": "vite build",diff --git a/package.json b/package.jsonindex 5bcc70982d..e827d26152 100644--- a/package.json+++ b/package.json@@ -6,11 +6,14 @@"author": "Adam Eivy (@antic|@atomantic)","license": "MIT","type": "module",+ "engines": {+ "node": ">=22.12.0"+ },"scripts": {- "dev": "node scripts/dev-start.js",+ "dev": "node scripts/checkNodeVersion.js && node scripts/dev-start.js","dev:stop": "node ./node_modules/pm2/bin/pm2 stop ecosystem.config.cjs","build": "npm run build --prefix client",- "start": "node scripts/ensure-deps.js && npm run build && node scripts/setup-db.js && node scripts/setup-cert.js && (node ./node_modules/pm2/bin/pm2 delete ecosystem.config.cjs --silent || echo pm2 delete skipped) && node ./node_modules/pm2/bin/pm2 start ecosystem.config.cjs && node ./node_modules/pm2/bin/pm2 save",+ "start": "node scripts/checkNodeVersion.js && node scripts/ensure-deps.js && npm run build && node scripts/setup-db.js && node scripts/setup-cert.js && (node ./node_modules/pm2/bin/pm2 delete ecosystem.config.cjs --silent || echo pm2 delete skipped) && node ./node_modules/pm2/bin/pm2 start ecosystem.config.cjs && node ./node_modules/pm2/bin/pm2 save","pm2:start": "node ./node_modules/pm2/bin/pm2 start ecosystem.config.cjs","pm2:stop": "node ./node_modules/pm2/bin/pm2 stop ecosystem.config.cjs","pm2:restart": "node ./node_modules/pm2/bin/pm2 restart ecosystem.config.cjs",@@ -20,7 +23,7 @@"pm2:startup": "node ./node_modules/pm2/bin/pm2 startup","install:all": "npm run setup","migrations": "node scripts/run-migrations.js",- "setup": "git submodule update --init --recursive && npm install && npm install --prefix client && npm install --prefix server && npm install --prefix autofixer && node scripts/trusted-rebuilds.js server && node scripts/setup-data.js && node scripts/setup-db.js && node scripts/setup-llm.js && node scripts/setup-browser.js",+ "setup": "node scripts/checkNodeVersion.js && git submodule update --init --recursive && npm install && npm install --prefix client && npm install --prefix server && npm install --prefix autofixer && node scripts/trusted-rebuilds.js server && node scripts/setup-data.js && node scripts/setup-db.js && node scripts/setup-llm.js && node scripts/setup-browser.js","setup:data": "node scripts/setup-data.js","setup:db": "node scripts/setup-db.js","setup:db:test": "npm run setup:db:test --prefix server",diff --git a/scripts/checkNodeVersion.js b/scripts/checkNodeVersion.jsnew file mode 100644index 0000000000..c6b5ae051b--- /dev/null+++ b/scripts/checkNodeVersion.js@@ -0,0 +1,80 @@+/**+ * Single source of truth for the Node.js version floor (issue #3863).+ *+ * The floor used to be copied into five places that could drift independently+ * (setup.sh, setup.ps1, .nvmrc, the CI workflows, README prose) while the+ * primary install path — `npm run setup` && `npm start`, straight out of the+ * README — enforced none of them. On an unsupported Node the install would+ * succeed, several minutes would pass, and the run would die inside Vite with+ * an error that never names the cause.+ *+ * MIN_NODE below is now the only place the floor is written down:+ * - the four `engines` fields declare it machine-readably (npm warns on a+ * mismatch; `engine-strict` is deliberately NOT set — see the .npmrc note,+ * it would make one dependency's narrow range break every install),+ * - `npm run setup` / `npm start` / `npm run dev` run this file first, so an+ * unsupported Node fails in the first second instead of the fifth minute,+ * - scripts/node-version-drift.test.js fails if any of the other sites is+ * left behind when MIN_NODE moves.+ *+ * Why 22.12 and not Vite's own `^20.19 || >=22.12`: nothing here is tested on+ * 20 (.nvmrc and every CI job are 24), so advertising 20 would promise a+ * configuration that never actually runs. `.nvmrc`/CI at 24 is a *preference*+ * and is asserted to be >= this floor, not equal to it.+ */++/** The hard floor. Changing the version means changing exactly this string. */+export const MIN_NODE = '22.12.0';++/** Parse `v22.12.0` / `22.12` / `22` into a [major, minor, patch] tuple. */+export function parseVersion(version) {+ const parts = String(version)+ .trim()+ .replace(/^v/, '')+ .split('-')[0]+ .split('.')+ .map((part) => Number.parseInt(part, 10));+ return [parts[0] || 0, parts[1] || 0, parts[2] || 0];+}++/** -1 / 0 / 1, comparing `a` against `b` semver-numerically. */+export function compareVersions(a, b) {+ const left = parseVersion(a);+ const right = parseVersion(b);+ for (let i = 0; i < 3; i += 1) {+ if (left[i] !== right[i]) return left[i] < right[i] ? -1 : 1;+ }+ return 0;+}++/** True when `version` is at or above the floor. */+export function satisfiesMinNode(version = process.versions.node) {+ return compareVersions(version, MIN_NODE) >= 0;+}++/** The one-line failure message, mirroring the shape the shell gates print. */+export function unsupportedNodeMessage(version = process.versions.node) {+ return `Node.js ${MIN_NODE}+ required (found v${String(version).replace(/^v/, '')}) — see .nvmrc`;+}++/**+ * Exit non-zero with `unsupportedNodeMessage` when the running Node is below+ * the floor. Injectable so the test can exercise both branches without+ * spawning a second interpreter or tearing down the runner.+ */+export function assertNodeVersion({+ version = process.versions.node,+ onFail = (message) => {+ console.error(`❌ ${message}`);+ process.exit(1);+ },+} = {}) {+ if (satisfiesMinNode(version)) return true;+ onFail(unsupportedNodeMessage(version));+ return false;+}++// Runnable directly: `node scripts/checkNodeVersion.js`.+if (process.argv[1] && import.meta.url === `file://${process.argv[1]}`) {+ assertNodeVersion();+}diff --git a/scripts/checkNodeVersion.test.js b/scripts/checkNodeVersion.test.jsnew file mode 100644index 0000000000..6ebb18d061--- /dev/null+++ b/scripts/checkNodeVersion.test.js@@ -0,0 +1,89 @@+/**+ * Unit tests for the Node floor gate (issue #3863). The drift test next door+ * checks that every *site* agrees with MIN_NODE; this one checks that the gate+ * itself accepts and rejects the right versions — in particular that a v22.0+ * machine (which the coarse `-lt 22` shell gates wave through) is still+ * rejected by the precise check that `npm run setup` / `npm start` run.+ */+import { describe, it, expect, vi } from 'vitest';++import {+ MIN_NODE,+ assertNodeVersion,+ compareVersions,+ parseVersion,+ satisfiesMinNode,+ unsupportedNodeMessage,+} from './checkNodeVersion.js';++describe('parseVersion', () => {+ it.each([+ ['v22.12.0', [22, 12, 0]],+ ['22.12.0', [22, 12, 0]],+ ['22.12', [22, 12, 0]],+ ['24', [24, 0, 0]],+ [' 24.1.2\n', [24, 1, 2]],+ ['22.12.0-nightly20240101', [22, 12, 0]],+ ])('parses %s', (input, expected) => {+ expect(parseVersion(input)).toEqual(expected);+ });+});++describe('compareVersions', () => {+ it.each([+ ['22.12.0', '22.12.0', 0],+ ['22.11.9', '22.12.0', -1],+ ['22.12.1', '22.12.0', 1],+ ['20.19.0', '22.12.0', -1],+ ['24.0.0', '22.12.0', 1],+ // Numeric, not lexical: "9" > "10" as strings, but not as versions.+ ['22.9.0', '22.10.0', -1],+ ])('compares %s to %s', (a, b, expected) => {+ expect(compareVersions(a, b)).toBe(expected);+ });+});++describe('satisfiesMinNode', () => {+ it('rejects the versions the coarse shell gates would let through', () => {+ // Major 22 clears `-lt 22`, but 22.0/22.11 are below the real Vite floor.+ expect(satisfiesMinNode('22.0.0')).toBe(false);+ expect(satisfiesMinNode('22.11.0')).toBe(false);+ });++ it('rejects the versions the README used to advertise', () => {+ expect(satisfiesMinNode('18.20.0')).toBe(false);+ expect(satisfiesMinNode('20.19.0')).toBe(false);+ });++ it('accepts the floor and everything above it', () => {+ expect(satisfiesMinNode(MIN_NODE)).toBe(true);+ expect(satisfiesMinNode('22.12.1')).toBe(true);+ expect(satisfiesMinNode('v24.0.0')).toBe(true);+ });++ it('defaults to the running interpreter, which must itself satisfy the floor', () => {+ expect(satisfiesMinNode()).toBe(true);+ });+});++describe('assertNodeVersion', () => {+ it('passes without invoking the failure path on a supported Node', () => {+ const onFail = vi.fn();+ expect(assertNodeVersion({ version: '24.1.0', onFail })).toBe(true);+ expect(onFail).not.toHaveBeenCalled();+ });++ it('reports the required and found versions on an unsupported Node', () => {+ const onFail = vi.fn();+ expect(assertNodeVersion({ version: 'v20.19.0', onFail })).toBe(false);+ expect(onFail).toHaveBeenCalledTimes(1);+ const message = onFail.mock.calls[0][0];+ expect(message).toContain(MIN_NODE);+ expect(message).toContain('20.19.0');+ });++ it('does not double up the v prefix', () => {+ expect(unsupportedNodeMessage('v18.0.0')).toContain('found v18.0.0');+ expect(unsupportedNodeMessage('18.0.0')).toContain('found v18.0.0');+ });+});diff --git a/scripts/node-version-drift.test.js b/scripts/node-version-drift.test.jsnew file mode 100644index 0000000000..eb953d56a7--- /dev/null+++ b/scripts/node-version-drift.test.js@@ -0,0 +1,117 @@+/**+ * Drift guard for the Node.js version floor (issue #3863).+ *+ * The floor used to be written out longhand in five independent places —+ * setup.sh, setup.ps1, .nvmrc, the CI workflows, and README prose — with+ * nothing keeping them in agreement, and none of them on the primary+ * `npm run setup` / `npm start` path. scripts/checkNodeVersion.js now owns the+ * number; this test is what makes the other sites follow it.+ *+ * Two different assertions, deliberately:+ * - the *floor* sites (shell gates, `engines`, README prose) must EQUAL+ * MIN_NODE — they promise what the project supports;+ * - the *preference* sites (.nvmrc, CI `node-version`) must be >= MIN_NODE —+ * running CI on 24 while supporting 22.12 is correct, not drift.+ */+import { describe, it, expect } from 'vitest';+import { execFileSync } from 'child_process';+import { readFileSync } from 'fs';+import { dirname, join } from 'path';+import { fileURLToPath } from 'url';++import { MIN_NODE, compareVersions, parseVersion } from './checkNodeVersion.js';++const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');+const [MIN_MAJOR, MIN_MINOR] = parseVersion(MIN_NODE);+/** The README states the floor without its patch component ("22.12"). */+const MIN_NODE_SHORT = `${MIN_MAJOR}.${MIN_MINOR}`;+const ENGINES_RANGE = `>=${MIN_NODE}`;++const read = (rel) => readFileSync(join(REPO_ROOT, rel), 'utf8');+const readJson = (rel) => JSON.parse(read(rel));++const MANIFESTS = ['package.json', 'client/package.json', 'server/package.json', 'autofixer/package.json'];+const NPMRCS = ['.npmrc', 'client/.npmrc', 'server/.npmrc', 'autofixer/.npmrc'];++describe('Node version floor has exactly one owner (issue #3863)', () => {+ it('MIN_NODE is a concrete three-part version', () => {+ expect(MIN_NODE).toMatch(/^\d+\.\d+\.\d+$/);+ });++ describe('floor sites equal MIN_NODE', () => {+ it('setup.sh gates on the MIN_NODE major', () => {+ const match = read('setup.sh').match(/"\$NODE_VERSION"\s+-lt\s+(\d+)/);+ expect(match, 'setup.sh no longer contains a `-lt <major>` Node gate').toBeTruthy();+ expect(Number(match[1])).toBe(MIN_MAJOR);+ });++ it('setup.ps1 gates on the MIN_NODE major', () => {+ const match = read('setup.ps1').match(/\$majorVersion\s+-lt\s+(\d+)/);+ expect(match, 'setup.ps1 no longer contains a `-lt <major>` Node gate').toBeTruthy();+ expect(Number(match[1])).toBe(MIN_MAJOR);+ });++ it.each(MANIFESTS)('%s declares engines.node = the floor', (rel) => {+ expect(readJson(rel).engines?.node).toBe(ENGINES_RANGE);+ });++ it('README states the floor', () => {+ expect(read('README.md')).toContain(`Node.js ${MIN_NODE_SHORT} or later`);+ });+ });++ describe('preference sites stay at or above the floor', () => {+ it('.nvmrc is >= MIN_NODE', () => {+ const nvmrc = read('.nvmrc').trim();+ expect(nvmrc).toMatch(/^\d+(\.\d+)*$/);+ expect(compareVersions(nvmrc, `${MIN_MAJOR}`)).toBeGreaterThanOrEqual(0);+ // A bare major in .nvmrc ("24") resolves to that line's latest release, so+ // compare majors when it omits a minor rather than reading "24" as 24.0.0.+ if (parseVersion(nvmrc)[0] === MIN_MAJOR) {+ expect(compareVersions(nvmrc, MIN_NODE)).toBeGreaterThanOrEqual(0);+ }+ });++ it('every CI job pins a node-version >= MIN_NODE', () => {+ const workflows = execFileSync('git', ['ls-files', '-z', '.github/workflows'], {+ cwd: REPO_ROOT,+ encoding: 'utf8',+ })+ .split('\0')+ .filter(Boolean);+ const pins = workflows.flatMap((rel) =>+ [...read(rel).matchAll(/node-version:\s*['"]?(\d+)(?:\.[\dx]+)*/g)].map((m) => ({+ rel,+ major: Number(m[1]),+ }))+ );+ // Sanity: without this the .each below would pass vacuously.+ expect(pins.length).toBeGreaterThan(0);+ for (const { rel, major } of pins) {+ expect(major, `${rel} pins node-version below the floor`).toBeGreaterThanOrEqual(MIN_MAJOR);+ }+ });+ });++ describe('the floor is actually enforced', () => {+ // Regression guard for the fix that #3863 originally proposed and this+ // change deliberately reversed: `engine-strict=true` makes npm treat+ // EBADENGINE as fatal for *dependencies* as well as for this project, so a+ // single transitive package with a narrow range breaks `npm install` on a+ // Node PortOS fully supports (jsdom@30 wants `^22.22.2 || ^24.15.0 || >=26`+ // — a supported Node 24.14 fails it). Enforcement lives in the script chain+ // below instead. Re-adding this line breaks every install, so it is guarded.+ it.each(NPMRCS)('%s does not set engine-strict', (rel) => {+ expect(read(rel)).not.toMatch(/^\s*engine-strict\s*=\s*true/m);+ });++ it.each(['setup', 'start', 'dev'])(+ 'the root `%s` script runs the version check first',+ (name) => {+ expect(readJson('package.json').scripts[name]).toMatch(+ /^node scripts\/checkNodeVersion\.js &&/+ );+ }+ );+ });+});diff --git a/server/.npmrc b/server/.npmrcindex 3aae64f952..409f7dbe81 100644--- a/server/.npmrc+++ b/server/.npmrc@@ -15,3 +15,16 @@# for you. Skipping that step leaves node-pty unbuilt and the shell/TUI features# will crash on a missing binding.ignore-scripts=true++# Deliberately NOT engine-strict (issue #3863). The Node floor lives in+# scripts/checkNodeVersion.js (MIN_NODE) and is mirrored into this workspace's+# `engines` field, but `engine-strict=true` makes npm treat EBADENGINE as fatal+# for *dependencies* too, not just for this project — so one transitive package+# shipping a narrow range breaks `npm install` on a Node the project fully+# supports. That is not hypothetical: jsdom@30 requires+# `^22.22.2 || ^24.15.0 || >=26`, which a supported Node 24.14 fails. PortOS is+# distributed software installed on many machines and Node patch levels, so the+# floor is enforced by `node scripts/checkNodeVersion.js` at the head of the+# root `setup` / `start` / `dev` scripts instead — a check that gates on this+# project's floor and nothing else. `engines` stays for the npm warning and as+# the machine-readable declaration.diff --git a/server/package.json b/server/package.jsonindex e0077ea87f..604ec79de9 100644--- a/server/package.json+++ b/server/package.json@@ -3,6 +3,9 @@"version": "1.7.1","private": true,"type": "module",+ "engines": {+ "node": ">=22.12.0"+ },"scripts": {"dev": "node --watch index.js","start": "node index.js",