@kaitranntt/ccs 7.65.3 → 7.66.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.
Files changed (226) hide show
  1. package/README.md +88 -750
  2. package/dist/api/services/profile-lifecycle-service.d.ts.map +1 -1
  3. package/dist/api/services/profile-lifecycle-service.js +4 -0
  4. package/dist/api/services/profile-lifecycle-service.js.map +1 -1
  5. package/dist/api/services/profile-writer.d.ts.map +1 -1
  6. package/dist/api/services/profile-writer.js +3 -0
  7. package/dist/api/services/profile-writer.js.map +1 -1
  8. package/dist/auth/auth-commands.d.ts +1 -0
  9. package/dist/auth/auth-commands.d.ts.map +1 -1
  10. package/dist/auth/auth-commands.js +11 -0
  11. package/dist/auth/auth-commands.js.map +1 -1
  12. package/dist/auth/commands/backup-command.d.ts +3 -0
  13. package/dist/auth/commands/backup-command.d.ts.map +1 -0
  14. package/dist/auth/commands/backup-command.js +126 -0
  15. package/dist/auth/commands/backup-command.js.map +1 -0
  16. package/dist/auth/commands/index.d.ts +1 -0
  17. package/dist/auth/commands/index.d.ts.map +1 -1
  18. package/dist/auth/commands/index.js +3 -1
  19. package/dist/auth/commands/index.js.map +1 -1
  20. package/dist/auth/profile-continuity-inheritance.d.ts +1 -0
  21. package/dist/auth/profile-continuity-inheritance.d.ts.map +1 -1
  22. package/dist/auth/profile-continuity-inheritance.js +10 -6
  23. package/dist/auth/profile-continuity-inheritance.js.map +1 -1
  24. package/dist/auth/profile-detector.d.ts +9 -1
  25. package/dist/auth/profile-detector.d.ts.map +1 -1
  26. package/dist/auth/profile-detector.js +35 -0
  27. package/dist/auth/profile-detector.js.map +1 -1
  28. package/dist/auth/resume-lane-diagnostics.d.ts +21 -0
  29. package/dist/auth/resume-lane-diagnostics.d.ts.map +1 -0
  30. package/dist/auth/resume-lane-diagnostics.js +146 -0
  31. package/dist/auth/resume-lane-diagnostics.js.map +1 -0
  32. package/dist/auth/resume-lane-warning.d.ts +9 -0
  33. package/dist/auth/resume-lane-warning.d.ts.map +1 -0
  34. package/dist/auth/resume-lane-warning.js +60 -0
  35. package/dist/auth/resume-lane-warning.js.map +1 -0
  36. package/dist/ccs.js +79 -7
  37. package/dist/ccs.js.map +1 -1
  38. package/dist/cliproxy/executor/env-resolver.d.ts +3 -0
  39. package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
  40. package/dist/cliproxy/executor/env-resolver.js +19 -1
  41. package/dist/cliproxy/executor/env-resolver.js.map +1 -1
  42. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  43. package/dist/cliproxy/executor/index.js +24 -5
  44. package/dist/cliproxy/executor/index.js.map +1 -1
  45. package/dist/cliproxy/gemini-cli-quota-normalizer.d.ts +10 -0
  46. package/dist/cliproxy/gemini-cli-quota-normalizer.d.ts.map +1 -0
  47. package/dist/cliproxy/gemini-cli-quota-normalizer.js +122 -0
  48. package/dist/cliproxy/gemini-cli-quota-normalizer.js.map +1 -0
  49. package/dist/cliproxy/quota-fetcher-gemini-cli.d.ts.map +1 -1
  50. package/dist/cliproxy/quota-fetcher-gemini-cli.js +133 -92
  51. package/dist/cliproxy/quota-fetcher-gemini-cli.js.map +1 -1
  52. package/dist/cliproxy/quota-types.d.ts +8 -0
  53. package/dist/cliproxy/quota-types.d.ts.map +1 -1
  54. package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
  55. package/dist/cliproxy/services/variant-settings.js +11 -0
  56. package/dist/cliproxy/services/variant-settings.js.map +1 -1
  57. package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
  58. package/dist/commands/cliproxy/quota-subcommand.js +10 -1
  59. package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
  60. package/dist/commands/command-catalog.d.ts +39 -0
  61. package/dist/commands/command-catalog.d.ts.map +1 -0
  62. package/dist/commands/command-catalog.js +298 -0
  63. package/dist/commands/command-catalog.js.map +1 -0
  64. package/dist/commands/completion-backend.d.ts +14 -0
  65. package/dist/commands/completion-backend.d.ts.map +1 -0
  66. package/dist/commands/completion-backend.js +208 -0
  67. package/dist/commands/completion-backend.js.map +1 -0
  68. package/dist/commands/cursor-command-display.d.ts.map +1 -1
  69. package/dist/commands/cursor-command-display.js +25 -5
  70. package/dist/commands/cursor-command-display.js.map +1 -1
  71. package/dist/commands/cursor-command.d.ts +1 -3
  72. package/dist/commands/cursor-command.d.ts.map +1 -1
  73. package/dist/commands/cursor-command.js +3 -15
  74. package/dist/commands/cursor-command.js.map +1 -1
  75. package/dist/commands/help-command.d.ts +4 -3
  76. package/dist/commands/help-command.d.ts.map +1 -1
  77. package/dist/commands/help-command.js +155 -507
  78. package/dist/commands/help-command.js.map +1 -1
  79. package/dist/commands/install-command.d.ts.map +1 -1
  80. package/dist/commands/install-command.js +16 -3
  81. package/dist/commands/install-command.js.map +1 -1
  82. package/dist/commands/root-command-router.d.ts +2 -0
  83. package/dist/commands/root-command-router.d.ts.map +1 -1
  84. package/dist/commands/root-command-router.js +13 -13
  85. package/dist/commands/root-command-router.js.map +1 -1
  86. package/dist/commands/shell-completion-command.d.ts +1 -0
  87. package/dist/commands/shell-completion-command.d.ts.map +1 -1
  88. package/dist/commands/shell-completion-command.js +27 -11
  89. package/dist/commands/shell-completion-command.js.map +1 -1
  90. package/dist/copilot/copilot-executor.d.ts +2 -0
  91. package/dist/copilot/copilot-executor.d.ts.map +1 -1
  92. package/dist/copilot/copilot-executor.js +36 -4
  93. package/dist/copilot/copilot-executor.js.map +1 -1
  94. package/dist/cursor/constants.d.ts +3 -0
  95. package/dist/cursor/constants.d.ts.map +1 -0
  96. package/dist/cursor/constants.js +20 -0
  97. package/dist/cursor/constants.js.map +1 -0
  98. package/dist/cursor/cursor-models.d.ts.map +1 -1
  99. package/dist/cursor/cursor-models.js +2 -0
  100. package/dist/cursor/cursor-models.js.map +1 -1
  101. package/dist/cursor/cursor-profile-executor.d.ts +10 -0
  102. package/dist/cursor/cursor-profile-executor.d.ts.map +1 -0
  103. package/dist/cursor/cursor-profile-executor.js +158 -0
  104. package/dist/cursor/cursor-profile-executor.js.map +1 -0
  105. package/dist/cursor/cursor-translator.d.ts +22 -11
  106. package/dist/cursor/cursor-translator.d.ts.map +1 -1
  107. package/dist/cursor/cursor-translator.js +254 -75
  108. package/dist/cursor/cursor-translator.js.map +1 -1
  109. package/dist/cursor/index.d.ts +1 -0
  110. package/dist/cursor/index.d.ts.map +1 -1
  111. package/dist/cursor/index.js +4 -1
  112. package/dist/cursor/index.js.map +1 -1
  113. package/dist/delegation/headless-executor.d.ts.map +1 -1
  114. package/dist/delegation/headless-executor.js +79 -2
  115. package/dist/delegation/headless-executor.js.map +1 -1
  116. package/dist/management/checks/image-analysis-check.d.ts.map +1 -1
  117. package/dist/management/checks/image-analysis-check.js +4 -5
  118. package/dist/management/checks/image-analysis-check.js.map +1 -1
  119. package/dist/management/instance-manager.js +1 -1
  120. package/dist/management/instance-manager.js.map +1 -1
  121. package/dist/shared/claude-extension-setup.d.ts.map +1 -1
  122. package/dist/shared/claude-extension-setup.js +36 -16
  123. package/dist/shared/claude-extension-setup.js.map +1 -1
  124. package/dist/targets/target-runtime-compatibility.d.ts.map +1 -1
  125. package/dist/targets/target-runtime-compatibility.js +6 -0
  126. package/dist/targets/target-runtime-compatibility.js.map +1 -1
  127. package/dist/types/profile.d.ts +1 -1
  128. package/dist/types/profile.d.ts.map +1 -1
  129. package/dist/ui/assets/accounts-BjfPKR8m.js +1 -0
  130. package/dist/ui/assets/{alert-dialog-D0EFRcfB.js → alert-dialog-Dh2NUFdm.js} +1 -1
  131. package/dist/ui/assets/{api-DhM3BYXr.js → api-C-3mQCFf.js} +1 -1
  132. package/dist/ui/assets/{auth-section-DVp8FQGm.js → auth-section-Dp10_YyD.js} +1 -1
  133. package/dist/ui/assets/{backups-section-CRo0NZkA.js → backups-section-C0jF8MP1.js} +1 -1
  134. package/dist/ui/assets/{channels-uZ_9CBqO.js → channels-CkXuK5i7.js} +1 -1
  135. package/dist/ui/assets/{checkbox-32DNqW_Q.js → checkbox-tA5FH8Ol.js} +1 -1
  136. package/dist/ui/assets/{claude-extension-BfXlz5gV.js → claude-extension-Bg2ZkzMz.js} +1 -1
  137. package/dist/ui/assets/{cliproxy-DjNY9H-U.js → cliproxy-1qRVSbVC.js} +2 -2
  138. package/dist/ui/assets/{cliproxy-ai-providers-5SHLMHiy.js → cliproxy-ai-providers-DBSXTTyw.js} +1 -1
  139. package/dist/ui/assets/cliproxy-control-panel-Da-sGGyI.js +1 -0
  140. package/dist/ui/assets/{codex-CRUSpjsu.js → codex-ooWKOPa2.js} +1 -1
  141. package/dist/ui/assets/{confirm-dialog-DVf5ZmCZ.js → confirm-dialog-CKjwhn9j.js} +1 -1
  142. package/dist/ui/assets/{copilot-BZrihl_Z.js → copilot-GA7EPiK1.js} +1 -1
  143. package/dist/ui/assets/{cursor-BP4nbEk_.js → cursor-B6c8CyHG.js} +1 -1
  144. package/dist/ui/assets/{droid-BG92rdM2.js → droid-CPRHOIX2.js} +1 -1
  145. package/dist/ui/assets/{globalenv-section-Cf6dKgSf.js → globalenv-section-Czgnw_GV.js} +1 -1
  146. package/dist/ui/assets/{health-BTy1UZs3.js → health-CXLOMk8n.js} +1 -1
  147. package/dist/ui/assets/icons-B9oTjo-t.js +1 -0
  148. package/dist/ui/assets/index-BMHPMj0j.js +69 -0
  149. package/dist/ui/assets/{index-BVeN0dIB.js → index-BceMcbCR.js} +1 -1
  150. package/dist/ui/assets/{index-N2ZSJurX.js → index-Boa5e-GY.js} +1 -1
  151. package/dist/ui/assets/index-CknHGRYp.css +1 -0
  152. package/dist/ui/assets/{index-wg7UtkFv.js → index-CvfzKRSH.js} +1 -1
  153. package/dist/ui/assets/{index-DuRYaONg.js → index-D2v_-6AW.js} +1 -1
  154. package/dist/ui/assets/{index-DHrTq-0n.js → index-v-DY6Zby.js} +1 -1
  155. package/dist/ui/assets/{masked-input-DX9bedLy.js → masked-input-B1_asiUI.js} +1 -1
  156. package/dist/ui/assets/{proxy-status-widget-DVDMuZK5.js → proxy-status-widget-Ci1JpStj.js} +1 -1
  157. package/dist/ui/assets/{radix-ui-C98W0NRG.js → radix-ui-Zb8sVEtn.js} +1 -1
  158. package/dist/ui/assets/{raw-json-settings-editor-panel-Dkt5E6Z_.js → raw-json-settings-editor-panel-DMbTkxWw.js} +1 -1
  159. package/dist/ui/assets/{searchable-select-BP3Q1-Yn.js → searchable-select-HbP2PXl3.js} +1 -1
  160. package/dist/ui/assets/{separator-BLGGUlh9.js → separator-CdaalG0K.js} +1 -1
  161. package/dist/ui/assets/{shared-G0XRyLig.js → shared-BiFB-et0.js} +1 -1
  162. package/dist/ui/assets/{table-B4lRrWC-.js → table-BPwgFXLQ.js} +1 -1
  163. package/dist/ui/assets/{tanstack-CfKik0yL.js → tanstack-DWm6aJ-G.js} +1 -1
  164. package/dist/ui/assets/{updates--A2Sdo7N.js → updates-l8Co9uve.js} +1 -1
  165. package/dist/ui/index.html +5 -5
  166. package/dist/utils/config-manager.d.ts +5 -0
  167. package/dist/utils/config-manager.d.ts.map +1 -1
  168. package/dist/utils/config-manager.js +10 -1
  169. package/dist/utils/config-manager.js.map +1 -1
  170. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts +26 -0
  171. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts.map +1 -1
  172. package/dist/utils/hooks/get-image-analysis-hook-env.js +79 -1
  173. package/dist/utils/hooks/get-image-analysis-hook-env.js.map +1 -1
  174. package/dist/utils/hooks/image-analysis-backend-resolver.d.ts.map +1 -1
  175. package/dist/utils/hooks/image-analysis-backend-resolver.js +13 -5
  176. package/dist/utils/hooks/image-analysis-backend-resolver.js.map +1 -1
  177. package/dist/utils/hooks/image-analysis-runtime-status.d.ts +2 -0
  178. package/dist/utils/hooks/image-analysis-runtime-status.d.ts.map +1 -1
  179. package/dist/utils/hooks/image-analysis-runtime-status.js +15 -11
  180. package/dist/utils/hooks/image-analysis-runtime-status.js.map +1 -1
  181. package/dist/utils/hooks/image-analyzer-hook-installer.d.ts.map +1 -1
  182. package/dist/utils/hooks/image-analyzer-hook-installer.js +60 -27
  183. package/dist/utils/hooks/image-analyzer-hook-installer.js.map +1 -1
  184. package/dist/utils/hooks/image-analyzer-profile-hook-injector.d.ts.map +1 -1
  185. package/dist/utils/hooks/image-analyzer-profile-hook-injector.js +3 -0
  186. package/dist/utils/hooks/image-analyzer-profile-hook-injector.js.map +1 -1
  187. package/dist/utils/hooks/index.d.ts +2 -1
  188. package/dist/utils/hooks/index.d.ts.map +1 -1
  189. package/dist/utils/hooks/index.js +14 -7
  190. package/dist/utils/hooks/index.js.map +1 -1
  191. package/dist/utils/image-analysis/claude-tool-args.d.ts +6 -0
  192. package/dist/utils/image-analysis/claude-tool-args.d.ts.map +1 -0
  193. package/dist/utils/image-analysis/claude-tool-args.js +65 -0
  194. package/dist/utils/image-analysis/claude-tool-args.js.map +1 -0
  195. package/dist/utils/image-analysis/index.d.ts +4 -0
  196. package/dist/utils/image-analysis/index.d.ts.map +1 -1
  197. package/dist/utils/image-analysis/index.js +20 -1
  198. package/dist/utils/image-analysis/index.js.map +1 -1
  199. package/dist/utils/image-analysis/mcp-installer.d.ts +18 -0
  200. package/dist/utils/image-analysis/mcp-installer.d.ts.map +1 -0
  201. package/dist/utils/image-analysis/mcp-installer.js +447 -0
  202. package/dist/utils/image-analysis/mcp-installer.js.map +1 -0
  203. package/dist/web-server/routes/account-routes.d.ts.map +1 -1
  204. package/dist/web-server/routes/account-routes.js +14 -2
  205. package/dist/web-server/routes/account-routes.js.map +1 -1
  206. package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
  207. package/dist/web-server/routes/cliproxy-auth-routes.js +80 -6
  208. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  209. package/dist/web-server/routes/image-analysis-routes.d.ts.map +1 -1
  210. package/dist/web-server/routes/image-analysis-routes.js +30 -5
  211. package/dist/web-server/routes/image-analysis-routes.js.map +1 -1
  212. package/lib/hooks/image-analysis-runtime.cjs +469 -0
  213. package/lib/hooks/image-analyzer-transformer.cjs +27 -418
  214. package/lib/hooks/websearch-transformer.cjs +37 -2
  215. package/lib/mcp/ccs-image-analysis-server.cjs +440 -0
  216. package/package.json +1 -1
  217. package/scripts/completion/README.md +55 -131
  218. package/scripts/completion/ccs.bash +22 -190
  219. package/scripts/completion/ccs.fish +19 -245
  220. package/scripts/completion/ccs.ps1 +37 -427
  221. package/scripts/completion/ccs.zsh +27 -305
  222. package/dist/ui/assets/accounts-BHEYnq6b.js +0 -1
  223. package/dist/ui/assets/cliproxy-control-panel-Zax_m1AC.js +0 -1
  224. package/dist/ui/assets/icons-CeH5899d.js +0 -1
  225. package/dist/ui/assets/index-B6SrL1O-.css +0 -1
  226. package/dist/ui/assets/index-Corv1lSo.js +0 -69
