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