72 lines
2.6 KiB
Bash
Executable file
72 lines
2.6 KiB
Bash
Executable file
#!/bin/bash
|
|
# Verifikations-Hook fuer dual_agent-Pipeline.
|
|
# Wird nach dem Executor-Lauf aufgerufen; Exit 0 = gruen.
|
|
# stdout/stderr landen bei Retry als Kontext beim Planner.
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
FAIL=0
|
|
|
|
# --- 1. Statisch: JS-Syntax in index.html ------------------------------
|
|
if [ -f "$ROOT/web/index.html" ]; then
|
|
python3 - <<'PY' || FAIL=1
|
|
import re, subprocess, tempfile, sys, os
|
|
html = open(sys.argv[1] if len(sys.argv) > 1 else 'web/index.html').read()
|
|
for i, s in enumerate(re.findall(r'<script[^>]*>([\s\S]*?)</script>', html)):
|
|
with tempfile.NamedTemporaryFile('w', suffix='.js', delete=False) as f:
|
|
f.write(s); p = f.name
|
|
try:
|
|
r = subprocess.run(['node', '--check', p], capture_output=True, text=True)
|
|
except FileNotFoundError:
|
|
print('WARN: node nicht gefunden — JS-Syntax-Check übersprungen')
|
|
sys.exit(0)
|
|
if r.returncode != 0:
|
|
print(f'JS[{i}] syntax error:\n{r.stderr}')
|
|
sys.exit(1)
|
|
finally:
|
|
os.unlink(p)
|
|
print('JS syntax OK')
|
|
PY
|
|
else
|
|
echo "FAIL: web/index.html fehlt"
|
|
FAIL=1
|
|
fi
|
|
|
|
# --- 2. Dynamisch: Smoke-Test (alle Endpunkte) -------------------------
|
|
if [ -x "$ROOT/scripts/smoke_test.sh" ]; then
|
|
SMOKE_PORT=$(( $$ % 1000 + 9000 ))
|
|
"$ROOT/scripts/smoke_test.sh" "$SMOKE_PORT" || FAIL=1
|
|
fi
|
|
|
|
# --- 3. Semantisch: Pseudo-Fix-Muster verbieten ------------------------
|
|
# Diese Patterns haben wir als No-Op-Fixes im JSON-Editor erlebt.
|
|
# Ein neuer Bugfix darf sie nicht wieder einfuehren.
|
|
if [ -f "$ROOT/web/index.html" ]; then
|
|
# Doppeldeklaration einer Funktion
|
|
for fn in buildJsonForm extractJsonFromForm createJsonEditUI createTextEditUI applyFilters; do
|
|
count=$(grep -cE "function[[:space:]]+${fn}" "$ROOT/web/index.html" 2>/dev/null || true)
|
|
count=${count:-0}
|
|
count=$(echo "$count" | tail -1 | tr -dc '0-9')
|
|
if [ "$count" -gt 1 ]; then
|
|
echo "FAIL: Funktion '$fn' ist $count mal deklariert (erwartet: 1)"
|
|
FAIL=1
|
|
fi
|
|
done
|
|
# Platzhalter-Leichen in geaenderten HTML-Attributen
|
|
if grep -qE 'an[[:space:]][[:space:]]+und[[:space:]][[:space:]]+angehaengt' "$ROOT/web/index.html"; then
|
|
echo "FAIL: Platzhalter-Leichen in der Datei (Variablen nicht interpoliert)"
|
|
FAIL=1
|
|
fi
|
|
fi
|
|
|
|
# --- 4. Git-Hygiene: Commit-Message ohne Platzhalter-Leichen ----------
|
|
if ! git rev-parse HEAD >/dev/null 2>&1; then
|
|
echo "WARN: Kein Commit im Repo"
|
|
fi
|
|
last_msg=$(git log -1 --pretty=%B 2>/dev/null || true)
|
|
if printf '%s\n' "$last_msg" | grep -qE '\b(an|in|mit)[[:space:]][[:space:]]+und'; then
|
|
echo "FAIL: letzter Commit hat doppelte Leerzeichen (Platzhalter nicht ersetzt):"
|
|
printf '%s\n' "$last_msg" | head -3
|
|
FAIL=1
|
|
fi
|
|
|
|
exit $FAIL
|