-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·398 lines (349 loc) · 13.4 KB
/
install.sh
File metadata and controls
executable file
·398 lines (349 loc) · 13.4 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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
#!/bin/bash
# Accordo Global Installation Script
# This script installs accordo with support for pipx (global) and uv (venv)
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Installation method variable
INSTALL_METHOD=""
# Print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if Python 3.12+ is available
check_python() {
print_status "Checking Python version..."
if ! command -v python3 &> /dev/null; then
print_error "Python 3 is not installed or not in PATH"
exit 1
fi
PYTHON_VERSION=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
REQUIRED_VERSION="3.12"
if python3 -c "import sys; exit(0 if sys.version_info >= (3, 12) else 1)"; then
print_success "Python ${PYTHON_VERSION} detected (>= ${REQUIRED_VERSION})"
else
print_error "Python ${REQUIRED_VERSION}+ is required. Found: ${PYTHON_VERSION}"
print_status "Please upgrade Python and try again."
exit 1
fi
}
# Detect environment and available tools
detect_environment() {
print_status "Detecting environment and available tools..."
# Check if we're in a virtual environment
if [[ -n "$VIRTUAL_ENV" ]]; then
print_status "Virtual environment detected: $VIRTUAL_ENV"
IN_VENV=true
else
print_status "No virtual environment detected"
IN_VENV=false
fi
# Check available tools
HAS_PIPX=false
HAS_UV=false
if command -v pipx &> /dev/null; then
print_status "pipx is available"
HAS_PIPX=true
fi
if command -v uv &> /dev/null; then
print_status "uv is available"
HAS_UV=true
fi
}
# Let user choose installation method
choose_installation_method() {
# Check if INSTALL_METHOD is already set via environment variable
if [[ -n "$INSTALL_METHOD" ]]; then
print_success "Using preset installation method: $INSTALL_METHOD"
return 0
fi
echo
print_status "Choose installation method:"
echo
local options=()
local choice_num=1
# Option 1: Always offer global installation first (pipx)
echo "${choice_num}. 🌍 Global installation (pipx) - Recommended"
echo " Installs accordo globally, accessible from anywhere"
if [[ "$HAS_PIPX" == true ]]; then
echo " ✅ pipx is available"
else
echo " ⚠️ pipx will be installed automatically"
fi
options[$choice_num]="global"
((choice_num++))
# Option 2: Virtual environment installation (if in venv and uv available)
if [[ "$IN_VENV" == true && "$HAS_UV" == true ]]; then
echo "${choice_num}. 📦 Virtual environment installation (uv)"
echo " Installs in current virtual environment: $(basename $VIRTUAL_ENV)"
echo " ✅ uv is available"
options[$choice_num]="venv_uv"
((choice_num++))
fi
# Option 3: Virtual environment with pip (if in venv)
if [[ "$IN_VENV" == true ]]; then
echo "${choice_num}. 📦 Virtual environment installation (pip)"
echo " Installs in current virtual environment using pip"
options[$choice_num]="venv_pip"
((choice_num++))
fi
echo
# Get user choice
local max_choice=$((choice_num - 1))
while true; do
read -p "Enter your choice (1-${max_choice}) [default: 1]: " choice </dev/tty
# Default to 1 if empty
if [[ -z "$choice" ]]; then
choice=1
fi
if [[ "$choice" =~ ^[0-9]+$ ]] && [[ "$choice" -ge 1 ]] && [[ "$choice" -le "$max_choice" ]]; then
INSTALL_METHOD="${options[$choice]}"
break
else
print_error "Invalid choice. Please enter a number between 1 and ${max_choice}."
fi
done
print_success "Selected installation method: $INSTALL_METHOD"
}
# Check if pipx is available and install if needed
ensure_pipx() {
if command -v pipx &> /dev/null; then
print_success "pipx is available"
return 0
fi
print_warning "pipx not found. Installing pipx..."
# Try to install pipx using different methods
if command -v apt &> /dev/null; then
# Ubuntu/Debian
print_status "Installing pipx using apt..."
if command -v sudo &> /dev/null; then
sudo apt update && sudo apt install -y pipx
else
print_error "sudo not available. Please install pipx manually:"
echo " sudo apt install pipx"
exit 1
fi
elif command -v brew &> /dev/null; then
# macOS with Homebrew
print_status "Installing pipx using Homebrew..."
brew install pipx
elif command -v pip3 &> /dev/null; then
# Fallback to pip3 --user
print_status "Installing pipx using pip3..."
pip3 install --user pipx
# Add to PATH if needed
local user_bin="$HOME/.local/bin"
if [[ -d "$user_bin" ]] && [[ ":$PATH:" != *":$user_bin:"* ]]; then
export PATH="$user_bin:$PATH"
fi
else
print_error "Could not install pipx automatically."
print_status "Please install pipx manually and run this script again:"
echo " # Ubuntu/Debian:"
echo " sudo apt install pipx"
echo " # macOS:"
echo " brew install pipx"
echo " # Other systems:"
echo " pip3 install --user pipx"
exit 1
fi
# Verify pipx installation
if command -v pipx &> /dev/null; then
print_success "pipx installed successfully"
# Ensure pipx path is set up
print_status "Ensuring pipx path is configured..."
pipx ensurepath --force
else
print_error "pipx installation failed"
exit 1
fi
}
# Install accordo
install_workflow_commander() {
# Smart installation source detection:
# - For development: If running from accordo project directory, install from local source
# - For end users: Install from PyPI package (default behavior)
# This allows the same script to work for both development and public installation
local install_source="accordo-workflow-mcp"
if [[ -f "pyproject.toml" ]] && grep -q '"accordo-workflow-mcp"' pyproject.toml; then
# We're in the accordo project directory, install from local source for development
install_source="."
print_status "Detected accordo project directory - installing from local source"
else
# Standard end-user installation from PyPI - works from any directory
print_status "Installing accordo from PyPI"
fi
case "$INSTALL_METHOD" in
"global")
print_status "Installing accordo globally using pipx..."
ensure_pipx
if pipx install --force "$install_source"; then
print_success "accordo installed globally with pipx"
else
print_error "Failed to install accordo with pipx"
if [[ "$install_source" == "accordo-workflow-mcp" ]]; then
print_status "This may be because the package is not yet available on PyPI."
print_status "Please check if the package name is correct or try installing from source."
fi
exit 1
fi
;;
"venv_uv")
print_status "Installing accordo in virtual environment using uv..."
if ! command -v uv &> /dev/null; then
print_error "uv not available"
exit 1
fi
if uv pip install --force-reinstall "$install_source"; then
print_success "accordo installed in virtual environment with uv"
else
print_error "Failed to install accordo with uv"
if [[ "$install_source" == "accordo-workflow-mcp" ]]; then
print_status "This may be because the package is not yet available on PyPI."
print_status "Please check if the package name is correct or try installing from source."
fi
exit 1
fi
;;
"venv_pip")
print_status "Installing accordo in virtual environment using pip..."
if pip install --force-reinstall "$install_source"; then
print_success "accordo installed in virtual environment with pip"
else
print_error "Failed to install accordo with pip"
if [[ "$install_source" == "accordo-workflow-mcp" ]]; then
print_status "This may be because the package is not yet available on PyPI."
print_status "Please check if the package name is correct or try installing from source."
fi
exit 1
fi
;;
*)
print_error "Unknown installation method: $INSTALL_METHOD"
exit 1
;;
esac
}
# Verify installation
verify_installation() {
print_status "Verifying installation..."
# For global installation, ensure PATH is set up
if [[ "$INSTALL_METHOD" == "global" ]]; then
# Refresh PATH for pipx binaries
if [[ -d "$HOME/.local/bin" ]] && [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
export PATH="$HOME/.local/bin:$PATH"
fi
fi
if command -v accordo &> /dev/null; then
VERSION=$(accordo --version 2>/dev/null || echo "Unknown")
print_success "accordo is accessible: $VERSION"
return 0
else
print_warning "accordo not found in PATH"
if [[ "$INSTALL_METHOD" == "global" ]]; then
print_status "Trying to refresh PATH..."
# Try to source common shell configs
for config in ~/.bashrc ~/.zshrc ~/.profile; do
if [[ -f "$config" ]]; then
source "$config" 2>/dev/null || true
fi
done
# Check again
if command -v accordo &> /dev/null; then
VERSION=$(accordo --version 2>/dev/null || echo "Unknown")
print_success "accordo is now accessible: $VERSION"
else
print_warning "accordo still not in PATH"
print_status "You may need to restart your terminal or run:"
echo " source ~/.bashrc # or ~/.zshrc"
print_status "Or manually add pipx bin directory to PATH:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
fi
else
print_status "Make sure your virtual environment is activated:"
echo " source $VIRTUAL_ENV/bin/activate"
fi
fi
}
# Display usage examples
show_usage_examples() {
print_success "Installation complete! Here are some usage examples:"
echo
echo "📋 List supported platforms:"
echo " accordo list-platforms"
echo
echo "🔧 Interactive configuration:"
echo " accordo configure"
echo
echo "⚡ Quick non-interactive setup:"
echo " accordo configure -p cursor -s accordo -y"
echo " accordo configure -p claude-code -s accordo -y"
echo
echo "🚀 Deploy workflow guidelines to AI assistants:"
echo " accordo bootstrap-rules # Deploy to all assistants"
echo " accordo bootstrap-rules cursor # Deploy to Cursor only"
echo " accordo bootstrap-rules --force all # Overwrite existing content"
echo
echo "📊 List configured servers:"
echo " accordo list-servers -p cursor"
echo
echo "✅ Validate configuration:"
echo " accordo validate -p cursor"
echo
echo "🗑️ Remove a server:"
echo " accordo remove-server accordo -p cursor"
echo
echo "❓ Get help:"
echo " accordo --help"
echo
if [[ "$INSTALL_METHOD" == "global" ]]; then
echo "🔧 Manage with pipx:"
echo " pipx list # List installed packages"
echo " pipx upgrade accordo # Upgrade to latest version"
echo " pipx uninstall accordo # Uninstall completely"
else
echo "🔧 Manage in virtual environment:"
echo " pip list | grep accordo # Check installation"
if [[ "$INSTALL_METHOD" == "venv_uv" ]]; then
echo " uv pip install --upgrade accordo # Upgrade"
echo " uv pip uninstall accordo # Uninstall"
else
echo " pip install --upgrade accordo # Upgrade"
echo " pip uninstall accordo # Uninstall"
fi
fi
echo
}
# Main installation flow
main() {
echo "🚀 accordo Installation Script"
echo "=========================================="
echo
check_python
detect_environment
choose_installation_method
install_workflow_commander
verify_installation
show_usage_examples
print_success "Ready to configure accordo MCP server for your AI coding platforms!"
if [[ "$INSTALL_METHOD" == "global" ]]; then
print_status "Note: If accordo is not immediately available, restart your terminal."
else
print_status "Note: accordo is installed in your virtual environment."
fi
}
# Run main function
main "$@"