feat: Major directory reorganization and cleanup
Reorganized project structure for better maintainability and reduced disk usage by 95.9% (11 GB -> 451 MB). Directory Reorganization (85% reduction in root files): - Created docs/ with subdirectories (deployment, testing, database, etc.) - Created infrastructure/vpn-configs/ for VPN scripts - Moved 90+ files from root to organized locations - Archived obsolete documentation (context system, offline mode, zombie debugging) - Moved all test files to tests/ directory - Root directory: 119 files -> 18 files Disk Cleanup (10.55 GB recovered): - Deleted Rust build artifacts: 9.6 GB (target/ directories) - Deleted Python virtual environments: 161 MB (venv/ directories) - Deleted Python cache: 50 KB (__pycache__/) New Structure: - docs/ - All documentation organized by category - docs/archives/ - Obsolete but preserved documentation - infrastructure/ - VPN configs and SSH setup - tests/ - All test files consolidated - logs/ - Ready for future logs Benefits: - Cleaner root directory (18 vs 119 files) - Logical organization of documentation - 95.9% disk space reduction - Faster navigation and discovery - Better portability (build artifacts excluded) Build artifacts can be regenerated: - Rust: cargo build --release (5-15 min per project) - Python: pip install -r requirements.txt (2-3 min) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,59 @@
|
||||
|
||||
---
|
||||
|
||||
## Core Operating Principle: You Are a Coordinator
|
||||
|
||||
**CRITICAL:** Main Claude is a **coordinator**, not an executor. Your primary role is to delegate work to specialized agents and preserve your main context space.
|
||||
|
||||
**Main Context Space is Sacred:**
|
||||
- Your context window is valuable and limited
|
||||
- Delegate ALL significant operations to agents unless doing it yourself is significantly cheaper in tokens
|
||||
- Agents have their own full context windows for specialized tasks
|
||||
- Keep your context focused on coordination, decision-making, and user interaction
|
||||
|
||||
**When to Delegate (via Task tool):**
|
||||
- Database operations (queries, inserts, updates) → Database Agent
|
||||
- Code generation → Coding Agent
|
||||
- Code review → Code Review Agent (MANDATORY for all code)
|
||||
- Test execution → Testing Agent
|
||||
- Git operations → Gitea Agent
|
||||
- File exploration/search → Explore Agent
|
||||
- Complex problem-solving → General-purpose agent with Sequential Thinking MCP
|
||||
|
||||
**When to Do It Yourself:**
|
||||
- Simple user responses (conversational replies)
|
||||
- Reading a single file to answer a question
|
||||
- Basic file operations (1-2 files)
|
||||
- Presenting agent results to user
|
||||
- Making decisions about what to do next
|
||||
- Creating task checklists
|
||||
|
||||
**Example - Database Query (DELEGATE):**
|
||||
```
|
||||
User: "How many projects are in the database?"
|
||||
|
||||
❌ WRONG: ssh guru@172.16.3.30 "mysql -u claudetools ... SELECT COUNT(*) ..."
|
||||
✅ CORRECT: Launch Database Agent with task: "Count projects in database"
|
||||
```
|
||||
|
||||
**Example - Simple File Read (DO YOURSELF):**
|
||||
```
|
||||
User: "What's in the README?"
|
||||
|
||||
✅ CORRECT: Use Read tool directly (cheap, preserves context)
|
||||
❌ WRONG: Launch agent just to read one file (wasteful)
|
||||
```
|
||||
|
||||
**Rule of Thumb:**
|
||||
- If the operation will consume >500 tokens of your context → Delegate to agent
|
||||
- If it's a simple read/search/response → Do it yourself
|
||||
- If it's code generation or database work → ALWAYS delegate
|
||||
- When in doubt → Delegate (agents are cheap, your context is precious)
|
||||
|
||||
**See:** `.claude/AGENT_COORDINATION_RULES.md` for complete delegation guidelines
|
||||
|
||||
---
|
||||
|
||||
## Project Structure
|
||||
|
||||
```
|
||||
@@ -321,5 +374,5 @@ alembic upgrade head
|
||||
|
||||
---
|
||||
|
||||
**Last Updated:** 2026-01-18 (Context system removed)
|
||||
**Last Updated:** 2026-01-18 (Context system removed, coordinator role enforced)
|
||||
**Project Progress:** Phase 5 Complete
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
================================================================================
|
||||
DATA MIGRATION - COPY/PASTE COMMANDS
|
||||
================================================================================
|
||||
|
||||
Step 1: Open PuTTY and connect to Jupiter (172.16.3.20)
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Copy and paste this entire block:
|
||||
|
||||
docker exec mariadb mysqldump \
|
||||
-u claudetools \
|
||||
-pCT_e8fcd5a3952030a79ed6debae6c954ed \
|
||||
--no-create-info \
|
||||
--skip-add-drop-table \
|
||||
--insert-ignore \
|
||||
--complete-insert \
|
||||
claudetools | \
|
||||
ssh guru@172.16.3.30 "mysql -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed -D claudetools"
|
||||
|
||||
Press Enter and wait (should complete in 5-10 seconds)
|
||||
|
||||
Expected output: (nothing = success, or some INSERT statements scrolling by)
|
||||
|
||||
|
||||
Step 2: Verify the migration succeeded
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Open another PuTTY window and connect to RMM (172.16.3.30)
|
||||
|
||||
Copy and paste this:
|
||||
|
||||
mysql -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed -D claudetools -e "SELECT TABLE_NAME, TABLE_ROWS FROM information_schema.TABLES WHERE TABLE_SCHEMA='claudetools' AND TABLE_ROWS > 0 ORDER BY TABLE_ROWS DESC;"
|
||||
|
||||
Expected output:
|
||||
TABLE_NAME TABLE_ROWS
|
||||
conversation_contexts 68
|
||||
(possibly other tables with data)
|
||||
|
||||
|
||||
Step 3: Test from Windows
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Open PowerShell or Command Prompt and run:
|
||||
|
||||
curl -s http://172.16.3.30:8001/api/conversation-contexts?limit=3
|
||||
|
||||
Expected: JSON output with 3 conversation contexts
|
||||
|
||||
|
||||
================================================================================
|
||||
TROUBLESHOOTING
|
||||
================================================================================
|
||||
|
||||
If Step 1 asks for a password:
|
||||
- Enter the password for guru@172.16.3.30 when prompted
|
||||
|
||||
If Step 1 says "Permission denied":
|
||||
- RMM and Jupiter need SSH keys configured
|
||||
- Alternative: Do it in 3 steps (export, copy, import) - see below
|
||||
|
||||
If Step 2 shows 0 rows:
|
||||
- Something went wrong with import
|
||||
- Check for error messages from Step 1
|
||||
|
||||
|
||||
================================================================================
|
||||
ALTERNATIVE: 3-STEP METHOD (if single command doesn't work)
|
||||
================================================================================
|
||||
|
||||
On Jupiter (172.16.3.20):
|
||||
------------------------------------------------------------------------
|
||||
docker exec mariadb mysqldump \
|
||||
-u claudetools \
|
||||
-pCT_e8fcd5a3952030a79ed6debae6c954ed \
|
||||
--no-create-info \
|
||||
--skip-add-drop-table \
|
||||
--insert-ignore \
|
||||
--complete-insert \
|
||||
claudetools > /tmp/data_export.sql
|
||||
|
||||
ls -lh /tmp/data_export.sql
|
||||
|
||||
Copy this file to RMM:
|
||||
------------------------------------------------------------------------
|
||||
scp /tmp/data_export.sql guru@172.16.3.30:/tmp/
|
||||
|
||||
On RMM (172.16.3.30):
|
||||
------------------------------------------------------------------------
|
||||
mysql -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed -D claudetools < /tmp/data_export.sql
|
||||
|
||||
Verify:
|
||||
------------------------------------------------------------------------
|
||||
mysql -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed -D claudetools -e "SELECT COUNT(*) as contexts FROM conversation_contexts;"
|
||||
|
||||
Should show: contexts = 68 (or more)
|
||||
|
||||
|
||||
================================================================================
|
||||
QUICK CHECK: Is there data on Jupiter to migrate?
|
||||
================================================================================
|
||||
|
||||
On Jupiter (172.16.3.20):
|
||||
------------------------------------------------------------------------
|
||||
docker exec mariadb mysql -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed -D claudetools -e "SELECT COUNT(*) FROM conversation_contexts;"
|
||||
|
||||
Should show: 68 (from yesterday's import)
|
||||
|
||||
If it shows 0, then there's nothing to migrate!
|
||||
|
||||
|
||||
================================================================================
|
||||
@@ -1,608 +0,0 @@
|
||||
# ClaudeTools Migration to RMM Server
|
||||
|
||||
**Date:** 2026-01-17
|
||||
**Objective:** Centralize ClaudeTools database and API on RMM server (172.16.3.30)
|
||||
**Estimated Time:** 30-45 minutes
|
||||
|
||||
---
|
||||
|
||||
## Current State
|
||||
|
||||
**Database (Jupiter - 172.16.3.20:3306):**
|
||||
- MariaDB in Docker container
|
||||
- Database: `claudetools`
|
||||
- User: `claudetools`
|
||||
- Password: `CT_e8fcd5a3952030a79ed6debae6c954ed`
|
||||
- 43 tables, ~0 rows (newly created)
|
||||
|
||||
**API:**
|
||||
- Running locally on each machine (localhost:8000)
|
||||
- Requires Python, venv, dependencies on each machine
|
||||
- Inconsistent versions across machines
|
||||
|
||||
**Configuration:**
|
||||
- Encryption Key: `C:\Users\MikeSwanson\claude-projects\shared-data\.encryption-key`
|
||||
- JWT Secret: `NdwgH6jsGR1WfPdUwR3u9i1NwNx3QthhLHBsRCfFxcg=`
|
||||
|
||||
---
|
||||
|
||||
## Target State
|
||||
|
||||
**Database (RMM Server - 172.16.3.30:3306):**
|
||||
- MariaDB installed natively on Ubuntu 22.04
|
||||
- Database: `claudetools`
|
||||
- User: `claudetools`
|
||||
- Same password (for simplicity)
|
||||
- Accessible from local network (172.16.3.0/24)
|
||||
|
||||
**API (RMM Server - 172.16.3.30:8001):**
|
||||
- Running as systemd service
|
||||
- URL: `http://172.16.3.30:8001`
|
||||
- External URL (via nginx): `https://claudetools-api.azcomputerguru.com`
|
||||
- Auto-starts on boot
|
||||
- Single deployment point
|
||||
|
||||
**Client Configuration (.claude/context-recall-config.env):**
|
||||
```bash
|
||||
CLAUDE_API_URL=http://172.16.3.30:8001
|
||||
CLAUDE_PROJECT_ID=auto-detected
|
||||
JWT_TOKEN=obtained-from-central-api
|
||||
CONTEXT_RECALL_ENABLED=true
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Migration Steps
|
||||
|
||||
### Phase 1: Database Setup on RMM Server (10 min)
|
||||
|
||||
**1.1 Install MariaDB on RMM Server**
|
||||
```bash
|
||||
ssh guru@172.16.3.30
|
||||
|
||||
# Install MariaDB
|
||||
sudo apt update
|
||||
sudo apt install -y mariadb-server mariadb-client
|
||||
|
||||
# Start and enable service
|
||||
sudo systemctl start mariadb
|
||||
sudo systemctl enable mariadb
|
||||
|
||||
# Secure installation
|
||||
sudo mysql_secure_installation
|
||||
# - Set root password: CT_rmm_root_2026
|
||||
# - Remove anonymous users: Yes
|
||||
# - Disallow root login remotely: Yes
|
||||
# - Remove test database: Yes
|
||||
# - Reload privilege tables: Yes
|
||||
```
|
||||
|
||||
**1.2 Create ClaudeTools Database and User**
|
||||
```bash
|
||||
sudo mysql -u root -p
|
||||
|
||||
CREATE DATABASE claudetools CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
CREATE USER 'claudetools'@'172.16.3.%' IDENTIFIED BY 'CT_e8fcd5a3952030a79ed6debae6c954ed';
|
||||
GRANT ALL PRIVILEGES ON claudetools.* TO 'claudetools'@'172.16.3.%';
|
||||
|
||||
CREATE USER 'claudetools'@'localhost' IDENTIFIED BY 'CT_e8fcd5a3952030a79ed6debae6c954ed';
|
||||
GRANT ALL PRIVILEGES ON claudetools.* TO 'claudetools'@'localhost';
|
||||
|
||||
FLUSH PRIVILEGES;
|
||||
EXIT;
|
||||
```
|
||||
|
||||
**1.3 Configure MariaDB for Network Access**
|
||||
```bash
|
||||
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
|
||||
|
||||
# Change bind-address to allow network connections
|
||||
# FROM: bind-address = 127.0.0.1
|
||||
# TO: bind-address = 0.0.0.0
|
||||
|
||||
sudo systemctl restart mariadb
|
||||
|
||||
# Test connection from Windows
|
||||
# From D:\ClaudeTools:
|
||||
mysql -h 172.16.3.30 -u claudetools -p claudetools
|
||||
# Password: CT_e8fcd5a3952030a79ed6debae6c954ed
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 2: Export Data from Jupiter (5 min)
|
||||
|
||||
**2.1 Export Current Database**
|
||||
```bash
|
||||
# On Jupiter (172.16.3.20)
|
||||
ssh root@172.16.3.20
|
||||
|
||||
# Export database
|
||||
docker exec -it mariadb mysqldump \
|
||||
-u claudetools \
|
||||
-pCT_e8fcd5a3952030a79ed6debae6c954ed \
|
||||
claudetools > /tmp/claudetools_export.sql
|
||||
|
||||
# Check export size
|
||||
ls -lh /tmp/claudetools_export.sql
|
||||
|
||||
# Copy to RMM server
|
||||
scp /tmp/claudetools_export.sql guru@172.16.3.30:/tmp/
|
||||
```
|
||||
|
||||
**2.2 Import to RMM Server**
|
||||
```bash
|
||||
# On RMM server
|
||||
ssh guru@172.16.3.30
|
||||
|
||||
# Import database
|
||||
mysql -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed claudetools < /tmp/claudetools_export.sql
|
||||
|
||||
# Verify tables
|
||||
mysql -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed claudetools -e "SHOW TABLES;"
|
||||
|
||||
# Should show 43 tables
|
||||
```
|
||||
|
||||
**Alternative: Fresh Migration with Alembic** (if export is empty/small)
|
||||
```bash
|
||||
# On Windows (D:\ClaudeTools)
|
||||
# Update .env to point to RMM server
|
||||
DATABASE_URL=mysql+pymysql://claudetools:CT_e8fcd5a3952030a79ed6debae6c954ed@172.16.3.30:3306/claudetools?charset=utf8mb4
|
||||
|
||||
# Run migrations
|
||||
alembic upgrade head
|
||||
|
||||
# This creates all 43 tables fresh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 3: Deploy API on RMM Server (15 min)
|
||||
|
||||
**3.1 Create API Directory and Virtual Environment**
|
||||
```bash
|
||||
ssh guru@172.16.3.30
|
||||
|
||||
# Create directory
|
||||
sudo mkdir -p /opt/claudetools
|
||||
sudo chown guru:guru /opt/claudetools
|
||||
cd /opt/claudetools
|
||||
|
||||
# Clone or copy API code
|
||||
# Option A: Via git (recommended)
|
||||
git clone https://git.azcomputerguru.com/mike/ClaudeTools.git .
|
||||
|
||||
# Option B: Copy from Windows
|
||||
# From Windows: scp -r D:\ClaudeTools\api guru@172.16.3.30:/opt/claudetools/
|
||||
# From Windows: scp D:\ClaudeTools\requirements.txt guru@172.16.3.30:/opt/claudetools/
|
||||
# From Windows: scp D:\ClaudeTools\alembic.ini guru@172.16.3.30:/opt/claudetools/
|
||||
# From Windows: scp -r D:\ClaudeTools\migrations guru@172.16.3.30:/opt/claudetools/
|
||||
|
||||
# Create Python virtual environment
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
|
||||
# Install dependencies
|
||||
pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
**3.2 Configure Environment**
|
||||
```bash
|
||||
# Create .env file
|
||||
cat > /opt/claudetools/.env <<'EOF'
|
||||
# Database Configuration
|
||||
DATABASE_URL=mysql+pymysql://claudetools:CT_e8fcd5a3952030a79ed6debae6c954ed@localhost:3306/claudetools?charset=utf8mb4
|
||||
DATABASE_POOL_SIZE=20
|
||||
DATABASE_MAX_OVERFLOW=10
|
||||
|
||||
# Security Configuration
|
||||
JWT_SECRET_KEY=NdwgH6jsGR1WfPdUwR3u9i1NwNx3QthhLHBsRCfFxcg=
|
||||
ENCRYPTION_KEY=your-encryption-key-from-shared-data
|
||||
JWT_ALGORITHM=HS256
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES=1440
|
||||
|
||||
# API Configuration
|
||||
ALLOWED_ORIGINS=*
|
||||
DATABASE_NAME=claudetools
|
||||
EOF
|
||||
|
||||
# Copy encryption key from shared data
|
||||
# From Windows: scp C:\Users\MikeSwanson\claude-projects\shared-data\.encryption-key guru@172.16.3.30:/opt/claudetools/.encryption-key
|
||||
|
||||
# Update .env with actual encryption key
|
||||
ENCRYPTION_KEY=$(cat /opt/claudetools/.encryption-key)
|
||||
sed -i "s|ENCRYPTION_KEY=.*|ENCRYPTION_KEY=$ENCRYPTION_KEY|" /opt/claudetools/.env
|
||||
```
|
||||
|
||||
**3.3 Create Systemd Service**
|
||||
```bash
|
||||
sudo nano /etc/systemd/system/claudetools-api.service
|
||||
```
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=ClaudeTools Context Recall API
|
||||
After=network.target mariadb.service
|
||||
Wants=mariadb.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=guru
|
||||
Group=guru
|
||||
WorkingDirectory=/opt/claudetools
|
||||
Environment="PATH=/opt/claudetools/venv/bin"
|
||||
EnvironmentFile=/opt/claudetools/.env
|
||||
ExecStart=/opt/claudetools/venv/bin/uvicorn api.main:app --host 0.0.0.0 --port 8001 --workers 2
|
||||
Restart=always
|
||||
RestartSec=10
|
||||
|
||||
# Logging
|
||||
StandardOutput=append:/var/log/claudetools-api.log
|
||||
StandardError=append:/var/log/claudetools-api-error.log
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
**3.4 Start Service**
|
||||
```bash
|
||||
# Create log files
|
||||
sudo touch /var/log/claudetools-api.log /var/log/claudetools-api-error.log
|
||||
sudo chown guru:guru /var/log/claudetools-api*.log
|
||||
|
||||
# Enable and start service
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable claudetools-api
|
||||
sudo systemctl start claudetools-api
|
||||
|
||||
# Check status
|
||||
sudo systemctl status claudetools-api
|
||||
|
||||
# Test API
|
||||
curl http://localhost:8001/health
|
||||
curl http://172.16.3.30:8001/health
|
||||
|
||||
# View logs
|
||||
sudo journalctl -u claudetools-api -f
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 4: Configure Nginx Reverse Proxy (5 min)
|
||||
|
||||
**4.1 Create Nginx Config**
|
||||
```bash
|
||||
sudo nano /etc/nginx/sites-available/claudetools-api
|
||||
```
|
||||
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
server_name claudetools-api.azcomputerguru.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:8001;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# WebSocket support (if needed)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```bash
|
||||
# Enable site
|
||||
sudo ln -s /etc/nginx/sites-available/claudetools-api /etc/nginx/sites-enabled/
|
||||
sudo nginx -t
|
||||
sudo systemctl reload nginx
|
||||
|
||||
# Test
|
||||
curl http://172.16.3.30/health
|
||||
```
|
||||
|
||||
**4.2 Setup SSL (Optional - via NPM or Certbot)**
|
||||
```bash
|
||||
# Option A: Use NPM on Jupiter (easier)
|
||||
# Add proxy host in NPM: claudetools-api.azcomputerguru.com → http://172.16.3.30:8001
|
||||
|
||||
# Option B: Use Certbot directly
|
||||
sudo apt install -y certbot python3-certbot-nginx
|
||||
sudo certbot --nginx -d claudetools-api.azcomputerguru.com
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 5: Update Client Configurations (5 min)
|
||||
|
||||
**5.1 Update Shared Config Template**
|
||||
```bash
|
||||
# On Windows
|
||||
# Edit C:\Users\MikeSwanson\claude-projects\shared-data\context-recall-config.env.template
|
||||
|
||||
cat > "C:\Users\MikeSwanson\claude-projects\shared-data\context-recall-config.env.template" <<'EOF'
|
||||
# Claude Code Context Recall Configuration Template
|
||||
# Copy this to your project's .claude/context-recall-config.env
|
||||
|
||||
# API Configuration
|
||||
CLAUDE_API_URL=http://172.16.3.30:8001
|
||||
|
||||
# Project Identification (auto-detected from git)
|
||||
CLAUDE_PROJECT_ID=
|
||||
|
||||
# Authentication (get from API)
|
||||
JWT_TOKEN=
|
||||
|
||||
# Context Recall Settings
|
||||
CONTEXT_RECALL_ENABLED=true
|
||||
MIN_RELEVANCE_SCORE=5.0
|
||||
MAX_CONTEXTS=10
|
||||
AUTO_SAVE_CONTEXT=true
|
||||
DEFAULT_RELEVANCE_SCORE=7.0
|
||||
DEBUG_CONTEXT_RECALL=false
|
||||
EOF
|
||||
```
|
||||
|
||||
**5.2 Update Current Machine**
|
||||
```bash
|
||||
# In D:\ClaudeTools
|
||||
# Update .claude/context-recall-config.env
|
||||
sed -i 's|CLAUDE_API_URL=.*|CLAUDE_API_URL=http://172.16.3.30:8001|' .claude/context-recall-config.env
|
||||
|
||||
# Get new JWT token from central API
|
||||
curl -X POST http://172.16.3.30:8001/api/auth/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username": "admin", "password": "your-password"}' | jq -r '.access_token'
|
||||
|
||||
# Update JWT_TOKEN in config file
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Phase 6: Create New-Machine Setup Script (5 min)
|
||||
|
||||
**6.1 Create Simple Setup Script**
|
||||
```bash
|
||||
# Save as: scripts/setup-new-machine.sh
|
||||
cat > scripts/setup-new-machine.sh <<'EOF'
|
||||
#!/bin/bash
|
||||
#
|
||||
# ClaudeTools New Machine Setup
|
||||
# Quick setup for new machines (30 seconds)
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
echo "=========================================="
|
||||
echo "ClaudeTools New Machine Setup"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Detect project root
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
CONFIG_FILE="$PROJECT_ROOT/.claude/context-recall-config.env"
|
||||
|
||||
echo "Project root: $PROJECT_ROOT"
|
||||
echo ""
|
||||
|
||||
# Check if template exists in shared data
|
||||
SHARED_TEMPLATE="C:/Users/MikeSwanson/claude-projects/shared-data/context-recall-config.env"
|
||||
|
||||
if [ ! -f "$SHARED_TEMPLATE" ]; then
|
||||
echo "❌ ERROR: Template not found at $SHARED_TEMPLATE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copy template
|
||||
echo "[1/3] Copying configuration template..."
|
||||
cp "$SHARED_TEMPLATE" "$CONFIG_FILE"
|
||||
echo "✓ Configuration file created"
|
||||
echo ""
|
||||
|
||||
# Get project ID from git
|
||||
echo "[2/3] Detecting project ID..."
|
||||
PROJECT_ID=$(git config --local claude.projectid 2>/dev/null || echo "")
|
||||
|
||||
if [ -z "$PROJECT_ID" ]; then
|
||||
# Generate from git remote
|
||||
GIT_REMOTE=$(git config --get remote.origin.url 2>/dev/null || echo "")
|
||||
if [ -n "$GIT_REMOTE" ]; then
|
||||
PROJECT_ID=$(echo -n "$GIT_REMOTE" | md5sum | cut -d' ' -f1)
|
||||
git config --local claude.projectid "$PROJECT_ID"
|
||||
echo "✓ Generated project ID: $PROJECT_ID"
|
||||
else
|
||||
echo "⚠ Warning: Could not detect project ID"
|
||||
fi
|
||||
else
|
||||
echo "✓ Project ID: $PROJECT_ID"
|
||||
fi
|
||||
|
||||
# Update config with project ID
|
||||
if [ -n "$PROJECT_ID" ]; then
|
||||
sed -i "s|CLAUDE_PROJECT_ID=.*|CLAUDE_PROJECT_ID=$PROJECT_ID|" "$CONFIG_FILE"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Get JWT token
|
||||
echo "[3/3] Obtaining JWT token..."
|
||||
echo "Enter API credentials:"
|
||||
read -p "Username [admin]: " API_USERNAME
|
||||
API_USERNAME="${API_USERNAME:-admin}"
|
||||
read -sp "Password: " API_PASSWORD
|
||||
echo ""
|
||||
|
||||
if [ -z "$API_PASSWORD" ]; then
|
||||
echo "❌ ERROR: Password required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
JWT_TOKEN=$(curl -s -X POST http://172.16.3.30:8001/api/auth/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"username\": \"$API_USERNAME\", \"password\": \"$API_PASSWORD\"}" | \
|
||||
grep -o '"access_token":"[^"]*' | sed 's/"access_token":"//')
|
||||
|
||||
if [ -z "$JWT_TOKEN" ]; then
|
||||
echo "❌ ERROR: Failed to get JWT token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update config with token
|
||||
sed -i "s|JWT_TOKEN=.*|JWT_TOKEN=$JWT_TOKEN|" "$CONFIG_FILE"
|
||||
|
||||
echo "✓ JWT token obtained and saved"
|
||||
echo ""
|
||||
|
||||
echo "=========================================="
|
||||
echo "Setup Complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Configuration file: $CONFIG_FILE"
|
||||
echo "API URL: http://172.16.3.30:8001"
|
||||
echo "Project ID: $PROJECT_ID"
|
||||
echo ""
|
||||
echo "You can now use Claude Code normally."
|
||||
echo "Context will be automatically recalled from the central server."
|
||||
echo ""
|
||||
EOF
|
||||
|
||||
chmod +x scripts/setup-new-machine.sh
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Rollback Plan
|
||||
|
||||
If migration fails, revert to Jupiter database:
|
||||
|
||||
```bash
|
||||
# Update .claude/context-recall-config.env
|
||||
CLAUDE_API_URL=http://172.16.3.20:8000
|
||||
|
||||
# Restart local API
|
||||
cd D:\ClaudeTools
|
||||
api\venv\Scripts\activate
|
||||
python -m api.main
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Testing Checklist
|
||||
|
||||
After migration, verify:
|
||||
|
||||
- [ ] Database accessible from RMM server: `mysql -h localhost -u claudetools -p`
|
||||
- [ ] Database accessible from Windows: `mysql -h 172.16.3.30 -u claudetools -p`
|
||||
- [ ] API health endpoint: `curl http://172.16.3.30:8001/health`
|
||||
- [ ] API docs accessible: http://172.16.3.30:8001/api/docs
|
||||
- [ ] JWT authentication works: `curl -X POST http://172.16.3.30:8001/api/auth/login ...`
|
||||
- [ ] Context recall works: `bash .claude/hooks/user-prompt-submit`
|
||||
- [ ] Context saving works: `bash .claude/hooks/task-complete`
|
||||
- [ ] Service auto-starts: `sudo systemctl restart claudetools-api && systemctl status claudetools-api`
|
||||
- [ ] Logs are clean: `sudo journalctl -u claudetools-api -n 50`
|
||||
|
||||
---
|
||||
|
||||
## New Machine Setup (Post-Migration)
|
||||
|
||||
**Simple 3-step process:**
|
||||
|
||||
```bash
|
||||
# 1. Clone repo
|
||||
git clone https://git.azcomputerguru.com/mike/ClaudeTools.git
|
||||
cd ClaudeTools
|
||||
|
||||
# 2. Run setup script
|
||||
bash scripts/setup-new-machine.sh
|
||||
|
||||
# 3. Done! (30 seconds total)
|
||||
```
|
||||
|
||||
**No need for:**
|
||||
- Python installation
|
||||
- Virtual environment
|
||||
- Dependencies installation
|
||||
- API server management
|
||||
- Database configuration
|
||||
|
||||
---
|
||||
|
||||
## Maintenance
|
||||
|
||||
**Updating API code:**
|
||||
```bash
|
||||
ssh guru@172.16.3.30
|
||||
cd /opt/claudetools
|
||||
git pull origin main
|
||||
sudo systemctl restart claudetools-api
|
||||
```
|
||||
|
||||
**Viewing logs:**
|
||||
```bash
|
||||
# Live tail
|
||||
sudo journalctl -u claudetools-api -f
|
||||
|
||||
# Last 100 lines
|
||||
sudo journalctl -u claudetools-api -n 100
|
||||
|
||||
# Log files
|
||||
tail -f /var/log/claudetools-api.log
|
||||
tail -f /var/log/claudetools-api-error.log
|
||||
```
|
||||
|
||||
**Database backup:**
|
||||
```bash
|
||||
# Daily backup cron
|
||||
crontab -e
|
||||
|
||||
# Add:
|
||||
0 2 * * * mysqldump -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed claudetools | gzip > /home/guru/backups/claudetools_$(date +\%Y\%m\%d).sql.gz
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Benefits of Central Architecture
|
||||
|
||||
**Before (Local API on each machine):**
|
||||
- Setup time: 15 minutes per machine
|
||||
- Dependencies: Python, venv, 20+ packages per machine
|
||||
- Maintenance: Update N machines separately
|
||||
- Version drift: Different API versions across machines
|
||||
- Troubleshooting: Complex, machine-specific issues
|
||||
|
||||
**After (Central API on RMM server):**
|
||||
- Setup time: 30 seconds per machine
|
||||
- Dependencies: None (just git clone + config file)
|
||||
- Maintenance: Update once, affects all machines
|
||||
- Version consistency: Single API version everywhere
|
||||
- Troubleshooting: Check one service, one log
|
||||
|
||||
**Resource usage:**
|
||||
- Before: 3-5 Python processes (one per machine)
|
||||
- After: 1 systemd service with 2 workers
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. Execute migration (Phases 1-5)
|
||||
2. Test thoroughly (Testing Checklist)
|
||||
3. Update shared template in credentials.md
|
||||
4. Document in SESSION_STATE.md
|
||||
5. Commit migration scripts to git
|
||||
6. Setup monitoring/alerting for API service (optional)
|
||||
7. Configure SSL certificate (optional, via NPM)
|
||||
|
||||
---
|
||||
|
||||
**Estimated Total Time:** 30-45 minutes
|
||||
**Risk Level:** Low (database is new, easy rollback)
|
||||
**Downtime:** 5 minutes (during API switchover)
|
||||
@@ -1,2 +0,0 @@
|
||||
pst-admin
|
||||
24Hearts$
|
||||
@@ -1,9 +0,0 @@
|
||||
[INFO] ================================================================================
|
||||
[INFO] ClaudeTools Conversation Import Script
|
||||
[INFO] ================================================================================
|
||||
[INFO] Logs directory: D:\ClaudeTools\projects\msp-tools\guru-connect-conversation-logs
|
||||
[INFO] API URL: http://172.16.3.30:8001
|
||||
[INFO] Mode: IMPORT
|
||||
[INFO] ================================================================================
|
||||
[ERROR] No JWT_TOKEN in environment and no API_USER_EMAIL/API_USER_PASSWORD
|
||||
[ERROR] Cannot proceed without JWT token. Set JWT_TOKEN or API_USER_EMAIL/API_USER_PASSWORD in .env
|
||||
@@ -1,11 +0,0 @@
|
||||
======================================================================
|
||||
CLAUDE CONTEXT IMPORT TOOL
|
||||
======================================================================
|
||||
[OK] Loaded JWT token from .claude\context-recall-config.env
|
||||
|
||||
[API] Calling: http://172.16.3.30:8001/api/bulk-import/import-folder
|
||||
Mode: EXECUTE
|
||||
Folder: C:\Users\MikeSwanson\.claude\projects
|
||||
|
||||
[ERROR] API Error: 404 Client Error: Not Found for url: http://172.16.3.30:8001/api/bulk-import/import-folder?folder_path=C%3A%5CUsers%5CMikeSwanson%5C.claude%5Cprojects&dry_run=False
|
||||
Detail: Base path does not exist: C:\Users\MikeSwanson\.claude\projects
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,80 +0,0 @@
|
||||
========================================
|
||||
Timestamp: 2026-01-17 13:43:28
|
||||
========================================
|
||||
Process Counts:
|
||||
Git: 0
|
||||
Bash: 21
|
||||
SSH: 11
|
||||
Conhost: 21
|
||||
Python: 1
|
||||
TOTAL: 54
|
||||
|
||||
Memory Usage:
|
||||
Total: 31.43 GB
|
||||
Used: 17.65 GB (56.2%)
|
||||
Free: 13.78 GB
|
||||
|
||||
========================================
|
||||
Timestamp: 2026-01-17 14:03:33
|
||||
========================================
|
||||
Process Counts:
|
||||
Git: 0
|
||||
Bash: 0
|
||||
SSH: 1
|
||||
Conhost: 6
|
||||
Python: 0
|
||||
TOTAL: 7
|
||||
|
||||
Memory Usage:
|
||||
Total: 31.43 GB
|
||||
Used: 14.35 GB (45.7%)
|
||||
Free: 17.08 GB
|
||||
|
||||
========================================
|
||||
Timestamp: 2026-01-17 14:27:14
|
||||
========================================
|
||||
Process Counts:
|
||||
Git: 0
|
||||
Bash: 3
|
||||
SSH: 1
|
||||
Conhost: 7
|
||||
Python: 2
|
||||
TOTAL: 13
|
||||
|
||||
Memory Usage:
|
||||
Total: 31.43 GB
|
||||
Used: 12.2 GB (38.8%)
|
||||
Free: 19.23 GB
|
||||
|
||||
========================================
|
||||
Timestamp: 2026-01-17 14:33:06
|
||||
========================================
|
||||
Process Counts:
|
||||
Git: 0
|
||||
Bash: 3
|
||||
SSH: 1
|
||||
Conhost: 7
|
||||
Python: 2
|
||||
TOTAL: 13
|
||||
|
||||
Memory Usage:
|
||||
Total: 31.43 GB
|
||||
Used: 12.32 GB (39.2%)
|
||||
Free: 19.11 GB
|
||||
|
||||
========================================
|
||||
Timestamp: 2026-01-18 10:12:43
|
||||
========================================
|
||||
Process Counts:
|
||||
Git: 0
|
||||
Bash: 6
|
||||
SSH: 2
|
||||
Conhost: 9
|
||||
Python: 2
|
||||
TOTAL: 19
|
||||
|
||||
Memory Usage:
|
||||
Total: 31.43 GB
|
||||
Used: 26.2 GB (83.4%)
|
||||
Free: 5.23 GB
|
||||
|
||||
Reference in New Issue
Block a user