#!/bin/bash # ReasonKit Installer # https://get.reasonkit.sh # # Linux/macOS: curl -fsSL https://get.reasonkit.sh | bash # Windows: irm https://get.reasonkit.sh/windows | iex # set -e # ANSI colors (disabled if not interactive terminal) if [ -t 1 ]; then CYAN='\033[0;36m' GREEN='\033[0;32m' YELLOW='\033[1;33m' RED='\033[0;31m' BOLD='\033[1m' NC='\033[0m' else CYAN='' GREEN='' YELLOW='' RED='' BOLD='' NC='' fi VERSION="0.1.0" REPO="https://github.com/reasonkit/reasonkit-core" echo "" echo -e "${CYAN}${BOLD}ReasonKit Installer${NC}" echo -e "Version: ${VERSION}" echo -e "────────────────────────────────────────" echo "" # Detect OS and architecture RAW_OS=$(uname -s) ARCH=$(uname -m) case "$ARCH" in x86_64|amd64) ARCH="x86_64" ;; aarch64|arm64) ARCH="aarch64" ;; armv7l) ARCH="armv7" ;; *) echo -e "${RED}Unsupported architecture: $ARCH${NC}" exit 1 ;; esac case "$RAW_OS" in Linux*) OS="linux" # Check for WSL if grep -qEi "(Microsoft|WSL)" /proc/version 2>/dev/null; then echo -e "${YELLOW}Detected: Windows Subsystem for Linux (WSL)${NC}" OS="linux-wsl" fi INSTALL_DIR="${HOME}/.local/bin" ;; Darwin*) OS="macos" INSTALL_DIR="${HOME}/.local/bin" ;; MINGW*|MSYS*|CYGWIN*) echo -e "${YELLOW}Detected: Windows (Git Bash/MSYS2/Cygwin)${NC}" echo "" echo -e "For native Windows installation, use PowerShell:" echo -e "${CYAN} irm https://get.reasonkit.sh/windows | iex${NC}" echo "" echo -e "Continuing with Unix-style installation..." OS="windows-mingw" INSTALL_DIR="${HOME}/.local/bin" ;; *) echo -e "${RED}Unsupported OS: $RAW_OS${NC}" echo "" echo -e "Supported platforms:" echo -e " • Linux (x86_64, aarch64)" echo -e " • macOS (Intel & Apple Silicon)" echo -e " • Windows (use PowerShell): irm https://get.reasonkit.sh/windows | iex" exit 1 ;; esac echo -e "Detected: ${BOLD}${OS}-${ARCH}${NC}" echo "" # Function to install via cargo install_cargo() { echo -e "${CYAN}Installing via Cargo (recommended)...${NC}" if ! command -v cargo >/dev/null 2>&1; then echo -e "${YELLOW}Rust not found. Installing Rust first...${NC}" curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y source "$HOME/.cargo/env" fi echo -e "Building from source (this may take 2-3 minutes)..." # Clone and build TEMP_DIR=$(mktemp -d) cd "$TEMP_DIR" echo -e "Cloning ReasonKit..." git clone --depth 1 ${REPO}.git reasonkit-core 2>/dev/null || { echo -e "${RED}Failed to clone repository.${NC}" echo -e "Repository may not be public yet. Try again later or visit:" echo -e "${CYAN}${REPO}${NC}" rm -rf "$TEMP_DIR" exit 1 } cd reasonkit-core echo -e "Building ReasonKit (release mode)..." cargo build --release 2>/dev/null || { echo -e "${RED}Build failed.${NC}" rm -rf "$TEMP_DIR" exit 1 } # Create install directory mkdir -p "$INSTALL_DIR" # Copy binary cp target/release/rk-core "$INSTALL_DIR/" 2>/dev/null || { echo -e "${YELLOW}Binary not found at expected path. Checking alternatives...${NC}" find target/release -name "rk*" -type f -executable 2>/dev/null | head -1 } # Cleanup cd / rm -rf "$TEMP_DIR" # Add to PATH if needed if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then echo "" echo -e "${YELLOW}Add to your PATH:${NC}" echo -e " export PATH=\"\$PATH:$INSTALL_DIR\"" echo "" echo "Add this line to your ~/.bashrc or ~/.zshrc for permanent access." fi echo "" echo -e "${GREEN}${BOLD}ReasonKit installed successfully!${NC}" } # Function to download pre-built binary (when available) install_binary() { BINARY_URL="${REPO}/releases/download/v${VERSION}/rk-core-${OS}-${ARCH}" echo -e "${CYAN}Downloading pre-built binary...${NC}" mkdir -p "$INSTALL_DIR" if curl -fsSL "$BINARY_URL" -o "$INSTALL_DIR/rk-core" 2>/dev/null; then chmod +x "$INSTALL_DIR/rk-core" echo -e "${GREEN}Downloaded successfully!${NC}" else echo -e "${YELLOW}Pre-built binary not available. Building from source...${NC}" install_cargo return fi echo "" echo -e "${GREEN}${BOLD}ReasonKit installed successfully!${NC}" } # Main installation logic main() { # Try binary first, fall back to cargo echo -e "${CYAN}Installation method: Build from source${NC}" echo "" # Check prerequisites if ! command -v git >/dev/null 2>&1; then echo -e "${RED}Git is required but not installed.${NC}" echo "Please install git first." exit 1 fi install_cargo echo "" echo -e "────────────────────────────────────────" echo "" echo -e "${BOLD}Quick Start:${NC}" echo "" echo -e " ${CYAN}rk-core think 'Should I take this job offer?'${NC}" echo "" echo -e " ${CYAN}rk-core think 'Is crypto a good investment?' --profile balanced${NC}" echo "" echo -e "${BOLD}Documentation:${NC} https://reasonkit.sh/docs/" echo "" echo -e "${BOLD}ThinkTools:${NC}" echo -e " • GigaThink - See all angles (10+ perspectives)" echo -e " • LaserLogic - Spot bad reasoning" echo -e " • BedRock - Find first principles" echo -e " • ProofGuard - Verify claims" echo -e " • BrutalHonesty - Reality check" echo "" echo -e "Turn Prompts into Protocols." echo "" } main "$@"