Files
ccs/scripts/completion
Kai (Tam Nhu) Tranandkaitranntt fe4ff882b0 feat(cli): enhance version and help display formatting (#11)
* feat: add -sc short flag for --shell-completion

Add -sc as a short flag alias for --shell-completion,
matching the pattern of -h for --help and -v for --version.

Changes:
- bin/ccs.js: Add -sc support in help text and flag detection
- lib/ccs: Add -sc support in help text and flag detection
- lib/ccs.ps1: Add -sc support in help text and flag detection

* chore: bump version to 4.1.4

* chore: bump version to 4.1.5

* feat: emphasize concurrent account usage in auth help text

Update all auth-related help messages to emphasize the ability
to run multiple Claude accounts concurrently.

Changes:
- bin/ccs.js: "Run multiple Claude accounts concurrently"
- bin/auth/auth-commands.js: "CCS Concurrent Account Management"
- lib/ccs: Updated both main help and auth_help function
- lib/ccs.ps1: Updated both main help and Show-AuthHelp function

* feat: implement ccs update command across all platforms

Add cross-platform ccs update command to sync delegation commands
and skills from ~/.ccs/.claude/ to ~/.claude/. Replaces vague
"CCS items" wording with specific "delegation commands and skills".

Changes:
- bin/ccs.js: Add update command handler and update help text
- bin/utils/claude-symlink-manager.js: Update user-facing messages
- lib/ccs: Implement update_run() function with symlink logic
- lib/ccs.ps1: Implement Update-Run function with Junction/SymbolicLink support

Features:
- Automatically backs up existing files before symlinking
- Skips items that are already correctly symlinked
- Reports installed vs up-to-date counts
- Handles Windows permissions gracefully (suggests Admin/Developer Mode)

Cross-platform parity: bash, PowerShell, and Node.js now all support ccs update

* refactor: rename ccs update to ccs sync for clarity

Rename the update command to sync across all platforms to avoid
confusion with updating the CCS tool itself. The sync command
clearly communicates syncing delegation features from the CCS
package to ~/.claude/.

Changes:
- bin/ccs.js: Rename handleUpdateCommand → handleSyncCommand
- bin/utils/claude-symlink-manager.js: Rename update() → sync()
- lib/ccs: Rename update_run() → sync_run()
- lib/ccs.ps1: Rename Update-Run → Sync-Run
- All: Update help text "update" → "sync"
- All: Update messages "Updating" → "Syncing"

Command usage: ccs sync or ccs --sync

* fix: update GitHub documentation links to stable permalink

Update broken #usage anchor links to stable /blob/main/README.md
permalink format. This matches the format already used in PowerShell
version and ensures links always work.

Changes:
- bin/ccs.js: Update link from #usage to /blob/main/README.md
- lib/ccs: Update link from #usage to /blob/main/README.md
- Now consistent with lib/ccs.ps1 which already used this format

Old: https://github.com/kaitranntt/ccs#usage
New: https://github.com/kaitranntt/ccs/blob/main/README.md

* feat: add sync command and -sc flag to shell completions

Update all shell completion scripts to include the newly added
sync command and -sc short flag for --shell-completion.

Changes across all completion scripts (bash, zsh, fish, PowerShell):
- Add 'sync' command to completion suggestions
- Add '-sc' as short flag for '--shell-completion'
- Update fish to handle both -sc and --shell-completion for subflags
- Update PowerShell to recognize -sc for shell completion flags
- Add sync command description: "Sync delegation commands and skills"

This ensures tab completion discovers the sync command and users
can use both -sc and --shell-completion interchangeably.

* fix: standardize help text across all implementations

Fix inconsistencies in help text that appeared after merge from main.
Ensures all three implementations (bash, PowerShell, Node.js) display
identical help messages.

Changes:
- lib/ccs: Update "Delegation (Token Optimization)" → "Delegation (inside Claude Code CLI)"
- lib/ccs: Remove redundant /ccs:create line, simplify description
- lib/ccs.ps1: Add missing Delegation section
- All: Now use consistent messaging about delegation features

This ensures users see the same information regardless of which
platform they're using (Linux/macOS bash, Windows PowerShell, or npm).

* fix: update description text to emphasize concurrent sessions

Update outdated description in lib/ccs and lib/ccs.ps1 to match
the improved wording already in bin/ccs.js. The new description
better emphasizes running concurrent Claude CLI sessions.

Changes:
- lib/ccs: Update description to emphasize "Run different Claude CLI sessions concurrently"
- lib/ccs.ps1: Update description to match bash and Node.js versions
- Remove "(work, personal, team)" examples to keep description cleaner
- Emphasize "Run different Claude CLI sessions concurrently" over vague "Concurrent sessions"

Old: "Switch between multiple Claude accounts (work, personal, team) and
      alternative models (GLM, Kimi) instantly. Concurrent sessions with
      auto-recovery. Zero downtime."

New: "Switch between multiple Claude accounts and alternative models
      (GLM, Kimi) instantly. Run different Claude CLI sessions concurrently
      with auto-recovery. Zero downtime."

All three implementations now show identical, clearer description text.

* feat(cli): enhance version display formatting and delegation status

---------
2025-11-18 01:19:28 -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