Sync metadata-rich resource tables
Browse filesMirror GitHub commit 522e3b4: organize all 509 resources into publication-aware tables and add deterministic README table validation.
- .github/workflows/quality.yml +3 -0
- CONTRIBUTING.md +6 -4
- README.md +0 -0
- data/README.md +3 -2
- data/resources.csv +0 -0
- data/resources.jsonl +0 -0
- meta/AWESOME_SUBMISSION.md +3 -0
- meta/CURATION.md +2 -2
- meta/MAINTENANCE.md +3 -0
- scripts/check_resource_labels.py +5 -9
- scripts/export_resource_dataset.py +43 -10
- scripts/render_readme_tables.py +201 -0
.github/workflows/quality.yml
CHANGED
|
@@ -48,6 +48,9 @@ jobs:
|
|
| 48 |
- name: Check resource type labels
|
| 49 |
run: python scripts/check_resource_labels.py README.md
|
| 50 |
|
|
|
|
|
|
|
|
|
|
| 51 |
- name: Check resource dataset export
|
| 52 |
run: python scripts/export_resource_dataset.py --check
|
| 53 |
|
|
|
|
| 48 |
- name: Check resource type labels
|
| 49 |
run: python scripts/check_resource_labels.py README.md
|
| 50 |
|
| 51 |
+
- name: Check README resource tables
|
| 52 |
+
run: python scripts/render_readme_tables.py --check
|
| 53 |
+
|
| 54 |
- name: Check resource dataset export
|
| 55 |
run: python scripts/export_resource_dataset.py --check
|
| 56 |
|
CONTRIBUTING.md
CHANGED
|
@@ -23,12 +23,14 @@ Maintainers will still apply the same scope, duplication, source-quality, and an
|
|
| 23 |
1. Search `README.md` for the resource title, author, project, and URL.
|
| 24 |
1. Confirm the resource is about AI/coding-agent Loop Engineering or a direct foundation for it.
|
| 25 |
1. Pick the most specific category.
|
| 26 |
-
1. Add one
|
| 27 |
|
| 28 |
```md
|
| 29 |
-
|
| 30 |
```
|
| 31 |
|
|
|
|
|
|
|
| 32 |
1. Open a PR using the template and explain:
|
| 33 |
- why the resource belongs;
|
| 34 |
- which category it updates;
|
|
@@ -130,13 +132,13 @@ Use the resource type legend from `README.md`:
|
|
| 130 |
Prefer:
|
| 131 |
|
| 132 |
```md
|
| 133 |
-
|
| 134 |
```
|
| 135 |
|
| 136 |
Avoid:
|
| 137 |
|
| 138 |
```md
|
| 139 |
-
|
| 140 |
```
|
| 141 |
|
| 142 |
## Adding A Loop Pattern
|
|
|
|
| 23 |
1. Search `README.md` for the resource title, author, project, and URL.
|
| 24 |
1. Confirm the resource is about AI/coding-agent Loop Engineering or a direct foundation for it.
|
| 25 |
1. Pick the most specific category.
|
| 26 |
+
1. Add one metadata-rich row with a resource type label, verified year/source context, and one specific key feature:
|
| 27 |
|
| 28 |
```md
|
| 29 |
+
| 📄 **[Title](https://example.com)**<br><sub>Paper</sub> | **2026** · arXiv<br><sub>First Author et al.</sub> | One sentence explaining the resource's contribution to Loop Engineering. |
|
| 30 |
```
|
| 31 |
|
| 32 |
+
Use `Undated` when the source does not expose a reliable publication date. Do not infer one from a search-result snippet. Maintainers regenerate the table layout and structured exports after review.
|
| 33 |
+
|
| 34 |
1. Open a PR using the template and explain:
|
| 35 |
- why the resource belongs;
|
| 36 |
- which category it updates;
|
|
|
|
| 132 |
Prefer:
|
| 133 |
|
| 134 |
```md
|
| 135 |
+
| 🔁 **[Autonomous Loops](https://example.com)**<br><sub>Pattern</sub> | **2026** · Example publisher | Shows how to combine task files, stop hooks, limits, and kill switches into a self-continuing agent loop. |
|
| 136 |
```
|
| 137 |
|
| 138 |
Avoid:
|
| 139 |
|
| 140 |
```md
|
| 141 |
+
| 📝 **[Cool Agent Article](https://example.com)**<br><sub>Blog</sub> | **Undated** · Example publisher | Interesting article about AI. |
|
| 142 |
```
|
| 143 |
|
| 144 |
## Adding A Loop Pattern
|
README.md
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/README.md
CHANGED
|
@@ -16,13 +16,14 @@ The main exports preserve the original section and annotation while adding three
|
|
| 16 |
|
| 17 |
`key_contribution`, `novelty`, and `impact` are resource-specific. `signal` states the evidence basis and its limits; GitHub stars and forks are reported as current context, never as proof of reliability. Signal strength is calibrated as `high` for primary official documentation and benchmarks, `medium` for inspectable implementations, papers, patterns, and repository-native artifacts, `contextual` for practitioner analysis and curated lists, and `unverified` only when the latest source audit cannot validate availability.
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
```sh
|
|
|
|
| 22 |
python3 scripts/export_resource_dataset.py
|
| 23 |
```
|
| 24 |
|
| 25 |
-
The export is deterministic and includes one row for every README
|
| 26 |
|
| 27 |
Run a network-backed source audit when refreshing the Hugging Face dataset:
|
| 28 |
|
|
|
|
| 16 |
|
| 17 |
`key_contribution`, `novelty`, and `impact` are resource-specific. `signal` states the evidence basis and its limits; GitHub stars and forks are reported as current context, never as proof of reliability. Signal strength is calibrated as `high` for primary official documentation and benchmarks, `medium` for inspectable implementations, papers, patterns, and repository-native artifacts, `contextual` for practitioner analysis and curated lists, and `unverified` only when the latest source audit cannot validate availability.
|
| 18 |
|
| 19 |
+
Render the README rows first, then regenerate all three discovery files after changing resource entries or refreshing the source audit:
|
| 20 |
|
| 21 |
```sh
|
| 22 |
+
python3 scripts/render_readme_tables.py
|
| 23 |
python3 scripts/export_resource_dataset.py
|
| 24 |
```
|
| 25 |
|
| 26 |
+
The export is deterministic and includes one row for every README resource-table row that follows the repository's curated entry format: marker, resource type, title, link, publication/source context, annotation, section, and source line.
|
| 27 |
|
| 28 |
Run a network-backed source audit when refreshing the Hugging Face dataset:
|
| 29 |
|
data/resources.csv
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/resources.jsonl
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
meta/AWESOME_SUBMISSION.md
CHANGED
|
@@ -31,6 +31,9 @@ npx --yes awesome-lint https://github.com/ChaoYue0307/awesome-loop-engineering
|
|
| 31 |
npx --yes markdownlint-cli2 "**/*.md"
|
| 32 |
python3 scripts/check_license.py
|
| 33 |
python3 scripts/check_resource_labels.py README.md
|
|
|
|
|
|
|
|
|
|
| 34 |
python3 scripts/check_loop_contract_examples.py
|
| 35 |
python3 scripts/check_pages_metadata.py
|
| 36 |
python3 scripts/check_internal_links.py
|
|
|
|
| 31 |
npx --yes markdownlint-cli2 "**/*.md"
|
| 32 |
python3 scripts/check_license.py
|
| 33 |
python3 scripts/check_resource_labels.py README.md
|
| 34 |
+
python3 scripts/render_readme_tables.py --check
|
| 35 |
+
python3 scripts/export_resource_dataset.py --check
|
| 36 |
+
python3 scripts/check_publication_metadata.py
|
| 37 |
python3 scripts/check_loop_contract_examples.py
|
| 38 |
python3 scripts/check_pages_metadata.py
|
| 39 |
python3 scripts/check_internal_links.py
|
meta/CURATION.md
CHANGED
|
@@ -50,13 +50,13 @@ Each annotation should answer: **why does this matter for Loop Engineering?**
|
|
| 50 |
Good:
|
| 51 |
|
| 52 |
```md
|
| 53 |
-
|
| 54 |
```
|
| 55 |
|
| 56 |
Weak:
|
| 57 |
|
| 58 |
```md
|
| 59 |
-
|
| 60 |
```
|
| 61 |
|
| 62 |
## Resource Type Labels
|
|
|
|
| 50 |
Good:
|
| 51 |
|
| 52 |
```md
|
| 53 |
+
| 🔁 **[Autonomous Loops](https://example.com)**<br><sub>Pattern</sub> | **2026** · Example publisher | Shows how task files, stop hooks, hard limits, and a kill switch form a self-continuing agent loop. |
|
| 54 |
```
|
| 55 |
|
| 56 |
Weak:
|
| 57 |
|
| 58 |
```md
|
| 59 |
+
| 📝 **[Cool Agent Article](https://example.com)**<br><sub>Blog</sub> | **Undated** · Example publisher | Interesting article about agents. |
|
| 60 |
```
|
| 61 |
|
| 62 |
## Resource Type Labels
|
meta/MAINTENANCE.md
CHANGED
|
@@ -69,6 +69,9 @@ npx --yes markdownlint-cli2 "**/*.md"
|
|
| 69 |
python3 -m py_compile scripts/*.py
|
| 70 |
python3 scripts/check_license.py
|
| 71 |
python3 scripts/check_resource_labels.py README.md
|
|
|
|
|
|
|
|
|
|
| 72 |
python3 scripts/check_loop_contract_examples.py
|
| 73 |
python3 scripts/check_pages_metadata.py
|
| 74 |
python3 scripts/check_internal_links.py
|
|
|
|
| 69 |
python3 -m py_compile scripts/*.py
|
| 70 |
python3 scripts/check_license.py
|
| 71 |
python3 scripts/check_resource_labels.py README.md
|
| 72 |
+
python3 scripts/render_readme_tables.py --check
|
| 73 |
+
python3 scripts/export_resource_dataset.py --check
|
| 74 |
+
python3 scripts/check_publication_metadata.py
|
| 75 |
python3 scripts/check_loop_contract_examples.py
|
| 76 |
python3 scripts/check_pages_metadata.py
|
| 77 |
python3 scripts/check_internal_links.py
|
scripts/check_resource_labels.py
CHANGED
|
@@ -4,10 +4,11 @@
|
|
| 4 |
from __future__ import annotations
|
| 5 |
|
| 6 |
import argparse
|
| 7 |
-
import re
|
| 8 |
import sys
|
| 9 |
from pathlib import Path
|
| 10 |
|
|
|
|
|
|
|
| 11 |
|
| 12 |
RESOURCE_SECTIONS = {
|
| 13 |
"Canonical Definition",
|
|
@@ -35,12 +36,6 @@ RESOURCE_SECTIONS = {
|
|
| 35 |
"Adjacent Awesome Lists",
|
| 36 |
}
|
| 37 |
|
| 38 |
-
LABEL_RE = re.compile(
|
| 39 |
-
r"^- (📄|📝|📚|🧰|🧪|🔁|🧾|🧭|⚠️) "
|
| 40 |
-
r"\*\*(Paper|Blog|Docs|Tool|Benchmark|Pattern|Template|List|Critique)\*\* "
|
| 41 |
-
)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
def check_readme(path: Path) -> list[tuple[int, str]]:
|
| 45 |
failures: list[tuple[int, str]] = []
|
| 46 |
current_section = ""
|
|
@@ -53,13 +48,14 @@ def check_readme(path: Path) -> list[tuple[int, str]]:
|
|
| 53 |
if current_section not in RESOURCE_SECTIONS:
|
| 54 |
continue
|
| 55 |
|
| 56 |
-
if not line.startswith("- "):
|
| 57 |
continue
|
| 58 |
|
| 59 |
if "](http" not in line and "](" not in line:
|
| 60 |
continue
|
| 61 |
|
| 62 |
-
|
|
|
|
| 63 |
failures.append((line_number, line))
|
| 64 |
|
| 65 |
return failures
|
|
|
|
| 4 |
from __future__ import annotations
|
| 5 |
|
| 6 |
import argparse
|
|
|
|
| 7 |
import sys
|
| 8 |
from pathlib import Path
|
| 9 |
|
| 10 |
+
from export_resource_dataset import TYPE_MARKERS, parse_entry_line
|
| 11 |
+
|
| 12 |
|
| 13 |
RESOURCE_SECTIONS = {
|
| 14 |
"Canonical Definition",
|
|
|
|
| 36 |
"Adjacent Awesome Lists",
|
| 37 |
}
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
def check_readme(path: Path) -> list[tuple[int, str]]:
|
| 40 |
failures: list[tuple[int, str]] = []
|
| 41 |
current_section = ""
|
|
|
|
| 48 |
if current_section not in RESOURCE_SECTIONS:
|
| 49 |
continue
|
| 50 |
|
| 51 |
+
if not line.startswith(("- ", "| ")):
|
| 52 |
continue
|
| 53 |
|
| 54 |
if "](http" not in line and "](" not in line:
|
| 55 |
continue
|
| 56 |
|
| 57 |
+
entry = parse_entry_line(line)
|
| 58 |
+
if not entry or TYPE_MARKERS.get(entry["resource_type"]) != entry["marker"]:
|
| 59 |
failures.append((line_number, line))
|
| 60 |
|
| 61 |
return failures
|
scripts/export_resource_dataset.py
CHANGED
|
@@ -37,9 +37,26 @@ ENTRY_RE = re.compile(
|
|
| 37 |
r"^- (?P<marker>\S+) \*\*(?P<resource_type>[^*]+)\*\* "
|
| 38 |
r"\[(?P<title>[^\]]+)\]\((?P<url>[^)]+)\) - (?P<annotation>.+)$"
|
| 39 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
HEADING_RE = re.compile(r"^(?P<level>#{2,3}) (?P<title>.+)$")
|
| 41 |
NON_SLUG_RE = re.compile(r"[^a-z0-9]+")
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
FIELDS = [
|
| 44 |
"row_id",
|
| 45 |
"section",
|
|
@@ -296,6 +313,22 @@ def clean(value: str) -> str:
|
|
| 296 |
return " ".join(value.strip().split())
|
| 297 |
|
| 298 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
def classify_url(url: str) -> tuple[str, str]:
|
| 300 |
parsed = urlparse(url)
|
| 301 |
if parsed.scheme in {"http", "https"}:
|
|
@@ -455,17 +488,17 @@ def iter_rows(readme_path: Path = README) -> list[dict[str, str]]:
|
|
| 455 |
section_slug = slugify(section)
|
| 456 |
continue
|
| 457 |
|
| 458 |
-
|
| 459 |
-
if not
|
| 460 |
continue
|
| 461 |
|
| 462 |
-
url = clean(
|
| 463 |
if "example.com" in url:
|
| 464 |
continue
|
| 465 |
|
| 466 |
url_kind, domain = classify_url(url)
|
| 467 |
-
annotation = clean(
|
| 468 |
-
resource_type = clean(
|
| 469 |
row_number = len(rows) + 1
|
| 470 |
row_id = f"ale-{row_number:04d}"
|
| 471 |
collection, user_goal = collection_for(section)
|
|
@@ -478,16 +511,16 @@ def iter_rows(readme_path: Path = README) -> list[dict[str, str]]:
|
|
| 478 |
"section": section,
|
| 479 |
"section_slug": section_slug,
|
| 480 |
"resource_type": resource_type,
|
| 481 |
-
"marker": clean(
|
| 482 |
-
"title": clean(
|
| 483 |
"url": url,
|
| 484 |
"url_kind": url_kind,
|
| 485 |
"domain": domain,
|
| 486 |
"annotation": annotation,
|
| 487 |
"description": annotation,
|
| 488 |
"key_contribution": key_contribution(annotation),
|
| 489 |
-
"novelty": novelty(section, clean(
|
| 490 |
-
"impact": impact(collection, clean(
|
| 491 |
"signal": signal_text,
|
| 492 |
"signal_strength": signal_strength,
|
| 493 |
"source_readme": "README.md",
|
|
@@ -497,7 +530,7 @@ def iter_rows(readme_path: Path = README) -> list[dict[str, str]]:
|
|
| 497 |
"collection": collection,
|
| 498 |
"collection_slug": slugify(collection),
|
| 499 |
"user_goal": user_goal,
|
| 500 |
-
"lifecycle_stages": lifecycle_stages(section, clean(
|
| 501 |
"audience": audience_for(section, resource_type),
|
| 502 |
"evidence_class": evidence,
|
| 503 |
"source_status": audit.get("audit_status", "not-audited"),
|
|
|
|
| 37 |
r"^- (?P<marker>\S+) \*\*(?P<resource_type>[^*]+)\*\* "
|
| 38 |
r"\[(?P<title>[^\]]+)\]\((?P<url>[^)]+)\) - (?P<annotation>.+)$"
|
| 39 |
)
|
| 40 |
+
TABLE_ENTRY_RE = re.compile(
|
| 41 |
+
r"^\| (?P<marker>\S+) \*\*\[(?P<title>[^\]]+)\]\((?P<url>[^)]+)\)\*\*"
|
| 42 |
+
r"<br><sub>(?P<resource_type>[^<]+)</sub>\s+\| (?P<metadata>.*?) \| "
|
| 43 |
+
r"(?P<annotation>.+) \|$"
|
| 44 |
+
)
|
| 45 |
HEADING_RE = re.compile(r"^(?P<level>#{2,3}) (?P<title>.+)$")
|
| 46 |
NON_SLUG_RE = re.compile(r"[^a-z0-9]+")
|
| 47 |
|
| 48 |
+
TYPE_MARKERS = {
|
| 49 |
+
"Paper": "📄",
|
| 50 |
+
"Blog": "📝",
|
| 51 |
+
"Docs": "📚",
|
| 52 |
+
"Tool": "🧰",
|
| 53 |
+
"Benchmark": "🧪",
|
| 54 |
+
"Pattern": "🔁",
|
| 55 |
+
"Template": "🧾",
|
| 56 |
+
"List": "🧭",
|
| 57 |
+
"Critique": "⚠️",
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
FIELDS = [
|
| 61 |
"row_id",
|
| 62 |
"section",
|
|
|
|
| 313 |
return " ".join(value.strip().split())
|
| 314 |
|
| 315 |
|
| 316 |
+
def parse_entry_line(raw_line: str) -> dict[str, str] | None:
|
| 317 |
+
"""Parse the legacy list syntax or the current tabular resource-row syntax."""
|
| 318 |
+
match = ENTRY_RE.match(raw_line)
|
| 319 |
+
if match:
|
| 320 |
+
return match.groupdict()
|
| 321 |
+
|
| 322 |
+
match = TABLE_ENTRY_RE.match(raw_line)
|
| 323 |
+
if not match:
|
| 324 |
+
return None
|
| 325 |
+
|
| 326 |
+
entry = match.groupdict()
|
| 327 |
+
for field in ("title", "url", "annotation"):
|
| 328 |
+
entry[field] = entry[field].replace(r"\|", "|")
|
| 329 |
+
return entry
|
| 330 |
+
|
| 331 |
+
|
| 332 |
def classify_url(url: str) -> tuple[str, str]:
|
| 333 |
parsed = urlparse(url)
|
| 334 |
if parsed.scheme in {"http", "https"}:
|
|
|
|
| 488 |
section_slug = slugify(section)
|
| 489 |
continue
|
| 490 |
|
| 491 |
+
entry = parse_entry_line(raw_line)
|
| 492 |
+
if not entry:
|
| 493 |
continue
|
| 494 |
|
| 495 |
+
url = clean(entry["url"])
|
| 496 |
if "example.com" in url:
|
| 497 |
continue
|
| 498 |
|
| 499 |
url_kind, domain = classify_url(url)
|
| 500 |
+
annotation = clean(entry["annotation"])
|
| 501 |
+
resource_type = clean(entry["resource_type"])
|
| 502 |
row_number = len(rows) + 1
|
| 503 |
row_id = f"ale-{row_number:04d}"
|
| 504 |
collection, user_goal = collection_for(section)
|
|
|
|
| 511 |
"section": section,
|
| 512 |
"section_slug": section_slug,
|
| 513 |
"resource_type": resource_type,
|
| 514 |
+
"marker": clean(entry["marker"]),
|
| 515 |
+
"title": clean(entry["title"]),
|
| 516 |
"url": url,
|
| 517 |
"url_kind": url_kind,
|
| 518 |
"domain": domain,
|
| 519 |
"annotation": annotation,
|
| 520 |
"description": annotation,
|
| 521 |
"key_contribution": key_contribution(annotation),
|
| 522 |
+
"novelty": novelty(section, clean(entry["title"]), annotation),
|
| 523 |
+
"impact": impact(collection, clean(entry["title"])),
|
| 524 |
"signal": signal_text,
|
| 525 |
"signal_strength": signal_strength,
|
| 526 |
"source_readme": "README.md",
|
|
|
|
| 530 |
"collection": collection,
|
| 531 |
"collection_slug": slugify(collection),
|
| 532 |
"user_goal": user_goal,
|
| 533 |
+
"lifecycle_stages": lifecycle_stages(section, clean(entry["title"]), annotation),
|
| 534 |
"audience": audience_for(section, resource_type),
|
| 535 |
"evidence_class": evidence,
|
| 536 |
"source_status": audit.get("audit_status", "not-audited"),
|
scripts/render_readme_tables.py
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Render README resources as compact, metadata-rich Markdown tables."""
|
| 3 |
+
|
| 4 |
+
from __future__ import annotations
|
| 5 |
+
|
| 6 |
+
import argparse
|
| 7 |
+
import sys
|
| 8 |
+
from collections import Counter
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
from export_resource_dataset import README, TYPE_MARKERS, iter_rows
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
TABLE_HEADERS = ("Resource", "Publication / source", "Key feature")
|
| 15 |
+
SUMMARY_START = "<!-- resource-type-summary:start -->"
|
| 16 |
+
SUMMARY_END = "<!-- resource-type-summary:end -->"
|
| 17 |
+
|
| 18 |
+
TYPE_DESCRIPTIONS = {
|
| 19 |
+
"Paper": "Academic paper, preprint, or technical report",
|
| 20 |
+
"Blog": "Essay, field note, article, or practitioner write-up",
|
| 21 |
+
"Docs": "Official product, API, SDK, or platform documentation",
|
| 22 |
+
"Tool": "Repository, framework, SDK, runtime, or implementation",
|
| 23 |
+
"Benchmark": "Benchmark, eval suite, leaderboard, or evaluation dataset",
|
| 24 |
+
"Pattern": "Operational playbook or reusable workflow",
|
| 25 |
+
"Template": "Template, checklist, schema, guide, or contribution artifact",
|
| 26 |
+
"List": "Adjacent awesome list, ecosystem map, or curated collection",
|
| 27 |
+
"Critique": "Risk analysis, limitation, caveat, or skeptical take",
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
GITHUB_OWNER_LABELS = {
|
| 31 |
+
"cloudflare": "Cloudflare",
|
| 32 |
+
"vercel": "Vercel",
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def escape_cell(value: str) -> str:
|
| 37 |
+
return value.replace("|", r"\|")
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def author_summary(authors: str) -> str:
|
| 41 |
+
names = [name.strip() for name in authors.split(";") if name.strip()]
|
| 42 |
+
if not names:
|
| 43 |
+
return ""
|
| 44 |
+
if len(names) == 1:
|
| 45 |
+
return names[0]
|
| 46 |
+
if len(names) == 2:
|
| 47 |
+
return f"{names[0]} & {names[1]}"
|
| 48 |
+
return f"{names[0]} et al."
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def publication_cell(row: dict[str, str]) -> str:
|
| 52 |
+
year = row["publication_year"] or "Undated"
|
| 53 |
+
resource_type = row["resource_type"]
|
| 54 |
+
details: list[str] = []
|
| 55 |
+
|
| 56 |
+
if row["github_repo"]:
|
| 57 |
+
source = "GitHub"
|
| 58 |
+
owner, separator, repository = row["github_repo"].partition("/")
|
| 59 |
+
owner = GITHUB_OWNER_LABELS.get(owner, owner)
|
| 60 |
+
details.append(f"{owner}{separator}{repository}")
|
| 61 |
+
license_id = row["github_license"]
|
| 62 |
+
if license_id and license_id != "NOASSERTION":
|
| 63 |
+
details.append(f"License: {license_id}")
|
| 64 |
+
else:
|
| 65 |
+
source = row["publication_venue"] or row["publisher"] or row["domain"] or "Source not stated"
|
| 66 |
+
if resource_type in {"Paper", "Benchmark", "Blog", "Critique"}:
|
| 67 |
+
author = author_summary(row["authors"])
|
| 68 |
+
if author:
|
| 69 |
+
details.append(author)
|
| 70 |
+
|
| 71 |
+
primary = f"**{escape_cell(year)}** · {escape_cell(source)}"
|
| 72 |
+
if details:
|
| 73 |
+
secondary = " · ".join(escape_cell(detail) for detail in details)
|
| 74 |
+
return f"{primary}<br><sub>{secondary}</sub>"
|
| 75 |
+
return primary
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def resource_cells(row: dict[str, str]) -> tuple[str, str, str]:
|
| 79 |
+
title = escape_cell(row["title"])
|
| 80 |
+
url = escape_cell(row["url"])
|
| 81 |
+
annotation = escape_cell(row["annotation"])
|
| 82 |
+
marker = escape_cell(row["marker"])
|
| 83 |
+
resource_type = escape_cell(row["resource_type"])
|
| 84 |
+
resource = f"{marker} **[{title}]({url})**<br><sub>{resource_type}</sub>"
|
| 85 |
+
return resource, publication_cell(row), annotation
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def markdown_table(headers: tuple[str, ...], data: list[tuple[str, ...]]) -> list[str]:
|
| 89 |
+
# Remark aligns source offsets as UTF-16 code units, matching JavaScript.
|
| 90 |
+
def source_length(value: str) -> int:
|
| 91 |
+
return len(value.encode("utf-16-le")) // 2
|
| 92 |
+
|
| 93 |
+
widths = [
|
| 94 |
+
max(source_length(headers[index]), *(source_length(row[index]) for row in data))
|
| 95 |
+
for index in range(len(headers))
|
| 96 |
+
]
|
| 97 |
+
|
| 98 |
+
def format_row(row: tuple[str, ...]) -> str:
|
| 99 |
+
cells = (
|
| 100 |
+
cell + " " * (width - source_length(cell))
|
| 101 |
+
for cell, width in zip(row, widths)
|
| 102 |
+
)
|
| 103 |
+
return "| " + " | ".join(cells) + " |"
|
| 104 |
+
|
| 105 |
+
separator = tuple("-" * max(3, width) for width in widths)
|
| 106 |
+
return [format_row(headers), format_row(separator), *(format_row(row) for row in data)]
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def is_resource_table_header(line: str) -> bool:
|
| 110 |
+
if not line.startswith("|"):
|
| 111 |
+
return False
|
| 112 |
+
cells = tuple(cell.strip() for cell in line.strip().strip("|").split("|"))
|
| 113 |
+
return cells == TABLE_HEADERS
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def is_table_separator(line: str) -> bool:
|
| 117 |
+
if not line.startswith("|"):
|
| 118 |
+
return False
|
| 119 |
+
cells = tuple(cell.strip() for cell in line.strip().strip("|").split("|"))
|
| 120 |
+
return len(cells) == len(TABLE_HEADERS) and all(
|
| 121 |
+
len(cell) >= 3 and not cell.strip("-") for cell in cells
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def summary_lines(rows: list[dict[str, str]]) -> list[str]:
|
| 126 |
+
counts = Counter(row["resource_type"] for row in rows)
|
| 127 |
+
data = []
|
| 128 |
+
for resource_type, marker in TYPE_MARKERS.items():
|
| 129 |
+
data.append(
|
| 130 |
+
(
|
| 131 |
+
f"{marker} **{resource_type}**",
|
| 132 |
+
str(counts[resource_type]),
|
| 133 |
+
TYPE_DESCRIPTIONS[resource_type],
|
| 134 |
+
)
|
| 135 |
+
)
|
| 136 |
+
return [SUMMARY_START, *markdown_table(("Type", "Rows", "Includes"), data), SUMMARY_END]
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def replace_summary(lines: list[str], rows: list[dict[str, str]]) -> list[str]:
|
| 140 |
+
try:
|
| 141 |
+
start = lines.index(SUMMARY_START)
|
| 142 |
+
end = lines.index(SUMMARY_END, start + 1)
|
| 143 |
+
except ValueError as error:
|
| 144 |
+
raise RuntimeError("README resource-type summary markers are missing") from error
|
| 145 |
+
return lines[:start] + summary_lines(rows) + lines[end + 1 :]
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
def render_readme(readme_path: Path = README) -> str:
|
| 149 |
+
rows = iter_rows(readme_path)
|
| 150 |
+
rows_by_line = {int(row["source_line"]): row for row in rows}
|
| 151 |
+
lines = readme_path.read_text(encoding="utf-8").splitlines()
|
| 152 |
+
output: list[str] = []
|
| 153 |
+
index = 0
|
| 154 |
+
|
| 155 |
+
while index < len(lines):
|
| 156 |
+
line = lines[index]
|
| 157 |
+
if is_resource_table_header(line):
|
| 158 |
+
index += 1
|
| 159 |
+
if index < len(lines) and is_table_separator(lines[index]):
|
| 160 |
+
index += 1
|
| 161 |
+
continue
|
| 162 |
+
|
| 163 |
+
row = rows_by_line.get(index + 1)
|
| 164 |
+
if row:
|
| 165 |
+
run: list[tuple[str, ...]] = []
|
| 166 |
+
while index < len(lines):
|
| 167 |
+
row = rows_by_line.get(index + 1)
|
| 168 |
+
if not row:
|
| 169 |
+
break
|
| 170 |
+
run.append(resource_cells(row))
|
| 171 |
+
index += 1
|
| 172 |
+
output.extend(markdown_table(TABLE_HEADERS, run))
|
| 173 |
+
continue
|
| 174 |
+
|
| 175 |
+
output.append(line)
|
| 176 |
+
index += 1
|
| 177 |
+
|
| 178 |
+
output = replace_summary(output, rows)
|
| 179 |
+
return "\n".join(output) + "\n"
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def main() -> int:
|
| 183 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 184 |
+
parser.add_argument("--check", action="store_true", help="fail when README tables are stale")
|
| 185 |
+
args = parser.parse_args()
|
| 186 |
+
|
| 187 |
+
rendered = render_readme()
|
| 188 |
+
current = README.read_text(encoding="utf-8")
|
| 189 |
+
if args.check:
|
| 190 |
+
if rendered != current:
|
| 191 |
+
print("README resource tables are stale; run scripts/render_readme_tables.py", file=sys.stderr)
|
| 192 |
+
return 1
|
| 193 |
+
return 0
|
| 194 |
+
|
| 195 |
+
README.write_text(rendered, encoding="utf-8")
|
| 196 |
+
print(f"Rendered {len(iter_rows())} resource rows in {README.name}")
|
| 197 |
+
return 0
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
if __name__ == "__main__":
|
| 201 |
+
raise SystemExit(main())
|