You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Typing a typo'd slash command (/upadte, /sesions, /dotor) currently returns a flat "unknown command — try /help". That's a guaranteed wasted turn: the user has to ask /help, scan the list, retype. A "did you mean: /update?" suggestion turns the typo into a one-keystroke fix.
The full set of registered command names is available at this point — dispatch.ts has them.
Expected behaviour
When the user types an unknown slash, find up to 3 commands within Levenshtein distance ≤ 3 of the typed one and append them to the message:
unknown command: /upadte — did you mean /update?
unknown command: /sesions — did you mean /sessions, /session?
unknown command: /xyz123 (try /help)
(Last case: nothing close enough, falls back to today's behaviour.)
Files to touch
src/cli/ui/slash/dispatch.ts:48 — the message construction
New util: src/cli/ui/slash/nearest.ts (or co-located in dispatch.ts if small)
New test: tests/slash-nearest.test.ts
Acceptance criteria
New helper nearestCommands(input: string, all: readonly string[], opts?: { max?: number; maxDistance?: number }): string[] returning the closest names, sorted by distance ascending
dispatch.ts calls it and appends "— did you mean /a, /b, /c?" when results exist
Defaults: max 3 suggestions, max Levenshtein distance 3, but capped at Math.floor(input.length / 2) for very short inputs (so /x doesn't suggest /xx etc.)
Tests cover: typo inside word (upadte→update), missing letter, extra letter, transposition, no-match-found returns []
No new dependencies — write the Levenshtein DP yourself, it's ~15 lines
Hints
Levenshtein DP: search "Wagner-Fischer". The standard 2-row tabular implementation is plenty fast for a few dozen names.
Keep the suggestion sort stable: tie-break by alphabetical so output is deterministic.
The current commands list is ~30 names — no need to optimise; readable beats clever.
Background
Typing a typo'd slash command (
/upadte,/sesions,/dotor) currently returns a flat "unknown command — try /help". That's a guaranteed wasted turn: the user has to ask/help, scan the list, retype. A "did you mean: /update?" suggestion turns the typo into a one-keystroke fix.Current behaviour
src/cli/ui/slash/dispatch.ts:48:The full set of registered command names is available at this point —
dispatch.tshas them.Expected behaviour
When the user types an unknown slash, find up to 3 commands within Levenshtein distance ≤ 3 of the typed one and append them to the message:
(Last case: nothing close enough, falls back to today's behaviour.)
Files to touch
src/cli/ui/slash/dispatch.ts:48— the message constructionsrc/cli/ui/slash/nearest.ts(or co-located indispatch.tsif small)tests/slash-nearest.test.tsAcceptance criteria
nearestCommands(input: string, all: readonly string[], opts?: { max?: number; maxDistance?: number }): string[]returning the closest names, sorted by distance ascendingdispatch.tscalls it and appends "— did you mean /a, /b, /c?" when results existMath.floor(input.length / 2)for very short inputs (so/xdoesn't suggest/xxetc.)Hints
Out of scope
/cmd <args>patterns; just suggest the command nameSlashSuggestionsUI (that's the live-typed completion popover, different code path)Difficulty
2-3 hours.