Repository navigation
feat(ui): link prose paths with non-ASCII file names - #1798
Open
heunghingwan wants to merge 1 commit into
Open
heunghingwan wants to merge 1 commit into
heunghingwan wants to merge 1 commit into
Conversation
Prose (non-backtick) bare paths keep the ASCII-only tokenizer, so a CJK or otherwise non-ASCII file name never linked: the token split at the letters and the fragments stayed plain text. Inline code got exact-path linking in NeuralNomadsAI#1780; reviewers asked for the prose grammar as a separate change, which this is. A prose token now contains every script's letters, marks and digits as file-name content. A token carrying them offers its integral reading first — the whole token as one path — and falls back to its boundary readings: edge letter runs glued to word characters trim as surrounding prose, edge runs whose inner neighbour is a separator are the path's own segments (项目/v2/启动), and interior runs split the token as connectors (src/app.ts和docs/x.md). The candidate cap counts readings — the integral probe plus every boundary piece, one file lookup each — instead of tokens, so a glued run of paths cannot multiply directory reads past the 64-lookup bound. A mid-token Windows drive prefix stays glued to preceding prose (打开C:\…) while a single-letter-colon prefix still splits like a scheme (File:/x), and a token rooted at a doubled separator is one URL that yields no readings — fixing the suffix leak where a prose URL with a non-ASCII path linked its same-named local tail (https://example.com/资料README.md linking the root README.md). A reading whose literal, verified target and generated destination could disagree — a percent escape that decodes, a fragment — stays plain, applying the same three-way agreement the inline grammar enforces; prose anchors keep their literal href, which the gate holds to the verified target and the click's re-resolution. The exact inline-code grammar from NeuralNomadsAI#1780 is unchanged. Unit tests pin the two-reading grammar, the URL guards, the reading-budget cap and the agreement gate (30 lib tests). The Chromium fixture covers the whole-file CJK link, both-edges segment probes, the connector fallback, the exposed-punctuation trim, the prose URL and percent negatives, and a 200-path glued token staying within 64 directory reads (5 browser tests, three consecutive green runs). Help pages in all ten locales and TRANSCRIPT.md describe the behavior.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1780, which narrowed bare-path linking to exact inline-code paths and kept the prose parser for a separate change. This is that change: prose (non-backtick) paths now recognize file names written in any script.
What links now
已写入 docs/superpowers/specs/2026-11-26-算法工作台MVP-design.md 定稿— the whole path links: a prose token contains every script's letters, marks and digits as file-name content.看看src/app.ts吧(ASCII path glued into CJK prose) and对比 src/app.ts和docs/x.md 一下(a CJK connector between two paths) keep linking as before;打开C:\repo\src\app.tskeeps its drive prefix andFile:/fixture-root/README.mdstill splits at the colon like a scheme.脚本/启动,项目/v2/启动) read as one path; a trimmed edge run that exposes trailing punctuation (看看README.md.吧) trims it.Fail closed
https://example.com/资料README.md) stays whole: a token rooted at a doubled separator is one URL that yields no readings, so its tail can no longer link a same-named local file (README.mdat the root) — dev's suffix leak, covered by a regression test with that file present.#fragment — stays plain, the same agreement the inline grammar enforces (docs/%E7%AE%97.mdstays text even whendocs/算.mdexists).docs/as a folder link) — dev's boundary grammar produces the identicaldocs/candidate today, and the new whole-file link replaces it whenever the file exists.Cost bounded
Implementation
lib/markdown-bare-paths.tsre-adds the two-reading grammar (integral + boundary pieces) with the scheme-splitting drive lookbehind and the URL-root guard;inlineCodeCandidatesis unchanged apart from its return type name.components/markdown-bare-paths.tsconverts the integral reading first (whole token or nothing; pieces never overlap a converted integral) and falls back to pieces; inline spans keep the verified-target href from feat(ui): link bare paths with non-ASCII file names and inside inline code #1780, prose pieces keep their literal href, which the new agreement gate holds to the verified target and the click's re-resolution.Validation
tsc --noEmit, rootnpm run test:help31/31.