Skip to content

feat(cli): fuzzy command completer with alias + substring match#195

Merged
emal-avala merged 1 commit intomainfrom
feat/fuzzy-command-completer
Apr 23, 2026
Merged

feat(cli): fuzzy command completer with alias + substring match#195
emal-avala merged 1 commit intomainfrom
feat/fuzzy-command-completer

Conversation

@emal-avala
Copy link
Copy Markdown
Member

Summary

The slash-command tab-completer was prefix-only and name-only — typing /rvw, /github, or a command's alias returned nothing. Replaced with a scored match that surfaces the right command even when the user half-remembers the name.

Scoring

Tier Score Match
1 1000 Name has the partial as a prefix
2 500 Name contains the partial as a substring
3 150 An alias has the partial as a prefix
4 100 An alias contains the partial
5 ~100 Name fuzzy-matches (each char in order, not necessarily contiguous)

Case-insensitive throughout. Stable-sorted by score desc, then alphabetically by command name for deterministic ordering at ties.

Display

Completions now include aliases when present:

/output-style — Set response style: ...  (alias: /style)
/install-github-app — Walk through `gh` CLI setup ...  (alias: /gh-setup)

New behaviours

/github     → /install-github-app     (substring match)
/style      → /output-style           (alias prefix match)
/rvw        → /review                 (fuzzy subsequence match)
/gh-        → /install-github-app     (alias prefix match)

What's unchanged

The inline-hint (grey autocomplete) behaviour is still prefix-only. Hints have to be literal continuations of what the user typed — you can't suffix a substring match mid-word without rearranging characters already on screen.

Test plan

  • cargo fmt --all — clean
  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo test -p agent-code --bin agent completer_tests — 8/8 pass
    • empty_partial_matches_everything_at_top_score
    • prefix_beats_substring
    • substring_match_works
    • alias_match_is_recognised
    • fuzzy_subsequence_basic
    • case_insensitive_matching
    • no_match_returns_none
    • prefix_scores_higher_than_alias_prefix
  • Manual: /gh<TAB> now lists /install-github-app; /STYLE<TAB> (uppercase) finds /output-style; /rvw<TAB> finds /review

The completer was prefix-only and name-only — typing `/rvw` or a
command's alias returned nothing. Replaced with a scored match:

  tier 1 (score 1000)  name has the partial as a prefix
  tier 2 (score  500)  name contains the partial as a substring
  tier 3 (score  150)  an alias has the partial as a prefix
  tier 4 (score  100)  an alias contains the partial
  tier 5 (score ~100)  name fuzzy-matches (each char in order)

Case-insensitive throughout. Stable-sorted by score desc, then
alphabetically by command name for deterministic ordering at ties.

Display now includes aliases when present:
  /output-style — Set response style: ...  (alias: /style)

Completion examples that now work:
  /github      → /install-github-app     (substring)
  /style       → /output-style           (alias prefix)
  /rvw         → /review                 (fuzzy subsequence)
  /gh-         → /install-github-app     (alias prefix)

Hint-on-type behaviour (grey inline autocomplete) is unchanged —
still prefix-only, because hints must be literal continuations of
what the user typed.

Tests: 8 unit tests in `completer_tests` covering every tier, case
insensitivity, non-matches, and prefix-beats-substring ordering.
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@emal-avala emal-avala merged commit e813112 into main Apr 23, 2026
14 checks passed
@emal-avala emal-avala deleted the feat/fuzzy-command-completer branch April 23, 2026 05:21
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.

1 participant