MCPcopy
hub / github.com/github/awesome-copilot / lint_wiki

Function lint_wiki

skills/mini-context-graph/scripts/tools/wiki_store.py:248–294  ·  view source on GitHub ↗

Health-check the wiki as described in Karpathy's LLM Wiki pattern. Checks for: - Orphan pages (in directory but not in index) - Missing pages (in index but file deleted) - Broken wikilinks ([[slug]] pointing to non-existent file) - Pages with no wikilinks (isolated pages)

()

Source from the content-addressed store, hash-verified

246
247
248def lint_wiki() -> dict:
249 """
250 Health-check the wiki as described in Karpathy's LLM Wiki pattern.
251
252 Checks for:
253 - Orphan pages (in directory but not in index)
254 - Missing pages (in index but file deleted)
255 - Broken wikilinks ([[slug]] pointing to non-existent file)
256 - Pages with no wikilinks (isolated pages)
257
258 Returns:
259 {
260 "orphan_pages": [...],
261 "missing_pages": [...],
262 "broken_wikilinks": {slug: [broken_links]},
263 "isolated_pages": [...],
264 }
265 """
266 index_entries = {e["slug"] for e in _load_index()}
267 file_slugs: dict[str, Path] = {}
268 for d in _CATEGORY_DIRS.values():
269 if d.exists():
270 for p in d.glob("*.md"):
271 file_slugs[p.stem] = p
272
273 orphans = [s for s in file_slugs if s not in index_entries]
274 missing = [s for s in index_entries if s not in file_slugs]
275
276 broken_wikilinks: dict[str, list[str]] = {}
277 isolated: list[str] = []
278 all_slugs = set(file_slugs.keys())
279
280 for slug, path in file_slugs.items():
281 content = path.read_text()
282 links = re.findall(r"\[\[([^\]]+)\]\]", content)
283 if not links:
284 isolated.append(slug)
285 broken = [lnk for lnk in links if _slug(lnk) not in all_slugs]
286 if broken:
287 broken_wikilinks[slug] = broken
288
289 return {
290 "orphan_pages": orphans,
291 "missing_pages": missing,
292 "broken_wikilinks": broken_wikilinks,
293 "isolated_pages": isolated,
294 }

Callers

nothing calls this directly

Calls 2

_load_indexFunction · 0.85
_slugFunction · 0.85

Tested by

no test coverage detected