Fuzzy match-and-rank function in TypeScript #146

Closed
opened 2026-09-03 13:26:50 +01:00 by naps62-yolo · 1 comment
Collaborator

Implement the match-and-rank function from docs/COMMAND-BAR.md in
TypeScript, in web/src/, as a pure function over candidates — no DOM, no
network, testable directly like web/src/tree.ts and web/src/paths.ts are.

It takes a query and a list of candidates (each carrying the text fields the
doc says are matched: name, directory, command, tool) and returns the matching
subset in ranked order, along with the matched character ranges so the UI can
highlight them.

Test it against the fixture table in docs/COMMAND-BAR.md — the same cases the
Rust matcher is tested against. Those shared cases are the point: they are what
stops the two clients' rankings from drifting.

Non-goals: no UI, no wiring into the sidebar's existing filter, no command or
directory candidates yet — this issue is the scoring function and its tests.

Depends on: #144

Implement the match-and-rank function from `docs/COMMAND-BAR.md` in TypeScript, in `web/src/`, as a pure function over candidates — no DOM, no network, testable directly like `web/src/tree.ts` and `web/src/paths.ts` are. It takes a query and a list of candidates (each carrying the text fields the doc says are matched: name, directory, command, tool) and returns the matching subset in ranked order, along with the matched character ranges so the UI can highlight them. Test it against the fixture table in `docs/COMMAND-BAR.md` — the same cases the Rust matcher is tested against. Those shared cases are the point: they are what stops the two clients' rankings from drifting. Non-goals: no UI, no wiring into the sidebar's existing filter, no command or directory candidates yet — this issue is the scoring function and its tests. Depends on: #144
naps62-yolo added this to the Command bar milestone 2026-09-03 13:26:50 +01:00
naps62-yolo added the area/webdifficulty/mediumtype/feat labels 2026-09-03 13:26:50 +01:00
naps62-yolo added a new dependency 2026-09-03 13:26:52 +01:00
Author
Collaborator

Merged into blitz/command-bar. Suite re-run on the integration branch: 332
tests across 39 files, green.

I checked the fixture scores against docs/COMMAND-BAR.md rather than only
against the run, since a matcher that agrees with itself proves nothing. All
twelve match the doc's numbers, including the two that discriminate: F5's
[0, 8, 9] embedding, which greedy matching cannot produce, and F11's
~/documents/dev-notes at 44, where the segment-start d at position 12 beats
the earlier d at position 2.

bestEmbedding is the dynamic program the doc asks for, with the leftmost
position-vector tie-break, so the fixtures pass for the right reason.

Merged into `blitz/command-bar`. Suite re-run on the integration branch: 332 tests across 39 files, green. I checked the fixture scores against `docs/COMMAND-BAR.md` rather than only against the run, since a matcher that agrees with itself proves nothing. All twelve match the doc's numbers, including the two that discriminate: F5's `[0, 8, 9]` embedding, which greedy matching cannot produce, and F11's `~/documents/dev-notes` at 44, where the segment-start `d` at position 12 beats the earlier `d` at position 2. `bestEmbedding` is the dynamic program the doc asks for, with the leftmost position-vector tie-break, so the fixtures pass for the right reason.
This repo is archived. You cannot comment on issues.
1 Participants
Due Date
No due date set.
Reference: naps62/maestro#146