feat(completions): enhance cliproxy help and update shell completion scripts

- Styled cliproxy help output with UI primitives and added status hint
- Added cliproxy --help reference to main help command
- Updated bash, zsh, fish, and PowerShell completions with:
  - Missing commands (api, cliproxy)
  - CLIProxy OAuth profiles (gemini, codex, agy, qwen)
  - Provider flags and update command flags
This commit is contained in:
kaitranntt
2025-12-06 02:28:34 -05:00
parent 244b441663
commit 59a2f2b717
6 changed files with 584 additions and 151 deletions
+69 -10
View File
@@ -18,8 +18,9 @@ _ccs_completion() {
# Top-level completion (first argument)
if [[ ${COMP_CWORD} -eq 1 ]]; then
local commands="auth profile doctor sync update"
local commands="auth api cliproxy doctor sync update"
local flags="--help --version --shell-completion -h -v -sc"
local cliproxy_profiles="gemini codex agy qwen"
local profiles=""
# Add profiles from config.json (settings-based profiles)
@@ -32,12 +33,24 @@ _ccs_completion() {
profiles="$profiles $(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null || true)"
fi
# Add cliproxy variants from config.json
if [[ -f ~/.ccs/config.json ]]; then
profiles="$profiles $(jq -r '.cliproxy | keys[]' ~/.ccs/config.json 2>/dev/null || true)"
fi
# Combine all options
local opts="$commands $flags $profiles"
local opts="$commands $flags $cliproxy_profiles $profiles"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
# CLIProxy provider flags (gemini, codex, agy, qwen)
if [[ ${COMP_WORDS[1]} =~ ^(gemini|codex|agy|qwen)$ ]]; then
local provider_flags="--auth --config --logout --headless --help -h"
COMPREPLY=( $(compgen -W "${provider_flags}" -- ${cur}) )
return 0
fi
# auth subcommands
if [[ ${prev} == "auth" ]]; then
local auth_commands="create list show remove default --help -h"
@@ -45,15 +58,54 @@ _ccs_completion() {
return 0
fi
# profile subcommands
if [[ ${prev} == "profile" ]]; then
local profile_commands="create list remove --help -h"
COMPREPLY=( $(compgen -W "${profile_commands}" -- ${cur}) )
# api subcommands
if [[ ${prev} == "api" ]]; then
local api_commands="create list remove --help -h"
COMPREPLY=( $(compgen -W "${api_commands}" -- ${cur}) )
return 0
fi
# Completion for profile subcommands
if [[ ${COMP_WORDS[1]} == "profile" ]]; then
# cliproxy subcommands
if [[ ${prev} == "cliproxy" ]]; then
local cliproxy_commands="create list remove --install --latest --help -h"
COMPREPLY=( $(compgen -W "${cliproxy_commands}" -- ${cur}) )
return 0
fi
# Completion for cliproxy subcommands
if [[ ${COMP_WORDS[1]} == "cliproxy" ]]; then
case "${prev}" in
remove|delete|rm)
# Complete with cliproxy variant names
if [[ -f ~/.ccs/config.json ]]; then
local variants=$(jq -r '.cliproxy | keys[]' ~/.ccs/config.json 2>/dev/null || true)
COMPREPLY=( $(compgen -W "${variants}" -- ${cur}) )
fi
return 0
;;
create)
# Complete with create flags
COMPREPLY=( $(compgen -W "--provider --model --force --yes -y" -- ${cur}) )
return 0
;;
--provider)
# Complete with provider names
COMPREPLY=( $(compgen -W "gemini codex agy qwen" -- ${cur}) )
return 0
;;
list|ls)
# No flags for list
return 0
;;
--install)
# User enters version number
return 0
;;
esac
fi
# Completion for api subcommands
if [[ ${COMP_WORDS[1]} == "api" ]]; then
case "${prev}" in
remove|delete|rm)
# Complete with settings profile names
@@ -87,7 +139,8 @@ _ccs_completion() {
return 0
;;
create)
# No completion for create (user enters new name)
# Complete with create flags
COMPREPLY=( $(compgen -W "--force" -- ${cur}) )
return 0
;;
list)
@@ -104,8 +157,14 @@ _ccs_completion() {
return 0
fi
# Flags for update command
if [[ ${COMP_WORDS[1]} == "update" ]]; then
COMPREPLY=( $(compgen -W "--force --beta --dev --help -h" -- ${cur}) )
return 0
fi
# Flags for shell-completion command
if [[ ${prev} == "--shell-completion" ]]; then
if [[ ${prev} == "--shell-completion" || ${prev} == "-sc" ]]; then
COMPREPLY=( $(compgen -W "--bash --zsh --fish --powershell" -- ${cur}) )
return 0
fi
+153 -72
View File
@@ -2,7 +2,7 @@
# Compatible with fish 3.0+
#
# Features:
# - Categorized completions with [cmd], [model], and [account] prefixes
# - Categorized completions with [cmd], [proxy], [model], and [account] prefixes
# - Dynamic profile loading from config.json and profiles.json
# - Context-aware subcommand completion
#
@@ -18,23 +18,19 @@
function __fish_ccs_get_settings_profiles
set -l config_path ~/.ccs/config.json
# Get settings-based profiles from config.json
if test -f $config_path
jq -r '.profiles | keys[]' $config_path 2>/dev/null
end
end
# Helper function to get custom/unknown settings profiles
# (profiles not in the hardcoded known list)
function __fish_ccs_get_custom_settings_profiles
set -l config_path ~/.ccs/config.json
set -l known_profiles default glm glmt kimi
# Get all settings profiles
if test -f $config_path
set -l all_profiles (jq -r '.profiles | keys[]' $config_path 2>/dev/null)
# Filter out known profiles
for profile in $all_profiles
if not contains $profile $known_profiles
echo $profile
@@ -43,6 +39,15 @@ function __fish_ccs_get_custom_settings_profiles
end
end
# Helper function to get cliproxy variants
function __fish_ccs_get_cliproxy_variants
set -l config_path ~/.ccs/config.json
if test -f $config_path
jq -r '.cliproxy | keys[]' $config_path 2>/dev/null
end
end
# Helper function to get profiles with all types
function __fish_ccs_get_profiles
__fish_ccs_get_settings_profiles
@@ -69,70 +74,27 @@ function __fish_ccs_using_auth_subcommand
__fish_ccs_using_auth; and __fish_seen_subcommand_from $subcommand
end
# Disable file completion for ccs
complete -c ccs -f
# Helper function to check if we're in api context
function __fish_ccs_using_api
__fish_seen_subcommand_from api
end
# Top-level flags
complete -c ccs -s h -l help -d 'Show help message'
complete -c ccs -s v -l version -d 'Show version information'
complete -c ccs -s sc -l shell-completion -d 'Install shell completion'
# Helper function to check specific api subcommand
function __fish_ccs_using_api_subcommand
set -l subcommand $argv[1]
__fish_ccs_using_api; and __fish_seen_subcommand_from $subcommand
end
# Commands - grouped with [cmd] prefix for visual distinction
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a 'auth' -d '[cmd] Manage multiple Claude accounts'
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a 'profile' -d '[cmd] Manage API profiles (create/remove)'
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a 'doctor' -d '[cmd] Run health check and diagnostics'
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a 'sync' -d '[cmd] Sync delegation commands and skills'
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a 'update' -d '[cmd] Update CCS to latest version'
# Helper function to check if we're in cliproxy context
function __fish_ccs_using_cliproxy
__fish_seen_subcommand_from cliproxy
end
# Model profiles - grouped with [model] prefix for visual distinction
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a 'default' -d '[model] Default Claude Sonnet 4.5'
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a 'glm' -d '[model] GLM-4.6 (cost-optimized)'
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a 'glmt' -d '[model] GLM-4.6 with thinking mode'
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a 'kimi' -d '[model] Kimi for Coding (long-context)'
# Custom model profiles - dynamic with [model] prefix
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a '(__fish_ccs_get_custom_settings_profiles)' -d '[model] Settings-based profile'
# Account profiles - dynamic with [account] prefix
complete -c ccs -n 'not __fish_seen_subcommand_from auth profile doctor sync update' -a '(__fish_ccs_get_account_profiles)' -d '[account] Account-based profile'
# shell-completion subflags
complete -c ccs -n '__fish_seen_argument -l shell-completion; or __fish_seen_argument -s sc' -l bash -d 'Install for bash'
complete -c ccs -n '__fish_seen_argument -l shell-completion; or __fish_seen_argument -s sc' -l zsh -d 'Install for zsh'
complete -c ccs -n '__fish_seen_argument -l shell-completion; or __fish_seen_argument -s sc' -l fish -d 'Install for fish'
complete -c ccs -n '__fish_seen_argument -l shell-completion; or __fish_seen_argument -s sc' -l powershell -d 'Install for PowerShell'
# auth subcommands
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'create' -d 'Create new profile and login'
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'list' -d 'List all saved profiles'
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'show' -d 'Show profile details'
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'remove' -d 'Remove saved profile'
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'default' -d 'Set default profile'
# auth command flags
complete -c ccs -n '__fish_ccs_using_auth' -s h -l help -d 'Show help for auth commands'
# auth create flags
complete -c ccs -n '__fish_ccs_using_auth_subcommand create' -l force -d 'Allow overwriting existing profile'
# auth list flags
complete -c ccs -n '__fish_ccs_using_auth_subcommand list' -l verbose -d 'Show additional details'
complete -c ccs -n '__fish_ccs_using_auth_subcommand list' -l json -d 'Output in JSON format'
# auth show - profile names and flags
complete -c ccs -n '__fish_ccs_using_auth_subcommand show' -a '(__fish_ccs_get_account_profiles)' -d 'Account profile'
complete -c ccs -n '__fish_ccs_using_auth_subcommand show' -l json -d 'Output in JSON format'
# auth remove - profile names and flags
complete -c ccs -n '__fish_ccs_using_auth_subcommand remove' -a '(__fish_ccs_get_account_profiles)' -d 'Account profile'
complete -c ccs -n '__fish_ccs_using_auth_subcommand remove' -l yes -d 'Skip confirmation prompts'
complete -c ccs -n '__fish_ccs_using_auth_subcommand remove' -s y -d 'Skip confirmation prompts'
# auth default - profile names only
complete -c ccs -n '__fish_ccs_using_auth_subcommand default' -a '(__fish_ccs_get_account_profiles)' -d 'Account profile'
# doctor command flags
complete -c ccs -n '__fish_seen_subcommand_from doctor' -s h -l help -d 'Show help for doctor command'
# Helper function to check specific cliproxy subcommand
function __fish_ccs_using_cliproxy_subcommand
set -l subcommand $argv[1]
__fish_ccs_using_cliproxy; and __fish_seen_subcommand_from $subcommand
end
# Helper function to check if we're in profile context
function __fish_ccs_using_profile
@@ -145,23 +107,142 @@ function __fish_ccs_using_profile_subcommand
__fish_ccs_using_profile; and __fish_seen_subcommand_from $subcommand
end
# profile subcommands
# Helper function to check if we're using a CLIProxy provider
function __fish_ccs_using_provider
__fish_seen_subcommand_from gemini codex agy qwen
end
# Disable file completion for ccs
complete -c ccs -f
# Top-level flags
complete -c ccs -s h -l help -d 'Show help message'
complete -c ccs -s v -l version -d 'Show version information'
complete -c ccs -s sc -l shell-completion -d 'Install shell completion'
# Commands - grouped with [cmd] prefix for visual distinction
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'auth' -d '[cmd] Manage multiple Claude accounts'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'api' -d '[cmd] Manage API profiles (create/remove)'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'cliproxy' -d '[cmd] Manage CLIProxy variants and binary'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'doctor' -d '[cmd] Run health check and diagnostics'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'sync' -d '[cmd] Sync delegation commands and skills'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'update' -d '[cmd] Update CCS to latest version'
# CLIProxy profiles - grouped with [proxy] prefix for OAuth providers
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'gemini' -d '[proxy] Google Gemini (OAuth)'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'codex' -d '[proxy] OpenAI Codex (OAuth)'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'agy' -d '[proxy] Antigravity (OAuth)'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'qwen' -d '[proxy] Qwen Code (OAuth)'
# Model profiles - grouped with [model] prefix for visual distinction
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'default' -d '[model] Default Claude Sonnet 4.5'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'glm' -d '[model] GLM-4.6 (cost-optimized)'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'glmt' -d '[model] GLM-4.6 with thinking mode'
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a 'kimi' -d '[model] Kimi for Coding (long-context)'
# Custom model profiles - dynamic with [model] prefix
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a '(__fish_ccs_get_custom_settings_profiles)' -d '[model] Settings-based profile'
# CLIProxy variants - dynamic with [variant] prefix
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a '(__fish_ccs_get_cliproxy_variants)' -d '[variant] CLIProxy variant'
# Account profiles - dynamic with [account] prefix
complete -c ccs -n 'not __fish_seen_subcommand_from auth api cliproxy doctor sync update gemini codex agy qwen' -a '(__fish_ccs_get_account_profiles)' -d '[account] Account-based profile'
# shell-completion subflags
complete -c ccs -n '__fish_seen_argument -l shell-completion; or __fish_seen_argument -s sc' -l bash -d 'Install for bash'
complete -c ccs -n '__fish_seen_argument -l shell-completion; or __fish_seen_argument -s sc' -l zsh -d 'Install for zsh'
complete -c ccs -n '__fish_seen_argument -l shell-completion; or __fish_seen_argument -s sc' -l fish -d 'Install for fish'
complete -c ccs -n '__fish_seen_argument -l shell-completion; or __fish_seen_argument -s sc' -l powershell -d 'Install for PowerShell'
# CLIProxy provider flags (gemini, codex, agy, qwen)
complete -c ccs -n '__fish_ccs_using_provider' -l auth -d 'Authenticate only'
complete -c ccs -n '__fish_ccs_using_provider' -l config -d 'Change model configuration'
complete -c ccs -n '__fish_ccs_using_provider' -l logout -d 'Clear authentication'
complete -c ccs -n '__fish_ccs_using_provider' -l headless -d 'Headless auth (for SSH)'
complete -c ccs -n '__fish_ccs_using_provider' -s h -l help -d 'Show help'
# update command flags
complete -c ccs -n '__fish_seen_subcommand_from update' -l force -d 'Force reinstall current version'
complete -c ccs -n '__fish_seen_subcommand_from update' -l beta -d 'Install from dev channel'
complete -c ccs -n '__fish_seen_subcommand_from update' -l dev -d 'Install from dev channel'
complete -c ccs -n '__fish_seen_subcommand_from update' -s h -l help -d 'Show help'
# doctor command flags
complete -c ccs -n '__fish_seen_subcommand_from doctor' -s h -l help -d 'Show help for doctor command'
# ============================================================================
# auth subcommands
# ============================================================================
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'create' -d 'Create new profile and login'
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'list' -d 'List all saved profiles'
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'show' -d 'Show profile details'
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'remove' -d 'Remove saved profile'
complete -c ccs -n '__fish_ccs_using_auth; and not __fish_seen_subcommand_from create list show remove default' -a 'default' -d 'Set default profile'
complete -c ccs -n '__fish_ccs_using_auth' -s h -l help -d 'Show help for auth commands'
complete -c ccs -n '__fish_ccs_using_auth_subcommand create' -l force -d 'Allow overwriting existing profile'
complete -c ccs -n '__fish_ccs_using_auth_subcommand list' -l verbose -d 'Show additional details'
complete -c ccs -n '__fish_ccs_using_auth_subcommand list' -l json -d 'Output in JSON format'
complete -c ccs -n '__fish_ccs_using_auth_subcommand show' -a '(__fish_ccs_get_account_profiles)' -d 'Account profile'
complete -c ccs -n '__fish_ccs_using_auth_subcommand show' -l json -d 'Output in JSON format'
complete -c ccs -n '__fish_ccs_using_auth_subcommand remove' -a '(__fish_ccs_get_account_profiles)' -d 'Account profile'
complete -c ccs -n '__fish_ccs_using_auth_subcommand remove' -l yes -d 'Skip confirmation prompts'
complete -c ccs -n '__fish_ccs_using_auth_subcommand remove' -s y -d 'Skip confirmation prompts'
complete -c ccs -n '__fish_ccs_using_auth_subcommand default' -a '(__fish_ccs_get_account_profiles)' -d 'Account profile'
# ============================================================================
# api subcommands
# ============================================================================
complete -c ccs -n '__fish_ccs_using_api; and not __fish_seen_subcommand_from create list remove' -a 'create' -d 'Create new API profile'
complete -c ccs -n '__fish_ccs_using_api; and not __fish_seen_subcommand_from create list remove' -a 'list' -d 'List all API profiles'
complete -c ccs -n '__fish_ccs_using_api; and not __fish_seen_subcommand_from create list remove' -a 'remove' -d 'Remove an API profile'
complete -c ccs -n '__fish_ccs_using_api' -s h -l help -d 'Show help for api commands'
complete -c ccs -n '__fish_ccs_using_api_subcommand create' -l base-url -d 'API base URL'
complete -c ccs -n '__fish_ccs_using_api_subcommand create' -l api-key -d 'API key'
complete -c ccs -n '__fish_ccs_using_api_subcommand create' -l model -d 'Default model'
complete -c ccs -n '__fish_ccs_using_api_subcommand create' -l force -d 'Overwrite existing profile'
complete -c ccs -n '__fish_ccs_using_api_subcommand create' -l yes -d 'Skip prompts'
complete -c ccs -n '__fish_ccs_using_api_subcommand create' -s y -d 'Skip prompts'
complete -c ccs -n '__fish_ccs_using_api_subcommand remove' -a '(__fish_ccs_get_settings_profiles)' -d 'Settings profile'
complete -c ccs -n '__fish_ccs_using_api_subcommand remove' -l yes -d 'Skip confirmation'
complete -c ccs -n '__fish_ccs_using_api_subcommand remove' -s y -d 'Skip confirmation'
# ============================================================================
# cliproxy subcommands
# ============================================================================
complete -c ccs -n '__fish_ccs_using_cliproxy; and not __fish_seen_subcommand_from create list remove' -a 'create' -d 'Create new CLIProxy variant'
complete -c ccs -n '__fish_ccs_using_cliproxy; and not __fish_seen_subcommand_from create list remove' -a 'list' -d 'List all CLIProxy variants'
complete -c ccs -n '__fish_ccs_using_cliproxy; and not __fish_seen_subcommand_from create list remove' -a 'remove' -d 'Remove a CLIProxy variant'
complete -c ccs -n '__fish_ccs_using_cliproxy' -s h -l help -d 'Show help for cliproxy commands'
complete -c ccs -n '__fish_ccs_using_cliproxy' -l install -d 'Install specific version'
complete -c ccs -n '__fish_ccs_using_cliproxy' -l latest -d 'Install latest version'
complete -c ccs -n '__fish_ccs_using_cliproxy_subcommand create' -l provider -d 'Provider name'
complete -c ccs -n '__fish_ccs_using_cliproxy_subcommand create; and __fish_seen_argument -l provider' -a 'gemini codex agy qwen' -d 'Provider'
complete -c ccs -n '__fish_ccs_using_cliproxy_subcommand create' -l model -d 'Model name'
complete -c ccs -n '__fish_ccs_using_cliproxy_subcommand create' -l force -d 'Overwrite existing variant'
complete -c ccs -n '__fish_ccs_using_cliproxy_subcommand create' -l yes -d 'Skip prompts'
complete -c ccs -n '__fish_ccs_using_cliproxy_subcommand create' -s y -d 'Skip prompts'
complete -c ccs -n '__fish_ccs_using_cliproxy_subcommand remove' -a '(__fish_ccs_get_cliproxy_variants)' -d 'CLIProxy variant'
complete -c ccs -n '__fish_ccs_using_cliproxy_subcommand remove' -l yes -d 'Skip confirmation'
complete -c ccs -n '__fish_ccs_using_cliproxy_subcommand remove' -s y -d 'Skip confirmation'
# ============================================================================
# profile subcommands (legacy - redirects to api)
# ============================================================================
complete -c ccs -n '__fish_ccs_using_profile; and not __fish_seen_subcommand_from create list remove' -a 'create' -d 'Create new API profile'
complete -c ccs -n '__fish_ccs_using_profile; and not __fish_seen_subcommand_from create list remove' -a 'list' -d 'List all profiles'
complete -c ccs -n '__fish_ccs_using_profile; and not __fish_seen_subcommand_from create list remove' -a 'remove' -d 'Remove a profile'
# profile command flags
complete -c ccs -n '__fish_ccs_using_profile' -s h -l help -d 'Show help for profile commands'
# profile create flags
complete -c ccs -n '__fish_ccs_using_profile_subcommand create' -l base-url -d 'API base URL'
complete -c ccs -n '__fish_ccs_using_profile_subcommand create' -l api-key -d 'API key'
complete -c ccs -n '__fish_ccs_using_profile_subcommand create' -l model -d 'Default model'
complete -c ccs -n '__fish_ccs_using_profile_subcommand create' -l force -d 'Overwrite existing profile'
complete -c ccs -n '__fish_ccs_using_profile_subcommand create' -l yes -d 'Skip prompts'
complete -c ccs -n '__fish_ccs_using_profile_subcommand create' -s y -d 'Skip prompts'
# profile remove - profile names and flags
complete -c ccs -n '__fish_ccs_using_profile_subcommand remove' -a '(__fish_ccs_get_settings_profiles)' -d 'Settings profile'
complete -c ccs -n '__fish_ccs_using_profile_subcommand remove' -l yes -d 'Skip confirmation'
complete -c ccs -n '__fish_ccs_using_profile_subcommand remove' -s y -d 'Skip confirmation'
+180 -15
View File
@@ -12,14 +12,20 @@
Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
param($commandName, $wordToComplete, $commandAst, $fakeBoundParameters)
$commands = @('auth', 'profile', 'doctor', 'sync', 'update', '--help', '--version', '--shell-completion', '-h', '-v', '-sc')
$commands = @('auth', 'api', 'cliproxy', 'doctor', 'sync', 'update', '--help', '--version', '--shell-completion', '-h', '-v', '-sc')
$cliproxyProfiles = @('gemini', 'codex', 'agy', 'qwen')
$authCommands = @('create', 'list', 'show', 'remove', 'default', '--help', '-h')
$profileCommands = @('create', 'list', 'remove', '--help', '-h')
$profileCreateFlags = @('--base-url', '--api-key', '--model', '--force', '--yes', '-y')
$apiCommands = @('create', 'list', 'remove', '--help', '-h')
$cliproxyCommands = @('create', 'list', 'remove', '--install', '--latest', '--help', '-h')
$apiCreateFlags = @('--base-url', '--api-key', '--model', '--force', '--yes', '-y')
$cliproxyCreateFlags = @('--provider', '--model', '--force', '--yes', '-y')
$providerFlags = @('--auth', '--config', '--logout', '--headless', '--help', '-h')
$updateFlags = @('--force', '--beta', '--dev', '--help', '-h')
$shellCompletionFlags = @('--bash', '--zsh', '--fish', '--powershell')
$listFlags = @('--verbose', '--json')
$removeFlags = @('--yes', '-y')
$showFlags = @('--json')
$providers = @('gemini', 'codex', 'agy', 'qwen')
# Get current position in command
$words = $commandAst.ToString() -split '\s+' | Where-Object { $_ -ne '' }
@@ -53,12 +59,25 @@ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
}
}
# CLIProxy variants
if ($Type -in @('all', 'cliproxy')) {
$configPath = "$env:USERPROFILE\.ccs\config.json"
if (Test-Path $configPath) {
try {
$config = Get-Content $configPath -Raw | ConvertFrom-Json
if ($config.cliproxy) {
$profiles += $config.cliproxy.PSObject.Properties.Name
}
} catch {}
}
}
return $profiles | Sort-Object -Unique
}
# Top-level completion
if ($position -eq 2) {
$allOptions = $commands + (Get-CcsProfiles)
$allOptions = $commands + $cliproxyProfiles + (Get-CcsProfiles)
$allOptions | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
@@ -85,10 +104,35 @@ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
return
}
# CLIProxy provider flags (gemini, codex, agy, qwen)
if ($words[1] -in $cliproxyProfiles) {
$providerFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
return
}
# update command completion
if ($words[1] -eq 'update') {
$updateFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
return
}
# auth subcommand completion
if ($words[1] -eq 'auth') {
if ($position -eq 3) {
# auth subcommands
$authCommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
@@ -98,7 +142,6 @@ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
)
}
} elseif ($position -eq 4) {
# Profile names or flags for auth subcommands
switch ($words[2]) {
'show' {
$options = (Get-CcsProfiles -Type account) + $showFlags
@@ -143,11 +186,17 @@ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
}
}
'create' {
# No completion for create (user types new name)
@('--force') | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
}
}
} elseif ($position -eq 5) {
# Flags after profile name
switch ($words[2]) {
'show' {
$showFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
@@ -171,13 +220,13 @@ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
}
}
}
return
}
# profile subcommand completion
if ($words[1] -eq 'profile') {
# api subcommand completion
if ($words[1] -eq 'api') {
if ($position -eq 3) {
# profile subcommands
$profileCommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
$apiCommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
@@ -186,7 +235,6 @@ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
)
}
} elseif ($position -eq 4) {
# Profile names or flags for profile subcommands
switch ($words[2]) {
'remove' {
$options = (Get-CcsProfiles -Type settings) + $removeFlags
@@ -200,7 +248,7 @@ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
}
}
'create' {
$profileCreateFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
$apiCreateFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
@@ -211,7 +259,6 @@ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
}
}
} elseif ($position -eq 5) {
# Flags after profile name
switch ($words[2]) {
'remove' {
$removeFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
@@ -225,5 +272,123 @@ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
}
}
}
return
}
# cliproxy subcommand completion
if ($words[1] -eq 'cliproxy') {
if ($position -eq 3) {
$cliproxyCommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
} elseif ($position -eq 4) {
switch ($words[2]) {
'remove' {
$options = (Get-CcsProfiles -Type cliproxy) + $removeFlags
$options | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
}
'create' {
$cliproxyCreateFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
}
}
} elseif ($position -eq 5) {
switch ($words[2]) {
'remove' {
$removeFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
}
'create' {
# After --provider, complete with provider names
if ($words[3] -eq '--provider') {
$providers | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
}
}
}
}
return
}
# profile subcommand completion (legacy)
if ($words[1] -eq 'profile') {
if ($position -eq 3) {
@('create', 'list', 'remove', '--help', '-h') | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
} elseif ($position -eq 4) {
switch ($words[2]) {
'remove' {
$options = (Get-CcsProfiles -Type settings) + $removeFlags
$options | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
}
'create' {
$apiCreateFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
}
}
} elseif ($position -eq 5) {
switch ($words[2]) {
'remove' {
$removeFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
[System.Management.Automation.CompletionResult]::new(
$_,
$_,
'ParameterValue',
$_
)
}
}
}
}
return
}
}
+107 -28
View File
@@ -13,10 +13,8 @@
# sudo cp scripts/completion/ccs.zsh /usr/local/share/zsh/site-functions/_ccs
# Set up completion styles for better formatting and colors
# Color codes: 0;34=blue, 0;32=green, 0;33=yellow, 2;37=dim white
# Pattern format: =(#b)(group1)(group2)==color_for_group1=color_for_group2
# The leading '=' means no color for whole match, then each '=' assigns to each group
zstyle ':completion:*:*:ccs:*:commands' list-colors '=(#b)(auth|profile|doctor|sync|update)([[:space:]]#--[[:space:]]#*)==0\;34=2\;37'
zstyle ':completion:*:*:ccs:*:commands' list-colors '=(#b)(auth|api|cliproxy|doctor|sync|update)([[:space:]]#--[[:space:]]#*)==0\;34=2\;37'
zstyle ':completion:*:*:ccs:*:proxy-profiles' list-colors '=(#b)(gemini|codex|agy|qwen)([[:space:]]#--[[:space:]]#*)==0\;35=2\;37'
zstyle ':completion:*:*:ccs:*:model-profiles' list-colors '=(#b)(default|glm|glmt|kimi|[^[:space:]]##)([[:space:]]#--[[:space:]]#*)==0\;32=2\;37'
zstyle ':completion:*:*:ccs:*:account-profiles' list-colors '=(#b)([^[:space:]]##)([[:space:]]#--[[:space:]]#*)==0\;33=2\;37'
zstyle ':completion:*:*:ccs:*' group-name ''
@@ -26,20 +24,29 @@ zstyle ':completion:*:*:ccs:*' list-rows-first true
zstyle ':completion:*:*:ccs:*' menu select
_ccs() {
local -a commands settings_profiles_described account_profiles_described
local -a commands proxy_profiles settings_profiles_described account_profiles_described cliproxy_variants_described
local curcontext="$curcontext" state line
typeset -A opt_args
# Define top-level commands (padded for alignment)
# Define top-level commands
commands=(
'auth:Manage multiple Claude accounts'
'profile:Manage API profiles (create/remove)'
'api:Manage API profiles (create/remove)'
'cliproxy:Manage CLIProxy variants and binary'
'doctor:Run health check and diagnostics'
'sync:Sync delegation commands and skills'
'update:Update CCS to latest version'
)
# Define known settings profiles with descriptions (consistent padding)
# Define CLIProxy hardcoded profiles (OAuth providers)
proxy_profiles=(
'gemini:Google Gemini (OAuth)'
'codex:OpenAI Codex (OAuth)'
'agy:Antigravity (OAuth)'
'qwen:Qwen Code (OAuth)'
)
# Define known settings profiles with descriptions
local -A profile_descriptions
profile_descriptions=(
'default' 'Default Claude Sonnet 4.5'
@@ -53,7 +60,6 @@ _ccs() {
local -a raw_settings_profiles
raw_settings_profiles=(${(f)"$(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null)"})
# Add descriptions to settings profiles
for profile in $raw_settings_profiles; do
local desc="${profile_descriptions[$profile]:-Settings-based profile}"
settings_profiles_described+=("${profile}:${desc}")
@@ -65,12 +71,21 @@ _ccs() {
local -a raw_account_profiles
raw_account_profiles=(${(f)"$(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null)"})
# Add descriptions to account profiles
for profile in $raw_account_profiles; do
account_profiles_described+=("${profile}:Account-based profile")
done
fi
# Load cliproxy variants from config.json
if [[ -f ~/.ccs/config.json ]]; then
local -a raw_cliproxy_variants
raw_cliproxy_variants=(${(f)"$(jq -r '.cliproxy | keys[]' ~/.ccs/config.json 2>/dev/null)"})
for variant in $raw_cliproxy_variants; do
cliproxy_variants_described+=("${variant}:CLIProxy variant")
done
fi
_arguments -C \
'(- *)'{-h,--help}'[Show help message]' \
'(- *)'{-v,--version}'[Show version information]' \
@@ -80,10 +95,11 @@ _ccs() {
case $state in
command)
# Describe commands and profiles with proper tagging for colors
_describe -t commands 'commands' commands
_describe -t proxy-profiles 'CLIProxy profiles' proxy_profiles
_describe -t model-profiles 'model profiles' settings_profiles_described
_describe -t account-profiles 'account profiles' account_profiles_described
_describe -t cliproxy-variants 'CLIProxy variants' cliproxy_variants_described
;;
args)
@@ -91,14 +107,32 @@ _ccs() {
auth)
_ccs_auth
;;
profile)
_ccs_profile
api)
_ccs_api
;;
cliproxy)
_ccs_cliproxy
;;
update)
_arguments \
'--force[Force reinstall current version]' \
'--beta[Install from dev channel]' \
'--dev[Install from dev channel]' \
'(- *)'{-h,--help}'[Show help]'
;;
doctor)
_arguments \
'(- *)'{-h,--help}'[Show help for doctor command]'
;;
--shell-completion)
gemini|codex|agy|qwen)
_arguments \
'--auth[Authenticate only]' \
'--config[Change model configuration]' \
'--logout[Clear authentication]' \
'--headless[Headless auth (for SSH)]' \
'(- *)'{-h,--help}'[Show help]'
;;
--shell-completion|-sc)
_arguments \
'--bash[Install for bash]' \
'--zsh[Install for zsh]' \
@@ -106,7 +140,6 @@ _ccs() {
'--powershell[Install for PowerShell]'
;;
*)
# For profile names, complete with Claude CLI arguments
_message 'Claude CLI arguments'
;;
esac
@@ -114,32 +147,30 @@ _ccs() {
esac
}
_ccs_profile() {
_ccs_api() {
local curcontext="$curcontext" state line
typeset -A opt_args
local -a profile_commands settings_profiles
local -a api_commands settings_profiles
# Define profile subcommands
profile_commands=(
api_commands=(
'create:Create new API profile (interactive)'
'list:List all profiles'
'remove:Remove a profile'
'list:List all API profiles'
'remove:Remove an API profile'
)
# Load settings profiles for remove command
if [[ -f ~/.ccs/config.json ]]; then
settings_profiles=(${(f)"$(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null)"})
fi
_arguments -C \
'(- *)'{-h,--help}'[Show help for profile commands]' \
'(- *)'{-h,--help}'[Show help for api commands]' \
'1: :->subcommand' \
'*:: :->subargs'
case $state in
subcommand)
_describe -t profile-commands 'profile commands' profile_commands
_describe -t api-commands 'api commands' api_commands
;;
subargs)
@@ -154,7 +185,6 @@ _ccs_profile() {
{--yes,-y}'[Skip prompts]'
;;
list)
# No arguments
;;
remove|delete|rm)
_arguments \
@@ -166,13 +196,64 @@ _ccs_profile() {
esac
}
_ccs_cliproxy() {
local curcontext="$curcontext" state line
typeset -A opt_args
local -a cliproxy_commands cliproxy_variants providers
cliproxy_commands=(
'create:Create new CLIProxy variant profile'
'list:List all CLIProxy variant profiles'
'remove:Remove a CLIProxy variant profile'
)
providers=(gemini codex agy qwen)
if [[ -f ~/.ccs/config.json ]]; then
cliproxy_variants=(${(f)"$(jq -r '.cliproxy | keys[]' ~/.ccs/config.json 2>/dev/null)"})
fi
_arguments -C \
'(- *)'{-h,--help}'[Show help for cliproxy commands]' \
'--install[Install specific version]:version:' \
'--latest[Install latest version]' \
'1: :->subcommand' \
'*:: :->subargs'
case $state in
subcommand)
_describe -t cliproxy-commands 'cliproxy commands' cliproxy_commands
;;
subargs)
case $words[1] in
create)
_arguments \
'1:variant name:' \
'--provider[Provider name]:provider:($providers)' \
'--model[Model name]:model:' \
'--force[Overwrite existing variant]' \
{--yes,-y}'[Skip prompts]'
;;
list|ls)
;;
remove|delete|rm)
_arguments \
'1:variant:($cliproxy_variants)' \
{--yes,-y}'[Skip confirmation]'
;;
esac
;;
esac
}
_ccs_auth() {
local curcontext="$curcontext" state line
typeset -A opt_args
local -a auth_commands account_profiles
# Define auth subcommands
auth_commands=(
'create:Create new profile and login'
'list:List all saved profiles'
@@ -181,7 +262,6 @@ _ccs_auth() {
'default:Set default profile'
)
# Load account profiles
if [[ -f ~/.ccs/profiles.json ]]; then
account_profiles=(${(f)"$(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null)"})
fi
@@ -225,5 +305,4 @@ _ccs_auth() {
esac
}
# Register the completion function
_ccs "$@"
+74 -26
View File
@@ -494,39 +494,85 @@ async function handleRemove(args: string[]): Promise<void> {
// ============================================================================
/**
* Show cliproxy command help
* Show cliproxy command help with styled UI
*/
function showHelp(): void {
async function showHelp(): Promise<void> {
await initUI();
console.log('');
console.log('Usage: ccs cliproxy <command> [options]');
console.log(header('CLIProxy Management'));
console.log('');
console.log('Manage CLIProxy variants and binary installation.');
// Usage
console.log(subheader('Usage:'));
console.log(` ${color('ccs cliproxy', 'command')} <command> [options]`);
console.log('');
console.log('Profile Commands:');
console.log(' create [name] Create new CLIProxy variant profile');
console.log(' list List all CLIProxy variant profiles');
console.log(' remove <name> Remove a CLIProxy variant profile');
// Profile Commands
console.log(subheader('Profile Commands:'));
const profileCmds: [string, string][] = [
['create [name]', 'Create new CLIProxy variant profile'],
['list', 'List all CLIProxy variant profiles'],
['remove <name>', 'Remove a CLIProxy variant profile'],
];
const maxProfileLen = Math.max(...profileCmds.map(([cmd]) => cmd.length));
for (const [cmd, desc] of profileCmds) {
console.log(` ${color(cmd.padEnd(maxProfileLen + 2), 'command')} ${desc}`);
}
console.log('');
console.log('Binary Commands:');
console.log(' --install <version> Install a specific binary version');
console.log(' --latest Install the latest binary version');
// Binary Commands
console.log(subheader('Binary Commands:'));
const binaryCmds: [string, string][] = [
['--install <version>', 'Install a specific binary version'],
['--latest', 'Install the latest binary version'],
];
const maxBinaryLen = Math.max(...binaryCmds.map(([cmd]) => cmd.length));
for (const [cmd, desc] of binaryCmds) {
console.log(` ${color(cmd.padEnd(maxBinaryLen + 2), 'command')} ${desc}`);
}
console.log('');
console.log('Create Options:');
console.log(' --provider <name> Provider (gemini, codex, agy, qwen)');
console.log(' --model <model> Model name');
console.log(' --force Overwrite existing variant');
console.log(' --yes, -y Skip confirmation prompts');
// Create Options
console.log(subheader('Create Options:'));
const createOpts: [string, string][] = [
['--provider <name>', 'Provider (gemini, codex, agy, qwen)'],
['--model <model>', 'Model name'],
['--force', 'Overwrite existing variant'],
['--yes, -y', 'Skip confirmation prompts'],
];
const maxOptLen = Math.max(...createOpts.map(([opt]) => opt.length));
for (const [opt, desc] of createOpts) {
console.log(` ${color(opt.padEnd(maxOptLen + 2), 'command')} ${desc}`);
}
console.log('');
console.log('Examples:');
console.log(' ccs cliproxy create Interactive wizard');
console.log(' ccs cliproxy create g3 --provider gemini --model gemini-3-pro-preview');
console.log(' ccs cliproxy list Show all variants');
console.log(' ccs cliproxy remove g3 Remove variant');
console.log(' ccs cliproxy --latest Update binary');
// Examples
console.log(subheader('Examples:'));
console.log(
` $ ${color('ccs cliproxy create', 'command')} ${dim('# Interactive wizard')}`
);
console.log(` $ ${color('ccs cliproxy create g3 --provider gemini', 'command')}`);
console.log(
` ${color('--model gemini-3-pro-preview', 'command')} ${dim('# Non-interactive')}`
);
console.log(
` $ ${color('ccs cliproxy list', 'command')} ${dim('# Show all variants')}`
);
console.log(
` $ ${color('ccs cliproxy remove g3', 'command')} ${dim('# Remove variant')}`
);
console.log(
` $ ${color('ccs cliproxy --latest', 'command')} ${dim('# Update binary')}`
);
console.log('');
console.log('Notes:');
console.log(` Default fallback version: ${CLIPROXY_FALLBACK_VERSION}`);
console.log(' Releases: https://github.com/router-for-me/CLIProxyAPI/releases');
// Notes
console.log(subheader('Notes:'));
console.log(` Default fallback version: ${color(CLIPROXY_FALLBACK_VERSION, 'info')}`);
console.log(
` Releases: ${color('https://github.com/router-for-me/CLIProxyAPI/releases', 'path')}`
);
console.log('');
}
@@ -577,6 +623,8 @@ async function showStatus(verbose: boolean): Promise<void> {
}
console.log('');
console.log(dim(`Run "ccs cliproxy --help" for all available commands`));
console.log('');
}
/**
@@ -657,7 +705,7 @@ export async function handleCliproxyCommand(args: string[]): Promise<void> {
// Handle --help
if (args.includes('--help') || args.includes('-h')) {
showHelp();
await showHelp();
return;
}
+1
View File
@@ -207,6 +207,7 @@ Claude Code Profile & Model Switcher`.trim();
// CLI Proxy management
printSubSection('CLI Proxy Management', [
['ccs cliproxy', 'Show CLIProxyAPI status and version'],
['ccs cliproxy --help', 'Full CLIProxy management help'],
['ccs cliproxy --install <ver>', 'Install specific version (e.g., 6.5.40)'],
['ccs cliproxy --latest', 'Update to latest version'],
]);