@cnbcool/mcp-server 0.4.1 → 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.
@@ -1,17 +1,23 @@
1
- import CnbApiClient from '../api/client.js';
2
- import registerGroupTools from './groupTools.js';
3
- import registerRepoTools from './repoTools.js';
4
- import registerIssueTools from './issueTools.js';
5
- import registerWorkspaceTools from './workspaceTools.js';
6
- import registerPullTools from './pullTools.js';
7
- export function registerTools(server, token) {
8
- CnbApiClient.initialize({
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
- registerGroupTools(server);
13
- registerRepoTools(server);
14
- registerIssueTools(server);
15
- registerWorkspaceTools(server);
16
- registerPullTools(server);
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
  }
@@ -1,37 +1,40 @@
1
- import { z } from 'zod';
2
- import { createIssue, createIssueComment, getIssue, listIssueComments, listIssues, updateIssue, updateIssueComment, listIssueLabels, addIssueLabels, setIssueLabels, deleteIssueLabels, deleteIssueLabel } from '../api/issue.js';
3
- import { formatTextToolResult, formatToolError } from '../helpers/formatToolResult.js';
4
- export default function registerIssueTools(server) {
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,177 +47,193 @@ 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
- }, async ({ repo, title, body, assignees, labels, priority }) => {
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())
81
+ .describe('Issue 截止时间,格式为 YYYY-MM-DD'),
82
+ start_date: zod_1.z
83
+ .preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
84
+ .describe('Issue 起始时间,格式为 YYYY-MM-DD')
85
+ }, async ({ repo, title, body, assignees, labels, priority, end_date, start_date }) => {
77
86
  try {
78
- const issue = await createIssue(repo, {
87
+ const issue = await (0, issue_js_1.createIssue)(repo, {
79
88
  title,
80
89
  body,
81
90
  assignees,
82
91
  labels,
83
- priority
92
+ priority,
93
+ end_date,
94
+ start_date
84
95
  });
85
- return formatTextToolResult(JSON.stringify(issue, null, 2), 'create-issue');
96
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(issue, null, 2), 'create-issue');
86
97
  }
87
98
  catch (error) {
88
- return formatToolError(error, 'create-issue');
99
+ return (0, formatToolResult_js_1.formatToolError)(error, 'create-issue');
89
100
  }
90
101
  });
91
102
  server.tool('update-issue', '更新一个 Issue。 如需更新 Issue 标签,需要另外调用 set-issue-labels', {
92
- repo: z.string().describe('仓库路径'),
93
- issueId: z.number().describe('Issue ID'),
94
- title: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 标题'),
95
- body: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 描述'),
96
- priority: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 优先级'),
97
- state: z.preprocess((val) => (val === null ? undefined : val), z.string().optional()).describe('Issue 状态'),
98
- state_reason: z
99
- .preprocess((val) => (val === null ? undefined : val), z.enum(['completed', 'not_planned', 'reopened']).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())
110
+ .describe('Issue 截止时间,格式为 YYYY-MM-DD'),
111
+ start_date: zod_1.z
112
+ .preprocess((val) => (val === null ? undefined : val), zod_1.z.string().optional())
113
+ .describe('Issue 起始时间,格式为 YYYY-MM-DD'),
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())
100
117
  .describe('Issue 状态原因')
101
- }, async ({ repo, issueId, title, body, priority, state, state_reason }) => {
118
+ }, async ({ repo, issueId, title, body, priority, end_date, start_date, state, state_reason }) => {
102
119
  try {
103
- const issue = await updateIssue(repo, issueId, {
120
+ const issue = await (0, issue_js_1.updateIssue)(repo, issueId, {
104
121
  title,
105
122
  body,
106
123
  priority,
124
+ end_date,
125
+ start_date,
107
126
  state,
108
127
  state_reason
109
128
  });
110
- return formatTextToolResult(JSON.stringify(issue, null, 2), 'update-issue');
129
+ return (0, formatToolResult_js_1.formatTextToolResult)(JSON.stringify(issue, null, 2), 'update-issue');
111
130
  }
112
131
  catch (error) {
113
- return formatToolError(error, 'update-issue');
132
+ return (0, formatToolResult_js_1.formatToolError)(error, 'update-issue');
114
133
  }
115
134
  });
116
135
  server.tool('list-issue-comments', '查询 Issue 评论列表', {
117
- repo: z.string().describe('仓库路径'),
118
- issueId: z.number().describe('Issue ID'),
119
- page: z.number().default(1).describe('第几页,从1开始'),
120
- 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')
121
140
  }, async ({ repo, issueId, page, page_size }) => {
122
141
  try {
123
- const comments = await listIssueComments(repo, issueId, { page, page_size });
124
- 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');
125
144
  }
126
145
  catch (error) {
127
- return formatToolError(error, 'list-issue-comments');
146
+ return (0, formatToolResult_js_1.formatToolError)(error, 'list-issue-comments');
128
147
  }
129
148
  });
130
149
  server.tool('create-issue-comment', '创建一个 Issue 评论', {
131
- repo: z.string().describe('仓库路径'),
132
- issueId: z.number().describe('Issue ID'),
133
- 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('评论内容')
134
153
  }, async ({ repo, issueId, body }) => {
135
154
  try {
136
- const comment = await createIssueComment(repo, issueId, { body });
137
- 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');
138
157
  }
139
158
  catch (error) {
140
- return formatToolError(error, 'create-issue-comment');
159
+ return (0, formatToolResult_js_1.formatToolError)(error, 'create-issue-comment');
141
160
  }
142
161
  });
143
162
  server.tool('update-issue-comment', '更新一个 Issue 评论', {
144
- repo: z.string().describe('仓库路径'),
145
- issueId: z.number().describe('Issue ID'),
146
- commentId: z.string().describe('评论 ID'),
147
- 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('评论内容')
148
167
  }, async ({ repo, issueId, commentId, body }) => {
149
168
  try {
150
- const comment = await updateIssueComment(repo, issueId, commentId, { body });
151
- 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');
152
171
  }
153
172
  catch (error) {
154
- return formatToolError(error, 'update-issue-comment');
173
+ return (0, formatToolResult_js_1.formatToolError)(error, 'update-issue-comment');
155
174
  }
156
175
  });
157
176
  server.tool('list-issue-labels', '查询指定Issue的标签', {
158
- repo: z.string().describe('仓库路径'),
159
- issueId: z.number().describe('Issue ID')
177
+ repo: zod_1.z.string().describe('仓库路径'),
178
+ issueId: zod_1.z.number().describe('Issue ID')
160
179
  }, async ({ repo, issueId }) => {
161
180
  try {
162
- const labels = await listIssueLabels(repo, issueId);
163
- 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');
164
183
  }
165
184
  catch (error) {
166
- return formatToolError(error, 'list-issue-labels');
185
+ return (0, formatToolResult_js_1.formatToolError)(error, 'list-issue-labels');
167
186
  }
168
187
  });
169
188
  server.tool('add-issue-labels', '为指定Issue添加标签', {
170
- repo: z.string().describe('仓库路径'),
171
- issueId: z.number().describe('Issue ID'),
172
- 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('要添加的标签列表,每个标签需要从仓库标签列表中选择')
173
192
  }, async ({ repo, issueId, labels }) => {
174
193
  try {
175
- const result = await addIssueLabels(repo, issueId, labels);
176
- 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');
177
196
  }
178
197
  catch (error) {
179
- return formatToolError(error, 'add-issue-labels');
198
+ return (0, formatToolResult_js_1.formatToolError)(error, 'add-issue-labels');
180
199
  }
181
200
  });
182
201
  server.tool('set-issue-labels', '设置Issue的标签(替换所有现有标签)', {
183
- repo: z.string().describe('仓库路径'),
184
- issueId: z.number().describe('Issue ID'),
185
- 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('新的标签列表(将替换所有现有标签),每个标签需要从仓库标签列表中选择')
186
205
  }, async ({ repo, issueId, labels }) => {
187
206
  try {
188
- const result = await setIssueLabels(repo, issueId, labels);
189
- 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');
190
209
  }
191
210
  catch (error) {
192
- return formatToolError(error, 'set-issue-labels');
211
+ return (0, formatToolResult_js_1.formatToolError)(error, 'set-issue-labels');
193
212
  }
194
213
  });
195
214
  server.tool('delete-issue-labels', '删除Issue的所有标签', {
196
- repo: z.string().describe('仓库路径'),
197
- issueId: z.number().describe('Issue ID')
215
+ repo: zod_1.z.string().describe('仓库路径'),
216
+ issueId: zod_1.z.number().describe('Issue ID')
198
217
  }, async ({ repo, issueId }) => {
199
218
  try {
200
- await deleteIssueLabels(repo, issueId);
201
- 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');
202
221
  }
203
222
  catch (error) {
204
- return formatToolError(error, 'delete-issue-labels');
223
+ return (0, formatToolResult_js_1.formatToolError)(error, 'delete-issue-labels');
205
224
  }
206
225
  });
207
226
  server.tool('delete-issue-label', '删除Issue的指定标签', {
208
- repo: z.string().describe('仓库路径'),
209
- issueId: z.number().describe('Issue ID'),
210
- 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('要删除的标签名称')
211
230
  }, async ({ repo, issueId, labelName }) => {
212
231
  try {
213
- await deleteIssueLabel(repo, issueId, labelName);
214
- 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');
215
234
  }
216
235
  catch (error) {
217
- return formatToolError(error, 'delete-issue-label');
236
+ return (0, formatToolResult_js_1.formatToolError)(error, 'delete-issue-label');
218
237
  }
219
238
  });
220
239
  }
@@ -1,118 +1,121 @@
1
- import { z } from 'zod';
2
- import { listPulls, getPull, createPull, updatePull, mergePull, listPullComments, createPullComment } from '../api/pull.js';
3
- import { formatTextToolResult, formatToolError } from '../helpers/formatToolResult.js';
4
- export default function registerPullTools(server) {
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
  }