-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·318 lines (267 loc) · 10.9 KB
/
install.sh
File metadata and controls
executable file
·318 lines (267 loc) · 10.9 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#!/bin/bash
# Agent Cube CLI Installer
# Usage: curl -fsSL https://raw.githubusercontent.com/aetheronhq/agent-cube/main/install.sh | bash
set -e
VERSION="1.0.0"
INSTALL_DIR="$HOME/.agent-cube"
BIN_DIR="$HOME/.local/bin"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m'
print_error() {
echo -e "${RED}❌ Error: $1${NC}" >&2
}
print_success() {
echo -e "${GREEN}✅ $1${NC}"
}
print_info() {
echo -e "${CYAN}ℹ️ $1${NC}"
}
print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}"
}
echo -e "${CYAN}╔════════════════════════════════════════╗${NC}"
echo -e "${CYAN}║ Agent Cube CLI Installer ║${NC}"
echo -e "${CYAN}║ Version ${VERSION} ║${NC}"
echo -e "${CYAN}╚════════════════════════════════════════╝${NC}"
echo ""
# Check prerequisites
print_info "Checking prerequisites..."
# Check bash prerequisites
if ! command -v curl &> /dev/null; then
print_error "curl is not installed"
echo "curl is required to download files"
exit 1
fi
if ! command -v jq &> /dev/null; then
print_warning "jq is not installed (required for bash version agent output parsing)"
echo "Install jq: brew install jq (macOS) or apt-get install jq (Linux)"
echo ""
fi
if ! command -v cursor-agent &> /dev/null; then
print_warning "cursor-agent is not installed (required to run agents)"
echo "Install cursor-agent: npm install -g @cursor/cli"
echo "Then authenticate: cursor-agent login"
echo ""
fi
# Check Python prerequisites
PYTHON_VERSION=""
if command -v python3 &> /dev/null; then
PYTHON_VERSION=$(python3 --version 2>&1 | awk '{print $2}')
PYTHON_MAJOR=$(echo $PYTHON_VERSION | cut -d. -f1)
PYTHON_MINOR=$(echo $PYTHON_VERSION | cut -d. -f2)
if [ "$PYTHON_MAJOR" -ge 3 ] && [ "$PYTHON_MINOR" -ge 10 ]; then
print_success "Python $PYTHON_VERSION detected (Python version available)"
INSTALL_PYTHON=true
else
print_warning "Python $PYTHON_VERSION detected (need 3.10+, Python version disabled)"
INSTALL_PYTHON=false
fi
else
print_warning "Python 3 not found (Python version disabled)"
INSTALL_PYTHON=false
fi
print_success "Prerequisites check complete"
echo ""
# Create installation directory
print_info "Installing to $INSTALL_DIR..."
if [ -d "$INSTALL_DIR" ]; then
print_warning "Removing existing installation"
rm -rf "$INSTALL_DIR"
fi
mkdir -p "$INSTALL_DIR/scripts/automation"
# Install from local repository
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ ! -f "$SCRIPT_DIR/scripts/cube" ]; then
print_error "scripts/cube not found. Please run this from the cloned agent-cube repository."
exit 1
fi
print_info "Installing from local repository..."
# Check if we're in a git repository
if [ -d "$SCRIPT_DIR/.git" ]; then
print_info "Git repository detected - creating direct symlinks (dev mode)"
INSTALL_DIR="$SCRIPT_DIR"
else
print_info "Non-git directory - copying files to $INSTALL_DIR"
cp "$SCRIPT_DIR/scripts/cube" "$INSTALL_DIR/scripts/cube"
chmod +x "$INSTALL_DIR/scripts/cube"
for script in launch-dual-writers.sh launch-judge-panel.sh send-writer-feedback.sh stream-agent.sh; do
if [ ! -f "$SCRIPT_DIR/scripts/automation/$script" ]; then
print_error "scripts/automation/$script not found"
exit 1
fi
cp "$SCRIPT_DIR/scripts/automation/$script" "$INSTALL_DIR/scripts/automation/$script"
chmod +x "$INSTALL_DIR/scripts/automation/$script"
done
# Copy documentation
[ -f "$SCRIPT_DIR/AGENT_CUBE.md" ] && cp "$SCRIPT_DIR/AGENT_CUBE.md" "$INSTALL_DIR/AGENT_CUBE.md"
[ -f "$SCRIPT_DIR/AGENT_CUBE_AUTOMATION.md" ] && cp "$SCRIPT_DIR/AGENT_CUBE_AUTOMATION.md" "$INSTALL_DIR/AGENT_CUBE_AUTOMATION.md"
fi
print_success "Files installed from: $INSTALL_DIR"
echo ""
# Create bin directory if it doesn't exist
mkdir -p "$BIN_DIR"
# Create symlink
print_info "Creating symlink in $BIN_DIR..."
if [ -L "$BIN_DIR/cube" ] || [ -f "$BIN_DIR/cube" ]; then
rm -f "$BIN_DIR/cube"
fi
ln -s "$INSTALL_DIR/scripts/cube" "$BIN_DIR/cube"
chmod +x "$INSTALL_DIR/scripts/cube"
print_success "Symlink created: $BIN_DIR/cube -> $INSTALL_DIR/scripts/cube"
echo ""
# Install Python version if available
if [ "$INSTALL_PYTHON" = true ]; then
echo ""
print_info "Installing Python version (cube-py)..."
echo ""
# Check if running from git repo
if [ -d "$SCRIPT_DIR/.git" ]; then
# Development mode - use pip install -e
print_info "Git repository detected - installing in editable mode"
cd "$INSTALL_DIR/python"
if python3 -m pip install -e . --quiet 2>/dev/null; then
print_success "Python version installed in editable mode"
# Find where pip installed the entry point
CUBE_PY_PATH=$(python3 -c "import sys; print([p for p in sys.path if 'bin' in p and p.startswith('$HOME')][0] + '/cube-py' if [p for p in sys.path if 'bin' in p and p.startswith('$HOME')] else '')" 2>/dev/null)
if [ -z "$CUBE_PY_PATH" ]; then
# Fallback: find cube-py in common locations
for bindir in ~/.pyenv/versions/*/bin ~/.local/bin /usr/local/bin; do
if [ -f "$bindir/cube-py" ]; then
CUBE_PY_PATH="$bindir/cube-py"
break
fi
done
fi
# Create symlink in ~/.local/bin if cube-py found elsewhere
if [ -n "$CUBE_PY_PATH" ] && [ -f "$CUBE_PY_PATH" ] && [ "$CUBE_PY_PATH" != "$BIN_DIR/cube-py" ]; then
print_info "Creating symlink to pip-installed cube-py"
ln -sf "$CUBE_PY_PATH" "$BIN_DIR/cube-py"
print_success "Symlink created: $BIN_DIR/cube-py -> $CUBE_PY_PATH"
elif [ ! -f "$BIN_DIR/cube-py" ]; then
# Create wrapper script as fallback
cat > "$BIN_DIR/cube-py" << EOF
#!/bin/bash
cd "$INSTALL_DIR/python"
python3 -m cube.cli "\$@"
EOF
chmod +x "$BIN_DIR/cube-py"
print_success "Wrapper script created: $BIN_DIR/cube-py"
fi
else
print_warning "Failed to install Python version with pip"
print_info "Trying manual installation..."
# Create wrapper script
cat > "$BIN_DIR/cube-py" << EOF
#!/bin/bash
cd "$INSTALL_DIR/python"
python3 -m cube.cli "\$@"
EOF
chmod +x "$BIN_DIR/cube-py"
print_success "Python version installed (manual wrapper)"
fi
else
# Non-git: copy python directory and create wrapper
print_info "Copying Python implementation..."
if [ -d "$SCRIPT_DIR/python" ]; then
cp -r "$SCRIPT_DIR/python" "$INSTALL_DIR/python"
# Create wrapper script
cat > "$BIN_DIR/cube-py" << EOF
#!/bin/bash
cd "$INSTALL_DIR/python"
python3 -m cube.cli "\$@"
EOF
chmod +x "$BIN_DIR/cube-py"
# Try to install dependencies
print_info "Installing Python dependencies..."
if python3 -m pip install -r "$INSTALL_DIR/python/requirements.txt" --quiet 2>/dev/null; then
print_success "Python dependencies installed"
else
print_warning "Could not install Python dependencies automatically"
echo "Install manually: pip install -r $INSTALL_DIR/python/requirements.txt"
fi
print_success "Python version installed"
else
print_warning "Python directory not found, skipping Python installation"
INSTALL_PYTHON=false
fi
fi
echo ""
fi
# Install SDK bridge (TypeScript) — backs claude-sdk / codex-sdk / cursor-sdk adapters.
# Idempotent. Skipped silently if sdk-bridge/ isn't present (older checkouts)
# or if neither bun nor npm is available.
if [ -f "$INSTALL_DIR/sdk-bridge/package.json" ]; then
print_info "Setting up SDK bridge (claude-sdk / codex-sdk / cursor-sdk adapters)..."
BRIDGE_DIR="$INSTALL_DIR/sdk-bridge"
BRIDGE_INSTALLED=false
if command -v bun >/dev/null 2>&1; then
if (cd "$BRIDGE_DIR" && bun install >/dev/null 2>&1); then
print_success "SDK bridge installed (bun)"
BRIDGE_INSTALLED=true
fi
fi
if [ "$BRIDGE_INSTALLED" = false ] && command -v npm >/dev/null 2>&1; then
if (cd "$BRIDGE_DIR" && npm install --silent >/dev/null 2>&1); then
print_success "SDK bridge installed (npm)"
BRIDGE_INSTALLED=true
fi
fi
if [ "$BRIDGE_INSTALLED" = false ]; then
print_warning "SDK bridge skipped — bun / npm not found or install failed."
echo " Install bun (https://bun.sh) then run: cd $BRIDGE_DIR && bun install"
echo " Legacy CLI adapters (cli: claude / codex / cursor) keep working without this."
fi
echo ""
fi
# Check PATH
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
print_warning "$BIN_DIR is not in your PATH"
echo ""
echo "Add this line to your shell config (~/.zshrc or ~/.bashrc):"
echo -e "${YELLOW}export PATH=\"\$HOME/.local/bin:\$PATH\"${NC}"
echo ""
echo "Then reload your shell:"
echo -e "${YELLOW}source ~/.zshrc${NC} # or source ~/.bashrc"
echo ""
else
print_success "$BIN_DIR is in your PATH"
fi
# Installation complete
echo ""
echo -e "${GREEN}╔════════════════════════════════════════╗${NC}"
echo -e "${GREEN}║ Installation Complete! 🎉 ║${NC}"
echo -e "${GREEN}╚════════════════════════════════════════╝${NC}"
echo ""
echo "Installed versions:"
if [ -L "$BIN_DIR/cube" ]; then
echo -e " ${CYAN}cube${NC} Bash version (primary)"
fi
if [ "$INSTALL_PYTHON" = true ] && [ -f "$BIN_DIR/cube-py" ]; then
echo -e " ${CYAN}cube-py${NC} Python version (alternative)"
fi
echo ""
echo "Get started:"
echo -e " ${CYAN}cube --help${NC} Show all commands (bash)"
if [ "$INSTALL_PYTHON" = true ]; then
echo -e " ${CYAN}cube-py --help${NC} Show all commands (python)"
fi
echo -e " ${CYAN}cube version${NC} Show version"
echo -e " ${CYAN}cube sessions${NC} List active sessions"
echo ""
echo "Documentation:"
echo -e " ${CYAN}cat $INSTALL_DIR/AGENT_CUBE.md${NC}"
if [ "$INSTALL_PYTHON" = true ]; then
echo -e " ${CYAN}cat $INSTALL_DIR/python/README.md${NC}"
fi
echo ""
echo "To uninstall:"
if [ "$INSTALL_PYTHON" = true ]; then
echo -e " ${YELLOW}rm -rf $INSTALL_DIR $BIN_DIR/cube $BIN_DIR/cube-py${NC}"
else
echo -e " ${YELLOW}rm -rf $INSTALL_DIR $BIN_DIR/cube${NC}"
fi
echo ""