@@ -1,446 +1,56 @@
1
1
  # PowerShell completion for CCS (Claude Code Switch)
2
- # Compatible with PowerShell 5.1+
3
- #
4
- # Installation:
5
- # Add to your PowerShell profile ($PROFILE):
6
- # . /path/to/ccs/scripts/completion/ccs.ps1
7
- #
8
- # Or install for current user:
9
- # Copy-Item scripts/completion/ccs.ps1 ~\Documents\PowerShell\Scripts\
10
- # Add to profile: . ~\Documents\PowerShell\Scripts\ccs.ps1
11
2
 
12
- Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
13
- param($commandName, $wordToComplete, $commandAst, $fakeBoundParameters)
14
-
15
- $commands = @('auth', 'api', 'cliproxy', 'doctor', 'env', 'sync', 'update', '--help', '--version', '--shell-completion', '-h', '-v', '-sc')
16
- $cliproxyProfiles = @('gemini', 'codex', 'agy', 'qwen', 'iflow', 'kiro', 'ghcp', 'claude')
17
- $authCommands = @('create', 'list', 'show', 'remove', 'default', '--help', '-h')
18
- $apiCommands = @('create', 'list', 'remove', '--help', '-h')
19
- $cliproxyCommands = @('create', 'list', 'remove', '--install', '--latest', '--help', '-h')
20
- $apiCreateFlags = @('--base-url', '--api-key', '--model', '--force', '--yes', '-y')
21
- $cliproxyCreateFlags = @('--provider', '--model', '--force', '--yes', '-y')
22
- $providerFlags = @('--auth', '--config', '--logout', '--headless', '--help', '-h')
23
- $updateFlags = @('--force', '--beta', '--dev', '--help', '-h')
24
- $envFlags = @('--format', '--shell', '--help', '-h')
25
- $envFormats = @('openai', 'anthropic', 'raw')
26
- $envShells = @('auto', 'bash', 'zsh', 'fish', 'powershell')
27
- $shellCompletionFlags = @('--bash', '--zsh', '--fish', '--powershell')
28
- $listFlags = @('--verbose', '--json')
29
- $removeFlags = @('--yes', '-y')
30
- $showFlags = @('--json')
31
- $providers = @('gemini', 'codex', 'agy', 'qwen')
32
-
33
- # Get current position in command
34
- $words = $commandAst.ToString() -split '\s+' | Where-Object { $_ -ne '' }
35
- $position = $words.Count
36
-
37
- # Helper function to get profiles
38
- function Get-CcsProfiles {
39
- param([string]$Type = 'all')
40
-
41
- $profiles = @()
42
-
43
- # Settings-based profiles
44
- if ($Type -in @('all', 'settings')) {
45
- $configPath = "$env:USERPROFILE\.ccs\config.json"
46
- if (Test-Path $configPath) {
47
- try {
48
- $config = Get-Content $configPath -Raw | ConvertFrom-Json
49
- $profiles += $config.profiles.PSObject.Properties.Name
50
- } catch {}
51
- }
52
- }
53
-
54
- # Account-based profiles
55
- if ($Type -in @('all', 'account')) {
56
- $profilesPath = "$env:USERPROFILE\.ccs\profiles.json"
57
- if (Test-Path $profilesPath) {
58
- try {
59
- $data = Get-Content $profilesPath -Raw | ConvertFrom-Json
60
- $profiles += $data.profiles.PSObject.Properties.Name
61
- } catch {}
62
- }
63
- }
64
-
65
- # CLIProxy variants
66
- if ($Type -in @('all', 'cliproxy')) {
67
- $configPath = "$env:USERPROFILE\.ccs\config.json"
68
- if (Test-Path $configPath) {
69
- try {
70
- $config = Get-Content $configPath -Raw | ConvertFrom-Json
71
- if ($config.cliproxy) {
72
- $profiles += $config.cliproxy.PSObject.Properties.Name
73
- }
74
- } catch {}
75
- }
76
- }
77
-
78
- return $profiles | Sort-Object -Unique
79
- }
80
-
81
- # Top-level completion
82
- if ($position -eq 2) {
83
- $allOptions = $commands + $cliproxyProfiles + (Get-CcsProfiles)
84
- $allOptions | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
85
- [System.Management.Automation.CompletionResult]::new(
86
- $_,
87
- $_,
88
- 'ParameterValue',
89
- $_
90
- )
91
- }
92
- return
93
- }
3
+ function Invoke-CcsCompletionBackend {
4
+ param(
5
+ [string]$CurrentWord,
6
+ [string[]]$TokensBeforeCurrent
7
+ )
94
8
 
95
- # shell-completion flag completion
96
- if ($words[1] -eq '--shell-completion' -or $words[1] -eq '-sc') {
97
- if ($position -eq 3) {
98
- $shellCompletionFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
99
- [System.Management.Automation.CompletionResult]::new(
100
- $_,
101
- $_,
102
- 'ParameterValue',
103
- $_
104
- )
105
- }
106
- }
107
- return
9
+ $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
10
+ $repoCli = Join-Path $repoRoot 'dist\ccs.js'
11
+ if (-not (Test-Path $repoCli)) {
12
+ $repoCli = Join-Path $repoRoot 'bin\ccs.js'
108
13
  }
109
-
110
- # CLIProxy provider flags (gemini, codex, agy, qwen)
111
- if ($words[1] -in $cliproxyProfiles) {
112
- $providerFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
113
- [System.Management.Automation.CompletionResult]::new(
114
- $_,
115
- $_,
116
- 'ParameterValue',
117
- $_
118
- )
119
- }
14
+ if (Test-Path $repoCli) {
15
+ & node $repoCli __complete --shell powershell --current $CurrentWord -- @TokensBeforeCurrent 2>$null
120
16
  return
121
17
  }
122
18
 
123
- # update command completion
124
- if ($words[1] -eq 'update') {
125
- $updateFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
126
- [System.Management.Automation.CompletionResult]::new(
127
- $_,
128
- $_,
129
- 'ParameterValue',
130
- $_
131
- )
132
- }
133
- return
19
+ if (Get-Command ccs -ErrorAction SilentlyContinue) {
20
+ & ccs __complete --shell powershell --current $CurrentWord -- @TokensBeforeCurrent 2>$null
134
21
  }
22
+ }
135
23
 
136
- # env command completion
137
- if ($words[1] -eq 'env') {
138
- if ($position -eq 3) {
139
- $options = $cliproxyProfiles + (Get-CcsProfiles -Type settings) + $envFlags
140
- $options | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
141
- [System.Management.Automation.CompletionResult]::new(
142
- $_,
143
- $_,
144
- 'ParameterValue',
145
- $_
146
- )
147
- }
148
- } elseif ($position -ge 4) {
149
- switch ($words[$position - 2]) {
150
- '--format' {
151
- $envFormats | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
152
- [System.Management.Automation.CompletionResult]::new(
153
- $_,
154
- $_,
155
- 'ParameterValue',
156
- $_
157
- )
158
- }
159
- }
160
- '--shell' {
161
- $envShells | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
162
- [System.Management.Automation.CompletionResult]::new(
163
- $_,
164
- $_,
165
- 'ParameterValue',
166
- $_
167
- )
168
- }
169
- }
170
- default {
171
- $envFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
172
- [System.Management.Automation.CompletionResult]::new(
173
- $_,
174
- $_,
175
- 'ParameterValue',
176
- $_
177
- )
178
- }
179
- }
180
- }
181
- }
182
- return
183
- }
24
+ Register-ArgumentCompleter -CommandName ccs -ScriptBlock {
25
+ param($commandName, $wordToComplete, $commandAst, $fakeBoundParameters)
184
26
 
185
- # auth subcommand completion
186
- if ($words[1] -eq 'auth') {
187
- if ($position -eq 3) {
188
- $authCommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
189
- [System.Management.Automation.CompletionResult]::new(
190
- $_,
191
- $_,
192
- 'ParameterValue',
193
- $_
194
- )
195
- }
196
- } elseif ($position -eq 4) {
197
- switch ($words[2]) {
198
- 'show' {
199
- $options = (Get-CcsProfiles -Type account) + $showFlags
200
- $options | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
201
- [System.Management.Automation.CompletionResult]::new(
202
- $_,
203
- $_,
204
- 'ParameterValue',
205
- $_
206
- )
207
- }
208
- }
209
- 'remove' {
210
- $options = (Get-CcsProfiles -Type account) + $removeFlags
211
- $options | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
212
- [System.Management.Automation.CompletionResult]::new(
213
- $_,
214
- $_,
215
- 'ParameterValue',
216
- $_
217
- )
218
- }
219
- }
220
- 'default' {
221
- Get-CcsProfiles -Type account | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
222
- [System.Management.Automation.CompletionResult]::new(
223
- $_,
224
- $_,
225
- 'ParameterValue',
226
- $_
227
- )
228
- }
229
- }
230
- 'list' {
231
- $listFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
232
- [System.Management.Automation.CompletionResult]::new(
233
- $_,
234
- $_,
235
- 'ParameterValue',
236
- $_
237
- )
238
- }
239
- }
240
- 'create' {
241
- @('--force') | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
242
- [System.Management.Automation.CompletionResult]::new(
243
- $_,
244
- $_,
245
- 'ParameterValue',
246
- $_
247
- )
248
- }
249
- }
250
- }
251
- } elseif ($position -eq 5) {
252
- switch ($words[2]) {
253
- 'show' {
254
- $showFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
255
- [System.Management.Automation.CompletionResult]::new(
256
- $_,
257
- $_,
258
- 'ParameterValue',
259
- $_
260
- )
261
- }
262
- }
263
- 'remove' {
264
- $removeFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
265
- [System.Management.Automation.CompletionResult]::new(
266
- $_,
267
- $_,
268
- 'ParameterValue',
269
- $_
270
- )
271
- }
272
- }
27
+ $commandElements = @($commandAst.CommandElements | ForEach-Object { $_.Extent.Text })
28
+ $tokensBeforeCurrent = @()
29
+ if ($commandElements.Count -gt 1) {
30
+ $tokensBeforeCurrent = $commandElements[1..($commandElements.Count - 1)]
31
+ if ($tokensBeforeCurrent.Count -gt 0 -and $tokensBeforeCurrent[-1] -eq $wordToComplete) {
32
+ $tokensBeforeCurrent = if ($tokensBeforeCurrent.Count -gt 1) {
33
+ $tokensBeforeCurrent[0..($tokensBeforeCurrent.Count - 2)]
34
+ } else {
35
+ @()
273
36
  }
274
37
  }
275
- return
276
38
  }
277
39
 
278
- # api subcommand completion
279
- if ($words[1] -eq 'api') {
280
- if ($position -eq 3) {
281
- $apiCommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
282
- [System.Management.Automation.CompletionResult]::new(
283
- $_,
284
- $_,
285
- 'ParameterValue',
286
- $_
287
- )
288
- }
289
- } elseif ($position -eq 4) {
290
- switch ($words[2]) {
291
- 'remove' {
292
- $options = (Get-CcsProfiles -Type settings) + $removeFlags
293
- $options | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
294
- [System.Management.Automation.CompletionResult]::new(
295
- $_,
296
- $_,
297
- 'ParameterValue',
298
- $_
299
- )
300
- }
301
- }
302
- 'create' {
303
- $apiCreateFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
304
- [System.Management.Automation.CompletionResult]::new(
305
- $_,
306
- $_,
307
- 'ParameterValue',
308
- $_
309
- )
310
- }
311
- }
312
- }
313
- } elseif ($position -eq 5) {
314
- switch ($words[2]) {
315
- 'remove' {
316
- $removeFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
317
- [System.Management.Automation.CompletionResult]::new(
318
- $_,
319
- $_,
320
- 'ParameterValue',
321
- $_
322
- )
323
- }
324
- }
325
- }
40
+ foreach ($line in Invoke-CcsCompletionBackend -CurrentWord $wordToComplete -TokensBeforeCurrent $tokensBeforeCurrent) {
41
+ if ([string]::IsNullOrWhiteSpace($line)) {
42
+ continue
326
43
  }
327
- return
328
- }
329
44
 
330
- # cliproxy subcommand completion
331
- if ($words[1] -eq 'cliproxy') {
332
- if ($position -eq 3) {
333
- $cliproxyCommands | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
334
- [System.Management.Automation.CompletionResult]::new(
335
- $_,
336
- $_,
337
- 'ParameterValue',
338
- $_
339
- )
340
- }
341
- } elseif ($position -eq 4) {
342
- switch ($words[2]) {
343
- 'remove' {
344
- $options = (Get-CcsProfiles -Type cliproxy) + $removeFlags
345
- $options | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
346
- [System.Management.Automation.CompletionResult]::new(
347
- $_,
348
- $_,
349
- 'ParameterValue',
350
- $_
351
- )
352
- }
353
- }
354
- 'create' {
355
- $cliproxyCreateFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
356
- [System.Management.Automation.CompletionResult]::new(
357
- $_,
358
- $_,
359
- 'ParameterValue',
360
- $_
361
- )
362
- }
363
- }
364
- }
365
- } elseif ($position -eq 5) {
366
- switch ($words[2]) {
367
- 'remove' {
368
- $removeFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
369
- [System.Management.Automation.CompletionResult]::new(
370
- $_,
371
- $_,
372
- 'ParameterValue',
373
- $_
374
- )
375
- }
376
- }
377
- 'create' {
378
- # After --provider, complete with provider names
379
- if ($words[3] -eq '--provider') {
380
- $providers | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
381
- [System.Management.Automation.CompletionResult]::new(
382
- $_,
383
- $_,
384
- 'ParameterValue',
385
- $_
386
- )
387
- }
388
- }
389
- }
390
- }
391
- }
392
- return
393
- }
45
+ $parts = $line -split "`t", 2
46
+ $value = $parts[0]
47
+ $description = if ($parts.Count -gt 1) { $parts[1] } else { $parts[0] }
394
48
 
