#!/usr/bin/env python3
"""Archive RUN NOTE 2026-11-05 .. 2026-11-07 out of SKILL.md into references/."""
import re, os
SK = "/home/kiro/.hermes/skills/social-media/x-account-monitor/SKILL.md"
REF = "/home/kiro/.hermes/skills/social-media/x-account-monitor/references/run-notes-2026-11-05-to-11-07.md"
src = open(SK).read()
start = src.index("### RUN NOTE (2026-11-05)")
end = src.index("\n---\n\n## Date")
block = src[start:end].rstrip()
os.makedirs(os.path.dirname(REF), exist_ok=True)
with open(REF, "w") as f:
    f.write("# X Account Monitor -- run notes 2026-11-05 to 2026-11-07\n\n"
            "Archived verbatim from SKILL.md on 2026-11-08 (SKILL.md was 96.2K, closing on the 100K write limit).\n"
            "The newest note in SKILL.md always wins.\n\n" + block + "\n")
stub = ("<!-- RUN NOTES 2026-11-05 -> 2026-11-07 archived verbatim to\n"
        "     references/run-notes-2026-11-05-to-11-07.md on 2026-11-08 (SKILL.md at 96.2K).\n"
        "     The newest note in SKILL.md always wins. -->\n\n")
new = src[:start] + stub + src[end:].lstrip("\n")
open(SK, "w").write(new)
print("archived", len(block), "chars ->", REF)
print("SKILL.md now", len(new), "chars")
