mcp-probe-kit 2.3.0 → 2.5.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.
- package/README.md +131 -48
- package/build/index.js +1 -7
- package/build/lib/guidance.d.ts +8 -0
- package/build/lib/guidance.js +30 -0
- package/build/lib/orchestration-guidance.d.ts +8 -0
- package/build/lib/orchestration-guidance.js +16 -0
- package/build/lib/template-loader.d.ts +25 -0
- package/build/lib/template-loader.js +473 -0
- package/build/lib/toolset-manager.d.ts +4 -4
- package/build/lib/toolset-manager.js +10 -13
- package/build/schemas/code-analysis-tools.d.ts +0 -18
- package/build/schemas/code-analysis-tools.js +0 -19
- package/build/schemas/doc-util-tools.d.ts +0 -9
- package/build/schemas/doc-util-tools.js +0 -10
- package/build/schemas/index.d.ts +46 -47
- package/build/schemas/orchestration-tools.d.ts +42 -2
- package/build/schemas/orchestration-tools.js +42 -2
- package/build/schemas/output/core-tools.d.ts +1 -117
- package/build/schemas/output/core-tools.js +1 -60
- package/build/schemas/output/index.d.ts +5 -4
- package/build/schemas/output/index.js +6 -4
- package/build/schemas/output/product-design-tools.d.ts +160 -0
- package/build/schemas/output/product-design-tools.js +75 -0
- package/build/schemas/output/project-tools.d.ts +1 -217
- package/build/schemas/output/project-tools.js +1 -103
- package/build/schemas/project-tools.d.ts +4 -18
- package/build/schemas/project-tools.js +4 -19
- package/build/schemas/structured-output.d.ts +309 -99
- package/build/schemas/structured-output.js +174 -72
- package/build/schemas/ui-ux-schemas.d.ts +26 -0
- package/build/schemas/ui-ux-schemas.js +26 -0
- package/build/tools/__tests__/add_feature.template.test.d.ts +4 -0
- package/build/tools/__tests__/add_feature.template.test.js +47 -0
- package/build/tools/__tests__/start_bugfix.unit.test.d.ts +4 -0
- package/build/tools/__tests__/start_bugfix.unit.test.js +85 -0
- package/build/tools/__tests__/start_feature.unit.test.d.ts +4 -0
- package/build/tools/__tests__/start_feature.unit.test.js +83 -0
- package/build/tools/__tests__/start_ui.integration.test.js +4 -3
- package/build/tools/__tests__/start_ui.loop.test.d.ts +4 -0
- package/build/tools/__tests__/start_ui.loop.test.js +24 -0
- package/build/tools/__tests__/start_ui.unit.test.js +39 -1
- package/build/tools/add_feature.js +184 -406
- package/build/tools/ask_user.js +18 -5
- package/build/tools/code_review.js +8 -1
- package/build/tools/estimate.js +9 -2
- package/build/tools/fix_bug.js +9 -2
- package/build/tools/gen_mock.js +8 -1
- package/build/tools/gen_prd.d.ts +1 -7
- package/build/tools/gen_prd.js +41 -27
- package/build/tools/gen_prototype.d.ts +1 -7
- package/build/tools/gen_prototype.js +47 -27
- package/build/tools/genapi.js +8 -1
- package/build/tools/genchangelog.js +8 -1
- package/build/tools/gencommit.d.ts +1 -1
- package/build/tools/gencommit.js +49 -18
- package/build/tools/gendoc.js +9 -1
- package/build/tools/genpr.js +8 -1
- package/build/tools/genreadme.js +8 -1
- package/build/tools/gensql.js +8 -1
- package/build/tools/gentest.js +8 -1
- package/build/tools/index.d.ts +0 -3
- package/build/tools/index.js +0 -3
- package/build/tools/interview.d.ts +1 -13
- package/build/tools/interview.js +96 -31
- package/build/tools/perf.js +8 -1
- package/build/tools/refactor.js +8 -1
- package/build/tools/resolve_conflict.js +8 -1
- package/build/tools/security_scan.js +9 -2
- package/build/tools/start_api.js +44 -4
- package/build/tools/start_bugfix.js +377 -15
- package/build/tools/start_doc.js +40 -4
- package/build/tools/start_feature.js +287 -92
- package/build/tools/start_onboard.js +83 -100
- package/build/tools/start_product.d.ts +1 -1
- package/build/tools/start_product.js +183 -6
- package/build/tools/start_ralph.js +51 -2
- package/build/tools/start_refactor.js +39 -4
- package/build/tools/start_release.js +33 -4
- package/build/tools/start_review.js +39 -4
- package/build/tools/start_ui.js +669 -52
- package/build/utils/design-reasoning-engine.d.ts +5 -0
- package/build/utils/design-reasoning-engine.js +85 -5
- package/docs/data/tools.js +308 -478
- package/docs/index.html +1 -1
- package/docs/pages/all-tools.html +37 -22
- package/docs/pages/examples.html +100 -35
- package/docs/pages/getting-started.html +43 -3
- package/docs/pages/migration.html +14 -8
- package/package.json +79 -79
- package/build/lib/analysis-tasks.d.ts +0 -35
- package/build/lib/analysis-tasks.js +0 -788
- package/build/lib/elicitation-helper.d.ts +0 -73
- package/build/lib/elicitation-helper.js +0 -130
- package/build/lib/task-generator.d.ts +0 -11
- package/build/lib/task-generator.js +0 -109
- package/build/lib/template-generator.d.ts +0 -14
- package/build/lib/template-generator.js +0 -62
- package/build/lib/templates/backend-templates.d.ts +0 -8
- package/build/lib/templates/backend-templates.js +0 -26
- package/build/resources/index.d.ts +0 -4
- package/build/resources/index.js +0 -4
- package/build/resources/tool-params-guide.d.ts +0 -571
- package/build/resources/tool-params-guide.js +0 -488
- package/build/tools/analyze_project.d.ts +0 -1
- package/build/tools/analyze_project.js +0 -566
- package/build/tools/check_deps.d.ts +0 -1
- package/build/tools/check_deps.js +0 -213
- package/build/tools/convert.d.ts +0 -13
- package/build/tools/convert.js +0 -599
- package/build/tools/css_order.d.ts +0 -13
- package/build/tools/css_order.js +0 -81
- package/build/tools/debug.d.ts +0 -1
- package/build/tools/debug.js +0 -133
- package/build/tools/design2code.d.ts +0 -20
- package/build/tools/design2code.js +0 -426
- package/build/tools/detect_shell.d.ts +0 -6
- package/build/tools/detect_shell.js +0 -151
- package/build/tools/explain.d.ts +0 -13
- package/build/tools/explain.js +0 -390
- package/build/tools/fix.d.ts +0 -13
- package/build/tools/fix.js +0 -303
- package/build/tools/gen_skill.d.ts +0 -13
- package/build/tools/gen_skill.js +0 -560
- package/build/tools/genui.d.ts +0 -13
- package/build/tools/genui.js +0 -803
- package/build/tools/init_setting.d.ts +0 -13
- package/build/tools/init_setting.js +0 -47
- package/build/tools/split.d.ts +0 -13
- package/build/tools/split.js +0 -599
- package/build/tools/templates/architecture-template.d.ts +0 -5
- package/build/tools/templates/architecture-template.js +0 -42
- package/build/tools/templates/coding-standards-template.d.ts +0 -5
- package/build/tools/templates/coding-standards-template.js +0 -41
- package/build/tools/templates/dependencies-template.d.ts +0 -5
- package/build/tools/templates/dependencies-template.js +0 -38
- package/build/tools/templates/index-template.d.ts +0 -5
- package/build/tools/templates/index-template.js +0 -64
- package/build/tools/templates/tech-stack-template.d.ts +0 -5
- package/build/tools/templates/tech-stack-template.js +0 -35
- package/build/tools/templates/workflows-template.d.ts +0 -5
- package/build/tools/templates/workflows-template.js +0 -31
- package/docs/specs/algorithm-enhancement/roadmap.md +0 -619
- package/docs/specs/project-context-modular/design.md +0 -722
- package/docs/specs/project-context-modular/example-output.md +0 -123
- package/docs/specs/project-context-modular/implementation-v2.md +0 -275
- package/docs/specs/project-context-modular/requirements.md +0 -234
- package/docs/specs/project-context-modular/tasks.md +0 -386
- package/docs/specs/v2.1-planning.md +0 -335
- package/docs/specs/vnext-upgrade/00-OVERVIEW.md +0 -258
- package/docs/specs/vnext-upgrade/BETA_RELEASE_GUIDE.md +0 -328
- package/docs/specs/vnext-upgrade/GITHUB_DISCUSSION_TEMPLATE.md +0 -236
- package/docs/specs/vnext-upgrade/M8.9-PROGRESS-UPDATE.md +0 -248
- package/docs/specs/vnext-upgrade/PROGRESS-SUMMARY.md +0 -195
- package/docs/specs/vnext-upgrade/QUICK_REFERENCE.md +0 -338
- package/docs/specs/vnext-upgrade/README.md +0 -125
- package/docs/specs/vnext-upgrade/STATUS-UPDATE-2026-01-26.md +0 -230
- package/docs/specs/vnext-upgrade/TOOL_CLEANUP.md +0 -343
- package/docs/specs/vnext-upgrade/completed/M1-M2-SUMMARY.md +0 -27
- package/docs/specs/vnext-upgrade/completed/M3_COMPLETION_SUMMARY.md +0 -273
- package/docs/specs/vnext-upgrade/completed/M4-SUMMARY.md +0 -19
- package/docs/specs/vnext-upgrade/completed/M5_COMPLETION_SUMMARY.md +0 -0
- package/docs/specs/vnext-upgrade/completed/M8.1-SUMMARY.md +0 -247
- package/docs/specs/vnext-upgrade/completed/M8.2-SUMMARY.md +0 -296
- package/docs/specs/vnext-upgrade/completed/M8.3-SUMMARY.md +0 -241
- package/docs/specs/vnext-upgrade/completed/M8.3-TEST-SUMMARY.md +0 -216
- package/docs/specs/vnext-upgrade/completed/M8.4-SUMMARY.md +0 -217
- package/docs/specs/vnext-upgrade/completed/M8.4-TEST-SUMMARY.md +0 -198
- package/docs/specs/vnext-upgrade/completed/M8.5-SUMMARY.md +0 -202
- package/docs/specs/vnext-upgrade/completed/M8.5-TEST-SUMMARY.md +0 -223
- package/docs/specs/vnext-upgrade/completed/M8.6-SUMMARY.md +0 -299
- package/docs/specs/vnext-upgrade/completed/M8.8-TEST-SUMMARY.md +0 -216
- package/docs/specs/vnext-upgrade/completed/TOOL-CLEANUP-SUMMARY.md +0 -210
- package/docs/specs/vnext-upgrade/design.md +0 -848
- package/docs/specs/vnext-upgrade/requirements.md +0 -221
- package/docs/specs/vnext-upgrade/tasks/00-INDEX.md +0 -335
- package/docs/specs/vnext-upgrade/tasks/M8.1-SCHEMA-DEFINITION.md +0 -300
- package/docs/specs/vnext-upgrade/tasks/M8.2-P1-TOOLS.md +0 -249
- package/docs/specs/vnext-upgrade/tasks/M8.3-GENERATION-TOOLS.md +0 -49
- package/docs/specs/vnext-upgrade/tasks/M8.4-ORCHESTRATION-TOOLS.md +0 -28
- package/docs/specs/vnext-upgrade/tasks/M8.5-PROJECT-TOOLS.md +0 -29
- package/docs/specs/vnext-upgrade/tasks/M8.6-UI-TOOLS.md +0 -66
- package/docs/specs/vnext-upgrade/tasks/M8.7-HELPER-TOOLS.md +0 -24
- package/docs/specs/vnext-upgrade/tasks/M8.8-INTEGRATION-TESTS.md +0 -90
- package/docs/specs/vnext-upgrade/tasks/M8.9-DOCUMENTATION.md +0 -103
- package/docs/vnext/MCP_2025-11-25_GUIDE.md +0 -276
- package/docs/vnext/vNext-PRD.md +0 -488
package/build/tools/convert.js
DELETED
|
@@ -1,599 +0,0 @@
|
|
|
1
|
-
import { parseArgs, getString } from "../utils/parseArgs.js";
|
|
2
|
-
// convert 工具实现
|
|
3
|
-
export async function convert(args) {
|
|
4
|
-
try {
|
|
5
|
-
// 智能参数解析,支持自然语言输入
|
|
6
|
-
const parsedArgs = parseArgs(args, {
|
|
7
|
-
defaultValues: {
|
|
8
|
-
code: "",
|
|
9
|
-
from: "",
|
|
10
|
-
to: "",
|
|
11
|
-
},
|
|
12
|
-
primaryField: "code", // 纯文本输入默认映射到 code 字段
|
|
13
|
-
fieldAliases: {
|
|
14
|
-
code: ["source", "src", "代码", "content"],
|
|
15
|
-
from: ["source_format", "source_type", "源格式", "源类型"],
|
|
16
|
-
to: ["target_format", "target_type", "目标格式", "目标类型"],
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
const code = getString(parsedArgs.code);
|
|
20
|
-
const from = getString(parsedArgs.from);
|
|
21
|
-
const to = getString(parsedArgs.to);
|
|
22
|
-
const message = `请转换以下代码:
|
|
23
|
-
|
|
24
|
-
📝 **源代码**:
|
|
25
|
-
${code || "请提供需要转换的代码"}
|
|
26
|
-
|
|
27
|
-
🔄 **转换类型**:${from} → ${to}
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## 代码转换指南
|
|
32
|
-
|
|
33
|
-
### 支持的转换类型
|
|
34
|
-
|
|
35
|
-
#### 语言转换
|
|
36
|
-
- JavaScript → TypeScript
|
|
37
|
-
- TypeScript → JavaScript
|
|
38
|
-
- Python → JavaScript
|
|
39
|
-
- CommonJS → ESM
|
|
40
|
-
|
|
41
|
-
#### 框架转换
|
|
42
|
-
- Class Component → Hooks
|
|
43
|
-
- Vue 2 → Vue 3
|
|
44
|
-
- AngularJS → React
|
|
45
|
-
- jQuery → Vanilla JS
|
|
46
|
-
|
|
47
|
-
#### 样式转换
|
|
48
|
-
- CSS → Tailwind CSS
|
|
49
|
-
- SCSS → CSS-in-JS
|
|
50
|
-
- Styled-components → Emotion
|
|
51
|
-
|
|
52
|
-
#### 数据格式转换
|
|
53
|
-
- JSON → TypeScript Interface
|
|
54
|
-
- GraphQL → REST
|
|
55
|
-
- XML → JSON
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
## 转换示例
|
|
60
|
-
|
|
61
|
-
### 1️⃣ JavaScript → TypeScript
|
|
62
|
-
|
|
63
|
-
**JavaScript (Before):**
|
|
64
|
-
\`\`\`javascript
|
|
65
|
-
function calculateTotal(items, discount) {
|
|
66
|
-
const subtotal = items.reduce((sum, item) => {
|
|
67
|
-
return sum + item.price * item.quantity;
|
|
68
|
-
}, 0);
|
|
69
|
-
|
|
70
|
-
return discount ? subtotal * (1 - discount) : subtotal;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const order = {
|
|
74
|
-
id: '123',
|
|
75
|
-
items: [
|
|
76
|
-
{ name: 'Book', price: 29.99, quantity: 2 },
|
|
77
|
-
{ name: 'Pen', price: 1.99, quantity: 5 }
|
|
78
|
-
],
|
|
79
|
-
discount: 0.1
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const total = calculateTotal(order.items, order.discount);
|
|
83
|
-
\`\`\`
|
|
84
|
-
|
|
85
|
-
**TypeScript (After):**
|
|
86
|
-
\`\`\`typescript
|
|
87
|
-
interface Item {
|
|
88
|
-
name: string;
|
|
89
|
-
price: number;
|
|
90
|
-
quantity: number;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
interface Order {
|
|
94
|
-
id: string;
|
|
95
|
-
items: Item[];
|
|
96
|
-
discount?: number;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function calculateTotal(items: Item[], discount?: number): number {
|
|
100
|
-
const subtotal = items.reduce((sum, item) => {
|
|
101
|
-
return sum + item.price * item.quantity;
|
|
102
|
-
}, 0);
|
|
103
|
-
|
|
104
|
-
return discount ? subtotal * (1 - discount) : subtotal;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const order: Order = {
|
|
108
|
-
id: '123',
|
|
109
|
-
items: [
|
|
110
|
-
{ name: 'Book', price: 29.99, quantity: 2 },
|
|
111
|
-
{ name: 'Pen', price: 1.99, quantity: 5 }
|
|
112
|
-
],
|
|
113
|
-
discount: 0.1
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const total: number = calculateTotal(order.items, order.discount);
|
|
117
|
-
\`\`\`
|
|
118
|
-
|
|
119
|
-
**✅ 转换要点**:
|
|
120
|
-
1. 添加类型接口定义
|
|
121
|
-
2. 函数参数和返回值添加类型注解
|
|
122
|
-
3. 变量添加类型声明(可选)
|
|
123
|
-
4. 可选属性用 \`?\` 标记
|
|
124
|
-
|
|
125
|
-
---
|
|
126
|
-
|
|
127
|
-
### 2️⃣ Class Component → React Hooks
|
|
128
|
-
|
|
129
|
-
**Class Component (Before):**
|
|
130
|
-
\`\`\`jsx
|
|
131
|
-
import React, { Component } from 'react';
|
|
132
|
-
|
|
133
|
-
class UserProfile extends Component {
|
|
134
|
-
constructor(props) {
|
|
135
|
-
super(props);
|
|
136
|
-
this.state = {
|
|
137
|
-
user: null,
|
|
138
|
-
loading: true,
|
|
139
|
-
error: null
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
componentDidMount() {
|
|
144
|
-
this.fetchUser();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
componentDidUpdate(prevProps) {
|
|
148
|
-
if (prevProps.userId !== this.props.userId) {
|
|
149
|
-
this.fetchUser();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
componentWillUnmount() {
|
|
154
|
-
this.abortController?.abort();
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
async fetchUser() {
|
|
158
|
-
this.setState({ loading: true });
|
|
159
|
-
this.abortController = new AbortController();
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
const response = await fetch(\`/api/users/\${this.props.userId}\`, {
|
|
163
|
-
signal: this.abortController.signal
|
|
164
|
-
});
|
|
165
|
-
const user = await response.json();
|
|
166
|
-
this.setState({ user, loading: false });
|
|
167
|
-
} catch (error) {
|
|
168
|
-
if (error.name !== 'AbortError') {
|
|
169
|
-
this.setState({ error: error.message, loading: false });
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
render() {
|
|
175
|
-
const { user, loading, error } = this.state;
|
|
176
|
-
|
|
177
|
-
if (loading) return <div>Loading...</div>;
|
|
178
|
-
if (error) return <div>Error: {error}</div>;
|
|
179
|
-
if (!user) return null;
|
|
180
|
-
|
|
181
|
-
return (
|
|
182
|
-
<div>
|
|
183
|
-
<h1>{user.name}</h1>
|
|
184
|
-
<p>{user.email}</p>
|
|
185
|
-
</div>
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export default UserProfile;
|
|
191
|
-
\`\`\`
|
|
192
|
-
|
|
193
|
-
**Hooks (After):**
|
|
194
|
-
\`\`\`tsx
|
|
195
|
-
import React, { useState, useEffect } from 'react';
|
|
196
|
-
|
|
197
|
-
interface User {
|
|
198
|
-
name: string;
|
|
199
|
-
email: string;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
interface UserProfileProps {
|
|
203
|
-
userId: string;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
const UserProfile: React.FC<UserProfileProps> = ({ userId }) => {
|
|
207
|
-
const [user, setUser] = useState<User | null>(null);
|
|
208
|
-
const [loading, setLoading] = useState(true);
|
|
209
|
-
const [error, setError] = useState<string | null>(null);
|
|
210
|
-
|
|
211
|
-
useEffect(() => {
|
|
212
|
-
const abortController = new AbortController();
|
|
213
|
-
|
|
214
|
-
async function fetchUser() {
|
|
215
|
-
setLoading(true);
|
|
216
|
-
setError(null);
|
|
217
|
-
|
|
218
|
-
try {
|
|
219
|
-
const response = await fetch(\`/api/users/\${userId}\`, {
|
|
220
|
-
signal: abortController.signal
|
|
221
|
-
});
|
|
222
|
-
const userData = await response.json();
|
|
223
|
-
setUser(userData);
|
|
224
|
-
} catch (err) {
|
|
225
|
-
if (err instanceof Error && err.name !== 'AbortError') {
|
|
226
|
-
setError(err.message);
|
|
227
|
-
}
|
|
228
|
-
} finally {
|
|
229
|
-
setLoading(false);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
fetchUser();
|
|
234
|
-
|
|
235
|
-
return () => {
|
|
236
|
-
abortController.abort();
|
|
237
|
-
};
|
|
238
|
-
}, [userId]); // userId 变化时重新获取
|
|
239
|
-
|
|
240
|
-
if (loading) return <div>Loading...</div>;
|
|
241
|
-
if (error) return <div>Error: {error}</div>;
|
|
242
|
-
if (!user) return null;
|
|
243
|
-
|
|
244
|
-
return (
|
|
245
|
-
<div>
|
|
246
|
-
<h1>{user.name}</h1>
|
|
247
|
-
<p>{user.email}</p>
|
|
248
|
-
</div>
|
|
249
|
-
);
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
export default UserProfile;
|
|
253
|
-
\`\`\`
|
|
254
|
-
|
|
255
|
-
**✅ 转换要点**:
|
|
256
|
-
1. \`constructor\` + \`this.state\` → \`useState\`
|
|
257
|
-
2. \`componentDidMount\` + \`componentDidUpdate\` → \`useEffect\`
|
|
258
|
-
3. \`componentWillUnmount\` → \`useEffect\` 清理函数
|
|
259
|
-
4. \`this.props\` → 函数参数
|
|
260
|
-
5. \`this.setState\` → \`setState\` 函数
|
|
261
|
-
6. 类方法 → 函数内部函数或自定义 Hook
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
### 3️⃣ Promises → Async/Await
|
|
266
|
-
|
|
267
|
-
**Promises (Before):**
|
|
268
|
-
\`\`\`javascript
|
|
269
|
-
function getUserData(userId) {
|
|
270
|
-
return fetch(\`/api/users/\${userId}\`)
|
|
271
|
-
.then(response => {
|
|
272
|
-
if (!response.ok) {
|
|
273
|
-
throw new Error('User not found');
|
|
274
|
-
}
|
|
275
|
-
return response.json();
|
|
276
|
-
})
|
|
277
|
-
.then(user => {
|
|
278
|
-
return fetch(\`/api/posts?userId=\${user.id}\`);
|
|
279
|
-
})
|
|
280
|
-
.then(response => response.json())
|
|
281
|
-
.then(posts => {
|
|
282
|
-
return { user, posts };
|
|
283
|
-
})
|
|
284
|
-
.catch(error => {
|
|
285
|
-
console.error('Error:', error);
|
|
286
|
-
throw error;
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
// 使用
|
|
291
|
-
getUserData('123')
|
|
292
|
-
.then(data => console.log(data))
|
|
293
|
-
.catch(error => console.error(error));
|
|
294
|
-
\`\`\`
|
|
295
|
-
|
|
296
|
-
**Async/Await (After):**
|
|
297
|
-
\`\`\`javascript
|
|
298
|
-
async function getUserData(userId) {
|
|
299
|
-
try {
|
|
300
|
-
const userResponse = await fetch(\`/api/users/\${userId}\`);
|
|
301
|
-
|
|
302
|
-
if (!userResponse.ok) {
|
|
303
|
-
throw new Error('User not found');
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const user = await userResponse.json();
|
|
307
|
-
const postsResponse = await fetch(\`/api/posts?userId=\${user.id}\`);
|
|
308
|
-
const posts = await postsResponse.json();
|
|
309
|
-
|
|
310
|
-
return { user, posts };
|
|
311
|
-
} catch (error) {
|
|
312
|
-
console.error('Error:', error);
|
|
313
|
-
throw error;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// 使用
|
|
318
|
-
try {
|
|
319
|
-
const data = await getUserData('123');
|
|
320
|
-
console.log(data);
|
|
321
|
-
} catch (error) {
|
|
322
|
-
console.error(error);
|
|
323
|
-
}
|
|
324
|
-
\`\`\`
|
|
325
|
-
|
|
326
|
-
**✅ 转换要点**:
|
|
327
|
-
1. 函数前加 \`async\` 关键字
|
|
328
|
-
2. \`.then()\` → \`await\`
|
|
329
|
-
3. \`.catch()\` → \`try/catch\`
|
|
330
|
-
4. Promise 链条变为顺序执行
|
|
331
|
-
5. 代码更易读,像同步代码
|
|
332
|
-
|
|
333
|
-
---
|
|
334
|
-
|
|
335
|
-
### 4️⃣ CSS → Tailwind CSS
|
|
336
|
-
|
|
337
|
-
**CSS (Before):**
|
|
338
|
-
\`\`\`css
|
|
339
|
-
.button {
|
|
340
|
-
display: inline-flex;
|
|
341
|
-
align-items: center;
|
|
342
|
-
justify-content: center;
|
|
343
|
-
padding: 0.5rem 1rem;
|
|
344
|
-
font-size: 0.875rem;
|
|
345
|
-
font-weight: 500;
|
|
346
|
-
border-radius: 0.375rem;
|
|
347
|
-
background-color: #3b82f6;
|
|
348
|
-
color: white;
|
|
349
|
-
transition: background-color 0.2s;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
.button:hover {
|
|
353
|
-
background-color: #2563eb;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
.button:disabled {
|
|
357
|
-
opacity: 0.5;
|
|
358
|
-
cursor: not-allowed;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
.button-lg {
|
|
362
|
-
padding: 0.75rem 1.5rem;
|
|
363
|
-
font-size: 1rem;
|
|
364
|
-
}
|
|
365
|
-
\`\`\`
|
|
366
|
-
|
|
367
|
-
**Tailwind CSS (After):**
|
|
368
|
-
\`\`\`jsx
|
|
369
|
-
// 基础按钮
|
|
370
|
-
<button className="inline-flex items-center justify-center px-4 py-2 text-sm font-medium rounded-md bg-blue-600 text-white transition-colors hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed">
|
|
371
|
-
Button
|
|
372
|
-
</button>
|
|
373
|
-
|
|
374
|
-
// 大按钮
|
|
375
|
-
<button className="inline-flex items-center justify-center px-6 py-3 text-base font-medium rounded-md bg-blue-600 text-white transition-colors hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed">
|
|
376
|
-
Large Button
|
|
377
|
-
</button>
|
|
378
|
-
|
|
379
|
-
// 或使用组件抽象
|
|
380
|
-
const Button = ({ size = 'default', children, ...props }) => {
|
|
381
|
-
const sizeClasses = {
|
|
382
|
-
default: 'px-4 py-2 text-sm',
|
|
383
|
-
lg: 'px-6 py-3 text-base'
|
|
384
|
-
};
|
|
385
|
-
|
|
386
|
-
return (
|
|
387
|
-
<button
|
|
388
|
-
className={\`
|
|
389
|
-
inline-flex items-center justify-center font-medium rounded-md
|
|
390
|
-
bg-blue-600 text-white transition-colors
|
|
391
|
-
hover:bg-blue-700
|
|
392
|
-
disabled:opacity-50 disabled:cursor-not-allowed
|
|
393
|
-
\${sizeClasses[size]}
|
|
394
|
-
\`}
|
|
395
|
-
{...props}
|
|
396
|
-
>
|
|
397
|
-
{children}
|
|
398
|
-
</button>
|
|
399
|
-
);
|
|
400
|
-
};
|
|
401
|
-
\`\`\`
|
|
402
|
-
|
|
403
|
-
**✅ Tailwind 类名对照表**:
|
|
404
|
-
|
|
405
|
-
| CSS 属性 | Tailwind 类名 |
|
|
406
|
-
|----------|---------------|
|
|
407
|
-
| \`display: flex\` | \`flex\` |
|
|
408
|
-
| \`align-items: center\` | \`items-center\` |
|
|
409
|
-
| \`justify-content: center\` | \`justify-center\` |
|
|
410
|
-
| \`padding: 0.5rem 1rem\` | \`px-4 py-2\` |
|
|
411
|
-
| \`font-size: 0.875rem\` | \`text-sm\` |
|
|
412
|
-
| \`font-weight: 500\` | \`font-medium\` |
|
|
413
|
-
| \`border-radius: 0.375rem\` | \`rounded-md\` |
|
|
414
|
-
| \`background-color: #3b82f6\` | \`bg-blue-600\` |
|
|
415
|
-
| \`color: white\` | \`text-white\` |
|
|
416
|
-
|
|
417
|
-
---
|
|
418
|
-
|
|
419
|
-
### 5️⃣ CommonJS → ESM
|
|
420
|
-
|
|
421
|
-
**CommonJS (Before):**
|
|
422
|
-
\`\`\`javascript
|
|
423
|
-
// math.js
|
|
424
|
-
function add(a, b) {
|
|
425
|
-
return a + b;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
function multiply(a, b) {
|
|
429
|
-
return a * b;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
module.exports = {
|
|
433
|
-
add,
|
|
434
|
-
multiply
|
|
435
|
-
};
|
|
436
|
-
|
|
437
|
-
// main.js
|
|
438
|
-
const { add, multiply } = require('./math');
|
|
439
|
-
const lodash = require('lodash');
|
|
440
|
-
|
|
441
|
-
console.log(add(2, 3));
|
|
442
|
-
\`\`\`
|
|
443
|
-
|
|
444
|
-
**ESM (After):**
|
|
445
|
-
\`\`\`javascript
|
|
446
|
-
// math.js
|
|
447
|
-
export function add(a, b) {
|
|
448
|
-
return a + b;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
export function multiply(a, b) {
|
|
452
|
-
return a * b;
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
// 或默认导出
|
|
456
|
-
// export default { add, multiply };
|
|
457
|
-
|
|
458
|
-
// main.js
|
|
459
|
-
import { add, multiply } from './math.js';
|
|
460
|
-
import lodash from 'lodash';
|
|
461
|
-
|
|
462
|
-
console.log(add(2, 3));
|
|
463
|
-
\`\`\`
|
|
464
|
-
|
|
465
|
-
**✅ 转换要点**:
|
|
466
|
-
1. \`module.exports\` → \`export\` / \`export default\`
|
|
467
|
-
2. \`require()\` → \`import\`
|
|
468
|
-
3. 文件扩展名:ESM 中通常需要 \`.js\`
|
|
469
|
-
4. \`package.json\` 需要设置 \`"type": "module"\`
|
|
470
|
-
|
|
471
|
-
---
|
|
472
|
-
|
|
473
|
-
### 6️⃣ JSON → TypeScript Interface
|
|
474
|
-
|
|
475
|
-
**JSON (Before):**
|
|
476
|
-
\`\`\`json
|
|
477
|
-
{
|
|
478
|
-
"id": "123",
|
|
479
|
-
"name": "John Doe",
|
|
480
|
-
"email": "john@example.com",
|
|
481
|
-
"age": 30,
|
|
482
|
-
"isActive": true,
|
|
483
|
-
"roles": ["admin", "user"],
|
|
484
|
-
"address": {
|
|
485
|
-
"street": "123 Main St",
|
|
486
|
-
"city": "New York",
|
|
487
|
-
"zipCode": "10001"
|
|
488
|
-
},
|
|
489
|
-
"metadata": {
|
|
490
|
-
"createdAt": "2024-01-01T00:00:00Z",
|
|
491
|
-
"updatedAt": "2024-01-15T00:00:00Z"
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
\`\`\`
|
|
495
|
-
|
|
496
|
-
**TypeScript Interface (After):**
|
|
497
|
-
\`\`\`typescript
|
|
498
|
-
interface Address {
|
|
499
|
-
street: string;
|
|
500
|
-
city: string;
|
|
501
|
-
zipCode: string;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
interface Metadata {
|
|
505
|
-
createdAt: string; // 或 Date
|
|
506
|
-
updatedAt: string; // 或 Date
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
interface User {
|
|
510
|
-
id: string;
|
|
511
|
-
name: string;
|
|
512
|
-
email: string;
|
|
513
|
-
age: number;
|
|
514
|
-
isActive: boolean;
|
|
515
|
-
roles: string[];
|
|
516
|
-
address: Address;
|
|
517
|
-
metadata: Metadata;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
// 使用
|
|
521
|
-
const user: User = {
|
|
522
|
-
id: "123",
|
|
523
|
-
name: "John Doe",
|
|
524
|
-
email: "john@example.com",
|
|
525
|
-
age: 30,
|
|
526
|
-
isActive: true,
|
|
527
|
-
roles: ["admin", "user"],
|
|
528
|
-
address: {
|
|
529
|
-
street: "123 Main St",
|
|
530
|
-
city: "New York",
|
|
531
|
-
zipCode: "10001"
|
|
532
|
-
},
|
|
533
|
-
metadata: {
|
|
534
|
-
createdAt: "2024-01-01T00:00:00Z",
|
|
535
|
-
updatedAt: "2024-01-15T00:00:00Z"
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
\`\`\`
|
|
539
|
-
|
|
540
|
-
---
|
|
541
|
-
|
|
542
|
-
## 转换注意事项
|
|
543
|
-
|
|
544
|
-
### ⚠️ 潜在问题
|
|
545
|
-
|
|
546
|
-
1. **类型安全**
|
|
547
|
-
- 转换后需要添加类型检查
|
|
548
|
-
- 注意 null/undefined 处理
|
|
549
|
-
|
|
550
|
-
2. **API 差异**
|
|
551
|
-
- 不同框架的生命周期不同
|
|
552
|
-
- 状态管理方式不同
|
|
553
|
-
|
|
554
|
-
3. **性能影响**
|
|
555
|
-
- 某些转换可能影响性能
|
|
556
|
-
- 需要测试和优化
|
|
557
|
-
|
|
558
|
-
4. **依赖更新**
|
|
559
|
-
- 检查依赖包兼容性
|
|
560
|
-
- 更新 package.json
|
|
561
|
-
|
|
562
|
-
---
|
|
563
|
-
|
|
564
|
-
---
|
|
565
|
-
|
|
566
|
-
## ⚠️ 边界约束
|
|
567
|
-
|
|
568
|
-
- ❌ 仅输出转换后代码,不自动替换源文件
|
|
569
|
-
- ❌ 不执行代码或命令
|
|
570
|
-
- ✅ 保持功能等价,不改变业务逻辑
|
|
571
|
-
- ✅ 输出完整可用的转换代码
|
|
572
|
-
|
|
573
|
-
现在请根据需求进行代码转换,提供:
|
|
574
|
-
1. 转换后的完整代码
|
|
575
|
-
2. 关键变更说明
|
|
576
|
-
3. 潜在问题提示
|
|
577
|
-
4. 迁移步骤(如需要)`;
|
|
578
|
-
return {
|
|
579
|
-
content: [
|
|
580
|
-
{
|
|
581
|
-
type: "text",
|
|
582
|
-
text: message,
|
|
583
|
-
},
|
|
584
|
-
],
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
catch (error) {
|
|
588
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
589
|
-
return {
|
|
590
|
-
content: [
|
|
591
|
-
{
|
|
592
|
-
type: "text",
|
|
593
|
-
text: `❌ 代码转换失败: ${errorMessage}`,
|
|
594
|
-
},
|
|
595
|
-
],
|
|
596
|
-
isError: true,
|
|
597
|
-
};
|
|
598
|
-
}
|
|
599
|
-
}
|
package/build/tools/css_order.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// css_order 工具实现
|
|
2
|
-
export async function cssOrder(_args) {
|
|
3
|
-
try {
|
|
4
|
-
const message = `请根据以下规则**书写或重排 CSS**(不是解释规则)。目标是让 CSS 属性顺序更一致、可读、可维护。
|
|
5
|
-
|
|
6
|
-
如果我提供了 CSS 片段/文件,请直接给出**已按规则整理后的 CSS**;如果没提供,请先让我提供需要处理的 CSS。
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## 排序逻辑(由外向内,由大到小)
|
|
11
|
-
|
|
12
|
-
将属性分为五类,按顺序排列:
|
|
13
|
-
|
|
14
|
-
### 1. 定位属性 (Positioning)
|
|
15
|
-
决定元素“在哪里”。
|
|
16
|
-
- \`position\` / \`z-index\` / \`top\` / \`right\` / \`bottom\` / \`left\` / \`float\` / \`clear\`
|
|
17
|
-
|
|
18
|
-
### 2. 盒子模型 (Box Model)
|
|
19
|
-
决定元素“占多大空间”。
|
|
20
|
-
- \`display\` / \`flex\` / \`grid\` 相关属性
|
|
21
|
-
- \`width\` / \`height\` / \`max-width\` / \`min-width\`
|
|
22
|
-
- \`margin\` / \`padding\` / \`border\`
|
|
23
|
-
- \`box-sizing\` / \`overflow\`
|
|
24
|
-
|
|
25
|
-
### 3. 文本排版 (Typography)
|
|
26
|
-
决定元素内“文字内容”的样式。
|
|
27
|
-
- \`font-family\` / \`font-size\` / \`font-weight\` / \`line-height\`
|
|
28
|
-
- \`text-align\` / \`text-transform\` / \`text-decoration\` / \`letter-spacing\` / \`white-space\` / \`color\`
|
|
29
|
-
|
|
30
|
-
### 4. 视觉表现 (Visual/Decoration)
|
|
31
|
-
决定元素“皮肤”的外观。
|
|
32
|
-
- \`background\` / \`box-shadow\` / \`opacity\` / \`visibility\` / \`cursor\` / \`outline\`
|
|
33
|
-
|
|
34
|
-
### 5. 其他与交互 (Misc/Transitions)
|
|
35
|
-
动效和交互相关。
|
|
36
|
-
- \`transition\` / \`animation\` / \`transform\` / \`will-change\`
|
|
37
|
-
|
|
38
|
-
---
|
|
39
|
-
|
|
40
|
-
## 处理要求
|
|
41
|
-
|
|
42
|
-
1. **只调整属性顺序,不改动语义**(除非存在明显重复/冲突属性)。
|
|
43
|
-
2. **保留注释与格式风格**(缩进、空行、选择器顺序不变)。
|
|
44
|
-
3. **同类属性保持原有相对顺序**,除非有明显更合理的排序。
|
|
45
|
-
4. 如果存在 **CSS 变量**(\`--*\`)或自定义属性,放在**当前类的最前**。
|
|
46
|
-
5. 如遇 CSS-in-JS、Tailwind 或非标准语法,**只处理可确定的纯 CSS 属性**。
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## 快速对比表
|
|
51
|
-
|
|
52
|
-
| 顺序 | 类别 | 常用属性举例 | 核心目的 |
|
|
53
|
-
| --- | --- | --- | --- |
|
|
54
|
-
| **1** | **定位** | \`position\`, \`z-index\`, \`top\` | 确定位置 |
|
|
55
|
-
| **2** | **盒模型** | \`display\`, \`width\`, \`margin\`, \`padding\` | 确定形状和间距 |
|
|
56
|
-
| **3** | **排版** | \`font\`, \`line-height\`, \`color\`, \`text-align\` | 确定内容样式 |
|
|
57
|
-
| **4** | **视觉** | \`background\`, \`border-radius\`, \`box-shadow\` | 确定外观修饰 |
|
|
58
|
-
| **5** | **其他** | \`transition\`, \`transform\`, \`animation\` | 确定动态交互 |
|
|
59
|
-
`;
|
|
60
|
-
return {
|
|
61
|
-
content: [
|
|
62
|
-
{
|
|
63
|
-
type: "text",
|
|
64
|
-
text: message,
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
71
|
-
return {
|
|
72
|
-
content: [
|
|
73
|
-
{
|
|
74
|
-
type: "text",
|
|
75
|
-
text: `❌ CSS 顺序规范生成失败: ${errorMessage}`,
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
isError: true,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
}
|
package/build/tools/debug.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function debug(args: any): Promise<import("../lib/response.js").ToolResponse>;
|