Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:42:29 +08:00
commit bece5178ef
31 changed files with 9410 additions and 0 deletions

21
hooks/pre-agent-invoke.sh Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash
# Pre-agent invocation hook - Optimized
# Verifies Rails project exists before agents run
set -e
# Combined check: Gemfile exists AND contains rails gem AND has app/ directory
if [ ! -f "Gemfile" ] || [ ! -d "app" ] || ! grep -q "gem ['\"]rails['\"]" Gemfile 2>/dev/null; then
echo "❌ Not a Rails project (missing Gemfile, app/, or rails gem)"
exit 1
fi
# Quick version detection from Gemfile.lock (most accurate) or Gemfile
if [ -f "Gemfile.lock" ]; then
RAILS_VERSION=$(grep -A1 "^ rails " Gemfile.lock 2>/dev/null | head -1 | tr -d ' ' || echo "")
else
RAILS_VERSION=$(grep "gem ['\"]rails['\"]" Gemfile | sed -n 's/.*[~>= ]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p' | head -1)
fi
echo "✅ Rails ${RAILS_VERSION:-?} project verified"
exit 0