51 lines
2.2 KiB
Python
51 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Check packaged resource integrity; not a semantic or live-host test."""
|
|
import json
|
|
from pathlib import Path
|
|
import re
|
|
import sys
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def check() -> list:
|
|
errors = []
|
|
skill = ROOT / "skills/codex-subagent-router"
|
|
for name in ("SKILL.md", "agents/openai.yaml", "references/lifecycle.md",
|
|
"references/platforms.md", "references/evidence-packet.md",
|
|
"references/routing-matrix.md", "references/escalation.md",
|
|
"scripts/validate_decision_record.py", "scripts/validate_evidence_packet.py"):
|
|
if not (skill / name).is_file():
|
|
errors.append("missing skill resource: " + name)
|
|
entry = (skill / "SKILL.md").read_text(encoding="utf-8")
|
|
version = (ROOT / "VERSION").read_text(encoding="utf-8").strip()
|
|
if not re.fullmatch(r"\d+\.\d+\.\d+", version) or "Version " + version + "." not in entry:
|
|
errors.append("invalid or inconsistent package version")
|
|
if not re.match(r"\A---\nname: codex-subagent-router\ndescription: .+\n---\n", entry):
|
|
errors.append("invalid expected skill frontmatter")
|
|
metadata = (skill / "agents/openai.yaml").read_text(encoding="utf-8")
|
|
if "$codex-subagent-router" not in metadata:
|
|
errors.append("UI default prompt must name the skill")
|
|
for file in ROOT.rglob("*.md"):
|
|
if any(part in {".git", "work", "outputs", ".venv"} for part in file.relative_to(ROOT).parts):
|
|
continue
|
|
content = file.read_text(encoding="utf-8")
|
|
for target in re.findall(r"\[[^\]]*\]\(([^)]+)\)", content):
|
|
if "://" in target or target.startswith("#"):
|
|
continue
|
|
path = target.split("#", 1)[0]
|
|
if not (file.parent / path).exists():
|
|
errors.append(str(file.relative_to(ROOT)) + ": broken link " + target)
|
|
for fixture in (ROOT / "examples").glob("*.json"):
|
|
try:
|
|
json.loads(fixture.read_text(encoding="utf-8"))
|
|
except ValueError:
|
|
errors.append("invalid JSON: " + str(fixture.relative_to(ROOT)))
|
|
return errors
|
|
|
|
|
|
if __name__ == "__main__":
|
|
errors = check()
|
|
print("\n".join(errors) if errors else "Repository resource checks passed")
|
|
sys.exit(bool(errors))
|