cloudcc-cli 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +21 -0
  2. package/bin/cc.js +1 -0
  3. package/bin/mcp.js +18 -0
  4. package/package.json +14 -6
  5. package/src/classes/create.js +1 -0
  6. package/src/classes/get.js +1 -0
  7. package/src/classes/publish.js +4 -0
  8. package/src/classes/pull.js +5 -1
  9. package/src/mcp/index.js +227 -0
  10. package/src/mcp/readme.md +132 -0
  11. package/src/mcp/tools/ccdk/fetcher.js +18 -0
  12. package/src/mcp/tools/ccdk/handler.js +98 -0
  13. package/src/mcp/tools/ccdk/prompt.js +453 -0
  14. package/src/mcp/tools/classes/handler.js +358 -0
  15. package/src/mcp/tools/classes/prompt.js +1261 -0
  16. package/src/mcp/tools/dev-env/fetcher.js +500 -0
  17. package/src/mcp/tools/dev-env/handler.js +92 -0
  18. package/src/mcp/tools/dev-env/prompt.js +256 -0
  19. package/src/mcp/tools/key-guide/fetcher.js +278 -0
  20. package/src/mcp/tools/key-guide/handler.js +43 -0
  21. package/src/mcp/tools/key-guide/prompt.js +71 -0
  22. package/src/mcp/tools/plugin/handler.js +92 -0
  23. package/src/mcp/tools/plugin/prompt.js +659 -0
  24. package/src/plugin/create.js +1 -2
  25. package/src/plugin/create1.js +1 -2
  26. package/src/plugin/publish.js +3 -0
  27. package/src/plugin/publish1.js +6 -2
  28. package/src/script/publish.js +3 -0
  29. package/src/script/pull.js +3 -0
  30. package/src/timer/publish.js +3 -0
  31. package/src/timer/pull.js +3 -0
  32. package/src/triggers/publish.js +3 -0
  33. package/src/triggers/pull.js +3 -0
  34. package/template/Appvue +452 -12
  35. package/template/cloudcc-cli.configjs +7 -1
  36. package/template/index.js +0 -4
  37. package/template/vueconfigjs +10 -10
  38. package/utils/checkVersion.js +2 -0
  39. package/utils/utils.js +32 -9
  40. package/template/demojava +0 -15
  41. package/template/indexvue +0 -29
  42. package/template/javaconfigjson +0 -3
  43. package/template/package-lockjson +0 -13952
package/README.md CHANGED
@@ -1,3 +1,24 @@
1
+ # ReleaseV2.2.3
2
+ #### Release Date: 2025-12-11
3
+ #### Release Scope: Full
4
+ #### Release Content
5
+ * Optimization
6
+ * Add development environment setup MCP service
7
+ * Add security key retrieval MCP service
8
+ * Add Class management MCP service
9
+ * Add custom component management MCP service
10
+ * Configuration information prioritized from config
11
+ * Fix script tag search logic
12
+
13
+ # ReleaseV2.2.2
14
+ #### Release Date: 2025-12-3
15
+ #### Release Scope: Full
16
+ #### Release Content
17
+ * Optimization
18
+ * Added links to development documentation and changelog to version check output
19
+ * Upgraded Node dependencies to version 20
20
+ * Added timestamp output to multiple files to enhance user experience
21
+
1
22
  # ReleaseV2.2.1
2
23
  #### Release Date: 2025-11-24
3
24
  #### Release Scope: Full
package/bin/cc.js CHANGED
@@ -52,6 +52,7 @@ cc.recordType = require("../src/recordType/index")
52
52
  cc.config = require("../src/config/index")
53
53
 
54
54
  cc.version = require("../src/version/index")
