@cloudbase/cli 2.8.0-beta.6 → 2.8.0-beta.8
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/bin/{cloudbase-mcp.js → cloudbase-mcp.cjs} +1 -1
- package/lib/utils/ai/const.js +8 -7
- package/lib/utils/ai/router.js +14 -36
- package/lib/utils/ai/setup.js +4 -2
- package/package.json +5 -5
- package/post-install.js +13 -11
- package/types/utils/ai/const.d.ts +6 -5
- package/types/utils/ai/router.d.ts +0 -1
- package/.env.local +0 -5
|
@@ -6,7 +6,7 @@ const { spawn } = require('child_process')
|
|
|
6
6
|
|
|
7
7
|
// 获取内置包的路径并拼接 CLI 路径
|
|
8
8
|
const mcpPackagePath = require.resolve('@cloudbase/cloudbase-mcp')
|
|
9
|
-
const mcpCliPath = path.join(path.dirname(mcpPackagePath), 'cli.
|
|
9
|
+
const mcpCliPath = path.join(path.dirname(mcpPackagePath), 'cli.cjs')
|
|
10
10
|
|
|
11
11
|
// 执行内置的 MCP CLI
|
|
12
12
|
const child = spawn('node', [mcpCliPath, ...process.argv.slice(2)], {
|
package/lib/utils/ai/const.js
CHANGED
|
@@ -3,13 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getDefaultModelByBaseUrl = exports.BASE_URL_MODEL_MAPPING = exports.getAgentConfigValidator = exports.getDefaultConfig = exports.CLOUDBASE_PROVIDERS = exports.AGENTS = exports.NONE = exports.AIDER = exports.CODEX = exports.QWEN = exports.CLAUDE = exports.DEFAULT_CONFIG = exports.CLOUDBASE_MCP_CONFIG_PATH = exports.CLAUDE_CODE_ROUTER_CONFIG_PATH = exports.ENV_LOCAL_PATH = exports.CONFIG_PATH = void 0;
|
|
6
|
+
exports.getDefaultModelByBaseUrl = exports.BASE_URL_MODEL_MAPPING = exports.getAgentConfigValidator = exports.getDefaultConfig = exports.CLOUDBASE_PROVIDERS = exports.AGENTS = exports.NONE = exports.AIDER = exports.CODEX = exports.QWEN = exports.CLAUDE = exports.DEFAULT_CONFIG = exports.CLOUDBASE_MCP_CONFIG_PATH = exports.CLAUDE_CODE_ROUTER_LOG_PATH = exports.CLAUDE_CODE_ROUTER_CONFIG_PATH = exports.ENV_LOCAL_PATH = exports.CONFIG_PATH = void 0;
|
|
7
7
|
const os_1 = __importDefault(require("os"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const v3_1 = __importDefault(require("zod/v3"));
|
|
10
10
|
exports.CONFIG_PATH = path_1.default.join(process.cwd(), 'cloudbaserc.json');
|
|
11
11
|
exports.ENV_LOCAL_PATH = path_1.default.join(process.cwd(), '.env.local');
|
|
12
12
|
exports.CLAUDE_CODE_ROUTER_CONFIG_PATH = path_1.default.join(os_1.default.homedir(), '.claude-code-router', 'config.json');
|
|
13
|
+
exports.CLAUDE_CODE_ROUTER_LOG_PATH = path_1.default.join(os_1.default.homedir(), '.claude-code-router', 'claude-code-router.log');
|
|
13
14
|
exports.CLOUDBASE_MCP_CONFIG_PATH = path_1.default.join(os_1.default.homedir(), '.cloudbase-env-id');
|
|
14
15
|
exports.DEFAULT_CONFIG = `{
|
|
15
16
|
"envId": "{{env.ENV_ID}}"
|
|
@@ -105,18 +106,18 @@ exports.NONE = {
|
|
|
105
106
|
};
|
|
106
107
|
exports.AGENTS = [exports.CLAUDE, exports.QWEN, exports.CODEX, exports.AIDER, exports.NONE];
|
|
107
108
|
exports.CLOUDBASE_PROVIDERS = [
|
|
109
|
+
{
|
|
110
|
+
name: 'Kimi',
|
|
111
|
+
value: 'kimi-exp',
|
|
112
|
+
models: ['kimi-k2-instruct-local'],
|
|
113
|
+
transformer: undefined
|
|
114
|
+
},
|
|
108
115
|
{
|
|
109
116
|
name: 'DeepSeek',
|
|
110
117
|
value: 'deepseek',
|
|
111
118
|
models: ['deepseek-v3'],
|
|
112
119
|
transformer: 'deepseek'
|
|
113
120
|
},
|
|
114
|
-
{
|
|
115
|
-
name: 'KIMI',
|
|
116
|
-
value: 'kimi',
|
|
117
|
-
models: ['Kimi-K2-Instruct-Online-128K'],
|
|
118
|
-
transformer: undefined
|
|
119
|
-
},
|
|
120
121
|
{
|
|
121
122
|
name: '自定义',
|
|
122
123
|
value: 'custom',
|
package/lib/utils/ai/router.js
CHANGED
|
@@ -202,13 +202,13 @@ class AICommandRouter {
|
|
|
202
202
|
name: 'templateType',
|
|
203
203
|
message: '选择要下载的模板类型:',
|
|
204
204
|
choices: [
|
|
205
|
+
{ name: '🟦 微信小程序 + CloudBase', value: 'miniprogram' },
|
|
205
206
|
{ name: '🚀 Web 应用 - React + CloudBase', value: 'react' },
|
|
206
207
|
{ name: '🟢 Web 应用 - Vue + CloudBase', value: 'vue' },
|
|
207
|
-
{ name: '🟦 微信小程序 + CloudBase', value: 'miniprogram' },
|
|
208
208
|
{ name: '🌈 跨端应用 - UniApp + CloudBase', value: 'uniapp' },
|
|
209
209
|
{ name: '🧩 只下载 AI 规则和配置', value: 'rules' }
|
|
210
210
|
],
|
|
211
|
-
default: '
|
|
211
|
+
default: 'miniprogram'
|
|
212
212
|
}
|
|
213
213
|
]);
|
|
214
214
|
const shouldCheckOverwrite = yield this.shouldCheckOverwrite(templateType);
|
|
@@ -359,38 +359,6 @@ class AICommandRouter {
|
|
|
359
359
|
yield this.modifyMCPConfigs(extractDir, log);
|
|
360
360
|
});
|
|
361
361
|
}
|
|
362
|
-
validateTemplateIntegrity(templateType, extractDir, log) {
|
|
363
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
364
|
-
const fs = yield Promise.resolve().then(() => __importStar(require('fs-extra')));
|
|
365
|
-
const path = yield Promise.resolve().then(() => __importStar(require('path')));
|
|
366
|
-
const requiredFiles = {
|
|
367
|
-
rules: ['.mcp.json', 'CLAUDE.md'],
|
|
368
|
-
react: ['package.json', 'src/', 'public/', 'cloudbaserc.json'],
|
|
369
|
-
vue: ['package.json', 'src/', 'public/', 'cloudbaserc.json'],
|
|
370
|
-
miniprogram: ['app.js', 'app.json', 'pages/', 'cloudbaserc.json'],
|
|
371
|
-
uniapp: ['pages.json', 'manifest.json', 'pages/', 'cloudbaserc.json']
|
|
372
|
-
};
|
|
373
|
-
const files = requiredFiles[templateType] || [];
|
|
374
|
-
const missingFiles = [];
|
|
375
|
-
for (const file of files) {
|
|
376
|
-
const filePath = path.join(extractDir, file);
|
|
377
|
-
if (!(yield fs.pathExists(filePath))) {
|
|
378
|
-
missingFiles.push(file);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
if (missingFiles.length > 0) {
|
|
382
|
-
log.warn(`⚠️ 模板解压不完整,缺失文件: ${missingFiles.join(', ')}`);
|
|
383
|
-
log.info('💡 建议重新下载模板或检查网络连接');
|
|
384
|
-
if (templateType === 'miniprogram' && missingFiles.some((f) => f.includes('pages/'))) {
|
|
385
|
-
log.warn('⚠️ 小程序 pages 文件夹缺失,可能影响项目正常运行');
|
|
386
|
-
log.info('💡 请重新运行 tcb ai 并选择下载 miniprogram 模板');
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
log.info('✅ 模板完整性校验通过,所有必要文件已解压');
|
|
391
|
-
}
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
362
|
getInstallCommand(agent) {
|
|
395
363
|
switch (agent) {
|
|
396
364
|
case 'claude':
|
|
@@ -454,6 +422,9 @@ class AICommandRouter {
|
|
|
454
422
|
log.info('💡 可能是参数错误或配置问题');
|
|
455
423
|
log.info('🔧 请检查 API 密钥、模型名称等配置是否正确');
|
|
456
424
|
}
|
|
425
|
+
if (command === 'ccr') {
|
|
426
|
+
log.info(`🔧 请前往 ${const_1.CLAUDE_CODE_ROUTER_LOG_PATH} 查看日志`);
|
|
427
|
+
}
|
|
457
428
|
reject(new Error(errorMsg));
|
|
458
429
|
}
|
|
459
430
|
});
|
|
@@ -597,7 +568,7 @@ class AICommandRouter {
|
|
|
597
568
|
while (current < max) {
|
|
598
569
|
current++;
|
|
599
570
|
if (current > max) {
|
|
600
|
-
throw new Error(
|
|
571
|
+
throw new Error(`ccr 重启完成失败,可前往 ${const_1.CLAUDE_CODE_ROUTER_LOG_PATH} 查看日志`);
|
|
601
572
|
}
|
|
602
573
|
log.info(`${current}/${max}等待 ccr 重启完成...`);
|
|
603
574
|
const isRunning = yield this.isClaudeCodeRouterRunning();
|
|
@@ -708,7 +679,8 @@ class AICommandRouter {
|
|
|
708
679
|
config.Router === null) {
|
|
709
680
|
config.Router = {};
|
|
710
681
|
}
|
|
711
|
-
config.Router.default =
|
|
682
|
+
config.Router.default = `cloudbase,${model}`;
|
|
683
|
+
config.Log = true;
|
|
712
684
|
yield fs.writeJson(const_1.CLAUDE_CODE_ROUTER_CONFIG_PATH, config, { spaces: 2 });
|
|
713
685
|
log.debug('✅ claude-code-router 配置完成');
|
|
714
686
|
}
|
|
@@ -989,6 +961,9 @@ class AICommandRouter {
|
|
|
989
961
|
if (argsStr.includes('npm-global-exec@latest') && argsStr.includes('@cloudbase/cloudbase-mcp@latest')) {
|
|
990
962
|
result.command = 'cloudbase-mcp';
|
|
991
963
|
result.args = [];
|
|
964
|
+
result.env = {
|
|
965
|
+
INTEGRATION_IDE: process.env.INTEGRATION_IDE || 'CloudBaseCLI'
|
|
966
|
+
};
|
|
992
967
|
modified = true;
|
|
993
968
|
log.debug(`修改配置文件 ${filePath}: npx -> cloudbase-mcp`);
|
|
994
969
|
}
|
|
@@ -1030,6 +1005,9 @@ class AICommandRouter {
|
|
|
1030
1005
|
if (argsStr.includes('@cloudbase/cloudbase-mcp@latest')) {
|
|
1031
1006
|
result.command = 'cloudbase-mcp';
|
|
1032
1007
|
result.args = [];
|
|
1008
|
+
result.env = {
|
|
1009
|
+
INTEGRATION_IDE: process.env.INTEGRATION_IDE || 'CloudBaseCLI'
|
|
1010
|
+
};
|
|
1033
1011
|
modified = true;
|
|
1034
1012
|
log.debug(`修改配置文件 ${filePath}: npx -> cloudbase-mcp`);
|
|
1035
1013
|
}
|
package/lib/utils/ai/setup.js
CHANGED
|
@@ -124,7 +124,8 @@ class AISetupWizard {
|
|
|
124
124
|
{
|
|
125
125
|
type: 'confirm',
|
|
126
126
|
name: 'shouldUpdateEnvId',
|
|
127
|
-
message: `当前使用的 envId 为 ${configEnvId}
|
|
127
|
+
message: `当前使用的 envId 为 ${configEnvId},是否需要更新?`,
|
|
128
|
+
default: false
|
|
128
129
|
}
|
|
129
130
|
]);
|
|
130
131
|
if (shouldUpdateEnvId) {
|
|
@@ -236,6 +237,7 @@ class AISetupWizard {
|
|
|
236
237
|
choices: [
|
|
237
238
|
{ name: 'Kimi - https://api.moonshot.cn/anthropic', value: 'https://api.moonshot.cn/anthropic' },
|
|
238
239
|
{ name: '智谱 - https://open.bigmodel.cn/api/anthropic', value: 'https://open.bigmodel.cn/api/anthropic' },
|
|
240
|
+
{ name: 'Anthropic - https://api.anthropic.com', value: 'https://api.anthropic.com' },
|
|
239
241
|
{ name: '🛠️ 自定义 URL', value: 'custom' }
|
|
240
242
|
],
|
|
241
243
|
default: 'https://api.moonshot.cn/anthropic'
|
|
@@ -492,7 +494,7 @@ class AISetupWizard {
|
|
|
492
494
|
name: 'selectedProvider',
|
|
493
495
|
message: '选择大模型供应商:',
|
|
494
496
|
choices: const_1.CLOUDBASE_PROVIDERS.map(p => ({ name: p.name, value: p.value })),
|
|
495
|
-
default: '
|
|
497
|
+
default: 'kimi-exp'
|
|
496
498
|
}
|
|
497
499
|
]);
|
|
498
500
|
if (selectedProvider === 'custom') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "2.8.0-beta.
|
|
3
|
+
"version": "2.8.0-beta.8",
|
|
4
4
|
"description": "cli tool for cloudbase",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"bin": {
|
|
23
23
|
"cloudbase": "bin/cloudbase.js",
|
|
24
|
-
"
|
|
25
|
-
"
|
|
24
|
+
"cloudbase-mcp": "bin/cloudbase-mcp.cjs",
|
|
25
|
+
"tcb": "bin/tcb.js"
|
|
26
26
|
},
|
|
27
27
|
"husky": {
|
|
28
28
|
"hooks": {
|
|
@@ -33,13 +33,13 @@
|
|
|
33
33
|
"license": "ISC",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@cloudbase/cloud-api": "^0.5.5",
|
|
36
|
-
"@cloudbase/cloudbase-mcp": "^1.8.
|
|
36
|
+
"@cloudbase/cloudbase-mcp": "^1.8.28",
|
|
37
37
|
"@cloudbase/framework-core": "^1.9.7",
|
|
38
38
|
"@cloudbase/functions-framework": "1.16.0",
|
|
39
39
|
"@cloudbase/iac-core": "0.0.3-alpha.11",
|
|
40
40
|
"@cloudbase/lowcode-cli": "^0.22.2",
|
|
41
41
|
"@cloudbase/manager-node": "4.3.3",
|
|
42
|
-
"@cloudbase/toolbox": "^0.7.
|
|
42
|
+
"@cloudbase/toolbox": "^0.7.7",
|
|
43
43
|
"@dotenvx/dotenvx": "^1.48.3",
|
|
44
44
|
"address": "^1.1.2",
|
|
45
45
|
"camelcase-keys": "^7.0.2",
|
package/post-install.js
CHANGED
|
@@ -4,17 +4,19 @@ const { execSync } = require('child_process')
|
|
|
4
4
|
|
|
5
5
|
const isWin32 = process.platform === 'win32'
|
|
6
6
|
|
|
7
|
-
const print =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
const print =
|
|
8
|
+
(color = null) =>
|
|
9
|
+
(str = '') => {
|
|
10
|
+
const terminalCols = retrieveCols()
|
|
11
|
+
const strLength = str.replace(/\u001B\[[0-9]{2}m/g, '').length
|
|
12
|
+
const leftPaddingLength = Math.floor((terminalCols - strLength) / 2)
|
|
13
|
+
const leftPadding = ' '.repeat(Math.max(leftPaddingLength, 0))
|
|
14
|
+
if (color) {
|
|
15
|
+
str = chalk[color](str)
|
|
16
|
+
}
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
+
console.log(leftPadding, str)
|
|
19
|
+
}
|
|
18
20
|
|
|
19
21
|
const retrieveCols = (() => {
|
|
20
22
|
let result = false
|
|
@@ -52,7 +54,7 @@ function printFooter() {
|
|
|
52
54
|
print()(
|
|
53
55
|
' '.repeat(15) +
|
|
54
56
|
`${chalk.bold(emoji('👉'))} ${chalk.underline(
|
|
55
|
-
'https://docs.cloudbase.net/cli-v1/quick-start
|
|
57
|
+
'https://docs.cloudbase.net/cli-v1/quick-start'
|
|
56
58
|
)}`
|
|
57
59
|
)
|
|
58
60
|
emptyLine()
|
|
@@ -2,6 +2,7 @@ import z from 'zod/v3';
|
|
|
2
2
|
export declare const CONFIG_PATH: string;
|
|
3
3
|
export declare const ENV_LOCAL_PATH: string;
|
|
4
4
|
export declare const CLAUDE_CODE_ROUTER_CONFIG_PATH: string;
|
|
5
|
+
export declare const CLAUDE_CODE_ROUTER_LOG_PATH: string;
|
|
5
6
|
export declare const CLOUDBASE_MCP_CONFIG_PATH: string;
|
|
6
7
|
export declare const DEFAULT_CONFIG = "{\n \"envId\": \"{{env.ENV_ID}}\"\n}";
|
|
7
8
|
export declare const CLAUDE: {
|
|
@@ -299,15 +300,15 @@ export declare const AGENTS: readonly [{
|
|
|
299
300
|
value: string;
|
|
300
301
|
}];
|
|
301
302
|
export declare const CLOUDBASE_PROVIDERS: readonly [{
|
|
303
|
+
readonly name: "Kimi";
|
|
304
|
+
readonly value: "kimi-exp";
|
|
305
|
+
readonly models: readonly ["kimi-k2-instruct-local"];
|
|
306
|
+
readonly transformer: any;
|
|
307
|
+
}, {
|
|
302
308
|
readonly name: "DeepSeek";
|
|
303
309
|
readonly value: "deepseek";
|
|
304
310
|
readonly models: readonly ["deepseek-v3"];
|
|
305
311
|
readonly transformer: "deepseek";
|
|
306
|
-
}, {
|
|
307
|
-
readonly name: "KIMI";
|
|
308
|
-
readonly value: "kimi";
|
|
309
|
-
readonly models: readonly ["Kimi-K2-Instruct-Online-128K"];
|
|
310
|
-
readonly transformer: any;
|
|
311
312
|
}, {
|
|
312
313
|
readonly name: "自定义";
|
|
313
314
|
readonly value: "custom";
|
|
@@ -13,7 +13,6 @@ export declare class AICommandRouter {
|
|
|
13
13
|
private promptForTemplateDownload;
|
|
14
14
|
private downloadTemplate;
|
|
15
15
|
private downloadAndExtractTemplate;
|
|
16
|
-
private validateTemplateIntegrity;
|
|
17
16
|
private getInstallCommand;
|
|
18
17
|
private shouldCheckOverwrite;
|
|
19
18
|
private executeCommand;
|