mageagent-local 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/QUICK_START.md +255 -0
- package/README.md +453 -0
- package/bin/install-launchagent.js +135 -0
- package/bin/mageagent.js +255 -0
- package/bin/postinstall.js +43 -0
- package/config/com.adverant.mageagent.plist +38 -0
- package/config/config.example.json +41 -0
- package/docs/AUTOSTART.md +300 -0
- package/docs/MENUBAR_APP.md +238 -0
- package/docs/PATTERNS.md +501 -0
- package/docs/TROUBLESHOOTING.md +364 -0
- package/docs/VSCODE_SETUP.md +230 -0
- package/docs/assets/mageagent-logo.png +0 -0
- package/docs/assets/mageagent-logo.svg +57 -0
- package/docs/assets/menubar-screenshot.png +0 -0
- package/docs/diagrams/architecture.md +229 -0
- package/mageagent/__init__.py +4 -0
- package/mageagent/server.py +951 -0
- package/mageagent/tool_executor.py +453 -0
- package/menubar-app/MageAgentMenuBar/AppDelegate.swift +1337 -0
- package/menubar-app/MageAgentMenuBar/Info.plist +38 -0
- package/menubar-app/MageAgentMenuBar/main.swift +16 -0
- package/menubar-app/Package.swift +18 -0
- package/menubar-app/build/MageAgentMenuBar.app/Contents/Info.plist +38 -0
- package/menubar-app/build/MageAgentMenuBar.app/Contents/MacOS/MageAgentMenuBar +0 -0
- package/menubar-app/build/MageAgentMenuBar.app/Contents/PkgInfo +1 -0
- package/menubar-app/build/MageAgentMenuBar.app/Contents/Resources/icon.png +0 -0
- package/menubar-app/build.sh +96 -0
- package/package.json +81 -0
- package/scripts/build-dmg.sh +196 -0
- package/scripts/install.sh +641 -0
- package/scripts/mageagent-server.sh +218 -0
|
@@ -0,0 +1,641 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Nexus Local MageAgent - Complete Installation Script
|
|
4
|
+
# Installs and configures MageAgent multi-model orchestration for MLX
|
|
5
|
+
# Includes: Server, Menu Bar App, Claude Code Hooks, Slash Commands, VSCode Integration
|
|
6
|
+
|
|
7
|
+
set -e # Exit on error
|
|
8
|
+
|
|
9
|
+
echo "==============================================================="
|
|
10
|
+
echo " Nexus Local MageAgent - Complete Installation"
|
|
11
|
+
echo " Multi-Model AI Orchestration for Apple Silicon"
|
|
12
|
+
echo " Version 2.0.0"
|
|
13
|
+
echo "==============================================================="
|
|
14
|
+
echo ""
|
|
15
|
+
|
|
16
|
+
# Color codes
|
|
17
|
+
RED='\033[0;31m'
|
|
18
|
+
GREEN='\033[0;32m'
|
|
19
|
+
YELLOW='\033[1;33m'
|
|
20
|
+
BLUE='\033[0;34m'
|
|
21
|
+
CYAN='\033[0;36m'
|
|
22
|
+
NC='\033[0m' # No Color
|
|
23
|
+
|
|
24
|
+
# Parse arguments
|
|
25
|
+
SKIP_MODELS=false
|
|
26
|
+
SKIP_MENUBAR=false
|
|
27
|
+
SKIP_AUTOSTART=false
|
|
28
|
+
SKIP_CLAUDE_CODE=false
|
|
29
|
+
SKIP_VSCODE=false
|
|
30
|
+
|
|
31
|
+
for arg in "$@"; do
|
|
32
|
+
case $arg in
|
|
33
|
+
--skip-models) SKIP_MODELS=true ;;
|
|
34
|
+
--skip-menubar) SKIP_MENUBAR=true ;;
|
|
35
|
+
--skip-autostart) SKIP_AUTOSTART=true ;;
|
|
36
|
+
--skip-claude-code) SKIP_CLAUDE_CODE=true ;;
|
|
37
|
+
--skip-vscode) SKIP_VSCODE=true ;;
|
|
38
|
+
--minimal) SKIP_MODELS=true; SKIP_AUTOSTART=true ;;
|
|
39
|
+
--server-only) SKIP_MENUBAR=true; SKIP_AUTOSTART=true; SKIP_CLAUDE_CODE=true; SKIP_VSCODE=true ;;
|
|
40
|
+
--help)
|
|
41
|
+
echo "Usage: ./scripts/install.sh [options]"
|
|
42
|
+
echo ""
|
|
43
|
+
echo "Options:"
|
|
44
|
+
echo " --skip-models Skip MLX model download (~109GB)"
|
|
45
|
+
echo " --skip-menubar Skip menu bar app installation"
|
|
46
|
+
echo " --skip-autostart Skip LaunchAgent configuration"
|
|
47
|
+
echo " --skip-claude-code Skip Claude Code hooks/commands"
|
|
48
|
+
echo " --skip-vscode Skip VSCode integration"
|
|
49
|
+
echo " --minimal Skip models and autostart"
|
|
50
|
+
echo " --server-only Install server components only"
|
|
51
|
+
echo " --help Show this help"
|
|
52
|
+
exit 0
|
|
53
|
+
;;
|
|
54
|
+
esac
|
|
55
|
+
done
|
|
56
|
+
|
|
57
|
+
# Check if running on macOS
|
|
58
|
+
if [[ "$OSTYPE" != "darwin"* ]]; then
|
|
59
|
+
echo -e "${RED}Error: This script requires macOS with Apple Silicon${NC}"
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Check for Apple Silicon
|
|
64
|
+
if [[ $(uname -m) != "arm64" ]]; then
|
|
65
|
+
echo -e "${RED}Error: Apple Silicon (M1/M2/M3/M4) required${NC}"
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
# Check memory
|
|
70
|
+
TOTAL_MEM=$(sysctl -n hw.memsize)
|
|
71
|
+
TOTAL_GB=$((TOTAL_MEM / 1024 / 1024 / 1024))
|
|
72
|
+
if [ $TOTAL_GB -lt 64 ]; then
|
|
73
|
+
echo -e "${YELLOW}Warning: 128GB+ unified memory recommended for full MageAgent${NC}"
|
|
74
|
+
echo -e " Your system has ${TOTAL_GB}GB. Some patterns may not work.${NC}"
|
|
75
|
+
echo ""
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
echo "Checking Prerequisites..."
|
|
79
|
+
echo ""
|
|
80
|
+
|
|
81
|
+
# Check Python
|
|
82
|
+
if ! command -v python3 &> /dev/null; then
|
|
83
|
+
echo -e "${RED}Error: Python 3 is not installed${NC}"
|
|
84
|
+
echo " Install from: https://www.python.org/ or brew install python"
|
|
85
|
+
exit 1
|
|
86
|
+
fi
|
|
87
|
+
echo -e "${GREEN}✓${NC} Python $(python3 --version | cut -d' ' -f2)"
|
|
88
|
+
|
|
89
|
+
# Check pip
|
|
90
|
+
if ! command -v pip3 &> /dev/null; then
|
|
91
|
+
echo -e "${RED}Error: pip3 is not installed${NC}"
|
|
92
|
+
exit 1
|
|
93
|
+
fi
|
|
94
|
+
echo -e "${GREEN}✓${NC} pip3 installed"
|
|
95
|
+
|
|
96
|
+
# Check Node.js (optional but recommended)
|
|
97
|
+
if command -v node &> /dev/null; then
|
|
98
|
+
echo -e "${GREEN}✓${NC} Node.js $(node --version)"
|
|
99
|
+
else
|
|
100
|
+
echo -e "${YELLOW}!${NC} Node.js not found (optional, needed for npm commands)"
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
# Check Xcode Command Line Tools (needed for Swift compilation)
|
|
104
|
+
if xcode-select -p &> /dev/null; then
|
|
105
|
+
echo -e "${GREEN}✓${NC} Xcode Command Line Tools"
|
|
106
|
+
else
|
|
107
|
+
echo -e "${YELLOW}!${NC} Xcode Command Line Tools not found"
|
|
108
|
+
echo " Install with: xcode-select --install"
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
echo ""
|
|
112
|
+
echo "==============================================================="
|
|
113
|
+
echo -e " ${CYAN}Step 1/7:${NC} Installing Python Dependencies"
|
|
114
|
+
echo "==============================================================="
|
|
115
|
+
echo ""
|
|
116
|
+
|
|
117
|
+
# Get script directory
|
|
118
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
119
|
+
|
|
120
|
+
# Install MLX and dependencies
|
|
121
|
+
pip3 install --quiet mlx mlx-lm
|
|
122
|
+
echo -e "${GREEN}✓${NC} MLX framework installed"
|
|
123
|
+
|
|
124
|
+
pip3 install --quiet fastapi uvicorn pydantic
|
|
125
|
+
echo -e "${GREEN}✓${NC} FastAPI server dependencies installed"
|
|
126
|
+
|
|
127
|
+
pip3 install --quiet huggingface_hub
|
|
128
|
+
echo -e "${GREEN}✓${NC} Hugging Face Hub installed"
|
|
129
|
+
|
|
130
|
+
# Install from requirements.txt if exists
|
|
131
|
+
if [ -f "$SCRIPT_DIR/requirements.txt" ]; then
|
|
132
|
+
pip3 install --quiet -r "$SCRIPT_DIR/requirements.txt"
|
|
133
|
+
echo -e "${GREEN}✓${NC} Additional dependencies installed"
|
|
134
|
+
fi
|
|
135
|
+
|
|
136
|
+
echo ""
|
|
137
|
+
echo "==============================================================="
|
|
138
|
+
echo -e " ${CYAN}Step 2/7:${NC} Setting Up Directory Structure"
|
|
139
|
+
echo "==============================================================="
|
|
140
|
+
echo ""
|
|
141
|
+
|
|
142
|
+
# Create all required directories
|
|
143
|
+
mkdir -p ~/.claude/mageagent
|
|
144
|
+
mkdir -p ~/.claude/scripts
|
|
145
|
+
mkdir -p ~/.claude/debug
|
|
146
|
+
mkdir -p ~/.claude/hooks
|
|
147
|
+
mkdir -p ~/.claude/commands
|
|
148
|
+
mkdir -p ~/.claude/mageagent-menubar/icons
|
|
149
|
+
mkdir -p ~/.cache/mlx-models
|
|
150
|
+
mkdir -p ~/Library/LaunchAgents
|
|
151
|
+
|
|
152
|
+
echo -e "${GREEN}✓${NC} Directory structure created"
|
|
153
|
+
|
|
154
|
+
echo ""
|
|
155
|
+
echo "==============================================================="
|
|
156
|
+
echo -e " ${CYAN}Step 3/7:${NC} Installing Server Components"
|
|
157
|
+
echo "==============================================================="
|
|
158
|
+
echo ""
|
|
159
|
+
|
|
160
|
+
# Copy server files
|
|
161
|
+
cp "$SCRIPT_DIR/mageagent/server.py" ~/.claude/mageagent/
|
|
162
|
+
echo -e "${GREEN}✓${NC} MageAgent server installed"
|
|
163
|
+
|
|
164
|
+
cp "$SCRIPT_DIR/scripts/mageagent-server.sh" ~/.claude/scripts/
|
|
165
|
+
chmod +x ~/.claude/scripts/mageagent-server.sh
|
|
166
|
+
echo -e "${GREEN}✓${NC} Server management script installed"
|
|
167
|
+
|
|
168
|
+
# Create symlink for global access
|
|
169
|
+
if [ -w /usr/local/bin ]; then
|
|
170
|
+
ln -sf ~/.claude/scripts/mageagent-server.sh /usr/local/bin/mageagent 2>/dev/null || true
|
|
171
|
+
echo -e "${GREEN}✓${NC} Global 'mageagent' command available"
|
|
172
|
+
elif [ -d ~/bin ]; then
|
|
173
|
+
ln -sf ~/.claude/scripts/mageagent-server.sh ~/bin/mageagent 2>/dev/null || true
|
|
174
|
+
echo -e "${GREEN}✓${NC} User 'mageagent' command available in ~/bin"
|
|
175
|
+
fi
|
|
176
|
+
|
|
177
|
+
echo ""
|
|
178
|
+
echo "==============================================================="
|
|
179
|
+
echo -e " ${CYAN}Step 4/7:${NC} Installing Menu Bar App"
|
|
180
|
+
echo "==============================================================="
|
|
181
|
+
echo ""
|
|
182
|
+
|
|
183
|
+
if [ "$SKIP_MENUBAR" = true ]; then
|
|
184
|
+
echo -e "${YELLOW}⚠${NC} Skipping menu bar app (--skip-menubar)"
|
|
185
|
+
else
|
|
186
|
+
if [ -d "$SCRIPT_DIR/menubar-app" ]; then
|
|
187
|
+
cd "$SCRIPT_DIR/menubar-app"
|
|
188
|
+
if [ -f "build.sh" ]; then
|
|
189
|
+
echo "Building MageAgentMenuBar.app..."
|
|
190
|
+
bash build.sh
|
|
191
|
+
echo -e "${GREEN}✓${NC} Menu bar app installed to /Applications"
|
|
192
|
+
fi
|
|
193
|
+
cd "$SCRIPT_DIR"
|
|
194
|
+
else
|
|
195
|
+
echo -e "${YELLOW}⚠${NC} Menu bar app source not found"
|
|
196
|
+
fi
|
|
197
|
+
fi
|
|
198
|
+
|
|
199
|
+
echo ""
|
|
200
|
+
echo "==============================================================="
|
|
201
|
+
echo -e " ${CYAN}Step 5/7:${NC} Claude Code Integration"
|
|
202
|
+
echo "==============================================================="
|
|
203
|
+
echo ""
|
|
204
|
+
|
|
205
|
+
if [ "$SKIP_CLAUDE_CODE" = true ]; then
|
|
206
|
+
echo -e "${YELLOW}⚠${NC} Skipping Claude Code integration (--skip-claude-code)"
|
|
207
|
+
else
|
|
208
|
+
# Install hooks
|
|
209
|
+
echo "Installing Claude Code hooks..."
|
|
210
|
+
|
|
211
|
+
# Pre-tool hook for MageAgent routing
|
|
212
|
+
cat > ~/.claude/hooks/mageagent-pretool.sh << 'HOOKEOF'
|
|
213
|
+
#!/bin/bash
|
|
214
|
+
# MageAgent Pre-Tool Hook
|
|
215
|
+
# Automatically routes to MageAgent for certain tool calls
|
|
216
|
+
|
|
217
|
+
TOOL_NAME="$1"
|
|
218
|
+
TOOL_INPUT="$2"
|
|
219
|
+
|
|
220
|
+
# Log tool calls if debug enabled
|
|
221
|
+
if [ "$MAGEAGENT_DEBUG" = "1" ]; then
|
|
222
|
+
echo "[$(date)] Tool: $TOOL_NAME" >> ~/.claude/debug/hook.log
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
# Allow all tools by default
|
|
226
|
+
exit 0
|
|
227
|
+
HOOKEOF
|
|
228
|
+
chmod +x ~/.claude/hooks/mageagent-pretool.sh
|
|
229
|
+
echo -e "${GREEN}✓${NC} Pre-tool hook installed"
|
|
230
|
+
|
|
231
|
+
# Post-response hook for logging
|
|
232
|
+
cat > ~/.claude/hooks/mageagent-postresponse.sh << 'HOOKEOF'
|
|
233
|
+
#!/bin/bash
|
|
234
|
+
# MageAgent Post-Response Hook
|
|
235
|
+
# Logs responses for debugging
|
|
236
|
+
|
|
237
|
+
RESPONSE="$1"
|
|
238
|
+
|
|
239
|
+
if [ "$MAGEAGENT_DEBUG" = "1" ]; then
|
|
240
|
+
echo "[$(date)] Response length: ${#RESPONSE}" >> ~/.claude/debug/hook.log
|
|
241
|
+
fi
|
|
242
|
+
|
|
243
|
+
exit 0
|
|
244
|
+
HOOKEOF
|
|
245
|
+
chmod +x ~/.claude/hooks/mageagent-postresponse.sh
|
|
246
|
+
echo -e "${GREEN}✓${NC} Post-response hook installed"
|
|
247
|
+
|
|
248
|
+
# Install slash commands
|
|
249
|
+
echo "Installing Claude Code slash commands..."
|
|
250
|
+
|
|
251
|
+
# /mageagent command
|
|
252
|
+
cat > ~/.claude/commands/mageagent.md << 'CMDEOF'
|
|
253
|
+
# /mageagent - MageAgent Server Control
|
|
254
|
+
|
|
255
|
+
Control the MageAgent multi-model orchestration server.
|
|
256
|
+
|
|
257
|
+
## Usage
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
/mageagent [command]
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Commands
|
|
264
|
+
|
|
265
|
+
- `status` - Check server status
|
|
266
|
+
- `start` - Start the server
|
|
267
|
+
- `stop` - Stop the server
|
|
268
|
+
- `restart` - Restart the server
|
|
269
|
+
- `test` - Run quick test
|
|
270
|
+
- `logs` - View recent logs
|
|
271
|
+
|
|
272
|
+
## Examples
|
|
273
|
+
|
|
274
|
+
```
|
|
275
|
+
/mageagent status
|
|
276
|
+
/mageagent restart
|
|
277
|
+
/mageagent test
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Implementation
|
|
281
|
+
|
|
282
|
+
When the user runs this command, execute:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
~/.claude/scripts/mageagent-server.sh [command]
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
If no command specified, show status.
|
|
289
|
+
CMDEOF
|
|
290
|
+
echo -e "${GREEN}✓${NC} /mageagent command installed"
|
|
291
|
+
|
|
292
|
+
# /mage command (quick pattern selector)
|
|
293
|
+
cat > ~/.claude/commands/mage.md << 'CMDEOF'
|
|
294
|
+
# /mage - Quick MageAgent Pattern Selection
|
|
295
|
+
|
|
296
|
+
Quickly switch to a MageAgent pattern.
|
|
297
|
+
|
|
298
|
+
## Usage
|
|
299
|
+
|
|
300
|
+
```
|
|
301
|
+
/mage [pattern]
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
## Patterns
|
|
305
|
+
|
|
306
|
+
- `auto` - Intelligent task routing (default)
|
|
307
|
+
- `hybrid` - 72B reasoning + Hermes-3 tools
|
|
308
|
+
- `validated` - Generate + validate + revise
|
|
309
|
+
- `compete` - Multi-model with judge
|
|
310
|
+
- `execute` - ReAct loop with real tool execution
|
|
311
|
+
- `tools` - Fast Hermes-3 tool calling
|
|
312
|
+
- `primary` - Direct 72B access
|
|
313
|
+
- `fast` - Fast 7B validator
|
|
314
|
+
|
|
315
|
+
## Examples
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
/mage hybrid
|
|
319
|
+
/mage execute
|
|
320
|
+
/mage compete
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Implementation
|
|
324
|
+
|
|
325
|
+
When user runs `/mage [pattern]`, switch the model:
|
|
326
|
+
|
|
327
|
+
```
|
|
328
|
+
/model mageagent,mageagent:[pattern]
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
If no pattern specified, use `auto`.
|
|
332
|
+
CMDEOF
|
|
333
|
+
echo -e "${GREEN}✓${NC} /mage command installed"
|
|
334
|
+
|
|
335
|
+
# /warmup command
|
|
336
|
+
cat > ~/.claude/commands/warmup.md << 'CMDEOF'
|
|
337
|
+
# /warmup - Preload MageAgent Models
|
|
338
|
+
|
|
339
|
+
Preload MLX models into GPU/unified memory for faster inference.
|
|
340
|
+
|
|
341
|
+
## Usage
|
|
342
|
+
|
|
343
|
+
```
|
|
344
|
+
/warmup [model|all]
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## Models
|
|
348
|
+
|
|
349
|
+
- `primary` - Qwen-72B Q8 (77GB)
|
|
350
|
+
- `tools` - Hermes-3 8B Q8 (9GB)
|
|
351
|
+
- `validator` - Qwen-Coder 7B (5GB)
|
|
352
|
+
- `competitor` - Qwen-Coder 32B (18GB)
|
|
353
|
+
- `all` - Load all models
|
|
354
|
+
|
|
355
|
+
## Examples
|
|
356
|
+
|
|
357
|
+
```
|
|
358
|
+
/warmup primary
|
|
359
|
+
/warmup all
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## Implementation
|
|
363
|
+
|
|
364
|
+
Send a minimal request to each model to load it:
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
curl -X POST http://localhost:3457/v1/chat/completions \
|
|
368
|
+
-H "Content-Type: application/json" \
|
|
369
|
+
-d '{"model": "mageagent:[model]", "messages": [{"role": "user", "content": "hi"}], "max_tokens": 1}'
|
|
370
|
+
```
|
|
371
|
+
CMDEOF
|
|
372
|
+
echo -e "${GREEN}✓${NC} /warmup command installed"
|
|
373
|
+
|
|
374
|
+
# Update CLAUDE.md with MageAgent instructions
|
|
375
|
+
if [ -f ~/.claude/CLAUDE.md ]; then
|
|
376
|
+
if ! grep -q "MageAgent" ~/.claude/CLAUDE.md; then
|
|
377
|
+
cat >> ~/.claude/CLAUDE.md << 'CLAUDEMD'
|
|
378
|
+
|
|
379
|
+
## MageAgent Multi-Model Orchestration
|
|
380
|
+
|
|
381
|
+
MageAgent provides intelligent multi-model AI orchestration running locally on Apple Silicon.
|
|
382
|
+
|
|
383
|
+
### Quick Commands
|
|
384
|
+
|
|
385
|
+
- `/mage hybrid` - Switch to hybrid pattern (recommended)
|
|
386
|
+
- `/mage execute` - Switch to execute pattern (real tool execution)
|
|
387
|
+
- `/mageagent status` - Check server status
|
|
388
|
+
- `/warmup all` - Preload all models
|
|
389
|
+
|
|
390
|
+
### Server Management
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
mageagent start # Start server
|
|
394
|
+
mageagent stop # Stop server
|
|
395
|
+
mageagent status # Check status
|
|
396
|
+
mageagent test # Run tests
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### API Endpoint
|
|
400
|
+
|
|
401
|
+
- URL: http://localhost:3457
|
|
402
|
+
- Docs: http://localhost:3457/docs
|
|
403
|
+
|
|
404
|
+
### Available Patterns
|
|
405
|
+
|
|
406
|
+
| Pattern | Models | Use Case |
|
|
407
|
+
|---------|--------|----------|
|
|
408
|
+
| `auto` | Varies | Intelligent routing |
|
|
409
|
+
| `hybrid` | 72B + 8B | Complex reasoning + tools |
|
|
410
|
+
| `execute` | 72B + 8B | Real file/web access |
|
|
411
|
+
| `validated` | 72B + 7B | Code validation |
|
|
412
|
+
| `compete` | 72B + 32B + 7B | Critical code |
|
|
413
|
+
|
|
414
|
+
CLAUDEMD
|
|
415
|
+
echo -e "${GREEN}✓${NC} Updated CLAUDE.md with MageAgent docs"
|
|
416
|
+
fi
|
|
417
|
+
fi
|
|
418
|
+
fi
|
|
419
|
+
|
|
420
|
+
echo ""
|
|
421
|
+
echo "==============================================================="
|
|
422
|
+
echo -e " ${CYAN}Step 6/7:${NC} VSCode Integration"
|
|
423
|
+
echo "==============================================================="
|
|
424
|
+
echo ""
|
|
425
|
+
|
|
426
|
+
if [ "$SKIP_VSCODE" = true ]; then
|
|
427
|
+
echo -e "${YELLOW}⚠${NC} Skipping VSCode integration (--skip-vscode)"
|
|
428
|
+
else
|
|
429
|
+
# Check for VSCode
|
|
430
|
+
VSCODE_DIR=""
|
|
431
|
+
if [ -d "$HOME/Library/Application Support/Code/User" ]; then
|
|
432
|
+
VSCODE_DIR="$HOME/Library/Application Support/Code/User"
|
|
433
|
+
elif [ -d "$HOME/.config/Code/User" ]; then
|
|
434
|
+
VSCODE_DIR="$HOME/.config/Code/User"
|
|
435
|
+
fi
|
|
436
|
+
|
|
437
|
+
if [ -n "$VSCODE_DIR" ]; then
|
|
438
|
+
# Create/update VSCode settings
|
|
439
|
+
SETTINGS_FILE="$VSCODE_DIR/settings.json"
|
|
440
|
+
|
|
441
|
+
if [ -f "$SETTINGS_FILE" ]; then
|
|
442
|
+
# Backup existing settings
|
|
443
|
+
cp "$SETTINGS_FILE" "$SETTINGS_FILE.backup"
|
|
444
|
+
echo -e "${GREEN}✓${NC} Backed up existing VSCode settings"
|
|
445
|
+
fi
|
|
446
|
+
|
|
447
|
+
# Create Claude Code extension settings snippet
|
|
448
|
+
cat > "$VSCODE_DIR/mageagent-settings.json" << 'VSCODEJSON'
|
|
449
|
+
{
|
|
450
|
+
"claude-code.customInstructions": "MageAgent multi-model orchestration is available at http://localhost:3457. Use /mage [pattern] to switch patterns.",
|
|
451
|
+
"claude-code.hooks.preTool": "~/.claude/hooks/mageagent-pretool.sh",
|
|
452
|
+
"claude-code.hooks.postResponse": "~/.claude/hooks/mageagent-postresponse.sh"
|
|
453
|
+
}
|
|
454
|
+
VSCODEJSON
|
|
455
|
+
echo -e "${GREEN}✓${NC} VSCode MageAgent settings created"
|
|
456
|
+
echo " Merge $VSCODE_DIR/mageagent-settings.json into your settings.json"
|
|
457
|
+
else
|
|
458
|
+
echo -e "${YELLOW}⚠${NC} VSCode user directory not found"
|
|
459
|
+
fi
|
|
460
|
+
fi
|
|
461
|
+
|
|
462
|
+
echo ""
|
|
463
|
+
echo "==============================================================="
|
|
464
|
+
echo -e " ${CYAN}Step 7/7:${NC} Auto-Start Configuration"
|
|
465
|
+
echo "==============================================================="
|
|
466
|
+
echo ""
|
|
467
|
+
|
|
468
|
+
if [ "$SKIP_AUTOSTART" = true ]; then
|
|
469
|
+
echo -e "${YELLOW}⚠${NC} Skipping auto-start (--skip-autostart)"
|
|
470
|
+
else
|
|
471
|
+
# Server LaunchAgent
|
|
472
|
+
cat > ~/Library/LaunchAgents/ai.adverant.mageagent.plist << EOF
|
|
473
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
474
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
475
|
+
<plist version="1.0">
|
|
476
|
+
<dict>
|
|
477
|
+
<key>Label</key>
|
|
478
|
+
<string>ai.adverant.mageagent</string>
|
|
479
|
+
<key>ProgramArguments</key>
|
|
480
|
+
<array>
|
|
481
|
+
<string>$HOME/.claude/scripts/mageagent-server.sh</string>
|
|
482
|
+
<string>start</string>
|
|
483
|
+
</array>
|
|
484
|
+
<key>RunAtLoad</key>
|
|
485
|
+
<true/>
|
|
486
|
+
<key>KeepAlive</key>
|
|
487
|
+
<false/>
|
|
488
|
+
<key>StandardOutPath</key>
|
|
489
|
+
<string>$HOME/.claude/debug/mageagent-launchd.log</string>
|
|
490
|
+
<key>StandardErrorPath</key>
|
|
491
|
+
<string>$HOME/.claude/debug/mageagent-launchd.error.log</string>
|
|
492
|
+
<key>EnvironmentVariables</key>
|
|
493
|
+
<dict>
|
|
494
|
+
<key>PATH</key>
|
|
495
|
+
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
|
|
496
|
+
<key>HOME</key>
|
|
497
|
+
<string>$HOME</string>
|
|
498
|
+
</dict>
|
|
499
|
+
</dict>
|
|
500
|
+
</plist>
|
|
501
|
+
EOF
|
|
502
|
+
|
|
503
|
+
# Menu bar LaunchAgent
|
|
504
|
+
if [ -d "/Applications/MageAgentMenuBar.app" ]; then
|
|
505
|
+
cat > ~/Library/LaunchAgents/ai.adverant.mageagent.menubar.plist << EOF
|
|
506
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
507
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
508
|
+
<plist version="1.0">
|
|
509
|
+
<dict>
|
|
510
|
+
<key>Label</key>
|
|
511
|
+
<string>ai.adverant.mageagent.menubar</string>
|
|
512
|
+
<key>ProgramArguments</key>
|
|
513
|
+
<array>
|
|
514
|
+
<string>/Applications/MageAgentMenuBar.app/Contents/MacOS/MageAgentMenuBar</string>
|
|
515
|
+
</array>
|
|
516
|
+
<key>RunAtLoad</key>
|
|
517
|
+
<true/>
|
|
518
|
+
<key>KeepAlive</key>
|
|
519
|
+
<false/>
|
|
520
|
+
<key>StandardOutPath</key>
|
|
521
|
+
<string>$HOME/.claude/debug/mageagent-menubar.log</string>
|
|
522
|
+
<key>StandardErrorPath</key>
|
|
523
|
+
<string>$HOME/.claude/debug/mageagent-menubar.error.log</string>
|
|
524
|
+
</dict>
|
|
525
|
+
</plist>
|
|
526
|
+
EOF
|
|
527
|
+
fi
|
|
528
|
+
|
|
529
|
+
# Load LaunchAgents
|
|
530
|
+
launchctl unload ~/Library/LaunchAgents/ai.adverant.mageagent.plist 2>/dev/null || true
|
|
531
|
+
launchctl load ~/Library/LaunchAgents/ai.adverant.mageagent.plist
|
|
532
|
+
echo -e "${GREEN}✓${NC} Server LaunchAgent installed"
|
|
533
|
+
|
|
534
|
+
if [ -f ~/Library/LaunchAgents/ai.adverant.mageagent.menubar.plist ]; then
|
|
535
|
+
launchctl unload ~/Library/LaunchAgents/ai.adverant.mageagent.menubar.plist 2>/dev/null || true
|
|
536
|
+
launchctl load ~/Library/LaunchAgents/ai.adverant.mageagent.menubar.plist
|
|
537
|
+
echo -e "${GREEN}✓${NC} Menu bar LaunchAgent installed"
|
|
538
|
+
fi
|
|
539
|
+
fi
|
|
540
|
+
|
|
541
|
+
echo ""
|
|
542
|
+
echo "==============================================================="
|
|
543
|
+
echo -e " ${CYAN}Downloading MLX Models${NC}"
|
|
544
|
+
echo "==============================================================="
|
|
545
|
+
echo ""
|
|
546
|
+
|
|
547
|
+
if [ "$SKIP_MODELS" = true ]; then
|
|
548
|
+
echo -e "${YELLOW}⚠${NC} Skipping model download (--skip-models)"
|
|
549
|
+
echo " Models will be downloaded on first use"
|
|
550
|
+
else
|
|
551
|
+
echo "MageAgent requires the following models (~109GB total):"
|
|
552
|
+
echo ""
|
|
553
|
+
echo -e " ${BLUE}Hermes-3-Llama-3.1-8B-8bit${NC} (9GB) - Tool calling"
|
|
554
|
+
echo -e " ${BLUE}Qwen2.5-72B-Instruct-8bit${NC} (77GB) - Primary reasoning"
|
|
555
|
+
echo -e " ${BLUE}Qwen2.5-Coder-32B-Instruct-4bit${NC} (18GB) - Code generation"
|
|
556
|
+
echo -e " ${BLUE}Qwen2.5-Coder-7B-Instruct-4bit${NC} (5GB) - Fast validation"
|
|
557
|
+
echo ""
|
|
558
|
+
|
|
559
|
+
read -p "Download models now? This will take 30-60 minutes. (y/n) " -n 1 -r
|
|
560
|
+
echo
|
|
561
|
+
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
562
|
+
echo ""
|
|
563
|
+
echo "Downloading models from Hugging Face..."
|
|
564
|
+
python3 << 'PYTHON'
|
|
565
|
+
from huggingface_hub import snapshot_download
|
|
566
|
+
import os
|
|
567
|
+
|
|
568
|
+
models_dir = os.path.expanduser("~/.cache/mlx-models")
|
|
569
|
+
|
|
570
|
+
models = [
|
|
571
|
+
('mlx-community/Hermes-3-Llama-3.1-8B-8bit', 'Hermes-3 8B (9GB)'),
|
|
572
|
+
('mlx-community/Qwen2.5-Coder-7B-Instruct-4bit', 'Qwen-Coder 7B (5GB)'),
|
|
573
|
+
('mlx-community/Qwen2.5-Coder-32B-Instruct-4bit', 'Qwen-Coder 32B (18GB)'),
|
|
574
|
+
('mlx-community/Qwen2.5-72B-Instruct-8bit', 'Qwen 72B (77GB)'),
|
|
575
|
+
]
|
|
576
|
+
|
|
577
|
+
for i, (repo, name) in enumerate(models, 1):
|
|
578
|
+
print(f"{i}/{len(models)} Downloading {name}...")
|
|
579
|
+
local_name = repo.split('/')[-1]
|
|
580
|
+
snapshot_download(repo, local_dir=f'{models_dir}/{local_name}')
|
|
581
|
+
print(f" ✓ {name} complete")
|
|
582
|
+
|
|
583
|
+
print("\nAll models downloaded!")
|
|
584
|
+
PYTHON
|
|
585
|
+
echo -e "${GREEN}✓${NC} All models downloaded"
|
|
586
|
+
else
|
|
587
|
+
echo "Skipping model download"
|
|
588
|
+
fi
|
|
589
|
+
fi
|
|
590
|
+
|
|
591
|
+
echo ""
|
|
592
|
+
echo "==============================================================="
|
|
593
|
+
echo -e " ${CYAN}Starting MageAgent${NC}"
|
|
594
|
+
echo "==============================================================="
|
|
595
|
+
echo ""
|
|
596
|
+
|
|
597
|
+
~/.claude/scripts/mageagent-server.sh start 2>/dev/null || true
|
|
598
|
+
|
|
599
|
+
sleep 3
|
|
600
|
+
|
|
601
|
+
# Verify installation
|
|
602
|
+
if curl -s http://localhost:3457/health > /dev/null 2>&1; then
|
|
603
|
+
echo -e "${GREEN}✓${NC} MageAgent server is running!"
|
|
604
|
+
else
|
|
605
|
+
echo -e "${YELLOW}!${NC} Server may still be starting..."
|
|
606
|
+
echo " Check with: curl http://localhost:3457/health"
|
|
607
|
+
fi
|
|
608
|
+
|
|
609
|
+
# Open menu bar app if installed
|
|
610
|
+
if [ -d "/Applications/MageAgentMenuBar.app" ] && [ "$SKIP_MENUBAR" != true ]; then
|
|
611
|
+
open /Applications/MageAgentMenuBar.app
|
|
612
|
+
echo -e "${GREEN}✓${NC} Menu bar app launched"
|
|
613
|
+
fi
|
|
614
|
+
|
|
615
|
+
echo ""
|
|
616
|
+
echo "==============================================================="
|
|
617
|
+
echo -e " ${GREEN}Installation Complete!${NC}"
|
|
618
|
+
echo "==============================================================="
|
|
619
|
+
echo ""
|
|
620
|
+
echo "MageAgent is now running at: ${GREEN}http://localhost:3457${NC}"
|
|
621
|
+
echo ""
|
|
622
|
+
echo -e "${BLUE}Quick Start:${NC}"
|
|
623
|
+
echo " • Menu bar: Look for the Adverant icon in your menu bar"
|
|
624
|
+
echo " • Terminal: mageagent status / start / stop"
|
|
625
|
+
echo " • Claude Code: /mage hybrid"
|
|
626
|
+
echo " • API Docs: http://localhost:3457/docs"
|
|
627
|
+
echo ""
|
|
628
|
+
echo -e "${BLUE}Available Patterns:${NC}"
|
|
629
|
+
echo " • mageagent:hybrid - Reasoning + tools (recommended)"
|
|
630
|
+
echo " • mageagent:execute - Real tool execution"
|
|
631
|
+
echo " • mageagent:validated - Generate + validate"
|
|
632
|
+
echo " • mageagent:compete - Multi-model judge"
|
|
633
|
+
echo " • mageagent:auto - Intelligent routing"
|
|
634
|
+
echo ""
|
|
635
|
+
echo -e "${BLUE}Test the Server:${NC}"
|
|
636
|
+
echo " curl http://localhost:3457/health"
|
|
637
|
+
echo ""
|
|
638
|
+
echo -e "${BLUE}Documentation:${NC}"
|
|
639
|
+
echo " https://github.com/adverant/nexus-local-mageagent"
|
|
640
|
+
echo ""
|
|
641
|
+
echo "==============================================================="
|