Skip to content

fix(Prioritize): keep non-Latin letters in stableId so titles don't collide - #2950

Open
sniwas wants to merge 1 commit into
danielmiessler:mainfrom
sniwas:fix/prioritize-stableid-unicode
Open

sniwas wants to merge 1 commit into
danielmiessler:mainfrom
sniwas:fix/prioritize-stableid-unicode

Conversation

@sniwas

@sniwas sniwas commented Nov 24, 2026 •

Copy link
Copy Markdown

What was wrong

stableId() in skills/Prioritize/Tools/Prioritize.ts normalised the title with .replace(/[^a-z0-9]+/g, " "), which deletes every non-ASCII letter. A title written only in Cyrillic, CJK, Greek, Arabic, etc. became the empty string, so every such recommendation in a category got the id <category>-e3b0c44298. validate then dropped all but the first as duplicates, and dismissing one dismissed them all (#2920).

What changed

One line: the hash input now keeps Unicode letters and digits (title.normalize("NFC").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, " ")), as suggested in the issue. The id itself stays ASCII (category + hex hash), so it still matches ID_RE.

Compatibility: for ASCII-only titles the hash input is identical, so their ids and existing dismissals are unchanged. Titles that mix Latin with accented letters (e.g. "café") now hash the accented letter too, so those particular ids change once.

How it was checked

The repo has no test runner for skills, so I checked with a throwaway Node 26 script (not part of this diff) that imports Prioritize.ts and calls stableId:

  • Before the fix: stableId("work", "Купить датчик воздуха"), stableId("work", "Позвонить врачу") and stableId("work", "購入する") all returned work-e3b0c44298, and the distinctness assertion failed.
  • After the fix: they return three different ids (work-25cc1f2099, work-36735b3e44, work-b702838d52), all matching /^[a-z0-9-]{6,64}$/.
  • ASCII titles give the same ids before and after: stableId("work", "Fix the roof leak!") = work-51055a1850, stableId("capture", "Call Dr. Smith @ 9am -- re: MRI (2nd)") = capture-d1bfcc7bab on both revisions.

Not run: the full Prioritize skill end to end (no inference backend here), and nothing under Bun.

Fixes #2920

@sniwas
sniwas force-pushed the fix/prioritize-stableid-unicode branch from 0a0e33a to c8bc3ef Compare November 25, 2026 10:49
…ollide

stableId() stripped every character outside [a-z0-9] before hashing, so a
title written entirely in Cyrillic, CJK, Greek, Arabic, etc. hashed the
empty string and every such recommendation in a category got the same id.
validate() then dropped all but the first as duplicates, and dismissing one
dismissed them all.

Keep Unicode letters and digits (NFC-normalised) in the hash input. Ids of
ASCII-only titles are unchanged, so existing dismissals keep working.

Fixes danielmiessler#2920
@sniwas
sniwas force-pushed the fix/prioritize-stableid-unicode branch from c8bc3ef to be9326e Compare November 26, 2026 06:56
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.

[bug] Prioritize stableId gives every non-Latin title in a category the same id, so…

1 participant