- serve.py: explizite if/else Content-Type (GET), PUT antwortet mit passendem CT - index.html: Original-Indent speichern/wiederverwenden, View-Modal-Status nach Edit - smoke_test.sh: $$ statt $PORT für Log-PID, pkill mit TERM+Retry+SIGKILL - agent_verify.sh: try/except FileNotFoundError für node-Check - validate.py: re.fullmatch statt re.match für Pattern-Validierung
68 lines
2.5 KiB
Bash
Executable file
68 lines
2.5 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
|
|
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=True) 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)
|
|
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 || echo 0)
|
|
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
|