cloudcc-cli 2.2.6 → 2.2.7

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 (117) hide show
  1. package/.cloudcc-cache.json +24 -20
  2. package/README.md +12 -0
  3. package/bin/cc.js +7 -0
  4. package/java/com/cloudcc/core/BaseException.java +100 -0
  5. package/java/com/cloudcc/core/BusiException.java +43 -0
  6. package/java/com/cloudcc/core/CCService.java +3 -1
  7. package/java/com/cloudcc/core/StringUtils.java +7 -0
  8. package/java/com/cloudcc/core/TimeUtil.java +33 -0
  9. package/java/com/cloudcc/core/UserInfo.java +9 -0
  10. package/package.json +7 -1
  11. package/pom.xml +1 -1
  12. package/skill/BACKEND_CODE.md +114 -0
  13. package/skill/CLI_CHEATSHEET.md +90 -0
  14. package/skill/INSTALL_AND_BOOTSTRAP.md +59 -0
  15. package/skill/OBJECTS_AND_FIELDS.md +120 -0
  16. package/skill/REQUIREMENTS_BREAKDOWN.md +98 -0
  17. package/skill/SKILL.md +33 -0
  18. package/skill/VUE_CUSTOM_COMPONENT.md +50 -0
  19. package/src/api/backend-sdk-java.md +427 -0
  20. package/src/api/ccdk-sdk.md +1039 -0
  21. package/src/classes/doc.js +486 -0
  22. package/src/classes/index.js +1 -0
  23. package/src/mcp/cliRunner.js +61 -0
  24. package/src/mcp/index.js +41 -3
  25. package/src/mcp/tools/Application Creator/handler.js +7 -9
  26. package/src/mcp/tools/Approval/handler.js +34 -151
  27. package/src/mcp/tools/Class Creator/handler.js +18 -15
  28. package/src/mcp/tools/Class Detail Retriever/handler.js +8 -9
  29. package/src/mcp/tools/Class Editor Guide/handler.js +5 -19
  30. package/src/mcp/tools/Class List Retriever/handler.js +8 -3
  31. package/src/mcp/tools/Class Publisher/handler.js +7 -9
  32. package/src/mcp/tools/Class Puller/handler.js +6 -65
  33. package/src/mcp/tools/Client Script Detail Retriever/handler.js +12 -18
  34. package/src/mcp/tools/Client Script Editor Guide/handler.js +9 -605
  35. package/src/mcp/tools/Client Script List Retriever/handler.js +30 -33
  36. package/src/mcp/tools/Client Script Publisher/handler.js +12 -11
  37. package/src/mcp/tools/Client Script Puller/handler.js +23 -30
  38. package/src/mcp/tools/CloudCC Development Overview/handler.js +11 -5
  39. package/src/mcp/tools/Component Creator/handler.js +12 -11
  40. package/src/mcp/tools/Component Detail Retriever/handler.js +12 -9
  41. package/src/mcp/tools/Component Editor Guide/handler.js +5 -22
  42. package/src/mcp/tools/Component List Retriever/handler.js +21 -18
  43. package/src/mcp/tools/Component Publisher/handler.js +25 -3
  44. package/src/mcp/tools/Component Puller/handler.js +13 -16
  45. package/src/mcp/tools/Dev Environment Creator/handler.js +5 -72
  46. package/src/mcp/tools/Dev Environment Validator/handler.js +5 -66
  47. package/src/mcp/tools/Developer Key Setup Guide/handler.js +11 -20
  48. package/src/mcp/tools/JSP Migrator/handler.js +842 -0
  49. package/src/mcp/tools/Menu Creator/handler.js +7 -30
  50. package/src/mcp/tools/Object Creator/handler.js +14 -6
  51. package/src/mcp/tools/Object Fields Creator/handler.js +9 -10
  52. package/src/mcp/tools/Object Fields Retriever/handler.js +6 -3
  53. package/src/mcp/tools/Object List Retriever/handler.js +10 -7
  54. package/src/mcp/tools/Scheduled Class Creator/handler.js +12 -16
  55. package/src/mcp/tools/Scheduled Class Detail Retriever/handler.js +7 -9
  56. package/src/mcp/tools/Scheduled Class List Retriever/handler.js +21 -23
  57. package/src/mcp/tools/Scheduled Class Publisher/handler.js +7 -9
  58. package/src/mcp/tools/Scheduled Class Puller/handler.js +6 -70
  59. package/src/mcp/tools/Trigger Creator/handler.js +12 -20
  60. package/src/mcp/tools/Trigger Detail Retriever/handler.js +7 -9
  61. package/src/mcp/tools/Trigger Editor Guide/handler.js +10 -35
  62. package/src/mcp/tools/Trigger List Retriever/handler.js +12 -4
  63. package/src/mcp/tools/Trigger Publisher/handler.js +8 -11
  64. package/src/mcp/tools/Trigger Puller/handler.js +12 -17
  65. package/src/plugin/doc.js +801 -0
  66. package/src/plugin/index.js +1 -0
  67. package/src/project/doc.js +378 -0
  68. package/src/project/index.js +1 -0
  69. package/src/script/doc.js +259 -0
  70. package/src/script/index.js +1 -0
  71. package/src/timer/index.js +1 -0
  72. package/src/triggers/doc.js +342 -0
  73. package/src/triggers/index.js +5 -0
  74. package/target/classes/com/cloudcc/core/BaseException.class +0 -0
  75. package/target/classes/com/cloudcc/core/BusiException.class +0 -0
  76. package/target/classes/com/cloudcc/core/CCService.class +0 -0
  77. package/target/classes/com/cloudcc/core/StringUtils.class +0 -0
  78. package/target/classes/com/cloudcc/core/TimeUtil.class +0 -0
  79. package/target/classes/com/cloudcc/core/UserInfo.class +0 -0
  80. package/template/lib/ccopenapi-0.0.4.jar +0 -0
  81. package/test/application.cli.test.js +30 -0
  82. package/test/classes.cli.test.js +121 -0
  83. package/test/fields.cli.test.js +69 -0
  84. package/test/mcp.cli.test.js +21 -0
  85. package/test/menu.cli.test.js +41 -0
  86. package/test/object.cli.test.js +64 -0
  87. package/test/plugin.cli.test.js +109 -0
  88. package/test/script.cli.test.js +101 -0
  89. package/test/timer.cli.test.js +107 -0
  90. package/test/trigger.cli.test.js +146 -0
  91. package/.vscode/settings.json +0 -3
  92. package/bin/mcp-svc.js +0 -13
  93. package/src/mcp/MCP/345/234/272/346/231/257/346/250/241/346/213/237.md +0 -8
  94. package/src/mcp/index-sse-svc.js +0 -126
  95. package/src/mcp/index-streamable-svc.js +0 -180
  96. package/src/mcp/tools/Class Detail Retriever/prompt.js +0 -37
  97. package/src/mcp/tools/Class Editor Guide/prompt.js +0 -468
  98. package/src/mcp/tools/Class Publisher/prompt.js +0 -40
  99. package/src/mcp/tools/Class Puller/prompt.js +0 -49
  100. package/src/mcp/tools/Client Script Creator/handler.js +0 -179
  101. package/src/mcp/tools/CloudCC Development Overview/prompt.js +0 -871
  102. package/src/mcp/tools/Component Editor Guide/prompt.js +0 -519
  103. package/src/mcp/tools/Component Publisher/prompt.js +0 -659
  104. package/src/mcp/tools/Dev Environment Creator/prompt.js +0 -273
  105. package/src/mcp/tools/Dev Environment Validator/prompt.js +0 -193
  106. package/src/mcp/tools/Developer Key Setup Guide/prompt.js +0 -71
  107. package/src/mcp/tools/Object Fields Retriever/prompt.js +0 -10
  108. package/src/mcp/tools/Object List Retriever/prompt.js +0 -10
  109. package/src/mcp/tools/ccdk/fetcher.js +0 -18
  110. package/src/mcp/tools/ccdk/handler.js +0 -98
  111. package/src/mcp/tools/ccdk/prompt.js +0 -453
  112. package/target/ccopenapi-0.0.3-classes.jar +0 -0
  113. package/target/ccopenapi-0.0.3.jar +0 -0
  114. package/target/maven-archiver/pom.properties +0 -3
  115. package/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +0 -18
  116. package/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +0 -19
  117. package/template/lib/ccopenapi-0.0.3.jar +0 -0
