@cloudbase/cli 2.11.5 → 2.11.7

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 (596) hide show
  1. package/.augment-guidelines +119 -0
  2. package/.claude/settings.local.json +6 -0
  3. package/.clinerules/cloudbase-rules.mdc +119 -0
  4. package/.cursor/rules/cloudbase-rules.mdc +119 -0
  5. package/.editorconfig +10 -0
  6. package/.eslintignore +8 -0
  7. package/.eslintrc +35 -0
  8. package/.mcp.json +11 -0
  9. package/.prettierignore +1 -0
  10. package/.prettierrc.js +29 -0
  11. package/.vscode/launch.json +26 -0
  12. package/.yarnrc.yml +1 -0
  13. package/CLAUDE.md +119 -0
  14. package/LICENSE +6 -0
  15. package/bin/ccr.js +3 -0
  16. package/bin/cloudbase.js +7 -0
  17. package/bin/tcb.js +339 -0
  18. package/changelog.md +6 -0
  19. package/cloudbaserc.json +13 -0
  20. package/jest.config.js +17 -0
  21. package/lib/auth/index.js +18 -0
  22. package/lib/auth/login.js +111 -0
  23. package/lib/auth/logout.js +20 -0
  24. package/lib/commands/account/index.js +18 -0
  25. package/lib/commands/account/login.js +269 -0
  26. package/lib/commands/account/logout.js +56 -0
  27. package/lib/commands/ai/index.js +200 -0
  28. package/lib/commands/cloudfunction/base.js +369 -0
  29. package/lib/commands/cloudfunction/index.js +17 -0
  30. package/lib/commands/cloudrun/base.js +1040 -0
  31. package/lib/commands/cloudrun/cloudrun-run-ui/index.html +193 -0
  32. package/lib/commands/cloudrun/index.js +17 -0
  33. package/lib/commands/common.js +225 -0
  34. package/lib/commands/config/delete.js +72 -0
  35. package/lib/commands/config/get.js +69 -0
  36. package/lib/commands/config/index.js +21 -0
  37. package/lib/commands/config/interface.js +25 -0
  38. package/lib/commands/config/list.js +72 -0
  39. package/lib/commands/config/set.js +89 -0
  40. package/lib/commands/constants.js +11 -0
  41. package/lib/commands/db/base.js +399 -0
  42. package/lib/commands/db/index.js +17 -0
  43. package/lib/commands/env/base.js +129 -0
  44. package/lib/commands/env/domain.js +222 -0
  45. package/lib/commands/env/index.js +19 -0
  46. package/lib/commands/env/login.js +271 -0
  47. package/lib/commands/framework/index.js +196 -0
  48. package/lib/commands/fun/base.js +434 -0
  49. package/lib/commands/fun/index.js +17 -0
  50. package/lib/commands/functions/alias/getRoute.js +99 -0
  51. package/lib/commands/functions/alias/index.js +18 -0
  52. package/lib/commands/functions/alias/setRoute.js +101 -0
  53. package/lib/commands/functions/code-download.js +123 -0
  54. package/lib/commands/functions/code-update.js +96 -0
  55. package/lib/commands/functions/concurrency/delete.js +71 -0
  56. package/lib/commands/functions/concurrency/index.js +19 -0
  57. package/lib/commands/functions/concurrency/list.js +82 -0
  58. package/lib/commands/functions/concurrency/set.js +73 -0
  59. package/lib/commands/functions/config-update.js +103 -0
  60. package/lib/commands/functions/copy.js +82 -0
  61. package/lib/commands/functions/delete.js +102 -0
  62. package/lib/commands/functions/deploy.js +331 -0
  63. package/lib/commands/functions/detail.js +166 -0
  64. package/lib/commands/functions/index.js +33 -0
  65. package/lib/commands/functions/invoke.js +140 -0
  66. package/lib/commands/functions/layer/bind.js +191 -0
  67. package/lib/commands/functions/layer/common.js +13 -0
  68. package/lib/commands/functions/layer/create.js +88 -0
  69. package/lib/commands/functions/layer/delete.js +92 -0
  70. package/lib/commands/functions/layer/download.js +112 -0
  71. package/lib/commands/functions/layer/index.js +23 -0
  72. package/lib/commands/functions/layer/list.js +105 -0
  73. package/lib/commands/functions/layer/sort.js +98 -0
  74. package/lib/commands/functions/list.js +92 -0
  75. package/lib/commands/functions/log.js +156 -0
  76. package/lib/commands/functions/run.js +245 -0
  77. package/lib/commands/functions/trigger-create.js +99 -0
  78. package/lib/commands/functions/trigger-delete.js +121 -0
  79. package/lib/commands/functions/version/index.js +18 -0
  80. package/lib/commands/functions/version/list.js +97 -0
  81. package/lib/commands/functions/version/publish.js +71 -0
  82. package/lib/commands/gateway/create.js +125 -0
  83. package/lib/commands/gateway/delete.js +111 -0
  84. package/lib/commands/gateway/domain.js +202 -0
  85. package/lib/commands/gateway/index.js +21 -0
  86. package/lib/commands/gateway/list.js +107 -0
  87. package/lib/commands/gateway/switch.js +144 -0
  88. package/lib/commands/helpers/index.js +19 -0
  89. package/lib/commands/helpers/init.js +395 -0
  90. package/lib/commands/helpers/new.js +130 -0
  91. package/lib/commands/helpers/open.js +90 -0
  92. package/lib/commands/hosting/hosting.js +378 -0
  93. package/lib/commands/hosting/index.js +17 -0
  94. package/lib/commands/index.js +38 -0
  95. package/lib/commands/lowcode/app.js +400 -0
  96. package/lib/commands/lowcode/comps.js +384 -0
  97. package/lib/commands/lowcode/deps.js +85 -0
  98. package/lib/commands/lowcode/index.js +19 -0
  99. package/lib/commands/lowcode/utils.js +308 -0
  100. package/lib/commands/pull/index.js +17 -0
  101. package/lib/commands/pull/pull.js +107 -0
  102. package/lib/commands/run/delete.js +102 -0
  103. package/lib/commands/run/image/common.js +13 -0
  104. package/lib/commands/run/image/delete.js +91 -0
  105. package/lib/commands/run/image/download.js +86 -0
  106. package/lib/commands/run/image/index.js +21 -0
  107. package/lib/commands/run/image/list.js +104 -0
  108. package/lib/commands/run/image/upload.js +114 -0
  109. package/lib/commands/run/index.js +21 -0
  110. package/lib/commands/run/list.js +104 -0
  111. package/lib/commands/run/service/config.js +113 -0
  112. package/lib/commands/run/service/deploy.js +155 -0
  113. package/lib/commands/run/service/index.js +20 -0
  114. package/lib/commands/run/service/list.js +116 -0
  115. package/lib/commands/run/service/update.js +141 -0
  116. package/lib/commands/run/standalonegateway/common.js +13 -0
  117. package/lib/commands/run/standalonegateway/create.js +106 -0
  118. package/lib/commands/run/standalonegateway/destroy.js +82 -0
  119. package/lib/commands/run/standalonegateway/index.js +21 -0
  120. package/lib/commands/run/standalonegateway/list.js +78 -0
  121. package/lib/commands/run/standalonegateway/package.js +87 -0
  122. package/lib/commands/run/standalonegateway/turn.js +87 -0
  123. package/lib/commands/run/version/common.js +13 -0
  124. package/lib/commands/run/version/create.js +329 -0
  125. package/lib/commands/run/version/delete.js +90 -0
  126. package/lib/commands/run/version/index.js +21 -0
  127. package/lib/commands/run/version/list.js +109 -0
  128. package/lib/commands/run/version/modify.js +142 -0
  129. package/lib/commands/run/version/update.js +353 -0
  130. package/lib/commands/runf/base.js +453 -0
  131. package/lib/commands/runf/index.js +17 -0
  132. package/lib/commands/self-update.js +134 -0
  133. package/lib/commands/smart.js +124 -0
  134. package/lib/commands/storage/index.js +17 -0
  135. package/lib/commands/storage/storage.js +515 -0
  136. package/lib/commands/third/index.js +17 -0
  137. package/lib/commands/third/thirdAttach.js +78 -0
  138. package/lib/commands/utils.js +197 -0
  139. package/lib/completion/index.js +15 -0
  140. package/lib/constant.js +142 -0
  141. package/lib/db/index.js +85 -0
  142. package/lib/decorators/captureError.js +30 -0
  143. package/lib/decorators/constants.js +15 -0
  144. package/lib/decorators/deprecate.js +18 -0
  145. package/lib/decorators/guard.js +35 -0
  146. package/lib/decorators/index.js +25 -0
  147. package/lib/decorators/injectParams.js +58 -0
  148. package/lib/decorators/params/common.js +16 -0
  149. package/lib/decorators/params/index.js +34 -0
  150. package/lib/env/domain.js +42 -0
  151. package/lib/env/index.js +80 -0
  152. package/lib/env/login.js +78 -0
  153. package/lib/error.js +17 -0
  154. package/lib/function/alias.js +54 -0
  155. package/lib/function/base.js +266 -0
  156. package/lib/function/code.js +28 -0
  157. package/lib/function/concurrency.js +70 -0
  158. package/lib/function/create.js +72 -0
  159. package/lib/function/delete.js +53 -0
  160. package/lib/function/index.js +27 -0
  161. package/lib/function/layer/attach.js +63 -0
  162. package/lib/function/layer/create.js +63 -0
  163. package/lib/function/layer/delete.js +24 -0
  164. package/lib/function/layer/download.js +37 -0
  165. package/lib/function/layer/index.js +23 -0
  166. package/lib/function/layer/list.js +36 -0
  167. package/lib/function/layer/sort.js +25 -0
  168. package/lib/function/trigger.js +106 -0
  169. package/lib/function/update.js +41 -0
  170. package/lib/function/version.js +52 -0
  171. package/lib/function/vpc.js +35 -0
  172. package/lib/gateway/index.js +136 -0
  173. package/lib/help.js +44 -0
  174. package/lib/hosting.js +244 -0
  175. package/lib/i18n/index.js +73 -0
  176. package/lib/index.js +13 -0
  177. package/lib/logger.js +19 -0
  178. package/lib/run/delete.js +22 -0
  179. package/lib/run/image/build.js +37 -0
  180. package/lib/run/image/delete.js +22 -0
  181. package/lib/run/image/index.js +20 -0
  182. package/lib/run/image/info.js +29 -0
  183. package/lib/run/image/list.js +30 -0
  184. package/lib/run/index.js +23 -0
  185. package/lib/run/list.js +39 -0
  186. package/lib/run/repo.js +31 -0
  187. package/lib/run/service/common.js +271 -0
  188. package/lib/run/service/config.js +70 -0
  189. package/lib/run/service/deployPackage.js +83 -0
  190. package/lib/run/service/index.js +22 -0
  191. package/lib/run/service/list.js +31 -0
  192. package/lib/run/service/showLogs.js +117 -0
  193. package/lib/run/service/update.js +84 -0
  194. package/lib/run/standalonegateway/create.js +32 -0
  195. package/lib/run/standalonegateway/destroy.js +28 -0
  196. package/lib/run/standalonegateway/index.js +21 -0
  197. package/lib/run/standalonegateway/list.js +48 -0
  198. package/lib/run/standalonegateway/package/index.js +17 -0
  199. package/lib/run/standalonegateway/package/list.js +32 -0
  200. package/lib/run/standalonegateway/turn/index.js +18 -0
  201. package/lib/run/standalonegateway/turn/off.js +28 -0
  202. package/lib/run/standalonegateway/turn/on.js +28 -0
  203. package/lib/run/version/create.js +50 -0
  204. package/lib/run/version/delete.js +23 -0
  205. package/lib/run/version/index.js +22 -0
  206. package/lib/run/version/list.js +24 -0
  207. package/lib/run/version/modify.js +24 -0
  208. package/lib/run/version/repo.js +33 -0
  209. package/lib/run/version/update.js +39 -0
  210. package/lib/storage.js +125 -0
  211. package/lib/third/index.js +25 -0
  212. package/lib/types.js +12 -0
  213. package/lib/utils/ai/banner.js +106 -0
  214. package/lib/utils/ai/claudeWindows.js +64 -0
  215. package/lib/utils/ai/config.js +290 -0
  216. package/lib/utils/ai/const.js +178 -0
  217. package/lib/utils/ai/ensureFiles.js +27 -0
  218. package/lib/utils/ai/env.js +37 -0
  219. package/lib/utils/ai/envLocalManager.js +145 -0
  220. package/lib/utils/ai/nodeVersion.js +19 -0
  221. package/lib/utils/ai/router.js +1315 -0
  222. package/lib/utils/ai/setup.js +705 -0
  223. package/lib/utils/auth.js +28 -0
  224. package/lib/utils/checkTcbrEnv.js +76 -0
  225. package/lib/utils/cli-table.js +19 -0
  226. package/lib/utils/commonParamsCheck.js +49 -0
  227. package/lib/utils/config.js +59 -0
  228. package/lib/utils/debug-logger.js +31 -0
  229. package/lib/utils/dts.js +154 -0
  230. package/lib/utils/env.js +222 -0
  231. package/lib/utils/fs/del.js +11 -0
  232. package/lib/utils/fs/index.js +94 -0
  233. package/lib/utils/function-packer.js +87 -0
  234. package/lib/utils/index.js +38 -0
  235. package/lib/utils/log.js +85 -0
  236. package/lib/utils/mcp-config-modifier.js +205 -0
  237. package/lib/utils/net/cloud-api-request.js +64 -0
  238. package/lib/utils/net/credential.js +61 -0
  239. package/lib/utils/net/http-request.js +108 -0
  240. package/lib/utils/net/index.js +21 -0
  241. package/lib/utils/net/manager-service.js +51 -0
  242. package/lib/utils/net/proxy.js +9 -0
  243. package/lib/utils/notice.js +37 -0
  244. package/lib/utils/output/highlight.js +11 -0
  245. package/lib/utils/output/index.js +19 -0
  246. package/lib/utils/output/link.js +16 -0
  247. package/lib/utils/output/loading.js +68 -0
  248. package/lib/utils/parallel.js +65 -0
  249. package/lib/utils/platform/index.js +19 -0
  250. package/lib/utils/platform/mac.js +37 -0
  251. package/lib/utils/platform/os.js +59 -0
  252. package/lib/utils/platform/port.js +26 -0
  253. package/lib/utils/progress-bar.js +44 -0
  254. package/lib/utils/prompt/index.js +17 -0
  255. package/lib/utils/prompt/select.js +54 -0
  256. package/lib/utils/report.js +78 -0
  257. package/lib/utils/reporter/agree.js +31 -0
  258. package/lib/utils/reporter/download.js +37 -0
  259. package/lib/utils/reporter/index.js +19 -0
  260. package/lib/utils/reporter/usage.js +32 -0
  261. package/lib/utils/store/auth.js +59 -0
  262. package/lib/utils/store/common.js +8 -0
  263. package/lib/utils/store/config.js +49 -0
  264. package/lib/utils/store/db.js +84 -0
  265. package/lib/utils/store/index.js +21 -0
  266. package/lib/utils/store/usage.js +9 -0
  267. package/lib/utils/tcbrApi/callTcbrApi.js +39 -0
  268. package/lib/utils/tcbrApi/index.js +17 -0
  269. package/lib/utils/template-manager.js +458 -0
  270. package/lib/utils/template.js +131 -0
  271. package/lib/utils/tools/common.js +74 -0
  272. package/lib/utils/tools/encoding.js +13 -0
  273. package/lib/utils/tools/index.js +20 -0
  274. package/lib/utils/tools/object.js +28 -0
  275. package/lib/utils/tools/time.js +49 -0
  276. package/lib/utils/tools/uid.js +25 -0
  277. package/lib/utils/url.js +19 -0
  278. package/lib/utils/validator.js +72 -0
  279. package/locales/README.md +160 -0
  280. package/locales/i18next-scanner.config.js +211 -0
  281. package/locales/index.js +5 -0
  282. package/locales/langs/en.json +1236 -0
  283. package/locales/langs/zh.json +1236 -0
  284. package/locales/mapping.json +1242 -0
  285. package/package.json +133 -16
  286. package/patches/@musistudio+claude-code-router+1.0.36.patch +40 -0
  287. package/post-install.js +63 -0
  288. package/rules/cloudbase-platform.mdc +44 -0
  289. package/rules/database.mdc +25 -0
  290. package/rules/miniprogram-development.mdc +61 -0
  291. package/rules/ui-design.mdc +24 -0
  292. package/rules/web-development.mdc +44 -0
  293. package/rules/workflows.mdc +30 -0
  294. package/runtime/nodejs/bootstrap.js +255 -0
  295. package/runtime/nodejs/runtime.js +183 -0
  296. package/specs/ai-cli-bootstrap/QWEN.md +196 -0
  297. package/specs/ai-cli-bootstrap/design.md +185 -0
  298. package/specs/ai-cli-bootstrap/requirements.md +51 -0
  299. package/specs/ai-cli-bootstrap/tasks.md +70 -0
  300. package/specs/ai-cli-bootstrap/technical-docs.md +421 -0
  301. package/specs/cli-install-upgrade/design.md +207 -0
  302. package/specs/cli-install-upgrade/requirements.md +315 -0
  303. package/specs/cli-install-upgrade/tasks.md +120 -0
  304. package/specs/codebuddy-integration/design.md +152 -0
  305. package/specs/codebuddy-integration/requirements.md +85 -0
  306. package/specs/codebuddy-integration/tasks.md +159 -0
  307. package/specs/mcp-global-bin/design.md +57 -0
  308. package/specs/mcp-global-bin/requirements.md +43 -0
  309. package/specs/mcp-global-bin/tasks.md +54 -0
  310. package/specs/ssl-fix/design.md +93 -0
  311. package/specs/ssl-fix/requirements.md +47 -0
  312. package/specs/ssl-fix/tasks.md +65 -0
  313. package/specs/tcb-pull-cnb-support/design.md +137 -0
  314. package/specs/tcb-pull-cnb-support/requirements.md +56 -0
  315. package/specs/tcb-pull-cnb-support/tasks.md +101 -0
  316. package/specs/tcb-pull-mcp-integration/design.md +153 -0
  317. package/specs/tcb-pull-mcp-integration/implementation-summary.md +127 -0
  318. package/specs/tcb-pull-mcp-integration/requirements.md +68 -0
  319. package/specs/tcb-pull-mcp-integration/tasks.md +125 -0
  320. package/specs/template-pull-command/design.md +135 -0
  321. package/specs/template-pull-command/implementation-summary.md +160 -0
  322. package/specs/template-pull-command/requirements.md +73 -0
  323. package/specs/template-pull-command/tasks.md +101 -0
  324. package/templates/html/loginFail.html +90 -0
  325. package/templates/html/loginSuccess.html +86 -0
  326. package/templates/server/node/_gitignore +54 -0
  327. package/templates/server/node/cloudbaserc.json +10 -0
  328. package/templates/server/node/index.js +6 -0
  329. package/templates/server/node/package.json +9 -0
  330. package/test-mcp-integration.js +68 -0
  331. package/tsconfig.json +20 -0
  332. package/tsconfig.test.json +13 -0
  333. package/types/auth/index.d.ts +2 -0
  334. package/types/auth/login.d.ts +25 -0
  335. package/types/auth/logout.d.ts +1 -0
  336. package/types/commands/account/index.d.ts +2 -0
  337. package/types/commands/account/login.d.ts +15 -0
  338. package/types/commands/account/logout.d.ts +12 -0
  339. package/types/commands/ai/index.d.ts +23 -0
  340. package/types/commands/cloudfunction/base.d.ts +43 -0
  341. package/types/commands/cloudfunction/index.d.ts +1 -0
  342. package/types/commands/cloudrun/base.d.ts +160 -0
  343. package/types/commands/cloudrun/index.d.ts +1 -0
  344. package/types/commands/common.d.ts +38 -0
  345. package/types/commands/config/delete.d.ts +13 -0
  346. package/types/commands/config/get.d.ts +13 -0
  347. package/types/commands/config/index.d.ts +5 -0
  348. package/types/commands/config/interface.d.ts +17 -0
  349. package/types/commands/config/list.d.ts +13 -0
  350. package/types/commands/config/set.d.ts +13 -0
  351. package/types/commands/constants.d.ts +8 -0
  352. package/types/commands/db/base.d.ts +44 -0
  353. package/types/commands/db/index.d.ts +1 -0
  354. package/types/commands/env/base.d.ts +27 -0
  355. package/types/commands/env/domain.d.ts +53 -0
  356. package/types/commands/env/index.d.ts +3 -0
  357. package/types/commands/env/login.d.ts +47 -0
  358. package/types/commands/framework/index.d.ts +42 -0
  359. package/types/commands/fun/base.d.ts +43 -0
  360. package/types/commands/fun/index.d.ts +1 -0
  361. package/types/commands/functions/alias/getRoute.d.ts +13 -0
  362. package/types/commands/functions/alias/index.d.ts +2 -0
  363. package/types/commands/functions/alias/setRoute.d.ts +13 -0
  364. package/types/commands/functions/code-download.d.ts +18 -0
  365. package/types/commands/functions/code-update.d.ts +18 -0
  366. package/types/commands/functions/concurrency/delete.d.ts +13 -0
  367. package/types/commands/functions/concurrency/index.d.ts +3 -0
  368. package/types/commands/functions/concurrency/list.d.ts +13 -0
  369. package/types/commands/functions/concurrency/set.d.ts +13 -0
  370. package/types/commands/functions/config-update.d.ts +19 -0
  371. package/types/commands/functions/copy.d.ts +15 -0
  372. package/types/commands/functions/delete.d.ts +14 -0
  373. package/types/commands/functions/deploy.d.ts +22 -0
  374. package/types/commands/functions/detail.d.ts +16 -0
  375. package/types/commands/functions/index.d.ts +17 -0
  376. package/types/commands/functions/invoke.d.ts +15 -0
  377. package/types/commands/functions/layer/bind.d.ts +35 -0
  378. package/types/commands/functions/layer/common.d.ts +8 -0
  379. package/types/commands/functions/layer/create.d.ts +18 -0
  380. package/types/commands/functions/layer/delete.d.ts +18 -0
  381. package/types/commands/functions/layer/download.d.ts +18 -0
  382. package/types/commands/functions/layer/index.d.ts +7 -0
  383. package/types/commands/functions/layer/list.d.ts +19 -0
  384. package/types/commands/functions/layer/sort.d.ts +18 -0
  385. package/types/commands/functions/list.d.ts +14 -0
  386. package/types/commands/functions/log.d.ts +15 -0
  387. package/types/commands/functions/run.d.ts +17 -0
  388. package/types/commands/functions/trigger-create.d.ts +18 -0
  389. package/types/commands/functions/trigger-delete.d.ts +18 -0
  390. package/types/commands/functions/version/index.d.ts +2 -0
  391. package/types/commands/functions/version/list.d.ts +13 -0
  392. package/types/commands/functions/version/publish.d.ts +13 -0
  393. package/types/commands/gateway/create.d.ts +14 -0
  394. package/types/commands/gateway/delete.d.ts +14 -0
  395. package/types/commands/gateway/domain.d.ts +47 -0
  396. package/types/commands/gateway/index.d.ts +5 -0
  397. package/types/commands/gateway/list.d.ts +15 -0
  398. package/types/commands/gateway/switch.d.ts +31 -0
  399. package/types/commands/helpers/index.d.ts +3 -0
  400. package/types/commands/helpers/init.d.ts +22 -0
  401. package/types/commands/helpers/new.d.ts +17 -0
  402. package/types/commands/helpers/open.d.ts +11 -0
  403. package/types/commands/hosting/hosting.d.ts +66 -0
  404. package/types/commands/hosting/index.d.ts +1 -0
  405. package/types/commands/index.d.ts +22 -0
  406. package/types/commands/lowcode/app.d.ts +81 -0
  407. package/types/commands/lowcode/comps.d.ts +77 -0
  408. package/types/commands/lowcode/deps.d.ts +15 -0
  409. package/types/commands/lowcode/index.d.ts +3 -0
  410. package/types/commands/lowcode/utils.d.ts +23 -0
  411. package/types/commands/pull/index.d.ts +1 -0
  412. package/types/commands/pull/pull.d.ts +16 -0
  413. package/types/commands/run/delete.d.ts +13 -0
  414. package/types/commands/run/image/common.d.ts +8 -0
  415. package/types/commands/run/image/delete.d.ts +17 -0
  416. package/types/commands/run/image/download.d.ts +17 -0
  417. package/types/commands/run/image/index.d.ts +5 -0
  418. package/types/commands/run/image/list.d.ts +17 -0
  419. package/types/commands/run/image/upload.d.ts +17 -0
  420. package/types/commands/run/index.d.ts +5 -0
  421. package/types/commands/run/list.d.ts +13 -0
  422. package/types/commands/run/service/config.d.ts +14 -0
  423. package/types/commands/run/service/deploy.d.ts +13 -0
  424. package/types/commands/run/service/index.d.ts +4 -0
  425. package/types/commands/run/service/list.d.ts +13 -0
  426. package/types/commands/run/service/update.d.ts +13 -0
  427. package/types/commands/run/standalonegateway/common.d.ts +8 -0
  428. package/types/commands/run/standalonegateway/create.d.ts +17 -0
  429. package/types/commands/run/standalonegateway/destroy.d.ts +17 -0
  430. package/types/commands/run/standalonegateway/index.d.ts +5 -0
  431. package/types/commands/run/standalonegateway/list.d.ts +17 -0
  432. package/types/commands/run/standalonegateway/package.d.ts +17 -0
  433. package/types/commands/run/standalonegateway/turn.d.ts +17 -0
  434. package/types/commands/run/version/common.d.ts +8 -0
  435. package/types/commands/run/version/create.d.ts +17 -0
  436. package/types/commands/run/version/delete.d.ts +17 -0
  437. package/types/commands/run/version/index.d.ts +5 -0
  438. package/types/commands/run/version/list.d.ts +17 -0
  439. package/types/commands/run/version/modify.d.ts +17 -0
  440. package/types/commands/run/version/update.d.ts +17 -0
  441. package/types/commands/runf/base.d.ts +43 -0
  442. package/types/commands/runf/index.d.ts +1 -0
  443. package/types/commands/self-update.d.ts +24 -0
  444. package/types/commands/smart.d.ts +1 -0
  445. package/types/commands/storage/index.d.ts +1 -0
  446. package/types/commands/storage/storage.d.ts +106 -0
  447. package/types/commands/third/index.d.ts +1 -0
  448. package/types/commands/third/thirdAttach.d.ts +15 -0
  449. package/types/commands/utils.d.ts +28 -0
  450. package/types/completion/index.d.ts +4 -0
  451. package/types/constant.d.ts +71 -0
  452. package/types/db/index.d.ts +24 -0
  453. package/types/decorators/captureError.d.ts +1 -0
  454. package/types/decorators/constants.d.ts +11 -0
  455. package/types/decorators/deprecate.d.ts +4 -0
  456. package/types/decorators/guard.d.ts +5 -0
  457. package/types/decorators/index.d.ts +7 -0
  458. package/types/decorators/injectParams.d.ts +1 -0
  459. package/types/decorators/params/common.d.ts +4 -0
  460. package/types/decorators/params/index.d.ts +8 -0
  461. package/types/env/domain.d.ts +11 -0
  462. package/types/env/index.d.ts +12 -0
  463. package/types/env/login.d.ts +16 -0
  464. package/types/error.d.ts +20 -0
  465. package/types/function/alias.d.ts +3 -0
  466. package/types/function/base.d.ts +32 -0
  467. package/types/function/code.d.ts +8 -0
  468. package/types/function/concurrency.d.ts +4 -0
  469. package/types/function/create.d.ts +3 -0
  470. package/types/function/delete.d.ts +8 -0
  471. package/types/function/index.d.ts +11 -0
  472. package/types/function/layer/attach.d.ts +9 -0
  473. package/types/function/layer/create.d.ts +8 -0
  474. package/types/function/layer/delete.d.ts +5 -0
  475. package/types/function/layer/download.d.ts +7 -0
  476. package/types/function/layer/index.d.ts +7 -0
  477. package/types/function/layer/list.d.ts +10 -0
  478. package/types/function/layer/sort.d.ts +10 -0
  479. package/types/function/trigger.d.ts +5 -0
  480. package/types/function/update.d.ts +2 -0
  481. package/types/function/version.d.ts +3 -0
  482. package/types/function/vpc.d.ts +2 -0
  483. package/types/gateway/index.d.ts +18 -0
  484. package/types/help.d.ts +1 -0
  485. package/types/hosting.d.ts +35 -0
  486. package/types/i18n/index.d.ts +3 -0
  487. package/types/index.d.ts +4 -0
  488. package/types/logger.d.ts +3 -0
  489. package/types/run/delete.d.ts +2 -0
  490. package/types/run/image/build.d.ts +10 -0
  491. package/types/run/image/delete.d.ts +2 -0
  492. package/types/run/image/index.d.ts +4 -0
  493. package/types/run/image/info.d.ts +1 -0
  494. package/types/run/image/list.d.ts +3 -0
  495. package/types/run/index.d.ts +7 -0
  496. package/types/run/list.d.ts +2 -0
  497. package/types/run/repo.d.ts +5 -0
  498. package/types/run/service/common.d.ts +42 -0
  499. package/types/run/service/config.d.ts +23 -0
  500. package/types/run/service/deployPackage.d.ts +11 -0
  501. package/types/run/service/index.d.ts +6 -0
  502. package/types/run/service/list.d.ts +2 -0
  503. package/types/run/service/showLogs.d.ts +2 -0
  504. package/types/run/service/update.d.ts +3 -0
  505. package/types/run/standalonegateway/create.d.ts +2 -0
  506. package/types/run/standalonegateway/destroy.d.ts +2 -0
  507. package/types/run/standalonegateway/index.d.ts +5 -0
  508. package/types/run/standalonegateway/list.d.ts +2 -0
  509. package/types/run/standalonegateway/package/index.d.ts +1 -0
  510. package/types/run/standalonegateway/package/list.d.ts +2 -0
  511. package/types/run/standalonegateway/turn/index.d.ts +2 -0
  512. package/types/run/standalonegateway/turn/off.d.ts +2 -0
  513. package/types/run/standalonegateway/turn/on.d.ts +2 -0
  514. package/types/run/version/create.d.ts +10 -0
  515. package/types/run/version/delete.d.ts +2 -0
  516. package/types/run/version/index.d.ts +6 -0
  517. package/types/run/version/list.d.ts +2 -0
  518. package/types/run/version/modify.d.ts +2 -0
  519. package/types/run/version/repo.d.ts +10 -0
  520. package/types/run/version/update.d.ts +6 -0
  521. package/types/storage.d.ts +34 -0
  522. package/types/third/index.d.ts +1 -0
  523. package/types/types.d.ts +590 -0
  524. package/types/utils/ai/banner.d.ts +2 -0
  525. package/types/utils/ai/claudeWindows.d.ts +2 -0
  526. package/types/utils/ai/config.d.ts +89 -0
  527. package/types/utils/ai/const.d.ts +401 -0
  528. package/types/utils/ai/ensureFiles.d.ts +1 -0
  529. package/types/utils/ai/env.d.ts +2 -0
  530. package/types/utils/ai/envLocalManager.d.ts +23 -0
  531. package/types/utils/ai/nodeVersion.d.ts +2 -0
  532. package/types/utils/ai/router.d.ts +59 -0
  533. package/types/utils/ai/setup.d.ts +26 -0
  534. package/types/utils/auth.d.ts +3 -0
  535. package/types/utils/checkTcbrEnv.d.ts +3 -0
  536. package/types/utils/cli-table.d.ts +2 -0
  537. package/types/utils/commonParamsCheck.d.ts +3 -0
  538. package/types/utils/config.d.ts +27 -0
  539. package/types/utils/debug-logger.d.ts +1 -0
  540. package/types/utils/dts.d.ts +6 -0
  541. package/types/utils/env.d.ts +5 -0
  542. package/types/utils/fs/del.d.ts +1 -0
  543. package/types/utils/fs/index.d.ts +7 -0
  544. package/types/utils/function-packer.d.ts +18 -0
  545. package/types/utils/index.d.ts +22 -0
  546. package/types/utils/log.d.ts +22 -0
  547. package/types/utils/mcp-config-modifier.d.ts +7 -0
  548. package/types/utils/net/cloud-api-request.d.ts +9 -0
  549. package/types/utils/net/credential.d.ts +5 -0
  550. package/types/utils/net/http-request.d.ts +8 -0
  551. package/types/utils/net/index.d.ts +5 -0
  552. package/types/utils/net/manager-service.d.ts +4 -0
  553. package/types/utils/net/proxy.d.ts +1 -0
  554. package/types/utils/notice.d.ts +1 -0
  555. package/types/utils/output/highlight.d.ts +1 -0
  556. package/types/utils/output/index.d.ts +3 -0
  557. package/types/utils/output/link.d.ts +1 -0
  558. package/types/utils/output/loading.d.ts +18 -0
  559. package/types/utils/parallel.d.ts +11 -0
  560. package/types/utils/platform/index.d.ts +3 -0
  561. package/types/utils/platform/mac.d.ts +2 -0
  562. package/types/utils/platform/os.d.ts +2 -0
  563. package/types/utils/platform/port.d.ts +1 -0
  564. package/types/utils/progress-bar.d.ts +1 -0
  565. package/types/utils/prompt/index.d.ts +1 -0
  566. package/types/utils/prompt/select.d.ts +4 -0
  567. package/types/utils/report.d.ts +16 -0
  568. package/types/utils/reporter/agree.d.ts +1 -0
  569. package/types/utils/reporter/download.d.ts +1 -0
  570. package/types/utils/reporter/index.d.ts +3 -0
  571. package/types/utils/reporter/usage.d.ts +1 -0
  572. package/types/utils/store/auth.d.ts +8 -0
  573. package/types/utils/store/common.d.ts +2 -0
  574. package/types/utils/store/config.d.ts +8 -0
  575. package/types/utils/store/db.d.ts +17 -0
  576. package/types/utils/store/index.d.ts +5 -0
  577. package/types/utils/store/usage.d.ts +2 -0
  578. package/types/utils/tcbrApi/callTcbrApi.d.ts +1 -0
  579. package/types/utils/tcbrApi/index.d.ts +1 -0
  580. package/types/utils/template-manager.d.ts +27 -0
  581. package/types/utils/template.d.ts +8 -0
  582. package/types/utils/tools/common.d.ts +1 -0
  583. package/types/utils/tools/encoding.d.ts +1 -0
  584. package/types/utils/tools/index.d.ts +4 -0
  585. package/types/utils/tools/object.d.ts +1 -0
  586. package/types/utils/tools/time.d.ts +2 -0
  587. package/types/utils/tools/uid.d.ts +2 -0
  588. package/types/utils/url.d.ts +18 -0
  589. package/types/utils/validator.d.ts +9 -0
  590. package/bin/ccr +0 -2
  591. package/bin/cloudbase +0 -2
  592. package/bin/cloudbase-mcp +0 -2
  593. package/bin/tcb +0 -2
  594. package/dist/fonts/Slant.flf +0 -1295
  595. package/dist/standalone/ccr.js +0 -78668
  596. package/dist/standalone/cli.js +0 -627919
