mcp-probe-kit 3.2.0 → 3.3.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 (104) hide show
  1. package/README.md +10 -0
  2. package/build/lib/__tests__/memory-orchestration.unit.test.js +88 -0
  3. package/build/lib/__tests__/memory-payload.unit.test.js +35 -0
  4. package/build/lib/__tests__/quality-constraints.unit.test.d.ts +1 -0
  5. package/build/lib/__tests__/quality-constraints.unit.test.js +54 -0
  6. package/build/lib/__tests__/spec-validator.unit.test.js +106 -74
  7. package/build/lib/agents-md-template.js +32 -32
  8. package/build/lib/cursor-history-client.d.ts +54 -0
  9. package/build/lib/cursor-history-client.js +240 -0
  10. package/build/lib/quality-constraints.d.ts +54 -0
  11. package/build/lib/quality-constraints.js +155 -0
  12. package/build/lib/skill-bridge.js +12 -12
  13. package/build/lib/spec-validator.js +16 -3
  14. package/build/lib/template-loader.js +83 -23
  15. package/build/resources/ui-ux-data/guidelines/vercel-web-interface.json +1632 -1632
  16. package/build/resources/ui-ux-data/metadata.json +30 -30
  17. package/build/resources/ui-ux-data/shadcn/blocks.json +2541 -2541
  18. package/build/resources/ui-ux-data/shadcn/components.json +997 -997
  19. package/build/resources/ui-ux-data/themes/presets.json +483 -483
  20. package/build/tools/__tests__/cursor-history.unit.test.d.ts +1 -0
  21. package/build/tools/__tests__/cursor-history.unit.test.js +38 -0
  22. package/build/tools/check_spec.js +16 -16
  23. package/build/tools/code_insight.js +41 -41
  24. package/build/tools/code_review.js +11 -4
  25. package/build/tools/cursor_read_conversation.d.ts +7 -0
  26. package/build/tools/cursor_read_conversation.js +36 -0
  27. package/build/tools/fix_bug.js +161 -161
  28. package/build/tools/gencommit.js +60 -60
  29. package/build/tools/init_project_context.js +432 -432
  30. package/build/tools/start_product.js +1 -1
  31. package/build/tools/start_ui.js +17 -0
  32. package/build/tools/ui-ux-tools.d.ts +3 -0
  33. package/build/tools/ui-ux-tools.js +302 -290
  34. package/build/utils/__tests__/vercel-guidelines-sync.unit.test.js +12 -12
  35. package/build/utils/design-reasoning-engine.d.ts +2 -0
  36. package/build/utils/design-reasoning-engine.js +3 -0
  37. package/build/utils/themes-sync.js +8 -8
  38. package/package.json +3 -2
  39. package/build/resources/index.d.ts +0 -4
  40. package/build/resources/index.js +0 -4
  41. package/build/resources/tool-params-guide.d.ts +0 -571
  42. package/build/resources/tool-params-guide.js +0 -488
  43. package/build/tools/analyze_project.d.ts +0 -1
  44. package/build/tools/analyze_project.js +0 -527
  45. package/build/tools/check_deps.d.ts +0 -13
  46. package/build/tools/check_deps.js +0 -204
  47. package/build/tools/convert.d.ts +0 -13
  48. package/build/tools/convert.js +0 -599
  49. package/build/tools/css_order.d.ts +0 -13
  50. package/build/tools/css_order.js +0 -81
  51. package/build/tools/debug.d.ts +0 -13
  52. package/build/tools/debug.js +0 -131
  53. package/build/tools/design2code.d.ts +0 -20
  54. package/build/tools/design2code.js +0 -426
  55. package/build/tools/detect_shell.d.ts +0 -6
  56. package/build/tools/detect_shell.js +0 -151
  57. package/build/tools/explain.d.ts +0 -13
  58. package/build/tools/explain.js +0 -390
  59. package/build/tools/fix.d.ts +0 -13
  60. package/build/tools/fix.js +0 -303
  61. package/build/tools/gen_mock.d.ts +0 -22
  62. package/build/tools/gen_mock.js +0 -269
  63. package/build/tools/gen_skill.d.ts +0 -13
  64. package/build/tools/gen_skill.js +0 -560
  65. package/build/tools/genapi.d.ts +0 -13
  66. package/build/tools/genapi.js +0 -174
  67. package/build/tools/genchangelog.d.ts +0 -13
  68. package/build/tools/genchangelog.js +0 -250
  69. package/build/tools/gendoc.d.ts +0 -13
  70. package/build/tools/gendoc.js +0 -232
  71. package/build/tools/genpr.d.ts +0 -13
  72. package/build/tools/genpr.js +0 -194
  73. package/build/tools/genreadme.d.ts +0 -13
  74. package/build/tools/genreadme.js +0 -626
  75. package/build/tools/gensql.d.ts +0 -13
  76. package/build/tools/gensql.js +0 -320
  77. package/build/tools/genui.d.ts +0 -13
  78. package/build/tools/genui.js +0 -803
  79. package/build/tools/init_component_catalog.d.ts +0 -22
  80. package/build/tools/init_component_catalog.js +0 -809
  81. package/build/tools/init_setting.d.ts +0 -13
  82. package/build/tools/init_setting.js +0 -47
  83. package/build/tools/perf.d.ts +0 -13
  84. package/build/tools/perf.js +0 -409
  85. package/build/tools/render_ui.d.ts +0 -22
  86. package/build/tools/render_ui.js +0 -384
  87. package/build/tools/resolve_conflict.d.ts +0 -13
  88. package/build/tools/resolve_conflict.js +0 -349
  89. package/build/tools/security_scan.d.ts +0 -22
  90. package/build/tools/security_scan.js +0 -323
  91. package/build/tools/split.d.ts +0 -13
  92. package/build/tools/split.js +0 -599
  93. package/build/tools/start_api.d.ts +0 -13
  94. package/build/tools/start_api.js +0 -193
  95. package/build/tools/start_doc.d.ts +0 -13
  96. package/build/tools/start_doc.js +0 -207
  97. package/build/tools/start_refactor.d.ts +0 -13
  98. package/build/tools/start_refactor.js +0 -188
  99. package/build/tools/start_release.d.ts +0 -13
  100. package/build/tools/start_release.js +0 -167
  101. package/build/tools/start_review.d.ts +0 -13
  102. package/build/tools/start_review.js +0 -175
  103. /package/build/{utils/design-docs-generator.d.ts → lib/__tests__/memory-orchestration.unit.test.d.ts} +0 -0
  104. /package/build/{utils/design-docs-generator.js → lib/__tests__/memory-payload.unit.test.d.ts} +0 -0
