rd13_copilot_setup/git-templates/hooks/post-commit
Conrad Schulz 16588b1888 feat: mandatory agent session protocol – start/end history logging
- user-settings/settings.json: new codeGeneration.instruction forces agents to
  read PROJECT_CONTEXT.md on session start and write history log on session end
- git-templates/.github/copilot-instructions.md: prominent MANDATORY section
  at top of file (highest priority, cannot be ignored)
- .github/copilot-instructions.md: same protocol for this repo itself
2026-05-31 13:01:12 +00:00

63 lines
1.7 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env sh
# post-commit Automatischer History-Log
#
# Läuft nach jedem erfolgreichen Commit.
# Schreibt einen faktischen Eintrag in history/prompts/ mit:
# - Commit-Hash, Branch, Datum, Message
# - Liste der geänderten Dateien
#
# Die Datei wird NICHT automatisch committed (kein Rekursionsrisiko).
# Sie wird beim nächsten regulären Commit mit erfasst (history/ ist tracked).
HASH=$(git rev-parse --short HEAD 2>/dev/null)
FULL_HASH=$(git rev-parse HEAD 2>/dev/null)
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
DATE=$(date '+%Y-%m-%d')
DATETIME=$(date '+%Y-%m-%d %H:%M:%S')
MSG=$(git log -1 --format='%s' 2>/dev/null)
AUTHOR=$(git log -1 --format='%an <%ae>' 2>/dev/null)
# Nur ausführen wenn history/prompts/ existiert
if [ ! -d "history/prompts" ]; then
exit 0
fi
# Dateiname: Datum + Branch (bereinigt) + Hash
BRANCH_CLEAN=$(printf '%s' "$BRANCH" | tr '/' '-' | tr ' ' '-')
OUTFILE="history/prompts/${DATE}_${BRANCH_CLEAN}_${HASH}.md"
# Geänderte Dateien dieses Commits
CHANGED_FILES=$(git diff-tree --no-commit-id -r --name-status "$FULL_HASH" 2>/dev/null \
| awk '{printf "| %-1s | %s |\n", $1, $2}')
cat > "$OUTFILE" << EOF
# Auto-Log: $MSG
| Feld | Wert |
|---|---|
| Datum | $DATETIME |
| Branch | \`$BRANCH\` |
| Commit | \`$FULL_HASH\` |
| Autor | $AUTHOR |
## Commit Message
\`\`\`
$MSG
\`\`\`
## Geänderte Dateien
| Status | Datei |
|---|---|
$CHANGED_FILES
---
*Automatisch generiert durch post-commit hook kein KI-Inhalt.*
*Für KI-generierte Zusammenfassung: Copilot Chat → \`/history\`*
EOF
# Staging-Info ausgeben (nicht automatisch stagen vermeidet Komplikationen)
echo ""
echo " ✓ history: $(basename "$OUTFILE") geschrieben"
echo " → wird beim nächsten Commit automatisch erfasst"