Skip to content

feat: add shell completion for bash, zsh, and fish#22

Merged
jsanter27 merged 3 commits intopolyai:mainfrom
HelenGreul:feat/shell-completion
Mar 16, 2026
Merged

feat: add shell completion for bash, zsh, and fish#22
jsanter27 merged 3 commits intopolyai:mainfrom
HelenGreul:feat/shell-completion

Conversation

@HelenGreul
Copy link
Copy Markdown
Contributor

Summary

Adds a poly completion <shell> command that prints a shell completion script, enabling tab completion for all poly/adk commands, subcommands, and flags.

Motivation

Shell completion is a standard ergonomic feature for any CLI tool — especially one with 12+ subcommands and numerous flags. Without it, users must remember exact command names and flags, slowing down daily use. Every major comparable CLI (Google ADK, AWS AgentCore, gh, kubectl) ships with completion support.

Changes

  • Add argcomplete>=3.0.0 dependency (Apache 2.0 — passes license checks)
  • Call argcomplete.autocomplete(parser) in main() — this is the hook that makes tab completion work at runtime; it exits immediately when not in a completion context, so there is zero overhead for normal CLI usage
  • Add completion subparser with bash, zsh, fish choices and per-shell installation instructions in the help text
  • Add AgentStudioCLI.print_completion() classmethod
  • Both poly and adk entry points are registered in the generated scripts

Usage

# Bash — add to ~/.bashrc or ~/.bash_profile
eval "$(poly completion bash)"

# Zsh — add to ~/.zshrc
eval "$(poly completion zsh)"

# Fish — add to ~/.config/fish/completions/poly.fish
poly completion fish | source

Test strategy

  • Added unit tests for all three shells and invalid shell rejection
  • Manual CLI testing (poly <command>)
  • Tested against a live Agent Studio project
  • N/A (docs, config, or trivial change)

Checklist

  • ruff check . and ruff format --check . pass
  • pytest passes
  • No breaking changes to the poly CLI interface (or migration path documented)
  • Commit messages follow conventional commits

Adds a `poly completion <shell>` command that prints a completion script
users can eval or source to get tab completion for all poly/adk commands,
subcommands, and flags.

- Add `argcomplete>=3.0.0` dependency (Apache 2.0)
- Call `argcomplete.autocomplete(parser)` in `main()` to enable completions
- Add `completion` subcommand with per-shell installation instructions
- Add `print_completion()` classmethod on `AgentStudioCLI`
- Add unit tests for all three shells and invalid shell rejection

Usage:
  # Bash — add to ~/.bashrc or ~/.bash_profile
  eval "$(poly completion bash)"

  # Zsh — add to ~/.zshrc
  eval "$(poly completion zsh)"

  # Fish — add to ~/.config/fish/completions/poly.fish
  poly completion fish | source
@jsanter27 jsanter27 added enhancement New feature or request good first issue Good for newcomers labels Mar 16, 2026
@jsanter27
Copy link
Copy Markdown
Contributor

Hi @HelenGreul , appreciate the nice feature here! I've enabled the Actions workflow for you as a first time contributor to the repo. PR looks good, can you just fix the formatting to pass CI? Should be good after that ✅

@jsanter27
Copy link
Copy Markdown
Contributor

LGTM, thanks again!

@HelenGreul
Copy link
Copy Markdown
Contributor Author

Thanks for the quick review and for enabling the workflow @jsanter27!
Took two fixes - formatting and a missing licenses.json entry for the new argcomplete dependency

@jsanter27 jsanter27 merged commit 2c563ff into polyai:main Mar 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request good first issue Good for newcomers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants