[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

@@ -1,13 +1,14 @@
#!/bin/bash
#
# Claude Code Hook: task-complete
# Claude Code Hook: task-complete (v2 - with offline support)
# Runs AFTER a task is completed
# Saves conversation context to the database for future recall
# FALLBACK: Queues locally when API is unavailable, syncs later
#
# Expected environment variables:
# CLAUDE_PROJECT_ID - UUID of the current project
# JWT_TOKEN - Authentication token for API
# CLAUDE_API_URL - API base URL (default: http://localhost:8000)
# CLAUDE_API_URL - API base URL (default: http://172.16.3.30:8001)
# CONTEXT_RECALL_ENABLED - Set to "false" to disable (default: true)
# TASK_SUMMARY - Summary of completed task (auto-generated by Claude)
# TASK_FILES - Files modified during task (comma-separated)
@@ -20,9 +21,15 @@ if [ -f "$CONFIG_FILE" ]; then
fi
# Default values
API_URL="${CLAUDE_API_URL:-http://localhost:8000}"
API_URL="${CLAUDE_API_URL:-http://172.16.3.30:8001}"
ENABLED="${CONTEXT_RECALL_ENABLED:-true}"
# Local storage paths
CLAUDE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
QUEUE_DIR="$CLAUDE_DIR/context-queue"
PENDING_DIR="$QUEUE_DIR/pending"
UPLOADED_DIR="$QUEUE_DIR/uploaded"
# Exit early if disabled
if [ "$ENABLED" != "true" ]; then
exit 0
@@ -42,13 +49,17 @@ else
PROJECT_ID="$CLAUDE_PROJECT_ID"
fi
# Exit if no project ID or JWT token
if [ -z "$PROJECT_ID" ] || [ -z "$JWT_TOKEN" ]; then
# Exit if no project ID
if [ -z "$PROJECT_ID" ]; then
exit 0
fi
# Create queue directories if they don't exist
mkdir -p "$PENDING_DIR" "$UPLOADED_DIR" 2>/dev/null
# Gather task information
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
TIMESTAMP_FILENAME=$(date -u +"%Y%m%d_%H%M%S")
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
GIT_COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "none")
@@ -104,13 +115,6 @@ CONTEXT_PAYLOAD=$(cat <<EOF
EOF
)
# POST to conversation-contexts endpoint
RESPONSE=$(curl -s --max-time 5 \
-X POST "${API_URL}/api/conversation-contexts" \
-H "Authorization: Bearer ${JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d "$CONTEXT_PAYLOAD" 2>/dev/null)
# Update project state
PROJECT_STATE_PAYLOAD=$(cat <<EOF
{
@@ -126,15 +130,53 @@ PROJECT_STATE_PAYLOAD=$(cat <<EOF
EOF
)
curl -s --max-time 5 \
-X POST "${API_URL}/api/project-states" \
-H "Authorization: Bearer ${JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d "$PROJECT_STATE_PAYLOAD" 2>/dev/null >/dev/null
# Try to POST to API if we have a JWT token
API_SUCCESS=false
if [ -n "$JWT_TOKEN" ]; then
RESPONSE=$(curl -s --max-time 5 -w "\n%{http_code}" \
-X POST "${API_URL}/api/conversation-contexts" \
-H "Authorization: Bearer ${JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d "$CONTEXT_PAYLOAD" 2>/dev/null)
# Log success (optional - comment out for silent operation)
if [ -n "$RESPONSE" ]; then
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
RESPONSE_BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "201" ]; then
API_SUCCESS=true
# Also update project state
curl -s --max-time 5 \
-X POST "${API_URL}/api/project-states" \
-H "Authorization: Bearer ${JWT_TOKEN}" \
-H "Content-Type: application/json" \
-d "$PROJECT_STATE_PAYLOAD" 2>/dev/null >/dev/null
fi
fi
# If API call failed, queue locally
if [ "$API_SUCCESS" = "false" ]; then
# Save context to pending queue
QUEUE_FILE="$PENDING_DIR/${PROJECT_ID}_${TIMESTAMP_FILENAME}_context.json"
echo "$CONTEXT_PAYLOAD" > "$QUEUE_FILE"
# Save project state to pending queue
STATE_QUEUE_FILE="$PENDING_DIR/${PROJECT_ID}_${TIMESTAMP_FILENAME}_state.json"
echo "$PROJECT_STATE_PAYLOAD" > "$STATE_QUEUE_FILE"
echo "⚠ Context queued locally (API unavailable) - will sync when online" >&2
# Try to sync in background (opportunistic)
if [ -n "$JWT_TOKEN" ]; then
bash "$(dirname "${BASH_SOURCE[0]}")/sync-contexts" >/dev/null 2>&1 &
fi
else
echo "✓ Context saved to database" >&2
# Trigger background sync of any queued items
if [ -n "$JWT_TOKEN" ]; then
bash "$(dirname "${BASH_SOURCE[0]}")/sync-contexts" >/dev/null 2>&1 &
fi
fi
exit 0