mcp-probe-kit 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 (51) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +607 -0
  3. package/build/index.d.ts +2 -0
  4. package/build/index.js +553 -0
  5. package/build/tools/check_deps.d.ts +13 -0
  6. package/build/tools/check_deps.js +204 -0
  7. package/build/tools/code_review.d.ts +13 -0
  8. package/build/tools/code_review.js +138 -0
  9. package/build/tools/convert.d.ts +13 -0
  10. package/build/tools/convert.js +575 -0
  11. package/build/tools/debug.d.ts +13 -0
  12. package/build/tools/debug.js +78 -0
  13. package/build/tools/detect_shell.d.ts +6 -0
  14. package/build/tools/detect_shell.js +138 -0
  15. package/build/tools/explain.d.ts +13 -0
  16. package/build/tools/explain.js +369 -0
  17. package/build/tools/fix.d.ts +13 -0
  18. package/build/tools/fix.js +290 -0
  19. package/build/tools/genapi.d.ts +13 -0
  20. package/build/tools/genapi.js +152 -0
  21. package/build/tools/genchangelog.d.ts +13 -0
  22. package/build/tools/genchangelog.js +227 -0
  23. package/build/tools/gencommit.d.ts +13 -0
  24. package/build/tools/gencommit.js +95 -0
  25. package/build/tools/gendoc.d.ts +13 -0
  26. package/build/tools/gendoc.js +208 -0
  27. package/build/tools/genpr.d.ts +13 -0
  28. package/build/tools/genpr.js +173 -0
  29. package/build/tools/genreadme.d.ts +13 -0
  30. package/build/tools/genreadme.js +613 -0
  31. package/build/tools/gensql.d.ts +13 -0
  32. package/build/tools/gensql.js +307 -0
  33. package/build/tools/gentest.d.ts +13 -0
  34. package/build/tools/gentest.js +155 -0
  35. package/build/tools/genui.d.ts +13 -0
  36. package/build/tools/genui.js +781 -0
  37. package/build/tools/index.d.ts +22 -0
  38. package/build/tools/index.js +22 -0
  39. package/build/tools/init_project.d.ts +13 -0
  40. package/build/tools/init_project.js +142 -0
  41. package/build/tools/init_setting.d.ts +13 -0
  42. package/build/tools/init_setting.js +47 -0
  43. package/build/tools/perf.d.ts +13 -0
  44. package/build/tools/perf.js +359 -0
  45. package/build/tools/refactor.d.ts +13 -0
  46. package/build/tools/refactor.js +318 -0
  47. package/build/tools/resolve_conflict.d.ts +13 -0
  48. package/build/tools/resolve_conflict.js +338 -0
  49. package/build/tools/split.d.ts +13 -0
  50. package/build/tools/split.js +577 -0
  51. package/package.json +66 -0
