Markdown Page Links Implementation Plan
For Claude: REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
Goal: Retire authored wikilinks and derive page graph edges from normal Markdown links.
Architecture: Page documents own extraction from authored Markdown into page-link edges. The index stores those edges in a derived page_links table. Viewer rendering rewrites internal Markdown page links to SPA page routes while external links keep their normal href.
Tech Stack: Python 3.12, markdown-it-py, SQLite, pytest, Ruff.
Read Before Coding#
MANUAL.mdimplementation-tickets.md, Ticket 4almanac/architecture/wiki-tree.mdalmanac/architecture/indexing.mdsrc/codealmanac/services/wiki/documents.pysrc/codealmanac/services/viewer/renderer.py
Link Rules#
Authored page links are normal Markdown links:
[Source provenance](decisions/source-provenance)
[Wiki tree](../architecture/wiki-tree)Resolution rules:
- Page ids are paths under
almanac/without.md. - For a normal page, relative links resolve from that page's folder.
- For a folder
README.md, relative links resolve from that folder route. - External URLs and anchor-only links are not wiki page links.
- Repo files are not Markdown page links; file evidence belongs in
sources:. - Authored wikilinks are not parsed as graph edges.
Task 1: Add Markdown Page-Link Extraction#
Files:
- Create:
src/codealmanac/services/wiki/links.py - Modify:
src/codealmanac/services/wiki/documents.py - Modify:
src/codealmanac/services/wiki/models.py - Test:
tests/test_wiki_parsing.py - Test:
tests/test_read_model.py
Steps:
- Add a Markdown parser helper that walks inline
link_opentokens. - Resolve relative hrefs against the source page id.
- Ignore external URLs, anchor-only hrefs, paths with file extensions, and invalid
..escapes. - Use the helper in
load_page_document. - Remove wikilink extraction from page loading.
Task 2: Rename Derived Link Storage#
Files:
- Modify:
src/codealmanac/services/index/schema.py - Modify:
src/codealmanac/services/index/projection.py - Modify:
src/codealmanac/services/index/page_views.py - Modify:
src/codealmanac/services/index/health_graph_views.py - Modify:
src/codealmanac/services/index/models.py - Modify:
src/codealmanac/cli/render/pages.py - Modify:
src/codealmanac/services/viewer/service.py
Steps:
- Replace the derived
wikilinkstable withpage_links. - Rename
wikilinks_in/outmodel fields topage_links_in/out. - Keep CLI flags
--linksand--backlinks; only internal names change. - Keep health category name
broken_links, but read frompage_links.
Task 3: Render Markdown Page Links For Viewer#
Files:
- Modify:
src/codealmanac/services/viewer/renderer.py - Test:
tests/test_viewer_renderer.py - Test:
tests/test_viewer_service.py - Test:
tests/conftest.py
Steps:
- Pass the current page id into the Markdown renderer from viewer service.
- Rewrite internal page-link hrefs to
#/page/<page-id>during rendering. - Leave inline code and fenced code untouched through normal Markdown parsing.
- Remove wikilink-specific renderer tests.
Task 4: Update Guidance And Fixtures#
Files:
- Modify:
src/codealmanac/prompts/base/syntax.md - Modify:
src/codealmanac/manual/pages.md - Modify:
MANUAL.md - Modify:
notes.md - Modify:
almanac/architecture/indexing.md
Steps:
- Remove wikilink guidance from active prompts and manual pages.
- Update examples to use extensionless Markdown page links.
- Keep historical mentions only where they describe removed legacy behavior.
Verification#
Run:
uv run pytest tests/test_wiki_parsing.py tests/test_read_model.py tests/test_topics_health.py tests/test_viewer_renderer.py tests/test_viewer_service.py tests/test_cli.py tests/test_prompts.py tests/test_public_contract.py
uv run pytest
uv run ruff check .
tmp_home=$(mktemp -d); HOME="$tmp_home" uv run codealmanac health
rg "wikilinks|\\[\\[" src/codealmanac/services/wiki src/codealmanac/services/index src/codealmanac/services/viewer src/codealmanac/prompts src/codealmanac/manual tests almanac MANUAL.md README.md AGENTS.mdExpected:
- Markdown page links create backlinks and broken-link health findings.
- Authored wikilinks do not create page links.
- Viewer renders Markdown page links as local page navigation.
- No active prompt/manual/parser code teaches wikilinks.