Skip to content

Interactive Tab completion never suggests option names (--flags) #43

Description

@autocarl

Description

The interactive REPL's Tab completion does not suggest option names (--xxx), even though docs/interactive-loop.md documents that it should:

As the user types, the autocompletion system suggests available commands, contexts, and option names visible from the current scope.

Repro steps

In an interactive session:

> [nothing typed] + Tab
Matches: catalog, list, install, update, uninstall (+5)

> i + Tab
Command: install

> install + Tab
Param skillName: The skill to install

> install msaf-architect -- + Tab
[nothing useful is suggested]

Command-name completion and positional-parameter completion both work correctly. Only option/flag completion (--) produces no usable suggestion.

Expected behavior

Tab should list the options available on the resolved route (for example --help and route-specific options), the same way the external shell completion bridge (completion __complete, used for bash/zsh/fish/PowerShell/Nu) already does.

Observed behavior

No option names are suggested and no live hint is shown for -- or partial option prefixes.

A local probe on current origin/main (de6de5b) produced only a non-selectable invalid placeholder for the interactive path:

interactive candidates for: install msaf-architect --
--|Invalid|selectable=False
interactive live hint: <null>

Shell completion validation

The external shell completion path does handle option candidates.

Existing regression tests pass:

dotnet test src/Repl.IntegrationTests/Repl.IntegrationTests.csproj -c Release --filter 'FullyQualifiedName~Given_Completions'
# total: 6, failed: 0, succeeded: 6, skipped: 0

A local route-option probe also returned route and global option candidates from completion __complete:

shell candidates for: repl install msaf-architect --
--force
--help
--human
--interactive
--json
--markdown
--no-interactive
--no-logo
--output:
--output:human
--output:json
--output:markdown
--output:xml
--output:yaml
--xml
--yaml
--yml

So this appears scoped to the interactive autocomplete engine, not the shell bridge.

Technical diagnosis

The repo currently has two separate completion engines:

  • src/Repl.Core/ShellCompletion/ShellCompletionEngine.cs drives the external shell bridge described in docs/shell-completion.md. It implements option suggestions:
    • ResolveShellCompletionCandidates detects option tokens and calls AddShellOptionCandidates.
    • AddGlobalShellOptionCandidates and AddRouteShellOptionCandidates use static globals, output aliases/formats, custom globals, and route.OptionSchema.KnownTokens.
    • Existing coverage includes src/Repl.IntegrationTests/Given_Completions.cs for custom global option completion.
  • src/Repl.Core/Autocomplete/AutocompleteEngine.cs drives the interactive loop (CoreReplApp.Autocomplete.cs, Session/InteractiveSession.cs, Console/ConsoleLineReader.Autocomplete.cs). Its CollectAutocompleteSuggestionsAsync currently assembles command, context, dynamic, ambient, and ambient-continuation candidates, but has no equivalent branch that generates ---prefixed option candidates.

AutocompleteEngine.IsGlobalOptionToken exists, but today it is used for token classification/live-hint behavior, not for collecting selectable option suggestions.

There also appears to be no existing interactive autocomplete regression for option/flag candidates: Given_ConsoleLineReader_Autocomplete.cs and Given_InteractiveAutocomplete_LiveHint.cs contain no -- / option-name coverage.

Suggested direction

Share or port the option-candidate logic from ShellCompletionEngine into AutocompleteEngine, so interactive Tab completion uses the same sources of truth:

  • static global options (--help, --interactive, etc.);
  • output aliases and output formats;
  • custom global options;
  • route-specific options from route.OptionSchema.KnownTokens.

Add regression tests for at least:

  1. install msaf-architect -- suggests route/global options interactively;
  2. partial option prefixes (for example --fo) filter correctly;
  3. shell completion remains green, to keep parity between both completion paths.

Context

Reported by an external user following the shell-completion documentation who expected -- completion to work the same way inside the interactive REPL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions