Skip to content

Conversation

@bdmorin
Copy link

@bdmorin bdmorin commented Jan 12, 2026

Summary

  • Adds imsg completions <shell> command generating shell completion scripts
  • Supports bash, zsh, fish shells plus an "llm" format for AI assistant context
  • Uses centralized CompletionMetadata structure with consistency tests to prevent drift

Design Notes

This introduces a parallel metadata structure (CompletionMetadata) rather than extending Commander's types because:

  • Commander's OptionDefinition doesn't support value hints (file, rowid, timestamp) or enumerated choices needed for rich shell completion
  • A consistency test (completionMetadataContainsAllCommands) verifies command names stay in sync with CommandRouter

If maintainers prefer, we'd be happy to extend Commander's base types instead - just let us know.

Test plan

  • swift build passes
  • swift test passes (97 tests, including 12 new completion tests)
  • Manual verification of generated completions:
    • imsg completions bash - generates valid bash-completion script
    • imsg completions zsh - generates valid zsh completion script
    • imsg completions fish - generates valid fish completion script
    • imsg completions llm - generates markdown CLI reference
  • Error handling: imsg completions and imsg completions powershell produce friendly error messages

Add `imsg completions <shell>` command that generates shell completion
scripts dynamically from registered commands. Supports bash, zsh, fish,
and an "llm" format for AI assistant context.

- CompletionMetadata.swift holds command/option metadata for generation
- CompletionsCommand.swift implements generators for each shell format
- Consistency test verifies metadata stays in sync with CommandRouter
- Service choices derive from MessageService.allCases (not hardcoded)
Adds comprehensive docstrings to CompletionMetadata and
CompletionsCommand to satisfy CodeRabbit's documentation
coverage requirement.
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