#!/bin/bash
# Post-edit hook - runs after Edit or Write operations

# Get the file path from the hook arguments (passed as JSON)
# This is a minimal hook that can be extended

# Check if the edited file is a Python file
if [[ "$1" == *.py ]]; then
    # Could add auto-formatting here if desired
    # ruff format "$1" 2>/dev/null
    :
fi

# Check if the edited file is a TypeScript/JavaScript file
if [[ "$1" == *.ts ]] || [[ "$1" == *.tsx ]] || [[ "$1" == *.js ]] || [[ "$1" == *.jsx ]]; then
    # Could add auto-formatting here if desired
    # npx prettier --write "$1" 2>/dev/null
    :
fi

# Warn if console.log or print statements are detected
if [[ "$1" == *.py ]]; then
    if grep -q "^[[:space:]]*print(" "$1" 2>/dev/null; then
        echo "⚠️  Warning: print() statements detected - use structured logging"
    fi
elif [[ "$1" == *.ts ]] || [[ "$1" == *.tsx ]] || [[ "$1" == *.js ]] || [[ "$1" == *.jsx ]]; then
    if grep -q "console\.log" "$1" 2>/dev/null; then
        echo "⚠️  Warning: console.log statements detected - remove before commit"
    fi
fi

exit 0
