File size: 2,197 Bytes
549e098 1769aa9 549e098 3181a66 549e098 30cda2b 549e098 1769aa9 549e098 1769aa9 549e098 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #!/usr/bin/env python3
"""Ensure README resource entries carry a visible resource type label."""
from __future__ import annotations
import argparse
import sys
from pathlib import Path
from export_resource_dataset import TYPE_MARKERS, parse_entry_line
RESOURCE_SECTIONS = {
"Working Definition",
"Concept Guides",
"Start Here",
"Core Loop Primitives",
"Official Runtime Guides",
"Research Foundations",
"Agent Workflow Patterns",
"Coding-Agent Loop Systems",
"Verification And Feedback Gates",
"Securing Unattended Loops",
"State, Memory, And Context Persistence",
"Orchestration And Multi-Agent Delegation",
"Benchmarks And Evaluation",
"Operations Playbooks",
"Templates And Patterns",
"Examples And Schema",
"Community Gallery",
"Pattern Library",
"Explore And Reuse",
"Shape What Comes Next",
"Critiques, Risks, And Limitations",
"Adjacent Awesome Lists",
}
def check_readme(path: Path) -> list[tuple[int, str]]:
failures: list[tuple[int, str]] = []
current_section = ""
for line_number, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
if line.startswith("## "):
current_section = line.removeprefix("## ").strip()
continue
if current_section not in RESOURCE_SECTIONS:
continue
if not line.startswith(("- ", "| ")):
continue
if "](http" not in line and "](" not in line:
continue
entry = parse_entry_line(line)
if not entry or TYPE_MARKERS.get(entry["resource_type"]) != entry["marker"]:
failures.append((line_number, line))
return failures
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("readme", type=Path, default=Path("README.md"), nargs="?")
args = parser.parse_args()
failures = check_readme(args.readme)
if not failures:
return 0
print("Resource entries missing type labels:", file=sys.stderr)
for line_number, line in failures:
print(f"- line {line_number}: {line}", file=sys.stderr)
return 1
if __name__ == "__main__":
raise SystemExit(main())
|