57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
from __future__ import annotations
|
|
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from claridoc.style_contracts import first_person_metrics, plain_form_ending_locations
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
AUTHOR_SKILL = ROOT / ".agents" / "skills" / "technical-document-author"
|
|
|
|
|
|
class RepositoryContractTests(unittest.TestCase):
|
|
def test_technical_author_skill_is_complete(self) -> None:
|
|
required_files = (
|
|
AUTHOR_SKILL / "SKILL.md",
|
|
AUTHOR_SKILL / "references" / "logic-contract.md",
|
|
AUTHOR_SKILL / "references" / "review-rubric.md",
|
|
AUTHOR_SKILL / "agents" / "openai.yaml",
|
|
)
|
|
for path in required_files:
|
|
with self.subTest(path=path.relative_to(ROOT)):
|
|
self.assertTrue(path.is_file())
|
|
|
|
skill_text = (AUTHOR_SKILL / "SKILL.md").read_text(encoding="utf-8")
|
|
for required_term in (
|
|
"Brief",
|
|
"SourcePack",
|
|
"STRUCTURE_SPECS",
|
|
"revising-korean-technical-prose",
|
|
"quality-gate.json",
|
|
"provenance",
|
|
):
|
|
with self.subTest(required_term=required_term):
|
|
self.assertIn(required_term, skill_text)
|
|
|
|
normalized = " ".join(skill_text.casefold().split())
|
|
self.assertIn("do not claim completion", normalized)
|
|
self.assertIn("lint", normalized)
|
|
self.assertIn("independent review", normalized)
|
|
self.assertIn("quality-gate", normalized)
|
|
|
|
def test_repository_readme_satisfies_korean_experience_contract(self) -> None:
|
|
text = (ROOT / "README.md").read_text(encoding="utf-8")
|
|
metrics = first_person_metrics(text)
|
|
|
|
self.assertEqual(plain_form_ending_locations(text), [])
|
|
self.assertTrue(metrics["opening_has_first_person"])
|
|
self.assertGreaterEqual(metrics["experience_section_coverage"], 0.5)
|
|
self.assertIn("STYLE002", text)
|
|
self.assertIn("STYLE003", text)
|
|
self.assertIn("examples/briefs/claridoc-readme.json", text)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|