Skip to content

fix(images): write note-relative image links in sources pages#181

Open
Aldominguez12 wants to merge 1 commit into
VectifyAI:mainfrom
Aldominguez12:fix/note-relative-image-links
Open

fix(images): write note-relative image links in sources pages#181
Aldominguez12 wants to merge 1 commit into
VectifyAI:mainfrom
Aldominguez12:fix/note-relative-image-links

Conversation

@Aldominguez12

Copy link
Copy Markdown
Contributor

Problem

Short-doc source pages live at wiki/sources/<doc>.md but embedded their images with wiki-root-relative links (![image](sources/images/<doc>/file.png)). Markdown renderers resolve links relative to the containing file — Obsidian, GitHub, VS Code — so from a sources page every image resolved to the non-existent wiki/sources/sources/images/... and rendered broken. This breaks the "Opens in Obsidian" integration promised in the README for any document with figures.

Fix

  • New md_image_ref() helper emits note-relative images/<doc>/... links, used by the three .md-visible writers (convert_pdf_with_images, extract_base64_images, copy_relative_images). These resolve correctly in Obsidian, GitHub, and VS Code.
  • Long-doc JSON page metadata keeps wiki-root-relative paths: it is internal, consumed by get_wiki_page_content / read_wiki_image against the wiki root. The two conventions are now documented explicitly in the docstrings.
  • read_wiki_image() retries note-relative paths under sources/, so agents can pass image paths verbatim as seen in either surface.
  • Query/skill-factory prompts and the openkb skill's wiki-schema.md updated to describe both path forms.

Notes

Already-ingested KBs keep their old-style links (the read_wiki_image fallback keeps agent flows working, but renderers still show them broken). A migration helper for existing sources pages would be a natural follow-up — happy to send it if there's interest.

Verification

  • Updated tests/test_images.py expectations plus new TestNoteRelativeResolution (generated links must resolve from wiki/sources/<doc>.md on disk) and TestReadWikiImage (both path forms, not-found, path escape).
  • pytest tests/test_images.py tests/test_agent_tools.py tests/test_converter.py tests/test_indexer.py tests/test_query.py tests/test_skill_creator.py tests/test_skill_tools.py tests/test_chat_session.py green; ruff check/format and mypy clean on the touched modules.

🤖 Generated with Claude Code

Short-doc source pages live at wiki/sources/<doc>.md but embedded
their images with wiki-root-relative links
(sources/images/<doc>/file.png). Markdown renderers resolve links
relative to the containing file — Obsidian, GitHub, VS Code — so
every image resolved to the non-existent
wiki/sources/sources/images/... and rendered broken.

- New md_image_ref() helper emits note-relative images/<doc>/...
  links, used by the three .md-visible writers
  (convert_pdf_with_images, extract_base64_images,
  copy_relative_images).
- Long-doc JSON page metadata keeps wiki-root-relative paths: it is
  internal, consumed by get_wiki_page_content/read_wiki_image against
  the wiki root. Now documented explicitly in the docstrings.
- read_wiki_image() retries note-relative paths under sources/, so
  agents can pass image paths verbatim as seen in either surface.
- Query/skill-factory prompts and the openkb skill's wiki-schema.md
  updated to describe both path forms.

Existing KBs keep their old-style links (the read_wiki_image fallback
does not cover them in renderers); a migration helper for already
ingested sources pages is left as a follow-up.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Aldominguez12 Aldominguez12 force-pushed the fix/note-relative-image-links branch from b5048e4 to b95f054 Compare July 12, 2026 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant