refactor: simplify gga script and exclude api/ via config

This commit is contained in:
Alan Buscaglia
2025-12-16 14:07:42 +01:00
parent 07a995a210
commit 2a3c71c435
2 changed files with 3 additions and 43 deletions

3
.gga
View File

@@ -10,7 +10,8 @@ PROVIDER="claude"
FILE_PATTERNS="*.ts,*.tsx,*.js,*.jsx,*.py"
# File patterns to exclude from review (comma-separated globs)
EXCLUDE_PATTERNS="*.test.ts,*.test.tsx,*.spec.ts,*.spec.tsx,*.d.ts,*_test.py,test_*.py,conftest.py"
# Excludes: test files, type definitions, and api/ folder (no AGENTS.md yet)
EXCLUDE_PATTERNS="*.test.ts,*.test.tsx,*.spec.ts,*.spec.tsx,*.d.ts,*_test.py,test_*.py,conftest.py,api/*"
# File containing your coding standards (relative to repo root)
RULES_FILE="AGENTS-CODE-REVIEW.md"

View File

@@ -1,16 +1,12 @@
#!/bin/bash
# Gentleman Guardian Angel (gga) - AI Code Review Hook
# This script is called by pre-commit after all formatters/linters have run
#
# Only reviews files in directories that have an AGENTS.md file.
# This allows teams to opt-in to AI code review by adding AGENTS.md to their component.
set -e
# Colors
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
GREEN='\033[0;32m'
NC='\033[0m'
# Check if AI code review is enabled
@@ -25,44 +21,6 @@ if [ ! -f "AGENTS-CODE-REVIEW.md" ]; then
exit 0
fi
# Get staged files
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(ts|tsx|js|jsx|py)$' || true)
if [ -z "$STAGED_FILES" ]; then
echo -e "${YELLOW}⏭️ No matching files staged for AI review${NC}"
exit 0
fi
# Filter out files from directories without AGENTS.md (opt-in model)
FILES_TO_REVIEW=""
SKIPPED_DIRS=""
for file in $STAGED_FILES; do
# Get the top-level directory of the file
TOP_DIR=$(echo "$file" | cut -d'/' -f1)
# Check if this directory has an AGENTS.md file
if [ -f "${TOP_DIR}/AGENTS.md" ]; then
FILES_TO_REVIEW="$FILES_TO_REVIEW $file"
else
# Track skipped directories (only unique)
if [[ ! "$SKIPPED_DIRS" =~ $TOP_DIR ]]; then
SKIPPED_DIRS="$SKIPPED_DIRS $TOP_DIR"
fi
fi
done
# Report skipped directories
if [ -n "$SKIPPED_DIRS" ]; then
echo -e "${YELLOW} Skipping directories without AGENTS.md:${SKIPPED_DIRS}${NC}"
fi
# Check if there are files to review after filtering
if [ -z "$(echo "$FILES_TO_REVIEW" | tr -d ' ')" ]; then
echo -e "${GREEN}✅ No files to review (all staged files are in directories without AGENTS.md)${NC}"
exit 0
fi
# Install gga if not present
if ! command -v gga &> /dev/null; then
echo -e "${BLUE}📦 Installing Gentleman Guardian Angel (gga)...${NC}"
@@ -87,4 +45,5 @@ if ! command -v gga &> /dev/null; then
fi
# Run gga code review
# Exclusions are configured in .gga file (EXCLUDE_PATTERNS)
exec gga run