ckb/tests/unit/test_docs_consistency.py
Michał Kopeć 6427567a0b Template 2.0.1: 3.8 compatibility, routines --mark, exporter containment
Fixes F1-F5 from the 2.0.0 script review:
- removeprefix/removesuffix (3.9+) replaced; lint, retrieve and
  consolidate crashed on Python 3.8 with any graph edges
- routines.py --mark wrote `last_run:DATE` (invalid YAML) and swallowed
  trailing comments into the value
- export_okf.py --out must be inside outputs/ (it is rmtree'd);
  export_starlight.py image copies confined to wiki/assets/
- script counts in AGENTS.md, READMEs and manuals

New tests/unit/ (stdlib unittest, run from smoke.sh): 3.8 API guard,
routines round-trips, exporter containment, AGENTS.md consistency.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-11 14:26:10 +01:00

36 lines
1.4 KiB
Python

"""AGENTS.md is loaded into every session; what it says about the skills must
match what ships."""
import re
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
AGENTS = (ROOT / "AGENTS.md").read_text(encoding="utf-8")
WORDS = {3: "Three", 4: "Four", 5: "Five", 6: "Six", 7: "Seven", 8: "Eight",
9: "Nine", 10: "Ten", 11: "Eleven", 12: "Twelve"}
def core_skills():
return sorted(p.name for p in (ROOT / ".agents/skills").iterdir() if (p / "SKILL.md").is_file())
def skills_with_scripts():
return sorted(p.name for p in (ROOT / ".agents/skills").iterdir() if list((p / "scripts").glob("*.py")))
class AgentsMd(unittest.TestCase):
def test_script_sentence_matches_disk(self):
m = re.search(r"(\w+) skills ship a deterministic Python script \(([^)]*)\)", AGENTS)
self.assertIsNotNone(m, "the 'N skills ship a deterministic Python script' sentence is missing")
named = sorted(re.findall(r"`(ckb-[\w-]+)`", m.group(2)))
self.assertEqual(named, skills_with_scripts())
self.assertEqual(m.group(1), WORDS.get(len(named)), "count word does not match the list")
def test_every_core_skill_is_routed(self):
routing = AGENTS.split("## 3. SKILL ROUTING", 1)[1].split("### Scripts", 1)[0]
missing = [s for s in core_skills() if f"`{s}`" not in routing]
self.assertEqual(missing, [], "skills with no routing-table row")
if __name__ == "__main__":
unittest.main()