# -*- coding: utf-8 -*-
import json, io, sys, os, re, 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("第七十八轮：USC CMB（计算分子生物学 MS）1条闭环，新建 det+CATD。其余候选定性排除：USC MEB/MGB/GEOL/ENVST 为本校 progressive 4+1 仅对内；USC DLA 全在线；UChicago BMI 全远程；GaTech BCFM 晚间在职；GaTech CS/Analytics/ME/BME 已录过；UNC Philosophy 为 PhD 附带。")
b["note"] = "第七十八轮：PROGRAMS 575→576，CATD 2763→2764，details 2950→2951。"
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)
