@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.
- package/.augment-guidelines +119 -0
- package/.claude/settings.local.json +6 -0
- package/.clinerules/cloudbase-rules.mdc +119 -0
- package/.cursor/rules/cloudbase-rules.mdc +119 -0
- package/.editorconfig +10 -0
- package/.eslintignore +8 -0
- package/.eslintrc +35 -0
- package/.mcp.json +11 -0
- package/.prettierignore +1 -0
- package/.prettierrc.js +29 -0
- package/.vscode/launch.json +26 -0
- package/.yarnrc.yml +1 -0
- package/CLAUDE.md +119 -0
- package/LICENSE +6 -0
- package/bin/ccr.js +3 -0
- package/bin/cloudbase.js +7 -0
- package/bin/tcb.js +339 -0
- package/changelog.md +6 -0
- package/cloudbaserc.json +13 -0
- package/jest.config.js +17 -0
- package/lib/auth/index.js +18 -0
- package/lib/auth/login.js +111 -0
- package/lib/auth/logout.js +20 -0
- package/lib/commands/account/index.js +18 -0
- package/lib/commands/account/login.js +269 -0
- package/lib/commands/account/logout.js +56 -0
- package/lib/commands/ai/index.js +200 -0
- package/lib/commands/cloudfunction/base.js +369 -0
- package/lib/commands/cloudfunction/index.js +17 -0
- package/lib/commands/cloudrun/base.js +1040 -0
- package/lib/commands/cloudrun/cloudrun-run-ui/index.html +193 -0
- package/lib/commands/cloudrun/index.js +17 -0
- package/lib/commands/common.js +225 -0
- package/lib/commands/config/delete.js +72 -0
- package/lib/commands/config/get.js +69 -0
- package/lib/commands/config/index.js +21 -0
- package/lib/commands/config/interface.js +25 -0
- package/lib/commands/config/list.js +72 -0
- package/lib/commands/config/set.js +89 -0
- package/lib/commands/constants.js +11 -0
- package/lib/commands/db/base.js +399 -0
- package/lib/commands/db/index.js +17 -0
- package/lib/commands/env/base.js +129 -0
- package/lib/commands/env/domain.js +222 -0
- package/lib/commands/env/index.js +19 -0
- package/lib/commands/env/login.js +271 -0
- package/lib/commands/framework/index.js +196 -0
- package/lib/commands/fun/base.js +434 -0
- package/lib/commands/fun/index.js +17 -0
- package/lib/commands/functions/alias/getRoute.js +99 -0
- package/lib/commands/functions/alias/index.js +18 -0
- package/lib/commands/functions/alias/setRoute.js +101 -0
- package/lib/commands/functions/code-download.js +123 -0
- package/lib/commands/functions/code-update.js +96 -0
- package/lib/commands/functions/concurrency/delete.js +71 -0
- package/lib/commands/functions/concurrency/index.js +19 -0
- package/lib/commands/functions/concurrency/list.js +82 -0
- package/lib/commands/functions/concurrency/set.js +73 -0
- package/lib/commands/functions/config-update.js +103 -0
- package/lib/commands/functions/copy.js +82 -0
- package/lib/commands/functions/delete.js +102 -0
- package/lib/commands/functions/deploy.js +331 -0
- package/lib/commands/functions/detail.js +166 -0
- package/lib/commands/functions/index.js +33 -0
- package/lib/commands/functions/invoke.js +140 -0
- package/lib/commands/functions/layer/bind.js +191 -0
- package/lib/commands/functions/layer/common.js +13 -0
- package/lib/commands/functions/layer/create.js +88 -0
- package/lib/commands/functions/layer/delete.js +92 -0
- package/lib/commands/functions/layer/download.js +112 -0
- package/lib/commands/functions/layer/index.js +23 -0
- package/lib/commands/functions/layer/list.js +105 -0
- package/lib/commands/functions/layer/sort.js +98 -0
- package/lib/commands/functions/list.js +92 -0
- package/lib/commands/functions/log.js +156 -0
- package/lib/commands/functions/run.js +245 -0
- package/lib/commands/functions/trigger-create.js +99 -0
- package/lib/commands/functions/trigger-delete.js +121 -0
- package/lib/commands/functions/version/index.js +18 -0
- package/lib/commands/functions/version/list.js +97 -0
- package/lib/commands/functions/version/publish.js +71 -0
- package/lib/commands/gateway/create.js +125 -0
- package/lib/commands/gateway/delete.js +111 -0
- package/lib/commands/gateway/domain.js +202 -0
- package/lib/commands/gateway/index.js +21 -0
- package/lib/commands/gateway/list.js +107 -0
- package/lib/commands/gateway/switch.js +144 -0
- package/lib/commands/helpers/index.js +19 -0
- package/lib/commands/helpers/init.js +395 -0
- package/lib/commands/helpers/new.js +130 -0
- package/lib/commands/helpers/open.js +90 -0
- package/lib/commands/hosting/hosting.js +378 -0
- package/lib/commands/hosting/index.js +17 -0
- package/lib/commands/index.js +38 -0
- package/lib/commands/lowcode/app.js +400 -0
- package/lib/commands/lowcode/comps.js +384 -0
- package/lib/commands/lowcode/deps.js +85 -0
- package/lib/commands/lowcode/index.js +19 -0
- package/lib/commands/lowcode/utils.js +308 -0
- package/lib/commands/pull/index.js +17 -0
- package/lib/commands/pull/pull.js +107 -0
- package/lib/commands/run/delete.js +102 -0
- package/lib/commands/run/image/common.js +13 -0
- package/lib/commands/run/image/delete.js +91 -0
- package/lib/commands/run/image/download.js +86 -0
- package/lib/commands/run/image/index.js +21 -0
- package/lib/commands/run/image/list.js +104 -0
- package/lib/commands/run/image/upload.js +114 -0
- package/lib/commands/run/index.js +21 -0
- package/lib/commands/run/list.js +104 -0
- package/lib/commands/run/service/config.js +113 -0
- package/lib/commands/run/service/deploy.js +155 -0
- package/lib/commands/run/service/index.js +20 -0
- package/lib/commands/run/service/list.js +116 -0
- package/lib/commands/run/service/update.js +141 -0
- package/lib/commands/run/standalonegateway/common.js +13 -0
- package/lib/commands/run/standalonegateway/create.js +106 -0
- package/lib/commands/run/standalonegateway/destroy.js +82 -0
- package/lib/commands/run/standalonegateway/index.js +21 -0
- package/lib/commands/run/standalonegateway/list.js +78 -0
- package/lib/commands/run/standalonegateway/package.js +87 -0
- package/lib/commands/run/standalonegateway/turn.js +87 -0
- package/lib/commands/run/version/common.js +13 -0
- package/lib/commands/run/version/create.js +329 -0
- package/lib/commands/run/version/delete.js +90 -0
- package/lib/commands/run/version/index.js +21 -0
- package/lib/commands/run/version/list.js +109 -0
- package/lib/commands/run/version/modify.js +142 -0
- package/lib/commands/run/version/update.js +353 -0
- package/lib/commands/runf/base.js +453 -0
- package/lib/commands/runf/index.js +17 -0
- package/lib/commands/self-update.js +134 -0
- package/lib/commands/smart.js +124 -0
- package/lib/commands/storage/index.js +17 -0
- package/lib/commands/storage/storage.js +515 -0
- package/lib/commands/third/index.js +17 -0
- package/lib/commands/third/thirdAttach.js +78 -0
- package/lib/commands/utils.js +197 -0
- package/lib/completion/index.js +15 -0
- package/lib/constant.js +142 -0
- package/lib/db/index.js +85 -0
- package/lib/decorators/captureError.js +30 -0
- package/lib/decorators/constants.js +15 -0
- package/lib/decorators/deprecate.js +18 -0
- package/lib/decorators/guard.js +35 -0
- package/lib/decorators/index.js +25 -0
- package/lib/decorators/injectParams.js +58 -0
- package/lib/decorators/params/common.js +16 -0
- package/lib/decorators/params/index.js +34 -0
- package/lib/env/domain.js +42 -0
- package/lib/env/index.js +80 -0
- package/lib/env/login.js +78 -0
- package/lib/error.js +17 -0
- package/lib/function/alias.js +54 -0
- package/lib/function/base.js +266 -0
- package/lib/function/code.js +28 -0
- package/lib/function/concurrency.js +70 -0
- package/lib/function/create.js +72 -0
- package/lib/function/delete.js +53 -0
- package/lib/function/index.js +27 -0
- package/lib/function/layer/attach.js +63 -0
- package/lib/function/layer/create.js +63 -0
- package/lib/function/layer/delete.js +24 -0
- package/lib/function/layer/download.js +37 -0
- package/lib/function/layer/index.js +23 -0
- package/lib/function/layer/list.js +36 -0
- package/lib/function/layer/sort.js +25 -0
- package/lib/function/trigger.js +106 -0
- package/lib/function/update.js +41 -0
- package/lib/function/version.js +52 -0
- package/lib/function/vpc.js +35 -0
- package/lib/gateway/index.js +136 -0
- package/lib/help.js +44 -0
- package/lib/hosting.js +244 -0
- package/lib/i18n/index.js +73 -0
- package/lib/index.js +13 -0
- package/lib/logger.js +19 -0
- package/lib/run/delete.js +22 -0
- package/lib/run/image/build.js +37 -0
- package/lib/run/image/delete.js +22 -0
- package/lib/run/image/index.js +20 -0
- package/lib/run/image/info.js +29 -0
- package/lib/run/image/list.js +30 -0
- package/lib/run/index.js +23 -0
- package/lib/run/list.js +39 -0
- package/lib/run/repo.js +31 -0
- package/lib/run/service/common.js +271 -0
- package/lib/run/service/config.js +70 -0
- package/lib/run/service/deployPackage.js +83 -0
- package/lib/run/service/index.js +22 -0
- package/lib/run/service/list.js +31 -0
- package/lib/run/service/showLogs.js +117 -0
- package/lib/run/service/update.js +84 -0
- package/lib/run/standalonegateway/create.js +32 -0
- package/lib/run/standalonegateway/destroy.js +28 -0
- package/lib/run/standalonegateway/index.js +21 -0
- package/lib/run/standalonegateway/list.js +48 -0
- package/lib/run/standalonegateway/package/index.js +17 -0
- package/lib/run/standalonegateway/package/list.js +32 -0
- package/lib/run/standalonegateway/turn/index.js +18 -0
- package/lib/run/standalonegateway/turn/off.js +28 -0
- package/lib/run/standalonegateway/turn/on.js +28 -0
- package/lib/run/version/create.js +50 -0
- package/lib/run/version/delete.js +23 -0
- package/lib/run/version/index.js +22 -0
- package/lib/run/version/list.js +24 -0
- package/lib/run/version/modify.js +24 -0
- package/lib/run/version/repo.js +33 -0
- package/lib/run/version/update.js +39 -0
- package/lib/storage.js +125 -0
- package/lib/third/index.js +25 -0
- package/lib/types.js +12 -0
- package/lib/utils/ai/banner.js +106 -0
- package/lib/utils/ai/claudeWindows.js +64 -0
- package/lib/utils/ai/config.js +290 -0
- package/lib/utils/ai/const.js +178 -0
- package/lib/utils/ai/ensureFiles.js +27 -0
- package/lib/utils/ai/env.js +37 -0
- package/lib/utils/ai/envLocalManager.js +145 -0
- package/lib/utils/ai/nodeVersion.js +19 -0
- package/lib/utils/ai/router.js +1315 -0
- package/lib/utils/ai/setup.js +705 -0
- package/lib/utils/auth.js +28 -0
- package/lib/utils/checkTcbrEnv.js +76 -0
- package/lib/utils/cli-table.js +19 -0
- package/lib/utils/commonParamsCheck.js +49 -0
- package/lib/utils/config.js +59 -0
- package/lib/utils/debug-logger.js +31 -0
- package/lib/utils/dts.js +154 -0
- package/lib/utils/env.js +222 -0
- package/lib/utils/fs/del.js +11 -0
- package/lib/utils/fs/index.js +94 -0
- package/lib/utils/function-packer.js +87 -0
- package/lib/utils/index.js +38 -0
- package/lib/utils/log.js +85 -0
- package/lib/utils/mcp-config-modifier.js +205 -0
- package/lib/utils/net/cloud-api-request.js +64 -0
- package/lib/utils/net/credential.js +61 -0
- package/lib/utils/net/http-request.js +108 -0
- package/lib/utils/net/index.js +21 -0
- package/lib/utils/net/manager-service.js +51 -0
- package/lib/utils/net/proxy.js +9 -0
- package/lib/utils/notice.js +37 -0
- package/lib/utils/output/highlight.js +11 -0
- package/lib/utils/output/index.js +19 -0
- package/lib/utils/output/link.js +16 -0
- package/lib/utils/output/loading.js +68 -0
- package/lib/utils/parallel.js +65 -0
- package/lib/utils/platform/index.js +19 -0
- package/lib/utils/platform/mac.js +37 -0
- package/lib/utils/platform/os.js +59 -0
- package/lib/utils/platform/port.js +26 -0
- package/lib/utils/progress-bar.js +44 -0
- package/lib/utils/prompt/index.js +17 -0
- package/lib/utils/prompt/select.js +54 -0
- package/lib/utils/report.js +78 -0
- package/lib/utils/reporter/agree.js +31 -0
- package/lib/utils/reporter/download.js +37 -0
- package/lib/utils/reporter/index.js +19 -0
- package/lib/utils/reporter/usage.js +32 -0
- package/lib/utils/store/auth.js +59 -0
- package/lib/utils/store/common.js +8 -0
- package/lib/utils/store/config.js +49 -0
- package/lib/utils/store/db.js +84 -0
- package/lib/utils/store/index.js +21 -0
- package/lib/utils/store/usage.js +9 -0
- package/lib/utils/tcbrApi/callTcbrApi.js +39 -0
- package/lib/utils/tcbrApi/index.js +17 -0
- package/lib/utils/template-manager.js +458 -0
- package/lib/utils/template.js +131 -0
- package/lib/utils/tools/common.js +74 -0
- package/lib/utils/tools/encoding.js +13 -0
- package/lib/utils/tools/index.js +20 -0
- package/lib/utils/tools/object.js +28 -0
- package/lib/utils/tools/time.js +49 -0
- package/lib/utils/tools/uid.js +25 -0
- package/lib/utils/url.js +19 -0
- package/lib/utils/validator.js +72 -0
- package/locales/README.md +160 -0
- package/locales/i18next-scanner.config.js +211 -0
- package/locales/index.js +5 -0
- package/locales/langs/en.json +1236 -0
- package/locales/langs/zh.json +1236 -0
- package/locales/mapping.json +1242 -0
- package/package.json +133 -16
- package/patches/@musistudio+claude-code-router+1.0.36.patch +40 -0
- package/post-install.js +63 -0
- package/rules/cloudbase-platform.mdc +44 -0
- package/rules/database.mdc +25 -0
- package/rules/miniprogram-development.mdc +61 -0
- package/rules/ui-design.mdc +24 -0
- package/rules/web-development.mdc +44 -0
- package/rules/workflows.mdc +30 -0
- package/runtime/nodejs/bootstrap.js +255 -0
- package/runtime/nodejs/runtime.js +183 -0
- package/specs/ai-cli-bootstrap/QWEN.md +196 -0
- package/specs/ai-cli-bootstrap/design.md +185 -0
- package/specs/ai-cli-bootstrap/requirements.md +51 -0
- package/specs/ai-cli-bootstrap/tasks.md +70 -0
- package/specs/ai-cli-bootstrap/technical-docs.md +421 -0
- package/specs/cli-install-upgrade/design.md +207 -0
- package/specs/cli-install-upgrade/requirements.md +315 -0
- package/specs/cli-install-upgrade/tasks.md +120 -0
- package/specs/codebuddy-integration/design.md +152 -0
- package/specs/codebuddy-integration/requirements.md +85 -0
- package/specs/codebuddy-integration/tasks.md +159 -0
- package/specs/mcp-global-bin/design.md +57 -0
- package/specs/mcp-global-bin/requirements.md +43 -0
- package/specs/mcp-global-bin/tasks.md +54 -0
- package/specs/ssl-fix/design.md +93 -0
- package/specs/ssl-fix/requirements.md +47 -0
- package/specs/ssl-fix/tasks.md +65 -0
- package/specs/tcb-pull-cnb-support/design.md +137 -0
- package/specs/tcb-pull-cnb-support/requirements.md +56 -0
- package/specs/tcb-pull-cnb-support/tasks.md +101 -0
- package/specs/tcb-pull-mcp-integration/design.md +153 -0
- package/specs/tcb-pull-mcp-integration/implementation-summary.md +127 -0
- package/specs/tcb-pull-mcp-integration/requirements.md +68 -0
- package/specs/tcb-pull-mcp-integration/tasks.md +125 -0
- package/specs/template-pull-command/design.md +135 -0
- package/specs/template-pull-command/implementation-summary.md +160 -0
- package/specs/template-pull-command/requirements.md +73 -0
- package/specs/template-pull-command/tasks.md +101 -0
- package/templates/html/loginFail.html +90 -0
- package/templates/html/loginSuccess.html +86 -0
- package/templates/server/node/_gitignore +54 -0
- package/templates/server/node/cloudbaserc.json +10 -0
- package/templates/server/node/index.js +6 -0
- package/templates/server/node/package.json +9 -0
- package/test-mcp-integration.js +68 -0
- package/tsconfig.json +20 -0
- package/tsconfig.test.json +13 -0
- package/types/auth/index.d.ts +2 -0
- package/types/auth/login.d.ts +25 -0
- package/types/auth/logout.d.ts +1 -0
- package/types/commands/account/index.d.ts +2 -0
- package/types/commands/account/login.d.ts +15 -0
- package/types/commands/account/logout.d.ts +12 -0
- package/types/commands/ai/index.d.ts +23 -0
- package/types/commands/cloudfunction/base.d.ts +43 -0
- package/types/commands/cloudfunction/index.d.ts +1 -0
- package/types/commands/cloudrun/base.d.ts +160 -0
- package/types/commands/cloudrun/index.d.ts +1 -0
- package/types/commands/common.d.ts +38 -0
- package/types/commands/config/delete.d.ts +13 -0
- package/types/commands/config/get.d.ts +13 -0
- package/types/commands/config/index.d.ts +5 -0
- package/types/commands/config/interface.d.ts +17 -0
- package/types/commands/config/list.d.ts +13 -0
- package/types/commands/config/set.d.ts +13 -0
- package/types/commands/constants.d.ts +8 -0
- package/types/commands/db/base.d.ts +44 -0
- package/types/commands/db/index.d.ts +1 -0
- package/types/commands/env/base.d.ts +27 -0
- package/types/commands/env/domain.d.ts +53 -0
- package/types/commands/env/index.d.ts +3 -0
- package/types/commands/env/login.d.ts +47 -0
- package/types/commands/framework/index.d.ts +42 -0
- package/types/commands/fun/base.d.ts +43 -0
- package/types/commands/fun/index.d.ts +1 -0
- package/types/commands/functions/alias/getRoute.d.ts +13 -0
- package/types/commands/functions/alias/index.d.ts +2 -0
- package/types/commands/functions/alias/setRoute.d.ts +13 -0
- package/types/commands/functions/code-download.d.ts +18 -0
- package/types/commands/functions/code-update.d.ts +18 -0
- package/types/commands/functions/concurrency/delete.d.ts +13 -0
- package/types/commands/functions/concurrency/index.d.ts +3 -0
- package/types/commands/functions/concurrency/list.d.ts +13 -0
- package/types/commands/functions/concurrency/set.d.ts +13 -0
- package/types/commands/functions/config-update.d.ts +19 -0
- package/types/commands/functions/copy.d.ts +15 -0
- package/types/commands/functions/delete.d.ts +14 -0
- package/types/commands/functions/deploy.d.ts +22 -0
- package/types/commands/functions/detail.d.ts +16 -0
- package/types/commands/functions/index.d.ts +17 -0
- package/types/commands/functions/invoke.d.ts +15 -0
- package/types/commands/functions/layer/bind.d.ts +35 -0
- package/types/commands/functions/layer/common.d.ts +8 -0
- package/types/commands/functions/layer/create.d.ts +18 -0
- package/types/commands/functions/layer/delete.d.ts +18 -0
- package/types/commands/functions/layer/download.d.ts +18 -0
- package/types/commands/functions/layer/index.d.ts +7 -0
- package/types/commands/functions/layer/list.d.ts +19 -0
- package/types/commands/functions/layer/sort.d.ts +18 -0
- package/types/commands/functions/list.d.ts +14 -0
- package/types/commands/functions/log.d.ts +15 -0
- package/types/commands/functions/run.d.ts +17 -0
- package/types/commands/functions/trigger-create.d.ts +18 -0
- package/types/commands/functions/trigger-delete.d.ts +18 -0
- package/types/commands/functions/version/index.d.ts +2 -0
- package/types/commands/functions/version/list.d.ts +13 -0
- package/types/commands/functions/version/publish.d.ts +13 -0
- package/types/commands/gateway/create.d.ts +14 -0
- package/types/commands/gateway/delete.d.ts +14 -0
- package/types/commands/gateway/domain.d.ts +47 -0
- package/types/commands/gateway/index.d.ts +5 -0
- package/types/commands/gateway/list.d.ts +15 -0
- package/types/commands/gateway/switch.d.ts +31 -0
- package/types/commands/helpers/index.d.ts +3 -0
- package/types/commands/helpers/init.d.ts +22 -0
- package/types/commands/helpers/new.d.ts +17 -0
- package/types/commands/helpers/open.d.ts +11 -0
- package/types/commands/hosting/hosting.d.ts +66 -0
- package/types/commands/hosting/index.d.ts +1 -0
- package/types/commands/index.d.ts +22 -0
- package/types/commands/lowcode/app.d.ts +81 -0
- package/types/commands/lowcode/comps.d.ts +77 -0
- package/types/commands/lowcode/deps.d.ts +15 -0
- package/types/commands/lowcode/index.d.ts +3 -0
- package/types/commands/lowcode/utils.d.ts +23 -0
- package/types/commands/pull/index.d.ts +1 -0
- package/types/commands/pull/pull.d.ts +16 -0
- package/types/commands/run/delete.d.ts +13 -0
- package/types/commands/run/image/common.d.ts +8 -0
- package/types/commands/run/image/delete.d.ts +17 -0
- package/types/commands/run/image/download.d.ts +17 -0
- package/types/commands/run/image/index.d.ts +5 -0
- package/types/commands/run/image/list.d.ts +17 -0
- package/types/commands/run/image/upload.d.ts +17 -0
- package/types/commands/run/index.d.ts +5 -0
- package/types/commands/run/list.d.ts +13 -0
- package/types/commands/run/service/config.d.ts +14 -0
- package/types/commands/run/service/deploy.d.ts +13 -0
- package/types/commands/run/service/index.d.ts +4 -0
- package/types/commands/run/service/list.d.ts +13 -0
- package/types/commands/run/service/update.d.ts +13 -0
- package/types/commands/run/standalonegateway/common.d.ts +8 -0
- package/types/commands/run/standalonegateway/create.d.ts +17 -0
- package/types/commands/run/standalonegateway/destroy.d.ts +17 -0
- package/types/commands/run/standalonegateway/index.d.ts +5 -0
- package/types/commands/run/standalonegateway/list.d.ts +17 -0
- package/types/commands/run/standalonegateway/package.d.ts +17 -0
- package/types/commands/run/standalonegateway/turn.d.ts +17 -0
- package/types/commands/run/version/common.d.ts +8 -0
- package/types/commands/run/version/create.d.ts +17 -0
- package/types/commands/run/version/delete.d.ts +17 -0
- package/types/commands/run/version/index.d.ts +5 -0
- package/types/commands/run/version/list.d.ts +17 -0
- package/types/commands/run/version/modify.d.ts +17 -0
- package/types/commands/run/version/update.d.ts +17 -0
- package/types/commands/runf/base.d.ts +43 -0
- package/types/commands/runf/index.d.ts +1 -0
- package/types/commands/self-update.d.ts +24 -0
- package/types/commands/smart.d.ts +1 -0
- package/types/commands/storage/index.d.ts +1 -0
- package/types/commands/storage/storage.d.ts +106 -0
- package/types/commands/third/index.d.ts +1 -0
- package/types/commands/third/thirdAttach.d.ts +15 -0
- package/types/commands/utils.d.ts +28 -0
- package/types/completion/index.d.ts +4 -0
- package/types/constant.d.ts +71 -0
- package/types/db/index.d.ts +24 -0
- package/types/decorators/captureError.d.ts +1 -0
- package/types/decorators/constants.d.ts +11 -0
- package/types/decorators/deprecate.d.ts +4 -0
- package/types/decorators/guard.d.ts +5 -0
- package/types/decorators/index.d.ts +7 -0
- package/types/decorators/injectParams.d.ts +1 -0
- package/types/decorators/params/common.d.ts +4 -0
- package/types/decorators/params/index.d.ts +8 -0
- package/types/env/domain.d.ts +11 -0
- package/types/env/index.d.ts +12 -0
- package/types/env/login.d.ts +16 -0
- package/types/error.d.ts +20 -0
- package/types/function/alias.d.ts +3 -0
- package/types/function/base.d.ts +32 -0
- package/types/function/code.d.ts +8 -0
- package/types/function/concurrency.d.ts +4 -0
- package/types/function/create.d.ts +3 -0
- package/types/function/delete.d.ts +8 -0
- package/types/function/index.d.ts +11 -0
- package/types/function/layer/attach.d.ts +9 -0
- package/types/function/layer/create.d.ts +8 -0
- package/types/function/layer/delete.d.ts +5 -0
- package/types/function/layer/download.d.ts +7 -0
- package/types/function/layer/index.d.ts +7 -0
- package/types/function/layer/list.d.ts +10 -0
- package/types/function/layer/sort.d.ts +10 -0
- package/types/function/trigger.d.ts +5 -0
- package/types/function/update.d.ts +2 -0
- package/types/function/version.d.ts +3 -0
- package/types/function/vpc.d.ts +2 -0
- package/types/gateway/index.d.ts +18 -0
- package/types/help.d.ts +1 -0
- package/types/hosting.d.ts +35 -0
- package/types/i18n/index.d.ts +3 -0
- package/types/index.d.ts +4 -0
- package/types/logger.d.ts +3 -0
- package/types/run/delete.d.ts +2 -0
- package/types/run/image/build.d.ts +10 -0
- package/types/run/image/delete.d.ts +2 -0
- package/types/run/image/index.d.ts +4 -0
- package/types/run/image/info.d.ts +1 -0
- package/types/run/image/list.d.ts +3 -0
- package/types/run/index.d.ts +7 -0
- package/types/run/list.d.ts +2 -0
- package/types/run/repo.d.ts +5 -0
- package/types/run/service/common.d.ts +42 -0
- package/types/run/service/config.d.ts +23 -0
- package/types/run/service/deployPackage.d.ts +11 -0
- package/types/run/service/index.d.ts +6 -0
- package/types/run/service/list.d.ts +2 -0
- package/types/run/service/showLogs.d.ts +2 -0
- package/types/run/service/update.d.ts +3 -0
- package/types/run/standalonegateway/create.d.ts +2 -0
- package/types/run/standalonegateway/destroy.d.ts +2 -0
- package/types/run/standalonegateway/index.d.ts +5 -0
- package/types/run/standalonegateway/list.d.ts +2 -0
- package/types/run/standalonegateway/package/index.d.ts +1 -0
- package/types/run/standalonegateway/package/list.d.ts +2 -0
- package/types/run/standalonegateway/turn/index.d.ts +2 -0
- package/types/run/standalonegateway/turn/off.d.ts +2 -0
- package/types/run/standalonegateway/turn/on.d.ts +2 -0
- package/types/run/version/create.d.ts +10 -0
- package/types/run/version/delete.d.ts +2 -0
- package/types/run/version/index.d.ts +6 -0
- package/types/run/version/list.d.ts +2 -0
- package/types/run/version/modify.d.ts +2 -0
- package/types/run/version/repo.d.ts +10 -0
- package/types/run/version/update.d.ts +6 -0
- package/types/storage.d.ts +34 -0
- package/types/third/index.d.ts +1 -0
- package/types/types.d.ts +590 -0
- package/types/utils/ai/banner.d.ts +2 -0
- package/types/utils/ai/claudeWindows.d.ts +2 -0
- package/types/utils/ai/config.d.ts +89 -0
- package/types/utils/ai/const.d.ts +401 -0
- package/types/utils/ai/ensureFiles.d.ts +1 -0
- package/types/utils/ai/env.d.ts +2 -0
- package/types/utils/ai/envLocalManager.d.ts +23 -0
- package/types/utils/ai/nodeVersion.d.ts +2 -0
- package/types/utils/ai/router.d.ts +59 -0
- package/types/utils/ai/setup.d.ts +26 -0
- package/types/utils/auth.d.ts +3 -0
- package/types/utils/checkTcbrEnv.d.ts +3 -0
- package/types/utils/cli-table.d.ts +2 -0
- package/types/utils/commonParamsCheck.d.ts +3 -0
- package/types/utils/config.d.ts +27 -0
- package/types/utils/debug-logger.d.ts +1 -0
- package/types/utils/dts.d.ts +6 -0
- package/types/utils/env.d.ts +5 -0
- package/types/utils/fs/del.d.ts +1 -0
- package/types/utils/fs/index.d.ts +7 -0
- package/types/utils/function-packer.d.ts +18 -0
- package/types/utils/index.d.ts +22 -0
- package/types/utils/log.d.ts +22 -0
- package/types/utils/mcp-config-modifier.d.ts +7 -0
- package/types/utils/net/cloud-api-request.d.ts +9 -0
- package/types/utils/net/credential.d.ts +5 -0
- package/types/utils/net/http-request.d.ts +8 -0
- package/types/utils/net/index.d.ts +5 -0
- package/types/utils/net/manager-service.d.ts +4 -0
- package/types/utils/net/proxy.d.ts +1 -0
- package/types/utils/notice.d.ts +1 -0
- package/types/utils/output/highlight.d.ts +1 -0
- package/types/utils/output/index.d.ts +3 -0
- package/types/utils/output/link.d.ts +1 -0
- package/types/utils/output/loading.d.ts +18 -0
- package/types/utils/parallel.d.ts +11 -0
- package/types/utils/platform/index.d.ts +3 -0
- package/types/utils/platform/mac.d.ts +2 -0
- package/types/utils/platform/os.d.ts +2 -0
- package/types/utils/platform/port.d.ts +1 -0
- package/types/utils/progress-bar.d.ts +1 -0
- package/types/utils/prompt/index.d.ts +1 -0
- package/types/utils/prompt/select.d.ts +4 -0
- package/types/utils/report.d.ts +16 -0
- package/types/utils/reporter/agree.d.ts +1 -0
- package/types/utils/reporter/download.d.ts +1 -0
- package/types/utils/reporter/index.d.ts +3 -0
- package/types/utils/reporter/usage.d.ts +1 -0
- package/types/utils/store/auth.d.ts +8 -0
- package/types/utils/store/common.d.ts +2 -0
- package/types/utils/store/config.d.ts +8 -0
- package/types/utils/store/db.d.ts +17 -0
- package/types/utils/store/index.d.ts +5 -0
- package/types/utils/store/usage.d.ts +2 -0
- package/types/utils/tcbrApi/callTcbrApi.d.ts +1 -0
- package/types/utils/tcbrApi/index.d.ts +1 -0
- package/types/utils/template-manager.d.ts +27 -0
- package/types/utils/template.d.ts +8 -0
- package/types/utils/tools/common.d.ts +1 -0
- package/types/utils/tools/encoding.d.ts +1 -0
- package/types/utils/tools/index.d.ts +4 -0
- package/types/utils/tools/object.d.ts +1 -0
- package/types/utils/tools/time.d.ts +2 -0
- package/types/utils/tools/uid.d.ts +2 -0
- package/types/utils/url.d.ts +18 -0
- package/types/utils/validator.d.ts +9 -0
- package/bin/ccr +0 -2
- package/bin/cloudbase +0 -2
- package/bin/cloudbase-mcp +0 -2
- package/bin/tcb +0 -2
- package/dist/fonts/Slant.flf +0 -1295
- package/dist/standalone/ccr.js +0 -78668
- package/dist/standalone/cli.js +0 -627919
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
# AI 开发套件
|
|
2
|
+
|
|
3
|
+
AI 开发套件是云开发为用户提供的 AI 辅助开发能力,用户可以通过云开发提供的 CLI 工具快速启动和配置主流 AI 编程工具,如 Claude Code、OpenAI Codex、Gemini CLI 等。AI 开发套件内置云开发全栈能力,支持生成、部署和托管全栈 Web 应用与小程序、数据库和后端服务。
|
|
4
|
+
|
|
5
|
+
## 命令总览
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
tcb ai [options] -- [agent-args]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 路径说明
|
|
12
|
+
|
|
13
|
+
* `options` 为 AI 开发套件的配置选项,如 `-a claude`、`-e my-env` 等。
|
|
14
|
+
* `agent-args` 为目标 AI CLI 工具的原生参数,通过 `--` 分隔符透传。
|
|
15
|
+
|
|
16
|
+
⚠️ 注意事项
|
|
17
|
+
|
|
18
|
+
* `--` 分隔符后的所有参数将原样传递给目标 AI CLI 工具,请确保参数格式正确。
|
|
19
|
+
* 首次使用需要运行 `tcb ai --setup` 进行配置。
|
|
20
|
+
* 确保已安装目标 AI CLI 工具,如 Claude Code、OpenAI CLI 等。
|
|
21
|
+
|
|
22
|
+
## 快速开始
|
|
23
|
+
|
|
24
|
+
### 1. 配置 AI 开发套件
|
|
25
|
+
|
|
26
|
+
首次使用需要配置 AI 开发套件:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# 启动配置向导
|
|
30
|
+
tcb ai --setup
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
配置向导将引导您:
|
|
34
|
+
- 选择默认的 AI 工具(Claude Code、OpenAI Codex、Gemini CLI)
|
|
35
|
+
- 配置 API 密钥和基础 URL
|
|
36
|
+
- 设置云开发环境 ID
|
|
37
|
+
- 选择模型和协议类型
|
|
38
|
+
|
|
39
|
+
### 2. 启动 AI 工具
|
|
40
|
+
|
|
41
|
+
配置完成后,可以直接启动 AI 工具:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# 使用默认配置启动 Claude Code
|
|
45
|
+
tcb ai -a claude -- --continue
|
|
46
|
+
|
|
47
|
+
# 指定环境 ID 启动
|
|
48
|
+
tcb ai -a claude -e my-env -- --model=claude-3.5-sonnet
|
|
49
|
+
|
|
50
|
+
# 查看帮助信息
|
|
51
|
+
tcb ai -a claude -- --help
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 核心功能
|
|
55
|
+
|
|
56
|
+
### 启动 AI 工具
|
|
57
|
+
|
|
58
|
+
您可以使用下面的命令启动配置好的 AI 工具:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
tcb ai -a <agent> [options] -- [agent-args]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**参数说明:**
|
|
65
|
+
- `-a, --agent <name>`: 指定 AI 工具名称(claude/codex/gemini)
|
|
66
|
+
- `-e, --envId <id>`: 指定云开发环境 ID
|
|
67
|
+
- `--`: 参数分隔符,后面的参数将透传给 AI 工具
|
|
68
|
+
|
|
69
|
+
**使用示例:**
|
|
70
|
+
```bash
|
|
71
|
+
# 启动 Claude Code 并继续上次会话
|
|
72
|
+
tcb ai -a claude -- --continue
|
|
73
|
+
|
|
74
|
+
# 启动 OpenAI Codex 并指定模型
|
|
75
|
+
tcb ai -a codex -- --model=gpt-4
|
|
76
|
+
|
|
77
|
+
# 启动 Gemini CLI 并设置最大 token
|
|
78
|
+
tcb ai -a gemini -- --max-tokens=4096
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 配置管理
|
|
82
|
+
|
|
83
|
+
#### 查看当前配置
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
tcb ai --config
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
显示当前配置信息,包括:
|
|
90
|
+
- 默认 AI 工具
|
|
91
|
+
- API 密钥状态
|
|
92
|
+
- 环境 ID 配置
|
|
93
|
+
- 模型和协议设置
|
|
94
|
+
|
|
95
|
+
#### 重置配置
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
tcb ai --reset
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
清除所有配置信息,恢复到初始状态。
|
|
102
|
+
|
|
103
|
+
#### 交互式配置
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
tcb ai --setup
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
启动交互式配置向导,引导您完成:
|
|
110
|
+
- AI 工具选择和配置
|
|
111
|
+
- API 密钥设置
|
|
112
|
+
- 云开发环境绑定
|
|
113
|
+
- 协议和模型选择
|
|
114
|
+
|
|
115
|
+
## 支持的 AI 工具
|
|
116
|
+
|
|
117
|
+
### Claude Code
|
|
118
|
+
|
|
119
|
+
Claude Code 是 Anthropic 推出的 AI 编程助手,支持自然语言编程和代码生成。
|
|
120
|
+
|
|
121
|
+
**安装命令:**
|
|
122
|
+
```bash
|
|
123
|
+
npm install -g @anthropic-ai/claude-code
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**配置要求:**
|
|
127
|
+
- API 密钥:`ANTHROPIC_API_KEY`
|
|
128
|
+
- 基础 URL:`https://api.anthropic.com`
|
|
129
|
+
- 支持模型:claude-3.5-sonnet, claude-3-opus 等
|
|
130
|
+
|
|
131
|
+
**使用示例:**
|
|
132
|
+
```bash
|
|
133
|
+
# 启动 Claude Code
|
|
134
|
+
tcb ai -a claude -- --continue
|
|
135
|
+
|
|
136
|
+
# 指定模型和参数
|
|
137
|
+
tcb ai -a claude -- --model=claude-3.5-sonnet --max-tokens=4096
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### OpenAI Codex
|
|
141
|
+
|
|
142
|
+
OpenAI Codex 是 OpenAI 的代码生成 AI,基于 GPT 模型优化。
|
|
143
|
+
|
|
144
|
+
**安装命令:**
|
|
145
|
+
```bash
|
|
146
|
+
npm install -g openai
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**配置要求:**
|
|
150
|
+
- API 密钥:`OPENAI_API_KEY`
|
|
151
|
+
- 基础 URL:`https://api.openai.com`
|
|
152
|
+
- 支持模型:gpt-4, gpt-3.5-turbo 等
|
|
153
|
+
|
|
154
|
+
**使用示例:**
|
|
155
|
+
```bash
|
|
156
|
+
# 启动 OpenAI Codex
|
|
157
|
+
tcb ai -a codex -- --model=gpt-4
|
|
158
|
+
|
|
159
|
+
# 设置温度和最大 token
|
|
160
|
+
tcb ai -a codex -- --temperature=0.7 --max-tokens=2048
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Gemini CLI
|
|
164
|
+
|
|
165
|
+
Gemini CLI 是 Google 的 AI 编程工具,基于 Gemini 模型。
|
|
166
|
+
|
|
167
|
+
**安装命令:**
|
|
168
|
+
```bash
|
|
169
|
+
npm install -g @google/generative-ai
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**配置要求:**
|
|
173
|
+
- API 密钥:`GOOGLE_API_KEY`
|
|
174
|
+
- 基础 URL:`https://generativelanguage.googleapis.com`
|
|
175
|
+
- 支持模型:gemini-2.0-flash, gemini-2.0-pro 等
|
|
176
|
+
|
|
177
|
+
**使用示例:**
|
|
178
|
+
```bash
|
|
179
|
+
# 启动 Gemini CLI
|
|
180
|
+
tcb ai -a gemini -- --model=gemini-2.0-pro
|
|
181
|
+
|
|
182
|
+
# 设置安全过滤
|
|
183
|
+
tcb ai -a gemini -- --safety-level=BLOCK_MEDIUM_AND_ABOVE
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## 协议适配
|
|
187
|
+
|
|
188
|
+
### Anthropic 协议
|
|
189
|
+
|
|
190
|
+
支持 Anthropic 协议的 AI 工具可以直接透传:
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
# Claude Code(原生支持)
|
|
194
|
+
tcb ai -a claude -- --continue
|
|
195
|
+
|
|
196
|
+
# Kimi(支持 Anthropic 协议)
|
|
197
|
+
tcb ai -a kimi -- --model=claude-3.5-sonnet
|
|
198
|
+
|
|
199
|
+
# K2(支持 Anthropic 协议)
|
|
200
|
+
tcb ai -a k2 -- --max-tokens=4096
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### OpenAI 协议
|
|
204
|
+
|
|
205
|
+
支持 OpenAI 协议的 AI 工具通过 claude-code-router 转发:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# 自动检测并安装 claude-code-router
|
|
209
|
+
tcb ai -a openai -- --model=gpt-4
|
|
210
|
+
|
|
211
|
+
# 自定义 OpenAI 兼容服务
|
|
212
|
+
tcb ai -a custom -- --base-url=https://api.example.com
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## 云开发集成
|
|
216
|
+
|
|
217
|
+
### 环境变量注入
|
|
218
|
+
|
|
219
|
+
AI 开发套件会自动注入云开发相关环境变量:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
# 自动注入环境 ID
|
|
223
|
+
tcb ai -a claude -e my-env -- --continue
|
|
224
|
+
|
|
225
|
+
# 环境变量示例
|
|
226
|
+
CLOUDBASE_ENV_ID=my-env
|
|
227
|
+
CLOUDBASE_REGION=ap-shanghai
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 模板下载
|
|
231
|
+
|
|
232
|
+
支持下载云开发项目模板:
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
# 下载 React + CloudBase 模板
|
|
236
|
+
tcb ai --template react
|
|
237
|
+
|
|
238
|
+
# 下载小程序模板
|
|
239
|
+
tcb ai --template miniprogram
|
|
240
|
+
|
|
241
|
+
# 下载 Vue + CloudBase 模板
|
|
242
|
+
tcb ai --template vue
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
**支持的模板类型:**
|
|
246
|
+
- `rules`: AI 编辑器配置模板
|
|
247
|
+
- `react`: React + CloudBase 全栈应用
|
|
248
|
+
- `vue`: Vue + CloudBase 全栈应用
|
|
249
|
+
- `miniprogram`: 微信小程序 + 云开发
|
|
250
|
+
- `uniapp`: UniApp + CloudBase 跨端应用
|
|
251
|
+
|
|
252
|
+
### 自动部署
|
|
253
|
+
|
|
254
|
+
AI 工具生成的代码可以直接部署到云开发:
|
|
255
|
+
|
|
256
|
+
```bash
|
|
257
|
+
# 生成并部署 React 应用
|
|
258
|
+
tcb ai -a claude -e my-env -- --prompt="创建一个 React 购物车应用"
|
|
259
|
+
|
|
260
|
+
# 部署到云函数
|
|
261
|
+
tcb ai -a claude -e my-env -- --prompt="创建一个用户注册云函数"
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## 高级配置
|
|
265
|
+
|
|
266
|
+
### 自定义 Provider
|
|
267
|
+
|
|
268
|
+
支持配置自定义 AI 服务提供商:
|
|
269
|
+
|
|
270
|
+
```json
|
|
271
|
+
{
|
|
272
|
+
"defaultAgent": "custom",
|
|
273
|
+
"agents": {
|
|
274
|
+
"custom": {
|
|
275
|
+
"command": "claude",
|
|
276
|
+
"apiKey": "sk-xxx",
|
|
277
|
+
"baseUrl": "https://api.custom-ai.com",
|
|
278
|
+
"model": "custom-model"
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### 多环境支持
|
|
285
|
+
|
|
286
|
+
支持配置多个云开发环境:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
# 开发环境
|
|
290
|
+
tcb ai -a claude -e dev-env -- --continue
|
|
291
|
+
|
|
292
|
+
# 生产环境
|
|
293
|
+
tcb ai -a claude -e prod-env -- --continue
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 代理配置
|
|
297
|
+
|
|
298
|
+
支持通过代理访问 AI 服务:
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
# 设置代理
|
|
302
|
+
export HTTP_PROXY=http://127.0.0.1:7890
|
|
303
|
+
export HTTPS_PROXY=http://127.0.0.1:7890
|
|
304
|
+
|
|
305
|
+
# 启动 AI 工具
|
|
306
|
+
tcb ai -a claude -- --continue
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## 故障排除
|
|
310
|
+
|
|
311
|
+
### 常见问题
|
|
312
|
+
|
|
313
|
+
#### 1. AI 工具未安装
|
|
314
|
+
|
|
315
|
+
**错误信息:** `⚠️ claude 工具未安装`
|
|
316
|
+
|
|
317
|
+
**解决方案:**
|
|
318
|
+
```bash
|
|
319
|
+
# 安装 Claude Code
|
|
320
|
+
npm install -g @anthropic-ai/claude-code
|
|
321
|
+
|
|
322
|
+
# 检查安装
|
|
323
|
+
claude doctor
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
#### 2. API 密钥无效
|
|
327
|
+
|
|
328
|
+
**错误信息:** `❌ API 密钥无效`
|
|
329
|
+
|
|
330
|
+
**解决方案:**
|
|
331
|
+
```bash
|
|
332
|
+
# 重新配置
|
|
333
|
+
tcb ai --setup
|
|
334
|
+
|
|
335
|
+
# 检查 API 密钥格式
|
|
336
|
+
# Claude: sk-ant-api03-xxx
|
|
337
|
+
# OpenAI: sk-xxx
|
|
338
|
+
# Google: AIzaSyCxxx
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
#### 3. 网络连接问题
|
|
342
|
+
|
|
343
|
+
**错误信息:** `❌ 网络连接失败`
|
|
344
|
+
|
|
345
|
+
**解决方案:**
|
|
346
|
+
```bash
|
|
347
|
+
# 检查网络连接
|
|
348
|
+
ping api.anthropic.com
|
|
349
|
+
|
|
350
|
+
# 配置代理
|
|
351
|
+
export HTTP_PROXY=http://127.0.0.1:7890
|
|
352
|
+
|
|
353
|
+
# 使用国内镜像(如果支持)
|
|
354
|
+
tcb ai -a claude -- --base-url=https://api.anthropic.cn
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
#### 4. 模板下载失败
|
|
358
|
+
|
|
359
|
+
**错误信息:** `❌ 模板下载失败`
|
|
360
|
+
|
|
361
|
+
**解决方案:**
|
|
362
|
+
```bash
|
|
363
|
+
# 检查网络连接
|
|
364
|
+
curl -I https://static.cloudbase.net
|
|
365
|
+
|
|
366
|
+
# 重新下载
|
|
367
|
+
tcb ai --template react --force
|
|
368
|
+
|
|
369
|
+
# 手动下载模板
|
|
370
|
+
wget https://static.cloudbase.net/cloudbase-examples/web-cloudbase-react-template.zip
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
### 调试模式
|
|
374
|
+
|
|
375
|
+
启用调试模式获取详细信息:
|
|
376
|
+
|
|
377
|
+
```bash
|
|
378
|
+
# 启用调试
|
|
379
|
+
DEBUG=* tcb ai -a claude -- --continue
|
|
380
|
+
|
|
381
|
+
# 查看详细日志
|
|
382
|
+
tcb ai -a claude -- --verbose --continue
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## 最佳实践
|
|
386
|
+
|
|
387
|
+
### 1. 配置管理
|
|
388
|
+
|
|
389
|
+
- 使用 `tcb ai --setup` 进行初始配置
|
|
390
|
+
- 定期更新 API 密钥
|
|
391
|
+
- 为不同项目使用不同的环境 ID
|
|
392
|
+
|
|
393
|
+
### 2. 安全考虑
|
|
394
|
+
|
|
395
|
+
- 不要在代码中硬编码 API 密钥
|
|
396
|
+
- 使用环境变量存储敏感信息
|
|
397
|
+
- 定期轮换 API 密钥
|
|
398
|
+
|
|
399
|
+
### 3. 性能优化
|
|
400
|
+
|
|
401
|
+
- 选择合适的模型和参数
|
|
402
|
+
- 使用 `--continue` 保持会话连续性
|
|
403
|
+
- 合理设置 `max-tokens` 参数
|
|
404
|
+
|
|
405
|
+
### 4. 云开发集成
|
|
406
|
+
|
|
407
|
+
- 充分利用云开发的全栈能力
|
|
408
|
+
- 使用模板快速搭建项目
|
|
409
|
+
- 结合云函数和数据库构建完整应用
|
|
410
|
+
|
|
411
|
+
## 相关资源
|
|
412
|
+
|
|
413
|
+
- [CloudBase CLI 官方文档](https://docs.cloudbase.net/cli-v1/)
|
|
414
|
+
- [Claude Code 官方文档](https://docs.anthropic.com/en/docs/claude-code)
|
|
415
|
+
- [OpenAI API 文档](https://platform.openai.com/docs)
|
|
416
|
+
- [Google AI Studio](https://aistudio.google.com/)
|
|
417
|
+
- [云开发社区](https://cloudbase.net/community)
|
|
418
|
+
|
|
419
|
+
---
|
|
420
|
+
|
|
421
|
+
上一页[云存储](./storage) 下一页[静态网站托管](./hosting)
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# 技术方案设计:CloudBase CLI 安装脚本升级
|
|
2
|
+
|
|
3
|
+
## 目标与范围
|
|
4
|
+
- 目标:提供无需 npm/系统 Node 的一键安装体验,内置运行时,稳定、可观测,可原子升级/回滚。
|
|
5
|
+
- OS/ARCH:darwin x64/arm64、linux x64/arm64;Windows 暂支持 WSL/Git Bash。
|
|
6
|
+
- 暴露入口:`cloudbase`、`tcb`、`cloudbase-mcp`。
|
|
7
|
+
|
|
8
|
+
## 架构概览
|
|
9
|
+
```mermaid
|
|
10
|
+
flowchart TD
|
|
11
|
+
subgraph Install
|
|
12
|
+
A[用户运行安装脚本] --> B[检测 OS/ARCH]
|
|
13
|
+
B --> C[下载 {os}/{arch} 包 + sha256]
|
|
14
|
+
C --> D[解压到 ~/.local/share/cloudbase-cli/versions/<version>]
|
|
15
|
+
D --> E[创建 ~/.local/bin/ 符号链接\ncloudbase | tcb | cloudbase-mcp]
|
|
16
|
+
E --> F[PATH 提示]
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
subgraph Runtime
|
|
20
|
+
F --> G[launcher 执行 ./node ./cli.js\n(webpack 单文件 bundle)]
|
|
21
|
+
G --> H{入口名分发\nCLI_BIN_NAME / argv[1]}
|
|
22
|
+
H --> I[CloudBase/Tcb 模块\n(CLI Core in index.js)]
|
|
23
|
+
H --> J[cloudbase-mcp 模块\n(MCP Core in index.js)]
|
|
24
|
+
I --> K[self-update 等子流程]
|
|
25
|
+
J --> K
|
|
26
|
+
end
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 包形态(更新)
|
|
30
|
+
- 压缩包:`.tar.gz`
|
|
31
|
+
- 目录结构:
|
|
32
|
+
```
|
|
33
|
+
<root>
|
|
34
|
+
├─ node / node.exe # 内置 Node 可执行文件(Node 22)
|
|
35
|
+
├─ cli.js # 主 CLI 入口(webpack 单文件 bundle)
|
|
36
|
+
├─ mcp.js # cloudbase-mcp 入口(来自 @cloudbase/cloudbase-mcp/dist/cli.cjs)
|
|
37
|
+
├─ bin/
|
|
38
|
+
│ ├─ cloudbase # 薄启动脚本(shell)
|
|
39
|
+
│ ├─ tcb # 薄启动脚本(shell)
|
|
40
|
+
│ └─ cloudbase-mcp # 薄启动脚本(shell)
|
|
41
|
+
├─ install.sh # 便于自更新时本地调用
|
|
42
|
+
└─ manifest.json # 版本与校验信息
|
|
43
|
+
```
|
|
44
|
+
- 启动脚本职责:定位自身目录,执行 `./node ./cli.js "$@"`(`cloudbase-mcp` 启动 `./node ./mcp.js`)。
|
|
45
|
+
|
|
46
|
+
## 分发与产物目录(最终,更新)
|
|
47
|
+
- 本地 out 目录与线上 CDN 建议结构一致:
|
|
48
|
+
```
|
|
49
|
+
out/
|
|
50
|
+
├─ <version>/
|
|
51
|
+
│ ├─ darwin/arm64/cloudbase-cli-<version>.tar.gz{,.sha256}
|
|
52
|
+
│ ├─ darwin/x64/cloudbase-cli-<version>.tar.gz{,.sha256}
|
|
53
|
+
│ ├─ linux/arm64/cloudbase-cli-<version>.tar.gz{,.sha256}
|
|
54
|
+
│ ├─ linux/x64/cloudbase-cli-<version>.tar.gz{,.sha256}
|
|
55
|
+
│ ├─ windows/arm64/cloudbase-cli-<version>.zip{,.sha256}
|
|
56
|
+
│ └─ windows/x64/cloudbase-cli-<version>.zip{,.sha256}
|
|
57
|
+
├─ install/
|
|
58
|
+
│ └─ install.sh # 安装脚本(CDN 可提供 /install → /install/install.sh 的别名)
|
|
59
|
+
├─ stable.txt # latest(stable)版本号
|
|
60
|
+
├─ beta.txt # latest(beta)版本号
|
|
61
|
+
├─ artifacts/ # 本地构建缓存(CDN 可忽略)
|
|
62
|
+
└─ unpacked/ # 本地展开验证(CDN 可忽略)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- 下载 URL:
|
|
66
|
+
- `https://static.cloudbase.net/cli/<version>/{darwin|linux}/{x64|arm64}/cloudbase-cli-<version>.tar.gz`
|
|
67
|
+
- `https://static.cloudbase.net/cli/<version>/windows/{x64|arm64}/cloudbase-cli-<version>.zip`
|
|
68
|
+
- 校验文件:对应路径追加 `.sha256`
|
|
69
|
+
- 安装脚本入口:`curl -fsSL https://static.cloudbase.net/cli/install | bash`
|
|
70
|
+
- CDN 提供 `/install`(别名)指向 `/install/install.sh`
|
|
71
|
+
- latest 解析:`https://static.cloudbase.net/cli/stable.txt | beta.txt`
|
|
72
|
+
|
|
73
|
+
原生 Windows:`irm https://static.cloudbase.net/cli/install.ps1 | iex`
|
|
74
|
+
- CDN 提供 `/install.ps1`(别名)指向 `/install/install.ps1`
|
|
75
|
+
- latest 解析同上
|
|
76
|
+
|
|
77
|
+
## 安装脚本设计(更新)
|
|
78
|
+
- 入口:`curl -fsSL https://static.cloudbase.net/cli/install | bash`
|
|
79
|
+
- 变量:支持 `CHANNEL=stable|beta`、`VERSION=<semver|latest>`、可选 `DOWNLOAD_BASE`。
|
|
80
|
+
- 关键步骤:
|
|
81
|
+
1) 检测 OS/ARCH(Darwin/Linux;x64/arm64;Windows 仅 WSL 路径)
|
|
82
|
+
2) 解析版本:当 `VERSION=latest` 时,从 `https://static.cloudbase.net/cli/<channel>.txt` 读取版本号
|
|
83
|
+
3) 创建临时目录:`~/.local/share/cloudbase-cli/versions/.tmp-<version>-<ts>`(失败自动清理)
|
|
84
|
+
4) 下载并校验 sha256
|
|
85
|
+
5) 解压(strip-components=1)到临时目录
|
|
86
|
+
6) 原子切换为 `~/.local/share/cloudbase-cli/versions/<version>`(mv)
|
|
87
|
+
7) 为 `cloudbase`/`tcb`/`cloudbase-mcp` 创建或更新符号链接至 `~/.local/bin`
|
|
88
|
+
8) 若 PATH 未包含 `~/.local/bin` 则输出提示
|
|
89
|
+
- 兼容:避免 sudo;仅依赖 `bash`/`curl`/`tar`。
|
|
90
|
+
- Windows 适配:
|
|
91
|
+
- 分发层面产出 `windows/{x64,arm64}` 包(含 `node.exe` 与相同目录结构)。
|
|
92
|
+
- 安装脚本仅在 WSL 下执行;检测到 Git Bash/MSYS/Cygwin 时提示转到 WSL 并退出。
|
|
93
|
+
- 新增 PowerShell 版安装器与 `.zip`:见“PowerShell 安装器设计”。
|
|
94
|
+
|
|
95
|
+
## PowerShell 安装器设计(新增)
|
|
96
|
+
- 脚本:`install.ps1`(根 CDN:`/install/install.ps1`,别名 `/install.ps1`)
|
|
97
|
+
- 主要逻辑:
|
|
98
|
+
1) 解析 `$env:CHANNEL`/`$env:VERSION`/`$env:DOWNLOAD_BASE`(或脚本参数),默认 `stable`/`latest`/`https://static.cloudbase.net/cli`;
|
|
99
|
+
2) OS/ARCH:基于 `Environment.Is64BitOperatingSystem` 与 `PROCESSOR_ARCHITECTURE` 判定 `x64|arm64`;
|
|
100
|
+
3) 路径:`$Root=$env:LOCALAPPDATA\cloudbase-cli`,`$Versions=$Root\versions`,`$Tmp=$Versions\.tmp-<guid>`;
|
|
101
|
+
4) 下载:`Invoke-WebRequest` 到临时文件,读取对应 `.sha256`,校验哈希;
|
|
102
|
+
5) 解压:`Expand-Archive` 到 `$Tmp\cloudbase-cli-<version>`;
|
|
103
|
+
6) 原子切换:若存在 `$Versions\<version>` 则清理;`Move-Item $Tmp\cloudbase-cli-<version> $Versions\<version>`;
|
|
104
|
+
7) 记录当前:写入 `$Root\current.txt` 为 `<version>`;
|
|
105
|
+
8) 生成启动器:`$Root\bin\{cloudbase,tcb,cloudbase-mcp}.cmd`,内容调用 `node.exe` 运行 `cli.js`/`mcp.js`;
|
|
106
|
+
9) PATH 提示:若 `%LOCALAPPDATA%\cloudbase-cli\bin` 未在 PATH,输出添加建议;
|
|
107
|
+
10) 清理:删除 `$Tmp`;异常时回滚并输出错误;
|
|
108
|
+
11) 可选:执行自更新/回滚命令与卸载脚本支持。
|
|
109
|
+
|
|
110
|
+
## current 符号链接方案(新增)
|
|
111
|
+
- 目的:实现升级/回滚的原子切换与可诊断性,减少反复改动 `~/.local/bin`。
|
|
112
|
+
- 目录结构(用户主目录下):
|
|
113
|
+
- `~/.local/share/cloudbase-cli/versions/<version>/`:每个版本一目录
|
|
114
|
+
- `~/.local/share/cloudbase-cli/current -> versions/<version>`:指向“当前生效版本”的符号链接
|
|
115
|
+
- `~/.local/bin/{cloudbase,tcb,cloudbase-mcp} -> ~/.local/share/cloudbase-cli/current/bin/<name>`
|
|
116
|
+
- 安装流程中的切换顺序:
|
|
117
|
+
1) 完成解压到 `versions/<version>`
|
|
118
|
+
2) 原子更新 `current` 指向该版本(`ln -sfn`)
|
|
119
|
+
3) 将 `~/.local/bin` 的 3 个命令统一指向 `current/bin/*`(后续版本切换无需再改动)
|
|
120
|
+
- 回滚流程:仅需更新 `current` 指向上一个版本;`~/.local/bin` 无需改动。
|
|
121
|
+
|
|
122
|
+
## cloudbase-mcp 入口设计(最终)
|
|
123
|
+
- 入口:包内 `mcp.js`,来自已发布的 `@cloudbase/cloudbase-mcp` 模块(复制其 `dist/cli.cjs`)。
|
|
124
|
+
- 启动:`bin/cloudbase-mcp` 调用 `./node ./mcp.js "$@"`。
|
|
125
|
+
- 与主 CLI 解耦:mcp 不参与 webpack bundling,避免 `exports` 限制与打包体积膨胀;与主 CLI 共用同一内置 Node。
|
|
126
|
+
- 验证策略:安装阶段仅做静态校验(存在性/可读性),避免运行 `--help` 时进入常驻进程导致阻塞。
|
|
127
|
+
|
|
128
|
+
## 低码链路处理(Strategy A,最终落地)
|
|
129
|
+
- 决策:核心 CLI 与低码解耦;在 bundle 中剔除低码等重型依赖。
|
|
130
|
+
- 实施:
|
|
131
|
+
- 打包:使用 IgnorePlugin 剔除 `@cloudbase/lowcode-*`、`vue-loader`、`@vue/compiler-sfc`、`consolidate`、`webpack-dev-server` 等;对原生或可选依赖标记 externals。
|
|
132
|
+
- nodemon 系命令:对 `nodemon` 改为运行时可选 `require`,缺失时给出引导提示(独立发行版不内置)。
|
|
133
|
+
- 运行:低码相关命令可后续按需引导安装。
|
|
134
|
+
- 影响:
|
|
135
|
+
- 常规 CLI 能力不受影响;包体显著减小,安装速度与成功率提升。
|
|
136
|
+
- 低码能力需二次安装,避免影响主 CLI 的安装质量与体积。
|
|
137
|
+
|
|
138
|
+
## 升级与回滚(已实现)
|
|
139
|
+
- 命令(新增):
|
|
140
|
+
- `tcb self-update [--version <v>] [--channel stable|beta] [--download-base <url>]`
|
|
141
|
+
- `tcb rollback`
|
|
142
|
+
- 行为说明:
|
|
143
|
+
- self-update:优先调用“当前安装目录中的安装器”`~/.local/share/cloudbase-cli/current/install.sh` 执行更新;若缺失再回退为 `curl -fsSL <DOWNLOAD_BASE>/install | bash`。
|
|
144
|
+
- 参数透传:通过环境变量向安装器传递 `VERSION`、`CHANNEL`、`DOWNLOAD_BASE`,下载并安装目标版本。
|
|
145
|
+
- 原子切换:安装器采用“临时目录解压 + `mv`”与 `current` 符号链接,确保中断可恢复、不破坏已安装版本。
|
|
146
|
+
- 回滚:枚举 `versions/` 子目录,选择上一个版本,更新 `current` 指向该版本并输出结果。
|
|
147
|
+
- 版本保留:后续引入“最多保留 N 个版本(默认≥2)”的清理策略,避免磁盘占用过大。
|
|
148
|
+
|
|
149
|
+
## 构建与打包流程(新增,更新)
|
|
150
|
+
- `build/scripts/fetch-node.sh`:从 `nodejs.org` 下载官方 Node(默认 v22.18.0,可通过 `NODE_VERSION` 覆盖)到 `build/runtime/<os>/<arch>/node`。
|
|
151
|
+
- `build/scripts/package.sh`:组装单平台包;若未提供内置 Node,开发模式下回退复制系统 `node`(仅本地调试)。
|
|
152
|
+
- `build/scripts/build-all.sh`:
|
|
153
|
+
- 使用 `package.json` 版本号;构建前清理 `out/`;
|
|
154
|
+
- 自动拉取 Node(darwin/linux/windows × x64/arm64),Windows 从 `nodejs.org` 下载 `.zip` 并抽取 `node.exe`;
|
|
155
|
+
- 打包 darwin/linux/windows × x64/arm64;
|
|
156
|
+
- 生成 `out/stable.txt` / `out/beta.txt` 与 `out/install/install.sh`;
|
|
157
|
+
- 收尾执行 `prune-out.sh`,删除 `out/artifacts` 与 `out/unpacked`,并创建 `/install` 别名(指向 `/install/install.sh`)。
|
|
158
|
+
|
|
159
|
+
## 输出净化(实现)
|
|
160
|
+
- 关闭无关警告:在入口对 Node 弃用告警做静默处理。
|
|
161
|
+
- 过滤偶发 `[NaN]` 日志:在入口包裹 `console.log`,忽略仅包含单个 `NaN` 的数组打印(源自第三方依赖的边缘输出)。
|
|
162
|
+
|
|
163
|
+
## 与 npm 全局安装的冲突处理
|
|
164
|
+
- 检测:`command -v cloudbase|tcb|cloudbase-mcp` 显示现有路径;若非 `~/.local/bin` 则提示 PATH 优先级调整。
|
|
165
|
+
- 策略:不覆盖系统路径与全局可执行;仅在 `~/.local/bin` 建立链接并提示将其置前。
|
|
166
|
+
- 提供检测命令提示:`which -a cloudbase`、`echo $PATH` 调整方法。
|
|
167
|
+
|
|
168
|
+
## 打包策略(webpack 单文件)
|
|
169
|
+
- 工具:参考 `CloudBase-AI-ToolKit/mcp/webpack/cli.config.cjs`,产出单 `index.js`。
|
|
170
|
+
- 多入口:在 runtime 通过 `process.env.CLI_BIN_NAME` 区分行为,或在 JS 层读取 `process.argv[1]` 判断调用来源。
|
|
171
|
+
- Node 运行时:随包包含 `node`(22);launcher 固定调用 `./node`,避免系统 Node 差异。
|
|
172
|
+
- 原生依赖:若发现原生模块(如 sqlite3),按 OS/ARCH 预编译并随包置于 `assets/`,运行时设置 `NODE_OPTIONS=--no-addons` 或 `NODE_PATH`/`LD_LIBRARY_PATH` 定位(仅必要时)。
|
|
173
|
+
|
|
174
|
+
## 分平台打包评估结论
|
|
175
|
+
- 必须分平台打包:内置 Node 需按 OS/ARCH 分发,至少 darwin/linux × x64/arm64(四包)。
|
|
176
|
+
- JS bundle 不分平台:当前依赖未见强原生模块,webpack 单文件在各平台通用。
|
|
177
|
+
- cloudbase-mcp:与主 CLI 共用 bundle 与内置 Node,随 OS/ARCH 同步分发。
|
|
178
|
+
- 建议策略:单 JS bundle + 按 OS/ARCH 发四包。
|
|
179
|
+
- 风险提示:如存在可选原生加速(例 `bufferutil`/`utf-8-validate`),建议通过 webpack IgnorePlugin/alias 明确排除,避免触发编译路径。
|
|
180
|
+
|
|
181
|
+
## 兼容性(更新)
|
|
182
|
+
- macOS: darwin x64/arm64(Apple Silicon 原生)
|
|
183
|
+
- Linux: glibc x64/arm64(要求 `tar`/`bash` 可用)
|
|
184
|
+
- Windows: 推荐使用 WSL。若在 Git Bash/MSYS/Cygwin 环境执行安装脚本,将提示切换到 WSL 并退出。
|
|
185
|
+
|
|
186
|
+
## 观测(可选,默认关闭)
|
|
187
|
+
- 安装器支持 `CLOUDBASE_CLI_REPORT=1` 时,匿名上报:版本、OS/ARCH、结果、耗时;失败错误码。
|
|
188
|
+
- 传输:HTTPS,最小字段,无个人数据。
|
|
189
|
+
|
|
190
|
+
## 安全
|
|
191
|
+
- 强制 HTTPS;校验 `sha256`;脚本最小权限;不使用 sudo。
|
|
192
|
+
- 升级原子性保障:临时目录 + `mv`,失败自动清理。
|
|
193
|
+
|
|
194
|
+
## 卸载
|
|
195
|
+
- 删除目录:`rm -rf ~/.local/share/cloudbase-cli`。
|
|
196
|
+
- 删除链接:`rm -f ~/.local/bin/{cloudbase,tcb,cloudbase-mcp}`。
|
|
197
|
+
|
|
198
|
+
## 风险与缓解
|
|
199
|
+
- 包体过大:控制 ≤ 80MB;按需裁剪依赖;必要时拆分资源到 `assets/` 懒加载。
|
|
200
|
+
- PATH 冲突:明确检测与提示脚本;不自动改 PATH 避免破坏用户环境。
|
|
201
|
+
- 原生依赖差异:优先纯 JS;确需原生则预编译并在 CI 验证多平台。
|
|
202
|
+
|
|
203
|
+
## 开放问题(需对齐)
|
|
204
|
+
1. 分发域名与是否提供国内镜像域(例如 `download.cloudbase.cn`)。
|
|
205
|
+
2. Node 版本锁定为 22 是否合适(或 20 LTS)。
|
|
206
|
+
3. 包体上限与保留版本数策略(默认 2 个)。
|
|
207
|
+
4. `cloudbase-mcp` 是否需要与主 CLI 解耦为独立包形态(当前为多入口同包)。
|