"""Check a PRD has every required section, non-empty.
Usage: check_prd.py <prd.md>
REQUIRED = ["Problem", "Goals", "Requirements", "Success Metrics", "Scope", "Open Questions"]
print("Usage: check_prd.py <prd.md>", file=sys.stderr)
text = open(sys.argv[1], encoding="utf-8").read()
headings = re.split(r"^#{1,3}\s+", text, flags=re.MULTILINE)
match = re.search(rf"^#{{1,3}}\s+.*{re.escape(section)}.*$", text, re.IGNORECASE | re.MULTILINE)
print(f"❌ missing required section: {section}")
next_heading = re.search(r"\n#{1,3}\s", rest)
body = rest[:next_heading.start()] if next_heading else rest
print(f"❌ section '{section}' present but empty")
print(f"✅ section '{section}' present and non-empty")
if __name__ == "__main__":