Skip to content

feat(ui): suggest nearest slash commands on unknown input#302

Open
zerone0x wants to merge 1 commit intoesengine:mainfrom
zerone0x:feat/slash-nearest-command-17
Open

feat(ui): suggest nearest slash commands on unknown input#302
zerone0x wants to merge 1 commit intoesengine:mainfrom
zerone0x:feat/slash-nearest-command-17

Conversation

@zerone0x
Copy link
Copy Markdown
Contributor

@zerone0x zerone0x commented May 6, 2026

What

Unknown slash-command errors now suggest up to three nearby registered commands instead of always falling back to /help. Added a small Levenshtein helper and regression coverage for typo, omission, insertion, transposition, and no-match cases.

Why

Closes #17. A typo like /upadte was a wasted turn even though the command set is already known at dispatch time. Suggesting the nearest commands turns that into a one-step correction.

How to verify

  • npx biome check src/cli/ui/slash/dispatch.ts src/cli/ui/slash/nearest.ts tests/slash-nearest.test.ts
  • npm test -- --silent tests/slash-nearest.test.ts tests/slash.test.ts
  • In the TUI, type /upadte and confirm the error says did you mean /update?

Checklist

  • npm run verify passes locally (lint + typecheck + tests + comment-policy gate)
  • No Co-Authored-By: Claude trailer in commits
  • Comments follow CONTRIBUTING.md (no module-essay headers, no incident history)
  • No edits to CHANGELOG.md — release notes are maintainer-written at release time

@esengine
Copy link
Copy Markdown
Owner

esengine commented May 6, 2026

Thanks for picking this up — the implementation matches the spec cleanly. Wagner-Fischer DP, the half-length cap for very short inputs, the alphabetical tiebreak for deterministic output, and all five test cases (typo / missing / extra / transposition / no-match) are covered. Nice work for a first PR.

One blocker on CI: typecheck fails because the repo runs noUncheckedIndexedAccess: true, so the indexed reads in the inner DP loop come back as number | undefined. Three ! assertions on line 33 will clear it:

next[j + 1] = Math.min(next[j]! + 1, prev[j + 1]! + 1, prev[j]! + cost);

The trailing prev[b.length] ?? 0 is already fine — that one doesn't need a change.

Push that and I'll merge.

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.

Suggest the closest slash command on unknown command errors

2 participants