# -*- 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["catd"] = 2817
b["vd_set"] = len(set(vd)); b["details_html"] = details; b["node_check"] = "exit 0"
b["blocked_notes"].append("第八十九轮：UPenn catalog 继续，闭环 5 条：MAPP（升级CATD占位up-c4e6bf6）/ Government Administration (FT) MPA（升级CATD占位up-c250a59）/ I-MPA / MPH / SMART M.S.Ed.。排除：Government Administration (Exec) MPA（在职高管版）/ MHCI（全在线+working professionals）/ Education Studies M.S.Ed.（暂停招生+全在线OMES）/ Learning Analytics and AI M.S.Ed.（全在线）。International Impact Evaluation MPA 为 Fels FT MPA 的方向不单独录。")
b["note"] = "第八十九轮：PROGRAMS 626→631，CATD 2814→2817（+3，MAPP/GAMPA 已有占位），details 3000→3003。"
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"], "catd", b["catd"], "vd", b["vd_set"], "details", b["details_html"], "mtime", mt)
