@github-tools/sdk 1.11.1 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -2
- package/dist/connect/eve.d.mts +2 -2
- package/dist/connect/eve.mjs +1 -1
- package/dist/connect.d.mts +2 -2
- package/dist/connect.mjs +2 -2
- package/dist/{eve-runtime-DInXr4h5.mjs → eve-runtime-3asyv7YM.mjs} +52 -15
- package/dist/eve-runtime-3asyv7YM.mjs.map +1 -0
- package/dist/{eve-runtime-Cb0LVEvS.d.mts → eve-runtime-BmoVTbEU.d.mts} +18 -7
- package/dist/eve-runtime-BmoVTbEU.d.mts.map +1 -0
- package/dist/eve-runtime.d.mts +4 -4
- package/dist/eve-runtime.mjs +3 -3
- package/dist/eve.d.mts +3 -3
- package/dist/eve.mjs +2 -2
- package/dist/{index-BNeMjmgp.d.mts → index-CGeFo38P.d.mts} +15 -2
- package/dist/index-CGeFo38P.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/{src-jQWS2Txw.mjs → src-D45Onmsn.mjs} +20 -3
- package/dist/{src-jQWS2Txw.mjs.map → src-D45Onmsn.mjs.map} +1 -1
- package/dist/{token-1uPUq_g-.mjs → token-BIn80-XU.mjs} +16 -3
- package/dist/{token-1uPUq_g-.mjs.map → token-BIn80-XU.mjs.map} +1 -1
- package/dist/{types-BD5YvGxm.d.mts → types-CiNZNOXa.d.mts} +3 -3
- package/dist/{types-BD5YvGxm.d.mts.map → types-CiNZNOXa.d.mts.map} +1 -1
- package/dist/{types-BDO-Mmn6.d.mts → types-CoTpsxxp.d.mts} +2 -2
- package/dist/{types-BDO-Mmn6.d.mts.map → types-CoTpsxxp.d.mts.map} +1 -1
- package/dist/workflow.d.mts +1 -1
- package/dist/workflow.mjs +2 -2
- package/dist/{write-tools-Dk32V9Hl.mjs → write-tools-CnJE0Vvu.mjs} +1568 -1327
- package/dist/write-tools-CnJE0Vvu.mjs.map +1 -0
- package/package.json +4 -4
- package/dist/eve-runtime-Cb0LVEvS.d.mts.map +0 -1
- package/dist/eve-runtime-DInXr4h5.mjs.map +0 -1
- package/dist/index-BNeMjmgp.d.mts.map +0 -1
- package/dist/write-tools-Dk32V9Hl.mjs.map +0 -1
|
@@ -1,8 +1,101 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { Octokit } from "octokit";
|
|
3
|
+
//#region src/core/rate-limit.ts
|
|
4
|
+
const snapshots = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
function headerValue(headers, name) {
|
|
6
|
+
if (!headers) return void 0;
|
|
7
|
+
const value = headers[name] ?? headers[name.toLowerCase()];
|
|
8
|
+
if (value == null) return void 0;
|
|
9
|
+
return String(value);
|
|
10
|
+
}
|
|
11
|
+
function isPlainObject(value) {
|
|
12
|
+
return value != null && typeof value === "object" && !Array.isArray(value) && Object.getPrototypeOf(value) === Object.prototype;
|
|
13
|
+
}
|
|
14
|
+
function isRateLimit(value) {
|
|
15
|
+
return isPlainObject(value) && typeof value.remaining === "number" && typeof value.limit === "number" && typeof value.reset === "number";
|
|
16
|
+
}
|
|
17
|
+
/** Parse GitHub `x-ratelimit-*` / `retry-after` headers. Returns undefined when the trio is missing. */
|
|
18
|
+
function parseGithubRateLimit(headers) {
|
|
19
|
+
const remaining = Number(headerValue(headers, "x-ratelimit-remaining"));
|
|
20
|
+
const limit = Number(headerValue(headers, "x-ratelimit-limit"));
|
|
21
|
+
const reset = Number(headerValue(headers, "x-ratelimit-reset"));
|
|
22
|
+
if (!Number.isFinite(remaining) || !Number.isFinite(limit) || !Number.isFinite(reset)) return;
|
|
23
|
+
const resource = headerValue(headers, "x-ratelimit-resource");
|
|
24
|
+
const retryAfter = Number(headerValue(headers, "retry-after"));
|
|
25
|
+
return {
|
|
26
|
+
remaining,
|
|
27
|
+
limit,
|
|
28
|
+
reset,
|
|
29
|
+
...resource ? { resource } : {},
|
|
30
|
+
...Number.isFinite(retryAfter) ? { retryAfter } : {}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function recordGithubRateLimit(owner, headers) {
|
|
34
|
+
const rateLimit = parseGithubRateLimit(headers);
|
|
35
|
+
if (rateLimit) snapshots.set(owner, rateLimit);
|
|
36
|
+
}
|
|
37
|
+
function stripRateLimit(output) {
|
|
38
|
+
if (!isPlainObject(output) || !("rateLimit" in output)) return output;
|
|
39
|
+
const rest = { ...output };
|
|
40
|
+
delete rest.rateLimit;
|
|
41
|
+
return rest;
|
|
42
|
+
}
|
|
43
|
+
function attachRateLimit(result, rateLimit) {
|
|
44
|
+
if (!rateLimit || !isPlainObject(result)) return result;
|
|
45
|
+
return {
|
|
46
|
+
...result,
|
|
47
|
+
rateLimit
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function finishGithubResult(owner, result) {
|
|
51
|
+
return attachRateLimit(result, snapshots.get(owner));
|
|
52
|
+
}
|
|
53
|
+
function pickRateLimitDeep(value) {
|
|
54
|
+
let found;
|
|
55
|
+
if (isPlainObject(value)) {
|
|
56
|
+
if (isRateLimit(value.rateLimit)) found = value.rateLimit;
|
|
57
|
+
for (const child of Object.values(value)) {
|
|
58
|
+
const nested = pickRateLimitDeep(child);
|
|
59
|
+
if (nested) found = nested;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return found;
|
|
63
|
+
}
|
|
64
|
+
function stripRateLimitDeep(value) {
|
|
65
|
+
if (Array.isArray(value)) return value;
|
|
66
|
+
if (!isPlainObject(value)) return value;
|
|
67
|
+
const next = stripRateLimit({ ...value });
|
|
68
|
+
return Object.fromEntries(Object.entries(next).map(([key, child]) => [key, stripRateLimitDeep(child)]));
|
|
69
|
+
}
|
|
70
|
+
/** Lift a nested child's `rateLimit` onto a composed object and strip it from children. */
|
|
71
|
+
function withComposedRateLimit(result) {
|
|
72
|
+
return attachRateLimit(stripRateLimitDeep(result), pickRateLimitDeep(result));
|
|
73
|
+
}
|
|
74
|
+
function errorStatus(error) {
|
|
75
|
+
if (error == null || typeof error !== "object" || !("status" in error)) return void 0;
|
|
76
|
+
const status = error.status;
|
|
77
|
+
return typeof status === "number" ? status : void 0;
|
|
78
|
+
}
|
|
79
|
+
function formatRateLimitSuffix(rateLimit) {
|
|
80
|
+
const resource = rateLimit.resource ? ` ${rateLimit.resource}` : "";
|
|
81
|
+
const retry = rateLimit.retryAfter != null ? `, retry after ${rateLimit.retryAfter}s` : "";
|
|
82
|
+
return `GitHub rate limit${resource}: ${rateLimit.remaining}/${rateLimit.limit} remaining, resets at ${rateLimit.reset}${retry}`;
|
|
83
|
+
}
|
|
84
|
+
function enrichGithubRateLimitError(error, rateLimit) {
|
|
85
|
+
const status = errorStatus(error);
|
|
86
|
+
if (!rateLimit || status !== 403 && status !== 429 || !(error instanceof Error)) return error;
|
|
87
|
+
const suffix = formatRateLimitSuffix(rateLimit);
|
|
88
|
+
if (!error.message.includes(suffix)) error.message = `${error.message} (${suffix})`;
|
|
89
|
+
return error;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
3
92
|
//#region src/client.ts
|
|
4
93
|
/** @see https://docs.github.com/en/rest/about-the-rest-api/api-versions */
|
|
5
94
|
const GITHUB_API_VERSION = "2026-03-10";
|
|
95
|
+
function errorResponseHeaders(error) {
|
|
96
|
+
if (error == null || typeof error !== "object" || !("response" in error)) return void 0;
|
|
97
|
+
return error.response?.headers;
|
|
98
|
+
}
|
|
6
99
|
function createOctokit(token) {
|
|
7
100
|
const octokit = new Octokit({ auth: token });
|
|
8
101
|
octokit.hook.before("request", (options) => {
|
|
@@ -11,8 +104,21 @@ function createOctokit(token) {
|
|
|
11
104
|
"X-GitHub-Api-Version": GITHUB_API_VERSION
|
|
12
105
|
};
|
|
13
106
|
});
|
|
107
|
+
octokit.hook.after("request", (response) => {
|
|
108
|
+
recordGithubRateLimit(octokit, response.headers);
|
|
109
|
+
});
|
|
110
|
+
octokit.hook.error("request", (error) => {
|
|
111
|
+
const rateLimit = parseGithubRateLimit(errorResponseHeaders(error));
|
|
112
|
+
if (rateLimit) recordGithubRateLimit(octokit, errorResponseHeaders(error));
|
|
113
|
+
throw enrichGithubRateLimitError(error, rateLimit);
|
|
114
|
+
});
|
|
14
115
|
return octokit;
|
|
15
116
|
}
|
|
117
|
+
/** Run a GitHub `*Core` body and attach `rateLimit` from this Octokit instance. */
|
|
118
|
+
async function withOctokit(token, fn) {
|
|
119
|
+
const octokit = createOctokit(token);
|
|
120
|
+
return finishGithubResult(octokit, await fn(octokit));
|
|
121
|
+
}
|
|
16
122
|
//#endregion
|
|
17
123
|
//#region src/core/sha1.ts
|
|
18
124
|
/** SHA-1 hex digest without Node.js `crypto` (safe in workflow bundles). */
|
|
@@ -144,24 +250,26 @@ const getRepositoryInputSchema = z.object({
|
|
|
144
250
|
});
|
|
145
251
|
const getRepositoryDescription = "Get information about a GitHub repository including description, stars, forks, language, and default branch";
|
|
146
252
|
async function getRepositoryCore({ token, owner, repo }) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
253
|
+
return withOctokit(token, async (octokit) => {
|
|
254
|
+
const { data } = await octokit.rest.repos.get({
|
|
255
|
+
owner,
|
|
256
|
+
repo
|
|
257
|
+
});
|
|
258
|
+
return {
|
|
259
|
+
name: data.name,
|
|
260
|
+
fullName: data.full_name,
|
|
261
|
+
description: data.description,
|
|
262
|
+
url: data.html_url,
|
|
263
|
+
defaultBranch: data.default_branch,
|
|
264
|
+
stars: data.stargazers_count,
|
|
265
|
+
forks: data.forks_count,
|
|
266
|
+
openIssues: data.open_issues_count,
|
|
267
|
+
language: data.language,
|
|
268
|
+
private: data.private,
|
|
269
|
+
createdAt: data.created_at,
|
|
270
|
+
updatedAt: data.updated_at
|
|
271
|
+
};
|
|
150
272
|
});
|
|
151
|
-
return {
|
|
152
|
-
name: data.name,
|
|
153
|
-
fullName: data.full_name,
|
|
154
|
-
description: data.description,
|
|
155
|
-
url: data.html_url,
|
|
156
|
-
defaultBranch: data.default_branch,
|
|
157
|
-
stars: data.stargazers_count,
|
|
158
|
-
forks: data.forks_count,
|
|
159
|
-
openIssues: data.open_issues_count,
|
|
160
|
-
language: data.language,
|
|
161
|
-
private: data.private,
|
|
162
|
-
createdAt: data.created_at,
|
|
163
|
-
updatedAt: data.updated_at
|
|
164
|
-
};
|
|
165
273
|
}
|
|
166
274
|
const listBranchesInputSchema = z.object({
|
|
167
275
|
owner: z.string().describe("Repository owner"),
|
|
@@ -170,16 +278,18 @@ const listBranchesInputSchema = z.object({
|
|
|
170
278
|
});
|
|
171
279
|
const listBranchesDescription = "List branches in a GitHub repository";
|
|
172
280
|
async function listBranchesCore({ token, owner, repo, perPage }) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
281
|
+
return withOctokit(token, async (octokit) => {
|
|
282
|
+
const { data } = await octokit.rest.repos.listBranches({
|
|
283
|
+
owner,
|
|
284
|
+
repo,
|
|
285
|
+
per_page: perPage
|
|
286
|
+
});
|
|
287
|
+
return data.map((branch) => ({
|
|
288
|
+
name: branch.name,
|
|
289
|
+
sha: branch.commit.sha,
|
|
290
|
+
protected: branch.protected
|
|
291
|
+
}));
|
|
177
292
|
});
|
|
178
|
-
return data.map((branch) => ({
|
|
179
|
-
name: branch.name,
|
|
180
|
-
sha: branch.commit.sha,
|
|
181
|
-
protected: branch.protected
|
|
182
|
-
}));
|
|
183
293
|
}
|
|
184
294
|
const getFileContentInputSchema = z.object({
|
|
185
295
|
owner: z.string().describe("Repository owner"),
|
|
@@ -192,51 +302,53 @@ const getFileContentInputSchema = z.object({
|
|
|
192
302
|
});
|
|
193
303
|
const getFileContentDescription = "Get the content of a file from a GitHub repository. Prefer startLine/endLine or maxLines to read only the lines you need";
|
|
194
304
|
async function getFileContentCore({ token, owner, repo, path, ref, startLine, endLine, maxLines }) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
305
|
+
return withOctokit(token, async (octokit) => {
|
|
306
|
+
const { data } = await octokit.rest.repos.getContent({
|
|
307
|
+
owner,
|
|
308
|
+
repo,
|
|
309
|
+
path,
|
|
310
|
+
ref
|
|
311
|
+
});
|
|
312
|
+
if (Array.isArray(data)) return {
|
|
313
|
+
type: "directory",
|
|
314
|
+
entries: data.map((e) => ({
|
|
315
|
+
name: e.name,
|
|
316
|
+
type: e.type,
|
|
317
|
+
path: e.path
|
|
318
|
+
}))
|
|
319
|
+
};
|
|
320
|
+
if (data.type !== "file") return {
|
|
321
|
+
type: data.type,
|
|
322
|
+
path: data.path
|
|
323
|
+
};
|
|
324
|
+
const fullContent = Buffer.from(data.content, "base64").toString("utf-8");
|
|
325
|
+
const lines = fullContent.split("\n");
|
|
326
|
+
const totalLines = lines.length;
|
|
327
|
+
if (!(startLine != null || endLine != null || maxLines != null)) return {
|
|
328
|
+
type: "file",
|
|
329
|
+
path: data.path,
|
|
330
|
+
sha: data.sha,
|
|
331
|
+
size: data.size,
|
|
332
|
+
totalLines,
|
|
333
|
+
content: fullContent
|
|
334
|
+
};
|
|
335
|
+
const from = startLine ?? 1;
|
|
336
|
+
const to = endLine ?? (maxLines != null ? from + maxLines - 1 : totalLines);
|
|
337
|
+
const clampedFrom = Math.min(Math.max(from, 1), totalLines);
|
|
338
|
+
const clampedTo = Math.min(Math.max(to, clampedFrom), totalLines);
|
|
339
|
+
const slice = lines.slice(clampedFrom - 1, clampedTo);
|
|
340
|
+
return {
|
|
341
|
+
type: "file",
|
|
342
|
+
path: data.path,
|
|
343
|
+
sha: data.sha,
|
|
344
|
+
size: data.size,
|
|
345
|
+
totalLines,
|
|
346
|
+
startLine: clampedFrom,
|
|
347
|
+
endLine: clampedTo,
|
|
348
|
+
truncated: clampedFrom > 1 || clampedTo < totalLines,
|
|
349
|
+
content: slice.join("\n")
|
|
350
|
+
};
|
|
351
|
+
});
|
|
240
352
|
}
|
|
241
353
|
const getRepositoryTreeInputSchema = z.object({
|
|
242
354
|
owner: z.string().describe("Repository owner"),
|
|
@@ -246,27 +358,28 @@ const getRepositoryTreeInputSchema = z.object({
|
|
|
246
358
|
});
|
|
247
359
|
const getRepositoryTreeDescription = "List the file and directory structure of a repository at a given ref";
|
|
248
360
|
async function getRepositoryTreeCore({ token, owner, repo, ref, recursive }) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
361
|
+
return withOctokit(token, async (octokit) => {
|
|
362
|
+
const treeSha = ref || (await octokit.rest.repos.get({
|
|
363
|
+
owner,
|
|
364
|
+
repo
|
|
365
|
+
})).data.default_branch;
|
|
366
|
+
const { data } = await octokit.rest.git.getTree({
|
|
367
|
+
owner,
|
|
368
|
+
repo,
|
|
369
|
+
tree_sha: treeSha,
|
|
370
|
+
recursive: recursive ? "true" : void 0
|
|
371
|
+
});
|
|
372
|
+
return {
|
|
373
|
+
sha: data.sha,
|
|
374
|
+
truncated: data.truncated,
|
|
375
|
+
entries: data.tree.map((entry) => ({
|
|
376
|
+
path: entry.path,
|
|
377
|
+
type: entry.type,
|
|
378
|
+
size: entry.size,
|
|
379
|
+
sha: entry.sha
|
|
380
|
+
}))
|
|
381
|
+
};
|
|
259
382
|
});
|
|
260
|
-
return {
|
|
261
|
-
sha: data.sha,
|
|
262
|
-
truncated: data.truncated,
|
|
263
|
-
entries: data.tree.map((entry) => ({
|
|
264
|
-
path: entry.path,
|
|
265
|
-
type: entry.type,
|
|
266
|
-
size: entry.size,
|
|
267
|
-
sha: entry.sha
|
|
268
|
-
}))
|
|
269
|
-
};
|
|
270
383
|
}
|
|
271
384
|
const createBranchInputSchema = z.object({
|
|
272
385
|
owner: z.string().describe("Repository owner"),
|
|
@@ -277,42 +390,43 @@ const createBranchInputSchema = z.object({
|
|
|
277
390
|
const createBranchDescription = "Create a new branch in a GitHub repository from an existing branch or commit SHA";
|
|
278
391
|
/** Idempotent when the branch already exists at the target SHA. Not idempotent otherwise. */
|
|
279
392
|
async function createBranchCore({ token, owner, repo, branch, from }) {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
owner,
|
|
285
|
-
repo,
|
|
286
|
-
ref: `heads/${from || (await octokit.rest.repos.get({
|
|
393
|
+
return withOctokit(token, async (octokit) => {
|
|
394
|
+
let sha = from;
|
|
395
|
+
if (!sha || !sha.match(/^[0-9a-f]{40}$/i)) {
|
|
396
|
+
const { data: ref } = await octokit.rest.git.getRef({
|
|
287
397
|
owner,
|
|
288
|
-
repo
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
398
|
+
repo,
|
|
399
|
+
ref: `heads/${from || (await octokit.rest.repos.get({
|
|
400
|
+
owner,
|
|
401
|
+
repo
|
|
402
|
+
})).data.default_branch}`
|
|
403
|
+
});
|
|
404
|
+
sha = ref.object.sha;
|
|
405
|
+
}
|
|
406
|
+
try {
|
|
407
|
+
const { data: existingRef } = await octokit.rest.git.getRef({
|
|
408
|
+
owner,
|
|
409
|
+
repo,
|
|
410
|
+
ref: `heads/${branch}`
|
|
411
|
+
});
|
|
412
|
+
if (existingRef.object.sha === sha) return {
|
|
413
|
+
ref: existingRef.ref,
|
|
414
|
+
sha: existingRef.object.sha,
|
|
415
|
+
url: existingRef.url
|
|
416
|
+
};
|
|
417
|
+
} catch {}
|
|
418
|
+
const { data } = await octokit.rest.git.createRef({
|
|
295
419
|
owner,
|
|
296
420
|
repo,
|
|
297
|
-
ref: `heads/${branch}
|
|
421
|
+
ref: `refs/heads/${branch}`,
|
|
422
|
+
sha
|
|
298
423
|
});
|
|
299
|
-
|
|
300
|
-
ref:
|
|
301
|
-
sha:
|
|
302
|
-
url:
|
|
424
|
+
return {
|
|
425
|
+
ref: data.ref,
|
|
426
|
+
sha: data.object.sha,
|
|
427
|
+
url: data.url
|
|
303
428
|
};
|
|
304
|
-
} catch {}
|
|
305
|
-
const { data } = await octokit.rest.git.createRef({
|
|
306
|
-
owner,
|
|
307
|
-
repo,
|
|
308
|
-
ref: `refs/heads/${branch}`,
|
|
309
|
-
sha
|
|
310
429
|
});
|
|
311
|
-
return {
|
|
312
|
-
ref: data.ref,
|
|
313
|
-
sha: data.object.sha,
|
|
314
|
-
url: data.url
|
|
315
|
-
};
|
|
316
430
|
}
|
|
317
431
|
const forkRepositoryInputSchema = z.object({
|
|
318
432
|
owner: z.string().describe("Repository owner to fork from"),
|
|
@@ -323,25 +437,27 @@ const forkRepositoryInputSchema = z.object({
|
|
|
323
437
|
const forkRepositoryDescription = "Fork a GitHub repository to the authenticated user account or a specified organization";
|
|
324
438
|
/** Not idempotent — each call may create another fork attempt. */
|
|
325
439
|
async function forkRepositoryCore({ token, owner, repo, organization, name }) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
440
|
+
return withOctokit(token, async (octokit) => {
|
|
441
|
+
const { data } = await octokit.rest.repos.createFork({
|
|
442
|
+
owner,
|
|
443
|
+
repo,
|
|
444
|
+
organization,
|
|
445
|
+
name
|
|
446
|
+
});
|
|
447
|
+
return {
|
|
448
|
+
name: data.name,
|
|
449
|
+
fullName: data.full_name,
|
|
450
|
+
url: data.html_url,
|
|
451
|
+
cloneUrl: data.clone_url,
|
|
452
|
+
sshUrl: data.ssh_url,
|
|
453
|
+
defaultBranch: data.default_branch,
|
|
454
|
+
private: data.private,
|
|
455
|
+
parent: data.parent ? {
|
|
456
|
+
fullName: data.parent.full_name,
|
|
457
|
+
url: data.parent.html_url
|
|
458
|
+
} : null
|
|
459
|
+
};
|
|
331
460
|
});
|
|
332
|
-
return {
|
|
333
|
-
name: data.name,
|
|
334
|
-
fullName: data.full_name,
|
|
335
|
-
url: data.html_url,
|
|
336
|
-
cloneUrl: data.clone_url,
|
|
337
|
-
sshUrl: data.ssh_url,
|
|
338
|
-
defaultBranch: data.default_branch,
|
|
339
|
-
private: data.private,
|
|
340
|
-
parent: data.parent ? {
|
|
341
|
-
fullName: data.parent.full_name,
|
|
342
|
-
url: data.parent.html_url
|
|
343
|
-
} : null
|
|
344
|
-
};
|
|
345
461
|
}
|
|
346
462
|
const createRepositoryInputSchema = z.object({
|
|
347
463
|
name: z.string().describe("Repository name"),
|
|
@@ -355,30 +471,31 @@ const createRepositoryInputSchema = z.object({
|
|
|
355
471
|
const createRepositoryDescription = "Create a new GitHub repository for the authenticated user or a specified organization";
|
|
356
472
|
/** Not idempotent — each call creates a new repository. */
|
|
357
473
|
async function createRepositoryCore({ token, name, description, isPrivate, autoInit, gitignoreTemplate, licenseTemplate, org }) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
474
|
+
return withOctokit(token, async (octokit) => {
|
|
475
|
+
const params = {
|
|
476
|
+
name,
|
|
477
|
+
description,
|
|
478
|
+
private: isPrivate,
|
|
479
|
+
auto_init: autoInit,
|
|
480
|
+
gitignore_template: gitignoreTemplate,
|
|
481
|
+
license_template: licenseTemplate
|
|
482
|
+
};
|
|
483
|
+
const { data } = org ? await octokit.rest.repos.createInOrg({
|
|
484
|
+
org,
|
|
485
|
+
...params
|
|
486
|
+
}) : await octokit.rest.repos.createForAuthenticatedUser(params);
|
|
487
|
+
return {
|
|
488
|
+
name: data.name,
|
|
489
|
+
fullName: data.full_name,
|
|
490
|
+
description: data.description,
|
|
491
|
+
url: data.html_url,
|
|
492
|
+
cloneUrl: data.clone_url,
|
|
493
|
+
sshUrl: data.ssh_url,
|
|
494
|
+
defaultBranch: data.default_branch,
|
|
495
|
+
private: data.private,
|
|
496
|
+
createdAt: data.created_at
|
|
497
|
+
};
|
|
498
|
+
});
|
|
382
499
|
}
|
|
383
500
|
const createOrUpdateFileInputSchema = z.object({
|
|
384
501
|
owner: z.string().describe("Repository owner"),
|
|
@@ -392,83 +509,84 @@ const createOrUpdateFileInputSchema = z.object({
|
|
|
392
509
|
const createOrUpdateFileDescription = "Create or update a file in a GitHub repository. Provide the SHA when updating an existing file.";
|
|
393
510
|
/** Idempotent when updating with sha and content is unchanged. Not idempotent for new commits. */
|
|
394
511
|
async function createOrUpdateFileCore({ token, owner, repo, path, message, content, branch, sha, author, committer, coAuthors }) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
512
|
+
return withOctokit(token, async (octokit) => {
|
|
513
|
+
if (sha) {
|
|
514
|
+
const branchName = branch || (await octokit.rest.repos.get({
|
|
515
|
+
owner,
|
|
516
|
+
repo
|
|
517
|
+
})).data.default_branch;
|
|
518
|
+
try {
|
|
519
|
+
const { data: fileData } = await octokit.rest.repos.getContent({
|
|
520
|
+
owner,
|
|
521
|
+
repo,
|
|
522
|
+
path,
|
|
523
|
+
ref: branchName
|
|
524
|
+
});
|
|
525
|
+
if (!Array.isArray(fileData) && fileData.type === "file") {
|
|
526
|
+
if (Buffer.from(fileData.content, "base64").toString("utf-8") === content) return {
|
|
527
|
+
path: fileData.path,
|
|
528
|
+
sha: fileData.sha,
|
|
529
|
+
skipped: true,
|
|
530
|
+
message: "Content unchanged; no commit created"
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
} catch {}
|
|
534
|
+
}
|
|
535
|
+
if (!author && !committer) try {
|
|
536
|
+
const branchName = branch || (await octokit.rest.repos.get({
|
|
537
|
+
owner,
|
|
538
|
+
repo
|
|
539
|
+
})).data.default_branch;
|
|
540
|
+
const { data: ref } = await octokit.rest.git.getRef({
|
|
403
541
|
owner,
|
|
404
542
|
repo,
|
|
405
|
-
|
|
406
|
-
ref: branchName
|
|
543
|
+
ref: `heads/${branchName}`
|
|
407
544
|
});
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
545
|
+
const [headline, ...rest] = composeCommitMessage(message, coAuthors).split("\n");
|
|
546
|
+
const body = rest.join("\n").replace(/^\n+/, "") || void 0;
|
|
547
|
+
const result = await createCommitOnBranch(octokit, {
|
|
548
|
+
owner,
|
|
549
|
+
repo,
|
|
550
|
+
branch: branchName,
|
|
551
|
+
expectedHeadOid: ref.object.sha,
|
|
552
|
+
headline,
|
|
553
|
+
body,
|
|
554
|
+
additions: [{
|
|
555
|
+
path,
|
|
556
|
+
contents: Buffer.from(content).toString("base64")
|
|
557
|
+
}]
|
|
558
|
+
});
|
|
559
|
+
return {
|
|
560
|
+
path,
|
|
561
|
+
sha: gitBlobSha(content),
|
|
562
|
+
commitSha: result.commitSha,
|
|
563
|
+
commitUrl: result.commitUrl
|
|
564
|
+
};
|
|
565
|
+
} catch (error) {
|
|
566
|
+
if (error instanceof CreateCommitOnBranchError && error.reason === "stale_data") throw error;
|
|
567
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
568
|
+
console.warn(`[github-tools] Signed commit failed, using REST API: ${msg}`);
|
|
569
|
+
}
|
|
570
|
+
const encoded = Buffer.from(content).toString("base64");
|
|
571
|
+
const finalMessage = composeCommitMessage(message, coAuthors);
|
|
572
|
+
const { data } = await octokit.rest.repos.createOrUpdateFileContents({
|
|
431
573
|
owner,
|
|
432
574
|
repo,
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}]
|
|
575
|
+
path,
|
|
576
|
+
message: finalMessage,
|
|
577
|
+
content: encoded,
|
|
578
|
+
branch,
|
|
579
|
+
sha,
|
|
580
|
+
author,
|
|
581
|
+
committer
|
|
441
582
|
});
|
|
442
583
|
return {
|
|
443
|
-
path,
|
|
444
|
-
sha:
|
|
445
|
-
commitSha:
|
|
446
|
-
commitUrl:
|
|
584
|
+
path: data.content?.path,
|
|
585
|
+
sha: data.content?.sha,
|
|
586
|
+
commitSha: data.commit.sha,
|
|
587
|
+
commitUrl: data.commit.html_url
|
|
447
588
|
};
|
|
448
|
-
} catch (error) {
|
|
449
|
-
if (error instanceof CreateCommitOnBranchError && error.reason === "stale_data") throw error;
|
|
450
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
451
|
-
console.warn(`[github-tools] Signed commit failed, using REST API: ${msg}`);
|
|
452
|
-
}
|
|
453
|
-
const encoded = Buffer.from(content).toString("base64");
|
|
454
|
-
const finalMessage = composeCommitMessage(message, coAuthors);
|
|
455
|
-
const { data } = await octokit.rest.repos.createOrUpdateFileContents({
|
|
456
|
-
owner,
|
|
457
|
-
repo,
|
|
458
|
-
path,
|
|
459
|
-
message: finalMessage,
|
|
460
|
-
content: encoded,
|
|
461
|
-
branch,
|
|
462
|
-
sha,
|
|
463
|
-
author,
|
|
464
|
-
committer
|
|
465
589
|
});
|
|
466
|
-
return {
|
|
467
|
-
path: data.content?.path,
|
|
468
|
-
sha: data.content?.sha,
|
|
469
|
-
commitSha: data.commit.sha,
|
|
470
|
-
commitUrl: data.commit.html_url
|
|
471
|
-
};
|
|
472
590
|
}
|
|
473
591
|
//#endregion
|
|
474
592
|
//#region src/core/model-output.ts
|
|
@@ -605,28 +723,29 @@ const listPullRequestsInputSchema = z.object({
|
|
|
605
723
|
});
|
|
606
724
|
const listPullRequestsDescription = "List pull requests for a GitHub repository";
|
|
607
725
|
async function listPullRequestsCore({ token, owner, repo, state, perPage, maxPages }) {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
726
|
+
return withOctokit(token, async (octokit) => {
|
|
727
|
+
return (await fetchAllPages(async (page) => {
|
|
728
|
+
const { data } = await octokit.rest.pulls.list({
|
|
729
|
+
owner,
|
|
730
|
+
repo,
|
|
731
|
+
state,
|
|
732
|
+
per_page: perPage,
|
|
733
|
+
page
|
|
734
|
+
});
|
|
735
|
+
return data;
|
|
736
|
+
}, perPage, maxPages)).map((pr) => ({
|
|
737
|
+
number: pr.number,
|
|
738
|
+
title: pr.title,
|
|
739
|
+
state: pr.state,
|
|
740
|
+
url: pr.html_url,
|
|
741
|
+
author: pr.user?.login,
|
|
742
|
+
branch: pr.head.ref,
|
|
743
|
+
base: pr.base.ref,
|
|
744
|
+
draft: pr.draft,
|
|
745
|
+
createdAt: pr.created_at,
|
|
746
|
+
updatedAt: pr.updated_at
|
|
747
|
+
}));
|
|
748
|
+
});
|
|
630
749
|
}
|
|
631
750
|
const getPullRequestInputSchema = z.object({
|
|
632
751
|
owner: z.string().describe("Repository owner"),
|
|
@@ -636,31 +755,33 @@ const getPullRequestInputSchema = z.object({
|
|
|
636
755
|
});
|
|
637
756
|
const getPullRequestDescription = "Get detailed information about a specific pull request. Body is truncated by default (detail: summary) — set detail full for the complete description";
|
|
638
757
|
async function getPullRequestCore({ token, owner, repo, pullNumber, detail = "summary" }) {
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
758
|
+
return withOctokit(token, async (octokit) => {
|
|
759
|
+
const { data } = await octokit.rest.pulls.get({
|
|
760
|
+
owner,
|
|
761
|
+
repo,
|
|
762
|
+
pull_number: pullNumber
|
|
763
|
+
});
|
|
764
|
+
return {
|
|
765
|
+
number: data.number,
|
|
766
|
+
title: data.title,
|
|
767
|
+
body: applyDetailBody(data.body, detail),
|
|
768
|
+
state: data.state,
|
|
769
|
+
url: data.html_url,
|
|
770
|
+
author: data.user?.login,
|
|
771
|
+
branch: data.head.ref,
|
|
772
|
+
headSha: data.head.sha,
|
|
773
|
+
base: data.base.ref,
|
|
774
|
+
draft: data.draft,
|
|
775
|
+
merged: data.merged,
|
|
776
|
+
mergeable: data.mergeable,
|
|
777
|
+
additions: data.additions,
|
|
778
|
+
deletions: data.deletions,
|
|
779
|
+
changedFiles: data.changed_files,
|
|
780
|
+
createdAt: data.created_at,
|
|
781
|
+
updatedAt: data.updated_at,
|
|
782
|
+
mergedAt: data.merged_at
|
|
783
|
+
};
|
|
643
784
|
});
|
|
644
|
-
return {
|
|
645
|
-
number: data.number,
|
|
646
|
-
title: data.title,
|
|
647
|
-
body: applyDetailBody(data.body, detail),
|
|
648
|
-
state: data.state,
|
|
649
|
-
url: data.html_url,
|
|
650
|
-
author: data.user?.login,
|
|
651
|
-
branch: data.head.ref,
|
|
652
|
-
headSha: data.head.sha,
|
|
653
|
-
base: data.base.ref,
|
|
654
|
-
draft: data.draft,
|
|
655
|
-
merged: data.merged,
|
|
656
|
-
mergeable: data.mergeable,
|
|
657
|
-
additions: data.additions,
|
|
658
|
-
deletions: data.deletions,
|
|
659
|
-
changedFiles: data.changed_files,
|
|
660
|
-
createdAt: data.created_at,
|
|
661
|
-
updatedAt: data.updated_at,
|
|
662
|
-
mergedAt: data.merged_at
|
|
663
|
-
};
|
|
664
785
|
}
|
|
665
786
|
const createPullRequestInputSchema = z.object({
|
|
666
787
|
owner: z.string().describe("Repository owner"),
|
|
@@ -674,24 +795,26 @@ const createPullRequestInputSchema = z.object({
|
|
|
674
795
|
const createPullRequestDescription = "Create a new pull request in a GitHub repository";
|
|
675
796
|
/** Not idempotent — each call creates a new pull request. */
|
|
676
797
|
async function createPullRequestCore({ token, owner, repo, title, body, head, base, draft }) {
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
798
|
+
return withOctokit(token, async (octokit) => {
|
|
799
|
+
const { data } = await octokit.rest.pulls.create({
|
|
800
|
+
owner,
|
|
801
|
+
repo,
|
|
802
|
+
title,
|
|
803
|
+
body,
|
|
804
|
+
head,
|
|
805
|
+
base,
|
|
806
|
+
draft
|
|
807
|
+
});
|
|
808
|
+
return {
|
|
809
|
+
number: data.number,
|
|
810
|
+
title: data.title,
|
|
811
|
+
url: data.html_url,
|
|
812
|
+
state: data.state,
|
|
813
|
+
draft: data.draft,
|
|
814
|
+
branch: data.head.ref,
|
|
815
|
+
base: data.base.ref
|
|
816
|
+
};
|
|
685
817
|
});
|
|
686
|
-
return {
|
|
687
|
-
number: data.number,
|
|
688
|
-
title: data.title,
|
|
689
|
-
url: data.html_url,
|
|
690
|
-
state: data.state,
|
|
691
|
-
draft: data.draft,
|
|
692
|
-
branch: data.head.ref,
|
|
693
|
-
base: data.base.ref
|
|
694
|
-
};
|
|
695
818
|
}
|
|
696
819
|
const MARK_READY_FOR_REVIEW_MUTATION = `
|
|
697
820
|
mutation($pullRequestId: ID!) {
|
|
@@ -720,26 +843,31 @@ const updatePullRequestInputSchema = z.object({
|
|
|
720
843
|
const updatePullRequestDescription = "Update a pull request — title, body, state, base branch, or draft status. Draft toggling uses the GitHub GraphQL API since the REST update endpoint does not support it";
|
|
721
844
|
/** Not idempotent — each call applies a new revision. */
|
|
722
845
|
async function updatePullRequestCore({ token, owner, repo, pullNumber, title, body, state, base, draft }) {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
846
|
+
return withOctokit(token, async (octokit) => {
|
|
847
|
+
const { data } = title !== void 0 || body !== void 0 || state !== void 0 || base !== void 0 ? await octokit.rest.pulls.update({
|
|
848
|
+
owner,
|
|
849
|
+
repo,
|
|
850
|
+
pull_number: pullNumber,
|
|
851
|
+
title,
|
|
852
|
+
body,
|
|
853
|
+
state,
|
|
854
|
+
base
|
|
855
|
+
}) : await octokit.rest.pulls.get({
|
|
856
|
+
owner,
|
|
857
|
+
repo,
|
|
858
|
+
pull_number: pullNumber
|
|
859
|
+
});
|
|
860
|
+
if (draft !== void 0 && draft !== data.draft) await octokit.graphql(draft ? CONVERT_TO_DRAFT_MUTATION : MARK_READY_FOR_REVIEW_MUTATION, { pullRequestId: data.node_id });
|
|
861
|
+
return {
|
|
862
|
+
number: data.number,
|
|
863
|
+
title: data.title,
|
|
864
|
+
state: data.state,
|
|
865
|
+
draft: draft ?? data.draft,
|
|
866
|
+
url: data.html_url,
|
|
867
|
+
base: data.base.ref,
|
|
868
|
+
updatedAt: data.updated_at
|
|
869
|
+
};
|
|
732
870
|
});
|
|
733
|
-
if (draft !== void 0 && draft !== data.draft) await octokit.graphql(draft ? CONVERT_TO_DRAFT_MUTATION : MARK_READY_FOR_REVIEW_MUTATION, { pullRequestId: data.node_id });
|
|
734
|
-
return {
|
|
735
|
-
number: data.number,
|
|
736
|
-
title: data.title,
|
|
737
|
-
state: data.state,
|
|
738
|
-
draft: draft ?? data.draft,
|
|
739
|
-
url: data.html_url,
|
|
740
|
-
base: data.base.ref,
|
|
741
|
-
updatedAt: data.updated_at
|
|
742
|
-
};
|
|
743
871
|
}
|
|
744
872
|
const mergePullRequestInputSchema = z.object({
|
|
745
873
|
owner: z.string().describe("Repository owner"),
|
|
@@ -756,21 +884,22 @@ const mergePullRequestInputSchema = z.object({
|
|
|
756
884
|
const mergePullRequestDescription = "Merge a pull request";
|
|
757
885
|
/** Not idempotent — merging an already-merged PR returns an error from GitHub. */
|
|
758
886
|
async function mergePullRequestCore({ token, owner, repo, pullNumber, commitTitle, commitMessage, mergeMethod, coAuthors }) {
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
887
|
+
return withOctokit(token, async (octokit) => {
|
|
888
|
+
const finalMessage = composeCommitMessage(commitMessage ?? "", coAuthors) || void 0;
|
|
889
|
+
const { data } = await octokit.rest.pulls.merge({
|
|
890
|
+
owner,
|
|
891
|
+
repo,
|
|
892
|
+
pull_number: pullNumber,
|
|
893
|
+
commit_title: commitTitle,
|
|
894
|
+
commit_message: finalMessage,
|
|
895
|
+
merge_method: mergeMethod
|
|
896
|
+
});
|
|
897
|
+
return {
|
|
898
|
+
merged: data.merged,
|
|
899
|
+
message: data.message,
|
|
900
|
+
sha: data.sha
|
|
901
|
+
};
|
|
768
902
|
});
|
|
769
|
-
return {
|
|
770
|
-
merged: data.merged,
|
|
771
|
-
message: data.message,
|
|
772
|
-
sha: data.sha
|
|
773
|
-
};
|
|
774
903
|
}
|
|
775
904
|
const addPullRequestCommentInputSchema = z.object({
|
|
776
905
|
owner: z.string().describe("Repository owner"),
|
|
@@ -781,19 +910,21 @@ const addPullRequestCommentInputSchema = z.object({
|
|
|
781
910
|
const addPullRequestCommentDescription = "Add a comment to a pull request";
|
|
782
911
|
/** Not idempotent — each call adds another comment. */
|
|
783
912
|
async function addPullRequestCommentCore({ token, owner, repo, pullNumber, body }) {
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
913
|
+
return withOctokit(token, async (octokit) => {
|
|
914
|
+
const { data } = await octokit.rest.issues.createComment({
|
|
915
|
+
owner,
|
|
916
|
+
repo,
|
|
917
|
+
issue_number: pullNumber,
|
|
918
|
+
body
|
|
919
|
+
});
|
|
920
|
+
return {
|
|
921
|
+
id: data.id,
|
|
922
|
+
url: data.html_url,
|
|
923
|
+
body: data.body,
|
|
924
|
+
author: data.user?.login,
|
|
925
|
+
createdAt: data.created_at
|
|
926
|
+
};
|
|
789
927
|
});
|
|
790
|
-
return {
|
|
791
|
-
id: data.id,
|
|
792
|
-
url: data.html_url,
|
|
793
|
-
body: data.body,
|
|
794
|
-
author: data.user?.login,
|
|
795
|
-
createdAt: data.created_at
|
|
796
|
-
};
|
|
797
928
|
}
|
|
798
929
|
const updatePullRequestCommentInputSchema = z.object({
|
|
799
930
|
owner: z.string().describe("Repository owner"),
|
|
@@ -804,18 +935,20 @@ const updatePullRequestCommentInputSchema = z.object({
|
|
|
804
935
|
const updatePullRequestCommentDescription = "Update the body of a comment on a pull request";
|
|
805
936
|
/** Not idempotent — each call applies a new revision. */
|
|
806
937
|
async function updatePullRequestCommentCore({ token, owner, repo, commentId, body }) {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
938
|
+
return withOctokit(token, async (octokit) => {
|
|
939
|
+
const { data } = await octokit.rest.issues.updateComment({
|
|
940
|
+
owner,
|
|
941
|
+
repo,
|
|
942
|
+
comment_id: commentId,
|
|
943
|
+
body
|
|
944
|
+
});
|
|
945
|
+
return {
|
|
946
|
+
id: data.id,
|
|
947
|
+
url: data.html_url,
|
|
948
|
+
body: data.body,
|
|
949
|
+
updatedAt: data.updated_at
|
|
950
|
+
};
|
|
812
951
|
});
|
|
813
|
-
return {
|
|
814
|
-
id: data.id,
|
|
815
|
-
url: data.html_url,
|
|
816
|
-
body: data.body,
|
|
817
|
-
updatedAt: data.updated_at
|
|
818
|
-
};
|
|
819
952
|
}
|
|
820
953
|
const deletePullRequestCommentInputSchema = z.object({
|
|
821
954
|
owner: z.string().describe("Repository owner"),
|
|
@@ -825,15 +958,17 @@ const deletePullRequestCommentInputSchema = z.object({
|
|
|
825
958
|
const deletePullRequestCommentDescription = "Delete a comment from a pull request permanently";
|
|
826
959
|
/** Not idempotent — deleting an already-deleted comment returns 404 from GitHub. */
|
|
827
960
|
async function deletePullRequestCommentCore({ token, owner, repo, commentId }) {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
961
|
+
return withOctokit(token, async (octokit) => {
|
|
962
|
+
await octokit.rest.issues.deleteComment({
|
|
963
|
+
owner,
|
|
964
|
+
repo,
|
|
965
|
+
comment_id: commentId
|
|
966
|
+
});
|
|
967
|
+
return {
|
|
968
|
+
deleted: true,
|
|
969
|
+
commentId
|
|
970
|
+
};
|
|
832
971
|
});
|
|
833
|
-
return {
|
|
834
|
-
deleted: true,
|
|
835
|
-
commentId
|
|
836
|
-
};
|
|
837
972
|
}
|
|
838
973
|
const listPullRequestFilesInputSchema = z.object({
|
|
839
974
|
owner: z.string().describe("Repository owner"),
|
|
@@ -846,22 +981,24 @@ const listPullRequestFilesInputSchema = z.object({
|
|
|
846
981
|
});
|
|
847
982
|
const listPullRequestFilesDescription = "List files changed in a pull request with status and stats. Patches are omitted by default — set includePatch true (optionally with filenames) to fetch diffs";
|
|
848
983
|
async function listPullRequestFilesCore({ token, owner, repo, pullNumber, includePatch, filenames, perPage, page }) {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
984
|
+
return withOctokit(token, async (octokit) => {
|
|
985
|
+
const { data } = await octokit.rest.pulls.listFiles({
|
|
986
|
+
owner,
|
|
987
|
+
repo,
|
|
988
|
+
pull_number: pullNumber,
|
|
989
|
+
per_page: perPage,
|
|
990
|
+
page
|
|
991
|
+
});
|
|
992
|
+
const filenameSet = filenames?.length ? new Set(filenames) : null;
|
|
993
|
+
return data.filter((file) => !filenameSet || filenameSet.has(file.filename)).map((file) => ({
|
|
994
|
+
filename: file.filename,
|
|
995
|
+
status: file.status,
|
|
996
|
+
additions: file.additions,
|
|
997
|
+
deletions: file.deletions,
|
|
998
|
+
changes: file.changes,
|
|
999
|
+
...includePatch && file.patch != null ? { patch: file.patch } : {}
|
|
1000
|
+
}));
|
|
1001
|
+
});
|
|
865
1002
|
}
|
|
866
1003
|
const listPullRequestReviewsInputSchema = z.object({
|
|
867
1004
|
owner: z.string().describe("Repository owner"),
|
|
@@ -872,21 +1009,23 @@ const listPullRequestReviewsInputSchema = z.object({
|
|
|
872
1009
|
});
|
|
873
1010
|
const listPullRequestReviewsDescription = "List reviews on a pull request (approvals, change requests, and comments)";
|
|
874
1011
|
async function listPullRequestReviewsCore({ token, owner, repo, pullNumber, perPage, page }) {
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
1012
|
+
return withOctokit(token, async (octokit) => {
|
|
1013
|
+
const { data } = await octokit.rest.pulls.listReviews({
|
|
1014
|
+
owner,
|
|
1015
|
+
repo,
|
|
1016
|
+
pull_number: pullNumber,
|
|
1017
|
+
per_page: perPage,
|
|
1018
|
+
page
|
|
1019
|
+
});
|
|
1020
|
+
return data.map((review) => ({
|
|
1021
|
+
id: review.id,
|
|
1022
|
+
state: review.state,
|
|
1023
|
+
body: review.body,
|
|
1024
|
+
author: review.user?.login,
|
|
1025
|
+
url: review.html_url,
|
|
1026
|
+
submittedAt: review.submitted_at
|
|
1027
|
+
}));
|
|
1028
|
+
});
|
|
890
1029
|
}
|
|
891
1030
|
const createPullRequestReviewInputSchema = z.object({
|
|
892
1031
|
owner: z.string().describe("Repository owner"),
|
|
@@ -908,22 +1047,24 @@ const createPullRequestReviewInputSchema = z.object({
|
|
|
908
1047
|
const createPullRequestReviewDescription = "Submit a pull request review — approve, request changes, or comment with optional inline comments on specific lines";
|
|
909
1048
|
/** Not idempotent — each call submits a new review. */
|
|
910
1049
|
async function createPullRequestReviewCore({ token, owner, repo, pullNumber, body, event, comments }) {
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
1050
|
+
return withOctokit(token, async (octokit) => {
|
|
1051
|
+
const { data } = await octokit.rest.pulls.createReview({
|
|
1052
|
+
owner,
|
|
1053
|
+
repo,
|
|
1054
|
+
pull_number: pullNumber,
|
|
1055
|
+
body,
|
|
1056
|
+
event,
|
|
1057
|
+
comments
|
|
1058
|
+
});
|
|
1059
|
+
return {
|
|
1060
|
+
id: data.id,
|
|
1061
|
+
state: data.state,
|
|
1062
|
+
body: data.body,
|
|
1063
|
+
url: data.html_url,
|
|
1064
|
+
author: data.user?.login,
|
|
1065
|
+
submittedAt: data.submitted_at
|
|
1066
|
+
};
|
|
918
1067
|
});
|
|
919
|
-
return {
|
|
920
|
-
id: data.id,
|
|
921
|
-
state: data.state,
|
|
922
|
-
body: data.body,
|
|
923
|
-
url: data.html_url,
|
|
924
|
-
author: data.user?.login,
|
|
925
|
-
submittedAt: data.submitted_at
|
|
926
|
-
};
|
|
927
1068
|
}
|
|
928
1069
|
const requestReviewersInputSchema = z.object({
|
|
929
1070
|
owner: z.string().describe("Repository owner"),
|
|
@@ -935,19 +1076,21 @@ const requestReviewersInputSchema = z.object({
|
|
|
935
1076
|
const requestReviewersDescription = "Request reviews from users or teams on a pull request";
|
|
936
1077
|
/** Not idempotent — re-requesting an existing reviewer is a no-op on GitHub but still mutates. */
|
|
937
1078
|
async function requestReviewersCore({ token, owner, repo, pullNumber, reviewers, teamReviewers }) {
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
1079
|
+
return withOctokit(token, async (octokit) => {
|
|
1080
|
+
const { data } = await octokit.rest.pulls.requestReviewers({
|
|
1081
|
+
owner,
|
|
1082
|
+
repo,
|
|
1083
|
+
pull_number: pullNumber,
|
|
1084
|
+
reviewers,
|
|
1085
|
+
team_reviewers: teamReviewers
|
|
1086
|
+
});
|
|
1087
|
+
return {
|
|
1088
|
+
number: data.number,
|
|
1089
|
+
url: data.html_url,
|
|
1090
|
+
requestedReviewers: data.requested_reviewers?.map((r) => r.login),
|
|
1091
|
+
requestedTeams: data.requested_teams?.map((t) => t.slug)
|
|
1092
|
+
};
|
|
944
1093
|
});
|
|
945
|
-
return {
|
|
946
|
-
number: data.number,
|
|
947
|
-
url: data.html_url,
|
|
948
|
-
requestedReviewers: data.requested_reviewers?.map((r) => r.login),
|
|
949
|
-
requestedTeams: data.requested_teams?.map((t) => t.slug)
|
|
950
|
-
};
|
|
951
1094
|
}
|
|
952
1095
|
//#endregion
|
|
953
1096
|
//#region src/core/issues.ts
|
|
@@ -965,27 +1108,28 @@ const listIssuesInputSchema = z.object({
|
|
|
965
1108
|
});
|
|
966
1109
|
const listIssuesDescription = "List issues for a GitHub repository (excludes pull requests)";
|
|
967
1110
|
async function listIssuesCore({ token, owner, repo, state, labels, perPage, maxPages }) {
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1111
|
+
return withOctokit(token, async (octokit) => {
|
|
1112
|
+
return (await fetchAllPages(async (page) => {
|
|
1113
|
+
const { data } = await octokit.rest.issues.listForRepo({
|
|
1114
|
+
owner,
|
|
1115
|
+
repo,
|
|
1116
|
+
state,
|
|
1117
|
+
labels,
|
|
1118
|
+
per_page: perPage,
|
|
1119
|
+
page
|
|
1120
|
+
});
|
|
1121
|
+
return data;
|
|
1122
|
+
}, perPage, maxPages)).filter((issue) => !issue.pull_request).map((issue) => ({
|
|
1123
|
+
number: issue.number,
|
|
1124
|
+
title: issue.title,
|
|
1125
|
+
state: issue.state,
|
|
1126
|
+
url: issue.html_url,
|
|
1127
|
+
author: issue.user?.login,
|
|
1128
|
+
labels: issue.labels.map((l) => typeof l === "string" ? l : l.name),
|
|
1129
|
+
createdAt: issue.created_at,
|
|
1130
|
+
updatedAt: issue.updated_at
|
|
1131
|
+
}));
|
|
1132
|
+
});
|
|
989
1133
|
}
|
|
990
1134
|
const getIssueInputSchema = z.object({
|
|
991
1135
|
owner: z.string().describe("Repository owner"),
|
|
@@ -995,25 +1139,27 @@ const getIssueInputSchema = z.object({
|
|
|
995
1139
|
});
|
|
996
1140
|
const getIssueDescription = "Get detailed information about a specific issue. Body is truncated by default (detail: summary) — set detail full for the complete description";
|
|
997
1141
|
async function getIssueCore({ token, owner, repo, issueNumber, detail = "summary" }) {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1142
|
+
return withOctokit(token, async (octokit) => {
|
|
1143
|
+
const { data } = await octokit.rest.issues.get({
|
|
1144
|
+
owner,
|
|
1145
|
+
repo,
|
|
1146
|
+
issue_number: issueNumber
|
|
1147
|
+
});
|
|
1148
|
+
return {
|
|
1149
|
+
number: data.number,
|
|
1150
|
+
title: data.title,
|
|
1151
|
+
body: applyDetailBody(data.body, detail),
|
|
1152
|
+
state: data.state,
|
|
1153
|
+
url: data.html_url,
|
|
1154
|
+
author: data.user?.login,
|
|
1155
|
+
assignees: data.assignees?.map((a) => a.login),
|
|
1156
|
+
labels: data.labels.map((l) => typeof l === "string" ? l : l.name),
|
|
1157
|
+
comments: data.comments,
|
|
1158
|
+
createdAt: data.created_at,
|
|
1159
|
+
updatedAt: data.updated_at,
|
|
1160
|
+
closedAt: data.closed_at
|
|
1161
|
+
};
|
|
1002
1162
|
});
|
|
1003
|
-
return {
|
|
1004
|
-
number: data.number,
|
|
1005
|
-
title: data.title,
|
|
1006
|
-
body: applyDetailBody(data.body, detail),
|
|
1007
|
-
state: data.state,
|
|
1008
|
-
url: data.html_url,
|
|
1009
|
-
author: data.user?.login,
|
|
1010
|
-
assignees: data.assignees?.map((a) => a.login),
|
|
1011
|
-
labels: data.labels.map((l) => typeof l === "string" ? l : l.name),
|
|
1012
|
-
comments: data.comments,
|
|
1013
|
-
createdAt: data.created_at,
|
|
1014
|
-
updatedAt: data.updated_at,
|
|
1015
|
-
closedAt: data.closed_at
|
|
1016
|
-
};
|
|
1017
1163
|
}
|
|
1018
1164
|
const listIssueCommentsInputSchema = z.object({
|
|
1019
1165
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1025,21 +1171,23 @@ const listIssueCommentsInputSchema = z.object({
|
|
|
1025
1171
|
});
|
|
1026
1172
|
const listIssueCommentsDescription = "List comments on a GitHub issue. Bodies are truncated by default (detail: summary)";
|
|
1027
1173
|
async function listIssueCommentsCore({ token, owner, repo, issueNumber, perPage, page, detail = "summary" }) {
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1174
|
+
return withOctokit(token, async (octokit) => {
|
|
1175
|
+
const { data } = await octokit.rest.issues.listComments({
|
|
1176
|
+
owner,
|
|
1177
|
+
repo,
|
|
1178
|
+
issue_number: issueNumber,
|
|
1179
|
+
per_page: perPage,
|
|
1180
|
+
page
|
|
1181
|
+
});
|
|
1182
|
+
return data.map((comment) => ({
|
|
1183
|
+
id: comment.id,
|
|
1184
|
+
url: comment.html_url,
|
|
1185
|
+
body: applyDetailBody(comment.body, detail),
|
|
1186
|
+
author: comment.user?.login,
|
|
1187
|
+
createdAt: comment.created_at,
|
|
1188
|
+
updatedAt: comment.updated_at
|
|
1189
|
+
}));
|
|
1190
|
+
});
|
|
1043
1191
|
}
|
|
1044
1192
|
const createIssueInputSchema = z.object({
|
|
1045
1193
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1052,21 +1200,23 @@ const createIssueInputSchema = z.object({
|
|
|
1052
1200
|
const createIssueDescription = "Create a new issue in a GitHub repository";
|
|
1053
1201
|
/** Not idempotent — each call creates a new issue. */
|
|
1054
1202
|
async function createIssueCore({ token, owner, repo, title, body, labels, assignees }) {
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1203
|
+
return withOctokit(token, async (octokit) => {
|
|
1204
|
+
const { data } = await octokit.rest.issues.create({
|
|
1205
|
+
owner,
|
|
1206
|
+
repo,
|
|
1207
|
+
title,
|
|
1208
|
+
body,
|
|
1209
|
+
labels,
|
|
1210
|
+
assignees
|
|
1211
|
+
});
|
|
1212
|
+
return {
|
|
1213
|
+
number: data.number,
|
|
1214
|
+
title: data.title,
|
|
1215
|
+
url: data.html_url,
|
|
1216
|
+
state: data.state,
|
|
1217
|
+
labels: data.labels.map((l) => typeof l === "string" ? l : l.name)
|
|
1218
|
+
};
|
|
1062
1219
|
});
|
|
1063
|
-
return {
|
|
1064
|
-
number: data.number,
|
|
1065
|
-
title: data.title,
|
|
1066
|
-
url: data.html_url,
|
|
1067
|
-
state: data.state,
|
|
1068
|
-
labels: data.labels.map((l) => typeof l === "string" ? l : l.name)
|
|
1069
|
-
};
|
|
1070
1220
|
}
|
|
1071
1221
|
const addIssueCommentInputSchema = z.object({
|
|
1072
1222
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1077,19 +1227,21 @@ const addIssueCommentInputSchema = z.object({
|
|
|
1077
1227
|
const addIssueCommentDescription = "Add a comment to a GitHub issue";
|
|
1078
1228
|
/** Not idempotent — each call adds another comment. */
|
|
1079
1229
|
async function addIssueCommentCore({ token, owner, repo, issueNumber, body }) {
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1230
|
+
return withOctokit(token, async (octokit) => {
|
|
1231
|
+
const { data } = await octokit.rest.issues.createComment({
|
|
1232
|
+
owner,
|
|
1233
|
+
repo,
|
|
1234
|
+
issue_number: issueNumber,
|
|
1235
|
+
body
|
|
1236
|
+
});
|
|
1237
|
+
return {
|
|
1238
|
+
id: data.id,
|
|
1239
|
+
url: data.html_url,
|
|
1240
|
+
body: data.body,
|
|
1241
|
+
author: data.user?.login,
|
|
1242
|
+
createdAt: data.created_at
|
|
1243
|
+
};
|
|
1085
1244
|
});
|
|
1086
|
-
return {
|
|
1087
|
-
id: data.id,
|
|
1088
|
-
url: data.html_url,
|
|
1089
|
-
body: data.body,
|
|
1090
|
-
author: data.user?.login,
|
|
1091
|
-
createdAt: data.created_at
|
|
1092
|
-
};
|
|
1093
1245
|
}
|
|
1094
1246
|
const closeIssueInputSchema = z.object({
|
|
1095
1247
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1100,33 +1252,34 @@ const closeIssueInputSchema = z.object({
|
|
|
1100
1252
|
const closeIssueDescription = "Close an open GitHub issue";
|
|
1101
1253
|
/** Idempotent when the issue is already closed. */
|
|
1102
1254
|
async function closeIssueCore({ token, owner, repo, issueNumber, stateReason }) {
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1255
|
+
return withOctokit(token, async (octokit) => {
|
|
1256
|
+
const { data: existing } = await octokit.rest.issues.get({
|
|
1257
|
+
owner,
|
|
1258
|
+
repo,
|
|
1259
|
+
issue_number: issueNumber
|
|
1260
|
+
});
|
|
1261
|
+
if (existing.state === "closed") return {
|
|
1262
|
+
number: existing.number,
|
|
1263
|
+
title: existing.title,
|
|
1264
|
+
state: existing.state,
|
|
1265
|
+
url: existing.html_url,
|
|
1266
|
+
closedAt: existing.closed_at
|
|
1267
|
+
};
|
|
1268
|
+
const { data } = await octokit.rest.issues.update({
|
|
1269
|
+
owner,
|
|
1270
|
+
repo,
|
|
1271
|
+
issue_number: issueNumber,
|
|
1272
|
+
state: "closed",
|
|
1273
|
+
state_reason: stateReason
|
|
1274
|
+
});
|
|
1275
|
+
return {
|
|
1276
|
+
number: data.number,
|
|
1277
|
+
title: data.title,
|
|
1278
|
+
state: data.state,
|
|
1279
|
+
url: data.html_url,
|
|
1280
|
+
closedAt: data.closed_at
|
|
1281
|
+
};
|
|
1122
1282
|
});
|
|
1123
|
-
return {
|
|
1124
|
-
number: data.number,
|
|
1125
|
-
title: data.title,
|
|
1126
|
-
state: data.state,
|
|
1127
|
-
url: data.html_url,
|
|
1128
|
-
closedAt: data.closed_at
|
|
1129
|
-
};
|
|
1130
1283
|
}
|
|
1131
1284
|
const updateIssueInputSchema = z.object({
|
|
1132
1285
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1147,29 +1300,31 @@ const updateIssueInputSchema = z.object({
|
|
|
1147
1300
|
const updateIssueDescription = "Update a GitHub issue — title, body, labels, milestone, or assignees. Set state open to reopen a closed issue, or closed to close it";
|
|
1148
1301
|
/** Not idempotent — each call applies a new revision. */
|
|
1149
1302
|
async function updateIssueCore({ token, owner, repo, issueNumber, title, body, state, stateReason, labels, milestone, assignees }) {
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1303
|
+
return withOctokit(token, async (octokit) => {
|
|
1304
|
+
const { data } = await octokit.rest.issues.update({
|
|
1305
|
+
owner,
|
|
1306
|
+
repo,
|
|
1307
|
+
issue_number: issueNumber,
|
|
1308
|
+
title,
|
|
1309
|
+
body,
|
|
1310
|
+
state,
|
|
1311
|
+
state_reason: stateReason,
|
|
1312
|
+
labels,
|
|
1313
|
+
milestone,
|
|
1314
|
+
assignees
|
|
1315
|
+
});
|
|
1316
|
+
return {
|
|
1317
|
+
number: data.number,
|
|
1318
|
+
title: data.title,
|
|
1319
|
+
state: data.state,
|
|
1320
|
+
url: data.html_url,
|
|
1321
|
+
labels: data.labels.map((l) => typeof l === "string" ? l : l.name),
|
|
1322
|
+
assignees: data.assignees?.map((a) => a.login),
|
|
1323
|
+
milestone: data.milestone?.number ?? null,
|
|
1324
|
+
closedAt: data.closed_at,
|
|
1325
|
+
updatedAt: data.updated_at
|
|
1326
|
+
};
|
|
1161
1327
|
});
|
|
1162
|
-
return {
|
|
1163
|
-
number: data.number,
|
|
1164
|
-
title: data.title,
|
|
1165
|
-
state: data.state,
|
|
1166
|
-
url: data.html_url,
|
|
1167
|
-
labels: data.labels.map((l) => typeof l === "string" ? l : l.name),
|
|
1168
|
-
assignees: data.assignees?.map((a) => a.login),
|
|
1169
|
-
milestone: data.milestone?.number ?? null,
|
|
1170
|
-
closedAt: data.closed_at,
|
|
1171
|
-
updatedAt: data.updated_at
|
|
1172
|
-
};
|
|
1173
1328
|
}
|
|
1174
1329
|
const updateIssueCommentInputSchema = z.object({
|
|
1175
1330
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1180,18 +1335,20 @@ const updateIssueCommentInputSchema = z.object({
|
|
|
1180
1335
|
const updateIssueCommentDescription = "Update the body of a comment on a GitHub issue";
|
|
1181
1336
|
/** Not idempotent — each call applies a new revision. */
|
|
1182
1337
|
async function updateIssueCommentCore({ token, owner, repo, commentId, body }) {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1338
|
+
return withOctokit(token, async (octokit) => {
|
|
1339
|
+
const { data } = await octokit.rest.issues.updateComment({
|
|
1340
|
+
owner,
|
|
1341
|
+
repo,
|
|
1342
|
+
comment_id: commentId,
|
|
1343
|
+
body
|
|
1344
|
+
});
|
|
1345
|
+
return {
|
|
1346
|
+
id: data.id,
|
|
1347
|
+
url: data.html_url,
|
|
1348
|
+
body: data.body,
|
|
1349
|
+
updatedAt: data.updated_at
|
|
1350
|
+
};
|
|
1188
1351
|
});
|
|
1189
|
-
return {
|
|
1190
|
-
id: data.id,
|
|
1191
|
-
url: data.html_url,
|
|
1192
|
-
body: data.body,
|
|
1193
|
-
updatedAt: data.updated_at
|
|
1194
|
-
};
|
|
1195
1352
|
}
|
|
1196
1353
|
const deleteIssueCommentInputSchema = z.object({
|
|
1197
1354
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1201,15 +1358,17 @@ const deleteIssueCommentInputSchema = z.object({
|
|
|
1201
1358
|
const deleteIssueCommentDescription = "Delete a comment from a GitHub issue permanently";
|
|
1202
1359
|
/** Not idempotent — deleting an already-deleted comment returns 404 from GitHub. */
|
|
1203
1360
|
async function deleteIssueCommentCore({ token, owner, repo, commentId }) {
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1361
|
+
return withOctokit(token, async (octokit) => {
|
|
1362
|
+
await octokit.rest.issues.deleteComment({
|
|
1363
|
+
owner,
|
|
1364
|
+
repo,
|
|
1365
|
+
comment_id: commentId
|
|
1366
|
+
});
|
|
1367
|
+
return {
|
|
1368
|
+
deleted: true,
|
|
1369
|
+
commentId
|
|
1370
|
+
};
|
|
1208
1371
|
});
|
|
1209
|
-
return {
|
|
1210
|
-
deleted: true,
|
|
1211
|
-
commentId
|
|
1212
|
-
};
|
|
1213
1372
|
}
|
|
1214
1373
|
const listLabelsInputSchema = z.object({
|
|
1215
1374
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1219,17 +1378,19 @@ const listLabelsInputSchema = z.object({
|
|
|
1219
1378
|
});
|
|
1220
1379
|
const listLabelsDescription = "List labels available in a GitHub repository";
|
|
1221
1380
|
async function listLabelsCore({ token, owner, repo, perPage, page }) {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1381
|
+
return withOctokit(token, async (octokit) => {
|
|
1382
|
+
const { data } = await octokit.rest.issues.listLabelsForRepo({
|
|
1383
|
+
owner,
|
|
1384
|
+
repo,
|
|
1385
|
+
per_page: perPage,
|
|
1386
|
+
page
|
|
1387
|
+
});
|
|
1388
|
+
return data.map((label) => ({
|
|
1389
|
+
name: label.name,
|
|
1390
|
+
color: label.color,
|
|
1391
|
+
description: label.description
|
|
1392
|
+
}));
|
|
1227
1393
|
});
|
|
1228
|
-
return data.map((label) => ({
|
|
1229
|
-
name: label.name,
|
|
1230
|
-
color: label.color,
|
|
1231
|
-
description: label.description
|
|
1232
|
-
}));
|
|
1233
1394
|
}
|
|
1234
1395
|
const addLabelsInputSchema = z.object({
|
|
1235
1396
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1240,17 +1401,19 @@ const addLabelsInputSchema = z.object({
|
|
|
1240
1401
|
const addLabelsDescription = "Add labels to an issue or pull request";
|
|
1241
1402
|
/** Not idempotent — re-adding labels is a no-op on GitHub but still mutates. */
|
|
1242
1403
|
async function addLabelsCore({ token, owner, repo, issueNumber, labels }) {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1404
|
+
return withOctokit(token, async (octokit) => {
|
|
1405
|
+
const { data } = await octokit.rest.issues.addLabels({
|
|
1406
|
+
owner,
|
|
1407
|
+
repo,
|
|
1408
|
+
issue_number: issueNumber,
|
|
1409
|
+
labels
|
|
1410
|
+
});
|
|
1411
|
+
return data.map((label) => ({
|
|
1412
|
+
name: label.name,
|
|
1413
|
+
color: label.color,
|
|
1414
|
+
description: label.description
|
|
1415
|
+
}));
|
|
1248
1416
|
});
|
|
1249
|
-
return data.map((label) => ({
|
|
1250
|
-
name: label.name,
|
|
1251
|
-
color: label.color,
|
|
1252
|
-
description: label.description
|
|
1253
|
-
}));
|
|
1254
1417
|
}
|
|
1255
1418
|
const removeLabelInputSchema = z.object({
|
|
1256
1419
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1261,17 +1424,19 @@ const removeLabelInputSchema = z.object({
|
|
|
1261
1424
|
const removeLabelDescription = "Remove a label from an issue or pull request";
|
|
1262
1425
|
/** Not idempotent — removing a missing label returns 404 from GitHub. */
|
|
1263
1426
|
async function removeLabelCore({ token, owner, repo, issueNumber, label }) {
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1427
|
+
return withOctokit(token, async (octokit) => {
|
|
1428
|
+
await octokit.rest.issues.removeLabel({
|
|
1429
|
+
owner,
|
|
1430
|
+
repo,
|
|
1431
|
+
issue_number: issueNumber,
|
|
1432
|
+
name: label
|
|
1433
|
+
});
|
|
1434
|
+
return {
|
|
1435
|
+
removed: true,
|
|
1436
|
+
label,
|
|
1437
|
+
issueNumber
|
|
1438
|
+
};
|
|
1269
1439
|
});
|
|
1270
|
-
return {
|
|
1271
|
-
removed: true,
|
|
1272
|
-
label,
|
|
1273
|
-
issueNumber
|
|
1274
|
-
};
|
|
1275
1440
|
}
|
|
1276
1441
|
const createLabelInputSchema = z.object({
|
|
1277
1442
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1283,18 +1448,20 @@ const createLabelInputSchema = z.object({
|
|
|
1283
1448
|
const createLabelDescription = "Create a label in a GitHub repository";
|
|
1284
1449
|
/** Not idempotent — creating a label that already exists returns 422 from GitHub. */
|
|
1285
1450
|
async function createLabelCore({ token, owner, repo, name, color, description }) {
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1451
|
+
return withOctokit(token, async (octokit) => {
|
|
1452
|
+
const { data } = await octokit.rest.issues.createLabel({
|
|
1453
|
+
owner,
|
|
1454
|
+
repo,
|
|
1455
|
+
name,
|
|
1456
|
+
color,
|
|
1457
|
+
description
|
|
1458
|
+
});
|
|
1459
|
+
return {
|
|
1460
|
+
name: data.name,
|
|
1461
|
+
color: data.color,
|
|
1462
|
+
description: data.description
|
|
1463
|
+
};
|
|
1292
1464
|
});
|
|
1293
|
-
return {
|
|
1294
|
-
name: data.name,
|
|
1295
|
-
color: data.color,
|
|
1296
|
-
description: data.description
|
|
1297
|
-
};
|
|
1298
1465
|
}
|
|
1299
1466
|
const updateLabelInputSchema = z.object({
|
|
1300
1467
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1307,19 +1474,21 @@ const updateLabelInputSchema = z.object({
|
|
|
1307
1474
|
const updateLabelDescription = "Update a label in a GitHub repository — name, color, or description";
|
|
1308
1475
|
/** Not idempotent — each call applies a new revision. */
|
|
1309
1476
|
async function updateLabelCore({ token, owner, repo, name, newName, color, description }) {
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1477
|
+
return withOctokit(token, async (octokit) => {
|
|
1478
|
+
const { data } = await octokit.rest.issues.updateLabel({
|
|
1479
|
+
owner,
|
|
1480
|
+
repo,
|
|
1481
|
+
name,
|
|
1482
|
+
new_name: newName,
|
|
1483
|
+
color,
|
|
1484
|
+
description: description === null ? "" : description
|
|
1485
|
+
});
|
|
1486
|
+
return {
|
|
1487
|
+
name: data.name,
|
|
1488
|
+
color: data.color,
|
|
1489
|
+
description: data.description
|
|
1490
|
+
};
|
|
1317
1491
|
});
|
|
1318
|
-
return {
|
|
1319
|
-
name: data.name,
|
|
1320
|
-
color: data.color,
|
|
1321
|
-
description: data.description
|
|
1322
|
-
};
|
|
1323
1492
|
}
|
|
1324
1493
|
const deleteLabelInputSchema = z.object({
|
|
1325
1494
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1329,15 +1498,17 @@ const deleteLabelInputSchema = z.object({
|
|
|
1329
1498
|
const deleteLabelDescription = "Delete a label from a GitHub repository permanently";
|
|
1330
1499
|
/** Not idempotent — deleting a missing label returns 404 from GitHub. */
|
|
1331
1500
|
async function deleteLabelCore({ token, owner, repo, name }) {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1501
|
+
return withOctokit(token, async (octokit) => {
|
|
1502
|
+
await octokit.rest.issues.deleteLabel({
|
|
1503
|
+
owner,
|
|
1504
|
+
repo,
|
|
1505
|
+
name
|
|
1506
|
+
});
|
|
1507
|
+
return {
|
|
1508
|
+
deleted: true,
|
|
1509
|
+
name
|
|
1510
|
+
};
|
|
1336
1511
|
});
|
|
1337
|
-
return {
|
|
1338
|
-
deleted: true,
|
|
1339
|
-
name
|
|
1340
|
-
};
|
|
1341
1512
|
}
|
|
1342
1513
|
const addAssigneesInputSchema = z.object({
|
|
1343
1514
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1348,16 +1519,18 @@ const addAssigneesInputSchema = z.object({
|
|
|
1348
1519
|
const addAssigneesDescription = "Assign users to an issue or pull request";
|
|
1349
1520
|
/** Not idempotent — re-adding an existing assignee is a no-op on GitHub but still mutates. */
|
|
1350
1521
|
async function addAssigneesCore({ token, owner, repo, issueNumber, assignees }) {
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1522
|
+
return withOctokit(token, async (octokit) => {
|
|
1523
|
+
const { data } = await octokit.rest.issues.addAssignees({
|
|
1524
|
+
owner,
|
|
1525
|
+
repo,
|
|
1526
|
+
issue_number: issueNumber,
|
|
1527
|
+
assignees
|
|
1528
|
+
});
|
|
1529
|
+
return {
|
|
1530
|
+
number: data.number,
|
|
1531
|
+
assignees: data.assignees?.map((a) => a.login)
|
|
1532
|
+
};
|
|
1356
1533
|
});
|
|
1357
|
-
return {
|
|
1358
|
-
number: data.number,
|
|
1359
|
-
assignees: data.assignees?.map((a) => a.login)
|
|
1360
|
-
};
|
|
1361
1534
|
}
|
|
1362
1535
|
const removeAssigneesInputSchema = z.object({
|
|
1363
1536
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1368,16 +1541,18 @@ const removeAssigneesInputSchema = z.object({
|
|
|
1368
1541
|
const removeAssigneesDescription = "Remove assignees from an issue or pull request";
|
|
1369
1542
|
/** Idempotent — removing an assignee that is not assigned is a no-op on GitHub. */
|
|
1370
1543
|
async function removeAssigneesCore({ token, owner, repo, issueNumber, assignees }) {
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1544
|
+
return withOctokit(token, async (octokit) => {
|
|
1545
|
+
const { data } = await octokit.rest.issues.removeAssignees({
|
|
1546
|
+
owner,
|
|
1547
|
+
repo,
|
|
1548
|
+
issue_number: issueNumber,
|
|
1549
|
+
assignees
|
|
1550
|
+
});
|
|
1551
|
+
return {
|
|
1552
|
+
number: data.number,
|
|
1553
|
+
assignees: data.assignees?.map((a) => a.login)
|
|
1554
|
+
};
|
|
1376
1555
|
});
|
|
1377
|
-
return {
|
|
1378
|
-
number: data.number,
|
|
1379
|
-
assignees: data.assignees?.map((a) => a.login)
|
|
1380
|
-
};
|
|
1381
1556
|
}
|
|
1382
1557
|
//#endregion
|
|
1383
1558
|
//#region src/core/reactions.ts
|
|
@@ -1413,15 +1588,17 @@ const listIssueReactionsInputSchema = z.object({
|
|
|
1413
1588
|
});
|
|
1414
1589
|
const listIssueReactionsDescription = "List reactions on an issue or pull request conversation, with per-emoji counts for the returned page";
|
|
1415
1590
|
async function listIssueReactionsCore({ token, owner, repo, issueNumber, content, perPage, page }) {
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1591
|
+
return withOctokit(token, async (octokit) => {
|
|
1592
|
+
const { data } = await octokit.rest.reactions.listForIssue({
|
|
1593
|
+
owner,
|
|
1594
|
+
repo,
|
|
1595
|
+
issue_number: issueNumber,
|
|
1596
|
+
content,
|
|
1597
|
+
per_page: perPage,
|
|
1598
|
+
page
|
|
1599
|
+
});
|
|
1600
|
+
return shapeReactions(data);
|
|
1423
1601
|
});
|
|
1424
|
-
return shapeReactions(data);
|
|
1425
1602
|
}
|
|
1426
1603
|
const addIssueReactionInputSchema = z.object({
|
|
1427
1604
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1432,18 +1609,20 @@ const addIssueReactionInputSchema = z.object({
|
|
|
1432
1609
|
const addIssueReactionDescription = "React to an issue or pull request with an emoji. Prefer this over posting a comment to acknowledge a report without adding noise to the thread";
|
|
1433
1610
|
/** Idempotent — GitHub returns the existing reaction when the user already reacted with the same content. */
|
|
1434
1611
|
async function addIssueReactionCore({ token, owner, repo, issueNumber, content }) {
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1612
|
+
return withOctokit(token, async (octokit) => {
|
|
1613
|
+
const { data } = await octokit.rest.reactions.createForIssue({
|
|
1614
|
+
owner,
|
|
1615
|
+
repo,
|
|
1616
|
+
issue_number: issueNumber,
|
|
1617
|
+
content
|
|
1618
|
+
});
|
|
1619
|
+
return {
|
|
1620
|
+
id: data.id,
|
|
1621
|
+
content: data.content,
|
|
1622
|
+
user: data.user?.login,
|
|
1623
|
+
issueNumber
|
|
1624
|
+
};
|
|
1440
1625
|
});
|
|
1441
|
-
return {
|
|
1442
|
-
id: data.id,
|
|
1443
|
-
content: data.content,
|
|
1444
|
-
user: data.user?.login,
|
|
1445
|
-
issueNumber
|
|
1446
|
-
};
|
|
1447
1626
|
}
|
|
1448
1627
|
const listCommentReactionsInputSchema = z.object({
|
|
1449
1628
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1455,15 +1634,17 @@ const listCommentReactionsInputSchema = z.object({
|
|
|
1455
1634
|
});
|
|
1456
1635
|
const listCommentReactionsDescription = "List reactions on an issue or pull request comment, with per-emoji counts for the returned page";
|
|
1457
1636
|
async function listCommentReactionsCore({ token, owner, repo, commentId, content, perPage, page }) {
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1637
|
+
return withOctokit(token, async (octokit) => {
|
|
1638
|
+
const { data } = await octokit.rest.reactions.listForIssueComment({
|
|
1639
|
+
owner,
|
|
1640
|
+
repo,
|
|
1641
|
+
comment_id: commentId,
|
|
1642
|
+
content,
|
|
1643
|
+
per_page: perPage,
|
|
1644
|
+
page
|
|
1645
|
+
});
|
|
1646
|
+
return shapeReactions(data);
|
|
1465
1647
|
});
|
|
1466
|
-
return shapeReactions(data);
|
|
1467
1648
|
}
|
|
1468
1649
|
const addCommentReactionInputSchema = z.object({
|
|
1469
1650
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1474,18 +1655,20 @@ const addCommentReactionInputSchema = z.object({
|
|
|
1474
1655
|
const addCommentReactionDescription = "React to an issue or pull request comment with an emoji. Prefer this over a reply when acknowledging a comment";
|
|
1475
1656
|
/** Idempotent — GitHub returns the existing reaction when the user already reacted with the same content. */
|
|
1476
1657
|
async function addCommentReactionCore({ token, owner, repo, commentId, content }) {
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1658
|
+
return withOctokit(token, async (octokit) => {
|
|
1659
|
+
const { data } = await octokit.rest.reactions.createForIssueComment({
|
|
1660
|
+
owner,
|
|
1661
|
+
repo,
|
|
1662
|
+
comment_id: commentId,
|
|
1663
|
+
content
|
|
1664
|
+
});
|
|
1665
|
+
return {
|
|
1666
|
+
id: data.id,
|
|
1667
|
+
content: data.content,
|
|
1668
|
+
user: data.user?.login,
|
|
1669
|
+
commentId
|
|
1670
|
+
};
|
|
1482
1671
|
});
|
|
1483
|
-
return {
|
|
1484
|
-
id: data.id,
|
|
1485
|
-
content: data.content,
|
|
1486
|
-
user: data.user?.login,
|
|
1487
|
-
commentId
|
|
1488
|
-
};
|
|
1489
1672
|
}
|
|
1490
1673
|
//#endregion
|
|
1491
1674
|
//#region src/core/discussions.ts
|
|
@@ -1596,37 +1779,38 @@ const listDiscussionsInputSchema = z.object({
|
|
|
1596
1779
|
});
|
|
1597
1780
|
const listDiscussionsDescription = "List discussions in a GitHub repository, most recently updated first, optionally filtered by category (GitHub GraphQL API)";
|
|
1598
1781
|
async function listDiscussionsCore({ token, owner, repo, category, perPage, after }) {
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1782
|
+
return withOctokit(token, async (octokit) => {
|
|
1783
|
+
let categoryId;
|
|
1784
|
+
if (category) {
|
|
1785
|
+
const { id, available } = await resolveCategoryId(octokit, owner, repo, category);
|
|
1786
|
+
if (!id) return { error: `Unknown discussion category "${category}". Available categories: ${available.join(", ")}` };
|
|
1787
|
+
categoryId = id;
|
|
1788
|
+
}
|
|
1789
|
+
const data = await octokit.graphql(LIST_DISCUSSIONS_QUERY, {
|
|
1790
|
+
owner,
|
|
1791
|
+
name: repo,
|
|
1792
|
+
first: perPage,
|
|
1793
|
+
after,
|
|
1794
|
+
categoryId
|
|
1795
|
+
});
|
|
1796
|
+
if (!data.repository) return { error: `Repository not found, or discussions are disabled on ${owner}/${repo}` };
|
|
1797
|
+
const { pageInfo, nodes } = data.repository.discussions;
|
|
1798
|
+
return {
|
|
1799
|
+
hasNextPage: pageInfo.hasNextPage,
|
|
1800
|
+
endCursor: pageInfo.endCursor,
|
|
1801
|
+
discussions: nodes.map((node) => ({
|
|
1802
|
+
id: node.id,
|
|
1803
|
+
number: node.number,
|
|
1804
|
+
title: node.title,
|
|
1805
|
+
url: node.url,
|
|
1806
|
+
author: node.author?.login ?? null,
|
|
1807
|
+
category: node.category?.name ?? null,
|
|
1808
|
+
answerChosen: node.isAnswered,
|
|
1809
|
+
createdAt: node.createdAt,
|
|
1810
|
+
updatedAt: node.updatedAt
|
|
1811
|
+
}))
|
|
1812
|
+
};
|
|
1612
1813
|
});
|
|
1613
|
-
if (!data.repository) return { error: `Repository not found, or discussions are disabled on ${owner}/${repo}` };
|
|
1614
|
-
const { pageInfo, nodes } = data.repository.discussions;
|
|
1615
|
-
return {
|
|
1616
|
-
hasNextPage: pageInfo.hasNextPage,
|
|
1617
|
-
endCursor: pageInfo.endCursor,
|
|
1618
|
-
discussions: nodes.map((node) => ({
|
|
1619
|
-
id: node.id,
|
|
1620
|
-
number: node.number,
|
|
1621
|
-
title: node.title,
|
|
1622
|
-
url: node.url,
|
|
1623
|
-
author: node.author?.login ?? null,
|
|
1624
|
-
category: node.category?.name ?? null,
|
|
1625
|
-
answerChosen: node.isAnswered,
|
|
1626
|
-
createdAt: node.createdAt,
|
|
1627
|
-
updatedAt: node.updatedAt
|
|
1628
|
-
}))
|
|
1629
|
-
};
|
|
1630
1814
|
}
|
|
1631
1815
|
const getDiscussionInputSchema = z.object({
|
|
1632
1816
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1636,25 +1820,27 @@ const getDiscussionInputSchema = z.object({
|
|
|
1636
1820
|
});
|
|
1637
1821
|
const getDiscussionDescription = "Get a GitHub discussion by number. Body is truncated by default (detail: summary) — set detail full for the complete text (GitHub GraphQL API)";
|
|
1638
1822
|
async function getDiscussionCore({ token, owner, repo, discussionNumber, detail = "summary" }) {
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1823
|
+
return withOctokit(token, async (octokit) => {
|
|
1824
|
+
const discussion = (await octokit.graphql(GET_DISCUSSION_QUERY, {
|
|
1825
|
+
owner,
|
|
1826
|
+
name: repo,
|
|
1827
|
+
number: discussionNumber
|
|
1828
|
+
})).repository?.discussion;
|
|
1829
|
+
if (!discussion) return { error: `Discussion #${discussionNumber} not found on ${owner}/${repo}` };
|
|
1830
|
+
return {
|
|
1831
|
+
id: discussion.id,
|
|
1832
|
+
number: discussion.number,
|
|
1833
|
+
title: discussion.title,
|
|
1834
|
+
body: applyDetailBody(discussion.body, detail),
|
|
1835
|
+
url: discussion.url,
|
|
1836
|
+
author: discussion.author?.login ?? null,
|
|
1837
|
+
category: discussion.category?.name ?? null,
|
|
1838
|
+
answerChosen: discussion.isAnswered,
|
|
1839
|
+
commentsCount: discussion.comments.totalCount,
|
|
1840
|
+
createdAt: discussion.createdAt,
|
|
1841
|
+
updatedAt: discussion.updatedAt
|
|
1842
|
+
};
|
|
1843
|
+
});
|
|
1658
1844
|
}
|
|
1659
1845
|
const addDiscussionCommentInputSchema = z.object({
|
|
1660
1846
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1665,24 +1851,25 @@ const addDiscussionCommentInputSchema = z.object({
|
|
|
1665
1851
|
const addDiscussionCommentDescription = "Add a comment to a GitHub discussion (GitHub GraphQL API)";
|
|
1666
1852
|
/** Not idempotent — each call adds another comment. */
|
|
1667
1853
|
async function addDiscussionCommentCore({ token, owner, repo, discussionNumber, body }) {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1854
|
+
return withOctokit(token, async (octokit) => {
|
|
1855
|
+
const discussionId = (await octokit.graphql(DISCUSSION_ID_QUERY, {
|
|
1856
|
+
owner,
|
|
1857
|
+
name: repo,
|
|
1858
|
+
number: discussionNumber
|
|
1859
|
+
})).repository?.discussion?.id;
|
|
1860
|
+
if (!discussionId) return { error: `Discussion #${discussionNumber} not found on ${owner}/${repo}` };
|
|
1861
|
+
const comment = (await octokit.graphql(ADD_DISCUSSION_COMMENT_MUTATION, {
|
|
1862
|
+
discussionId,
|
|
1863
|
+
body
|
|
1864
|
+
})).addDiscussionComment.comment;
|
|
1865
|
+
return {
|
|
1866
|
+
id: comment.id,
|
|
1867
|
+
url: comment.url,
|
|
1868
|
+
body: comment.body,
|
|
1869
|
+
author: comment.author?.login ?? null,
|
|
1870
|
+
createdAt: comment.createdAt
|
|
1871
|
+
};
|
|
1872
|
+
});
|
|
1686
1873
|
}
|
|
1687
1874
|
//#endregion
|
|
1688
1875
|
//#region src/core/notifications.ts
|
|
@@ -1694,34 +1881,38 @@ const listNotificationsInputSchema = z.object({
|
|
|
1694
1881
|
});
|
|
1695
1882
|
const listNotificationsDescription = "List notification threads for the authenticated user. Unread only by default — set all true to include read threads. Requires a token with notifications access";
|
|
1696
1883
|
async function listNotificationsCore({ token, all, participating, perPage, page }) {
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1884
|
+
return withOctokit(token, async (octokit) => {
|
|
1885
|
+
const { data } = await octokit.rest.activity.listNotificationsForAuthenticatedUser({
|
|
1886
|
+
all,
|
|
1887
|
+
participating,
|
|
1888
|
+
per_page: perPage,
|
|
1889
|
+
page
|
|
1890
|
+
});
|
|
1891
|
+
return data.map((thread) => ({
|
|
1892
|
+
threadId: thread.id,
|
|
1893
|
+
repository: thread.repository.full_name,
|
|
1894
|
+
subject: {
|
|
1895
|
+
title: thread.subject.title,
|
|
1896
|
+
type: thread.subject.type,
|
|
1897
|
+
url: thread.subject.url
|
|
1898
|
+
},
|
|
1899
|
+
reason: thread.reason,
|
|
1900
|
+
unread: thread.unread,
|
|
1901
|
+
updatedAt: thread.updated_at
|
|
1902
|
+
}));
|
|
1903
|
+
});
|
|
1715
1904
|
}
|
|
1716
1905
|
const markNotificationReadInputSchema = z.object({ threadId: z.string().describe("Notification thread ID (from listNotifications)") });
|
|
1717
1906
|
const markNotificationReadDescription = "Mark a single notification thread as read";
|
|
1718
1907
|
/** Idempotent — marking an already-read thread is a no-op on GitHub. */
|
|
1719
1908
|
async function markNotificationReadCore({ token, threadId }) {
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1909
|
+
return withOctokit(token, async (octokit) => {
|
|
1910
|
+
await octokit.rest.activity.markThreadAsRead({ thread_id: Number(threadId) });
|
|
1911
|
+
return {
|
|
1912
|
+
marked: true,
|
|
1913
|
+
threadId
|
|
1914
|
+
};
|
|
1915
|
+
});
|
|
1725
1916
|
}
|
|
1726
1917
|
//#endregion
|
|
1727
1918
|
//#region src/core/search.ts
|
|
@@ -1736,22 +1927,24 @@ const searchCodeInputSchema = z.object({
|
|
|
1736
1927
|
});
|
|
1737
1928
|
const searchCodeDescription = "Search for code in GitHub repositories. Use qualifiers like \"repo:owner/name\" to scope the search. Results include matching text snippets when GitHub returns them.";
|
|
1738
1929
|
async function searchCodeCore({ token, query, perPage }) {
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1930
|
+
return withOctokit(token, async (octokit) => {
|
|
1931
|
+
const { data } = await octokit.rest.search.code({
|
|
1932
|
+
q: query,
|
|
1933
|
+
per_page: perPage,
|
|
1934
|
+
mediaType: { format: "text-match" }
|
|
1935
|
+
});
|
|
1936
|
+
return {
|
|
1937
|
+
totalCount: data.total_count,
|
|
1938
|
+
items: data.items.map((item) => ({
|
|
1939
|
+
name: item.name,
|
|
1940
|
+
path: item.path,
|
|
1941
|
+
url: item.html_url,
|
|
1942
|
+
repository: item.repository.full_name,
|
|
1943
|
+
sha: item.sha,
|
|
1944
|
+
textMatches: item.text_matches?.map((match) => ({ fragment: truncateFragment(match.fragment ?? "") }))
|
|
1945
|
+
}))
|
|
1946
|
+
};
|
|
1743
1947
|
});
|
|
1744
|
-
return {
|
|
1745
|
-
totalCount: data.total_count,
|
|
1746
|
-
items: data.items.map((item) => ({
|
|
1747
|
-
name: item.name,
|
|
1748
|
-
path: item.path,
|
|
1749
|
-
url: item.html_url,
|
|
1750
|
-
repository: item.repository.full_name,
|
|
1751
|
-
sha: item.sha,
|
|
1752
|
-
textMatches: item.text_matches?.map((match) => ({ fragment: truncateFragment(match.fragment ?? "") }))
|
|
1753
|
-
}))
|
|
1754
|
-
};
|
|
1755
1948
|
}
|
|
1756
1949
|
const searchRepositoriesInputSchema = z.object({
|
|
1757
1950
|
query: z.string().describe("Search query. Supports GitHub search qualifiers, e.g. \"nuxt language:typescript stars:>1000\""),
|
|
@@ -1766,25 +1959,27 @@ const searchRepositoriesInputSchema = z.object({
|
|
|
1766
1959
|
});
|
|
1767
1960
|
const searchRepositoriesDescription = "Search for GitHub repositories by keyword, topic, language, or other qualifiers";
|
|
1768
1961
|
async function searchRepositoriesCore({ token, query, perPage, sort, order }) {
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1962
|
+
return withOctokit(token, async (octokit) => {
|
|
1963
|
+
const { data } = await octokit.rest.search.repos({
|
|
1964
|
+
q: query,
|
|
1965
|
+
per_page: perPage,
|
|
1966
|
+
sort,
|
|
1967
|
+
order
|
|
1968
|
+
});
|
|
1969
|
+
return {
|
|
1970
|
+
totalCount: data.total_count,
|
|
1971
|
+
items: data.items.map((repo) => ({
|
|
1972
|
+
name: repo.name,
|
|
1973
|
+
fullName: repo.full_name,
|
|
1974
|
+
description: repo.description,
|
|
1975
|
+
url: repo.html_url,
|
|
1976
|
+
stars: repo.stargazers_count,
|
|
1977
|
+
forks: repo.forks_count,
|
|
1978
|
+
language: repo.language,
|
|
1979
|
+
topics: repo.topics
|
|
1980
|
+
}))
|
|
1981
|
+
};
|
|
1774
1982
|
});
|
|
1775
|
-
return {
|
|
1776
|
-
totalCount: data.total_count,
|
|
1777
|
-
items: data.items.map((repo) => ({
|
|
1778
|
-
name: repo.name,
|
|
1779
|
-
fullName: repo.full_name,
|
|
1780
|
-
description: repo.description,
|
|
1781
|
-
url: repo.html_url,
|
|
1782
|
-
stars: repo.stargazers_count,
|
|
1783
|
-
forks: repo.forks_count,
|
|
1784
|
-
language: repo.language,
|
|
1785
|
-
topics: repo.topics
|
|
1786
|
-
}))
|
|
1787
|
-
};
|
|
1788
1983
|
}
|
|
1789
1984
|
const searchIssuesInputSchema = z.object({
|
|
1790
1985
|
query: z.string().describe("Search query. Supports GitHub search qualifiers, e.g. \"repo:owner/name is:open label:bug\". Returns both issues and pull requests by default — use type:pr or is:pr to scope to pull requests, or type:issue / is:issue to exclude them"),
|
|
@@ -1800,28 +1995,30 @@ const searchIssuesInputSchema = z.object({
|
|
|
1800
1995
|
});
|
|
1801
1996
|
const searchIssuesDescription = "Search for issues and pull requests across GitHub using search qualifiers like \"repo:owner/name is:open\"";
|
|
1802
1997
|
async function searchIssuesCore({ token, query, perPage, sort, order }) {
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1998
|
+
return withOctokit(token, async (octokit) => {
|
|
1999
|
+
const { data } = await octokit.rest.search.issuesAndPullRequests({
|
|
2000
|
+
q: query,
|
|
2001
|
+
per_page: perPage,
|
|
2002
|
+
sort,
|
|
2003
|
+
order
|
|
2004
|
+
});
|
|
2005
|
+
return {
|
|
2006
|
+
totalCount: data.total_count,
|
|
2007
|
+
items: data.items.map((item) => ({
|
|
2008
|
+
number: item.number,
|
|
2009
|
+
title: item.title,
|
|
2010
|
+
state: item.state,
|
|
2011
|
+
url: item.html_url,
|
|
2012
|
+
repository: item.repository_url.split("/repos/").at(-1),
|
|
2013
|
+
author: item.user?.login,
|
|
2014
|
+
labels: item.labels.map((l) => typeof l === "string" ? l : l.name),
|
|
2015
|
+
comments: item.comments,
|
|
2016
|
+
createdAt: item.created_at,
|
|
2017
|
+
updatedAt: item.updated_at,
|
|
2018
|
+
isPullRequest: Boolean(item.pull_request)
|
|
2019
|
+
}))
|
|
2020
|
+
};
|
|
1808
2021
|
});
|
|
1809
|
-
return {
|
|
1810
|
-
totalCount: data.total_count,
|
|
1811
|
-
items: data.items.map((item) => ({
|
|
1812
|
-
number: item.number,
|
|
1813
|
-
title: item.title,
|
|
1814
|
-
state: item.state,
|
|
1815
|
-
url: item.html_url,
|
|
1816
|
-
repository: item.repository_url.split("/repos/").at(-1),
|
|
1817
|
-
author: item.user?.login,
|
|
1818
|
-
labels: item.labels.map((l) => typeof l === "string" ? l : l.name),
|
|
1819
|
-
comments: item.comments,
|
|
1820
|
-
createdAt: item.created_at,
|
|
1821
|
-
updatedAt: item.updated_at,
|
|
1822
|
-
isPullRequest: Boolean(item.pull_request)
|
|
1823
|
-
}))
|
|
1824
|
-
};
|
|
1825
2022
|
}
|
|
1826
2023
|
//#endregion
|
|
1827
2024
|
//#region src/core/commits.ts
|
|
@@ -1870,28 +2067,29 @@ const listCommitsInputSchema = z.object({
|
|
|
1870
2067
|
});
|
|
1871
2068
|
const listCommitsDescription = "List commits for a GitHub repository. Filter by file path to see commits that touched a file. For line-by-line attribution at a given ref, use getBlame instead.";
|
|
1872
2069
|
async function listCommitsCore({ token, owner, repo, path, sha, author, since, until, perPage, maxPages }) {
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
2070
|
+
return withOctokit(token, async (octokit) => {
|
|
2071
|
+
return (await fetchAllPages(async (page) => {
|
|
2072
|
+
const { data } = await octokit.rest.repos.listCommits({
|
|
2073
|
+
owner,
|
|
2074
|
+
repo,
|
|
2075
|
+
path,
|
|
2076
|
+
sha,
|
|
2077
|
+
author,
|
|
2078
|
+
since,
|
|
2079
|
+
until,
|
|
2080
|
+
per_page: perPage,
|
|
2081
|
+
page
|
|
2082
|
+
});
|
|
2083
|
+
return data;
|
|
2084
|
+
}, perPage, maxPages)).map((commit) => ({
|
|
2085
|
+
sha: commit.sha,
|
|
2086
|
+
message: commit.commit.message,
|
|
2087
|
+
author: commit.commit.author?.name,
|
|
2088
|
+
authorLogin: commit.author?.login,
|
|
2089
|
+
date: commit.commit.author?.date,
|
|
2090
|
+
url: commit.html_url
|
|
2091
|
+
}));
|
|
2092
|
+
});
|
|
1895
2093
|
}
|
|
1896
2094
|
const getCommitInputSchema = z.object({
|
|
1897
2095
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1901,31 +2099,33 @@ const getCommitInputSchema = z.object({
|
|
|
1901
2099
|
});
|
|
1902
2100
|
const getCommitDescription = "Get detailed information about a specific commit, including the list of files changed with additions and deletions. Patches are omitted by default — set includePatch true to include diffs";
|
|
1903
2101
|
async function getCommitCore({ token, owner, repo, ref, includePatch }) {
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2102
|
+
return withOctokit(token, async (octokit) => {
|
|
2103
|
+
const { data } = await octokit.rest.repos.getCommit({
|
|
2104
|
+
owner,
|
|
2105
|
+
repo,
|
|
2106
|
+
ref
|
|
2107
|
+
});
|
|
2108
|
+
return {
|
|
2109
|
+
sha: data.sha,
|
|
2110
|
+
message: data.commit.message,
|
|
2111
|
+
author: data.commit.author?.name,
|
|
2112
|
+
authorLogin: data.author?.login,
|
|
2113
|
+
date: data.commit.author?.date,
|
|
2114
|
+
url: data.html_url,
|
|
2115
|
+
stats: data.stats ? {
|
|
2116
|
+
additions: data.stats.additions,
|
|
2117
|
+
deletions: data.stats.deletions,
|
|
2118
|
+
total: data.stats.total
|
|
2119
|
+
} : null,
|
|
2120
|
+
files: data.files?.map((file) => ({
|
|
2121
|
+
filename: file.filename,
|
|
2122
|
+
status: file.status,
|
|
2123
|
+
additions: file.additions,
|
|
2124
|
+
deletions: file.deletions,
|
|
2125
|
+
...includePatch && file.patch != null ? { patch: file.patch } : {}
|
|
2126
|
+
}))
|
|
2127
|
+
};
|
|
1908
2128
|
});
|
|
1909
|
-
return {
|
|
1910
|
-
sha: data.sha,
|
|
1911
|
-
message: data.commit.message,
|
|
1912
|
-
author: data.commit.author?.name,
|
|
1913
|
-
authorLogin: data.author?.login,
|
|
1914
|
-
date: data.commit.author?.date,
|
|
1915
|
-
url: data.html_url,
|
|
1916
|
-
stats: data.stats ? {
|
|
1917
|
-
additions: data.stats.additions,
|
|
1918
|
-
deletions: data.stats.deletions,
|
|
1919
|
-
total: data.stats.total
|
|
1920
|
-
} : null,
|
|
1921
|
-
files: data.files?.map((file) => ({
|
|
1922
|
-
filename: file.filename,
|
|
1923
|
-
status: file.status,
|
|
1924
|
-
additions: file.additions,
|
|
1925
|
-
deletions: file.deletions,
|
|
1926
|
-
...includePatch && file.patch != null ? { patch: file.patch } : {}
|
|
1927
|
-
}))
|
|
1928
|
-
};
|
|
1929
2129
|
}
|
|
1930
2130
|
const getBlameInputSchema = z.object({
|
|
1931
2131
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1938,52 +2138,53 @@ const getBlameInputSchema = z.object({
|
|
|
1938
2138
|
});
|
|
1939
2139
|
const getBlameDescription = "Line-level git blame for a file at a commit-like ref (branch, tag, or SHA). Returns contiguous ranges mapping lines to the commits that last modified them — use this to see who introduced a line and when (GitHub GraphQL API).";
|
|
1940
2140
|
async function getBlameCore({ token, owner, repo, path, ref, line, lineStart, lineEnd }) {
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
2141
|
+
return withOctokit(token, async (octokit) => {
|
|
2142
|
+
let expression = ref;
|
|
2143
|
+
if (!expression) {
|
|
2144
|
+
const { data } = await octokit.rest.repos.get({
|
|
2145
|
+
owner,
|
|
2146
|
+
repo
|
|
2147
|
+
});
|
|
2148
|
+
expression = data.default_branch;
|
|
2149
|
+
}
|
|
2150
|
+
const data = await octokit.graphql(BLAME_QUERY, {
|
|
1945
2151
|
owner,
|
|
1946
|
-
repo
|
|
2152
|
+
name: repo,
|
|
2153
|
+
expression,
|
|
2154
|
+
path
|
|
1947
2155
|
});
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
authorLogin: r.commit.author?.user?.login ?? null
|
|
2156
|
+
if (!data.repository) return { error: `Repository not found: ${owner}/${repo}` };
|
|
2157
|
+
const obj = data.repository.object;
|
|
2158
|
+
if (!obj?.oid || !obj?.blame) return { error: `Ref "${expression}" did not resolve to a commit for this repository (or the path is invalid). Pass a branch name, tag, or full commit SHA.` };
|
|
2159
|
+
let ranges = obj.blame.ranges.map((r) => ({
|
|
2160
|
+
startingLine: r.startingLine,
|
|
2161
|
+
endingLine: r.endingLine,
|
|
2162
|
+
age: r.age,
|
|
2163
|
+
commit: {
|
|
2164
|
+
sha: r.commit.oid,
|
|
2165
|
+
abbreviatedSha: r.commit.abbreviatedOid,
|
|
2166
|
+
messageHeadline: r.commit.messageHeadline,
|
|
2167
|
+
authoredDate: r.commit.authoredDate,
|
|
2168
|
+
url: r.commit.url,
|
|
2169
|
+
authorName: r.commit.author?.name ?? null,
|
|
2170
|
+
authorEmail: r.commit.author?.email ?? null,
|
|
2171
|
+
authorLogin: r.commit.author?.user?.login ?? null
|
|
2172
|
+
}
|
|
2173
|
+
}));
|
|
2174
|
+
if (line != null) ranges = ranges.filter((r) => line >= r.startingLine && line <= r.endingLine);
|
|
2175
|
+
else if (lineStart != null || lineEnd != null) {
|
|
2176
|
+
const start = lineStart ?? 1;
|
|
2177
|
+
const end = lineEnd ?? Number.MAX_SAFE_INTEGER;
|
|
2178
|
+
ranges = ranges.filter((r) => r.endingLine >= start && r.startingLine <= end);
|
|
1972
2179
|
}
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
ref: expression,
|
|
1982
|
-
tipSha: obj.oid,
|
|
1983
|
-
path,
|
|
1984
|
-
rangeCount: ranges.length,
|
|
1985
|
-
ranges
|
|
1986
|
-
};
|
|
2180
|
+
return {
|
|
2181
|
+
ref: expression,
|
|
2182
|
+
tipSha: obj.oid,
|
|
2183
|
+
path,
|
|
2184
|
+
rangeCount: ranges.length,
|
|
2185
|
+
ranges
|
|
2186
|
+
};
|
|
2187
|
+
});
|
|
1987
2188
|
}
|
|
1988
2189
|
const compareCommitsInputSchema = z.object({
|
|
1989
2190
|
owner: z.string().describe("Repository owner"),
|
|
@@ -1994,31 +2195,33 @@ const compareCommitsInputSchema = z.object({
|
|
|
1994
2195
|
});
|
|
1995
2196
|
const compareCommitsDescription = "Compare two branches, tags, or commits — shows ahead/behind counts, the commits in between, and the files that differ. Patches are omitted by default — set includePatch true to include diffs";
|
|
1996
2197
|
async function compareCommitsCore({ token, owner, repo, base, head, includePatch }) {
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2198
|
+
return withOctokit(token, async (octokit) => {
|
|
2199
|
+
const { data } = await octokit.rest.repos.compareCommitsWithBasehead({
|
|
2200
|
+
owner,
|
|
2201
|
+
repo,
|
|
2202
|
+
basehead: `${base}...${head}`
|
|
2203
|
+
});
|
|
2204
|
+
return {
|
|
2205
|
+
status: data.status,
|
|
2206
|
+
aheadBy: data.ahead_by,
|
|
2207
|
+
behindBy: data.behind_by,
|
|
2208
|
+
totalCommits: data.total_commits,
|
|
2209
|
+
url: data.html_url,
|
|
2210
|
+
commits: data.commits.map((commit) => ({
|
|
2211
|
+
sha: commit.sha,
|
|
2212
|
+
message: commit.commit.message,
|
|
2213
|
+
author: commit.commit.author?.name,
|
|
2214
|
+
authorLogin: commit.author?.login
|
|
2215
|
+
})),
|
|
2216
|
+
files: data.files?.map((file) => ({
|
|
2217
|
+
filename: file.filename,
|
|
2218
|
+
status: file.status,
|
|
2219
|
+
additions: file.additions,
|
|
2220
|
+
deletions: file.deletions,
|
|
2221
|
+
...includePatch && file.patch != null ? { patch: file.patch } : {}
|
|
2222
|
+
}))
|
|
2223
|
+
};
|
|
2001
2224
|
});
|
|
2002
|
-
return {
|
|
2003
|
-
status: data.status,
|
|
2004
|
-
aheadBy: data.ahead_by,
|
|
2005
|
-
behindBy: data.behind_by,
|
|
2006
|
-
totalCommits: data.total_commits,
|
|
2007
|
-
url: data.html_url,
|
|
2008
|
-
commits: data.commits.map((commit) => ({
|
|
2009
|
-
sha: commit.sha,
|
|
2010
|
-
message: commit.commit.message,
|
|
2011
|
-
author: commit.commit.author?.name,
|
|
2012
|
-
authorLogin: commit.author?.login
|
|
2013
|
-
})),
|
|
2014
|
-
files: data.files?.map((file) => ({
|
|
2015
|
-
filename: file.filename,
|
|
2016
|
-
status: file.status,
|
|
2017
|
-
additions: file.additions,
|
|
2018
|
-
deletions: file.deletions,
|
|
2019
|
-
...includePatch && file.patch != null ? { patch: file.patch } : {}
|
|
2020
|
-
}))
|
|
2021
|
-
};
|
|
2022
2225
|
}
|
|
2023
2226
|
//#endregion
|
|
2024
2227
|
//#region src/core/gists.ts
|
|
@@ -2029,47 +2232,50 @@ const listGistsInputSchema = z.object({
|
|
|
2029
2232
|
});
|
|
2030
2233
|
const listGistsDescription = "List gists for the authenticated user or a specific user";
|
|
2031
2234
|
async function listGistsCore({ token, username, perPage, page }) {
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2235
|
+
return withOctokit(token, async (octokit) => {
|
|
2236
|
+
const { data } = username ? await octokit.rest.gists.listForUser({
|
|
2237
|
+
username,
|
|
2238
|
+
per_page: perPage,
|
|
2239
|
+
page
|
|
2240
|
+
}) : await octokit.rest.gists.list({
|
|
2241
|
+
per_page: perPage,
|
|
2242
|
+
page
|
|
2243
|
+
});
|
|
2244
|
+
return data.map((gist) => ({
|
|
2245
|
+
id: gist.id,
|
|
2246
|
+
description: gist.description,
|
|
2247
|
+
public: gist.public,
|
|
2248
|
+
url: gist.html_url,
|
|
2249
|
+
files: Object.keys(gist.files ?? {}),
|
|
2250
|
+
owner: gist.owner?.login,
|
|
2251
|
+
comments: gist.comments,
|
|
2252
|
+
createdAt: gist.created_at,
|
|
2253
|
+
updatedAt: gist.updated_at
|
|
2254
|
+
}));
|
|
2255
|
+
});
|
|
2052
2256
|
}
|
|
2053
2257
|
const getGistInputSchema = z.object({ gistId: z.string().describe("Gist ID") });
|
|
2054
2258
|
const getGistDescription = "Get a gist by ID, including file contents";
|
|
2055
2259
|
async function getGistCore({ token, gistId }) {
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2260
|
+
return withOctokit(token, async (octokit) => {
|
|
2261
|
+
const { data } = await octokit.rest.gists.get({ gist_id: gistId });
|
|
2262
|
+
return {
|
|
2263
|
+
id: data.id,
|
|
2264
|
+
description: data.description,
|
|
2265
|
+
public: data.public,
|
|
2266
|
+
url: data.html_url,
|
|
2267
|
+
owner: data.owner?.login,
|
|
2268
|
+
files: Object.values(data.files ?? {}).map((file) => ({
|
|
2269
|
+
filename: file?.filename,
|
|
2270
|
+
language: file?.language,
|
|
2271
|
+
size: file?.size,
|
|
2272
|
+
content: file?.content
|
|
2273
|
+
})),
|
|
2274
|
+
comments: data.comments,
|
|
2275
|
+
createdAt: data.created_at,
|
|
2276
|
+
updatedAt: data.updated_at
|
|
2277
|
+
};
|
|
2278
|
+
});
|
|
2073
2279
|
}
|
|
2074
2280
|
const listGistCommentsInputSchema = z.object({
|
|
2075
2281
|
gistId: z.string().describe("Gist ID"),
|
|
@@ -2078,19 +2284,21 @@ const listGistCommentsInputSchema = z.object({
|
|
|
2078
2284
|
});
|
|
2079
2285
|
const listGistCommentsDescription = "List comments on a gist";
|
|
2080
2286
|
async function listGistCommentsCore({ token, gistId, perPage, page }) {
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2287
|
+
return withOctokit(token, async (octokit) => {
|
|
2288
|
+
const { data } = await octokit.rest.gists.listComments({
|
|
2289
|
+
gist_id: gistId,
|
|
2290
|
+
per_page: perPage,
|
|
2291
|
+
page
|
|
2292
|
+
});
|
|
2293
|
+
return data.map((comment) => ({
|
|
2294
|
+
id: comment.id,
|
|
2295
|
+
body: comment.body,
|
|
2296
|
+
author: comment.user?.login,
|
|
2297
|
+
url: comment.url,
|
|
2298
|
+
createdAt: comment.created_at,
|
|
2299
|
+
updatedAt: comment.updated_at
|
|
2300
|
+
}));
|
|
2301
|
+
});
|
|
2094
2302
|
}
|
|
2095
2303
|
const createGistInputSchema = z.object({
|
|
2096
2304
|
description: z.string().optional().describe("Gist description"),
|
|
@@ -2100,19 +2308,21 @@ const createGistInputSchema = z.object({
|
|
|
2100
2308
|
const createGistDescription = "Create a new gist with one or more files";
|
|
2101
2309
|
/** Not idempotent — each call creates a new gist. */
|
|
2102
2310
|
async function createGistCore({ token, description, files, isPublic }) {
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2311
|
+
return withOctokit(token, async (octokit) => {
|
|
2312
|
+
const { data } = await octokit.rest.gists.create({
|
|
2313
|
+
description,
|
|
2314
|
+
files,
|
|
2315
|
+
public: isPublic
|
|
2316
|
+
});
|
|
2317
|
+
return {
|
|
2318
|
+
id: data.id,
|
|
2319
|
+
description: data.description,
|
|
2320
|
+
public: data.public,
|
|
2321
|
+
url: data.html_url,
|
|
2322
|
+
files: Object.keys(data.files ?? {}),
|
|
2323
|
+
owner: data.owner?.login
|
|
2324
|
+
};
|
|
2107
2325
|
});
|
|
2108
|
-
return {
|
|
2109
|
-
id: data.id,
|
|
2110
|
-
description: data.description,
|
|
2111
|
-
public: data.public,
|
|
2112
|
-
url: data.html_url,
|
|
2113
|
-
files: Object.keys(data.files ?? {}),
|
|
2114
|
-
owner: data.owner?.login
|
|
2115
|
-
};
|
|
2116
2326
|
}
|
|
2117
2327
|
const updateGistInputSchema = z.object({
|
|
2118
2328
|
gistId: z.string().describe("Gist ID"),
|
|
@@ -2123,31 +2333,34 @@ const updateGistInputSchema = z.object({
|
|
|
2123
2333
|
const updateGistDescription = "Update an existing gist — edit description, update files, or remove files";
|
|
2124
2334
|
/** Not idempotent — each call applies a new revision. */
|
|
2125
2335
|
async function updateGistCore({ token, gistId, description, files, filesToDelete }) {
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2336
|
+
return withOctokit(token, async (octokit) => {
|
|
2337
|
+
const fileUpdates = {};
|
|
2338
|
+
if (files) Object.assign(fileUpdates, files);
|
|
2339
|
+
if (filesToDelete) for (const name of filesToDelete) fileUpdates[name] = null;
|
|
2340
|
+
const { data } = await octokit.rest.gists.update({
|
|
2341
|
+
gist_id: gistId,
|
|
2342
|
+
description,
|
|
2343
|
+
files: fileUpdates
|
|
2344
|
+
});
|
|
2345
|
+
return {
|
|
2346
|
+
id: data.id,
|
|
2347
|
+
description: data.description,
|
|
2348
|
+
url: data.html_url,
|
|
2349
|
+
files: Object.keys(data.files ?? {})
|
|
2350
|
+
};
|
|
2134
2351
|
});
|
|
2135
|
-
return {
|
|
2136
|
-
id: data.id,
|
|
2137
|
-
description: data.description,
|
|
2138
|
-
url: data.html_url,
|
|
2139
|
-
files: Object.keys(data.files ?? {})
|
|
2140
|
-
};
|
|
2141
2352
|
}
|
|
2142
2353
|
const deleteGistInputSchema = z.object({ gistId: z.string().describe("Gist ID to delete") });
|
|
2143
2354
|
const deleteGistDescription = "Delete a gist permanently";
|
|
2144
2355
|
/** Not idempotent — deleting an already-deleted gist returns 404 from GitHub. */
|
|
2145
2356
|
async function deleteGistCore({ token, gistId }) {
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2357
|
+
return withOctokit(token, async (octokit) => {
|
|
2358
|
+
await octokit.rest.gists.delete({ gist_id: gistId });
|
|
2359
|
+
return {
|
|
2360
|
+
deleted: true,
|
|
2361
|
+
gistId
|
|
2362
|
+
};
|
|
2363
|
+
});
|
|
2151
2364
|
}
|
|
2152
2365
|
const createGistCommentInputSchema = z.object({
|
|
2153
2366
|
gistId: z.string().describe("Gist ID"),
|
|
@@ -2156,17 +2369,19 @@ const createGistCommentInputSchema = z.object({
|
|
|
2156
2369
|
const createGistCommentDescription = "Add a comment to a gist";
|
|
2157
2370
|
/** Not idempotent — each call adds another comment. */
|
|
2158
2371
|
async function createGistCommentCore({ token, gistId, body }) {
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2372
|
+
return withOctokit(token, async (octokit) => {
|
|
2373
|
+
const { data } = await octokit.rest.gists.createComment({
|
|
2374
|
+
gist_id: gistId,
|
|
2375
|
+
body
|
|
2376
|
+
});
|
|
2377
|
+
return {
|
|
2378
|
+
id: data.id,
|
|
2379
|
+
url: data.url,
|
|
2380
|
+
body: data.body,
|
|
2381
|
+
author: data.user?.login,
|
|
2382
|
+
createdAt: data.created_at
|
|
2383
|
+
};
|
|
2162
2384
|
});
|
|
2163
|
-
return {
|
|
2164
|
-
id: data.id,
|
|
2165
|
-
url: data.url,
|
|
2166
|
-
body: data.body,
|
|
2167
|
-
author: data.user?.login,
|
|
2168
|
-
createdAt: data.created_at
|
|
2169
|
-
};
|
|
2170
2385
|
}
|
|
2171
2386
|
//#endregion
|
|
2172
2387
|
//#region src/core/workflows.ts
|
|
@@ -2178,24 +2393,26 @@ const listWorkflowsInputSchema = z.object({
|
|
|
2178
2393
|
});
|
|
2179
2394
|
const listWorkflowsDescription = "List GitHub Actions workflows in a repository";
|
|
2180
2395
|
async function listWorkflowsCore({ token, owner, repo, perPage, page }) {
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2396
|
+
return withOctokit(token, async (octokit) => {
|
|
2397
|
+
const { data } = await octokit.rest.actions.listRepoWorkflows({
|
|
2398
|
+
owner,
|
|
2399
|
+
repo,
|
|
2400
|
+
per_page: perPage,
|
|
2401
|
+
page
|
|
2402
|
+
});
|
|
2403
|
+
return {
|
|
2404
|
+
totalCount: data.total_count,
|
|
2405
|
+
workflows: data.workflows.map((wf) => ({
|
|
2406
|
+
id: wf.id,
|
|
2407
|
+
name: wf.name,
|
|
2408
|
+
path: wf.path,
|
|
2409
|
+
state: wf.state,
|
|
2410
|
+
url: wf.html_url,
|
|
2411
|
+
createdAt: wf.created_at,
|
|
2412
|
+
updatedAt: wf.updated_at
|
|
2413
|
+
}))
|
|
2414
|
+
};
|
|
2186
2415
|
});
|
|
2187
|
-
return {
|
|
2188
|
-
totalCount: data.total_count,
|
|
2189
|
-
workflows: data.workflows.map((wf) => ({
|
|
2190
|
-
id: wf.id,
|
|
2191
|
-
name: wf.name,
|
|
2192
|
-
path: wf.path,
|
|
2193
|
-
state: wf.state,
|
|
2194
|
-
url: wf.html_url,
|
|
2195
|
-
createdAt: wf.created_at,
|
|
2196
|
-
updatedAt: wf.updated_at
|
|
2197
|
-
}))
|
|
2198
|
-
};
|
|
2199
2416
|
}
|
|
2200
2417
|
const listWorkflowRunsInputSchema = z.object({
|
|
2201
2418
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2225,47 +2442,48 @@ const listWorkflowRunsInputSchema = z.object({
|
|
|
2225
2442
|
});
|
|
2226
2443
|
const listWorkflowRunsDescription = "List workflow runs for a repository, optionally filtered by workflow, branch, status, or event";
|
|
2227
2444
|
async function listWorkflowRunsCore({ token, owner, repo, workflowId, branch, event, status, perPage, page, maxPages }) {
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2445
|
+
return withOctokit(token, async (octokit) => {
|
|
2446
|
+
let totalCount = 0;
|
|
2447
|
+
const runs = await fetchAllPages(async (currentPage) => {
|
|
2448
|
+
const { data } = workflowId ? await octokit.rest.actions.listWorkflowRuns({
|
|
2449
|
+
owner,
|
|
2450
|
+
repo,
|
|
2451
|
+
workflow_id: workflowId,
|
|
2452
|
+
per_page: perPage,
|
|
2453
|
+
page: currentPage,
|
|
2454
|
+
...branch && { branch },
|
|
2455
|
+
...event && { event },
|
|
2456
|
+
...status && { status }
|
|
2457
|
+
}) : await octokit.rest.actions.listWorkflowRunsForRepo({
|
|
2458
|
+
owner,
|
|
2459
|
+
repo,
|
|
2460
|
+
per_page: perPage,
|
|
2461
|
+
page: currentPage,
|
|
2462
|
+
...branch && { branch },
|
|
2463
|
+
...event && { event },
|
|
2464
|
+
...status && { status }
|
|
2465
|
+
});
|
|
2466
|
+
totalCount = data.total_count;
|
|
2467
|
+
return data.workflow_runs;
|
|
2468
|
+
}, perPage, maxPages, page);
|
|
2469
|
+
return {
|
|
2470
|
+
totalCount,
|
|
2471
|
+
runs: runs.map((run) => ({
|
|
2472
|
+
id: run.id,
|
|
2473
|
+
name: run.name,
|
|
2474
|
+
status: run.status,
|
|
2475
|
+
conclusion: run.conclusion,
|
|
2476
|
+
branch: run.head_branch,
|
|
2477
|
+
event: run.event,
|
|
2478
|
+
url: run.html_url,
|
|
2479
|
+
actor: run.actor?.login,
|
|
2480
|
+
createdAt: run.created_at,
|
|
2481
|
+
updatedAt: run.updated_at,
|
|
2482
|
+
runNumber: run.run_number,
|
|
2483
|
+
runAttempt: run.run_attempt
|
|
2484
|
+
}))
|
|
2485
|
+
};
|
|
2486
|
+
});
|
|
2269
2487
|
}
|
|
2270
2488
|
const getWorkflowRunInputSchema = z.object({
|
|
2271
2489
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2274,27 +2492,29 @@ const getWorkflowRunInputSchema = z.object({
|
|
|
2274
2492
|
});
|
|
2275
2493
|
const getWorkflowRunDescription = "Get details of a specific workflow run including status, timing, and trigger info";
|
|
2276
2494
|
async function getWorkflowRunCore({ token, owner, repo, runId }) {
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2495
|
+
return withOctokit(token, async (octokit) => {
|
|
2496
|
+
const { data } = await octokit.rest.actions.getWorkflowRun({
|
|
2497
|
+
owner,
|
|
2498
|
+
repo,
|
|
2499
|
+
run_id: runId
|
|
2500
|
+
});
|
|
2501
|
+
return {
|
|
2502
|
+
id: data.id,
|
|
2503
|
+
name: data.name,
|
|
2504
|
+
status: data.status,
|
|
2505
|
+
conclusion: data.conclusion,
|
|
2506
|
+
branch: data.head_branch,
|
|
2507
|
+
sha: data.head_sha,
|
|
2508
|
+
event: data.event,
|
|
2509
|
+
url: data.html_url,
|
|
2510
|
+
actor: data.actor?.login,
|
|
2511
|
+
runNumber: data.run_number,
|
|
2512
|
+
runAttempt: data.run_attempt,
|
|
2513
|
+
createdAt: data.created_at,
|
|
2514
|
+
updatedAt: data.updated_at,
|
|
2515
|
+
runStartedAt: data.run_started_at
|
|
2516
|
+
};
|
|
2281
2517
|
});
|
|
2282
|
-
return {
|
|
2283
|
-
id: data.id,
|
|
2284
|
-
name: data.name,
|
|
2285
|
-
status: data.status,
|
|
2286
|
-
conclusion: data.conclusion,
|
|
2287
|
-
branch: data.head_branch,
|
|
2288
|
-
sha: data.head_sha,
|
|
2289
|
-
event: data.event,
|
|
2290
|
-
url: data.html_url,
|
|
2291
|
-
actor: data.actor?.login,
|
|
2292
|
-
runNumber: data.run_number,
|
|
2293
|
-
runAttempt: data.run_attempt,
|
|
2294
|
-
createdAt: data.created_at,
|
|
2295
|
-
updatedAt: data.updated_at,
|
|
2296
|
-
runStartedAt: data.run_started_at
|
|
2297
|
-
};
|
|
2298
2518
|
}
|
|
2299
2519
|
const listWorkflowJobsInputSchema = z.object({
|
|
2300
2520
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2306,35 +2526,37 @@ const listWorkflowJobsInputSchema = z.object({
|
|
|
2306
2526
|
});
|
|
2307
2527
|
const listWorkflowJobsDescription = "List jobs for a workflow run, including step-level status and timing";
|
|
2308
2528
|
async function listWorkflowJobsCore({ token, owner, repo, runId, filter, perPage, page }) {
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2529
|
+
return withOctokit(token, async (octokit) => {
|
|
2530
|
+
const { data } = await octokit.rest.actions.listJobsForWorkflowRun({
|
|
2531
|
+
owner,
|
|
2532
|
+
repo,
|
|
2533
|
+
run_id: runId,
|
|
2534
|
+
filter,
|
|
2535
|
+
per_page: perPage,
|
|
2536
|
+
page
|
|
2537
|
+
});
|
|
2538
|
+
return {
|
|
2539
|
+
totalCount: data.total_count,
|
|
2540
|
+
jobs: data.jobs.map((job) => ({
|
|
2541
|
+
id: job.id,
|
|
2542
|
+
name: job.name,
|
|
2543
|
+
status: job.status,
|
|
2544
|
+
conclusion: job.conclusion,
|
|
2545
|
+
url: job.html_url,
|
|
2546
|
+
startedAt: job.started_at,
|
|
2547
|
+
completedAt: job.completed_at,
|
|
2548
|
+
runnerName: job.runner_name,
|
|
2549
|
+
steps: job.steps?.map((step) => ({
|
|
2550
|
+
name: step.name,
|
|
2551
|
+
status: step.status,
|
|
2552
|
+
conclusion: step.conclusion,
|
|
2553
|
+
number: step.number,
|
|
2554
|
+
startedAt: step.started_at,
|
|
2555
|
+
completedAt: step.completed_at
|
|
2556
|
+
}))
|
|
2335
2557
|
}))
|
|
2336
|
-
}
|
|
2337
|
-
};
|
|
2558
|
+
};
|
|
2559
|
+
});
|
|
2338
2560
|
}
|
|
2339
2561
|
const triggerWorkflowInputSchema = z.object({
|
|
2340
2562
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2346,18 +2568,20 @@ const triggerWorkflowInputSchema = z.object({
|
|
|
2346
2568
|
const triggerWorkflowDescription = "Trigger a workflow via workflow_dispatch event";
|
|
2347
2569
|
/** Not idempotent — each call starts a new workflow run. */
|
|
2348
2570
|
async function triggerWorkflowCore({ token, owner, repo, workflowId, ref, inputs }) {
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2571
|
+
return withOctokit(token, async (octokit) => {
|
|
2572
|
+
await octokit.rest.actions.createWorkflowDispatch({
|
|
2573
|
+
owner,
|
|
2574
|
+
repo,
|
|
2575
|
+
workflow_id: workflowId,
|
|
2576
|
+
ref,
|
|
2577
|
+
inputs
|
|
2578
|
+
});
|
|
2579
|
+
return {
|
|
2580
|
+
triggered: true,
|
|
2581
|
+
workflowId,
|
|
2582
|
+
ref
|
|
2583
|
+
};
|
|
2355
2584
|
});
|
|
2356
|
-
return {
|
|
2357
|
-
triggered: true,
|
|
2358
|
-
workflowId,
|
|
2359
|
-
ref
|
|
2360
|
-
};
|
|
2361
2585
|
}
|
|
2362
2586
|
const cancelWorkflowRunInputSchema = z.object({
|
|
2363
2587
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2367,15 +2591,17 @@ const cancelWorkflowRunInputSchema = z.object({
|
|
|
2367
2591
|
const cancelWorkflowRunDescription = "Cancel an in-progress workflow run";
|
|
2368
2592
|
/** Not idempotent — cancelling an already-finished run is a no-op on GitHub but still mutates. */
|
|
2369
2593
|
async function cancelWorkflowRunCore({ token, owner, repo, runId }) {
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2594
|
+
return withOctokit(token, async (octokit) => {
|
|
2595
|
+
await octokit.rest.actions.cancelWorkflowRun({
|
|
2596
|
+
owner,
|
|
2597
|
+
repo,
|
|
2598
|
+
run_id: runId
|
|
2599
|
+
});
|
|
2600
|
+
return {
|
|
2601
|
+
cancelled: true,
|
|
2602
|
+
runId
|
|
2603
|
+
};
|
|
2374
2604
|
});
|
|
2375
|
-
return {
|
|
2376
|
-
cancelled: true,
|
|
2377
|
-
runId
|
|
2378
|
-
};
|
|
2379
2605
|
}
|
|
2380
2606
|
const rerunWorkflowRunInputSchema = z.object({
|
|
2381
2607
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2386,22 +2612,23 @@ const rerunWorkflowRunInputSchema = z.object({
|
|
|
2386
2612
|
const rerunWorkflowRunDescription = "Re-run a workflow run, optionally only the failed jobs";
|
|
2387
2613
|
/** Not idempotent — each call starts another run attempt. */
|
|
2388
2614
|
async function rerunWorkflowRunCore({ token, owner, repo, runId, onlyFailedJobs }) {
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2615
|
+
return withOctokit(token, async (octokit) => {
|
|
2616
|
+
if (onlyFailedJobs) await octokit.rest.actions.reRunWorkflowFailedJobs({
|
|
2617
|
+
owner,
|
|
2618
|
+
repo,
|
|
2619
|
+
run_id: runId
|
|
2620
|
+
});
|
|
2621
|
+
else await octokit.rest.actions.reRunWorkflow({
|
|
2622
|
+
owner,
|
|
2623
|
+
repo,
|
|
2624
|
+
run_id: runId
|
|
2625
|
+
});
|
|
2626
|
+
return {
|
|
2627
|
+
rerun: true,
|
|
2628
|
+
runId,
|
|
2629
|
+
onlyFailedJobs
|
|
2630
|
+
};
|
|
2399
2631
|
});
|
|
2400
|
-
return {
|
|
2401
|
-
rerun: true,
|
|
2402
|
-
runId,
|
|
2403
|
-
onlyFailedJobs
|
|
2404
|
-
};
|
|
2405
2632
|
}
|
|
2406
2633
|
//#endregion
|
|
2407
2634
|
//#region src/core/checks.ts
|
|
@@ -2414,31 +2641,32 @@ const listCheckRunsInputSchema = z.object({
|
|
|
2414
2641
|
});
|
|
2415
2642
|
const listCheckRunsDescription = "List check runs (Checks API — GitHub Actions and other CI providers) for a commit, branch, or tag";
|
|
2416
2643
|
async function listCheckRunsCore({ token, owner, repo, ref, perPage, maxPages }) {
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2644
|
+
return withOctokit(token, async (octokit) => {
|
|
2645
|
+
let totalCount = 0;
|
|
2646
|
+
const checkRuns = await fetchAllPages(async (page) => {
|
|
2647
|
+
const { data } = await octokit.rest.checks.listForRef({
|
|
2648
|
+
owner,
|
|
2649
|
+
repo,
|
|
2650
|
+
ref,
|
|
2651
|
+
per_page: perPage,
|
|
2652
|
+
page
|
|
2653
|
+
});
|
|
2654
|
+
totalCount = data.total_count;
|
|
2655
|
+
return data.check_runs;
|
|
2656
|
+
}, perPage, maxPages);
|
|
2657
|
+
return {
|
|
2658
|
+
totalCount,
|
|
2659
|
+
checkRuns: checkRuns.map((run) => ({
|
|
2660
|
+
id: run.id,
|
|
2661
|
+
name: run.name,
|
|
2662
|
+
status: run.status,
|
|
2663
|
+
conclusion: run.conclusion,
|
|
2664
|
+
url: run.html_url,
|
|
2665
|
+
startedAt: run.started_at,
|
|
2666
|
+
completedAt: run.completed_at
|
|
2667
|
+
}))
|
|
2668
|
+
};
|
|
2669
|
+
});
|
|
2442
2670
|
}
|
|
2443
2671
|
const getCombinedStatusInputSchema = z.object({
|
|
2444
2672
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2447,21 +2675,23 @@ const getCombinedStatusInputSchema = z.object({
|
|
|
2447
2675
|
});
|
|
2448
2676
|
const getCombinedStatusDescription = "Get the combined commit status (Statuses API — legacy CI integrations) for a commit, branch, or tag";
|
|
2449
2677
|
async function getCombinedStatusCore({ token, owner, repo, ref }) {
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2678
|
+
return withOctokit(token, async (octokit) => {
|
|
2679
|
+
const { data } = await octokit.rest.repos.getCombinedStatusForRef({
|
|
2680
|
+
owner,
|
|
2681
|
+
repo,
|
|
2682
|
+
ref
|
|
2683
|
+
});
|
|
2684
|
+
return {
|
|
2685
|
+
state: data.state,
|
|
2686
|
+
totalCount: data.total_count,
|
|
2687
|
+
statuses: data.statuses.map((status) => ({
|
|
2688
|
+
context: status.context,
|
|
2689
|
+
state: status.state,
|
|
2690
|
+
description: status.description,
|
|
2691
|
+
url: status.target_url
|
|
2692
|
+
}))
|
|
2693
|
+
};
|
|
2454
2694
|
});
|
|
2455
|
-
return {
|
|
2456
|
-
state: data.state,
|
|
2457
|
-
totalCount: data.total_count,
|
|
2458
|
-
statuses: data.statuses.map((status) => ({
|
|
2459
|
-
context: status.context,
|
|
2460
|
-
state: status.state,
|
|
2461
|
-
description: status.description,
|
|
2462
|
-
url: status.target_url
|
|
2463
|
-
}))
|
|
2464
|
-
};
|
|
2465
2695
|
}
|
|
2466
2696
|
//#endregion
|
|
2467
2697
|
//#region src/core/releases.ts
|
|
@@ -2474,27 +2704,28 @@ const listReleasesInputSchema = z.object({
|
|
|
2474
2704
|
});
|
|
2475
2705
|
const listReleasesDescription = "List releases for a GitHub repository, newest first (includes drafts and prereleases). Bodies truncated by default (detail: summary)";
|
|
2476
2706
|
async function listReleasesCore({ token, owner, repo, perPage, maxPages, detail = "summary" }) {
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2707
|
+
return withOctokit(token, async (octokit) => {
|
|
2708
|
+
return (await fetchAllPages(async (page) => {
|
|
2709
|
+
const { data } = await octokit.rest.repos.listReleases({
|
|
2710
|
+
owner,
|
|
2711
|
+
repo,
|
|
2712
|
+
per_page: perPage,
|
|
2713
|
+
page
|
|
2714
|
+
});
|
|
2715
|
+
return data;
|
|
2716
|
+
}, perPage, maxPages)).map((release) => ({
|
|
2717
|
+
id: release.id,
|
|
2718
|
+
tagName: release.tag_name,
|
|
2719
|
+
name: release.name,
|
|
2720
|
+
body: applyDetailBody(release.body, detail),
|
|
2721
|
+
draft: release.draft,
|
|
2722
|
+
prerelease: release.prerelease,
|
|
2723
|
+
url: release.html_url,
|
|
2724
|
+
author: release.author?.login,
|
|
2725
|
+
createdAt: release.created_at,
|
|
2726
|
+
publishedAt: release.published_at
|
|
2727
|
+
}));
|
|
2728
|
+
});
|
|
2498
2729
|
}
|
|
2499
2730
|
const getLatestReleaseInputSchema = z.object({
|
|
2500
2731
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2503,26 +2734,28 @@ const getLatestReleaseInputSchema = z.object({
|
|
|
2503
2734
|
});
|
|
2504
2735
|
const getLatestReleaseDescription = "Get the latest published release for a GitHub repository (excludes drafts and prereleases). Body truncated by default (detail: summary)";
|
|
2505
2736
|
async function getLatestReleaseCore({ token, owner, repo, detail = "summary" }) {
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2737
|
+
return withOctokit(token, async (octokit) => {
|
|
2738
|
+
const { data } = await octokit.rest.repos.getLatestRelease({
|
|
2739
|
+
owner,
|
|
2740
|
+
repo
|
|
2741
|
+
});
|
|
2742
|
+
return {
|
|
2743
|
+
id: data.id,
|
|
2744
|
+
tagName: data.tag_name,
|
|
2745
|
+
name: data.name,
|
|
2746
|
+
body: applyDetailBody(data.body, detail),
|
|
2747
|
+
url: data.html_url,
|
|
2748
|
+
author: data.author?.login,
|
|
2749
|
+
createdAt: data.created_at,
|
|
2750
|
+
publishedAt: data.published_at,
|
|
2751
|
+
assets: data.assets.map((asset) => ({
|
|
2752
|
+
name: asset.name,
|
|
2753
|
+
downloadUrl: asset.browser_download_url,
|
|
2754
|
+
size: asset.size,
|
|
2755
|
+
downloadCount: asset.download_count
|
|
2756
|
+
}))
|
|
2757
|
+
};
|
|
2509
2758
|
});
|
|
2510
|
-
return {
|
|
2511
|
-
id: data.id,
|
|
2512
|
-
tagName: data.tag_name,
|
|
2513
|
-
name: data.name,
|
|
2514
|
-
body: applyDetailBody(data.body, detail),
|
|
2515
|
-
url: data.html_url,
|
|
2516
|
-
author: data.author?.login,
|
|
2517
|
-
createdAt: data.created_at,
|
|
2518
|
-
publishedAt: data.published_at,
|
|
2519
|
-
assets: data.assets.map((asset) => ({
|
|
2520
|
-
name: asset.name,
|
|
2521
|
-
downloadUrl: asset.browser_download_url,
|
|
2522
|
-
size: asset.size,
|
|
2523
|
-
downloadCount: asset.download_count
|
|
2524
|
-
}))
|
|
2525
|
-
};
|
|
2526
2759
|
}
|
|
2527
2760
|
const getReleaseInputSchema = z.object({
|
|
2528
2761
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2532,29 +2765,31 @@ const getReleaseInputSchema = z.object({
|
|
|
2532
2765
|
});
|
|
2533
2766
|
const getReleaseDescription = "Get a specific release by ID, including its assets. Body truncated by default (detail: summary)";
|
|
2534
2767
|
async function getReleaseCore({ token, owner, repo, releaseId, detail = "summary" }) {
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2768
|
+
return withOctokit(token, async (octokit) => {
|
|
2769
|
+
const { data } = await octokit.rest.repos.getRelease({
|
|
2770
|
+
owner,
|
|
2771
|
+
repo,
|
|
2772
|
+
release_id: releaseId
|
|
2773
|
+
});
|
|
2774
|
+
return {
|
|
2775
|
+
id: data.id,
|
|
2776
|
+
tagName: data.tag_name,
|
|
2777
|
+
name: data.name,
|
|
2778
|
+
body: applyDetailBody(data.body, detail),
|
|
2779
|
+
draft: data.draft,
|
|
2780
|
+
prerelease: data.prerelease,
|
|
2781
|
+
url: data.html_url,
|
|
2782
|
+
author: data.author?.login,
|
|
2783
|
+
createdAt: data.created_at,
|
|
2784
|
+
publishedAt: data.published_at,
|
|
2785
|
+
assets: data.assets.map((asset) => ({
|
|
2786
|
+
name: asset.name,
|
|
2787
|
+
downloadUrl: asset.browser_download_url,
|
|
2788
|
+
size: asset.size,
|
|
2789
|
+
downloadCount: asset.download_count
|
|
2790
|
+
}))
|
|
2791
|
+
};
|
|
2539
2792
|
});
|
|
2540
|
-
return {
|
|
2541
|
-
id: data.id,
|
|
2542
|
-
tagName: data.tag_name,
|
|
2543
|
-
name: data.name,
|
|
2544
|
-
body: applyDetailBody(data.body, detail),
|
|
2545
|
-
draft: data.draft,
|
|
2546
|
-
prerelease: data.prerelease,
|
|
2547
|
-
url: data.html_url,
|
|
2548
|
-
author: data.author?.login,
|
|
2549
|
-
createdAt: data.created_at,
|
|
2550
|
-
publishedAt: data.published_at,
|
|
2551
|
-
assets: data.assets.map((asset) => ({
|
|
2552
|
-
name: asset.name,
|
|
2553
|
-
downloadUrl: asset.browser_download_url,
|
|
2554
|
-
size: asset.size,
|
|
2555
|
-
downloadCount: asset.download_count
|
|
2556
|
-
}))
|
|
2557
|
-
};
|
|
2558
2793
|
}
|
|
2559
2794
|
const createReleaseInputSchema = z.object({
|
|
2560
2795
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2570,27 +2805,29 @@ const createReleaseInputSchema = z.object({
|
|
|
2570
2805
|
const createReleaseDescription = "Create a new release (and its tag if needed) in a GitHub repository";
|
|
2571
2806
|
/** Not idempotent — creating a release with an existing tag name returns an error from GitHub. */
|
|
2572
2807
|
async function createReleaseCore({ token, owner, repo, tagName, target, name, body, draft, prerelease, generateReleaseNotes }) {
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2808
|
+
return withOctokit(token, async (octokit) => {
|
|
2809
|
+
const { data } = await octokit.rest.repos.createRelease({
|
|
2810
|
+
owner,
|
|
2811
|
+
repo,
|
|
2812
|
+
tag_name: tagName,
|
|
2813
|
+
target_commitish: target,
|
|
2814
|
+
name,
|
|
2815
|
+
body,
|
|
2816
|
+
draft,
|
|
2817
|
+
prerelease,
|
|
2818
|
+
generate_release_notes: generateReleaseNotes
|
|
2819
|
+
});
|
|
2820
|
+
return {
|
|
2821
|
+
id: data.id,
|
|
2822
|
+
tagName: data.tag_name,
|
|
2823
|
+
name: data.name,
|
|
2824
|
+
body: data.body,
|
|
2825
|
+
url: data.html_url,
|
|
2826
|
+
draft: data.draft,
|
|
2827
|
+
prerelease: data.prerelease,
|
|
2828
|
+
createdAt: data.created_at
|
|
2829
|
+
};
|
|
2583
2830
|
});
|
|
2584
|
-
return {
|
|
2585
|
-
id: data.id,
|
|
2586
|
-
tagName: data.tag_name,
|
|
2587
|
-
name: data.name,
|
|
2588
|
-
body: data.body,
|
|
2589
|
-
url: data.html_url,
|
|
2590
|
-
draft: data.draft,
|
|
2591
|
-
prerelease: data.prerelease,
|
|
2592
|
-
createdAt: data.created_at
|
|
2593
|
-
};
|
|
2594
2831
|
}
|
|
2595
2832
|
const updateReleaseInputSchema = z.object({
|
|
2596
2833
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2606,27 +2843,29 @@ const updateReleaseInputSchema = z.object({
|
|
|
2606
2843
|
const updateReleaseDescription = "Update an existing release — tag, target, title, notes, draft, or prerelease status";
|
|
2607
2844
|
/** Not idempotent — each call applies a new revision. */
|
|
2608
2845
|
async function updateReleaseCore({ token, owner, repo, releaseId, tagName, target, name, body, draft, prerelease }) {
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2846
|
+
return withOctokit(token, async (octokit) => {
|
|
2847
|
+
const { data } = await octokit.rest.repos.updateRelease({
|
|
2848
|
+
owner,
|
|
2849
|
+
repo,
|
|
2850
|
+
release_id: releaseId,
|
|
2851
|
+
tag_name: tagName,
|
|
2852
|
+
target_commitish: target,
|
|
2853
|
+
name,
|
|
2854
|
+
body,
|
|
2855
|
+
draft,
|
|
2856
|
+
prerelease
|
|
2857
|
+
});
|
|
2858
|
+
return {
|
|
2859
|
+
id: data.id,
|
|
2860
|
+
tagName: data.tag_name,
|
|
2861
|
+
name: data.name,
|
|
2862
|
+
body: data.body,
|
|
2863
|
+
url: data.html_url,
|
|
2864
|
+
draft: data.draft,
|
|
2865
|
+
prerelease: data.prerelease,
|
|
2866
|
+
publishedAt: data.published_at
|
|
2867
|
+
};
|
|
2619
2868
|
});
|
|
2620
|
-
return {
|
|
2621
|
-
id: data.id,
|
|
2622
|
-
tagName: data.tag_name,
|
|
2623
|
-
name: data.name,
|
|
2624
|
-
body: data.body,
|
|
2625
|
-
url: data.html_url,
|
|
2626
|
-
draft: data.draft,
|
|
2627
|
-
prerelease: data.prerelease,
|
|
2628
|
-
publishedAt: data.published_at
|
|
2629
|
-
};
|
|
2630
2869
|
}
|
|
2631
2870
|
const deleteReleaseInputSchema = z.object({
|
|
2632
2871
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2636,15 +2875,17 @@ const deleteReleaseInputSchema = z.object({
|
|
|
2636
2875
|
const deleteReleaseDescription = "Delete a release permanently (does not delete the underlying git tag)";
|
|
2637
2876
|
/** Not idempotent — deleting an already-deleted release returns 404 from GitHub. */
|
|
2638
2877
|
async function deleteReleaseCore({ token, owner, repo, releaseId }) {
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2878
|
+
return withOctokit(token, async (octokit) => {
|
|
2879
|
+
await octokit.rest.repos.deleteRelease({
|
|
2880
|
+
owner,
|
|
2881
|
+
repo,
|
|
2882
|
+
release_id: releaseId
|
|
2883
|
+
});
|
|
2884
|
+
return {
|
|
2885
|
+
deleted: true,
|
|
2886
|
+
releaseId
|
|
2887
|
+
};
|
|
2643
2888
|
});
|
|
2644
|
-
return {
|
|
2645
|
-
deleted: true,
|
|
2646
|
-
releaseId
|
|
2647
|
-
};
|
|
2648
2889
|
}
|
|
2649
2890
|
//#endregion
|
|
2650
2891
|
//#region src/core/bundles.ts
|
|
@@ -2703,12 +2944,12 @@ async function getPullRequestContextCore({ token, owner, repo, pullNumber, inclu
|
|
|
2703
2944
|
combinedStatus
|
|
2704
2945
|
})) : Promise.resolve(void 0)
|
|
2705
2946
|
]);
|
|
2706
|
-
return {
|
|
2947
|
+
return withComposedRateLimit({
|
|
2707
2948
|
pullRequest,
|
|
2708
2949
|
...files !== void 0 ? { files } : {},
|
|
2709
2950
|
...reviews !== void 0 ? { reviews } : {},
|
|
2710
2951
|
...checks !== void 0 ? { checks } : {}
|
|
2711
|
-
};
|
|
2952
|
+
});
|
|
2712
2953
|
}
|
|
2713
2954
|
const getIssueContextInputSchema = z.object({
|
|
2714
2955
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2746,11 +2987,11 @@ async function getIssueContextCore({ token, owner, repo, issueNumber, includeLab
|
|
|
2746
2987
|
detail
|
|
2747
2988
|
}) : Promise.resolve(void 0)
|
|
2748
2989
|
]);
|
|
2749
|
-
return {
|
|
2990
|
+
return withComposedRateLimit({
|
|
2750
2991
|
issue,
|
|
2751
2992
|
...labels !== void 0 ? { labelNames: labels.map((label) => label.name) } : {},
|
|
2752
2993
|
...comments !== void 0 ? { comments } : {}
|
|
2753
|
-
};
|
|
2994
|
+
});
|
|
2754
2995
|
}
|
|
2755
2996
|
const getReleaseContextInputSchema = z.object({
|
|
2756
2997
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2792,11 +3033,11 @@ async function getReleaseContextCore({ token, owner, repo, releaseId, includePre
|
|
|
2792
3033
|
head: release.tagName,
|
|
2793
3034
|
includePatch: false
|
|
2794
3035
|
});
|
|
2795
|
-
return {
|
|
3036
|
+
return withComposedRateLimit({
|
|
2796
3037
|
release,
|
|
2797
3038
|
...previous !== void 0 ? { previousRelease: previous } : {},
|
|
2798
3039
|
...comparison !== void 0 ? { comparison } : {}
|
|
2799
|
-
};
|
|
3040
|
+
});
|
|
2800
3041
|
}
|
|
2801
3042
|
const getCiFailureContextInputSchema = z.object({
|
|
2802
3043
|
owner: z.string().describe("Repository owner"),
|
|
@@ -2864,14 +3105,14 @@ async function getCiFailureContextCore({ token, owner, repo, ref, maxFailedRuns,
|
|
|
2864
3105
|
steps: job.steps?.filter((step) => step.conclusion != null && FAILURE_CONCLUSIONS.has(step.conclusion))
|
|
2865
3106
|
}))
|
|
2866
3107
|
};
|
|
2867
|
-
return {
|
|
3108
|
+
return withComposedRateLimit({
|
|
2868
3109
|
ref,
|
|
2869
3110
|
combinedStatus,
|
|
2870
3111
|
failedCheckRuns,
|
|
2871
3112
|
checkRunTotalCount: checkRunsResult.totalCount,
|
|
2872
3113
|
recentFailedRuns: failedRuns.runs,
|
|
2873
3114
|
...latestFailure !== void 0 ? { latestFailure } : {}
|
|
2874
|
-
};
|
|
3115
|
+
});
|
|
2875
3116
|
}
|
|
2876
3117
|
//#endregion
|
|
2877
3118
|
//#region src/core/context.ts
|
|
@@ -3596,6 +3837,6 @@ const GITHUB_WRITE_TOOLS = {
|
|
|
3596
3837
|
};
|
|
3597
3838
|
Object.values(GITHUB_WRITE_TOOLS);
|
|
3598
3839
|
//#endregion
|
|
3599
|
-
export { listWorkflowJobsDescription as $, getIssueDescription as $n, requestReviewersDescription as $r, searchRepositoriesDescription as $t, getLatestReleaseInputSchema as A, getRepositoryDescription as Ai, addAssigneesInputSchema as An, createPullRequestInputSchema as Ar, listGistsInputSchema as At, getCombinedStatusCore as B, createIssueCore as Bn, listPullRequestFilesCore as Br, getCommitCore as Bt, createReleaseDescription as C, forkRepositoryCore as Ci, listCommentReactionsDescription as Cn, updateLabelDescription as Cr, getGistDescription as Ct, deleteReleaseInputSchema as D, getFileContentDescription as Di, listIssueReactionsInputSchema as Dn, addPullRequestCommentInputSchema as Dr, listGistCommentsInputSchema as Dt, deleteReleaseDescription as E, getFileContentCore as Ei, listIssueReactionsDescription as En, addPullRequestCommentDescription as Er, listGistCommentsDescription as Et, listReleasesDescription as F, listBranchesCore as Fi, addLabelsDescription as Fn, deletePullRequestCommentDescription as Fr, compareCommitsDescription as Ft, listCheckRunsInputSchema as G, createLabelInputSchema as Gn, listPullRequestReviewsInputSchema as Gr, listCommitsInputSchema as Gt, getCombinedStatusInputSchema as H, createIssueInputSchema as Hn, listPullRequestFilesInputSchema as Hr, getCommitInputSchema as Ht, listReleasesInputSchema as I, listBranchesDescription as Ii, addLabelsInputSchema as In, deletePullRequestCommentInputSchema as Ir, compareCommitsInputSchema as It, cancelWorkflowRunInputSchema as J, deleteIssueCommentInputSchema as Jn, listPullRequestsInputSchema as Jr, searchCodeInputSchema as Jt, cancelWorkflowRunCore as K, deleteIssueCommentCore as Kn, listPullRequestsCore as Kr, searchCodeCore as Kt, updateReleaseCore as L, listBranchesInputSchema as Li, closeIssueCore as Ln, getPullRequestCore as Lr, getBlameCore as Lt, getReleaseDescription as M, getRepositoryTreeCore as Mi, addIssueCommentDescription as Mn, createPullRequestReviewDescription as Mr, updateGistDescription as Mt, getReleaseInputSchema as N, getRepositoryTreeDescription as Ni, addIssueCommentInputSchema as Nn, createPullRequestReviewInputSchema as Nr, updateGistInputSchema as Nt, getLatestReleaseCore as O, getFileContentInputSchema as Oi, addAssigneesCore as On, createPullRequestCore as Or, listGistsCore as Ot, listReleasesCore as P, getRepositoryTreeInputSchema as Pi, addLabelsCore as Pn, deletePullRequestCommentCore as Pr, compareCommitsCore as Pt, listWorkflowJobsCore as Q, getIssueCore as Qn, requestReviewersCore as Qr, searchRepositoriesCore as Qt, updateReleaseDescription as R, createOctokit as Ri, closeIssueDescription as Rn, getPullRequestDescription as Rr, getBlameDescription as Rt, createReleaseCore as S, createRepositoryInputSchema as Si, listCommentReactionsCore as Sn, updateLabelCore as Sr, getGistCore as St, deleteReleaseCore as T, forkRepositoryInputSchema as Ti, listIssueReactionsCore as Tn, addPullRequestCommentCore as Tr, listGistCommentsCore as Tt, listCheckRunsCore as U, createLabelCore as Un, listPullRequestReviewsCore as Ur, listCommitsCore as Ut, getCombinedStatusDescription as V, createIssueDescription as Vn, listPullRequestFilesDescription as Vr, getCommitDescription as Vt, listCheckRunsDescription as W, createLabelDescription as Wn, listPullRequestReviewsDescription as Wr, listCommitsDescription as Wt, getWorkflowRunDescription as X, deleteLabelDescription as Xn, mergePullRequestDescription as Xr, searchIssuesDescription as Xt, getWorkflowRunCore as Y, deleteLabelCore as Yn, mergePullRequestCore as Yr, searchIssuesCore as Yt, getWorkflowRunInputSchema as Z, deleteLabelInputSchema as Zn, mergePullRequestInputSchema as Zr, searchIssuesInputSchema as Zt, getPullRequestContextDescription as _, createOrUpdateFileCore as _i, addCommentReactionDescription as _n, updateIssueCommentDescription as _r, createGistDescription as _t, resolvePresetTools as a, updatePullRequestDescription as ai, markNotificationReadDescription as an, listIssuesDescription as ar, listWorkflowsDescription as at, getReleaseContextDescription as b, createRepositoryCore as bi, addIssueReactionDescription as bn, updateIssueDescription as br, deleteGistDescription as bt, mergeContextArgs as c, resolveGithubToken as ci, addDiscussionCommentDescription as cn, listLabelsDescription as cr, rerunWorkflowRunDescription as ct, getCiFailureContextDescription as d, getFileContentToModelOutput as di, getDiscussionDescription as dn, removeAssigneesDescription as dr, triggerWorkflowDescription as dt, requestReviewersInputSchema as ei, searchRepositoriesInputSchema as en, getIssueInputSchema as er, listWorkflowJobsInputSchema as et, getCiFailureContextInputSchema as f, getPullRequestContextToModelOutput as fi, getDiscussionInputSchema as fn, removeAssigneesInputSchema as fr, triggerWorkflowInputSchema as ft, getPullRequestContextCore as g, createBranchInputSchema as gi, addCommentReactionCore as gn, updateIssueCommentCore as gr, createGistCore as gt, getIssueContextInputSchema as h, createBranchDescription as hi, listDiscussionsInputSchema as hn, removeLabelInputSchema as hr, createGistCommentInputSchema as ht, PRESET_TOOLS as i, updatePullRequestCore as ii, markNotificationReadCore as in, listIssuesCore as ir, listWorkflowsCore as it, getReleaseCore as j, getRepositoryInputSchema as ji, addIssueCommentCore as jn, createPullRequestReviewCore as jr, updateGistCore as jt, getLatestReleaseDescription as k, getRepositoryCore as ki, addAssigneesDescription as kn, createPullRequestDescription as kr, listGistsDescription as kt, softenContextSchema as l, compareCommitsToModelOutput as li, addDiscussionCommentInputSchema as ln, listLabelsInputSchema as lr, rerunWorkflowRunInputSchema as lt, getIssueContextDescription as m, createBranchCore as mi, listDiscussionsDescription as mn, removeLabelDescription as mr, createGistCommentDescription as mt, ALL_GITHUB_TOOL_NAMES as n, updatePullRequestCommentDescription as ni, listNotificationsDescription as nn, listIssueCommentsDescription as nr, listWorkflowRunsDescription as nt, bindToolsContext as o, updatePullRequestInputSchema as oi, markNotificationReadInputSchema as on, listIssuesInputSchema as or, listWorkflowsInputSchema as ot, getIssueContextCore as p, listPullRequestFilesToModelOutput as pi, listDiscussionsCore as pn, removeLabelCore as pr, createGistCommentCore as pt, cancelWorkflowRunDescription as q, deleteIssueCommentDescription as qn, listPullRequestsDescription as qr, searchCodeDescription as qt, GITHUB_TOOL_NAMES as r, updatePullRequestCommentInputSchema as ri, listNotificationsInputSchema as rn, listIssueCommentsInputSchema as rr, listWorkflowRunsInputSchema as rt, formatContextInstructions as s, createGithubTokenResolver as si, addDiscussionCommentCore as sn, listLabelsCore as sr, rerunWorkflowRunCore as st, GITHUB_WRITE_TOOLS as t, updatePullRequestCommentCore as ti, listNotificationsCore as tn, listIssueCommentsCore as tr, listWorkflowRunsCore as tt, getCiFailureContextCore as u, getCommitToModelOutput as ui, getDiscussionCore as un, removeAssigneesCore as ur, triggerWorkflowCore as ut, getPullRequestContextInputSchema as v, createOrUpdateFileDescription as vi, addCommentReactionInputSchema as vn, updateIssueCommentInputSchema as vr, createGistInputSchema as vt, createReleaseInputSchema as w, forkRepositoryDescription as wi, listCommentReactionsInputSchema as wn, updateLabelInputSchema as wr, getGistInputSchema as wt, getReleaseContextInputSchema as x, createRepositoryDescription as xi, addIssueReactionInputSchema as xn, updateIssueInputSchema as xr, deleteGistInputSchema as xt, getReleaseContextCore as y, createOrUpdateFileInputSchema as yi, addIssueReactionCore as yn, updateIssueCore as yr, deleteGistCore as yt, updateReleaseInputSchema as z, closeIssueInputSchema as zn, getPullRequestInputSchema as zr, getBlameInputSchema as zt };
|
|
3840
|
+
export { listWorkflowJobsDescription as $, getIssueDescription as $n, requestReviewersDescription as $r, searchRepositoriesDescription as $t, getLatestReleaseInputSchema as A, getRepositoryDescription as Ai, addAssigneesInputSchema as An, createPullRequestInputSchema as Ar, listGistsInputSchema as At, getCombinedStatusCore as B, createIssueCore as Bn, listPullRequestFilesCore as Br, getCommitCore as Bt, createReleaseDescription as C, forkRepositoryCore as Ci, listCommentReactionsDescription as Cn, updateLabelDescription as Cr, getGistDescription as Ct, deleteReleaseInputSchema as D, getFileContentDescription as Di, listIssueReactionsInputSchema as Dn, addPullRequestCommentInputSchema as Dr, listGistCommentsInputSchema as Dt, deleteReleaseDescription as E, getFileContentCore as Ei, listIssueReactionsDescription as En, addPullRequestCommentDescription as Er, listGistCommentsDescription as Et, listReleasesDescription as F, listBranchesCore as Fi, addLabelsDescription as Fn, deletePullRequestCommentDescription as Fr, compareCommitsDescription as Ft, listCheckRunsInputSchema as G, createLabelInputSchema as Gn, listPullRequestReviewsInputSchema as Gr, listCommitsInputSchema as Gt, getCombinedStatusInputSchema as H, createIssueInputSchema as Hn, listPullRequestFilesInputSchema as Hr, getCommitInputSchema as Ht, listReleasesInputSchema as I, listBranchesDescription as Ii, addLabelsInputSchema as In, deletePullRequestCommentInputSchema as Ir, compareCommitsInputSchema as It, cancelWorkflowRunInputSchema as J, deleteIssueCommentInputSchema as Jn, listPullRequestsInputSchema as Jr, searchCodeInputSchema as Jt, cancelWorkflowRunCore as K, deleteIssueCommentCore as Kn, listPullRequestsCore as Kr, searchCodeCore as Kt, updateReleaseCore as L, listBranchesInputSchema as Li, closeIssueCore as Ln, getPullRequestCore as Lr, getBlameCore as Lt, getReleaseDescription as M, getRepositoryTreeCore as Mi, addIssueCommentDescription as Mn, createPullRequestReviewDescription as Mr, updateGistDescription as Mt, getReleaseInputSchema as N, getRepositoryTreeDescription as Ni, addIssueCommentInputSchema as Nn, createPullRequestReviewInputSchema as Nr, updateGistInputSchema as Nt, getLatestReleaseCore as O, getFileContentInputSchema as Oi, addAssigneesCore as On, createPullRequestCore as Or, listGistsCore as Ot, listReleasesCore as P, getRepositoryTreeInputSchema as Pi, addLabelsCore as Pn, deletePullRequestCommentCore as Pr, compareCommitsCore as Pt, listWorkflowJobsCore as Q, getIssueCore as Qn, requestReviewersCore as Qr, searchRepositoriesCore as Qt, updateReleaseDescription as R, createOctokit as Ri, closeIssueDescription as Rn, getPullRequestDescription as Rr, getBlameDescription as Rt, createReleaseCore as S, createRepositoryInputSchema as Si, listCommentReactionsCore as Sn, updateLabelCore as Sr, getGistCore as St, deleteReleaseCore as T, forkRepositoryInputSchema as Ti, listIssueReactionsCore as Tn, addPullRequestCommentCore as Tr, listGistCommentsCore as Tt, listCheckRunsCore as U, createLabelCore as Un, listPullRequestReviewsCore as Ur, listCommitsCore as Ut, getCombinedStatusDescription as V, createIssueDescription as Vn, listPullRequestFilesDescription as Vr, getCommitDescription as Vt, listCheckRunsDescription as W, createLabelDescription as Wn, listPullRequestReviewsDescription as Wr, listCommitsDescription as Wt, getWorkflowRunDescription as X, deleteLabelDescription as Xn, mergePullRequestDescription as Xr, searchIssuesDescription as Xt, getWorkflowRunCore as Y, deleteLabelCore as Yn, mergePullRequestCore as Yr, searchIssuesCore as Yt, getWorkflowRunInputSchema as Z, deleteLabelInputSchema as Zn, mergePullRequestInputSchema as Zr, searchIssuesInputSchema as Zt, getPullRequestContextDescription as _, createOrUpdateFileCore as _i, addCommentReactionDescription as _n, updateIssueCommentDescription as _r, createGistDescription as _t, resolvePresetTools as a, updatePullRequestDescription as ai, markNotificationReadDescription as an, listIssuesDescription as ar, listWorkflowsDescription as at, getReleaseContextDescription as b, createRepositoryCore as bi, addIssueReactionDescription as bn, updateIssueDescription as br, deleteGistDescription as bt, mergeContextArgs as c, resolveGithubToken as ci, addDiscussionCommentDescription as cn, listLabelsDescription as cr, rerunWorkflowRunDescription as ct, getCiFailureContextDescription as d, getFileContentToModelOutput as di, getDiscussionDescription as dn, removeAssigneesDescription as dr, triggerWorkflowDescription as dt, requestReviewersInputSchema as ei, searchRepositoriesInputSchema as en, getIssueInputSchema as er, listWorkflowJobsInputSchema as et, getCiFailureContextInputSchema as f, getPullRequestContextToModelOutput as fi, getDiscussionInputSchema as fn, removeAssigneesInputSchema as fr, triggerWorkflowInputSchema as ft, getPullRequestContextCore as g, createBranchInputSchema as gi, addCommentReactionCore as gn, updateIssueCommentCore as gr, createGistCore as gt, getIssueContextInputSchema as h, createBranchDescription as hi, listDiscussionsInputSchema as hn, removeLabelInputSchema as hr, createGistCommentInputSchema as ht, PRESET_TOOLS as i, updatePullRequestCore as ii, markNotificationReadCore as in, listIssuesCore as ir, listWorkflowsCore as it, getReleaseCore as j, getRepositoryInputSchema as ji, addIssueCommentCore as jn, createPullRequestReviewCore as jr, updateGistCore as jt, getLatestReleaseDescription as k, getRepositoryCore as ki, addAssigneesDescription as kn, createPullRequestDescription as kr, listGistsDescription as kt, softenContextSchema as l, compareCommitsToModelOutput as li, addDiscussionCommentInputSchema as ln, listLabelsInputSchema as lr, rerunWorkflowRunInputSchema as lt, getIssueContextDescription as m, createBranchCore as mi, listDiscussionsDescription as mn, removeLabelDescription as mr, createGistCommentDescription as mt, ALL_GITHUB_TOOL_NAMES as n, updatePullRequestCommentDescription as ni, listNotificationsDescription as nn, listIssueCommentsDescription as nr, listWorkflowRunsDescription as nt, bindToolsContext as o, updatePullRequestInputSchema as oi, markNotificationReadInputSchema as on, listIssuesInputSchema as or, listWorkflowsInputSchema as ot, getIssueContextCore as p, listPullRequestFilesToModelOutput as pi, listDiscussionsCore as pn, removeLabelCore as pr, createGistCommentCore as pt, cancelWorkflowRunDescription as q, deleteIssueCommentDescription as qn, listPullRequestsDescription as qr, searchCodeDescription as qt, GITHUB_TOOL_NAMES as r, updatePullRequestCommentInputSchema as ri, listNotificationsInputSchema as rn, listIssueCommentsInputSchema as rr, listWorkflowRunsInputSchema as rt, formatContextInstructions as s, createGithubTokenResolver as si, addDiscussionCommentCore as sn, listLabelsCore as sr, rerunWorkflowRunCore as st, GITHUB_WRITE_TOOLS as t, updatePullRequestCommentCore as ti, listNotificationsCore as tn, listIssueCommentsCore as tr, listWorkflowRunsCore as tt, getCiFailureContextCore as u, getCommitToModelOutput as ui, getDiscussionCore as un, removeAssigneesCore as ur, triggerWorkflowCore as ut, getPullRequestContextInputSchema as v, createOrUpdateFileDescription as vi, addCommentReactionInputSchema as vn, updateIssueCommentInputSchema as vr, createGistInputSchema as vt, createReleaseInputSchema as w, forkRepositoryDescription as wi, listCommentReactionsInputSchema as wn, updateLabelInputSchema as wr, getGistInputSchema as wt, getReleaseContextInputSchema as x, createRepositoryDescription as xi, addIssueReactionInputSchema as xn, updateIssueInputSchema as xr, deleteGistInputSchema as xt, getReleaseContextCore as y, createOrUpdateFileInputSchema as yi, addIssueReactionCore as yn, updateIssueCore as yr, deleteGistCore as yt, updateReleaseInputSchema as z, stripRateLimit as zi, closeIssueInputSchema as zn, getPullRequestInputSchema as zr, getBlameInputSchema as zt };
|
|
3600
3841
|
|
|
3601
|
-
//# sourceMappingURL=write-tools-
|
|
3842
|
+
//# sourceMappingURL=write-tools-CnJE0Vvu.mjs.map
|