File size: 3,138 Bytes
c13f797
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
# ============================================================
# صانع (San'e) — One-Command Install Script
# ============================================================
# Installs San'e on macOS and Linux (Ubuntu)
# ============================================================

# Colors
BLUE='\033[0;34m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color

# Helper functions
echo_info() {
    echo -e "${BLUE}INFO: $1${NC}"
}

echo_success() {
    echo -e "${GREEN}SUCCESS: $1${NC}"
}

echo_warn() {
    echo -e "${YELLOW}WARN: $1${NC}"
}

echo_error() {
    echo -e "${RED}ERROR: $1${NC}"
    exit 1
}

# Check for required commands
check_command() {
    if ! command -v $1 &> /dev/null; then
        echo_error "$1 is not installed. Please install it first."
    fi
}

main() {
    echo_info "🦅 Starting San'e (صانع) installation..."

    # 1. Check dependencies
    echo_info "Checking dependencies (git, node, npm)..."
    check_command "git"
    check_command "node"
    check_command "npm"

    # Check Node version (must be >= 22)
    NODE_VERSION=$(node -v | cut -d'v' -f2)
    if [[ $(echo "$NODE_VERSION" | cut -d'.' -f1) -lt 22 ]]; then
        echo_error "Node.js version 22 or higher is required. You have v${NODE_VERSION}."
    fi
    echo_success "Dependencies are satisfied."

    # 2. Clone the repository
    if [ -d "sane-assistant" ]; then
        echo_warn "Directory 'sane-assistant' already exists. Skipping clone."
    else
        echo_info "Cloning the repository..."
        git clone https://github.com/your-org/sane-assistant.git || echo_error "Failed to clone repository."
    fi
    cd sane-assistant || echo_error "Failed to enter directory 'sane-assistant'."

    # 3. Install dependencies
    echo_info "Installing dependencies using pnpm (will be installed globally if needed)..."
    if ! command -v pnpm &> /dev/null; then
        npm install -g pnpm || echo_error "Failed to install pnpm."
    fi
    pnpm install || echo_error "Failed to install dependencies."
    echo_success "Dependencies installed."

    # 4. Setup .env file
    if [ -f ".env" ]; then
        echo_warn ".env file already exists. Skipping creation."
    else
        echo_info "Creating .env file from .env.example..."
        cp .env.example .env || echo_error "Failed to create .env file."
        echo_warn "Please edit the .env file now to add your API keys."
        echo_info "You need to set at least ANTHROPIC_API_KEY."
        read -p "Press [Enter] to open .env in your default editor..."
        ${EDITOR:-nano} .env
    fi

    # 5. Run onboarding wizard
    echo_info "Running the interactive onboarding wizard..."
    pnpm sane onboard || echo_error "Onboarding wizard failed."

    # 6. Final instructions
    echo_success "🎉 San'e (صانع) installation is complete!"
    echo_info "To start the assistant, run:"
    echo -e "${YELLOW}  cd sane-assistant${NC}"
    echo -e "${YELLOW}  pnpm start${NC}"
    echo_info "You can then interact with it via Telegram, WhatsApp, or the command line."
    echo_info "Dashboard: http://localhost:18789"
}

main