fix(images): write note-relative image links in sources pages#181
Open
Aldominguez12 wants to merge 1 commit into
Open
fix(images): write note-relative image links in sources pages#181Aldominguez12 wants to merge 1 commit into
Aldominguez12 wants to merge 1 commit into
Conversation
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>
b5048e4 to
b95f054
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Short-doc source pages live at
wiki/sources/<doc>.mdbut embedded their images with wiki-root-relative links (). Markdown renderers resolve links relative to the containing file — Obsidian, GitHub, VS Code — so from a sources page every image resolved to the non-existentwiki/sources/sources/images/...and rendered broken. This breaks the "Opens in Obsidian" integration promised in the README for any document with figures.Fix
md_image_ref()helper emits note-relativeimages/<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.get_wiki_page_content/read_wiki_imageagainst the wiki root. The two conventions are now documented explicitly in the docstrings.read_wiki_image()retries note-relative paths undersources/, so agents can pass image paths verbatim as seen in either surface.wiki-schema.mdupdated to describe both path forms.Notes
Already-ingested KBs keep their old-style links (the
read_wiki_imagefallback 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
tests/test_images.pyexpectations plus newTestNoteRelativeResolution(generated links must resolve fromwiki/sources/<doc>.mdon disk) andTestReadWikiImage(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.pygreen;ruff check/formatandmypyclean on the touched modules.🤖 Generated with Claude Code