diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index b16864a..8c5270a 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -1,5 +1,23 @@ # 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 diff --git a/git-templates/.github/copilot-instructions.md b/git-templates/.github/copilot-instructions.md index b16864a..8c5270a 100644 --- a/git-templates/.github/copilot-instructions.md +++ b/git-templates/.github/copilot-instructions.md @@ -1,5 +1,23 @@ # 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 diff --git a/git-templates/hooks/post-commit b/git-templates/hooks/post-commit new file mode 100644 index 0000000..1348b8e --- /dev/null +++ b/git-templates/hooks/post-commit @@ -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" diff --git a/git-templates/hooks/pre-commit b/git-templates/hooks/pre-commit index 39809ce..e0e4e21 100755 --- a/git-templates/hooks/pre-commit +++ b/git-templates/hooks/pre-commit @@ -5,6 +5,7 @@ # 1. Tests erstellt oder aktualisiert wurden # 2. Mindestens eine Zielgruppen-Dokumentation aktualisiert wurde # 3. Alle 3 Dokumentations-Zielgruppen vorhanden sind (USER/ADMIN/MAINTAINER) +# 4. history/summary/PROJECT_CONTEXT.md aktualisiert wurde # # Bypass (bewusst): git commit --no-verify @@ -72,7 +73,7 @@ if [ -n "$DOCS_DIR_STAGED" ] && [ -d "docs" ]; then if [ -n "$MISSING" ]; then 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" echo "" echo " Alle 3 Zielgruppen-Dokumente müssen existieren." @@ -82,11 +83,26 @@ if [ -n "$DOCS_DIR_STAGED" ] && [ -d "docs" ]; then 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 ────────────────────────────────────────────────────────────────── if [ "$ERRORS" -gt 0 ]; then 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 "══════════════════════════════════════════════════════════" echo "" diff --git a/user-settings/settings.json b/user-settings/settings.json index 7ee4861..43911af 100644 --- a/user-settings/settings.json +++ b/user-settings/settings.json @@ -34,6 +34,9 @@ }, { "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