# -*- coding: utf-8 -*-
import io, sys, os, re, json, datetime
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")

b = json.load(open("_heartbeat_baseline.json", encoding="utf-8"))
idx = open("index_main.html", encoding="utf-8").read()
seg = idx[idx.find("const PROGRAMS="):idx.find("const CATD=")]
lvl = re.findall(r'lvl:"([^"]+)"', seg)
vd = re.findall(r'"([^"]+\.html)"', idx[idx.find("const VERIFIED_DETAILS="):])
details = len([f for f in os.listdir("details") if f.endswith(".html")])
mt = datetime.datetime.fromtimestamp(os.path.getmtime("index_main.html")).strftime("%Y-%m-%d %H:%M:%S")
b["updated_at"] = mt; b["index_main_mtime"] = mt
b["programs"] = len(lvl); b["programs_master"] = lvl.count("m"); b["programs_phd"] = lvl.count("d")
b["vd_set"] = len(set(vd)); b["details_html"] = details; b["node_check"] = "exit 0"
b["blocked_notes"].append("第六十六轮：UT SGS 5 条占位 det 升级为六卡半核验页（LLM/MSW/Music MA/MScF Forestry/Dentistry MSc）；Dentistry MSc 新建 PROGRAMS+CATD；上轮发现 ut-ca0f935(MMF) 与旧条目 ut-mmf 重复、ut-c4f263b(MScAC) 与旧条目 ut-msac 重复，待批次5终检清理。")
b["note"] = "第六十六轮：UT SGS 5 条闭环，PROGRAMS 516→521。UT SGS slug 列表仍有大量硕士项目可探（Nursing MN/Architecture MArch 已录、Social Work MSW 本轮录、Law LLM 本轮录、Music MA 本轮录、Forestry MScF 本轮录、Dentistry MSc 本轮录）。"
json.dump(b, open("_heartbeat_baseline.json", "w", encoding="utf-8"), ensure_ascii=False, indent=2)
print("基线:", b["programs"], "master", b["programs_master"], "phd", b["programs_phd"], "vd", b["vd_set"], "details", b["details_html"], "mtime", mt)
