61 lines
2.1 KiB
Python
61 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify draft-evidence-check skill and a sample draft."""
|
|
import re
|
|
import sys
|
|
import pathlib
|
|
|
|
def check_skill(path):
|
|
content = pathlib.Path(path).read_text()
|
|
errors = []
|
|
if not content.startswith("---"):
|
|
errors.append("SKILL.md missing leading ---")
|
|
if "name: draft-evidence-check" not in content:
|
|
errors.append("Missing name field")
|
|
if "description:" not in content:
|
|
errors.append("Missing description field")
|
|
if "## When to Use" not in content:
|
|
errors.append("Missing 'When to Use' section")
|
|
if "## Protocol" not in content:
|
|
errors.append("Missing 'Protocol' section")
|
|
if "## Verification" not in content:
|
|
errors.append("Missing 'Verification' section")
|
|
if "## Pitfalls" not in content:
|
|
errors.append("Missing 'Pitfalls' section")
|
|
return errors
|
|
|
|
def check_draft(path):
|
|
content = pathlib.Path(path).read_text()
|
|
errors = []
|
|
if "VERDICT:" not in content:
|
|
errors.append("Draft missing VERDICT: line")
|
|
if "CHECK:" not in content:
|
|
errors.append("Draft missing CHECK: line")
|
|
# Extract CHECK line
|
|
m = re.search(r'^CHECK:\s*(.+)$', content, re.MULTILINE)
|
|
if not m:
|
|
errors.append("Could not parse CHECK: line")
|
|
else:
|
|
cmd = m.group(1).strip()
|
|
if "|| true" in cmd or "|| echo" in cmd or "|| exit" in cmd:
|
|
errors.append("CHECK: line contains forbidden fallback arm")
|
|
if ";" in cmd and not cmd.startswith("#"):
|
|
errors.append("CHECK: line contains semicolon (not a bare command)")
|
|
return errors
|
|
|
|
if __name__ == "__main__":
|
|
skill_path = pathlib.Path(__file__).parent / "SKILL.md"
|
|
draft_path = pathlib.Path(__file__).parent / "sample-draft.md"
|
|
|
|
skill_errors = check_skill(skill_path)
|
|
draft_errors = check_draft(draft_path)
|
|
|
|
all_errors = skill_errors + draft_errors
|
|
if all_errors:
|
|
print("FAIL:")
|
|
for e in all_errors:
|
|
print(f" - {e}")
|
|
sys.exit(1)
|
|
else:
|
|
print("PASS: skill and draft meet evidence-check protocol")
|
|
sys.exit(0)
|