S01: Checkpoint-Tooling eingeführt: checkpoint.cmd + checkpoint.ps1; Regel R7 ergänzt; agent-prompt.md auf Checkpoint-Workflow umgestellt

This commit is contained in:
tlg
2026-04-14 09:18:47 +02:00
parent 0c6cfda3d6
commit abf0c037ee
5 changed files with 174 additions and 28 deletions

92
checkpoint.ps1 Normal file
View File

@@ -0,0 +1,92 @@
# ============================================================
# checkpoint.ps1
# ------------------------------------------------------------
# Wird von checkpoint.cmd aufgerufen. Liest
# .checkpoint-pending.txt, haengt einen Eintrag an changelog.md
# an (mit aktuellem Timestamp vom lokalen PC), fuehrt einen
# Git-Commit aus und loescht die Pending-Datei.
# ============================================================
$ErrorActionPreference = 'Stop'
# Repo-Root = Ordner, in dem dieses Skript liegt
$repoRoot = $PSScriptRoot
Set-Location $repoRoot
$pendingFile = Join-Path $repoRoot '.checkpoint-pending.txt'
$changelogFile = Join-Path $repoRoot 'changelog.md'
# --- Pending-Datei lesen -----------------------------------
if (-not (Test-Path $pendingFile)) {
Write-Error ".checkpoint-pending.txt nicht gefunden."
exit 1
}
$lines = Get-Content $pendingFile -Encoding UTF8
if ($lines.Count -lt 2) {
Write-Error ".checkpoint-pending.txt muss mindestens 2 Zeilen enthalten (Session, Zusammenfassung)."
exit 1
}
$session = $lines[0].Trim()
$summary = ($lines | Select-Object -Skip 1 | Where-Object { $_.Trim() -ne '' }) -join ' '
$summary = $summary.Trim()
if ([string]::IsNullOrWhiteSpace($session)) {
Write-Error "Session-Nummer (Zeile 1) ist leer."
exit 1
}
if ($session -notmatch '^S\d{2,}$') {
Write-Error "Session-Nummer '$session' hat nicht das Format S<NN> (z.B. S01, S12)."
exit 1
}
if ([string]::IsNullOrWhiteSpace($summary)) {
Write-Error "Zusammenfassung (Zeile 2+) ist leer."
exit 1
}
# --- Timestamp und Eintrag bauen ---------------------------
$timestamp = Get-Date -Format 'yyyy-MM-dd HH:mm'
$entry = "$timestamp | $session | $summary"
Write-Host ""
Write-Host "[checkpoint] Neuer Eintrag:" -ForegroundColor Cyan
Write-Host " $entry"
Write-Host ""
# --- Eintrag an changelog.md anhaengen ---------------------
# Immer erst sicherstellen, dass die Datei mit einem Zeilenumbruch endet.
$utf8NoBom = New-Object System.Text.UTF8Encoding $false
if (Test-Path $changelogFile) {
$existing = [System.IO.File]::ReadAllText($changelogFile, $utf8NoBom)
if ($existing.Length -gt 0 -and -not ($existing.EndsWith("`n"))) {
[System.IO.File]::AppendAllText($changelogFile, "`r`n", $utf8NoBom)
}
} else {
Write-Error "changelog.md nicht gefunden."
exit 1
}
[System.IO.File]::AppendAllText($changelogFile, $entry + "`r`n", $utf8NoBom)
Write-Host "[checkpoint] An changelog.md angehaengt." -ForegroundColor Green
# --- Git add + commit --------------------------------------
& git add -A
if ($LASTEXITCODE -ne 0) {
Write-Error "git add fehlgeschlagen (Exit Code $LASTEXITCODE)."
exit $LASTEXITCODE
}
$commitMsg = "${session}: $summary"
& git commit -m $commitMsg
if ($LASTEXITCODE -ne 0) {
Write-Error "git commit fehlgeschlagen (Exit Code $LASTEXITCODE)."
exit $LASTEXITCODE
}
Write-Host "[checkpoint] Commit erstellt: $commitMsg" -ForegroundColor Green
# --- Pending-Datei loeschen --------------------------------
Remove-Item $pendingFile -Force
Write-Host "[checkpoint] .checkpoint-pending.txt entfernt." -ForegroundColor Green