congmao-cli 1.0.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.
Files changed (180) hide show
  1. package/README.md +2 -0
  2. package/bin/index.js +20 -0
  3. package/package.json +42 -0
  4. package/src/commands/create.js +171 -0
  5. package/src/commands/mcp.js +157 -0
  6. package/src/mcp/CURSOR_SETUP.md +259 -0
  7. package/src/mcp/README.md +134 -0
  8. package/src/mcp/USAGE_EXAMPLES.md +181 -0
  9. package/src/mcp/get-cursor-config.js +58 -0
  10. package/src/mcp/package.json +23 -0
  11. package/src/mcp/pnpm-lock.yaml +2441 -0
  12. package/src/mcp/src/handlers.js +211 -0
  13. package/src/mcp/src/http-server.js +332 -0
  14. package/src/mcp/src/index.js +195 -0
  15. package/src/mcp/src/schemas.js +54 -0
  16. package/src/mcp/test-create-project.js +49 -0
  17. package/src/mcp/test-mcp.js +89 -0
  18. package/src/mcp/test-show-tree.js +66 -0
  19. package/src/template/Uni-app/README.md +19 -0
  20. package/src/template/Uni-app/babel.config.js +81 -0
  21. package/src/template/Uni-app/package.json +107 -0
  22. package/src/template/Uni-app/postcss.config.js +27 -0
  23. package/src/template/Uni-app/public/index.html +25 -0
  24. package/src/template/Uni-app/shims-uni.d.ts +11 -0
  25. package/src/template/Uni-app/shims-vue.d.ts +4 -0
  26. package/src/template/Uni-app/src/App.vue +17 -0
  27. package/src/template/Uni-app/src/main.js +12 -0
  28. package/src/template/Uni-app/src/manifest.json +75 -0
  29. package/src/template/Uni-app/src/pages/index/index.vue +49 -0
  30. package/src/template/Uni-app/src/pages.json +16 -0
  31. package/src/template/Uni-app/src/static/logo.png +0 -0
  32. package/src/template/Uni-app/src/uni.promisify.adaptor.js +13 -0
  33. package/src/template/Uni-app/src/uni.scss +76 -0
  34. package/src/template/Uni-app/yarn.lock +11466 -0
  35. package/src/template/Vue2/.editorconfig +14 -0
  36. package/src/template/Vue2/.env +2 -0
  37. package/src/template/Vue2/.env.development +2 -0
  38. package/src/template/Vue2/.env.site +2 -0
  39. package/src/template/Vue2/.prettierrc.js +39 -0
  40. package/src/template/Vue2/.stylelintignore +8 -0
  41. package/src/template/Vue2/README-zh_CN.md +115 -0
  42. package/src/template/Vue2/commitlint.config.js +1 -0
  43. package/src/template/Vue2/docs/docs-starter.png +0 -0
  44. package/src/template/Vue2/docs/docs-startup.png +0 -0
  45. package/src/template/Vue2/docs/docs-structure.png +0 -0
  46. package/src/template/Vue2/globals.d.ts +13 -0
  47. package/src/template/Vue2/index.html +27 -0
  48. package/src/template/Vue2/jsx.d.ts +13 -0
  49. package/src/template/Vue2/mock/index.ts +147 -0
  50. package/src/template/Vue2/package.json +91 -0
  51. package/src/template/Vue2/package.json.ejs +91 -0
  52. package/src/template/Vue2/public/favicon.ico +0 -0
  53. package/src/template/Vue2/shims-vue.d.ts +5 -0
  54. package/src/template/Vue2/src/App.vue +19 -0
  55. package/src/template/Vue2/src/assets/assets-login-bg-black.png +0 -0
  56. package/src/template/Vue2/src/assets/assets-login-bg-white.png +0 -0
  57. package/src/template/Vue2/src/assets/assets-logo-full.svg +39 -0
  58. package/src/template/Vue2/src/assets/assets-product-1.svg +5 -0
  59. package/src/template/Vue2/src/assets/assets-product-2.svg +5 -0
  60. package/src/template/Vue2/src/assets/assets-product-3.svg +5 -0
  61. package/src/template/Vue2/src/assets/assets-product-4.svg +5 -0
  62. package/src/template/Vue2/src/assets/assets-result-403.svg +32 -0
  63. package/src/template/Vue2/src/assets/assets-result-404.svg +36 -0
  64. package/src/template/Vue2/src/assets/assets-result-500.svg +32 -0
  65. package/src/template/Vue2/src/assets/assets-result-ie.svg +33 -0
  66. package/src/template/Vue2/src/assets/assets-result-maintenance.svg +49 -0
  67. package/src/template/Vue2/src/assets/assets-result-wifi.svg +23 -0
  68. package/src/template/Vue2/src/assets/assets-setting-auto.svg +13 -0
  69. package/src/template/Vue2/src/assets/assets-setting-dark.svg +5 -0
  70. package/src/template/Vue2/src/assets/assets-setting-light.svg +13 -0
  71. package/src/template/Vue2/src/assets/assets-t-logo.svg +41 -0
  72. package/src/template/Vue2/src/assets/assets-tencent-logo.png +0 -0
  73. package/src/template/Vue2/src/components/color/index.vue +35 -0
  74. package/src/template/Vue2/src/components/product-card/index.vue +121 -0
  75. package/src/template/Vue2/src/components/result/index.vue +118 -0
  76. package/src/template/Vue2/src/components/thumbnail/index.vue +49 -0
  77. package/src/template/Vue2/src/components/trend/index.vue +105 -0
  78. package/src/template/Vue2/src/config/color.ts +30 -0
  79. package/src/template/Vue2/src/config/global.ts +2 -0
  80. package/src/template/Vue2/src/config/host.ts +26 -0
  81. package/src/template/Vue2/src/config/style.ts +14 -0
  82. package/src/template/Vue2/src/constants/index.ts +46 -0
  83. package/src/template/Vue2/src/interface.ts +39 -0
  84. package/src/template/Vue2/src/layouts/blank.vue +12 -0
  85. package/src/template/Vue2/src/layouts/components/Breadcrumb.vue +39 -0
  86. package/src/template/Vue2/src/layouts/components/Content.vue +43 -0
  87. package/src/template/Vue2/src/layouts/components/Footer.vue +27 -0
  88. package/src/template/Vue2/src/layouts/components/Header.vue +321 -0
  89. package/src/template/Vue2/src/layouts/components/LayoutContent.vue +168 -0
  90. package/src/template/Vue2/src/layouts/components/LayoutHeader.vue +52 -0
  91. package/src/template/Vue2/src/layouts/components/LayoutSidebar.vue +51 -0
  92. package/src/template/Vue2/src/layouts/components/MenuContent.vue +108 -0
  93. package/src/template/Vue2/src/layouts/components/Notice.vue +221 -0
  94. package/src/template/Vue2/src/layouts/components/Search.vue +134 -0
  95. package/src/template/Vue2/src/layouts/components/SideNav.vue +150 -0
  96. package/src/template/Vue2/src/layouts/index.vue +100 -0
  97. package/src/template/Vue2/src/layouts/setting.vue +404 -0
  98. package/src/template/Vue2/src/main.js +9 -0
  99. package/src/template/Vue2/src/main.jsx +51 -0
  100. package/src/template/Vue2/src/pages/dashboard/base/components/MiddleChart.vue +158 -0
  101. package/src/template/Vue2/src/pages/dashboard/base/components/OutputOverview.vue +189 -0
  102. package/src/template/Vue2/src/pages/dashboard/base/components/RankList.vue +111 -0
  103. package/src/template/Vue2/src/pages/dashboard/base/components/TopPanel.vue +246 -0
  104. package/src/template/Vue2/src/pages/dashboard/base/index.ts +702 -0
  105. package/src/template/Vue2/src/pages/dashboard/base/index.vue +44 -0
  106. package/src/template/Vue2/src/pages/dashboard/detail/index.ts +267 -0
  107. package/src/template/Vue2/src/pages/dashboard/detail/index.vue +242 -0
  108. package/src/template/Vue2/src/pages/detail/advanced/components/Product.vue +167 -0
  109. package/src/template/Vue2/src/pages/detail/advanced/index.less +74 -0
  110. package/src/template/Vue2/src/pages/detail/advanced/index.vue +219 -0
  111. package/src/template/Vue2/src/pages/detail/base/index.less +105 -0
  112. package/src/template/Vue2/src/pages/detail/base/index.vue +46 -0
  113. package/src/template/Vue2/src/pages/detail/deploy/index.ts +204 -0
  114. package/src/template/Vue2/src/pages/detail/deploy/index.vue +224 -0
  115. package/src/template/Vue2/src/pages/detail/secondary/index.less +71 -0
  116. package/src/template/Vue2/src/pages/detail/secondary/index.vue +131 -0
  117. package/src/template/Vue2/src/pages/form/base/index.less +57 -0
  118. package/src/template/Vue2/src/pages/form/base/index.vue +254 -0
  119. package/src/template/Vue2/src/pages/form/step/index.less +37 -0
  120. package/src/template/Vue2/src/pages/form/step/index.vue +259 -0
  121. package/src/template/Vue2/src/pages/frame/doc/index.vue +86 -0
  122. package/src/template/Vue2/src/pages/frame/tdesign/index.vue +86 -0
  123. package/src/template/Vue2/src/pages/list/base/index.vue +267 -0
  124. package/src/template/Vue2/src/pages/list/card/index.vue +221 -0
  125. package/src/template/Vue2/src/pages/list/components/CommonTable.vue +313 -0
  126. package/src/template/Vue2/src/pages/list/filter/index.vue +15 -0
  127. package/src/template/Vue2/src/pages/list/tree/index.vue +174 -0
  128. package/src/template/Vue2/src/pages/login/components/components-header.vue +74 -0
  129. package/src/template/Vue2/src/pages/login/components/components-login.vue +154 -0
  130. package/src/template/Vue2/src/pages/login/components/components-register.vue +144 -0
  131. package/src/template/Vue2/src/pages/login/index.less +202 -0
  132. package/src/template/Vue2/src/pages/login/index.vue +53 -0
  133. package/src/template/Vue2/src/pages/nest-menu/Index.vue +10 -0
  134. package/src/template/Vue2/src/pages/result/403/index.vue +14 -0
  135. package/src/template/Vue2/src/pages/result/404/index.vue +14 -0
  136. package/src/template/Vue2/src/pages/result/500/index.vue +14 -0
  137. package/src/template/Vue2/src/pages/result/browser-incompatible/index.vue +77 -0
  138. package/src/template/Vue2/src/pages/result/fail/index.vue +57 -0
  139. package/src/template/Vue2/src/pages/result/maintenance/index.vue +14 -0
  140. package/src/template/Vue2/src/pages/result/network-error/index.vue +24 -0
  141. package/src/template/Vue2/src/pages/result/success/index.vue +59 -0
  142. package/src/template/Vue2/src/pages/user/index.less +148 -0
  143. package/src/template/Vue2/src/pages/user/index.ts +157 -0
  144. package/src/template/Vue2/src/pages/user/index.vue +204 -0
  145. package/src/template/Vue2/src/permission.js +56 -0
  146. package/src/template/Vue2/src/router/index.js +43 -0
  147. package/src/template/Vue2/src/router/modules/base.ts +29 -0
  148. package/src/template/Vue2/src/router/modules/components.ts +175 -0
  149. package/src/template/Vue2/src/router/modules/others.ts +55 -0
  150. package/src/template/Vue2/src/service/service-advance.ts +233 -0
  151. package/src/template/Vue2/src/service/service-base.ts +205 -0
  152. package/src/template/Vue2/src/service/service-detail-base.ts +84 -0
  153. package/src/template/Vue2/src/service/service-detail-deploy.ts +234 -0
  154. package/src/template/Vue2/src/service/service-detail.ts +57 -0
  155. package/src/template/Vue2/src/service/service-user.ts +64 -0
  156. package/src/template/Vue2/src/store/index.ts +22 -0
  157. package/src/template/Vue2/src/store/modules/notification.ts +90 -0
  158. package/src/template/Vue2/src/store/modules/permission.ts +66 -0
  159. package/src/template/Vue2/src/store/modules/setting.ts +122 -0
  160. package/src/template/Vue2/src/store/modules/tab-router.ts +83 -0
  161. package/src/template/Vue2/src/store/modules/user.ts +98 -0
  162. package/src/template/Vue2/src/style/font-family.less +6 -0
  163. package/src/template/Vue2/src/style/index.less +5 -0
  164. package/src/template/Vue2/src/style/layout.less +201 -0
  165. package/src/template/Vue2/src/style/reset.less +78 -0
  166. package/src/template/Vue2/src/style/variables.less +27 -0
  167. package/src/template/Vue2/src/utils/charts.ts +38 -0
  168. package/src/template/Vue2/src/utils/color.ts +118 -0
  169. package/src/template/Vue2/src/utils/date.ts +12 -0
  170. package/src/template/Vue2/src/utils/request.ts +60 -0
  171. package/src/template/Vue2/stylelint.config.js +5 -0
  172. package/src/template/Vue2/tsconfig.json +26 -0
  173. package/src/template/Vue2/vite.config.js +58 -0
  174. package/src/template/Vue3/package.json.ejs +8 -0
  175. package/src/template/Vue3/pages.json +10 -0
  176. package/src/template/Vue3/src/main.js +7 -0
  177. package/src/utils/copy.js +17 -0
  178. package/src/utils/eslint.js +205 -0
  179. package/src/utils/logo.js +18 -0
  180. package/src/utils/render.js +20 -0
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import {
6
+ CallToolRequestSchema,
7
+ ListToolsRequestSchema,
8
+ } from "@modelcontextprotocol/sdk/types.js";
9
+ import packageJson from "../package.json" assert { type: "json" };
10
+ import { createProject, showProjectTree } from "./handlers.js";
11
+ import { validateCreateProject, validateShowProjectTree } from "./schemas.js";
12
+
13
+ /**
14
+ * CM CLI 的 MCP 服务器
15
+ * 为 AI 助手提供快速创建项目和查看项目结构的能力
16
+ */
17
+ const server = new Server(
18
+ {
19
+ name: packageJson.name,
20
+ version: packageJson.version,
21
+ },
22
+ {
23
+ capabilities: {
24
+ tools: {},
25
+ },
26
+ }
27
+ );
28
+
29
+ /**
30
+ * 快速创建项目工具
31
+ * 支持创建 Uni-app、Vue2、Vue3 项目
32
+ */
33
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
34
+ return {
35
+ tools: [
36
+ {
37
+ name: "create-project",
38
+ description:
39
+ "快速创建项目。支持创建移动端(Uni-app)、小程序(Uni-app)、后台管理系统(Vue2/Vue3)项目。可以自动配置ESLint。",
40
+ inputSchema: {
41
+ type: "object",
42
+ properties: {
43
+ projectName: {
44
+ type: "string",
45
+ description: "项目名称,只能包含小写字母、数字和连字符",
46
+ },
47
+ projectType: {
48
+ type: "string",
49
+ enum: ["mobile", "miniprogram", "admin"],
50
+ description: "项目类型:mobile-移动端, miniprogram-小程序, admin-后台管理系统",
51
+ },
52
+ vueVersion: {
53
+ type: "string",
54
+ enum: ["Vue2", "Vue3"],
55
+ description: "Vue版本(仅当projectType为admin时需要)",
56
+ },
57
+ needESLint: {
58
+ type: "boolean",
59
+ description: "是否配置ESLint,默认为true",
60
+ default: true,
61
+ },
62
+ targetPath: {
63
+ type: "string",
64
+ description: "目标路径,默认为当前工作目录",
65
+ },
66
+ },
67
+ required: ["projectName", "projectType"],
68
+ },
69
+ },
70
+ {
71
+ name: "show-project-tree",
72
+ description:
73
+ "查看项目结构树。可以显示指定项目的目录结构,支持自定义深度和忽略模式。",
74
+ inputSchema: {
75
+ type: "object",
76
+ properties: {
77
+ projectPath: {
78
+ type: "string",
79
+ description: "项目路径,可以是相对路径或绝对路径",
80
+ },
81
+ maxDepth: {
82
+ type: "number",
83
+ description: "最大深度,默认为3",
84
+ default: 3,
85
+ },
86
+ ignorePatterns: {
87
+ type: "array",
88
+ items: {
89
+ type: "string",
90
+ },
91
+ description: "忽略的目录模式,默认为['node_modules', '.git', 'dist', 'build']",
92
+ default: ["node_modules", ".git", "dist", "build"],
93
+ },
94
+ },
95
+ required: ["projectPath"],
96
+ },
97
+ },
98
+ ],
99
+ };
100
+ });
101
+
102
+ /**
103
+ * 处理工具调用请求
104
+ */
105
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
106
+ const { name, arguments: args } = request.params;
107
+
108
+ try {
109
+ switch (name) {
110
+ case "create-project": {
111
+ // 验证输入
112
+ const validatedInput = validateCreateProject(args);
113
+ const result = await createProject(validatedInput);
114
+
115
+ if (result.success) {
116
+ return {
117
+ content: [
118
+ {
119
+ type: "text",
120
+ text: result.message || "项目创建成功!",
121
+ },
122
+ ],
123
+ };
124
+ } else {
125
+ return {
126
+ content: [
127
+ {
128
+ type: "text",
129
+ text: `错误: ${result.error}`,
130
+ },
131
+ ],
132
+ isError: true,
133
+ };
134
+ }
135
+ }
136
+
137
+ case "show-project-tree": {
138
+ // 验证输入
139
+ const validatedInput = validateShowProjectTree(args);
140
+ const result = await showProjectTree(validatedInput);
141
+
142
+ if (result.success) {
143
+ return {
144
+ content: [
145
+ {
146
+ type: "text",
147
+ text: result.message || result.tree || "项目结构树",
148
+ },
149
+ ],
150
+ };
151
+ } else {
152
+ return {
153
+ content: [
154
+ {
155
+ type: "text",
156
+ text: `错误: ${result.error}`,
157
+ },
158
+ ],
159
+ isError: true,
160
+ };
161
+ }
162
+ }
163
+
164
+ default:
165
+ return {
166
+ content: [
167
+ {
168
+ type: "text",
169
+ text: `未知的工具: ${name}`,
170
+ },
171
+ ],
172
+ isError: true,
173
+ };
174
+ }
175
+ } catch (error) {
176
+ return {
177
+ content: [
178
+ {
179
+ type: "text",
180
+ text: `工具执行失败: ${error.message}`,
181
+ },
182
+ ],
183
+ isError: true,
184
+ };
185
+ }
186
+ });
187
+
188
+ // 启动服务器
189
+ async function main() {
190
+ const transport = new StdioServerTransport();
191
+ await server.connect(transport);
192
+ console.error("CM CLI MCP 服务器已启动");
193
+ }
194
+
195
+ main().catch(console.error);
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 验证创建项目的输入
3
+ */
4
+ export function validateCreateProject(input) {
5
+ const errors = [];
6
+
7
+ if (!input.projectName) {
8
+ errors.push("projectName 是必需的");
9
+ } else if (!/^[a-z0-9-]+$/.test(input.projectName)) {
10
+ errors.push("项目名称只能包含小写字母、数字和连字符");
11
+ }
12
+
13
+ if (!input.projectType) {
14
+ errors.push("projectType 是必需的");
15
+ } else if (!["mobile", "miniprogram", "admin"].includes(input.projectType)) {
16
+ errors.push("projectType 必须是 mobile、miniprogram 或 admin");
17
+ }
18
+
19
+ if (input.projectType === "admin" && !input.vueVersion) {
20
+ errors.push("后台管理系统需要指定 vueVersion");
21
+ }
22
+
23
+ if (input.vueVersion && !["Vue2", "Vue3"].includes(input.vueVersion)) {
24
+ errors.push("vueVersion 必须是 Vue2 或 Vue3");
25
+ }
26
+
27
+ if (errors.length > 0) {
28
+ throw new Error(errors.join("; "));
29
+ }
30
+
31
+ return {
32
+ projectName: input.projectName,
33
+ projectType: input.projectType,
34
+ vueVersion: input.vueVersion,
35
+ needESLint: input.needESLint !== undefined ? input.needESLint : true,
36
+ targetPath: input.targetPath || process.cwd(),
37
+ };
38
+ }
39
+
40
+ /**
41
+ * 验证查看项目结构树的输入
42
+ */
43
+ export function validateShowProjectTree(input) {
44
+ if (!input.projectPath) {
45
+ throw new Error("projectPath 是必需的");
46
+ }
47
+
48
+ return {
49
+ projectPath: input.projectPath,
50
+ maxDepth: input.maxDepth || 3,
51
+ ignorePatterns: input.ignorePatterns || ["node_modules", ".git", "dist", "build"],
52
+ };
53
+ }
54
+
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 测试 create-project 工具
5
+ * 直接调用 handlers 创建项目
6
+ */
7
+
8
+ import { createProject } from "./src/handlers.js";
9
+ import { validateCreateProject } from "./src/schemas.js";
10
+
11
+ async function testCreateProject() {
12
+ const input = {
13
+ projectName: "my-admin-app",
14
+ projectType: "admin",
15
+ vueVersion: "Vue2",
16
+ needESLint: true,
17
+ };
18
+
19
+ console.log("🚀 开始创建项目...");
20
+ console.log("参数:", JSON.stringify(input, null, 2));
21
+ console.log("");
22
+
23
+ try {
24
+ // 验证输入
25
+ const validatedInput = validateCreateProject(input);
26
+
27
+ // 创建项目
28
+ const result = await createProject(validatedInput);
29
+
30
+ if (result.success) {
31
+ console.log("✅", result.message);
32
+ console.log("");
33
+ console.log("📁 项目路径:", result.projectPath);
34
+ console.log("📦 模板类型:", result.templateName);
35
+ console.log("");
36
+ console.log("📝 下一步操作:");
37
+ console.log(result.startCommands);
38
+ } else {
39
+ console.error("❌ 创建失败:", result.error);
40
+ process.exit(1);
41
+ }
42
+ } catch (error) {
43
+ console.error("❌ 错误:", error.message);
44
+ process.exit(1);
45
+ }
46
+ }
47
+
48
+ testCreateProject();
49
+
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * MCP 服务器测试脚本
5
+ * 用于验证 MCP 服务器的功能
6
+ */
7
+
8
+ import { spawn } from "child_process";
9
+ import { fileURLToPath } from "url";
10
+ import { dirname, resolve } from "path";
11
+
12
+ const __filename = fileURLToPath(import.meta.url);
13
+ const __dirname = dirname(__filename);
14
+
15
+ // 启动 MCP 服务器
16
+ const mcpServer = spawn("node", [resolve(__dirname, "src/index.js")], {
17
+ stdio: ["pipe", "pipe", "pipe"],
18
+ });
19
+
20
+ // 发送测试请求
21
+ const testRequests = [
22
+ // 测试列出工具
23
+ {
24
+ jsonrpc: "2.0",
25
+ id: 1,
26
+ method: "tools/list",
27
+ params: {},
28
+ },
29
+ // 测试创建项目
30
+ {
31
+ jsonrpc: "2.0",
32
+ id: 2,
33
+ method: "tools/call",
34
+ params: {
35
+ name: "create-project",
36
+ arguments: {
37
+ projectName: "test-project",
38
+ projectType: "admin",
39
+ vueVersion: "Vue2",
40
+ needESLint: true,
41
+ },
42
+ },
43
+ },
44
+ // 测试查看项目结构树
45
+ {
46
+ jsonrpc: "2.0",
47
+ id: 3,
48
+ method: "tools/call",
49
+ params: {
50
+ name: "show-project-tree",
51
+ arguments: {
52
+ projectPath: ".",
53
+ maxDepth: 2,
54
+ },
55
+ },
56
+ },
57
+ ];
58
+
59
+ let requestIndex = 0;
60
+
61
+ mcpServer.stdout.on("data", (data) => {
62
+ const response = data.toString();
63
+ console.log("响应:", response);
64
+
65
+ // 发送下一个请求
66
+ if (requestIndex < testRequests.length - 1) {
67
+ requestIndex++;
68
+ setTimeout(() => {
69
+ mcpServer.stdin.write(JSON.stringify(testRequests[requestIndex]) + "\n");
70
+ }, 100);
71
+ } else {
72
+ mcpServer.kill();
73
+ }
74
+ });
75
+
76
+ mcpServer.stderr.on("data", (data) => {
77
+ console.error("错误:", data.toString());
78
+ });
79
+
80
+ mcpServer.on("close", (code) => {
81
+ console.log(`MCP 服务器退出,代码: ${code}`);
82
+ process.exit(code);
83
+ });
84
+
85
+ // 发送第一个请求
86
+ setTimeout(() => {
87
+ mcpServer.stdin.write(JSON.stringify(testRequests[0]) + "\n");
88
+ }, 500);
89
+
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * 测试 show-project-tree 工具
5
+ * 直接调用 handlers 显示项目结构树
6
+ */
7
+
8
+ import { showProjectTree } from "./src/handlers.js";
9
+ import { validateShowProjectTree } from "./src/schemas.js";
10
+
11
+ async function testShowProjectTree() {
12
+ // 测试不同的项目路径
13
+ const testCases = [
14
+ {
15
+ name: "查看当前项目结构(深度2)",
16
+ input: {
17
+ projectPath: ".",
18
+ maxDepth: 2,
19
+ },
20
+ },
21
+ {
22
+ name: "查看模板目录结构(深度3)",
23
+ input: {
24
+ projectPath: "../template/Vue2",
25
+ maxDepth: 3,
26
+ ignorePatterns: ["node_modules", ".git", "dist", "build", "docs"],
27
+ },
28
+ },
29
+ {
30
+ name: "查看 MCP 源码目录结构",
31
+ input: {
32
+ projectPath: "./src",
33
+ maxDepth: 2,
34
+ },
35
+ },
36
+ ];
37
+
38
+ for (const testCase of testCases) {
39
+ console.log(`\n${"=".repeat(60)}`);
40
+ console.log(`📁 ${testCase.name}`);
41
+ console.log("=".repeat(60));
42
+ console.log("参数:", JSON.stringify(testCase.input, null, 2));
43
+ console.log("");
44
+
45
+ try {
46
+ // 验证输入
47
+ const validatedInput = validateShowProjectTree(testCase.input);
48
+
49
+ // 显示项目结构树
50
+ const result = await showProjectTree(validatedInput);
51
+
52
+ if (result.success) {
53
+ console.log(result.message || result.tree);
54
+ console.log("");
55
+ console.log("📁 项目路径:", result.projectPath);
56
+ } else {
57
+ console.error("❌ 错误:", result.error);
58
+ }
59
+ } catch (error) {
60
+ console.error("❌ 错误:", error.message);
61
+ }
62
+ }
63
+ }
64
+
65
+ testShowProjectTree();
66
+
@@ -0,0 +1,19 @@
1
+ # preset-uni-test
2
+
3
+ ## Project setup
4
+ ```
5
+ yarn install
6
+ ```
7
+
8
+ ### Compiles and hot-reloads for development
9
+ ```
10
+ yarn serve
11
+ ```
12
+
13
+ ### Compiles and minifies for production
14
+ ```
15
+ yarn build
16
+ ```
17
+
18
+ ### Customize configuration
19
+ See [Configuration Reference](https://cli.vuejs.org/config/).
@@ -0,0 +1,81 @@
1
+ const webpack = require('webpack')
2
+ const plugins = []
3
+
4
+ if (process.env.UNI_OPT_TREESHAKINGNG) {
5
+ plugins.push(require('@dcloudio/vue-cli-plugin-uni-optimize/packages/babel-plugin-uni-api/index.js'))
6
+ }
7
+
8
+ if (
9
+ (
10
+ process.env.UNI_PLATFORM === 'app-plus' &&
11
+ process.env.UNI_USING_V8
12
+ ) ||
13
+ (
14
+ process.env.UNI_PLATFORM === 'h5' &&
15
+ process.env.UNI_H5_BROWSER === 'builtin'
16
+ )
17
+ ) {
18
+ const path = require('path')
19
+
20
+ const isWin = /^win/.test(process.platform)
21
+
22
+ const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
23
+
24
+ const input = normalizePath(process.env.UNI_INPUT_DIR)
25
+ try {
26
+ plugins.push([
27
+ require('@dcloudio/vue-cli-plugin-hbuilderx/packages/babel-plugin-console'),
28
+ {
29
+ file (file) {
30
+ file = normalizePath(file)
31
+ if (file.indexOf(input) === 0) {
32
+ return path.relative(input, file)
33
+ }
34
+ return false
35
+ }
36
+ }
37
+ ])
38
+ } catch (e) { }
39
+ }
40
+
41
+ process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
42
+ process.UNI_LIBRARIES.forEach(libraryName => {
43
+ plugins.push([
44
+ 'import',
45
+ {
46
+ 'libraryName': libraryName,
47
+ 'customName': (name) => {
48
+ return `${libraryName}/lib/${name}/${name}`
49
+ }
50
+ }
51
+ ])
52
+ })
53
+
54
+ if (process.env.UNI_PLATFORM !== 'h5') {
55
+ plugins.push('@babel/plugin-transform-runtime')
56
+ }
57
+
58
+ const config = {
59
+ presets: [
60
+ [
61
+ '@vue/app',
62
+ {
63
+ modules: webpack.version[0] > 4 ? 'auto' : 'commonjs',
64
+ useBuiltIns: process.env.UNI_PLATFORM === 'h5' ? 'usage' : 'entry'
65
+ }
66
+ ]
67
+ ],
68
+ plugins
69
+ }
70
+
71
+ const UNI_H5_TEST = '**/@dcloudio/uni-h5/dist/index.umd.min.js'
72
+ if (process.env.NODE_ENV === 'production') {
73
+ config.overrides = [{
74
+ test: UNI_H5_TEST,
75
+ compact: true,
76
+ }]
77
+ } else {
78
+ config.ignore = [UNI_H5_TEST]
79
+ }
80
+
81
+ module.exports = config
@@ -0,0 +1,107 @@
1
+ {
2
+ "name": "preset-uni-test",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "serve": "npm run dev:h5",
7
+ "build": "npm run build:h5",
8
+ "build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build",
9
+ "build:custom": "cross-env NODE_ENV=production uniapp-cli custom",
10
+ "build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build",
11
+ "build:mp-360": "cross-env NODE_ENV=production UNI_PLATFORM=mp-360 vue-cli-service uni-build",
12
+ "build:mp-alipay": "cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build",
13
+ "build:mp-baidu": "cross-env NODE_ENV=production UNI_PLATFORM=mp-baidu vue-cli-service uni-build",
14
+ "build:mp-harmony": "cross-env NODE_ENV=production UNI_PLATFORM=mp-harmony vue-cli-service uni-build",
15
+ "build:mp-jd": "cross-env NODE_ENV=production UNI_PLATFORM=mp-jd vue-cli-service uni-build",
16
+ "build:mp-kuaishou": "cross-env NODE_ENV=production UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build",
17
+ "build:mp-lark": "cross-env NODE_ENV=production UNI_PLATFORM=mp-lark vue-cli-service uni-build",
18
+ "build:mp-qq": "cross-env NODE_ENV=production UNI_PLATFORM=mp-qq vue-cli-service uni-build",
19
+ "build:mp-toutiao": "cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao vue-cli-service uni-build",
20
+ "build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build",
21
+ "build:mp-xhs": "cross-env NODE_ENV=production UNI_PLATFORM=mp-xhs vue-cli-service uni-build",
22
+ "build:quickapp-native": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-native vue-cli-service uni-build",
23
+ "build:quickapp-webview": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview vue-cli-service uni-build",
24
+ "build:quickapp-webview-huawei": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build",
25
+ "build:quickapp-webview-union": "cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build",
26
+ "dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch",
27
+ "dev:custom": "cross-env NODE_ENV=development uniapp-cli custom",
28
+ "dev:h5": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve",
29
+ "dev:mp-360": "cross-env NODE_ENV=development UNI_PLATFORM=mp-360 vue-cli-service uni-build --watch",
30
+ "dev:mp-alipay": "cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch",
31
+ "dev:mp-baidu": "cross-env NODE_ENV=development UNI_PLATFORM=mp-baidu vue-cli-service uni-build --watch",
32
+ "dev:mp-harmony": "cross-env NODE_ENV=development UNI_PLATFORM=mp-harmony vue-cli-service uni-build --watch",
33
+ "dev:mp-jd": "cross-env NODE_ENV=development UNI_PLATFORM=mp-jd vue-cli-service uni-build --watch",
34
+ "dev:mp-kuaishou": "cross-env NODE_ENV=development UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build --watch",
35
+ "dev:mp-lark": "cross-env NODE_ENV=development UNI_PLATFORM=mp-lark vue-cli-service uni-build --watch",
36
+ "dev:mp-qq": "cross-env NODE_ENV=development UNI_PLATFORM=mp-qq vue-cli-service uni-build --watch",
37
+ "dev:mp-toutiao": "cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao vue-cli-service uni-build --watch",
38
+ "dev:mp-weixin": "cross-env NODE_ENV=development UNI_PLATFORM=mp-weixin vue-cli-service uni-build --watch",
39
+ "dev:mp-xhs": "cross-env NODE_ENV=development UNI_PLATFORM=mp-xhs vue-cli-service uni-build --watch",
40
+ "dev:quickapp-native": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-native vue-cli-service uni-build --watch",
41
+ "dev:quickapp-webview": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview vue-cli-service uni-build --watch",
42
+ "dev:quickapp-webview-huawei": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch",
43
+ "dev:quickapp-webview-union": "cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-union vue-cli-service uni-build --watch",
44
+ "info": "node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js",
45
+ "serve:quickapp-native": "node node_modules/@dcloudio/uni-quickapp-native/bin/serve.js",
46
+ "test:android": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=android jest -i",
47
+ "test:h5": "cross-env UNI_PLATFORM=h5 jest -i",
48
+ "test:ios": "cross-env UNI_PLATFORM=app-plus UNI_OS_NAME=ios jest -i",
49
+ "test:mp-baidu": "cross-env UNI_PLATFORM=mp-baidu jest -i",
50
+ "test:mp-weixin": "cross-env UNI_PLATFORM=mp-weixin jest -i"
51
+ },
52
+ "dependencies": {
53
+ "@dcloudio/uni-app": "^2.0.2-4080720251210002",
54
+ "@dcloudio/uni-app-plus": "^2.0.2-4080720251210002",
55
+ "@dcloudio/uni-h5": "^2.0.2-4080720251210002",
56
+ "@dcloudio/uni-i18n": "^2.0.2-4080720251210002",
57
+ "@dcloudio/uni-mp-360": "^2.0.2-4080720251210002",
58
+ "@dcloudio/uni-mp-alipay": "^2.0.2-4080720251210002",
59
+ "@dcloudio/uni-mp-baidu": "^2.0.2-4080720251210002",
60
+ "@dcloudio/uni-mp-harmony": "^2.0.2-4080720251210002",
61
+ "@dcloudio/uni-mp-jd": "^2.0.2-4080720251210002",
62
+ "@dcloudio/uni-mp-kuaishou": "^2.0.2-4080720251210002",
63
+ "@dcloudio/uni-mp-lark": "^2.0.2-4080720251210002",
64
+ "@dcloudio/uni-mp-qq": "^2.0.2-4080720251210002",
65
+ "@dcloudio/uni-mp-toutiao": "^2.0.2-4080720251210002",
66
+ "@dcloudio/uni-mp-vue": "^2.0.2-4080720251210002",
67
+ "@dcloudio/uni-mp-weixin": "^2.0.2-4080720251210002",
68
+ "@dcloudio/uni-mp-xhs": "^2.0.2-4080720251210002",
69
+ "@dcloudio/uni-quickapp-native": "^2.0.2-4080720251210002",
70
+ "@dcloudio/uni-quickapp-webview": "^2.0.2-4080720251210002",
71
+ "@dcloudio/uni-stacktracey": "^2.0.2-4080720251210002",
72
+ "@dcloudio/uni-stat": "^2.0.2-4080720251210002",
73
+ "@vue/shared": "^3.0.0",
74
+ "core-js": "^3.8.3",
75
+ "flyio": "^0.6.2",
76
+ "vue": ">= 2.6.14 < 2.7",
77
+ "vuex": "^3.2.0"
78
+ },
79
+ "devDependencies": {
80
+ "@dcloudio/types": "^3.3.2",
81
+ "@dcloudio/uni-automator": "^2.0.2-4080720251210002",
82
+ "@dcloudio/uni-cli-i18n": "^2.0.2-4080720251210002",
83
+ "@dcloudio/uni-cli-shared": "^2.0.2-4080720251210002",
84
+ "@dcloudio/uni-helper-json": "*",
85
+ "@dcloudio/uni-migration": "^2.0.2-4080720251210002",
86
+ "@dcloudio/uni-template-compiler": "^2.0.2-4080720251210002",
87
+ "@dcloudio/vue-cli-plugin-hbuilderx": "^2.0.2-4080720251210002",
88
+ "@dcloudio/vue-cli-plugin-uni": "^2.0.2-4080720251210002",
89
+ "@dcloudio/vue-cli-plugin-uni-optimize": "^2.0.2-4080720251210002",
90
+ "@dcloudio/webpack-uni-mp-loader": "^2.0.2-4080720251210002",
91
+ "@dcloudio/webpack-uni-pages-loader": "^2.0.2-4080720251210002",
92
+ "@vue/cli-plugin-babel": "~5.0.0",
93
+ "@vue/cli-service": "~5.0.0",
94
+ "babel-plugin-import": "^1.11.0",
95
+ "cross-env": "^7.0.2",
96
+ "jest": "^25.4.0",
97
+ "postcss-comment": "^2.0.0",
98
+ "vue-template-compiler": ">= 2.6.14 < 2.7"
99
+ },
100
+ "browserslist": [
101
+ "Android >= 4.4",
102
+ "ios >= 9"
103
+ ],
104
+ "uni-app": {
105
+ "scripts": {}
106
+ }
107
+ }
@@ -0,0 +1,27 @@
1
+ const path = require('path')
2
+ const webpack = require('webpack')
3
+ const config = {
4
+ parser: require('postcss-comment'),
5
+ plugins: [
6
+ require('postcss-import')({
7
+ resolve (id, basedir, importOptions) {
8
+ if (id.startsWith('~@/')) {
9
+ return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
10
+ } else if (id.startsWith('@/')) {
11
+ return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
12
+ } else if (id.startsWith('/') && !id.startsWith('//')) {
13
+ return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
14
+ }
15
+ return id
16
+ }
17
+ }),
18
+ require('autoprefixer')({
19
+ remove: process.env.UNI_PLATFORM !== 'h5'
20
+ }),
21
+ require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
22
+ ]
23
+ }
24
+ if (webpack.version[0] > 4) {
25
+ delete config.parser
26
+ }
27
+ module.exports = config