@cnbcool/mcp-server 0.4.2 → 0.4.3
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/dist/api/client.js +4 -1
- package/dist/api/group.js +18 -9
- package/dist/api/issue.js +42 -25
- package/dist/api/pull.js +27 -15
- package/dist/api/repository.js +18 -9
- package/dist/api/user.js +9 -3
- package/dist/api/workspace.js +12 -5
- package/dist/helpers/createMcpServer.js +10 -8
- package/dist/helpers/formatToolResult.js +6 -2
- package/dist/helpers/sendResponse.js +4 -1
- package/dist/stdio.js +11 -6
- package/dist/streamable.js +26 -21
- package/dist/tools/groupTools.js +34 -31
- package/dist/tools/index.js +19 -13
- package/dist/tools/issueTools.js +112 -109
- package/dist/tools/pullTools.js +65 -62
- package/dist/tools/repoTools.js +56 -53
- package/dist/tools/workspaceTools.js +28 -25
- package/package.json +3 -4
package/dist/tools/index.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerTools = registerTools;
|
|
7
|
+
const client_js_1 = __importDefault(require("../api/client.js"));
|
|
8
|
+
const groupTools_js_1 = __importDefault(require("./groupTools.js"));
|
|
9
|
+
const repoTools_js_1 = __importDefault(require("./repoTools.js"));
|
|
10
|
+
const issueTools_js_1 = __importDefault(require("./issueTools.js"));
|
|
11
|
+
const workspaceTools_js_1 = __importDefault(require("./workspaceTools.js"));
|
|
12
|
+
const pullTools_js_1 = __importDefault(require("./pullTools.js"));
|
|
13
|
+
function registerTools(server, token) {
|
|
14
|
+
client_js_1.default.initialize({
|
|
9
15
|
baseUrl: process.env.API_BASE_URL || 'https://api.cnb.cool',
|
|
10
16
|
token: process.env.API_TOKEN || token || ''
|
|
11
17
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
(0, groupTools_js_1.default)(server);
|
|
19
|
+
(0, repoTools_js_1.default)(server);
|
|
20
|
+
(0, issueTools_js_1.default)(server);
|
|
21
|
+
(0, workspaceTools_js_1.default)(server);
|
|
22
|
+
(0, pullTools_js_1.default)(server);
|
|
17
23
|
}
|
package/dist/tools/issueTools.js
CHANGED
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = registerIssueTools;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const issue_js_1 = require("../api/issue.js");
|
|
6
|
+
const formatToolResult_js_1 = require("../helpers/formatToolResult.js");
|
|
7
|
+
function registerIssueTools(server) {
|
|
5
8
|
server.tool('list-issues', '查询仓库的 Issues', {
|
|
6
|
-
repo: z.string().describe('仓库路径'),
|
|
7
|
-
page: z.number().default(1).describe('第几页,从1开始'),
|
|
8
|
-
page_size: z.number().default(10).describe('每页多少条数据,默认是30'),
|
|
9
|
-
state: z
|
|
10
|
-
.preprocess((val) => (val === null ? undefined : val), z.enum(['open', 'closed']).optional())
|
|
9
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
10
|
+
page: zod_1.z.number().default(1).describe('第几页,从1开始'),
|
|
11
|
+
page_size: zod_1.z.number().default(10).describe('每页多少条数据,默认是30'),
|
|
12
|
+
state: zod_1.z
|
|
13
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['open', 'closed']).optional())
|
|
11
14
|
.describe('Issue 状态'),
|
|
12
|
-
keyword: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 关键字'),
|
|
13
|
-
priority: z
|
|
14
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
15
|
+
keyword: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Issue 关键字'),
|
|
16
|
+
priority: zod_1.z
|
|
17
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
15
18
|
.describe('Issue 优先级,example: p0,p1,p2,p3'),
|
|
16
|
-
labels: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 标签'),
|
|
17
|
-
authors: z
|
|
18
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
19
|
+
labels: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Issue 标签'),
|
|
20
|
+
authors: zod_1.z
|
|
21
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
19
22
|
.describe('Issue 作者的名字, example: 张三,李四'),
|
|
20
|
-
assignees: z
|
|
21
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
23
|
+
assignees: zod_1.z
|
|
24
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
22
25
|
.describe('Issue 处理人,example: 张三,李四,-; - means assign to nobody'),
|
|
23
|
-
updated_time_begin: z
|
|
24
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
26
|
+
updated_time_begin: zod_1.z
|
|
27
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
25
28
|
.describe('Issue 更新时间的范围,开始时间点,example: 2022-01-31'),
|
|
26
|
-
updated_time_end: z
|
|
27
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
29
|
+
updated_time_end: zod_1.z
|
|
30
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
28
31
|
.describe('Issue 更新时间的范围,结束时间点,example: 2022-01-31'),
|
|
29
|
-
order_by: z
|
|
30
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
32
|
+
order_by: zod_1.z
|
|
33
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
31
34
|
.describe('Issue 排序顺序.example: created_at, -updated_at, reference_count。‘-’ prefix means descending order')
|
|
32
35
|
}, async ({ repo, page, page_size, state, keyword, priority, labels, authors, assignees, updated_time_begin, updated_time_end, order_by }) => {
|
|
33
36
|
try {
|
|
34
|
-
const issues = await listIssues(repo, {
|
|
37
|
+
const issues = await (0, issue_js_1.listIssues)(repo, {
|
|
35
38
|
page,
|
|
36
39
|
page_size,
|
|
37
40
|
state,
|
|
@@ -44,44 +47,44 @@ export default function registerIssueTools(server) {
|
|
|
44
47
|
updated_time_end,
|
|
45
48
|
order_by
|
|
46
49
|
});
|
|
47
|
-
return formatTextToolResult(JSON.stringify(issues, null, 2), 'list-issues');
|
|
50
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(issues, null, 2), 'list-issues');
|
|
48
51
|
}
|
|
49
52
|
catch (error) {
|
|
50
|
-
return formatToolError(error, 'list-issues');
|
|
53
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'list-issues');
|
|
51
54
|
}
|
|
52
55
|
});
|
|
53
56
|
server.tool('get-issue', '获取指定 Issue 信息', {
|
|
54
|
-
repo: z.string().describe('仓库路径'),
|
|
55
|
-
issueId: z.number().describe('Issue ID')
|
|
57
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
58
|
+
issueId: zod_1.z.number().describe('Issue ID')
|
|
56
59
|
}, async ({ repo, issueId }) => {
|
|
57
60
|
try {
|
|
58
|
-
const issues = await getIssue(repo, issueId);
|
|
59
|
-
return formatTextToolResult(JSON.stringify(issues, null, 2), 'get-issue');
|
|
61
|
+
const issues = await (0, issue_js_1.getIssue)(repo, issueId);
|
|
62
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(issues, null, 2), 'get-issue');
|
|
60
63
|
}
|
|
61
64
|
catch (error) {
|
|
62
|
-
return formatToolError(error, 'get-issue');
|
|
65
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'get-issue');
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
68
|
server.tool('create-issue', '创建一个 Issue. 如需添加 Issue 标签,需要另外调用 add-issue-labels', {
|
|
66
|
-
repo: z.string().describe('仓库路径'),
|
|
67
|
-
title: z.string().describe('Issue 标题'),
|
|
68
|
-
body: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 描述'),
|
|
69
|
-
assignees: z
|
|
70
|
-
.preprocess((val) => (val === null ? undefined : val), z.array(z.string()).optional())
|
|
69
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
70
|
+
title: zod_1.z.string().describe('Issue 标题'),
|
|
71
|
+
body: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Issue 描述'),
|
|
72
|
+
assignees: zod_1.z
|
|
73
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.array(zod_1.z.string()).optional())
|
|
71
74
|
.describe('一个或多个 Issue 处理人的用户名'),
|
|
72
|
-
labels: z
|
|
73
|
-
.preprocess((val) => (val === null ? undefined : val), z.array(z.string()).optional())
|
|
75
|
+
labels: zod_1.z
|
|
76
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.array(zod_1.z.string()).optional())
|
|
74
77
|
.describe('一个或多个 Issue 标签'),
|
|
75
|
-
priority: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 优先级'),
|
|
76
|
-
end_date: z
|
|
77
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
78
|
+
priority: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Issue 优先级'),
|
|
79
|
+
end_date: zod_1.z
|
|
80
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
78
81
|
.describe('Issue 截止时间,格式为 YYYY-MM-DD'),
|
|
79
|
-
start_date: z
|
|
80
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
82
|
+
start_date: zod_1.z
|
|
83
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
81
84
|
.describe('Issue 起始时间,格式为 YYYY-MM-DD')
|
|
82
85
|
}, async ({ repo, title, body, assignees, labels, priority, end_date, start_date }) => {
|
|
83
86
|
try {
|
|
84
|
-
const issue = await createIssue(repo, {
|
|
87
|
+
const issue = await (0, issue_js_1.createIssue)(repo, {
|
|
85
88
|
title,
|
|
86
89
|
body,
|
|
87
90
|
assignees,
|
|
@@ -90,31 +93,31 @@ export default function registerIssueTools(server) {
|
|
|
90
93
|
end_date,
|
|
91
94
|
start_date
|
|
92
95
|
});
|
|
93
|
-
return formatTextToolResult(JSON.stringify(issue, null, 2), 'create-issue');
|
|
96
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(issue, null, 2), 'create-issue');
|
|
94
97
|
}
|
|
95
98
|
catch (error) {
|
|
96
|
-
return formatToolError(error, 'create-issue');
|
|
99
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'create-issue');
|
|
97
100
|
}
|
|
98
101
|
});
|
|
99
102
|
server.tool('update-issue', '更新一个 Issue。 如需更新 Issue 标签,需要另外调用 set-issue-labels', {
|
|
100
|
-
repo: z.string().describe('仓库路径'),
|
|
101
|
-
issueId: z.number().describe('Issue ID'),
|
|
102
|
-
title: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 标题'),
|
|
103
|
-
body: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 描述'),
|
|
104
|
-
priority: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 优先级'),
|
|
105
|
-
end_date: z
|
|
106
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
103
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
104
|
+
issueId: zod_1.z.number().describe('Issue ID'),
|
|
105
|
+
title: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Issue 标题'),
|
|
106
|
+
body: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Issue 描述'),
|
|
107
|
+
priority: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Issue 优先级'),
|
|
108
|
+
end_date: zod_1.z
|
|
109
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
107
110
|
.describe('Issue 截止时间,格式为 YYYY-MM-DD'),
|
|
108
|
-
start_date: z
|
|
109
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
111
|
+
start_date: zod_1.z
|
|
112
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
110
113
|
.describe('Issue 起始时间,格式为 YYYY-MM-DD'),
|
|
111
|
-
state: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 状态'),
|
|
112
|
-
state_reason: z
|
|
113
|
-
.preprocess((val) => (val === null ? undefined : val), z.enum(['completed', 'not_planned', 'reopened']).optional())
|
|
114
|
+
state: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('Issue 状态'),
|
|
115
|
+
state_reason: zod_1.z
|
|
116
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['completed', 'not_planned', 'reopened']).optional())
|
|
114
117
|
.describe('Issue 状态原因')
|
|
115
118
|
}, async ({ repo, issueId, title, body, priority, end_date, start_date, state, state_reason }) => {
|
|
116
119
|
try {
|
|
117
|
-
const issue = await updateIssue(repo, issueId, {
|
|
120
|
+
const issue = await (0, issue_js_1.updateIssue)(repo, issueId, {
|
|
118
121
|
title,
|
|
119
122
|
body,
|
|
120
123
|
priority,
|
|
@@ -123,114 +126,114 @@ export default function registerIssueTools(server) {
|
|
|
123
126
|
state,
|
|
124
127
|
state_reason
|
|
125
128
|
});
|
|
126
|
-
return formatTextToolResult(JSON.stringify(issue, null, 2), 'update-issue');
|
|
129
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(issue, null, 2), 'update-issue');
|
|
127
130
|
}
|
|
128
131
|
catch (error) {
|
|
129
|
-
return formatToolError(error, 'update-issue');
|
|
132
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'update-issue');
|
|
130
133
|
}
|
|
131
134
|
});
|
|
132
135
|
server.tool('list-issue-comments', '查询 Issue 评论列表', {
|
|
133
|
-
repo: z.string().describe('仓库路径'),
|
|
134
|
-
issueId: z.number().describe('Issue ID'),
|
|
135
|
-
page: z.number().default(1).describe('第几页,从1开始'),
|
|
136
|
-
page_size: z.number().default(30).describe('每页多少条数据,默认是30')
|
|
136
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
137
|
+
issueId: zod_1.z.number().describe('Issue ID'),
|
|
138
|
+
page: zod_1.z.number().default(1).describe('第几页,从1开始'),
|
|
139
|
+
page_size: zod_1.z.number().default(30).describe('每页多少条数据,默认是30')
|
|
137
140
|
}, async ({ repo, issueId, page, page_size }) => {
|
|
138
141
|
try {
|
|
139
|
-
const comments = await listIssueComments(repo, issueId, { page, page_size });
|
|
140
|
-
return formatTextToolResult(JSON.stringify(comments, null, 2), 'list-issue-comments');
|
|
142
|
+
const comments = await (0, issue_js_1.listIssueComments)(repo, issueId, { page, page_size });
|
|
143
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(comments, null, 2), 'list-issue-comments');
|
|
141
144
|
}
|
|
142
145
|
catch (error) {
|
|
143
|
-
return formatToolError(error, 'list-issue-comments');
|
|
146
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'list-issue-comments');
|
|
144
147
|
}
|
|
145
148
|
});
|
|
146
149
|
server.tool('create-issue-comment', '创建一个 Issue 评论', {
|
|
147
|
-
repo: z.string().describe('仓库路径'),
|
|
148
|
-
issueId: z.number().describe('Issue ID'),
|
|
149
|
-
body: z.string().describe('评论内容')
|
|
150
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
151
|
+
issueId: zod_1.z.number().describe('Issue ID'),
|
|
152
|
+
body: zod_1.z.string().describe('评论内容')
|
|
150
153
|
}, async ({ repo, issueId, body }) => {
|
|
151
154
|
try {
|
|
152
|
-
const comment = await createIssueComment(repo, issueId, { body });
|
|
153
|
-
return formatTextToolResult(JSON.stringify(comment, null, 2), 'create-issue-comment');
|
|
155
|
+
const comment = await (0, issue_js_1.createIssueComment)(repo, issueId, { body });
|
|
156
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(comment, null, 2), 'create-issue-comment');
|
|
154
157
|
}
|
|
155
158
|
catch (error) {
|
|
156
|
-
return formatToolError(error, 'create-issue-comment');
|
|
159
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'create-issue-comment');
|
|
157
160
|
}
|
|
158
161
|
});
|
|
159
162
|
server.tool('update-issue-comment', '更新一个 Issue 评论', {
|
|
160
|
-
repo: z.string().describe('仓库路径'),
|
|
161
|
-
issueId: z.number().describe('Issue ID'),
|
|
162
|
-
commentId: z.string().describe('评论 ID'),
|
|
163
|
-
body: z.string().describe('评论内容')
|
|
163
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
164
|
+
issueId: zod_1.z.number().describe('Issue ID'),
|
|
165
|
+
commentId: zod_1.z.string().describe('评论 ID'),
|
|
166
|
+
body: zod_1.z.string().describe('评论内容')
|
|
164
167
|
}, async ({ repo, issueId, commentId, body }) => {
|
|
165
168
|
try {
|
|
166
|
-
const comment = await updateIssueComment(repo, issueId, commentId, { body });
|
|
167
|
-
return formatTextToolResult(JSON.stringify(comment, null, 2), 'update-issue-comment');
|
|
169
|
+
const comment = await (0, issue_js_1.updateIssueComment)(repo, issueId, commentId, { body });
|
|
170
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(comment, null, 2), 'update-issue-comment');
|
|
168
171
|
}
|
|
169
172
|
catch (error) {
|
|
170
|
-
return formatToolError(error, 'update-issue-comment');
|
|
173
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'update-issue-comment');
|
|
171
174
|
}
|
|
172
175
|
});
|
|
173
176
|
server.tool('list-issue-labels', '查询指定Issue的标签', {
|
|
174
|
-
repo: z.string().describe('仓库路径'),
|
|
175
|
-
issueId: z.number().describe('Issue ID')
|
|
177
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
178
|
+
issueId: zod_1.z.number().describe('Issue ID')
|
|
176
179
|
}, async ({ repo, issueId }) => {
|
|
177
180
|
try {
|
|
178
|
-
const labels = await listIssueLabels(repo, issueId);
|
|
179
|
-
return formatTextToolResult(JSON.stringify(labels, null, 2), 'list-issue-labels');
|
|
181
|
+
const labels = await (0, issue_js_1.listIssueLabels)(repo, issueId);
|
|
182
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(labels, null, 2), 'list-issue-labels');
|
|
180
183
|
}
|
|
181
184
|
catch (error) {
|
|
182
|
-
return formatToolError(error, 'list-issue-labels');
|
|
185
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'list-issue-labels');
|
|
183
186
|
}
|
|
184
187
|
});
|
|
185
188
|
server.tool('add-issue-labels', '为指定Issue添加标签', {
|
|
186
|
-
repo: z.string().describe('仓库路径'),
|
|
187
|
-
issueId: z.number().describe('Issue ID'),
|
|
188
|
-
labels: z.array(z.string()).describe('要添加的标签列表,每个标签需要从仓库标签列表中选择')
|
|
189
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
190
|
+
issueId: zod_1.z.number().describe('Issue ID'),
|
|
191
|
+
labels: zod_1.z.array(zod_1.z.string()).describe('要添加的标签列表,每个标签需要从仓库标签列表中选择')
|
|
189
192
|
}, async ({ repo, issueId, labels }) => {
|
|
190
193
|
try {
|
|
191
|
-
const result = await addIssueLabels(repo, issueId, labels);
|
|
192
|
-
return formatTextToolResult(JSON.stringify(result, null, 2), 'add-issue-labels');
|
|
194
|
+
const result = await (0, issue_js_1.addIssueLabels)(repo, issueId, labels);
|
|
195
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), 'add-issue-labels');
|
|
193
196
|
}
|
|
194
197
|
catch (error) {
|
|
195
|
-
return formatToolError(error, 'add-issue-labels');
|
|
198
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'add-issue-labels');
|
|
196
199
|
}
|
|
197
200
|
});
|
|
198
201
|
server.tool('set-issue-labels', '设置Issue的标签(替换所有现有标签)', {
|
|
199
|
-
repo: z.string().describe('仓库路径'),
|
|
200
|
-
issueId: z.number().describe('Issue ID'),
|
|
201
|
-
labels: z.array(z.string()).describe('新的标签列表(将替换所有现有标签),每个标签需要从仓库标签列表中选择')
|
|
202
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
203
|
+
issueId: zod_1.z.number().describe('Issue ID'),
|
|
204
|
+
labels: zod_1.z.array(zod_1.z.string()).describe('新的标签列表(将替换所有现有标签),每个标签需要从仓库标签列表中选择')
|
|
202
205
|
}, async ({ repo, issueId, labels }) => {
|
|
203
206
|
try {
|
|
204
|
-
const result = await setIssueLabels(repo, issueId, labels);
|
|
205
|
-
return formatTextToolResult(JSON.stringify(result, null, 2), 'set-issue-labels');
|
|
207
|
+
const result = await (0, issue_js_1.setIssueLabels)(repo, issueId, labels);
|
|
208
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), 'set-issue-labels');
|
|
206
209
|
}
|
|
207
210
|
catch (error) {
|
|
208
|
-
return formatToolError(error, 'set-issue-labels');
|
|
211
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'set-issue-labels');
|
|
209
212
|
}
|
|
210
213
|
});
|
|
211
214
|
server.tool('delete-issue-labels', '删除Issue的所有标签', {
|
|
212
|
-
repo: z.string().describe('仓库路径'),
|
|
213
|
-
issueId: z.number().describe('Issue ID')
|
|
215
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
216
|
+
issueId: zod_1.z.number().describe('Issue ID')
|
|
214
217
|
}, async ({ repo, issueId }) => {
|
|
215
218
|
try {
|
|
216
|
-
await deleteIssueLabels(repo, issueId);
|
|
217
|
-
return formatTextToolResult('All labels deleted', 'delete-issue-labels');
|
|
219
|
+
await (0, issue_js_1.deleteIssueLabels)(repo, issueId);
|
|
220
|
+
return (0, formatToolResult_js_1.formatTextToolResult)('All labels deleted', 'delete-issue-labels');
|
|
218
221
|
}
|
|
219
222
|
catch (error) {
|
|
220
|
-
return formatToolError(error, 'delete-issue-labels');
|
|
223
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'delete-issue-labels');
|
|
221
224
|
}
|
|
222
225
|
});
|
|
223
226
|
server.tool('delete-issue-label', '删除Issue的指定标签', {
|
|
224
|
-
repo: z.string().describe('仓库路径'),
|
|
225
|
-
issueId: z.number().describe('Issue ID'),
|
|
226
|
-
labelName: z.string().describe('要删除的标签名称')
|
|
227
|
+
repo: zod_1.z.string().describe('仓库路径'),
|
|
228
|
+
issueId: zod_1.z.number().describe('Issue ID'),
|
|
229
|
+
labelName: zod_1.z.string().describe('要删除的标签名称')
|
|
227
230
|
}, async ({ repo, issueId, labelName }) => {
|
|
228
231
|
try {
|
|
229
|
-
await deleteIssueLabel(repo, issueId, labelName);
|
|
230
|
-
return formatTextToolResult(`${labelName} deleted`, 'delete-issue-label');
|
|
232
|
+
await (0, issue_js_1.deleteIssueLabel)(repo, issueId, labelName);
|
|
233
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(`${labelName} deleted`, 'delete-issue-label');
|
|
231
234
|
}
|
|
232
235
|
catch (error) {
|
|
233
|
-
return formatToolError(error, 'delete-issue-label');
|
|
236
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'delete-issue-label');
|
|
234
237
|
}
|
|
235
238
|
});
|
|
236
239
|
}
|
package/dist/tools/pullTools.js
CHANGED
|
@@ -1,118 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = registerPullTools;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const pull_js_1 = require("../api/pull.js");
|
|
6
|
+
const formatToolResult_js_1 = require("../helpers/formatToolResult.js");
|
|
7
|
+
function registerPullTools(server) {
|
|
5
8
|
server.tool('list-pulls', '查询仓库的Pull Requests', {
|
|
6
|
-
repo: z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
7
|
-
state: z
|
|
8
|
-
.preprocess((val) => (val === null ? undefined : val), z.enum(['open', 'closed', 'all']).optional())
|
|
9
|
+
repo: zod_1.z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
10
|
+
state: zod_1.z
|
|
11
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['open', 'closed', 'all']).optional())
|
|
9
12
|
.describe('Pull Request状态'),
|
|
10
|
-
sort: z
|
|
11
|
-
.preprocess((val) => (val === null ? undefined : val), z.enum(['created', 'updated']).optional())
|
|
13
|
+
sort: zod_1.z
|
|
14
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['created', 'updated']).optional())
|
|
12
15
|
.describe('排序字段'),
|
|
13
|
-
direction: z
|
|
14
|
-
.preprocess((val) => (val === null ? undefined : val), z.enum(['asc', 'desc']).optional())
|
|
16
|
+
direction: zod_1.z
|
|
17
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['asc', 'desc']).optional())
|
|
15
18
|
.describe('排序方向'),
|
|
16
|
-
page: z.number().default(1).describe('页码'),
|
|
17
|
-
per_page: z.number().default(30).describe('每页数量')
|
|
19
|
+
page: zod_1.z.number().default(1).describe('页码'),
|
|
20
|
+
per_page: zod_1.z.number().default(30).describe('每页数量')
|
|
18
21
|
}, async ({ repo, ...params }) => {
|
|
19
22
|
try {
|
|
20
|
-
const pulls = await listPulls(repo, params);
|
|
21
|
-
return formatTextToolResult(JSON.stringify(pulls, null, 2), 'list-pulls');
|
|
23
|
+
const pulls = await (0, pull_js_1.listPulls)(repo, params);
|
|
24
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(pulls, null, 2), 'list-pulls');
|
|
22
25
|
}
|
|
23
26
|
catch (error) {
|
|
24
|
-
return formatToolError(error, 'list-pulls');
|
|
27
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'list-pulls');
|
|
25
28
|
}
|
|
26
29
|
});
|
|
27
30
|
server.tool('get-pull', '获取单个Pull Request详情', {
|
|
28
|
-
repo: z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
29
|
-
number: z.number().describe('Pull Request编号')
|
|
31
|
+
repo: zod_1.z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
32
|
+
number: zod_1.z.number().describe('Pull Request编号')
|
|
30
33
|
}, async ({ repo, number }) => {
|
|
31
34
|
try {
|
|
32
|
-
const pull = await getPull(repo, number);
|
|
33
|
-
return formatTextToolResult(JSON.stringify(pull, null, 2), 'get-pull');
|
|
35
|
+
const pull = await (0, pull_js_1.getPull)(repo, number);
|
|
36
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(pull, null, 2), 'get-pull');
|
|
34
37
|
}
|
|
35
38
|
catch (error) {
|
|
36
|
-
return formatToolError(error, 'get-pull');
|
|
39
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'get-pull');
|
|
37
40
|
}
|
|
38
41
|
});
|
|
39
42
|
server.tool('create-pull', '创建Pull Request', {
|
|
40
|
-
repo: z.string().describe('目标仓库路径,格式为 {group}/{repo}'),
|
|
41
|
-
base: z.string().describe('目标仓库目标分支'),
|
|
42
|
-
head_repo: z.string().optional().describe('来源仓库路径,格式为 {group}/{repo},不填则为目标仓库'),
|
|
43
|
-
head: z.string().describe('来源仓库分支'),
|
|
44
|
-
title: z.string().describe('标题'),
|
|
45
|
-
body: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('描述')
|
|
43
|
+
repo: zod_1.z.string().describe('目标仓库路径,格式为 {group}/{repo}'),
|
|
44
|
+
base: zod_1.z.string().describe('目标仓库目标分支'),
|
|
45
|
+
head_repo: zod_1.z.string().optional().describe('来源仓库路径,格式为 {group}/{repo},不填则为目标仓库'),
|
|
46
|
+
head: zod_1.z.string().describe('来源仓库分支'),
|
|
47
|
+
title: zod_1.z.string().describe('标题'),
|
|
48
|
+
body: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('描述')
|
|
46
49
|
}, async ({ repo, ...params }) => {
|
|
47
50
|
try {
|
|
48
|
-
const pull = await createPull(repo, params);
|
|
49
|
-
return formatTextToolResult(JSON.stringify(pull, null, 2), 'create-pull');
|
|
51
|
+
const pull = await (0, pull_js_1.createPull)(repo, params);
|
|
52
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(pull, null, 2), 'create-pull');
|
|
50
53
|
}
|
|
51
54
|
catch (error) {
|
|
52
|
-
return formatToolError(error, 'create-pull');
|
|
55
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'create-pull');
|
|
53
56
|
}
|
|
54
57
|
});
|
|
55
58
|
server.tool('update-pull', '更新Pull Request', {
|
|
56
|
-
repo: z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
57
|
-
number: z.number().describe('Pull Request编号'),
|
|
58
|
-
title: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('标题'),
|
|
59
|
-
body: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('描述'),
|
|
60
|
-
state: z
|
|
61
|
-
.preprocess((val) => (val === null ? undefined : val), z.enum(['open', 'closed']).optional())
|
|
59
|
+
repo: zod_1.z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
60
|
+
number: zod_1.z.number().describe('Pull Request编号'),
|
|
61
|
+
title: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('标题'),
|
|
62
|
+
body: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional()).describe('描述'),
|
|
63
|
+
state: zod_1.z
|
|
64
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['open', 'closed']).optional())
|
|
62
65
|
.describe('状态')
|
|
63
66
|
}, async ({ repo, number, ...params }) => {
|
|
64
67
|
try {
|
|
65
|
-
const pull = await updatePull(repo, number, params);
|
|
66
|
-
return formatTextToolResult(JSON.stringify(pull, null, 2), 'update-pull');
|
|
68
|
+
const pull = await (0, pull_js_1.updatePull)(repo, number, params);
|
|
69
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(pull, null, 2), 'update-pull');
|
|
67
70
|
}
|
|
68
71
|
catch (error) {
|
|
69
|
-
return formatToolError(error, 'update-pull');
|
|
72
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'update-pull');
|
|
70
73
|
}
|
|
71
74
|
});
|
|
72
75
|
server.tool('merge-pull', '合并Pull Request', {
|
|
73
|
-
repo: z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
74
|
-
number: z.number().describe('Pull Request编号'),
|
|
75
|
-
merge_style: z
|
|
76
|
-
.preprocess((val) => (val === null ? undefined : val), z.enum(['merge', 'squash', 'rebase']).optional())
|
|
76
|
+
repo: zod_1.z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
77
|
+
number: zod_1.z.number().describe('Pull Request编号'),
|
|
78
|
+
merge_style: zod_1.z
|
|
79
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.enum(['merge', 'squash', 'rebase']).optional())
|
|
77
80
|
.describe('合并方式'),
|
|
78
|
-
commit_title: z.preprocess((val) => (val === null ? undefined : val), z.string()).describe('合并提交标题'),
|
|
79
|
-
commit_message: z
|
|
80
|
-
.preprocess((val) => (val === null ? undefined : val), z.string().optional())
|
|
81
|
+
commit_title: zod_1.z.preprocess((val) => (val === null ? undefined : val), zod_1.z.string()).describe('合并提交标题'),
|
|
82
|
+
commit_message: zod_1.z
|
|
83
|
+
.preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
|
|
81
84
|
.describe('合并提交信息')
|
|
82
85
|
}, async ({ repo, number, ...params }) => {
|
|
83
86
|
try {
|
|
84
|
-
const result = await mergePull(repo, number, params);
|
|
85
|
-
return formatTextToolResult(JSON.stringify(result, null, 2), 'merge-pull');
|
|
87
|
+
const result = await (0, pull_js_1.mergePull)(repo, number, params);
|
|
88
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(result, null, 2), 'merge-pull');
|
|
86
89
|
}
|
|
87
90
|
catch (error) {
|
|
88
|
-
return formatToolError(error, 'merge-pull');
|
|
91
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'merge-pull');
|
|
89
92
|
}
|
|
90
93
|
});
|
|
91
94
|
server.tool('list-pull-comments', '列出Pull Request的评论', {
|
|
92
|
-
repo: z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
93
|
-
number: z.number().describe('Pull Request编号'),
|
|
94
|
-
page: z.number().default(1).describe('页码'),
|
|
95
|
-
per_page: z.number().default(30).describe('每页数量')
|
|
95
|
+
repo: zod_1.z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
96
|
+
number: zod_1.z.number().describe('Pull Request编号'),
|
|
97
|
+
page: zod_1.z.number().default(1).describe('页码'),
|
|
98
|
+
per_page: zod_1.z.number().default(30).describe('每页数量')
|
|
96
99
|
}, async ({ repo, number, ...params }) => {
|
|
97
100
|
try {
|
|
98
|
-
const comments = await listPullComments(repo, number, params);
|
|
99
|
-
return formatTextToolResult(JSON.stringify(comments, null, 2), 'list-pull-comments');
|
|
101
|
+
const comments = await (0, pull_js_1.listPullComments)(repo, number, params);
|
|
102
|
+
return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(comments, null, 2), 'list-pull-comments');
|
|
100
103
|
}
|
|
101
104
|
catch (error) {
|
|
102
|
-
return formatToolError(error, 'list-pull-comments');
|
|
105
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'list-pull-comments');
|
|
103
106
|
}
|
|
104
107
|
});
|
|
105
108
|
server.tool('create-pull-comment', '创建Pull Request评论', {
|
|
106
|
-
repo: z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
107
|
-
number: z.number().describe('Pull Request编号'),
|
|
108
|
-
body: z.string().describe('评论内容')
|
|
109
|
+
repo: zod_1.z.string().describe('仓库路径,格式为 {group}/{repo}'),
|
|
110
|
+
number: zod_1.z.number().describe('Pull Request编号'),
|
|
111
|
+
body: zod_1.z.string().describe('评论内容')
|
|
109
112
|
}, async ({ repo, number, body }) => {
|
|
110
113
|
try {
|
|
111
|
-
await createPullComment(repo, number, { body });
|
|
112
|
-
return formatTextToolResult('Comment created', 'create-pull-comment');
|
|
114
|
+
await (0, pull_js_1.createPullComment)(repo, number, { body });
|
|
115
|
+
return (0, formatToolResult_js_1.formatTextToolResult)('Comment created', 'create-pull-comment');
|
|
113
116
|
}
|
|
114
117
|
catch (error) {
|
|
115
|
-
return formatToolError(error, 'create-pull-comment');
|
|
118
|
+
return (0, formatToolResult_js_1.formatToolError)(error, 'create-pull-comment');
|
|
116
119
|
}
|
|
117
120
|
});
|
|
118
121
|
}
|