@cloudbase/cloudbase-mcp 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +390 -12
- package/dist/index.cjs +390 -12
- package/dist/index.js +389 -12
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1550,6 +1550,7 @@ const auth_js_1 = __webpack_require__(77291);
|
|
|
1550
1550
|
const cloudbase_manager_js_1 = __webpack_require__(3431);
|
|
1551
1551
|
const logger_js_1 = __webpack_require__(13039);
|
|
1552
1552
|
const interactive_js_1 = __webpack_require__(3461);
|
|
1553
|
+
const rag_js_1 = __webpack_require__(64215);
|
|
1553
1554
|
function registerEnvTools(server) {
|
|
1554
1555
|
// 获取 cloudBaseOptions,如果没有则为 undefined
|
|
1555
1556
|
const cloudBaseOptions = server.cloudBaseOptions;
|
|
@@ -1557,7 +1558,7 @@ function registerEnvTools(server) {
|
|
|
1557
1558
|
// login - 登录云开发环境
|
|
1558
1559
|
server.registerTool?.("login", {
|
|
1559
1560
|
title: "登录云开发",
|
|
1560
|
-
description: "
|
|
1561
|
+
description: "登录云开发环境,在生成包含云开发 CloudBase 相关功能前**必须**先调用此工具进行登录。登录云开发环境并选择要使用的环境。",
|
|
1561
1562
|
inputSchema: {
|
|
1562
1563
|
forceUpdate: zod_1.z.boolean().optional().describe("是否强制重新选择环境")
|
|
1563
1564
|
},
|
|
@@ -1579,10 +1580,23 @@ function registerEnvTools(server) {
|
|
|
1579
1580
|
return { content: [{ type: "text", text: "用户取消了登录" }] };
|
|
1580
1581
|
}
|
|
1581
1582
|
if (selectedEnvId) {
|
|
1583
|
+
// Get CLAUDE.md prompt content
|
|
1584
|
+
let promptContent = "";
|
|
1585
|
+
try {
|
|
1586
|
+
promptContent = await (0, rag_js_1.getClaudePrompt)();
|
|
1587
|
+
}
|
|
1588
|
+
catch (promptError) {
|
|
1589
|
+
(0, logger_js_1.debug)("Failed to get CLAUDE prompt", { error: promptError });
|
|
1590
|
+
// Continue with login success even if prompt fetch fails
|
|
1591
|
+
}
|
|
1592
|
+
const successMessage = `✅ 登录成功,当前环境: ${selectedEnvId}`;
|
|
1593
|
+
const promptMessage = promptContent
|
|
1594
|
+
? `\n\n⚠️ 重要提示:后续所有云开发相关的开发工作必须严格遵循以下开发规范和最佳实践:\n\n${promptContent}`
|
|
1595
|
+
: "";
|
|
1582
1596
|
return {
|
|
1583
1597
|
content: [{
|
|
1584
1598
|
type: "text",
|
|
1585
|
-
text:
|
|
1599
|
+
text: successMessage + promptMessage
|
|
1586
1600
|
}]
|
|
1587
1601
|
};
|
|
1588
1602
|
}
|
|
@@ -1704,10 +1718,24 @@ function registerEnvTools(server) {
|
|
|
1704
1718
|
default:
|
|
1705
1719
|
throw new Error(`不支持的查询类型: ${action}`);
|
|
1706
1720
|
}
|
|
1721
|
+
let responseText = JSON.stringify(result, null, 2);
|
|
1722
|
+
// For info action, append CLAUDE.md prompt content
|
|
1723
|
+
if (action === "info") {
|
|
1724
|
+
try {
|
|
1725
|
+
const promptContent = await (0, rag_js_1.getClaudePrompt)();
|
|
1726
|
+
if (promptContent) {
|
|
1727
|
+
responseText += `\n\n⚠️ 重要提示:后续所有云开发相关的开发工作必须严格遵循以下开发规范和最佳实践:\n\n${promptContent}`;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
catch (promptError) {
|
|
1731
|
+
(0, logger_js_1.debug)("Failed to get CLAUDE prompt in envQuery", { error: promptError });
|
|
1732
|
+
// Continue without prompt if fetch fails
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1707
1735
|
return {
|
|
1708
1736
|
content: [{
|
|
1709
1737
|
type: "text",
|
|
1710
|
-
text:
|
|
1738
|
+
text: responseText
|
|
1711
1739
|
}]
|
|
1712
1740
|
};
|
|
1713
1741
|
}
|
|
@@ -134829,7 +134857,7 @@ class TelemetryReporter {
|
|
|
134829
134857
|
const nodeVersion = process.version; // Node.js版本
|
|
134830
134858
|
const arch = os_1.default.arch(); // 系统架构
|
|
134831
134859
|
// 从构建时注入的版本号获取MCP版本信息
|
|
134832
|
-
const mcpVersion = process.env.npm_package_version || "2.0.
|
|
134860
|
+
const mcpVersion = process.env.npm_package_version || "2.0.2" || 0;
|
|
134833
134861
|
return {
|
|
134834
134862
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
134835
134863
|
deviceId: this.deviceId,
|
|
@@ -185302,12 +185330,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
185302
185330
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
185303
185331
|
};
|
|
185304
185332
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
185333
|
+
exports.downloadWebTemplate = downloadWebTemplate;
|
|
185334
|
+
exports.getClaudePrompt = getClaudePrompt;
|
|
185305
185335
|
exports.registerRagTools = registerRagTools;
|
|
185306
|
-
const
|
|
185336
|
+
const adm_zip_1 = __importDefault(__webpack_require__(30283));
|
|
185337
|
+
const fs = __importStar(__webpack_require__(79748));
|
|
185307
185338
|
const os = __importStar(__webpack_require__(21820));
|
|
185308
185339
|
const path = __importStar(__webpack_require__(39902));
|
|
185309
|
-
const
|
|
185310
|
-
const
|
|
185340
|
+
const zod_1 = __webpack_require__(21614);
|
|
185341
|
+
const claude_prompt_js_1 = __webpack_require__(68359);
|
|
185311
185342
|
const logger_js_1 = __webpack_require__(13039);
|
|
185312
185343
|
// 1. 枚举定义
|
|
185313
185344
|
const KnowledgeBaseEnum = zod_1.z.enum(["cloudbase", "scf", "miniprogram"]);
|
|
@@ -185343,26 +185374,71 @@ function safeStringify(obj) {
|
|
|
185343
185374
|
return "";
|
|
185344
185375
|
}
|
|
185345
185376
|
}
|
|
185346
|
-
|
|
185377
|
+
// Download and extract web template, return extract directory path
|
|
185378
|
+
// Implements caching: only downloads if extractDir doesn't exist
|
|
185379
|
+
async function downloadWebTemplate() {
|
|
185347
185380
|
const baseDir = path.join(os.homedir(), ".cloudbase-mcp");
|
|
185348
185381
|
const zipPath = path.join(baseDir, "web-cloudbase-project.zip");
|
|
185349
185382
|
const extractDir = path.join(baseDir, "web-template");
|
|
185350
185383
|
const url = "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-project.zip";
|
|
185351
185384
|
await fs.mkdir(baseDir, { recursive: true });
|
|
185352
|
-
//
|
|
185385
|
+
// Check if extractDir already exists (cache hit)
|
|
185386
|
+
try {
|
|
185387
|
+
const stats = await fs.stat(extractDir);
|
|
185388
|
+
if (stats.isDirectory()) {
|
|
185389
|
+
// Directory exists, return it directly (use cache)
|
|
185390
|
+
return extractDir;
|
|
185391
|
+
}
|
|
185392
|
+
}
|
|
185393
|
+
catch (error) {
|
|
185394
|
+
// Directory doesn't exist, proceed with download
|
|
185395
|
+
}
|
|
185396
|
+
// Download zip to specified path (overwrite)
|
|
185353
185397
|
const response = await fetch(url);
|
|
185354
185398
|
if (!response.ok) {
|
|
185355
185399
|
throw new Error(`下载模板失败,状态码: ${response.status}`);
|
|
185356
185400
|
}
|
|
185357
185401
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
185358
185402
|
await fs.writeFile(zipPath, buffer);
|
|
185359
|
-
//
|
|
185403
|
+
// Clean and recreate extract directory
|
|
185360
185404
|
await fs.rm(extractDir, { recursive: true, force: true });
|
|
185361
185405
|
await fs.mkdir(extractDir, { recursive: true });
|
|
185362
185406
|
const zip = new adm_zip_1.default(zipPath);
|
|
185363
185407
|
zip.extractAllTo(extractDir, true);
|
|
185408
|
+
return extractDir;
|
|
185409
|
+
}
|
|
185410
|
+
async function prepareKnowledgeBaseWebTemplate() {
|
|
185411
|
+
const extractDir = await downloadWebTemplate();
|
|
185364
185412
|
return collectSkillDescriptions(path.join(extractDir, ".claude", "skills"));
|
|
185365
185413
|
}
|
|
185414
|
+
// Get CLAUDE.md prompt content
|
|
185415
|
+
// Priority: 1. From downloaded template, 2. Fallback to embedded constant
|
|
185416
|
+
async function getClaudePrompt() {
|
|
185417
|
+
try {
|
|
185418
|
+
// Try to get from downloaded template
|
|
185419
|
+
const extractDir = await downloadWebTemplate();
|
|
185420
|
+
const claudePath = path.join(extractDir, "CLAUDE.md");
|
|
185421
|
+
try {
|
|
185422
|
+
const content = await fs.readFile(claudePath, "utf8");
|
|
185423
|
+
return content;
|
|
185424
|
+
}
|
|
185425
|
+
catch (error) {
|
|
185426
|
+
// CLAUDE.md not found in template, use fallback
|
|
185427
|
+
(0, logger_js_1.warn)("[getClaudePrompt] CLAUDE.md not found in template, using fallback", {
|
|
185428
|
+
error,
|
|
185429
|
+
path: claudePath,
|
|
185430
|
+
});
|
|
185431
|
+
return claude_prompt_js_1.FALLBACK_CLAUDE_PROMPT;
|
|
185432
|
+
}
|
|
185433
|
+
}
|
|
185434
|
+
catch (error) {
|
|
185435
|
+
// Template download failed, use fallback
|
|
185436
|
+
(0, logger_js_1.warn)("[getClaudePrompt] Template download failed, using fallback", {
|
|
185437
|
+
error,
|
|
185438
|
+
});
|
|
185439
|
+
return claude_prompt_js_1.FALLBACK_CLAUDE_PROMPT;
|
|
185440
|
+
}
|
|
185441
|
+
}
|
|
185366
185442
|
async function registerRagTools(server) {
|
|
185367
185443
|
// 联网搜索
|
|
185368
185444
|
server.registerTool?.("searchWeb", {
|
|
@@ -195060,6 +195136,306 @@ const fallback = {
|
|
|
195060
195136
|
module.exports = isUnicodeSupported() ? main : fallback;
|
|
195061
195137
|
|
|
195062
195138
|
|
|
195139
|
+
/***/ }),
|
|
195140
|
+
|
|
195141
|
+
/***/ 68359:
|
|
195142
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
195143
|
+
|
|
195144
|
+
"use strict";
|
|
195145
|
+
|
|
195146
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
195147
|
+
exports.FALLBACK_CLAUDE_PROMPT = void 0;
|
|
195148
|
+
// Fallback CLAUDE.md prompt content
|
|
195149
|
+
// This is used when template download fails or CLAUDE.md is not found in the template
|
|
195150
|
+
exports.FALLBACK_CLAUDE_PROMPT = `---
|
|
195151
|
+
description: CloudBase AI Development Rules Guide - Provides scenario-based best practices to ensure development quality
|
|
195152
|
+
globs: *
|
|
195153
|
+
alwaysApply: true
|
|
195154
|
+
---
|
|
195155
|
+
|
|
195156
|
+
# CloudBase AI Development Rules Guide
|
|
195157
|
+
|
|
195158
|
+
## Quick Reference for AI
|
|
195159
|
+
|
|
195160
|
+
**⚠️ CRITICAL: Read this section first based on your project type**
|
|
195161
|
+
|
|
195162
|
+
### When Developing a Web Project:
|
|
195163
|
+
1. **Environment Check**: Call \`envQuery\` tool first (applies to all interactions)
|
|
195164
|
+
2. **⚠️ Template Download (MANDATORY for New Projects)**: **MUST call \`downloadTemplate\` tool FIRST when starting a new project** - Do NOT create files manually. Use \`downloadTemplate\` with \`template="react"\` or \`template="vue"\` to get the complete project structure. Only proceed with manual file creation if template download fails or user explicitly requests it.
|
|
195165
|
+
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.
|
|
195166
|
+
4. **Core Capabilities**: Read Core Capabilities section below (especially UI Design and Database + Authentication for Web)
|
|
195167
|
+
5. **Platform Rules**: Read \`rules/web-development/rule.md\` for platform-specific rules (SDK integration, static hosting, build configuration)
|
|
195168
|
+
6. **Authentication**: Read \`rules/auth-web/rule.md\` - **MUST use Web SDK built-in authentication**
|
|
195169
|
+
7. **Database**:
|
|
195170
|
+
- NoSQL: \`rules/no-sql-web-sdk/rule.md\`
|
|
195171
|
+
- MySQL: \`rules/relational-database-web/rule.md\` + \`rules/relational-database-mcp/rule.md\`
|
|
195172
|
+
|
|
195173
|
+
### When Developing a Mini Program Project:
|
|
195174
|
+
1. **Environment Check**: Call \`envQuery\` tool first (applies to all interactions)
|
|
195175
|
+
2. **⚠️ Template Download (MANDATORY for New Projects)**: **MUST call \`downloadTemplate\` tool FIRST when starting a new project** - Do NOT create files manually. Use \`downloadTemplate\` with \`template="miniprogram"\` to get the complete project structure. Only proceed with manual file creation if template download fails or user explicitly requests it.
|
|
195176
|
+
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.
|
|
195177
|
+
4. **Core Capabilities**: Read Core Capabilities section below (especially UI Design and Database + Authentication for Mini Program)
|
|
195178
|
+
5. **Platform Rules**: Read \`rules/miniprogram-development/rule.md\` for platform-specific rules (project structure, WeChat Developer Tools, wx.cloud usage)
|
|
195179
|
+
6. **Authentication**: Read \`rules/auth-wechat/rule.md\` - **Naturally login-free, get OPENID in cloud functions**
|
|
195180
|
+
7. **Database**:
|
|
195181
|
+
- NoSQL: \`rules/no-sql-wx-mp-sdk/rule.md\`
|
|
195182
|
+
- MySQL: \`rules/relational-database-mcp/rule.md\` (via MCP tools)
|
|
195183
|
+
|
|
195184
|
+
---
|
|
195185
|
+
|
|
195186
|
+
## Core Capabilities (Must Be Done Well)
|
|
195187
|
+
|
|
195188
|
+
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:
|
|
195189
|
+
|
|
195190
|
+
### 1. ⚠️ UI Design (CRITICAL - Highest Priority)
|
|
195191
|
+
**⚠️ MANDATORY: Must strictly follow \`rules/ui-design/rule.md\` rules for ALL design work**
|
|
195192
|
+
|
|
195193
|
+
**🚨 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.**
|
|
195194
|
+
|
|
195195
|
+
**Before generating ANY page, interface, component, or style:**
|
|
195196
|
+
1. **MUST FIRST explicitly read \`rules/ui-design/rule.md\` file** - Use file reading tools to read this file, do NOT skip this step
|
|
195197
|
+
2. **MUST complete design specification output** before writing any code:
|
|
195198
|
+
- Purpose Statement
|
|
195199
|
+
- Aesthetic Direction (choose from specific options, NOT generic terms)
|
|
195200
|
+
- Color Palette (with hex codes, avoid forbidden colors)
|
|
195201
|
+
- Typography (specific font names, avoid forbidden fonts)
|
|
195202
|
+
- Layout Strategy (asymmetric/creative approach, avoid centered templates)
|
|
195203
|
+
3. **MUST ensure** generated interfaces have distinctive aesthetic styles and high-quality visual design
|
|
195204
|
+
4. **MUST avoid** generic AI aesthetics (common fonts, clichéd color schemes, templated designs)
|
|
195205
|
+
|
|
195206
|
+
**This applies to ALL tasks involving:**
|
|
195207
|
+
- Page generation
|
|
195208
|
+
- Interface creation
|
|
195209
|
+
- Component design
|
|
195210
|
+
- Style/visual effects
|
|
195211
|
+
- Any frontend visual elements
|
|
195212
|
+
|
|
195213
|
+
**⚠️ VIOLATION DETECTION: If you find yourself writing UI code without first reading \`rules/ui-design/rule.md\`, STOP immediately and read the file first.**
|
|
195214
|
+
|
|
195215
|
+
### 2. Database + Authentication
|
|
195216
|
+
**Strengthen database and authentication capabilities**
|
|
195217
|
+
|
|
195218
|
+
**Authentication**:
|
|
195219
|
+
- **Web Projects**:
|
|
195220
|
+
- Must use CloudBase Web SDK built-in authentication, refer to \`rules/auth-web/rule.md\`
|
|
195221
|
+
- Platform development rules: Refer to \`rules/web-development/rule.md\` for Web SDK integration, static hosting deployment, and build configuration
|
|
195222
|
+
- **Mini Program Projects**:
|
|
195223
|
+
- Naturally login-free, get \`wxContext.OPENID\` in cloud functions, refer to \`rules/auth-wechat/rule.md\`
|
|
195224
|
+
- Platform development rules: Refer to \`rules/miniprogram-development/rule.md\` for mini program project structure, WeChat Developer Tools integration, and CloudBase capabilities
|
|
195225
|
+
- **Node.js Backend**: Refer to \`rules/auth-nodejs/rule.md\`
|
|
195226
|
+
|
|
195227
|
+
**Database Operations**:
|
|
195228
|
+
- **Web Projects**:
|
|
195229
|
+
- NoSQL Database: Refer to \`rules/no-sql-web-sdk/rule.md\`
|
|
195230
|
+
- 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)
|
|
195231
|
+
- Platform development rules: Refer to \`rules/web-development/rule.md\` for Web SDK database integration patterns
|
|
195232
|
+
- **Mini Program Projects**:
|
|
195233
|
+
- NoSQL Database: Refer to \`rules/no-sql-wx-mp-sdk/rule.md\`
|
|
195234
|
+
- MySQL Relational Database: Refer to \`rules/relational-database-mcp/rule.md\` (via MCP tools)
|
|
195235
|
+
- Platform development rules: Refer to \`rules/miniprogram-development/rule.md\` for mini program database integration and wx.cloud usage
|
|
195236
|
+
- **Data Model Creation** (Universal): Refer to \`rules/data-model-creation/rule.md\`
|
|
195237
|
+
|
|
195238
|
+
### 3. Static Hosting Deployment (Web)
|
|
195239
|
+
**Refer to deployment process in \`rules/web-development/rule.md\`**
|
|
195240
|
+
- Use CloudBase static hosting after build completion
|
|
195241
|
+
- Deploy using \`uploadFiles\` tool
|
|
195242
|
+
- Remind users that CDN has a few minutes of cache after deployment
|
|
195243
|
+
- Generate markdown format access links with random queryString
|
|
195244
|
+
|
|
195245
|
+
### 4. Backend Deployment (Cloud Functions or CloudRun)
|
|
195246
|
+
**Refer to \`rules/cloudrun-development/rule.md\`**
|
|
195247
|
+
- **Cloud Function Deployment**: Use \`getFunctionList\` to query, then call \`createFunction\` or \`updateFunctionCode\` to deploy
|
|
195248
|
+
- **CloudRun Deployment**: Use \`manageCloudRun\` tool for containerized deployment
|
|
195249
|
+
- Ensure backend code supports CORS, prepare Dockerfile (for container type)
|
|
195250
|
+
|
|
195251
|
+
## Development Process Standards
|
|
195252
|
+
|
|
195253
|
+
**Important: To ensure development quality, AI must complete the following steps before starting work:**
|
|
195254
|
+
|
|
195255
|
+
### 0. Environment Check (First Step)
|
|
195256
|
+
After user inputs any content, first check CloudBase environment status:
|
|
195257
|
+
- Ensure current CloudBase environment ID is known
|
|
195258
|
+
- If not present in conversation history, must call \`envQuery\` tool with parameter \`action=info\` to query current environment information and environment ID
|
|
195259
|
+
- **Important**: When environment ID configuration is involved in code later, automatically use the queried environment ID, no need for manual user input
|
|
195260
|
+
|
|
195261
|
+
### 1. Scenario Identification
|
|
195262
|
+
Identify current development scenario type, mainly for understanding project type, but core capabilities apply to all projects:
|
|
195263
|
+
- **Web Projects**: React/Vue/native JS frontend projects
|
|
195264
|
+
- **WeChat Mini Programs**: Mini program CloudBase projects
|
|
195265
|
+
- **CloudRun Projects**: CloudBase Run backend service projects (supports any language: Java/Go/Python/Node.js/PHP/.NET, etc.)
|
|
195266
|
+
- **Database Related**: Projects involving data operations
|
|
195267
|
+
- **UI Design/Interface Generation**: Projects requiring interface design, page generation, prototype creation, component design, etc.
|
|
195268
|
+
|
|
195269
|
+
### 2. Platform-Specific Quick Guide
|
|
195270
|
+
|
|
195271
|
+
**Web Projects - Required Rule Files:**
|
|
195272
|
+
- \`rules/web-development/rule.md\` - Platform development rules (SDK integration, static hosting, build configuration)
|
|
195273
|
+
- \`rules/auth-web/rule.md\` - Authentication (MUST use Web SDK built-in authentication)
|
|
195274
|
+
- \`rules/no-sql-web-sdk/rule.md\` - NoSQL database operations
|
|
195275
|
+
- \`rules/relational-database-web/rule.md\` - MySQL database operations (Web)
|
|
195276
|
+
- \`rules/relational-database-mcp/rule.md\` - MySQL database management (MCP tools)
|
|
195277
|
+
- \`rules/cloudbase-platform/rule.md\` - Universal CloudBase platform knowledge
|
|
195278
|
+
|
|
195279
|
+
**Mini Program Projects - Required Rule Files:**
|
|
195280
|
+
- \`rules/miniprogram-development/rule.md\` - Platform development rules (project structure, WeChat Developer Tools, wx.cloud)
|
|
195281
|
+
- \`rules/auth-wechat/rule.md\` - Authentication (naturally login-free, get OPENID in cloud functions)
|
|
195282
|
+
- \`rules/no-sql-wx-mp-sdk/rule.md\` - NoSQL database operations
|
|
195283
|
+
- \`rules/relational-database-mcp/rule.md\` - MySQL database operations (via MCP tools)
|
|
195284
|
+
- \`rules/cloudbase-platform/rule.md\` - Universal CloudBase platform knowledge
|
|
195285
|
+
|
|
195286
|
+
**Universal Rule Files (All Projects):**
|
|
195287
|
+
- **⚠️ \`rules/ui-design/rule.md\`** - **MANDATORY - HIGHEST PRIORITY** - Must read FIRST before any UI/page/component/style generation
|
|
195288
|
+
- \`rules/data-model-creation/rule.md\` - Data model creation and MySQL modeling
|
|
195289
|
+
- \`rules/spec-workflow/rule.md\` - Standard software engineering process (if needed)
|
|
195290
|
+
|
|
195291
|
+
### 3. Development Confirmation
|
|
195292
|
+
Before starting work, suggest confirming with user:
|
|
195293
|
+
1. "I identify this as a [scenario type] project"
|
|
195294
|
+
2. "I will strictly follow core capability requirements and refer to relevant rule files"
|
|
195295
|
+
3. "Please confirm if my understanding is correct"
|
|
195296
|
+
|
|
195297
|
+
## Core Behavior Rules
|
|
195298
|
+
1. **Tool Priority**: For Tencent CloudBase operations, must prioritize using CloudBase MCP tools
|
|
195299
|
+
2. **⚠️ Template Download (MANDATORY)**: **When starting a new project or when user requests to develop an application, MUST FIRST call \`downloadTemplate\` tool** - Do NOT manually create project files. Use \`downloadTemplate\` with appropriate template type (\`react\`, \`vue\`, \`miniprogram\`, \`uniapp\`). Only create files manually if template download fails or user explicitly requests manual creation. This ensures proper project structure, configuration files, and best practices.
|
|
195300
|
+
3. **Project Understanding**: First read current project's README.md, follow project instructions for development
|
|
195301
|
+
4. **Directory Standards**: Before outputting project code in current directory, first check current directory files
|
|
195302
|
+
5. **Development Order**: When developing, prioritize frontend first, then backend, ensuring frontend interface and interaction logic are completed first, then implement backend business logic
|
|
195303
|
+
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.**
|
|
195304
|
+
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.)
|
|
195305
|
+
8. **Deployment Order**: When there are backend dependencies, prioritize deploying backend before previewing frontend
|
|
195306
|
+
9. **Interactive Confirmation**: Use interactiveDialog to clarify when requirements are unclear, must confirm before executing high-risk operations
|
|
195307
|
+
10. **Real-time Communication**: Use CloudBase real-time database watch capability
|
|
195308
|
+
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
|
|
195309
|
+
- **Web Projects**: **MUST use CloudBase Web SDK built-in authentication** (e.g., \`auth.toDefaultLoginPage()\`), refer to \`rules/auth-web/rule.md\`
|
|
195310
|
+
- **Mini Program Projects**: **Naturally login-free**, get \`wxContext.OPENID\` in cloud functions, refer to \`rules/auth-wechat/rule.md\`
|
|
195311
|
+
|
|
195312
|
+
## Development Workflow
|
|
195313
|
+
|
|
195314
|
+
### Development
|
|
195315
|
+
|
|
195316
|
+
1. **⚠️ Download CloudBase Templates (MANDATORY for New Projects)**:
|
|
195317
|
+
- **MUST call \`downloadTemplate\` tool FIRST when starting a new project** - Do NOT manually create project files
|
|
195318
|
+
- For Web projects: Use \`downloadTemplate\` with \`template="react"\` or \`template="vue"\`
|
|
195319
|
+
- For Mini Program projects: Use \`downloadTemplate\` with \`template="miniprogram"\`
|
|
195320
|
+
- For UniApp projects: Use \`downloadTemplate\` with \`template="uniapp"\`
|
|
195321
|
+
- **Only proceed with manual file creation if template download fails or user explicitly requests manual creation**
|
|
195322
|
+
- If unable to download to current directory, can use scripts to copy, note that hidden files also need to be copied
|
|
195323
|
+
|
|
195324
|
+
2. **⚠️ UI Design Document Reading (MANDATORY)**:
|
|
195325
|
+
- **Before generating ANY page, interface, component, or style, MUST FIRST explicitly read the file \`rules/ui-design/rule.md\` using file reading tools**
|
|
195326
|
+
- **MUST output the design specification** (Purpose Statement, Aesthetic Direction, Color Palette, Typography, Layout Strategy) before writing any UI code
|
|
195327
|
+
- This is NOT optional - you MUST read the file and follow the design thinking framework and frontend aesthetics guidelines
|
|
195328
|
+
- Avoid generating generic AI aesthetic style interfaces
|
|
195329
|
+
|
|
195330
|
+
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
|
|
195331
|
+
|
|
195332
|
+
If remote links are needed in the application, can continue to call uploadFile to upload and obtain temporary access links and cloud storage cloudId
|
|
195333
|
+
|
|
195334
|
+
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
|
|
195335
|
+
|
|
195336
|
+
4. **WeChat Developer Tools Open Project Workflow**:
|
|
195337
|
+
- When detecting current project is a mini program project, suggest user to use WeChat Developer Tools for preview, debugging, and publishing
|
|
195338
|
+
- Before opening, confirm project.config.json has appid field configured. If not configured, must ask user to provide it
|
|
195339
|
+
- Use WeChat Developer built-in CLI command to open project (pointing to directory containing project.config.json):
|
|
195340
|
+
- Windows: \`"C:\\Program Files (x86)\\Tencent\\微信web开发者工具\\cli.bat" open --project "项目根目录路径"\`
|
|
195341
|
+
- macOS: \`/Applications/wechatwebdevtools.app/Contents/MacOS/cli open --project "/path/to/project/root"\`
|
|
195342
|
+
- Project root directory path is the directory containing project.config.json file
|
|
195343
|
+
|
|
195344
|
+
### Deployment Process
|
|
195345
|
+
|
|
195346
|
+
1. **Cloud Function Deployment Process**: Can use getFunctionList MCP tool to query if there are cloud functions, then directly call createFunction or updateFunctionCode to update cloud function code. Only need to point functionRootPath to parent directory of cloud function directory (e.g., absolute path of cloudfunctions directory). No need for code compression and other operations. The above tools will automatically read files from cloud function subdirectories with same name under parent directory and automatically deploy
|
|
195347
|
+
|
|
195348
|
+
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\`
|
|
195349
|
+
|
|
195350
|
+
3. **Static Hosting Deployment Process**: Deploy using uploadFiles tool. 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\`
|
|
195351
|
+
|
|
195352
|
+
### Documentation Generation Rules
|
|
195353
|
+
|
|
195354
|
+
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
|
|
195355
|
+
2. After deployment, if it's a web project, can write the official deployment access address in the documentation
|
|
195356
|
+
|
|
195357
|
+
### Configuration File Rules
|
|
195358
|
+
|
|
195359
|
+
1. To help others who don't use AI understand what resources are available, can generate a cloudbaserc.json file after generation
|
|
195360
|
+
|
|
195361
|
+
### MCP Interface Call Rules
|
|
195362
|
+
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.
|
|
195363
|
+
|
|
195364
|
+
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.
|
|
195365
|
+
|
|
195366
|
+
### Environment ID Auto-Configuration Rules
|
|
195367
|
+
- When generating project configuration files (such as \`cloudbaserc.json\`, \`project.config.json\`, etc.), automatically use the environment ID queried by \`envQuery\`
|
|
195368
|
+
- In code examples involving environment ID, automatically fill in current environment ID, no need for manual user replacement
|
|
195369
|
+
- In deployment and preview related operations, prioritize using already queried environment information
|
|
195370
|
+
|
|
195371
|
+
## Professional Rule File Reference
|
|
195372
|
+
|
|
195373
|
+
**Note**: For detailed information, refer to the specific skill files. This section provides quick reference only.
|
|
195374
|
+
|
|
195375
|
+
### Platform Development Skills
|
|
195376
|
+
- **Web**: \`rules/web-development/rule.md\` - SDK integration, static hosting, build configuration
|
|
195377
|
+
- **Mini Program**: \`rules/miniprogram-development/rule.md\` - Project structure, WeChat Developer Tools, wx.cloud
|
|
195378
|
+
- **CloudRun**: \`rules/cloudrun-development/rule.md\` - Backend deployment (functions/containers)
|
|
195379
|
+
- **Platform (Universal)**: \`rules/cloudbase-platform/rule.md\` - Environment, authentication, services
|
|
195380
|
+
|
|
195381
|
+
### Authentication Skills
|
|
195382
|
+
- **Web**: \`rules/auth-web/rule.md\` - **MUST use Web SDK built-in authentication**
|
|
195383
|
+
- **Mini Program**: \`rules/auth-wechat/rule.md\` - **Naturally login-free, get OPENID in cloud functions**
|
|
195384
|
+
- **Node.js**: \`rules/auth-nodejs/rule.md\`
|
|
195385
|
+
- **HTTP API**: \`rules/auth-http-api/rule.md\`
|
|
195386
|
+
|
|
195387
|
+
### Database Skills
|
|
195388
|
+
- **NoSQL (Web)**: \`rules/no-sql-web-sdk/rule.md\`
|
|
195389
|
+
- **NoSQL (Mini Program)**: \`rules/no-sql-wx-mp-sdk/rule.md\`
|
|
195390
|
+
- **MySQL (Web)**: \`rules/relational-database-web/rule.md\`
|
|
195391
|
+
- **MySQL (MCP)**: \`rules/relational-database-mcp/rule.md\`
|
|
195392
|
+
- **Data Model Creation**: \`rules/data-model-creation/rule.md\`
|
|
195393
|
+
|
|
195394
|
+
### 🎨 ⚠️ UI Design Skill (CRITICAL - Read FIRST)
|
|
195395
|
+
- **\`rules/ui-design/rule.md\`** - **MANDATORY - HIGHEST PRIORITY**
|
|
195396
|
+
- **MUST read FIRST before generating ANY interface/page/component/style**
|
|
195397
|
+
- Design thinking framework, complete design process, frontend aesthetics guidelines
|
|
195398
|
+
- **NO EXCEPTIONS**: All UI work requires reading this file first
|
|
195399
|
+
|
|
195400
|
+
### Workflow Skills
|
|
195401
|
+
- **Spec Workflow**: \`rules/spec-workflow/rule.md\` - Standard software engineering process (requirements, design, tasks)
|
|
195402
|
+
|
|
195403
|
+
## Development Quality Checklist
|
|
195404
|
+
|
|
195405
|
+
To ensure development quality, recommend completing the following checks before starting tasks:
|
|
195406
|
+
|
|
195407
|
+
### Recommended Steps
|
|
195408
|
+
0. **[ ] Environment Check**: Call \`envQuery\` tool to check CloudBase environment status (applies to all interactions)
|
|
195409
|
+
1. **[ ] Template Download Check (MANDATORY for New Projects)**: If starting a new project, have you called \`downloadTemplate\` tool FIRST? Do NOT manually create project files - use templates.
|
|
195410
|
+
2. **[ ] Scenario Identification**: Clearly identify what type of project this is (Web/Mini Program/Database/UI)
|
|
195411
|
+
3. **[ ] Core Capability Confirmation**: Confirm all four core capabilities have been considered
|
|
195412
|
+
- UI Design: Have you explicitly read the file \`rules/ui-design/rule.md\` using file reading tools?
|
|
195413
|
+
- Database + Authentication: Have you referred to corresponding authentication and database skills?
|
|
195414
|
+
- Static Hosting Deployment: Have you understood the deployment process?
|
|
195415
|
+
- Backend Deployment: Have you understood cloud function or CloudRun deployment process?
|
|
195416
|
+
4. **[ ] UI Design Rules Check (MANDATORY)**: If task involves generating pages, interfaces, components, or styles:
|
|
195417
|
+
- Have you explicitly read the file \`rules/ui-design/rule.md\` using file reading tools? (Required: YES)
|
|
195418
|
+
- Have you output the design specification before writing code? (Required: YES)
|
|
195419
|
+
- Have you understood and will follow the design thinking framework? (Required: YES)
|
|
195420
|
+
5. **[ ] User Confirmation**: Confirm with user whether scenario identification and core capability understanding are correct
|
|
195421
|
+
6. **[ ] Rule Execution**: Strictly follow core capability requirements and relevant rule files for development
|
|
195422
|
+
|
|
195423
|
+
### ⚠️ Common Issues to Avoid
|
|
195424
|
+
- **❌ DO NOT manually create project files** - Always use \`downloadTemplate\` tool first for new projects
|
|
195425
|
+
- **❌ DO NOT skip reading UI design document** - Must explicitly read \`rules/ui-design/rule.md\` file before generating any UI code
|
|
195426
|
+
- Avoid skipping core capabilities and starting development directly
|
|
195427
|
+
- Avoid mixing APIs and authentication methods from different platforms
|
|
195428
|
+
- Avoid ignoring UI design rules: All tasks involving interfaces, pages, components, styles must explicitly read and strictly follow \`rules/ui-design/rule.md\`
|
|
195429
|
+
- Avoid ignoring database and authentication standards: Must use correct authentication methods and database operation methods
|
|
195430
|
+
- Important technical solutions should be confirmed with users
|
|
195431
|
+
|
|
195432
|
+
### Quality Assurance
|
|
195433
|
+
If development is found to not comply with standards, can:
|
|
195434
|
+
- Point out specific issues
|
|
195435
|
+
- Require re-execution of rule check process
|
|
195436
|
+
- Clearly specify rule files that need to be followed`;
|
|
195437
|
+
|
|
195438
|
+
|
|
195063
195439
|
/***/ }),
|
|
195064
195440
|
|
|
195065
195441
|
/***/ 68385:
|
|
@@ -200137,7 +200513,7 @@ ${envIdSection}
|
|
|
200137
200513
|
## 环境信息
|
|
200138
200514
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
200139
200515
|
- Node.js版本: ${process.version}
|
|
200140
|
-
- MCP 版本:${process.env.npm_package_version || "2.0.
|
|
200516
|
+
- MCP 版本:${process.env.npm_package_version || "2.0.2" || 0}
|
|
200141
200517
|
- 系统架构: ${os_1.default.arch()}
|
|
200142
200518
|
- 时间: ${new Date().toISOString()}
|
|
200143
200519
|
- 请求ID: ${requestId}
|
|
@@ -214712,7 +215088,9 @@ function registerSetupTools(server) {
|
|
|
214712
215088
|
// downloadTemplate - 下载项目模板 (cloud-incompatible)
|
|
214713
215089
|
server.registerTool("downloadTemplate", {
|
|
214714
215090
|
title: "下载项目模板",
|
|
214715
|
-
description: `自动下载并部署CloudBase
|
|
215091
|
+
description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
|
|
215092
|
+
|
|
215093
|
+
**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- 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- vscode: Visual Studio Code\n\n特别说明:\n- rules 模板会自动包含当前 mcp 版本号信息(版本号:${ true ? "2.0.2" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
214716
215094
|
inputSchema: {
|
|
214717
215095
|
template: zod_1.z.enum(["react", "vue", "miniprogram", "uniapp", "rules"]).describe("要下载的模板类型"),
|
|
214718
215096
|
ide: zod_1.z.enum(IDE_TYPES).optional().default("all").describe("指定要下载的IDE类型,默认为all(下载所有IDE配置)"),
|