@@ -0,0 +1,315 @@
1
+ # 需求文档:CloudBase CLI 安装脚本升级(调研阶段)
2
+
3
+ ## 介绍
4
+ 为解决通过 npm 全局安装 `@cloudbase/cli` 安装慢、受 Node 版本影响、失败率偏高等问题,参考 Cursor CLI 的“预打包 + curl|bash 一键安装”方式,提供跨平台、高成功率、可原子升级与回滚的安装体验,并同时暴露 `cloudbase`、`tcb`、`cloudbase-mcp` 三个可执行入口。
5
+
6
+ ## 参考背景信息(原始输入摘录)
7
+ - 现状:`npm i -g @cloudbase/cli` 容易出现问题
8
+ - 安装速度缓慢、依赖 npm
9
+ - Node 版本可能过低导致失败
10
+ - 目标:提升安装成功率与速度
11
+ - 参考 Cursor CLI 的安装方式:`curl https://cursor.com/install -fsS | bash`
12
+ - 安装脚本示例(来自参考):
13
+
14
+ ```bash
15
+ #!/usr/bin/env bash
16
+
17
+ # Color definitions
18
+ CYAN='\033[0;36m'
19
+ GREEN='\033[0;32m'
20
+ YELLOW='\033[0;33m'
21
+ BLUE='\033[0;34m'
22
+ PURPLE='\033[0;35m'
23
+ RED='\033[0;31m'
24
+ BOLD='\033[1m'
25
+ DIM='\033[2m'
26
+ NC='\033[0m' # No Color
27
+
28
+ # Fancy header
29
+ echo ""
30
+ echo -e "${BOLD}Cursor Agent Installer${NC}"
31
+ echo ""
32
+
33
+ # Function to print steps with style
34
+ print_step() {
35
+ echo -e "${BLUE}▸${NC} ${1}"
36
+ }
37
+
38
+ # Function to print success
39
+ print_success() {
40
+ # Move cursor up one line and clear it
41
+ echo -ne "\033[1A\033[2K"
42
+ echo -e "${GREEN}✓${NC} ${1}"
43
+ }
44
+
45
+ # Function to print error
46
+ print_error() {
47
+ echo -e "${RED}✗${NC} ${1}"
48
+ }
49
+
50
+ # Detect OS and Architecture
51
+ print_step "Detecting system architecture..."
52
+
53
+ # Detect OS
54
+ OS="$(uname -s)"
55
+ case "${OS}" in
56
+ Linux*) OS="linux";;
57
+ Darwin*) OS="darwin";;
58
+ *)
59
+ print_error "Unsupported operating system: ${OS}"
60
+ exit 1
61
+ ;;
62
+ esac
63
+
64
+ # Detect Architecture
65
+ ARCH="$(uname -m)"
66
+ case "${ARCH}" in
67
+ x86_64|amd64) ARCH="x64";;
68
+ arm64|aarch64) ARCH="arm64";;
69
+ *)
70
+ print_error "Unsupported architecture: ${ARCH}"
71
+ exit 1
72
+ ;;
73
+ esac
74
+
75
+ print_success "Detected ${OS}/${ARCH}"
76
+
77
+ # Installation steps
78
+ print_step "Creating installation directory..."
79
+ # Create temporary directory for atomic download inside versions folder
80
+ TEMP_EXTRACT_DIR="$HOME/.local/share/cursor-agent/versions/.tmp-2025.08.09-d8191f3-$(date +%s)"
81
+ mkdir -p "${TEMP_EXTRACT_DIR}"
82
+
83
+ print_success "Directory created"
84
+
85
+
86
+ print_step "Downloading Cursor Agent package..."
87
+ DOWNLOAD_URL="https://downloads.cursor.com/lab/2025.08.09-d8191f3/${OS}/${ARCH}/agent-cli-package.tar.gz"
88
+ echo -e "${DIM} Download URL: ${DOWNLOAD_URL}${NC}"
89
+
90
+ # Cleanup function
91
+ cleanup() {
92
+ rm -rf "${TEMP_EXTRACT_DIR}"
93
+ }
94
+ trap cleanup EXIT
95
+
96
+ # Download with progress bar and better error handling
97
+ if curl -fSL --progress-bar "${DOWNLOAD_URL}" \
98
+ | tar --strip-components=1 -xzf - -C "${TEMP_EXTRACT_DIR}"; then
99
+ echo -ne "\033[1A\033[2K"
100
+ echo -ne "\033[1A\033[2K"
101
+ echo -ne "\033[1A\033[2K"
102
+ print_success "Package downloaded and extracted"
103
+ else
104
+ print_error "Download failed. Please check your internet connection and try again."
105
+ print_error "If the problem persists, the package might not be available for ${OS}/${ARCH}."
106
+ cleanup
107
+ exit 1
108
+ fi
109
+
110
+ print_step "Finalizing installation..."
111
+ # Atomically move from temp to final destination
112
+ FINAL_DIR="$HOME/.local/share/cursor-agent/versions/2025.08.09-d8191f3"
113
+ rm -rf "${FINAL_DIR}"
114
+ if mv "${TEMP_EXTRACT_DIR}" "${FINAL_DIR}"; then
115
+ print_success "Package installed successfully"
116
+ else
117
+ print_error "Failed to install package. Please check permissions."
118
+ cleanup
119
+ exit 1
120
+ fi
121
+
122
+
123
+ print_step "Creating bin directory..."
124
+ mkdir -p ~/.local/bin
125
+ print_success "Bin directory ready"
126
+
127
+
128
+ print_step "Creating symlink to cursor-agent executable..."
129
+ # Remove any existing symlink or file
130
+ rm -f ~/.local/bin/cursor-agent
131
+ # Create symlink to the cursor-agent executable
132
+ ln -s ~/.local/share/cursor-agent/versions/2025.08.09-d8191f3/cursor-agent ~/.local/bin/cursor-agent
133
+ print_success "Symlink created"
134
+
135
+ # Success message
136
+ echo ""
137
+ echo -e "${BOLD}${GREEN}✨ Installation Complete! ${NC}"
138
+ echo ""
139
+ echo ""
140
+
141
+ # Determine configured shells
142
+ CURRENT_SHELL="$(basename $SHELL)"
143
+ SHOW_BASH=false
144
+ SHOW_ZSH=false
145
+ SHOW_FISH=false
146
+
147
+ case "${CURRENT_SHELL}" in
148
+ bash) SHOW_BASH=true ;;
149
+ zsh) SHOW_ZSH=true ;;
150
+ fish) SHOW_FISH=true ;;
151
+ cesac
152
+
153
+ # Also consider presence of config files as configured
154
+ if [ -f "$HOME/.bashrc" ] || [ -f "$HOME/.bash_profile" ]; then SHOW_BASH=true; fi
155
+ if [ -f "$HOME/.zshrc" ]; then SHOW_ZSH=true; fi
156
+ if [ -f "$HOME/.config/fish/config.fish" ]; then SHOW_FISH=true; fi
157
+
158
+ # Next steps with style
159
+ echo -e "${BOLD}Next Steps${NC}"
160
+ echo ""
161
+ echo -e "${BOLD}1.${NC} Add ~/.local/bin to your PATH:"
162
+
163
+ if [ "${SHOW_BASH}" = true ]; then
164
+ echo -e " ${DIM}For bash:${NC}"
165
+ echo -e " ${BOLD}${BLUE}echo 'export PATH=\"$HOME/.local/bin:$PATH\"' >> ~/.bashrc${NC}"
166
+ echo -e " ${BOLD}${BLUE}source ~/.bashrc${NC}"
167
+ echo ""
168
+ fi
169
+
170
+ if [ "${SHOW_ZSH}" = true ]; then
171
+ echo -e " ${DIM}For zsh:${NC}"
172
+ echo -e " ${BOLD}${BLUE}echo 'export PATH=\"$HOME/.local/bin:$PATH\"' >> ~/.zshrc${NC}"
173
+ echo -e " ${BOLD}${BLUE}source ~/.zshrc${NC}"
174
+ echo ""
175
+ fi
176
+
177
+ if [ "${SHOW_FISH}" = true ]; then
178
+ echo -e " ${DIM}For fish:${NC}"
179
+ echo -e " ${BOLD}${BLUE}mkdir -p $HOME/.config/fish${NC}"
180
+ echo -e " ${BOLD}${BLUE}echo 'fish_add_path $HOME/.local/bin' >> $HOME/.config/fish/config.fish${NC}"
181
+ echo -e " ${BOLD}${BLUE}source $HOME/.config/fish/config.fish${NC}"
182
+ echo ""
183
+ fi
184
+
185
+ # Fallback if no known shells detected/configured
186
+ if [ "${SHOW_BASH}" != true ] && [ "${SHOW_ZSH}" != true ] && [ "${SHOW_FISH}" != true ]; then
187
+ echo -e " ${DIM}Add to PATH manually:${NC}"
188
+ echo -e " ${BOLD}${BLUE}export PATH=\"$HOME/.local/bin:$PATH\"${NC}"
189
+ echo ""
190
+ fi
191
+
192
+ echo -e "${BOLD}2.${NC} Start using Cursor Agent:"
193
+ echo -e " ${BOLD}cursor-agent${NC}"
194
+ echo ""
195
+ echo ""
196
+ echo -e "${BOLD}${CYAN}Happy coding! 🚀${NC}"
197
+ echo "%"
198
+ ```
199
+
200
+ - 示例包地址:`https://downloads.cursor.com/lab/2025.08.09-d8191f3/darwin/arm64/agent-cli-package.tar.gz`
201
+ - 示例包内容:
202
+
203
+ ```bash
204
+ /Users/bookerzhao/Downloads/dist-package
205
+ ├── build
206
+ | └── node_sqlite3.node
207
+ ├── cursor-agent
208
+ ├── index.js
209
+ ├── node
210
+ ├── package.json
211
+ └── rg
212
+
213
+ directory: 1 file: 6
214
+
215
+ ignored
216
+ ```
217
+
218
+ - 观察与结论:
219
+ - 包内置 `cursor-agent`、`node`(Node 22)、`index.js` 与必要原生依赖,安装无需系统 Node/npm。
220
+ - 价值:提升安装成功率与速度;bundle 后方便被 VS Code 扩展等调用。
221
+
222
+ - 方案参考要点(来自原始输入):
223
+ 1. CLI bundle 参考:`https://github.com/TencentCloudBase/CloudBase-AI-ToolKit/blob/main/mcp/webpack/cli.config.cjs`
224
+ 2. 内置并暴露多个 bin:`cloudbase`、`tcb`、`cloudbase-mcp`
225
+ 3. 与本地 npm 安装命令冲突的处理策略
226
+ 4. 升级策略(含自更新/回滚)
227
+ 5. 是否需要打包多个 tar 包的评估(按 OS/ARCH 拆分)
228
+
229
+ ## 需求(EARS)
230
+
231
+ ### 1. 一键安装脚本(更新:含原生 Windows)
232
+ - 用户故事:作为新用户,我希望通过一条命令完成安装,无需预装 Node 或 npm。
233
+ - 验收(EARS):
234
+ - While 在 macOS/Linux,when 执行 `curl -fsSL https://<domain>/install | bash`,the 安装器 shall 检测 OS/ARCH,创建 `~/.local/share/cloudbase-cli/versions/<version>`,解压包,维护 `current` 链接,创建到 `~/.local/bin` 的 `cloudbase`/`tcb`/`cloudbase-mcp` 符号链接,并输出 PATH 配置指引;无需 sudo。
235
+ - While 在原生 Windows(PowerShell 7+/5.1),when 执行 `irm https://<domain>/install.ps1 | iex`(或下载后执行),the 安装器 shall 检测架构,创建 `%LOCALAPPDATA%\\cloudbase-cli\\versions\\<version>`,解压 `.zip` 包,更新 `current.txt` 指向版本,生成 `%LOCALAPPDATA%\\cloudbase-cli\\bin\\{cloudbase,tcb,cloudbase-mcp}.cmd` 并提示将该 bin 目录加入 PATH。
236
+
237
+ ### 2. 预置运行时(内置 Node)
238
+ - 用户故事:我不希望因本地 Node 版本不满足而失败。
239
+ - 验收:When 运行任一入口,the 运行时 shall 使用随包分发的 Node(建议 Node 22 LTS),不依赖系统 Node。
240
+
241
+ ### 3. 多入口暴露与行为一致
242
+ - 用户故事:我需要继续使用 `cloudbase`、`tcb`,并使用 `cloudbase-mcp`。
243
+ - 验收:When 完成安装,the 系统 shall 暴露三命令,均可独立执行 `-v`、`-h`;其中 `cloudbase`/`tcb` 通过 `cli.js` 启动,`cloudbase-mcp` 通过包内 `mcp.js`(复制自 `@cloudbase/cloudbase-mcp/dist/cli.cjs`)启动,行为与 npm 安装一致。
244
+
245
+ ### 4. 包分发与结构(更新:含 Windows .zip 与安装器)
246
+ - 用户故事:作为发布者,我需要稳定分发与清晰目录,支持 CDN。
247
+ - 验收:When 发布 `<version>`,the 服务端 shall 提供 `{darwin,linux}/{x64,arm64}` 的 `.tar.gz{,.sha256}` 与 `{windows}/{x64,arm64}` 的 `.zip{,.sha256}`;包内含 `node`(或 `node.exe`)、`bin/*`、`cli.js`、`mcp.js`、`manifest.json`;线上采用版本化目录:
248
+ - `/<version>/{darwin,linux}/{x64,arm64}/cloudbase-cli-<version>.tar.gz{,.sha256}`
249
+ - `/<version>/windows/{x64,arm64}/cloudbase-cli-<version>.zip{,.sha256}`
250
+ - 根目录提供 `install/install.sh`(别名 `/install`)与 `install/install.ps1`(别名 `/install.ps1`)、`stable.txt`、`beta.txt`。
251
+
252
+ ### 5. 自更新与回滚(原子)
253
+ - 用户故事:我希望一键升级且可回滚。
254
+ - 验收:When 执行 `cloudbase self-update` 或重跑安装脚本,the 安装器 shall 下载至临时目录并原子切换 `versions/<version>` 与符号链接;至少保留 1 个上版本用于 `--rollback`;失败不影响当前可用版本。
255
+
256
+ ### 6. 与 npm 全局安装冲突处理
257
+ - 用户故事:历史用户可能已通过 npm 安装,避免冲突。
258
+ - 验收:When 检测到 PATH 中存在同名命令,the 安装器 shall 提示 PATH 优先级调整与检测命令;默认不覆盖,仅创建 `~/.local/bin` 链接并提示置前。
259
+
260
+ ### 7. 性能目标与网络备选
261
+ - 用户故事:在一般网络环境也能快速安装。
262
+ - 验收:While 中国大陆网络,when 下载同版本包,the P99 安装耗时 ≤ 20s(100Mbps,包体≤80MB)
263
+
264
+
265
+ ### 8. 安全与完整性
266
+ - 用户故事:我需要确认下载可信。
267
+ - 验收:When 执行安装,the 安装器 shall 强制 HTTPS、校验 `sha256`(或 `minisign`/COS 签名);脚本最小权限、无 sudo;提供卸载指令(删除 `~/.local/share/cloudbase-cli` 与链接)。
268
+
269
+ ### 9. 兼容性与范围(更新:含原生 Windows)
270
+ - 用户故事:我在常见桌面/服务器上可用。
271
+ - 验收:the 首版 shall 支持 macOS(darwin x64/arm64)与 Linux(glibc x64/arm64);原生 Windows(x64/arm64)通过 PowerShell 安装器与 `.zip` 产物完成安装;若在 Git Bash/MSYS/Cygwin 下执行 `install.sh`,安装器 shall 直接提示改用 WSL 或使用 PowerShell 安装器。
272
+
273
+ ### 11. Windows 原生安装器(新增)
274
+ - 用户故事:在不使用 WSL 的情况下,我希望用 PowerShell 一键安装/升级/回滚。
275
+ - 验收(EARS):
276
+ - When 执行 `irm https://<domain>/install.ps1 | iex`,the 安装器 shall:
277
+ 1) 解析 `CHANNEL`/`VERSION`/`DOWNLOAD_BASE`;
278
+ 2) 下载并校验 `.zip` 与 `.sha256`;
279
+ 3) 解压到 `%LOCALAPPDATA%\\cloudbase-cli\\versions\\<version>`(使用临时目录 + 原子移动);
280
+ 4) 写入/更新 `%LOCALAPPDATA%\\cloudbase-cli\\current.txt`;
281
+ 5) 生成或更新 `%LOCALAPPDATA%\\cloudbase-cli\\bin\\{cloudbase,tcb,cloudbase-mcp}.cmd`;
282
+ 6) 输出 PATH 提示与卸载说明。
283
+
284
+ ## CDN 上传清单与缓存策略(更新)
285
+ - 上传清单:
286
+ - `/<version>/{darwin,linux,windows}/{x64,arm64}/cloudbase-cli-<version>.tar.gz{,.sha256}`
287
+ - `/install/install.sh` 与别名 `/install`
288
+ - `/stable.txt`、`/beta.txt`
289
+ - 忽略:
290
+ - `/artifacts/**`、`/unpacked/**`(仅本地/CI 使用)
291
+ - 本地构建完成后通过清理脚本仅保留版本化目录与安装脚本(prune)
292
+ - 缓存策略建议:
293
+ - 版本化包与 `.sha256`:长缓存(immutable)
294
+ - 安装脚本 `/install`:中等缓存,可刷新
295
+ - `stable.txt`/`beta.txt`:短缓存(5~15 分钟)
296
+
297
+ ### 10. 观测与可运维
298
+ - 用户故事:发布者需要感知安装质量。
299
+ - 验收:When 安装完成或失败,the 安装器 shall 在用户允许前提下匿名上报版本、OS/ARCH、结果与耗时(默认关闭,明示开启)。
300
+
301
+ ## 非目标
302
+ - 不在首版自动修改 PATH(仅提示)。
303
+ - 不强制移除/覆盖 npm 全局安装。
304
+
305
+ ## 约束与依赖
306
+ - 分发域名与 CDN(建议 COS+CDN,国内外双域与回源)。
307
+ - Node 运行时版本:建议 Node 22 LTS;若含原生依赖需按 OS/ARCH 预编译。
308
+ - Bundle 方案:参考 CloudBase-AI-ToolKit `mcp/webpack/cli.config.cjs`;选择 `webpack` 单文件,以稳定优先;必要时随包内置额外二进制。
309
+
310
+ ## 开放问题(待确认)
311
+ 1. 分发域名与镜像策略(是否提供国内镜像域)。
312
+ 2. 运行时版本(Node 20 vs 22)与许可证合规说明。
313
+ 3. 包体上限与更新频率;是否拆分 runtime 层与 app 层以减少增量。
314
+ 4. `cloudbase-mcp` 的暴露方式:多入口单包 vs 独立启动脚本。
315
+ 5. 自更新渠道:稳定/beta 双通道与命令设计(如 `--channel beta`)。
@@ -0,0 +1,120 @@
1
+ # 实施计划(仅规划,不实施)
2
+
3
+ - [ ] 0. 基线与对齐
4
+ - 对齐分发域名与镜像策略(国内/海外域)
5
+ - 锁定 Node 运行时版本(建议 22)与许可证合规
6
+ - 版本与通道策略(stable/beta),版本保留数(默认 2)
7
+ - _需求: 约束/开放问题
8
+
9
+ - [x] 1. Bundle 架构落地(webpack 单文件)
10
+ - 建立 webpack 配置并产出 `dist/standalone/cli.js`
11
+ - 主 CLI 入口为 `cli.js`;`cloudbase-mcp` 通过复制 `@cloudbase/cloudbase-mcp/dist/cli.cjs` 为 `mcp.js`
12
+ - Ignore 可选/重型依赖(低码链路、dev server 等);externals 标记原生/可选模块
13
+ - _需求: 2,3
14
+
15
+ - [x] 2. 启动脚本与多入口
16
+ - 包内 `bin/cloudbase`、`bin/tcb`:`./node ./cli.js "$@"`;`bin/cloudbase-mcp`:`./node ./mcp.js "$@"`
17
+ - 启动器增强:支持从符号链接调用时解析真实路径
18
+ - _需求: 1,3
19
+
20
+ - [x] 3. 安装脚本(curl|bash)
21
+ - OS/ARCH 探测、目录与临时目录创建、下载、sha256 校验
22
+ - 解压(strip-components=1)、原子 `mv` 切换版本目录
23
+ - 维护 `current` 链接;`~/.local/bin/*` 指向 `current/bin/*`
24
+ - 创建 `~/.local/bin` 符号链接与 PATH 提示(不自动改)
25
+ - Windows 适配:Git Bash/MSYS/Cygwin 下提示改用 WSL 并退出;WSL 下按 Linux 流程
26
+ - _需求: 1,8,9
27
+
28
+ - [x] 4. 自更新与回滚
29
+ - `cloudbase self-update [--channel beta]`、`--rollback`
30
+ - manifest 查询、下载校验、原子切换、版本保留与清理
31
+ - _需求: 5
32
+
33
+ - [ ] 5. 与 npm 全局安装冲突处理
34
+ - 安装脚本:检测 `command -v`,提示 PATH 优先级与排查命令
35
+ - 运行时:`cloudbase doctor path`(可选)输出排查建议
36
+ - _需求: 6
37
+
38
+ - [x] 6. 分发与清单
39
+ - 目录规范:`/<version>/{darwin|linux}/{x64|arm64}/cloudbase-cli-<version>.tar.gz{,.sha256}`
40
+ - 生成 `manifest.json`(包内)与 `.sha256`;根目录提供 `install/install.sh`、`stable.txt`、`beta.txt`
41
+ - _需求: 4
42
+
43
+ - [x] 7. CI/CD 构建矩阵(本地脚本)
44
+ - 构建矩阵:darwin/linux/windows × x64/arm64(共六包)
45
+ - `build/scripts/fetch-node.sh` 拉取官方 Node(含 windows `.zip` 提取 `node.exe`);`build/scripts/build-all.sh` 一键清理+构建+打包+收尾清理
46
+ - 收尾清理:执行 `build/scripts/prune-out.sh`,仅保留 `out/<version>/**`、`out/install/install.sh`(及别名 `/install`)、`stable.txt`、`beta.txt`
47
+ - 产物上传 COS + CDN 刷新(CI 待接入)
48
+ - 冒烟脚本:安装 -> 运行 `cloudbase -v` / 静态校验 `cloudbase-mcp` 文件
49
+ - _需求: 4,7,10
50
+
51
+ - [ ] 8. 观测(可选,默认关闭)
52
+ - 安装脚本:尊重 `CLOUDBASE_CLI_REPORT=1` 开关,上报匿名指标
53
+ - 域名与接口对齐,文档披露与退出机制
54
+ - _需求: 10
55
+
56
+ - [ ] 9. 安全与合规
57
+ - 强制 HTTPS、sha256 校验、最小权限、不使用 sudo
58
+ - 第三方依赖许可证检查与 NOTICE
59
+ - _需求: 8
60
+
61
+ - [ ] 10. 卸载与文档
62
+ - 卸载脚本/指令:清理版本目录与符号链接
63
+ - 文档:README 安装/升级/回滚/卸载、WSL 提示(Git Bash 指向 WSL)
64
+ - _需求: 1,5,9
65
+
66
+ - [ ] 11. 测试计划
67
+ - 平台验证:macOS x64/arm64,Linux x64/arm64,WSL/Git Bash
68
+ - 网络与镜像:国内/海外、断网/重试、校验失败回滚
69
+ - 冲突与 PATH:同时存在 npm 全局安装的场景
70
+ - _需求: 1,6,7
71
+
72
+ - [ ] 12. 里程碑与发布
73
+ - 内测版本:beta 渠道与灰度用户
74
+ - 正式发布:稳定域名 + 文档更新 + 退场策略(npm 安装仍保留)
75
+ - _需求: 全局
76
+
77
+ ## 附录:CDN 上传清单与缓存策略(新增)
78
+ - 上传清单:
79
+ - `/<version>/{darwin,linux}/{x64,arm64}/cloudbase-cli-<version>.tar.gz{,.sha256}`
80
+ - `/install/install.sh`
81
+ - `/stable.txt`、`/beta.txt`
82
+ - 忽略:
83
+ - `/artifacts/**`、`/unpacked/**`
84
+ - 缓存建议:
85
+ - 版本化包与 `.sha256`:长缓存(immutable)
86
+ - `/install`:中等缓存;可设置别名至 `/install/install.sh`
87
+ - `stable.txt`/`beta.txt`:短缓存(5~15 分钟)
88
+
89
+ ## 新增:Windows 原生支持实施项
90
+
91
+ - [ ] W1. Windows `.zip` 产物
92
+ - 更新打包脚本,生成 `/<version>/windows/{x64,arm64}/cloudbase-cli-<version>.zip{,.sha256}`
93
+ - zip 内包含 `node.exe`、`cli.js`、`mcp.js`、`manifest.json`、`install.ps1`
94
+ - _需求: 4, 9, 11
95
+
96
+ - [ ] W2. CDN 清单与 prune 更新
97
+ - `prune-out.sh` 保留 Windows `.zip` 与 `.sha256`,并生成 `/install.ps1` 别名
98
+ - 文档与清单同步
99
+ - _需求: 4
100
+
101
+ - [ ] W3. `.cmd` 启动器
102
+ - 生成 `%LOCALAPPDATA%\\cloudbase-cli\\bin\\{cloudbase,tcb,cloudbase-mcp}.cmd`
103
+ - 内容:定位安装根目录,调用 `node.exe` 执行相应 `cli.js`/`mcp.js`,参数透传
104
+ - _需求: 3, 11
105
+
106
+ - [ ] W4. PowerShell 安装器 `install.ps1`
107
+ - 下载/校验 `.zip`,`Expand-Archive` 解压,原子切换到 `versions/<version>`
108
+ - 写入 `current.txt`,生成 `.cmd` 启动器,PATH 提示
109
+ - 支持 `CHANNEL`/`VERSION`/`DOWNLOAD_BASE` 参数
110
+ - _需求: 1, 5, 11
111
+
112
+ - [ ] W5. 自更新与回滚(Windows)
113
+ - `tcb self-update` 在 Windows 上可调用在线 `install.ps1`(或本地 `current/install.ps1`)
114
+ - `tcb rollback` 读取 `current.txt` 与 `versions` 列表回退
115
+ - _需求: 5, 11
116
+
117
+ - [ ] W6. 测试与验证
118
+ - PowerShell 5.1 / 7+、Windows 10/11、Server 2019/2022
119
+ - 签名与执行策略(`Set-ExecutionPolicy Bypass -Scope Process`)文档提示
120
+ - _需求: 10, 11
@@ -0,0 +1,152 @@
1
+ # 技术方案设计
2
+
3
+ ## 架构概述
4
+
5
+ 在 CloudBase CLI 的 ai 命令中集成 Codebuddy Code CLI,采用与现有 AI 工具(如 Claude、Qwen、Codex)相同的架构模式,通过命令路由器和配置管理器来实现统一的 AI 工具管理。
6
+
7
+ ## 技术架构
8
+
9
+ ```mermaid
10
+ graph TD
11
+ A[tcb ai -a codebuddy] --> B[AICommandRouter]
12
+ B --> C[executeCodebuddyAgent]
13
+ C --> D[AIConfigManager]
14
+ C --> E[CodebuddyExecutor]
15
+
16
+ D --> F[配置文件管理]
17
+ E --> G[命令执行]
18
+ E --> H[安装检查]
19
+
20
+ F --> I[~/.codebuddy/settings.json]
21
+ F --> J[项目级配置]
22
+
23
+ G --> K[codebuddy CLI]
24
+ H --> L[安装向导]
25
+ ```
26
+
27
+ ## 技术选型
28
+
29
+ ### 核心组件
30
+ - **AICommandRouter**: 现有的命令路由器,负责路由到不同的 AI 工具
31
+ - **CodebuddyConfigManager**: Codebuddy 配置管理器(复用现有的 AIConfigManager)
32
+ - **CodebuddyExecutor**: Codebuddy 命令执行器(集成到现有的 executeAgentWithConfig 方法中)
33
+
34
+ ### 配置管理
35
+ - **配置文件格式**: JSON
36
+ - **配置位置**:
37
+ - 用户级: `~/.codebuddy/settings.json`
38
+ - 项目级: `.codebuddy/settings.json`
39
+ - **配置验证**: 使用 Zod 进行配置验证
40
+ - **配置方式**: 主要通过环境变量和命令行参数,配置文件为辅
41
+
42
+ ### 命令执行
43
+ - **执行方式**: 子进程执行 `codebuddy` 命令
44
+ - **参数透传**: 通过 `--` 分隔符透传参数
45
+ - **环境变量**: 支持环境变量配置
46
+
47
+ ## 数据库/接口设计
48
+
49
+ ### 配置结构
50
+ ```typescript
51
+ interface CodebuddyConfig {
52
+ type: 'none' | 'custom';
53
+ apiKey?: string;
54
+ }
55
+
56
+ // Codebuddy Code CLI 配置特点:
57
+ // 1. 主要通过环境变量 CODEBUDDY_API_KEY 配置
58
+ // 2. 支持 OAuth 身份验证流程
59
+ // 3. MCP 服务器配置由 Codebuddy CLI 自己管理
60
+ // 4. 通过参数透传实现 MCP 命令管理
61
+ ```
62
+
63
+ ### 配置验证 Schema
64
+ ```typescript
65
+ const CodebuddyConfigSchema = z.discriminatedUnion('type', [
66
+ z.object({
67
+ type: z.literal('none')
68
+ }),
69
+ z.object({
70
+ type: z.literal('custom'),
71
+ apiKey: z.string().optional()
72
+ })
73
+ ])
74
+ ```
75
+
76
+ ## 实现策略
77
+
78
+ ### 1. 扩展现有架构
79
+ - 在 `src/utils/ai/const.ts` 中添加 Codebuddy 常量定义
80
+ - 在 `src/utils/ai/router.ts` 中添加 Codebuddy 路由逻辑
81
+ - 在 `src/utils/ai/config.ts` 中添加 Codebuddy 配置管理
82
+
83
+ ### 2. 命令执行流程
84
+ 1. 检查 Codebuddy CLI 是否已安装
85
+ 2. 验证配置有效性
86
+ 3. 解析透传参数
87
+ 4. 执行 Codebuddy 命令
88
+ 5. 处理执行结果
89
+
90
+ ### 3. 配置管理流程
91
+ 1. 检查配置文件是否存在
92
+ 2. 验证配置格式
93
+ 3. 提供配置向导
94
+ 4. 保存配置到指定位置
95
+
96
+ ### 4. MCP 服务器管理
97
+ - 通过参数透传实现 MCP 命令管理
98
+ - 支持三种配置作用域
99
+ - 配置文件自动合并
100
+
101
+ ## 测试策略
102
+
103
+ ### 单元测试
104
+ - 配置验证测试
105
+ - 命令解析测试
106
+ - 参数透传测试
107
+
108
+ ### 集成测试
109
+ - 完整命令执行流程测试
110
+ - 配置管理流程测试
111
+ - 错误处理测试
112
+
113
+ ### 端到端测试
114
+ - 用户场景测试
115
+ - 安装向导测试
116
+ - MCP 服务器管理测试
117
+
118
+ ## 安全性
119
+
120
+ ### 配置安全
121
+ - API 密钥加密存储
122
+ - 配置文件权限控制
123
+ - 敏感信息脱敏显示
124
+
125
+ ### 命令执行安全
126
+ - 参数验证和过滤
127
+ - 环境变量安全传递
128
+ - 子进程权限控制
129
+
130
+ ## 部署和发布
131
+
132
+ ### 开发阶段
133
+ 1. 实现核心功能
134
+ 2. 添加单元测试
135
+ 3. 集成测试验证
136
+
137
+ ### 发布阶段
138
+ 1. 更新文档
139
+ 2. 版本发布
140
+ 3. 用户反馈收集
141
+
142
+ ## 兼容性
143
+
144
+ ### 系统兼容性
145
+ - 支持 macOS、Linux、Windows
146
+ - Node.js 18+ 版本要求
147
+ - 与现有 AI 工具共存
148
+
149
+ ### 配置兼容性
150
+ - 向后兼容现有配置
151
+ - 支持配置迁移
152
+ - 配置文件格式统一
@@ -0,0 +1,85 @@
1
+ # 需求文档
2
+
3
+ ## 需求背景
4
+
5
+ ### 现状分析
6
+
7
+ 当前 CloudBase CLI 的 `ai` 命令主要集成了 Claude Code 和通义灵码等 AI 编程工具,但缺乏对 Codebuddy Code CLI 的支持。Codebuddy Code CLI 作为一个强大的自主编排编程智能体,具有以下优势:
8
+
9
+ 1. **自主编排能力**:能够根据开发任务自动选择合适的工具和策略
10
+ 2. **多语言支持**:支持多种编程语言和框架
11
+ 3. **上下文感知**:能够理解项目结构和代码上下文
12
+ 4. **MCP 协议支持**:通过 Model Context Protocol 连接外部工具和数据源
13
+
14
+ ### 问题描述
15
+
16
+ 1. **工具分散**:开发者需要分别安装和配置 CloudBase CLI 和 Codebuddy Code CLI,增加了使用复杂度
17
+ 2. **配置重复**:两个工具可能存在重复的配置项,如环境变量、认证信息等
18
+ 3. **工作流割裂**:在云开发场景中,开发者需要在不同工具间切换,影响开发效率
19
+ 4. **学习成本**:开发者需要学习两套不同的命令行接口和配置方式
20
+
21
+ ### 业务价值
22
+
23
+ 1. **提升开发效率**:统一的命令行入口,减少工具切换时间
24
+ 2. **降低使用门槛**:简化安装和配置流程,新用户更容易上手
25
+ 3. **增强云开发体验**:将 AI 编程能力深度集成到云开发工作流中
26
+ 4. **保持工具生态**:通过 MCP 协议,Codebuddy Code CLI 可以连接更多云开发相关的工具和服务
27
+
28
+ ### 目标用户
29
+
30
+ - **云开发开发者**:使用 CloudBase 进行应用开发的工程师
31
+ - **AI 编程用户**:希望通过 AI 辅助提升编程效率的开发者
32
+ - **DevOps 工程师**:需要自动化部署和运维的运维人员
33
+ - **全栈开发者**:同时进行前端、后端和云服务开发的工程师
34
+
35
+ ## 介绍
36
+
37
+ 在 CloudBase CLI 的 ai 命令中集成 Codebuddy Code CLI,为用户提供统一的 AI 开发工具入口。Codebuddy Code CLI 是一个面向开发者的自主编排的编程智能体,通过命令行界面为开发者提供强大的 AI 编程能力。
38
+
39
+ ## 需求
40
+
41
+ ### 需求 1 - Codebuddy Code CLI 基础集成
42
+
43
+ **用户故事:** 作为开发者,我希望在 CloudBase CLI 中能够直接启动和使用 Codebuddy Code CLI,这样我就不需要单独安装和配置 Codebuddy Code CLI。
44
+
45
+ #### 验收标准
46
+
47
+ 1. When 用户运行 `tcb ai -a codebuddy` 时,CloudBase CLI 应当启动 Codebuddy Code CLI 工具。
48
+ 2. When Codebuddy Code CLI 未安装时,系统应当提示用户安装并提供安装指导。
49
+ 3. When 用户运行 `tcb ai -a codebuddy --setup` 时,系统应当运行 Codebuddy Code CLI 的配置向导。
50
+ 4. When 用户运行 `tcb ai -a codebuddy --config` 时,系统应当显示当前的 Codebuddy Code CLI 配置信息。
51
+ 5. When 用户运行 `tcb ai -a codebuddy --reset` 时,系统应当重置 Codebuddy Code CLI 的配置。
52
+
53
+ ### 需求 2 - MCP 服务器管理功能
54
+
55
+ **用户故事:** 作为开发者,我希望能够在 CloudBase CLI 中管理 Codebuddy Code CLI 的 MCP 服务器,这样我就可以方便地连接外部工具和数据源。
56
+
57
+ #### 验收标准
58
+
59
+ 1. When 用户运行 `tcb ai -a codebuddy -- mcp add <server-name> --env <env-vars> -- <command>` 时,系统应当添加指定的 MCP 服务器。
60
+ 2. When 用户运行 `tcb ai -a codebuddy -- mcp list` 时,系统应当显示所有已配置的 MCP 服务器列表。
61
+ 3. When 用户运行 `tcb ai -a codebuddy -- mcp get <server-name>` 时,系统应当显示指定 MCP 服务器的详细信息。
62
+ 4. When 用户运行 `tcb ai -a codebuddy -- mcp remove <server-name>` 时,系统应当移除指定的 MCP 服务器。
63
+ 5. When 用户配置 MCP 服务器时,系统应当支持 Local、Project、User 三种配置作用域。
64
+
65
+ ### 需求 3 - 参数透传和命令执行
66
+
67
+ **用户故事:** 作为开发者,我希望能够将 CloudBase CLI 的参数透传给 Codebuddy Code CLI,这样我就可以使用 Codebuddy Code CLI 的所有功能。
68
+
69
+ #### 验收标准
70
+
71
+ 1. When 用户在 `tcb ai -a codebuddy` 后添加 `--` 和参数时,系统应当将这些参数透传给 Codebuddy Code CLI。
72
+ 2. When 用户使用 `tcb ai -a codebuddy -- -p "query"` 时,系统应当执行单次查询模式。
73
+ 3. When 用户使用 `tcb ai -a codebuddy -- -c` 时,系统应当继续最近的对话。
74
+ 4. When 用户使用 `tcb ai -a codebuddy -- -r "session-id" "query"` 时,系统应当恢复特定的会话。
75
+
76
+ ### 需求 4 - 配置管理和验证
77
+
78
+ **用户故事:** 作为开发者,我希望 CloudBase CLI 能够管理 Codebuddy Code CLI 的配置,并验证配置的有效性。
79
+
80
+ #### 验收标准
81
+
82
+ 1. When 用户首次使用 Codebuddy Code CLI 时,系统应当检查配置并引导用户完成配置。
83
+ 2. When 用户配置 Codebuddy Code CLI 时,系统应当验证配置的有效性。
84
+ 3. When 配置无效时,系统应当提供清晰的错误信息和修复建议。
85
+ 4. When 用户需要身份验证时,系统应当支持本地开发环境、远程开发环境和无交互环境的认证方式。