Files
hermes-agent/ui-tui/scripts/visual/run.mjs
Maciej Lisiewski 7062229090 chore(js): switch the workspaces from npm to pnpm
pnpm 12.15.0 (native executable) installs every JS workspace from one
pnpm-lock.yaml, imported from package-lock.json with the same resolved
versions. website/, the WhatsApp bridge and the photon sidecar stay separate
npm projects.

Configuration moves from .npmrc and the root manifest into
pnpm-workspace.yaml: the 14-day minimumReleaseAge and its excludes,
overrides, allowBuilds (the old allowScripts set, with strictDepBuilds
failing any unlisted build script), engineStrict, sideEffectsCache: false
(in-place rebuilds must not write into the store) and
verifyDepsBeforeRun: false (a `pnpm run` never installs).

The pnpm version is pinned in pm/lock.json and in root devEngines.
pmOnFail: ignore keeps that pin out of pnpm-lock.yaml: a leading pin
document makes osv-scanner read zero packages. scripts/build/node-deps.mjs
enforces the exact version instead, and every lock reader refuses a
multi-document lock. A root preinstall refuses `npm install`; devEngines
onFail is warn so npx (MCP servers, the tsc linter) keeps working inside
the checkout.

User-machine installs run --frozen-lockfile --trust-lockfile (release age is
checked when locking, in CI, not per user). node-deps removes npm-era
node_modules trees before the first pnpm install. Nix builds the store with
fetchPnpmDeps and a hash file that CI checks.
2026-11-06 04:08:24 +01:00

48 lines
1.7 KiB
JavaScript

// Zero-dependency launcher for the visual harness (`pnpm run visual`).
//
// - Sets FORCE_COLOR/COLORTERM itself instead of POSIX `VAR=x cmd` shell
// assignments (which break under the Windows npm command shell) — no
// cross-env needed.
// - Resolves electron from the desktop workspace, which already ships it,
// instead of declaring a second copy as a ui-tui dependency. ELECTRON_BIN
// overrides for exotic setups.
import { spawnSync } from 'child_process'
import { createRequire } from 'module'
import { dirname, join } from 'path'
import { fileURLToPath } from 'url'
const here = dirname(fileURLToPath(import.meta.url))
const require = createRequire(import.meta.url)
const run = (bin, args, env = {}) => {
const { status } = spawnSync(bin, args, { env: { ...process.env, ...env }, stdio: 'inherit' })
if (status !== 0) {
process.exit(status ?? 1)
}
}
// 1. Render the scene sheet (tsx is a ui-tui devDependency).
run(process.execPath, [require.resolve('tsx/cli'), join(here, 'render.tsx')], {
COLORTERM: 'truecolor',
FORCE_COLOR: '3'
})
// 2. Screenshot it with electron, borrowed from the workspace that owns it.
let electronBin = process.env.ELECTRON_BIN
if (!electronBin) {
try {
// In plain Node, `require('electron')` evaluates to the binary path.
electronBin = createRequire(join(here, '../../../apps/desktop/package.json'))('electron')
} catch {
console.error(
'electron is not installed in this tree — the visual harness borrows it from the\n' +
'desktop workspace. Run `pnpm install --frozen-lockfile` at the repo root, or point ELECTRON_BIN at a binary.'
)
process.exit(1)
}
}
run(electronBin, [join(here, 'shot.mjs')])