@cloudbase/cli 2.9.10 → 2.9.12
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/dist/standalone/ccr.js +78668 -0
- package/dist/standalone/cli.js +627712 -0
- package/lib/commands/ai/index.js +7 -2
- package/lib/i18n/index.js +7 -15
- package/lib/utils/ai/router.js +46 -24
- package/locales/index.js +9 -0
- package/package.json +1 -1
- package/tsconfig.json +2 -1
- package/types/utils/ai/router.d.ts +2 -1
- package/cloudbase-cli-2.7.8.tgz +0 -0
package/lib/commands/ai/index.js
CHANGED
|
@@ -65,6 +65,10 @@ let AICommand = class AICommand extends common_1.Command {
|
|
|
65
65
|
{
|
|
66
66
|
flags: '--template <template>',
|
|
67
67
|
desc: (0, i18n_1.t)('指定模板类型 (miniprogram, react, vue, uniapp, rules)')
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
flags: '-y, --yes',
|
|
71
|
+
desc: (0, i18n_1.t)('自动设置默认模板规则')
|
|
68
72
|
}
|
|
69
73
|
],
|
|
70
74
|
desc: (0, i18n_1.t)('CloudBase AI ToolKit CLI - 快速启动和配置主流 AI 编程工具\n\n示例:\n tcb ai -a claude -- --continue\n tcb ai -a codebuddy -- mcp list\n\n说明:-- 后的参数会直接传递给目标 AI CLI。'),
|
|
@@ -76,7 +80,7 @@ let AICommand = class AICommand extends common_1.Command {
|
|
|
76
80
|
execute(options, ctx, log) {
|
|
77
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
82
|
yield (0, ensureFiles_1.ensureFiles)();
|
|
79
|
-
const { envId, setup, config, reset, template } = options;
|
|
83
|
+
const { envId, setup, config, reset, template, yes: useDefaultConfig } = options;
|
|
80
84
|
let { agent } = options;
|
|
81
85
|
try {
|
|
82
86
|
yield (0, banner_1.showBanner)(log);
|
|
@@ -104,7 +108,8 @@ let AICommand = class AICommand extends common_1.Command {
|
|
|
104
108
|
log,
|
|
105
109
|
agent: agent || (yield configManager.loadConfig()).defaultAgent,
|
|
106
110
|
envId,
|
|
107
|
-
template
|
|
111
|
+
template,
|
|
112
|
+
useDefaultConfig
|
|
108
113
|
});
|
|
109
114
|
}
|
|
110
115
|
catch (error) {
|
package/lib/i18n/index.js
CHANGED
|
@@ -4,19 +4,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.isIntl = exports.getLanguage = exports.t = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
7
|
const os_locale_1 = __importDefault(require("os-locale"));
|
|
10
8
|
const db_1 = require("../utils/store/db");
|
|
9
|
+
const locales_1 = require("../../locales");
|
|
11
10
|
let i18n;
|
|
11
|
+
const LANG_DATA = {
|
|
12
|
+
zh: locales_1.zh,
|
|
13
|
+
en: locales_1.en
|
|
14
|
+
};
|
|
12
15
|
const configDB = (0, db_1.getSyncDB)('config');
|
|
13
16
|
const AVAILABLE_LANGS = ['zh', 'en'];
|
|
14
17
|
class I18n {
|
|
15
18
|
constructor() {
|
|
16
19
|
this.lang = getLanguage();
|
|
20
|
+
this.mapping = locales_1.mappingData;
|
|
17
21
|
if (this.lang !== 'zh') {
|
|
18
|
-
this.
|
|
19
|
-
this.loadMapping();
|
|
22
|
+
this.data = LANG_DATA[this.lang];
|
|
20
23
|
}
|
|
21
24
|
}
|
|
22
25
|
t(key, options) {
|
|
@@ -29,11 +32,6 @@ class I18n {
|
|
|
29
32
|
}
|
|
30
33
|
return key;
|
|
31
34
|
}
|
|
32
|
-
loadLanguage() {
|
|
33
|
-
const langPath = path_1.default.resolve(I18n.langDir, `${this.lang}.json`);
|
|
34
|
-
const langData = fs_1.default.readFileSync(langPath, 'utf-8');
|
|
35
|
-
this.data = JSON.parse(langData);
|
|
36
|
-
}
|
|
37
35
|
replaceVars(str, vars) {
|
|
38
36
|
let result = str;
|
|
39
37
|
if (!vars) {
|
|
@@ -44,13 +42,7 @@ class I18n {
|
|
|
44
42
|
});
|
|
45
43
|
return result;
|
|
46
44
|
}
|
|
47
|
-
loadMapping() {
|
|
48
|
-
const mappingPath = path_1.default.resolve(__dirname, '../../locales/mapping.json');
|
|
49
|
-
const mappingStr = fs_1.default.readFileSync(mappingPath, 'utf-8');
|
|
50
|
-
this.mapping = JSON.parse(mappingStr);
|
|
51
|
-
}
|
|
52
45
|
}
|
|
53
|
-
I18n.langDir = path_1.default.resolve(__dirname, '../../locales/langs');
|
|
54
46
|
function t(key, options) {
|
|
55
47
|
if (!i18n) {
|
|
56
48
|
i18n = new I18n();
|
package/lib/utils/ai/router.js
CHANGED
|
@@ -103,7 +103,7 @@ class AICommandRouter {
|
|
|
103
103
|
constructor() {
|
|
104
104
|
this.configManager = new config_1.AIConfigManager();
|
|
105
105
|
}
|
|
106
|
-
execute({ agent, addtionalArgs, log, template }) {
|
|
106
|
+
execute({ agent, addtionalArgs, log, template, useDefaultConfig }) {
|
|
107
107
|
var _a;
|
|
108
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
109
|
if ((0, config_1.isValidAgent)(agent) !== true) {
|
|
@@ -123,7 +123,7 @@ class AICommandRouter {
|
|
|
123
123
|
}
|
|
124
124
|
log.info((0, i18n_1.t)('🚀 启动 {{agent}} AI CLI 工具', { agent: chalk_1.default.bold(agentUpperCased) }));
|
|
125
125
|
try {
|
|
126
|
-
yield this.checkToolkitConfig(agent, log, template);
|
|
126
|
+
yield this.checkToolkitConfig({ agent, log, template, useDefaultConfig });
|
|
127
127
|
}
|
|
128
128
|
catch (e) {
|
|
129
129
|
log.warn((0, i18n_1.t)('⚠️ 云开发功能检查失败,但 AI 工具仍可正常使用'));
|
|
@@ -136,8 +136,9 @@ class AICommandRouter {
|
|
|
136
136
|
this.executeAgentWithConfig(agent, agentConfig, this.parseArgs(addtionalArgs), log);
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
checkToolkitConfig(
|
|
139
|
+
checkToolkitConfig(checkOptions) {
|
|
140
140
|
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
const { agent, log, template, useDefaultConfig } = checkOptions;
|
|
141
142
|
const { missingFiles } = yield this.configManager.checkToolkitConfig(agent);
|
|
142
143
|
if (missingFiles.length > 0) {
|
|
143
144
|
const skipTemplate = yield this.checkSkipTemplateConfig();
|
|
@@ -146,7 +147,7 @@ class AICommandRouter {
|
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
149
|
log.log('');
|
|
149
|
-
yield this.downloadTemplate(log, template);
|
|
150
|
+
yield this.downloadTemplate({ log, template, agent, useDefaultConfig });
|
|
150
151
|
log.log('');
|
|
151
152
|
}
|
|
152
153
|
});
|
|
@@ -176,31 +177,37 @@ class AICommandRouter {
|
|
|
176
177
|
}
|
|
177
178
|
});
|
|
178
179
|
}
|
|
179
|
-
downloadTemplate(
|
|
180
|
+
downloadTemplate(options) {
|
|
180
181
|
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
const { log, template, agent, useDefaultConfig } = options;
|
|
181
183
|
try {
|
|
182
184
|
let templateType;
|
|
183
185
|
if (template) {
|
|
184
186
|
templateType = template;
|
|
185
187
|
}
|
|
186
188
|
else {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
189
|
+
if (useDefaultConfig) {
|
|
190
|
+
templateType = 'rules';
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
const { templateType: selectedType } = yield inquirer_1.default.prompt([
|
|
194
|
+
{
|
|
195
|
+
type: 'list',
|
|
196
|
+
name: 'templateType',
|
|
197
|
+
message: (0, i18n_1.t)('下载模板以获取完整的开发体验: {{hint}}', { hint: const_1.LIST_HINT }),
|
|
198
|
+
choices: [
|
|
199
|
+
{ name: (0, i18n_1.t)('🟦 微信小程序 + CloudBase'), value: 'miniprogram' },
|
|
200
|
+
{ name: (0, i18n_1.t)('🚀 Web 应用 - React + CloudBase'), value: 'react' },
|
|
201
|
+
{ name: (0, i18n_1.t)('🟢 Web 应用 - Vue + CloudBase'), value: 'vue' },
|
|
202
|
+
{ name: (0, i18n_1.t)('🌈 跨端应用 - UniApp + CloudBase'), value: 'uniapp' },
|
|
203
|
+
{ name: (0, i18n_1.t)('🧩 只下载 AI 规则和配置'), value: 'rules' },
|
|
204
|
+
{ name: (0, i18n_1.t)('🚫 不下载模板'), value: 'none' }
|
|
205
|
+
],
|
|
206
|
+
default: 'miniprogram'
|
|
207
|
+
}
|
|
208
|
+
]);
|
|
209
|
+
templateType = selectedType;
|
|
210
|
+
}
|
|
204
211
|
}
|
|
205
212
|
if (templateType === 'none') {
|
|
206
213
|
log.info((0, i18n_1.t)('🚫 跳过模板下载'));
|
|
@@ -208,7 +215,7 @@ class AICommandRouter {
|
|
|
208
215
|
return;
|
|
209
216
|
}
|
|
210
217
|
log.info((0, i18n_1.t)('📦 正在下载并解压 {{templateType}} 模板...', { templateType }));
|
|
211
|
-
yield this.downloadAndExtractTemplate(templateType, log);
|
|
218
|
+
yield this.downloadAndExtractTemplate({ templateType, log, agent: agent, useDefaultConfig: useDefaultConfig || false });
|
|
212
219
|
log.info((0, i18n_1.t)('✅ {{templateType}} 模板配置完成', { templateType }));
|
|
213
220
|
}
|
|
214
221
|
catch (error) {
|
|
@@ -217,7 +224,7 @@ class AICommandRouter {
|
|
|
217
224
|
}
|
|
218
225
|
});
|
|
219
226
|
}
|
|
220
|
-
downloadAndExtractTemplate(
|
|
227
|
+
downloadAndExtractTemplate(options) {
|
|
221
228
|
var _a, e_1, _b, _c;
|
|
222
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
223
230
|
const fs = yield Promise.resolve().then(() => __importStar(require('fs-extra')));
|
|
@@ -226,6 +233,7 @@ class AICommandRouter {
|
|
|
226
233
|
const unzipper = yield Promise.resolve().then(() => __importStar(require('unzipper')));
|
|
227
234
|
const https = yield Promise.resolve().then(() => __importStar(require('https')));
|
|
228
235
|
let ConfigParser;
|
|
236
|
+
const { templateType, log, agent, useDefaultConfig } = options;
|
|
229
237
|
try {
|
|
230
238
|
ConfigParser = (yield Promise.resolve().then(() => __importStar(require('@cloudbase/toolbox')))).ConfigParser;
|
|
231
239
|
}
|
|
@@ -275,6 +283,7 @@ class AICommandRouter {
|
|
|
275
283
|
});
|
|
276
284
|
const extractDir = process.cwd();
|
|
277
285
|
const zipStream = fs.createReadStream(zipPath).pipe(unzipper.Parse({ forceStream: true }));
|
|
286
|
+
const agentDirs = ['.claude', '.codex', '.qwen', '.codebuddy', '.cursor'];
|
|
278
287
|
try {
|
|
279
288
|
for (var _e = true, _f = __asyncValues(zipStream), _g; _g = yield _f.next(), _a = _g.done, !_a;) {
|
|
280
289
|
_c = _g.value;
|
|
@@ -283,6 +292,15 @@ class AICommandRouter {
|
|
|
283
292
|
const entry = _c;
|
|
284
293
|
const entryPath = entry.path;
|
|
285
294
|
const destPath = path.join(extractDir, entryPath);
|
|
295
|
+
if (useDefaultConfig && agent) {
|
|
296
|
+
const currentAgentDir = `.${agent}`;
|
|
297
|
+
const isAgentDir = agentDirs.some(dir => entryPath.startsWith(dir + '/') || entryPath === dir);
|
|
298
|
+
if (isAgentDir && !entryPath.startsWith(currentAgentDir + '/') && entryPath !== currentAgentDir) {
|
|
299
|
+
log.debug && log.debug((0, i18n_1.t)('跳过不匹配的 agent 目录: {{entryPath}} (当前 agent: {{agent}})', { entryPath, agent }));
|
|
300
|
+
entry.autodrain();
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
286
304
|
if (entry.type === 'Directory') {
|
|
287
305
|
yield fs.ensureDir(destPath);
|
|
288
306
|
entry.autodrain();
|
|
@@ -327,6 +345,10 @@ class AICommandRouter {
|
|
|
327
345
|
continue;
|
|
328
346
|
}
|
|
329
347
|
if (yield fs.pathExists(destPath)) {
|
|
348
|
+
if (useDefaultConfig) {
|
|
349
|
+
entry.autodrain();
|
|
350
|
+
continue;
|
|
351
|
+
}
|
|
330
352
|
const { confirmOverwriteFile } = yield inquirer_1.default.prompt([
|
|
331
353
|
{
|
|
332
354
|
type: 'confirm',
|
package/locales/index.js
ADDED
package/package.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -5,11 +5,12 @@ interface IExecute {
|
|
|
5
5
|
addtionalArgs: string[];
|
|
6
6
|
log: Logger;
|
|
7
7
|
template?: string;
|
|
8
|
+
useDefaultConfig?: boolean;
|
|
8
9
|
}
|
|
9
10
|
export declare class AICommandRouter {
|
|
10
11
|
private configManager;
|
|
11
12
|
constructor();
|
|
12
|
-
execute({ agent, addtionalArgs, log, template }: IExecute): Promise<void>;
|
|
13
|
+
execute({ agent, addtionalArgs, log, template, useDefaultConfig }: IExecute): Promise<void>;
|
|
13
14
|
private checkToolkitConfig;
|
|
14
15
|
private checkSkipTemplateConfig;
|
|
15
16
|
private saveSkipTemplateConfig;
|
package/cloudbase-cli-2.7.8.tgz
DELETED
|
Binary file
|