@kaitranntt/ccs 4.1.6 → 4.3.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/lib/ccs.ps1 CHANGED
@@ -12,7 +12,7 @@ param(
12
12
  $ErrorActionPreference = "Stop"
13
13
 
14
14
  # Version (updated by scripts/bump-version.sh)
15
- $CcsVersion = "4.1.6"
15
+ $CcsVersion = "4.3.0"
16
16
  $ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
17
17
  $ConfigFile = if ($env:CCS_CONFIG) { $env:CCS_CONFIG } else { "$env:USERPROFILE\.ccs\config.json" }
18
18
  $ProfilesJson = "$env:USERPROFILE\.ccs\profiles.json"
@@ -246,6 +246,7 @@ function Show-Help {
246
246
  Write-ColorLine "Diagnostics:" "Cyan"
247
247
  Write-ColorLine " ccs doctor Run health check and diagnostics" "Yellow"
248
248
  Write-ColorLine " ccs sync Sync delegation commands and skills" "Yellow"
249
+ Write-ColorLine " ccs update Update CCS to latest version" "Yellow"
249
250
  Write-Host ""
250
251
 
251
252
  Write-ColorLine "Flags:" "Cyan"
@@ -1031,6 +1032,132 @@ function Sync-Run {
1031
1032
  Write-Host ""
1032
1033
  }
1033
1034
 
1035
+ # --- Update Command ---
1036
+
1037
+ function Update-Run {
1038
+ Write-Host ""
1039
+ Write-Host "Checking for updates..." -ForegroundColor Cyan
1040
+ Write-Host ""
1041
+
1042
+ # Detect installation method
1043
+ $InstallMethod = "direct"
1044
+ try {
1045
+ $NpmList = npm list -g @kaitranntt/ccs 2>&1
1046
+ if ($LASTEXITCODE -eq 0) {
1047
+ $InstallMethod = "npm"
1048
+ }
1049
+ } catch {
1050
+ # npm not available or not installed via npm
1051
+ }
1052
+
1053
+ # Fetch latest version from appropriate source
1054
+ $LatestVersion = ""
1055
+ try {
1056
+ if ($InstallMethod -eq "npm") {
1057
+ # Check npm registry for npm installations
1058
+ $Response = Invoke-RestMethod -Uri "https://registry.npmjs.org/@kaitranntt/ccs/latest" -TimeoutSec 5
1059
+ $LatestVersion = $Response.version
1060
+ } else {
1061
+ # Check GitHub releases for direct installations
1062
+ $Response = Invoke-RestMethod -Uri "https://api.github.com/repos/kaitranntt/ccs/releases/latest" -TimeoutSec 5
1063
+ $LatestVersion = $Response.tag_name -replace '^v', ''
1064
+ }
1065
+ } catch {
1066
+ Write-Host "[!] Unable to check for updates" -ForegroundColor Yellow
1067
+ Write-Host ""
1068
+ Write-Host "Try manually:"
1069
+ if ($InstallMethod -eq "npm") {
1070
+ Write-Host " npm install -g @kaitranntt/ccs@latest" -ForegroundColor Yellow
1071
+ } else {
1072
+ Write-Host " irm ccs.kaitran.ca/install | iex" -ForegroundColor Yellow
1073
+ }
1074
+ Write-Host ""
1075
+ exit 1
1076
+ }
1077
+
1078
+ # Compare versions
1079
+ if ($LatestVersion -eq $CcsVersion) {
1080
+ Write-Host "[OK] You are already on the latest version ($CcsVersion)" -ForegroundColor Green
1081
+ Write-Host ""
1082
+ exit 0
1083
+ }
1084
+
1085
+ # Check if update available
1086
+ $CurrentParts = $CcsVersion.Split('.')
1087
+ $LatestParts = $LatestVersion.Split('.')
1088
+
1089
+ $IsNewer = $false
1090
+ for ($i = 0; $i -lt 3; $i++) {
1091
+ $Current = [int]$CurrentParts[$i]
1092
+ $Latest = [int]$LatestParts[$i]
1093
+
1094
+ if ($Latest -gt $Current) {
1095
+ $IsNewer = $true
1096
+ break
1097
+ } elseif ($Latest -lt $Current) {
1098
+ break
1099
+ }
1100
+ }
1101
+
1102
+ if (-not $IsNewer) {
1103
+ Write-Host "[OK] You are on version $CcsVersion (latest is $LatestVersion)" -ForegroundColor Green
1104
+ Write-Host ""
1105
+ exit 0
1106
+ }
1107
+
1108
+ Write-Host "[i] Update available: $CcsVersion → $LatestVersion" -ForegroundColor Yellow
1109
+ Write-Host ""
1110
+
1111
+ # Perform update based on installation method
1112
+ if ($InstallMethod -eq "npm") {
1113
+ Write-Host "Updating via npm..." -ForegroundColor Cyan
1114
+ Write-Host ""
1115
+
1116
+ try {
1117
+ npm install -g @kaitranntt/ccs@latest
1118
+ if ($LASTEXITCODE -eq 0) {
1119
+ Write-Host ""
1120
+ Write-Host "[OK] Update successful!" -ForegroundColor Green
1121
+ Write-Host ""
1122
+ Write-Host "Run ccs --version to verify" -ForegroundColor Yellow
1123
+ Write-Host ""
1124
+ exit 0
1125
+ } else {
1126
+ throw "npm install failed"
1127
+ }
1128
+ } catch {
1129
+ Write-Host ""
1130
+ Write-Host "[X] Update failed" -ForegroundColor Red
1131
+ Write-Host ""
1132
+ Write-Host "Try manually:"
1133
+ Write-Host " npm install -g @kaitranntt/ccs@latest" -ForegroundColor Yellow
1134
+ Write-Host ""
1135
+ exit 1
1136
+ }
1137
+ } else {
1138
+ Write-Host "Updating via installer..." -ForegroundColor Cyan
1139
+ Write-Host ""
1140
+
1141
+ try {
1142
+ irm ccs.kaitran.ca/install | iex
1143
+ Write-Host ""
1144
+ Write-Host "[OK] Update successful!" -ForegroundColor Green
1145
+ Write-Host ""
1146
+ Write-Host "Run ccs --version to verify" -ForegroundColor Yellow
1147
+ Write-Host ""
1148
+ exit 0
1149
+ } catch {
1150
+ Write-Host ""
1151
+ Write-Host "[X] Update failed" -ForegroundColor Red
1152
+ Write-Host ""
1153
+ Write-Host "Try manually:"
1154
+ Write-Host " irm ccs.kaitran.ca/install | iex" -ForegroundColor Yellow
1155
+ Write-Host ""
1156
+ exit 1
1157
+ }
1158
+ }
1159
+ }
1160
+
1034
1161
  # --- Auth Commands (Phase 3) ---
1035
1162
 
1036
1163
  function Show-AuthHelp {
@@ -1519,6 +1646,12 @@ if ($RemainingArgs.Count -gt 0 -and ($RemainingArgs[0] -eq "sync" -or $Remaining
1519
1646
  exit 0
1520
1647
  }
1521
1648
 
1649
+ # Special case: update command
1650
+ if ($RemainingArgs.Count -gt 0 -and ($RemainingArgs[0] -eq "update" -or $RemainingArgs[0] -eq "--update")) {
1651
+ Update-Run
1652
+ exit 0
1653
+ }
1654
+
1522
1655
  # Run auto-recovery before main logic
1523
1656
  if (-not (Invoke-AutoRecovery)) {
1524
1657
  Write-ErrorMsg "Auto-recovery failed. Check permissions."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaitranntt/ccs",
3
- "version": "4.1.6",
3
+ "version": "4.3.0",
4
4
  "description": "Claude Code Switch - Instant profile switching between Claude Sonnet 4.5 and GLM 4.6",
5
5
  "keywords": [
6
6
  "cli",
@@ -57,6 +57,10 @@
57
57
  "prepare": "node scripts/check-executables.js",
58
58
  "postinstall": "node scripts/postinstall.js"
59
59
  },
60
+ "dependencies": {
61
+ "cli-table3": "^0.6.5",
62
+ "ora": "^5.4.1"
63
+ },
60
64
  "devDependencies": {
61
65
  "mocha": "^11.7.5"
62
66
  }
@@ -18,7 +18,7 @@ _ccs_completion() {
18
18
 
19
19
  # Top-level completion (first argument)
20
20
  if [[ ${COMP_CWORD} -eq 1 ]]; then
21
- local commands="auth doctor sync"
21
+ local commands="auth doctor sync update"
22
22
  local flags="--help --version --shell-completion -h -v -sc"
23
23
  local profiles=""
24
24
 
@@ -73,21 +73,22 @@ complete -c ccs -s v -l version -d 'Show version information'
73
73
  complete -c ccs -s sc -l shell-completion -d 'Install shell completion'
74
74
 
75
75
  # Top-level commands (blue color for commands)
76
- complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync' -a 'auth' -d (set_color blue)'Manage multiple Claude accounts'(set_color normal)
77
- complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync' -a 'doctor' -d (set_color blue)'Run health check and diagnostics'(set_color normal)
78
- complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync' -a 'sync' -d (set_color blue)'Sync delegation commands and skills'(set_color normal)
76
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a 'auth' -d (set_color blue)'Manage multiple Claude accounts'(set_color normal)
77
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a 'doctor' -d (set_color blue)'Run health check and diagnostics'(set_color normal)
78
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a 'sync' -d (set_color blue)'Sync delegation commands and skills'(set_color normal)
79
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a 'update' -d (set_color blue)'Update CCS to latest version'(set_color normal)
79
80
 
80
81
  # Top-level known settings profiles (green color for model profiles)
81
- complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync' -a 'default' -d (set_color green)'Default Claude Sonnet 4.5'(set_color normal)
82
- complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync' -a 'glm' -d (set_color green)'GLM-4.6 (cost-optimized)'(set_color normal)
83
- complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync' -a 'glmt' -d (set_color green)'GLM-4.6 with thinking mode'(set_color normal)
84
- complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync' -a 'kimi' -d (set_color green)'Kimi for Coding (long-context)'(set_color normal)
82
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a 'default' -d (set_color green)'Default Claude Sonnet 4.5'(set_color normal)
83
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a 'glm' -d (set_color green)'GLM-4.6 (cost-optimized)'(set_color normal)
84
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a 'glmt' -d (set_color green)'GLM-4.6 with thinking mode'(set_color normal)
85
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a 'kimi' -d (set_color green)'Kimi for Coding (long-context)'(set_color normal)
85
86
 
86
87
  # Top-level custom settings profiles (dynamic, with generic description in green)
87
- complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync' -a '(__fish_ccs_get_custom_settings_profiles)' -d (set_color green)'Settings-based profile'(set_color normal)
88
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a '(__fish_ccs_get_custom_settings_profiles)' -d (set_color green)'Settings-based profile'(set_color normal)
88
89
 
89
90
  # Top-level account profiles (dynamic, yellow color for account profiles)
90
- complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync' -a '(__fish_ccs_get_account_profiles)' -d (set_color yellow)'Account profile'(set_color normal)
91
+ complete -c ccs -n 'not __fish_seen_subcommand_from auth doctor sync update' -a '(__fish_ccs_get_account_profiles)' -d (set_color yellow)'Account profile'(set_color normal)
91
92
 
92
93
  # shell-completion subflags
93
94
  complete -c ccs -n '__fish_seen_argument -l shell-completion; or __fish_seen_argument -s sc' -l bash -d 'Install for bash'
@@ -12,7 +12,7 @@
12
12
  Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
13
13
  param($commandName, $wordToComplete, $commandAst, $fakeBoundParameters)
14
14
 
15
- $commands = @('auth', 'doctor', 'sync', '--help', '--version', '--shell-completion', '-h', '-v', '-sc')
15
+ $commands = @('auth', 'doctor', 'sync', 'update', '--help', '--version', '--shell-completion', '-h', '-v', '-sc')
16
16
  $authCommands = @('create', 'list', 'show', 'remove', 'default', '--help', '-h')
17
17
  $shellCompletionFlags = @('--bash', '--zsh', '--fish', '--powershell')
18
18
  $listFlags = @('--verbose', '--json')
@@ -16,7 +16,7 @@
16
16
  # Color codes: 0;34=blue, 0;32=green, 0;33=yellow, 2;37=dim white
17
17
  # Pattern format: =(#b)(group1)(group2)==color_for_group1=color_for_group2
18
18
  # The leading '=' means no color for whole match, then each '=' assigns to each group
19
- zstyle ':completion:*:*:ccs:*:commands' list-colors '=(#b)(auth|doctor|sync)([[:space:]]#--[[:space:]]#*)==0\;34=2\;37'
19
+ zstyle ':completion:*:*:ccs:*:commands' list-colors '=(#b)(auth|doctor|sync|update)([[:space:]]#--[[:space:]]#*)==0\;34=2\;37'
20
20
  zstyle ':completion:*:*:ccs:*:model-profiles' list-colors '=(#b)(default|glm|glmt|kimi|[^[:space:]]##)([[:space:]]#--[[:space:]]#*)==0\;32=2\;37'
21
21
  zstyle ':completion:*:*:ccs:*:account-profiles' list-colors '=(#b)([^[:space:]]##)([[:space:]]#--[[:space:]]#*)==0\;33=2\;37'
22
22
  zstyle ':completion:*:*:ccs:*' group-name ''
@@ -35,6 +35,7 @@ _ccs() {
35
35
  'auth:Manage multiple Claude accounts'
36
36
  'doctor:Run health check and diagnostics'
37
37
  'sync:Sync delegation commands and skills'
38
+ 'update:Update CCS to latest version'
38
39
  )
39
40
 
40
41
  # Define known settings profiles with descriptions (consistent padding)