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.

installer: offer to add ~/.local/bin to PATH, one quiet signature line, republish installers on change (CUA-1771) (#5311)

Francesco Bonacci49a561289178
diff --git a/.github/workflows/release-installers-feed.yml b/.github/workflows/release-installers-feed.yml
new file mode 100644
index 0000000000..86f676bcb3
--- /dev/null
+++ b/.github/workflows/release-installers-feed.yml
@@ -0,0 +1,47 @@
+name: "Release: installer scripts feed"
+
+# cua.ai/install.sh and install.ps1 redirect to the copies on the rolling
+# cua-install-latest release. cd-cua-sdk.yml and cd-cua-spaces.yml refresh
+# those copies only when a CLI or app release publishes, so an installer fix
+# merged between releases would not reach users (CUA-1771: the --pair guard
+# stayed unpublished while the manifest still pointed at CLI 0.4.2).
+# This workflow republishes the two scripts when they change on main. It
+# touches only the scripts, never release-artifacts.json.
+
+on:
+ push:
+ branches: [main]
+ paths:
+ - "scripts/install/install.sh"
+ - "scripts/install/install.ps1"
+ - "scripts/install/stamp_installers.py"
+ workflow_dispatch:
+
+permissions:
+ contents: write
+
+concurrency:
+ group: release-installers-feed
+ cancel-in-progress: false
+
+jobs:
+ publish:
+ name: Publish install.sh / install.ps1 to cua-install-latest
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ - name: Check the scripts
+ run: sh -n scripts/install/install.sh
+ - name: Stamp and upload
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ set -euo pipefail
+ if ! gh release view cua-install-latest --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
+ echo "no cua-install-latest release in $GITHUB_REPOSITORY yet; the first CLI or app release creates it"
+ exit 0
+ fi
+ python3 scripts/install/stamp_installers.py --repo "$GITHUB_REPOSITORY" --out stamped
+ gh release upload cua-install-latest stamped/install.sh stamped/install.ps1 \
+ --clobber --repo "$GITHUB_REPOSITORY"
+ echo "Published install.sh and install.ps1 from $GITHUB_SHA" >> "$GITHUB_STEP_SUMMARY"
diff --git a/scripts/install/README.md b/scripts/install/README.md
index 10dc33d2db..5de40a8a77 100644
--- a/scripts/install/README.md
+++ b/scripts/install/README.md
@@ -41,7 +41,8 @@ For cua-driver, `--prefix DIR` becomes `--bin-dir DIR/bin`, `--require-signature
| `--mode host\|client` | `-Mode host\|client` | Preselect the app's first-run choice (implies `spaces`) |
| `--version 1.2.3` | `-Version 1.2.3` | Pin the CLI release (default: latest) |
| `--prefix DIR` | `-Prefix DIR` | Install under `DIR/bin` (and `DIR/Applications` on macOS) |
-| `--modify-path` | `-ModifyPath` | Add the bin dir to your shell profile or user PATH |
+| `--modify-path` | `-ModifyPath` | Add the bin dir to your shell profile or user PATH without asking |
+| `--no-modify-path` | `-NoModifyPath` | Never edit the profile or user PATH; print the command instead |
| `--no-onboarding` | `-NoOnboarding` | Skip `cua auth login` |
| `--require-signature` | `-RequireSignature` | Fail unless minisign or cosign verifies |
| `--dry-run` | `-DryRun` | Print the plan, change nothing |
@@ -60,7 +61,7 @@ Pass install.sh options through the pipe with `sh -s --`, for example `curl -fsS
cua-driver lands where its own installer puts it: `~/.local/bin/cua-driver` (or `DIR/bin` with `--prefix`), `%LOCALAPPDATA%\Programs\Cua\cua-driver\bin` on Windows.
-The scripts never edit shell profiles unless you pass `--modify-path`. `--mode` writes `~/.cua/spaces-install-mode`, which the app reads on first launch.
+On Linux and macOS, when the bin dir is not on PATH, install.sh in a terminal asks once ("Add ... to PATH in ~/.zshrc? [Y/n]", Enter = yes). Without a terminal, or with `--yes`, it prints the exact one-line command for your shell instead and never edits a profile unless you pass `--modify-path`; `--no-modify-path` never edits it. `--pair` runs the CLI by its absolute path, so it works before PATH changes. install.ps1 adds the user PATH by default (`-NoModifyPath` opts out). `--mode` writes `~/.cua/spaces-install-mode`, which the app reads on first launch.
MDM on macOS: `apps/cua-spaces/scripts/build-pkg.sh` builds a `.pkg` (signed with `--sign`, install mode baked with `--mode`) that installs the app and links `/usr/local/bin/cua` to the CLI bundled inside it. The macOS app is the SwiftUI app (`apps/cua-spaces-macos`, `scripts/build-release.sh`), which carries the CLI as `Contents/MacOS/cua`; the Linux and Windows Electron app (`apps/cua-spaces-desktop`) bundles it itself, and the Tauri bundles (disabled) carry it as a sidecar (`apps/cua-spaces/scripts/prepare-cli-sidecar.sh` + `src-tauri/tauri.sidecar.conf.json`).
@@ -68,7 +69,7 @@ MDM on macOS: `apps/cua-spaces/scripts/build-pkg.sh` builds a `.pkg` (signed wit
Both scripts read `release-artifacts.json`:
-- latest: `https://github.com/trycua/cua/releases/download/cua-install-latest/release-artifacts.json` (a rolling release the CD workflows update)
+- latest: `https://github.com/trycua/cua/releases/download/cua-install-latest/release-artifacts.json` (a rolling release the CD workflows update: `cd-cua-sdk.yml` moves the `cli` version after a cua SDK publish, `cd-cua-spaces.yml` the `app` version, and `release-installers-feed.yml` republishes install.sh / install.ps1 when they change on main)
- pinned: `https://github.com/trycua/cua/releases/download/cua-sdk-v<version>/release-artifacts.json`
The copies of `install.sh` / `install.ps1` on a repository's `cua-install-latest` release default to that repository: the release workflows publish them through `stamp_installers.py --repo "$GITHUB_REPOSITORY"`, so the trycua/cua-staging feed downloads, and verifies Sigstore identities against, trycua/cua-staging's own releases. The files in this directory keep `trycua/cua`.
@@ -82,7 +83,7 @@ The copies of `install.sh` / `install.ps1` on a repository's `cua-install-latest
`<platform>` is `darwin-arm64`, `darwin-x64`, `linux-x64`, `linux-arm64`, `windows-x64` or `windows-arm64`. Each entry carries `url`, `sha256` and, when present next to the file, `minisig` and `cosign_bundle` URLs. Every artifact sits on one line so install.sh can read it without jq.
-Downloads always check sha256. Signatures are checked when the entry lists one and `minisign` (with `CUA_INSTALL_MINISIGN_PUBKEY` or the key baked into the script) or `cosign` is installed.
+Downloads always check sha256. Signatures are checked when the entry lists one and `minisign` (with `CUA_INSTALL_MINISIGN_PUBKEY` or the key baked into the script) or `cosign` is installed. If neither is installed the installer prints one info line (sha256 was checked) and goes on; `--require-signature` turns that into an error.
## Tests
diff --git a/scripts/install/install.ps1 b/scripts/install/install.ps1
index 71d7f40a54..3a345e909e 100644
--- a/scripts/install/install.ps1
+++ b/scripts/install/install.ps1
@@ -307,7 +307,11 @@ function Test-Signature([string]$File, $Entry, [string]$ManifestUrl) {
Stop-Install "no verifiable signature for $(Split-Path -Leaf $File) (install minisign or cosign)"
}
if (-not $ok -and ($Entry.PSObject.Properties['minisig'] -or $Entry.PSObject.Properties['cosign_bundle'])) {
- Write-Warning "$(Split-Path -Leaf $File) is signed, but neither minisign nor cosign is installed; verified its sha256 only (install cosign, or pass -RequireSignature to insist)"
+ # One quiet line per run: sha256 is checked either way.
+ if (-not $script:SigNoted) {
+ $script:SigNoted = $true
+ Write-Info 'checked sha256 (cosign is not installed, so release signatures were not checked; -RequireSignature makes that an error)'
+ }
}
}
diff --git a/scripts/install/install.sh b/scripts/install/install.sh
index 1f0cda587e..32b093f6c4 100755
--- a/scripts/install/install.sh
+++ b/scripts/install/install.sh
@@ -24,7 +24,8 @@
# --relay URL relay for --pair (default https://relay.cua.ai)
# --version VERSION install this CLI release (default: latest)
# --prefix DIR install under DIR (DIR/bin, DIR/Applications)
-# --modify-path add the bin dir to your shell profile
+# --modify-path add the bin dir to your shell profile without asking
+# --no-modify-path never edit your shell profile (print the one-line command)
# --no-onboarding do not run `cua auth login` afterwards
# --require-signature fail unless a signature (minisign/cosign) verifies
# --dry-run print what would happen, change nothing
@@ -70,6 +71,8 @@ relay_url=""
version=""
prefix=""
modify_path=0
+no_modify_path=0
+sig_noted=0
onboarding=1
require_sig=0
dry_run=0
@@ -158,6 +161,7 @@ parse_args() {
;;
--prefix=*) prefix="${1#--prefix=}" ;;
--modify-path) modify_path=1 ;;
+ --no-modify-path) no_modify_path=1 ;;
--no-onboarding) onboarding=0 ;;
--require-signature) require_sig=1 ;;
--dry-run) dry_run=1 ;;
@@ -581,7 +585,11 @@ verify_signature() { # file entry
die "no verifiable signature for ${1##*/} (install minisign or cosign)"
fi
if [ "$sig_ok" = 0 ] && { [ -n "$minisig" ] || [ -n "$bundle" ]; }; then
- warn "${1##*/} is signed, but neither minisign nor cosign is installed; verified its sha256 only (install cosign, or pass --require-signature to insist)"
+ # One quiet line per run: sha256 is checked either way.
+ if [ "$sig_noted" = 0 ]; then
+ sig_noted=1
+ info "checked sha256 (cosign is not installed, so release signatures were not checked; --require-signature makes that an error)"
+ fi
fi
}
@@ -657,7 +665,17 @@ ensure_path() { # dir
fi
profile="$(profile_file)"
line="$(path_line "$1" "$profile")"
- if [ "$modify_path" = 1 ]; then
+ if [ "$modify_path" = 0 ] && [ "$no_modify_path" = 0 ] && [ "$assume_yes" = 0 ] && [ "$dry_run" = 0 ] && [ "${CUA_INSTALL_NONINTERACTIVE:-0}" != 1 ] && tty_ok; then
+ # Interactive default: offer to add it (Enter = yes).
+ printf 'Add %s to PATH in %s so cua works in new terminals? [Y/n] ' "$1" "$profile" >/dev/tty
+ answer=""
+ read -r answer </dev/tty || answer=""
+ case "$answer" in
+ [nN] | [nN][oO]) ;;
+ *) modify_path=1 ;;
+ esac
+ fi
+ if [ "$modify_path" = 1 ] && [ "$no_modify_path" = 0 ]; then
if [ -f "$profile" ] && grep -qF "$line" "$profile"; then
return
fi
@@ -667,10 +685,10 @@ ensure_path() { # dir
fi
mkdir -p "$(dirname "$profile")"
printf '\n# Added by the cua installer\n%s\n' "$line" >>"$profile"
- info "added $1 to PATH in $profile (open a new shell to pick it up)"
+ info "added $1 to PATH in $profile (open a new terminal to pick it up)"
else
say ""
- say "$1 is not on your PATH. Add it with:"
+ say "$1 is not on your PATH. Add it with this one line, then open a new terminal:"
say " echo '$line' >> $profile"
say "(or rerun the installer with --modify-path)"
fi
diff --git a/scripts/install/tests/run.sh b/scripts/install/tests/run.sh
index d66fa27a68..c8545ca416 100755
--- a/scripts/install/tests/run.sh
+++ b/scripts/install/tests/run.sh
@@ -399,6 +399,29 @@ if [ "$(id -u)" = 0 ] && command -v apt-get >/dev/null 2>&1; then
check "root + apt: the app is the .deb" sh -c "[ $status = 0 ] && grep -q 'apt-get install' '$work/out' && grep -q 'cua-spaces-$version-linux-x64.deb' '$work/out'"
fi
+# PATH: not on PATH prints one exact line for the detected shell; never edits
+# the profile without consent; --no-modify-path stays silent about editing.
+inst SHELL=/bin/zsh -- --yes --cli-only --prefix "$work/pp1"
+check "PATH hint: exact one-liner for the user's shell (.zshrc)" sh -c "grep -qF \"echo 'export PATH=\\\"$work/pp1/bin:\\\$PATH\\\"' >> $home/.zshrc\" '$work/out' && [ ! -e '$home/.zshrc' ]"
+inst -- --yes --cli-only --no-modify-path --prefix "$work/pp2"
+check "--no-modify-path: profile untouched, hint printed" sh -c "[ $status = 0 ] && grep -q 'is not on your PATH' '$work/out' && [ ! -e '$home/.profile' ]"
+inst -- --yes --cli-only --modify-path --no-modify-path --prefix "$work/pp3"
+check "--no-modify-path wins over --modify-path" absent "$home/.profile"
+inst -- --pair K7QM-4XPB-2RHD --prefix "$work/pp4"
+check "--pair runs the CLI by absolute path even when it is not on PATH" sh -c "[ $status = 0 ] && grep -qx 'host setup --pair K7QM-4XPB-2RHD' '$home/cua.log' && grep -q 'This machine is added' '$work/out'"
+
+# One quiet info line when signatures cannot be checked (neither minisign nor cosign).
+sig2="$release/sig2"
+mkdir -p "$sig2"
+cp "$tag_dir"/cua-cli-* "$tag_dir"/cua-spaces-"$version"-linux-x64.AppImage "$sig2/"
+for f in "$sig2"/cua-cli-*.tar.gz "$sig2"/*.AppImage; do printf 'sig\n' >"$f.minisig"; done
+python3 "$manifest_tool" --component cli --version "$version" --dir "$sig2" --out "$sig2/cli.json"
+python3 "$manifest_tool" --component app --version "$version" --dir "$sig2" --merge "$sig2/cli.json" --out "$sig2/release-artifacts.json"
+inst CUA_INSTALL_MANIFEST_URL="$base/sig2/release-artifacts.json" -- --yes --no-onboarding --select spaces --prefix "$work/sg1"
+check "unverifiable signatures: one info line, no warning" sh -c "[ $status = 0 ] && [ \"\$(grep -c 'release signatures were not checked' '$work/out')\" = 1 ] && ! grep -qi 'warning.*minisign' '$work/out'"
+inst CUA_INSTALL_MANIFEST_URL="$base/sig2/release-artifacts.json" -- --yes --no-onboarding --select spaces --require-signature --prefix "$work/sg2"
+check "--require-signature still fails without minisign or cosign" sh -c "[ $status != 0 ] && grep -q 'no verifiable signature' '$work/out'"
+
inst -- --help
check "--help prints usage" sh -c "[ $status = 0 ] && grep -q -- '--cli-only' '$work/out'"
@@ -415,6 +438,27 @@ if script --version 2>/dev/null | grep -q util-linux; then
script -qec "$sh_bin '$installer' --yes --cli-only --no-onboarding --prefix '$work/p14'" /dev/null >"$work/out" 2>&1 </dev/null
check "interactive + --no-onboarding: no login" absent "$home/cua2.log"
+ # PATH prompt on a terminal: Enter adds it to the profile, n leaves it.
+ if command -v timeout >/dev/null 2>&1; then
+ pty_path() { # KEYS PREFIX
+ home="$work/home.pty.$RANDOM_SEQ"
+ RANDOM_SEQ=$((RANDOM_SEQ + 1))
+ mkdir -p "$home"
+ (
+ sleep 2
+ printf '%b' "$1"
+ sleep 2
+ ) | env -i PATH="$PATH" HOME="$home" SHELL=/bin/zsh CUA_HOME="$home/.cua" \
+ CUA_INSTALL_BASE_URL="$base" CUA_INSTALL_OS=linux CUA_INSTALL_ARCH=x86_64 CUA_FAKE_LOG="$home/cua.log" \
+ timeout 60 script -qec "$sh_bin '$installer' --cli-only --no-onboarding --prefix '$2'" /dev/null >"$work/out" 2>&1
+ status=$?
+ }
+ pty_path '\r' "$work/pt1"
+ check "PATH prompt: Enter adds the bin dir to .zshrc" sh -c "[ $status = 0 ] && grep -q '$work/pt1/bin' '$home/.zshrc' && grep -q 'Add .* to PATH' '$work/out'"
+ pty_path 'n\r' "$work/pt2"
+ check "PATH prompt: n leaves the profile alone and prints the one-liner" sh -c "[ $status = 0 ] && [ ! -e '$home/.zshrc' ] && grep -q 'is not on your PATH' '$work/out'"
+ fi
+
# The checklist, driven through a pty. Keys arrive after the prompt shows.
# tty_inst KEYS ARGS...: run install.sh in a pty with a fresh HOME.
tty_inst() {