-
Notifications
You must be signed in to change notification settings - Fork 9
fix(cli): anet -v 声明 Bun 前置(此前唯一的硬前置在自报信息里是隐形的) #744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1720,6 +1720,10 @@ function detectInstalledPackages() { | |
| commhubServer: detectCommandVersion("commhub-server", "commhub-server", "global"), | ||
| claude: detectCommandVersion("claude", "claude CLI"), | ||
| codex: detectCommandVersion("codex", "codex CLI"), | ||
| // Bun 不是「可选运行时」,它是本机跑 hub 的硬前置:`anet hub start` 在 | ||
| // 缺 bun/bunx 时直接 process.exit(1)(见 hub start 里的前置校验)。 | ||
| // 此前自报里完全不提它,用户只能撞上去才知道 —— 这正是本次要修的。 | ||
| bun: detectCommandVersion("bun", "Bun"), | ||
| }; | ||
|
|
||
| if (versions.agentNode.state !== "ok") { | ||
|
|
@@ -1745,6 +1749,16 @@ function formatLazyComponent(pkg: DetectedVersion): string { | |
| return `○ ${pkg.displayName} — not installed yet (will fetch via npx on first use)`; | ||
| } | ||
|
|
||
| /** Bun 的自报行。与 formatOptionalRuntime 分开,因为缺失时的语义完全不同: | ||
| * 可选运行时缺了只是少一种 runtime,Bun 缺了 `anet hub start` 直接失败, | ||
| * 所以这里要给出可直接执行的安装命令,而不是一句 "only needed for …"。 */ | ||
| function formatRequiredBun(pkg: DetectedVersion): string { | ||
| if (pkg.state === "ok" && pkg.version) return `✓ ${pkg.displayName} v${pkg.version}`; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When an older Bun such as 1.1.x is on PATH, this branch prints Useful? React with 👍 / 👎. |
||
| if (pkg.state === "unknown") return `✓ ${pkg.displayName} installed`; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If Useful? React with 👍 / 👎. |
||
| return `✗ ${pkg.displayName} not found — \`anet hub start\` will fail without it ` | ||
| + `(commhub-server is bun-only). Install: curl -fsSL https://bun.sh/install | bash`; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On native Windows PowerShell, which this CLI explicitly supports in Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| function formatOptionalRuntime(pkg: DetectedVersion, reason: string): string { | ||
| if (pkg.state === "ok" && pkg.version) return `✓ ${pkg.displayName} v${pkg.version}`; | ||
| if (pkg.state === "unknown") return `✓ ${pkg.displayName} installed`; | ||
|
|
@@ -1782,6 +1796,11 @@ function printVersionReport() { | |
| } | ||
| console.log(` ${formatLazyComponent(versions.commhubServer)}`); | ||
|
|
||
| // Bun 单独一节,不能混进 "Optional runtimes" —— 它不是可选的。 | ||
| // 措辞限定在「本机跑 hub」:节点连远程 hub 不需要 Bun,说成笼统必需是过度声称。 | ||
| console.log("\nRequired to run a hub on this machine:"); | ||
| console.log(` ${formatRequiredBun(versions.bun)}`); | ||
|
|
||
| console.log("\nOptional runtimes (install only what you'll use):"); | ||
| console.log(` ${formatOptionalRuntime(versions.claude, "the claude-code-cli runtime")}`); | ||
| console.log(` ${formatOptionalRuntime(versions.codex, "the codex-sdk runtime")}`); | ||
|
|
@@ -1791,6 +1810,11 @@ function printVersionReport() { | |
| console.log("\nNothing is broken — components are fetched the first time you run:"); | ||
| console.log(" anet hub start # bootstraps commhub-server"); | ||
| console.log(" anet node start <name> # bootstraps agent-node"); | ||
| // 缺 Bun 时上面这句会误导:`anet hub start` 不会「自动拉取后正常工作」, | ||
| // 它会在前置校验处 exit 1。所以这里必须把话收回来。 | ||
| if (!isInstalled(versions.bun)) { | ||
| console.log("\n ⚠️ but `anet hub start` will not succeed until Bun is installed — see above."); | ||
|
Comment on lines
+1815
to
+1816
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When either lazy component and Bun are both missing, the report still prints Useful? React with 👍 / 👎. |
||
| } | ||
| console.log("\nDocs: https://anet.sh/guide/getting-started"); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
bunis present butbunxis absent, this reports✓ Bun, butserverCommandalways launchesspawn("bunx", ...)at line 5708, soanet hub startstill fails with ENOENT. Conversely, a usablebunxwithout abuncommand is reported as missing even though the hub preflight at line 5689 accepts it. Detect the executable the hub actually launches, or make the launch path consistently fall back tobun x.Useful? React with 👍 / 👎.