Replace the Ink-based @zcode/tui implementation with the Node.js runtime path of
OpenTUI while preserving zcode's release model: one SEA executable per supported
platform and architecture.
The first implementation milestone is intentionally small. The TUI package may
discard the current Ink implementation and expose a basic OpenTUI shell through
the existing runTui(options) API. Business workflows, session state, command
handling, and permission behavior remain owned by the CLI/core packages and will
be wired back into the new renderer incrementally.
The OpenTUI dependency baseline is the local Node-compatible fork published under
the @mbears/opentui-core and @mbears/opentui-react package names. Local development can
wire these packages through file: dependencies or pnpm overrides that point at
../opentui-node/packages/*/dist; release packaging should consume the same
package names from the intended source. It keeps ZCode on the existing Node.js
24.14.x production baseline by using the OpenTUI Node FFI path backed by
koffi, unsafe-pointer, and the platform libopentui native package. Later
OpenTUI work that depends on Node's experimental node:ffi is not a runtime
baseline for this migration.
The CLI SEA entry remains CommonJS. zcode currently targets Node.js 24.14.0, and
that version executes the injected SEA main script as CommonJS. OpenTUI and
@zcode/tui remain ESM packages, so the CJS entry must load them with dynamic
import().
There are two load paths:
@zcode/tui through Node's
package resolver.@zcode/tui entry by
file:// URL.OpenTUI native artifacts must exist as real files. They are not spawned helper programs; they are native libraries loaded by the Node/OpenTUI runtime. The SEA binary therefore embeds them as assets and writes them to the cache before the TUI package is imported.
Each SEA target embeds a target-specific runtime bundle:
@zcode/tui/dist@zcode/tui/package.json@zcode/tui, currently
@zcode/i18n and @zcode/contracts, including each package's dist and
package.json@mbears/opentui-core@mbears/opentui-react@mbears/opentui-core-<platform>-<arch> native packagekoffi, unsafe-pointer, and their
target-specific .node filesreact, react-reconciler, and
scheduleryoga-layoutThe runtime bundle is stored under a single SEA asset prefix and extracted to a node_modules-shaped directory. The extracted layout should look like a normal package install rather than a temporary pile of random files.
Workspace runtime packages must be discovered from the workspace package
manifests and traversed with the same dependency closure as third-party runtime
packages. The collector must not maintain a partial @zcode/* allowlist: adding
a workspace package to dependencies means its built package surface is part of
the SEA runtime. Type-only or build-only workspace packages belong in
devDependencies so they do not inflate the extracted runtime.
The package bundle must be validated with the repository's Node 24 runtime.
OpenTUI branches that require Node 26 or node:ffi are out of scope unless
they regain a Node 24-compatible FFI backend.
The extractor writes to a per-user cache directory:
~/Library/Caches/zcode/sea-assets$XDG_CACHE_HOME/zcode/sea-assets or ~/.cache/zcode/sea-assets%LOCALAPPDATA%/zcode/Cache/sea-assetsThe full directory includes zcode version, target key, and manifest hash:
<cache>/sea-assets/<version>/<target>/<hash>/
manifest.json
node_modules/
@zcode/tui/
@mbears/opentui-core/
@mbears/opentui-react/
@mbears/opentui-core-darwin-arm64/
...
Extraction is idempotent. A complete manifest with the expected hash allows the next run to reuse the cache. If the manifest is missing or stale, the extractor rebuilds a temporary directory and atomically swaps it into place.
Unix file modes are normalized while extracting:
07550644.node files: 0755The cache must not default to /tmp, because some Linux systems mount it with
noexec, which can break dynamic library loading.
zcode continues to publish one binary per target:
darwin-arm64darwin-x64linux-arm64linux-x64win-arm64win-x64The SEA build generates a target-specific blob because the native OpenTUI package
differs by target. The workspace installs all optional OpenTUI native packages by
using pnpm supportedArchitectures, so the build can collect native packages for
targets other than the current host.
If a target native package is missing, the SEA build fails before injection with
a message that names the missing package and suggests running pnpm install.
@zcode/tui with a small OpenTUI shell that keeps the public TypeScript
API stable.zcode tui from a clean directory without
access to the repo node_modules.package.json and dist/index.js for
@zcode/tui, @zcode/i18n, and @zcode/contracts.@zcode/tui from that
directory, without falling back to repository node_modules.