@@ -0,0 +1,577 @@
1
+ // split 工具实现
2
+ export async function split(args) {
3
+ try {
4
+ const file = args?.file || "";
5
+ const strategy = args?.strategy || "auto"; // auto, type, function, component, feature
6
+ const message = `请拆分以下文件:
7
+
8
+ 📝 **文件内容**:
9
+ ${file || "请提供需要拆分的文件内容或路径"}
10
+
11
+ 🎯 **拆分策略**:${strategy}
12
+
13
+ ---
14
+
15
+ ## 文件拆分指南
16
+
17
+ ### 拆分策略
18
+
19
+ #### 1️⃣ 按类型拆分(type)
20
+ 适用于工具类、常量、类型定义混在一起的文件。
21
+
22
+ **示例场景**:
23
+ \`\`\`typescript
24
+ // ❌ utils.ts (500 行)
25
+ export const API_URL = 'https://api.example.com';
26
+ export const MAX_RETRY = 3;
27
+
28
+ export interface User {
29
+ id: string;
30
+ name: string;
31
+ }
32
+
33
+ export function formatDate(date: Date): string { }
34
+ export function validateEmail(email: string): boolean { }
35
+ \`\`\`
36
+
37
+ **拆分后**:
38
+ \`\`\`
39
+ src/
40
+ ├── constants/
41
+ │ └── api.ts # API_URL, MAX_RETRY
42
+ ├── types/
43
+ │ └── user.ts # User interface
44
+ └── utils/
45
+ ├── date.ts # formatDate
46
+ └── validation.ts # validateEmail
47
+ \`\`\`
48
+
49
+ ---
50
+
51
+ #### 2️⃣ 按功能拆分(function)
52
+ 适用于一个文件包含多个独立函数。
53
+
54
+ **示例场景**:
55
+ \`\`\`typescript
56
+ // ❌ helpers.ts (800 行)
57
+ export function userHelpers() { }
58
+ export function orderHelpers() { }
59
+ export function paymentHelpers() { }
60
+ \`\`\`
61
+
62
+ **拆分后**:
63
+ \`\`\`
64
+ src/helpers/
65
+ ├── user.ts # 用户相关
66
+ ├── order.ts # 订单相关
67
+ └── payment.ts # 支付相关
68
+ \`\`\`
69
+
70
+ ---
71
+
72
+ #### 3️⃣ 按组件拆分(component)
73
+ 适用于 React/Vue 组件过大,需要拆分为子组件。
74
+
75
+ **示例场景**:
76
+ \`\`\`tsx
77
+ // ❌ UserProfile.tsx (600 行)
78
+ export function UserProfile() {
79
+ return (
80
+ <div>
81
+ {/* Header 100 行 */}
82
+ {/* Sidebar 150 行 */}
83
+ {/* Content 200 行 */}
84
+ {/* Footer 150 行 */}
85
+ </div>
86
+ );
87
+ }
88
+ \`\`\`
89
+
90
+ **拆分后**:
91
+ \`\`\`
92
+ src/components/UserProfile/
93
+ ├── index.tsx # 主组件(组装)
94
+ ├── UserProfileHeader.tsx
95
+ ├── UserProfileSidebar.tsx
96
+ ├── UserProfileContent.tsx
97
+ ├── UserProfileFooter.tsx
98
+ └── styles.module.css
99
+ \`\`\`
100
+
101
+ ---
102
+
103
+ #### 4️⃣ 按功能模块拆分(feature)
104
+ 适用于功能模块混在一起的大文件。
105
+
106
+ **示例场景**:
107
+ \`\`\`typescript
108
+ // ❌ store.ts (1000 行)
109
+ // 用户模块 state, actions, reducers
110
+ // 订单模块 state, actions, reducers
111
+ // 购物车模块 state, actions, reducers
112
+ \`\`\`
113
+
114
+ **拆分后**:
115
+ \`\`\`
116
+ src/store/
117
+ ├── index.ts # 组装所有模块
118
+ ├── user/
119
+ │ ├── state.ts
120
+ │ ├── actions.ts
121
+ │ └── reducers.ts
122
+ ├── order/
123
+ │ ├── state.ts
124
+ │ ├── actions.ts
125
+ │ └── reducers.ts
126
+ └── cart/
127
+ ├── state.ts
128
+ ├── actions.ts
129
+ └── reducers.ts
130
+ \`\`\`
131
+
132
+ ---
133
+
134
+ #### 5️⃣ 自动分析拆分(auto)
135
+ AI 分析代码结构,自动选择最佳拆分策略。
136
+
137
+ ---
138
+
139
+ ## 拆分原则
140
+
141
+ ### ✅ 应该拆分的信号
142
+
143
+ 1. **文件行数过多**
144
+ - 超过 300 行:考虑拆分
145
+ - 超过 500 行:强烈建议拆分
146
+ - 超过 1000 行:必须拆分
147
+
148
+ 2. **职责过多**
149
+ - 处理多个不相关的业务逻辑
150
+ - 混合了类型定义、工具函数、组件
151
+
152
+ 3. **难以维护**
153
+ - 滚动半天找不到函数
154
+ - 修改一个功能影响其他功能
155
+ - Git 冲突频繁
156
+
157
+ 4. **复用性差**
158
+ - 只能整体导入,无法按需导入
159
+ - 想复用某个函数,必须导入整个文件
160
+
161
+ ### ⚠️ 不应该过度拆分
162
+
163
+ 1. **避免碎片化**
164
+ - 不要拆成几十个只有几行的文件
165
+ - 保持相关代码的内聚性
166
+
167
+ 2. **避免循环依赖**
168
+ - 拆分后注意依赖关系
169
+ - 使用依赖注入或中间层解耦
170
+
171
+ ---
172
+
173
+ ## 拆分实战示例
174
+
175
+ ### 示例 1:大型 React 组件拆分
176
+
177
+ **原始文件(UserDashboard.tsx - 800 行)**:
178
+ \`\`\`tsx
179
+ import React, { useState, useEffect } from 'react';
180
+ import './styles.css';
181
+
182
+ export function UserDashboard() {
183
+ const [user, setUser] = useState(null);
184
+ const [orders, setOrders] = useState([]);
185
+ const [stats, setStats] = useState({});
186
+
187
+ // 150 行:用户信息相关逻辑
188
+ useEffect(() => { /* 获取用户信息 */ }, []);
189
+ const updateUserProfile = () => { /* 更新用户 */ };
190
+
191
+ // 200 行:订单相关逻辑
192
+ useEffect(() => { /* 获取订单 */ }, []);
193
+ const filterOrders = () => { /* 过滤订单 */ };
194
+
195
+ // 150 行:统计相关逻辑
196
+ useEffect(() => { /* 获取统计 */ }, []);
197
+ const calculateStats = () => { /* 计算统计 */ };
198
+
199
+ // 300 行:渲染逻辑
200
+ return (
201
+ <div className="dashboard">
202
+ {/* Header */}
203
+ <div className="header">
204
+ {/* 50 行 */}
205
+ </div>
206
+
207
+ {/* Sidebar */}
208
+ <div className="sidebar">
209
+ {/* 100 行 */}
210
+ </div>
211
+
212
+ {/* Main Content */}
213
+ <div className="main">
214
+ {/* User Info Section - 80 行 */}
215
+ <div className="user-info">
216
+ <h2>{user?.name}</h2>
217
+ {/* ... */}
218
+ </div>
219
+
220
+ {/* Orders Section - 100 行 */}
221
+ <div className="orders">
222
+ <h3>我的订单</h3>
223
+ {/* ... */}
224
+ </div>
225
+
226
+ {/* Stats Section - 70 行 */}
227
+ <div className="stats">
228
+ <h3>统计数据</h3>
229
+ {/* ... */}
230
+ </div>
231
+ </div>
232
+ </div>
233
+ );
234
+ }
235
+ \`\`\`
236
+
237
+ **拆分方案**:
238
+
239
+ **1. 拆分自定义 Hooks**
240
+ \`\`\`typescript
241
+ // hooks/useUser.ts
242
+ export function useUser() {
243
+ const [user, setUser] = useState(null);
244
+
245
+ useEffect(() => {
246
+ // 获取用户信息
247
+ }, []);
248
+
249
+ const updateUserProfile = () => {
250
+ // 更新用户
251
+ };
252
+
253
+ return { user, updateUserProfile };
254
+ }
255
+
256
+ // hooks/useOrders.ts
257
+ export function useOrders() {
258
+ const [orders, setOrders] = useState([]);
259
+
260
+ useEffect(() => {
261
+ // 获取订单
262
+ }, []);
263
+
264
+ const filterOrders = () => {
265
+ // 过滤订单
266
+ };
267
+
268
+ return { orders, filterOrders };
269
+ }
270
+
271
+ // hooks/useStats.ts
272
+ export function useStats() {
273
+ const [stats, setStats] = useState({});
274
+
275
+ useEffect(() => {
276
+ // 获取统计
277
+ }, []);
278
+
279
+ const calculateStats = () => {
280
+ // 计算统计
281
+ };
282
+
283
+ return { stats, calculateStats };
284
+ }
285
+ \`\`\`
286
+
287
+ **2. 拆分子组件**
288
+ \`\`\`tsx
289
+ // components/DashboardHeader.tsx
290
+ export function DashboardHeader({ user }) {
291
+ return (
292
+ <div className="header">
293
+ {/* 50 行 */}
294
+ </div>
295
+ );
296
+ }
297
+
298
+ // components/DashboardSidebar.tsx
299
+ export function DashboardSidebar() {
300
+ return (
301
+ <div className="sidebar">
302
+ {/* 100 行 */}
303
+ </div>
304
+ );
305
+ }
306
+
307
+ // components/UserInfoSection.tsx
308
+ export function UserInfoSection({ user, onUpdate }) {
309
+ return (
310
+ <div className="user-info">
311
+ <h2>{user?.name}</h2>
312
+ {/* 80 行 */}
313
+ </div>
314
+ );
315
+ }
316
+
317
+ // components/OrdersSection.tsx
318
+ export function OrdersSection({ orders, onFilter }) {
319
+ return (
320
+ <div className="orders">
321
+ <h3>我的订单</h3>
322
+ {/* 100 行 */}
323
+ </div>
324
+ );
325
+ }
326
+
327
+ // components/StatsSection.tsx
328
+ export function StatsSection({ stats }) {
329
+ return (
330
+ <div className="stats">
331
+ <h3>统计数据</h3>
332
+ {/* 70 行 */}
333
+ </div>
334
+ );
335
+ }
336
+ \`\`\`
337
+
338
+ **3. 重构主组件(只有 50 行)**
339
+ \`\`\`tsx
340
+ // components/UserDashboard/index.tsx
341
+ import React from 'react';
342
+ import { useUser } from './hooks/useUser';
343
+ import { useOrders } from './hooks/useOrders';
344
+ import { useStats } from './hooks/useStats';
345
+ import { DashboardHeader } from './DashboardHeader';
346
+ import { DashboardSidebar } from './DashboardSidebar';
347
+ import { UserInfoSection } from './UserInfoSection';
348
+ import { OrdersSection } from './OrdersSection';
349
+ import { StatsSection } from './StatsSection';
350
+ import './styles.css';
351
+
352
+ export function UserDashboard() {
353
+ const { user, updateUserProfile } = useUser();
354
+ const { orders, filterOrders } = useOrders();
355
+ const { stats } = useStats();
356
+
357
+ return (
358
+ <div className="dashboard">
359
+ <DashboardHeader user={user} />
360
+ <DashboardSidebar />
361
+ <div className="main">
362
+ <UserInfoSection user={user} onUpdate={updateUserProfile} />
363
+ <OrdersSection orders={orders} onFilter={filterOrders} />
364
+ <StatsSection stats={stats} />
365
+ </div>
366
+ </div>
367
+ );
368
+ }
369
+ \`\`\`
370
+
371
+ **最终目录结构**:
372
+ \`\`\`
373
+ src/components/UserDashboard/
374
+ ├── index.tsx # 主组件 (50 行)
375
+ ├── DashboardHeader.tsx # 子组件 (50 行)
376
+ ├── DashboardSidebar.tsx # 子组件 (100 行)
377
+ ├── UserInfoSection.tsx # 子组件 (80 行)
378
+ ├── OrdersSection.tsx # 子组件 (100 行)
379
+ ├── StatsSection.tsx # 子组件 (70 行)
380
+ ├── hooks/
381
+ │ ├── useUser.ts # Hook (60 行)
382
+ │ ├── useOrders.ts # Hook (80 行)
383
+ │ └── useStats.ts # Hook (60 行)
384
+ └── styles.css
385
+ \`\`\`
386
+
387
+ **优势**:
388
+ - ✅ 每个文件职责单一,易于理解
389
+ - ✅ 组件可独立测试
390
+ - ✅ 逻辑可复用(Hooks)
391
+ - ✅ 多人协作减少冲突
392
+ - ✅ 按需导入,优化打包体积
393
+
394
+ ---
395
+
396
+ ### 示例 2:工具函数文件拆分
397
+
398
+ **原始文件(utils.ts - 600 行)**:
399
+ \`\`\`typescript
400
+ // 字符串工具 (150 行)
401
+ export function capitalize(str: string): string { }
402
+ export function truncate(str: string, length: number): string { }
403
+ export function slugify(str: string): string { }
404
+
405
+ // 日期工具 (150 行)
406
+ export function formatDate(date: Date): string { }
407
+ export function parseDate(str: string): Date { }
408
+ export function addDays(date: Date, days: number): Date { }
409
+
410
+ // 数组工具 (100 行)
411
+ export function unique<T>(arr: T[]): T[] { }
412
+ export function groupBy<T>(arr: T[], key: keyof T): Record<string, T[]> { }
413
+
414
+ // 验证工具 (100 行)
415
+ export function isEmail(str: string): boolean { }
416
+ export function isURL(str: string): boolean { }
417
+
418
+ // 数学工具 (100 行)
419
+ export function round(num: number, decimals: number): number { }
420
+ export function clamp(num: number, min: number, max: number): number { }
421
+ \`\`\`
422
+
423
+ **拆分后**:
424
+ \`\`\`
425
+ src/utils/
426
+ ├── index.ts # 统一导出
427
+ ├── string.ts # 字符串工具
428
+ ├── date.ts # 日期工具
429
+ ├── array.ts # 数组工具
430
+ ├── validation.ts # 验证工具
431
+ └── math.ts # 数学工具
432
+ \`\`\`
433
+
434
+ \`\`\`typescript
435
+ // utils/index.ts (统一导出)
436
+ export * from './string';
437
+ export * from './date';
438
+ export * from './array';
439
+ export * from './validation';
440
+ export * from './math';
441
+
442
+ // 使用方式不变
443
+ import { capitalize, formatDate, unique } from '@/utils';
444
+ \`\`\`
445
+
446
+ ---
447
+
448
+ ### 示例 3:Vue 组件拆分
449
+
450
+ **原始文件(ProductList.vue - 700 行)**:
451
+ \`\`\`vue
452
+ <template>
453
+ <div class="product-list">
454
+ <!-- Filter Section - 150 行 -->
455
+ <div class="filters">
456
+ <!-- 过滤器 UI -->
457
+ </div>
458
+
459
+ <!-- Product Grid - 300 行 -->
460
+ <div class="products">
461
+ <!-- 产品列表 -->
462
+ </div>
463
+
464
+ <!-- Pagination - 100 行 -->
465
+ <div class="pagination">
466
+ <!-- 分页 -->
467
+ </div>
468
+ </div>
469
+ </template>
470
+
471
+ <script setup lang="ts">
472
+ // 250 行逻辑
473
+ const products = ref([]);
474
+ const filters = ref({});
475
+ // ...
476
+ </script>
477
+
478
+ <style scoped>
479
+ /* 100 行样式 */
480
+ </style>
481
+ \`\`\`
482
+
483
+ **拆分后**:
484
+ \`\`\`
485
+ src/components/ProductList/
486
+ ├── ProductList.vue # 主组件 (100 行)
487
+ ├── ProductFilters.vue # 过滤器组件 (150 行)
488
+ ├── ProductGrid.vue # 产品网格 (200 行)
489
+ ├── ProductCard.vue # 产品卡片 (100 行)
490
+ ├── ProductPagination.vue # 分页组件 (100 行)
491
+ ├── composables/
492
+ │ ├── useProducts.ts # 产品数据逻辑
493
+ │ └── useFilters.ts # 过滤逻辑
494
+ └── styles.module.css
495
+ \`\`\`
496
+
497
+ ---
498
+
499
+ ## 拆分步骤
500
+
501
+ ### Step 1: 分析依赖关系
502
+ \`\`\`bash
503
+ # 使用工具分析依赖
504
+ npx madge --circular src/
505
+
506
+ # 或手动绘制依赖图
507
+ \`\`\`
508
+
509
+ ### Step 2: 识别独立模块
510
+ - 找出职责单一的代码块
511
+ - 识别可复用的逻辑
512
+ - 标记高内聚低耦合的部分
513
+
514
+ ### Step 3: 制定拆分计划
515
+ - 确定目录结构
516
+ - 规划文件命名
517
+ - 设计导出策略
518
+
519
+ ### Step 4: 逐步拆分
520
+ - 从最独立的模块开始
521
+ - 先拆分,后重构
522
+ - 每次拆分后运行测试
523
+
524
+ ### Step 5: 更新导入
525
+ - 批量替换 import 路径
526
+ - 使用 IDE 的重构功能
527
+ - 验证所有引用
528
+
529
+ ### Step 6: 清理优化
530
+ - 删除未使用的导出
531
+ - 优化重复代码
532
+ - 添加文档注释
533
+
534
+ ---
535
+
536
+ ## 拆分工具推荐
537
+
538
+ ### VS Code 扩展
539
+ - **Move TS** - 自动更新 import
540
+ - **JavaScript Refactor** - 快速提取函数/组件
541
+ - **Path Intellisense** - 路径自动补全
542
+
543
+ ### CLI 工具
544
+ - **madge** - 依赖分析
545
+ - **jscodeshift** - 代码自动化重构
546
+ - **ts-morph** - TypeScript AST 操作
547
+
548
+ ---
549
+
550
+ 现在请分析文件并提供详细的拆分方案,包括:
551
+ 1. 拆分策略分析
552
+ 2. 建议的目录结构
553
+ 3. 每个新文件的内容
554
+ 4. 导入导出关系
555
+ 5. 迁移步骤`;
556
+ return {
557
+ content: [
558
+ {
559
+ type: "text",
560
+ text: message,
561
+ },
562
+ ],
563
+ };
564
+ }
565
+ catch (error) {
566
+ const errorMessage = error instanceof Error ? error.message : String(error);
567
+ return {
568
+ content: [
569
+ {
570
+ type: "text",
571
+ text: `❌ 文件拆分失败: ${errorMessage}`,
572
+ },
573
+ ],
574
+ isError: true,
575
+ };
576
+ }
577
+ }
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "mcp-probe-kit",
3
+ "version": "1.0.0",
4
+ "description": "Cursor Development Enhancement Toolkit - MCP Server with 22 practical tools for code quality, development efficiency, and project management",
5
+ "type": "module",
6
+ "main": "build/index.js",
7
+ "bin": {
8
+ "mcp-probe-kit": "build/index.js"
9
+ },
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "watch": "tsc --watch",
13
+ "dev": "tsc && node build/index.js",
14
+ "test": "npm run build && node test-server.js",
15
+ "inspector": "npx @modelcontextprotocol/inspector node build/index.js",
16
+ "prepare": "npm run build",
17
+ "prepublishOnly": "npm run build"
18
+ },
19
+ "keywords": [
20
+ "mcp",
21
+ "model-context-protocol",
22
+ "cursor",
23
+ "ai-tools",
24
+ "development-tools",
25
+ "code-quality",
26
+ "code-review",
27
+ "refactor",
28
+ "debugging",
29
+ "sql-generator",
30
+ "ui-generator",
31
+ "react",
32
+ "vue",
33
+ "typescript",
34
+ "git-tools",
35
+ "ai-assistant"
36
+ ],
37
+ "author": {
38
+ "name": "小墨 (Kyle)",
39
+ "url": "https://www.bytezonex.com/"
40
+ },
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/mybolide/mcp-probe-kit.git"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/mybolide/mcp-probe-kit/issues"
48
+ },
49
+ "homepage": "https://github.com/mybolide/mcp-probe-kit#readme",
50
+ "engines": {
51
+ "node": ">=16.0.0"
52
+ },
53
+ "files": [
54
+ "build",
55
+ "README.md",
56
+ "LICENSE"
57
+ ],
58
+ "dependencies": {
59
+ "@modelcontextprotocol/sdk": "^0.5.0"
60
+ },
61
+ "devDependencies": {
62
+ "@types/node": "^20.0.0",
63
+ "typescript": "^5.3.0"
64
+ }
65
+ }
66
+