#!/bin/sh # Hive 1.0.0. Requires Node.js 20+. Installs only this CLI; setup is a separate step. set -eu command -v node >/dev/null 2>&1 || { echo 'Install Node.js 20 or newer from https://nodejs.org first.' >&2; exit 1; } node -e 'if (Number(process.versions.node.split(".")[0]) < 20) process.exit(1)' || { echo 'Node.js 20 or newer is required.' >&2; exit 1; } command -v curl >/dev/null 2>&1 || { echo 'curl is required.' >&2; exit 1; } install_dir="$HOME/.local/share/hivemindos-cli/1.0.0" bin_dir="$HOME/.local/bin" umask 077 mkdir -p "$install_dir" "$bin_dir" if [ -e "$bin_dir/hive" ] || [ -L "$bin_dir/hive" ]; then if ! head -n 2 "$bin_dir/hive" | grep -q '^# HivemindOS CLI launcher$'; then echo "$bin_dir/hive already exists. It was left unchanged. Install with npm or pipx instead." >&2 exit 1 fi fi staging=$(mktemp -d) trap 'rm -rf "$staging"' EXIT HUP INT TERM curl --proto '=https' --tlsv1.2 -fsSL 'https://hivemindos.app/hive/1.0.0/hive.mjs' -o "$staging/hive.mjs" node --input-type=module - "$staging/hive.mjs" <<'VERIFY' import { readFileSync } from 'node:fs'; import { createHash } from 'node:crypto'; if (createHash('sha256').update(readFileSync(process.argv[2])).digest('hex') !== '38c1ebeee350985e6f1aa5af5610e45db3e813bb0c8bec6a5daa8d7a1e2f69d4') { console.error('Download verification failed. Nothing was installed.'); process.exit(1); } VERIFY mv "$staging/hive.mjs" "$install_dir/hive.mjs" # The quoted heredoc leaves HOME to be resolved when hive is invoked. cat > "$staging/hive" <<'LAUNCHER' #!/bin/sh # HivemindOS CLI launcher HIVE_INSTALL_SOURCE=script exec node "$HOME/.local/share/hivemindos-cli/1.0.0/hive.mjs" "$@" LAUNCHER chmod 755 "$staging/hive" mv "$staging/hive" "$bin_dir/hive" echo 'Hive installed. Run: hive setup' case ":$PATH:" in *":$bin_dir:"*) ;; *) echo 'Add $HOME/.local/bin to PATH, or run: ~/.local/bin/hive setup' ;; esac