Skip to content

Fix #228: emit mixed [[label]](filename.md) wiki links for non-Obsidian agents - #674

Open
azizur100389 wants to merge 1 commit into
Graphify-Labs:v6from
azizur100389:fix/issue-228-wiki-mixed-wikilink-format
Open

azizur100389 wants to merge 1 commit into
Graphify-Labs:v6from
azizur100389:fix/issue-228-wiki-mixed-wikilink-format

Conversation

@azizur100389

Copy link
Copy Markdown
Contributor

Summary

Issue #228 reports that the wiki's --wiki output is described as "agent-crawlable", but the wikilinks emitted in index.md and inside articles use bare Obsidian syntax:

- [[API: Auth & Session Layer]] — 38 nodes

The actual file on disk is API-_Auth_&_Session_Layer.md (via _safe_filename substitutions). Any agent not running inside Obsidian — an LLM reading files from a git clone, a plain markdown renderer, GitHub's web view, etc. — sees the wikilink and cannot resolve it to a file path.

This PR switches every wiki-internal reference to a known article to the mixed form:

- [[API: Auth & Session Layer]](API-_Auth_&_Session_Layer.md) — 38 nodes

Obsidian still parses the [[…]] portion as a wikilink (so internal navigation in Obsidian is unchanged); standard markdown viewers and agents follow the explicit relative path. References to nodes that don't have their own article (regular neighbors of a god node) keep the bare [[label]] form — emitting a path to a non-existent file would break agent navigation worse than the bare wikilink.

Touch points

  • index.md community list
  • index.md god-node list
  • Cross-community links inside community articles
  • "Community: …" link at the top of god-node articles

Implementation

  • New _wikilink(label, slug_map) helper picks between the two forms based on whether the label maps to a real filename.
  • to_wiki() pre-computes the full slug_map before any article is written so cross-references resolve correctly regardless of generation order.
  • Slug map is threaded through _index_md / _community_article / _god_node_article (each gains a slug_map kwarg, defaulting to None for backward compatibility).

Closes #228

Test plan

6 new tests in tests/test_wiki.py (all 21 wiki tests pass):

  • test_index_uses_mixed_wikilink_for_communities
  • test_index_uses_mixed_wikilink_for_god_nodes
  • test_community_article_cross_links_use_mixed_format
  • test_god_node_article_community_link_is_mixed
  • test_neighbor_without_article_keeps_bare_wikilink — guards the non-article fallback
  • test_filenames_unique_under_collisions — every link in index.md must resolve to an existing file even when _safe_filename collides

All existing wiki tests still pass; backward-compatible with Obsidian parsers.

…ents (Graphify-Labs#228)

Wiki articles previously emitted bare Obsidian wikilinks like
[[API: Auth & Session Layer]] for community and god-node references.
The actual file on disk is the result of _safe_filename(), which
applies non-trivial substitutions (spaces -> _, : -> -, etc). An agent
that isn't running inside Obsidian (e.g. an LLM reading files from a
git clone, or any Markdown renderer) sees the wikilink and has no way
to follow it - the transformation rules aren't documented in the output.

Switch every wiki-internal reference to a known article to the mixed
form [[label]](filename.md). Obsidian still parses the [[label]]
portion as a wikilink, while standard markdown renderers and agents
follow the explicit relative path. References to nodes that don't
have their own article (regular neighbors of a god node) keep the
bare [[label]] form - emitting a path to a non-existent file would
break agent navigation worse than the bare wikilink.

Implementation:
- Add a _wikilink(label, slug_map) helper that picks between the two
  forms based on whether the label maps to an actual filename.
- Pre-compute the full slug_map at the top of to_wiki() so cross-
  references resolve correctly even when articles are written in any
  order.
- Pass slug_map through to _index_md / _community_article /
  _god_node_article so all four touch points emit consistent links.

6 new tests in tests/test_wiki.py cover index links (communities +
god nodes), cross-community links, the god-node-to-community link,
the bare-wikilink fallback for unlinked neighbors, and a regression
guard that every filename referenced by index.md actually exists on
disk even under _safe_filename collisions.
@Qodo-Free-For-OSS

Copy link
Copy Markdown

Hi, _wikilink() interpolates label directly into [[...]](slug.md) without escaping, so labels containing ], ), or newlines can produce malformed markdown/wikilinks and break navigation/rendering for those entries.

Severity: remediation recommended | Category: maintainability

How to fix: Escape label for markdown

Agent prompt to fix - you can give this to your LLM of choice:

Issue description

_wikilink() should render mixed links robustly even if labels contain markdown-special characters.

Issue Context

Filenames are sanitized via _safe_filename(), but the label is inserted into the markdown link text and Obsidian [[...]] syntax verbatim.

Fix Focus Areas

  • graphify/wiki.py[24-32]
    • Escape or sanitize label for safe inclusion inside [[...]] and markdown link text (at minimum handle ], ), and newlines). Consider a small helper that replaces these characters or strips newlines before formatting.

Found by Qodo code review

This branch has not been deployed

No deployments
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.

[wiki] index.md: use mixed wikilink+markdown format for agent navigation outside Obsidian

2 participants