Some checks failed
WEVAL NonReg / nonreg (push) Has been cancelled
Full E2E success on leadforge.html: Pipeline: 1. Playwright screenshot 58KB before.png 2. Gemini 2.5 Flash vision analysis avec prompt concis + maxTokens 16000 3. Parser Python separe wgux-parse.py extract JSON robuste 4. Apply python wgux-apply.py + GOLD backup + chattr + marker DOCTRINE-201 Handler v2 corrections vs v1: - Prompt concis (pas wevia brand details qui bouffent tokens) - maxTokens 6000 -> 16000 - responseMimeType application/json (STOP clean au lieu de MAX_TOKENS) - Scripts Python separes (pas inline heredoc bash) - Fichiers: wgux-build-payload.py wgux-parse.py wgux-apply.py Resultats leadforge: - plan.json 9978B ok:true finishReason:STOP safe:true - CSS 9424 chars avec tokens premium: * root vars --wtp-bg --wtp-card --wtp-primary --wtp-accent --wtp-secondary-text * .wtp-hero-premium radial-gradient + keyframes hero-gradient-pulse * .wtp-kpi-card hover transform translateY(-8px) * Media query mobile 768px bot-widget bottom 100px anti-overlap * Palette extraite image #ff4d6a rouge detecte - leadforge.html 40588 -> 52279 (+11.7KB CSS premium) - GOLD backup vault-gold/opus/leadforge.html.doctrine201-apply-20260424-171752.bak - HTTP 200 OK apres apply - Playwright overlap audit: tr:0 br:0 ZERO REGRESSION - Screenshot after.png 73KB (vs before 58KB = plus de contenu rendu) - Marker DOCTRINE-201-GEMINI-APPLY present idempotent Artefacts: - /var/www/html/api/wevia-gemini-ux-apply.sh (v2 2KB orchestrator) - /var/www/html/api/wgux-build-payload.py - /var/www/html/api/wgux-parse.py - /var/www/html/api/wgux-apply.py - /var/www/html/api/after-shot.js (verify module) - /var/www/html/api/after-audit.js (overlap verify module) - /var/www/html/products/leadforge.html patche Cumul: - 57 tags Opus - 40 doctrines (146-201) - 428 pages UX doctrine 60 - 1 page avec CSS Gemini appliquee (leadforge PROOF OF CONCEPT) - NR 153/153 invariant 59 phases WEVIA peut maintenant faire vraiment du UX premium autonome via chat NL.
46 lines
1.8 KiB
Python
Executable File
46 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Parse Gemini response robustly"""
|
|
import sys, json, re, os
|
|
|
|
raw_path = sys.argv[1]
|
|
out_path = sys.argv[2]
|
|
|
|
try:
|
|
with open(raw_path) as f:
|
|
resp = json.load(f)
|
|
|
|
if 'error' in resp:
|
|
out = {"ok": False, "err": resp['error']}
|
|
else:
|
|
text = resp['candidates'][0]['content']['parts'][0]['text']
|
|
finish = resp['candidates'][0].get('finishReason', 'UNKNOWN')
|
|
|
|
# Clean markdown wrappers
|
|
text = re.sub(r'```(?:json|html|css)?\s*', '', text)
|
|
text = text.replace('```', '').strip()
|
|
|
|
# Find JSON object
|
|
m = re.search(r'\{.*\}', text, re.DOTALL)
|
|
if m:
|
|
try:
|
|
plan = json.loads(m.group(0))
|
|
out = {"ok": True, "plan": plan, "finishReason": finish}
|
|
except json.JSONDecodeError as e:
|
|
# Try to extract css field directly
|
|
css_m = re.search(r'"css"\s*:\s*"(<style[^"]*(?:\\.[^"]*)*)"', text, re.DOTALL)
|
|
if css_m:
|
|
css_raw = css_m.group(1).encode().decode('unicode_escape')
|
|
out = {"ok": True, "plan": {"css": css_raw, "safe": False, "partial": True}, "finishReason": finish, "parse_mode": "regex_rescue"}
|
|
else:
|
|
out = {"ok": False, "raw": text[:8000], "finishReason": finish, "parse_err": str(e)[:100]}
|
|
else:
|
|
out = {"ok": False, "raw": text[:8000], "finishReason": finish}
|
|
|
|
with open(out_path, 'w') as f:
|
|
json.dump(out, f, ensure_ascii=False, indent=2)
|
|
print("PARSE_OK", out.get('ok'), out.get('finishReason', ''))
|
|
except Exception as e:
|
|
print("PARSE_ERR", str(e)[:200])
|
|
with open(out_path, 'w') as f:
|
|
json.dump({"ok": False, "err": str(e)[:200]}, f)
|