@cloudbase/cli 2.8.0-beta.4 → 2.8.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.augment-guidelines +119 -0
  2. package/.clinerules/cloudbase-rules.mdc +119 -0
  3. package/.cursor/rules/cloudbase-rules.mdc +119 -0
  4. package/.mcp.json +11 -0
  5. package/CLAUDE.md +119 -0
  6. package/README.md +13 -1
  7. package/bin/cloudbase-mcp.js +24 -0
  8. package/bin/tcb.js +0 -2
  9. package/cloudbaserc.json +3 -0
  10. package/lib/commands/ai/index.js +172 -0
  11. package/lib/commands/cloudrun/base.js +2 -2
  12. package/lib/commands/index.js +1 -0
  13. package/lib/commands/utils.js +10 -4
  14. package/lib/utils/ai/banner.js +88 -0
  15. package/lib/utils/ai/config.js +254 -0
  16. package/lib/utils/ai/const.js +150 -0
  17. package/lib/utils/ai/ensureFiles.js +26 -0
  18. package/lib/utils/ai/envLocalManager.js +144 -0
  19. package/lib/utils/ai/router.js +1089 -0
  20. package/lib/utils/ai/setup.js +550 -0
  21. package/package.json +11 -3
  22. package/rules/cloudbase-platform.mdc +44 -0
  23. package/rules/database.mdc +25 -0
  24. package/rules/miniprogram-development.mdc +61 -0
  25. package/rules/ui-design.mdc +24 -0
  26. package/rules/web-development.mdc +44 -0
  27. package/rules/workflows.mdc +30 -0
  28. package/specs/ai-cli-bootstrap/QWEN.md +196 -0
  29. package/specs/ai-cli-bootstrap/design.md +185 -0
  30. package/specs/ai-cli-bootstrap/requirements.md +51 -0
  31. package/specs/ai-cli-bootstrap/tasks.md +70 -0
  32. package/specs/ai-cli-bootstrap/technical-docs.md +421 -0
  33. package/specs/mcp-global-bin/design.md +57 -0
  34. package/specs/mcp-global-bin/requirements.md +43 -0
  35. package/specs/mcp-global-bin/tasks.md +54 -0
  36. package/types/commands/ai/index.d.ts +23 -0
  37. package/types/commands/index.d.ts +1 -0
  38. package/types/commands/utils.d.ts +6 -0
  39. package/types/utils/ai/banner.d.ts +2 -0
  40. package/types/utils/ai/config.d.ts +79 -0
  41. package/types/utils/ai/const.d.ts +323 -0
  42. package/types/utils/ai/ensureFiles.d.ts +1 -0
  43. package/types/utils/ai/envLocalManager.d.ts +23 -0
  44. package/types/utils/ai/router.d.ts +45 -0
  45. package/types/utils/ai/setup.d.ts +23 -0
  46. package/types/utils/config.d.ts +1 -0
