@cloudbase/cloudbase-mcp 2.0.6 → 2.2.0-alpha.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/dist/cli.cjs +837 -189
- package/dist/index.cjs +837 -189
- package/dist/index.js +426 -153
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import * as __WEBPACK_EXTERNAL_MODULE__cloudbase_cals_lib_cjs_utils_mermaid_data
|
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_ws__ from "ws";
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE_winston_daily_rotate_file_69928d76__ from "winston-daily-rotate-file";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE_winston__ from "winston";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE__modelcontextprotocol_sdk_types_js_70eb1363__ from "@modelcontextprotocol/sdk/types.js";
|
|
7
8
|
import * as __WEBPACK_EXTERNAL_MODULE_net__ from "net";
|
|
8
9
|
import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
|
|
9
10
|
import * as __WEBPACK_EXTERNAL_MODULE__modelcontextprotocol_sdk_server_stdio_js_25848778__ from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
@@ -38,6 +39,7 @@ const fs_1 = __importDefault(__webpack_require__(421));
|
|
|
38
39
|
const path_1 = __importDefault(__webpack_require__(521));
|
|
39
40
|
const zod_1 = __webpack_require__(971);
|
|
40
41
|
const cloudbase_manager_js_1 = __webpack_require__(431);
|
|
42
|
+
const notification_js_1 = __webpack_require__(720);
|
|
41
43
|
// CloudRun service types
|
|
42
44
|
exports.CLOUDRUN_SERVICE_TYPES = ['function', 'container'];
|
|
43
45
|
// CloudRun access types
|
|
@@ -542,6 +544,58 @@ for await (let x of res.textStream) {
|
|
|
542
544
|
catch (error) {
|
|
543
545
|
// Ignore cloudbaserc.json creation errors
|
|
544
546
|
}
|
|
547
|
+
// Send deployment notification to CodeBuddy IDE
|
|
548
|
+
try {
|
|
549
|
+
// Query service details to get access URL
|
|
550
|
+
let serviceUrl = "";
|
|
551
|
+
try {
|
|
552
|
+
const serviceDetails = await cloudrunService.detail({ serverName: input.serverName });
|
|
553
|
+
// Extract access URL from service details
|
|
554
|
+
// Priority: DefaultDomainName > CustomDomainName > PublicDomain > InternalDomain
|
|
555
|
+
const details = serviceDetails; // Use any to access dynamic properties
|
|
556
|
+
if (details?.BaseInfo?.DefaultDomainName) {
|
|
557
|
+
// DefaultDomainName is already a complete URL (e.g., https://...)
|
|
558
|
+
serviceUrl = details.BaseInfo.DefaultDomainName;
|
|
559
|
+
}
|
|
560
|
+
else if (details?.BaseInfo?.CustomDomainName) {
|
|
561
|
+
// CustomDomainName might be a domain without protocol
|
|
562
|
+
const customDomain = details.BaseInfo.CustomDomainName;
|
|
563
|
+
serviceUrl = customDomain.startsWith('http') ? customDomain : `https://${customDomain}`;
|
|
564
|
+
}
|
|
565
|
+
else if (details?.BaseInfo?.PublicDomain) {
|
|
566
|
+
serviceUrl = `https://${details.BaseInfo.PublicDomain}`;
|
|
567
|
+
}
|
|
568
|
+
else if (details?.BaseInfo?.InternalDomain) {
|
|
569
|
+
serviceUrl = `https://${details.BaseInfo.InternalDomain}`;
|
|
570
|
+
}
|
|
571
|
+
else if (details?.AccessInfo?.PublicDomain) {
|
|
572
|
+
serviceUrl = `https://${details.AccessInfo.PublicDomain}`;
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
serviceUrl = ""; // URL not available
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
catch (detailErr) {
|
|
579
|
+
// If query fails, continue with empty URL
|
|
580
|
+
serviceUrl = "";
|
|
581
|
+
}
|
|
582
|
+
// Extract project name from targetPath
|
|
583
|
+
const projectName = path_1.default.basename(targetPath);
|
|
584
|
+
// Build console URL
|
|
585
|
+
const consoleUrl = `https://tcb.cloud.tencent.com/dev?envId=${currentEnvId}#/platform-run/service/detail?serverName=${input.serverName}&tabId=overview&envId=${currentEnvId}`;
|
|
586
|
+
// Send notification
|
|
587
|
+
await (0, notification_js_1.sendDeployNotification)(server, {
|
|
588
|
+
deployType: 'cloudrun',
|
|
589
|
+
url: serviceUrl,
|
|
590
|
+
projectId: currentEnvId,
|
|
591
|
+
projectName: projectName,
|
|
592
|
+
consoleUrl: consoleUrl
|
|
593
|
+
});
|
|
594
|
+
}
|
|
595
|
+
catch (notifyErr) {
|
|
596
|
+
// Notification failure should not affect deployment flow
|
|
597
|
+
// Error is already logged in sendDeployNotification
|
|
598
|
+
}
|
|
545
599
|
return {
|
|
546
600
|
content: [
|
|
547
601
|
{
|
|
@@ -2664,6 +2718,7 @@ async function registerRagTools(server) {
|
|
|
2664
2718
|
}
|
|
2665
2719
|
});
|
|
2666
2720
|
let skills = [];
|
|
2721
|
+
let openapis = [];
|
|
2667
2722
|
// 知识库检索
|
|
2668
2723
|
try {
|
|
2669
2724
|
skills = await prepareKnowledgeBaseWebTemplate();
|
|
@@ -2673,22 +2728,40 @@ async function registerRagTools(server) {
|
|
|
2673
2728
|
error,
|
|
2674
2729
|
});
|
|
2675
2730
|
}
|
|
2731
|
+
// OpenAPI 文档准备
|
|
2732
|
+
try {
|
|
2733
|
+
openapis = await prepareOpenAPIDocs();
|
|
2734
|
+
}
|
|
2735
|
+
catch (error) {
|
|
2736
|
+
(0, logger_js_1.warn)("[searchKnowledgeBase] Failed to prepare OpenAPI docs", {
|
|
2737
|
+
error,
|
|
2738
|
+
});
|
|
2739
|
+
}
|
|
2676
2740
|
server.registerTool?.("searchKnowledgeBase", {
|
|
2677
2741
|
title: "云开发知识库检索",
|
|
2678
|
-
description: `云开发知识库智能检索工具,支持向量查询 (vector)
|
|
2742
|
+
description: `云开发知识库智能检索工具,支持向量查询 (vector)、固定文档 (doc) 和 OpenAPI 文档 (openapi) 查询。
|
|
2679
2743
|
|
|
2680
|
-
强烈推荐始终优先使用固定文档 (doc) 模式进行检索,仅当固定文档无法覆盖你的问题时,再使用向量查询 (vector) 模式。
|
|
2744
|
+
强烈推荐始终优先使用固定文档 (doc) 或 OpenAPI 文档 (openapi) 模式进行检索,仅当固定文档无法覆盖你的问题时,再使用向量查询 (vector) 模式。
|
|
2681
2745
|
|
|
2682
2746
|
固定文档 (doc) 查询当前支持 ${skills.length} 个固定文档,分别是:
|
|
2683
2747
|
${skills
|
|
2684
2748
|
.map((skill) => `文档名:${path.basename(path.dirname(skill.absolutePath))} 文档介绍:${skill.description}`)
|
|
2749
|
+
.join("\n")}
|
|
2750
|
+
|
|
2751
|
+
OpenAPI 文档 (openapi) 查询当前支持 ${openapis.length} 个 API 文档,分别是:
|
|
2752
|
+
${openapis
|
|
2753
|
+
.map((api) => `API名:${api.name} API介绍:${api.description}`)
|
|
2685
2754
|
.join("\n")}`,
|
|
2686
2755
|
inputSchema: {
|
|
2687
|
-
mode: zod_1.z.enum(["vector", "doc"]),
|
|
2756
|
+
mode: zod_1.z.enum(["vector", "doc", "openapi"]),
|
|
2688
2757
|
docName: zod_1.z
|
|
2689
2758
|
.enum(skills.map((skill) => path.basename(path.dirname(skill.absolutePath))))
|
|
2690
2759
|
.optional()
|
|
2691
2760
|
.describe("mode=doc 时指定。文档名称。"),
|
|
2761
|
+
apiName: zod_1.z
|
|
2762
|
+
.enum(openapis.map((api) => api.name))
|
|
2763
|
+
.optional()
|
|
2764
|
+
.describe("mode=openapi 时指定。API 名称。"),
|
|
2692
2765
|
threshold: zod_1.z
|
|
2693
2766
|
.number()
|
|
2694
2767
|
.default(0.5)
|
|
@@ -2718,7 +2791,7 @@ async function registerRagTools(server) {
|
|
|
2718
2791
|
openWorldHint: true,
|
|
2719
2792
|
category: "rag",
|
|
2720
2793
|
},
|
|
2721
|
-
}, async ({ id, content, options: { chunkExpand = [3, 3] } = {}, limit = 5, threshold = 0.5, mode, docName, }) => {
|
|
2794
|
+
}, async ({ id, content, options: { chunkExpand = [3, 3] } = {}, limit = 5, threshold = 0.5, mode, docName, apiName, }) => {
|
|
2722
2795
|
if (mode === "doc") {
|
|
2723
2796
|
const absolutePath = skills.find((skill) => skill.absolutePath.includes(docName)).absolutePath;
|
|
2724
2797
|
return {
|
|
@@ -2730,6 +2803,27 @@ async function registerRagTools(server) {
|
|
|
2730
2803
|
],
|
|
2731
2804
|
};
|
|
2732
2805
|
}
|
|
2806
|
+
if (mode === "openapi") {
|
|
2807
|
+
const api = openapis.find((api) => api.name === apiName);
|
|
2808
|
+
if (!api) {
|
|
2809
|
+
return {
|
|
2810
|
+
content: [
|
|
2811
|
+
{
|
|
2812
|
+
type: "text",
|
|
2813
|
+
text: `OpenAPI document "${apiName}" not found. Available APIs: ${openapis.map((a) => a.name).join(", ")}`,
|
|
2814
|
+
},
|
|
2815
|
+
],
|
|
2816
|
+
};
|
|
2817
|
+
}
|
|
2818
|
+
return {
|
|
2819
|
+
content: [
|
|
2820
|
+
{
|
|
2821
|
+
type: "text",
|
|
2822
|
+
text: `OpenAPI document: ${api.name}\nDescription: ${api.description}\nPath: ${api.absolutePath}\n\n${(await fs.readFile(api.absolutePath)).toString()}`,
|
|
2823
|
+
},
|
|
2824
|
+
],
|
|
2825
|
+
};
|
|
2826
|
+
}
|
|
2733
2827
|
// 枚举到后端 id 映射
|
|
2734
2828
|
const backendId = KnowledgeBaseIdMap[id] || id;
|
|
2735
2829
|
const signInRes = await fetch("https://tcb-advanced-a656fc.api.tcloudbasegateway.com/auth/v1/signin/anonymously", {
|
|
@@ -2806,6 +2900,65 @@ function extractDescriptionFromFrontMatter(content) {
|
|
|
2806
2900
|
.match(/^(?:decsription|description)\s*:\s*(.*)$/m);
|
|
2807
2901
|
return match ? match[1].trim() : null;
|
|
2808
2902
|
}
|
|
2903
|
+
// OpenAPI 文档 URL 列表
|
|
2904
|
+
const OPENAPI_SOURCES = [
|
|
2905
|
+
{
|
|
2906
|
+
name: "mysqldb",
|
|
2907
|
+
description: "MySQL RESTful API - 云开发 MySQL 数据库 HTTP API",
|
|
2908
|
+
url: "https://docs.cloudbase.net/openapi/mysqldb.v1.openapi.yaml",
|
|
2909
|
+
},
|
|
2910
|
+
{
|
|
2911
|
+
name: "functions",
|
|
2912
|
+
description: "Cloud Functions API - 云函数 HTTP API",
|
|
2913
|
+
url: "https://docs.cloudbase.net/openapi/functions.v1.openapi.yaml",
|
|
2914
|
+
},
|
|
2915
|
+
{
|
|
2916
|
+
name: "auth",
|
|
2917
|
+
description: "Authentication API - 身份认证 HTTP API",
|
|
2918
|
+
url: "https://docs.cloudbase.net/openapi/auth.v1.openapi.yaml",
|
|
2919
|
+
},
|
|
2920
|
+
{
|
|
2921
|
+
name: "cloudrun",
|
|
2922
|
+
description: "CloudRun API - 云托管服务 HTTP API",
|
|
2923
|
+
url: "https://docs.cloudbase.net/openapi/cloudrun.v1.openapi.yaml",
|
|
2924
|
+
},
|
|
2925
|
+
{
|
|
2926
|
+
name: "storage",
|
|
2927
|
+
description: "Storage API - 云存储 HTTP API",
|
|
2928
|
+
url: "https://docs.cloudbase.net/openapi/storage.v1.openapi.yaml",
|
|
2929
|
+
},
|
|
2930
|
+
];
|
|
2931
|
+
// 下载并准备 OpenAPI 文档
|
|
2932
|
+
async function prepareOpenAPIDocs() {
|
|
2933
|
+
const baseDir = path.join(os.homedir(), ".cloudbase-mcp", "openapi");
|
|
2934
|
+
await fs.mkdir(baseDir, { recursive: true });
|
|
2935
|
+
const results = [];
|
|
2936
|
+
await Promise.all(OPENAPI_SOURCES.map(async (source) => {
|
|
2937
|
+
try {
|
|
2938
|
+
const response = await fetch(source.url);
|
|
2939
|
+
if (!response.ok) {
|
|
2940
|
+
(0, logger_js_1.warn)(`[prepareOpenAPIDocs] Failed to download ${source.name}`, {
|
|
2941
|
+
status: response.status,
|
|
2942
|
+
});
|
|
2943
|
+
return;
|
|
2944
|
+
}
|
|
2945
|
+
const content = await response.text();
|
|
2946
|
+
const filePath = path.join(baseDir, `${source.name}.openapi.yaml`);
|
|
2947
|
+
await fs.writeFile(filePath, content, "utf8");
|
|
2948
|
+
results.push({
|
|
2949
|
+
name: source.name,
|
|
2950
|
+
description: source.description,
|
|
2951
|
+
absolutePath: filePath,
|
|
2952
|
+
});
|
|
2953
|
+
}
|
|
2954
|
+
catch (error) {
|
|
2955
|
+
(0, logger_js_1.warn)(`[prepareOpenAPIDocs] Failed to download ${source.name}`, {
|
|
2956
|
+
error,
|
|
2957
|
+
});
|
|
2958
|
+
}
|
|
2959
|
+
}));
|
|
2960
|
+
return results;
|
|
2961
|
+
}
|
|
2809
2962
|
async function collectSkillDescriptions(rootDir) {
|
|
2810
2963
|
const result = [];
|
|
2811
2964
|
async function walk(dir) {
|
|
@@ -3106,13 +3259,19 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_winston_daily_rotate_file_69928d76__;
|
|
|
3106
3259
|
/***/ }),
|
|
3107
3260
|
|
|
3108
3261
|
/***/ 279:
|
|
3109
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__)
|
|
3262
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3110
3263
|
|
|
3111
3264
|
|
|
3265
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3266
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
3267
|
+
};
|
|
3112
3268
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3113
3269
|
exports.registerHostingTools = registerHostingTools;
|
|
3270
|
+
const fs_1 = __importDefault(__webpack_require__(421));
|
|
3271
|
+
const path_1 = __importDefault(__webpack_require__(521));
|
|
3114
3272
|
const zod_1 = __webpack_require__(971);
|
|
3115
3273
|
const cloudbase_manager_js_1 = __webpack_require__(431);
|
|
3274
|
+
const notification_js_1 = __webpack_require__(720);
|
|
3116
3275
|
function registerHostingTools(server) {
|
|
3117
3276
|
// 获取 cloudBaseOptions,如果没有则为 undefined
|
|
3118
3277
|
const cloudBaseOptions = server.cloudBaseOptions;
|
|
@@ -3149,6 +3308,43 @@ function registerHostingTools(server) {
|
|
|
3149
3308
|
// 获取环境信息
|
|
3150
3309
|
const envInfo = await cloudbase.env.getEnvInfo();
|
|
3151
3310
|
const staticDomain = envInfo.EnvInfo?.StaticStorages?.[0]?.StaticDomain;
|
|
3311
|
+
const accessUrl = staticDomain ? `https://${staticDomain}/${cloudPath || ''}` : "";
|
|
3312
|
+
// Send deployment notification to CodeBuddy IDE
|
|
3313
|
+
try {
|
|
3314
|
+
const envId = await (0, cloudbase_manager_js_1.getEnvId)(cloudBaseOptions);
|
|
3315
|
+
// Extract project name from localPath
|
|
3316
|
+
let projectName = "unknown";
|
|
3317
|
+
if (localPath) {
|
|
3318
|
+
try {
|
|
3319
|
+
// If localPath is a file, get parent directory name; if it's a directory, get directory name
|
|
3320
|
+
const stats = fs_1.default.statSync(localPath);
|
|
3321
|
+
if (stats.isFile()) {
|
|
3322
|
+
projectName = path_1.default.basename(path_1.default.dirname(localPath));
|
|
3323
|
+
}
|
|
3324
|
+
else {
|
|
3325
|
+
projectName = path_1.default.basename(localPath);
|
|
3326
|
+
}
|
|
3327
|
+
}
|
|
3328
|
+
catch (statErr) {
|
|
3329
|
+
// If stat fails, try to extract from path directly
|
|
3330
|
+
projectName = path_1.default.basename(localPath);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
// Build console URL
|
|
3334
|
+
const consoleUrl = `https://tcb.cloud.tencent.com/dev?envId=${envId}#/static-hosting`;
|
|
3335
|
+
// Send notification
|
|
3336
|
+
await (0, notification_js_1.sendDeployNotification)(server, {
|
|
3337
|
+
deployType: 'hosting',
|
|
3338
|
+
url: accessUrl,
|
|
3339
|
+
projectId: envId,
|
|
3340
|
+
projectName: projectName,
|
|
3341
|
+
consoleUrl: consoleUrl
|
|
3342
|
+
});
|
|
3343
|
+
}
|
|
3344
|
+
catch (notifyErr) {
|
|
3345
|
+
// Notification failure should not affect deployment flow
|
|
3346
|
+
// Error is already logged in sendDeployNotification
|
|
3347
|
+
}
|
|
3152
3348
|
return {
|
|
3153
3349
|
content: [
|
|
3154
3350
|
{
|
|
@@ -3157,7 +3353,7 @@ function registerHostingTools(server) {
|
|
|
3157
3353
|
...result,
|
|
3158
3354
|
staticDomain,
|
|
3159
3355
|
message: "文件上传成功",
|
|
3160
|
-
accessUrl:
|
|
3356
|
+
accessUrl: accessUrl
|
|
3161
3357
|
}, null, 2)
|
|
3162
3358
|
}
|
|
3163
3359
|
]
|
|
@@ -5659,6 +5855,13 @@ async function getInteractiveServerSafe(mcpServer) {
|
|
|
5659
5855
|
}
|
|
5660
5856
|
|
|
5661
5857
|
|
|
5858
|
+
/***/ }),
|
|
5859
|
+
|
|
5860
|
+
/***/ 344:
|
|
5861
|
+
/***/ ((module) => {
|
|
5862
|
+
|
|
5863
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__modelcontextprotocol_sdk_types_js_70eb1363__;
|
|
5864
|
+
|
|
5662
5865
|
/***/ }),
|
|
5663
5866
|
|
|
5664
5867
|
/***/ 357:
|
|
@@ -6021,7 +6224,7 @@ ${envIdSection}
|
|
|
6021
6224
|
## 环境信息
|
|
6022
6225
|
- 操作系统: ${os_1.default.type()} ${os_1.default.release()}
|
|
6023
6226
|
- Node.js版本: ${process.version}
|
|
6024
|
-
- MCP 版本:${process.env.npm_package_version || "2.0.
|
|
6227
|
+
- MCP 版本:${process.env.npm_package_version || "2.2.0-alpha.0" || 0}
|
|
6025
6228
|
- 系统架构: ${os_1.default.arch()}
|
|
6026
6229
|
- 时间: ${new Date().toISOString()}
|
|
6027
6230
|
- 请求ID: ${requestId}
|
|
@@ -6188,7 +6391,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
6188
6391
|
// executeReadOnlySQL
|
|
6189
6392
|
server.registerTool?.("executeReadOnlySQL", {
|
|
6190
6393
|
title: "Execute read-only SQL query",
|
|
6191
|
-
description: "Execute a read-only SQL query on the SQL database. Note: For per-user ACL, each table should contain a fixed `_openid` column that represents the user and is used for access control.",
|
|
6394
|
+
description: "Execute a read-only SQL query on the SQL database. Note: For per-user ACL, each table should contain a fixed `_openid` column defined as `_openid VARCHAR(64) DEFAULT '' NOT NULL` that represents the user and is used for access control.",
|
|
6192
6395
|
inputSchema: {
|
|
6193
6396
|
sql: zod_1.z.string().describe("SQL query statement (SELECT queries only)"),
|
|
6194
6397
|
},
|
|
@@ -6247,7 +6450,7 @@ function registerSQLDatabaseTools(server) {
|
|
|
6247
6450
|
// executeWriteSQL
|
|
6248
6451
|
server.registerTool?.("executeWriteSQL", {
|
|
6249
6452
|
title: "Execute write SQL statement",
|
|
6250
|
-
description: "Execute a write SQL statement on the SQL database (INSERT, UPDATE, DELETE, etc.). Whenever you create a new table, you **must**
|
|
6453
|
+
description: "Execute a write SQL statement on the SQL database (INSERT, UPDATE, DELETE, etc.). Whenever you create a new table, you **must** include a fixed `_openid` column defined as `_openid VARCHAR(64) DEFAULT '' NOT NULL` that represents the user and is used for access control.",
|
|
6251
6454
|
inputSchema: {
|
|
6252
6455
|
sql: zod_1.z
|
|
6253
6456
|
.string()
|
|
@@ -6339,12 +6542,14 @@ const rag_js_1 = __webpack_require__(215);
|
|
|
6339
6542
|
const setup_js_1 = __webpack_require__(556);
|
|
6340
6543
|
const storage_js_1 = __webpack_require__(848);
|
|
6341
6544
|
// import { registerMiniprogramTools } from "./tools/miniprogram.js";
|
|
6545
|
+
const types_js_1 = __webpack_require__(344);
|
|
6342
6546
|
const cloudrun_js_1 = __webpack_require__(23);
|
|
6343
6547
|
const dataModel_js_1 = __webpack_require__(52);
|
|
6344
6548
|
const gateway_js_1 = __webpack_require__(319);
|
|
6345
6549
|
const invite_code_js_1 = __webpack_require__(760);
|
|
6346
6550
|
const security_rule_js_1 = __webpack_require__(862);
|
|
6347
6551
|
const cloud_mode_js_1 = __webpack_require__(684);
|
|
6552
|
+
const logger_js_1 = __webpack_require__(39);
|
|
6348
6553
|
const tool_wrapper_js_1 = __webpack_require__(363);
|
|
6349
6554
|
// 默认插件列表
|
|
6350
6555
|
const DEFAULT_PLUGINS = [
|
|
@@ -6445,6 +6650,13 @@ async function createCloudBaseMcpServer(options) {
|
|
|
6445
6650
|
...(ide === "CodeBuddy" ? { logging: {} } : {}),
|
|
6446
6651
|
},
|
|
6447
6652
|
});
|
|
6653
|
+
// Only set logging handler if logging capability is declared
|
|
6654
|
+
if (ide === "CodeBuddy") {
|
|
6655
|
+
server.server.setRequestHandler(types_js_1.SetLevelRequestSchema, (request, extra) => {
|
|
6656
|
+
(0, logger_js_1.info)(`--- Logging level: ${request.params.level}`);
|
|
6657
|
+
return {};
|
|
6658
|
+
});
|
|
6659
|
+
}
|
|
6448
6660
|
// Store cloudBaseOptions in server instance for tools to access
|
|
6449
6661
|
if (cloudBaseOptions) {
|
|
6450
6662
|
server.cloudBaseOptions = cloudBaseOptions;
|
|
@@ -6475,10 +6687,10 @@ function getDefaultServer() {
|
|
|
6475
6687
|
}
|
|
6476
6688
|
var stdio_js_1 = __webpack_require__(448);
|
|
6477
6689
|
Object.defineProperty(exports, "StdioServerTransport", ({ enumerable: true, get: function () { return stdio_js_1.StdioServerTransport; } }));
|
|
6478
|
-
var
|
|
6479
|
-
Object.defineProperty(exports, "error", ({ enumerable: true, get: function () { return
|
|
6480
|
-
Object.defineProperty(exports, "info", ({ enumerable: true, get: function () { return
|
|
6481
|
-
Object.defineProperty(exports, "warn", ({ enumerable: true, get: function () { return
|
|
6690
|
+
var logger_js_2 = __webpack_require__(39);
|
|
6691
|
+
Object.defineProperty(exports, "error", ({ enumerable: true, get: function () { return logger_js_2.error; } }));
|
|
6692
|
+
Object.defineProperty(exports, "info", ({ enumerable: true, get: function () { return logger_js_2.info; } }));
|
|
6693
|
+
Object.defineProperty(exports, "warn", ({ enumerable: true, get: function () { return logger_js_2.warn; } }));
|
|
6482
6694
|
var telemetry_js_1 = __webpack_require__(880);
|
|
6483
6695
|
Object.defineProperty(exports, "reportToolCall", ({ enumerable: true, get: function () { return telemetry_js_1.reportToolCall; } }));
|
|
6484
6696
|
Object.defineProperty(exports, "reportToolkitLifecycle", ({ enumerable: true, get: function () { return telemetry_js_1.reportToolkitLifecycle; } }));
|
|
@@ -6640,7 +6852,7 @@ async function getCloudBaseManager(options = {}) {
|
|
|
6640
6852
|
secretKey,
|
|
6641
6853
|
envId: finalEnvId || loginEnvId,
|
|
6642
6854
|
token,
|
|
6643
|
-
proxy: process.env.http_proxy
|
|
6855
|
+
proxy: process.env.http_proxy,
|
|
6644
6856
|
});
|
|
6645
6857
|
return manager;
|
|
6646
6858
|
}
|
|
@@ -6657,13 +6869,8 @@ async function getCloudBaseManager(options = {}) {
|
|
|
6657
6869
|
function createCloudBaseManagerWithOptions(cloudBaseOptions) {
|
|
6658
6870
|
(0, logger_js_1.debug)('使用传入的 CloudBase 配置创建 manager:', cloudBaseOptions);
|
|
6659
6871
|
const manager = new manager_node_1.default({
|
|
6660
|
-
|
|
6661
|
-
secretKey: cloudBaseOptions.secretKey,
|
|
6662
|
-
envId: cloudBaseOptions.envId,
|
|
6663
|
-
token: cloudBaseOptions.token,
|
|
6872
|
+
...cloudBaseOptions,
|
|
6664
6873
|
proxy: cloudBaseOptions.proxy || process.env.http_proxy,
|
|
6665
|
-
region: cloudBaseOptions.region,
|
|
6666
|
-
envType: cloudBaseOptions.envType
|
|
6667
6874
|
});
|
|
6668
6875
|
return manager;
|
|
6669
6876
|
}
|
|
@@ -6918,26 +7125,26 @@ const path = __importStar(__webpack_require__(521));
|
|
|
6918
7125
|
const zod_1 = __webpack_require__(971);
|
|
6919
7126
|
// CloudBase 模板配置
|
|
6920
7127
|
const TEMPLATES = {
|
|
6921
|
-
|
|
7128
|
+
react: {
|
|
6922
7129
|
description: "React + CloudBase 全栈应用模板",
|
|
6923
|
-
url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-react-template.zip"
|
|
7130
|
+
url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-react-template.zip",
|
|
6924
7131
|
},
|
|
6925
|
-
|
|
7132
|
+
vue: {
|
|
6926
7133
|
description: "Vue + CloudBase 全栈应用模板",
|
|
6927
|
-
url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-vue-template.zip"
|
|
7134
|
+
url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-vue-template.zip",
|
|
6928
7135
|
},
|
|
6929
|
-
|
|
7136
|
+
miniprogram: {
|
|
6930
7137
|
description: "微信小程序 + 云开发模板",
|
|
6931
|
-
url: "https://static.cloudbase.net/cloudbase-examples/miniprogram-cloudbase-miniprogram-template.zip"
|
|
7138
|
+
url: "https://static.cloudbase.net/cloudbase-examples/miniprogram-cloudbase-miniprogram-template.zip",
|
|
6932
7139
|
},
|
|
6933
|
-
|
|
7140
|
+
uniapp: {
|
|
6934
7141
|
description: "UniApp + CloudBase 跨端应用模板",
|
|
6935
|
-
url: "https://static.cloudbase.net/cloudbase-examples/universal-cloudbase-uniapp-template.zip"
|
|
7142
|
+
url: "https://static.cloudbase.net/cloudbase-examples/universal-cloudbase-uniapp-template.zip",
|
|
6936
7143
|
},
|
|
6937
|
-
|
|
7144
|
+
rules: {
|
|
6938
7145
|
description: "AI编辑器配置模板(包含所有主流编辑器配置)",
|
|
6939
|
-
url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-project.zip"
|
|
6940
|
-
}
|
|
7146
|
+
url: "https://static.cloudbase.net/cloudbase-examples/web-cloudbase-project.zip",
|
|
7147
|
+
},
|
|
6941
7148
|
};
|
|
6942
7149
|
// IDE类型枚举
|
|
6943
7150
|
const IDE_TYPES = [
|
|
@@ -6957,22 +7164,13 @@ const IDE_TYPES = [
|
|
|
6957
7164
|
"roocode", // RooCode AI编辑器
|
|
6958
7165
|
"tongyi-lingma", // 通义灵码
|
|
6959
7166
|
"trae", // Trae AI编辑器
|
|
6960
|
-
"vscode" // Visual Studio Code
|
|
7167
|
+
"vscode", // Visual Studio Code
|
|
6961
7168
|
];
|
|
6962
7169
|
// IDE到文件的映射关系
|
|
6963
7170
|
const IDE_FILE_MAPPINGS = {
|
|
6964
|
-
"cursor"
|
|
6965
|
-
|
|
6966
|
-
|
|
6967
|
-
],
|
|
6968
|
-
"windsurf": [
|
|
6969
|
-
".windsurf/rules/cloudbase-rules.md"
|
|
6970
|
-
],
|
|
6971
|
-
"codebuddy": [
|
|
6972
|
-
".rules/cloudbase-rules.md",
|
|
6973
|
-
"CODEBUDDY.md",
|
|
6974
|
-
".mcp.json"
|
|
6975
|
-
],
|
|
7171
|
+
cursor: [".cursor/rules/cloudbase-rules.mdc", ".cursor/mcp.json"],
|
|
7172
|
+
windsurf: [".windsurf/rules/cloudbase-rules.md"],
|
|
7173
|
+
codebuddy: [".rules/cloudbase-rules.md", "CODEBUDDY.md", ".mcp.json"],
|
|
6976
7174
|
"claude-code": [
|
|
6977
7175
|
"CLAUDE.md",
|
|
6978
7176
|
".mcp.json",
|
|
@@ -6981,49 +7179,22 @@ const IDE_FILE_MAPPINGS = {
|
|
|
6981
7179
|
".claude/commands/spec.md",
|
|
6982
7180
|
".claude/commands/no_spec.md",
|
|
6983
7181
|
],
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
],
|
|
6987
|
-
"
|
|
6988
|
-
".gemini/GEMINI.md",
|
|
6989
|
-
".gemini/settings.json"
|
|
6990
|
-
],
|
|
6991
|
-
"opencode": [
|
|
6992
|
-
".opencode.json"
|
|
6993
|
-
],
|
|
6994
|
-
"qwen-code": [
|
|
6995
|
-
".qwen/QWEN.md",
|
|
6996
|
-
".qwen/settings.json"
|
|
6997
|
-
],
|
|
7182
|
+
cline: [".clinerules/cloudbase-rules.mdc"],
|
|
7183
|
+
"gemini-cli": [".gemini/GEMINI.md", ".gemini/settings.json"],
|
|
7184
|
+
opencode: [".opencode.json"],
|
|
7185
|
+
"qwen-code": [".qwen/QWEN.md", ".qwen/settings.json"],
|
|
6998
7186
|
"baidu-comate": [
|
|
6999
7187
|
".comate/rules/cloudbase-rules.mdr",
|
|
7000
7188
|
".comate/rules/cloudbaase-rules.mdr",
|
|
7001
|
-
".comate/mcp.json"
|
|
7189
|
+
".comate/mcp.json",
|
|
7002
7190
|
],
|
|
7003
|
-
"openai-codex-cli": [
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
],
|
|
7007
|
-
"
|
|
7008
|
-
|
|
7009
|
-
],
|
|
7010
|
-
"github-copilot": [
|
|
7011
|
-
".github/copilot-instructions.md"
|
|
7012
|
-
],
|
|
7013
|
-
"roocode": [
|
|
7014
|
-
".roo/rules/cloudbaase-rules.md",
|
|
7015
|
-
".roo/mcp.json"
|
|
7016
|
-
],
|
|
7017
|
-
"tongyi-lingma": [
|
|
7018
|
-
".lingma/rules/cloudbaase-rules.md"
|
|
7019
|
-
],
|
|
7020
|
-
"trae": [
|
|
7021
|
-
".trae/rules/cloudbase-rules.md"
|
|
7022
|
-
],
|
|
7023
|
-
"vscode": [
|
|
7024
|
-
".vscode/mcp.json",
|
|
7025
|
-
".vscode/settings.json"
|
|
7026
|
-
]
|
|
7191
|
+
"openai-codex-cli": [".codex/config.toml", "AGENTS.md"],
|
|
7192
|
+
"augment-code": [".augment-guidelines"],
|
|
7193
|
+
"github-copilot": [".github/copilot-instructions.md"],
|
|
7194
|
+
roocode: [".roo/rules/cloudbaase-rules.md", ".roo/mcp.json"],
|
|
7195
|
+
"tongyi-lingma": [".lingma/rules/cloudbaase-rules.md"],
|
|
7196
|
+
trae: [".trae/rules/cloudbase-rules.md"],
|
|
7197
|
+
vscode: [".vscode/mcp.json", ".vscode/settings.json"],
|
|
7027
7198
|
};
|
|
7028
7199
|
// 所有IDE配置文件的完整列表 - 通过IDE_FILE_MAPPINGS计算得出
|
|
7029
7200
|
const ALL_IDE_FILES = Array.from(new Set(Object.values(IDE_FILE_MAPPINGS).flat()));
|
|
@@ -7031,51 +7202,87 @@ const ALL_IDE_FILES = Array.from(new Set(Object.values(IDE_FILE_MAPPINGS).flat()
|
|
|
7031
7202
|
IDE_FILE_MAPPINGS["all"] = ALL_IDE_FILES;
|
|
7032
7203
|
// IDE描述映射
|
|
7033
7204
|
const IDE_DESCRIPTIONS = {
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7205
|
+
all: "所有IDE配置",
|
|
7206
|
+
cursor: "Cursor AI编辑器",
|
|
7207
|
+
windsurf: "WindSurf AI编辑器",
|
|
7208
|
+
codebuddy: "CodeBuddy AI编辑器",
|
|
7038
7209
|
"claude-code": "Claude Code AI编辑器",
|
|
7039
|
-
|
|
7210
|
+
cline: "Cline AI编辑器",
|
|
7040
7211
|
"gemini-cli": "Gemini CLI",
|
|
7041
|
-
|
|
7212
|
+
opencode: "OpenCode AI编辑器",
|
|
7042
7213
|
"qwen-code": "通义灵码",
|
|
7043
7214
|
"baidu-comate": "百度Comate",
|
|
7044
7215
|
"openai-codex-cli": "OpenAI Codex CLI",
|
|
7045
7216
|
"augment-code": "Augment Code",
|
|
7046
7217
|
"github-copilot": "GitHub Copilot",
|
|
7047
|
-
|
|
7218
|
+
roocode: "RooCode AI编辑器",
|
|
7048
7219
|
"tongyi-lingma": "通义灵码",
|
|
7049
|
-
|
|
7050
|
-
|
|
7220
|
+
trae: "Trae AI编辑器",
|
|
7221
|
+
vscode: "Visual Studio Code",
|
|
7222
|
+
};
|
|
7223
|
+
// INTEGRATION_IDE 环境变量值到 IDE 类型的映射
|
|
7224
|
+
const INTEGRATION_IDE_MAPPING = {
|
|
7225
|
+
Cursor: "cursor",
|
|
7226
|
+
WindSurf: "windsurf",
|
|
7227
|
+
CodeBuddy: "codebuddy",
|
|
7228
|
+
CodeBuddyManual: "codebuddy",
|
|
7229
|
+
CodeBuddyCode: "codebuddy",
|
|
7230
|
+
"Claude Code": "claude-code",
|
|
7231
|
+
CLINE: "cline",
|
|
7232
|
+
"Gemini CLI": "gemini-cli",
|
|
7233
|
+
OpenCode: "opencode",
|
|
7234
|
+
"Qwen Code": "qwen-code",
|
|
7235
|
+
"Baidu Comate": "baidu-comate",
|
|
7236
|
+
"OpenAI Codex CLI": "openai-codex-cli",
|
|
7237
|
+
"Augment Code": "augment-code",
|
|
7238
|
+
"GitHub Copilot": "github-copilot",
|
|
7239
|
+
RooCode: "roocode",
|
|
7240
|
+
"Tongyi Lingma": "tongyi-lingma",
|
|
7241
|
+
Trae: "trae",
|
|
7242
|
+
VSCode: "vscode",
|
|
7051
7243
|
};
|
|
7244
|
+
// 根据 INTEGRATION_IDE 环境变量获取默认 IDE 类型
|
|
7245
|
+
function getDefaultIDEFromEnv() {
|
|
7246
|
+
const integrationIDE = process.env.INTEGRATION_IDE;
|
|
7247
|
+
if (integrationIDE) {
|
|
7248
|
+
const mappedIDE = INTEGRATION_IDE_MAPPING[integrationIDE];
|
|
7249
|
+
if (mappedIDE) {
|
|
7250
|
+
return mappedIDE;
|
|
7251
|
+
}
|
|
7252
|
+
}
|
|
7253
|
+
return "all";
|
|
7254
|
+
}
|
|
7052
7255
|
// 下载文件到临时目录
|
|
7053
7256
|
async function downloadFile(url, filePath) {
|
|
7054
7257
|
return new Promise((resolve, reject) => {
|
|
7055
|
-
const client = url.startsWith(
|
|
7056
|
-
client
|
|
7258
|
+
const client = url.startsWith("https:") ? https : http;
|
|
7259
|
+
client
|
|
7260
|
+
.get(url, (res) => {
|
|
7057
7261
|
if (res.statusCode === 200) {
|
|
7058
7262
|
const file = fs.createWriteStream(filePath);
|
|
7059
7263
|
res.pipe(file);
|
|
7060
|
-
file.on(
|
|
7264
|
+
file.on("finish", () => {
|
|
7061
7265
|
file.close();
|
|
7062
7266
|
resolve();
|
|
7063
7267
|
});
|
|
7064
|
-
file.on(
|
|
7268
|
+
file.on("error", reject);
|
|
7065
7269
|
}
|
|
7066
7270
|
else if (res.statusCode === 302 || res.statusCode === 301) {
|
|
7067
7271
|
// 处理重定向
|
|
7068
7272
|
if (res.headers.location) {
|
|
7069
|
-
downloadFile(res.headers.location, filePath)
|
|
7273
|
+
downloadFile(res.headers.location, filePath)
|
|
7274
|
+
.then(resolve)
|
|
7275
|
+
.catch(reject);
|
|
7070
7276
|
}
|
|
7071
7277
|
else {
|
|
7072
|
-
reject(new Error(
|
|
7278
|
+
reject(new Error("重定向但没有location header"));
|
|
7073
7279
|
}
|
|
7074
7280
|
}
|
|
7075
7281
|
else {
|
|
7076
7282
|
reject(new Error(`下载失败,状态码: ${res.statusCode}`));
|
|
7077
7283
|
}
|
|
7078
|
-
})
|
|
7284
|
+
})
|
|
7285
|
+
.on("error", reject);
|
|
7079
7286
|
});
|
|
7080
7287
|
}
|
|
7081
7288
|
// 解压ZIP文件
|
|
@@ -7088,7 +7295,7 @@ async function extractZip(zipPath, extractPath) {
|
|
|
7088
7295
|
zip.extractAllTo(extractPath, true);
|
|
7089
7296
|
}
|
|
7090
7297
|
catch (error) {
|
|
7091
|
-
throw new Error(`解压失败: ${error instanceof Error ? error.message :
|
|
7298
|
+
throw new Error(`解压失败: ${error instanceof Error ? error.message : "未知错误"}`);
|
|
7092
7299
|
}
|
|
7093
7300
|
}
|
|
7094
7301
|
// 获取目录下所有文件的相对路径列表
|
|
@@ -7112,7 +7319,7 @@ async function copyFileIfNotExists(src, dest) {
|
|
|
7112
7319
|
try {
|
|
7113
7320
|
// 检查目标文件是否存在
|
|
7114
7321
|
if (fs.existsSync(dest)) {
|
|
7115
|
-
return { copied: false, reason:
|
|
7322
|
+
return { copied: false, reason: "文件已存在" };
|
|
7116
7323
|
}
|
|
7117
7324
|
// 创建目标目录
|
|
7118
7325
|
await fsPromises.mkdir(path.dirname(dest), { recursive: true });
|
|
@@ -7121,14 +7328,17 @@ async function copyFileIfNotExists(src, dest) {
|
|
|
7121
7328
|
return { copied: true };
|
|
7122
7329
|
}
|
|
7123
7330
|
catch (error) {
|
|
7124
|
-
return {
|
|
7331
|
+
return {
|
|
7332
|
+
copied: false,
|
|
7333
|
+
reason: `复制失败: ${error instanceof Error ? error.message : "未知错误"}`,
|
|
7334
|
+
};
|
|
7125
7335
|
}
|
|
7126
7336
|
}
|
|
7127
7337
|
// 复制文件,支持覆盖模式
|
|
7128
7338
|
// 判断是否应该跳过 README.md 文件
|
|
7129
7339
|
function shouldSkipReadme(template, destPath, overwrite) {
|
|
7130
|
-
const isReadme = path.basename(destPath).toLowerCase() ===
|
|
7131
|
-
const isRulesTemplate = template ===
|
|
7340
|
+
const isReadme = path.basename(destPath).toLowerCase() === "readme.md";
|
|
7341
|
+
const isRulesTemplate = template === "rules";
|
|
7132
7342
|
const exists = fs.existsSync(destPath);
|
|
7133
7343
|
return isReadme && isRulesTemplate && exists && !overwrite;
|
|
7134
7344
|
}
|
|
@@ -7137,11 +7347,15 @@ async function copyFile(src, dest, overwrite = false, template) {
|
|
|
7137
7347
|
const destExists = fs.existsSync(dest);
|
|
7138
7348
|
// 检查是否需要跳过 README.md 文件(仅对 rules 模板)
|
|
7139
7349
|
if (template && shouldSkipReadme(template, dest, overwrite)) {
|
|
7140
|
-
return {
|
|
7350
|
+
return {
|
|
7351
|
+
copied: false,
|
|
7352
|
+
reason: "README.md 文件已存在,已保护",
|
|
7353
|
+
action: "protected",
|
|
7354
|
+
};
|
|
7141
7355
|
}
|
|
7142
7356
|
// 如果目标文件存在且不允许覆盖
|
|
7143
7357
|
if (destExists && !overwrite) {
|
|
7144
|
-
return { copied: false, reason:
|
|
7358
|
+
return { copied: false, reason: "文件已存在", action: "skipped" };
|
|
7145
7359
|
}
|
|
7146
7360
|
// 创建目标目录
|
|
7147
7361
|
await fsPromises.mkdir(path.dirname(dest), { recursive: true });
|
|
@@ -7149,11 +7363,14 @@ async function copyFile(src, dest, overwrite = false, template) {
|
|
|
7149
7363
|
await fsPromises.copyFile(src, dest);
|
|
7150
7364
|
return {
|
|
7151
7365
|
copied: true,
|
|
7152
|
-
action: destExists ?
|
|
7366
|
+
action: destExists ? "overwritten" : "created",
|
|
7153
7367
|
};
|
|
7154
7368
|
}
|
|
7155
7369
|
catch (error) {
|
|
7156
|
-
return {
|
|
7370
|
+
return {
|
|
7371
|
+
copied: false,
|
|
7372
|
+
reason: `复制失败: ${error instanceof Error ? error.message : "未知错误"}`,
|
|
7373
|
+
};
|
|
7157
7374
|
}
|
|
7158
7375
|
}
|
|
7159
7376
|
// IDE验证函数
|
|
@@ -7161,13 +7378,13 @@ function validateIDE(ide) {
|
|
|
7161
7378
|
if (ide === "all") {
|
|
7162
7379
|
return { valid: true };
|
|
7163
7380
|
}
|
|
7164
|
-
const supportedIDEs = IDE_TYPES.filter(type => type !== "all");
|
|
7381
|
+
const supportedIDEs = IDE_TYPES.filter((type) => type !== "all");
|
|
7165
7382
|
const isValid = supportedIDEs.includes(ide);
|
|
7166
7383
|
if (!isValid) {
|
|
7167
7384
|
return {
|
|
7168
7385
|
valid: false,
|
|
7169
7386
|
error: `不支持的IDE类型: ${ide}`,
|
|
7170
|
-
supportedIDEs: supportedIDEs
|
|
7387
|
+
supportedIDEs: supportedIDEs,
|
|
7171
7388
|
};
|
|
7172
7389
|
}
|
|
7173
7390
|
return { valid: true };
|
|
@@ -7182,9 +7399,9 @@ function filterFilesByIDE(files, ide) {
|
|
|
7182
7399
|
return files; // 如果找不到映射,返回所有文件
|
|
7183
7400
|
}
|
|
7184
7401
|
// 计算需要排除的IDE文件(除了当前IDE需要的文件)
|
|
7185
|
-
const filesToExclude = ALL_IDE_FILES.filter(file => !ideFiles.includes(file));
|
|
7402
|
+
const filesToExclude = ALL_IDE_FILES.filter((file) => !ideFiles.includes(file));
|
|
7186
7403
|
// 排除不需要的IDE配置文件,保留其他所有文件
|
|
7187
|
-
return files.filter(file => !filesToExclude.includes(file));
|
|
7404
|
+
return files.filter((file) => !filesToExclude.includes(file));
|
|
7188
7405
|
}
|
|
7189
7406
|
// 创建过滤后的目录结构
|
|
7190
7407
|
async function createFilteredDirectory(extractDir, filteredFiles, ide) {
|
|
@@ -7192,7 +7409,7 @@ async function createFilteredDirectory(extractDir, filteredFiles, ide) {
|
|
|
7192
7409
|
return extractDir; // 如果选择所有IDE,直接返回原目录
|
|
7193
7410
|
}
|
|
7194
7411
|
// 创建新的过滤后目录
|
|
7195
|
-
const filteredDir = path.join(path.dirname(extractDir),
|
|
7412
|
+
const filteredDir = path.join(path.dirname(extractDir), "filtered");
|
|
7196
7413
|
await fsPromises.mkdir(filteredDir, { recursive: true });
|
|
7197
7414
|
// 只复制过滤后的文件到新目录
|
|
7198
7415
|
for (const relativePath of filteredFiles) {
|
|
@@ -7211,32 +7428,42 @@ function registerSetupTools(server) {
|
|
|
7211
7428
|
title: "下载项目模板",
|
|
7212
7429
|
description: `自动下载并部署CloudBase项目模板。⚠️ **MANDATORY FOR NEW PROJECTS** ⚠️
|
|
7213
7430
|
|
|
7214
|
-
**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.
|
|
7431
|
+
**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.2.0-alpha.0" : 0}),便于后续维护和版本追踪\n- 下载 rules 模板时,如果项目中已存在 README.md 文件,系统会自动保护该文件不被覆盖(除非设置 overwrite=true)`,
|
|
7215
7432
|
inputSchema: {
|
|
7216
|
-
template: zod_1.z
|
|
7217
|
-
|
|
7218
|
-
|
|
7433
|
+
template: zod_1.z
|
|
7434
|
+
.enum(["react", "vue", "miniprogram", "uniapp", "rules"])
|
|
7435
|
+
.describe("要下载的模板类型"),
|
|
7436
|
+
ide: zod_1.z
|
|
7437
|
+
.enum(IDE_TYPES)
|
|
7438
|
+
.optional()
|
|
7439
|
+
.describe("指定要下载的IDE类型。如果未指定,会根据 INTEGRATION_IDE 环境变量自动选择对应的IDE配置;如果环境变量也未设置,则默认下载所有IDE配置"),
|
|
7440
|
+
overwrite: zod_1.z
|
|
7441
|
+
.boolean()
|
|
7442
|
+
.optional()
|
|
7443
|
+
.describe("是否覆盖已存在的文件,默认为false(不覆盖)"),
|
|
7219
7444
|
},
|
|
7220
7445
|
annotations: {
|
|
7221
7446
|
readOnlyHint: false,
|
|
7222
7447
|
destructiveHint: false,
|
|
7223
7448
|
idempotentHint: false,
|
|
7224
7449
|
openWorldHint: true,
|
|
7225
|
-
category: "setup"
|
|
7226
|
-
}
|
|
7227
|
-
}, async ({ template, ide
|
|
7450
|
+
category: "setup",
|
|
7451
|
+
},
|
|
7452
|
+
}, async ({ template, ide, overwrite = false, }) => {
|
|
7228
7453
|
try {
|
|
7454
|
+
// 如果没有传入 ide 参数,根据 INTEGRATION_IDE 环境变量获取默认值
|
|
7455
|
+
const resolvedIDE = ide ?? getDefaultIDEFromEnv();
|
|
7229
7456
|
// 验证IDE类型
|
|
7230
|
-
const ideValidation = validateIDE(
|
|
7457
|
+
const ideValidation = validateIDE(resolvedIDE);
|
|
7231
7458
|
if (!ideValidation.valid) {
|
|
7232
|
-
const supportedIDEs = ideValidation.supportedIDEs?.join(
|
|
7459
|
+
const supportedIDEs = ideValidation.supportedIDEs?.join(", ") || "";
|
|
7233
7460
|
return {
|
|
7234
7461
|
content: [
|
|
7235
7462
|
{
|
|
7236
7463
|
type: "text",
|
|
7237
|
-
text: `❌ ${ideValidation.error}\n\n支持的IDE类型: ${supportedIDEs}
|
|
7238
|
-
}
|
|
7239
|
-
]
|
|
7464
|
+
text: `❌ ${ideValidation.error}\n\n支持的IDE类型: ${supportedIDEs}`,
|
|
7465
|
+
},
|
|
7466
|
+
],
|
|
7240
7467
|
};
|
|
7241
7468
|
}
|
|
7242
7469
|
const templateConfig = TEMPLATES[template];
|
|
@@ -7245,23 +7472,23 @@ function registerSetupTools(server) {
|
|
|
7245
7472
|
content: [
|
|
7246
7473
|
{
|
|
7247
7474
|
type: "text",
|
|
7248
|
-
text: `❌ 不支持的模板类型: ${template}
|
|
7249
|
-
}
|
|
7250
|
-
]
|
|
7475
|
+
text: `❌ 不支持的模板类型: ${template}`,
|
|
7476
|
+
},
|
|
7477
|
+
],
|
|
7251
7478
|
};
|
|
7252
7479
|
}
|
|
7253
7480
|
// 创建临时目录
|
|
7254
|
-
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(),
|
|
7255
|
-
const zipPath = path.join(tempDir,
|
|
7256
|
-
const extractDir = path.join(tempDir,
|
|
7481
|
+
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "cloudbase-template-"));
|
|
7482
|
+
const zipPath = path.join(tempDir, "template.zip");
|
|
7483
|
+
const extractDir = path.join(tempDir, "extracted");
|
|
7257
7484
|
// 下载和解压
|
|
7258
7485
|
await downloadFile(templateConfig.url, zipPath);
|
|
7259
7486
|
await extractZip(zipPath, extractDir);
|
|
7260
7487
|
const extractedFiles = await getAllFiles(extractDir);
|
|
7261
7488
|
// 根据IDE类型过滤文件
|
|
7262
|
-
const filteredFiles = filterFilesByIDE(extractedFiles,
|
|
7489
|
+
const filteredFiles = filterFilesByIDE(extractedFiles, resolvedIDE);
|
|
7263
7490
|
// 创建过滤后的目录结构(当选择特定IDE时)
|
|
7264
|
-
const workingDir = await createFilteredDirectory(extractDir, filteredFiles,
|
|
7491
|
+
const workingDir = await createFilteredDirectory(extractDir, filteredFiles, resolvedIDE);
|
|
7265
7492
|
// 检查是否需要复制到项目目录
|
|
7266
7493
|
const workspaceFolder = process.env.WORKSPACE_FOLDER_PATHS || process.cwd();
|
|
7267
7494
|
let finalFiles = [];
|
|
@@ -7276,7 +7503,7 @@ function registerSetupTools(server) {
|
|
|
7276
7503
|
const destPath = path.join(workspaceFolder, relativePath);
|
|
7277
7504
|
const copyResult = await copyFile(srcPath, destPath, overwrite, template);
|
|
7278
7505
|
if (copyResult.copied) {
|
|
7279
|
-
if (copyResult.action ===
|
|
7506
|
+
if (copyResult.action === "overwritten") {
|
|
7280
7507
|
overwrittenCount++;
|
|
7281
7508
|
}
|
|
7282
7509
|
else {
|
|
@@ -7285,7 +7512,7 @@ function registerSetupTools(server) {
|
|
|
7285
7512
|
finalFiles.push(destPath);
|
|
7286
7513
|
}
|
|
7287
7514
|
else {
|
|
7288
|
-
if (copyResult.action ===
|
|
7515
|
+
if (copyResult.action === "protected") {
|
|
7289
7516
|
protectedCount++;
|
|
7290
7517
|
}
|
|
7291
7518
|
else {
|
|
@@ -7295,11 +7522,11 @@ function registerSetupTools(server) {
|
|
|
7295
7522
|
}
|
|
7296
7523
|
}
|
|
7297
7524
|
// 添加IDE过滤信息
|
|
7298
|
-
const ideInfo = IDE_DESCRIPTIONS[
|
|
7525
|
+
const ideInfo = IDE_DESCRIPTIONS[resolvedIDE] || resolvedIDE;
|
|
7299
7526
|
results.push(`✅ ${templateConfig.description} (${ideInfo}) 同步完成`);
|
|
7300
7527
|
results.push(`📁 临时目录: ${workingDir}`);
|
|
7301
7528
|
results.push(`🔍 文件过滤: ${extractedFiles.length} → ${filteredFiles.length} 个文件`);
|
|
7302
|
-
if (
|
|
7529
|
+
if (resolvedIDE !== "all") {
|
|
7303
7530
|
results.push(`✨ 已过滤IDE配置,仅保留 ${ideInfo} 相关文件`);
|
|
7304
7531
|
}
|
|
7305
7532
|
const stats = [];
|
|
@@ -7312,36 +7539,36 @@ function registerSetupTools(server) {
|
|
|
7312
7539
|
if (skippedCount > 0)
|
|
7313
7540
|
stats.push(`跳过 ${skippedCount} 个已存在文件`);
|
|
7314
7541
|
if (stats.length > 0) {
|
|
7315
|
-
results.push(`📊 ${stats.join(
|
|
7542
|
+
results.push(`📊 ${stats.join(",")}`);
|
|
7316
7543
|
}
|
|
7317
7544
|
if (overwrite || overwrittenCount > 0 || skippedCount > 0) {
|
|
7318
|
-
results.push(`🔄 覆盖模式: ${overwrite ?
|
|
7545
|
+
results.push(`🔄 覆盖模式: ${overwrite ? "启用" : "禁用"}`);
|
|
7319
7546
|
}
|
|
7320
7547
|
}
|
|
7321
7548
|
else {
|
|
7322
|
-
finalFiles = filteredFiles.map(relativePath => path.join(workingDir, relativePath));
|
|
7323
|
-
const ideInfo = IDE_DESCRIPTIONS[
|
|
7549
|
+
finalFiles = filteredFiles.map((relativePath) => path.join(workingDir, relativePath));
|
|
7550
|
+
const ideInfo = IDE_DESCRIPTIONS[resolvedIDE] || resolvedIDE;
|
|
7324
7551
|
results.push(`✅ ${templateConfig.description} (${ideInfo}) 下载完成`);
|
|
7325
7552
|
results.push(`📁 保存在临时目录: ${workingDir}`);
|
|
7326
7553
|
results.push(`🔍 文件过滤: ${extractedFiles.length} → ${filteredFiles.length} 个文件`);
|
|
7327
|
-
if (
|
|
7554
|
+
if (resolvedIDE !== "all") {
|
|
7328
7555
|
results.push(`✨ 已过滤IDE配置,仅保留 ${ideInfo} 相关文件`);
|
|
7329
7556
|
}
|
|
7330
|
-
results.push(
|
|
7557
|
+
results.push("💡 如需将模板(包括隐藏文件)复制到项目目录,请确保复制时包含所有隐藏文件。");
|
|
7331
7558
|
}
|
|
7332
7559
|
// 文件路径列表
|
|
7333
|
-
results.push(
|
|
7334
|
-
results.push(
|
|
7335
|
-
finalFiles.forEach(filePath => {
|
|
7560
|
+
results.push("");
|
|
7561
|
+
results.push("📋 文件列表:");
|
|
7562
|
+
finalFiles.forEach((filePath) => {
|
|
7336
7563
|
results.push(`${filePath}`);
|
|
7337
7564
|
});
|
|
7338
7565
|
return {
|
|
7339
7566
|
content: [
|
|
7340
7567
|
{
|
|
7341
7568
|
type: "text",
|
|
7342
|
-
text: results.join(
|
|
7343
|
-
}
|
|
7344
|
-
]
|
|
7569
|
+
text: results.join("\n"),
|
|
7570
|
+
},
|
|
7571
|
+
],
|
|
7345
7572
|
};
|
|
7346
7573
|
}
|
|
7347
7574
|
catch (error) {
|
|
@@ -7349,9 +7576,9 @@ function registerSetupTools(server) {
|
|
|
7349
7576
|
content: [
|
|
7350
7577
|
{
|
|
7351
7578
|
type: "text",
|
|
7352
|
-
text: `❌ 下载模板失败: ${error instanceof Error ? error.message :
|
|
7353
|
-
}
|
|
7354
|
-
]
|
|
7579
|
+
text: `❌ 下载模板失败: ${error instanceof Error ? error.message : "未知错误"}`,
|
|
7580
|
+
},
|
|
7581
|
+
],
|
|
7355
7582
|
};
|
|
7356
7583
|
}
|
|
7357
7584
|
});
|
|
@@ -7487,6 +7714,52 @@ function shouldRegisterTool(toolName) {
|
|
|
7487
7714
|
}
|
|
7488
7715
|
|
|
7489
7716
|
|
|
7717
|
+
/***/ }),
|
|
7718
|
+
|
|
7719
|
+
/***/ 720:
|
|
7720
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7721
|
+
|
|
7722
|
+
|
|
7723
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7724
|
+
exports.sendDeployNotification = sendDeployNotification;
|
|
7725
|
+
const logger_js_1 = __webpack_require__(39);
|
|
7726
|
+
/**
|
|
7727
|
+
* Send deployment notification to CodeBuddy IDE
|
|
7728
|
+
* @param server ExtendedMcpServer instance
|
|
7729
|
+
* @param notificationData Deployment notification data
|
|
7730
|
+
*/
|
|
7731
|
+
async function sendDeployNotification(server, notificationData) {
|
|
7732
|
+
// Check if current IDE is CodeBuddy (prefer server.ide, fallback to environment variable)
|
|
7733
|
+
const currentIde = server.ide || process.env.INTEGRATION_IDE;
|
|
7734
|
+
if (currentIde !== 'CodeBuddy' || !server.server) {
|
|
7735
|
+
// Not CodeBuddy IDE, skip notification
|
|
7736
|
+
return;
|
|
7737
|
+
}
|
|
7738
|
+
try {
|
|
7739
|
+
// Send notification using sendLoggingMessage
|
|
7740
|
+
server.server.sendLoggingMessage({
|
|
7741
|
+
level: "notice",
|
|
7742
|
+
data: {
|
|
7743
|
+
type: "tcb",
|
|
7744
|
+
event: "deploy",
|
|
7745
|
+
data: {
|
|
7746
|
+
type: notificationData.deployType, // "hosting" or "cloudrun"
|
|
7747
|
+
url: notificationData.url,
|
|
7748
|
+
projectId: notificationData.projectId,
|
|
7749
|
+
projectName: notificationData.projectName,
|
|
7750
|
+
consoleUrl: notificationData.consoleUrl
|
|
7751
|
+
}
|
|
7752
|
+
}
|
|
7753
|
+
});
|
|
7754
|
+
(0, logger_js_1.info)(`CodeBuddy IDE: 已发送部署通知 - ${notificationData.deployType} - ${notificationData.url}`);
|
|
7755
|
+
}
|
|
7756
|
+
catch (err) {
|
|
7757
|
+
// Log error but don't throw - notification failure should not affect deployment flow
|
|
7758
|
+
(0, logger_js_1.error)(`Failed to send deployment notification: ${err instanceof Error ? err.message : err}`, err);
|
|
7759
|
+
}
|
|
7760
|
+
}
|
|
7761
|
+
|
|
7762
|
+
|
|
7490
7763
|
/***/ }),
|
|
7491
7764
|
|
|
7492
7765
|
/***/ 760:
|
|
@@ -8253,7 +8526,7 @@ class TelemetryReporter {
|
|
|
8253
8526
|
const nodeVersion = process.version; // Node.js版本
|
|
8254
8527
|
const arch = os_1.default.arch(); // 系统架构
|
|
8255
8528
|
// 从构建时注入的版本号获取MCP版本信息
|
|
8256
|
-
const mcpVersion = process.env.npm_package_version || "2.0.
|
|
8529
|
+
const mcpVersion = process.env.npm_package_version || "2.2.0-alpha.0" || 0;
|
|
8257
8530
|
return {
|
|
8258
8531
|
userAgent: `${osType} ${osRelease} ${arch} ${nodeVersion} CloudBase-MCP/${mcpVersion}`,
|
|
8259
8532
|
deviceId: this.deviceId,
|