@@ -3,7 +3,8 @@
3
3
  * 提供客户端脚本列表查询功能
4
4
  */
5
5
 
6
- const getScriptModule = require('../../../script/get');
6
+ const path = require('path');
7
+ const { runCcJsonCommand } = require('../../cliRunner');
7
8
 
8
9
  /**
9
10
  * 获取客户端脚本列表
@@ -13,45 +14,41 @@ const getScriptModule = require('../../../script/get');
13
14
  */
14
15
  async function listClientScripts({ projectPath = process.cwd(), condition = {} }) {
15
16
  try {
16
- const originalCwd = process.cwd();
17
- process.chdir(projectPath);
18
-
19
- try {
20
- // 构建查询条件
21
- const configContent = {
22
- pageSize: 10000,
23
- pageNo: 1,
24
- condition: {
25
- id: condition.id || '',
26
- pageLabel: condition.pageLabel || '',
27
- objName: condition.objName || ''
28
- }
29
- };
30
-
31
- // 将配置对象编码为 URI 格式(get.js 期望的格式)
32
- const encodedConfig = encodeURI(JSON.stringify(configContent));
33
-
34
- // 调用原有的 get 模块
35
- const scriptList = await getScriptModule(['get', 'script', encodedConfig, projectPath], true);
36
-
37
- if (!scriptList || scriptList.length === 0) {
38
- return {
39
- content: [{
40
- type: 'text',
41
- text: '未找到任何客户端脚本\n\n提示:使用 create_client_script 创建新脚本'
42
- }]
43
- };
17
+ const resolvedPath = path.resolve(projectPath);
18
+ const configContent = {
19
+ pageSize: 10000,
20
+ pageNo: 1,
21
+ condition: {
22
+ id: condition.id || '',
23
+ pageLabel: condition.pageLabel || '',
24
+ objName: condition.objName || ''
44
25
  }
45
-
26
+ };
27
+ const encodedConfig = encodeURI(JSON.stringify(configContent));
28
+ const run = runCcJsonCommand(['get', 'script', encodedConfig, resolvedPath], { cwd: resolvedPath });
29
+ if (!run.success) {
30
+ return {
31
+ content: [{
32
+ type: 'text',
33
+ text: `✗ 查询失败: ${run.detail || 'cc 命令执行失败'}\n\n可能的原因:\n- 项目路径不正确\n- 网络连接问题\n- 服务器API不可用`
34
+ }]
35
+ };
36
+ }
37
+ const scriptList = run.data || [];
38
+ if (!scriptList.length) {
46
39
  return {
47
40
  content: [{
48
41
  type: 'text',
49
- text: JSON.stringify(scriptList, null, 2)
42
+ text: '未找到任何客户端脚本\n\n提示:使用 create_client_script 创建新脚本'
50
43
  }]
51
44
  };
52
- } finally {
53
- process.chdir(originalCwd);
54
45
  }
46
+ return {
47
+ content: [{
48
+ type: 'text',
49
+ text: JSON.stringify(scriptList, null, 2)
50
+ }]
51
+ };
55
52
  } catch (error) {
56
53
  return {
57
54
  content: [{
@@ -3,7 +3,8 @@
3
3
  * 将本地客户端脚本发布到服务器
4
4
  */
5
5
 
6
- const publishScriptModule = require('../../../script/publish');
6
+ const path = require('path');
7
+ const { runCcCommand, buildRunDetail } = require('../../cliRunner');
7
8
 
8
9
  /**
9
10
  * 发布客户端脚本到服务器
@@ -22,22 +23,22 @@ async function publishClientScript({ scriptPath, projectPath = process.cwd() })
22
23
  };
23
24
  }
24
25
 
25
- const originalCwd = process.cwd();
26
- process.chdir(projectPath);
27
-
28
- try {
29
- // 调用原有的 publish 模块
30
- await publishScriptModule(['publish', 'script', scriptPath], true);
31
-
26
+ const resolvedPath = path.resolve(projectPath);
27
+ const run = runCcCommand(['publish', 'script', scriptPath], { cwd: resolvedPath });
28
+ if (!run.success) {
32
29
  return {
33
30
  content: [{
34
31
  type: 'text',
35
- text: `✓ 发布成功!客户端脚本已发布到服务器\n\n脚本路径: script/${scriptPath}/\n\n提示:首次发布后,config.json 中会自动添加 id 字段`
32
+ text: `✗ 发布失败: ${buildRunDetail(run) || 'cc 命令执行失败'}\n\n可能的原因:\n- 脚本文件不存在\n- 脚本格式不正确(必须包含 function main($CCDK, obj) 函数)\n- 网络连接问题\n- 服务器API不可用`
36
33
  }]
37
34
  };
38
- } finally {
39
- process.chdir(originalCwd);
40
35
  }
36
+ return {
37
+ content: [{
38
+ type: 'text',
39
+ text: `✓ 发布成功!客户端脚本已发布到服务器\n\n脚本路径: script/${scriptPath}/\n\n提示:首次发布后,config.json 中会自动添加 id 字段`
40
+ }]
41
+ };
41
42
  } catch (error) {
42
43
  return {
43
44
  content: [{
@@ -3,8 +3,8 @@
3
3
  * 从服务器拉取客户端脚本到本地
4
4
  */
5
5
 
6
- const pullScriptModule = require('../../../script/pull');
7
- const pullListScriptModule = require('../../../script/pullList');
6
+ const path = require('path');
7
+ const { runCcCommand, buildRunDetail } = require('../../cliRunner');
8
8
 
9
9
  /**
10
10
  * 从服务器拉取客户端脚本
@@ -27,36 +27,29 @@ async function pullClientScript({ scriptPath, scriptId, projectPath = process.cw
27
27
  };
28
28
  }
29
29
 
30
- const originalCwd = process.cwd();
31
- process.chdir(projectPath);
32
-
33
- try {
34
- // 如果提供了 scriptId,使用 pullList 方法(会自动创建目录和文件)
35
- if (scriptId) {
36
- await pullListScriptModule(['pullList', 'script', scriptId, projectPath], true);
37
-
38
- return {
39
- content: [{
40
- type: 'text',
41
- text: `✓ 拉取成功!脚本已从服务器拉取到本地\n\n脚本ID: ${scriptId}\n\n提示:脚本文件已自动创建在 script/{objName}/{scriptName}/ 目录下`
42
- }]
43
- };
44
- }
45
-
46
- // 如果提供了 scriptPath,使用 pull 方法(需要本地已存在)
47
- if (scriptPath) {
48
- await pullScriptModule([null, null, scriptPath]);
49
-
50
- return {
51
- content: [{
52
- type: 'text',
53
- text: `✓ 拉取成功!脚本已从服务器更新到本地\n\n脚本路径: script/${scriptPath}/`
54
- }]
55
- };
30
+ const resolvedPath = path.resolve(projectPath);
31
+ if (scriptId) {
32
+ const run = runCcCommand(['pullList', 'script', scriptId, resolvedPath], { cwd: resolvedPath });
33
+ if (!run.success) {
34
+ return { content: [{ type: 'text', text: `✗ 拉取失败: ${buildRunDetail(run) || 'cc 命令执行失败'}` }] };
56
35
  }
57
- } finally {
58
- process.chdir(originalCwd);
36
+ return {
37
+ content: [{
38
+ type: 'text',
39
+ text: `✓ 拉取成功!脚本已从服务器拉取到本地\n\n脚本ID: ${scriptId}\n\n提示:脚本文件已自动创建在 script/{objName}/{scriptName}/ 目录下`
40
+ }]
41
+ };
59
42
  }
43
+ const run = runCcCommand(['pull', 'script', scriptPath], { cwd: resolvedPath });
44
+ if (!run.success) {
45
+ return { content: [{ type: 'text', text: `✗ 拉取失败: ${buildRunDetail(run) || 'cc 命令执行失败'}` }] };
46
+ }
47
+ return {
48
+ content: [{
49
+ type: 'text',
50
+ text: `✓ 拉取成功!脚本已从服务器更新到本地\n\n脚本路径: script/${scriptPath}/`
51
+ }]
52
+ };
60
53
  } catch (error) {
61
54
  return {
62
55
  content: [{
@@ -3,7 +3,7 @@
3
3
  * 提供 CloudCC 开发项目的总纲和工具导航
4
4
  */
5
5
 
6
- const { prompts } = require('./prompt.js');
6
+ const { runCcCommand, buildRunDetail } = require('../../cliRunner');
7
7
 
8
8
  /**
9
9
  * 获取 CloudCC 开发项目概要信息
@@ -21,14 +21,20 @@ const { prompts } = require('./prompt.js');
21
21
  */
22
22
  async function getCloudCCDevelopmentOverview({ }) {
23
23
  try {
24
-
25
- // 获取指定主题的内容
26
- const result = prompts.overviewContent;
24
+ const run = runCcCommand(['doc', 'project', 'overview']);
25
+ if (!run.success) {
26
+ return {
27
+ content: [{
28
+ type: 'text',
29
+ text: `✗ 获取 CloudCC 开发项目概要失败: ${buildRunDetail(run) || 'cc 命令执行失败'}`
30
+ }]
31
+ };
32
+ }
27
33
 
28
34
  return {
29
35
  content: [{
30
36
  type: 'text',
31
- text: result
37
+ text: run.stdout || ''
32
38
  }]
33
39
  };
34
40
  } catch (error) {
@@ -5,29 +5,30 @@
5
5
  */
6
6
 
7
7
  const path = require('path');
8
- const createPluginModule = require('../../../plugin/create1');
8
+ const { runCcCommand, buildRunDetail } = require('../../cliRunner');
9
9
 
10
10
  /**
11
11
  * 创建插件/自定义组件
12
12
  */
13
13
  async function createCustomComponent({ pluginName, projectPath = process.cwd() }) {
14
14
  try {
15
- // 临时改变工作目录以兼容原有模块
16
- const originalCwd = process.cwd();
17
- process.chdir(projectPath);
18
-
19
- try {
20
- await createPluginModule(['plugin', 'create', pluginName]);
21
- const pluginPath = path.join(projectPath, `plugins/${pluginName}`);
15
+ const resolvedPath = path.resolve(projectPath);
16
+ const run = runCcCommand(['create', 'plugin', pluginName], { cwd: resolvedPath });
17
+ if (!run.success) {
22
18
  return {
23
19
  content: [{
24
20
  type: 'text',
25
- text: `✓ 自定义组件创建成功!\n\n组件路径: ${pluginPath}\n生成的文件:\n - ${pluginName}.vue (主组件文件)\n - components/HelloWorld.vue (示例子组件)\n - config.json (配置文件)\n\n下一步:\n1. 编辑 ${pluginName}.vue 实现你的组件逻辑\n2. 在 componentInfo 中配置组件信息\n3. 确保所有 <style> 标签都有 scoped 属性\n4. 使用 publish_plugin 或 publish_component 发布到服务器`
21
+ text: `✗ 创建失败: ${buildRunDetail(run) || 'cc 命令执行失败'}`
26
22
  }]
27
23
  };
28
- } finally {
29
- process.chdir(originalCwd);
30
24
  }
25
+ const pluginPath = path.join(projectPath, `plugins/${pluginName}`);
26
+ return {
27
+ content: [{
28
+ type: 'text',
29
+ text: `✓ 自定义组件创建成功!\n\n组件路径: ${pluginPath}\n生成的文件:\n - ${pluginName}.vue (主组件文件)\n - components/HelloWorld.vue (示例子组件)\n - config.json (配置文件)\n\n下一步:\n1. 编辑 ${pluginName}.vue 实现你的组件逻辑\n2. 在 componentInfo 中配置组件信息\n3. 确保所有 <style> 标签都有 scoped 属性\n4. 使用 publish_plugin 或 publish_component 发布到服务器`
30
+ }]
31
+ };
31
32
  } catch (error) {
32
33
  return {
33
34
  content: [{
@@ -3,7 +3,8 @@
3
3
  * 获取自定义组件的详细信息
4
4
  */
5
5
 
6
- const detailModule = require('../../../plugin/detail');
6
+ const path = require('path');
7
+ const { runCcJsonCommand } = require('../../cliRunner');
7
8
 
8
9
  /**
9
10
  * 获取自定义组件详细信息
@@ -14,15 +15,17 @@ const detailModule = require('../../../plugin/detail');
14
15
  */
15
16
  async function getCustomComponentDetail({ pluginName, pluginId, projectPath = process.cwd() }) {
16
17
  try {
17
- const originalCwd = process.cwd();
18
- process.chdir(projectPath);
19
-
20
- try {
21
- const detail = await detailModule(['get', pluginName, pluginId, projectPath]);
22
- return { content: [{ type: 'text', text: JSON.stringify(detail, null, 2) }] };
23
- } finally {
24
- process.chdir(originalCwd);
18
+ const resolvedPath = path.resolve(projectPath);
19
+ const run = runCcJsonCommand(['detail', 'plugin', pluginName || '', pluginId || '', resolvedPath], { cwd: resolvedPath });
20
+ if (!run.success) {
21
+ return {
22
+ content: [{
23
+ type: 'text',
24
+ text: `✗ 获取失败: ${run.detail || 'cc 命令执行失败'}\n\n可能的原因:\n- 组件不存在\n- 组件名称或ID不正确\n- 网络连接问题`
25
+ }]
26
+ };
25
27
  }
28
+ return { content: [{ type: 'text', text: JSON.stringify(run.data, null, 2) }] };
26
29
  } catch (error) {
27
30
  return {
28
31
  content: [{
@@ -6,7 +6,7 @@
6
6
  * 1. 默认返回规范、最佳实践、强制要求和API概要
7
7
  * 2. 需要详细信息时再查询具体主题
8
8
  */
9
- const prompt = require('./prompt');
9
+ const { runCcCommand, buildRunDetail } = require('../../cliRunner');
10
10
 
11
11
  /**
12
12
  * 获取编辑指南
@@ -28,37 +28,20 @@ const prompt = require('./prompt');
28
28
  */
29
29
  async function editComponent({ topic = 'overview' } = {}) {
30
30
  try {
31
- // 验证 topic 参数
32
- const validTopics = [
33
- 'overview',
34
- 'component-structure',
35
- 'config',
36
- 'data-structure',
37
- 'style-scoped',
38
- 'publish-workflow',
39
- 'dependency',
40
- 'project-config',
41
- 'api',
42
- 'bestpractices',
43
- 'faq'
44
- ];
45
-
46
- if (topic && !validTopics.includes(topic)) {
31
+ const run = runCcCommand(['doc', 'plugin', topic]);
32
+ if (!run.success) {
47
33
  return {
48
34
  content: [{
49
35
  type: 'text',
50
- text: `✗ 无效的主题: "${topic}"\n\n支持的主题:\n${validTopics.map(t => `- ${t}`).join('\n')}`
36
+ text: `✗ 获取编辑指南失败: ${buildRunDetail(run) || 'cc 命令执行失败'}`
51
37
  }]
52
38
  };
53
39
  }
54
40
 
55
- // 获取指定主题的编辑指南
56
- const result = prompt.getEditGuide(topic);
57
-
58
41
  return {
59
42
  content: [{
60
43
  type: 'text',
61
- text: result
44
+ text: run.stdout || ''
62
45
  }]
63
46
  };
64
47
  } catch (error) {
@@ -3,31 +3,34 @@
3
3
  * 提供自定义组件列表查询功能
4
4
  */
5
5
 
6
- const getPluginModule = require('../../../plugin/get');
6
+ const path = require('path');
7
+ const { runCcJsonCommand } = require('../../cliRunner');
7
8
 
8
9
  /**
9
10
  * 获取自定义组件列表
10
11
  */
11
12
  async function listCustomComponents({ projectPath = process.cwd() }) {
12
13
  try {
13
- const originalCwd = process.cwd();
14
- process.chdir(projectPath);
15
-
16
- try {
17
- const componentList = await getPluginModule(['get', projectPath]);
18
-
19
- if (!componentList || componentList.length === 0) {
20
- return {
21
- content: [{
22
- type: 'text',
23
- text: '未找到任何自定义组件\n\n提示:使用 create_plugin 创建新组件'
24
- }]
25
- };
26
- }
27
- return { content: [{ type: 'text', text: JSON.stringify(componentList, null, 2) }] };
28
- } finally {
29
- process.chdir(originalCwd);
14
+ const resolvedPath = path.resolve(projectPath);
15
+ const run = runCcJsonCommand(['get', 'plugin', resolvedPath], { cwd: resolvedPath });
16
+ if (!run.success) {
17
+ return {
18
+ content: [{
19
+ type: 'text',
20
+ text: `✗ 查询失败: ${run.detail || 'cc 命令执行失败'}\n\n可能的原因:\n- 项目路径不正确\n- 网络连接问题\n- 服务器API不可用`
21
+ }]
22
+ };
23
+ }
24
+ const componentList = run.data || [];
25
+ if (!componentList.length) {
26
+ return {
27
+ content: [{
28
+ type: 'text',
29
+ text: '未找到任何自定义组件\n\n提示:使用 create_plugin 创建新组件'
30
+ }]
31
+ };
30
32
  }
33
+ return { content: [{ type: 'text', text: JSON.stringify(componentList, null, 2) }] };
31
34
  } catch (error) {
32
35
  return {
33
36
  content: [{
@@ -1,14 +1,36 @@
1
1
  /**
2
2
  * 发布插件/自定义组件到服务器
3
- * 返回命令给智能体执行,而不是在工具中执行
4
3
  */
4
+ const path = require('path');
5
+ const { runCcCommand } = require('../../cliRunner');
6
+
5
7
  async function publishCustomComponent({ componentName, projectPath = process.cwd() }) {
6
- const command = `npx cc publish plugin ${componentName}`;
8
+ if (!componentName || !componentName.trim()) {
9
+ return {
10
+ content: [{
11
+ type: 'text',
12
+ text: '✗ 参数缺失: componentName 必须提供'
13
+ }]
14
+ };
15
+ }
16
+
17
+ const resolvedPath = path.resolve(projectPath);
18
+ const runResult = runCcCommand(['publish', 'plugin', componentName], { cwd: resolvedPath });
19
+
20
+ if (!runResult.success) {
21
+ const detail = [runResult.error, runResult.stderr, runResult.stdout].filter(Boolean).join('\n');
22
+ return {
23
+ content: [{
24
+ type: 'text',
25
+ text: `✗ 发布失败: ${detail || 'cc 命令执行失败'}`
26
+ }]
27
+ };
28
+ }
7
29
 
8
30
  return {
9
31
  content: [{
10
32
  type: 'text',
11
- text: `请执行以下命令发布自定义组件:\n\n\`\`\`bash\n${command}\n\`\`\`\n\n组件名称: ${componentName}\n项目路径: ${projectPath}\n\n执行此命令将:\n1. 编译 Vue 组件\n2. 收集依赖文件\n3. 上传到 CloudCC 服务器`
33
+ text: `✓ 自定义组件发布成功\n\n调用命令: cc publish plugin ${componentName}\n执行目录: ${resolvedPath}\n组件名称: ${componentName}\n\n执行过程:\n1. 编译 Vue 组件\n2. 收集依赖文件\n3. 上传到 CloudCC 服务器`
12
34
  }]
13
35
  };
14
36
  }
@@ -4,7 +4,8 @@
4
4
  * 支持通过组件名或ID拉取
5
5
  */
6
6
 
7
- const pullPluginModule = require('../../../plugin/pull');
7
+ const path = require('path');
8
+ const { runCcCommand, buildRunDetail } = require('../../cliRunner');
8
9
 
9
10
  /**
10
11
  * 从服务器拉取自定义组件
@@ -27,27 +28,23 @@ async function pullCustomComponent({ componentName, componentId, projectPath = p
27
28
  };
28
29
  }
29
30
 
30
- const originalCwd = process.cwd();
31
- process.chdir(projectPath);
32
-
33
- try {
34
- // pull.js 已经支持组件名和ID的自动判断
35
- // 如果传入组件名且本地存在 config.json,会自动读取 id
36
- // 如果传入 ID,直接通过 ID 拉取
37
- await pullPluginModule([null, null, input, projectPath]);
38
-
39
- // 从输入推断组件名(用于显示)
40
- const displayName = componentName || input;
41
-
31
+ const resolvedPath = path.resolve(projectPath);
32
+ const run = runCcCommand(['pull', 'plugin', input, resolvedPath], { cwd: resolvedPath });
33
+ if (!run.success) {
42
34
  return {
43
35
  content: [{
44
36
  type: 'text',
45
- text: `✓ 拉取成功!组件已从服务器拉取到本地\n\n本地路径: plugins/${displayName}/`
37
+ text: `✗ 拉取失败: ${buildRunDetail(run) || 'cc 命令执行失败'}`
46
38
  }]
47
39
  };
48
- } finally {
49
- process.chdir(originalCwd);
50
40
  }
41
+ const displayName = componentName || input;
42
+ return {
43
+ content: [{
44
+ type: 'text',
45
+ text: `✓ 拉取成功!组件已从服务器拉取到本地\n\n本地路径: plugins/${displayName}/`
46
+ }]
47
+ };
51
48
  } catch (error) {
52
49
  return {
53
50
  content: [{
@@ -3,85 +3,18 @@
3
3
  * 提供开发环境搭建指南的查询功能
4
4
  */
5
5
 
6
- const devEnvDoc = require('./prompt.js');
7
- const {
8
- searchSteps,
9
- getCommandsByPlatform,
10
- getStep,
11
- getAllSteps,
12
- getStepsByDifficulty,
13
- } = require('./prompt.js');
6
+ const { runCcCommand, buildRunDetail } = require('../../cliRunner');
14
7
 
15
8
  /**
16
9
  * 获取开发环境搭建指南
17
10
  */
18
11
  async function getDevEnvSetup(params = {}) {
19
- const { step, search, difficulty, platform, command } = params;
20
-
21
12
  try {
22
- if (search) {
23
- const results = searchSteps(search);
24
- if (results.length === 0) {
25
- return { content: [{ type: 'text', text: `未找到包含 "${search}" 的步骤。` }] };
26
- }
27
- let content = `# 搜索结果: "${search}"\n\n找到 ${results.length} 个相关步骤\n\n`;
28
- results.forEach(s => {
29
- content += `## ${s.number}. ${s.title}\n**难度**: ${s.difficulty}\n\n`;
30
- });
31
- return { content: [{ type: 'text', text: content }] };
13
+ const run = runCcCommand(['doc', 'project', 'dev-env-creator', JSON.stringify(params || {})]);
14
+ if (!run.success) {
15
+ return { content: [{ type: 'text', text: `错误: ${buildRunDetail(run) || 'cc 命令执行失败'}` }] };
32
16
  }
33
-
34
- if (difficulty) {
35
- const results = getStepsByDifficulty(difficulty);
36
- let content = `# ${difficulty} 难度步骤 (共 ${results.length} 个)\n\n`;
37
- results.forEach(s => {
38
- content += `${s.number}. ${s.title}\n`;
39
- });
40
- return { content: [{ type: 'text', text: content }] };
41
- }
42
-
43
- if (platform) {
44
- const commands = getCommandsByPlatform(platform);
45
- let content = `# ${platform} 平台命令 (共 ${commands.length} 个)\n\n`;
46
- commands.forEach((cmd, idx) => {
47
- content += `${idx + 1}. ${cmd.description}\n\`\`\`bash\n${cmd.command}\n\`\`\`\n\n`;
48
- });
49
- return { content: [{ type: 'text', text: content }] };
50
- }
51
-
52
- if (step) {
53
- const targetStep = getStep(step);
54
- if (!targetStep) {
55
- return { content: [{ type: 'text', text: `无效的步骤编号 ${step}` }] };
56
- }
57
- let content = `# 步骤 ${targetStep.number}: ${targetStep.title}\n\n**难度**: ${targetStep.difficulty}\n**耗时**: ${targetStep.estimatedTime} 分钟\n\n${targetStep.description}`;
58
- if (targetStep.commands && targetStep.commands.length > 0) {
59
- content += `\n\n## 命令 (共 ${targetStep.commands.length} 个)\n\n`;
60
- targetStep.commands.forEach((cmd, idx) => {
61
- content += `${idx + 1}. ${cmd.description}\n\`\`\`bash\n${cmd.command}\n\`\`\`\n\n`;
62
- });
63
- }
64
- return { content: [{ type: 'text', text: content }] };
65
- }
66
-
67
- if (command) {
68
- const steps = getAllSteps();
69
- let content = `# 所有命令 (共 ${steps.reduce((sum, s) => sum + s.commands.length, 0)} 个)\n\n`;
70
- steps.forEach(s => {
71
- if (s.commands.length > 0) {
72
- content += `## ${s.title}\n`;
73
- s.commands.forEach(cmd => {
74
- content += `\`\`\`bash\n${cmd.command}\n\`\`\`\n`;
75
- });
76
- }
77
- });
78
- return { content: [{ type: 'text', text: content }] };
79
- }
80
-
81
- // Default overview
82
- const allSteps = getAllSteps();
83
- let content = `# ${devEnvDoc.title}\n\n${devEnvDoc.description}\n\n**版本**: ${devEnvDoc.version}\n**步骤**: ${allSteps.length}`;
84
- return { content: [{ type: 'text', text: content }] };
17
+ return { content: [{ type: 'text', text: run.stdout || '' }] };
85
18
  } catch (error) {
86
19
  return { content: [{ type: 'text', text: `错误: ${error.message}` }] };
87
20
  }