[Config] Add coding guidelines and code-fixer agent

Major additions:
- Add CODING_GUIDELINES.md with "NO EMOJIS" rule
- Create code-fixer agent for automated violation fixes
- Add offline mode v2 hooks with local caching/queue
- Add periodic context save with invisible Task Scheduler setup
- Add agent coordination rules and database connection docs

Infrastructure:
- Update hooks: task-complete-v2, user-prompt-submit-v2
- Add periodic_save_check.py for auto-save every 5min
- Add PowerShell scripts: setup_periodic_save.ps1, update_to_invisible.ps1
- Add sync-contexts script for queue synchronization

Documentation:
- OFFLINE_MODE.md, PERIODIC_SAVE_INVISIBLE_SETUP.md
- Migration procedures and verification docs
- Fix flashing window guide

Updates:
- Update agent configs (backup, code-review, coding, database, gitea, testing)
- Update claude.md with coding guidelines reference
- Update .gitignore for new cache/queue directories

Status: Pre-automated-fixer baseline commit

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-17 12:51:43 -07:00
parent 390b10b32c
commit 25f3759ecc
52 changed files with 8692 additions and 53 deletions

View File

@@ -0,0 +1,66 @@
#!/bin/bash
#
# Fix MariaDB setup after initial installation
#
set -e
echo "=========================================="
echo "Fixing MariaDB Setup"
echo "=========================================="
echo ""
# Secure installation using sudo mysql (unix_socket auth)
echo "[1/4] Securing MariaDB installation..."
sudo mysql <<'EOF'
ALTER USER 'root'@'localhost' IDENTIFIED BY 'CT_rmm_root_2026';
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DROP DATABASE IF EXISTS test;
DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';
FLUSH PRIVILEGES;
EOF
echo "✓ MariaDB secured"
echo ""
# Create ClaudeTools database
echo "[2/4] Creating ClaudeTools database..."
sudo mysql -u root -pCT_rmm_root_2026 <<'EOF'
CREATE DATABASE IF NOT EXISTS claudetools CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS 'claudetools'@'172.16.3.%' IDENTIFIED BY 'CT_e8fcd5a3952030a79ed6debae6c954ed';
GRANT ALL PRIVILEGES ON claudetools.* TO 'claudetools'@'172.16.3.%';
CREATE USER IF NOT EXISTS 'claudetools'@'localhost' IDENTIFIED BY 'CT_e8fcd5a3952030a79ed6debae6c954ed';
GRANT ALL PRIVILEGES ON claudetools.* TO 'claudetools'@'localhost';
FLUSH PRIVILEGES;
EOF
echo "✓ Database and users created"
echo ""
# Configure for network access
echo "[3/4] Configuring MariaDB for network access..."
sudo sed -i 's/bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/' /etc/mysql/mariadb.conf.d/50-server.cnf
sudo systemctl restart mariadb
echo "✓ Network access configured"
echo ""
# Test connection
echo "[4/4] Testing connection..."
mysql -h localhost -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed -e "SELECT 'Connection successful!' AS status, DATABASE() AS current_db;"
echo "✓ Connection test passed"
echo ""
echo "=========================================="
echo "MariaDB Setup Complete!"
echo "=========================================="
echo ""
echo "Database: claudetools"
echo "User: claudetools"
echo "Password: CT_e8fcd5a3952030a79ed6debae6c954ed"
echo "Host: 172.16.3.30:3306"
echo ""
echo "Next: Test from Windows with:"
echo " mysql -h 172.16.3.30 -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed claudetools"
echo ""

View File

