Compare index.md wikilinks against actual files on disk. Returns issues for: - Links in index.md pointing to non-existent pages - Pages in summaries/, concepts/, or entities/ not mentioned in index.md Args: wiki: Path to the wiki root directory. Returns: List o
(wiki: Path)
| 417 | |
| 418 | |
| 419 | def check_index_sync(wiki: Path) -> list[str]: |
| 420 | """Compare index.md wikilinks against actual files on disk. |
| 421 | |
| 422 | Returns issues for: |
| 423 | - Links in index.md pointing to non-existent pages |
| 424 | - Pages in summaries/, concepts/, or entities/ not mentioned in index.md |
| 425 | |
| 426 | Args: |
| 427 | wiki: Path to the wiki root directory. |
| 428 | |
| 429 | Returns: |
| 430 | List of sync issue strings. |
| 431 | """ |
| 432 | index_path = wiki / "index.md" |
| 433 | issues: list[str] = [] |
| 434 | |
| 435 | if not index_path.exists(): |
| 436 | return ["index.md does not exist"] |
| 437 | |
| 438 | index_text = _read_md(index_path) |
| 439 | index_links = set(_extract_wikilinks(index_text)) |
| 440 | pages = _all_wiki_pages(wiki) |
| 441 | |
| 442 | # Check that all index links resolve |
| 443 | for lnk in index_links: |
| 444 | lnk_norm = lnk.strip().strip("/") |
| 445 | if lnk_norm not in pages: |
| 446 | issues.append(f"index.md links to missing page: [[{lnk}]]") |
| 447 | |
| 448 | # Check that summaries, concepts, and entities pages are mentioned in index |
| 449 | index_stems = {Path(lnk.strip()).stem for lnk in index_links} |
| 450 | index_text_lower = index_text.lower() |
| 451 | |
| 452 | for subdir in PAGE_CONTENT_DIRS: |
| 453 | subdir_path = wiki / subdir |
| 454 | if not subdir_path.exists(): |
| 455 | continue |
| 456 | for md in sorted(subdir_path.glob("*.md")): |
| 457 | stem = md.stem |
| 458 | if stem not in index_stems and stem.lower() not in index_text_lower: |
| 459 | issues.append(f"{subdir}/{stem}.md not mentioned in index.md") |
| 460 | |
| 461 | return sorted(issues) |
| 462 | |
| 463 | |
| 464 | def _load_wiki_pages(wiki: Path) -> dict[Path, str]: |