@kaitranntt/ccs 3.4.6 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +470 -146
- package/README.md +338 -151
- package/README.vi.md +484 -157
- package/VERSION +1 -1
- package/bin/auth/auth-commands.js +98 -13
- package/bin/auth/profile-detector.js +11 -6
- package/bin/ccs.js +87 -2
- package/bin/utils/error-codes.js +59 -0
- package/bin/utils/error-manager.js +38 -32
- package/bin/utils/helpers.js +65 -1
- package/bin/utils/progress-indicator.js +111 -0
- package/bin/utils/prompt.js +134 -0
- package/bin/utils/shell-completion.js +234 -0
- package/lib/ccs +541 -25
- package/lib/ccs.ps1 +381 -20
- package/lib/error-codes.ps1 +55 -0
- package/lib/error-codes.sh +63 -0
- package/lib/progress-indicator.ps1 +120 -0
- package/lib/progress-indicator.sh +117 -0
- package/lib/prompt.ps1 +109 -0
- package/lib/prompt.sh +99 -0
- package/package.json +1 -1
- package/scripts/completion/README.md +308 -0
- package/scripts/completion/ccs.bash +81 -0
- package/scripts/completion/ccs.fish +92 -0
- package/scripts/completion/ccs.ps1 +157 -0
- package/scripts/completion/ccs.zsh +130 -0
- package/scripts/postinstall.js +24 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
#compdef ccs
|
|
2
|
+
|
|
3
|
+
# Zsh completion for CCS (Claude Code Switch)
|
|
4
|
+
# Compatible with zsh 5.0+
|
|
5
|
+
#
|
|
6
|
+
# Installation:
|
|
7
|
+
# Add to ~/.zshrc:
|
|
8
|
+
# fpath=(~/.zsh/completion $fpath)
|
|
9
|
+
# autoload -Uz compinit && compinit
|
|
10
|
+
# source /path/to/ccs/scripts/completion/ccs.zsh
|
|
11
|
+
#
|
|
12
|
+
# Or install system-wide:
|
|
13
|
+
# sudo cp scripts/completion/ccs.zsh /usr/local/share/zsh/site-functions/_ccs
|
|
14
|
+
|
|
15
|
+
_ccs() {
|
|
16
|
+
local -a commands profiles settings_profiles account_profiles
|
|
17
|
+
local curcontext="$curcontext" state line
|
|
18
|
+
typeset -A opt_args
|
|
19
|
+
|
|
20
|
+
# Define top-level commands
|
|
21
|
+
commands=(
|
|
22
|
+
'auth:Manage multiple Claude accounts'
|
|
23
|
+
'doctor:Run health check and diagnostics'
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
# Load settings-based profiles from config.json
|
|
27
|
+
if [[ -f ~/.ccs/config.json ]]; then
|
|
28
|
+
settings_profiles=(${(f)"$(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null)"})
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Load account-based profiles from profiles.json
|
|
32
|
+
if [[ -f ~/.ccs/profiles.json ]]; then
|
|
33
|
+
account_profiles=(${(f)"$(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null)"})
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
# Combine all profiles
|
|
37
|
+
profiles=($settings_profiles $account_profiles)
|
|
38
|
+
|
|
39
|
+
_arguments -C \
|
|
40
|
+
'(- *)'{-h,--help}'[Show help message]' \
|
|
41
|
+
'(- *)'{-v,--version}'[Show version information]' \
|
|
42
|
+
'1: :->command' \
|
|
43
|
+
'*:: :->args'
|
|
44
|
+
|
|
45
|
+
case $state in
|
|
46
|
+
command)
|
|
47
|
+
local -a all_options
|
|
48
|
+
all_options=($commands $profiles)
|
|
49
|
+
_describe -t commands 'ccs commands' all_options
|
|
50
|
+
;;
|
|
51
|
+
|
|
52
|
+
args)
|
|
53
|
+
case $words[1] in
|
|
54
|
+
auth)
|
|
55
|
+
_ccs_auth
|
|
56
|
+
;;
|
|
57
|
+
doctor)
|
|
58
|
+
_arguments \
|
|
59
|
+
'(- *)'{-h,--help}'[Show help for doctor command]'
|
|
60
|
+
;;
|
|
61
|
+
*)
|
|
62
|
+
# For profile names, complete with Claude CLI arguments
|
|
63
|
+
_message 'Claude CLI arguments'
|
|
64
|
+
;;
|
|
65
|
+
esac
|
|
66
|
+
;;
|
|
67
|
+
esac
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_ccs_auth() {
|
|
71
|
+
local curcontext="$curcontext" state line
|
|
72
|
+
typeset -A opt_args
|
|
73
|
+
|
|
74
|
+
local -a auth_commands account_profiles
|
|
75
|
+
|
|
76
|
+
# Define auth subcommands
|
|
77
|
+
auth_commands=(
|
|
78
|
+
'create:Create new profile and login'
|
|
79
|
+
'list:List all saved profiles'
|
|
80
|
+
'show:Show profile details'
|
|
81
|
+
'remove:Remove saved profile'
|
|
82
|
+
'default:Set default profile'
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# Load account profiles
|
|
86
|
+
if [[ -f ~/.ccs/profiles.json ]]; then
|
|
87
|
+
account_profiles=(${(f)"$(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null)"})
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
_arguments -C \
|
|
91
|
+
'(- *)'{-h,--help}'[Show help for auth commands]' \
|
|
92
|
+
'1: :->subcommand' \
|
|
93
|
+
'*:: :->subargs'
|
|
94
|
+
|
|
95
|
+
case $state in
|
|
96
|
+
subcommand)
|
|
97
|
+
_describe -t auth-commands 'auth commands' auth_commands
|
|
98
|
+
;;
|
|
99
|
+
|
|
100
|
+
subargs)
|
|
101
|
+
case $words[1] in
|
|
102
|
+
create)
|
|
103
|
+
_message 'new profile name'
|
|
104
|
+
_arguments '--force[Allow overwriting existing profile]'
|
|
105
|
+
;;
|
|
106
|
+
list)
|
|
107
|
+
_arguments \
|
|
108
|
+
'--verbose[Show additional details]' \
|
|
109
|
+
'--json[Output in JSON format]'
|
|
110
|
+
;;
|
|
111
|
+
show)
|
|
112
|
+
_arguments \
|
|
113
|
+
'1:profile:($account_profiles)' \
|
|
114
|
+
'--json[Output in JSON format]'
|
|
115
|
+
;;
|
|
116
|
+
remove)
|
|
117
|
+
_arguments \
|
|
118
|
+
'1:profile:($account_profiles)' \
|
|
119
|
+
{--yes,-y}'[Skip confirmation prompts]'
|
|
120
|
+
;;
|
|
121
|
+
default)
|
|
122
|
+
_arguments '1:profile:($account_profiles)'
|
|
123
|
+
;;
|
|
124
|
+
esac
|
|
125
|
+
;;
|
|
126
|
+
esac
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
# Register the completion function
|
|
130
|
+
_ccs "$@"
|
package/scripts/postinstall.js
CHANGED
|
@@ -287,6 +287,30 @@ function createConfigFiles() {
|
|
|
287
287
|
console.log('[OK] Kimi profile exists: ~/.ccs/kimi.settings.json (preserved)');
|
|
288
288
|
}
|
|
289
289
|
|
|
290
|
+
// Copy shell completion files to ~/.ccs/completions/
|
|
291
|
+
const completionsDir = path.join(ccsDir, 'completions');
|
|
292
|
+
const scriptsCompletionDir = path.join(__dirname, '../scripts/completion');
|
|
293
|
+
|
|
294
|
+
if (!fs.existsSync(completionsDir)) {
|
|
295
|
+
fs.mkdirSync(completionsDir, { recursive: true, mode: 0o755 });
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const completionFiles = ['ccs.bash', 'ccs.zsh', 'ccs.fish', 'ccs.ps1'];
|
|
299
|
+
completionFiles.forEach(file => {
|
|
300
|
+
const src = path.join(scriptsCompletionDir, file);
|
|
301
|
+
const dest = path.join(completionsDir, file);
|
|
302
|
+
|
|
303
|
+
if (fs.existsSync(src)) {
|
|
304
|
+
fs.copyFileSync(src, dest);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
console.log('[OK] Installed shell completions: ~/.ccs/completions/');
|
|
309
|
+
console.log('');
|
|
310
|
+
console.log(' [i] Enable auto-completion:');
|
|
311
|
+
console.log(' Run: ccs --shell-completion');
|
|
312
|
+
console.log('');
|
|
313
|
+
|
|
290
314
|
// Create ~/.claude/settings.json if missing (NEW)
|
|
291
315
|
const claudeDir = path.join(homedir, '.claude');
|
|
292
316
|
const claudeSettingsPath = path.join(claudeDir, 'settings.json');
|