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.
- package/LICENSE +22 -0
- package/README.md +607 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +553 -0
- package/build/tools/check_deps.d.ts +13 -0
- package/build/tools/check_deps.js +204 -0
- package/build/tools/code_review.d.ts +13 -0
- package/build/tools/code_review.js +138 -0
- package/build/tools/convert.d.ts +13 -0
- package/build/tools/convert.js +575 -0
- package/build/tools/debug.d.ts +13 -0
- package/build/tools/debug.js +78 -0
- package/build/tools/detect_shell.d.ts +6 -0
- package/build/tools/detect_shell.js +138 -0
- package/build/tools/explain.d.ts +13 -0
- package/build/tools/explain.js +369 -0
- package/build/tools/fix.d.ts +13 -0
- package/build/tools/fix.js +290 -0
- package/build/tools/genapi.d.ts +13 -0
- package/build/tools/genapi.js +152 -0
- package/build/tools/genchangelog.d.ts +13 -0
- package/build/tools/genchangelog.js +227 -0
- package/build/tools/gencommit.d.ts +13 -0
- package/build/tools/gencommit.js +95 -0
- package/build/tools/gendoc.d.ts +13 -0
- package/build/tools/gendoc.js +208 -0
- package/build/tools/genpr.d.ts +13 -0
- package/build/tools/genpr.js +173 -0
- package/build/tools/genreadme.d.ts +13 -0
- package/build/tools/genreadme.js +613 -0
- package/build/tools/gensql.d.ts +13 -0
- package/build/tools/gensql.js +307 -0
- package/build/tools/gentest.d.ts +13 -0
- package/build/tools/gentest.js +155 -0
- package/build/tools/genui.d.ts +13 -0
- package/build/tools/genui.js +781 -0
- package/build/tools/index.d.ts +22 -0
- package/build/tools/index.js +22 -0
- package/build/tools/init_project.d.ts +13 -0
- package/build/tools/init_project.js +142 -0
- package/build/tools/init_setting.d.ts +13 -0
- package/build/tools/init_setting.js +47 -0
- package/build/tools/perf.d.ts +13 -0
- package/build/tools/perf.js +359 -0
- package/build/tools/refactor.d.ts +13 -0
- package/build/tools/refactor.js +318 -0
- package/build/tools/resolve_conflict.d.ts +13 -0
- package/build/tools/resolve_conflict.js +338 -0
- package/build/tools/split.d.ts +13 -0
- package/build/tools/split.js +577 -0
- package/package.json +66 -0
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// fix 工具实现
|
|
2
|
+
export async function fix(args) {
|
|
3
|
+
try {
|
|
4
|
+
const code = args?.code || "";
|
|
5
|
+
const type = args?.type || "all"; // lint, type, format, import, unused
|
|
6
|
+
const message = `请自动修复以下代码问题:
|
|
7
|
+
|
|
8
|
+
📝 **代码内容**:
|
|
9
|
+
${code || "请提供需要修复的代码"}
|
|
10
|
+
|
|
11
|
+
🎯 **修复类型**:${type}
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 自动修复步骤
|
|
16
|
+
|
|
17
|
+
### 第一步:识别问题
|
|
18
|
+
|
|
19
|
+
执行以下检查:
|
|
20
|
+
\`\`\`bash
|
|
21
|
+
# Lint 检查
|
|
22
|
+
npm run lint
|
|
23
|
+
|
|
24
|
+
# TypeScript 类型检查
|
|
25
|
+
tsc --noEmit
|
|
26
|
+
|
|
27
|
+
# 格式化检查
|
|
28
|
+
npm run format:check
|
|
29
|
+
\`\`\`
|
|
30
|
+
|
|
31
|
+
### 第二步:问题分类
|
|
32
|
+
|
|
33
|
+
**1️⃣ Lint 错误**
|
|
34
|
+
- ESLint 规则违反
|
|
35
|
+
- 代码质量问题
|
|
36
|
+
- 潜在 Bug
|
|
37
|
+
|
|
38
|
+
**2️⃣ TypeScript 类型错误**
|
|
39
|
+
- 类型不匹配
|
|
40
|
+
- 缺少类型定义
|
|
41
|
+
- 隐式 any
|
|
42
|
+
|
|
43
|
+
**3️⃣ 格式化问题**
|
|
44
|
+
- 缩进不一致
|
|
45
|
+
- 引号风格
|
|
46
|
+
- 分号使用
|
|
47
|
+
- 换行规则
|
|
48
|
+
|
|
49
|
+
**4️⃣ Import 问题**
|
|
50
|
+
- 未使用的 import
|
|
51
|
+
- 重复 import
|
|
52
|
+
- Import 顺序混乱
|
|
53
|
+
- 相对路径 vs 绝对路径
|
|
54
|
+
|
|
55
|
+
**5️⃣ 未使用代码**
|
|
56
|
+
- 未使用的变量
|
|
57
|
+
- 未使用的函数
|
|
58
|
+
- 死代码(Dead Code)
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## 修复策略
|
|
63
|
+
|
|
64
|
+
### 🔧 Lint 错误修复
|
|
65
|
+
|
|
66
|
+
**常见问题和修复:**
|
|
67
|
+
|
|
68
|
+
1. **no-unused-vars**
|
|
69
|
+
\`\`\`typescript
|
|
70
|
+
// ❌ Before
|
|
71
|
+
const unusedVar = 123;
|
|
72
|
+
function test() {
|
|
73
|
+
const result = compute();
|
|
74
|
+
return 42;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ✅ After
|
|
78
|
+
function test() {
|
|
79
|
+
return 42;
|
|
80
|
+
}
|
|
81
|
+
\`\`\`
|
|
82
|
+
|
|
83
|
+
2. **no-console**
|
|
84
|
+
\`\`\`typescript
|
|
85
|
+
// ❌ Before
|
|
86
|
+
console.log('debug info');
|
|
87
|
+
|
|
88
|
+
// ✅ After (开发环境)
|
|
89
|
+
if (process.env.NODE_ENV === 'development') {
|
|
90
|
+
console.log('debug info');
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ✅ After (使用 logger)
|
|
94
|
+
logger.debug('debug info');
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
3. **prefer-const**
|
|
98
|
+
\`\`\`typescript
|
|
99
|
+
// ❌ Before
|
|
100
|
+
let value = 10;
|
|
101
|
+
const result = value * 2;
|
|
102
|
+
|
|
103
|
+
// ✅ After
|
|
104
|
+
const value = 10;
|
|
105
|
+
const result = value * 2;
|
|
106
|
+
\`\`\`
|
|
107
|
+
|
|
108
|
+
### 🔧 TypeScript 类型错误修复
|
|
109
|
+
|
|
110
|
+
**常见问题和修复:**
|
|
111
|
+
|
|
112
|
+
1. **隐式 any**
|
|
113
|
+
\`\`\`typescript
|
|
114
|
+
// ❌ Before
|
|
115
|
+
function process(data) {
|
|
116
|
+
return data.value;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ✅ After
|
|
120
|
+
function process(data: { value: string }): string {
|
|
121
|
+
return data.value;
|
|
122
|
+
}
|
|
123
|
+
\`\`\`
|
|
124
|
+
|
|
125
|
+
2. **类型不匹配**
|
|
126
|
+
\`\`\`typescript
|
|
127
|
+
// ❌ Before
|
|
128
|
+
const num: number = "123";
|
|
129
|
+
|
|
130
|
+
// ✅ After
|
|
131
|
+
const num: number = 123;
|
|
132
|
+
// 或
|
|
133
|
+
const num: number = parseInt("123");
|
|
134
|
+
\`\`\`
|
|
135
|
+
|
|
136
|
+
3. **可能为 null/undefined**
|
|
137
|
+
\`\`\`typescript
|
|
138
|
+
// ❌ Before
|
|
139
|
+
function getName(user) {
|
|
140
|
+
return user.name.toUpperCase();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ✅ After
|
|
144
|
+
function getName(user: User | null): string {
|
|
145
|
+
return user?.name?.toUpperCase() ?? 'Unknown';
|
|
146
|
+
}
|
|
147
|
+
\`\`\`
|
|
148
|
+
|
|
149
|
+
### 🔧 Import 优化
|
|
150
|
+
|
|
151
|
+
**修复策略:**
|
|
152
|
+
|
|
153
|
+
\`\`\`typescript
|
|
154
|
+
// ❌ Before
|
|
155
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
156
|
+
import { Button } from './components/Button';
|
|
157
|
+
import React from 'react';
|
|
158
|
+
import { formatDate } from '../utils/date';
|
|
159
|
+
import { api } from '../../services/api';
|
|
160
|
+
|
|
161
|
+
// ✅ After
|
|
162
|
+
// 外部依赖
|
|
163
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
164
|
+
|
|
165
|
+
// 内部模块(按层级从远到近)
|
|
166
|
+
import { api } from '../../services/api';
|
|
167
|
+
import { formatDate } from '../utils/date';
|
|
168
|
+
import { Button } from './components/Button';
|
|
169
|
+
\`\`\`
|
|
170
|
+
|
|
171
|
+
### 🔧 格式化修复
|
|
172
|
+
|
|
173
|
+
**自动格式化:**
|
|
174
|
+
\`\`\`bash
|
|
175
|
+
# Prettier
|
|
176
|
+
npm run format
|
|
177
|
+
|
|
178
|
+
# ESLint 自动修复
|
|
179
|
+
npm run lint:fix
|
|
180
|
+
\`\`\`
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 批量修复命令
|
|
185
|
+
|
|
186
|
+
**一键修复所有可自动修复的问题:**
|
|
187
|
+
\`\`\`bash
|
|
188
|
+
# 1. 格式化代码
|
|
189
|
+
npm run format
|
|
190
|
+
|
|
191
|
+
# 2. ESLint 自动修复
|
|
192
|
+
npm run lint:fix
|
|
193
|
+
|
|
194
|
+
# 3. 整理 import
|
|
195
|
+
npx organize-imports-cli 'src/**/*.ts'
|
|
196
|
+
|
|
197
|
+
# 4. 移除未使用的 import
|
|
198
|
+
npx ts-unused-exports tsconfig.json --deleteUnusedFile
|
|
199
|
+
|
|
200
|
+
# 5. TypeScript 类型检查
|
|
201
|
+
tsc --noEmit
|
|
202
|
+
\`\`\`
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 修复报告
|
|
207
|
+
|
|
208
|
+
### 📊 问题统计
|
|
209
|
+
- Lint 错误: X 个
|
|
210
|
+
- 类型错误: Y 个
|
|
211
|
+
- 格式问题: Z 个
|
|
212
|
+
- Import 问题: W 个
|
|
213
|
+
|
|
214
|
+
### ✅ 已自动修复
|
|
215
|
+
1. [文件:行号] 问题描述 → 已修复
|
|
216
|
+
2. [文件:行号] 问题描述 → 已修复
|
|
217
|
+
|
|
218
|
+
### ⚠️ 需要手动处理
|
|
219
|
+
1. [文件:行号] 问题描述 → 修复建议
|
|
220
|
+
2. [文件:行号] 问题描述 → 修复建议
|
|
221
|
+
|
|
222
|
+
### 📝 修复后的代码
|
|
223
|
+
\`\`\`typescript
|
|
224
|
+
// 完整的修复后代码
|
|
225
|
+
\`\`\`
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## 预防措施
|
|
230
|
+
|
|
231
|
+
**配置自动修复:**
|
|
232
|
+
|
|
233
|
+
\`\`\`.vscode/settings.json
|
|
234
|
+
{
|
|
235
|
+
"editor.formatOnSave": true,
|
|
236
|
+
"editor.codeActionsOnSave": {
|
|
237
|
+
"source.fixAll.eslint": true,
|
|
238
|
+
"source.organizeImports": true
|
|
239
|
+
},
|
|
240
|
+
"eslint.validate": [
|
|
241
|
+
"javascript",
|
|
242
|
+
"typescript",
|
|
243
|
+
"javascriptreact",
|
|
244
|
+
"typescriptreact"
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
\`\`\`
|
|
248
|
+
|
|
249
|
+
**Git Hooks(Husky):**
|
|
250
|
+
\`\`\`json
|
|
251
|
+
{
|
|
252
|
+
"husky": {
|
|
253
|
+
"hooks": {
|
|
254
|
+
"pre-commit": "lint-staged"
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
"lint-staged": {
|
|
258
|
+
"*.{js,ts,tsx}": [
|
|
259
|
+
"eslint --fix",
|
|
260
|
+
"prettier --write"
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
\`\`\`
|
|
265
|
+
|
|
266
|
+
---
|
|
267
|
+
|
|
268
|
+
现在请开始分析代码问题并自动修复。`;
|
|
269
|
+
return {
|
|
270
|
+
content: [
|
|
271
|
+
{
|
|
272
|
+
type: "text",
|
|
273
|
+
text: message,
|
|
274
|
+
},
|
|
275
|
+
],
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
280
|
+
return {
|
|
281
|
+
content: [
|
|
282
|
+
{
|
|
283
|
+
type: "text",
|
|
284
|
+
text: `❌ 自动修复失败: ${errorMessage}`,
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
isError: true,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// genapi 工具实现
|
|
2
|
+
export async function genapi(args) {
|
|
3
|
+
try {
|
|
4
|
+
const code = args?.code || "";
|
|
5
|
+
const format = args?.format || "markdown"; // markdown, openapi, jsdoc
|
|
6
|
+
const message = `请为以下代码生成 API 文档:
|
|
7
|
+
|
|
8
|
+
📝 **代码**:
|
|
9
|
+
${code || "请提供需要生成文档的代码(函数、类、API 端点等)"}
|
|
10
|
+
|
|
11
|
+
📖 **文档格式**:${format}
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
🎯 **API 文档生成指南**:
|
|
16
|
+
|
|
17
|
+
**基础信息**:
|
|
18
|
+
- API 名称和描述
|
|
19
|
+
- 版本信息
|
|
20
|
+
- 基础 URL
|
|
21
|
+
|
|
22
|
+
**详细文档**(每个端点/函数):
|
|
23
|
+
|
|
24
|
+
1. **功能描述**
|
|
25
|
+
- 简短说明(一句话)
|
|
26
|
+
- 详细描述(用途、场景)
|
|
27
|
+
|
|
28
|
+
2. **请求参数**
|
|
29
|
+
| 参数名 | 类型 | 必填 | 描述 | 示例 |
|
|
30
|
+
|--------|------|------|------|------|
|
|
31
|
+
| id | string | 是 | 用户 ID | "12345" |
|
|
32
|
+
| name | string | 否 | 用户名 | "张三" |
|
|
33
|
+
|
|
34
|
+
3. **返回值**
|
|
35
|
+
- 成功响应(状态码、数据结构、示例)
|
|
36
|
+
- 错误响应(错误码、错误信息)
|
|
37
|
+
|
|
38
|
+
4. **示例代码**
|
|
39
|
+
\`\`\`typescript
|
|
40
|
+
// 请求示例
|
|
41
|
+
const response = await fetch('/api/users/123');
|
|
42
|
+
const data = await response.json();
|
|
43
|
+
|
|
44
|
+
// 响应示例
|
|
45
|
+
{
|
|
46
|
+
"code": 200,
|
|
47
|
+
"data": {
|
|
48
|
+
"id": "123",
|
|
49
|
+
"name": "张三"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
\`\`\`
|
|
53
|
+
|
|
54
|
+
5. **注意事项**
|
|
55
|
+
- 权限要求
|
|
56
|
+
- 速率限制
|
|
57
|
+
- 废弃信息
|
|
58
|
+
- 相关链接
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
**Markdown 格式模板**:
|
|
63
|
+
\`\`\`markdown
|
|
64
|
+
# API 文档
|
|
65
|
+
|
|
66
|
+
## 用户管理
|
|
67
|
+
|
|
68
|
+
### 获取用户信息
|
|
69
|
+
|
|
70
|
+
**接口地址**:\`GET /api/users/:id\`
|
|
71
|
+
|
|
72
|
+
**功能描述**:根据用户 ID 获取用户详细信息
|
|
73
|
+
|
|
74
|
+
**请求参数**:
|
|
75
|
+
| 参数 | 类型 | 必填 | 描述 |
|
|
76
|
+
|------|------|------|------|
|
|
77
|
+
| id | string | 是 | 用户 ID |
|
|
78
|
+
|
|
79
|
+
**返回示例**:
|
|
80
|
+
\`\`\`json
|
|
81
|
+
{
|
|
82
|
+
"code": 200,
|
|
83
|
+
"data": {
|
|
84
|
+
"id": "123",
|
|
85
|
+
"name": "张三",
|
|
86
|
+
"email": "zhangsan@example.com"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
\`\`\`
|
|
90
|
+
|
|
91
|
+
**错误码**:
|
|
92
|
+
- 404: 用户不存在
|
|
93
|
+
- 403: 无权限访问
|
|
94
|
+
\`\`\`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
**OpenAPI 3.0 格式模板**:
|
|
99
|
+
\`\`\`yaml
|
|
100
|
+
openapi: 3.0.0
|
|
101
|
+
info:
|
|
102
|
+
title: User API
|
|
103
|
+
version: 1.0.0
|
|
104
|
+
paths:
|
|
105
|
+
/api/users/{id}:
|
|
106
|
+
get:
|
|
107
|
+
summary: 获取用户信息
|
|
108
|
+
parameters:
|
|
109
|
+
- name: id
|
|
110
|
+
in: path
|
|
111
|
+
required: true
|
|
112
|
+
schema:
|
|
113
|
+
type: string
|
|
114
|
+
responses:
|
|
115
|
+
'200':
|
|
116
|
+
description: 成功
|
|
117
|
+
content:
|
|
118
|
+
application/json:
|
|
119
|
+
schema:
|
|
120
|
+
type: object
|
|
121
|
+
properties:
|
|
122
|
+
code:
|
|
123
|
+
type: integer
|
|
124
|
+
data:
|
|
125
|
+
type: object
|
|
126
|
+
\`\`\`
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
现在请根据上述代码生成完整的 API 文档,并将文档保存到项目的 \`docs/api/\` 目录。`;
|
|
131
|
+
return {
|
|
132
|
+
content: [
|
|
133
|
+
{
|
|
134
|
+
type: "text",
|
|
135
|
+
text: message,
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
142
|
+
return {
|
|
143
|
+
content: [
|
|
144
|
+
{
|
|
145
|
+
type: "text",
|
|
146
|
+
text: `❌ 生成 API 文档失败: ${errorMessage}`,
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
isError: true,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// genchangelog 工具实现
|
|
2
|
+
export async function genchangelog(args) {
|
|
3
|
+
try {
|
|
4
|
+
const version = args?.version || "";
|
|
5
|
+
const from = args?.from || "";
|
|
6
|
+
const to = args?.to || "HEAD";
|
|
7
|
+
const message = `请生成项目的 CHANGELOG(变更日志):
|
|
8
|
+
|
|
9
|
+
📝 **版本信息**:
|
|
10
|
+
${version || "请提供版本号(如:v1.2.0)"}
|
|
11
|
+
|
|
12
|
+
📋 **Commit 范围**:
|
|
13
|
+
从 ${from || "上一个 tag"} 到 ${to}
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Changelog 生成步骤
|
|
18
|
+
|
|
19
|
+
### 第一步:获取 Commit 历史
|
|
20
|
+
|
|
21
|
+
执行以下命令:
|
|
22
|
+
\`\`\`bash
|
|
23
|
+
# 查看 commit 历史
|
|
24
|
+
git log ${from}..${to} --oneline --no-merges
|
|
25
|
+
|
|
26
|
+
# 查看详细信息
|
|
27
|
+
git log ${from}..${to} --pretty=format:"%h - %s (%an)" --no-merges
|
|
28
|
+
|
|
29
|
+
# 查看所有 tags
|
|
30
|
+
git tag -l
|
|
31
|
+
|
|
32
|
+
# 查看贡献者
|
|
33
|
+
git shortlog ${from}..${to} -sn
|
|
34
|
+
\`\`\`
|
|
35
|
+
|
|
36
|
+
### 第二步:分类 Commits
|
|
37
|
+
|
|
38
|
+
按类型分组:
|
|
39
|
+
- **✨ Features (feat)**:新功能
|
|
40
|
+
- **🐛 Bug Fixes (fix)**:Bug 修复
|
|
41
|
+
- **📝 Documentation (docs)**:文档变更
|
|
42
|
+
- **💄 Styles (style)**:代码格式
|
|
43
|
+
- **♻️ Refactoring (refactor)**:重构
|
|
44
|
+
- **⚡ Performance (perf)**:性能优化
|
|
45
|
+
- **✅ Tests (test)**:测试相关
|
|
46
|
+
- **🔧 Chores (chore)**:构建/工具变更
|
|
47
|
+
- **💥 BREAKING CHANGES**:破坏性变更
|
|
48
|
+
|
|
49
|
+
### 第三步:生成 Changelog
|
|
50
|
+
|
|
51
|
+
**格式标准**:[Keep a Changelog](https://keepachangelog.com/)
|
|
52
|
+
|
|
53
|
+
\`\`\`markdown
|
|
54
|
+
# Changelog
|
|
55
|
+
|
|
56
|
+
All notable changes to this project will be documented in this file.
|
|
57
|
+
|
|
58
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
59
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
60
|
+
|
|
61
|
+
## [版本号] - YYYY-MM-DD
|
|
62
|
+
|
|
63
|
+
### Added(新增)
|
|
64
|
+
- 新功能 1 (#PR号)
|
|
65
|
+
- 新功能 2 by @contributor
|
|
66
|
+
|
|
67
|
+
### Changed(变更)
|
|
68
|
+
- 修改的功能 1
|
|
69
|
+
- 修改的功能 2
|
|
70
|
+
|
|
71
|
+
### Deprecated(废弃)
|
|
72
|
+
- 即将移除的功能
|
|
73
|
+
|
|
74
|
+
### Removed(移除)
|
|
75
|
+
- 已移除的功能
|
|
76
|
+
|
|
77
|
+
### Fixed(修复)
|
|
78
|
+
- Bug 修复 1 (#issue号)
|
|
79
|
+
- Bug 修复 2
|
|
80
|
+
|
|
81
|
+
### Security(安全)
|
|
82
|
+
- 安全漏洞修复
|
|
83
|
+
|
|
84
|
+
## [上一个版本] - YYYY-MM-DD
|
|
85
|
+
|
|
86
|
+
...
|
|
87
|
+
\`\`\`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Changelog 模板
|
|
92
|
+
|
|
93
|
+
\`\`\`markdown
|
|
94
|
+
# Changelog
|
|
95
|
+
|
|
96
|
+
## [${version || "1.2.0"}] - ${new Date().toISOString().split('T')[0]}
|
|
97
|
+
|
|
98
|
+
### ✨ Added
|
|
99
|
+
- 新增用户认证功能 (#123) [@contributor1]
|
|
100
|
+
- 新增数据导出功能 (#125)
|
|
101
|
+
- 新增邮件通知系统
|
|
102
|
+
|
|
103
|
+
### 🔄 Changed
|
|
104
|
+
- 优化数据库查询性能 (#130)
|
|
105
|
+
- 更新 UI 设计风格
|
|
106
|
+
- 升级依赖包到最新版本
|
|
107
|
+
|
|
108
|
+
### 🗑️ Deprecated
|
|
109
|
+
- \`oldAPI()\` 方法即将在 v2.0 中移除,请使用 \`newAPI()\`
|
|
110
|
+
|
|
111
|
+
### ❌ Removed
|
|
112
|
+
- 移除了废弃的 \`legacyFeature\`
|
|
113
|
+
- 删除了未使用的配置项
|
|
114
|
+
|
|
115
|
+
### 🐛 Fixed
|
|
116
|
+
- 修复登录页面样式错误 (#128)
|
|
117
|
+
- 修复数据分页显示问题 (#132)
|
|
118
|
+
- 修复内存泄漏问题 (#135)
|
|
119
|
+
|
|
120
|
+
### 🔒 Security
|
|
121
|
+
- 修复 SQL 注入漏洞 (CVE-2024-XXXX)
|
|
122
|
+
- 更新依赖以修复安全漏洞
|
|
123
|
+
|
|
124
|
+
### 💥 BREAKING CHANGES
|
|
125
|
+
- API 端点从 \`/api/v1/users\` 改为 \`/api/v2/users\`
|
|
126
|
+
- 配置文件格式从 JSON 改为 YAML
|
|
127
|
+
- 最低 Node.js 版本要求提升到 18.x
|
|
128
|
+
|
|
129
|
+
### 📚 Documentation
|
|
130
|
+
- 更新 README 文档
|
|
131
|
+
- 添加 API 使用指南
|
|
132
|
+
- 完善贡献指南
|
|
133
|
+
|
|
134
|
+
### 🏗️ Infrastructure
|
|
135
|
+
- 升级 CI/CD 流程
|
|
136
|
+
- 添加 Docker 支持
|
|
137
|
+
- 配置自动化测试
|
|
138
|
+
|
|
139
|
+
### 👥 Contributors
|
|
140
|
+
感谢以下贡献者:
|
|
141
|
+
- @contributor1 - 3 commits
|
|
142
|
+
- @contributor2 - 2 commits
|
|
143
|
+
- @contributor3 - 1 commit
|
|
144
|
+
|
|
145
|
+
**Full Changelog**: https://github.com/owner/repo/compare/v1.1.0...v${version || "1.2.0"}
|
|
146
|
+
\`\`\`
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Changelog 最佳实践
|
|
151
|
+
|
|
152
|
+
### 内容要求
|
|
153
|
+
|
|
154
|
+
1. **明确说明变更**
|
|
155
|
+
- 用户能理解的语言(避免技术术语)
|
|
156
|
+
- 说明影响范围
|
|
157
|
+
- 提供迁移指南(破坏性变更)
|
|
158
|
+
|
|
159
|
+
2. **链接相关 Issue/PR**
|
|
160
|
+
- 使用 (#123) 格式
|
|
161
|
+
- 方便追溯详细信息
|
|
162
|
+
|
|
163
|
+
3. **归功贡献者**
|
|
164
|
+
- 使用 @username 格式
|
|
165
|
+
- 体现团队协作
|
|
166
|
+
|
|
167
|
+
### 版本规范
|
|
168
|
+
|
|
169
|
+
**语义化版本 (Semantic Versioning)**:
|
|
170
|
+
- **Major (X.0.0)**:破坏性变更
|
|
171
|
+
- **Minor (x.X.0)**:新功能(向后兼容)
|
|
172
|
+
- **Patch (x.x.X)**:Bug 修复
|
|
173
|
+
|
|
174
|
+
### 发布流程
|
|
175
|
+
|
|
176
|
+
1. 更新 CHANGELOG.md
|
|
177
|
+
2. 更新 package.json 版本号
|
|
178
|
+
3. 创建 Git tag:\`git tag -a v1.2.0 -m "Release v1.2.0"\`
|
|
179
|
+
4. 推送 tag:\`git push origin v1.2.0\`
|
|
180
|
+
5. 发布 GitHub Release
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 自动化工具
|
|
185
|
+
|
|
186
|
+
**推荐工具**:
|
|
187
|
+
- **standard-version**:自动生成 changelog
|
|
188
|
+
- **conventional-changelog**:基于 commit 生成
|
|
189
|
+
- **semantic-release**:自动发布版本
|
|
190
|
+
|
|
191
|
+
**使用示例**:
|
|
192
|
+
\`\`\`bash
|
|
193
|
+
# 安装
|
|
194
|
+
npm install -D standard-version
|
|
195
|
+
|
|
196
|
+
# 生成 changelog
|
|
197
|
+
npx standard-version
|
|
198
|
+
|
|
199
|
+
# 首次发布
|
|
200
|
+
npx standard-version --first-release
|
|
201
|
+
\`\`\`
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
现在请根据 commit 历史生成详细的 CHANGELOG.md 文件。`;
|
|
206
|
+
return {
|
|
207
|
+
content: [
|
|
208
|
+
{
|
|
209
|
+
type: "text",
|
|
210
|
+
text: message,
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
catch (error) {
|
|
216
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
217
|
+
return {
|
|
218
|
+
content: [
|
|
219
|
+
{
|
|
220
|
+
type: "text",
|
|
221
|
+
text: `❌ 生成 Changelog 失败: ${errorMessage}`,
|
|
222
|
+
},
|
|
223
|
+
],
|
|
224
|
+
isError: true,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
}
|