#!/bin/sh set -e BASE_URL="https://cli.sariphi.ai" BINARIES="sariphi" AI_USAGE_INSTALLER="https://sariphi.ai/ai-usage.sh" # Installing sariphi also installs the ai-usage dashboard and registers the # 'ai' dispatcher (ai c, ai o, ai cost, ai usage) + 'awake' in ~/.zshrc. # --no-ai skip the ai-usage dashboard + shell commands # --skills also install the Claude/Codex agent skills (~/.agents/skills) # Env equivalents: SARIPHI_INSTALL_AI=0, SARIPHI_INSTALL_SKILLS=1. INSTALL_AI="${SARIPHI_INSTALL_AI:-1}" INSTALL_SKILLS="${SARIPHI_INSTALL_SKILLS:-0}" for arg in "$@"; do case "$arg" in --no-ai) INSTALL_AI=0 ;; --skills) INSTALL_SKILLS=1 ;; esac done # -- Detect platform ---------------------------------------------------------- OS="$(uname -s)" ARCH="$(uname -m)" case "$OS" in Darwin) OS_TAG="darwin" ;; Linux) OS_TAG="linux" ;; *) echo "Unsupported OS: $OS"; exit 1 ;; esac case "$ARCH" in x86_64|amd64) ARCH_TAG="x64" ;; arm64|aarch64) ARCH_TAG="arm64" ;; *) echo "Unsupported architecture: $ARCH"; exit 1 ;; esac INSTALL_DIR="/usr/local/bin" TMPDIR="${TMPDIR:-/tmp}" # -- Download and install each binary ----------------------------------------- for BINARY_NAME in $BINARIES; do ASSET="${BINARY_NAME}-${OS_TAG}-${ARCH_TAG}" DOWNLOAD_URL="${BASE_URL}/releases/latest/${ASSET}" TMP_FILE="${TMPDIR}/${ASSET}" echo "Downloading ${ASSET}..." if command -v curl >/dev/null 2>&1; then HTTP_CODE=$(curl -sSL -w "%{http_code}" -o "$TMP_FILE" "$DOWNLOAD_URL") if [ "$HTTP_CODE" -lt 200 ] || [ "$HTTP_CODE" -ge 300 ]; then echo " Skipping ${BINARY_NAME} (HTTP $HTTP_CODE)" rm -f "$TMP_FILE" continue fi elif command -v wget >/dev/null 2>&1; then wget -qO "$TMP_FILE" "$DOWNLOAD_URL" || { echo " Skipping ${BINARY_NAME}"; continue; } else echo "Error: curl or wget required"; exit 1 fi chmod +x "$TMP_FILE" if [ -w "$INSTALL_DIR" ]; then mv "$TMP_FILE" "${INSTALL_DIR}/${BINARY_NAME}" else sudo mv "$TMP_FILE" "${INSTALL_DIR}/${BINARY_NAME}" fi echo " Installed ${BINARY_NAME}" done # -- Create config dir --------------------------------------------------------- CONFIG_DIR="${HOME}/.sariphi" if [ ! -d "$CONFIG_DIR" ]; then mkdir -p "$CONFIG_DIR" chmod 700 "$CONFIG_DIR" fi # -- ai-usage dashboard + 'ai' shell commands ---------------------------------- # Best-effort: sariphi itself is installed by now, so a failure here must not # fail the install (set -e). The ai-usage installer handles Bun + PATH itself. if [ "$INSTALL_AI" = "1" ]; then if command -v curl >/dev/null 2>&1; then AI_FLAGS="--shell" [ "$INSTALL_SKILLS" = "1" ] && AI_FLAGS="--shell --skills" echo "" echo "Installing the ai-usage dashboard + ai shell commands..." if ! curl -fsSL "$AI_USAGE_INSTALLER" | sh -s -- $AI_FLAGS; then echo "" echo "ai-usage install failed (sariphi itself installed fine). Retry with:" echo " curl -fsSL $AI_USAGE_INSTALLER | sh -s -- $AI_FLAGS" fi else echo "Skipping the ai-usage dashboard (needs curl). Install later with:" echo " curl -fsSL $AI_USAGE_INSTALLER | sh -s -- --shell" fi fi echo "" echo "Get started:" echo " sariphi node register --purpose '' # request a node; an admin approves it in the dashboard" echo " sariphi node activate # after approval" echo " sariphi setup # check setup status" if [ "$INSTALL_AI" = "1" ]; then echo " ai usage # AI usage dashboard (ai help for more)" fi if [ "$INSTALL_SKILLS" != "1" ]; then echo "" echo "Optional: install the Claude/Codex agent skills too:" echo " curl -fsSL $AI_USAGE_INSTALLER | sh -s -- --skills" fi echo ""