@cloudbase/cli 2.9.9 → 2.9.10-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cloudbase.js +2 -1
- package/bin/tcb.js +35 -28
- package/lib/auth/login.js +21 -13
- package/lib/commands/account/login.js +43 -42
- package/lib/commands/account/logout.js +3 -2
- package/lib/commands/ai/index.js +13 -12
- package/lib/commands/cloudfunction/base.js +24 -26
- package/lib/commands/cloudrun/base.js +87 -96
- package/lib/commands/common.js +11 -10
- 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 +24 -0
- package/lib/commands/config/list.js +72 -0
- package/lib/commands/config/set.js +89 -0
- package/lib/commands/db/base.js +33 -32
- package/lib/commands/env/base.js +12 -11
- package/lib/commands/env/domain.js +24 -23
- package/lib/commands/env/login.js +31 -30
- package/lib/commands/fun/base.js +37 -36
- package/lib/commands/functions/alias/getRoute.js +5 -4
- package/lib/commands/functions/alias/setRoute.js +7 -6
- package/lib/commands/functions/code-download.js +15 -11
- package/lib/commands/functions/code-update.js +8 -7
- package/lib/commands/functions/concurrency/delete.js +5 -4
- package/lib/commands/functions/concurrency/list.js +6 -5
- package/lib/commands/functions/concurrency/set.js +5 -4
- package/lib/commands/functions/config-update.js +8 -7
- package/lib/commands/functions/copy.js +7 -6
- package/lib/commands/functions/delete.js +8 -7
- package/lib/commands/functions/deploy.js +35 -34
- package/lib/commands/functions/detail.js +32 -31
- package/lib/commands/functions/invoke.js +16 -15
- package/lib/commands/functions/layer/bind.js +26 -25
- package/lib/commands/functions/layer/common.js +2 -1
- package/lib/commands/functions/layer/create.js +7 -6
- package/lib/commands/functions/layer/delete.js +9 -8
- package/lib/commands/functions/layer/download.js +10 -9
- package/lib/commands/functions/layer/list.js +10 -9
- package/lib/commands/functions/layer/sort.js +9 -8
- package/lib/commands/functions/list.js +9 -8
- package/lib/commands/functions/log.js +28 -27
- package/lib/commands/functions/run.js +21 -20
- package/lib/commands/functions/trigger-create.js +9 -8
- package/lib/commands/functions/trigger-delete.js +10 -9
- package/lib/commands/functions/version/list.js +9 -8
- package/lib/commands/functions/version/publish.js +5 -4
- package/lib/commands/gateway/create.js +14 -13
- package/lib/commands/gateway/delete.js +10 -9
- package/lib/commands/gateway/domain.js +25 -24
- package/lib/commands/gateway/list.js +11 -10
- package/lib/commands/gateway/switch.js +22 -19
- package/lib/commands/helpers/init.js +38 -37
- package/lib/commands/helpers/new.js +7 -6
- package/lib/commands/helpers/open.js +7 -6
- package/lib/commands/hosting/hosting.js +45 -44
- package/lib/commands/index.js +1 -0
- package/lib/commands/pull/pull.js +12 -11
- package/lib/commands/run/delete.js +16 -15
- package/lib/commands/run/image/common.js +2 -1
- package/lib/commands/run/image/delete.js +10 -9
- package/lib/commands/run/image/download.js +8 -7
- package/lib/commands/run/image/list.js +11 -10
- package/lib/commands/run/image/upload.js +9 -8
- package/lib/commands/run/list.js +10 -9
- package/lib/commands/run/service/config.js +13 -12
- package/lib/commands/run/service/deploy.js +24 -23
- package/lib/commands/run/service/list.js +10 -9
- package/lib/commands/run/service/update.js +22 -21
- package/lib/commands/run/standalonegateway/common.js +2 -1
- package/lib/commands/run/standalonegateway/create.js +14 -13
- package/lib/commands/run/standalonegateway/destroy.js +9 -8
- package/lib/commands/run/standalonegateway/list.js +7 -6
- package/lib/commands/run/standalonegateway/package.js +7 -6
- package/lib/commands/run/standalonegateway/turn.js +10 -9
- package/lib/commands/run/version/common.js +2 -1
- package/lib/commands/run/version/create.js +41 -40
- package/lib/commands/run/version/delete.js +10 -9
- package/lib/commands/run/version/list.js +13 -12
- package/lib/commands/run/version/modify.js +13 -12
- package/lib/commands/run/version/update.js +57 -54
- package/lib/commands/runf/base.js +42 -40
- package/lib/commands/self-update.js +11 -10
- package/lib/commands/smart.js +5 -4
- package/lib/commands/storage/storage.js +61 -56
- package/lib/commands/third/thirdAttach.js +6 -5
- package/lib/commands/utils.js +8 -5
- package/lib/constant.js +18 -17
- package/lib/decorators/deprecate.js +2 -1
- package/lib/function/alias.js +3 -2
- package/lib/function/base.js +9 -8
- package/lib/function/concurrency.js +4 -3
- package/lib/function/create.js +5 -4
- package/lib/function/delete.js +2 -1
- package/lib/function/layer/attach.js +2 -1
- package/lib/function/layer/create.js +2 -1
- package/lib/function/layer/download.js +2 -1
- package/lib/function/trigger.js +6 -5
- package/lib/function/update.js +3 -2
- package/lib/function/version.js +3 -2
- package/lib/help.js +22 -20
- package/lib/hosting.js +18 -17
- package/lib/i18n/index.js +81 -0
- package/lib/run/service/common.js +14 -13
- package/lib/run/service/config.js +4 -3
- package/lib/run/service/deployPackage.js +6 -5
- package/lib/run/service/showLogs.js +3 -2
- package/lib/run/service/update.js +7 -6
- package/lib/run/standalonegateway/list.js +5 -1
- package/lib/storage.js +2 -1
- package/lib/utils/ai/banner.js +12 -11
- package/lib/utils/ai/claudeWindows.js +5 -3
- package/lib/utils/ai/config.js +3 -2
- package/lib/utils/ai/const.js +4 -3
- package/lib/utils/ai/env.js +3 -2
- package/lib/utils/ai/envLocalManager.js +6 -5
- package/lib/utils/ai/nodeVersion.js +5 -1
- package/lib/utils/ai/router.js +129 -106
- package/lib/utils/ai/setup.js +95 -91
- package/lib/utils/checkTcbrEnv.js +22 -21
- package/lib/utils/cli-table.js +2 -1
- package/lib/utils/commonParamsCheck.js +4 -3
- package/lib/utils/debug-logger.js +2 -1
- package/lib/utils/dts.js +4 -3
- package/lib/utils/env.js +23 -21
- package/lib/utils/fs/index.js +5 -4
- package/lib/utils/function-packer.js +3 -2
- package/lib/utils/index.js +1 -0
- package/lib/utils/mcp-config-modifier.js +18 -17
- package/lib/utils/net/cloud-api-request.js +2 -1
- package/lib/utils/net/credential.js +2 -1
- package/lib/utils/net/http-request.js +2 -1
- package/lib/utils/progress-bar.js +2 -1
- package/lib/utils/prompt/select.js +8 -6
- package/lib/utils/store/auth.js +3 -2
- package/lib/utils/store/config.js +49 -0
- package/lib/utils/store/db.js +5 -0
- package/lib/utils/store/index.js +1 -1
- package/lib/utils/tcbrApi/callTcbrApi.js +2 -1
- package/lib/utils/template-manager.js +37 -36
- package/lib/utils/template.js +10 -9
- package/lib/utils/tools/common.js +3 -2
- package/lib/utils/url.js +19 -0
- package/lib/utils/validator.js +12 -4
- package/locales/README.md +160 -0
- package/locales/i18next-scanner.config.js +206 -0
- package/locales/langs/en.json +1235 -0
- package/locales/langs/zh.json +1235 -0
- package/locales/mapping.json +1235 -0
- package/package.json +9 -2
- 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/index.d.ts +1 -0
- package/types/i18n/index.d.ts +3 -0
- package/types/utils/ai/const.d.ts +1 -1
- package/types/utils/index.d.ts +1 -0
- package/types/utils/store/config.d.ts +8 -0
- package/types/utils/store/db.d.ts +2 -0
- package/types/utils/store/index.d.ts +1 -1
- package/types/utils/url.d.ts +18 -0
package/lib/utils/ai/router.js
CHANGED
|
@@ -49,12 +49,14 @@ const error_1 = require("../../error");
|
|
|
49
49
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
50
50
|
const chalk_1 = __importDefault(require("chalk"));
|
|
51
51
|
const output_1 = require("../output");
|
|
52
|
+
const i18n_1 = require("../../i18n");
|
|
52
53
|
const const_1 = require("./const");
|
|
53
54
|
const utils_1 = require("../../commands/utils");
|
|
54
55
|
const auth_1 = require("../../auth");
|
|
55
56
|
const nodeVersion_1 = require("./nodeVersion");
|
|
56
57
|
const claudeWindows_1 = require("./claudeWindows");
|
|
57
58
|
const env_1 = require("./env");
|
|
59
|
+
const url_1 = require("../url");
|
|
58
60
|
const IDE_FILE_MAPPINGS = {
|
|
59
61
|
cursor: [
|
|
60
62
|
{ path: '.cursor/rules/cloudbase-rules.mdc' },
|
|
@@ -105,30 +107,30 @@ class AICommandRouter {
|
|
|
105
107
|
var _a;
|
|
106
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
107
109
|
if ((0, config_1.isValidAgent)(agent) !== true) {
|
|
108
|
-
log.error(
|
|
110
|
+
log.error((0, i18n_1.t)('❌ 无效的 agent: {{agent}}', { agent }));
|
|
109
111
|
return;
|
|
110
112
|
}
|
|
111
113
|
const config = yield this.configManager.loadConfig();
|
|
112
114
|
if (!config) {
|
|
113
|
-
log.warn("⚠️
|
|
115
|
+
log.warn((0, i18n_1.t)("⚠️ 未检测到 AI ToolKit CLI 配置,请运行 'tcb ai --setup' 进行配置"));
|
|
114
116
|
return;
|
|
115
117
|
}
|
|
116
118
|
const agentUpperCased = agent.toUpperCase();
|
|
117
119
|
const agentConfig = (_a = config.agents) === null || _a === void 0 ? void 0 : _a[agent];
|
|
118
120
|
if (!agentConfig) {
|
|
119
|
-
log.warn(
|
|
121
|
+
log.warn((0, i18n_1.t)('⚠️ 未找到 {{agent}} 配置,请运行 tcb ai --setup 进行配置', { agent: agentUpperCased }));
|
|
120
122
|
return;
|
|
121
123
|
}
|
|
122
|
-
log.info(
|
|
124
|
+
log.info((0, i18n_1.t)('🚀 启动 {{agent}} AI CLI 工具', { agent: chalk_1.default.bold(agentUpperCased) }));
|
|
123
125
|
try {
|
|
124
126
|
yield this.checkToolkitConfig(agent, log, template);
|
|
125
127
|
}
|
|
126
128
|
catch (e) {
|
|
127
|
-
log.warn('⚠️
|
|
129
|
+
log.warn((0, i18n_1.t)('⚠️ 云开发功能检查失败,但 AI 工具仍可正常使用'));
|
|
128
130
|
}
|
|
129
131
|
const isValid = yield this.validateAgentConfig(agent, agentConfig, log);
|
|
130
132
|
if (!isValid) {
|
|
131
|
-
log.warn(
|
|
133
|
+
log.warn((0, i18n_1.t)('⚠️ {{agent}} 配置无效,请重新配置', { agent: agent.toUpperCase() }));
|
|
132
134
|
return;
|
|
133
135
|
}
|
|
134
136
|
this.executeAgentWithConfig(agent, agentConfig, this.parseArgs(addtionalArgs), log);
|
|
@@ -140,7 +142,7 @@ class AICommandRouter {
|
|
|
140
142
|
if (missingFiles.length > 0) {
|
|
141
143
|
const skipTemplate = yield this.checkSkipTemplateConfig();
|
|
142
144
|
if (skipTemplate) {
|
|
143
|
-
log.info('🚫 已跳过模板下载,无法使用云开发 MCP 及 AI 规则。如需使用,请参考 tcb pull --help');
|
|
145
|
+
log.info((0, i18n_1.t)('🚫 已跳过模板下载,无法使用云开发 MCP 及 AI 规则。如需使用,请参考 tcb pull --help'));
|
|
144
146
|
return;
|
|
145
147
|
}
|
|
146
148
|
log.log('');
|
|
@@ -186,14 +188,14 @@ class AICommandRouter {
|
|
|
186
188
|
{
|
|
187
189
|
type: 'list',
|
|
188
190
|
name: 'templateType',
|
|
189
|
-
message:
|
|
191
|
+
message: (0, i18n_1.t)('下载模板以获取完整的开发体验: {{hint}}', { hint: const_1.LIST_HINT }),
|
|
190
192
|
choices: [
|
|
191
|
-
{ name: '🟦 微信小程序 + CloudBase', value: 'miniprogram' },
|
|
192
|
-
{ name: '🚀 Web 应用 - React + CloudBase', value: 'react' },
|
|
193
|
-
{ name: '🟢 Web 应用 - Vue + CloudBase', value: 'vue' },
|
|
194
|
-
{ name: '🌈 跨端应用 - UniApp + CloudBase', value: 'uniapp' },
|
|
195
|
-
{ name: '🧩 只下载 AI 规则和配置', value: 'rules' },
|
|
196
|
-
{ name: '🚫 不下载模板', value: 'none' }
|
|
193
|
+
{ name: (0, i18n_1.t)('🟦 微信小程序 + CloudBase'), value: 'miniprogram' },
|
|
194
|
+
{ name: (0, i18n_1.t)('🚀 Web 应用 - React + CloudBase'), value: 'react' },
|
|
195
|
+
{ name: (0, i18n_1.t)('🟢 Web 应用 - Vue + CloudBase'), value: 'vue' },
|
|
196
|
+
{ name: (0, i18n_1.t)('🌈 跨端应用 - UniApp + CloudBase'), value: 'uniapp' },
|
|
197
|
+
{ name: (0, i18n_1.t)('🧩 只下载 AI 规则和配置'), value: 'rules' },
|
|
198
|
+
{ name: (0, i18n_1.t)('🚫 不下载模板'), value: 'none' }
|
|
197
199
|
],
|
|
198
200
|
default: 'miniprogram'
|
|
199
201
|
}
|
|
@@ -201,17 +203,17 @@ class AICommandRouter {
|
|
|
201
203
|
templateType = selectedType;
|
|
202
204
|
}
|
|
203
205
|
if (templateType === 'none') {
|
|
204
|
-
log.info('🚫 跳过模板下载');
|
|
206
|
+
log.info((0, i18n_1.t)('🚫 跳过模板下载'));
|
|
205
207
|
yield this.saveSkipTemplateConfig();
|
|
206
208
|
return;
|
|
207
209
|
}
|
|
208
|
-
log.info(
|
|
210
|
+
log.info((0, i18n_1.t)('📦 正在下载并解压 {{templateType}} 模板...', { templateType }));
|
|
209
211
|
yield this.downloadAndExtractTemplate(templateType, log);
|
|
210
|
-
log.info(
|
|
212
|
+
log.info((0, i18n_1.t)('✅ {{templateType}} 模板配置完成', { templateType }));
|
|
211
213
|
}
|
|
212
214
|
catch (error) {
|
|
213
|
-
log.error(
|
|
214
|
-
throw new error_1.CloudBaseError('模板下载失败', { original: error });
|
|
215
|
+
log.error((0, i18n_1.t)('❌ 配置失败: {{error}}', { error: error.message }));
|
|
216
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('模板下载失败'), { original: error });
|
|
215
217
|
}
|
|
216
218
|
});
|
|
217
219
|
}
|
|
@@ -249,7 +251,7 @@ class AICommandRouter {
|
|
|
249
251
|
};
|
|
250
252
|
const template = templateMap[templateType];
|
|
251
253
|
if (!template)
|
|
252
|
-
throw new error_1.CloudBaseError('未知模板类型');
|
|
254
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('未知模板类型'));
|
|
253
255
|
const tmpDir = os.tmpdir();
|
|
254
256
|
const zipPath = path.join(tmpDir, `cloudbase-template-${templateType}-${Date.now()}.zip`);
|
|
255
257
|
yield new Promise((resolve, reject) => {
|
|
@@ -257,7 +259,7 @@ class AICommandRouter {
|
|
|
257
259
|
https
|
|
258
260
|
.get(template.url, (response) => {
|
|
259
261
|
if (response.statusCode !== 200) {
|
|
260
|
-
reject(new Error(
|
|
262
|
+
reject(new Error((0, i18n_1.t)('下载失败: {{statusCode}}', { statusCode: response.statusCode })));
|
|
261
263
|
return;
|
|
262
264
|
}
|
|
263
265
|
response.pipe(file);
|
|
@@ -291,7 +293,7 @@ class AICommandRouter {
|
|
|
291
293
|
yield this.mergeMcpConfig(entry, destPath, inferConfigFormat(entryPath), log);
|
|
292
294
|
}
|
|
293
295
|
catch (e) {
|
|
294
|
-
log.warn(
|
|
296
|
+
log.warn((0, i18n_1.t)('MCP 配置合并失败 {{entryPath}}:{{error}},已跳过', { entryPath, error: e.message }));
|
|
295
297
|
}
|
|
296
298
|
continue;
|
|
297
299
|
}
|
|
@@ -320,7 +322,7 @@ class AICommandRouter {
|
|
|
320
322
|
yield fs.writeJson(destPath, merged, { spaces: 2 });
|
|
321
323
|
}
|
|
322
324
|
catch (e) {
|
|
323
|
-
log.warn('cloudbaserc.json 合并失败,已跳过: '
|
|
325
|
+
log.warn((0, i18n_1.t)('cloudbaserc.json 合并失败,已跳过: {{error}}', { error: e.message }));
|
|
324
326
|
}
|
|
325
327
|
continue;
|
|
326
328
|
}
|
|
@@ -329,7 +331,10 @@ class AICommandRouter {
|
|
|
329
331
|
{
|
|
330
332
|
type: 'confirm',
|
|
331
333
|
name: 'confirmOverwriteFile',
|
|
332
|
-
message:
|
|
334
|
+
message: (0, i18n_1.t)('检测到已存在文件 {{entryPath}},是否覆盖? {{hint}}', {
|
|
335
|
+
entryPath,
|
|
336
|
+
hint: (0, const_1.getBooleanHint)(false)
|
|
337
|
+
}),
|
|
333
338
|
default: false
|
|
334
339
|
}
|
|
335
340
|
]);
|
|
@@ -397,7 +402,7 @@ class AICommandRouter {
|
|
|
397
402
|
message: 'npm install -g @tencent-ai/codebuddy-code'
|
|
398
403
|
};
|
|
399
404
|
default:
|
|
400
|
-
return { success: false, message:
|
|
405
|
+
return { success: false, message: (0, i18n_1.t)('# 请查阅 {{agent}} 的官方安装文档', { agent }) };
|
|
401
406
|
}
|
|
402
407
|
}
|
|
403
408
|
executeCommand(command, args, env, log) {
|
|
@@ -414,31 +419,35 @@ class AICommandRouter {
|
|
|
414
419
|
resolve();
|
|
415
420
|
}
|
|
416
421
|
else {
|
|
417
|
-
const errorMsg =
|
|
418
|
-
|
|
422
|
+
const errorMsg = (0, i18n_1.t)('命令执行失败: {{command}} {{args}} (退出码: {{code}})', {
|
|
423
|
+
command,
|
|
424
|
+
args: args.join(' '),
|
|
425
|
+
code
|
|
426
|
+
});
|
|
427
|
+
log.error((0, i18n_1.t)('❌ {{errorMsg}}', { errorMsg }));
|
|
419
428
|
if (code === 127) {
|
|
420
|
-
log.info('💡 命令未找到,请检查是否正确安装');
|
|
421
|
-
log.info(
|
|
429
|
+
log.info((0, i18n_1.t)('💡 命令未找到,请检查是否正确安装'));
|
|
430
|
+
log.info((0, i18n_1.t)('📦 安装命令: {{installCmd}}', { installCmd: this.getInstallCommand(command).message }));
|
|
422
431
|
}
|
|
423
432
|
else if (code === 1) {
|
|
424
|
-
log.info('💡 可能是参数错误或配置问题');
|
|
425
|
-
log.info('🔧 请检查 API 密钥、模型名称等配置是否正确');
|
|
433
|
+
log.info((0, i18n_1.t)('💡 可能是参数错误或配置问题'));
|
|
434
|
+
log.info((0, i18n_1.t)('🔧 请检查 API 密钥、模型名称等配置是否正确'));
|
|
426
435
|
}
|
|
427
436
|
if (command === 'ccr') {
|
|
428
|
-
log.info(
|
|
437
|
+
log.info((0, i18n_1.t)('🔧 请前往 {{logPath}} 查看日志', { logPath: const_1.CLAUDE_CODE_ROUTER_LOG_PATH }));
|
|
429
438
|
}
|
|
430
439
|
reject(new Error(errorMsg));
|
|
431
440
|
}
|
|
432
441
|
});
|
|
433
442
|
child.on('error', (err) => {
|
|
434
|
-
const errorMsg =
|
|
435
|
-
log.error(
|
|
443
|
+
const errorMsg = (0, i18n_1.t)('启动失败: {{command}} ({{error}})', { command, error: err.message });
|
|
444
|
+
log.error((0, i18n_1.t)('❌ {{errorMsg}}', { errorMsg }));
|
|
436
445
|
if (err.message.includes('ENOENT')) {
|
|
437
|
-
log.info('💡 命令不存在,请先安装对应的 AI CLI 工具');
|
|
438
|
-
log.info(
|
|
446
|
+
log.info((0, i18n_1.t)('💡 命令不存在,请先安装对应的 AI CLI 工具'));
|
|
447
|
+
log.info((0, i18n_1.t)('📦 安装命令: {{installCmd}}', { installCmd: this.getInstallCommand(command).message }));
|
|
439
448
|
}
|
|
440
449
|
else if (err.message.includes('EACCES')) {
|
|
441
|
-
log.info('💡 权限不足,请检查文件权限或使用管理员权限');
|
|
450
|
+
log.info((0, i18n_1.t)('💡 权限不足,请检查文件权限或使用管理员权限'));
|
|
442
451
|
}
|
|
443
452
|
reject(new Error(errorMsg));
|
|
444
453
|
});
|
|
@@ -464,16 +473,16 @@ class AICommandRouter {
|
|
|
464
473
|
validateAgentConfig(agent, agentConfig, log) {
|
|
465
474
|
return __awaiter(this, void 0, void 0, function* () {
|
|
466
475
|
if (!agentConfig) {
|
|
467
|
-
log.error('❌ Agent 配置为空');
|
|
476
|
+
log.error((0, i18n_1.t)('❌ Agent 配置为空'));
|
|
468
477
|
return false;
|
|
469
478
|
}
|
|
470
479
|
const validateResult = (0, const_1.getAgentConfigValidator)(agent)(agentConfig);
|
|
471
480
|
if (validateResult.success === true) {
|
|
472
|
-
log.debug('✅ Agent 配置验证通过');
|
|
481
|
+
log.debug((0, i18n_1.t)('✅ Agent 配置验证通过'));
|
|
473
482
|
return true;
|
|
474
483
|
}
|
|
475
484
|
else {
|
|
476
|
-
log.error(
|
|
485
|
+
log.error((0, i18n_1.t)('❌ {{agent}} 配置无效: {{error}}', { agent, error: validateResult.error }));
|
|
477
486
|
return false;
|
|
478
487
|
}
|
|
479
488
|
});
|
|
@@ -534,7 +543,7 @@ class AICommandRouter {
|
|
|
534
543
|
return yield this.executeNoneCodebuddyAgent(additionalArgs, log);
|
|
535
544
|
}
|
|
536
545
|
default:
|
|
537
|
-
throw new Error(
|
|
546
|
+
throw new Error((0, i18n_1.t)('不支持的 AI 工具: {{agent}}', { agent }));
|
|
538
547
|
}
|
|
539
548
|
});
|
|
540
549
|
}
|
|
@@ -579,10 +588,12 @@ class AICommandRouter {
|
|
|
579
588
|
token: credential.token
|
|
580
589
|
});
|
|
581
590
|
if (!accessToken.access_token) {
|
|
582
|
-
log.error(
|
|
591
|
+
log.error((0, i18n_1.t)('获取云开发 Access Token 失败,请运行 tcb login 后再重试,{{token}}', {
|
|
592
|
+
token: JSON.stringify(accessToken)
|
|
593
|
+
}));
|
|
583
594
|
process.exit(1);
|
|
584
595
|
}
|
|
585
|
-
const baseUrl =
|
|
596
|
+
const baseUrl = `${(0, url_1.getGatewayUrl)(envId)}/v1/ai/${provider}`;
|
|
586
597
|
const apiKey = accessToken.access_token;
|
|
587
598
|
yield this.executeCommand('qwen', additionalArgs, Object.assign(Object.assign({}, process.env), { OPENAI_API_KEY: apiKey, OPENAI_BASE_URL: baseUrl, OPENAI_MODEL: model }), log);
|
|
588
599
|
});
|
|
@@ -603,7 +614,7 @@ class AICommandRouter {
|
|
|
603
614
|
yield this.executeCommand('ccr', ['restart'], process.env, log);
|
|
604
615
|
}
|
|
605
616
|
catch (e) {
|
|
606
|
-
log.error('执行 ccr restart 失败,尝试执行 ccr stop && ccr start');
|
|
617
|
+
log.error((0, i18n_1.t)('执行 ccr restart 失败,尝试执行 ccr stop && ccr start'));
|
|
607
618
|
yield this.executeCommand('ccr', ['stop'], process.env, log);
|
|
608
619
|
this.executeCommand('ccr', ['start'], process.env, log);
|
|
609
620
|
const max = 3;
|
|
@@ -611,12 +622,12 @@ class AICommandRouter {
|
|
|
611
622
|
while (current < max) {
|
|
612
623
|
current++;
|
|
613
624
|
if (current > max) {
|
|
614
|
-
throw new Error(
|
|
625
|
+
throw new Error((0, i18n_1.t)('ccr 重启完成失败,可前往 {{logPath}} 查看日志', { logPath: const_1.CLAUDE_CODE_ROUTER_LOG_PATH }));
|
|
615
626
|
}
|
|
616
|
-
log.info(
|
|
627
|
+
log.info((0, i18n_1.t)('{{current}}/{{max}}等待 ccr 重启完成...', { current, max }));
|
|
617
628
|
const isRunning = yield this.isClaudeCodeRouterRunning();
|
|
618
629
|
if (isRunning) {
|
|
619
|
-
log.info('ccr 重启完成');
|
|
630
|
+
log.info((0, i18n_1.t)('ccr 重启完成'));
|
|
620
631
|
break;
|
|
621
632
|
}
|
|
622
633
|
}
|
|
@@ -659,12 +670,14 @@ class AICommandRouter {
|
|
|
659
670
|
token: credential.token
|
|
660
671
|
});
|
|
661
672
|
if (!accessToken.access_token) {
|
|
662
|
-
log.error(
|
|
673
|
+
log.error((0, i18n_1.t)('获取云开发 Access Token 失败,请运行 tcb login 后再重试,{{token}}', {
|
|
674
|
+
token: JSON.stringify(accessToken)
|
|
675
|
+
}));
|
|
663
676
|
process.exit(1);
|
|
664
677
|
}
|
|
665
678
|
const cloudbaseProvider = {
|
|
666
679
|
name: 'cloudbase',
|
|
667
|
-
api_base_url:
|
|
680
|
+
api_base_url: `${(0, url_1.getGatewayUrl)(envId)}/v1/ai/${provider}/chat/completions`,
|
|
668
681
|
api_key: accessToken.access_token,
|
|
669
682
|
models: [model]
|
|
670
683
|
};
|
|
@@ -674,9 +687,9 @@ class AICommandRouter {
|
|
|
674
687
|
yield fs.ensureFile(const_1.CLAUDE_CODE_ROUTER_CONFIG_PATH);
|
|
675
688
|
const claudeCodeRouterConfig = yield fs.readFile(const_1.CLAUDE_CODE_ROUTER_CONFIG_PATH, 'utf-8');
|
|
676
689
|
if (claudeCodeRouterConfig.trim().length === 0) {
|
|
677
|
-
log.debug('🛠️ claude-code-router 配置为空,写入 Cloudbase 配置...');
|
|
690
|
+
log.debug((0, i18n_1.t)('🛠️ claude-code-router 配置为空,写入 Cloudbase 配置...'));
|
|
678
691
|
yield fs.writeJson(const_1.CLAUDE_CODE_ROUTER_CONFIG_PATH, { Providers: [cloudbaseProvider] });
|
|
679
|
-
log.debug('✅ claude-code-router 配置完成');
|
|
692
|
+
log.debug((0, i18n_1.t)('✅ claude-code-router 配置完成'));
|
|
680
693
|
}
|
|
681
694
|
else {
|
|
682
695
|
const config = safeParseJson(claudeCodeRouterConfig);
|
|
@@ -685,29 +698,29 @@ class AICommandRouter {
|
|
|
685
698
|
{
|
|
686
699
|
type: 'confirm',
|
|
687
700
|
name: 'shouldOverwrite',
|
|
688
|
-
message:
|
|
701
|
+
message: (0, i18n_1.t)('claude-code-router 配置文件非合法 JSON ,是否覆盖? {{hint}}', { hint: (0, const_1.getBooleanHint)() })
|
|
689
702
|
}
|
|
690
703
|
]);
|
|
691
704
|
if (shouldOverwrite) {
|
|
692
705
|
yield fs.writeJson(const_1.CLAUDE_CODE_ROUTER_CONFIG_PATH, {
|
|
693
706
|
Providers: [cloudbaseProvider]
|
|
694
707
|
}, { spaces: 2 });
|
|
695
|
-
log.debug('✅ claude-code-router 配置完成');
|
|
708
|
+
log.debug((0, i18n_1.t)('✅ claude-code-router 配置完成'));
|
|
696
709
|
}
|
|
697
710
|
else {
|
|
698
|
-
log.error('❌ claude-code-router 配置文件非合法 JSON ,请手动修复');
|
|
711
|
+
log.error((0, i18n_1.t)('❌ claude-code-router 配置文件非合法 JSON ,请手动修复'));
|
|
699
712
|
process.exit(1);
|
|
700
713
|
}
|
|
701
714
|
}
|
|
702
715
|
if (typeof config !== 'object' || config === null) {
|
|
703
|
-
log.error('❌ 未知 claude-code-router 配置文件格式请手动修复');
|
|
716
|
+
log.error((0, i18n_1.t)('❌ 未知 claude-code-router 配置文件格式请手动修复'));
|
|
704
717
|
process.exit(1);
|
|
705
718
|
}
|
|
706
719
|
if (!('Providers' in config)) {
|
|
707
720
|
config.Providers = [cloudbaseProvider];
|
|
708
721
|
}
|
|
709
722
|
if (!Array.isArray(config.Providers)) {
|
|
710
|
-
log.error('❌ claude-code-router 配置文件 Providers 字段非数组类型,请手动修复');
|
|
723
|
+
log.error((0, i18n_1.t)('❌ claude-code-router 配置文件 Providers 字段非数组类型,请手动修复'));
|
|
711
724
|
process.exit(1);
|
|
712
725
|
}
|
|
713
726
|
const providers = config.Providers;
|
|
@@ -726,7 +739,7 @@ class AICommandRouter {
|
|
|
726
739
|
config.Router.default = `cloudbase,${model}`;
|
|
727
740
|
config.Log = true;
|
|
728
741
|
yield fs.writeJson(const_1.CLAUDE_CODE_ROUTER_CONFIG_PATH, config, { spaces: 2 });
|
|
729
|
-
log.debug('✅ claude-code-router 配置完成');
|
|
742
|
+
log.debug((0, i18n_1.t)('✅ claude-code-router 配置完成'));
|
|
730
743
|
}
|
|
731
744
|
});
|
|
732
745
|
}
|
|
@@ -751,22 +764,24 @@ class AICommandRouter {
|
|
|
751
764
|
});
|
|
752
765
|
});
|
|
753
766
|
if (isAvailable) {
|
|
754
|
-
log.debug('claude code router 已安装!');
|
|
767
|
+
log.debug((0, i18n_1.t)('claude code router 已安装!'));
|
|
755
768
|
}
|
|
756
769
|
else {
|
|
757
770
|
const { shouldInstall } = yield inquirer_1.default.prompt([
|
|
758
771
|
{
|
|
759
772
|
type: 'confirm',
|
|
760
773
|
name: 'shouldInstall',
|
|
761
|
-
message:
|
|
774
|
+
message: (0, i18n_1.t)('AI 开发缺少 claude code router 依赖,是否安装? {{hint}}', {
|
|
775
|
+
hint: (0, const_1.getBooleanHint)(true)
|
|
776
|
+
})
|
|
762
777
|
}
|
|
763
778
|
]);
|
|
764
779
|
if (shouldInstall) {
|
|
765
780
|
yield this.executeCommand('npm', ['install', '-g', '@musistudio/claude-code-router'], process.env, log);
|
|
766
|
-
log.info('✅ claude-code-router 安装完成');
|
|
781
|
+
log.info((0, i18n_1.t)('✅ claude-code-router 安装完成'));
|
|
767
782
|
}
|
|
768
783
|
else {
|
|
769
|
-
log.info('❌ claude code router 未安装,请手动安装');
|
|
784
|
+
log.info((0, i18n_1.t)('❌ claude code router 未安装,请手动安装'));
|
|
770
785
|
process.exit(1);
|
|
771
786
|
}
|
|
772
787
|
}
|
|
@@ -775,14 +790,14 @@ class AICommandRouter {
|
|
|
775
790
|
ensureClaudeCode(log) {
|
|
776
791
|
return __awaiter(this, void 0, void 0, function* () {
|
|
777
792
|
if (yield this.isToolAvailable('claude')) {
|
|
778
|
-
log.debug('claude code 已安装!');
|
|
793
|
+
log.debug((0, i18n_1.t)('claude code 已安装!'));
|
|
779
794
|
}
|
|
780
795
|
else {
|
|
781
796
|
const { shouldInstall } = yield inquirer_1.default.prompt([
|
|
782
797
|
{
|
|
783
798
|
type: 'confirm',
|
|
784
799
|
name: 'shouldInstall',
|
|
785
|
-
message:
|
|
800
|
+
message: (0, i18n_1.t)('AI 开发缺少 claude code 依赖,是否安装? {{hint}}', { hint: (0, const_1.getBooleanHint)(true) })
|
|
786
801
|
}
|
|
787
802
|
]);
|
|
788
803
|
if (shouldInstall) {
|
|
@@ -795,23 +810,27 @@ class AICommandRouter {
|
|
|
795
810
|
yield this.executeCommand('sh', ['-c', 'curl -fsSL https://claude.ai/install.sh | bash'], process.env, log);
|
|
796
811
|
}
|
|
797
812
|
catch (error) {
|
|
798
|
-
log.warn('⚠️ curl 安装失败,尝试使用 npm 安装...');
|
|
813
|
+
log.warn((0, i18n_1.t)('⚠️ curl 安装失败,尝试使用 npm 安装...'));
|
|
799
814
|
try {
|
|
800
815
|
yield this.executeCommand('npm', ['install', '-g', '@anthropic-ai/claude-code'], process.env, log);
|
|
801
816
|
}
|
|
802
817
|
catch (npmError) {
|
|
803
|
-
log.error('❌ claude code 安装失败');
|
|
804
|
-
log.error('请手动安装 claude code:');
|
|
805
|
-
log.error(
|
|
818
|
+
log.error((0, i18n_1.t)('❌ claude code 安装失败'));
|
|
819
|
+
log.error((0, i18n_1.t)('请手动安装 claude code:'));
|
|
820
|
+
log.error((0, i18n_1.t)('📖 安装文档: {{link}}', {
|
|
821
|
+
link: (0, output_1.genClickableLink)('https://docs.anthropic.com/en/docs/claude-code/setup')
|
|
822
|
+
}));
|
|
806
823
|
process.exit(1);
|
|
807
824
|
}
|
|
808
825
|
}
|
|
809
826
|
}
|
|
810
|
-
log.info('✅ claude code 安装完成');
|
|
827
|
+
log.info((0, i18n_1.t)('✅ claude code 安装完成'));
|
|
811
828
|
}
|
|
812
829
|
else {
|
|
813
|
-
log.info('❌ claude code 未安装,请手动安装');
|
|
814
|
-
log.info(
|
|
830
|
+
log.info((0, i18n_1.t)('❌ claude code 未安装,请手动安装'));
|
|
831
|
+
log.info((0, i18n_1.t)('📖 安装文档: {{link}}', {
|
|
832
|
+
link: (0, output_1.genClickableLink)('https://docs.anthropic.com/en/docs/claude-code/setup')
|
|
833
|
+
}));
|
|
815
834
|
process.exit(1);
|
|
816
835
|
}
|
|
817
836
|
}
|
|
@@ -820,22 +839,22 @@ class AICommandRouter {
|
|
|
820
839
|
ensureQwenCode(log) {
|
|
821
840
|
return __awaiter(this, void 0, void 0, function* () {
|
|
822
841
|
if (yield this.isToolAvailable('qwen')) {
|
|
823
|
-
log.debug('qwen code 已安装!');
|
|
842
|
+
log.debug((0, i18n_1.t)('qwen code 已安装!'));
|
|
824
843
|
}
|
|
825
844
|
else {
|
|
826
845
|
const { shouldInstall } = yield inquirer_1.default.prompt([
|
|
827
846
|
{
|
|
828
847
|
type: 'confirm',
|
|
829
848
|
name: 'shouldInstall',
|
|
830
|
-
message:
|
|
849
|
+
message: (0, i18n_1.t)('AI 开发缺少 qwen code 依赖,是否安装? {{hint}}', { hint: (0, const_1.getBooleanHint)(true) })
|
|
831
850
|
}
|
|
832
851
|
]);
|
|
833
852
|
if (shouldInstall) {
|
|
834
853
|
yield this.executeCommand('npm', ['install', '-g', '@qwen-code/qwen-code'], process.env, log);
|
|
835
|
-
log.info('✅ qwen code 安装完成');
|
|
854
|
+
log.info((0, i18n_1.t)('✅ qwen code 安装完成'));
|
|
836
855
|
}
|
|
837
856
|
else {
|
|
838
|
-
log.info('❌ qwen code 未安装,请手动安装');
|
|
857
|
+
log.info((0, i18n_1.t)('❌ qwen code 未安装,请手动安装'));
|
|
839
858
|
process.exit(1);
|
|
840
859
|
}
|
|
841
860
|
}
|
|
@@ -878,10 +897,12 @@ class AICommandRouter {
|
|
|
878
897
|
token: credential.token
|
|
879
898
|
});
|
|
880
899
|
if (!accessToken.access_token) {
|
|
881
|
-
log.error(
|
|
900
|
+
log.error((0, i18n_1.t)('获取云开发 Access Token 失败,请运行 tcb login 后再重试,{{token}}', {
|
|
901
|
+
token: JSON.stringify(accessToken)
|
|
902
|
+
}));
|
|
882
903
|
process.exit(1);
|
|
883
904
|
}
|
|
884
|
-
const baseUrl =
|
|
905
|
+
const baseUrl = `${(0, url_1.getGatewayUrl)(envId)}/v1/ai/${provider}`;
|
|
885
906
|
const apiKey = accessToken.access_token;
|
|
886
907
|
const codexArgs = [
|
|
887
908
|
'--config',
|
|
@@ -908,23 +929,23 @@ class AICommandRouter {
|
|
|
908
929
|
ensureCursor(log) {
|
|
909
930
|
return __awaiter(this, void 0, void 0, function* () {
|
|
910
931
|
if (yield this.isToolAvailable('cursor-agent')) {
|
|
911
|
-
log.debug('Cursor CLI 已安装!');
|
|
932
|
+
log.debug((0, i18n_1.t)('Cursor CLI 已安装!'));
|
|
912
933
|
}
|
|
913
934
|
else {
|
|
914
935
|
const { shouldInstall } = yield inquirer_1.default.prompt([
|
|
915
936
|
{
|
|
916
937
|
type: 'confirm',
|
|
917
938
|
name: 'shouldInstall',
|
|
918
|
-
message:
|
|
939
|
+
message: (0, i18n_1.t)('AI 开发缺少 Cursor CLI 依赖,是否安装? {{hint}}', { hint: (0, const_1.getBooleanHint)(true) })
|
|
919
940
|
}
|
|
920
941
|
]);
|
|
921
942
|
if (shouldInstall) {
|
|
922
|
-
log.info('正在安装 Cursor CLI...');
|
|
943
|
+
log.info((0, i18n_1.t)('正在安装 Cursor CLI...'));
|
|
923
944
|
yield this.executeCommand('sh', ['-c', 'curl https://cursor.com/install -fsS | bash'], process.env, log);
|
|
924
|
-
log.info('✅ Cursor CLI 安装完成');
|
|
945
|
+
log.info((0, i18n_1.t)('✅ Cursor CLI 安装完成'));
|
|
925
946
|
}
|
|
926
947
|
else {
|
|
927
|
-
log.info('❌ Cursor CLI 未安装,请手动安装');
|
|
948
|
+
log.info((0, i18n_1.t)('❌ Cursor CLI 未安装,请手动安装'));
|
|
928
949
|
process.exit(1);
|
|
929
950
|
}
|
|
930
951
|
}
|
|
@@ -933,22 +954,22 @@ class AICommandRouter {
|
|
|
933
954
|
ensureCodexCode(log) {
|
|
934
955
|
return __awaiter(this, void 0, void 0, function* () {
|
|
935
956
|
if (yield this.isToolAvailable('codex')) {
|
|
936
|
-
log.debug('codex 已安装!');
|
|
957
|
+
log.debug((0, i18n_1.t)('codex 已安装!'));
|
|
937
958
|
}
|
|
938
959
|
else {
|
|
939
960
|
const { shouldInstall } = yield inquirer_1.default.prompt([
|
|
940
961
|
{
|
|
941
962
|
type: 'confirm',
|
|
942
963
|
name: 'shouldInstall',
|
|
943
|
-
message:
|
|
964
|
+
message: (0, i18n_1.t)('AI 开发缺少 codex 依赖,是否安装? {{hint}}', { hint: (0, const_1.getBooleanHint)(true) })
|
|
944
965
|
}
|
|
945
966
|
]);
|
|
946
967
|
if (shouldInstall) {
|
|
947
968
|
yield this.executeCommand('npm', ['install', '-g', '@openai/codex'], process.env, log);
|
|
948
|
-
log.info('✅ codex 安装完成');
|
|
969
|
+
log.info((0, i18n_1.t)('✅ codex 安装完成'));
|
|
949
970
|
}
|
|
950
971
|
else {
|
|
951
|
-
log.info('❌ codex 未安装,请手动安装');
|
|
972
|
+
log.info((0, i18n_1.t)('❌ codex 未安装,请手动安装'));
|
|
952
973
|
process.exit(1);
|
|
953
974
|
}
|
|
954
975
|
}
|
|
@@ -978,10 +999,12 @@ class AICommandRouter {
|
|
|
978
999
|
token: credential.token
|
|
979
1000
|
});
|
|
980
1001
|
if (!accessToken.access_token) {
|
|
981
|
-
log.error(
|
|
1002
|
+
log.error((0, i18n_1.t)('获取云开发 Access Token 失败,请运行 tcb login 后再重试,{{token}}', {
|
|
1003
|
+
token: JSON.stringify(accessToken)
|
|
1004
|
+
}));
|
|
982
1005
|
process.exit(1);
|
|
983
1006
|
}
|
|
984
|
-
const baseUrl =
|
|
1007
|
+
const baseUrl = `${(0, url_1.getGatewayUrl)(envId)}/v1/ai/${provider}`;
|
|
985
1008
|
const apiKey = accessToken.access_token;
|
|
986
1009
|
const aiderArgs = ['--model', `openai/${model}`, ...additionalArgs];
|
|
987
1010
|
const env = Object.assign(Object.assign({}, process.env), { OPENAI_API_KEY: apiKey, OPENAI_API_BASE: baseUrl });
|
|
@@ -991,18 +1014,18 @@ class AICommandRouter {
|
|
|
991
1014
|
ensureAider(log) {
|
|
992
1015
|
return __awaiter(this, void 0, void 0, function* () {
|
|
993
1016
|
if (yield this.isToolAvailable('aider')) {
|
|
994
|
-
log.debug('aider 已安装!');
|
|
1017
|
+
log.debug((0, i18n_1.t)('aider 已安装!'));
|
|
995
1018
|
}
|
|
996
1019
|
else {
|
|
997
1020
|
const { shouldInstall } = yield inquirer_1.default.prompt([
|
|
998
1021
|
{
|
|
999
1022
|
type: 'confirm',
|
|
1000
1023
|
name: 'shouldInstall',
|
|
1001
|
-
message:
|
|
1024
|
+
message: (0, i18n_1.t)('AI 开发缺少 aider 依赖,是否安装? {{hint}}', { hint: (0, const_1.getBooleanHint)(true) })
|
|
1002
1025
|
}
|
|
1003
1026
|
]);
|
|
1004
1027
|
if (shouldInstall) {
|
|
1005
|
-
log.info('正在安装 aider...');
|
|
1028
|
+
log.info((0, i18n_1.t)('正在安装 aider...'));
|
|
1006
1029
|
const platform = process.platform;
|
|
1007
1030
|
if (platform === 'win32') {
|
|
1008
1031
|
yield this.executeCommand('powershell', ['-c', 'irm https://aider.chat/install.ps1 | iex'], process.env, log);
|
|
@@ -1010,10 +1033,10 @@ class AICommandRouter {
|
|
|
1010
1033
|
else {
|
|
1011
1034
|
yield this.executeCommand('sh', ['-c', 'curl -LsSf https://aider.chat/install.sh | sh'], process.env, log);
|
|
1012
1035
|
}
|
|
1013
|
-
log.info('✅ aider 安装完成');
|
|
1036
|
+
log.info((0, i18n_1.t)('✅ aider 安装完成'));
|
|
1014
1037
|
}
|
|
1015
1038
|
else {
|
|
1016
|
-
log.info('❌ aider 未安装,请手动安装');
|
|
1039
|
+
log.info((0, i18n_1.t)('❌ aider 未安装,请手动安装'));
|
|
1017
1040
|
process.exit(1);
|
|
1018
1041
|
}
|
|
1019
1042
|
}
|
|
@@ -1024,7 +1047,7 @@ class AICommandRouter {
|
|
|
1024
1047
|
const fs = yield Promise.resolve().then(() => __importStar(require('fs-extra')));
|
|
1025
1048
|
const path = yield Promise.resolve().then(() => __importStar(require('path')));
|
|
1026
1049
|
try {
|
|
1027
|
-
log.info('🔧 正在修改 MCP 配置文件...');
|
|
1050
|
+
log.info((0, i18n_1.t)('🔧 正在修改 MCP 配置文件...'));
|
|
1028
1051
|
for (const [, files] of Object.entries(IDE_FILE_MAPPINGS)) {
|
|
1029
1052
|
for (const descriptor of files) {
|
|
1030
1053
|
if (!descriptor.isMcpConfig)
|
|
@@ -1041,10 +1064,10 @@ class AICommandRouter {
|
|
|
1041
1064
|
}
|
|
1042
1065
|
}
|
|
1043
1066
|
}
|
|
1044
|
-
log.info('✅ MCP 配置文件修改完成');
|
|
1067
|
+
log.info((0, i18n_1.t)('✅ MCP 配置文件修改完成'));
|
|
1045
1068
|
}
|
|
1046
1069
|
catch (error) {
|
|
1047
|
-
log.warn(
|
|
1070
|
+
log.warn((0, i18n_1.t)('⚠️ MCP 配置文件修改失败: {{error}}', { error: error.message }));
|
|
1048
1071
|
}
|
|
1049
1072
|
});
|
|
1050
1073
|
}
|
|
@@ -1073,7 +1096,7 @@ class AICommandRouter {
|
|
|
1073
1096
|
INTEGRATION_IDE: process.env.INTEGRATION_IDE || 'CloudBaseCLI'
|
|
1074
1097
|
};
|
|
1075
1098
|
modified = true;
|
|
1076
|
-
log.debug(
|
|
1099
|
+
log.debug((0, i18n_1.t)('修改配置文件 {{filePath}}: npx -> cloudbase-mcp', { filePath }));
|
|
1077
1100
|
}
|
|
1078
1101
|
}
|
|
1079
1102
|
for (const [key, value] of Object.entries(result)) {
|
|
@@ -1084,11 +1107,11 @@ class AICommandRouter {
|
|
|
1084
1107
|
const modifiedConfig = modifyCommands(config);
|
|
1085
1108
|
if (modified) {
|
|
1086
1109
|
yield fs.writeJson(filePath, modifiedConfig, { spaces: 2 });
|
|
1087
|
-
log.debug(
|
|
1110
|
+
log.debug((0, i18n_1.t)('✅ 已修改 {{filePath}}', { filePath }));
|
|
1088
1111
|
}
|
|
1089
1112
|
}
|
|
1090
1113
|
catch (error) {
|
|
1091
|
-
log.warn(
|
|
1114
|
+
log.warn((0, i18n_1.t)('⚠️ 修改配置文件 {{filePath}} 失败: {{error}}', { filePath, error: error.message }));
|
|
1092
1115
|
}
|
|
1093
1116
|
});
|
|
1094
1117
|
}
|
|
@@ -1117,7 +1140,7 @@ class AICommandRouter {
|
|
|
1117
1140
|
INTEGRATION_IDE: process.env.INTEGRATION_IDE || 'CloudBaseCLI'
|
|
1118
1141
|
};
|
|
1119
1142
|
modified = true;
|
|
1120
|
-
log.debug(
|
|
1143
|
+
log.debug((0, i18n_1.t)('修改配置文件 {{filePath}}: npx -> cloudbase-mcp', { filePath }));
|
|
1121
1144
|
}
|
|
1122
1145
|
}
|
|
1123
1146
|
for (const [key, value] of Object.entries(result)) {
|
|
@@ -1129,11 +1152,11 @@ class AICommandRouter {
|
|
|
1129
1152
|
if (modified) {
|
|
1130
1153
|
const tomlString = this.objectToToml(modifiedConfig);
|
|
1131
1154
|
yield fs.writeFile(filePath, tomlString, 'utf-8');
|
|
1132
|
-
log.debug(
|
|
1155
|
+
log.debug((0, i18n_1.t)('✅ 已修改 {{filePath}}', { filePath }));
|
|
1133
1156
|
}
|
|
1134
1157
|
}
|
|
1135
1158
|
catch (error) {
|
|
1136
|
-
log.warn(
|
|
1159
|
+
log.warn((0, i18n_1.t)('⚠️ 修改配置文件 {{filePath}} 失败: {{error}}', { filePath, error: error.message }));
|
|
1137
1160
|
}
|
|
1138
1161
|
});
|
|
1139
1162
|
}
|
|
@@ -1227,23 +1250,23 @@ class AICommandRouter {
|
|
|
1227
1250
|
ensureCodebuddy(log) {
|
|
1228
1251
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1229
1252
|
if (yield this.isToolAvailable('codebuddy')) {
|
|
1230
|
-
log.debug('codebuddy 已安装!');
|
|
1253
|
+
log.debug((0, i18n_1.t)('codebuddy 已安装!'));
|
|
1231
1254
|
}
|
|
1232
1255
|
else {
|
|
1233
1256
|
const { shouldInstall } = yield inquirer_1.default.prompt([
|
|
1234
1257
|
{
|
|
1235
1258
|
type: 'confirm',
|
|
1236
1259
|
name: 'shouldInstall',
|
|
1237
|
-
message:
|
|
1260
|
+
message: (0, i18n_1.t)('AI 开发缺少 codebuddy 依赖,是否安装? {{hint}}', { hint: (0, const_1.getBooleanHint)(true) })
|
|
1238
1261
|
}
|
|
1239
1262
|
]);
|
|
1240
1263
|
if (shouldInstall) {
|
|
1241
1264
|
yield this.executeCommand('npm', ['install', '-g', '@tencent-ai/codebuddy-code'], process.env, log);
|
|
1242
|
-
log.info('✅ codebuddy 安装完成');
|
|
1265
|
+
log.info((0, i18n_1.t)('✅ codebuddy 安装完成'));
|
|
1243
1266
|
}
|
|
1244
1267
|
else {
|
|
1245
|
-
log.info('❌ codebuddy 未安装,请手动安装');
|
|
1246
|
-
log.info('📦 安装命令: npm install -g @tencent-ai/codebuddy-code');
|
|
1268
|
+
log.info((0, i18n_1.t)('❌ codebuddy 未安装,请手动安装'));
|
|
1269
|
+
log.info((0, i18n_1.t)('📦 安装命令: npm install -g @tencent-ai/codebuddy-code'));
|
|
1247
1270
|
process.exit(1);
|
|
1248
1271
|
}
|
|
1249
1272
|
}
|