#!/usr/bin/env bash set -euo pipefail # ============================================================================= # install.sh — One-line installer for ai-initializer # # Usage: # curl -fsSL https://raw.githubusercontent.com/itdar/agents-initializer/main/install.sh | bash # # # Or with options: # curl -fsSL https://raw.githubusercontent.com/itdar/agents-initializer/main/install.sh | bash -s -- --no-run # # Downloads HOW_TO_AGENTS.md + setup.sh + ai-agency.sh into the current directory, # then runs setup.sh interactively. # ============================================================================= # --- Colors --- RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' CYAN='\033[0;36m' BOLD='\033[1m' DIM='\033[2m' NC='\033[0m' # --- Config --- REPO="itdar/agents-initializer" BRANCH="main" BASE_URL="https://raw.githubusercontent.com/${REPO}/${BRANCH}" # Files to download (always) REQUIRED_FILES=( "HOW_TO_AGENTS.md" "setup.sh" "ai-agency.sh" "scripts/sync-ai-rules.sh" ) # --- Parse arguments --- AUTO_RUN=true while [[ $# -gt 0 ]]; do case "$1" in --no-run) AUTO_RUN=false; shift ;; --help|-h) echo "" echo "ai-initializer installer" echo "" echo "Usage:" echo " curl -fsSL https://raw.githubusercontent.com/${REPO}/${BRANCH}/install.sh | bash" echo "" echo "Options (pass via: ... | bash -s -- [options]):" echo " --no-run Download files only, don't run setup.sh" echo " -h, --help Show this help" echo "" exit 0 ;; *) echo "Unknown option: $1"; exit 1 ;; esac done # --- Banner --- echo "" echo -e "${CYAN}${BOLD}" echo " +---------------------------------------------------------+" echo " | |" echo " | ai-initializer Installer |" echo " | |" echo " | github.com/${REPO} |" echo " | |" echo " +---------------------------------------------------------+" echo -e "${NC}" # --- Check prerequisites --- if ! command -v curl &>/dev/null; then echo -e "${RED}Error: curl is required but not installed.${NC}" exit 1 fi # --- Download files --- echo -e "${BOLD}Downloading files...${NC}" echo "" download_file() { local file="$1" local url="${BASE_URL}/${file}" # Create parent directory if needed local dir dir="$(dirname "$file")" if [[ "$dir" != "." ]]; then mkdir -p "$dir" fi if [[ -f "$file" ]]; then echo -e " ${YELLOW}~${NC} ${file} ${DIM}(already exists, overwriting)${NC}" fi if curl -fsSL "$url" -o "$file"; then echo -e " ${GREEN}+${NC} ${file}" else echo -e " ${RED}x${NC} ${file} ${DIM}(download failed)${NC}" return 1 fi } # Download required files for file in "${REQUIRED_FILES[@]}"; do download_file "$file" done # Make shell scripts executable chmod +x setup.sh ai-agency.sh scripts/sync-ai-rules.sh echo "" echo -e "${GREEN}${BOLD}Download complete!${NC}" echo "" # --- Run setup or show next steps --- if $AUTO_RUN; then echo -e "${DIM}Starting setup...${NC}" echo "" exec ./setup.sh else echo -e "${BOLD}Next steps:${NC}" echo "" echo -e " ${CYAN}# Run interactive setup${NC}" echo -e " ${BOLD}./setup.sh${NC}" echo "" echo -e " ${CYAN}# Launch agent sessions after setup${NC}" echo -e " ${BOLD}./ai-agency.sh${NC}" echo "" fi