Skip to content

[recipes] entity-wiki: emit real wikilinks and clickable thought-citation links in compiled wikis - #447

Open
araece wants to merge 1 commit into
NateBJones-Projects:mainfrom
araece:entity-wiki-links
Open

[recipes] entity-wiki: emit real wikilinks and clickable thought-citation links in compiled wikis#447
araece wants to merge 1 commit into
NateBJones-Projects:mainfrom
araece:entity-wiki-links

Conversation

@araece

@araece araece commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Compiled wikis contain no link syntax at all. The synthesis prompt never asks the LLM for links, and the LLM never sees target filenames (slugs are computed later, at write time), so:

  • Relationships sections are inert plain text — in Obsidian, nothing on an entity page is navigable (- Claude Code (support: 3) is just text).
  • [#thought-id] citations aren't clickable — and Obsidian misparses them as #tags, flooding the tag pane with meaningless hex tags.

Changes to generate-wiki.mjs

Deterministic Relationships rendering. The section is now rendered in script code from the structured typed_edges_by_relation data the script already builds, computing each target's slug with the same slugify() used for output filenames — so links are guaranteed to match real (or future) page names, with zero LLM involvement in the mechanical part. Bullets become - [[slug|Name]] (support: N). The system prompt tells the model to omit the section, and any LLM-emitted copy is stripped defensively.

Citation linkification. [#thought-id] refs — 8-char prefixes, full UUIDs, and multi-ref brackets like [#a, #b] (all three shapes observed in real output) — are rewritten into markdown links via a configurable URL template (--citation-url-template / OB_WIKI_CITATION_URL_TEMPLATE, must contain a <uuid> placeholder; a Supabase table-editor deep link works well). Resolution is scoped to each entity's own provenance ids; unresolvable or ambiguous refs stay untouched. There is deliberately no built-in default (project ref / table id are deployment-specific) — when unset, citations remain plain text. Re-running on already-linkified text is a no-op.

New retrofit scripts (for existing vaults, no recompile needed)

  • retrofit-links.mjs — rewrites Relationships bullets into [[wikilinks]] where the target page exists. Unique-name matching with full-token extraction (never prefix matching), collision-safe: ambiguous names are left plain unless a (type) annotation disambiguates. Backs the vault up first.
  • retrofit-citations.mjs — resolves citation ids against the thoughts table via PostgREST and links them with the same URL template. Deleted/ambiguous ids are left plain and counted. Verifies against the backup that only citation wrappers changed.

Tested

Run against a real 83-page compiled vault (~1,250 citations): 61 relationship links and 1,234 citation links added, 100% of emitted link targets resolve, and a byte-level diff confirmed the only changes anywhere are the link wrappers. node --check passes on all touched scripts. Idempotency re-run: 0 changes.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the recipe Contribution: step-by-step recipe label Jul 14, 2026
@github-actions

Copy link
Copy Markdown

Hey @araece — welcome to Open Brain Source! 👋

Thanks for submitting your first PR. The automated review will run shortly and check things like metadata, folder structure, and README completeness. If anything needs fixing, the review comment will tell you exactly what.

Once the automated checks pass, a human admin will review for quality and clarity. Expect a response within a few days.

If you have questions, check out CONTRIBUTING.md or open an issue.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown

OB1 PR Gate

Folder structure — All files are in allowed directories
Required files — README.md and metadata.json found in all contribution folders
Metadata valid — All metadata.json files passed JSON Schema validation
No credentials — No API keys, tokens, or secrets detected
SQL safety — No destructive SQL or core table modifications
Category artifacts — Required file types present for each category
PR format — Title follows [category] Description format
No binary blobs — No oversized or binary files
README completeness — All READMEs include Prerequisites, Steps, and Expected Outcome
Contribution dependencies — All declared skill and primitive dependencies exist and are linked in README
LLM clarity review — Covered by Claude PR Review workflow
Remote MCP pattern — No local MCP server patterns detected — uses remote MCP correctly
Tool audit link — Extensions/integrations link to the MCP Tool Audit guide
Scope check — All changes are within the contribution folder(s)
Internal links — All relative links in READMEs resolve to existing files

Result: All 15 checks passed! Ready for human review.


Post-Merge Tasks

These don't block merge — they're reminders for admins after this PR lands.

@araece araece changed the title entity-wiki: emit real wikilinks and clickable thought-citation links in compiled wikis [recipes] entity-wiki: emit real wikilinks and clickable thought-citation links in compiled wikis Jul 14, 2026
Compiled wikis previously contained no link syntax at all: the synthesis
prompt never asked the LLM for links, and the LLM never sees target
filenames (slugs are computed at write time), so Relationships sections
and [#thought-id] citations were inert plain text. In Obsidian nothing
was navigable, and bracketed citations were misparsed as #tags.

generate-wiki.mjs:
- Render Relationships deterministically in script code from the
  structured typed_edges_by_relation data, computing each target slug
  with the same slugify() used for filenames; emit bullets as
  "- [[slug|Name]] (support: N)". Instruct the LLM to omit the section
  and strip any LLM-emitted copy defensively.
- Linkify [#thought-id] citations (8-char prefixes, full UUIDs, and
  multi-ref brackets) via a configurable URL template
  (--citation-url-template / OB_WIKI_CITATION_URL_TEMPLATE, requires a
  "<uuid>" placeholder). Resolution is scoped to each entity's own
  provenance ids; unresolvable or ambiguous refs are left untouched.
  No built-in default template (project ref / table id are
  deployment-specific); when unset, citations stay plain text.
  Idempotent on re-runs.

New retrofit scripts for existing vaults (no recompile needed):
- retrofit-links.mjs: rewrite Relationships bullets to [[wikilinks]]
  where the target page exists; unique-name matching, collision-safe,
  vault backup first.
- retrofit-citations.mjs: resolve citation ids against the thoughts
  table via PostgREST and link them with the same template; verifies
  zero collateral changes against the backup.

Tested against a real 83-page vault: 61 relationship links and 1234
citation links added, 100% of emitted targets resolve, byte-level diff
showed only link wrappers changed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

recipe Contribution: step-by-step recipe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant