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
This commit is contained in:
Conrad Schulz 2026-05-31 13:01:12 +00:00
parent 67fbc150f8
commit 16588b1888
5 changed files with 120 additions and 2 deletions

View file

@ -1,5 +1,23 @@
# GitHub Copilot Project Instructions # GitHub Copilot Project Instructions
## ⚡ Agent Session Protocol (MANDATORY)
> Diese Sektion hat höchste Priorität und darf nicht ignoriert werden.
**Session START** Bevor du irgendetwas tust:
1. Lies `history/summary/PROJECT_CONTEXT.md` (falls vorhanden)
2. Verstehe den aktuellen Projektzustand bevor du anfängst
**Session END** Nach jeder bedeutenden Aufgabe (auch ohne explizite Aufforderung):
1. Erstelle `history/prompts/YYYY-MM-DD_kurztitel.md` mit vollständigem Log der Session
2. Aktualisiere `history/summary/PROJECT_CONTEXT.md` mit dem neuen Projektstand
3. Stage beide Dateien: `git add history/`
> Kein Bypass. Kein Vergessen. Kein "mache ich beim nächsten Mal".
> Die History ist das Gedächtnis des Projekts.
---
## Project ## Project
<!-- TODO: Beschreibe das Projekt in 1-2 Sätzen --> <!-- TODO: Beschreibe das Projekt in 1-2 Sätzen -->

View file

@ -1,5 +1,23 @@
# GitHub Copilot Project Instructions # GitHub Copilot Project Instructions
## ⚡ Agent Session Protocol (MANDATORY)
> Diese Sektion hat höchste Priorität und darf nicht ignoriert werden.
**Session START** Bevor du irgendetwas tust:
1. Lies `history/summary/PROJECT_CONTEXT.md` (falls vorhanden)
2. Verstehe den aktuellen Projektzustand bevor du anfängst
**Session END** Nach jeder bedeutenden Aufgabe (auch ohne explizite Aufforderung):
1. Erstelle `history/prompts/YYYY-MM-DD_kurztitel.md` mit vollständigem Log der Session
2. Aktualisiere `history/summary/PROJECT_CONTEXT.md` mit dem neuen Projektstand
3. Stage beide Dateien: `git add history/`
> Kein Bypass. Kein Vergessen. Kein "mache ich beim nächsten Mal".
> Die History ist das Gedächtnis des Projekts.
---
## Project ## Project
<!-- TODO: Beschreibe das Projekt in 1-2 Sätzen --> <!-- TODO: Beschreibe das Projekt in 1-2 Sätzen -->

View file

@ -0,0 +1,63 @@
#!/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"

View file

@ -5,6 +5,7 @@
# 1. Tests erstellt oder aktualisiert wurden # 1. Tests erstellt oder aktualisiert wurden
# 2. Mindestens eine Zielgruppen-Dokumentation aktualisiert wurde # 2. Mindestens eine Zielgruppen-Dokumentation aktualisiert wurde
# 3. Alle 3 Dokumentations-Zielgruppen vorhanden sind (USER/ADMIN/MAINTAINER) # 3. Alle 3 Dokumentations-Zielgruppen vorhanden sind (USER/ADMIN/MAINTAINER)
# 4. history/summary/PROJECT_CONTEXT.md aktualisiert wurde
# #
# Bypass (bewusst): git commit --no-verify # Bypass (bewusst): git commit --no-verify
@ -72,7 +73,7 @@ if [ -n "$DOCS_DIR_STAGED" ] && [ -d "docs" ]; then
if [ -n "$MISSING" ]; then if [ -n "$MISSING" ]; then
echo "" echo ""
echo "✗ AGENT QUALITY GATE [3/3]: Fehlende Zielgruppen-Dokumentation" echo "✗ AGENT QUALITY GATE [3/4]: Fehlende Zielgruppen-Dokumentation"
printf " Nicht vorhanden:%b\n" "$MISSING" printf " Nicht vorhanden:%b\n" "$MISSING"
echo "" echo ""
echo " Alle 3 Zielgruppen-Dokumente müssen existieren." echo " Alle 3 Zielgruppen-Dokumente müssen existieren."
@ -82,11 +83,26 @@ if [ -n "$DOCS_DIR_STAGED" ] && [ -d "docs" ]; then
fi fi
fi fi
# ── Check 4: PROJECT_CONTEXT.md aktualisiert ──────────────────────────────────
if [ -f "history/summary/PROJECT_CONTEXT.md" ]; then
CONTEXT_STAGED=$(printf '%s\n' "$STAGED" | grep -F 'history/summary/PROJECT_CONTEXT.md')
if [ -z "$CONTEXT_STAGED" ]; then
echo ""
echo "✗ AGENT QUALITY GATE [4/4]: PROJECT_CONTEXT.md nicht aktualisiert"
echo " Bei Code-Änderungen muss der Agent-Kontext aktuell gehalten werden."
echo " history/summary/PROJECT_CONTEXT.md"
echo ""
echo " → Copilot Chat: /history (loggt Session + aktualisiert Kontext)"
echo " → Bypass: git commit --no-verify"
ERRORS=$((ERRORS + 1))
fi
fi
# ── Ergebnis ────────────────────────────────────────────────────────────────── # ── Ergebnis ──────────────────────────────────────────────────────────────────
if [ "$ERRORS" -gt 0 ]; then if [ "$ERRORS" -gt 0 ]; then
echo "" echo ""
echo "══════════════════════════════════════════════════════════" echo "══════════════════════════════════════════════════════════"
echo " $ERRORS von 3 Quality Gate(s) nicht bestanden." echo " $ERRORS von 4 Quality Gate(s) nicht bestanden."
echo " Behebe die Probleme ODER: git commit --no-verify" echo " Behebe die Probleme ODER: git commit --no-verify"
echo "══════════════════════════════════════════════════════════" echo "══════════════════════════════════════════════════════════"
echo "" echo ""

View file

@ -34,6 +34,9 @@
}, },
{ {
"text": "Responses: short and precise. No padding, no repetition. Code comments in English. Chat explanations can be in German." "text": "Responses: short and precise. No padding, no repetition. Code comments in English. Chat explanations can be in German."
},
{
"text": "MANDATORY Agent Session Protocol: (1) START: If the file history/summary/PROJECT_CONTEXT.md exists in the repo, read it FIRST before doing anything else. (2) END: After completing any meaningful task, you MUST create a log file in history/prompts/YYYY-MM-DD_short-title.md documenting what was done, and update history/summary/PROJECT_CONTEXT.md with the current project state. This is not optional and must not be skipped. If the user ends the session without asking for it, do it anyway and stage the files."
} }
], ],
// Commit-Messages immer als Conventional Commits // Commit-Messages immer als Conventional Commits