@zzp123/mcp-zentao 1.15.0 → 1.17.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 CHANGED
@@ -5,6 +5,61 @@ 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.17.0] - 2025-11-10
9
+
10
+ ### Added
11
+ - **角色专用版本** 🎭
12
+ - 新增三个角色专用的精简版本,大幅减少上下文占用
13
+ - `zentao-pm`: 产品经理版本(54个工具,文件减小32%)
14
+ - `zentao-qa`: 测试工程师版本(38个工具,文件减小45%)
15
+ - `zentao-dev`: 开发工程师版本(46个工具,文件减小44%)
16
+ - `zentao`: 完整版本(94个工具,所有功能)
17
+
18
+ ### Changed
19
+ - **优化上下文使用** 📊
20
+ - 每个角色版本只包含相关工具,显著降低 LLM 上下文消耗
21
+ - 产品经理版本:需求、产品、计划、反馈等管理工具
22
+ - 测试工程师版本:Bug、测试用例、构建版本等测试工具
23
+ - 开发工程师版本:任务、项目、执行、Bug解决等开发工具
24
+
25
+ ### Technical
26
+ - 新增角色版本源文件:`src/index-pm.ts`, `src/index-qa.ts`, `src/index-dev.ts`
27
+ - 新增角色配置模块:`src/roleConfig.ts`
28
+ - 新增生成脚本:`generate-role-versions.cjs`
29
+ - 更新 package.json 支持多个 bin 入口点
30
+
31
+ ### Documentation
32
+ - 新增角色分类文档:`ROLES.md`
33
+ - 新增角色配置指南:`ROLE_GUIDE.md`
34
+
35
+ ## [1.16.0] - 2025-11-07
36
+
37
+ ### Fixed
38
+ - **修复评论功能 - 使用正确的 REST API v1 接口** 🔧
39
+ - 之前版本使用的是 HTML 接口,现已改用标准 REST API
40
+ - 修复了评论创建、更新、删除等功能
41
+
42
+ ### Added
43
+ - **完整的评论管理工具** 💬
44
+ - `getComments`: 获取指定对象的评论列表
45
+ - `getCommentDetail`: 获取单条评论详情
46
+ - `addComment`: 创建评论(支持11种对象类型)
47
+ - `updateComment`: 更新评论内容
48
+ - `deleteComment`: 删除评论
49
+ - 便捷工具:`addStoryComment`、`addTaskComment`、`addBugComment`
50
+
51
+ ### Changed
52
+ - **更新评论接口实现**
53
+ - 使用标准 REST API:`POST /comment`、`GET /comments/{type}/{id}`
54
+ - 支持更多对象类型:新增 execution、project 类型
55
+ - 返回完整的评论对象信息(包含 id、actor、date 等)
56
+
57
+ ### Technical
58
+ - 更新 `Comment` 接口定义
59
+ - 添加 `UpdateCommentRequest` 接口
60
+ - 添加 `CommentListResponse` 接口
61
+ - 所有评论方法使用统一的 `request()` 方法,保持 Token 认证
62
+
8
63
  ## [1.15.0] - 2025-11-07
9
64
 
10
65
  ### Added
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![npm version](https://badge.fury.io/js/%40zzp123%2Fmcp-zentao.svg)](https://www.npmjs.com/package/@zzp123/mcp-zentao)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
 
6
- 禅道项目管理系统的高级API集成包,提供任务管理、Bug跟踪等功能的完整封装,专为Cursor IDE设计的MCP扩展。
6
+ 禅道项目管理系统的高级API集成包,提供任务管理、Bug跟踪等功能的完整封装,专为Cursor IDE设计的MCP扩展。**支持产品经理、测试工程师、开发工程师三种角色的精简版本,大幅减少上下文占用。**
7
7
 
8
8
  ## 📦 安装
9
9
 
@@ -11,21 +11,92 @@
11
11
  npm install @zzp123/mcp-zentao -g
12
12
  ```
13
13
 
14
+ ## 🎭 角色版本选择
15
+
16
+ 从 v1.17.0 开始,提供了三个角色专用的精简版本,每个版本只包含对应角色常用的工具,**可显著减少 LLM 上下文占用 30-45%**:
17
+
18
+ | 版本 | 命令 | 工具数量 | 文件大小 | 适用角色 |
19
+ |------|------|---------|---------|---------|
20
+ | **完整版** | `zentao` | 94个 | 69 KB | 需要使用全部功能 |
21
+ | **产品经理版** | `zentao-pm` | 54个 | 47 KB (-32%) | 需求、产品、计划管理 |
22
+ | **测试工程师版** | `zentao-qa` | 38个 | 38 KB (-45%) | Bug、测试用例、构建 |
23
+ | **开发工程师版** | `zentao-dev` | 46个 | 39 KB (-44%) | 任务、项目、Bug解决 |
24
+
25
+ ### 如何选择版本?
26
+
27
+ 在 Claude Desktop 配置文件中,将 `command` 字段改为对应的命令即可:
28
+
29
+ ```json
30
+ {
31
+ "mcpServers": {
32
+ "zentao-pm": {
33
+ "command": "zentao-pm",
34
+ "args": []
35
+ }
36
+ }
37
+ }
38
+ ```
39
+
40
+ ### 各版本包含的功能
41
+
42
+ <details>
43
+ <summary><b>产品经理版 (zentao-pm)</b> - 点击展开</summary>
44
+
45
+ - ✅ 初始化配置
46
+ - ✅ 需求管理(创建、查看、修改、删除)
47
+ - ✅ 产品管理
48
+ - ✅ 计划管理
49
+ - ✅ 项目集管理
50
+ - ✅ 反馈管理
51
+ - ✅ Bug查看(只读)
52
+ - ✅ 任务查看(只读)
53
+ - ✅ 评论功能
54
+ - ✅ 工单管理
55
+ - ✅ 文件上传
56
+ </details>
57
+
58
+ <details>
59
+ <summary><b>测试工程师版 (zentao-qa)</b> - 点击展开</summary>
60
+
61
+ - ✅ 初始化配置
62
+ - ✅ Bug管理(创建、查看、修改、解决、删除)
63
+ - ✅ 测试用例管理
64
+ - ✅ 构建版本管理
65
+ - ✅ 需求查看(只读)
66
+ - ✅ 任务查看(只读)
67
+ - ✅ 评论功能
68
+ - ✅ 工单管理
69
+ - ✅ 文件上传
70
+ </details>
71
+
72
+ <details>
73
+ <summary><b>开发工程师版 (zentao-dev)</b> - 点击展开</summary>
74
+
75
+ - ✅ 初始化配置
76
+ - ✅ 任务管理(创建、查看、更新、完成、删除)
77
+ - ✅ Bug解决(查看、解决、评论)
78
+ - ✅ 项目管理
79
+ - ✅ 执行管理
80
+ - ✅ 构建版本管理
81
+ - ✅ 需求查看(只读)
82
+ - ✅ 评论功能
83
+ - ✅ 工单管理
84
+ - ✅ 文件上传
85
+ </details>
86
+
14
87
  ## 📋 版本历史
15
88
 
16
89
  查看完整的版本更新历史,请访问 [CHANGELOG.md](./CHANGELOG.md)
17
90
 
18
- **最新版本**: v1.9.0
19
- - 修复 getMyBugs 工具的过滤逻辑问题
20
- - 改为客户端过滤,正确获取当前用户的bug
21
- - 支持 assignedTo 的对象和字符串两种格式
91
+ **最新版本**: v1.17.0 - 2025-11-10
92
+ - 🎭 新增三个角色专用版本(PM/QA/Dev)
93
+ - 📊 大幅减少上下文占用(30-45%)
94
+ - 🚀 提升 LLM 响应速度和准确性
22
95
 
23
96
  **近期版本**:
24
- - v1.8.9 - 修复 resolveBug 工具自动设置默认 resolvedBuild
25
- - v1.8.8 - 修复 getMyBugs 工具返回Bug数量为0的问题
26
- - v1.6.1 - 修复 Windows 剪贴板图片读取问题
27
- - v1.4.0 - 新增解决Bug接口
28
- - v1.3.0 - 添加命令行脚本支持
97
+ - v1.16.0 - 修复评论功能,使用正确的 REST API v1 接口
98
+ - v1.15.0 - 新增完整的评论管理工具
99
+ - v1.9.0 - 修复 getMyBugs 工具的过滤逻辑问题
29
100
 
30
101
  ## 使用方法
31
102
 
@@ -1,4 +1,4 @@
1
- import { AssignFeedbackRequest, Bug, BugStatus, Build, CloseFeedbackRequest, CreateBuildRequest, CreateBugRequest, CreateExecutionRequest, CreateFeedbackRequest, CreatePlanRequest, CreateProductRequest, CreateProgramRequest, CreateProjectRequest, CreateStoryRequest, CreateTaskRequest, CreateTestCaseRequest, CreateTicketRequest, CreateUserRequest, Execution, Feedback, FileUploadResponse, ModulesResponse, ModuleType, Plan, Product, Program, Project, Release, ResolveBugRequest, Story, Task, TaskStatus, TaskUpdate, TestCase, Ticket, UpdateBuildRequest, UpdateBugRequest, UpdateExecutionRequest, UpdateFeedbackRequest, UpdatePlanRequest, UpdateProductRequest, UpdateProgramRequest, UpdateProjectRequest, ChangeStoryRequest, UpdateTestCaseRequest, UpdateTicketRequest, UpdateUserRequest, UploadFileRequest, UserDetail, ZentaoConfig } from '../types/zentao';
1
+ import { AddCommentRequest, AssignFeedbackRequest, Bug, BugStatus, Build, CloseFeedbackRequest, Comment, CommentObjectType, CreateBuildRequest, CreateBugRequest, CreateExecutionRequest, CreateFeedbackRequest, CreatePlanRequest, CreateProductRequest, CreateProgramRequest, CreateProjectRequest, CreateStoryRequest, CreateTaskRequest, CreateTestCaseRequest, CreateTicketRequest, CreateUserRequest, Execution, Feedback, FileUploadResponse, ModulesResponse, ModuleType, Plan, Product, Program, Project, Release, ResolveBugRequest, Story, Task, TaskStatus, TaskUpdate, TestCase, Ticket, UpdateBuildRequest, UpdateBugRequest, UpdateCommentRequest, UpdateExecutionRequest, UpdateFeedbackRequest, UpdatePlanRequest, UpdateProductRequest, UpdateProgramRequest, UpdateProjectRequest, ChangeStoryRequest, UpdateTestCaseRequest, UpdateTicketRequest, UpdateUserRequest, UploadFileRequest, UserDetail, ZentaoConfig } from '../types/zentao';
2
2
  export declare class ZentaoAPI {
3
3
  private config;
4
4
  private client;
@@ -239,6 +239,32 @@ export declare class ZentaoAPI {
239
239
  getModules(type: ModuleType, id: number, fields?: string): Promise<ModulesResponse>;
240
240
  uploadFile(uploadRequest: UploadFileRequest): Promise<FileUploadResponse>;
241
241
  downloadFile(fileId: number): Promise<Buffer>;
242
- addComment(objectType: string, objectID: number, comment: string): Promise<any>;
242
+ /**
243
+ * 获取评论列表
244
+ * GET /comments/{objectType}/{objectID}
245
+ */
246
+ getComments(objectType: CommentObjectType, objectID: number): Promise<Comment[]>;
247
+ /**
248
+ * 获取单条评论详情
249
+ * GET /comment/{id}
250
+ */
251
+ getCommentDetail(commentId: number): Promise<Comment>;
252
+ /**
253
+ * 创建评论
254
+ * POST /comment
255
+ */
256
+ addComment(request: AddCommentRequest): Promise<Comment>;
257
+ /**
258
+ * 更新评论
259
+ * PUT /comment/{id}
260
+ */
261
+ updateComment(commentId: number, update: UpdateCommentRequest): Promise<Comment>;
262
+ /**
263
+ * 删除评论
264
+ * DELETE /comment/{id}
265
+ */
266
+ deleteComment(commentId: number): Promise<{
267
+ message: string;
268
+ }>;
243
269
  getConfig(): ZentaoConfig;
244
270
  }
@@ -1534,63 +1534,87 @@ export class ZentaoAPI {
1534
1534
  throw error;
1535
1535
  }
1536
1536
  }
1537
- // 评论模块 - 使用 HTML 接口
1538
- async addComment(objectType, objectID, comment) {
1537
+ // 评论模块 - 使用 REST API v1 接口
1538
+ /**
1539
+ * 获取评论列表
1540
+ * GET /comments/{objectType}/{objectID}
1541
+ */
1542
+ async getComments(objectType, objectID) {
1539
1543
  try {
1540
- console.log(`正在为 ${objectType} ${objectID} 添加评论...`);
1541
- const token = await this.getToken();
1542
- const htmlUrl = `${this.config.url}/zentao/action-comment-${objectType}-${objectID}.html`;
1543
- // 使用 form-urlencoded 格式发送数据
1544
- const formData = new URLSearchParams();
1545
- formData.append('actioncomment', comment);
1546
- const response = await axios.post(htmlUrl, formData.toString(), {
1547
- headers: {
1548
- 'Content-Type': 'application/x-www-form-urlencoded',
1549
- 'Token': token
1550
- },
1551
- timeout: 10000
1552
- });
1553
- console.log('添加评论响应:', response.data);
1554
- // 返回统一格式
1555
- if (response.data && typeof response.data === 'object') {
1556
- // 如果是 JSON 响应(API 模式)
1557
- if (response.data.status === 'success' || response.data.result === 'success') {
1558
- return {
1559
- status: 'success',
1560
- actionID: response.data.data || response.data.actionID,
1561
- message: '评论添加成功'
1562
- };
1563
- }
1564
- else if (response.data.result === 'fail' || response.data.status === 'fail') {
1565
- throw new Error(response.data.message || '评论添加失败');
1566
- }
1567
- }
1568
- // 如果返回的是 HTML 或其他格式,认为成功
1569
- return {
1570
- status: 'success',
1571
- message: '评论添加成功'
1572
- };
1544
+ console.log(`正在获取 ${objectType} ${objectID} 的评论列表...`);
1545
+ const response = await this.request('GET', `/comments/${objectType}/${objectID}`);
1546
+ console.log('获取评论列表响应:', response);
1547
+ return response;
1548
+ }
1549
+ catch (error) {
1550
+ console.error('获取评论列表失败:', error);
1551
+ throw error;
1552
+ }
1553
+ }
1554
+ /**
1555
+ * 获取单条评论详情
1556
+ * GET /comment/{id}
1557
+ */
1558
+ async getCommentDetail(commentId) {
1559
+ try {
1560
+ console.log(`正在获取评论 ${commentId} 的详情...`);
1561
+ const response = await this.request('GET', `/comment/${commentId}`);
1562
+ console.log('获取评论详情响应:', response);
1563
+ return response;
1564
+ }
1565
+ catch (error) {
1566
+ console.error('获取评论详情失败:', error);
1567
+ throw error;
1568
+ }
1569
+ }
1570
+ /**
1571
+ * 创建评论
1572
+ * POST /comment
1573
+ */
1574
+ async addComment(request) {
1575
+ try {
1576
+ console.log(`正在为 ${request.objectType} ${request.objectID} 添加评论...`);
1577
+ const response = await this.request('POST', '/comment', undefined, request);
1578
+ console.log('添加评论响应:', response);
1579
+ return response;
1573
1580
  }
1574
1581
  catch (error) {
1575
- if (axios.isAxiosError(error)) {
1576
- console.error('添加评论失败:', {
1577
- status: error.response?.status,
1578
- data: error.response?.data,
1579
- message: error.message
1580
- });
1581
- // 尝试解析错误消息
1582
- if (error.response?.data) {
1583
- const errorData = error.response.data;
1584
- if (typeof errorData === 'object' && errorData.message) {
1585
- throw new Error(`添加评论失败: ${errorData.message}`);
1586
- }
1587
- }
1588
- throw new Error(`添加评论失败: ${error.message}`);
1589
- }
1590
1582
  console.error('添加评论失败:', error);
1591
1583
  throw error;
1592
1584
  }
1593
1585
  }
1586
+ /**
1587
+ * 更新评论
1588
+ * PUT /comment/{id}
1589
+ */
1590
+ async updateComment(commentId, update) {
1591
+ try {
1592
+ console.log(`正在更新评论 ${commentId}...`);
1593
+ const response = await this.request('PUT', `/comment/${commentId}`, undefined, update);
1594
+ console.log('更新评论响应:', response);
1595
+ return response;
1596
+ }
1597
+ catch (error) {
1598
+ console.error('更新评论失败:', error);
1599
+ throw error;
1600
+ }
1601
+ }
1602
+ /**
1603
+ * 删除评论
1604
+ * DELETE /comment/{id}
1605
+ */
1606
+ async deleteComment(commentId) {
1607
+ try {
1608
+ console.log(`正在删除评论 ${commentId}...`);
1609
+ const response = await this.request('DELETE', `/comment/${commentId}`);
1610
+ console.log('删除评论响应:', response);
1611
+ return response;
1612
+ }
1613
+ catch (error) {
1614
+ console.error('删除评论失败:', error);
1615
+ throw error;
1616
+ }
1617
+ }
1594
1618
  // 获取配置信息(用于生成图片 URL)
1595
1619
  getConfig() {
1596
1620
  return this.config;
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { ZentaoConfig } from './config.js';
3
+ interface UserParams {
4
+ config?: ZentaoConfig;
5
+ name: string;
6
+ age: number;
7
+ skills: string[];
8
+ }
9
+ export default function main(params: UserParams): Promise<void>;
10
+ export {};