@@ -0,0 +1,172 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.AICommand = void 0;
25
+ const common_1 = require("../common");
26
+ const decorators_1 = require("../../decorators");
27
+ const log_1 = require("../../utils/log");
28
+ const config_1 = require("../../utils/ai/config");
29
+ const router_1 = require("../../utils/ai/router");
30
+ const setup_1 = require("../../utils/ai/setup");
31
+ const report_1 = require("../../utils/report");
32
+ const error_1 = require("../../error");
33
+ const banner_1 = require("../../utils/ai/banner");
34
+ const ensureFiles_1 = require("../../utils/ai/ensureFiles");
35
+ let AICommand = class AICommand extends common_1.Command {
36
+ get options() {
37
+ return {
38
+ cmd: 'ai',
39
+ options: [
40
+ {
41
+ flags: '-a, --agent <agent>',
42
+ desc: 'AI CLI 工具 (claude, qwen, codex, aider)'
43
+ },
44
+ {
45
+ flags: '-e, --envId <envId>',
46
+ desc: '云开发环境 ID'
47
+ },
48
+ {
49
+ flags: '--setup',
50
+ desc: '运行配置向导'
51
+ },
52
+ {
53
+ flags: '--config',
54
+ desc: '显示配置信息'
55
+ },
56
+ {
57
+ flags: '--reset',
58
+ desc: '重置配置'
59
+ }
60
+ ],
61
+ desc: 'CloudBase AI ToolKit CLI - 快速启动和配置主流 AI 编程工具\n\n示例:\n tcb ai -a claude -- --continue\n\n说明:-- 后的参数会直接传递给目标 AI CLI。',
62
+ requiredEnvId: false,
63
+ withoutAuth: true,
64
+ allowUnknownOption: true
65
+ };
66
+ }
67
+ execute(options, ctx, log) {
68
+ return __awaiter(this, void 0, void 0, function* () {
69
+ yield (0, ensureFiles_1.ensureFiles)();
70
+ const { envId, setup, config, reset } = options;
71
+ let { agent } = options;
72
+ try {
73
+ yield (0, banner_1.showBanner)(log);
74
+ yield reportAIUsage(agent, Boolean(envId), this.getSubCommand(ctx.params));
75
+ const configManager = new config_1.AIConfigManager();
76
+ if (reset) {
77
+ return yield this.resetConfig(configManager, log);
78
+ }
79
+ if (setup) {
80
+ const wizard = new setup_1.AISetupWizard(envId);
81
+ return yield wizard.setUp(log);
82
+ }
83
+ if (config) {
84
+ return yield this.showConfig(configManager, log);
85
+ }
86
+ if (!(yield configManager.isConfigured())) {
87
+ log.info('AI 功能未配置,正在启动配置向导...');
88
+ const wizard = new setup_1.AISetupWizard(envId);
89
+ const { defaultAgent } = yield wizard.setUpDefault(log);
90
+ agent = defaultAgent;
91
+ }
92
+ const args = this.parseArgs();
93
+ const router = new router_1.AICommandRouter();
94
+ yield router.execute({
95
+ addtionalArgs: args,
96
+ log,
97
+ agent: agent || (yield configManager.loadConfig()).defaultAgent,
98
+ envId
99
+ });
100
+ }
101
+ catch (error) {
102
+ yield reportAIError(agent, error.message);
103
+ throw error;
104
+ }
105
+ });
106
+ }
107
+ resetConfig(configManager, log) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ try {
110
+ yield configManager.resetConfig();
111
+ log.info('✅ AI 配置已重置');
112
+ }
113
+ catch (error) {
114
+ throw new error_1.CloudBaseError('重置配置失败', { original: error });
115
+ }
116
+ });
117
+ }
118
+ showConfig(configManager, log) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ try {
121
+ const aiConfig = yield configManager.loadConfig();
122
+ log.info('当前 AI 配置:');
123
+ log.info(JSON.stringify(aiConfig, null, 2));
124
+ }
125
+ catch (error) {
126
+ if (error instanceof error_1.CloudBaseError && error.code === config_1.CONFIG_NOT_FOUND) {
127
+ log.error(error.message);
128
+ }
129
+ else {
130
+ throw new error_1.CloudBaseError('读取配置失败', { original: error });
131
+ }
132
+ }
133
+ });
134
+ }
135
+ parseArgs() {
136
+ const args = process.argv.slice(2);
137
+ const doubleDashIndex = args.indexOf('--');
138
+ if (doubleDashIndex !== -1) {
139
+ return args.slice(doubleDashIndex + 1);
140
+ }
141
+ return [];
142
+ }
143
+ getSubCommand(params) {
144
+ return params.length > 0 ? params[0] : 'default';
145
+ }
146
+ };
147
+ __decorate([
148
+ (0, decorators_1.InjectParams)(),
149
+ __param(0, (0, decorators_1.ArgsOptions)()),
150
+ __param(1, (0, decorators_1.CmdContext)()),
151
+ __param(2, (0, decorators_1.Log)()),
152
+ __metadata("design:type", Function),
153
+ __metadata("design:paramtypes", [Object, Object, log_1.Logger]),
154
+ __metadata("design:returntype", Promise)
155
+ ], AICommand.prototype, "execute", null);
156
+ AICommand = __decorate([
157
+ (0, common_1.ICommand)()
158
+ ], AICommand);
159
+ exports.AICommand = AICommand;
160
+ function reportAIUsage(agent, hasEnvId, subCommand) {
161
+ return report_1.beaconAction.report('ai_command_usage', {
162
+ agent,
163
+ hasEnvId,
164
+ subCommand
165
+ });
166
+ }
167
+ function reportAIError(agent, error) {
168
+ return report_1.beaconAction.report('ai_command_error', {
169
+ agent,
170
+ error
171
+ });
172
+ }
@@ -872,8 +872,8 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
872
872
  })
