@cloudbase/cloudbase-mcp 2.17.0 → 2.18.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/README.md +13 -6
- package/dist/341.index.js +92 -2
- package/dist/602.index.cjs +92 -2
- package/dist/cli.cjs +3 -3
- package/dist/index.cjs +257 -432
- package/dist/index.d.ts +3 -0
- package/dist/index.js +256 -430
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1769,7 +1769,6 @@ const auth_js_1 = __webpack_require__(77291);
|
|
|
1769
1769
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
1770
1770
|
const logger_js_1 = __webpack_require__(13039);
|
|
1771
1771
|
const tool_result_js_1 = __webpack_require__(9835);
|
|
1772
|
-
const rag_js_1 = __webpack_require__(64215);
|
|
1773
1772
|
const env_setup_js_1 = __webpack_require__(6978);
|
|
1774
1773
|
/**
|
|
1775
1774
|
* Simplify environment list data by keeping only essential fields for AI assistant
|
|
@@ -1903,6 +1902,7 @@ function formatDeviceAuthHint(deviceAuthInfo) {
|
|
|
1903
1902
|
if (!deviceAuthInfo) {
|
|
1904
1903
|
return "";
|
|
1905
1904
|
}
|
|
1905
|
+
const verificationUriComplete = (0, auth_js_1.buildVerificationUriComplete)(deviceAuthInfo);
|
|
1906
1906
|
const lines = [
|
|
1907
1907
|
"",
|
|
1908
1908
|
"### Device Flow 授权信息",
|
|
@@ -1911,8 +1911,11 @@ function formatDeviceAuthHint(deviceAuthInfo) {
|
|
|
1911
1911
|
if (deviceAuthInfo.verification_uri) {
|
|
1912
1912
|
lines.push(`- verification_uri: ${deviceAuthInfo.verification_uri}`);
|
|
1913
1913
|
}
|
|
1914
|
+
if (verificationUriComplete) {
|
|
1915
|
+
lines.push(`- verification_uri_complete: ${verificationUriComplete}`);
|
|
1916
|
+
}
|
|
1914
1917
|
lines.push(`- expires_in: ${deviceAuthInfo.expires_in}s`);
|
|
1915
|
-
lines.push("", "
|
|
1918
|
+
lines.push("", "请优先向用户展示完整的 `verification_uri_complete`,不要截断或改写 URL。");
|
|
1916
1919
|
return lines.join("\n");
|
|
1917
1920
|
}
|
|
1918
1921
|
function emitDeviceAuthNotice(server, deviceAuthInfo) {
|
|
@@ -2226,19 +2229,6 @@ async function enrichEnvInfoWithBilling(params) {
|
|
|
2226
2229
|
return params.result;
|
|
2227
2230
|
}
|
|
2228
2231
|
}
|
|
2229
|
-
async function getGuidePrompt(server) {
|
|
2230
|
-
if (getCurrentIde(server) === "CodeBuddy" ||
|
|
2231
|
-
process.env.CLOUDBASE_GUIDE_PROMPT === "false") {
|
|
2232
|
-
return "";
|
|
2233
|
-
}
|
|
2234
|
-
try {
|
|
2235
|
-
return await (0, rag_js_1.getClaudePrompt)();
|
|
2236
|
-
}
|
|
2237
|
-
catch (promptError) {
|
|
2238
|
-
(0, logger_js_1.debug)("Failed to get CLAUDE prompt", { error: promptError });
|
|
2239
|
-
return "";
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
2232
|
function normalizeOptionalToolString(value) {
|
|
2243
2233
|
return typeof value === "string" && value.trim().length > 0
|
|
2244
2234
|
? value.trim()
|
|
@@ -2351,13 +2341,7 @@ function registerEnvTools(server) {
|
|
|
2351
2341
|
(0, auth_js_1.setPendingAuthProgressState)(info, "device");
|
|
2352
2342
|
// emitDeviceAuthNotice(server, info);
|
|
2353
2343
|
};
|
|
2354
|
-
const authChallenge = () => deviceAuthInfo
|
|
2355
|
-
? {
|
|
2356
|
-
user_code: deviceAuthInfo.user_code,
|
|
2357
|
-
verification_uri: deviceAuthInfo.verification_uri,
|
|
2358
|
-
expires_in: deviceAuthInfo.expires_in,
|
|
2359
|
-
}
|
|
2360
|
-
: undefined;
|
|
2344
|
+
const authChallenge = () => (0, auth_js_1.buildDeviceAuthChallengePayload)(deviceAuthInfo);
|
|
2361
2345
|
try {
|
|
2362
2346
|
if (!supportedAuthActions.includes(action)) {
|
|
2363
2347
|
return (0, tool_result_js_1.buildJsonToolResult)({
|
|
@@ -2404,12 +2388,8 @@ function registerEnvTools(server) {
|
|
|
2404
2388
|
current_env_id: null,
|
|
2405
2389
|
...buildEnvCandidatePayload([]),
|
|
2406
2390
|
}),
|
|
2407
|
-
auth_challenge: authFlowState.status === "PENDING"
|
|
2408
|
-
?
|
|
2409
|
-
user_code: authFlowState.authChallenge.user_code,
|
|
2410
|
-
verification_uri: authFlowState.authChallenge.verification_uri,
|
|
2411
|
-
expires_in: authFlowState.authChallenge.expires_in,
|
|
2412
|
-
}
|
|
2391
|
+
auth_challenge: authFlowState.status === "PENDING"
|
|
2392
|
+
? (0, auth_js_1.buildDeviceAuthChallengePayload)(authFlowState.authChallenge)
|
|
2413
2393
|
: undefined,
|
|
2414
2394
|
message,
|
|
2415
2395
|
next_step: authStatus === "REQUIRED"
|
|
@@ -2430,11 +2410,7 @@ function registerEnvTools(server) {
|
|
|
2430
2410
|
ok: true,
|
|
2431
2411
|
code: "AUTH_PENDING",
|
|
2432
2412
|
message: "设备码授权进行中,请在浏览器中打开 verification_uri 并输入 user_code 完成授权。",
|
|
2433
|
-
auth_challenge:
|
|
2434
|
-
user_code: authFlowState.authChallenge.user_code,
|
|
2435
|
-
verification_uri: authFlowState.authChallenge.verification_uri,
|
|
2436
|
-
expires_in: authFlowState.authChallenge.expires_in,
|
|
2437
|
-
},
|
|
2413
|
+
auth_challenge: (0, auth_js_1.buildDeviceAuthChallengePayload)(authFlowState.authChallenge),
|
|
2438
2414
|
next_step: (0, tool_result_js_1.buildAuthNextStep)("status", {
|
|
2439
2415
|
suggestedArgs: { action: "status" },
|
|
2440
2416
|
}),
|
|
@@ -2897,23 +2873,7 @@ function registerEnvTools(server) {
|
|
|
2897
2873
|
default:
|
|
2898
2874
|
throw new Error(`不支持的查询类型: ${action}`);
|
|
2899
2875
|
}
|
|
2900
|
-
|
|
2901
|
-
// For info action, append CLAUDE.md prompt content (skip for CodeBuddy IDE)
|
|
2902
|
-
const currentIde = server.ide || process.env.INTEGRATION_IDE;
|
|
2903
|
-
if (action === "info" && currentIde !== "CodeBuddy" && process.env.CLOUDBASE_GUIDE_PROMPT !== "false") {
|
|
2904
|
-
try {
|
|
2905
|
-
const promptContent = await (0, rag_js_1.getClaudePrompt)();
|
|
2906
|
-
if (promptContent) {
|
|
2907
|
-
responseText += `\n\n⚠️ 重要提示:后续所有云开发相关的开发工作必须严格遵循以下开发规范和最佳实践:\n\n${promptContent}`;
|
|
2908
|
-
}
|
|
2909
|
-
}
|
|
2910
|
-
catch (promptError) {
|
|
2911
|
-
(0, logger_js_1.debug)("Failed to get CLAUDE prompt in envQuery", {
|
|
2912
|
-
error: promptError,
|
|
2913
|
-
});
|
|
2914
|
-
// Continue without prompt if fetch fails
|
|
2915
|
-
}
|
|
2916
|
-
}
|
|
2876
|
+
const responseText = JSON.stringify(result, null, 2);
|
|
2917
2877
|
return {
|
|
2918
2878
|
content: [
|
|
2919
2879
|
{
|
|
@@ -24632,13 +24592,7 @@ async function throwPendingAuthError() {
|
|
|
24632
24592
|
ok: false,
|
|
24633
24593
|
code: "AUTH_PENDING",
|
|
24634
24594
|
message: authState.lastError || "设备码授权进行中,请先完成登录后再重试当前工具。",
|
|
24635
|
-
auth_challenge: authState.authChallenge
|
|
24636
|
-
? {
|
|
24637
|
-
user_code: authState.authChallenge.user_code,
|
|
24638
|
-
verification_uri: authState.authChallenge.verification_uri,
|
|
24639
|
-
expires_in: authState.authChallenge.expires_in,
|
|
24640
|
-
}
|
|
24641
|
-
: undefined,
|
|
24595
|
+
auth_challenge: (0, auth_js_1.buildDeviceAuthChallengePayload)(authState.authChallenge),
|
|
24642
24596
|
next_step: (0, tool_result_js_1.buildAuthNextStep)("status", {
|
|
24643
24597
|
suggestedArgs: {
|
|
24644
24598
|
action: "status",
|
|
@@ -88375,6 +88329,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
88375
88329
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
88376
88330
|
exports.MANAGE_FUNCTION_ACTIONS = exports.QUERY_FUNCTION_ACTIONS = exports.TRIGGER_CONFIG_EXAMPLES = exports.SUPPORTED_TRIGGER_TYPES = exports.DEFAULT_NODEJS_RUNTIME = exports.SUPPORTED_NODEJS_RUNTIMES = exports.RECOMMENDED_RUNTIMES = exports.DEFAULT_RUNTIME = exports.ALL_SUPPORTED_RUNTIMES = exports.SUPPORTED_RUNTIMES = void 0;
|
|
88377
88331
|
exports.formatRuntimeList = formatRuntimeList;
|
|
88332
|
+
exports.validateTimerCron = validateTimerCron;
|
|
88378
88333
|
exports.shouldInstallDependencyForFunction = shouldInstallDependencyForFunction;
|
|
88379
88334
|
exports.resolveEventFunctionRuntime = resolveEventFunctionRuntime;
|
|
88380
88335
|
exports.buildFunctionOperationErrorMessage = buildFunctionOperationErrorMessage;
|
|
@@ -88478,12 +88433,32 @@ const VPC_SCHEMA = zod_1.z.object({
|
|
|
88478
88433
|
vpcId: zod_1.z.string(),
|
|
88479
88434
|
subnetId: zod_1.z.string(),
|
|
88480
88435
|
});
|
|
88436
|
+
const SEVEN_FIELD_CRON_REGEX = /^\s*\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s+\S+\s*$/;
|
|
88437
|
+
function validateTimerCron(config) {
|
|
88438
|
+
const trimmed = config.trim();
|
|
88439
|
+
const fields = trimmed.split(/\s+/);
|
|
88440
|
+
if (fields.length === 5) {
|
|
88441
|
+
throw new Error(`timer 触发器的 cron 表达式必须使用 7 段格式(秒 分 时 日 月 星期 年),不支持标准 5 段格式。` +
|
|
88442
|
+
`\n收到 5 段: "${trimmed}"` +
|
|
88443
|
+
`\n正确示例: "0 */5 * * * * *"(每 5 分钟执行),"0 0 2 1 * * *"(每月 1 号 2 点)`);
|
|
88444
|
+
}
|
|
88445
|
+
if (fields.length < 7) {
|
|
88446
|
+
throw new Error(`timer 触发器的 cron 表达式必须使用 7 段格式(秒 分 时 日 月 星期 年),当前只有 ${fields.length} 段。` +
|
|
88447
|
+
`\n正确示例: "0 */5 * * * * *"(每 5 分钟执行),"0 0 2 1 * * *"(每月 1 号 2 点)`);
|
|
88448
|
+
}
|
|
88449
|
+
return trimmed;
|
|
88450
|
+
}
|
|
88481
88451
|
const TRIGGER_SCHEMA = zod_1.z.object({
|
|
88482
88452
|
name: zod_1.z.string().describe("触发器名称"),
|
|
88483
88453
|
type: zod_1.z.enum(exports.SUPPORTED_TRIGGER_TYPES).describe("触发器类型"),
|
|
88484
88454
|
config: zod_1.z
|
|
88485
88455
|
.string()
|
|
88486
|
-
.describe("
|
|
88456
|
+
.describe("触发器配置。timer 必须使用 CloudBase 7 段 cron 格式:秒 分 时 日 月 星期 年。" +
|
|
88457
|
+
"⚠️ 不支持标准 5 段 cron(如 */5 * * * * 是错误的)。" +
|
|
88458
|
+
"正确示例:0 */5 * * * * *(每5分钟)、0 0 2 1 * * *(每月1号2点)、0 30 9 * * * *(每天9:30)")
|
|
88459
|
+
.refine((val) => SEVEN_FIELD_CRON_REGEX.test(val), {
|
|
88460
|
+
message: "timer 触发器的 cron 表达式必须使用 7 段格式(秒 分 时 日 月 星期 年),不支持 5 段格式。正确示例:0 */5 * * * * *",
|
|
88461
|
+
}),
|
|
88487
88462
|
});
|
|
88488
88463
|
const CREATE_FUNCTION_SCHEMA = zod_1.z.object({
|
|
88489
88464
|
name: zod_1.z.string().describe("函数名称"),
|
|
@@ -89146,6 +89121,12 @@ function registerFunctionTools(server) {
|
|
|
89146
89121
|
if (!input.triggers?.length) {
|
|
89147
89122
|
throw new Error("createFunctionTrigger 操作时,triggers 参数是必需的");
|
|
89148
89123
|
}
|
|
89124
|
+
// Validate timer cron format before sending to CloudBase
|
|
89125
|
+
for (const trigger of input.triggers) {
|
|
89126
|
+
if (trigger.type === "timer") {
|
|
89127
|
+
validateTimerCron(trigger.config);
|
|
89128
|
+
}
|
|
89129
|
+
}
|
|
89149
89130
|
const cloudbase = await getManager();
|
|
89150
89131
|
const result = await cloudbase.functions.createFunctionTriggers(input.functionName, input.triggers);
|
|
89151
89132
|
(0, cloudbase_manager_js_1.logCloudBaseResult)(server.logger, result);
|
|
@@ -89377,10 +89358,13 @@ function registerFunctionTools(server) {
|
|
|
89377
89358
|
.enum(exports.MANAGE_FUNCTION_ACTIONS)
|
|
89378
89359
|
.describe("写操作类型,例如 createFunction、invokeFunction、attachLayer"),
|
|
89379
89360
|
func: CREATE_FUNCTION_SCHEMA.optional().describe("createFunction 操作的函数配置"),
|
|
89380
|
-
functionRootPath: zod_1.z.string().optional().describe("
|
|
89361
|
+
functionRootPath: zod_1.z.string().optional().describe("创建或更新函数代码时默认推荐的本地目录方式。函数根目录(父目录绝对路径)。" +
|
|
89362
|
+
"本地应按 cloudfunctions/<functionName>/index.js 布局," +
|
|
89363
|
+
"此参数传 cloudfunctions 目录的绝对路径(如 /abs/path/cloudfunctions),不要传到函数名子目录。" +
|
|
89364
|
+
"SDK 会自动拼接函数名子目录,无需预先压缩 zip 或 base64 编码。"),
|
|
89381
89365
|
force: zod_1.z.boolean().optional().describe("createFunction 时是否覆盖"),
|
|
89382
89366
|
functionName: zod_1.z.string().optional().describe("函数名称。大多数 action 使用该字段作为统一目标"),
|
|
89383
|
-
zipFile: zod_1.z.string().optional().describe("
|
|
89367
|
+
zipFile: zod_1.z.string().optional().describe("仅兼容特殊场景:预先准备好的代码包 base64 编码。普通 createFunction/updateFunctionCode 默认不要先压缩 zip,优先使用 functionRootPath。"),
|
|
89384
89368
|
handler: zod_1.z.string().optional().describe("函数入口"),
|
|
89385
89369
|
timeout: zod_1.z.number().optional().describe("配置更新时的超时时间"),
|
|
89386
89370
|
envVariables: zod_1.z.record(zod_1.z.string()).optional().describe("配置更新时要合并的环境变量"),
|
|
@@ -108450,10 +108434,10 @@ function registerDataModelTools(server) {
|
|
|
108450
108434
|
throw new Error(`不支持的操作类型: ${action}`);
|
|
108451
108435
|
}
|
|
108452
108436
|
});
|
|
108453
|
-
// modifyDataModel -
|
|
108437
|
+
// modifyDataModel - 数据模型写工具(兼容名称,当前仅支持创建)
|
|
108454
108438
|
server.registerTool?.("modifyDataModel", {
|
|
108455
|
-
title: "
|
|
108456
|
-
description: "基于Mermaid classDiagram
|
|
108439
|
+
title: "修改数据模型(当前仅支持创建)",
|
|
108440
|
+
description: "基于Mermaid classDiagram创建数据模型。为保持兼容性,工具名仍为 modifyDataModel;当前仅支持创建新模型,不支持更新现有模型结构。内置异步任务监控,自动轮询直至完成或超时。",
|
|
108457
108441
|
inputSchema: {
|
|
108458
108442
|
mermaidDiagram: zod_1.z.string()
|
|
108459
108443
|
.describe(`Mermaid classDiagram代码,描述数据模型结构。
|
|
@@ -108613,10 +108597,10 @@ classDiagram
|
|
|
108613
108597
|
status: status,
|
|
108614
108598
|
action: action,
|
|
108615
108599
|
message: status === "success"
|
|
108616
|
-
?
|
|
108600
|
+
? `数据模型创建成功,共处理${models.length}个模型`
|
|
108617
108601
|
: status === "init"
|
|
108618
108602
|
? `任务超时,任务ID: ${taskId},请稍后手动查询状态`
|
|
108619
|
-
:
|
|
108603
|
+
: `数据模型创建失败`,
|
|
108620
108604
|
taskResult: statusResult?.Data,
|
|
108621
108605
|
}, null, 2),
|
|
108622
108606
|
},
|
|
@@ -111843,14 +111827,15 @@ exports.CLOUDRUN_SERVICE_TYPES = ['function', 'container'];
|
|
|
111843
111827
|
exports.CLOUDRUN_ACCESS_TYPES = ['OA', 'PUBLIC', 'MINIAPP', 'VPC'];
|
|
111844
111828
|
// Input schema for queryCloudRun tool
|
|
111845
111829
|
const queryCloudRunInputSchema = {
|
|
111846
|
-
action: zod_1.z.enum(['list', 'detail', 'templates']).describe('查询操作类型:list=获取云托管服务列表(支持分页和筛选),detail
|
|
111830
|
+
action: zod_1.z.enum(['list', 'detail', 'templates', 'getDeployLog']).describe('查询操作类型:list=获取云托管服务列表(支持分页和筛选),detail=查询指定服务的详细信息(包含服务配置和最新部署状态),templates=获取可用的项目模板列表(用于初始化新项目),getDeployLog=获取指定服务最近一次或指定构建的部署日志'),
|
|
111847
111831
|
// List operation parameters
|
|
111848
111832
|
pageSize: zod_1.z.number().min(1).max(100).optional().default(10).describe('分页大小,控制每页返回的服务数量。取值范围:1-100,默认值:10。建议根据网络性能和显示需求调整'),
|
|
111849
111833
|
pageNum: zod_1.z.number().min(1).optional().default(1).describe('页码,用于分页查询。从1开始,默认值:1。配合pageSize使用可实现分页浏览'),
|
|
111850
111834
|
serverName: zod_1.z.string().optional().describe('服务名称筛选条件,支持模糊匹配。例如:输入"test"可匹配"test-service"、"my-test-app"等服务名称。留空则查询所有服务'),
|
|
111851
111835
|
serverType: zod_1.z.enum(exports.CLOUDRUN_SERVICE_TYPES).optional().describe('服务类型筛选条件:function=函数型云托管(仅支持Node.js,有特殊的开发要求和限制,适合简单的API服务),container=容器型服务(推荐使用,支持任意语言和框架如Java/Go/Python/PHP/.NET等,适合大多数应用场景)'),
|
|
111852
|
-
// Detail operation parameters
|
|
111853
|
-
detailServerName: zod_1.z.string().optional().describe('
|
|
111836
|
+
// Detail and log operation parameters
|
|
111837
|
+
detailServerName: zod_1.z.string().optional().describe('要查询详细信息或部署日志的服务名称。当action为detail或getDeployLog时建议提供,必须是已存在的服务名称。可通过list操作获取可用的服务名称列表'),
|
|
111838
|
+
buildId: zod_1.z.number().optional().describe('构建ID,仅在action=getDeployLog时使用。不传时默认返回最近一次部署的构建日志'),
|
|
111854
111839
|
};
|
|
111855
111840
|
// Input schema for manageCloudRun tool
|
|
111856
111841
|
const ManageCloudRunInputSchema = {
|
|
@@ -111958,6 +111943,28 @@ function buildManageCloudRunErrorMessage(action, serverName, error) {
|
|
|
111958
111943
|
}
|
|
111959
111944
|
return `[manageCloudRun/${action}] ${baseMessage}\n建议:${suggestions.join(" ")}`;
|
|
111960
111945
|
}
|
|
111946
|
+
function getCloudRunQueryServerName(input) {
|
|
111947
|
+
return input.detailServerName || input.serverName;
|
|
111948
|
+
}
|
|
111949
|
+
function normalizeProcessLogText(logs) {
|
|
111950
|
+
return logs
|
|
111951
|
+
.map((log) => {
|
|
111952
|
+
if (typeof log === "string") {
|
|
111953
|
+
return log;
|
|
111954
|
+
}
|
|
111955
|
+
if (log && typeof log === "object") {
|
|
111956
|
+
if ("Log" in log && typeof log.Log === "string") {
|
|
111957
|
+
return log.Log;
|
|
111958
|
+
}
|
|
111959
|
+
if ("Text" in log && typeof log.Text === "string") {
|
|
111960
|
+
return log.Text;
|
|
111961
|
+
}
|
|
111962
|
+
return JSON.stringify(log);
|
|
111963
|
+
}
|
|
111964
|
+
return String(log);
|
|
111965
|
+
})
|
|
111966
|
+
.join("\n");
|
|
111967
|
+
}
|
|
111961
111968
|
/**
|
|
111962
111969
|
* Format CloudRun service info for display
|
|
111963
111970
|
*/
|
|
@@ -111972,7 +111979,7 @@ function registerCloudRunTools(server) {
|
|
|
111972
111979
|
// Tool 1: Get CloudRun service information (read operations)
|
|
111973
111980
|
server.registerTool("queryCloudRun", {
|
|
111974
111981
|
title: "查询 CloudRun 服务信息",
|
|
111975
|
-
description: "
|
|
111982
|
+
description: "查询云托管服务信息,支持获取服务列表、查询服务详情、获取可用模板列表和部署日志。返回的服务信息包括服务名称、状态、访问类型、配置详情以及最近部署上下文。",
|
|
111976
111983
|
inputSchema: queryCloudRunInputSchema,
|
|
111977
111984
|
annotations: {
|
|
111978
111985
|
readOnlyHint: true,
|
|
@@ -112021,7 +112028,21 @@ function registerCloudRunTools(server) {
|
|
|
112021
112028
|
};
|
|
112022
112029
|
}
|
|
112023
112030
|
case 'detail': {
|
|
112024
|
-
const serverName = input
|
|
112031
|
+
const serverName = getCloudRunQueryServerName(input);
|
|
112032
|
+
if (!serverName) {
|
|
112033
|
+
return {
|
|
112034
|
+
content: [
|
|
112035
|
+
{
|
|
112036
|
+
type: "text",
|
|
112037
|
+
text: JSON.stringify({
|
|
112038
|
+
success: false,
|
|
112039
|
+
error: "detailServerName or serverName is required for detail action",
|
|
112040
|
+
message: "Please provide detailServerName or serverName."
|
|
112041
|
+
}, null, 2)
|
|
112042
|
+
}
|
|
112043
|
+
]
|
|
112044
|
+
};
|
|
112045
|
+
}
|
|
112025
112046
|
const result = await cloudrunService.detail({ serverName });
|
|
112026
112047
|
if (!result) {
|
|
112027
112048
|
return {
|
|
@@ -112037,6 +112058,30 @@ function registerCloudRunTools(server) {
|
|
|
112037
112058
|
]
|
|
112038
112059
|
};
|
|
112039
112060
|
}
|
|
112061
|
+
let latestDeploy = null;
|
|
112062
|
+
let deployRecordsWarning;
|
|
112063
|
+
let message;
|
|
112064
|
+
try {
|
|
112065
|
+
const deployRecords = await cloudrunService.getDeployRecords({ serverName });
|
|
112066
|
+
latestDeploy = deployRecords?.DeployRecords?.[0] ?? null;
|
|
112067
|
+
if (!latestDeploy) {
|
|
112068
|
+
message = `Retrieved details for service '${serverName}'. No deploy records found yet.`;
|
|
112069
|
+
}
|
|
112070
|
+
else if (typeof latestDeploy.Status === 'string' && latestDeploy.Status.includes('failed')) {
|
|
112071
|
+
message = `Service '${serverName}' latest deploy failed. Please use queryCloudRun(action="getDeployLog") for details.`;
|
|
112072
|
+
}
|
|
112073
|
+
else if (typeof latestDeploy.Status === 'string' && latestDeploy.Status.includes('creating')) {
|
|
112074
|
+
message = `Service '${serverName}' latest deploy is still running. Please check again later or query the deploy log for progress.`;
|
|
112075
|
+
}
|
|
112076
|
+
else {
|
|
112077
|
+
message = `Retrieved details for service '${serverName}'. Latest service status: ${result.BaseInfo?.Status || 'unknown'}, latest deploy status: ${latestDeploy.Status || 'unknown'}.`;
|
|
112078
|
+
}
|
|
112079
|
+
}
|
|
112080
|
+
catch (error) {
|
|
112081
|
+
const baseMessage = error instanceof Error ? error.message : String(error);
|
|
112082
|
+
deployRecordsWarning = `Failed to fetch deploy records: ${baseMessage}`;
|
|
112083
|
+
message = `Retrieved details for service '${serverName}', but deploy records are currently unavailable.`;
|
|
112084
|
+
}
|
|
112040
112085
|
return {
|
|
112041
112086
|
content: [
|
|
112042
112087
|
{
|
|
@@ -112044,9 +112089,11 @@ function registerCloudRunTools(server) {
|
|
|
112044
112089
|
text: JSON.stringify({
|
|
112045
112090
|
success: true,
|
|
112046
112091
|
data: {
|
|
112047
|
-
service: result
|
|
112092
|
+
service: result,
|
|
112093
|
+
latestDeploy,
|
|
112094
|
+
...(deployRecordsWarning ? { deployRecordsWarning } : {})
|
|
112048
112095
|
},
|
|
112049
|
-
message
|
|
112096
|
+
message
|
|
112050
112097
|
}, null, 2)
|
|
112051
112098
|
}
|
|
112052
112099
|
]
|
|
@@ -112069,6 +112116,79 @@ function registerCloudRunTools(server) {
|
|
|
112069
112116
|
]
|
|
112070
112117
|
};
|
|
112071
112118
|
}
|
|
112119
|
+
case 'getDeployLog': {
|
|
112120
|
+
const serverName = getCloudRunQueryServerName(input);
|
|
112121
|
+
if (!serverName) {
|
|
112122
|
+
return {
|
|
112123
|
+
content: [
|
|
112124
|
+
{
|
|
112125
|
+
type: "text",
|
|
112126
|
+
text: JSON.stringify({
|
|
112127
|
+
success: false,
|
|
112128
|
+
error: "detailServerName or serverName is required for getDeployLog action",
|
|
112129
|
+
message: "Please provide detailServerName or serverName."
|
|
112130
|
+
}, null, 2)
|
|
112131
|
+
}
|
|
112132
|
+
]
|
|
112133
|
+
};
|
|
112134
|
+
}
|
|
112135
|
+
const deployRecords = await cloudrunService.getDeployRecords({ serverName });
|
|
112136
|
+
const latestDeploy = deployRecords?.DeployRecords?.[0];
|
|
112137
|
+
if (!latestDeploy) {
|
|
112138
|
+
return {
|
|
112139
|
+
content: [
|
|
112140
|
+
{
|
|
112141
|
+
type: "text",
|
|
112142
|
+
text: JSON.stringify({
|
|
112143
|
+
success: false,
|
|
112144
|
+
error: `Service '${serverName}' has no deploy records.`,
|
|
112145
|
+
message: "Please deploy the service first, then query the deploy log again."
|
|
112146
|
+
}, null, 2)
|
|
112147
|
+
}
|
|
112148
|
+
]
|
|
112149
|
+
};
|
|
112150
|
+
}
|
|
112151
|
+
const buildId = input.buildId ?? latestDeploy.BuildId;
|
|
112152
|
+
const buildLogResult = await cloudrunService.getBuildLog({
|
|
112153
|
+
serverName,
|
|
112154
|
+
buildId,
|
|
112155
|
+
});
|
|
112156
|
+
let processLogs = [];
|
|
112157
|
+
let processLogsWarning;
|
|
112158
|
+
if (latestDeploy.RunId && typeof cloudrunService.getProcessLog === 'function') {
|
|
112159
|
+
try {
|
|
112160
|
+
const processLogResult = await cloudrunService.getProcessLog({
|
|
112161
|
+
RunId: latestDeploy.RunId,
|
|
112162
|
+
});
|
|
112163
|
+
processLogs = processLogResult?.Logs || [];
|
|
112164
|
+
}
|
|
112165
|
+
catch (error) {
|
|
112166
|
+
processLogsWarning = error instanceof Error ? error.message : String(error);
|
|
112167
|
+
}
|
|
112168
|
+
}
|
|
112169
|
+
const buildLogText = typeof buildLogResult?.Log?.Text === 'string' ? buildLogResult.Log.Text : '';
|
|
112170
|
+
const processLogText = Array.isArray(processLogs) && processLogs.length > 0 ? normalizeProcessLogText(processLogs) : '';
|
|
112171
|
+
const combinedLogText = [buildLogText, processLogText].filter(Boolean).join('\n');
|
|
112172
|
+
return {
|
|
112173
|
+
content: [
|
|
112174
|
+
{
|
|
112175
|
+
type: "text",
|
|
112176
|
+
text: JSON.stringify({
|
|
112177
|
+
success: true,
|
|
112178
|
+
data: {
|
|
112179
|
+
buildId,
|
|
112180
|
+
deployRecord: latestDeploy,
|
|
112181
|
+
buildLog: buildLogResult?.Log || null,
|
|
112182
|
+
processLogs,
|
|
112183
|
+
combinedLogText,
|
|
112184
|
+
...(processLogsWarning ? { processLogsWarning } : {})
|
|
112185
|
+
},
|
|
112186
|
+
message: `Retrieved deploy log for service '${serverName}'`
|
|
112187
|
+
}, null, 2)
|
|
112188
|
+
}
|
|
112189
|
+
]
|
|
112190
|
+
};
|
|
112191
|
+
}
|
|
112072
112192
|
default:
|
|
112073
112193
|
throw new Error(`Unsupported action: ${input.action}`);
|
|
112074
112194
|
}
|
|
@@ -112336,6 +112456,7 @@ for await (let x of res.textStream) {
|
|
|
112336
112456
|
name: input.serverName
|
|
112337
112457
|
}
|
|
112338
112458
|
};
|
|
112459
|
+
const consoleUrl = `https://tcb.cloud.tencent.com/dev?envId=${currentEnvId}#/platform-run/service/detail?serverName=${input.serverName}&tabId=overview&envId=${currentEnvId}`;
|
|
112339
112460
|
try {
|
|
112340
112461
|
fs_1.default.writeFileSync(cloudbasercPath, JSON.stringify(cloudbasercContent, null, 2));
|
|
112341
112462
|
}
|
|
@@ -112379,8 +112500,6 @@ for await (let x of res.textStream) {
|
|
|
112379
112500
|
}
|
|
112380
112501
|
// Extract project name from targetPath
|
|
112381
112502
|
const projectName = path_1.default.basename(targetPath);
|
|
112382
|
-
// Build console URL
|
|
112383
|
-
const consoleUrl = `https://tcb.cloud.tencent.com/dev?envId=${currentEnvId}#/platform-run/service/detail?serverName=${input.serverName}&tabId=overview&envId=${currentEnvId}`;
|
|
112384
112503
|
// Send notification
|
|
112385
112504
|
await (0, notification_js_1.sendDeployNotification)(server, {
|
|
112386
112505
|
deployType: 'cloudrun',
|
|
@@ -112402,12 +112521,13 @@ for await (let x of res.textStream) {
|
|
|
112402
112521
|
success: true,
|
|
112403
112522
|
data: {
|
|
112404
112523
|
serviceName: input.serverName,
|
|
112405
|
-
status: '
|
|
112524
|
+
status: 'deploying',
|
|
112406
112525
|
deployPath: targetPath,
|
|
112407
112526
|
serverType: serverType,
|
|
112408
|
-
cloudbasercGenerated: true
|
|
112527
|
+
cloudbasercGenerated: true,
|
|
112528
|
+
consoleUrl
|
|
112409
112529
|
},
|
|
112410
|
-
message: `
|
|
112530
|
+
message: `Triggered deployment for ${serverType} service '${input.serverName}' from ${targetPath}. You can follow the progress in ${consoleUrl}`
|
|
112411
112531
|
}, null, 2)
|
|
112412
112532
|
}
|
|
112413
112533
|
]
|
|
@@ -133564,7 +133684,7 @@ class TelemetryReporter {
|
|
|
133564
133684
|
const nodeVersion = process.version; // Node.js版本
|
|
133565
133685
|
const arch = os_1.default.arch(); // 系统架构
|
|
133566
133686
|
// 从构建时注入的版本号获取MCP版本信息
|
|
133567
|
-
const mcpVersion = process.env.npm_package_version || "2.
|
|
133687
|
+
const mcpVersion = process.env.npm_package_version || "2.18.0" || 0;
|
|
133568
133688
|
return {
|
|
133569
133689
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
133570
133690
|
deviceId: this.deviceId,
|
|
@@ -177816,7 +177936,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
177816
177936
|
};
|
|
177817
177937
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
177818
177938
|
exports.resolveSkillSearchRoots = resolveSkillSearchRoots;
|
|
177819
|
-
exports.getClaudePrompt = getClaudePrompt;
|
|
177820
177939
|
exports.registerRagTools = registerRagTools;
|
|
177821
177940
|
const adm_zip_1 = __importDefault(__webpack_require__(30283));
|
|
177822
177941
|
const fs = __importStar(__webpack_require__(79748));
|
|
@@ -177825,7 +177944,6 @@ const os = __importStar(__webpack_require__(21820));
|
|
|
177825
177944
|
const path = __importStar(__webpack_require__(39902));
|
|
177826
177945
|
const zod_1 = __webpack_require__(21614);
|
|
177827
177946
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
177828
|
-
const claude_prompt_js_1 = __webpack_require__(68359);
|
|
177829
177947
|
const json_content_js_1 = __webpack_require__(4365);
|
|
177830
177948
|
const logger_js_1 = __webpack_require__(13039);
|
|
177831
177949
|
// 1. 枚举定义
|
|
@@ -178191,34 +178309,6 @@ async function downloadResources() {
|
|
|
178191
178309
|
});
|
|
178192
178310
|
return resourceDownloadPromise;
|
|
178193
178311
|
}
|
|
178194
|
-
// Get CLAUDE.md prompt content
|
|
178195
|
-
// Priority: 1. From downloaded template, 2. Fallback to embedded constant
|
|
178196
|
-
async function getClaudePrompt() {
|
|
178197
|
-
try {
|
|
178198
|
-
// Try to get from downloaded template
|
|
178199
|
-
const extractDir = await downloadWebTemplate();
|
|
178200
|
-
const claudePath = path.join(extractDir, "CLAUDE.md");
|
|
178201
|
-
try {
|
|
178202
|
-
const content = await fs.readFile(claudePath, "utf8");
|
|
178203
|
-
return content;
|
|
178204
|
-
}
|
|
178205
|
-
catch (error) {
|
|
178206
|
-
// CLAUDE.md not found in template, use fallback
|
|
178207
|
-
(0, logger_js_1.warn)("[getClaudePrompt] CLAUDE.md not found in template, using fallback", {
|
|
178208
|
-
error,
|
|
178209
|
-
path: claudePath,
|
|
178210
|
-
});
|
|
178211
|
-
return claude_prompt_js_1.FALLBACK_CLAUDE_PROMPT;
|
|
178212
|
-
}
|
|
178213
|
-
}
|
|
178214
|
-
catch (error) {
|
|
178215
|
-
// Template download failed, use fallback
|
|
178216
|
-
(0, logger_js_1.warn)("[getClaudePrompt] Template download failed, using fallback", {
|
|
178217
|
-
error,
|
|
178218
|
-
});
|
|
178219
|
-
return claude_prompt_js_1.FALLBACK_CLAUDE_PROMPT;
|
|
178220
|
-
}
|
|
178221
|
-
}
|
|
178222
178312
|
async function registerRagTools(server) {
|
|
178223
178313
|
// 联网搜索
|
|
178224
178314
|
server.registerTool?.("searchWeb", {
|
|
@@ -187740,323 +187830,6 @@ const fallback = {
|
|
|
187740
187830
|
module.exports = isUnicodeSupported() ? main : fallback;
|
|
187741
187831
|
|
|
187742
187832
|
|
|
187743
|
-
/***/ }),
|
|
187744
|
-
|
|
187745
|
-
/***/ 68359:
|
|
187746
|
-
/***/ ((__unused_webpack_module, exports) => {
|
|
187747
|
-
|
|
187748
|
-
"use strict";
|
|
187749
|
-
|
|
187750
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
187751
|
-
exports.FALLBACK_CLAUDE_PROMPT = void 0;
|
|
187752
|
-
// Fallback CLAUDE.md prompt content
|
|
187753
|
-
// This is used when template download fails or CLAUDE.md is not found in the template
|
|
187754
|
-
exports.FALLBACK_CLAUDE_PROMPT = `---
|
|
187755
|
-
description: CloudBase AI Development Rules Guide - Provides scenario-based best practices to ensure development quality
|
|
187756
|
-
globs: *
|
|
187757
|
-
alwaysApply: true
|
|
187758
|
-
---
|
|
187759
|
-
|
|
187760
|
-
# CloudBase AI Development Rules Guide
|
|
187761
|
-
|
|
187762
|
-
## Quick Reference for AI
|
|
187763
|
-
|
|
187764
|
-
**⚠️ CRITICAL: Read this section first based on your project type**
|
|
187765
|
-
|
|
187766
|
-
### When Developing a Web Project:
|
|
187767
|
-
1. **Environment Check**: Query environment info only when the task actually needs environment metadata, deployment, or an env ID. For existing applications with active TODOs or unfinished handlers, do not spend turns on hosting or domain queries unless the user explicitly asks for deployment.
|
|
187768
|
-
1. **Execution Mode for Existing-Code Tasks**: If the task is to complete an existing application, wire TODO logic, or repair a broken flow, do **not** enter design-only, brainstorming-only, or spec-only flows first. Gather only the minimum context needed, then implement directly. Do not stop after “project exploration complete”.
|
|
187769
|
-
1. **Existing File Focus (MANDATORY)**: For an existing Web app with active pages or TODO-bearing files, do not broad-scan the whole repo before coding. First inspect only the task-critical files: \`src/lib/backend.*\`, \`src/lib/auth.*\`, \`src/lib/cms-service.*\`, \`src/lib/storage-service.*\`, and the page/components that already consume those APIs. Then implement those TODOs before doing any wide repo exploration.
|
|
187770
|
-
1. **Task Tool Discipline**: For targeted repair tasks, do not spend many turns in \`TaskCreate\`, \`TaskUpdate\`, or project-management loops. At most keep one short checklist. After that, write code. Do not let task-management consume the turn budget.
|
|
187771
|
-
1. **No README / UI-Design Detour For Existing Apps**: If the repo already contains the target pages and only backend TODOs are missing, skip README-driven discovery and skip UI-design workflows unless the task explicitly asks for a visual redesign. Backend wiring is the priority.
|
|
187772
|
-
1. **No Broad Grep / Glob Sweep**: In targeted repair tasks, do not recursively Grep / Glob the whole repo for long periods. Open the known TODO-bearing files directly and start editing.
|
|
187773
|
-
3. **⚠️ UI Design (CRITICAL)**: **MUST read \`rules/ui-design/rule.md\` FIRST before generating any page, interface, component, or style** - This is NOT optional. You MUST explicitly read this file and output the design specification before writing any UI code.
|
|
187774
|
-
4. **Core Capabilities**: Read Core Capabilities section below (especially UI Design and Database + Authentication for Web)
|
|
187775
|
-
5. **Platform Rules**: Read \`rules/web-development/rule.md\` for platform-specific rules (SDK integration, static hosting, build configuration)
|
|
187776
|
-
6. **Authentication**: Read \`rules/auth-web/rule.md\` - **MUST use Web SDK built-in authentication**
|
|
187777
|
-
- \`accessKey\` can only be a real Publishable Key obtained from CloudBase auth/app config. Never use \`envId\`, a username, or any placeholder string as \`accessKey\`.
|
|
187778
|
-
- If you do not have a real Publishable Key yet, do not fabricate one. First query or configure auth readiness, or initialize without \`accessKey\` if the login flow itself is what will establish end-user identity.
|
|
187779
|
-
7. **Cloud Storage (when files are uploaded from browser code)**: Read \`rules/cloud-storage-web/rule.md\` before implementing upload / preview / temp URL flows. For local dev origins (for example Vite on \`127.0.0.1\` / \`localhost\`), query current security domains first and compare against the returned whitelist entry format (usually \`host:port\`, such as \`127.0.0.1:4173\` or \`localhost:5173\`). If \`envQuery(action="domains")\` reports missing local entries or returns a \`next_step\`, execute that \`envDomainManagement\` step before relying on \`app.uploadFile()\`. After upload, do not handcraft a storage URL from \`envId\`, bucket domain, or \`cloudPath\`; resolve an actual browser-usable URL through \`app.getTempFileURL()\` using the returned \`fileID\`.
|
|
187780
|
-
7. **Database**:
|
|
187781
|
-
- NoSQL: \`rules/no-sql-web-sdk/rule.md\`
|
|
187782
|
-
- MySQL: \`rules/relational-database-web/rule.md\` + \`rules/relational-database-mcp/rule.md\`
|
|
187783
|
-
|
|
187784
|
-
### When Developing a Mini Program Project:
|
|
187785
|
-
1. **Environment Check**: Call \`envQuery\` tool first (applies to all interactions)
|
|
187786
|
-
2. **⚠️ UI Design (CRITICAL)**: **MUST read \`rules/ui-design/rule.md\` FIRST before generating any page, interface, component, or style** - This is NOT optional. You MUST explicitly read this file and output the design specification before writing any UI code.
|
|
187787
|
-
3. **Core Capabilities**: Read Core Capabilities section below (especially UI Design and Database + Authentication for Mini Program)
|
|
187788
|
-
4. **Platform Rules**: Read \`rules/miniprogram-development/rule.md\` for platform-specific rules (project structure, WeChat Developer Tools, wx.cloud usage)
|
|
187789
|
-
5. **Authentication**: Read \`rules/auth-wechat/rule.md\` - **Naturally login-free, get OPENID in cloud functions**
|
|
187790
|
-
6. **Database**:
|
|
187791
|
-
- NoSQL: \`rules/no-sql-wx-mp-sdk/rule.md\`
|
|
187792
|
-
- MySQL: \`rules/relational-database-mcp/rule.md\` (via MCP tools)
|
|
187793
|
-
|
|
187794
|
-
---
|
|
187795
|
-
|
|
187796
|
-
## Core Capabilities (Must Be Done Well)
|
|
187797
|
-
|
|
187798
|
-
As the most important part of application development, the following four core capabilities must be done well, without needing to read different rules for different platforms:
|
|
187799
|
-
|
|
187800
|
-
### 1. ⚠️ UI Design (CRITICAL - Highest Priority)
|
|
187801
|
-
**⚠️ MANDATORY: Must strictly follow \`rules/ui-design/rule.md\` rules for ALL design work**
|
|
187802
|
-
|
|
187803
|
-
**🚨 CRITICAL ENFORCEMENT: You MUST explicitly read the file \`rules/ui-design/rule.md\` before generating ANY UI code. This is NOT a suggestion - it is a MANDATORY requirement.**
|
|
187804
|
-
|
|
187805
|
-
**Before generating ANY page, interface, component, or style:**
|
|
187806
|
-
1. **MUST FIRST explicitly read \`rules/ui-design/rule.md\` file** - Use file reading tools to read this file, do NOT skip this step
|
|
187807
|
-
2. **MUST complete design specification output** before writing any code:
|
|
187808
|
-
- Purpose Statement
|
|
187809
|
-
- Aesthetic Direction (choose from specific options, NOT generic terms)
|
|
187810
|
-
- Color Palette (with hex codes, avoid forbidden colors)
|
|
187811
|
-
- Typography (specific font names, avoid forbidden fonts)
|
|
187812
|
-
- Layout Strategy (asymmetric/creative approach, avoid centered templates)
|
|
187813
|
-
3. **MUST ensure** generated interfaces have distinctive aesthetic styles and high-quality visual design
|
|
187814
|
-
4. **MUST avoid** generic AI aesthetics (common fonts, clichéd color schemes, templated designs)
|
|
187815
|
-
|
|
187816
|
-
**This applies to ALL tasks involving:**
|
|
187817
|
-
- Page generation
|
|
187818
|
-
- Interface creation
|
|
187819
|
-
- Component design
|
|
187820
|
-
- Style/visual effects
|
|
187821
|
-
- Any frontend visual elements
|
|
187822
|
-
|
|
187823
|
-
**⚠️ VIOLATION DETECTION: If you find yourself writing UI code without first reading \`rules/ui-design/rule.md\`, STOP immediately and read the file first.**
|
|
187824
|
-
|
|
187825
|
-
### 2. Database + Authentication
|
|
187826
|
-
**Strengthen database and authentication capabilities**
|
|
187827
|
-
|
|
187828
|
-
**Authentication**:
|
|
187829
|
-
- **Web Projects**:
|
|
187830
|
-
- Must use CloudBase Web SDK built-in authentication, refer to \`rules/auth-web/rule.md\`
|
|
187831
|
-
- For username-style accounts, use \`auth.signUp({ username, password })\` and \`auth.signInWithPassword({ username, password })\`
|
|
187832
|
-
- Do not use email-only helpers or email-only input semantics when the account identifier is a plain username string
|
|
187833
|
-
- When an existing schema or fixture already provides role/profile metadata in \`users\`, \`profiles\`, or \`user_roles\`, reuse that collection instead of inventing yet another one. In role-based content-management flows, a \`user_roles\` collection keyed by \`uid\` is an acceptable and validated pattern.
|
|
187834
|
-
- For browser-side file upload / preview flows, read \`rules/cloud-storage-web/rule.md\`; on local dev origins, verify the required local host entries (for example \`127.0.0.1:4173\`, \`localhost:5173\`) are already in the environment security-domain whitelist before depending on \`app.uploadFile()\`. If \`envQuery(action="domains")\` returns missing local entries or a \`next_step\`, execute that \`envDomainManagement\` action first. After upload, use \`app.getTempFileURL()\` to resolve the preview/download URL instead of constructing a URL string manually.
|
|
187835
|
-
- Platform development rules: Refer to \`rules/web-development/rule.md\` for Web SDK integration, static hosting deployment, and build configuration
|
|
187836
|
-
- **Mini Program Projects**:
|
|
187837
|
-
- Naturally login-free, get \`wxContext.OPENID\` in cloud functions, refer to \`rules/auth-wechat/rule.md\`
|
|
187838
|
-
- Platform development rules: Refer to \`rules/miniprogram-development/rule.md\` for mini program project structure, WeChat Developer Tools integration, and CloudBase capabilities
|
|
187839
|
-
- **Node.js Backend**: Refer to \`rules/auth-nodejs/rule.md\`
|
|
187840
|
-
|
|
187841
|
-
**Database Operations**:
|
|
187842
|
-
- **Web Projects**:
|
|
187843
|
-
- NoSQL Database: Refer to \`rules/no-sql-web-sdk/rule.md\`
|
|
187844
|
-
- For content collections that only need owner-only writes, simple permissions such as \`READONLY\` can be a good fit. But for CMS-style collections that require **app-level admin users** to edit/delete any record while editors can only edit/delete their own records, a \`CUSTOM\` rule is expected.
|
|
187845
|
-
- A validated CMS article rule shape is: \`{"read":"auth.uid != null","create":"auth.uid != null","update":"auth.uid != null && (get('database.user_roles.' + auth.uid).role == 'admin' || doc.authorId == auth.uid)","delete":"auth.uid != null && (get('database.user_roles.' + auth.uid).role == 'admin' || doc.authorId == auth.uid)"}\`.
|
|
187846
|
-
- For that CMS pattern, frontend writes can stay on \`.doc(id).update()\` / \`.doc(id).remove()\`. Do not force a \`where(...)\` rewrite unless the task explicitly requires a different rule design.
|
|
187847
|
-
- MySQL Relational Database: Refer to \`rules/relational-database-web/rule.md\` (Web application development) and \`rules/relational-database-mcp/rule.md\` (Management via MCP tools)
|
|
187848
|
-
- Platform development rules: Refer to \`rules/web-development/rule.md\` for Web SDK database integration patterns
|
|
187849
|
-
- **Mini Program Projects**:
|
|
187850
|
-
- NoSQL Database: Refer to \`rules/no-sql-wx-mp-sdk/rule.md\`
|
|
187851
|
-
- MySQL Relational Database: Refer to \`rules/relational-database-mcp/rule.md\` (via MCP tools)
|
|
187852
|
-
- Platform development rules: Refer to \`rules/miniprogram-development/rule.md\` for mini program database integration and wx.cloud usage
|
|
187853
|
-
- **Data Model Creation** (Universal): Refer to \`rules/data-model-creation/rule.md\`
|
|
187854
|
-
|
|
187855
|
-
### 3. Static Hosting Deployment (Web)
|
|
187856
|
-
**Refer to deployment process in \`rules/web-development/rule.md\`**
|
|
187857
|
-
- Use CloudBase static hosting after build completion
|
|
187858
|
-
- Deploy using \`uploadFiles\` tool
|
|
187859
|
-
- \`uploadFiles\` is only for static hosting deployment; do not use it for COS / cloud storage uploads. For storage objects, use \`manageStorage(action="upload")\`
|
|
187860
|
-
- If the task is local verification or an unfinished application repair with a dev server workflow, skip static hosting deployment unless the user explicitly asks for a deployed URL
|
|
187861
|
-
- Remind users that CDN has a few minutes of cache after deployment
|
|
187862
|
-
- Generate markdown format access links with random queryString
|
|
187863
|
-
|
|
187864
|
-
### 4. Backend Deployment (Cloud Functions or CloudRun)
|
|
187865
|
-
**Refer to \`rules/cloudrun-development/rule.md\`**
|
|
187866
|
-
- **Cloud Function Deployment**: Prefer \`queryFunctions\` to inspect current state, then use \`manageFunctions\` with \`action="createFunction"\` or \`action="updateFunctionCode"\`.
|
|
187867
|
-
- In agent / non-interactive runs, treat \`manageFunctions\` as the default deployment path for both Event and HTTP functions; do not fall back to CLI login flows unless MCP tools are unavailable.
|
|
187868
|
-
- For HTTP functions, create or update them through \`manageFunctions\` with \`func.type="HTTP"\` instead of relying on \`tcb fn deploy\` as the primary path.
|
|
187869
|
-
- **CloudRun Deployment**: Use \`manageCloudRun\` tool for containerized deployment
|
|
187870
|
-
- Ensure backend code supports CORS, prepare Dockerfile (for container type)
|
|
187871
|
-
|
|
187872
|
-
## Development Process Standards
|
|
187873
|
-
|
|
187874
|
-
**Important: To ensure development quality, AI must complete the following steps before starting work:**
|
|
187875
|
-
|
|
187876
|
-
### 0. Environment Check (First Step)
|
|
187877
|
-
After user inputs any content, first check CloudBase environment status:
|
|
187878
|
-
- Ensure current CloudBase environment ID is known
|
|
187879
|
-
- If not present in conversation history and the task needs env metadata or deployment, call \`envQuery\` tool with parameter \`action=info\` to query current environment information and environment ID
|
|
187880
|
-
- **Important**: When environment ID configuration is involved in code later, automatically use the queried environment ID, no need for manual user input
|
|
187881
|
-
|
|
187882
|
-
### 1. Scenario Identification
|
|
187883
|
-
Identify current development scenario type, mainly for understanding project type, but core capabilities apply to all projects:
|
|
187884
|
-
- **Web Projects**: React/Vue/native JS frontend projects
|
|
187885
|
-
- **WeChat Mini Programs**: Mini program CloudBase projects
|
|
187886
|
-
- **CloudRun Projects**: CloudBase Run backend service projects (supports any language: Java/Go/Python/Node.js/PHP/.NET, etc.)
|
|
187887
|
-
- **Database Related**: Projects involving data operations
|
|
187888
|
-
- **UI Design/Interface Generation**: Projects requiring interface design, page generation, prototype creation, component design, etc.
|
|
187889
|
-
|
|
187890
|
-
### 2. Platform-Specific Quick Guide
|
|
187891
|
-
|
|
187892
|
-
**Web Projects - Required Rule Files:**
|
|
187893
|
-
- \`rules/web-development/rule.md\` - Platform development rules (SDK integration, static hosting, build configuration)
|
|
187894
|
-
- \`rules/auth-web/rule.md\` - Authentication (MUST use Web SDK built-in authentication)
|
|
187895
|
-
- \`rules/no-sql-web-sdk/rule.md\` - NoSQL database operations
|
|
187896
|
-
- \`rules/relational-database-web/rule.md\` - MySQL database operations (Web)
|
|
187897
|
-
- \`rules/relational-database-mcp/rule.md\` - MySQL database management (MCP tools)
|
|
187898
|
-
- \`rules/cloudbase-platform/rule.md\` - Universal CloudBase platform knowledge
|
|
187899
|
-
|
|
187900
|
-
**Mini Program Projects - Required Rule Files:**
|
|
187901
|
-
- \`rules/miniprogram-development/rule.md\` - Platform development rules (project structure, WeChat Developer Tools, wx.cloud)
|
|
187902
|
-
- \`rules/auth-wechat/rule.md\` - Authentication (naturally login-free, get OPENID in cloud functions)
|
|
187903
|
-
- \`rules/no-sql-wx-mp-sdk/rule.md\` - NoSQL database operations
|
|
187904
|
-
- \`rules/relational-database-mcp/rule.md\` - MySQL database operations (via MCP tools)
|
|
187905
|
-
- \`rules/cloudbase-platform/rule.md\` - Universal CloudBase platform knowledge
|
|
187906
|
-
|
|
187907
|
-
**Universal Rule Files (All Projects):**
|
|
187908
|
-
- **⚠️ \`rules/ui-design/rule.md\`** - **MANDATORY - HIGHEST PRIORITY** - Must read FIRST before any UI/page/component/style generation
|
|
187909
|
-
- \`rules/data-model-creation/rule.md\` - Data model creation and MySQL modeling
|
|
187910
|
-
- \`rules/spec-workflow/rule.md\` - Standard software engineering process (if needed)
|
|
187911
|
-
|
|
187912
|
-
### 3. Development Confirmation
|
|
187913
|
-
Before starting work, suggest confirming with user:
|
|
187914
|
-
1. "I identify this as a [scenario type] project"
|
|
187915
|
-
2. "I will strictly follow core capability requirements and refer to relevant rule files"
|
|
187916
|
-
3. "Please confirm if my understanding is correct"
|
|
187917
|
-
|
|
187918
|
-
## Core Behavior Rules
|
|
187919
|
-
0. **Existing-Code Completion Bias**: For existing applications with TODOs or broken flows, implementation is the goal. Do not hand off to a design-only phase, do not stop at exploration, and do not treat a summary of findings as task completion. After minimal context gathering, write code and wire the real backend flow.
|
|
187920
|
-
0. **No Broad Exploration For TODO Apps**: When the repo already exposes TODO markers in backend integration files, do not keep globbing, summarizing, or reading unrelated files. Open the TODO-bearing files and implement them.
|
|
187921
|
-
0. **No Task-Loop Derailment**: In targeted repair tasks, avoid repeated \`TaskCreate\` / \`TaskUpdate\` cycles. One minimal checklist is enough; the rest of the budget should go to file edits, tool calls, and verification.
|
|
187922
|
-
0. **Do Not Delegate Or Defer**: In targeted repair tasks, do not invoke design copilots, brainstorming helpers, or delegated agent flows before the core TODO files are implemented. Finish the direct file edits first.
|
|
187923
|
-
1. **Tool Priority**: For Tencent CloudBase operations, must prioritize using CloudBase MCP tools
|
|
187924
|
-
2. **Project Understanding**: First read current project's README.md, follow project instructions for development. Exception: for existing applications where the missing work is clearly in known backend integration files, skip README-first and go straight to those files.
|
|
187925
|
-
4. **Directory Standards**: Before outputting project code in current directory, first check current directory files
|
|
187926
|
-
5. **Development Order**: When developing, prioritize frontend first, then backend, ensuring frontend interface and interaction logic are completed first, then implement backend business logic
|
|
187927
|
-
6. **⚠️ UI Design Rules Mandatory Application**: When tasks involve generating pages, interfaces, components, styles, or any frontend visual elements, **MUST FIRST explicitly read the file \`rules/ui-design/rule.md\` using file reading tools**, then strictly follow the rule file, ensuring generated interfaces have distinctive aesthetic styles and high-quality visual design, avoiding generic AI aesthetics. **You MUST output the design specification before writing any UI code.** Exception: for existing applications where page structure is already fixed and only backend integration is missing, do not trigger the UI-design workflow.
|
|
187928
|
-
7. **Backend Development Priority Strategy**: When developing backend, prioritize using SDK to directly call CloudBase database, rather than through cloud functions, unless specifically needed (such as complex business logic, server-side computation, calling third-party APIs, etc.)
|
|
187929
|
-
8. **Deployment Order**: When there are backend dependencies, prioritize deploying backend before previewing frontend
|
|
187930
|
-
9. **Interactive Confirmation**: Clarify requirements when needed, and confirm before executing high-risk operations
|
|
187931
|
-
10. **Real-time Communication**: Use CloudBase real-time database watch capability
|
|
187932
|
-
11. **⚠️ Authentication Rules**: When users develop projects, if user login authentication is needed, must use built-in authentication functions, must strictly distinguish authentication methods by platform
|
|
187933
|
-
- **Web Projects**: **MUST use CloudBase Web SDK built-in authentication** (e.g., \`auth.toDefaultLoginPage()\`), refer to \`rules/auth-web/rule.md\`
|
|
187934
|
-
- **Username-style Web accounts**: Use \`auth.signUp({ username, password })\` for registration and \`auth.signInWithPassword({ username, password })\` for login. Do not use \`signInWithEmailAndPassword\` / \`signUpWithEmailAndPassword\` when the identifier is not an email address.
|
|
187935
|
-
- **Web initialization**: Only set \`accessKey\` when you have a real Publishable Key. Never set \`accessKey: envId\` or any made-up string.
|
|
187936
|
-
- **Mini Program Projects**: **Naturally login-free**, get \`wxContext.OPENID\` in cloud functions, refer to \`rules/auth-wechat/rule.md\`
|
|
187937
|
-
|
|
187938
|
-
## Development Workflow
|
|
187939
|
-
|
|
187940
|
-
### Development
|
|
187941
|
-
|
|
187942
|
-
1. **Project Bootstrap Discipline**:
|
|
187943
|
-
- Prefer the existing project structure and scripts when they already exist
|
|
187944
|
-
- For new projects, keep the initial structure consistent and avoid mixing unrelated frameworks in one workspace
|
|
187945
|
-
- If you bootstrap or copy an existing starter manually, hidden files and project config must be carried over as well
|
|
187946
|
-
|
|
187947
|
-
2. **⚠️ UI Design Document Reading (MANDATORY)**:
|
|
187948
|
-
- **Before generating ANY page, interface, component, or style, MUST FIRST explicitly read the file \`rules/ui-design/rule.md\` using file reading tools**
|
|
187949
|
-
- **MUST output the design specification** (Purpose Statement, Aesthetic Direction, Color Palette, Typography, Layout Strategy) before writing any UI code
|
|
187950
|
-
- This is NOT optional - you MUST read the file and follow the design thinking framework and frontend aesthetics guidelines
|
|
187951
|
-
- Avoid generating generic AI aesthetic style interfaces
|
|
187952
|
-
|
|
187953
|
-
3. **Mini Program TabBar Material Download - Download Remote Material Links**: Mini program Tabbar and other material images must use **png** format, must use downloadRemoteFile tool to download files locally. Can select from Unsplash, wikimedia (generally choose 500 size), Pexels, Apple official UI and other resources
|
|
187954
|
-
|
|
187955
|
-
If remote links are needed in the application, can continue to call uploadFile to upload and obtain temporary access links and cloud storage cloudId
|
|
187956
|
-
|
|
187957
|
-
3. **Query Professional Knowledge from Knowledge Base**: If uncertain about any CloudBase knowledge, can use searchKnowledgeBase tool to intelligently search CloudBase knowledge base (supports CloudBase and cloud functions, mini program frontend knowledge, etc.), quickly obtain professional documents and answers through vector search
|
|
187958
|
-
|
|
187959
|
-
4. **WeChat Developer Tools Open Project Workflow**:
|
|
187960
|
-
- When detecting current project is a mini program project, suggest user to use WeChat Developer Tools for preview, debugging, and publishing
|
|
187961
|
-
- Before opening, confirm project.config.json has appid field configured. If not configured, must ask user to provide it
|
|
187962
|
-
- Use WeChat Developer built-in CLI command to open project (pointing to directory containing project.config.json):
|
|
187963
|
-
- Windows: \`"C:\\Program Files (x86)\\Tencent\\微信web开发者工具\\cli.bat" open --project "项目根目录路径"\`
|
|
187964
|
-
- macOS: \`/Applications/wechatwebdevtools.app/Contents/MacOS/cli open --project "/path/to/project/root"\`
|
|
187965
|
-
- Project root directory path is the directory containing project.config.json file
|
|
187966
|
-
|
|
187967
|
-
### Deployment Process
|
|
187968
|
-
|
|
187969
|
-
1. **Cloud Function Deployment Process**: Prefer \`queryFunctions\` to query current functions, then call \`manageFunctions\` with \`action="createFunction"\` or \`action="updateFunctionCode"\` to deploy cloud function code. In agent / non-interactive runs, keep deployment on MCP tools instead of CLI login flows. For HTTP functions, set \`func.type="HTTP"\` when creating them. Only need to point \`functionRootPath\` to the parent directory of the cloud function directory (for example, the absolute path of the \`cloudfunctions\` directory). No need for code compression or other preprocessing.
|
|
187970
|
-
|
|
187971
|
-
2. **CloudRun Deployment Process**: For non-cloud function backend services (Java, Go, PHP, Python, Node.js, etc.), use manageCloudRun tool for deployment. Ensure backend code supports CORS, prepare Dockerfile, then call manageCloudRun for containerized deployment. For details, refer to \`rules/cloudrun-development/rule.md\`
|
|
187972
|
-
|
|
187973
|
-
3. **Static Hosting Deployment Process**: Deploy using uploadFiles tool for static hosting only. If the task needs a COS object that must be queried or polled with the storage SDK, use \`manageStorage\` / \`queryStorage\` instead. For local verification or unfinished application repairs, do not deploy hosting unless the user explicitly asks for deployment. After deployment, remind users that CDN has a few minutes of cache. Can generate markdown format access links with random queryString. For details, refer to \`rules/web-development/rule.md\`
|
|
187974
|
-
|
|
187975
|
-
### Documentation Generation Rules
|
|
187976
|
-
|
|
187977
|
-
1. You will generate a README.md file after generating the project, containing basic project information, such as project name, project description. Most importantly, clearly explain the project architecture and involved CloudBase resources, so maintainers can refer to it for modification and maintenance
|
|
187978
|
-
2. After deployment, if it's a web project, can write the official deployment access address in the documentation
|
|
187979
|
-
|
|
187980
|
-
### Configuration File Rules
|
|
187981
|
-
|
|
187982
|
-
1. To help others who don't use AI understand what resources are available, can generate a cloudbaserc.json file after generation
|
|
187983
|
-
|
|
187984
|
-
### MCP Interface Call Rules
|
|
187985
|
-
When calling MCP services, you need to fully understand the data types of all interfaces to be called, as well as return value types. If you're not sure which interface to call, first check the documentation and tool descriptions, then determine which interface and parameters to call based on the documentation and tool descriptions. Do not have incorrect method parameters or parameter type errors.
|
|
187986
|
-
|
|
187987
|
-
For example, many interfaces require a confirm parameter, which is a boolean type. If you don't provide this parameter, or provide incorrect data type, the interface will return an error.
|
|
187988
|
-
|
|
187989
|
-
### Environment ID Auto-Configuration Rules
|
|
187990
|
-
- When generating project configuration files (such as \`cloudbaserc.json\`, \`project.config.json\`, etc.), automatically use the environment ID queried by \`envQuery\`
|
|
187991
|
-
- In code examples involving environment ID, automatically fill in current environment ID, no need for manual user replacement
|
|
187992
|
-
- In deployment and preview related operations, prioritize using already queried environment information
|
|
187993
|
-
|
|
187994
|
-
## Professional Rule File Reference
|
|
187995
|
-
|
|
187996
|
-
**Note**: For detailed information, refer to the specific skill files. This section provides quick reference only.
|
|
187997
|
-
|
|
187998
|
-
### Platform Development Skills
|
|
187999
|
-
- **Web**: \`rules/web-development/rule.md\` - SDK integration, static hosting, build configuration
|
|
188000
|
-
- **Mini Program**: \`rules/miniprogram-development/rule.md\` - Project structure, WeChat Developer Tools, wx.cloud
|
|
188001
|
-
- **CloudRun**: \`rules/cloudrun-development/rule.md\` - Backend deployment (functions/containers)
|
|
188002
|
-
- **Platform (Universal)**: \`rules/cloudbase-platform/rule.md\` - Environment, authentication, services
|
|
188003
|
-
|
|
188004
|
-
### Authentication Skills
|
|
188005
|
-
- **Web**: \`rules/auth-web/rule.md\` - **MUST use Web SDK built-in authentication**
|
|
188006
|
-
- **Mini Program**: \`rules/auth-wechat/rule.md\` - **Naturally login-free, get OPENID in cloud functions**
|
|
188007
|
-
- **Node.js**: \`rules/auth-nodejs/rule.md\`
|
|
188008
|
-
- **HTTP API**: \`rules/auth-http-api/rule.md\`
|
|
188009
|
-
|
|
188010
|
-
### Database Skills
|
|
188011
|
-
- **NoSQL (Web)**: \`rules/no-sql-web-sdk/rule.md\`
|
|
188012
|
-
- **NoSQL (Mini Program)**: \`rules/no-sql-wx-mp-sdk/rule.md\`
|
|
188013
|
-
- **MySQL (Web)**: \`rules/relational-database-web/rule.md\`
|
|
188014
|
-
- **MySQL (MCP)**: \`rules/relational-database-mcp/rule.md\`
|
|
188015
|
-
- **Data Model Creation**: \`rules/data-model-creation/rule.md\`
|
|
188016
|
-
|
|
188017
|
-
### 🎨 ⚠️ UI Design Skill (CRITICAL - Read FIRST)
|
|
188018
|
-
- **\`rules/ui-design/rule.md\`** - **MANDATORY - HIGHEST PRIORITY**
|
|
188019
|
-
- **MUST read FIRST before generating ANY interface/page/component/style**
|
|
188020
|
-
- Design thinking framework, complete design process, frontend aesthetics guidelines
|
|
188021
|
-
- **NO EXCEPTIONS**: All UI work requires reading this file first
|
|
188022
|
-
|
|
188023
|
-
### Workflow Skills
|
|
188024
|
-
- **Spec Workflow**: \`rules/spec-workflow/rule.md\` - Standard software engineering process (requirements, design, tasks)
|
|
188025
|
-
|
|
188026
|
-
## Development Quality Checklist
|
|
188027
|
-
|
|
188028
|
-
To ensure development quality, recommend completing the following checks before starting tasks:
|
|
188029
|
-
|
|
188030
|
-
### Recommended Steps
|
|
188031
|
-
0. **[ ] Environment Check**: Call \`envQuery\` tool to check CloudBase environment status (applies to all interactions)
|
|
188032
|
-
1. **[ ] Scenario Identification**: Clearly identify what type of project this is (Web/Mini Program/Database/UI)
|
|
188033
|
-
3. **[ ] Core Capability Confirmation**: Confirm all four core capabilities have been considered
|
|
188034
|
-
- UI Design: Have you explicitly read the file \`rules/ui-design/rule.md\` using file reading tools?
|
|
188035
|
-
- Database + Authentication: Have you referred to corresponding authentication and database skills?
|
|
188036
|
-
- Static Hosting Deployment: Have you understood the deployment process?
|
|
188037
|
-
- Backend Deployment: Have you understood cloud function or CloudRun deployment process?
|
|
188038
|
-
4. **[ ] UI Design Rules Check (MANDATORY)**: If task involves generating pages, interfaces, components, or styles:
|
|
188039
|
-
- Have you explicitly read the file \`rules/ui-design/rule.md\` using file reading tools? (Required: YES)
|
|
188040
|
-
- Have you output the design specification before writing code? (Required: YES)
|
|
188041
|
-
- Have you understood and will follow the design thinking framework? (Required: YES)
|
|
188042
|
-
5. **[ ] User Confirmation**: Confirm with user whether scenario identification and core capability understanding are correct
|
|
188043
|
-
6. **[ ] Rule Execution**: Strictly follow core capability requirements and relevant rule files for development
|
|
188044
|
-
|
|
188045
|
-
### ⚠️ Common Issues to Avoid
|
|
188046
|
-
- **❌ DO NOT skip reading UI design document** - Must explicitly read \`rules/ui-design/rule.md\` file before generating any UI code
|
|
188047
|
-
- Avoid skipping core capabilities and starting development directly
|
|
188048
|
-
- Avoid mixing APIs and authentication methods from different platforms
|
|
188049
|
-
- Avoid ignoring UI design rules: All tasks involving interfaces, pages, components, styles must explicitly read and strictly follow \`rules/ui-design/rule.md\`
|
|
188050
|
-
- Avoid ignoring database and authentication standards: Must use correct authentication methods and database operation methods
|
|
188051
|
-
- Important technical solutions should be confirmed with users
|
|
188052
|
-
|
|
188053
|
-
### Quality Assurance
|
|
188054
|
-
If development is found to not comply with standards, can:
|
|
188055
|
-
- Point out specific issues
|
|
188056
|
-
- Require re-execution of rule check process
|
|
188057
|
-
- Clearly specify rule files that need to be followed`;
|
|
188058
|
-
|
|
188059
|
-
|
|
188060
187833
|
/***/ }),
|
|
188061
187834
|
|
|
188062
187835
|
/***/ 68385:
|
|
@@ -191778,7 +191551,7 @@ ${envIdSection}
|
|
|
191778
191551
|
## 环境信息
|
|
191779
191552
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
191780
191553
|
- Node.js版本: ${process.version}
|
|
191781
|
-
- MCP 版本:${process.env.npm_package_version || "2.
|
|
191554
|
+
- MCP 版本:${process.env.npm_package_version || "2.18.0" || 0}
|
|
191782
191555
|
- 系统架构: ${os_1.default.arch()}
|
|
191783
191556
|
- 时间: ${new Date().toISOString()}
|
|
191784
191557
|
- 请求ID: ${requestId}
|
|
@@ -200363,7 +200136,7 @@ deleteCollection: 删除集合`),
|
|
|
200363
200136
|
// writeNoSqlDatabaseContent
|
|
200364
200137
|
server.registerTool?.("writeNoSqlDatabaseContent", {
|
|
200365
200138
|
title: "修改 NoSQL 数据库数据记录",
|
|
200366
|
-
description: "修改 NoSQL 数据库数据记录。可按 MongoDB updateOne/updateMany 的心智模型理解:部分更新必须使用
|
|
200139
|
+
description: "修改 NoSQL 数据库数据记录。可按 MongoDB updateOne/updateMany 的心智模型理解:部分更新必须使用 `$set`、`$inc`、`$push` 等更新操作符;如果直接传“字段到值的普通对象”这类内容,底层会把它当作替换内容,存在覆盖整条文档的风险。更新嵌套对象中的某个字段时必须使用点号路径,例如把 `address.city` 设为 `shenzhen`;如果把整个 `address` 对象作为 `$set` 的值传入,则整个 `address` 对象会被替换,同级其他字段将丢失。若集合中的角色/档案文档会在前端通过 `db.collection(...).doc(uid)` 读取,请确保文档 `_id` 就是该 `uid`;不要用按 `uid` 条件查询再配合 `upsert=true` 的方式去更新 `users` / `profiles`,否则经常会生成一个不同的 `_id`,导致后续 `doc(uid)` 读取命中不到。",
|
|
200367
200140
|
inputSchema: {
|
|
200368
200141
|
action: zod_1.z
|
|
200369
200142
|
.enum(["insert", "update", "delete"])
|
|
@@ -200384,7 +200157,7 @@ deleteCollection: 删除集合`),
|
|
|
200384
200157
|
update: zod_1.z
|
|
200385
200158
|
.union([zod_1.z.object({}).passthrough(), zod_1.z.string()])
|
|
200386
200159
|
.optional()
|
|
200387
|
-
.describe("更新内容(对象或字符串,推荐对象)(update 操作必填)。按 MongoDB 更新语义传入 MgoUpdate:部分更新请使用
|
|
200160
|
+
.describe("更新内容(对象或字符串,推荐对象)(update 操作必填)。按 MongoDB 更新语义传入 MgoUpdate:部分更新请使用 `$set`、`$inc`、`$unset`、`$push` 等操作符,例如使用 `$set` 更新 `status`;不要直接传“字段到值的普通对象”,否则可能替换整条文档。更新嵌套字段时必须使用点号路径,例如通过 `$set` 更新 `address.city`;不要把整个 `address` 对象作为 `$set` 的值传入,否则会替换整个 `address` 对象。"),
|
|
200388
200161
|
isMulti: zod_1.z
|
|
200389
200162
|
.boolean()
|
|
200390
200163
|
.optional()
|
|
@@ -206320,7 +206093,7 @@ function registerSetupTools(server) {
|
|
|
206320
206093
|
title: "下载项目模板",
|
|
206321
206094
|
description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
|
|
206322
206095
|
|
|
206323
|
-
**CRITICAL**: This tool MUST be called FIRST when starting a new project.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置\n- cursor: Cursor AI编辑器\n- 其他IDE类型见下方列表\n\n注意:如果未传入 ide 参数且无法从环境变量检测到 IDE,将提示错误并要求传入 ide 参数\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- qoder: Qoder AI编辑器\n- antigravity: Google Antigravity AI编辑器\n- vscode: Visual Studio Code\n- kiro: Kiro AI编辑器\n- aider: Aider AI编辑器\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.
|
|
206096
|
+
**CRITICAL**: This tool MUST be called FIRST when starting a new project.\n\n支持的模板:\n- react: React + CloudBase 全栈应用模板\n- vue: Vue + CloudBase 全栈应用模板\n- miniprogram: 微信小程序 + 云开发模板 \n- uniapp: UniApp + CloudBase 跨端应用模板\n- rules: 只包含AI编辑器配置文件(包含Cursor、WindSurf、CodeBuddy等所有主流编辑器配置),适合在已有项目中补充AI编辑器配置\n\n支持的IDE类型:\n- all: 下载所有IDE配置\n- cursor: Cursor AI编辑器\n- 其他IDE类型见下方列表\n\n注意:如果未传入 ide 参数且无法从环境变量检测到 IDE,将提示错误并要求传入 ide 参数\n- windsurf: WindSurf AI编辑器\n- codebuddy: CodeBuddy AI编辑器\n- claude-code: Claude Code AI编辑器\n- cline: Cline AI编辑器\n- gemini-cli: Gemini CLI\n- opencode: OpenCode AI编辑器\n- qwen-code: 通义灵码\n- baidu-comate: 百度Comate\n- openai-codex-cli: OpenAI Codex CLI\n- augment-code: Augment Code\n- github-copilot: GitHub Copilot\n- roocode: RooCode AI编辑器\n- tongyi-lingma: 通义灵码\n- trae: Trae AI编辑器\n- qoder: Qoder AI编辑器\n- antigravity: Google Antigravity AI编辑器\n- vscode: Visual Studio Code\n- kiro: Kiro AI编辑器\n- aider: Aider AI编辑器\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.18.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
206324
206097
|
inputSchema: {
|
|
206325
206098
|
template: zod_1.z
|
|
206326
206099
|
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
@@ -207612,6 +207385,8 @@ module.exports.sync = path => {
|
|
|
207612
207385
|
"use strict";
|
|
207613
207386
|
|
|
207614
207387
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
207388
|
+
exports.buildVerificationUriComplete = buildVerificationUriComplete;
|
|
207389
|
+
exports.buildDeviceAuthChallengePayload = buildDeviceAuthChallengePayload;
|
|
207615
207390
|
exports.getAuthProgressStateSync = getAuthProgressStateSync;
|
|
207616
207391
|
exports.getAuthProgressState = getAuthProgressState;
|
|
207617
207392
|
exports.resolveAuthOptions = resolveAuthOptions;
|
|
@@ -207640,6 +207415,54 @@ function normalizeOptionalString(value) {
|
|
|
207640
207415
|
const trimmed = value.trim();
|
|
207641
207416
|
return trimmed.length > 0 ? trimmed : undefined;
|
|
207642
207417
|
}
|
|
207418
|
+
function buildVerificationUriComplete(deviceAuthInfo) {
|
|
207419
|
+
const explicitComplete = normalizeOptionalString(deviceAuthInfo?.verification_uri_complete);
|
|
207420
|
+
if (explicitComplete) {
|
|
207421
|
+
return explicitComplete;
|
|
207422
|
+
}
|
|
207423
|
+
const verificationUri = normalizeOptionalString(deviceAuthInfo?.verification_uri);
|
|
207424
|
+
const userCode = normalizeOptionalString(deviceAuthInfo?.user_code);
|
|
207425
|
+
if (!verificationUri || !userCode) {
|
|
207426
|
+
return undefined;
|
|
207427
|
+
}
|
|
207428
|
+
try {
|
|
207429
|
+
const url = new URL(verificationUri);
|
|
207430
|
+
const hash = url.hash.startsWith("#") ? url.hash.slice(1) : url.hash;
|
|
207431
|
+
if (hash) {
|
|
207432
|
+
const [hashPath, hashQuery = ""] = hash.split("?");
|
|
207433
|
+
const hashParams = new URLSearchParams(hashQuery);
|
|
207434
|
+
if (!hashParams.has("user_code")) {
|
|
207435
|
+
hashParams.set("user_code", userCode);
|
|
207436
|
+
}
|
|
207437
|
+
url.hash = hashParams.toString()
|
|
207438
|
+
? `#${hashPath}?${hashParams.toString()}`
|
|
207439
|
+
: `#${hashPath}`;
|
|
207440
|
+
return url.toString();
|
|
207441
|
+
}
|
|
207442
|
+
if (!url.searchParams.has("user_code")) {
|
|
207443
|
+
url.searchParams.set("user_code", userCode);
|
|
207444
|
+
}
|
|
207445
|
+
return url.toString();
|
|
207446
|
+
}
|
|
207447
|
+
catch {
|
|
207448
|
+
if (verificationUri.includes("user_code=")) {
|
|
207449
|
+
return verificationUri;
|
|
207450
|
+
}
|
|
207451
|
+
const separator = verificationUri.includes("?") ? "&" : "?";
|
|
207452
|
+
return `${verificationUri}${separator}user_code=${encodeURIComponent(userCode)}`;
|
|
207453
|
+
}
|
|
207454
|
+
}
|
|
207455
|
+
function buildDeviceAuthChallengePayload(deviceAuthInfo) {
|
|
207456
|
+
if (!deviceAuthInfo) {
|
|
207457
|
+
return undefined;
|
|
207458
|
+
}
|
|
207459
|
+
return {
|
|
207460
|
+
user_code: deviceAuthInfo.user_code,
|
|
207461
|
+
verification_uri: deviceAuthInfo.verification_uri,
|
|
207462
|
+
verification_uri_complete: buildVerificationUriComplete(deviceAuthInfo),
|
|
207463
|
+
expires_in: deviceAuthInfo.expires_in,
|
|
207464
|
+
};
|
|
207465
|
+
}
|
|
207643
207466
|
function normalizeAuthMode(value) {
|
|
207644
207467
|
return value === "web" || value === "device" ? value : undefined;
|
|
207645
207468
|
}
|
|
@@ -208784,7 +208607,7 @@ module.exports = toComparators
|
|
|
208784
208607
|
"use strict";
|
|
208785
208608
|
|
|
208786
208609
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
208787
|
-
exports.DEFAULT_NODEJS_RUNTIME = exports.SUPPORTED_NODEJS_RUNTIMES = exports.formatRuntimeList = exports.RECOMMENDED_RUNTIMES = exports.DEFAULT_RUNTIME = exports.ALL_SUPPORTED_RUNTIMES = exports.SUPPORTED_RUNTIMES = exports.RAW_IDE_FILE_MAPPINGS = exports.simplifyEnvList = exports.envManager = exports.createCloudBaseManagerWithOptions = exports.resetCloudBaseManagerCache = exports.getEnvId = exports.getCloudBaseManager = exports.shouldRegisterTool = exports.getCloudModeStatus = exports.enableCloudMode = exports.isCloudMode = exports.logout = exports.getLoginState = exports.warn = exports.error = exports.info = exports.reportToolCall = exports.reportToolkitLifecycle = exports.telemetryReporter = exports.StdioServerTransport = exports.getDefaultServer = exports.createCloudBaseMcpServer = void 0;
|
|
208610
|
+
exports.validateTimerCron = exports.DEFAULT_NODEJS_RUNTIME = exports.SUPPORTED_NODEJS_RUNTIMES = exports.formatRuntimeList = exports.RECOMMENDED_RUNTIMES = exports.DEFAULT_RUNTIME = exports.ALL_SUPPORTED_RUNTIMES = exports.SUPPORTED_RUNTIMES = exports.RAW_IDE_FILE_MAPPINGS = exports.simplifyEnvList = exports.envManager = exports.createCloudBaseManagerWithOptions = exports.resetCloudBaseManagerCache = exports.getEnvId = exports.getCloudBaseManager = exports.shouldRegisterTool = exports.getCloudModeStatus = exports.enableCloudMode = exports.isCloudMode = exports.logout = exports.getLoginState = exports.warn = exports.error = exports.info = exports.reportToolCall = exports.reportToolkitLifecycle = exports.telemetryReporter = exports.StdioServerTransport = exports.getDefaultServer = exports.createCloudBaseMcpServer = void 0;
|
|
208788
208611
|
exports.getInteractiveServerAsync = getInteractiveServerAsync;
|
|
208789
208612
|
// CloudBase MCP Server Library
|
|
208790
208613
|
var server_js_1 = __webpack_require__(31422);
|
|
@@ -208824,6 +208647,7 @@ Object.defineProperty(exports, "RECOMMENDED_RUNTIMES", ({ enumerable: true, get:
|
|
|
208824
208647
|
Object.defineProperty(exports, "formatRuntimeList", ({ enumerable: true, get: function () { return functions_js_1.formatRuntimeList; } }));
|
|
208825
208648
|
Object.defineProperty(exports, "SUPPORTED_NODEJS_RUNTIMES", ({ enumerable: true, get: function () { return functions_js_1.SUPPORTED_NODEJS_RUNTIMES; } }));
|
|
208826
208649
|
Object.defineProperty(exports, "DEFAULT_NODEJS_RUNTIME", ({ enumerable: true, get: function () { return functions_js_1.DEFAULT_NODEJS_RUNTIME; } }));
|
|
208650
|
+
Object.defineProperty(exports, "validateTimerCron", ({ enumerable: true, get: function () { return functions_js_1.validateTimerCron; } }));
|
|
208827
208651
|
/**
|
|
208828
208652
|
* Get interactive server instance (CommonJS compatible)
|
|
208829
208653
|
*/
|
|
@@ -256291,7 +256115,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
256291
256115
|
exports.resolveWebCredential = exports.resolveCredential = exports.checkAuth = void 0;
|
|
256292
256116
|
const cloud_api_1 = __webpack_require__(2090);
|
|
256293
256117
|
const config_1 = __webpack_require__(88472);
|
|
256294
|
-
// 调用
|
|
256118
|
+
// 调用 CheckTcbService 接口,检查密钥是否有效
|
|
256119
|
+
// 相比 DescribeEnvs,该接口不会返回环境列表,仅验证登录态,性能更好
|
|
256295
256120
|
function checkAuth(credential, options = {}) {
|
|
256296
256121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
256297
256122
|
// 兼容原临时秘钥
|
|
@@ -256310,7 +256135,7 @@ function checkAuth(credential, options = {}) {
|
|
|
256310
256135
|
});
|
|
256311
256136
|
return tcbService.request({
|
|
256312
256137
|
region,
|
|
256313
|
-
action: '
|
|
256138
|
+
action: 'CheckTcbService'
|
|
256314
256139
|
});
|
|
256315
256140
|
});
|
|
256316
256141
|
}
|