A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
repo: Markdown link check, dead relative links fail (fixes #333) (#334)
agamrafaeli-instinct7788ba83e133
diff --git a/.github/skills/statecraft-historical-content/SKILL.md b/.github/skills/statecraft-historical-content/SKILL.mdindex b4fd69bf3..0694403e7 100644--- a/.github/skills/statecraft-historical-content/SKILL.md+++ b/.github/skills/statecraft-historical-content/SKILL.md@@ -19,11 +19,11 @@ disable-model-invocation: falseBefore drafting, read these first:-- [README.md](../../README.md)-- [CONTRIBUTING.md](../../CONTRIBUTING.md)-- [docs/CONTENT_POLICY.md](../../docs/CONTENT_POLICY.md)-- [docs/WRITING_EVENTS.md](../../docs/WRITING_EVENTS.md)-- [docs/WRITING_GUIDE.md](../../docs/WRITING_GUIDE.md)+- [README.md](../../../README.md)+- [CONTRIBUTING.md](../../../CONTRIBUTING.md)+- [docs/CONTENT_POLICY.md](../../../docs/CONTENT_POLICY.md)+- [docs/WRITING_EVENTS.md](../../../docs/WRITING_EVENTS.md)+- [docs/WRITING_GUIDE.md](../../../docs/WRITING_GUIDE.md)## Mandatory workflow@@ -63,7 +63,7 @@ This skill package is intentionally structured like a real agent skill bundle, n## References- [Historical writing guide](./references/historical-writing-checklist.md)-- [Content policy](../../docs/CONTENT_POLICY.md)-- [Event schema](../../docs/WRITING_EVENTS.md)+- [Content policy](../../../docs/CONTENT_POLICY.md)+- [Event schema](../../../docs/WRITING_EVENTS.md)- [Event draft template](./templates/event-draft.yaml)- [Source coverage script](./scripts/check_source_coverage.py)diff --git a/.github/skills/statecraft-writing-voice/SKILL.md b/.github/skills/statecraft-writing-voice/SKILL.mdindex c44769e6c..27d945e44 100644--- a/.github/skills/statecraft-writing-voice/SKILL.md+++ b/.github/skills/statecraft-writing-voice/SKILL.md@@ -63,9 +63,9 @@ This skill package is intentionally structured as a reusable agent workflow with## References-- [Writing guide](../../docs/WRITING_GUIDE.md)-- [Content policy](../../docs/CONTENT_POLICY.md)-- [Event writing rules](../../docs/WRITING_EVENTS.md)+- [Writing guide](../../../docs/WRITING_GUIDE.md)+- [Content policy](../../../docs/CONTENT_POLICY.md)+- [Event writing rules](../../../docs/WRITING_EVENTS.md)- [Tone rules](./references/tone-rules.md)- [Tone pass template](./templates/tone-pass-checklist.md)- [Phrase scan script](./scripts/scan_for_generic_ai_phrases.py)diff --git a/docs/dev-setup.md b/docs/dev-setup.mdindex ad6bdd83e..cbf0395cc 100644--- a/docs/dev-setup.md+++ b/docs/dev-setup.md@@ -23,6 +23,7 @@ Unity, a Unity licence and macOS are only needed for `unity/`. The sim, the cont| Policy checker tests | `uv run --with pytest==9.1.1 --with pyyaml==6.0.3 --with requests==2.32.5 pytest scripts/oss/tests -q` | Repo policy || Data tool tests (one runs the sim's release gate, so they need the .NET SDK too) | `uv run --with pytest==9.1.1 --with rasterio==1.5.2 --with numpy==2.5.3 --with pyyaml==6.0.3 --with pillow==12.3.0 --with requests==2.32.5 --with pyproj==3.8.0 pytest tools/tests -q` | Tools (pytest) || GDD feature sections (also run by the policy checker tests) | `uv run scripts/oss/gdd_lint.py` | Repo policy |+| Dead relative links in Markdown files (also run by the policy checker tests) | `uv run scripts/oss/md_links.py` | Repo policy || Changelog line | `uv run scripts/oss/changelog_check.py --base origin/main` | Changelog |`scripts/check.sh` runs all of them in one go, cheapest first, plus a sim build with warnings as errors. It stops at the first failure and shows the end of its output. It takes the base ref as its argument (default `origin/main`); set `CHECK_NO_CHANGELOG=1` if the PR has the `no-changelog` label.diff --git a/scripts/oss/md_links.py b/scripts/oss/md_links.pynew file mode 100644index 000000000..a1078c351--- /dev/null+++ b/scripts/oss/md_links.py@@ -0,0 +1,48 @@+#!/usr/bin/env python3+"""Markdown link check (#333): every relative link in a tracked *.md file must point at a file that exists.++`uv run scripts/oss/md_links.py [--root DIR]`. Ignores code fences, absolute URLs (any `scheme:`), `#anchor` and+`mailto:` links, and targets with brackets (reference-style leftovers). Anchors after `#` are not checked, only the file.+One line per dead link (file: link); exit 1 if any."""+import argparse+import os+import re+import subprocess+import sys+from pathlib import Path++ROOT = Path(__file__).resolve().parents[2]+LINK = re.compile(r"\[[^\]]*\]\(([^)\s]+)\)")+FENCE = re.compile(r"```.*?```", re.S)+++def tracked_markdown(root: Path) -> list[str]:+ out = subprocess.run(["git", "-C", str(root), "ls-files", "-z", "*.md"], capture_output=True, text=True, check=True).stdout+ return [f for f in out.split("\0") if f]+++def dead_links(root: Path) -> list[tuple[str, str]]:+ bad = []+ for f in tracked_markdown(root):+ text = FENCE.sub("", (root / f).read_text(encoding="utf-8"))+ for m in LINK.finditer(text):+ target = m.group(1)+ if re.match(r"[A-Za-z][A-Za-z0-9+.-]*:|#", target) or "[" in target:+ continue+ path = target.split("#")[0]+ if path and not (root / os.path.normpath(os.path.join(os.path.dirname(f), path))).exists():+ bad.append((f, target))+ return bad+++def main(argv: list[str] | None = None) -> int:+ p = argparse.ArgumentParser(description=__doc__.split("\n")[0])+ p.add_argument("--root", type=Path, default=ROOT)+ bad = dead_links(p.parse_args(argv).root)+ for f, t in bad:+ print(f"{f}: {t}")+ return 1 if bad else 0+++if __name__ == "__main__":+ sys.exit(main())diff --git a/scripts/oss/tests/test_md_links.py b/scripts/oss/tests/test_md_links.pynew file mode 100644index 000000000..09ff1e425--- /dev/null+++ b/scripts/oss/tests/test_md_links.py@@ -0,0 +1,28 @@+"""Markdown link check: a dead relative link is found; URLs, anchors, code fences and good links are not; the repo is clean."""+import importlib.util+from pathlib import Path++ROOT = Path(__file__).resolve().parents[3]+SPEC = importlib.util.spec_from_file_location('md_links', ROOT / 'scripts/oss/md_links.py')+m = importlib.util.module_from_spec(SPEC)+SPEC.loader.exec_module(m)+++def test_finds_only_dead_relative_links(make_repo, capsys):+ root = make_repo({+ 'README.md': '[ok](docs/a.md) [anchor](docs/a.md#x) [url](https://x.example/y) [mail](mailto:someone) [top](#t)\n'+ '```\n[in a fence](nope.md)\n```\n[ref][one] [odd](a[b])\n[dead](missing.md#s)\n',+ 'docs/a.md': '[up](../README.md) [bad](../../README.md)\n',+ })+ assert m.dead_links(root) == [('README.md', 'missing.md#s'), ('docs/a.md', '../../README.md')]+ assert m.main(['--root', str(root)]) == 1+ assert 'docs/a.md: ../../README.md' in capsys.readouterr().out+++def test_clean_repo_returns_zero(make_repo):+ root = make_repo({'README.md': '[a](a.md)\n', 'a.md': 'x\n'})+ assert m.main(['--root', str(root)]) == 0+++def test_this_repo_has_no_dead_relative_links():+ assert m.dead_links(ROOT) == []