@@ -1,13 +0,0 @@
1
- export declare function initSetting(args: any): Promise<{
2
- content: {
3
- type: string;
4
- text: string;
5
- }[];
6
- isError?: undefined;
7
- } | {
8
- content: {
9
- type: string;
10
- text: string;
11
- }[];
12
- isError: boolean;
13
- }>;
@@ -1,47 +0,0 @@
1
- // init_setting 工具实现
2
- export async function initSetting(args) {
3
- try {
4
- // 要写入的配置
5
- const settings = {
6
- // 统一使用 Claude-4.5-Sonnet(Chat / Composer / Edit 三处都钉死,便于复现)
7
- "ai.chatModel": "claude-sonnet-4-5",
8
- "ai.composerModel": "claude-sonnet-4-5",
9
- "ai.editModel": "claude-sonnet-4-5",
10
- // 采样温度:0 更"严格/确定",适合生成结构化/按规范的代码与 JSON
11
- "ai.temperature": 0,
12
- // 单次生成的最大 token(上限按平台限制,4096 对大多数修改/重构足够)
13
- // "ai.maxTokens": 4096, // 保守:4096 平衡:8192 激进:16384
14
- // ======================= 代码库上下文(让模型更懂你的项目) =======================
15
- // 语义检索:用向量搜索理解项目,而不是仅靠邻近几行
16
- "ai.contextEngine": "semantic",
17
- // 检索深度:high 提高命中率(更"聪明"地找引用/类型/API 使用示例)
18
- "ai.contextDepth": "high",
19
- // 是否将代码库上下文喂给模型:日常开发建议开启
20
- "ai.includeCodebaseContext": true, // 做模型指纹/一致性实验时 设置成:false
21
- // 语义与邻近的折中策略:balanced(常用且稳)
22
- "ai.contextStrategy": "balanced", // 做模型指纹/一致性实验时 设置成:neighboring
23
- };
24
- const message = `你要在项目的根目录下 .cursor/settings.json 文件内容追加以下内容,不要替换原有内容:
25
- ${JSON.stringify(settings, null, 2)}`;
26
- return {
27
- content: [
28
- {
29
- type: "text",
30
- text: message,
31
- },
32
- ],
33
- };
34
- }
35
- catch (error) {
36
- const errorMessage = error instanceof Error ? error.message : String(error);
37
- return {
38
- content: [
39
- {
40
- type: "text",
41
- text: `❌ 初始化配置失败: ${errorMessage}\n\n可能原因:\n- 没有文件写入权限\n- 不在 Cursor 工作区中\n- 路径错误`,
42
- },
43
- ],
44
- isError: true,
45
- };
46
- }
47
- }
@@ -1,13 +0,0 @@
1
- export declare function perf(args: any): Promise<{
2
- content: {
3
- type: string;
4
- text: string;
5
- }[];
6
- isError?: undefined;
7
- } | {
8
- content: {
9
- type: string;
10
- text: string;
11
- }[];
12
- isError: boolean;
13
- }>;
@@ -1,409 +0,0 @@
1
- import { parseArgs, getString } from "../utils/parseArgs.js";
2
- // perf 工具实现
3
- export async function perf(args) {
4
- try {
5
- // 智能参数解析,支持自然语言输入
6
- const parsedArgs = parseArgs(args, {
7
- defaultValues: {
8
- code: "",
9
- type: "all",
10
- },
11
- primaryField: "code", // 纯文本输入默认映射到 code 字段
12
- fieldAliases: {
13
- code: ["source", "src", "代码", "function"],
14
- type: ["analysis_type", "category", "类型", "分析类型"],
15
- },
16
- });
17
- const code = getString(parsedArgs.code);
18
- const type = getString(parsedArgs.type) || "all"; // algorithm, memory, react, database
19
- const message = `请分析以下代码的性能问题并提供优化建议:
20
-
21
- 📝 **代码内容**:
22
- ${code || "请提供需要性能分析的代码"}
23
-
24
- 🎯 **分析重点**:${type}
25
-
26
- ---
27
-
28
- ## 性能分析流程
29
-
30
- ### 第一步:识别性能瓶颈
31
-
32
- **常见性能问题**:
33
- 1. **时间复杂度过高**
34
- - 嵌套循环 O(n²) 或更差
35
- - 未优化的算法
36
- - 重复计算
37
-
38
- 2. **空间复杂度问题**
39
- - 内存泄漏
40
- - 大对象频繁创建
41
- - 缓存滥用
42
-
43
- 3. **I/O 阻塞**
44
- - 同步 I/O 操作
45
- - 未使用连接池
46
- - 缺少缓存机制
47
-
48
- 4. **渲染性能**
49
- - 不必要的重渲染
50
- - 大列表未虚拟化
51
- - 图片未优化
52
-
53
- ---
54
-
55
- ## 性能优化指南
56
-
57
- ### 1️⃣ 算法优化
58
-
59
- **复杂度分析**:
60
- \`\`\`
61
- O(1) - 常数时间 ✅ 最优
62
- O(log n) - 对数时间 ✅ 很好
63
- O(n) - 线性时间 ✅ 良好
64
- O(n log n) - 线性对数 ⚠️ 可接受
65
- O(n²) - 平方时间 ⚠️ 注意
66
- O(2ⁿ) - 指数时间 ❌ 避免
67
- O(n!) - 阶乘时间 ❌ 严禁
68
- \`\`\`
69
-
70
- **优化技巧**:
71
-
72
- **示例 1:使用 Map 替代数组查找**
73
- \`\`\`typescript
74
- // Before - O(n²)
75
- function findDuplicates(arr) {
76
- const duplicates = [];
77
- for (let i = 0; i < arr.length; i++) {
78
- for (let j = i + 1; j < arr.length; j++) {
79
- if (arr[i] === arr[j]) {
80
- duplicates.push(arr[i]);
81
- }
82
- }
83
- }
84
- return duplicates;
85
- }
86
-
87
- // After - O(n)
88
- function findDuplicates(arr) {
89
- const seen = new Map();
90
- const duplicates = new Set();
91
-
92
- for (const item of arr) {
93
- if (seen.has(item)) {
94
- duplicates.add(item);
95
- } else {
96
- seen.set(item, true);
97
- }
98
- }
99
-
100
- return Array.from(duplicates);
101
- }
102
- \`\`\`
103
-
104
- **示例 2:缓存计算结果**
105
- \`\`\`typescript
106
- // Before - 重复计算
107
- function fibonacci(n) {
108
- if (n <= 1) return n;
109
- return fibonacci(n - 1) + fibonacci(n - 2);
110
- }
111
-
112
- // After - 使用 memoization
113
- const memo = new Map();
114
- function fibonacci(n) {
115
- if (n <= 1) return n;
116
- if (memo.has(n)) return memo.get(n);
117
-
118
- const result = fibonacci(n - 1) + fibonacci(n - 2);
119
- memo.set(n, result);
120
- return result;
121
- }
122
- \`\`\`
123
-
124
- ### 2️⃣ 内存优化
125
-
126
- **避免内存泄漏**:
127
- \`\`\`typescript
128
- // ❌ 内存泄漏
129
- class EventManager {
130
- listeners = [];
131
-
132
- addEventListener(listener) {
133
- this.listeners.push(listener);
134
- // 忘记移除监听器
135
- }
136
- }
137
-
138
- // ✅ 正确做法
139
- class EventManager {
140
- listeners = new Set();
141
-
142
- addEventListener(listener) {
143
- this.listeners.add(listener);
144
- }
145
-
146
- removeEventListener(listener) {
147
- this.listeners.delete(listener);
148
- }
149
-
150
- destroy() {
151
- this.listeners.clear();
152
- }
153
- }
154
- \`\`\`
155
-
156
- **对象池复用**:
157
- \`\`\`typescript
158
- // ❌ 频繁创建对象
159
- for (let i = 0; i < 10000; i++) {
160
- const obj = { x: i, y: i * 2 };
161
- process(obj);
162
- }
163
-
164
- // ✅ 对象池
165
- class ObjectPool {
166
- pool = [];
167
-
168
- acquire() {
169
- return this.pool.pop() || {};
170
- }
171
-
172
- release(obj) {
173
- this.pool.push(obj);
174
- }
175
- }
176
-
177
- const pool = new ObjectPool();
178
- for (let i = 0; i < 10000; i++) {
179
- const obj = pool.acquire();
180
- obj.x = i;
181
- obj.y = i * 2;
182
- process(obj);
183
- pool.release(obj);
184
- }
185
- \`\`\`
186
-
187
- ### 3️⃣ React 性能优化
188
-
189
- **useMemo 和 useCallback**:
190
- \`\`\`typescript
191
- // ❌ 每次渲染都创建新函数
192
- function MyComponent({ data }) {
193
- const processedData = expensiveComputation(data);
194
- const handleClick = () => { /* ... */ };
195
-
196
- return <ChildComponent data={processedData} onClick={handleClick} />;
197
- }
198
-
199
- // ✅ 使用 hooks 优化
200
- function MyComponent({ data }) {
201
- const processedData = useMemo(
202
- () => expensiveComputation(data),
203
- [data]
204
- );
205
-
206
- const handleClick = useCallback(() => {
207
- /* ... */
208
- }, []);
209
-
210
- return <ChildComponent data={processedData} onClick={handleClick} />;
211
- }
212
- \`\`\`
213
-
214
- **React.memo 避免重渲染**:
215
- \`\`\`typescript
216
- // ✅ 使用 memo
217
- const ChildComponent = React.memo(({ data, onClick }) => {
218
- return <div onClick={onClick}>{data}</div>;
219
- });
220
- \`\`\`
221
-
222
- **虚拟列表**:
223
- \`\`\`typescript
224
- // ❌ 渲染 10000 个元素
225
- function List({ items }) {
226
- return (
227
- <div>
228
- {items.map(item => <Item key={item.id} data={item} />)}
229
- </div>
230
- );
231
- }
232
-
233
- // ✅ 使用虚拟列表
234
- import { FixedSizeList } from 'react-window';
235
-
236
- function List({ items }) {
237
- return (
238
- <FixedSizeList
239
- height={600}
240
- itemCount={items.length}
241
- itemSize={50}
242
- >
243
- {({ index, style }) => (
244
- <div style={style}>
245
- <Item data={items[index]} />
246
- </div>
247
- )}
248
- </FixedSizeList>
249
- );
250
- }
251
- \`\`\`
252
-
253
- ### 4️⃣ 数据库优化
254
-
255
- **添加索引**:
256
- \`\`\`sql
257
- -- Before
258
- SELECT * FROM users WHERE email = 'user@example.com';
259
-
260
- -- After
261
- CREATE INDEX idx_users_email ON users(email);
262
- SELECT * FROM users WHERE email = 'user@example.com';
263
- \`\`\`
264
-
265
- **查询优化**:
266
- \`\`\`typescript
267
- // ❌ N+1 查询
268
- const users = await User.findAll();
269
- for (const user of users) {
270
- user.posts = await Post.findAll({ where: { userId: user.id } });
271
- }
272
-
273
- // ✅ 使用 JOIN
274
- const users = await User.findAll({
275
- include: [{ model: Post }]
276
- });
277
- \`\`\`
278
-
279
- **批量操作**:
280
- \`\`\`typescript
281
- // ❌ 逐条插入
282
- for (const item of items) {
283
- await db.insert(item);
284
- }
285
-
286
- // ✅ 批量插入
287
- await db.insertMany(items);
288
- \`\`\`
289
-
290
- ---
291
-
292
- ## 性能测试
293
-
294
- ### Benchmark 测试
295
- \`\`\`typescript
296
- console.time('operation');
297
- // 执行操作
298
- console.timeEnd('operation');
299
-
300
- // 或使用 performance API
301
- const start = performance.now();
302
- // 执行操作
303
- const end = performance.now();
304
- console.log(\`耗时: \${end - start}ms\`);
305
- \`\`\`
306
-
307
- ### 性能指标
308
-
309
- **目标值**:
310
- - 首屏加载:< 1s
311
- - 交互响应:< 100ms
312
- - 动画帧率:60 FPS
313
- - API 响应:< 200ms
314
-
315
- ---
316
-
317
- ## 性能优化报告模板
318
-
319
- ### 📊 性能分析
320
-
321
- **当前性能**:
322
- - 时间复杂度:O(n²)
323
- - 内存占用:150MB
324
- - 响应时间:800ms
325
-
326
- **瓶颈识别**:
327
- 1. 嵌套循环导致复杂度过高
328
- 2. 未缓存计算结果
329
- 3. 数组查找效率低
330
-
331
- ### 🎯 优化方案
332
-
333
- **方案 1:算法优化**
334
- - 使用 Map 替代数组
335
- - 预期提升:70%
336
-
337
- **方案 2:添加缓存**
338
- - 使用 memoization
339
- - 预期提升:50%
340
-
341
- ### 📈 优化效果
342
-
343
- **优化后性能**:
344
- - 时间复杂度:O(n)
345
- - 内存占用:50MB ↓ 67%
346
- - 响应时间:200ms ↓ 75%
347
-
348
- ---
349
-
350
- ---
351
-
352
- ## 📤 输出格式要求
353
-
354
- 请严格按以下 JSON 格式输出分析结果:
355
-
356
- \`\`\`json
357
- {
358
- "summary": "性能评估总结(一句话)",
359
- "overall_score": 70,
360
- "bottlenecks": [
361
- {
362
- "type": "algorithm|memory|io|render|database",
363
- "severity": "critical|high|medium|low",
364
- "location": { "file": "文件路径", "line": 25 },
365
- "current_complexity": "O(n²)",
366
- "evidence": "问题证据描述",
367
- "fix": "优化建议",
368
- "expected_improvement": "70%",
369
- "fix_example": "优化后代码示例"
370
- }
371
- ],
372
- "metrics": {
373
- "time_complexity": "O(n²)",
374
- "space_complexity": "O(n)",
375
- "potential_improvement": "60-80%"
376
- }
377
- }
378
- \`\`\`
379
-
380
- ## ⚠️ 边界约束
381
-
382
- - ❌ 仅分析,不自动修改代码
383
- - ❌ 不执行性能测试(仅静态分析)
384
- - ❌ 不做精确的性能数值预测
385
- - ✅ 输出结构化瓶颈清单和优化建议
386
-
387
- 现在请分析代码,提供详细的性能优化建议。`;
388
- return {
389
- content: [
390
- {
391
- type: "text",
392
- text: message,
393
- },
394
- ],
395
- };
396
- }
397
- catch (error) {
398
- const errorMessage = error instanceof Error ? error.message : String(error);
399
- return {
400
- content: [
401
- {
402
- type: "text",
403
- text: `❌ 性能分析失败: ${errorMessage}`,
404
- },
405
- ],
406
- isError: true,
407
- };
408
- }
409
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * UI 渲染工具
3
- *
4
- * 将 JSON 模板渲染为最终代码
5
- * 自动应用设计规范,确保样式统一
6
- */
7
- /**
8
- * UI 渲染工具
9
- */
10
- export declare function renderUi(args: any): Promise<{
11
- content: {
12
- type: string;
13
- text: string;
14
- }[];
15
- isError: boolean;
16
- } | {
17
- content: {
18
- type: string;
19
- text: string;
20
- }[];
21
- isError?: undefined;
22
- }>;