Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Fix yargs --version implementation printing "unknown" for built .exe's

Dillon DuPontfb55b429207d
diff --git a/libs/typescript/cua-cli/src/cli.ts b/libs/typescript/cua-cli/src/cli.ts
index 6d00ffd298..70985c0f09 100644
--- a/libs/typescript/cua-cli/src/cli.ts
+++ b/libs/typescript/cua-cli/src/cli.ts
@@ -22,6 +22,27 @@ export async function runCli() {
'\n' +
'Documentation: https://docs.cua.ai/libraries/cua-cli/commands'
);
+ // version command
+ argv = argv.command(
+ 'version',
+ 'Show CUA CLI version',
+ (y) => y,
+ async () => {
+ try {
+ const home = process.env.HOME || process.env.USERPROFILE || '';
+ const path = `${home}/.cua/bin/.version`;
+ const version = await Bun.file(path).text();
+ const v = version.trim();
+ if (v) {
+ console.log(v);
+ } else {
+ console.log('unknown');
+ }
+ } catch {
+ console.log('unknown');
+ }
+ }
+ );
argv = registerAuthCommands(argv);
argv = registerSandboxCommands(argv);
await argv.demandCommand(1).strict().help().parseAsync();
diff --git a/scripts/install-cli.ps1 b/scripts/install-cli.ps1
index 7659983cd1..d1c6e9eca3 100644
--- a/scripts/install-cli.ps1
+++ b/scripts/install-cli.ps1
@@ -32,11 +32,29 @@ function Install-WithBun {
try {
bun add -g @trycua/cli
+ # Determine installed version from npm registry
+ try {
+ $bunVersion = (npm view @trycua/cli version) 2>$null
+ if (-not $bunVersion) { $bunVersion = "unknown" }
+ } catch { $bunVersion = "unknown" }
+ # Ensure install dir and write version file
+ $installDir = "$env:USERPROFILE\.cua\bin"
+ if (-not (Test-Path $installDir)) { New-Item -ItemType Directory -Path $installDir -Force | Out-Null }
+ Set-Content -Path (Join-Path $installDir ".version") -Value $bunVersion -NoNewline
return $true
} catch {
Write-Host "Warning: Failed to install with Bun, trying npm..." -ForegroundColor Yellow
try {
npm install -g @trycua/cli
+ # Determine installed version from npm registry
+ try {
+ $npmVersion = (npm view @trycua/cli version) 2>$null
+ if (-not $npmVersion) { $npmVersion = "unknown" }
+ } catch { $npmVersion = "unknown" }
+ # Ensure install dir and write version file
+ $installDir = "$env:USERPROFILE\.cua\bin"
+ if (-not (Test-Path $installDir)) { New-Item -ItemType Directory -Path $installDir -Force | Out-Null }
+ Set-Content -Path (Join-Path $installDir ".version") -Value $npmVersion -NoNewline
return $true
} catch {
Write-Host "Error: Installation failed with npm as well." -ForegroundColor Red
@@ -106,6 +124,13 @@ try {
}
}
+# Write version file for binary install
+try {
+ Set-Content -Path (Join-Path $installDir ".version") -Value $version -NoNewline
+} catch {
+ # Non-fatal
+}
+
# Add to PATH if not already there
$currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($currentPath -notlike "*$installDir*") {
diff --git a/scripts/install-cli.sh b/scripts/install-cli.sh
index 8bbb4b7b7b..0c9a508c1f 100644
--- a/scripts/install-cli.sh
+++ b/scripts/install-cli.sh
@@ -63,8 +63,15 @@ install_with_bun() {
elif [ -f "$HOME/.profile" ]; then
config_file="$HOME/.profile"
fi
-
- print_success "cua" "$VERSION" "$config_file"
+ # Determine installed version via npm registry (fallback to unknown)
+ local VERSION_BUN
+ VERSION_BUN=$(npm view @trycua/cli version 2>/dev/null || echo "unknown")
+ # Write version file to ~/.cua/bin/.version
+ local INSTALL_DIR="$HOME/.cua/bin"
+ mkdir -p "$INSTALL_DIR"
+ echo "$VERSION_BUN" > "$INSTALL_DIR/.version"
+ # Print success and exit
+ print_success "$(command -v cua)" "$VERSION_BUN" "$config_file"
exit 0
else
echo "❌ Installation failed. Please try installing manually:"
@@ -114,6 +121,7 @@ VERSION=${TAG_NAME#cua-v}
# Find the binary URL in the release assets
BINARY_URL=$(echo "$LATEST_RELEASE" | grep -o 'https://.*/download/[^"]*/'${BINARY_NAME}'"' | head -1)
BINARY_URL="${BINARY_URL%\"}"
+printf "\033[90mBINARY_URL: %s\033[0m\n" "$BINARY_URL"
if [ -z "$BINARY_URL" ]; then
echo "⚠️ Could not find ${BINARY_NAME} in release assets, falling back to Bun installation"
@@ -136,6 +144,9 @@ fi
# Make the binary executable
chmod +x "$INSTALL_DIR/cua"
+# Write version file
+echo "$VERSION" > "$INSTALL_DIR/.version"
+
# Add ~/.cua/bin to PATH if not already in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
# Add to .bashrc, .zshrc, or .profile