|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# conductor-init.sh - Universal Installer for Conductor-Score |
| 4 | +# Usage: bash <(curl -fsSL https://raw.githubusercontent.com/ryanmac/conductor-score/main/conductor-init.sh) |
| 5 | +# Installs Conductor-Score into the current Git repository without full cloning. |
| 6 | + |
| 7 | +set -e |
| 8 | + |
| 9 | +# Color codes for output |
| 10 | +RED='\033[0;31m' |
| 11 | +GREEN='\033[0;32m' |
| 12 | +YELLOW='\033[1;33m' |
| 13 | +NC='\033[0m' # No Color |
| 14 | + |
| 15 | +echo -e "${GREEN}🚀 Conductor-Score Universal Installer${NC}" |
| 16 | +echo "==========================================" |
| 17 | +echo "This script will install Conductor-Score into your current Git repository." |
| 18 | +echo "It will download necessary files and run the setup automatically." |
| 19 | +echo "" |
| 20 | + |
| 21 | +# Step 1: Prerequisite Checks |
| 22 | +echo -e "${YELLOW}🔍 Checking prerequisites...${NC}" |
| 23 | + |
| 24 | +# Check if in a Git repository |
| 25 | +if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then |
| 26 | + echo -e "${RED}❌ Error: Not in a Git repository. Please run this from the root of a Git repo.${NC}" |
| 27 | + exit 1 |
| 28 | +fi |
| 29 | + |
| 30 | +# Check for Git |
| 31 | +if ! command -v git >/dev/null 2>&1; then |
| 32 | + echo -e "${RED}❌ Error: Git is not installed. Please install Git and try again.${NC}" |
| 33 | + exit 1 |
| 34 | +fi |
| 35 | + |
| 36 | +# Check for Python 3.9+ |
| 37 | +if ! command -v python3 >/dev/null 2>&1 || ! python3 -c "import sys; exit(0 if sys.version_info >= (3,9) else 1)"; then |
| 38 | + echo -e "${RED}❌ Error: Python 3.9+ is required. Please install Python 3.9 or higher.${NC}" |
| 39 | + exit 1 |
| 40 | +fi |
| 41 | + |
| 42 | +# Check for curl |
| 43 | +if ! command -v curl >/dev/null 2>&1; then |
| 44 | + echo -e "${RED}❌ Error: curl is not installed. Please install curl and try again.${NC}" |
| 45 | + exit 1 |
| 46 | +fi |
| 47 | + |
| 48 | +# Check for tar (needed for extraction) |
| 49 | +if ! command -v tar >/dev/null 2>&1; then |
| 50 | + echo -e "${RED}❌ Error: tar is not installed. Please install tar and try again.${NC}" |
| 51 | + exit 1 |
| 52 | +fi |
| 53 | + |
| 54 | +# Check for existing installation |
| 55 | +if [ -d ".conductor" ]; then |
| 56 | + echo -e "${YELLOW}⚠️ Existing .conductor directory found.${NC}" |
| 57 | + read -p "Do you want to overwrite and reinstall? [y/N]: " -n 1 -r |
| 58 | + echo "" |
| 59 | + if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
| 60 | + echo -e "${RED}❌ Installation cancelled.${NC}" |
| 61 | + exit 0 |
| 62 | + fi |
| 63 | + rm -rf .conductor |
| 64 | +fi |
| 65 | + |
| 66 | +echo -e "${GREEN}✅ All prerequisites met.${NC}" |
| 67 | +echo "" |
| 68 | + |
| 69 | +# Step 2: Download and Extract Essential Files from Tarball |
| 70 | +echo -e "${YELLOW}📥 Downloading and extracting from GitHub tarball...${NC}" |
| 71 | +REPO_TARBALL_URL="https://github.com/ryanmac/conductor-score/archive/refs/heads/main.tar.gz" |
| 72 | +TEMP_DIR="/tmp/conductor-score-init" |
| 73 | + |
| 74 | +# Create temp dir |
| 75 | +mkdir -p "$TEMP_DIR" |
| 76 | + |
| 77 | +# Download and extract tarball to temp dir |
| 78 | +curl -fsSL "$REPO_TARBALL_URL" | tar -xz -C "$TEMP_DIR" --strip-components=1 || { |
| 79 | + echo -e "${RED}❌ Failed to download or extract tarball. Check your network or URL.${NC}" |
| 80 | + rm -rf "$TEMP_DIR" |
| 81 | + exit 1 |
| 82 | +} |
| 83 | + |
| 84 | +# Copy essential files and directories |
| 85 | +cp -r "$TEMP_DIR/.conductor" . || { |
| 86 | + echo -e "${RED}❌ Failed to copy .conductor directory.${NC}" |
| 87 | + rm -rf "$TEMP_DIR" |
| 88 | + exit 1 |
| 89 | +} |
| 90 | +cp "$TEMP_DIR/setup.py" . || { |
| 91 | + echo -e "${RED}❌ Failed to copy setup.py.${NC}" |
| 92 | + rm -rf "$TEMP_DIR" |
| 93 | + exit 1 |
| 94 | +} |
| 95 | +cp "$TEMP_DIR/requirements.txt" . || { |
| 96 | + echo -e "${RED}❌ Failed to copy requirements.txt.${NC}" |
| 97 | + rm -rf "$TEMP_DIR" |
| 98 | + exit 1 |
| 99 | +} |
| 100 | +cp "$TEMP_DIR/pyproject.toml" . || { |
| 101 | + echo -e "${RED}❌ Failed to copy pyproject.toml.${NC}" |
| 102 | + rm -rf "$TEMP_DIR" |
| 103 | + exit 1 |
| 104 | +} |
| 105 | +cp "$TEMP_DIR/VERSION" . || { |
| 106 | + echo -e "${RED}❌ Failed to copy VERSION.${NC}" |
| 107 | + rm -rf "$TEMP_DIR" |
| 108 | + exit 1 |
| 109 | +} |
| 110 | + |
| 111 | +# Optionally copy examples (prompt user) |
| 112 | +read -p "Do you want to copy example configurations (recommended for new users)? [Y/n]: " -n 1 -r |
| 113 | +echo "" |
| 114 | +if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then |
| 115 | + cp -r "$TEMP_DIR/examples" . || { |
| 116 | + echo -e "${YELLOW}⚠️ Failed to copy examples directory (continuing anyway).${NC}" |
| 117 | + } |
| 118 | + echo -e "${GREEN}✅ Examples copied.${NC}" |
| 119 | +fi |
| 120 | + |
| 121 | +# Clean up temp dir |
| 122 | +rm -rf "$TEMP_DIR" |
| 123 | + |
| 124 | +echo -e "${GREEN}✅ Files extracted: .conductor/, setup.py, requirements.txt, pyproject.toml, VERSION${NC}" |
| 125 | +echo "" |
| 126 | + |
| 127 | +# Step 3: Install Dependencies |
| 128 | +echo -e "${YELLOW}📦 Installing dependencies...${NC}" |
| 129 | + |
| 130 | +# Prefer Poetry if available, otherwise use pip + venv |
| 131 | +if command -v poetry >/dev/null 2>&1; then |
| 132 | + echo "🎵 Poetry detected. Using Poetry for installation." |
| 133 | + poetry install || { |
| 134 | + echo -e "${RED}❌ Poetry install failed.${NC}" |
| 135 | + exit 1 |
| 136 | + } |
| 137 | +else |
| 138 | + echo "📦 Poetry not found. Using pip and virtual environment." |
| 139 | + python3 -m venv .venv || { |
| 140 | + echo -e "${RED}❌ Failed to create virtual environment.${NC}" |
| 141 | + exit 1 |
| 142 | + } |
| 143 | + source .venv/bin/activate |
| 144 | + pip install --upgrade pip || { |
| 145 | + echo -e "${RED}❌ Failed to upgrade pip.${NC}" |
| 146 | + exit 1 |
| 147 | + } |
| 148 | + pip install -r requirements.txt || { |
| 149 | + echo -e "${RED}❌ Pip install failed.${NC}" |
| 150 | + exit 1 |
| 151 | + } |
| 152 | +fi |
| 153 | + |
| 154 | +echo -e "${GREEN}✅ Dependencies installed.${NC}" |
| 155 | +echo "" |
| 156 | + |
| 157 | +# Step 4: Run Setup |
| 158 | +echo -e "${YELLOW}🔧 Running automatic setup...${NC}" |
| 159 | + |
| 160 | +# Run setup.py with --auto flag |
| 161 | +if command -v poetry >/dev/null 2>&1; then |
| 162 | + poetry run python setup.py --auto || { |
| 163 | + echo -e "${RED}❌ Setup failed.${NC}" |
| 164 | + exit 1 |
| 165 | + } |
| 166 | +else |
| 167 | + python setup.py --auto || { |
| 168 | + echo -e "${RED}❌ Setup failed.${NC}" |
| 169 | + exit 1 |
| 170 | + } |
| 171 | +fi |
| 172 | + |
| 173 | +echo -e "${GREEN}✅ Setup complete.${NC}" |
| 174 | +echo "" |
| 175 | + |
| 176 | +# Note: No cleanup of setup.py, requirements.txt, etc. - leaving them in place for user reference and future use. |
| 177 | + |
| 178 | +# Step 5: Next Steps |
| 179 | +echo -e "${GREEN}🎉 Installation Successful!${NC}" |
| 180 | +echo "==========================================" |
| 181 | +echo "Conductor-Score is now installed in your repository." |
| 182 | +echo "" |
| 183 | +echo "Next steps:" |
| 184 | +echo "1. Review .conductor/config.yaml and customize if needed." |
| 185 | +echo "2. Create a task: Use GitHub Issues with 'conductor:task' label." |
| 186 | +echo "3. Launch an agent: bash .conductor/scripts/bootstrap.sh dev" |
| 187 | +echo "4. For full documentation, see the original repo: https://github.com/ryanmac/conductor-score" |
| 188 | +echo "" |
| 189 | +echo "If you encounter issues, check the troubleshooting guide in the repo." |
| 190 | +echo -e "${GREEN}Happy orchestrating! 🎼${NC}" |
0 commit comments