#!/bin/sh
# project-kit: keep AI assistants out of the commit history.
# Removes "Co-authored-by:" trailers added by AI tools, and their "Generated with" lines.
# Enable with:  git config core.hooksPath .githooks
file="$1"
tmp="$file.pk-tmp"
grep -v -i -E \
  -e '^co-authored-by:.*<[^>]*(@anthropic\.com|@openai\.com|@cursor\.com|@aider\.chat|\[bot\]@users\.noreply\.github\.com|copilot@users\.noreply\.github\.com|copilot@github\.com)>' \
  -e '^co-authored-by: *((github )?copilot|chatgpt|codex|cursor( agent)?|claude( code| (opus|sonnet|haiku)[0-9. ]*)?|aider( \([^)]*\))?) *<' \
  -e '^.*generated with.*(claude|copilot|codex|gemini|cursor)' \
  "$file" > "$tmp"
# grep exits 1 when nothing is left (an empty message): keep that case valid and silent.
cat "$tmp" > "$file"
rm -f "$tmp"
exit 0