873
873
  .on('start', () => __awaiter(this, void 0, void 0, function* () {
874
874
  logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
875
- if (!nodemonInstance._firstStartDone) {
876
- nodemonInstance._firstStartDone = true;
875
+ if (!process.env.NODEMON_FIRST_START) {
876
+ process.env.NODEMON_FIRST_START = 'true';
877
877
  this.checkAndRunTsc();
878
878
  this.openDebugApp(type, port, envId, agentId, openDebugPanel !== 'false');
879
879
  }
@@ -32,3 +32,4 @@ __exportStar(require("./fun"), exports);
32
32
  __exportStar(require("./runf"), exports);
33
33
  __exportStar(require("./cloudfunction"), exports);
34
34
  __exportStar(require("./cloudrun"), exports);
35
+ __exportStar(require("./ai"), exports);
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getCloudbaserc = exports.upsertCloudbaserc = exports.fetchAccessToken = exports.getCredential = exports.trackCallback = exports.isDirectoryEmptyOrNotExists = exports.getPackageJsonName = exports.selectEnv = void 0;
26
+ exports.getCloudbaserc = exports.upsertCloudbaserc = exports.rawFetchAccessToken = exports.fetchAccessToken = exports.getCredential = exports.trackCallback = exports.isDirectoryEmptyOrNotExists = exports.getPackageJsonName = exports.selectEnv = void 0;
27
27
  const fs_1 = require("@cloudbase/iac-core/lib/src/fs");
28
28
  const signature_nodejs_1 = require("@cloudbase/signature-nodejs");
29
29
  const fs_extra_1 = require("fs-extra");
@@ -115,6 +115,13 @@ function getCredential(ctx, options) {
115
115
  }
116
116
  exports.getCredential = getCredential;
117
117
  function fetchAccessToken(params) {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const result = yield rawFetchAccessToken(params);
120
+ return result === null || result === void 0 ? void 0 : result.access_token;
121
+ });
122
+ }
123
+ exports.fetchAccessToken = fetchAccessToken;
124
+ function rawFetchAccessToken(params) {
118
125
  return __awaiter(this, void 0, void 0, function* () {
119
126
  const { envId, secretId, secretKey, token } = params;
120
127
  const domain = `${envId}.api.tcloudbasegateway.com`;
@@ -144,11 +151,10 @@ function fetchAccessToken(params) {
144
151
  headers: Object.assign(Object.assign({}, requiredHeaders), { Authorization: `${authorization}, Timestamp=${timestamp}, Token=${token}` }),
145
152
  body: JSON.stringify(body)
146
153
  });
147
- const res = yield tokenResponse.json();
148
- return res === null || res === void 0 ? void 0 : res.access_token;
154
+ return tokenResponse.json();
149
155
  });
150
156
  }
151
- exports.fetchAccessToken = fetchAccessToken;
157
+ exports.rawFetchAccessToken = rawFetchAccessToken;
152
158
  function upsertCloudbaserc(projectPath, inputData) {
153
159
  return __awaiter(this, void 0, void 0, function* () {
154
160
  const { envId } = inputData, rest = __rest(inputData, ["envId"]);
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.showBanner = void 0;
39
+ const chalk_1 = __importDefault(require("chalk"));
40
+ function showBanner(log) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ try {
43
+ const figlet = yield Promise.resolve().then(() => __importStar(require('figlet')));
44
+ const data = figlet.textSync(`CloudBase
45
+ AI ToolKit`, {
46
+ font: 'Slant',
47
+ horizontalLayout: 'fitted',
48
+ verticalLayout: 'fitted'
49
+ });
50
+ const supportsColor = process.stdout.isTTY && process.env.TERM !== 'dumb';
51
+ if (supportsColor) {
52
+ try {
53
+ const gradient = yield Promise.resolve().then(() => __importStar(require('gradient-string')));
54
+ const gradientText = gradient
55
+ .default(['cyan', 'rgb(0, 111, 150)', 'rgb(0, 246,136)'])
56
+ .multiline(data);
57
+ log.log(chalk_1.default.bold(gradientText + '\n'));
58
+ }
59
+ catch (gradientError) {
60
+ log.log(chalk_1.default.bold.cyan(data + '\n'));
61
+ }
62
+ }
63
+ else {
64
+ log.log(data + '\n');
65
+ }
66
+ if (supportsColor) {
67
+ log.log(chalk_1.default.hex('#34495E')(' 🚀 统一集成各种 AI CLI 工具,内置云开发全栈能力'));
68
+ log.log(chalk_1.default.hex('#34495E')(' ⚡ 生成、部署和托管全栈 Web 应用与小程序、数据库和后端服务'));
69
+ log.log(chalk_1.default.hex('#34495E')(' 🎯 无需运维,极速上线你的创意 💫'));
70
+ }
71
+ else {
72
+ log.log(' 🚀 统一集成各种 AI CLI 工具,内置云开发全栈能力');
73
+ log.log(' ⚡ 生成、部署和托管全栈 Web 应用与小程序、数据库和后端服务');
74
+ log.log(' 🎯 无需运维,极速上线你的创意 💫');
75
+ }
76
+ log.log('');
77
+ }
78
+ catch (e) {
79
+ log.log(chalk_1.default.bold.cyanBright('⛰︎'), chalk_1.default.bold.hex('#FFFFFF')(' CloudBase AI ToolKit CLI'));
80
+ log.log(chalk_1.default.bold.cyanBright(''));
81
+ log.log(chalk_1.default.hex('#34495E')(' 🚀 统一集成各种 AI CLI 工具,内置云开发全栈能力'));
82
+ log.log(chalk_1.default.hex('#34495E')(' ⚡ 生成、部署和托管全栈 Web 应用与小程序、数据库和后端服务'));
83
+ log.log(chalk_1.default.hex('#34495E')(' 🎯 无需运维,极速上线你的创意 💫'));
84
+ log.log('');
85
+ }
86
+ });
87
+ }
88
+ exports.showBanner = showBanner;
@@ -0,0 +1,254 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AIConfigManager = exports.createConfigParser = exports.TOOLKIT_CONFIGS = exports.isValidAgent = exports.CONFIG_NOT_FOUND = void 0;
16
+ const error_1 = require("../../error");
17
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
+ const envLocalManager_1 = require("./envLocalManager");
19
+ const toolbox_1 = require("@cloudbase/toolbox");
20
+ const const_1 = require("./const");
21
+ exports.CONFIG_NOT_FOUND = 'CONFIG_NOT_FOUND';
22
+ const notFoundError = () => {
23
+ throw new error_1.CloudBaseError('AI 配置未找到,请运行 tcb ai --setup 进行配置', {
24
+ code: exports.CONFIG_NOT_FOUND
25
+ });
26
+ };
27
+ function isValidAgent(agent) {
28
+ return ['claude', 'qwen', 'codex', 'aider'].includes(agent);
29
+ }
30
+ exports.isValidAgent = isValidAgent;
31
+ exports.TOOLKIT_CONFIGS = {
32
+ [const_1.CLAUDE.value]: {
33
+ mcp: '.mcp.json',
34
+ rules: 'CLAUDE.md'
35
+ },
36
+ [const_1.QWEN.value]: {
37
+ config: '.env.local',
38
+ rules: 'QWEN.md'
39
+ },
40
+ [const_1.CODEX.value]: {
41
+ config: '.env.local'
42
+ },
43
+ [const_1.AIDER.value]: {
44
+ config: '.aider.conf.yml'
45
+ }
46
+ };
47
+ function createConfigParser() {
48
+ return new toolbox_1.ConfigParser({ configPath: const_1.CONFIG_PATH });
49
+ }
50
+ exports.createConfigParser = createConfigParser;
51
+ class AIConfigManager {
52
+ constructor() {
53
+ this.envLocalManager = new envLocalManager_1.EnvLocalManager();
54
+ }
55
+ loadConfig() {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ const parser = createConfigParser();
58
+ const config = yield parser.get('ai');
59
+ !config && notFoundError();
60
+ return config;
61
+ });
62
+ }
63
+ isConfigured() {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ try {
66
+ const config = yield this.loadConfig();
67
+ return Object.keys(config.agents).length > 0;
68
+ }
69
+ catch (_a) {
70
+ return false;
71
+ }
72
+ });
73
+ }
74
+ getAgentConfig(agent) {
75
+ return __awaiter(this, void 0, void 0, function* () {
76
+ const config = yield this.loadConfig();
77
+ return config.agents[agent] || null;
78
+ });
79
+ }
80
+ resetConfig() {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ try {
83
+ yield Promise.all([
84
+ new envLocalManager_1.EnvLocalManager().removeAIConfig(),
85
+ createConfigParser().update('ai', {})
86
+ ]);
87
+ }
88
+ catch (error) {
89
+ throw new error_1.CloudBaseError('重置 AI 配置失败,请手动删除 `.env.local`、`cloudbaserc.json` 文件中的 AI 配置部分,或重新运行 tcb ai --setup', { original: error });
90
+ }
91
+ });
92
+ }
93
+ checkToolkitConfig(agent) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ const toolkitConfig = exports.TOOLKIT_CONFIGS[agent];
96
+ if (!toolkitConfig) {
97
+ return { hasConfig: false, hasMcp: false, hasRules: false, missingFiles: [] };
98
+ }
99
+ const results = {
100
+ hasConfig: false,
101
+ hasMcp: false,
102
+ hasRules: false,
103
+ missingFiles: []
104
+ };
105
+ if ('mcp' in toolkitConfig) {
106
+ results.hasMcp = yield fs_extra_1.default.pathExists(toolkitConfig.mcp);
107
+ results.hasConfig = results.hasMcp;
108
+ if (!results.hasMcp) {
109
+ results.missingFiles.push(toolkitConfig.mcp);
110
+ }
111
+ }
112
+ else if ('config' in toolkitConfig) {
113
+ results.hasConfig = yield fs_extra_1.default.pathExists(toolkitConfig.config);
114
+ if (!results.hasConfig) {
115
+ results.missingFiles.push(toolkitConfig.config);
116
+ }
117
+ }
118
+ if (toolkitConfig.rules) {
119
+ results.hasRules = yield fs_extra_1.default.pathExists(toolkitConfig.rules);
120
+ if (!results.hasRules) {
121
+ results.missingFiles.push(toolkitConfig.rules);
122
+ }
123
+ }
124
+ return results;
125
+ });
126
+ }
127
+ updateEnvId(envId) {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ this.updateConfig('envId', envId, 'ENV_ID');
130
+ yield fs_extra_1.default.ensureFile(const_1.CLOUDBASE_MCP_CONFIG_PATH);
131
+ yield fs_extra_1.default.writeJson(const_1.CLOUDBASE_MCP_CONFIG_PATH, {
132
+ envId,
133
+ updatedAt: new Date().toISOString(),
134
+ version: '1.0'
135
+ }, { spaces: 2 });
136
+ });
137
+ }
138
+ updateDefaultAgent(agent) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ const configParser = createConfigParser();
141
+ yield configParser.update('ai.defaultAgent', '{{env.AI_DEFAULT_AGENT}}');
142
+ this.envLocalManager.updateDefaultAgent(agent);
143
+ });
144
+ }
145
+ updateClaudeConfig(type, config) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ yield this.updateConfig('ai.agents.claude.type', type);
148
+ if (type === 'custom') {
149
+ if (config.baseUrl) {
150
+ yield this.updateConfig('ai.agents.claude.baseUrl', config.baseUrl, 'AI_CLAUDE_BASE_URL');
151
+ }
152
+ if (config.apiKey) {
153
+ yield this.updateConfig('ai.agents.claude.apiKey', config.apiKey, 'AI_CLAUDE_API_KEY');
154
+ }
155
+ }
156
+ else if (type === 'cloudbase') {
157
+ if (config.provider) {
158
+ yield this.updateConfig('ai.agents.claude.provider', config.provider);
159
+ }
160
+ if (config.model) {
161
+ yield this.updateConfig('ai.agents.claude.model', config.model);
162
+ }
163
+ if (config.transformer) {
164
+ yield this.updateConfig('ai.agents.claude.transformer', config.transformer);
165
+ }
166
+ }
167
+ });
168
+ }
169
+ updateQwenConfig(type, config) {
170
+ return __awaiter(this, void 0, void 0, function* () {
171
+ yield this.updateConfig('ai.agents.qwen.type', type);
172
+ if (type === 'custom') {
173
+ if (config.baseUrl) {
174
+ yield this.updateConfig('ai.agents.qwen.baseUrl', config.baseUrl, 'AI_QWEN_BASE_URL');
175
+ }
176
+ if (config.apiKey) {
177
+ yield this.updateConfig('ai.agents.qwen.apiKey', config.apiKey, 'AI_QWEN_API_KEY');
178
+ }
179
+ if (config.model) {
180
+ yield this.updateConfig('ai.agents.qwen.model', config.model, 'AI_QWEN_MODEL');
181
+ }
182
+ }
183
+ else if (type === 'cloudbase') {
184
+ if (config.provider) {
185
+ yield this.updateConfig('ai.agents.qwen.provider', config.provider);
186
+ }
187
+ if (config.model) {
188
+ yield this.updateConfig('ai.agents.qwen.model', config.model);
189
+ }
190
+ }
191
+ });
192
+ }
193
+ updateCodexConfig(type, config) {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ yield this.updateConfig('ai.agents.codex.type', type);
196
+ if (type === 'custom') {
197
+ if (config.baseUrl) {
198
+ yield this.updateConfig('ai.agents.codex.baseUrl', config.baseUrl, 'AI_CODEX_BASE_URL');
199
+ }
200
+ if (config.apiKey) {
201
+ yield this.updateConfig('ai.agents.codex.apiKey', config.apiKey, 'AI_CODEX_API_KEY');
202
+ }
203
+ if (config.model) {
204
+ yield this.updateConfig('ai.agents.codex.model', config.model, 'AI_CODEX_MODEL');
205
+ }
206
+ }
207
+ else if (type === 'cloudbase') {
208
+ if (config.provider) {
209
+ yield this.updateConfig('ai.agents.codex.provider', config.provider);
210
+ }
211
+ if (config.model) {
212
+ yield this.updateConfig('ai.agents.codex.model', config.model);
213
+ }
214
+ }
215
+ });
216
+ }
217
+ updateAiderConfig(type, config) {
218
+ return __awaiter(this, void 0, void 0, function* () {
219
+ yield this.updateConfig('ai.agents.aider.type', type);
220
+ if (type === 'custom') {
221
+ if (config.apiKey) {
222
+ yield this.updateConfig('ai.agents.aider.apiKey', config.apiKey, 'AI_AIDER_API_KEY');
223
+ }
224
+ if (config.baseUrl) {
225
+ yield this.updateConfig('ai.agents.aider.baseUrl', config.baseUrl, 'AI_AIDER_BASE_URL');
226
+ }
227
+ if (config.model) {
228
+ yield this.updateConfig('ai.agents.aider.model', config.model, 'AI_AIDER_MODEL');
229
+ }
230
+ }
231
+ else if (type === 'cloudbase') {
232
+ if (config.provider) {
233
+ yield this.updateConfig('ai.agents.aider.provider', config.provider);
234
+ }
235
+ if (config.model) {
236
+ yield this.updateConfig('ai.agents.aider.model', config.model);
237
+ }
238
+ }
239
+ });
240
+ }
241
+ updateConfig(key, value, env) {
242
+ return __awaiter(this, void 0, void 0, function* () {
243
+ const configParser = createConfigParser();
244
+ if (env) {
245
+ this.envLocalManager.setEnvLocal(env, value);
246
+ yield configParser.update(key, `{{env.${env}}}`);
247
+ }
248
+ else {
249
+ yield configParser.update(key, value);
250
+ }
251
+ });
252
+ }
253
+ }
254
+ exports.AIConfigManager = AIConfigManager;