[bug] ASCII-only letter classes: three tools miscount non-English text
What happened
8.761.0: three tools match words with ASCII-only letter classes, so text in another script gets zero words or is left unstripped
Summary
In 8.761.0, several tools match words with [A-Za-z] or with \b. In JavaScript, \b only sees ASCII word characters, even with the u flag. So text in another script gets zero words or is left unstripped, and accented Latin text ("café", "über", "très") splits into fragments.
Each item below is a point fix: a Unicode letter class. This is not a request for a localization layer (#2230, #1706). Where a regex fix is proposed, I checked it gives the same output as today on the English sample shown.
Environment: clean checkout of tag v8.761.0, bun 1.4.4, macOS. Commands run from the repo root.
1. stripVoiceTags leaves non-ASCII directions on screen
Where: LifeOS/install/LIFEOS/TOOLS/VoiceTags.ts:15
const BRACKET_RE = /\[[A-Za-z][A-Za-z ,'\-]{0,60}\](?!\()/g
Repro:
bun -e 'import {stripVoiceTags as s} from "./LifeOS/install/LIFEOS/TOOLS/VoiceTags.ts"; console.log([s("[calm] Done."), s("[спокойно] Готово."), s("[très calme] Fini.")])'
- Expected:
Done.,Готово.,Fini. - Actual:
Done.,[спокойно] Готово.,[très calme] Fini.
Effect: LIFEOS_SYSTEM_PROMPT.md:70 says every display and the length cap see only the spoken words. The direction is free-form, so a DA writing its closer in another language may write the direction in that language too. That direction then stays visible in the terminal and counts toward the closer cap in FormatGate.
Minimal fix:
const BRACKET_RE = /\[\p{L}[\p{L} ,'\-]{0,60}\](?!\()/gu
English tags, inline markdown links and [1] behave as before. Non-ASCII bracket text that is not followed by ( is then treated the way ASCII bracket text already is today. The class covers precomposed letters; add \p{M} if decomposed forms matter. If Drama 3 is only meant to receive English directions, the alternative is to say so at LIFEOS_SYSTEM_PROMPT.md:70. Either way, the strip and the doctrine should agree. This is separate from #2621 and #2653.
2. StatSignals counts zero words in non-Latin text
Where: LifeOS/install/LIFEOS/TOOLS/StatSignals.ts:66
return text.toLowerCase().match(/\b[\p{L}']+\b/gu) ?? [];
Repro:
bun LifeOS/install/LIFEOS/TOOLS/StatSignals.ts --json --text "Он открыл дверь и вышел на улицу, потому что было холодно и тихо."
bun LifeOS/install/LIFEOS/TOOLS/StatSignals.ts --json --text "He opened the door and stepped outside because it was cold and quiet."
- Expected: a non-zero word count for both.
- Actual: Russian gives
"words": 0and every signal0. English gives"words": 13andunigram_entropy3.5466.
Accented Latin is affected too: "naïve café résumé über" tokenizes as naïve, caf, résum, ber.
Minimal fix: /\p{L}+(?:'\p{L}+)*/gu. On the English sentence above followed by don't 'tis rock'n'roll dog's it gives the same 17 tokens as the current regex. Inputs with doubled apostrophes (foo''bar) tokenize differently.
The same regex is in LifeOS/install/LIFEOS/TOOLS/WatermarkScan.ts:141 (repetitionScore). I read that one but did not run it.
3. WriteStory's VoiceMetrics copy counts only ASCII words
Where: LifeOS/install/skills/WriteStory/Tools/VoiceMetrics.ts:86
const words = (s: string): string[] => s.match(/[A-Za-z][A-Za-z'’-]*/g) ?? [];
The lexicon edge checks at line 202 use (?<![a-z])…(?![a-z]), which is ASCII-only in the same way.
Repro:
bun LifeOS/install/skills/WriteStory/Tools/VoiceMetrics.ts --text "Он открыл дверь и вышел на улицу. Было холодно. Она ждала его у машины, молча."
- Expected: a word count and sentence-length stats.
- Actual:
word_count0,sentence_count3, and everysent_len_*value 0. The English text "He opened the door and stepped outside. It was cold. She waited for him by the car, silent." givesword_count18 andsentence_count3.
StoryGate.ts:26 imports measure from this file. So the word-based metrics the Revise gate takes from it are computed over zero words for prose in a non-Latin script. StoryGate's own whitespace-based counts are not affected.
Relation to #2634: that issue and its fix name skills/Writing/Tools/VoiceMetrics.ts. This is the second copy, with the same line in 8.761.0. If the #2634 word fix already covers this copy, please ignore this item. Only the word and edge fix (\p{L}) is asked here; in the RegExp constructor string at line 202 it needs the u flag and an escaped backslash. The English lexicons remain the open part of #2634.
Details
- Kind: bug
- LifeOS version: 8.761.0
Filed with the LifeOS /feedback command. The reporter approved this exact text before it was sent; paths, secrets and personal details were stripped locally.
[!NOTE] 🤖 Kai (AI assistant) responding on behalf of Daniel Miessler
Thanks @IvanLeontev-stack for the report.
This is fixed in our source and goes out in the next release. Text statistics and story voice checks count accented and non-Latin words as whole words. Voice cleanup also removes bracketed directions written with those letters.
Please reopen if it still happens after you upgrade.