61 lines
2.3 KiB
Bash
61 lines
2.3 KiB
Bash
|
|
#!/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 -u
|
||
|
|
FAIL=0
|
||
|
|
|
||
|
|
# --- 1. Statisch: JS-Syntax in index.html ------------------------------
|
||
|
|
if [ -f web/index.html ]; then
|
||
|
|
python3 - <<'PY' || FAIL=1
|
||
|
|
import re, subprocess, tempfile, sys
|
||
|
|
html = open('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
|
||
|
|
r = subprocess.run(['node', '--check', p], capture_output=True, text=True)
|
||
|
|
if r.returncode != 0:
|
||
|
|
print(f'JS[{i}] syntax error:\n{r.stderr}')
|
||
|
|
sys.exit(1)
|
||
|
|
print('JS syntax OK')
|
||
|
|
PY
|
||
|
|
fi
|
||
|
|
|
||
|
|
# --- 2. Dynamisch: Smoke-Test (alle Endpunkte) -------------------------
|
||
|
|
if [ -x scripts/smoke_test.sh ]; then
|
||
|
|
./scripts/smoke_test.sh 8088 || 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 web/index.html ]; then
|
||
|
|
# No-Op-Pattern: leerer Container + while(firstChild) -> nichts zu bewegen
|
||
|
|
if grep -qE 'document\.createElement\([^)]+\)[^;]*;[[:space:]]*[^;]*\.appendChild\([^)]*firstChild\)' web/index.html; then
|
||
|
|
: # zu grob — deaktiviert
|
||
|
|
fi
|
||
|
|
# Doppeldeklaration einer Funktion
|
||
|
|
for fn in buildJsonForm extractJsonFromForm createJsonEditUI createTextEditUI applyFilters; do
|
||
|
|
count=$(grep -cE "function[[:space:]]+${fn}\\b" web/index.html || true)
|
||
|
|
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' 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 ----------
|
||
|
|
last_msg=$(git log -1 --pretty=%B 2>/dev/null || true)
|
||
|
|
if echo "$last_msg" | grep -qE '\b(an|in|mit)[[:space:]][[:space:]]+und'; then
|
||
|
|
echo "FAIL: letzter Commit hat doppelte Leerzeichen (Platzhalter nicht ersetzt):"
|
||
|
|
echo "$last_msg" | head -3
|
||
|
|
FAIL=1
|
||
|
|
fi
|
||
|
|
|
||
|
|
exit $FAIL
|