@@ -0,0 +1,84 @@
#!/bin/bash
#
# ClaudeTools - Install MariaDB on RMM Server
# Run this on 172.16.3.30 as guru user
#
set -e
echo "=========================================="
echo "Installing MariaDB on RMM Server"
echo "=========================================="
echo ""
# Install MariaDB
echo "[1/7] Installing MariaDB..."
sudo apt update
sudo apt install -y mariadb-server mariadb-client
echo "✓ MariaDB installed"
echo ""
# Start and enable service
echo "[2/7] Starting MariaDB service..."
sudo systemctl start mariadb
sudo systemctl enable mariadb
echo "✓ MariaDB service started and enabled"
echo ""
# Secure installation (automated)
echo "[3/7] Securing MariaDB installation..."
sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED BY 'CT_rmm_root_2026';"
sudo mysql -e "DELETE FROM mysql.user WHERE User='';"
sudo mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
sudo mysql -e "DROP DATABASE IF EXISTS test;"
sudo mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%';"
sudo mysql -e "FLUSH PRIVILEGES;"
echo "✓ MariaDB secured (root password: CT_rmm_root_2026)"
echo ""
# Create ClaudeTools database
echo "[4/7] Creating ClaudeTools database..."
sudo mysql -u root -pCT_rmm_root_2026 <<'EOF'
CREATE DATABASE IF NOT EXISTS claudetools CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS 'claudetools'@'172.16.3.%' IDENTIFIED BY 'CT_e8fcd5a3952030a79ed6debae6c954ed';
GRANT ALL PRIVILEGES ON claudetools.* TO 'claudetools'@'172.16.3.%';
CREATE USER IF NOT EXISTS 'claudetools'@'localhost' IDENTIFIED BY 'CT_e8fcd5a3952030a79ed6debae6c954ed';
GRANT ALL PRIVILEGES ON claudetools.* TO 'claudetools'@'localhost';
FLUSH PRIVILEGES;
EOF
echo "✓ Database and users created"
echo ""
# Configure for network access
echo "[5/7] Configuring MariaDB for network access..."
sudo sed -i 's/bind-address\s*=\s*127.0.0.1/bind-address = 0.0.0.0/' /etc/mysql/mariadb.conf.d/50-server.cnf
echo "✓ Network access configured"
echo ""
# Restart MariaDB
echo "[6/7] Restarting MariaDB..."
sudo systemctl restart mariadb
echo "✓ MariaDB restarted"
echo ""
# Test connection
echo "[7/7] Testing connection..."
mysql -h localhost -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed -e "SELECT 'Connection successful!' AS status;"
echo "✓ Connection test passed"
echo ""
echo "=========================================="
echo "MariaDB Installation Complete!"
echo "=========================================="
echo ""
echo "Database: claudetools"
echo "User: claudetools"
echo "Password: CT_e8fcd5a3952030a79ed6debae6c954ed"
echo "Host: 172.16.3.30:3306"
echo ""
echo "Test from Windows:"
echo " mysql -h 172.16.3.30 -u claudetools -pCT_e8fcd5a3952030a79ed6debae6c954ed claudetools"
echo ""

View File

