Files
troupe-standup/wizard-work/quill/verify-runbook.py
T

45 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Verify draft-incident-response-runbook-v0.2.md meets minimum standards."""
import re
import sys
from pathlib import Path
path = Path("/root/.hermes/wizard-outputs/quill/draft-incident-response-runbook-v0.2.md")
text = path.read_text()
checks = []
# 1) Title
checks.append(("title", bool(re.search(r"^#\s+.+", text, re.MULTILINE))))
# 2) At least 5 ## sections
section_count = len(re.findall(r"^##\s+.+", text, re.MULTILINE))
checks.append(("five_sections", section_count >= 5))
# 3) At least 3 shell commands (lines containing `$` or ```bash or ```sh)
shell_lines = [
line for line in text.splitlines()
if line.strip().startswith("`") and (
"`" in line[1:] or "$" in line
) and any(c in line for c in ["$", "```"])
]
# More reliable: count lines that contain backtick-wrapped commands
commands = re.findall(r"`([^`]+)`", text)
checks.append(("three_commands", len(commands) >= 3))
# 4) Verification section present
checks.append(("verification_section", "## Verification" in text))
failed = [name for name, ok in checks if not ok]
print(f"Checks passed: {len(checks) - len(failed)}/{len(checks)}")
for name, ok in checks:
print(f" {name}: {'PASS' if ok else 'FAIL'}")
if failed:
print(f"FAILED checks: {', '.join(failed)}")
sys.exit(1)
else:
print("All checks passed.")
sys.exit(0)