#!/usr/bin/env python3 """Resumo compacto das execuções em output/runs/. Economiza tokens: em vez de ler report.json/render.log inteiros, imprime uma linha por execução com status, perfil, verificações, tempos e digest. Uso: python .claude/skills/cenaforge/scripts/runs_summary.py # últimas 10 python .claude/skills/cenaforge/scripts/runs_summary.py --last 3 --details python .claude/skills/cenaforge/scripts/runs_summary.py --run --details """ from __future__ import annotations import argparse from pathlib import Path from _common import LAST_SUCCESS, RUNS_DIR, load_json, rel, utf8_stdout def main() -> int: utf8_stdout() ap = argparse.ArgumentParser(description="Resumo compacto das execuções de render.") ap.add_argument("--last", type=int, default=10, help="quantas execuções mostrar (mais novas)") ap.add_argument("--run", help="uma pasta de execução específica") ap.add_argument("--details", action="store_true", help="falhas, avisos, MP4 e imagem de inspeção") args = ap.parse_args() if args.run: runs = [Path(args.run).resolve()] else: runs = sorted((p for p in RUNS_DIR.glob("*") if (p / "report.json").is_file()), reverse=True)[: args.last] if not runs: print("nenhuma execução encontrada em", rel(RUNS_DIR)) return 1 last_ok = load_json(LAST_SUCCESS).get("runDir") if LAST_SUCCESS.is_file() else None print("status perfil total_s godot_s checks digest execução") for run in runs: r = load_json(run / "report.json") checks = r.get("checks", []) failed = [c for c in checks if not c.get("ok")] t = r.get("timingsSeconds", {}) digest = ((r.get("godot") or {}).get("stateDigest") or "-")[:8] mark = " *" if last_ok and rel(run) == last_ok else "" print(f"{r.get('status', '?'):9} {r.get('profile', '?'):8} {t.get('total', '-'):>8} {t.get('godotRender', '-'):>8}" f" {len(checks) - len(failed):>2}/{len(checks):<3} {digest:9} {run.name}{mark}") if args.details: if r.get("error"): print(f" erro ({r.get('failedStage')}): {r['error'].splitlines()[0]}") for c in failed: print(f" FALHA {c['name']}: {c['detail']}") for w in r.get("warnings", []): print(f" AVISO {w}") if r.get("mp4"): print(f" mp4: {r['mp4']}") if r.get("inspection"): print(f" inspeção: {r['inspection'][-1]}") if last_ok: print("* = output/last-success.json") return 0 if __name__ == "__main__": raise SystemExit(main())