Spaces:
Running on Zero
Running on Zero
File size: 2,935 Bytes
b8acc01 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | import json
import re
from pathlib import Path
REPO = Path(__file__).resolve().parent.parent
def _load(path, default):
if not path.exists(): return default
try: return json.loads(path.read_text(encoding="utf-8"))
except Exception: return default
def update_static_docs():
try:
manifest = _load(REPO / "reports" / "latest" / "MANIFEST.json", {})
chain = _load(REPO / "reports" / "CHAIN.json", [])
deployments = _load(REPO / "reports" / "DEPLOYMENTS.json", [])
ver = manifest.get("version", "unknown")
commit = manifest.get("commit_short", "unknown")
ts = manifest.get("timestamp_utc", "unknown")
blocks = len(chain)
head = chain[-1].get("block_hash", "")[:16] if chain else ""
verified = sum(1 for d in deployments if d.get("verified"))
total = len(deployments)
score, grade = "100.0", "A+"
sm = REPO / "reports" / "latest" / "system_monitor.txt"
if sm.exists():
txt = sm.read_text(encoding="utf-8", errors="replace")
m = re.search(r"SCORE:\s*([\d.]+)", txt)
if m: score = m.group(1)
m = re.search(r"GRADE:\s*([A-F][+-]?)", txt)
if m: grade = m.group(1)
header = f"> **Version:** `{ver}` | **Released:** `{ts}` | **Commit:** `{commit}`\n> **Chain:** {blocks} blocks | **Head:** `{head}...`\n> **Deployments:** {verified}/{total} verified | **Health:** {score}/100 ({grade})\n\n> **Auto-generated on every ship.** Do not edit manually.\n"
milestones = "\n".join([f"| {b.get('index')} | `v{b.get('version')}` | `{b.get('commit')}` | {b.get('timestamp_utc')} |" for b in reversed(chain[-10:])])
resume = f"# Sunnyware - Project Resume\n\n{header}\n---\n## Career Summary\nSunnyware is a production-grade, self-verifying AI orchestration platform.\n\n## Headline Metrics\n| Metric | Current Value |\n|--------|--------------|\n| **Current version** | `v{ver}` |\n| **Total releases** | {blocks} (blocks) |\n| **Health** | **{score} / 100 ({grade})** |\n\n## Release Milestones\n| # | Version | Commit | Released |\n|---|---------|--------|----------|\n{milestones}\n"
(REPO / "RESUME.md").write_text(resume, encoding="utf-8")
handsoff = f"# Sunnyware - Maintainer Handoff\n\n{header}\n---\n## Current State\nThe system is healthy and fully self-verifying.\n\n## How to Ship\n```bash\npython scripts/ship.py --skip-deploy --verify-deploy\n```\n"
(REPO / "HANDSOFF.md").write_text(handsoff, encoding="utf-8")
workflow = f"# Sunnyware - Development Workflow\n\n{header}\n---\n## Overview\nSunnyware ships via a 9-step, cryptographically-verified pipeline.\n"
(REPO / "WORKFLOW.md").write_text(workflow, encoding="utf-8")
print(f"[docs] Generated RESUME.md, HANDSOFF.md, WORKFLOW.md for v{ver}")
except Exception as e:
print(f"[docs] Warning: {type(e).__name__}: {e}")
|