Skip to content

Add stateless headless CLI - #3668

Draft
nkmlombardi wants to merge 1 commit into
JannisX11:nextfrom
nkmlombardi:feat/headless-cli
Draft

Add stateless headless CLI#3668
nkmlombardi wants to merge 1 commit into
JannisX11:nextfrom
nkmlombardi:feat/headless-cli

Conversation

@nkmlombardi

Copy link
Copy Markdown

What changed

Adds a one-shot, stateless headless CLI to the desktop app:

Blockbench --headless \
  --input creature.bbmodel \
  --script transform.js \
  --output creature_modified.bbmodel
  • Boots Blockbench in a hidden offscreen renderer, so scripts use the real live globals (Project, Cube, Group, Mesh, Texture, Undo, Canvas, codecs, etc.).
  • Loads through Blockbench's normal model-loading path and saves .bbmodel output through Codecs.project.
  • Supports async script bodies, CommonJS function exports, --eval, trailing script arguments, --force, and a configurable timeout.
  • Emits a machine-readable JSON result and phase-specific process exit codes.
  • Uses a unique temporary profile for every invocation and removes it after Chromium exits.
  • Skips plugin loading/network calls, updates, recent-project state, backups, and other persistent desktop startup work in headless mode.
  • Atomically claims non-forced output paths so concurrent actions cannot both overwrite the same destination.
  • Documents the CLI and its trusted-code security boundary.

Why

Automation currently requires either raw file transformations, which bypass Blockbench's runtime behavior, or a long-lived interactive/plugin server with shared project state. This provides a direct process boundary: one input, one action against the actual renderer APIs, one output, then exit.

Independent invocations do not share Project, Undo, scene, codec, profile, port, or plugin state, so batch workers and coding agents can safely operate on different model files in parallel.

Validation

  • npm run build-electron
  • npx tsc --project tsconfig.json --noEmit
  • npm run test-headless-cli — 5 parser/profile tests
  • node --test tests/headless_cli.e2e.test.js — help, preflight failure, live-global edit/save, and script failure tests
  • BLOCKBENCH_HEADLESS_CONCURRENCY=24 node --test tests/headless_cli.concurrent.test.js — 24 independent actions completed in 8.2s; same-output collision test passed
  • electron-builder --dir --win --x64 --config.win.signAndEditExecutable=false
  • The packaged Windows executable passed the same 4 end-to-end tests

The existing non-headless startup path remains the default and retains its normal profile, plugins, updater, backups, recent-project handling, and visible window behavior.

@netlify

netlify Bot commented Aug 8, 2026

Copy link
Copy Markdown

Deploy Preview for blockbench-dev ready!

Name Link
🔨 Latest commit f0f63c8
🔍 Latest deploy log https://app.netlify.com/projects/blockbench-dev/deploys/6a76f04a6834390008601be2
😎 Deploy Preview https://deploy-preview-3668--blockbench-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant