@kaitranntt/ccs 7.65.3 → 7.66.0-dev.2

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 (245) 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 +82 -7
  37. package/dist/ccs.js.map +1 -1
  38. package/dist/cliproxy/auth/auth-types.d.ts +29 -6
  39. package/dist/cliproxy/auth/auth-types.d.ts.map +1 -1
  40. package/dist/cliproxy/auth/auth-types.js +58 -10
  41. package/dist/cliproxy/auth/auth-types.js.map +1 -1
  42. package/dist/cliproxy/auth/oauth-handler.d.ts +9 -1
  43. package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
  44. package/dist/cliproxy/auth/oauth-handler.js +196 -45
  45. package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
  46. package/dist/cliproxy/auth/oauth-process.d.ts +13 -1
  47. package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
  48. package/dist/cliproxy/auth/oauth-process.js +262 -17
  49. package/dist/cliproxy/auth/oauth-process.js.map +1 -1
  50. package/dist/cliproxy/executor/env-resolver.d.ts +3 -0
  51. package/dist/cliproxy/executor/env-resolver.d.ts.map +1 -1
  52. package/dist/cliproxy/executor/env-resolver.js +19 -1
  53. package/dist/cliproxy/executor/env-resolver.js.map +1 -1
  54. package/dist/cliproxy/executor/index.d.ts +5 -0
  55. package/dist/cliproxy/executor/index.d.ts.map +1 -1
  56. package/dist/cliproxy/executor/index.js +138 -12
  57. package/dist/cliproxy/executor/index.js.map +1 -1
  58. package/dist/cliproxy/gemini-cli-quota-normalizer.d.ts +10 -0
  59. package/dist/cliproxy/gemini-cli-quota-normalizer.d.ts.map +1 -0
  60. package/dist/cliproxy/gemini-cli-quota-normalizer.js +122 -0
  61. package/dist/cliproxy/gemini-cli-quota-normalizer.js.map +1 -0
  62. package/dist/cliproxy/quota-fetcher-gemini-cli.d.ts.map +1 -1
  63. package/dist/cliproxy/quota-fetcher-gemini-cli.js +133 -92
  64. package/dist/cliproxy/quota-fetcher-gemini-cli.js.map +1 -1
  65. package/dist/cliproxy/quota-types.d.ts +8 -0
  66. package/dist/cliproxy/quota-types.d.ts.map +1 -1
  67. package/dist/cliproxy/services/variant-settings.d.ts.map +1 -1
  68. package/dist/cliproxy/services/variant-settings.js +11 -0
  69. package/dist/cliproxy/services/variant-settings.js.map +1 -1
  70. package/dist/commands/cliproxy/quota-subcommand.d.ts.map +1 -1
  71. package/dist/commands/cliproxy/quota-subcommand.js +10 -1
  72. package/dist/commands/cliproxy/quota-subcommand.js.map +1 -1
  73. package/dist/commands/command-catalog.d.ts +39 -0
  74. package/dist/commands/command-catalog.d.ts.map +1 -0
  75. package/dist/commands/command-catalog.js +299 -0
  76. package/dist/commands/command-catalog.js.map +1 -0
  77. package/dist/commands/completion-backend.d.ts +14 -0
  78. package/dist/commands/completion-backend.d.ts.map +1 -0
  79. package/dist/commands/completion-backend.js +216 -0
  80. package/dist/commands/completion-backend.js.map +1 -0
  81. package/dist/commands/cursor-command-display.d.ts.map +1 -1
  82. package/dist/commands/cursor-command-display.js +25 -5
  83. package/dist/commands/cursor-command-display.js.map +1 -1
  84. package/dist/commands/cursor-command.d.ts +1 -3
  85. package/dist/commands/cursor-command.d.ts.map +1 -1
  86. package/dist/commands/cursor-command.js +3 -15
  87. package/dist/commands/cursor-command.js.map +1 -1
  88. package/dist/commands/help-command.d.ts +4 -3
  89. package/dist/commands/help-command.d.ts.map +1 -1
  90. package/dist/commands/help-command.js +209 -503
  91. package/dist/commands/help-command.js.map +1 -1
  92. package/dist/commands/install-command.d.ts.map +1 -1
  93. package/dist/commands/install-command.js +16 -3
  94. package/dist/commands/install-command.js.map +1 -1
  95. package/dist/commands/root-command-router.d.ts +2 -0
  96. package/dist/commands/root-command-router.d.ts.map +1 -1
  97. package/dist/commands/root-command-router.js +13 -13
  98. package/dist/commands/root-command-router.js.map +1 -1
  99. package/dist/commands/shell-completion-command.d.ts +1 -0
  100. package/dist/commands/shell-completion-command.d.ts.map +1 -1
  101. package/dist/commands/shell-completion-command.js +27 -11
  102. package/dist/commands/shell-completion-command.js.map +1 -1
  103. package/dist/copilot/copilot-executor.d.ts +2 -0
  104. package/dist/copilot/copilot-executor.d.ts.map +1 -1
  105. package/dist/copilot/copilot-executor.js +36 -4
  106. package/dist/copilot/copilot-executor.js.map +1 -1
  107. package/dist/cursor/constants.d.ts +3 -0
  108. package/dist/cursor/constants.d.ts.map +1 -0
  109. package/dist/cursor/constants.js +20 -0
  110. package/dist/cursor/constants.js.map +1 -0
  111. package/dist/cursor/cursor-models.d.ts.map +1 -1
  112. package/dist/cursor/cursor-models.js +2 -0
  113. package/dist/cursor/cursor-models.js.map +1 -1
  114. package/dist/cursor/cursor-profile-executor.d.ts +10 -0
  115. package/dist/cursor/cursor-profile-executor.d.ts.map +1 -0
  116. package/dist/cursor/cursor-profile-executor.js +158 -0
  117. package/dist/cursor/cursor-profile-executor.js.map +1 -0
  118. package/dist/cursor/cursor-translator.d.ts +22 -11
  119. package/dist/cursor/cursor-translator.d.ts.map +1 -1
  120. package/dist/cursor/cursor-translator.js +254 -75
  121. package/dist/cursor/cursor-translator.js.map +1 -1
  122. package/dist/cursor/index.d.ts +1 -0
  123. package/dist/cursor/index.d.ts.map +1 -1
  124. package/dist/cursor/index.js +4 -1
  125. package/dist/cursor/index.js.map +1 -1
  126. package/dist/delegation/headless-executor.d.ts.map +1 -1
  127. package/dist/delegation/headless-executor.js +79 -2
  128. package/dist/delegation/headless-executor.js.map +1 -1
  129. package/dist/management/checks/image-analysis-check.d.ts.map +1 -1
  130. package/dist/management/checks/image-analysis-check.js +4 -5
  131. package/dist/management/checks/image-analysis-check.js.map +1 -1
  132. package/dist/management/instance-manager.js +1 -1
  133. package/dist/management/instance-manager.js.map +1 -1
  134. package/dist/shared/claude-extension-setup.d.ts.map +1 -1
  135. package/dist/shared/claude-extension-setup.js +36 -16
  136. package/dist/shared/claude-extension-setup.js.map +1 -1
  137. package/dist/targets/target-runtime-compatibility.d.ts.map +1 -1
  138. package/dist/targets/target-runtime-compatibility.js +6 -0
  139. package/dist/targets/target-runtime-compatibility.js.map +1 -1
  140. package/dist/types/profile.d.ts +1 -1
  141. package/dist/types/profile.d.ts.map +1 -1
  142. package/dist/ui/assets/accounts-l__hcQUq.js +1 -0
  143. package/dist/ui/assets/{alert-dialog-D0EFRcfB.js → alert-dialog-BtM3eP43.js} +1 -1
  144. package/dist/ui/assets/{api-DhM3BYXr.js → api-Ddwn7EXC.js} +1 -1
  145. package/dist/ui/assets/{auth-section-DVp8FQGm.js → auth-section-BnYn1EA3.js} +1 -1
  146. package/dist/ui/assets/{backups-section-CRo0NZkA.js → backups-section-M4jx3HzK.js} +1 -1
  147. package/dist/ui/assets/{channels-uZ_9CBqO.js → channels-D9ywyAj3.js} +1 -1
  148. package/dist/ui/assets/{checkbox-32DNqW_Q.js → checkbox-Df-yoPbe.js} +1 -1
  149. package/dist/ui/assets/{claude-extension-BfXlz5gV.js → claude-extension-Cxg0a-Ee.js} +1 -1
  150. package/dist/ui/assets/cliproxy-DPFdpIHy.js +3 -0
  151. package/dist/ui/assets/{cliproxy-ai-providers-5SHLMHiy.js → cliproxy-ai-providers-DtW-6cPc.js} +6 -6
  152. package/dist/ui/assets/cliproxy-control-panel-0TyLDMf7.js +1 -0
  153. package/dist/ui/assets/{codex-CRUSpjsu.js → codex-BtPojOrJ.js} +3 -3
  154. package/dist/ui/assets/{confirm-dialog-DVf5ZmCZ.js → confirm-dialog-BMwFBq5G.js} +1 -1
  155. package/dist/ui/assets/{copilot-BZrihl_Z.js → copilot-BG3BnHxa.js} +2 -2
  156. package/dist/ui/assets/{cursor-BP4nbEk_.js → cursor-BfDO73Lu.js} +1 -1
  157. package/dist/ui/assets/{droid-BG92rdM2.js → droid-iW-Vtuhy.js} +2 -2
  158. package/dist/ui/assets/{globalenv-section-Cf6dKgSf.js → globalenv-section-d9h23hIf.js} +1 -1
  159. package/dist/ui/assets/{health-BTy1UZs3.js → health-BPPMFQMR.js} +1 -1
  160. package/dist/ui/assets/icons-BxSzn11s.js +1 -0
  161. package/dist/ui/assets/index-B6Y8wFQ0.css +1 -0
  162. package/dist/ui/assets/{index-wg7UtkFv.js → index-BPyp9RJE.js} +1 -1
  163. package/dist/ui/assets/{index-DHrTq-0n.js → index-CctYE17X.js} +1 -1
  164. package/dist/ui/assets/{index-BVeN0dIB.js → index-CeP2Pr2w.js} +1 -1
  165. package/dist/ui/assets/{index-DuRYaONg.js → index-DYY3wcwk.js} +1 -1
  166. package/dist/ui/assets/{index-N2ZSJurX.js → index-DusmDwkD.js} +1 -1
  167. package/dist/ui/assets/index-wIy8qzU9.js +69 -0
  168. package/dist/ui/assets/{masked-input-DX9bedLy.js → masked-input-DWNtAEKs.js} +1 -1
  169. package/dist/ui/assets/{proxy-status-widget-DVDMuZK5.js → proxy-status-widget-GS3qroms.js} +1 -1
  170. package/dist/ui/assets/{radix-ui-C98W0NRG.js → radix-ui-Zb8sVEtn.js} +1 -1
  171. package/dist/ui/assets/{raw-json-settings-editor-panel-Dkt5E6Z_.js → raw-json-settings-editor-panel-e3Ziu5B1.js} +1 -1
  172. package/dist/ui/assets/{searchable-select-BP3Q1-Yn.js → searchable-select-D2G6gg3h.js} +1 -1
  173. package/dist/ui/assets/{separator-BLGGUlh9.js → separator-CR1SGLxF.js} +1 -1
  174. package/dist/ui/assets/{shared-G0XRyLig.js → shared-BpB5GiWS.js} +1 -1
  175. package/dist/ui/assets/{table-B4lRrWC-.js → table-BMbwptG_.js} +1 -1
  176. package/dist/ui/assets/{tanstack-CfKik0yL.js → tanstack-DWm6aJ-G.js} +1 -1
  177. package/dist/ui/assets/{updates--A2Sdo7N.js → updates-iC3kvbKP.js} +1 -1
  178. package/dist/ui/index.html +5 -5
  179. package/dist/utils/config-manager.d.ts +5 -0
  180. package/dist/utils/config-manager.d.ts.map +1 -1
  181. package/dist/utils/config-manager.js +10 -1
  182. package/dist/utils/config-manager.js.map +1 -1
  183. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts +26 -0
  184. package/dist/utils/hooks/get-image-analysis-hook-env.d.ts.map +1 -1
  185. package/dist/utils/hooks/get-image-analysis-hook-env.js +79 -1
  186. package/dist/utils/hooks/get-image-analysis-hook-env.js.map +1 -1
  187. package/dist/utils/hooks/image-analysis-backend-resolver.d.ts.map +1 -1
  188. package/dist/utils/hooks/image-analysis-backend-resolver.js +13 -5
  189. package/dist/utils/hooks/image-analysis-backend-resolver.js.map +1 -1
  190. package/dist/utils/hooks/image-analysis-runtime-status.d.ts +2 -0
  191. package/dist/utils/hooks/image-analysis-runtime-status.d.ts.map +1 -1
  192. package/dist/utils/hooks/image-analysis-runtime-status.js +15 -11
  193. package/dist/utils/hooks/image-analysis-runtime-status.js.map +1 -1
  194. package/dist/utils/hooks/image-analyzer-hook-installer.d.ts.map +1 -1
  195. package/dist/utils/hooks/image-analyzer-hook-installer.js +60 -27
  196. package/dist/utils/hooks/image-analyzer-hook-installer.js.map +1 -1
  197. package/dist/utils/hooks/image-analyzer-profile-hook-injector.d.ts.map +1 -1
  198. package/dist/utils/hooks/image-analyzer-profile-hook-injector.js +3 -0
  199. package/dist/utils/hooks/image-analyzer-profile-hook-injector.js.map +1 -1
  200. package/dist/utils/hooks/index.d.ts +2 -1
  201. package/dist/utils/hooks/index.d.ts.map +1 -1
  202. package/dist/utils/hooks/index.js +14 -7
  203. package/dist/utils/hooks/index.js.map +1 -1
  204. package/dist/utils/image-analysis/claude-tool-args.d.ts +6 -0
  205. package/dist/utils/image-analysis/claude-tool-args.d.ts.map +1 -0
  206. package/dist/utils/image-analysis/claude-tool-args.js +65 -0
  207. package/dist/utils/image-analysis/claude-tool-args.js.map +1 -0
  208. package/dist/utils/image-analysis/index.d.ts +4 -0
  209. package/dist/utils/image-analysis/index.d.ts.map +1 -1
  210. package/dist/utils/image-analysis/index.js +20 -1
  211. package/dist/utils/image-analysis/index.js.map +1 -1
  212. package/dist/utils/image-analysis/mcp-installer.d.ts +18 -0
  213. package/dist/utils/image-analysis/mcp-installer.d.ts.map +1 -0
  214. package/dist/utils/image-analysis/mcp-installer.js +447 -0
  215. package/dist/utils/image-analysis/mcp-installer.js.map +1 -0
  216. package/dist/web-server/routes/account-routes.d.ts.map +1 -1
  217. package/dist/web-server/routes/account-routes.js +14 -2
  218. package/dist/web-server/routes/account-routes.js.map +1 -1
  219. package/dist/web-server/routes/auth-routes.d.ts +10 -0
  220. package/dist/web-server/routes/auth-routes.d.ts.map +1 -1
  221. package/dist/web-server/routes/auth-routes.js +33 -6
  222. package/dist/web-server/routes/auth-routes.js.map +1 -1
  223. package/dist/web-server/routes/cliproxy-auth-routes.d.ts +8 -0
  224. package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
  225. package/dist/web-server/routes/cliproxy-auth-routes.js +141 -11
  226. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  227. package/dist/web-server/routes/image-analysis-routes.d.ts.map +1 -1
  228. package/dist/web-server/routes/image-analysis-routes.js +30 -5
  229. package/dist/web-server/routes/image-analysis-routes.js.map +1 -1
  230. package/lib/hooks/image-analysis-runtime.cjs +469 -0
  231. package/lib/hooks/image-analyzer-transformer.cjs +27 -418
  232. package/lib/hooks/websearch-transformer.cjs +37 -2
  233. package/lib/mcp/ccs-image-analysis-server.cjs +440 -0
  234. package/package.json +1 -1
  235. package/scripts/completion/README.md +55 -131
  236. package/scripts/completion/ccs.bash +22 -190
  237. package/scripts/completion/ccs.fish +19 -245
  238. package/scripts/completion/ccs.ps1 +37 -427
  239. package/scripts/completion/ccs.zsh +27 -305
  240. package/dist/ui/assets/accounts-BHEYnq6b.js +0 -1
  241. package/dist/ui/assets/cliproxy-DjNY9H-U.js +0 -3
  242. package/dist/ui/assets/cliproxy-control-panel-Zax_m1AC.js +0 -1
  243. package/dist/ui/assets/icons-CeH5899d.js +0 -1
  244. package/dist/ui/assets/index-B6SrL1O-.css +0 -1
  245. package/dist/ui/assets/index-Corv1lSo.js +0 -69
@@ -2,14 +2,16 @@
2
2
 
3
3
  Tab completion for CCS commands, subcommands, profiles, and flags.
4
4
 
5
+ The completion scripts are thin adapters over the hidden `ccs __complete` backend so
6
+ all supported shells stay aligned with the same command graph.
7
+
5
8
  **Supported Shells:** Bash, Zsh, Fish, PowerShell
6
9
 
7
10
  ## Features
8
11
 
9
12
  - Complete profile names (both settings-based and account-based)
10
- - Complete `ccs auth` subcommands (create, list, show, remove, default)
11
- - Complete flags (`--help`, `--version`, `--json`, `--verbose`, `--yes`)
12
- - Complete profile names for auth subcommands
13
+ - Complete root commands, help topics, provider shortcuts, and command flags
14
+ - Complete `ccs auth` and `ccs api` lifecycle subcommands
13
15
  - Context-aware: suggests relevant options based on current command
14
16
 
15
17
  ## Quick Install (Recommended)
@@ -32,6 +34,12 @@ ccs --shell-completion --fish # Force fish
32
34
  ccs --shell-completion --powershell # Force PowerShell
33
35
  ```
34
36
 
37
+ **Help and verification:**
38
+ ```bash
39
+ ccs help completion
40
+ ccs --shell-completion --force
41
+ ```
42
+
35
43
  ## Manual Installation
36
44
 
37
45
  Completion files are installed to `~/.ccs/completions/` during `npm install`.
@@ -116,188 +124,104 @@ sudo cp scripts/completion/ccs.fish /usr/share/fish/vendor_completions.d/
116
124
 
117
125
  ```bash
118
126
  $ ccs <TAB>
119
- auth doctor glm kimi work personal --help --version
127
+ auth api cliproxy config doctor docker help
120
128
 
121
- $ ccs auth <TAB>
122
- create list show remove default --help
129
+ $ ccs help <TAB>
130
+ profiles providers completion targets
123
131
  ```
124
132
 
125
- ### Profile Completion
133
+ ### Context Completion
126
134
 
127
135
  ```bash
128
136
  $ ccs auth show <TAB>
129
137
  work personal team --json
130
138
 
131
- $ ccs auth remove <TAB>
132
- work personal team --yes -y
139
+ $ ccs api <TAB>
140
+ create list discover copy export import remove
133
141
  ```
134
142
 
135
- ### Flag Completion
143
+ ### Backend Contract
136
144
 
137
145
  ```bash
138
- $ ccs auth list <TAB>
139
- --verbose --json
140
-
141
- $ ccs auth show work <TAB>
142
- --json
146
+ $ ccs __complete --shell bash --current do
147
+ doctor
148
+ docker
143
149
  ```
144
150
 
145
- ## Completion Behavior
146
-
147
- ### Top-level (after `ccs`)
148
- - Built-in commands: `auth`, `doctor`
149
- - Flags: `--help`, `--version`, `-h`, `-v`
150
- - Settings-based profiles: from `~/.ccs/config.json`
151
- - Account-based profiles: from `~/.ccs/profiles.json`
152
-
153
- ### After `ccs auth`
154
- - Subcommands: `create`, `list`, `show`, `remove`, `default`
155
- - Flags: `--help`, `-h`
156
-
157
- ### After `ccs auth <subcommand>`
158
- - **create**: No completion (user enters new profile name)
159
- - Flags: `--force`
160
- - **list**: No profile completion
161
- - Flags: `--verbose`, `--json`
162
- - **show**: Account profiles only
163
- - Flags: `--json`
164
- - **remove**: Account profiles only
165
- - Flags: `--yes`, `-y`
166
- - **default**: Account profiles only
167
-
168
- ### After `ccs <profile>`
169
- - No completion (Claude CLI arguments are free-form)
151
+ Shell adapters now call the shared CCS completion backend instead of maintaining their own
152
+ copy of the command graph. That means:
153
+ - top-level commands, help topics, and provider shortcuts come from CCS itself
154
+ - dynamic profiles and CLIProxy variants resolve through the real config loaders
155
+ - bash, zsh, fish, and PowerShell stay aligned with the same completion logic
170
156
 
171
157
  ## Troubleshooting
172
158
 
173
- ### Bash: Completion not working
174
-
175
- 1. Check if bash-completion is installed:
176
- ```bash
177
- # macOS
178
- brew install bash-completion
179
-
180
- # Ubuntu/Debian
181
- sudo apt install bash-completion
182
- ```
183
-
184
- 2. Verify jq is installed (required for profile completion):
185
- ```bash
186
- command -v jq
187
- ```
159
+ ### Bash
188
160
 
189
- 3. Check if completion is loaded:
161
+ 1. Check if completion is loaded:
190
162
  ```bash
191
163
  complete -p ccs
192
164
  ```
193
-
194
- Should output:
195
- ```
196
- complete -F _ccs_completion ccs
165
+ 2. Verify the backend directly:
166
+ ```bash
167
+ ccs __complete --shell bash --current "" -- help
197
168
  ```
198
169
 
199
- ### Zsh: Completion not working
170
+ ### Zsh
200
171
 
201
- 1. Verify completion system is enabled in `~/.zshrc`:
172
+ 1. Verify completion system is enabled:
202
173
  ```zsh
203
174
  autoload -Uz compinit && compinit
204
175
  ```
205
-
206
- 2. Check if completion is loaded:
176
+ 2. Rebuild the cache if needed:
207
177
  ```zsh
208
- which _ccs
178
+ rm ~/.zcompdump && compinit
209
179
  ```
210
-
211
- 3. Rebuild completion cache:
180
+ 3. Verify the backend directly:
212
181
  ```zsh
213
- rm ~/.zcompdump && compinit
182
+ ccs __complete --shell zsh --current "" -- help
214
183
  ```
215
184
 
216
- ### PowerShell: Completion not working
217
-
218
- 1. Check PowerShell version (5.1+ required):
219
- ```powershell
220
- $PSVersionTable.PSVersion
221
- ```
185
+ ### PowerShell
222
186
 
223
- 2. Verify profile is loaded:
187
+ 1. Check that the profile exists:
224
188
  ```powershell
225
189
  Test-Path $PROFILE
226
190
  ```
227
-
228
- 3. Check if completion is registered:
191
+ 2. Verify the backend directly:
229
192
  ```powershell
230
- (Get-ArgumentCompleter).CommandName | Select-String ccs
193
+ ccs __complete --shell powershell --current "" -- help
231
194
  ```
232
195
 
233
- ### Fish: Completion not working
234
-
235
- 1. Check Fish version (3.0+ required):
236
- ```fish
237
- fish --version
238
- ```
196
+ ### Fish
239
197
 
240
- 2. Verify completion file is in the right location:
198
+ 1. Verify completion file location:
241
199
  ```fish
242
200
  ls ~/.config/fish/completions/ccs.fish
243
201
  ```
244
-
245
- 3. Verify jq is installed (required for profile completion):
246
- ```fish
247
- which jq
248
- ```
249
-
250
- 4. Test completion manually:
202
+ 2. Test completion manually:
251
203
  ```fish
252
204
  complete -C'ccs '
253
205
  ```
254
-
255
- 5. If needed, rebuild completions:
206
+ 3. Verify the backend directly:
256
207
  ```fish
257
- fish_update_completions
208
+ ccs __complete --shell fish --current "" -- help
258
209
  ```
259
210
 
260
211
  ## Technical Details
261
212
 
262
- ### Bash Implementation
263
- - Uses `complete -F` for programmable completion
264
- - Compatible with bash 3.2+ (macOS default)
265
- - Reads profiles dynamically using `jq`
266
- - Context-aware based on `COMP_CWORD` and `COMP_WORDS`
267
-
268
- ### Zsh Implementation
269
- - Uses `_arguments` and `_describe` for rich completion
270
- - Compatible with zsh 5.0+
271
- - Supports completion descriptions
272
- - Context-aware using `$state` and `$words`
273
-
274
- ### PowerShell Implementation
275
- - Uses `Register-ArgumentCompleter`
276
- - Compatible with PowerShell 5.1+
277
- - Reads profiles dynamically using `ConvertFrom-Json`
278
- - Provides `CompletionResult` objects
279
-
280
- ### Fish Implementation
281
- - Uses declarative `complete` command
282
- - Compatible with Fish 3.0+
283
- - Automatic loading from `~/.config/fish/completions/`
284
- - Helper functions for dynamic profile loading
285
- - Context-aware using `__fish_seen_subcommand_from`
286
- - No manual sourcing required
287
-
288
- ## Dependencies
289
-
290
- - **jq**: Required for reading profiles from JSON files
291
- - Install: `brew install jq` (macOS) or `apt install jq` (Ubuntu)
292
- - Already required by CCS core functionality
213
+ - Bash uses `complete -F`
214
+ - Zsh uses a custom `_ccs` completion function
215
+ - Fish uses `complete -a` with backend command substitution
216
+ - PowerShell uses `Register-ArgumentCompleter`
217
+ - All four shells now delegate suggestion logic to `ccs __complete`
293
218
 
294
219
  ## Contributing
295
220
 
296
- When adding new commands or flags:
297
- 1. Update all four completion scripts (bash, zsh, fish, PowerShell)
298
- 2. Test on each shell
299
- 3. Update this README with new completion examples
300
- 4. Maintain cross-shell parity
221
+ When adding or changing command surfaces:
222
+ 1. Update the shared TypeScript command/completion catalog
223
+ 2. Run `bun run validate`
224
+ 3. Smoke-check at least one installed shell adapter plus the backend directly
301
225
 
302
226
  ## See Also
303
227
 
@@ -1,210 +1,42 @@
1
1
  # Bash completion for CCS (Claude Code Switch)
2
2
  # Compatible with bash 3.2+
3
- #
4
- # Installation:
5
- # Add to ~/.bashrc or ~/.bash_profile:
6
- # source /path/to/ccs/scripts/completion/ccs.bash
7
- #
8
- # Or install system-wide (requires sudo):
9
- # sudo cp scripts/completion/ccs.bash /etc/bash_completion.d/ccs
10
3
 
11
4
  _ccs_completion() {
12
- local cur prev words cword
5
+ local cur
13
6
  COMPREPLY=()
14
-
15
- # Get current word and previous word
16
7
  cur="${COMP_WORDS[COMP_CWORD]}"
17
- prev="${COMP_WORDS[COMP_CWORD-1]}"
18
-
19
- # Top-level completion (first argument)
20
- if [[ ${COMP_CWORD} -eq 1 ]]; then
21
- local commands="auth api cliproxy config doctor env persist sync update"
22
- local flags="--help --version --shell-completion -h -v -sc"
23
- local cliproxy_profiles="gemini codex agy qwen"
24
- local profiles=""
25
-
26
- # Add profiles from config.json (settings-based profiles)
27
- if [[ -f ~/.ccs/config.json ]]; then
28
- profiles="$profiles $(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null || true)"
29
- fi
30
-
31
- # Add profiles from profiles.json (account-based profiles)
32
- if [[ -f ~/.ccs/profiles.json ]]; then
33
- profiles="$profiles $(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null || true)"
34
- fi
35
-
36
- # Add cliproxy variants from config.json
37
- if [[ -f ~/.ccs/config.json ]]; then
38
- profiles="$profiles $(jq -r '.cliproxy | keys[]' ~/.ccs/config.json 2>/dev/null || true)"
39
- fi
40
-
41
- # Combine all options
42
- local opts="$commands $flags $cliproxy_profiles $profiles"
43
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
44
- return 0
45
- fi
46
-
47
- # CLIProxy provider flags (gemini, codex, agy, qwen)
48
- if [[ ${COMP_WORDS[1]} =~ ^(gemini|codex|agy|qwen)$ ]]; then
49
- local provider_flags="--auth --config --logout --headless --help -h"
50
- COMPREPLY=( $(compgen -W "${provider_flags}" -- ${cur}) )
51
- return 0
52
- fi
53
-
54
- # auth subcommands
55
- if [[ ${prev} == "auth" ]]; then
56
- local auth_commands="create list show remove default --help -h"
57
- COMPREPLY=( $(compgen -W "${auth_commands}" -- ${cur}) )
58
- return 0
59
- fi
60
-
61
- # api subcommands
62
- if [[ ${prev} == "api" ]]; then
63
- local api_commands="create list remove --help -h"
64
- COMPREPLY=( $(compgen -W "${api_commands}" -- ${cur}) )
65
- return 0
66
- fi
67
-
68
- # cliproxy subcommands
69
- if [[ ${prev} == "cliproxy" ]]; then
70
- local cliproxy_commands="create list remove --install --latest --help -h"
71
- COMPREPLY=( $(compgen -W "${cliproxy_commands}" -- ${cur}) )
72
- return 0
73
- fi
74
8
 
75
- # Completion for cliproxy subcommands
76
- if [[ ${COMP_WORDS[1]} == "cliproxy" ]]; then
77
- case "${prev}" in
78
- remove|delete|rm)
79
- # Complete with cliproxy variant names
80
- if [[ -f ~/.ccs/config.json ]]; then
81
- local variants=$(jq -r '.cliproxy | keys[]' ~/.ccs/config.json 2>/dev/null || true)
82
- COMPREPLY=( $(compgen -W "${variants}" -- ${cur}) )
83
- fi
84
- return 0
85
- ;;
86
- create)
87
- # Complete with create flags
88
- COMPREPLY=( $(compgen -W "--provider --model --force --yes -y" -- ${cur}) )
89
- return 0
90
- ;;
91
- --provider)
92
- # Complete with provider names
93
- COMPREPLY=( $(compgen -W "gemini codex agy qwen" -- ${cur}) )
94
- return 0
95
- ;;
96
- list|ls)
97
- # No flags for list
98
- return 0
99
- ;;
100
- --install)
101
- # User enters version number
102
- return 0
103
- ;;
104
- esac
9
+ local tokens_before_current=()
10
+ if [[ ${COMP_CWORD} -gt 1 ]]; then
11
+ tokens_before_current=("${COMP_WORDS[@]:1:COMP_CWORD-1}")
105
12
  fi
106
13
 
107
- # Completion for api subcommands
108
- if [[ ${COMP_WORDS[1]} == "api" ]]; then
109
- case "${prev}" in
110
- remove|delete|rm)
111
- # Complete with settings profile names
112
- if [[ -f ~/.ccs/config.json ]]; then
113
- local profiles=$(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null || true)
114
- COMPREPLY=( $(compgen -W "${profiles}" -- ${cur}) )
115
- fi
116
- return 0
117
- ;;
118
- create)
119
- # Complete with create flags
120
- COMPREPLY=( $(compgen -W "--base-url --api-key --model --force --yes -y" -- ${cur}) )
121
- return 0
122
- ;;
123
- list)
124
- # No flags for list
125
- return 0
126
- ;;
127
- esac
128
- fi
14
+ while IFS= read -r line; do
15
+ [[ -n "${line}" ]] && COMPREPLY+=("${line}")
16
+ done < <(__ccs_completion_run "${cur}" "${tokens_before_current[@]}")
129
17
 
130
- # Completion for auth subcommands that need profile names
131
- if [[ ${COMP_WORDS[1]} == "auth" ]]; then
132
- case "${prev}" in
133
- show|remove|default)
134
- # Complete with account profile names only
135
- if [[ -f ~/.ccs/profiles.json ]]; then
136
- local profiles=$(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null || true)
137
- COMPREPLY=( $(compgen -W "${profiles}" -- ${cur}) )
138
- fi
139
- return 0
140
- ;;
141
- create)
142
- # Complete with create flags
143
- COMPREPLY=( $(compgen -W "--force" -- ${cur}) )
144
- return 0
145
- ;;
146
- list)
147
- # Complete with list flags
148
- COMPREPLY=( $(compgen -W "--verbose --json" -- ${cur}) )
149
- return 0
150
- ;;
151
- esac
152
- fi
18
+ return 0
19
+ }
153
20
 
154
- # env subcommands
155
- if [[ ${COMP_WORDS[1]} == "env" ]]; then
156
- case "${prev}" in
157
- env)
158
- # Complete with profile names and flags (inline profiles since $cliproxy_profiles is out of scope)
159
- local env_opts="--format --shell --ide --help -h gemini codex agy qwen iflow kiro ghcp claude default"
160
- if [[ -f ~/.ccs/config.json ]]; then
161
- env_opts="$env_opts $(jq -r '.profiles | keys[]' ~/.ccs/config.json 2>/dev/null || true)"
162
- fi
163
- if [[ -f ~/.ccs/profiles.json ]]; then
164
- env_opts="$env_opts $(jq -r '.profiles | keys[]' ~/.ccs/profiles.json 2>/dev/null || true)"
165
- fi
166
- COMPREPLY=( $(compgen -W "${env_opts}" -- ${cur}) )
167
- return 0
168
- ;;
169
- --format)
170
- COMPREPLY=( $(compgen -W "openai anthropic raw claude-extension" -- ${cur}) )
171
- return 0
172
- ;;
173
- --shell)
174
- COMPREPLY=( $(compgen -W "auto bash zsh fish powershell" -- ${cur}) )
175
- return 0
176
- ;;
177
- --ide)
178
- COMPREPLY=( $(compgen -W "vscode cursor windsurf" -- ${cur}) )
179
- return 0
180
- ;;
181
- *)
182
- COMPREPLY=( $(compgen -W "--format --shell --ide --help -h" -- ${cur}) )
183
- return 0
184
- ;;
185
- esac
186
- fi
21
+ __ccs_completion_run() {
22
+ local current="$1"
23
+ shift || true
187
24
 
188
- # Flags for doctor command
189
- if [[ ${COMP_WORDS[1]} == "doctor" ]]; then
190
- COMPREPLY=( $(compgen -W "--help -h" -- ${cur}) )
191
- return 0
25
+ local script_dir repo_root repo_cli
26
+ script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
27
+ repo_root="$(cd "${script_dir}/../.." && pwd)"
28
+ repo_cli="${repo_root}/dist/ccs.js"
29
+ if [[ ! -f "${repo_cli}" ]]; then
30
+ repo_cli="${repo_root}/bin/ccs.js"
192
31
  fi
193
-
194
- # Flags for update command
195
- if [[ ${COMP_WORDS[1]} == "update" ]]; then
196
- COMPREPLY=( $(compgen -W "--force --beta --dev --help -h" -- ${cur}) )
32
+ if [[ -f "${repo_cli}" ]]; then
33
+ node "${repo_cli}" __complete --shell bash --current "${current}" -- "$@" 2>/dev/null
197
34
  return 0
198
35
  fi
199
36
 
200
- # Flags for shell-completion command
201
- if [[ ${prev} == "--shell-completion" || ${prev} == "-sc" ]]; then
202
- COMPREPLY=( $(compgen -W "--bash --zsh --fish --powershell" -- ${cur}) )
203
- return 0
37
+ if command -v ccs >/dev/null 2>&1; then
38
+ ccs __complete --shell bash --current "${current}" -- "$@" 2>/dev/null
204
39
  fi
205
-
206
- return 0
207
40
  }
208
41
 
209
- # Register completion function
210
42
  complete -F _ccs_completion ccs