@@ -0,0 +1,107 @@
#!/bin/bash
#
# Migrate Data from Jupiter (172.16.3.20) to RMM (172.16.3.30)
# Migrates conversation contexts and any other data
#
set -e
echo "=========================================="
echo "ClaudeTools Data Migration"
echo "=========================================="
echo ""
echo "Source: Jupiter (172.16.3.20:3306) - Docker MariaDB"
echo "Target: RMM (172.16.3.30:3306) - Native MariaDB"
echo ""
# Database credentials
DB_USER="claudetools"
DB_PASS="CT_e8fcd5a3952030a79ed6debae6c954ed"
DB_NAME="claudetools"
SOURCE_HOST="172.16.3.20"
TARGET_HOST="172.16.3.30"
# Step 1: Export data from Jupiter
echo "[1/4] Exporting data from Jupiter (172.16.3.20)..."
echo ""
# Use PuTTY's plink instead of SSH
plink -batch guru@${SOURCE_HOST} "docker exec mariadb mysqldump \
-u ${DB_USER} \
-p${DB_PASS} \
--no-create-info \
--skip-add-drop-table \
--insert-ignore \
${DB_NAME} > /tmp/claudetools_data.sql && \
cat /tmp/claudetools_data.sql" > D:/ClaudeTools/temp_data_export.sql
EXPORT_SIZE=$(wc -l < D:/ClaudeTools/temp_data_export.sql)
echo "Exported ${EXPORT_SIZE} lines"
echo ""
# Step 2: Check what tables have data
echo "[2/4] Analyzing exported data..."
echo ""
grep "^INSERT INTO" D:/ClaudeTools/temp_data_export.sql | \
sed 's/INSERT INTO `\([^`]*\)`.*/\1/' | \
sort | uniq -c | \
awk '{printf " %-30s %s rows\n", $2, $1}'
echo ""
# Step 3: Copy to RMM server
echo "[3/4] Transferring to RMM server..."
echo ""
# Use PuTTY's pscp to copy file
pscp -batch D:/ClaudeTools/temp_data_export.sql guru@${TARGET_HOST}:/tmp/
echo "File transferred"
echo ""
# Step 4: Import into RMM database
echo "[4/4] Importing into RMM database..."
echo ""
plink -batch guru@${TARGET_HOST} "mysql \
-u ${DB_USER} \
-p${DB_PASS} \
-D ${DB_NAME} < /tmp/claudetools_data.sql && \
echo 'Import successful'"
echo ""
# Step 5: Verify
echo "=========================================="
echo "Verification"
echo "=========================================="
echo ""
plink -batch guru@${TARGET_HOST} "mysql \
-u ${DB_USER} \
-p${DB_PASS} \
-D ${DB_NAME} \
-e \"SELECT 'conversation_contexts' as table_name, COUNT(*) as records FROM conversation_contexts \
UNION ALL SELECT 'credentials', COUNT(*) FROM credentials \
UNION ALL SELECT 'clients', COUNT(*) FROM clients \
UNION ALL SELECT 'machines', COUNT(*) FROM machines \
UNION ALL SELECT 'sessions', COUNT(*) FROM sessions;\" 2>/dev/null"
echo ""
echo "=========================================="
echo "Data Migration Complete!"
echo "=========================================="
echo ""
# Cleanup
rm -f D:/ClaudeTools/temp_data_export.sql
plink -batch guru@${TARGET_HOST} "rm -f /tmp/claudetools_data.sql" 2>/dev/null || true
echo "Temporary files cleaned up"
echo ""
echo "Next steps:"
echo " 1. Verify data in database"
echo " 2. Test context recall via API"
echo " 3. Update any remaining references to 172.16.3.20"
echo ""

View File

@@ -0,0 +1,102 @@
#!/bin/bash
#
# ClaudeTools New Machine Setup
# Quick setup for new machines (30 seconds)
#
# Usage: bash scripts/setup-new-machine.sh
#
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 ""

View File

