#!/bin/sh set -e REPO="chris/agent-tui" BASE_URL="https://gitea.yeeted.lol" INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}" OS=$(uname -s | tr '[:upper:]' '[:lower:]') ARCH=$(uname -m) case "$ARCH" in x86_64|amd64) ARCH="amd64" ;; arm64|aarch64) ARCH="arm64" ;; *) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;; esac case "$OS" in darwin|linux) ;; *) echo "Unsupported OS: $OS" >&2; exit 1 ;; esac # Resolve tag: use argument, or fetch latest release if [ -n "$1" ]; then TAG="$1" else TAG=$(curl -fsSL "${BASE_URL}/api/v1/repos/${REPO}/releases?limit=1" \ | grep -o '"tag_name":"[^"]*"' | head -1 | cut -d'"' -f4) if [ -z "$TAG" ]; then echo "Error: could not determine latest release" >&2 exit 1 fi fi BINARY="agent-tui-${OS}-${ARCH}" URL="${BASE_URL}/${REPO}/releases/download/${TAG}/${BINARY}" echo "Downloading ${BINARY} (${TAG})..." TMP=$(mktemp) trap 'rm -f "$TMP"' EXIT if command -v curl >/dev/null 2>&1; then curl -fSL -o "$TMP" "$URL" elif command -v wget >/dev/null 2>&1; then wget -qO "$TMP" "$URL" else echo "Error: curl or wget required" >&2 exit 1 fi chmod +x "$TMP" mkdir -p "$INSTALL_DIR" mv "$TMP" "${INSTALL_DIR}/agent-tui" echo "Installed agent-tui ${TAG} to ${INSTALL_DIR}/agent-tui" # Check if INSTALL_DIR is in PATH case ":$PATH:" in *":${INSTALL_DIR}:"*) ;; *) echo "" echo "Add to your PATH by running:" echo " echo 'export PATH=\"${INSTALL_DIR}:\$PATH\"' >> ~/.zshrc && source ~/.zshrc" ;; esac