-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·185 lines (165 loc) · 6.35 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·185 lines (165 loc) · 6.35 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/usr/bin/env bash
# ══════════════════════════════════════════════════════════════
# Cleo Agent Stack — One-click local dev setup
# Usage: bash setup.sh
# ══════════════════════════════════════════════════════════════
set -euo pipefail
ROOT="$(cd "$(dirname "$0")" && pwd)"
cd "$ROOT"
VENV_DIR=".venv"
# ── Colors ──
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
DIM='\033[2m'
BOLD='\033[1m'
RESET='\033[0m'
ok() { echo -e " ${GREEN}✓${RESET} $1"; }
fail() { echo -e " ${RED}✗${RESET} $1"; exit 1; }
info() { echo -e " ${DIM}$1${RESET}"; }
warn() { echo -e " ${YELLOW}!${RESET} $1"; }
echo ""
echo " ██████╗██╗ ███████╗ ██████╗ "
echo " ██╔════╝██║ ██╔════╝██╔═══██╗"
echo " ██║ ██║ █████╗ ██║ ██║"
echo " ██║ ██║ ██╔══╝ ██║ ██║"
echo " ╚██████╗███████╗███████╗╚██████╔╝"
echo " ╚═════╝╚══════╝╚══════╝ ╚═════╝ "
echo ""
# ── 1. Find Python 3 ──
PYTHON=""
for candidate in python3 python; do
if command -v "$candidate" &>/dev/null; then
version=$("$candidate" --version 2>&1 | grep -oE '[0-9]+\.[0-9]+')
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
if [ "$major" -ge 3 ] && [ "$minor" -ge 10 ]; then
PYTHON="$candidate"
break
fi
fi
done
if [ -z "$PYTHON" ]; then
fail "Python 3.10+ required. Install: brew install python3"
fi
ok "Python: $($PYTHON --version)"
# ── 2. Create virtual environment ──
if [ ! -d "$VENV_DIR" ]; then
info "Creating virtual environment..."
"$PYTHON" -m venv "$VENV_DIR"
ok "Virtual environment created"
else
ok "Virtual environment exists"
fi
# Activate
# shellcheck disable=SC1091
source "$VENV_DIR/bin/activate"
# ── 3. Install package (editable mode) ──
info "Installing cleo + dependencies..."
pip install --upgrade pip -q 2>/dev/null
pip install -e ".[dev]" -q 2>&1 | tail -3 || true
ok "Dependencies installed"
# ── 4. Create .env if missing ──
if [ ! -f .env ]; then
if [ -f .env.example ]; then
cp .env.example .env
ok "Created .env from .env.example"
info "Edit .env to add your API keys"
fi
else
ok ".env exists"
fi
# ── 5. Create directories ──
mkdir -p config .logs memory workflows
# ── 6. Install 'cleo' command globally ──
# After `pip install -e .`, cleo is at .venv/bin/cleo
# Symlink to /usr/local/bin so it works from anywhere
CLEO_BIN="$ROOT/$VENV_DIR/bin/cleo"
TARGET="/usr/local/bin/cleo"
if [ -f "$CLEO_BIN" ]; then
if [ -L "$TARGET" ] && [ "$(readlink "$TARGET")" = "$CLEO_BIN" ]; then
ok "CLI: cleo (already linked)"
elif [ -e "$TARGET" ]; then
warn "Cannot link: $TARGET already exists (different program)"
info "Use: $CLEO_BIN or source .venv/bin/activate && cleo"
else
info "Linking cleo → /usr/local/bin/ (may ask for password)"
if ln -sf "$CLEO_BIN" "$TARGET" 2>/dev/null; then
ok "CLI: cleo (linked to /usr/local/bin/)"
elif sudo ln -sf "$CLEO_BIN" "$TARGET" 2>/dev/null; then
ok "CLI: cleo (linked to /usr/local/bin/)"
else
warn "Could not link to /usr/local/bin/"
info "Use: source .venv/bin/activate && cleo"
fi
fi
else
warn "cleo binary not found — try: pip install -e ."
fi
# ── 7. Health check ──
info "Running health check..."
if python3 -c "import yaml, httpx, filelock, rich, questionary" 2>/dev/null; then
ok "All core packages importable"
else
fail "Some packages failed to import — check pip install output above"
fi
# ── 8. Shell completion (bash/zsh) ──
COMP_SCRIPT="$ROOT/cleo-completion.sh"
cat > "$COMP_SCRIPT" <<'COMPEOF'
# Cleo CLI bash/zsh completion
_cleo_completions() {
local cur="${COMP_WORDS[COMP_CWORD]}"
local prev="${COMP_WORDS[COMP_CWORD-1]}"
local cmds="onboard run status scores doctor gateway agents workflow chain export cron install uninstall update"
case "$prev" in
cleo)
COMPREPLY=( $(compgen -W "$cmds" -- "$cur") ) ;;
gateway)
COMPREPLY=( $(compgen -W "start stop restart status install uninstall" -- "$cur") ) ;;
agents)
COMPREPLY=( $(compgen -W "create add" -- "$cur") ) ;;
workflow)
COMPREPLY=( $(compgen -W "list run" -- "$cur") ) ;;
chain)
COMPREPLY=( $(compgen -W "status balance init register health" -- "$cur") ) ;;
cron)
COMPREPLY=( $(compgen -W "list add remove run" -- "$cur") ) ;;
doctor)
COMPREPLY=( $(compgen -W "--repair --deep" -- "$cur") ) ;;
export)
COMPREPLY=( $(compgen -W "--format" -- "$cur") ) ;;
--format|-f)
COMPREPLY=( $(compgen -W "md json" -- "$cur") ) ;;
--action-type)
COMPREPLY=( $(compgen -W "task exec webhook" -- "$cur") ) ;;
--type)
COMPREPLY=( $(compgen -W "once interval cron" -- "$cur") ) ;;
--template)
COMPREPLY=( $(compgen -W "researcher coder debugger doc_writer" -- "$cur") ) ;;
esac
}
complete -F _cleo_completions cleo
COMPEOF
INSTALLED_COMP=false
for rcfile in "$HOME/.bashrc" "$HOME/.zshrc"; do
if [ -f "$rcfile" ]; then
if ! grep -q "cleo-completion" "$rcfile" 2>/dev/null; then
echo "" >> "$rcfile"
echo "# Cleo CLI completion" >> "$rcfile"
echo "[ -f \"$COMP_SCRIPT\" ] && source \"$COMP_SCRIPT\"" >> "$rcfile"
INSTALLED_COMP=true
fi
fi
done
if [ "$INSTALLED_COMP" = true ]; then
ok "Shell completion installed (restart shell to activate)"
else
ok "Shell completion ready"
fi
echo ""
echo -e " ${GREEN}${BOLD}Setup complete!${RESET}"
echo ""
# ── 9. Launch onboarding wizard ──
echo -e " ${BOLD}Launching onboarding wizard...${RESET}"
echo ""
exec "$ROOT/$VENV_DIR/bin/cleo" onboard