fix(windows): launch step under Bun with Node fallback to text CLI#79
fix(windows): launch step under Bun with Node fallback to text CLI#79knqiufan wants to merge 10 commits into
Conversation
|
这个 PR 的架构判断我们完全认可:用 合入前差两件事:
两个不卡合入的小点: rebase + 验证记录齐了 @ 我们,这个我们想尽快合。 |
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
winget installs Bun as a zero-byte reparse point at %LOCALAPPDATA%\Microsoft\WinGet\Links\bun.exe. PowerShell and cmd.exe resolve it via shell APIs, but Node's child_process.spawn uses CreateProcess directly and gets ENOENT — breaking Invoke-StepCli which spawns via node scripts/run-step.mjs. When the resolved Bun path is a WinGet shim, leave STEP_BUN_BIN unset. Node spawns then fall back to tsx (existing behavior), and the step.cmd launcher resolves Bun via 'where bun' (cmd handles the alias correctly). Windows CI was the first to hit this because it runs setup.ps1 without -SkipBun; real Windows users would hit it too.
4ecfd8a to
dcec217
Compare
|
@ZouR-Ma Thank you for the detailed review. All requested follow-ups are now complete:
One observation for transparency: Bun 1.3.14 rendered the TUI successfully, but crashed while closing it with Esc. This occurred after the validation target had started and appears to be a Bun runtime crash; it is separate from the Node/OpenTUI startup issue addressed here. Regarding the exit diagnosis (for Windows) of Bun 1.3.14.
The application currently uses Current Windows workaround: exit with Self-check
Could you please take another look when convenient? Thank you! |
关联 Issue
Closes #78
Refs #29
变更类型
影响范围
packages/protocol/(跨边界协议,需要同步 SDK)packages/core/的公开 APIsrc/gateway/(session authority 行为变更)AGENTS.md与.dependency-cruiser.cjs)变更说明(why,而非 what)
Windows 上的
setup.ps1一直生成 Node-basedstep.cmd启动器(来自 #12),但@opentui/core是 Bun-built 包:bundle 顶部有 11 个.scmwith { type: "file" }import、6 个.wasmimport、4 个bun:ffi顶层 import、以及bun-webgpu依赖。Node.js 的严格 ESM loader 拒绝.scm(用户当前看到的Unknown file extension ".scm"),即使 loader hook 假装掉.scm/.wasm,bun:ffi也会立刻挂——FFI 调用无法伪造。#29 跟踪了同类问题,但 mitigation 是"装 Linux-native Bun",对 Windows 不适用。
本 PR 同时做两件事:
src/runtime/open-tui-capability.ts新增isOpenTuiRuntimeSupported(),用typeof process.versions.bun !== "undefined"检测 Bun。root-command.ts和resume-command.ts的shouldUseTui计算叠加这个检查——Node 上直接跳过 TUI 路径并打印一行警告,落到文本 CLI。voice-command.ts在 Node 上抛清晰错误,指引装 Bun。scripts/setup.ps1新增Install-Bun函数(PATH → winget → 直接下载 zip 三级回退、bun --version验证、finally清理临时 zip、PATH 去重)、-SkipBunflag、把生成的step.cmd改成优先 Bun(STEP_BUN_BIN→ PATH → Node 三级回退)。两者合一构成完整的 Windows 故事:installer 尽量装 Bun 拿到全功能 TUI;万一 Bun 不可用,src 层兜底保证
step文本 CLI 仍可用。step voice在 Node 上明确不支持,错误信息指引装 Bun。Test status
pnpm check: 1526 passed / 24 skipped; lint has 0 errors (5 existing warnings).setup.ps1with Bun 1.3.14 already installed (skipping only dependency installation); the installed launcher opened the STEP interactive TUI.-SkipBun: with Bun removed from the child PATH,setup.ps1 -SkipInstall -SkipBuild -SkipBuncompleted andstepused the Node text CLI with the one-time fallback warning;step voicereturned the expected actionable Bun installation error.STEP_BUN_BIN: with bothbunandnodeabsent from PATH, settingSTEP_BUN_BINto Bun started the installed launcher successfully (step --versionreturned 1.0.0).step.cmdfrom a project directory now resolves installed runtime dependencies and starts successfully.Commits
本 PR 包含 7 个原子 commit,按依赖顺序:
feat(runtime): expose isOpenTuiRuntimeSupported for Bun detectionfix(commands): skip TUI path on Node.js runtime in step root commandfix(commands): skip TUI path on Node.js runtime in step resumefix(commands): fail step voice with actionable error on Node runtimefix(commands): make voice runtime error platform-awarefeat(setup): install Bun on Windows and prefer it in step.cmd launcherfix(setup): harden Install-Bun against partial failures and stale PATH已知限制 / 后续工作
Install-Bun当前硬编码下载bun-windows-x64.zip。ARM64 Windows 会装 x64 二进制走模拟(慢但能跑)。Bun 的 ARM64 Windows 构建稳定后可加分支。step voice在 Node 上明确不支持:voice 是 TUI-driven 流程,没有合理的文本回退。错误信息明确指引装 Bun。