#!/usr/bin/env python3
"""Archive the 2026-11-03 and 2026-11-04 RUN NOTEs out of SKILL.md into references/."""
import os

SK = "/home/kiro/.hermes/skills/social-media/x-account-monitor/SKILL.md"
REF = "/home/kiro/.hermes/skills/social-media/x-account-monitor/references"
os.makedirs(REF, exist_ok=True)

s = open(SK, encoding="utf-8").read()
print("before:", len(s))

start = s.index("### RUN NOTE (2026-11-03)")
end = s.index("### RUN NOTE (2026-11-05)")
note = s[start:end].rstrip() + "\n"

out = os.path.join(REF, "run-notes-2026-11-03-to-11-04.md")
with open(out, "w", encoding="utf-8") as f:
    f.write("# X Account Monitor -- RUN NOTES 2026-11-03 and 2026-11-04\n\n"
            "Archived verbatim from SKILL.md on 2026-11-06 (SKILL.md was 89.1K and the\n"
            "2026-11-06 run note would have exceeded the 100K write limit).\n\n")
    f.write(note)
print("wrote", out, os.path.getsize(out), "bytes")

pointer = ("<!-- RUN NOTES 2026-11-03 -> 2026-11-04 archived verbatim to\n"
           "     references/run-notes-2026-11-03-to-11-04.md on 2026-11-06 (SKILL.md at 89.1K).\n"
           "     The newest note in SKILL.md always wins. -->\n\n")
s = s[:start] + pointer + s[end:]
open(SK, "w", encoding="utf-8").write(s)
print("after:", len(s))
