[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,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 ""