395
- # profile subcommand completion (legacy)
396
- if ($words[1] -eq 'profile') {
397
- if ($position -eq 3) {
398
- @('create', 'list', 'remove', '--help', '-h') | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
399
- [System.Management.Automation.CompletionResult]::new(
400
- $_,
401
- $_,
402
- 'ParameterValue',
403
- $_
404
- )
405
- }
406
- } elseif ($position -eq 4) {
407
- switch ($words[2]) {
408
- 'remove' {
409
- $options = (Get-CcsProfiles -Type settings) + $removeFlags
410
- $options | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
411
- [System.Management.Automation.CompletionResult]::new(
412
- $_,
413
- $_,
414
- 'ParameterValue',
415
- $_
416
- )
417
- }
418
- }
419
- 'create' {
420
- $apiCreateFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
421
- [System.Management.Automation.CompletionResult]::new(
422
- $_,
423
- $_,
424
- 'ParameterValue',
425
- $_
426
- )
427
- }
428
- }
429
- }
430
- } elseif ($position -eq 5) {
431
- switch ($words[2]) {
432
- 'remove' {
433
- $removeFlags | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {
434
- [System.Management.Automation.CompletionResult]::new(
435
- $_,
436
- $_,
437
- 'ParameterValue',
438
- $_
439
- )
440
- }
441
- }
442
- }
443
- }
444
- return
49
+ [System.Management.Automation.CompletionResult]::new(
50
+ $value,
51
+ $value,
52
+ 'ParameterValue',
53
+ $description
54
+ )
445
55
  }
446
56
  }