yari
yari copied to clipboard
enhance(ai-help): hash markdown to identify formatting updates
Summary
Problem
The scripts/ai-help-macros.ts script updates the document content if the document hash changes, but this hash also changes when building the content from another yari branch (e.g. next), because the branch name is included in the source property:
Solution
Use the hash of the markdown content to determine whether the content has changed.
Note: We still use the text content to determine whether the embedding needs to be regenerated.
How did you test this change?
Ran the following query on the Supabase dev project to populate the new markdown_hash column:
update mdn_doc_macro set markdown_hash = encode(digest (markdown, 'sha256'), 'base64');
Then ran yarn ai-help-macros update-index locally.