Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions agent-network/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Check bunx before reporting the hub prerequisite as ready

When bun is present but bunx is absent, this reports ✓ Bun, but serverCommand always launches spawn("bunx", ...) at line 5708, so anet hub start still fails with ENOENT. Conversely, a usable bunx without a bun command 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 to bun x.

Useful? React with 👍 / 👎.

};

if (versions.agentNode.state !== "ok") {
Expand All @@ -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}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject Bun versions below the declared minimum

When an older Bun such as 1.1.x is on PATH, this branch prints ✓ Bun v1.1.x and treats the hub prerequisite as satisfied even though server/package.json:45-46 declares bun >=1.2.0 and the getting-started guide specifies the same minimum. Compare the detected version against the supported floor so the report does not direct users with an incompatible runtime to proceed to anet hub start.

Useful? React with 👍 / 👎.

if (pkg.state === "unknown") return `✓ ${pkg.displayName} installed`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Do not mark a failed Bun probe as ready

If bun is discoverable but bun --version exits nonzero, times out, or emits an unparseable version, detectCommandVersion returns state: "unknown", yet this branch prints a success checkmark and isInstalled suppresses the missing-prerequisite warning. In that scenario the report cannot establish that the hard prerequisite is runnable, so it should surface an unverifiable or failed state rather than declaring Bun installed.

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`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Provide a platform-appropriate Bun installation command

On native Windows PowerShell, which this CLI explicitly supports in docs-site/docs/en/guide/windows.md:3-29, the suggested curl ... | bash command is not usable because bash is not available in that environment. A Windows user running anet -v to diagnose a missing local-hub prerequisite therefore receives a remediation that cannot install it; select Bun's PowerShell installer when process.platform === "win32".

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`;
Expand Down Expand Up @@ -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")}`);
Expand All @@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Replace the unconditional all-clear when Bun is missing

When either lazy component and Bun are both missing, the report still prints Nothing is broken and advertises anet hub start before appending this warning. That leaves the exact false all-clear this change intends to remove in the output, merely followed by a contradictory qualification; condition the earlier message on Bun being ready or use wording that says only the lazy components are healthy.

Useful? React with 👍 / 👎.

}
console.log("\nDocs: https://anet.sh/guide/getting-started");
}
}
Expand Down
Loading