For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (
- [ ]) syntax for tracking.
Goal: Ship the completed Windows CUA source runtime inside ZCode Windows x64/arm64 packages and start it without a local source checkout.
Architecture: Stage the pinned @zcode/zcode-cua Windows entry, native addon, and minimal external dependencies into bundled-tools/<triplet>/cua-helper, then package it at resources/tools/cua-helper. A single asynchronous resolver admits either an explicit development root or the verified packaged manifest, while the existing named-pipe Helper host remains the only lifecycle implementation.
Tech Stack: TypeScript, Node.js 24, Electron 41.0.3, Node-API, Win32 PE, electron-builder 26, Vitest, PowerShell/vsigntool.
/remote, replayable delivery, owner, queue, snapshot, or workspace identity behavior.resources/tools/cua-helper; source override remains ZCODE_CUA_DEV_ROOT.1, package name is @zcode/zcode-cua, Electron version is 41.0.3, and target architectures are x64 and arm64.0x8664 means x64 and 0xaa64 means arm64; mismatches fail the build.pnpm typecheck and pnpm lint; report pre-existing unrelated failures separately.C:/Users/dev/zcode-cua/package.json: publishable Windows Helper entry/version contract.C:/Users/dev/zcode-cua/test/windows-package-artifacts.test.ts: packable artifact regression.packages/desktop/scripts/windows-cua-helper-assets.mjs: staging, manifest, SHA-256 and PE helpers.packages/desktop/scripts/prepare-windows-cua-helper.mjs: target-aware build entry.packages/desktop/test/windows-cua-helper-assets.test.ts: pure asset/staging tests.packages/desktop/scripts/prepare-runtime-assets.mjs: invokes Windows Helper staging after agent assets.packages/desktop/package.json: exposes prepare:windows-cua-helper.packages/desktop/electron-builder.config.js: packages, signs and asserts Helper assets.packages/desktop/test/runtime-asset-scripts.test.ts: packaging policy regression.packages/services/src/cua-permission-broker/windowsCuaDevRuntime.ts: generalized source/product resolver and manifest validation.packages/services/src/cua-permission-broker/windowsCuaDevHelperHost.ts: generic product naming alias over the single lifecycle.packages/services/src/node.ts: enables lazy packaged Windows product runtime.packages/services/test/windowsCuaDevRuntime.test.ts: resolver fail-closed matrix.packages/services/test/cuaPermissionBrokerProductAgentEnv.test.ts: default factory/admission tests.packages/services/test/windowsCuaProductHelper.integration.test.ts: staged product root ready/health/cleanup acceptance.docs/cua/windows-product-runtime.md: current product behavior and evidence.Files:
C:/Users/dev/zcode-cua/package.jsonC:/Users/dev/zcode-cua/test/windows-package-artifacts.test.tsC:/Users/dev/zcode-cua/dist/windows-helper.jsInterfaces:
Produces: package version 0.3.28, export ./windows-helper, and pack contents containing dist/windows-helper.js, binding.gyp, src/native/ax_win.cc, and scripts/build-native.cjs.
[ ] Step 1: Write the failing artifact test
Add a Vitest case that reads package.json, asserts version 0.3.28 and
exports["./windows-helper"].import === "./dist/windows-helper.js", then runs
pnpm pack --dry-run --json and asserts the four required paths are present.
Run: pnpm exec vitest run test/windows-package-artifacts.test.ts
Expected: FAIL because version/export are absent.
Set version to 0.3.28, add the exact ESM subpath export, and run pnpm build.
Do not add the compiled .node file to git; desktop target builds still compile it.
Run:
pnpm exec vitest run test/windows-package-artifacts.test.ts
pnpm typecheck
pnpm lint
pnpm build
Expected: all exit 0.
Commit: feat(windows): publish CUA helper runtime artifacts
Push codex/windows-cua-pointer-foundation so ZCode can pin the resulting exact commit.
Files:
packages/desktop/scripts/windows-cua-helper-assets.mjspackages/desktop/scripts/prepare-windows-cua-helper.mjspackages/desktop/test/windows-cua-helper-assets.test.tspackages/desktop/package.jsonpackages/desktop/scripts/prepare-runtime-assets.mjspackages/services/package.jsonpnpm-lock.yamlInterfaces:
@zcode/zcode-cua-helper-runtime at the Task 1 commit, or explicit absolute ZCODE_CUA_DEV_ROOT.Produces: prepareWindowsCuaHelperAssets({ sourceRoot, outputRoot, targetPlatform, electronVersion }) and a schema-1 runtime-manifest.json.
[ ] Step 1: Write RED tests for staging
Cover successful x64 staging, missing entry/addon, wrong package name, x64/arm64
PE mismatch, deterministic lowercase SHA-256, dependency directories, and non-Windows
no-op behavior. Build minimal PE fixtures by writing MZ, a PE header offset at
0x3c, PE\0\0, and machine at peOffset + 4.
Run: pnpm exec vitest run packages/desktop/test/windows-cua-helper-assets.test.ts
Expected: FAIL because the assets module does not exist.
Resolve the source from non-empty absolute ZCODE_CUA_DEV_ROOT, otherwise from
@zcode/zcode-cua-helper-runtime. Validate source identity/version/artifacts,
parse the PE machine, copy entry/addon, stage the express dependency closure
plus target Sharp packages into node_modules, hash entry/addon, and atomically
replace bundled-tools/<triplet>/cua-helper.
Add prepare:windows-cua-helper; invoke it after prepare:agent-bundle and
prepare:rg. Update @zcode/zcode-cua-helper-runtime to the exact remote Task 1
commit and regenerate the lockfile.
Run:
pnpm exec vitest run packages/desktop/test/windows-cua-helper-assets.test.ts
$env:ZCODE_CUA_DEV_ROOT='C:\Users\dev\zcode-cua'; pnpm --filter @zcode/desktop prepare:windows-cua-helper
Expected: tests pass and staged manifest reports win32/x64, Electron 41.0.3, package 0.3.28, matching hashes and PE machine.
Commit: build(windows): stage packaged CUA helper runtime
Files:
packages/services/src/cua-permission-broker/windowsCuaDevRuntime.tspackages/services/src/cua-permission-broker/windowsCuaDevHelperHost.tspackages/services/src/cua-permission-broker/index.tspackages/services/src/node.tspackages/services/test/windowsCuaDevRuntime.test.tspackages/services/test/cuaPermissionBrokerProductAgentEnv.test.tspackages/services/test/cuaPermissionBrokerServiceDispose.test.tsInterfaces:
resolveWindowsCuaRuntime(options): Promise<WindowsCuaRuntime>.resolveWindowsCuaDevRuntime,
WindowsCuaDevRuntime, and WindowsCuaDevHelperHost for existing callers/tests.Product options include injectable resourcesPath, arch, electronVersion, and async filesystem/hash dependencies.
[ ] Step 1: Extend resolver tests to RED
Add packaged-root success and failures for missing resourcesPath, invalid manifest,
schema/package/platform/arch/Electron mismatch, path traversal, missing file and
entry/addon hash mismatch. Assert a non-empty but broken ZCODE_CUA_DEV_ROOT never
falls back. Keep the existing source cases.
Change Windows admission expectation: internal feature enabled is sufficient even
without ZCODE_CUA_DEV_ROOT. Inject a packaged runtime into the factory and assert
no macOS host is constructed. Keep desktop-local/remote guards unchanged.
Source mode preserves existing stable diagnostics. Product mode reads only
<resourcesPath>/tools/cua-helper/runtime-manifest.json, validates exact schema and
relative paths, hashes both artifacts asynchronously, and returns
process.execPath with token-free { ELECTRON_RUN_AS_NODE: "1" }.
Export WindowsCuaHelperHost as the product name and keep the old class alias.
Update the logger scope/message naming without changing ready PID, health PID,
restart, termination blocker, token, or named-pipe behavior.
Run:
pnpm exec vitest run packages/services/test/windowsCuaDevRuntime.test.ts packages/services/test/cuaPermissionBrokerProductAgentEnv.test.ts packages/services/test/cuaPermissionBrokerServiceDispose.test.ts packages/services/test/windowsCuaDevHelperHost.test.ts
Expected: all focused tests pass.
Commit: feat(windows): resolve packaged CUA helper runtime
Files:
packages/desktop/electron-builder.config.jspackages/desktop/test/runtime-asset-scripts.test.tspackages/desktop/scripts/windows-cua-helper-assets.mjsInterfaces:
bundled-tools/<triplet>/cua-helper.Produces: installed resources/tools/cua-helper, signed native files in release builds, and verifyPackagedWindowsCuaHelper(...).
[ ] Step 1: Write RED packaging policy tests
Assert two explicit extraResources entries (runtime tree and its node_modules),
win.signExts contains .node and .dll, and afterPack calls the packaged Helper
verifier only for win32.
Run: pnpm exec vitest run packages/desktop/test/runtime-asset-scripts.test.ts
Expected: FAIL because no Windows Helper packaging policy exists.
Copy the staged tree to tools/cua-helper, copy its node_modules explicitly,
add native signing extensions, and run manifest/hash/PE verification in afterPack.
Local unsigned builds remain allowed; release signing still requires
ZCODE_ENABLE_WINDOWS_SIGN=1.
Run:
pnpm exec vitest run packages/desktop/test/runtime-asset-scripts.test.ts packages/desktop/test/windows-cua-helper-assets.test.ts
Expected: all tests pass.
Commit: build(windows): package and sign CUA helper assets
Files:
packages/services/test/windowsCuaProductHelper.integration.test.tsdocs/cua/windows-product-runtime.mddocs/cua/windows-source-development.mdInterfaces:
resources/tools/cua-helper.Produces: unattended evidence for Electron addon load, ready/health, named-pipe cleanup and no orphan process.
[ ] Step 1: Write the integration test
Gate on win32 plus an explicit product-root environment variable. Resolve the
product manifest, construct WindowsCuaHelperHost, start it with the Electron
executable, assert ready/health PID equality, then stop and prove the named pipe
rejects a fresh connection within 500 ms.
Run the test without the product-root variable and assert it is explicitly skipped; run it with an invalid root and confirm failure is a stable runtime resolution error.
Run:
$env:ZCODE_CUA_DEV_ROOT='C:\Users\dev\zcode-cua'
$env:ZCODE_SKIP_REMOTE_ASSETS='1'
pnpm --filter @zcode/desktop build
pnpm --filter @zcode/desktop exec electron-builder --win --x64 --dir
Expected: afterPack verifies resources/tools/cua-helper; no signing certificate is
required for this local acceptance build.
Point the integration test at the unpacked resources directory and use the
unpacked ZCode executable as process.execPath injection. Then run the existing
Windows screen-capture, pointer, clipboard and 30-tool live smokes from
C:/Users/dev/zcode-cua.
Expected: all booleans true, pipe closed after stop, and no owned Helper child remains.
Run:
pnpm exec vitest run packages/services/test/windowsCuaDevRuntime.test.ts packages/services/test/windowsCuaDevHelperHost.test.ts packages/services/test/windowsCuaProductHelper.integration.test.ts packages/services/test/cuaPermissionBrokerProductAgentEnv.test.ts packages/services/test/cuaPermissionBrokerServiceDispose.test.ts packages/desktop/test/windows-cua-helper-assets.test.ts packages/desktop/test/runtime-asset-scripts.test.ts
pnpm typecheck
pnpm lint
pnpm test:unit:affected
Expected: focused tests/typecheck/lint exit 0; any unchanged affected-suite failures
are listed by file and kept separate from CUA results.
Record exact package path, manifest, Electron/Node/N-API versions, test counts, signing limitation of the local build, and remaining HDR/ICC risk.
Commit: test(windows): prove packaged CUA helper lifecycle