55
+
55
56
  try {
56
57
  cc[argvs[1]](argvs[0], argvs);
57
58
  } catch (e) {
package/bin/mcp.js ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * MCP (Model Context Protocol) 服务启动脚本
4
+ * 用于与 Claude Desktop、IDE 等客户端通信
5
+ */
6
+
7
+ const { StdioServerTransport } = require('@modelcontextprotocol/sdk/server/stdio.js');
8
+ const mcpServer = require('../src/mcp/index.js');
9
+
10
+ async function main() {
11
+ const transport = new StdioServerTransport();
12
+ await mcpServer.connect(transport);
13
+ }
14
+
15
+ main().catch(error => {
16
+ console.error('Server error:', error);
17
+ process.exit(1);
18
+ });
package/package.json CHANGED
@@ -1,30 +1,36 @@
1
1
  {
2
2
  "name": "cloudcc-cli",
3
- "version": "2.2.1",
3
+ "version": "2.2.3",
4
4
  "description": "cloudcc-cli",
5
+ "author": "cloudcc",
6
+ "license": "ISC",
5
7
  "keywords": [
6
8
  "cloudcc",
7
9
  "cloudcc-cli"
8
10
  ],
9
11
  "main": "./bin",
10
- "author": "cloudcc",
11
- "license": "ISC",
12
12
  "bin": {
13
13
  "cloudccCreate": "bin/project.js",
14
14
  "cloudccBuild": "bin/plugin.js",
15
- "cc": "bin/cc.js"
15
+ "cc": "bin/cc.js",
16
+ "cc-mcp": "bin/mcp.js"
16
17
  },
17
18
  "scripts": {
18
19
  "cc-pull": "git fetch --tags -f && git pull",
19
20
  "publish-lib": "npm publish --registry https://registry.npmjs.org && git add . && git commit -m 'update' && git push && curl https://npmmirror.com/sync/cloudcc-cli",
20
- "package-jar": "mvn clean && mvn package"
21
+ "package-jar": "mvn clean && mvn package",
22
+ "fetch-dev-env": "node src/mcp/tools/dev-env/fetcher.js",
23
+ "fetch-key-guide": "node src/mcp/tools/key-guide/fetcher.js",
24
+ "fetch-ccdk": "node src/mcp/tools/ccdk/fetcher.js"
21
25
  },
22
26
  "dependencies": {
23
27
  "@babel/parser": "^7.28.5",
24
28
  "@babel/traverse": "^7.28.5",
29
+ "@modelcontextprotocol/sdk": "^1.23.0",
25
30
  "axios": "^0.21.4",
26
31
  "boxen": "^4.0.0",
27
32
  "chalk": "^2.4.2",
33
+ "cheerio": "^1.0.0-rc.12",
28
34
  "crypto-js": "^4.1.1",
29
35
  "dayjs": "^1.10.7",
30
36
  "fs-extra": "^11.2.0",
@@ -32,7 +38,9 @@
32
38
  "marked": "^5.0.1",
33
39
  "mem-fs": "^2.2.1",
34
40
  "mem-fs-editor": "^9.0.1",
41
+ "node-fetch": "^3.3.2",
35
42
  "vue-custom-element": "^3.3.0",
36
- "vue-template-compiler": "^2.6.14"
43
+ "vue-template-compiler": "^2.6.14",
44
+ "zod": "^4.1.13"
37
45
  }
38
46
  }
@@ -58,6 +58,7 @@ public class ${name}Test {
58
58
  console.log()
59
59
  console.log(chalk.red("Creation Class Failed:" + e))
60
60
  console.log()
61
+ throw new Error("Creation Class Failed: " + e);
61
62
  }
62
63
  }
63
64
  }
@@ -15,6 +15,7 @@ async function get(arg, path) {
15
15
  return res.data.list
16
16
  } else {
17
17
  console.error('error:', res.message);
18
+ throw new Error('Get Class Failed: ' + res.message);
18
19
  }
19
20
  }
20
21
 