@@ -0,0 +1,169 @@
#!/bin/bash
#
# Upgrade ClaudeTools Hooks to Offline-Capable Version
# Migrates from v1 hooks to v2 hooks with local storage fallback
#
# Usage: bash scripts/upgrade-to-offline-mode.sh
#
set -e
echo "=========================================="
echo "ClaudeTools Offline Mode Upgrade"
echo "=========================================="
echo ""
echo "This script will upgrade your hooks to support offline operation."
echo ""
# Detect project root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
HOOKS_DIR="$PROJECT_ROOT/.claude/hooks"
echo "Project root: $PROJECT_ROOT"
echo ""
# Check if hooks directory exists
if [ ! -d "$HOOKS_DIR" ]; then
echo "❌ ERROR: Hooks directory not found at $HOOKS_DIR"
exit 1
fi
# Step 1: Backup existing hooks
echo "[1/5] Backing up existing hooks..."
BACKUP_DIR="$HOOKS_DIR/backup_$(date +%Y%m%d_%H%M%S)"
mkdir -p "$BACKUP_DIR"
if [ -f "$HOOKS_DIR/user-prompt-submit" ]; then
cp "$HOOKS_DIR/user-prompt-submit" "$BACKUP_DIR/"
echo " ✓ Backed up user-prompt-submit"
fi
if [ -f "$HOOKS_DIR/task-complete" ]; then
cp "$HOOKS_DIR/task-complete" "$BACKUP_DIR/"
echo " ✓ Backed up task-complete"
fi
echo " Backup location: $BACKUP_DIR"
echo ""
# Step 2: Install new hooks
echo "[2/5] Installing offline-capable hooks..."
if [ -f "$HOOKS_DIR/user-prompt-submit-v2" ]; then
cp "$HOOKS_DIR/user-prompt-submit-v2" "$HOOKS_DIR/user-prompt-submit"
chmod +x "$HOOKS_DIR/user-prompt-submit"
echo " ✓ Installed user-prompt-submit (v2)"
else
echo " ⚠ Warning: user-prompt-submit-v2 not found"
fi
if [ -f "$HOOKS_DIR/task-complete-v2" ]; then
cp "$HOOKS_DIR/task-complete-v2" "$HOOKS_DIR/task-complete"
chmod +x "$HOOKS_DIR/task-complete"
echo " ✓ Installed task-complete (v2)"
else
echo " ⚠ Warning: task-complete-v2 not found"
fi
if [ -f "$HOOKS_DIR/sync-contexts" ]; then
chmod +x "$HOOKS_DIR/sync-contexts"
echo " ✓ Made sync-contexts executable"
else
echo " ⚠ Warning: sync-contexts not found"
fi
echo ""
# Step 3: Create storage directories
echo "[3/5] Creating local storage directories..."
mkdir -p "$PROJECT_ROOT/.claude/context-cache"
mkdir -p "$PROJECT_ROOT/.claude/context-queue/pending"
mkdir -p "$PROJECT_ROOT/.claude/context-queue/uploaded"
mkdir -p "$PROJECT_ROOT/.claude/context-queue/failed"
echo " ✓ Created .claude/context-cache/"
echo " ✓ Created .claude/context-queue/{pending,uploaded,failed}/"
echo ""
# Step 4: Update .gitignore
echo "[4/5] Updating .gitignore..."
GITIGNORE="$PROJECT_ROOT/.gitignore"
if [ -f "$GITIGNORE" ]; then
# Check if entries already exist
if ! grep -q "\.claude/context-cache/" "$GITIGNORE" 2>/dev/null; then
echo "" >> "$GITIGNORE"
echo "# Context recall local storage (offline mode)" >> "$GITIGNORE"
echo ".claude/context-cache/" >> "$GITIGNORE"
echo ".claude/context-queue/" >> "$GITIGNORE"
echo " ✓ Added entries to .gitignore"
else
echo " .gitignore already updated"
fi
else
echo " ⚠ Warning: .gitignore not found"
fi
echo ""
# Step 5: Verification
echo "[5/5] Verifying installation..."
VERIFICATION_PASSED=true
# Check hooks are executable
if [ ! -x "$HOOKS_DIR/user-prompt-submit" ]; then
echo " ✗ user-prompt-submit is not executable"
VERIFICATION_PASSED=false
fi
if [ ! -x "$HOOKS_DIR/task-complete" ]; then
echo " ✗ task-complete is not executable"
VERIFICATION_PASSED=false
fi
if [ ! -x "$HOOKS_DIR/sync-contexts" ]; then
echo " ✗ sync-contexts is not executable"
VERIFICATION_PASSED=false
fi
# Check directories exist
if [ ! -d "$PROJECT_ROOT/.claude/context-cache" ]; then
echo " ✗ context-cache directory missing"
VERIFICATION_PASSED=false
fi
if [ ! -d "$PROJECT_ROOT/.claude/context-queue/pending" ]; then
echo " ✗ context-queue/pending directory missing"
VERIFICATION_PASSED=false
fi
if [ "$VERIFICATION_PASSED" = "true" ]; then
echo " ✓ All checks passed"
else
echo " ⚠ Some checks failed - please review"
fi
echo ""
echo "=========================================="
echo "Upgrade Complete!"
echo "=========================================="
echo ""
echo "✅ Offline mode is now active!"
echo ""
echo "Features enabled:"
echo " • Context caching for offline reading"
echo " • Context queuing when API unavailable"
echo " • Automatic sync when API restored"
echo ""
echo "Next steps:"
echo " 1. Use Claude Code normally - offline support is automatic"
echo " 2. Review documentation: .claude/OFFLINE_MODE.md"
echo " 3. Test offline mode by stopping the API temporarily"
echo ""
echo "Manual sync command:"
echo " bash .claude/hooks/sync-contexts"
echo ""
echo "Rollback (if needed):"
echo " cp $BACKUP_DIR/* .claude/hooks/"
echo ""