#!/bin/sh # Verify that local Markdown links resolve inside the repository. set -eu TASK_ROOT=${ORBIT_ROOT_DIR:-.} python3 - "$TASK_ROOT" <<'PY' import re import sys from pathlib import Path root = Path(sys.argv[1]).resolve() missing = [] files = 0 for path in root.rglob("*.md"): if ".git" in path.parts or "bin" in path.parts: continue files += 1 text = path.read_text(encoding="utf-8") for raw in re.findall(r"\]\(([^)]+)\)", text): target = raw.strip() if target.startswith("<") and target.endswith(">"): target = target[1:-1] target = target.split("#", 1)[0].split("?", 1)[0] if not target or "://" in target or target.startswith(("mailto:", "/")): continue if not (path.parent / target).exists(): missing.append(f"{path.relative_to(root)}: {raw}") if missing: print("unresolved local Markdown links:", file=sys.stderr) print("\n".join(missing), file=sys.stderr) raise SystemExit(1) print(f'{{"markdown_files":{files},"local_links":"resolved"}}') PY