@@ -13,6 +13,9 @@ async function publish(name) {
13
13
  let res = await checkUpdate();
14
14
  if (!res) {
15
15
  console.log();
16
+ const now = new Date();
17
+ const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
18
+ console.log(chalk.green(timeStr));
16
19
  console.log(chalk.green('Posting, please wait...'));
17
20
  console.log();
18
21
  const classPath = path.join(process.cwd(), `classes/${name}/`);
@@ -41,6 +44,7 @@ async function publish(name) {
41
44
  }
42
45
  } else {
43
46
  console.log(chalk.red('Publish Class Failed:' + res.returnInfo));
47
+ throw new Error('Publish Class Failed: ' + res.returnInfo);
44
48
  }
45
49
  }
46
50
  }
@@ -12,13 +12,16 @@ async function pull(name) {
12
12
  let res = await checkUpdate();
13
13
  if (!res) {
14
14
  console.log();
15
+ const now = new Date();
16
+ const timeStr = now.getFullYear() + '-' + String(now.getMonth() + 1).padStart(2, '0') + '-' + String(now.getDate()).padStart(2, '0') + ' ' + String(now.getHours()).padStart(2, '0') + ':' + String(now.getMinutes()).padStart(2, '0') + ':' + String(now.getSeconds()).padStart(2, '0');
17
+ console.log(chalk.green(timeStr));
15
18
  console.log(chalk.green('Pulling, please wait...'));
16
19
  console.log();
17
20
  const classPath = path.join(process.cwd(), `classes/${name}/`);
18
21
  let configContent = JSON.parse(fs.readFileSync(classPath + "config.json", 'utf8'));
19
22
  if (!configContent.id) {
20
23
  console.log(chalk.red('Class ID is not exist, please publish first!'));
21
- return;
24
+ throw new Error('Class ID is not exist, please publish first!');
22
25
  }
23
26
  let body = {
24
27
  "id": configContent.id,
@@ -45,6 +48,7 @@ async function pull(name) {
45
48
 
46
49
  } else {
47
50
  console.log(chalk.red('Pull Class Failed:' + res.returnInfo));
51
+ throw new Error('Pull Class Failed: ' + res.returnInfo);
48
52
  }
49
53
  }
50
54
  }
@@ -0,0 +1,227 @@
1
+ /**
2
+ * MCP 服务核心(标准 I/O 版本)
3
+ * 用于与 Claude / IDE 等客户端通信
4
+ *
5
+ * 重构说明:
6
+ * - 每个工具都在独立的文件夹中,包含 prompt.js(知识库)、fetcher.js(爬取工具)、handler.js(工具实现)
7
+ * - 主文件负责统一注册所有工具
8
+ */
9
+
10
+ const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js");
11
+ const { z } = require("zod");
12
+
13
+ // 导入各个工具的处理器
14
+ const ccdkHandler = require("./tools/ccdk/handler.js");
15
+ const devEnvHandler = require("./tools/dev-env/handler.js");
16
+ const classesHandler = require("./tools/classes/handler.js");
17
+ const keyGuideHandler = require("./tools/key-guide/handler.js");
18
+ const pluginHandler = require("./tools/plugin/handler.js");
19
+
20
+ const mcpServer = new McpServer({
21
+ name: 'cctool',
22
+ version: '1.0.0'
23
+ });
24
+
25
+ // ==================== CCDK 工具 ====================
26
+
27
+ // Tool: Get CCDK documentation (full or by module)
28
+ mcpServer.registerTool(
29
+ 'get_ccdk_docs',
30
+ {
31
+ description: '获取 CloudCC CCDK API 文档。可以获取完整文档或指定模块的文档(如 CCPage、CCDetail、CCList 等)',
32
+ inputSchema: {
33
+ module: z.string().optional().describe('可选:指定模块名称,如 "CCPage"、"CCDetail"、"CCCommon" 等。不指定则返回所有模块概览')
34
+ }
35
+ },
36
+ ccdkHandler.getCcdkDocs
37
+ );
38
+
39
+ // Tool: Search CCDK documentation
40
+ mcpServer.registerTool(
41
+ 'search_ccdk_docs',
42
+ {
43
+ description: '在 CCDK 文档中搜索关键词,支持搜索 API 名称、方法名、功能描述等',
44
+ inputSchema: {
45
+ keyword: z.string().describe('搜索关键词'),
46
+ maxResults: z.number().optional().default(20)
47
+ }
48
+ },
49
+ ccdkHandler.searchCcdkDocs
50
+ );
51
+
52
+ // Tool: List CCDK modules
53
+ mcpServer.registerTool(
54
+ 'list_ccdk_modules',
55
+ {
56
+ description: '列出 CCDK 所有可用的 API 模块',
57
+ inputSchema: {
58
+ showApis: z.boolean().optional().default(false)
59
+ }
60
+ },
61
+ ccdkHandler.listCcdkModules
62
+ );
63
+
64
+ // ==================== Dev-Env 工具 ====================
65
+
66
+ // Tool: Get dev environment setup guide
67
+ mcpServer.registerTool(
68
+ 'get_dev_env_setup',
69
+ {
70
+ description: '获取 CloudCC 开发环境搭建指南',
71
+ inputSchema: z.object({
72
+ step: z.number().int().optional(),
73
+ search: z.string().optional(),
74
+ difficulty: z.enum(['easy', 'medium', 'hard']).optional(),
75
+ platform: z.enum(['windows', 'macos', 'linux']).optional(),
76
+ command: z.boolean().optional(),
77
+ })
78
+ },
79
+ devEnvHandler.getDevEnvSetup
80
+ );
81
+
82
+ // ==================== Classes 工具 ====================
83
+
84
+ // Tool: Create custom class
85
+ mcpServer.registerTool(
86
+ 'create_class',
87
+ {
88
+ description: '创建一个新的 CloudCC 自定义类,会在 classes/{ClassName}/ 目录下生成 Java 类文件、测试文件和配置文件',
89
+ inputSchema: {
90
+ className: z.string().min(1).describe('Java 类名,必须符合 Java 命名规范(字母开头,只能包含字母、数字和下划线)'),
91
+ projectPath: z.string().describe('项目根目录路径,默认为当前工作目录')
92
+ }
93
+ },
94
+ classesHandler.createClass
95
+ );
96
+
97
+ // Tool: Publish class to server
98
+ mcpServer.registerTool(
99
+ 'publish_class',
100
+ {
101
+ description: '将本地自定义类发布到 CloudCC 服务器,只上传 @SOURCE_CONTENT_START 和 @SOURCE_CONTENT_END 之间的代码',
102
+ inputSchema: {
103
+ className: z.string().min(1).describe('要发布的类名'),
104
+ projectPath: z.string().describe('项目根目录路径,默认为当前工作目录')
105
+ }
106
+ },
107
+ classesHandler.publishClass
108
+ );
109
+
110
+ // Tool: Pull class from server
111
+ mcpServer.registerTool(
112
+ 'pull_class',
113
+ {
114
+ description: '从 CloudCC 服务器拉取自定义类的最新代码,更新本地文件中 @SOURCE_CONTENT_START 和 @SOURCE_CONTENT_END 之间的内容',
115
+ inputSchema: {
116
+ className: z.string().min(1).describe('要拉取的类名'),
117
+ projectPath: z.string().describe('项目根目录路径,默认为当前工作目录')
118
+ }
119
+ },
120
+ classesHandler.pullClass
121
+ );
122
+
123
+ // Tool: List classes
124
+ mcpServer.registerTool(
125
+ 'list_classes',
126
+ {
127
+ description: '获取 CloudCC 服务器上的自定义类列表',
128
+ inputSchema: {
129
+ queryParams: z.object({}).passthrough().optional().describe('查询条件,JSON 对象格式,例如 {"name": "MyClass"}'),
130
+ limit: z.number().int().positive().optional().default(20).describe('返回结果数量限制,默认 20'),
131
+ projectPath: z.string().describe('项目根目录路径,默认为当前工作目录')
132
+ }
133
+ },
134
+ classesHandler.listClasses
135
+ );
136
+
137
+ // Tool: Get class detail
138
+ mcpServer.registerTool(
139
+ 'get_class_detail',
140
+ {
141
+ description: '获取本地自定义类的详细信息,包括配置、文件路径和源码预览',
142
+ inputSchema: {
143
+ className: z.string().min(1).describe('类名'),
144
+ projectPath: z.string().describe('项目根目录路径,默认为当前工作目录')
145
+ }
146
+ },
147
+ classesHandler.getClassDetail
148
+ );
149
+
150
+ // Tool: Pull multiple classes
151
+ mcpServer.registerTool(
152
+ 'pull_multiple_classes',
153
+ {
154
+ description: '批量从 CloudCC 服务器拉取多个自定义类,适用于初始化项目或批量下载。遇到错误会继续处理其他类,最后返回统计结果',
155
+ inputSchema: {
156
+ classIds: z.array(z.string()).min(1).describe('要拉取的类 ID 数组,例如 ["id1", "id2", "id3"]'),
157
+ projectPath: z.string().describe('项目根目录路径,默认为当前工作目录')
158
+ }
159
+ },
160
+ classesHandler.pullMultipleClasses
161
+ );
162
+
163
+ // Tool: Edit class with knowledge base
164
+ mcpServer.registerTool(
165
+ 'edit_class',
166
+ {
167
+ description: '获取编辑 CloudCC 自定义类时所需的知识库、API 文档和代码示例。包含 CCService、CCObject、SendEmail、TimeUtil、UserInfo、DevLogger 等核心 API 的详细使用说明。代码示例和最佳实践会自动附加 CloudCC 标准 API 规范检查表,确保编辑后的代码符合 CloudCC 官方标准',
168
+ inputSchema: {
169
+ topic: z.enum(['overview', 'ccservice', 'object', 'email', 'time', 'user', 'logger', 'scenarios', 'bestpractices'])
170
+ .optional()
171
+ .default('overview')
172
+ .describe(`知识库主题:
173
+ - overview: 类概览和快速导航
174
+ - ccservice: CCService 数据操作 API(查询、新增、更新、删除等)
175
+ - object: CCObject 对象操作方法
176
+ - email: SendEmail 邮件服务
177
+ - time: TimeUtil 时间格式化工具
178
+ - user: UserInfo 用户信息获取
179
+ - logger: DevLogger 日志输出
180
+ - scenarios: 常见编辑场景示例
181
+ - bestpractices: 编辑最佳实践`)
182
+ }
183
+ },
184
+ classesHandler.editClass
185
+ );
186
+
187
+ // ==================== Key Guide 工具 ====================
188
+
189
+ // Tool: Get security key guide
190
+ mcpServer.registerTool(
191
+ 'get_key_guideeee',
192
+ {
193
+ description: '获取 CloudCC 安全标记和开发者密钥相关的完整指南,包括获取开发者密钥、安全标记、配置方法等',
194
+ inputSchema: z.object({})
195
+ },
196
+ keyGuideHandler.getKeyGuide
197
+ );
198
+
199
+ // ==================== Plugin 工具 ====================
200
+
201
+ // Tool: Create plugin
202
+ mcpServer.registerTool(
203
+ 'create_plugin',
204
+ {
205
+ description: '创建一个新的 CloudCC Vue 自定义组件,会在 plugins/{pluginName}/ 目录下生成主组件文件、子组件目录和配置文件',
206
+ inputSchema: {
207
+ pluginName: z.string().min(1).describe('插件名称,用于创建目录和主文件'),
208
+ projectPath: z.string().describe('项目根目录路径,默认为当前工作目录')
209
+ }
210
+ },
211
+ pluginHandler.createPlugin
212
+ );
213
+
214
+ // Tool: Publish plugin
215
+ mcpServer.registerTool(
216
+ 'publish_plugin',
217
+ {
218
+ description: '将 Vue 自定义组件编译并发布到 CloudCC 服务器。会自动收集所有依赖、编译为 UMD 格式并上传',
219
+ inputSchema: {
220
+ pluginName: z.string().min(1).describe('要发布的插件名称'),
221
+ projectPath: z.string().describe('项目根目录路径,默认为当前工作目录')
222
+ }
223
+ },
224
+ pluginHandler.publishPlugin
225
+ );
226
+
227
+ module.exports = mcpServer;
@@ -0,0 +1,132 @@
1
+ ## MCP设计方案
2
+ * 每个功能独立一个工具
3
+
4
+ ## 工具列表说明
5
+ ### 1:开发环境检查Tool
6
+ * 用于检查当前环境,是否满足开发条件
7
+ * 需要使用知识库
8
+
9
+ ### 2:创建开发环境Tool
10
+ * 通过特定步骤创建一个开发模版项目
11
+ * 需要使用知识库
12
+
13
+ ### 3:指导配置开发者密钥Tool
14
+ * 检查当前环境的开发者密钥是否配置正确
15
+ * 指导如何获取密钥,以及如何配置
16
+
17
+ ### 4:创建应用程序Tool
18
+ * 创建一个应用程序
19
+
20
+ ### 5:查询应用列表
21
+ * 查询环境所有应用程序
22
+
23
+ ### 6:创建自定义对象Tool
24
+ * 创建一个自定义对象
25
+
26
+ ### 7:查询对象列表Tool
27
+ * 查询所有对象信息,包含标准以及自定义
28
+
29
+ ### 8:查询某个对象的详细信息Tool
30
+ * 查询某个对象的详细信息
31
+
32
+ ### 9:创建字段Tool
33
+ * 为某个对象批量创建字段
34
+ * 需要所有字段知识库
35
+
36
+ ### 10:查询某个对象字段列表Tool
37
+ * 通过对象id查询对象的字段列表信息
38
+
39
+ ### 11:创建自定义类Tool
40
+ * 创建一个自定义类
41
+
42
+ ### 12:查询自定义类列表Tool
43
+ * 查询自定义类列表
44
+
45
+ ### 13:查询某个类的详细信息Tool
46
+ * 根据id查询某个类详细信息
47
+
48
+ ### 14:编辑类Tool
49
+ * 使用类的开发者知识库进行编辑开发
50
+ * 类的常用sdk
51
+
52
+ ### 15:拉取自定义类到本地Tool
53
+ * 拉取线上的某个类代码到本地
54
+
55
+ ### 16:推送自定义类到线上Tool
56
+ * 推送某个自定义类代码到线上
57
+
58
+ ### 17:创建定时类Tool
59
+ * 创建一个自定义类
60
+
61
+ ### 18:查询定时类列表Tool
62
+ * 查询自定义类列表
63
+
64
+ ### 19:查询某个定时类的详细信息Tool
65
+ * 根据id查询某个类详细信息
66
+
67
+ ### 20:编辑定时类Tool
68
+ * 使用定时类的开发者知识库进行编辑开发
69
+ * 类的常用sdk
70
+
71
+ ### 21:拉取定时类到本地Tool
72
+ * 拉取线上的某个类代码到本地
73
+
74
+ ### 22:推送定时类代码到线上Tool
75
+ * 推送某个自定义类代码到线上
76
+
77
+ ### 23:创建触发器Tool
78
+ * 创建一个自定义类
79
+
80
+ ### 24:查询触发器列表Tool
81
+ * 查询自定义类列表
82
+
83
+ ### 25:查询某个触发器的详细信息Tool
84
+ * 根据id查询某个类详细信息
85
+
86
+ ### 26:编辑触发器Tool
87
+ * 使用定时类的开发者知识库进行编辑开发
88
+ * 类的常用sdk
89
+
90
+ ### 27:拉取触发器到本地Tool
91
+ * 拉取线上的某个类代码到本地
92
+
93
+ ### 28:推送触发器代码到线上Tool
94
+ * 推送某个自定义类代码到线上
95
+
96
+ ### 29:创建自定义组件Tool
97
+ * 创建一个自定义类
98
+
99
+ ### 30:查询自定义组件列表Tool
100
+ * 查询自定义类列表
101
+
102
+ ### 31:查询某个自定义组件的详细信息Tool
103
+ * 根据id查询某个类详细信息
104
+
105
+ ### 32:编辑自定义组件Tool
106
+ * 使用定时类的开发者知识库进行编辑开发
107
+ * 类的常用sdk
108
+
109
+ ### 33:拉取自定义组件到本地Tool
110
+ * 拉取线上的某个类代码到本地
111
+
112
+ ### 34:推送自定义组件代码到线上Tool
113
+ * 推送某个自定义类代码到线上
114
+
115
+ ### 35:创建客户端脚本Tool
116
+ * 创建一个自定义类
117
+
118
+ ### 36:查询客户端脚本组件列表Tool
119
+ * 查询自定义类列表
120
+
121
+ ### 37:查询某个客户端脚本的详细信息Tool
122
+ * 根据id查询某个类详细信息
123
+
124
+ ### 38:编辑客户端脚本Tool
125
+ * 使用定时类的开发者知识库进行编辑开发
126
+ * 类的常用sdk
127
+
128
+ ### 39:拉取客户端脚本到本地Tool
129
+ * 拉取线上的某个类代码到本地
130
+
131
+ ### 40:推送客户端脚本件代码到线上Tool
132
+ * 推送某个自定义类代码到线上
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * CCDK API 文档爬取工具
5
+ * 用于从 CloudCC 官方文档爬取 CCDK API 信息并生成结构化知识库
6
+ *
7
+ * TODO: 实现 CCDK 文档的自动爬取功能
8
+ * 目前 CCDK 文档是手动维护的,未来可以添加自动爬取功能
9
+ */
10
+
11
+ console.log('CCDK 文档爬取工具');
12
+ console.log('注意:当前 CCDK 文档为手动维护,暂无自动爬取功能');
13
+ console.log('如需更新文档,请手动编辑 prompt.js 文件');
14
+
15
+ // 预留:未来可以添加从官方文档网站爬取 CCDK API 的功能
16
+ // 参考 dev-env 的实现方式
17
+
18
+ process.exit(0);
@@ -0,0 +1,98 @@
1
+ /**
2
+ * CCDK 工具处理器
3
+ * 提供 CCDK API 文档查询、搜索等功能的具体实现
4
+ */
5
+
6
+ const { ccdkApiTree } = require('./prompt.js');
7
+
8
+ /**
9
+ * 获取 CCDK 文档(完整或指定模块)
10
+ */
11
+ async function getCcdkDocs({ module } = {}) {
12
+ const tree = ccdkApiTree;
13
+
14
+ if (module) {
15
+ const moduleInfo = tree[module];
16
+ if (moduleInfo) {
17
+ let content = `# ${module} - ${moduleInfo.name}\n\n${moduleInfo.description}\n\n---\n\n`;
18
+ Object.entries(moduleInfo.apis).forEach(([apiName, apiInfo]) => {
19
+ content += `## ${apiName}\n\n**描述**: ${apiInfo.description}\n\n**版本**: ${apiInfo.version}\n\n${apiInfo.content}\n\n---\n\n`;
20
+ });
21
+ return { content: [{ type: 'text', text: content }] };
22
+ } else {
23
+ const modules = Object.keys(tree);
24
+ return { content: [{ type: 'text', text: `未找到 "${module}" 模块的文档。\n\n可用模块:\n${modules.map(m => `- ${m}`).join('\n')}` }] };
25
+ }
26
+ } else {
27
+ let content = '# CloudCC CCDK API 模块概览\n\n';
28
+ Object.entries(tree).forEach(([moduleName, moduleInfo]) => {
29
+ const apiCount = Object.keys(moduleInfo.apis).length;
30
+ content += `## ${moduleName} - ${moduleInfo.name}\n\n${moduleInfo.description}\n\n**API 数量**: ${apiCount}\n\n---\n\n`;
31
+ });
32
+ content += '\n💡 使用 `get_ccdk_docs` 工具并指定 `module` 参数获取模块详细文档';
33
+ return { content: [{ type: 'text', text: content }] };
34
+ }
35
+ }
36
+
37
+ /**
38
+ * 搜索 CCDK 文档
39
+ */
40
+ async function searchCcdkDocs({ keyword, maxResults = 20 }) {
41
+ const tree = ccdkApiTree;
42
+ const keywordLower = keyword.toLowerCase();
43
+ const results = [];
44
+
45
+ Object.entries(tree).forEach(([moduleName, moduleInfo]) => {
46
+ Object.entries(moduleInfo.apis).forEach(([apiName, apiInfo]) => {
47
+ let score = 0;
48
+ if (apiName.toLowerCase() === keywordLower) score += 100;
49
+ else if (apiName.toLowerCase().includes(keywordLower)) score += 50;
50
+ if (apiInfo.keyword.toLowerCase().includes(keywordLower)) score += 30;
51
+ if (apiInfo.description.toLowerCase().includes(keywordLower)) score += 20;
52
+ if (apiInfo.content.toLowerCase().includes(keywordLower)) score += 10;
53
+ if (moduleInfo.name.toLowerCase().includes(keywordLower)) score += 15;
54
+ if (moduleInfo.description.toLowerCase().includes(keywordLower)) score += 10;
55
+ if (score > 0) results.push({ score, moduleName, moduleInfo, apiName, apiInfo });
56
+ });
57
+ });
58
+
59
+ results.sort((a, b) => b.score - a.score);
60
+ const topResults = results.slice(0, maxResults);
61
+
62
+ if (topResults.length > 0) {
63
+ let content = `# 搜索结果:${keyword}\n\n找到 ${topResults.length} 个相关 API (共 ${results.length} 个匹配)\n\n---\n\n`;
64
+ topResults.forEach(({ moduleName, moduleInfo, apiName, apiInfo }) => {
65
+ content += `## ${moduleName}.${apiName}\n\n**模块**: ${moduleInfo.name}\n\n**描述**: ${apiInfo.description}\n\n**版本**: ${apiInfo.version}\n\n${apiInfo.content}\n\n---\n\n`;
66
+ });
67
+ return { content: [{ type: 'text', text: content }] };
68
+ } else {
69
+ return { content: [{ type: 'text', text: `未找到包含 "${keyword}" 的内容。` }] };
70
+ }
71
+ }
72
+
73
+ /**
74
+ * 列出 CCDK 模块
75
+ */
76
+ async function listCcdkModules({ showApis = false }) {
77
+ const tree = ccdkApiTree;
78
+ let content = '# CCDK API 模块列表\n\n';
79
+ Object.entries(tree).forEach(([moduleName, moduleInfo]) => {
80
+ const apiCount = Object.keys(moduleInfo.apis).length;
81
+ content += `## ${moduleName} - ${moduleInfo.name}\n\n${moduleInfo.description}\n\n**API 数量**: ${apiCount}\n\n`;
82
+ if (showApis) {
83
+ content += '**包含 API**:\n';
84
+ Object.entries(moduleInfo.apis).forEach(([apiName, apiInfo]) => {
85
+ content += `- \`${apiName}\`: ${apiInfo.description}\n`;
86
+ });
87
+ content += '\n';
88
+ }
89
+ content += '---\n\n';
90
+ });
91
+ return { content: [{ type: 'text', text: content }] };
92
+ }
93
+
94
+ module.exports = {
95
+ getCcdkDocs,
96
+ searchCcdkDocs,
97
+ listCcdkModules
98
+ };