Files
ccs/scripts/completion
7ec8cc8369 feat(profile,shell-completion,prompt): add profile commands and improve input handling (#34)
* fix(cliproxy): use double-dash flags for cliproxyapi auth (#24)

CLIProxyAPI updated from single-dash to double-dash CLI flags.
Changed -login to --login, -codex-login to --codex-login,
-antigravity-login to --antigravity-login, -config to --config,
and -no-browser to --no-browser.

* chore(release): 5.1.1-beta.1 [skip ci]

## [5.1.1-beta.1](https://github.com/kaitranntt/ccs/compare/v5.1.0...v5.1.1-beta.1) (2025-12-01)

### Bug Fixes

* **cliproxy:** use double-dash flags for cliproxyapi auth ([#24](https://github.com/kaitranntt/ccs/issues/24)) ([4c81f28](https://github.com/kaitranntt/ccs/commit/4c81f28f0b67ef92cf74d0f5c13a5943ff0a7f00))

* chore(release): 5.1.1-beta.2 [skip ci]

## [5.1.1-beta.2](https://github.com/kaitranntt/ccs/compare/v5.1.1-beta.1...v5.1.1-beta.2) (2025-12-01)

### Bug Fixes

* **cliproxy:** use double-dash flags for cliproxyapi auth ([9489884](https://github.com/kaitranntt/ccs/commit/94898848ea4533dcfc142e1b6c9bf939ba655537))

* fix(glmt): handle 401 errors and headers-already-sent exception (#30)

- add res.headersSent check before writing error headers
- write error as SSE event when headers already sent (streaming mode)
- add parseUpstreamError() for user-friendly error messages
- return proper HTTP status codes (401, 403, 429, 502, 504)
- clear auth error: check ANTHROPIC_AUTH_TOKEN in config

Fixes #26

* chore(release): 5.1.1-beta.3 [skip ci]

## [5.1.1-beta.3](https://github.com/kaitranntt/ccs/compare/v5.1.1-beta.2...v5.1.1-beta.3) (2025-12-01)

### Bug Fixes

* **glmt:** handle 401 errors and headers-already-sent exception ([#30](https://github.com/kaitranntt/ccs/issues/30)) ([c953382](https://github.com/kaitranntt/ccs/commit/c95338232a37981b95b785b47185ce18d6d94b7a)), closes [#26](https://github.com/kaitranntt/ccs/issues/26)

* chore(release): enable success comments and released labels in semantic-release

* feat(cliproxy): add qwen code oauth provider support (#31)

Add 'qwen' as new CLIProxy OAuth provider with --qwen-login flag.
Support qwen3-coder model with base config at config/base-qwen.settings.json.
Register qwen OAuth endpoints and token prefix handling.
Update help documentation across all CLI entry points.

Implements issue #29

* chore(release): 5.2.0-beta.1 [skip ci]

# [5.2.0-beta.1](https://github.com/kaitranntt/ccs/compare/v5.1.1-beta.3...v5.2.0-beta.1) (2025-12-01)

### Features

* **cliproxy:** add qwen code oauth provider support ([#31](https://github.com/kaitranntt/ccs/issues/31)) ([a3f1e52](https://github.com/kaitranntt/ccs/commit/a3f1e52ac68600ba0806d67aacceb6477ffa3543)), closes [#29](https://github.com/kaitranntt/ccs/issues/29)

* feat(cliproxy): auto-update cliproxyapi to latest release on startup

- add github api integration to fetch latest release version
- check for updates on every startup (cached for 1 hour)
- auto-download newer versions when available
- rename CLIPROXY_VERSION to CLIPROXY_FALLBACK_VERSION (safety net)
- add version tracking (.version file) and caching (.version-cache.json)
- non-blocking: startup continues if update check fails

* chore(release): 5.2.0-beta.2 [skip ci]

# [5.2.0-beta.2](https://github.com/kaitranntt/ccs/compare/v5.2.0-beta.1...v5.2.0-beta.2) (2025-12-01)

### Features

* **cliproxy:** auto-update cliproxyapi to latest release on startup ([8873ccd](https://github.com/kaitranntt/ccs/commit/8873ccd981679e8acff8965accdc22215c6e4aa2))

* chore(release): 5.3.0-beta.1 [skip ci]

# [5.3.0-beta.1](https://github.com/kaitranntt/ccs/compare/v5.2.0...v5.3.0-beta.1) (2025-12-01)

### Bug Fixes

* **cliproxy:** use double-dash flags for cliproxyapi auth ([#24](https://github.com/kaitranntt/ccs/issues/24)) ([4c81f28](https://github.com/kaitranntt/ccs/commit/4c81f28f0b67ef92cf74d0f5c13a5943ff0a7f00))
* **glmt:** handle 401 errors and headers-already-sent exception ([#30](https://github.com/kaitranntt/ccs/issues/30)) ([c953382](https://github.com/kaitranntt/ccs/commit/c95338232a37981b95b785b47185ce18d6d94b7a)), closes [#26](https://github.com/kaitranntt/ccs/issues/26)

### Features

* **cliproxy:** add qwen code oauth provider support ([#31](https://github.com/kaitranntt/ccs/issues/31)) ([a3f1e52](https://github.com/kaitranntt/ccs/commit/a3f1e52ac68600ba0806d67aacceb6477ffa3543)), closes [#29](https://github.com/kaitranntt/ccs/issues/29)
* **cliproxy:** auto-update cliproxyapi to latest release on startup ([8873ccd](https://github.com/kaitranntt/ccs/commit/8873ccd981679e8acff8965accdc22215c6e4aa2))

* fix(cliproxy): improve qwen oauth error handling

- Updated OAuth port documentation with correct flow types per provider
- Removed Qwen from port cleanup logic (Device Code Flow has no callback)
- Fixed Qwen error messages to show Device Code Flow troubleshooting tips

Fixes #29

* chore(release): 5.3.0-beta.2 [skip ci]

# [5.3.0-beta.2](https://github.com/kaitranntt/ccs/compare/v5.3.0-beta.1...v5.3.0-beta.2) (2025-12-01)

### Bug Fixes

* **cliproxy:** improve qwen oauth error handling ([7e0b0fe](https://github.com/kaitranntt/ccs/commit/7e0b0feca8ce2ed5d505c5bf6c84e54c6df8839e)), closes [#29](https://github.com/kaitranntt/ccs/issues/29)

* feat(profile): add profile command with configuration display

* feat(shell-completion): add --force flag and fix zsh profile coloring

* fix(prompt): improve password input handling with raw mode and buffer support

* chore(release): 5.3.0-beta.3 [skip ci]

# [5.3.0-beta.3](https://github.com/kaitranntt/ccs/compare/v5.3.0-beta.2...v5.3.0-beta.3) (2025-12-01)

### Bug Fixes

* **prompt:** improve password input handling with raw mode and buffer support ([bc56d2e](https://github.com/kaitranntt/ccs/commit/bc56d2e135532b2ae443144dd42217b26bcba951))

### Features

* **profile:** add profile command with configuration display ([53d7a15](https://github.com/kaitranntt/ccs/commit/53d7a15c047e760723e051dc0f7be3c0dd42d087))
* **shell-completion:** add --force flag and fix zsh profile coloring ([7faed1d](https://github.com/kaitranntt/ccs/commit/7faed1d84ba29ba02bf687bae5b3458617512e67))

* chore(release): 5.3.0-beta.4 [skip ci]

# [5.3.0-beta.4](https://github.com/kaitranntt/ccs/compare/v5.3.0-beta.3...v5.3.0-beta.4) (2025-12-01)

### Bug Fixes

* **cliproxy:** improve qwen oauth error handling ([#33](https://github.com/kaitranntt/ccs/issues/33)) ([1c3374f](https://github.com/kaitranntt/ccs/commit/1c3374f6a7e4440e299d49b58808c6454b4547c2)), closes [#29](https://github.com/kaitranntt/ccs/issues/29)

---------

Co-authored-by: semantic-release-bot <semantic-release-bot@martynus.net>
2025-12-01 18:04:04 -05:00
..

Shell Completion for CCS

Tab completion for CCS commands, subcommands, profiles, and flags.

Supported Shells: Bash, Zsh, Fish, PowerShell

Features

  • Complete profile names (both settings-based and account-based)
  • Complete ccs auth subcommands (create, list, show, remove, default)
  • Complete flags (--help, --version, --json, --verbose, --yes)
  • Complete profile names for auth subcommands
  • Context-aware: suggests relevant options based on current command
ccs --shell-completion

This will:

  • Auto-detect your shell
  • Copy completion files to ~/.ccs/completions/
  • Configure your shell profile with proper comment markers
  • Show instructions to activate

Manual shell selection:

ccs --shell-completion --bash        # Force bash
ccs --shell-completion --zsh         # Force zsh
ccs --shell-completion --fish        # Force fish
ccs --shell-completion --powershell  # Force PowerShell

Manual Installation

Completion files are installed to ~/.ccs/completions/ during npm install.

Bash

Add to ~/.bashrc or ~/.bash_profile:

# CCS shell completion
source ~/.ccs/completions/ccs.bash

Then reload:

source ~/.bashrc

Zsh

  1. Create completion directory:

    mkdir -p ~/.zsh/completion
    
  2. Copy completion file:

    cp ~/.ccs/completions/ccs.zsh ~/.zsh/completion/_ccs
    
  3. Add to ~/.zshrc:

    # CCS shell completion
    fpath=(~/.zsh/completion $fpath)
    autoload -Uz compinit && compinit
    
  4. Reload:

    source ~/.zshrc
    

PowerShell

Add to your PowerShell profile ($PROFILE):

# CCS shell completion
. "$HOME\.ccs\completions\ccs.ps1"

Then reload:

. $PROFILE

Fish

User installation (recommended)

Fish automatically loads completions from ~/.config/fish/completions/:

# Create completion directory if it doesn't exist
mkdir -p ~/.config/fish/completions

# Copy completion script
cp scripts/completion/ccs.fish ~/.config/fish/completions/

That's it! Fish will automatically load the completion on demand. No need to source or reload.

System-wide installation (requires sudo)

sudo cp scripts/completion/ccs.fish /usr/share/fish/vendor_completions.d/

Usage Examples

Basic Completion

$ ccs <TAB>
auth      doctor    glm       glmt      kimi      work      personal  --help    --version

$ ccs auth <TAB>
create    list      show      remove    default   --help

Profile Completion

$ ccs auth show <TAB>
work      personal  team      --json

$ ccs auth remove <TAB>
work      personal  team      --yes     -y

Flag Completion

$ ccs auth list <TAB>
--verbose --json

$ ccs auth show work <TAB>
--json

Completion Behavior

Top-level (after ccs)

  • Built-in commands: auth, doctor
  • Flags: --help, --version, -h, -v
  • Settings-based profiles: from ~/.ccs/config.json
  • Account-based profiles: from ~/.ccs/profiles.json

After ccs auth

  • Subcommands: create, list, show, remove, default
  • Flags: --help, -h

After ccs auth <subcommand>

  • create: No completion (user enters new profile name)
    • Flags: --force
  • list: No profile completion
    • Flags: --verbose, --json
  • show: Account profiles only
    • Flags: --json
  • remove: Account profiles only
    • Flags: --yes, -y
  • default: Account profiles only

After ccs <profile>

  • No completion (Claude CLI arguments are free-form)

Troubleshooting

Bash: Completion not working

  1. Check if bash-completion is installed:

    # macOS
    brew install bash-completion
    
    # Ubuntu/Debian
    sudo apt install bash-completion
    
  2. Verify jq is installed (required for profile completion):

    command -v jq
    
  3. Check if completion is loaded:

    complete -p ccs
    

    Should output:

    complete -F _ccs_completion ccs
    

Zsh: Completion not working

  1. Verify completion system is enabled in ~/.zshrc:

    autoload -Uz compinit && compinit
    
  2. Check if completion is loaded:

    which _ccs
    
  3. Rebuild completion cache:

    rm ~/.zcompdump && compinit
    

PowerShell: Completion not working

  1. Check PowerShell version (5.1+ required):

    $PSVersionTable.PSVersion
    
  2. Verify profile is loaded:

    Test-Path $PROFILE
    
  3. Check if completion is registered:

    (Get-ArgumentCompleter).CommandName | Select-String ccs
    

Fish: Completion not working

  1. Check Fish version (3.0+ required):

    fish --version
    
  2. Verify completion file is in the right location:

    ls ~/.config/fish/completions/ccs.fish
    
  3. Verify jq is installed (required for profile completion):

    which jq
    
  4. Test completion manually:

    complete -C'ccs '
    
  5. If needed, rebuild completions:

    fish_update_completions
    

Technical Details

Bash Implementation

  • Uses complete -F for programmable completion
  • Compatible with bash 3.2+ (macOS default)
  • Reads profiles dynamically using jq
  • Context-aware based on COMP_CWORD and COMP_WORDS

Zsh Implementation

  • Uses _arguments and _describe for rich completion
  • Compatible with zsh 5.0+
  • Supports completion descriptions
  • Context-aware using $state and $words

PowerShell Implementation

  • Uses Register-ArgumentCompleter
  • Compatible with PowerShell 5.1+
  • Reads profiles dynamically using ConvertFrom-Json
  • Provides CompletionResult objects

Fish Implementation

  • Uses declarative complete command
  • Compatible with Fish 3.0+
  • Automatic loading from ~/.config/fish/completions/
  • Helper functions for dynamic profile loading
  • Context-aware using __fish_seen_subcommand_from
  • No manual sourcing required

Dependencies

  • jq: Required for reading profiles from JSON files
    • Install: brew install jq (macOS) or apt install jq (Ubuntu)
    • Already required by CCS core functionality

Contributing

When adding new commands or flags:

  1. Update all four completion scripts (bash, zsh, fish, PowerShell)
  2. Test on each shell
  3. Update this README with new completion examples
  4. Maintain cross-shell parity

See Also