@zzp123/mcp-zentao 1.8.8 → 1.9.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/CHANGELOG.md +28 -0
- package/dist/api/zentaoApi.js +39 -23
- package/dist/types/zentao.d.ts +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,34 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.9.0] - 2025-11-06
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- **修复 getMyBugs 工具过滤逻辑问题** 🔧
|
|
12
|
+
- 禅道API的 `/bugs` 接口不支持 `assignedTo` 参数进行服务端过滤
|
|
13
|
+
- 改为使用客户端过滤:获取更多数据后在本地筛选分配给当前用户的Bug
|
|
14
|
+
- 修复了使用 `onlyAssignedToMe=true` 时无法正确获取当前用户Bug的问题
|
|
15
|
+
- 现在能够正确识别 `assignedTo` 字段(支持对象和字符串两种格式)
|
|
16
|
+
|
|
17
|
+
### Improved
|
|
18
|
+
- 优化了 `getMyBugs` 的性能:当需要过滤时自动获取100条数据以确保有足够的结果
|
|
19
|
+
- 增加了详细的过滤日志输出,便于调试和追踪
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- 扩展了 `Bug` 类型定义,添加了 `assignedTo`、`openedBy`、`resolvedBy` 等字段
|
|
23
|
+
- 更新了文档,说明了禅道API的限制和客户端过滤的实现方式
|
|
24
|
+
|
|
25
|
+
## [1.8.9] - 2025-11-06
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- **修复 resolveBug 工具必须提供 resolvedBuild 参数的问题**
|
|
29
|
+
- 当 resolution 为 "fixed" 时,如果未提供 resolvedBuild,自动设置为 "trunk"(主干版本)
|
|
30
|
+
- 消除了使用 resolveBug 工具时的常见错误:"当解决方案为"已解决(fixed)"时,必须提供解决版本(resolvedBuild)"
|
|
31
|
+
- 简化了解决Bug的操作流程,提升用户体验
|
|
32
|
+
|
|
33
|
+
### Improved
|
|
34
|
+
- 添加了自动默认值设置的日志输出,便于调试和追踪
|
|
35
|
+
|
|
8
36
|
## [1.8.8] - 2025-11-06
|
|
9
37
|
|
|
10
38
|
### Fixed
|
package/dist/api/zentaoApi.js
CHANGED
|
@@ -125,38 +125,53 @@ export class ZentaoAPI {
|
|
|
125
125
|
// 默认每页20条,最多100条
|
|
126
126
|
const finalLimit = limit ? Math.min(limit, 100) : 20;
|
|
127
127
|
const finalPage = page || 1;
|
|
128
|
+
// 禅道API的/bugs接口不支持assignedTo参数过滤,需要客户端过滤
|
|
129
|
+
// 所以获取更多数据以确保有足够的结果
|
|
130
|
+
const fetchLimit = onlyAssignedToMe ? 100 : finalLimit;
|
|
128
131
|
const params = {
|
|
129
132
|
status: status || 'all',
|
|
130
133
|
product: productId,
|
|
131
|
-
page:
|
|
132
|
-
limit:
|
|
134
|
+
page: 1,
|
|
135
|
+
limit: fetchLimit
|
|
133
136
|
};
|
|
134
|
-
// 只有当明确指定时才过滤 assignedTo
|
|
135
|
-
if (onlyAssignedToMe) {
|
|
136
|
-
params.assignedTo = this.config.username;
|
|
137
|
-
}
|
|
138
137
|
try {
|
|
139
|
-
console.log(`正在获取Bug
|
|
138
|
+
console.log(`正在获取Bug列表,参数:`, params);
|
|
140
139
|
const response = await this.request('GET', '/bugs', params);
|
|
141
140
|
console.log(`Bug列表响应: 获取到 ${response.bugs?.length || 0} 条数据`);
|
|
141
|
+
let bugs = [];
|
|
142
142
|
if (Array.isArray(response)) {
|
|
143
|
-
|
|
144
|
-
return {
|
|
145
|
-
page: finalPage,
|
|
146
|
-
total: response.length,
|
|
147
|
-
limit: finalLimit,
|
|
148
|
-
bugs: response
|
|
149
|
-
};
|
|
143
|
+
bugs = response;
|
|
150
144
|
}
|
|
151
145
|
else if (response && typeof response === 'object' && Array.isArray(response.bugs)) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
146
|
+
bugs = response.bugs;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw new Error(`获取Bug列表失败: 响应格式不正确 ${JSON.stringify(response)}`);
|
|
150
|
+
}
|
|
151
|
+
// 如果需要过滤分配给当前用户的bug,在客户端进行过滤
|
|
152
|
+
if (onlyAssignedToMe) {
|
|
153
|
+
console.log(`客户端过滤:只保留分配给 ${this.config.username} 的Bug`);
|
|
154
|
+
bugs = bugs.filter(bug => {
|
|
155
|
+
// assignedTo可能是对象或字符串
|
|
156
|
+
if (typeof bug.assignedTo === 'object' && bug.assignedTo !== null) {
|
|
157
|
+
return bug.assignedTo.account === this.config.username;
|
|
158
|
+
}
|
|
159
|
+
else if (typeof bug.assignedTo === 'string') {
|
|
160
|
+
return bug.assignedTo === this.config.username;
|
|
161
|
+
}
|
|
162
|
+
return false;
|
|
163
|
+
});
|
|
164
|
+
console.log(`过滤后剩余 ${bugs.length} 个Bug`);
|
|
158
165
|
}
|
|
159
|
-
|
|
166
|
+
// 应用分页
|
|
167
|
+
const start = (finalPage - 1) * finalLimit;
|
|
168
|
+
const paginatedBugs = bugs.slice(start, start + finalLimit);
|
|
169
|
+
return {
|
|
170
|
+
page: finalPage,
|
|
171
|
+
total: bugs.length,
|
|
172
|
+
limit: finalLimit,
|
|
173
|
+
bugs: paginatedBugs
|
|
174
|
+
};
|
|
160
175
|
}
|
|
161
176
|
catch (error) {
|
|
162
177
|
if (error instanceof Error && error.message.includes('Need product id')) {
|
|
@@ -249,9 +264,10 @@ export class ZentaoAPI {
|
|
|
249
264
|
async resolveBug(bugId, resolution) {
|
|
250
265
|
try {
|
|
251
266
|
console.log(`正在解决Bug ${bugId}...`);
|
|
252
|
-
//
|
|
267
|
+
// 验证必填字段并设置默认值
|
|
253
268
|
if (resolution.resolution === 'fixed' && !resolution.resolvedBuild) {
|
|
254
|
-
|
|
269
|
+
console.log('解决方案为"fixed"时未提供resolvedBuild,自动设置为"trunk"');
|
|
270
|
+
resolution.resolvedBuild = 'trunk';
|
|
255
271
|
}
|
|
256
272
|
if (resolution.resolution === 'duplicate' && !resolution.duplicateBug) {
|
|
257
273
|
throw new Error('当解决方案为"重复Bug(duplicate)"时,必须提供重复Bug的ID(duplicateBug)');
|
package/dist/types/zentao.d.ts
CHANGED
|
@@ -40,6 +40,13 @@ export interface Bug {
|
|
|
40
40
|
days_open?: number;
|
|
41
41
|
aging_status?: string;
|
|
42
42
|
aging_description?: string;
|
|
43
|
+
assignedTo?: any;
|
|
44
|
+
openedBy?: any;
|
|
45
|
+
resolvedBy?: any;
|
|
46
|
+
product?: number;
|
|
47
|
+
module?: number;
|
|
48
|
+
pri?: number;
|
|
49
|
+
type?: string;
|
|
43
50
|
}
|
|
44
51
|
export interface TaskUpdate {
|
|
45
52
|
consumed?: number;
|