[recipes] entity-wiki: emit real wikilinks and clickable thought-citation links in compiled wikis - #447
[recipes] entity-wiki: emit real wikilinks and clickable thought-citation links in compiled wikis#447araece wants to merge 1 commit into
Conversation
|
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. |
OB1 PR Gate✅ Folder structure — All files are in allowed directories Result: All 15 checks passed! Ready for human review. Post-Merge TasksThese don't block merge — they're reminders for admins after this PR lands.
|
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>
bfdcf27 to
4407d29
Compare
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:
- 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.mjsDeterministic Relationships rendering. The section is now rendered in script code from the structured
typed_edges_by_relationdata the script already builds, computing each target's slug with the sameslugify()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 thethoughtstable 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 --checkpasses on all touched scripts. Idempotency re-run: 0 changes.🤖 Generated with Claude Code