@beeos-ai/cli 1.0.17 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/_existing_install_actions.json +30 -34
- package/scripts/install.Tests.ps1 +3 -1
- package/scripts/install.ps1 +29 -123
- package/scripts/install.sh +35 -150
package/package.json
CHANGED
|
@@ -1,56 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": [
|
|
3
|
-
"P1-E of the install-link review
|
|
3
|
+
"Existing-install copy lint anchor (was P1-E of the install-link review).",
|
|
4
4
|
"",
|
|
5
|
-
"
|
|
6
|
-
"menu with subtly different copy:",
|
|
5
|
+
"## Historical context",
|
|
7
6
|
"",
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
7
|
+
"Before CLI 1.0.18 the same 'BeeOS is already installed — what now?'",
|
|
8
|
+
"menu was rendered from THREE places — install.sh, install.ps1, and",
|
|
9
|
+
"init.ts — and this manifest enforced shared keyword wording across",
|
|
10
|
+
"all three. The bash + PowerShell sites can't import TypeScript",
|
|
11
|
+
"constants, so a vitest grep lint",
|
|
12
|
+
"(`web/packages/cli/src/__tests__/existing-install-actions.test.ts`)",
|
|
13
|
+
"kept the three menus from drifting apart.",
|
|
11
14
|
"",
|
|
12
|
-
"
|
|
13
|
-
"wording with this manifest plus a vitest grep lint",
|
|
14
|
-
"(`web/packages/cli/src/__tests__/existing-install-actions.test.ts`).",
|
|
15
|
-
"If you change a label in any of the three files, update the",
|
|
16
|
-
"matching `keywords` here so the lint stays representative; if you",
|
|
17
|
-
"add a new action altogether, add a new entry below + render it",
|
|
18
|
-
"in all three sites.",
|
|
15
|
+
"## CLI 1.0.18 simplification",
|
|
19
16
|
"",
|
|
20
|
-
"
|
|
17
|
+
"The bootstrap scripts (install.sh / install.ps1) are now framework-",
|
|
18
|
+
"agnostic: their only job is `detect Node + npm i -g @beeos-ai/cli +",
|
|
19
|
+
"exec beeos init`. They no longer render any menu — 'what to do",
|
|
20
|
+
"when BeeOS is already installed' is `beeos init`'s job, where the",
|
|
21
|
+
"user sees the upgrade / rebind / reset-all / skip choices.",
|
|
21
22
|
"",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
23
|
+
"Consequence: the cross-site copy alignment lint shrinks to a",
|
|
24
|
+
"**single-file** lint on detect.ts. install.sh and install.ps1 are",
|
|
25
|
+
"removed from `files`. The `actions` block stays as a sanity check",
|
|
26
|
+
"that detect.ts's `initDecisionLabel` keeps recognisable terminology",
|
|
27
|
+
"(Upgrade / Re-bind / Skip).",
|
|
24
28
|
"",
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"",
|
|
30
|
-
"These are NOT enforced across all 3 call sites because the",
|
|
31
|
-
"pre-Node bash/PowerShell installers have only [Reinstall][Re-run][Skip]",
|
|
32
|
-
"buttons — the rebind variants live exclusively inside `beeos init`'s",
|
|
33
|
-
"interactive menu. The 'rerun' keyword 'Re-bind' below incidentally",
|
|
34
|
-
"covers detect.ts's soft-rebind label, which keeps this lint passing."
|
|
29
|
+
"The `advisory` block (added in 1.0.17 for the soft-rebind / reset-all",
|
|
30
|
+
"split) is preserved and still pins the must-appear-in copy on",
|
|
31
|
+
"detect.ts so users can tell the two rebind variants apart from the",
|
|
32
|
+
"label alone."
|
|
35
33
|
],
|
|
36
34
|
"actions": {
|
|
37
35
|
"upgrade": {
|
|
38
|
-
"$comment": "
|
|
39
|
-
"keywords": ["
|
|
36
|
+
"$comment": "detect.ts 'Upgrade CLI & agents' label.",
|
|
37
|
+
"keywords": ["Upgrade"]
|
|
40
38
|
},
|
|
41
39
|
"rerun": {
|
|
42
|
-
"$comment": "
|
|
43
|
-
"keywords": ["Re-
|
|
40
|
+
"$comment": "detect.ts soft-rebind label includes 'Re-bind'; advisory block below pins the full phrasing.",
|
|
41
|
+
"keywords": ["Re-bind", "Reusing"]
|
|
44
42
|
},
|
|
45
43
|
"skip": {
|
|
46
|
-
"$comment": "
|
|
44
|
+
"$comment": "Stable across releases.",
|
|
47
45
|
"keywords": ["Skip"]
|
|
48
46
|
}
|
|
49
47
|
},
|
|
50
|
-
"$files_root_comment": "
|
|
48
|
+
"$files_root_comment": "Path is relative to the `web/` workspace root (the test resolves it against that anchor).",
|
|
51
49
|
"files": [
|
|
52
|
-
"packages/cli/scripts/install.sh",
|
|
53
|
-
"packages/cli/scripts/install.ps1",
|
|
54
50
|
"packages/core/src/detect.ts"
|
|
55
51
|
],
|
|
56
52
|
"$advisory_comment": "Strings below are advisory — not enforced by the lint, but checked by `existing-install-actions.test.ts` to make sure detect.ts's two rebind variants stay distinguishable from each other.",
|
|
@@ -64,6 +64,9 @@ Describe "install.ps1 parse-time integrity" {
|
|
|
64
64
|
# CLI >= 1.0.16: Install-DeviceAgentSuite has been removed —
|
|
65
65
|
# the device suite installs lazily on the first
|
|
66
66
|
# `beeos device attach` (see core/device-setup.ts).
|
|
67
|
+
# CLI >= 1.0.18: Read-ExistingInstallAction + Get-BeeosVersion
|
|
68
|
+
# are gone — `beeos init` is the single owner of the
|
|
69
|
+
# already-installed menu, the bootstrap script just hands off.
|
|
67
70
|
$expected = @(
|
|
68
71
|
"Write-BeeInfo",
|
|
69
72
|
"Write-BeeOk",
|
|
@@ -74,7 +77,6 @@ Describe "install.ps1 parse-time integrity" {
|
|
|
74
77
|
"Install-NodeAuto",
|
|
75
78
|
"Show-InstallHints",
|
|
76
79
|
"Send-Telemetry",
|
|
77
|
-
"Read-ExistingInstallAction",
|
|
78
80
|
"Invoke-BeeosCli",
|
|
79
81
|
# P2-8: PSCore + RunAs auto-elevation helpers.
|
|
80
82
|
"Test-IsAdministrator",
|
package/scripts/install.ps1
CHANGED
|
@@ -4,43 +4,28 @@
|
|
|
4
4
|
BeeOS CLI Installer for Windows.
|
|
5
5
|
|
|
6
6
|
.DESCRIPTION
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
$env:BEEOS_API_URL
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
$env:BEEOS_AGENT_GATEWAY_URL
|
|
23
|
-
|
|
24
|
-
$env:BEEOS_DASHBOARD_URL
|
|
25
|
-
$env:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
`beeos device attach`); export it
|
|
30
|
-
in the shell that runs `beeos
|
|
31
|
-
device attach` instead.
|
|
32
|
-
$env:BEEOS_MCP_SERVER_VERSION Same, for @beeos-ai/device-mcp-server.
|
|
33
|
-
$env:BEEOS_USE_NPX = "1" Power-user escape hatch: use `npx`
|
|
34
|
-
for a throwaway install. `beeos`
|
|
35
|
-
will NOT persist on PATH after
|
|
36
|
-
the script exits. Default
|
|
37
|
-
behaviour (since CLI 1.0.11) is
|
|
38
|
-
always `npm install -g` so the
|
|
39
|
-
CLI is globally available for
|
|
40
|
-
follow-up commands. The device
|
|
41
|
-
suite is NOT eagerly installed
|
|
42
|
-
(CLI >= 1.0.16); see
|
|
43
|
-
web/packages/core/src/device-setup.ts.
|
|
7
|
+
Responsibilities (deliberately minimal — framework-agnostic):
|
|
8
|
+
1. Detect or install Node.js (via winget / Chocolatey fallback).
|
|
9
|
+
2. `npm install -g @beeos-ai/cli`.
|
|
10
|
+
3. `exec beeos init` (or `beeos device attach` with `-Device`).
|
|
11
|
+
|
|
12
|
+
Anything else — "you already have BeeOS installed, what now?",
|
|
13
|
+
framework selection, rebind variants — lives inside the CLI's own
|
|
14
|
+
`beeos init` menu, not here. The bootstrap script stays small so
|
|
15
|
+
it's easy to maintain and easy to diagnose on a customer machine.
|
|
16
|
+
|
|
17
|
+
Optional env vars:
|
|
18
|
+
|
|
19
|
+
$env:BEEOS_API_URL Public API base (this script uses
|
|
20
|
+
it for telemetry; the CLI uses it
|
|
21
|
+
for runtime). Defaults to production.
|
|
22
|
+
$env:BEEOS_AGENT_GATEWAY_URL Agent Gateway base (forwarded as-is
|
|
23
|
+
to the spawned CLI).
|
|
24
|
+
$env:BEEOS_DASHBOARD_URL Dashboard base (OAuth / bind redirect).
|
|
25
|
+
$env:BEEOS_INSTALL_DRY_RUN=1 CI smoke-test escape hatch.
|
|
26
|
+
$env:BEEOS_NO_TELEMETRY=1 Disable script-level telemetry POSTs.
|
|
27
|
+
$env:BEEOS_USE_NPX = "1" Power-user throwaway install (beeos
|
|
28
|
+
won't persist on PATH).
|
|
44
29
|
|
|
45
30
|
.EXAMPLE
|
|
46
31
|
# One-liner (PowerShell 5+):
|
|
@@ -48,14 +33,14 @@
|
|
|
48
33
|
|
|
49
34
|
.EXAMPLE
|
|
50
35
|
# With specific CLI version:
|
|
51
|
-
.\install.ps1 -Version 1.0.
|
|
36
|
+
.\install.ps1 -Version 1.0.18
|
|
52
37
|
|
|
53
38
|
.EXAMPLE
|
|
54
39
|
# Jump straight into device attach instead of init:
|
|
55
40
|
.\install.ps1 -Device
|
|
56
41
|
|
|
57
42
|
.EXAMPLE
|
|
58
|
-
# Bare-metal one-
|
|
43
|
+
# Bare-metal staging one-liner:
|
|
59
44
|
$env:BEEOS_API_URL = "https://public-api-staging.beeos.ai"
|
|
60
45
|
$env:BEEOS_AGENT_GATEWAY_URL = "https://agent-gw-staging.beeos.ai"
|
|
61
46
|
$env:BEEOS_DASHBOARD_URL = "https://beeos-staging-web.vercel.app"
|
|
@@ -425,59 +410,6 @@ function Show-InstallHints {
|
|
|
425
410
|
}
|
|
426
411
|
}
|
|
427
412
|
|
|
428
|
-
# ── Existing install detection ───────────────────────────────
|
|
429
|
-
|
|
430
|
-
function Get-BeeosVersion {
|
|
431
|
-
try {
|
|
432
|
-
$out = & beeos --version 2>$null
|
|
433
|
-
if ($out) {
|
|
434
|
-
if ($out -match "\d+\.\d+\.\d+") { return $Matches[0] }
|
|
435
|
-
return ($out -replace '\s+','')
|
|
436
|
-
}
|
|
437
|
-
} catch {}
|
|
438
|
-
return $null
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
function Read-ExistingInstallAction {
|
|
442
|
-
# Note on naming: "Reinstall + upgrade CLI" deliberately differs
|
|
443
|
-
# from the `beeos init` menu's "Upgrade CLI & agents" item. The
|
|
444
|
-
# script-side action also re-bootstraps Node / pnpm and re-applies
|
|
445
|
-
# this shell's env vars before exec'ing the new binary, which the
|
|
446
|
-
# in-CLI upgrade does NOT do — choosing a different verb keeps the
|
|
447
|
-
# two flows distinguishable. See `install.sh` for the matching
|
|
448
|
-
# docstring.
|
|
449
|
-
#
|
|
450
|
-
# P1-E of the install-link review: the labels rendered below are
|
|
451
|
-
# anchored against `install.sh::prompt_existing_install_action` +
|
|
452
|
-
# `init.ts::decideAction` via
|
|
453
|
-
# `web/packages/cli/scripts/_existing_install_actions.json` and
|
|
454
|
-
# the vitest grep lint at
|
|
455
|
-
# `web/packages/cli/src/__tests__/existing-install-actions.test.ts`.
|
|
456
|
-
# Keep at least one keyword from `keywords[action]` per option.
|
|
457
|
-
$ver = Get-BeeosVersion
|
|
458
|
-
if (-not $ver) { $ver = "unknown" }
|
|
459
|
-
Write-BeeWarn "BeeOS CLI is already installed (v$ver)."
|
|
460
|
-
Write-Host ""
|
|
461
|
-
Write-Host " [1] Reinstall + upgrade CLI to the latest version, then run beeos init"
|
|
462
|
-
Write-Host " [2] Re-run beeos init without reinstalling"
|
|
463
|
-
Write-Host " [3] Skip (do nothing)"
|
|
464
|
-
Write-Host ""
|
|
465
|
-
|
|
466
|
-
if (-not [Environment]::UserInteractive) {
|
|
467
|
-
Write-BeeInfo "Non-interactive shell — defaulting to reinstall."
|
|
468
|
-
return "upgrade"
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
$choice = Read-Host "Choose [1-3]"
|
|
472
|
-
switch ($choice) {
|
|
473
|
-
"" { return "upgrade" }
|
|
474
|
-
"1" { return "upgrade" }
|
|
475
|
-
"2" { return "rerun" }
|
|
476
|
-
"3" { return "skip" }
|
|
477
|
-
default { return "upgrade" }
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
|
|
481
413
|
# ── Run CLI ──────────────────────────────────────────────────
|
|
482
414
|
|
|
483
415
|
function Invoke-BeeosCli {
|
|
@@ -608,37 +540,11 @@ if (-not (Test-NodeVersion)) {
|
|
|
608
540
|
$nodeVer = & node -v
|
|
609
541
|
Write-BeeOk "Node.js $nodeVer detected"
|
|
610
542
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
Write-BeeInfo "Skipping. Run `beeos init` or `beeos device attach` manually later."
|
|
617
|
-
exit 0
|
|
618
|
-
}
|
|
619
|
-
"upgrade" {
|
|
620
|
-
Write-BeeInfo "Reinstalling $CliPackage..."
|
|
621
|
-
& npm install -g $CliPackage
|
|
622
|
-
if ($LASTEXITCODE -ne 0) {
|
|
623
|
-
Send-Telemetry -Event "install.bootstrap.npm_fail" -ErrorCode "npm_install_cli_failed_upgrade" -Success $false
|
|
624
|
-
Write-BeeError "npm install -g $CliPackage failed."
|
|
625
|
-
Write-BeeError ""
|
|
626
|
-
Write-BeeError "Common fixes:"
|
|
627
|
-
Write-BeeError " - EEXIST on beeos from another package:"
|
|
628
|
-
Write-BeeError " npm uninstall -g beeos # then re-run installer"
|
|
629
|
-
Write-BeeError " - EACCES / permission error: run PowerShell as Administrator"
|
|
630
|
-
exit 1
|
|
631
|
-
}
|
|
632
|
-
# Device suite is NOT upgraded here. `beeos device upgrade`
|
|
633
|
-
# is the canonical refresh path (it also restarts the
|
|
634
|
-
# running fleet); the install-script upgrade prompt only
|
|
635
|
-
# refreshes the CLI itself.
|
|
636
|
-
}
|
|
637
|
-
"rerun" {
|
|
638
|
-
Write-BeeInfo "Reusing existing install."
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
}
|
|
543
|
+
# Bootstrap is finished. Hand off to `Invoke-BeeosCli` which performs
|
|
544
|
+
# `npm install -g @beeos-ai/cli` (idempotent — npm short-circuits when
|
|
545
|
+
# the requested version is already on disk) and then runs the freshly
|
|
546
|
+
# installed binary. "What does the CLI do when it's already installed?"
|
|
547
|
+
# is now `beeos init`'s problem; we don't second-guess it from out here.
|
|
642
548
|
|
|
643
549
|
Write-BeeInfo "Running BeeOS CLI..."
|
|
644
550
|
Write-Host ""
|
package/scripts/install.sh
CHANGED
|
@@ -1,58 +1,47 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
#
|
|
3
3
|
# BeeOS CLI Installer (macOS / Linux)
|
|
4
|
+
#
|
|
4
5
|
# Usage:
|
|
5
6
|
# curl -fsSL https://beeos.ai/install | bash
|
|
6
7
|
# curl -fsSL https://beeos.ai/install | bash -s -- [beeos init args]
|
|
7
|
-
# curl -fsSL https://beeos.ai/install | bash -s -- --device
|
|
8
|
+
# curl -fsSL https://beeos.ai/install | bash -s -- --device # → beeos device attach
|
|
8
9
|
#
|
|
9
|
-
#
|
|
10
|
+
# Responsibilities (deliberately minimal — framework-agnostic):
|
|
10
11
|
# 1. Detect OS + CPU architecture, refuse unsupported targets early.
|
|
11
|
-
# 2. Make sure Node.js >= MIN_NODE_VERSION is available (install via
|
|
12
|
-
# fnm / brew when possible).
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
# 4.
|
|
17
|
-
# `--device` is passed.
|
|
12
|
+
# 2. Make sure Node.js >= MIN_NODE_VERSION is available (install via
|
|
13
|
+
# nvm / fnm / brew when possible). All heavier dependencies (adb,
|
|
14
|
+
# scrcpy-bridge, the device-agent suite) are installed lazily by
|
|
15
|
+
# the CLI itself when the user actually needs them.
|
|
16
|
+
# 3. `npm install -g @beeos-ai/cli`.
|
|
17
|
+
# 4. `exec beeos init` (or `beeos device attach` with `--device`).
|
|
18
18
|
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
# Config` env-overrides layer; older CLIs only honor BEEOS_API_URL
|
|
24
|
-
# (telemetry) + BEEOS_AGENT_GATEWAY_URL (runtime).
|
|
19
|
+
# Anything else — "you already have BeeOS installed, what now?",
|
|
20
|
+
# framework selection, rebind variants — lives inside the CLI's own
|
|
21
|
+
# `beeos init` menu, not here. The bootstrap script stays small so it's
|
|
22
|
+
# easy to maintain and easy to diagnose on a customer machine.
|
|
25
23
|
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
#
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
# BEEOS_USE_NPX=1
|
|
39
|
-
#
|
|
40
|
-
# persist on PATH after the script exits.
|
|
41
|
-
# Default behaviour (since CLI 1.0.11) is
|
|
42
|
-
# always `npm install -g` so the CLI is
|
|
43
|
-
# globally available for follow-up commands.
|
|
44
|
-
# The device-agent suite is no longer
|
|
45
|
-
# eagerly installed (CLI ≥ 1.0.16); see
|
|
46
|
-
# `web/packages/core/src/device-setup.ts`.
|
|
24
|
+
# ── Optional env vars ─────────────────────────────────────────────
|
|
25
|
+
# BEEOS_API_URL Public API base (this script uses it for
|
|
26
|
+
# telemetry; the CLI uses it for runtime).
|
|
27
|
+
# Defaults to production.
|
|
28
|
+
# BEEOS_AGENT_GATEWAY_URL Agent Gateway base (forwarded as-is to the
|
|
29
|
+
# spawned CLI).
|
|
30
|
+
# BEEOS_DASHBOARD_URL Dashboard base (OAuth / bind redirect).
|
|
31
|
+
# BEEOS_INSTALL_LOG Path to a forensic log of Node-bootstrap
|
|
32
|
+
# stderr; defaults to /tmp/beeos-install-$$.log.
|
|
33
|
+
# BEEOS_INSTALL_DRY_RUN=1 CI smoke-test escape hatch — return 0
|
|
34
|
+
# from main() before any side effect.
|
|
35
|
+
# BEEOS_NO_TELEMETRY=1 Disable the script-level telemetry POSTs.
|
|
36
|
+
# BEEOS_USE_NPX=1 Power-user throwaway install (beeos won't
|
|
37
|
+
# persist on PATH).
|
|
47
38
|
#
|
|
48
|
-
#
|
|
49
|
-
# add `BEEOS_DEVICE_AGENT_VERSION=...` to the shell when you later run
|
|
50
|
-
# `beeos device attach` if you need to pin a specific build):
|
|
39
|
+
# Bare-metal staging one-liner:
|
|
51
40
|
#
|
|
52
41
|
# BEEOS_API_URL=https://public-api-staging.beeos.ai \
|
|
53
42
|
# BEEOS_AGENT_GATEWAY_URL=https://agent-gw-staging.beeos.ai \
|
|
54
43
|
# BEEOS_DASHBOARD_URL=https://beeos-staging-web.vercel.app \
|
|
55
|
-
# curl -fsSL https://beeos.ai/install | bash -s -- --version 1.0.
|
|
44
|
+
# curl -fsSL https://beeos.ai/install | bash -s -- --version 1.0.18
|
|
56
45
|
|
|
57
46
|
set -euo pipefail
|
|
58
47
|
|
|
@@ -65,11 +54,6 @@ RED="\033[31m"
|
|
|
65
54
|
CYAN="\033[36m"
|
|
66
55
|
|
|
67
56
|
CLI_PACKAGE="@beeos-ai/cli@latest"
|
|
68
|
-
# `@beeos-ai/device-agent` + `@beeos-ai/device-mcp-server` are NOT
|
|
69
|
-
# installed here. CLI ≥ 1.0.16 installs them lazily on the first
|
|
70
|
-
# `beeos device attach` via `ensureDeviceAgent` in
|
|
71
|
-
# `web/packages/core/src/device-setup.ts`. OpenClaw-only users never
|
|
72
|
-
# download the device suite at all.
|
|
73
57
|
MIN_NODE_VERSION=18
|
|
74
58
|
NVM_VERSION="v0.40.1"
|
|
75
59
|
FNM_INSTALL_URL="https://fnm.vercel.app/install"
|
|
@@ -410,76 +394,6 @@ print_install_hints() {
|
|
|
410
394
|
echo ""
|
|
411
395
|
}
|
|
412
396
|
|
|
413
|
-
# ── Existing install detection ───────────────────────────────
|
|
414
|
-
|
|
415
|
-
beeos_already_installed() {
|
|
416
|
-
if command -v beeos &>/dev/null; then
|
|
417
|
-
return 0
|
|
418
|
-
fi
|
|
419
|
-
return 1
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
beeos_current_version() {
|
|
423
|
-
# `beeos --version` currently prints just the semver string. Tolerate
|
|
424
|
-
# other formats by extracting the first dotted number we can find.
|
|
425
|
-
local out
|
|
426
|
-
out=$(beeos --version 2>/dev/null | head -n1 | tr -d '[:space:]' || true)
|
|
427
|
-
if [[ "$out" =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then
|
|
428
|
-
echo "${BASH_REMATCH[0]}"
|
|
429
|
-
else
|
|
430
|
-
echo "$out"
|
|
431
|
-
fi
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
prompt_existing_install_action() {
|
|
435
|
-
# The labels here are anchored against the equivalents in
|
|
436
|
-
# install.ps1 (Read-ExistingInstallAction) and `init.ts`'s
|
|
437
|
-
# `decideAction` menu by
|
|
438
|
-
# `web/packages/cli/scripts/_existing_install_actions.json` and the
|
|
439
|
-
# vitest grep lint at
|
|
440
|
-
# `web/packages/cli/src/__tests__/existing-install-actions.test.ts`
|
|
441
|
-
# (P1-E of the install-link review). Keep at least one keyword from
|
|
442
|
-
# the manifest's `keywords[action]` array per option so the lint
|
|
443
|
-
# doesn't break.
|
|
444
|
-
#
|
|
445
|
-
# Only prompt on an interactive TTY. When the script is piped without a
|
|
446
|
-
# TTY attached (e.g. one-liner with no tty allocated), default to
|
|
447
|
-
# "reinstall + re-run init" which is the safest non-destructive choice.
|
|
448
|
-
if [[ ! -t 0 ]] && [[ ! -t 1 ]]; then
|
|
449
|
-
info "Non-interactive shell detected — defaulting to reinstall."
|
|
450
|
-
echo "upgrade"
|
|
451
|
-
return 0
|
|
452
|
-
fi
|
|
453
|
-
|
|
454
|
-
# Note on naming: the option below is labelled "Reinstall + upgrade
|
|
455
|
-
# CLI" deliberately. `beeos init`'s own menu has an item called
|
|
456
|
-
# "Upgrade CLI & agents" — it does (now) call `npm i -g` for the
|
|
457
|
-
# three-piece suite and re-runs `beeos start openclaw`. The script
|
|
458
|
-
# action here is broader: it also re-bootstraps Node / pnpm if
|
|
459
|
-
# missing, re-applies env vars from this shell, and *exec*s the
|
|
460
|
-
# newly-installed binary. Different verb avoids the user thinking
|
|
461
|
-
# they're picking the same code path twice. (See `init.ts`'s own
|
|
462
|
-
# upgrade branch for the in-CLI behavior.)
|
|
463
|
-
local ver
|
|
464
|
-
ver=$(beeos_current_version || true)
|
|
465
|
-
ver="${ver:-unknown}"
|
|
466
|
-
warn "BeeOS CLI is already installed (v${ver})."
|
|
467
|
-
echo ""
|
|
468
|
-
echo " [1] Reinstall + upgrade CLI to the latest version, then run ${BOLD}beeos init${RESET}"
|
|
469
|
-
echo " [2] Re-run ${BOLD}beeos init${RESET} without reinstalling"
|
|
470
|
-
echo " [3] Skip (do nothing)"
|
|
471
|
-
echo ""
|
|
472
|
-
|
|
473
|
-
local choice
|
|
474
|
-
read -rp "Choose [1-3]: " choice </dev/tty || choice=""
|
|
475
|
-
case "$choice" in
|
|
476
|
-
""|1) echo "upgrade" ;;
|
|
477
|
-
2) echo "rerun" ;;
|
|
478
|
-
3) echo "skip" ;;
|
|
479
|
-
*) echo "upgrade" ;;
|
|
480
|
-
esac
|
|
481
|
-
}
|
|
482
|
-
|
|
483
397
|
# ── Main ─────────────────────────────────────────────────────
|
|
484
398
|
|
|
485
399
|
run_cli() {
|
|
@@ -581,41 +495,12 @@ main() {
|
|
|
581
495
|
|
|
582
496
|
success "Node.js $(node -v) detected"
|
|
583
497
|
|
|
584
|
-
#
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
info "Skipping. Run \`beeos init\` or \`beeos device attach\` manually later."
|
|
591
|
-
exit 0
|
|
592
|
-
;;
|
|
593
|
-
upgrade)
|
|
594
|
-
info "Reinstalling ${CLI_PACKAGE}..."
|
|
595
|
-
if command -v npm &>/dev/null; then
|
|
596
|
-
if ! npm install -g "$CLI_PACKAGE"; then
|
|
597
|
-
send_telemetry "install.bootstrap.npm_fail" "npm_install_cli_failed_upgrade" false
|
|
598
|
-
error "npm install -g ${CLI_PACKAGE} failed."
|
|
599
|
-
error ""
|
|
600
|
-
error "Common fixes:"
|
|
601
|
-
error " - EEXIST on /bin/beeos from another package:"
|
|
602
|
-
error " npm uninstall -g beeos # then re-run installer"
|
|
603
|
-
error " - EACCES permission error:"
|
|
604
|
-
error " use a node version manager (nvm / fnm) or sudo"
|
|
605
|
-
exit 1
|
|
606
|
-
fi
|
|
607
|
-
# Device-agent suite is intentionally NOT upgraded here.
|
|
608
|
-
# `beeos device upgrade` is the canonical refresh path (it
|
|
609
|
-
# also restarts the running fleet); the install-script
|
|
610
|
-
# upgrade prompt only refreshes the CLI itself.
|
|
611
|
-
fi
|
|
612
|
-
;;
|
|
613
|
-
rerun)
|
|
614
|
-
info "Reusing existing install."
|
|
615
|
-
;;
|
|
616
|
-
esac
|
|
617
|
-
fi
|
|
618
|
-
|
|
498
|
+
# Bootstrap is finished. Hand off to `run_cli` which performs
|
|
499
|
+
# `npm install -g @beeos-ai/cli` (idempotent — npm short-circuits
|
|
500
|
+
# when the requested version is already on disk) and then `exec`s
|
|
501
|
+
# the freshly-installed binary. "What does the CLI do when it's
|
|
502
|
+
# already installed?" is now `beeos init`'s problem; we don't
|
|
503
|
+
# second-guess it from out here.
|
|
619
504
|
info "Running BeeOS CLI..."
|
|
620
505
|
echo ""
|
|
621
506
|
|