@github-tools/sdk 1.11.1 → 1.13.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.
Files changed (46) hide show
  1. package/README.md +31 -14
  2. package/dist/connect/eve.d.mts +2 -3
  3. package/dist/connect/eve.d.mts.map +1 -1
  4. package/dist/connect/eve.mjs +1 -1
  5. package/dist/connect.d.mts +8 -86
  6. package/dist/connect.d.mts.map +1 -1
  7. package/dist/connect.mjs +2 -2
  8. package/dist/eve-runtime-BkzmgsI2.mjs +274 -0
  9. package/dist/eve-runtime-BkzmgsI2.mjs.map +1 -0
  10. package/dist/eve-runtime-C5HaKmOP.d.mts +85 -0
  11. package/dist/eve-runtime-C5HaKmOP.d.mts.map +1 -0
  12. package/dist/eve-runtime.d.mts +5 -4
  13. package/dist/eve-runtime.mjs +3 -3
  14. package/dist/eve.d.mts +4 -4
  15. package/dist/eve.d.mts.map +1 -1
  16. package/dist/eve.mjs +2 -2
  17. package/dist/index-BjRUOM2Z.d.mts +287 -0
  18. package/dist/index-BjRUOM2Z.d.mts.map +1 -0
  19. package/dist/index.d.mts +3 -2
  20. package/dist/index.mjs +3 -3
  21. package/dist/{src-jQWS2Txw.mjs → src-DPcwVTf-.mjs} +98 -4
  22. package/dist/src-DPcwVTf-.mjs.map +1 -0
  23. package/dist/{token-1uPUq_g-.mjs → token-qesvchbI.mjs} +23 -169
  24. package/dist/token-qesvchbI.mjs.map +1 -0
  25. package/dist/tool-types-K8i--5D9.d.mts +3255 -0
  26. package/dist/tool-types-K8i--5D9.d.mts.map +1 -0
  27. package/dist/{types-BD5YvGxm.d.mts → types-6aWpzNzg.d.mts} +3 -3
  28. package/dist/{types-BD5YvGxm.d.mts.map → types-6aWpzNzg.d.mts.map} +1 -1
  29. package/dist/{types-BDO-Mmn6.d.mts → types-BVSe0Zey.d.mts} +4 -3
  30. package/dist/types-BVSe0Zey.d.mts.map +1 -0
  31. package/dist/workflow.d.mts +2 -1
  32. package/dist/workflow.d.mts.map +1 -1
  33. package/dist/workflow.mjs +2 -2
  34. package/dist/{write-tools-Dk32V9Hl.mjs → write-tools-BEcL5Fv6.mjs} +2626 -1513
  35. package/dist/write-tools-BEcL5Fv6.mjs.map +1 -0
  36. package/package.json +5 -5
  37. package/dist/eve-runtime-Cb0LVEvS.d.mts +0 -66
  38. package/dist/eve-runtime-Cb0LVEvS.d.mts.map +0 -1
  39. package/dist/eve-runtime-DInXr4h5.mjs +0 -734
  40. package/dist/eve-runtime-DInXr4h5.mjs.map +0 -1
  41. package/dist/index-BNeMjmgp.d.mts +0 -770
  42. package/dist/index-BNeMjmgp.d.mts.map +0 -1
  43. package/dist/src-jQWS2Txw.mjs.map +0 -1
  44. package/dist/token-1uPUq_g-.mjs.map +0 -1
  45. package/dist/types-BDO-Mmn6.d.mts.map +0 -1
  46. 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
- const { data } = await createOctokit(token).rest.repos.get({
148
- owner,
149
- repo
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
- const { data } = await createOctokit(token).rest.repos.listBranches({
174
- owner,
175
- repo,
176
- per_page: perPage
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
- const { data } = await createOctokit(token).rest.repos.getContent({
196
- owner,
197
- repo,
198
- path,
199
- ref
200
- });
201
- if (Array.isArray(data)) return {
202
- type: "directory",
203
- entries: data.map((e) => ({
204
- name: e.name,
205
- type: e.type,
206
- path: e.path
207
- }))
208
- };
209
- if (data.type !== "file") return {
210
- type: data.type,
211
- path: data.path
212
- };
213
- const fullContent = Buffer.from(data.content, "base64").toString("utf-8");
214
- const lines = fullContent.split("\n");
215
- const totalLines = lines.length;
216
- if (!(startLine != null || endLine != null || maxLines != null)) return {
217
- type: "file",
218
- path: data.path,
219
- sha: data.sha,
220
- size: data.size,
221
- totalLines,
222
- content: fullContent
223
- };
224
- const from = startLine ?? 1;
225
- const to = endLine ?? (maxLines != null ? from + maxLines - 1 : totalLines);
226
- const clampedFrom = Math.min(Math.max(from, 1), totalLines);
227
- const clampedTo = Math.min(Math.max(to, clampedFrom), totalLines);
228
- const slice = lines.slice(clampedFrom - 1, clampedTo);
229
- return {
230
- type: "file",
231
- path: data.path,
232
- sha: data.sha,
233
- size: data.size,
234
- totalLines,
235
- startLine: clampedFrom,
236
- endLine: clampedTo,
237
- truncated: clampedFrom > 1 || clampedTo < totalLines,
238
- content: slice.join("\n")
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
- const octokit = createOctokit(token);
250
- const treeSha = ref || (await octokit.rest.repos.get({
251
- owner,
252
- repo
253
- })).data.default_branch;
254
- const { data } = await octokit.rest.git.getTree({
255
- owner,
256
- repo,
257
- tree_sha: treeSha,
258
- recursive: recursive ? "true" : void 0
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,63 @@ 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
- const octokit = createOctokit(token);
281
- let sha = from;
282
- if (!sha || !sha.match(/^[0-9a-f]{40}$/i)) {
283
- const { data: ref } = await octokit.rest.git.getRef({
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({
397
+ owner,
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({
284
419
  owner,
285
420
  repo,
286
- ref: `heads/${from || (await octokit.rest.repos.get({
287
- owner,
288
- repo
289
- })).data.default_branch}`
421
+ ref: `refs/heads/${branch}`,
422
+ sha
290
423
  });
291
- sha = ref.object.sha;
292
- }
293
- try {
294
- const { data: existingRef } = await octokit.rest.git.getRef({
424
+ return {
425
+ ref: data.ref,
426
+ sha: data.object.sha,
427
+ url: data.url
428
+ };
429
+ });
430
+ }
431
+ const deleteBranchInputSchema = z.object({
432
+ owner: z.string().describe("Repository owner"),
433
+ repo: z.string().describe("Repository name"),
434
+ branch: z.string().describe("Branch name to delete (without the refs/heads/ prefix)")
435
+ });
436
+ const deleteBranchDescription = "Delete a branch from a GitHub repository permanently";
437
+ /** Not idempotent — deleting a branch that no longer exists fails with a 422. */
438
+ async function deleteBranchCore({ token, owner, repo, branch }) {
439
+ return withOctokit(token, async (octokit) => {
440
+ await octokit.rest.git.deleteRef({
295
441
  owner,
296
442
  repo,
297
443
  ref: `heads/${branch}`
298
444
  });
299
- if (existingRef.object.sha === sha) return {
300
- ref: existingRef.ref,
301
- sha: existingRef.object.sha,
302
- url: existingRef.url
445
+ return {
446
+ deleted: true,
447
+ branch
303
448
  };
304
- } catch {}
305
- const { data } = await octokit.rest.git.createRef({
306
- owner,
307
- repo,
308
- ref: `refs/heads/${branch}`,
309
- sha
310
449
  });
311
- return {
312
- ref: data.ref,
313
- sha: data.object.sha,
314
- url: data.url
315
- };
316
450
  }
317
451
  const forkRepositoryInputSchema = z.object({
318
452
  owner: z.string().describe("Repository owner to fork from"),
@@ -323,25 +457,27 @@ const forkRepositoryInputSchema = z.object({
323
457
  const forkRepositoryDescription = "Fork a GitHub repository to the authenticated user account or a specified organization";
324
458
  /** Not idempotent — each call may create another fork attempt. */
325
459
  async function forkRepositoryCore({ token, owner, repo, organization, name }) {
326
- const { data } = await createOctokit(token).rest.repos.createFork({
327
- owner,
328
- repo,
329
- organization,
330
- name
460
+ return withOctokit(token, async (octokit) => {
461
+ const { data } = await octokit.rest.repos.createFork({
462
+ owner,
463
+ repo,
464
+ organization,
465
+ name
466
+ });
467
+ return {
468
+ name: data.name,
469
+ fullName: data.full_name,
470
+ url: data.html_url,
471
+ cloneUrl: data.clone_url,
472
+ sshUrl: data.ssh_url,
473
+ defaultBranch: data.default_branch,
474
+ private: data.private,
475
+ parent: data.parent ? {
476
+ fullName: data.parent.full_name,
477
+ url: data.parent.html_url
478
+ } : null
479
+ };
331
480
  });
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
481
  }
346
482
  const createRepositoryInputSchema = z.object({
347
483
  name: z.string().describe("Repository name"),
@@ -355,30 +491,31 @@ const createRepositoryInputSchema = z.object({
355
491
  const createRepositoryDescription = "Create a new GitHub repository for the authenticated user or a specified organization";
356
492
  /** Not idempotent — each call creates a new repository. */
357
493
  async function createRepositoryCore({ token, name, description, isPrivate, autoInit, gitignoreTemplate, licenseTemplate, org }) {
358
- const octokit = createOctokit(token);
359
- const params = {
360
- name,
361
- description,
362
- private: isPrivate,
363
- auto_init: autoInit,
364
- gitignore_template: gitignoreTemplate,
365
- license_template: licenseTemplate
366
- };
367
- const { data } = org ? await octokit.rest.repos.createInOrg({
368
- org,
369
- ...params
370
- }) : await octokit.rest.repos.createForAuthenticatedUser(params);
371
- return {
372
- name: data.name,
373
- fullName: data.full_name,
374
- description: data.description,
375
- url: data.html_url,
376
- cloneUrl: data.clone_url,
377
- sshUrl: data.ssh_url,
378
- defaultBranch: data.default_branch,
379
- private: data.private,
380
- createdAt: data.created_at
381
- };
494
+ return withOctokit(token, async (octokit) => {
495
+ const params = {
496
+ name,
497
+ description,
498
+ private: isPrivate,
499
+ auto_init: autoInit,
500
+ gitignore_template: gitignoreTemplate,
501
+ license_template: licenseTemplate
502
+ };
503
+ const { data } = org ? await octokit.rest.repos.createInOrg({
504
+ org,
505
+ ...params
506
+ }) : await octokit.rest.repos.createForAuthenticatedUser(params);
507
+ return {
508
+ name: data.name,
509
+ fullName: data.full_name,
510
+ description: data.description,
511
+ url: data.html_url,
512
+ cloneUrl: data.clone_url,
513
+ sshUrl: data.ssh_url,
514
+ defaultBranch: data.default_branch,
515
+ private: data.private,
516
+ createdAt: data.created_at
517
+ };
518
+ });
382
519
  }
383
520
  const createOrUpdateFileInputSchema = z.object({
384
521
  owner: z.string().describe("Repository owner"),
@@ -392,83 +529,84 @@ const createOrUpdateFileInputSchema = z.object({
392
529
  const createOrUpdateFileDescription = "Create or update a file in a GitHub repository. Provide the SHA when updating an existing file.";
393
530
  /** Idempotent when updating with sha and content is unchanged. Not idempotent for new commits. */
394
531
  async function createOrUpdateFileCore({ token, owner, repo, path, message, content, branch, sha, author, committer, coAuthors }) {
395
- const octokit = createOctokit(token);
396
- if (sha) {
397
- const branchName = branch || (await octokit.rest.repos.get({
398
- owner,
399
- repo
400
- })).data.default_branch;
401
- try {
402
- const { data: fileData } = await octokit.rest.repos.getContent({
532
+ return withOctokit(token, async (octokit) => {
533
+ if (sha) {
534
+ const branchName = branch || (await octokit.rest.repos.get({
535
+ owner,
536
+ repo
537
+ })).data.default_branch;
538
+ try {
539
+ const { data: fileData } = await octokit.rest.repos.getContent({
540
+ owner,
541
+ repo,
542
+ path,
543
+ ref: branchName
544
+ });
545
+ if (!Array.isArray(fileData) && fileData.type === "file") {
546
+ if (Buffer.from(fileData.content, "base64").toString("utf-8") === content) return {
547
+ path: fileData.path,
548
+ sha: fileData.sha,
549
+ skipped: true,
550
+ message: "Content unchanged; no commit created"
551
+ };
552
+ }
553
+ } catch {}
554
+ }
555
+ if (!author && !committer) try {
556
+ const branchName = branch || (await octokit.rest.repos.get({
557
+ owner,
558
+ repo
559
+ })).data.default_branch;
560
+ const { data: ref } = await octokit.rest.git.getRef({
403
561
  owner,
404
562
  repo,
405
- path,
406
- ref: branchName
563
+ ref: `heads/${branchName}`
407
564
  });
408
- if (!Array.isArray(fileData) && fileData.type === "file") {
409
- if (Buffer.from(fileData.content, "base64").toString("utf-8") === content) return {
410
- path: fileData.path,
411
- sha: fileData.sha,
412
- skipped: true,
413
- message: "Content unchanged; no commit created"
414
- };
415
- }
416
- } catch {}
417
- }
418
- if (!author && !committer) try {
419
- const branchName = branch || (await octokit.rest.repos.get({
420
- owner,
421
- repo
422
- })).data.default_branch;
423
- const { data: ref } = await octokit.rest.git.getRef({
424
- owner,
425
- repo,
426
- ref: `heads/${branchName}`
427
- });
428
- const [headline, ...rest] = composeCommitMessage(message, coAuthors).split("\n");
429
- const body = rest.join("\n").replace(/^\n+/, "") || void 0;
430
- const result = await createCommitOnBranch(octokit, {
565
+ const [headline, ...rest] = composeCommitMessage(message, coAuthors).split("\n");
566
+ const body = rest.join("\n").replace(/^\n+/, "") || void 0;
567
+ const result = await createCommitOnBranch(octokit, {
568
+ owner,
569
+ repo,
570
+ branch: branchName,
571
+ expectedHeadOid: ref.object.sha,
572
+ headline,
573
+ body,
574
+ additions: [{
575
+ path,
576
+ contents: Buffer.from(content).toString("base64")
577
+ }]
578
+ });
579
+ return {
580
+ path,
581
+ sha: gitBlobSha(content),
582
+ commitSha: result.commitSha,
583
+ commitUrl: result.commitUrl
584
+ };
585
+ } catch (error) {
586
+ if (error instanceof CreateCommitOnBranchError && error.reason === "stale_data") throw error;
587
+ const msg = error instanceof Error ? error.message : String(error);
588
+ console.warn(`[github-tools] Signed commit failed, using REST API: ${msg}`);
589
+ }
590
+ const encoded = Buffer.from(content).toString("base64");
591
+ const finalMessage = composeCommitMessage(message, coAuthors);
592
+ const { data } = await octokit.rest.repos.createOrUpdateFileContents({
431
593
  owner,
432
594
  repo,
433
- branch: branchName,
434
- expectedHeadOid: ref.object.sha,
435
- headline,
436
- body,
437
- additions: [{
438
- path,
439
- contents: Buffer.from(content).toString("base64")
440
- }]
595
+ path,
596
+ message: finalMessage,
597
+ content: encoded,
598
+ branch,
599
+ sha,
600
+ author,
601
+ committer
441
602
  });
442
603
  return {
443
- path,
444
- sha: gitBlobSha(content),
445
- commitSha: result.commitSha,
446
- commitUrl: result.commitUrl
604
+ path: data.content?.path,
605
+ sha: data.content?.sha,
606
+ commitSha: data.commit.sha,
607
+ commitUrl: data.commit.html_url
447
608
  };
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
609
  });
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
610
  }
473
611
  //#endregion
474
612
  //#region src/core/model-output.ts
@@ -605,28 +743,29 @@ const listPullRequestsInputSchema = z.object({
605
743
  });
606
744
  const listPullRequestsDescription = "List pull requests for a GitHub repository";
607
745
  async function listPullRequestsCore({ token, owner, repo, state, perPage, maxPages }) {
608
- const octokit = createOctokit(token);
609
- return (await fetchAllPages(async (page) => {
610
- const { data } = await octokit.rest.pulls.list({
611
- owner,
612
- repo,
613
- state,
614
- per_page: perPage,
615
- page
616
- });
617
- return data;
618
- }, perPage, maxPages)).map((pr) => ({
619
- number: pr.number,
620
- title: pr.title,
621
- state: pr.state,
622
- url: pr.html_url,
623
- author: pr.user?.login,
624
- branch: pr.head.ref,
625
- base: pr.base.ref,
626
- draft: pr.draft,
627
- createdAt: pr.created_at,
628
- updatedAt: pr.updated_at
629
- }));
746
+ return withOctokit(token, async (octokit) => {
747
+ return (await fetchAllPages(async (page) => {
748
+ const { data } = await octokit.rest.pulls.list({
749
+ owner,
750
+ repo,
751
+ state,
752
+ per_page: perPage,
753
+ page
754
+ });
755
+ return data;
756
+ }, perPage, maxPages)).map((pr) => ({
757
+ number: pr.number,
758
+ title: pr.title,
759
+ state: pr.state,
760
+ url: pr.html_url,
761
+ author: pr.user?.login,
762
+ branch: pr.head.ref,
763
+ base: pr.base.ref,
764
+ draft: pr.draft,
765
+ createdAt: pr.created_at,
766
+ updatedAt: pr.updated_at
767
+ }));
768
+ });
630
769
  }
631
770
  const getPullRequestInputSchema = z.object({
632
771
  owner: z.string().describe("Repository owner"),
@@ -636,31 +775,33 @@ const getPullRequestInputSchema = z.object({
636
775
  });
637
776
  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
777
  async function getPullRequestCore({ token, owner, repo, pullNumber, detail = "summary" }) {
639
- const { data } = await createOctokit(token).rest.pulls.get({
640
- owner,
641
- repo,
642
- pull_number: pullNumber
778
+ return withOctokit(token, async (octokit) => {
779
+ const { data } = await octokit.rest.pulls.get({
780
+ owner,
781
+ repo,
782
+ pull_number: pullNumber
783
+ });
784
+ return {
785
+ number: data.number,
786
+ title: data.title,
787
+ body: applyDetailBody(data.body, detail),
788
+ state: data.state,
789
+ url: data.html_url,
790
+ author: data.user?.login,
791
+ branch: data.head.ref,
792
+ headSha: data.head.sha,
793
+ base: data.base.ref,
794
+ draft: data.draft,
795
+ merged: data.merged,
796
+ mergeable: data.mergeable,
797
+ additions: data.additions,
798
+ deletions: data.deletions,
799
+ changedFiles: data.changed_files,
800
+ createdAt: data.created_at,
801
+ updatedAt: data.updated_at,
802
+ mergedAt: data.merged_at
803
+ };
643
804
  });
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
805
  }
665
806
  const createPullRequestInputSchema = z.object({
666
807
  owner: z.string().describe("Repository owner"),
@@ -674,24 +815,26 @@ const createPullRequestInputSchema = z.object({
674
815
  const createPullRequestDescription = "Create a new pull request in a GitHub repository";
675
816
  /** Not idempotent — each call creates a new pull request. */
676
817
  async function createPullRequestCore({ token, owner, repo, title, body, head, base, draft }) {
677
- const { data } = await createOctokit(token).rest.pulls.create({
678
- owner,
679
- repo,
680
- title,
681
- body,
682
- head,
683
- base,
684
- draft
818
+ return withOctokit(token, async (octokit) => {
819
+ const { data } = await octokit.rest.pulls.create({
820
+ owner,
821
+ repo,
822
+ title,
823
+ body,
824
+ head,
825
+ base,
826
+ draft
827
+ });
828
+ return {
829
+ number: data.number,
830
+ title: data.title,
831
+ url: data.html_url,
832
+ state: data.state,
833
+ draft: data.draft,
834
+ branch: data.head.ref,
835
+ base: data.base.ref
836
+ };
685
837
  });
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
838
  }
696
839
  const MARK_READY_FOR_REVIEW_MUTATION = `
697
840
  mutation($pullRequestId: ID!) {
@@ -720,26 +863,31 @@ const updatePullRequestInputSchema = z.object({
720
863
  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
864
  /** Not idempotent — each call applies a new revision. */
722
865
  async function updatePullRequestCore({ token, owner, repo, pullNumber, title, body, state, base, draft }) {
723
- const octokit = createOctokit(token);
724
- const { data } = await octokit.rest.pulls.update({
725
- owner,
726
- repo,
727
- pull_number: pullNumber,
728
- title,
729
- body,
730
- state,
731
- base
866
+ return withOctokit(token, async (octokit) => {
867
+ const { data } = title !== void 0 || body !== void 0 || state !== void 0 || base !== void 0 ? await octokit.rest.pulls.update({
868
+ owner,
869
+ repo,
870
+ pull_number: pullNumber,
871
+ title,
872
+ body,
873
+ state,
874
+ base
875
+ }) : await octokit.rest.pulls.get({
876
+ owner,
877
+ repo,
878
+ pull_number: pullNumber
879
+ });
880
+ if (draft !== void 0 && draft !== data.draft) await octokit.graphql(draft ? CONVERT_TO_DRAFT_MUTATION : MARK_READY_FOR_REVIEW_MUTATION, { pullRequestId: data.node_id });
881
+ return {
882
+ number: data.number,
883
+ title: data.title,
884
+ state: data.state,
885
+ draft: draft ?? data.draft,
886
+ url: data.html_url,
887
+ base: data.base.ref,
888
+ updatedAt: data.updated_at
889
+ };
732
890
  });
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
891
  }
744
892
  const mergePullRequestInputSchema = z.object({
745
893
  owner: z.string().describe("Repository owner"),
@@ -756,21 +904,22 @@ const mergePullRequestInputSchema = z.object({
756
904
  const mergePullRequestDescription = "Merge a pull request";
757
905
  /** Not idempotent — merging an already-merged PR returns an error from GitHub. */
758
906
  async function mergePullRequestCore({ token, owner, repo, pullNumber, commitTitle, commitMessage, mergeMethod, coAuthors }) {
759
- const octokit = createOctokit(token);
760
- const finalMessage = composeCommitMessage(commitMessage ?? "", coAuthors) || void 0;
761
- const { data } = await octokit.rest.pulls.merge({
762
- owner,
763
- repo,
764
- pull_number: pullNumber,
765
- commit_title: commitTitle,
766
- commit_message: finalMessage,
767
- merge_method: mergeMethod
907
+ return withOctokit(token, async (octokit) => {
908
+ const finalMessage = composeCommitMessage(commitMessage ?? "", coAuthors) || void 0;
909
+ const { data } = await octokit.rest.pulls.merge({
910
+ owner,
911
+ repo,
912
+ pull_number: pullNumber,
913
+ commit_title: commitTitle,
914
+ commit_message: finalMessage,
915
+ merge_method: mergeMethod
916
+ });
917
+ return {
918
+ merged: data.merged,
919
+ message: data.message,
920
+ sha: data.sha
921
+ };
768
922
  });
769
- return {
770
- merged: data.merged,
771
- message: data.message,
772
- sha: data.sha
773
- };
774
923
  }
775
924
  const addPullRequestCommentInputSchema = z.object({
776
925
  owner: z.string().describe("Repository owner"),
@@ -781,19 +930,21 @@ const addPullRequestCommentInputSchema = z.object({
781
930
  const addPullRequestCommentDescription = "Add a comment to a pull request";
782
931
  /** Not idempotent — each call adds another comment. */
783
932
  async function addPullRequestCommentCore({ token, owner, repo, pullNumber, body }) {
784
- const { data } = await createOctokit(token).rest.issues.createComment({
785
- owner,
786
- repo,
787
- issue_number: pullNumber,
788
- body
933
+ return withOctokit(token, async (octokit) => {
934
+ const { data } = await octokit.rest.issues.createComment({
935
+ owner,
936
+ repo,
937
+ issue_number: pullNumber,
938
+ body
939
+ });
940
+ return {
941
+ id: data.id,
942
+ url: data.html_url,
943
+ body: data.body,
944
+ author: data.user?.login,
945
+ createdAt: data.created_at
946
+ };
789
947
  });
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
948
  }
798
949
  const updatePullRequestCommentInputSchema = z.object({
799
950
  owner: z.string().describe("Repository owner"),
@@ -804,18 +955,20 @@ const updatePullRequestCommentInputSchema = z.object({
804
955
  const updatePullRequestCommentDescription = "Update the body of a comment on a pull request";
805
956
  /** Not idempotent — each call applies a new revision. */
806
957
  async function updatePullRequestCommentCore({ token, owner, repo, commentId, body }) {
807
- const { data } = await createOctokit(token).rest.issues.updateComment({
808
- owner,
809
- repo,
810
- comment_id: commentId,
811
- body
958
+ return withOctokit(token, async (octokit) => {
959
+ const { data } = await octokit.rest.issues.updateComment({
960
+ owner,
961
+ repo,
962
+ comment_id: commentId,
963
+ body
964
+ });
965
+ return {
966
+ id: data.id,
967
+ url: data.html_url,
968
+ body: data.body,
969
+ updatedAt: data.updated_at
970
+ };
812
971
  });
813
- return {
814
- id: data.id,
815
- url: data.html_url,
816
- body: data.body,
817
- updatedAt: data.updated_at
818
- };
819
972
  }
820
973
  const deletePullRequestCommentInputSchema = z.object({
821
974
  owner: z.string().describe("Repository owner"),
@@ -825,15 +978,17 @@ const deletePullRequestCommentInputSchema = z.object({
825
978
  const deletePullRequestCommentDescription = "Delete a comment from a pull request permanently";
826
979
  /** Not idempotent — deleting an already-deleted comment returns 404 from GitHub. */
827
980
  async function deletePullRequestCommentCore({ token, owner, repo, commentId }) {
828
- await createOctokit(token).rest.issues.deleteComment({
829
- owner,
830
- repo,
831
- comment_id: commentId
981
+ return withOctokit(token, async (octokit) => {
982
+ await octokit.rest.issues.deleteComment({
983
+ owner,
984
+ repo,
985
+ comment_id: commentId
986
+ });
987
+ return {
988
+ deleted: true,
989
+ commentId
990
+ };
832
991
  });
833
- return {
834
- deleted: true,
835
- commentId
836
- };
837
992
  }
838
993
  const listPullRequestFilesInputSchema = z.object({
839
994
  owner: z.string().describe("Repository owner"),
@@ -846,22 +1001,24 @@ const listPullRequestFilesInputSchema = z.object({
846
1001
  });
847
1002
  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
1003
  async function listPullRequestFilesCore({ token, owner, repo, pullNumber, includePatch, filenames, perPage, page }) {
849
- const { data } = await createOctokit(token).rest.pulls.listFiles({
850
- owner,
851
- repo,
852
- pull_number: pullNumber,
853
- per_page: perPage,
854
- page
855
- });
856
- const filenameSet = filenames?.length ? new Set(filenames) : null;
857
- return data.filter((file) => !filenameSet || filenameSet.has(file.filename)).map((file) => ({
858
- filename: file.filename,
859
- status: file.status,
860
- additions: file.additions,
861
- deletions: file.deletions,
862
- changes: file.changes,
863
- ...includePatch && file.patch != null ? { patch: file.patch } : {}
864
- }));
1004
+ return withOctokit(token, async (octokit) => {
1005
+ const { data } = await octokit.rest.pulls.listFiles({
1006
+ owner,
1007
+ repo,
1008
+ pull_number: pullNumber,
1009
+ per_page: perPage,
1010
+ page
1011
+ });
1012
+ const filenameSet = filenames?.length ? new Set(filenames) : null;
1013
+ return data.filter((file) => !filenameSet || filenameSet.has(file.filename)).map((file) => ({
1014
+ filename: file.filename,
1015
+ status: file.status,
1016
+ additions: file.additions,
1017
+ deletions: file.deletions,
1018
+ changes: file.changes,
1019
+ ...includePatch && file.patch != null ? { patch: file.patch } : {}
1020
+ }));
1021
+ });
865
1022
  }
866
1023
  const listPullRequestReviewsInputSchema = z.object({
867
1024
  owner: z.string().describe("Repository owner"),
@@ -872,21 +1029,23 @@ const listPullRequestReviewsInputSchema = z.object({
872
1029
  });
873
1030
  const listPullRequestReviewsDescription = "List reviews on a pull request (approvals, change requests, and comments)";
874
1031
  async function listPullRequestReviewsCore({ token, owner, repo, pullNumber, perPage, page }) {
875
- const { data } = await createOctokit(token).rest.pulls.listReviews({
876
- owner,
877
- repo,
878
- pull_number: pullNumber,
879
- per_page: perPage,
880
- page
881
- });
882
- return data.map((review) => ({
883
- id: review.id,
884
- state: review.state,
885
- body: review.body,
886
- author: review.user?.login,
887
- url: review.html_url,
888
- submittedAt: review.submitted_at
889
- }));
1032
+ return withOctokit(token, async (octokit) => {
1033
+ const { data } = await octokit.rest.pulls.listReviews({
1034
+ owner,
1035
+ repo,
1036
+ pull_number: pullNumber,
1037
+ per_page: perPage,
1038
+ page
1039
+ });
1040
+ return data.map((review) => ({
1041
+ id: review.id,
1042
+ state: review.state,
1043
+ body: review.body,
1044
+ author: review.user?.login,
1045
+ url: review.html_url,
1046
+ submittedAt: review.submitted_at
1047
+ }));
1048
+ });
890
1049
  }
891
1050
  const createPullRequestReviewInputSchema = z.object({
892
1051
  owner: z.string().describe("Repository owner"),
@@ -908,22 +1067,157 @@ const createPullRequestReviewInputSchema = z.object({
908
1067
  const createPullRequestReviewDescription = "Submit a pull request review — approve, request changes, or comment with optional inline comments on specific lines";
909
1068
  /** Not idempotent — each call submits a new review. */
910
1069
  async function createPullRequestReviewCore({ token, owner, repo, pullNumber, body, event, comments }) {
911
- const { data } = await createOctokit(token).rest.pulls.createReview({
912
- owner,
913
- repo,
914
- pull_number: pullNumber,
915
- body,
916
- event,
917
- comments
1070
+ return withOctokit(token, async (octokit) => {
1071
+ const { data } = await octokit.rest.pulls.createReview({
1072
+ owner,
1073
+ repo,
1074
+ pull_number: pullNumber,
1075
+ body,
1076
+ event,
1077
+ comments
1078
+ });
1079
+ return {
1080
+ id: data.id,
1081
+ state: data.state,
1082
+ body: data.body,
1083
+ url: data.html_url,
1084
+ author: data.user?.login,
1085
+ submittedAt: data.submitted_at
1086
+ };
1087
+ });
1088
+ }
1089
+ const listPullRequestReviewThreadsInputSchema = z.object({
1090
+ owner: z.string().describe("Repository owner"),
1091
+ repo: z.string().describe("Repository name"),
1092
+ pullNumber: z.number().describe("Pull request number"),
1093
+ status: z.enum(["unresolved", "all"]).optional().default("unresolved").describe("unresolved returns only threads awaiting action (default, saves tokens); all includes resolved threads"),
1094
+ detail: detailSchema,
1095
+ perPage: z.number().int().positive().max(50).optional().default(30).describe("Number of threads to fetch per call (max 50)"),
1096
+ after: z.string().optional().describe("Cursor from a previous call (endCursor) to fetch the next page of threads")
1097
+ });
1098
+ const listPullRequestReviewThreadsDescription = "List review threads on a pull request with their comments, resolution state, and the IDs needed to reply (commentId) or resolve (threadId). Unresolved threads only by default (GitHub GraphQL API)";
1099
+ const REVIEW_THREADS_QUERY = `
1100
+ query ReviewThreads($owner: String!, $name: String!, $number: Int!, $first: Int!, $after: String) {
1101
+ repository(owner: $owner, name: $name) {
1102
+ pullRequest(number: $number) {
1103
+ reviewThreads(first: $first, after: $after) {
1104
+ totalCount
1105
+ pageInfo {
1106
+ hasNextPage
1107
+ endCursor
1108
+ }
1109
+ nodes {
1110
+ id
1111
+ isResolved
1112
+ isOutdated
1113
+ path
1114
+ line
1115
+ startLine
1116
+ resolvedBy {
1117
+ login
1118
+ }
1119
+ comments(first: 30) {
1120
+ totalCount
1121
+ nodes {
1122
+ databaseId
1123
+ body
1124
+ createdAt
1125
+ author {
1126
+ login
1127
+ }
1128
+ }
1129
+ }
1130
+ }
1131
+ }
1132
+ }
1133
+ }
1134
+ }
1135
+ `;
1136
+ async function listPullRequestReviewThreadsCore({ token, owner, repo, pullNumber, status, detail, perPage, after }) {
1137
+ return withOctokit(token, async (octokit) => {
1138
+ const data = await octokit.graphql(REVIEW_THREADS_QUERY, {
1139
+ owner,
1140
+ name: repo,
1141
+ number: pullNumber,
1142
+ first: perPage,
1143
+ after
1144
+ });
1145
+ if (!data.repository) return { error: `Repository not found: ${owner}/${repo}` };
1146
+ const reviewThreads = data.repository.pullRequest?.reviewThreads;
1147
+ if (!reviewThreads) return { error: `Pull request not found: ${owner}/${repo}#${pullNumber}` };
1148
+ const threads = reviewThreads.nodes.filter((thread) => status === "all" || !thread.isResolved).map((thread) => ({
1149
+ threadId: thread.id,
1150
+ isResolved: thread.isResolved,
1151
+ isOutdated: thread.isOutdated,
1152
+ path: thread.path,
1153
+ line: thread.line,
1154
+ startLine: thread.startLine,
1155
+ resolvedBy: thread.resolvedBy?.login ?? null,
1156
+ commentCount: thread.comments.totalCount,
1157
+ comments: thread.comments.nodes.map((comment) => ({
1158
+ commentId: comment.databaseId,
1159
+ author: comment.author?.login ?? null,
1160
+ body: applyDetailBody(comment.body, detail),
1161
+ createdAt: comment.createdAt
1162
+ }))
1163
+ }));
1164
+ return {
1165
+ totalCount: reviewThreads.totalCount,
1166
+ returnedCount: threads.length,
1167
+ hasNextPage: reviewThreads.pageInfo.hasNextPage,
1168
+ endCursor: reviewThreads.pageInfo.endCursor,
1169
+ threads
1170
+ };
1171
+ });
1172
+ }
1173
+ const replyToReviewCommentInputSchema = z.object({
1174
+ owner: z.string().describe("Repository owner"),
1175
+ repo: z.string().describe("Repository name"),
1176
+ pullNumber: z.number().describe("Pull request number"),
1177
+ commentId: z.number().describe("commentId of the thread's first comment, from listPullRequestReviewThreads"),
1178
+ body: z.string().describe("Reply text (supports Markdown)")
1179
+ });
1180
+ const replyToReviewCommentDescription = "Reply to a pull request review comment, adding a message to its review thread";
1181
+ /** Not idempotent — each call posts a new reply. */
1182
+ async function replyToReviewCommentCore({ token, owner, repo, pullNumber, commentId, body }) {
1183
+ return withOctokit(token, async (octokit) => {
1184
+ const { data } = await octokit.rest.pulls.createReplyForReviewComment({
1185
+ owner,
1186
+ repo,
1187
+ pull_number: pullNumber,
1188
+ comment_id: commentId,
1189
+ body
1190
+ });
1191
+ return {
1192
+ id: data.id,
1193
+ url: data.html_url,
1194
+ author: data.user?.login,
1195
+ createdAt: data.created_at
1196
+ };
1197
+ });
1198
+ }
1199
+ const resolveReviewThreadInputSchema = z.object({ threadId: z.string().describe("Review thread ID (threadId from listPullRequestReviewThreads)") });
1200
+ const resolveReviewThreadDescription = "Mark a pull request review thread as resolved";
1201
+ const RESOLVE_THREAD_MUTATION = `
1202
+ mutation ResolveReviewThread($threadId: ID!) {
1203
+ resolveReviewThread(input: { threadId: $threadId }) {
1204
+ thread {
1205
+ id
1206
+ isResolved
1207
+ }
1208
+ }
1209
+ }
1210
+ `;
1211
+ /** Idempotent — resolving an already-resolved thread is a no-op on GitHub. */
1212
+ async function resolveReviewThreadCore({ token, threadId }) {
1213
+ return withOctokit(token, async (octokit) => {
1214
+ const thread = (await octokit.graphql(RESOLVE_THREAD_MUTATION, { threadId })).resolveReviewThread?.thread;
1215
+ if (!thread) return { error: `Review thread not found: ${threadId}` };
1216
+ return {
1217
+ threadId: thread.id,
1218
+ isResolved: thread.isResolved
1219
+ };
918
1220
  });
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
1221
  }
928
1222
  const requestReviewersInputSchema = z.object({
929
1223
  owner: z.string().describe("Repository owner"),
@@ -935,19 +1229,21 @@ const requestReviewersInputSchema = z.object({
935
1229
  const requestReviewersDescription = "Request reviews from users or teams on a pull request";
936
1230
  /** Not idempotent — re-requesting an existing reviewer is a no-op on GitHub but still mutates. */
937
1231
  async function requestReviewersCore({ token, owner, repo, pullNumber, reviewers, teamReviewers }) {
938
- const { data } = await createOctokit(token).rest.pulls.requestReviewers({
939
- owner,
940
- repo,
941
- pull_number: pullNumber,
942
- reviewers,
943
- team_reviewers: teamReviewers
1232
+ return withOctokit(token, async (octokit) => {
1233
+ const { data } = await octokit.rest.pulls.requestReviewers({
1234
+ owner,
1235
+ repo,
1236
+ pull_number: pullNumber,
1237
+ reviewers,
1238
+ team_reviewers: teamReviewers
1239
+ });
1240
+ return {
1241
+ number: data.number,
1242
+ url: data.html_url,
1243
+ requestedReviewers: data.requested_reviewers?.map((r) => r.login),
1244
+ requestedTeams: data.requested_teams?.map((t) => t.slug)
1245
+ };
944
1246
  });
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
1247
  }
952
1248
  //#endregion
953
1249
  //#region src/core/issues.ts
@@ -965,27 +1261,28 @@ const listIssuesInputSchema = z.object({
965
1261
  });
966
1262
  const listIssuesDescription = "List issues for a GitHub repository (excludes pull requests)";
967
1263
  async function listIssuesCore({ token, owner, repo, state, labels, perPage, maxPages }) {
968
- const octokit = createOctokit(token);
969
- return (await fetchAllPages(async (page) => {
970
- const { data } = await octokit.rest.issues.listForRepo({
971
- owner,
972
- repo,
973
- state,
974
- labels,
975
- per_page: perPage,
976
- page
977
- });
978
- return data;
979
- }, perPage, maxPages)).filter((issue) => !issue.pull_request).map((issue) => ({
980
- number: issue.number,
981
- title: issue.title,
982
- state: issue.state,
983
- url: issue.html_url,
984
- author: issue.user?.login,
985
- labels: issue.labels.map((l) => typeof l === "string" ? l : l.name),
986
- createdAt: issue.created_at,
987
- updatedAt: issue.updated_at
988
- }));
1264
+ return withOctokit(token, async (octokit) => {
1265
+ return (await fetchAllPages(async (page) => {
1266
+ const { data } = await octokit.rest.issues.listForRepo({
1267
+ owner,
1268
+ repo,
1269
+ state,
1270
+ labels,
1271
+ per_page: perPage,
1272
+ page
1273
+ });
1274
+ return data;
1275
+ }, perPage, maxPages)).filter((issue) => !issue.pull_request).map((issue) => ({
1276
+ number: issue.number,
1277
+ title: issue.title,
1278
+ state: issue.state,
1279
+ url: issue.html_url,
1280
+ author: issue.user?.login,
1281
+ labels: issue.labels.map((l) => typeof l === "string" ? l : l.name),
1282
+ createdAt: issue.created_at,
1283
+ updatedAt: issue.updated_at
1284
+ }));
1285
+ });
989
1286
  }
990
1287
  const getIssueInputSchema = z.object({
991
1288
  owner: z.string().describe("Repository owner"),
@@ -995,25 +1292,27 @@ const getIssueInputSchema = z.object({
995
1292
  });
996
1293
  const getIssueDescription = "Get detailed information about a specific issue. Body is truncated by default (detail: summary) — set detail full for the complete description";
997
1294
  async function getIssueCore({ token, owner, repo, issueNumber, detail = "summary" }) {
998
- const { data } = await createOctokit(token).rest.issues.get({
999
- owner,
1000
- repo,
1001
- issue_number: issueNumber
1295
+ return withOctokit(token, async (octokit) => {
1296
+ const { data } = await octokit.rest.issues.get({
1297
+ owner,
1298
+ repo,
1299
+ issue_number: issueNumber
1300
+ });
1301
+ return {
1302
+ number: data.number,
1303
+ title: data.title,
1304
+ body: applyDetailBody(data.body, detail),
1305
+ state: data.state,
1306
+ url: data.html_url,
1307
+ author: data.user?.login,
1308
+ assignees: data.assignees?.map((a) => a.login),
1309
+ labels: data.labels.map((l) => typeof l === "string" ? l : l.name),
1310
+ comments: data.comments,
1311
+ createdAt: data.created_at,
1312
+ updatedAt: data.updated_at,
1313
+ closedAt: data.closed_at
1314
+ };
1002
1315
  });
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
1316
  }
1018
1317
  const listIssueCommentsInputSchema = z.object({
1019
1318
  owner: z.string().describe("Repository owner"),
@@ -1025,21 +1324,23 @@ const listIssueCommentsInputSchema = z.object({
1025
1324
  });
1026
1325
  const listIssueCommentsDescription = "List comments on a GitHub issue. Bodies are truncated by default (detail: summary)";
1027
1326
  async function listIssueCommentsCore({ token, owner, repo, issueNumber, perPage, page, detail = "summary" }) {
1028
- const { data } = await createOctokit(token).rest.issues.listComments({
1029
- owner,
1030
- repo,
1031
- issue_number: issueNumber,
1032
- per_page: perPage,
1033
- page
1034
- });
1035
- return data.map((comment) => ({
1036
- id: comment.id,
1037
- url: comment.html_url,
1038
- body: applyDetailBody(comment.body, detail),
1039
- author: comment.user?.login,
1040
- createdAt: comment.created_at,
1041
- updatedAt: comment.updated_at
1042
- }));
1327
+ return withOctokit(token, async (octokit) => {
1328
+ const { data } = await octokit.rest.issues.listComments({
1329
+ owner,
1330
+ repo,
1331
+ issue_number: issueNumber,
1332
+ per_page: perPage,
1333
+ page
1334
+ });
1335
+ return data.map((comment) => ({
1336
+ id: comment.id,
1337
+ url: comment.html_url,
1338
+ body: applyDetailBody(comment.body, detail),
1339
+ author: comment.user?.login,
1340
+ createdAt: comment.created_at,
1341
+ updatedAt: comment.updated_at
1342
+ }));
1343
+ });
1043
1344
  }
1044
1345
  const createIssueInputSchema = z.object({
1045
1346
  owner: z.string().describe("Repository owner"),
@@ -1052,21 +1353,23 @@ const createIssueInputSchema = z.object({
1052
1353
  const createIssueDescription = "Create a new issue in a GitHub repository";
1053
1354
  /** Not idempotent — each call creates a new issue. */
1054
1355
  async function createIssueCore({ token, owner, repo, title, body, labels, assignees }) {
1055
- const { data } = await createOctokit(token).rest.issues.create({
1056
- owner,
1057
- repo,
1058
- title,
1059
- body,
1060
- labels,
1061
- assignees
1356
+ return withOctokit(token, async (octokit) => {
1357
+ const { data } = await octokit.rest.issues.create({
1358
+ owner,
1359
+ repo,
1360
+ title,
1361
+ body,
1362
+ labels,
1363
+ assignees
1364
+ });
1365
+ return {
1366
+ number: data.number,
1367
+ title: data.title,
1368
+ url: data.html_url,
1369
+ state: data.state,
1370
+ labels: data.labels.map((l) => typeof l === "string" ? l : l.name)
1371
+ };
1062
1372
  });
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
1373
  }
1071
1374
  const addIssueCommentInputSchema = z.object({
1072
1375
  owner: z.string().describe("Repository owner"),
@@ -1077,19 +1380,21 @@ const addIssueCommentInputSchema = z.object({
1077
1380
  const addIssueCommentDescription = "Add a comment to a GitHub issue";
1078
1381
  /** Not idempotent — each call adds another comment. */
1079
1382
  async function addIssueCommentCore({ token, owner, repo, issueNumber, body }) {
1080
- const { data } = await createOctokit(token).rest.issues.createComment({
1081
- owner,
1082
- repo,
1083
- issue_number: issueNumber,
1084
- body
1383
+ return withOctokit(token, async (octokit) => {
1384
+ const { data } = await octokit.rest.issues.createComment({
1385
+ owner,
1386
+ repo,
1387
+ issue_number: issueNumber,
1388
+ body
1389
+ });
1390
+ return {
1391
+ id: data.id,
1392
+ url: data.html_url,
1393
+ body: data.body,
1394
+ author: data.user?.login,
1395
+ createdAt: data.created_at
1396
+ };
1085
1397
  });
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
1398
  }
1094
1399
  const closeIssueInputSchema = z.object({
1095
1400
  owner: z.string().describe("Repository owner"),
@@ -1100,33 +1405,34 @@ const closeIssueInputSchema = z.object({
1100
1405
  const closeIssueDescription = "Close an open GitHub issue";
1101
1406
  /** Idempotent when the issue is already closed. */
1102
1407
  async function closeIssueCore({ token, owner, repo, issueNumber, stateReason }) {
1103
- const octokit = createOctokit(token);
1104
- const { data: existing } = await octokit.rest.issues.get({
1105
- owner,
1106
- repo,
1107
- issue_number: issueNumber
1108
- });
1109
- if (existing.state === "closed") return {
1110
- number: existing.number,
1111
- title: existing.title,
1112
- state: existing.state,
1113
- url: existing.html_url,
1114
- closedAt: existing.closed_at
1115
- };
1116
- const { data } = await octokit.rest.issues.update({
1117
- owner,
1118
- repo,
1119
- issue_number: issueNumber,
1120
- state: "closed",
1121
- state_reason: stateReason
1408
+ return withOctokit(token, async (octokit) => {
1409
+ const { data: existing } = await octokit.rest.issues.get({
1410
+ owner,
1411
+ repo,
1412
+ issue_number: issueNumber
1413
+ });
1414
+ if (existing.state === "closed") return {
1415
+ number: existing.number,
1416
+ title: existing.title,
1417
+ state: existing.state,
1418
+ url: existing.html_url,
1419
+ closedAt: existing.closed_at
1420
+ };
1421
+ const { data } = await octokit.rest.issues.update({
1422
+ owner,
1423
+ repo,
1424
+ issue_number: issueNumber,
1425
+ state: "closed",
1426
+ state_reason: stateReason
1427
+ });
1428
+ return {
1429
+ number: data.number,
1430
+ title: data.title,
1431
+ state: data.state,
1432
+ url: data.html_url,
1433
+ closedAt: data.closed_at
1434
+ };
1122
1435
  });
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
1436
  }
1131
1437
  const updateIssueInputSchema = z.object({
1132
1438
  owner: z.string().describe("Repository owner"),
@@ -1147,29 +1453,31 @@ const updateIssueInputSchema = z.object({
1147
1453
  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
1454
  /** Not idempotent — each call applies a new revision. */
1149
1455
  async function updateIssueCore({ token, owner, repo, issueNumber, title, body, state, stateReason, labels, milestone, assignees }) {
1150
- const { data } = await createOctokit(token).rest.issues.update({
1151
- owner,
1152
- repo,
1153
- issue_number: issueNumber,
1154
- title,
1155
- body,
1156
- state,
1157
- state_reason: stateReason,
1158
- labels,
1159
- milestone,
1160
- assignees
1456
+ return withOctokit(token, async (octokit) => {
1457
+ const { data } = await octokit.rest.issues.update({
1458
+ owner,
1459
+ repo,
1460
+ issue_number: issueNumber,
1461
+ title,
1462
+ body,
1463
+ state,
1464
+ state_reason: stateReason,
1465
+ labels,
1466
+ milestone,
1467
+ assignees
1468
+ });
1469
+ return {
1470
+ number: data.number,
1471
+ title: data.title,
1472
+ state: data.state,
1473
+ url: data.html_url,
1474
+ labels: data.labels.map((l) => typeof l === "string" ? l : l.name),
1475
+ assignees: data.assignees?.map((a) => a.login),
1476
+ milestone: data.milestone?.number ?? null,
1477
+ closedAt: data.closed_at,
1478
+ updatedAt: data.updated_at
1479
+ };
1161
1480
  });
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
1481
  }
1174
1482
  const updateIssueCommentInputSchema = z.object({
1175
1483
  owner: z.string().describe("Repository owner"),
@@ -1180,18 +1488,20 @@ const updateIssueCommentInputSchema = z.object({
1180
1488
  const updateIssueCommentDescription = "Update the body of a comment on a GitHub issue";
1181
1489
  /** Not idempotent — each call applies a new revision. */
1182
1490
  async function updateIssueCommentCore({ token, owner, repo, commentId, body }) {
1183
- const { data } = await createOctokit(token).rest.issues.updateComment({
1184
- owner,
1185
- repo,
1186
- comment_id: commentId,
1187
- body
1491
+ return withOctokit(token, async (octokit) => {
1492
+ const { data } = await octokit.rest.issues.updateComment({
1493
+ owner,
1494
+ repo,
1495
+ comment_id: commentId,
1496
+ body
1497
+ });
1498
+ return {
1499
+ id: data.id,
1500
+ url: data.html_url,
1501
+ body: data.body,
1502
+ updatedAt: data.updated_at
1503
+ };
1188
1504
  });
1189
- return {
1190
- id: data.id,
1191
- url: data.html_url,
1192
- body: data.body,
1193
- updatedAt: data.updated_at
1194
- };
1195
1505
  }
1196
1506
  const deleteIssueCommentInputSchema = z.object({
1197
1507
  owner: z.string().describe("Repository owner"),
@@ -1201,15 +1511,17 @@ const deleteIssueCommentInputSchema = z.object({
1201
1511
  const deleteIssueCommentDescription = "Delete a comment from a GitHub issue permanently";
1202
1512
  /** Not idempotent — deleting an already-deleted comment returns 404 from GitHub. */
1203
1513
  async function deleteIssueCommentCore({ token, owner, repo, commentId }) {
1204
- await createOctokit(token).rest.issues.deleteComment({
1205
- owner,
1206
- repo,
1207
- comment_id: commentId
1514
+ return withOctokit(token, async (octokit) => {
1515
+ await octokit.rest.issues.deleteComment({
1516
+ owner,
1517
+ repo,
1518
+ comment_id: commentId
1519
+ });
1520
+ return {
1521
+ deleted: true,
1522
+ commentId
1523
+ };
1208
1524
  });
1209
- return {
1210
- deleted: true,
1211
- commentId
1212
- };
1213
1525
  }
1214
1526
  const listLabelsInputSchema = z.object({
1215
1527
  owner: z.string().describe("Repository owner"),
@@ -1219,17 +1531,19 @@ const listLabelsInputSchema = z.object({
1219
1531
  });
1220
1532
  const listLabelsDescription = "List labels available in a GitHub repository";
1221
1533
  async function listLabelsCore({ token, owner, repo, perPage, page }) {
1222
- const { data } = await createOctokit(token).rest.issues.listLabelsForRepo({
1223
- owner,
1224
- repo,
1225
- per_page: perPage,
1226
- page
1534
+ return withOctokit(token, async (octokit) => {
1535
+ const { data } = await octokit.rest.issues.listLabelsForRepo({
1536
+ owner,
1537
+ repo,
1538
+ per_page: perPage,
1539
+ page
1540
+ });
1541
+ return data.map((label) => ({
1542
+ name: label.name,
1543
+ color: label.color,
1544
+ description: label.description
1545
+ }));
1227
1546
  });
1228
- return data.map((label) => ({
1229
- name: label.name,
1230
- color: label.color,
1231
- description: label.description
1232
- }));
1233
1547
  }
1234
1548
  const addLabelsInputSchema = z.object({
1235
1549
  owner: z.string().describe("Repository owner"),
@@ -1240,17 +1554,19 @@ const addLabelsInputSchema = z.object({
1240
1554
  const addLabelsDescription = "Add labels to an issue or pull request";
1241
1555
  /** Not idempotent — re-adding labels is a no-op on GitHub but still mutates. */
1242
1556
  async function addLabelsCore({ token, owner, repo, issueNumber, labels }) {
1243
- const { data } = await createOctokit(token).rest.issues.addLabels({
1244
- owner,
1245
- repo,
1246
- issue_number: issueNumber,
1247
- labels
1557
+ return withOctokit(token, async (octokit) => {
1558
+ const { data } = await octokit.rest.issues.addLabels({
1559
+ owner,
1560
+ repo,
1561
+ issue_number: issueNumber,
1562
+ labels
1563
+ });
1564
+ return data.map((label) => ({
1565
+ name: label.name,
1566
+ color: label.color,
1567
+ description: label.description
1568
+ }));
1248
1569
  });
1249
- return data.map((label) => ({
1250
- name: label.name,
1251
- color: label.color,
1252
- description: label.description
1253
- }));
1254
1570
  }
1255
1571
  const removeLabelInputSchema = z.object({
1256
1572
  owner: z.string().describe("Repository owner"),
@@ -1261,17 +1577,19 @@ const removeLabelInputSchema = z.object({
1261
1577
  const removeLabelDescription = "Remove a label from an issue or pull request";
1262
1578
  /** Not idempotent — removing a missing label returns 404 from GitHub. */
1263
1579
  async function removeLabelCore({ token, owner, repo, issueNumber, label }) {
1264
- await createOctokit(token).rest.issues.removeLabel({
1265
- owner,
1266
- repo,
1267
- issue_number: issueNumber,
1268
- name: label
1580
+ return withOctokit(token, async (octokit) => {
1581
+ await octokit.rest.issues.removeLabel({
1582
+ owner,
1583
+ repo,
1584
+ issue_number: issueNumber,
1585
+ name: label
1586
+ });
1587
+ return {
1588
+ removed: true,
1589
+ label,
1590
+ issueNumber
1591
+ };
1269
1592
  });
1270
- return {
1271
- removed: true,
1272
- label,
1273
- issueNumber
1274
- };
1275
1593
  }
1276
1594
  const createLabelInputSchema = z.object({
1277
1595
  owner: z.string().describe("Repository owner"),
@@ -1283,18 +1601,20 @@ const createLabelInputSchema = z.object({
1283
1601
  const createLabelDescription = "Create a label in a GitHub repository";
1284
1602
  /** Not idempotent — creating a label that already exists returns 422 from GitHub. */
1285
1603
  async function createLabelCore({ token, owner, repo, name, color, description }) {
1286
- const { data } = await createOctokit(token).rest.issues.createLabel({
1287
- owner,
1288
- repo,
1289
- name,
1290
- color,
1291
- description
1604
+ return withOctokit(token, async (octokit) => {
1605
+ const { data } = await octokit.rest.issues.createLabel({
1606
+ owner,
1607
+ repo,
1608
+ name,
1609
+ color,
1610
+ description
1611
+ });
1612
+ return {
1613
+ name: data.name,
1614
+ color: data.color,
1615
+ description: data.description
1616
+ };
1292
1617
  });
1293
- return {
1294
- name: data.name,
1295
- color: data.color,
1296
- description: data.description
1297
- };
1298
1618
  }
1299
1619
  const updateLabelInputSchema = z.object({
1300
1620
  owner: z.string().describe("Repository owner"),
@@ -1307,19 +1627,21 @@ const updateLabelInputSchema = z.object({
1307
1627
  const updateLabelDescription = "Update a label in a GitHub repository — name, color, or description";
1308
1628
  /** Not idempotent — each call applies a new revision. */
1309
1629
  async function updateLabelCore({ token, owner, repo, name, newName, color, description }) {
1310
- const { data } = await createOctokit(token).rest.issues.updateLabel({
1311
- owner,
1312
- repo,
1313
- name,
1314
- new_name: newName,
1315
- color,
1316
- description: description === null ? "" : description
1630
+ return withOctokit(token, async (octokit) => {
1631
+ const { data } = await octokit.rest.issues.updateLabel({
1632
+ owner,
1633
+ repo,
1634
+ name,
1635
+ new_name: newName,
1636
+ color,
1637
+ description: description === null ? "" : description
1638
+ });
1639
+ return {
1640
+ name: data.name,
1641
+ color: data.color,
1642
+ description: data.description
1643
+ };
1317
1644
  });
1318
- return {
1319
- name: data.name,
1320
- color: data.color,
1321
- description: data.description
1322
- };
1323
1645
  }
1324
1646
  const deleteLabelInputSchema = z.object({
1325
1647
  owner: z.string().describe("Repository owner"),
@@ -1329,15 +1651,17 @@ const deleteLabelInputSchema = z.object({
1329
1651
  const deleteLabelDescription = "Delete a label from a GitHub repository permanently";
1330
1652
  /** Not idempotent — deleting a missing label returns 404 from GitHub. */
1331
1653
  async function deleteLabelCore({ token, owner, repo, name }) {
1332
- await createOctokit(token).rest.issues.deleteLabel({
1333
- owner,
1334
- repo,
1335
- name
1654
+ return withOctokit(token, async (octokit) => {
1655
+ await octokit.rest.issues.deleteLabel({
1656
+ owner,
1657
+ repo,
1658
+ name
1659
+ });
1660
+ return {
1661
+ deleted: true,
1662
+ name
1663
+ };
1336
1664
  });
1337
- return {
1338
- deleted: true,
1339
- name
1340
- };
1341
1665
  }
1342
1666
  const addAssigneesInputSchema = z.object({
1343
1667
  owner: z.string().describe("Repository owner"),
@@ -1348,16 +1672,18 @@ const addAssigneesInputSchema = z.object({
1348
1672
  const addAssigneesDescription = "Assign users to an issue or pull request";
1349
1673
  /** Not idempotent — re-adding an existing assignee is a no-op on GitHub but still mutates. */
1350
1674
  async function addAssigneesCore({ token, owner, repo, issueNumber, assignees }) {
1351
- const { data } = await createOctokit(token).rest.issues.addAssignees({
1352
- owner,
1353
- repo,
1354
- issue_number: issueNumber,
1355
- assignees
1675
+ return withOctokit(token, async (octokit) => {
1676
+ const { data } = await octokit.rest.issues.addAssignees({
1677
+ owner,
1678
+ repo,
1679
+ issue_number: issueNumber,
1680
+ assignees
1681
+ });
1682
+ return {
1683
+ number: data.number,
1684
+ assignees: data.assignees?.map((a) => a.login)
1685
+ };
1356
1686
  });
1357
- return {
1358
- number: data.number,
1359
- assignees: data.assignees?.map((a) => a.login)
1360
- };
1361
1687
  }
1362
1688
  const removeAssigneesInputSchema = z.object({
1363
1689
  owner: z.string().describe("Repository owner"),
@@ -1368,16 +1694,18 @@ const removeAssigneesInputSchema = z.object({
1368
1694
  const removeAssigneesDescription = "Remove assignees from an issue or pull request";
1369
1695
  /** Idempotent — removing an assignee that is not assigned is a no-op on GitHub. */
1370
1696
  async function removeAssigneesCore({ token, owner, repo, issueNumber, assignees }) {
1371
- const { data } = await createOctokit(token).rest.issues.removeAssignees({
1372
- owner,
1373
- repo,
1374
- issue_number: issueNumber,
1375
- assignees
1697
+ return withOctokit(token, async (octokit) => {
1698
+ const { data } = await octokit.rest.issues.removeAssignees({
1699
+ owner,
1700
+ repo,
1701
+ issue_number: issueNumber,
1702
+ assignees
1703
+ });
1704
+ return {
1705
+ number: data.number,
1706
+ assignees: data.assignees?.map((a) => a.login)
1707
+ };
1376
1708
  });
1377
- return {
1378
- number: data.number,
1379
- assignees: data.assignees?.map((a) => a.login)
1380
- };
1381
1709
  }
1382
1710
  //#endregion
1383
1711
  //#region src/core/reactions.ts
@@ -1413,15 +1741,17 @@ const listIssueReactionsInputSchema = z.object({
1413
1741
  });
1414
1742
  const listIssueReactionsDescription = "List reactions on an issue or pull request conversation, with per-emoji counts for the returned page";
1415
1743
  async function listIssueReactionsCore({ token, owner, repo, issueNumber, content, perPage, page }) {
1416
- const { data } = await createOctokit(token).rest.reactions.listForIssue({
1417
- owner,
1418
- repo,
1419
- issue_number: issueNumber,
1420
- content,
1421
- per_page: perPage,
1422
- page
1744
+ return withOctokit(token, async (octokit) => {
1745
+ const { data } = await octokit.rest.reactions.listForIssue({
1746
+ owner,
1747
+ repo,
1748
+ issue_number: issueNumber,
1749
+ content,
1750
+ per_page: perPage,
1751
+ page
1752
+ });
1753
+ return shapeReactions(data);
1423
1754
  });
1424
- return shapeReactions(data);
1425
1755
  }
1426
1756
  const addIssueReactionInputSchema = z.object({
1427
1757
  owner: z.string().describe("Repository owner"),
@@ -1432,18 +1762,20 @@ const addIssueReactionInputSchema = z.object({
1432
1762
  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
1763
  /** Idempotent — GitHub returns the existing reaction when the user already reacted with the same content. */
1434
1764
  async function addIssueReactionCore({ token, owner, repo, issueNumber, content }) {
1435
- const { data } = await createOctokit(token).rest.reactions.createForIssue({
1436
- owner,
1437
- repo,
1438
- issue_number: issueNumber,
1439
- content
1765
+ return withOctokit(token, async (octokit) => {
1766
+ const { data } = await octokit.rest.reactions.createForIssue({
1767
+ owner,
1768
+ repo,
1769
+ issue_number: issueNumber,
1770
+ content
1771
+ });
1772
+ return {
1773
+ id: data.id,
1774
+ content: data.content,
1775
+ user: data.user?.login,
1776
+ issueNumber
1777
+ };
1440
1778
  });
1441
- return {
1442
- id: data.id,
1443
- content: data.content,
1444
- user: data.user?.login,
1445
- issueNumber
1446
- };
1447
1779
  }
1448
1780
  const listCommentReactionsInputSchema = z.object({
1449
1781
  owner: z.string().describe("Repository owner"),
@@ -1455,16 +1787,18 @@ const listCommentReactionsInputSchema = z.object({
1455
1787
  });
1456
1788
  const listCommentReactionsDescription = "List reactions on an issue or pull request comment, with per-emoji counts for the returned page";
1457
1789
  async function listCommentReactionsCore({ token, owner, repo, commentId, content, perPage, page }) {
1458
- const { data } = await createOctokit(token).rest.reactions.listForIssueComment({
1459
- owner,
1460
- repo,
1461
- comment_id: commentId,
1462
- content,
1463
- per_page: perPage,
1464
- page
1465
- });
1466
- return shapeReactions(data);
1467
- }
1790
+ return withOctokit(token, async (octokit) => {
1791
+ const { data } = await octokit.rest.reactions.listForIssueComment({
1792
+ owner,
1793
+ repo,
1794
+ comment_id: commentId,
1795
+ content,
1796
+ per_page: perPage,
1797
+ page
1798
+ });
1799
+ return shapeReactions(data);
1800
+ });
1801
+ }
1468
1802
  const addCommentReactionInputSchema = z.object({
1469
1803
  owner: z.string().describe("Repository owner"),
1470
1804
  repo: z.string().describe("Repository name"),
@@ -1474,18 +1808,20 @@ const addCommentReactionInputSchema = z.object({
1474
1808
  const addCommentReactionDescription = "React to an issue or pull request comment with an emoji. Prefer this over a reply when acknowledging a comment";
1475
1809
  /** Idempotent — GitHub returns the existing reaction when the user already reacted with the same content. */
1476
1810
  async function addCommentReactionCore({ token, owner, repo, commentId, content }) {
1477
- const { data } = await createOctokit(token).rest.reactions.createForIssueComment({
1478
- owner,
1479
- repo,
1480
- comment_id: commentId,
1481
- content
1811
+ return withOctokit(token, async (octokit) => {
1812
+ const { data } = await octokit.rest.reactions.createForIssueComment({
1813
+ owner,
1814
+ repo,
1815
+ comment_id: commentId,
1816
+ content
1817
+ });
1818
+ return {
1819
+ id: data.id,
1820
+ content: data.content,
1821
+ user: data.user?.login,
1822
+ commentId
1823
+ };
1482
1824
  });
1483
- return {
1484
- id: data.id,
1485
- content: data.content,
1486
- user: data.user?.login,
1487
- commentId
1488
- };
1489
1825
  }
1490
1826
  //#endregion
1491
1827
  //#region src/core/discussions.ts
@@ -1596,37 +1932,38 @@ const listDiscussionsInputSchema = z.object({
1596
1932
  });
1597
1933
  const listDiscussionsDescription = "List discussions in a GitHub repository, most recently updated first, optionally filtered by category (GitHub GraphQL API)";
1598
1934
  async function listDiscussionsCore({ token, owner, repo, category, perPage, after }) {
1599
- const octokit = createOctokit(token);
1600
- let categoryId;
1601
- if (category) {
1602
- const { id, available } = await resolveCategoryId(octokit, owner, repo, category);
1603
- if (!id) return { error: `Unknown discussion category "${category}". Available categories: ${available.join(", ")}` };
1604
- categoryId = id;
1605
- }
1606
- const data = await octokit.graphql(LIST_DISCUSSIONS_QUERY, {
1607
- owner,
1608
- name: repo,
1609
- first: perPage,
1610
- after,
1611
- categoryId
1935
+ return withOctokit(token, async (octokit) => {
1936
+ let categoryId;
1937
+ if (category) {
1938
+ const { id, available } = await resolveCategoryId(octokit, owner, repo, category);
1939
+ if (!id) return { error: `Unknown discussion category "${category}". Available categories: ${available.join(", ")}` };
1940
+ categoryId = id;
1941
+ }
1942
+ const data = await octokit.graphql(LIST_DISCUSSIONS_QUERY, {
1943
+ owner,
1944
+ name: repo,
1945
+ first: perPage,
1946
+ after,
1947
+ categoryId
1948
+ });
1949
+ if (!data.repository) return { error: `Repository not found, or discussions are disabled on ${owner}/${repo}` };
1950
+ const { pageInfo, nodes } = data.repository.discussions;
1951
+ return {
1952
+ hasNextPage: pageInfo.hasNextPage,
1953
+ endCursor: pageInfo.endCursor,
1954
+ discussions: nodes.map((node) => ({
1955
+ id: node.id,
1956
+ number: node.number,
1957
+ title: node.title,
1958
+ url: node.url,
1959
+ author: node.author?.login ?? null,
1960
+ category: node.category?.name ?? null,
1961
+ answerChosen: node.isAnswered,
1962
+ createdAt: node.createdAt,
1963
+ updatedAt: node.updatedAt
1964
+ }))
1965
+ };
1612
1966
  });
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
1967
  }
1631
1968
  const getDiscussionInputSchema = z.object({
1632
1969
  owner: z.string().describe("Repository owner"),
@@ -1636,25 +1973,27 @@ const getDiscussionInputSchema = z.object({
1636
1973
  });
1637
1974
  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
1975
  async function getDiscussionCore({ token, owner, repo, discussionNumber, detail = "summary" }) {
1639
- const discussion = (await createOctokit(token).graphql(GET_DISCUSSION_QUERY, {
1640
- owner,
1641
- name: repo,
1642
- number: discussionNumber
1643
- })).repository?.discussion;
1644
- if (!discussion) return { error: `Discussion #${discussionNumber} not found on ${owner}/${repo}` };
1645
- return {
1646
- id: discussion.id,
1647
- number: discussion.number,
1648
- title: discussion.title,
1649
- body: applyDetailBody(discussion.body, detail),
1650
- url: discussion.url,
1651
- author: discussion.author?.login ?? null,
1652
- category: discussion.category?.name ?? null,
1653
- answerChosen: discussion.isAnswered,
1654
- commentsCount: discussion.comments.totalCount,
1655
- createdAt: discussion.createdAt,
1656
- updatedAt: discussion.updatedAt
1657
- };
1976
+ return withOctokit(token, async (octokit) => {
1977
+ const discussion = (await octokit.graphql(GET_DISCUSSION_QUERY, {
1978
+ owner,
1979
+ name: repo,
1980
+ number: discussionNumber
1981
+ })).repository?.discussion;
1982
+ if (!discussion) return { error: `Discussion #${discussionNumber} not found on ${owner}/${repo}` };
1983
+ return {
1984
+ id: discussion.id,
1985
+ number: discussion.number,
1986
+ title: discussion.title,
1987
+ body: applyDetailBody(discussion.body, detail),
1988
+ url: discussion.url,
1989
+ author: discussion.author?.login ?? null,
1990
+ category: discussion.category?.name ?? null,
1991
+ answerChosen: discussion.isAnswered,
1992
+ commentsCount: discussion.comments.totalCount,
1993
+ createdAt: discussion.createdAt,
1994
+ updatedAt: discussion.updatedAt
1995
+ };
1996
+ });
1658
1997
  }
1659
1998
  const addDiscussionCommentInputSchema = z.object({
1660
1999
  owner: z.string().describe("Repository owner"),
@@ -1665,24 +2004,25 @@ const addDiscussionCommentInputSchema = z.object({
1665
2004
  const addDiscussionCommentDescription = "Add a comment to a GitHub discussion (GitHub GraphQL API)";
1666
2005
  /** Not idempotent — each call adds another comment. */
1667
2006
  async function addDiscussionCommentCore({ token, owner, repo, discussionNumber, body }) {
1668
- const octokit = createOctokit(token);
1669
- const discussionId = (await octokit.graphql(DISCUSSION_ID_QUERY, {
1670
- owner,
1671
- name: repo,
1672
- number: discussionNumber
1673
- })).repository?.discussion?.id;
1674
- if (!discussionId) return { error: `Discussion #${discussionNumber} not found on ${owner}/${repo}` };
1675
- const comment = (await octokit.graphql(ADD_DISCUSSION_COMMENT_MUTATION, {
1676
- discussionId,
1677
- body
1678
- })).addDiscussionComment.comment;
1679
- return {
1680
- id: comment.id,
1681
- url: comment.url,
1682
- body: comment.body,
1683
- author: comment.author?.login ?? null,
1684
- createdAt: comment.createdAt
1685
- };
2007
+ return withOctokit(token, async (octokit) => {
2008
+ const discussionId = (await octokit.graphql(DISCUSSION_ID_QUERY, {
2009
+ owner,
2010
+ name: repo,
2011
+ number: discussionNumber
2012
+ })).repository?.discussion?.id;
2013
+ if (!discussionId) return { error: `Discussion #${discussionNumber} not found on ${owner}/${repo}` };
2014
+ const comment = (await octokit.graphql(ADD_DISCUSSION_COMMENT_MUTATION, {
2015
+ discussionId,
2016
+ body
2017
+ })).addDiscussionComment.comment;
2018
+ return {
2019
+ id: comment.id,
2020
+ url: comment.url,
2021
+ body: comment.body,
2022
+ author: comment.author?.login ?? null,
2023
+ createdAt: comment.createdAt
2024
+ };
2025
+ });
1686
2026
  }
1687
2027
  //#endregion
1688
2028
  //#region src/core/notifications.ts
@@ -1694,34 +2034,38 @@ const listNotificationsInputSchema = z.object({
1694
2034
  });
1695
2035
  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
2036
  async function listNotificationsCore({ token, all, participating, perPage, page }) {
1697
- const { data } = await createOctokit(token).rest.activity.listNotificationsForAuthenticatedUser({
1698
- all,
1699
- participating,
1700
- per_page: perPage,
1701
- page
1702
- });
1703
- return data.map((thread) => ({
1704
- threadId: thread.id,
1705
- repository: thread.repository.full_name,
1706
- subject: {
1707
- title: thread.subject.title,
1708
- type: thread.subject.type,
1709
- url: thread.subject.url
1710
- },
1711
- reason: thread.reason,
1712
- unread: thread.unread,
1713
- updatedAt: thread.updated_at
1714
- }));
2037
+ return withOctokit(token, async (octokit) => {
2038
+ const { data } = await octokit.rest.activity.listNotificationsForAuthenticatedUser({
2039
+ all,
2040
+ participating,
2041
+ per_page: perPage,
2042
+ page
2043
+ });
2044
+ return data.map((thread) => ({
2045
+ threadId: thread.id,
2046
+ repository: thread.repository.full_name,
2047
+ subject: {
2048
+ title: thread.subject.title,
2049
+ type: thread.subject.type,
2050
+ url: thread.subject.url
2051
+ },
2052
+ reason: thread.reason,
2053
+ unread: thread.unread,
2054
+ updatedAt: thread.updated_at
2055
+ }));
2056
+ });
1715
2057
  }
1716
2058
  const markNotificationReadInputSchema = z.object({ threadId: z.string().describe("Notification thread ID (from listNotifications)") });
1717
2059
  const markNotificationReadDescription = "Mark a single notification thread as read";
1718
2060
  /** Idempotent — marking an already-read thread is a no-op on GitHub. */
1719
2061
  async function markNotificationReadCore({ token, threadId }) {
1720
- await createOctokit(token).rest.activity.markThreadAsRead({ thread_id: Number(threadId) });
1721
- return {
1722
- marked: true,
1723
- threadId
1724
- };
2062
+ return withOctokit(token, async (octokit) => {
2063
+ await octokit.rest.activity.markThreadAsRead({ thread_id: Number(threadId) });
2064
+ return {
2065
+ marked: true,
2066
+ threadId
2067
+ };
2068
+ });
1725
2069
  }
1726
2070
  //#endregion
1727
2071
  //#region src/core/search.ts
@@ -1736,22 +2080,24 @@ const searchCodeInputSchema = z.object({
1736
2080
  });
1737
2081
  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
2082
  async function searchCodeCore({ token, query, perPage }) {
1739
- const { data } = await createOctokit(token).rest.search.code({
1740
- q: query,
1741
- per_page: perPage,
1742
- mediaType: { format: "text-match" }
2083
+ return withOctokit(token, async (octokit) => {
2084
+ const { data } = await octokit.rest.search.code({
2085
+ q: query,
2086
+ per_page: perPage,
2087
+ mediaType: { format: "text-match" }
2088
+ });
2089
+ return {
2090
+ totalCount: data.total_count,
2091
+ items: data.items.map((item) => ({
2092
+ name: item.name,
2093
+ path: item.path,
2094
+ url: item.html_url,
2095
+ repository: item.repository.full_name,
2096
+ sha: item.sha,
2097
+ textMatches: item.text_matches?.map((match) => ({ fragment: truncateFragment(match.fragment ?? "") }))
2098
+ }))
2099
+ };
1743
2100
  });
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
2101
  }
1756
2102
  const searchRepositoriesInputSchema = z.object({
1757
2103
  query: z.string().describe("Search query. Supports GitHub search qualifiers, e.g. \"nuxt language:typescript stars:>1000\""),
@@ -1766,25 +2112,27 @@ const searchRepositoriesInputSchema = z.object({
1766
2112
  });
1767
2113
  const searchRepositoriesDescription = "Search for GitHub repositories by keyword, topic, language, or other qualifiers";
1768
2114
  async function searchRepositoriesCore({ token, query, perPage, sort, order }) {
1769
- const { data } = await createOctokit(token).rest.search.repos({
1770
- q: query,
1771
- per_page: perPage,
1772
- sort,
1773
- order
2115
+ return withOctokit(token, async (octokit) => {
2116
+ const { data } = await octokit.rest.search.repos({
2117
+ q: query,
2118
+ per_page: perPage,
2119
+ sort,
2120
+ order
2121
+ });
2122
+ return {
2123
+ totalCount: data.total_count,
2124
+ items: data.items.map((repo) => ({
2125
+ name: repo.name,
2126
+ fullName: repo.full_name,
2127
+ description: repo.description,
2128
+ url: repo.html_url,
2129
+ stars: repo.stargazers_count,
2130
+ forks: repo.forks_count,
2131
+ language: repo.language,
2132
+ topics: repo.topics
2133
+ }))
2134
+ };
1774
2135
  });
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
2136
  }
1789
2137
  const searchIssuesInputSchema = z.object({
1790
2138
  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 +2148,30 @@ const searchIssuesInputSchema = z.object({
1800
2148
  });
1801
2149
  const searchIssuesDescription = "Search for issues and pull requests across GitHub using search qualifiers like \"repo:owner/name is:open\"";
1802
2150
  async function searchIssuesCore({ token, query, perPage, sort, order }) {
1803
- const { data } = await createOctokit(token).rest.search.issuesAndPullRequests({
1804
- q: query,
1805
- per_page: perPage,
1806
- sort,
1807
- order
2151
+ return withOctokit(token, async (octokit) => {
2152
+ const { data } = await octokit.rest.search.issuesAndPullRequests({
2153
+ q: query,
2154
+ per_page: perPage,
2155
+ sort,
2156
+ order
2157
+ });
2158
+ return {
2159
+ totalCount: data.total_count,
2160
+ items: data.items.map((item) => ({
2161
+ number: item.number,
2162
+ title: item.title,
2163
+ state: item.state,
2164
+ url: item.html_url,
2165
+ repository: item.repository_url.split("/repos/").at(-1),
2166
+ author: item.user?.login,
2167
+ labels: item.labels.map((l) => typeof l === "string" ? l : l.name),
2168
+ comments: item.comments,
2169
+ createdAt: item.created_at,
2170
+ updatedAt: item.updated_at,
2171
+ isPullRequest: Boolean(item.pull_request)
2172
+ }))
2173
+ };
1808
2174
  });
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
2175
  }
1826
2176
  //#endregion
1827
2177
  //#region src/core/commits.ts
@@ -1870,28 +2220,29 @@ const listCommitsInputSchema = z.object({
1870
2220
  });
1871
2221
  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
2222
  async function listCommitsCore({ token, owner, repo, path, sha, author, since, until, perPage, maxPages }) {
1873
- const octokit = createOctokit(token);
1874
- return (await fetchAllPages(async (page) => {
1875
- const { data } = await octokit.rest.repos.listCommits({
1876
- owner,
1877
- repo,
1878
- path,
1879
- sha,
1880
- author,
1881
- since,
1882
- until,
1883
- per_page: perPage,
1884
- page
1885
- });
1886
- return data;
1887
- }, perPage, maxPages)).map((commit) => ({
1888
- sha: commit.sha,
1889
- message: commit.commit.message,
1890
- author: commit.commit.author?.name,
1891
- authorLogin: commit.author?.login,
1892
- date: commit.commit.author?.date,
1893
- url: commit.html_url
1894
- }));
2223
+ return withOctokit(token, async (octokit) => {
2224
+ return (await fetchAllPages(async (page) => {
2225
+ const { data } = await octokit.rest.repos.listCommits({
2226
+ owner,
2227
+ repo,
2228
+ path,
2229
+ sha,
2230
+ author,
2231
+ since,
2232
+ until,
2233
+ per_page: perPage,
2234
+ page
2235
+ });
2236
+ return data;
2237
+ }, perPage, maxPages)).map((commit) => ({
2238
+ sha: commit.sha,
2239
+ message: commit.commit.message,
2240
+ author: commit.commit.author?.name,
2241
+ authorLogin: commit.author?.login,
2242
+ date: commit.commit.author?.date,
2243
+ url: commit.html_url
2244
+ }));
2245
+ });
1895
2246
  }
1896
2247
  const getCommitInputSchema = z.object({
1897
2248
  owner: z.string().describe("Repository owner"),
@@ -1901,31 +2252,33 @@ const getCommitInputSchema = z.object({
1901
2252
  });
1902
2253
  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
2254
  async function getCommitCore({ token, owner, repo, ref, includePatch }) {
1904
- const { data } = await createOctokit(token).rest.repos.getCommit({
1905
- owner,
1906
- repo,
1907
- ref
2255
+ return withOctokit(token, async (octokit) => {
2256
+ const { data } = await octokit.rest.repos.getCommit({
2257
+ owner,
2258
+ repo,
2259
+ ref
2260
+ });
2261
+ return {
2262
+ sha: data.sha,
2263
+ message: data.commit.message,
2264
+ author: data.commit.author?.name,
2265
+ authorLogin: data.author?.login,
2266
+ date: data.commit.author?.date,
2267
+ url: data.html_url,
2268
+ stats: data.stats ? {
2269
+ additions: data.stats.additions,
2270
+ deletions: data.stats.deletions,
2271
+ total: data.stats.total
2272
+ } : null,
2273
+ files: data.files?.map((file) => ({
2274
+ filename: file.filename,
2275
+ status: file.status,
2276
+ additions: file.additions,
2277
+ deletions: file.deletions,
2278
+ ...includePatch && file.patch != null ? { patch: file.patch } : {}
2279
+ }))
2280
+ };
1908
2281
  });
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
2282
  }
1930
2283
  const getBlameInputSchema = z.object({
1931
2284
  owner: z.string().describe("Repository owner"),
@@ -1938,52 +2291,53 @@ const getBlameInputSchema = z.object({
1938
2291
  });
1939
2292
  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
2293
  async function getBlameCore({ token, owner, repo, path, ref, line, lineStart, lineEnd }) {
1941
- const octokit = createOctokit(token);
1942
- let expression = ref;
1943
- if (!expression) {
1944
- const { data } = await octokit.rest.repos.get({
2294
+ return withOctokit(token, async (octokit) => {
2295
+ let expression = ref;
2296
+ if (!expression) {
2297
+ const { data } = await octokit.rest.repos.get({
2298
+ owner,
2299
+ repo
2300
+ });
2301
+ expression = data.default_branch;
2302
+ }
2303
+ const data = await octokit.graphql(BLAME_QUERY, {
1945
2304
  owner,
1946
- repo
2305
+ name: repo,
2306
+ expression,
2307
+ path
1947
2308
  });
1948
- expression = data.default_branch;
1949
- }
1950
- const data = await octokit.graphql(BLAME_QUERY, {
1951
- owner,
1952
- name: repo,
1953
- expression,
1954
- path
1955
- });
1956
- if (!data.repository) return { error: `Repository not found: ${owner}/${repo}` };
1957
- const obj = data.repository.object;
1958
- 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.` };
1959
- let ranges = obj.blame.ranges.map((r) => ({
1960
- startingLine: r.startingLine,
1961
- endingLine: r.endingLine,
1962
- age: r.age,
1963
- commit: {
1964
- sha: r.commit.oid,
1965
- abbreviatedSha: r.commit.abbreviatedOid,
1966
- messageHeadline: r.commit.messageHeadline,
1967
- authoredDate: r.commit.authoredDate,
1968
- url: r.commit.url,
1969
- authorName: r.commit.author?.name ?? null,
1970
- authorEmail: r.commit.author?.email ?? null,
1971
- authorLogin: r.commit.author?.user?.login ?? null
2309
+ if (!data.repository) return { error: `Repository not found: ${owner}/${repo}` };
2310
+ const obj = data.repository.object;
2311
+ 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.` };
2312
+ let ranges = obj.blame.ranges.map((r) => ({
2313
+ startingLine: r.startingLine,
2314
+ endingLine: r.endingLine,
2315
+ age: r.age,
2316
+ commit: {
2317
+ sha: r.commit.oid,
2318
+ abbreviatedSha: r.commit.abbreviatedOid,
2319
+ messageHeadline: r.commit.messageHeadline,
2320
+ authoredDate: r.commit.authoredDate,
2321
+ url: r.commit.url,
2322
+ authorName: r.commit.author?.name ?? null,
2323
+ authorEmail: r.commit.author?.email ?? null,
2324
+ authorLogin: r.commit.author?.user?.login ?? null
2325
+ }
2326
+ }));
2327
+ if (line != null) ranges = ranges.filter((r) => line >= r.startingLine && line <= r.endingLine);
2328
+ else if (lineStart != null || lineEnd != null) {
2329
+ const start = lineStart ?? 1;
2330
+ const end = lineEnd ?? Number.MAX_SAFE_INTEGER;
2331
+ ranges = ranges.filter((r) => r.endingLine >= start && r.startingLine <= end);
1972
2332
  }
1973
- }));
1974
- if (line != null) ranges = ranges.filter((r) => line >= r.startingLine && line <= r.endingLine);
1975
- else if (lineStart != null || lineEnd != null) {
1976
- const start = lineStart ?? 1;
1977
- const end = lineEnd ?? Number.MAX_SAFE_INTEGER;
1978
- ranges = ranges.filter((r) => r.endingLine >= start && r.startingLine <= end);
1979
- }
1980
- return {
1981
- ref: expression,
1982
- tipSha: obj.oid,
1983
- path,
1984
- rangeCount: ranges.length,
1985
- ranges
1986
- };
2333
+ return {
2334
+ ref: expression,
2335
+ tipSha: obj.oid,
2336
+ path,
2337
+ rangeCount: ranges.length,
2338
+ ranges
2339
+ };
2340
+ });
1987
2341
  }
1988
2342
  const compareCommitsInputSchema = z.object({
1989
2343
  owner: z.string().describe("Repository owner"),
@@ -1994,31 +2348,33 @@ const compareCommitsInputSchema = z.object({
1994
2348
  });
1995
2349
  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
2350
  async function compareCommitsCore({ token, owner, repo, base, head, includePatch }) {
1997
- const { data } = await createOctokit(token).rest.repos.compareCommitsWithBasehead({
1998
- owner,
1999
- repo,
2000
- basehead: `${base}...${head}`
2351
+ return withOctokit(token, async (octokit) => {
2352
+ const { data } = await octokit.rest.repos.compareCommitsWithBasehead({
2353
+ owner,
2354
+ repo,
2355
+ basehead: `${base}...${head}`
2356
+ });
2357
+ return {
2358
+ status: data.status,
2359
+ aheadBy: data.ahead_by,
2360
+ behindBy: data.behind_by,
2361
+ totalCommits: data.total_commits,
2362
+ url: data.html_url,
2363
+ commits: data.commits.map((commit) => ({
2364
+ sha: commit.sha,
2365
+ message: commit.commit.message,
2366
+ author: commit.commit.author?.name,
2367
+ authorLogin: commit.author?.login
2368
+ })),
2369
+ files: data.files?.map((file) => ({
2370
+ filename: file.filename,
2371
+ status: file.status,
2372
+ additions: file.additions,
2373
+ deletions: file.deletions,
2374
+ ...includePatch && file.patch != null ? { patch: file.patch } : {}
2375
+ }))
2376
+ };
2001
2377
  });
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
2378
  }
2023
2379
  //#endregion
2024
2380
  //#region src/core/gists.ts
@@ -2029,47 +2385,50 @@ const listGistsInputSchema = z.object({
2029
2385
  });
2030
2386
  const listGistsDescription = "List gists for the authenticated user or a specific user";
2031
2387
  async function listGistsCore({ token, username, perPage, page }) {
2032
- const octokit = createOctokit(token);
2033
- const { data } = username ? await octokit.rest.gists.listForUser({
2034
- username,
2035
- per_page: perPage,
2036
- page
2037
- }) : await octokit.rest.gists.list({
2038
- per_page: perPage,
2039
- page
2040
- });
2041
- return data.map((gist) => ({
2042
- id: gist.id,
2043
- description: gist.description,
2044
- public: gist.public,
2045
- url: gist.html_url,
2046
- files: Object.keys(gist.files ?? {}),
2047
- owner: gist.owner?.login,
2048
- comments: gist.comments,
2049
- createdAt: gist.created_at,
2050
- updatedAt: gist.updated_at
2051
- }));
2388
+ return withOctokit(token, async (octokit) => {
2389
+ const { data } = username ? await octokit.rest.gists.listForUser({
2390
+ username,
2391
+ per_page: perPage,
2392
+ page
2393
+ }) : await octokit.rest.gists.list({
2394
+ per_page: perPage,
2395
+ page
2396
+ });
2397
+ return data.map((gist) => ({
2398
+ id: gist.id,
2399
+ description: gist.description,
2400
+ public: gist.public,
2401
+ url: gist.html_url,
2402
+ files: Object.keys(gist.files ?? {}),
2403
+ owner: gist.owner?.login,
2404
+ comments: gist.comments,
2405
+ createdAt: gist.created_at,
2406
+ updatedAt: gist.updated_at
2407
+ }));
2408
+ });
2052
2409
  }
2053
2410
  const getGistInputSchema = z.object({ gistId: z.string().describe("Gist ID") });
2054
2411
  const getGistDescription = "Get a gist by ID, including file contents";
2055
2412
  async function getGistCore({ token, gistId }) {
2056
- const { data } = await createOctokit(token).rest.gists.get({ gist_id: gistId });
2057
- return {
2058
- id: data.id,
2059
- description: data.description,
2060
- public: data.public,
2061
- url: data.html_url,
2062
- owner: data.owner?.login,
2063
- files: Object.values(data.files ?? {}).map((file) => ({
2064
- filename: file?.filename,
2065
- language: file?.language,
2066
- size: file?.size,
2067
- content: file?.content
2068
- })),
2069
- comments: data.comments,
2070
- createdAt: data.created_at,
2071
- updatedAt: data.updated_at
2072
- };
2413
+ return withOctokit(token, async (octokit) => {
2414
+ const { data } = await octokit.rest.gists.get({ gist_id: gistId });
2415
+ return {
2416
+ id: data.id,
2417
+ description: data.description,
2418
+ public: data.public,
2419
+ url: data.html_url,
2420
+ owner: data.owner?.login,
2421
+ files: Object.values(data.files ?? {}).map((file) => ({
2422
+ filename: file?.filename,
2423
+ language: file?.language,
2424
+ size: file?.size,
2425
+ content: file?.content
2426
+ })),
2427
+ comments: data.comments,
2428
+ createdAt: data.created_at,
2429
+ updatedAt: data.updated_at
2430
+ };
2431
+ });
2073
2432
  }
2074
2433
  const listGistCommentsInputSchema = z.object({
2075
2434
  gistId: z.string().describe("Gist ID"),
@@ -2078,19 +2437,21 @@ const listGistCommentsInputSchema = z.object({
2078
2437
  });
2079
2438
  const listGistCommentsDescription = "List comments on a gist";
2080
2439
  async function listGistCommentsCore({ token, gistId, perPage, page }) {
2081
- const { data } = await createOctokit(token).rest.gists.listComments({
2082
- gist_id: gistId,
2083
- per_page: perPage,
2084
- page
2085
- });
2086
- return data.map((comment) => ({
2087
- id: comment.id,
2088
- body: comment.body,
2089
- author: comment.user?.login,
2090
- url: comment.url,
2091
- createdAt: comment.created_at,
2092
- updatedAt: comment.updated_at
2093
- }));
2440
+ return withOctokit(token, async (octokit) => {
2441
+ const { data } = await octokit.rest.gists.listComments({
2442
+ gist_id: gistId,
2443
+ per_page: perPage,
2444
+ page
2445
+ });
2446
+ return data.map((comment) => ({
2447
+ id: comment.id,
2448
+ body: comment.body,
2449
+ author: comment.user?.login,
2450
+ url: comment.url,
2451
+ createdAt: comment.created_at,
2452
+ updatedAt: comment.updated_at
2453
+ }));
2454
+ });
2094
2455
  }
2095
2456
  const createGistInputSchema = z.object({
2096
2457
  description: z.string().optional().describe("Gist description"),
@@ -2100,19 +2461,21 @@ const createGistInputSchema = z.object({
2100
2461
  const createGistDescription = "Create a new gist with one or more files";
2101
2462
  /** Not idempotent — each call creates a new gist. */
2102
2463
  async function createGistCore({ token, description, files, isPublic }) {
2103
- const { data } = await createOctokit(token).rest.gists.create({
2104
- description,
2105
- files,
2106
- public: isPublic
2464
+ return withOctokit(token, async (octokit) => {
2465
+ const { data } = await octokit.rest.gists.create({
2466
+ description,
2467
+ files,
2468
+ public: isPublic
2469
+ });
2470
+ return {
2471
+ id: data.id,
2472
+ description: data.description,
2473
+ public: data.public,
2474
+ url: data.html_url,
2475
+ files: Object.keys(data.files ?? {}),
2476
+ owner: data.owner?.login
2477
+ };
2107
2478
  });
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
2479
  }
2117
2480
  const updateGistInputSchema = z.object({
2118
2481
  gistId: z.string().describe("Gist ID"),
@@ -2123,31 +2486,34 @@ const updateGistInputSchema = z.object({
2123
2486
  const updateGistDescription = "Update an existing gist — edit description, update files, or remove files";
2124
2487
  /** Not idempotent — each call applies a new revision. */
2125
2488
  async function updateGistCore({ token, gistId, description, files, filesToDelete }) {
2126
- const octokit = createOctokit(token);
2127
- const fileUpdates = {};
2128
- if (files) Object.assign(fileUpdates, files);
2129
- if (filesToDelete) for (const name of filesToDelete) fileUpdates[name] = null;
2130
- const { data } = await octokit.rest.gists.update({
2131
- gist_id: gistId,
2132
- description,
2133
- files: fileUpdates
2489
+ return withOctokit(token, async (octokit) => {
2490
+ const fileUpdates = {};
2491
+ if (files) Object.assign(fileUpdates, files);
2492
+ if (filesToDelete) for (const name of filesToDelete) fileUpdates[name] = null;
2493
+ const { data } = await octokit.rest.gists.update({
2494
+ gist_id: gistId,
2495
+ description,
2496
+ files: fileUpdates
2497
+ });
2498
+ return {
2499
+ id: data.id,
2500
+ description: data.description,
2501
+ url: data.html_url,
2502
+ files: Object.keys(data.files ?? {})
2503
+ };
2134
2504
  });
2135
- return {
2136
- id: data.id,
2137
- description: data.description,
2138
- url: data.html_url,
2139
- files: Object.keys(data.files ?? {})
2140
- };
2141
2505
  }
2142
2506
  const deleteGistInputSchema = z.object({ gistId: z.string().describe("Gist ID to delete") });
2143
2507
  const deleteGistDescription = "Delete a gist permanently";
2144
2508
  /** Not idempotent — deleting an already-deleted gist returns 404 from GitHub. */
2145
2509
  async function deleteGistCore({ token, gistId }) {
2146
- await createOctokit(token).rest.gists.delete({ gist_id: gistId });
2147
- return {
2148
- deleted: true,
2149
- gistId
2150
- };
2510
+ return withOctokit(token, async (octokit) => {
2511
+ await octokit.rest.gists.delete({ gist_id: gistId });
2512
+ return {
2513
+ deleted: true,
2514
+ gistId
2515
+ };
2516
+ });
2151
2517
  }
2152
2518
  const createGistCommentInputSchema = z.object({
2153
2519
  gistId: z.string().describe("Gist ID"),
@@ -2156,17 +2522,19 @@ const createGistCommentInputSchema = z.object({
2156
2522
  const createGistCommentDescription = "Add a comment to a gist";
2157
2523
  /** Not idempotent — each call adds another comment. */
2158
2524
  async function createGistCommentCore({ token, gistId, body }) {
2159
- const { data } = await createOctokit(token).rest.gists.createComment({
2160
- gist_id: gistId,
2161
- body
2525
+ return withOctokit(token, async (octokit) => {
2526
+ const { data } = await octokit.rest.gists.createComment({
2527
+ gist_id: gistId,
2528
+ body
2529
+ });
2530
+ return {
2531
+ id: data.id,
2532
+ url: data.url,
2533
+ body: data.body,
2534
+ author: data.user?.login,
2535
+ createdAt: data.created_at
2536
+ };
2162
2537
  });
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
2538
  }
2171
2539
  //#endregion
2172
2540
  //#region src/core/workflows.ts
@@ -2178,24 +2546,26 @@ const listWorkflowsInputSchema = z.object({
2178
2546
  });
2179
2547
  const listWorkflowsDescription = "List GitHub Actions workflows in a repository";
2180
2548
  async function listWorkflowsCore({ token, owner, repo, perPage, page }) {
2181
- const { data } = await createOctokit(token).rest.actions.listRepoWorkflows({
2182
- owner,
2183
- repo,
2184
- per_page: perPage,
2185
- page
2549
+ return withOctokit(token, async (octokit) => {
2550
+ const { data } = await octokit.rest.actions.listRepoWorkflows({
2551
+ owner,
2552
+ repo,
2553
+ per_page: perPage,
2554
+ page
2555
+ });
2556
+ return {
2557
+ totalCount: data.total_count,
2558
+ workflows: data.workflows.map((wf) => ({
2559
+ id: wf.id,
2560
+ name: wf.name,
2561
+ path: wf.path,
2562
+ state: wf.state,
2563
+ url: wf.html_url,
2564
+ createdAt: wf.created_at,
2565
+ updatedAt: wf.updated_at
2566
+ }))
2567
+ };
2186
2568
  });
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
2569
  }
2200
2570
  const listWorkflowRunsInputSchema = z.object({
2201
2571
  owner: z.string().describe("Repository owner"),
@@ -2225,47 +2595,48 @@ const listWorkflowRunsInputSchema = z.object({
2225
2595
  });
2226
2596
  const listWorkflowRunsDescription = "List workflow runs for a repository, optionally filtered by workflow, branch, status, or event";
2227
2597
  async function listWorkflowRunsCore({ token, owner, repo, workflowId, branch, event, status, perPage, page, maxPages }) {
2228
- const octokit = createOctokit(token);
2229
- let totalCount = 0;
2230
- const runs = await fetchAllPages(async (currentPage) => {
2231
- const { data } = workflowId ? await octokit.rest.actions.listWorkflowRuns({
2232
- owner,
2233
- repo,
2234
- workflow_id: workflowId,
2235
- per_page: perPage,
2236
- page: currentPage,
2237
- ...branch && { branch },
2238
- ...event && { event },
2239
- ...status && { status }
2240
- }) : await octokit.rest.actions.listWorkflowRunsForRepo({
2241
- owner,
2242
- repo,
2243
- per_page: perPage,
2244
- page: currentPage,
2245
- ...branch && { branch },
2246
- ...event && { event },
2247
- ...status && { status }
2248
- });
2249
- totalCount = data.total_count;
2250
- return data.workflow_runs;
2251
- }, perPage, maxPages, page);
2252
- return {
2253
- totalCount,
2254
- runs: runs.map((run) => ({
2255
- id: run.id,
2256
- name: run.name,
2257
- status: run.status,
2258
- conclusion: run.conclusion,
2259
- branch: run.head_branch,
2260
- event: run.event,
2261
- url: run.html_url,
2262
- actor: run.actor?.login,
2263
- createdAt: run.created_at,
2264
- updatedAt: run.updated_at,
2265
- runNumber: run.run_number,
2266
- runAttempt: run.run_attempt
2267
- }))
2268
- };
2598
+ return withOctokit(token, async (octokit) => {
2599
+ let totalCount = 0;
2600
+ const runs = await fetchAllPages(async (currentPage) => {
2601
+ const { data } = workflowId ? await octokit.rest.actions.listWorkflowRuns({
2602
+ owner,
2603
+ repo,
2604
+ workflow_id: workflowId,
2605
+ per_page: perPage,
2606
+ page: currentPage,
2607
+ ...branch && { branch },
2608
+ ...event && { event },
2609
+ ...status && { status }
2610
+ }) : await octokit.rest.actions.listWorkflowRunsForRepo({
2611
+ owner,
2612
+ repo,
2613
+ per_page: perPage,
2614
+ page: currentPage,
2615
+ ...branch && { branch },
2616
+ ...event && { event },
2617
+ ...status && { status }
2618
+ });
2619
+ totalCount = data.total_count;
2620
+ return data.workflow_runs;
2621
+ }, perPage, maxPages, page);
2622
+ return {
2623
+ totalCount,
2624
+ runs: runs.map((run) => ({
2625
+ id: run.id,
2626
+ name: run.name,
2627
+ status: run.status,
2628
+ conclusion: run.conclusion,
2629
+ branch: run.head_branch,
2630
+ event: run.event,
2631
+ url: run.html_url,
2632
+ actor: run.actor?.login,
2633
+ createdAt: run.created_at,
2634
+ updatedAt: run.updated_at,
2635
+ runNumber: run.run_number,
2636
+ runAttempt: run.run_attempt
2637
+ }))
2638
+ };
2639
+ });
2269
2640
  }
2270
2641
  const getWorkflowRunInputSchema = z.object({
2271
2642
  owner: z.string().describe("Repository owner"),
@@ -2274,27 +2645,29 @@ const getWorkflowRunInputSchema = z.object({
2274
2645
  });
2275
2646
  const getWorkflowRunDescription = "Get details of a specific workflow run including status, timing, and trigger info";
2276
2647
  async function getWorkflowRunCore({ token, owner, repo, runId }) {
2277
- const { data } = await createOctokit(token).rest.actions.getWorkflowRun({
2278
- owner,
2279
- repo,
2280
- run_id: runId
2648
+ return withOctokit(token, async (octokit) => {
2649
+ const { data } = await octokit.rest.actions.getWorkflowRun({
2650
+ owner,
2651
+ repo,
2652
+ run_id: runId
2653
+ });
2654
+ return {
2655
+ id: data.id,
2656
+ name: data.name,
2657
+ status: data.status,
2658
+ conclusion: data.conclusion,
2659
+ branch: data.head_branch,
2660
+ sha: data.head_sha,
2661
+ event: data.event,
2662
+ url: data.html_url,
2663
+ actor: data.actor?.login,
2664
+ runNumber: data.run_number,
2665
+ runAttempt: data.run_attempt,
2666
+ createdAt: data.created_at,
2667
+ updatedAt: data.updated_at,
2668
+ runStartedAt: data.run_started_at
2669
+ };
2281
2670
  });
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
2671
  }
2299
2672
  const listWorkflowJobsInputSchema = z.object({
2300
2673
  owner: z.string().describe("Repository owner"),
@@ -2306,36 +2679,73 @@ const listWorkflowJobsInputSchema = z.object({
2306
2679
  });
2307
2680
  const listWorkflowJobsDescription = "List jobs for a workflow run, including step-level status and timing";
2308
2681
  async function listWorkflowJobsCore({ token, owner, repo, runId, filter, perPage, page }) {
2309
- const { data } = await createOctokit(token).rest.actions.listJobsForWorkflowRun({
2310
- owner,
2311
- repo,
2312
- run_id: runId,
2313
- filter,
2314
- per_page: perPage,
2315
- page
2682
+ return withOctokit(token, async (octokit) => {
2683
+ const { data } = await octokit.rest.actions.listJobsForWorkflowRun({
2684
+ owner,
2685
+ repo,
2686
+ run_id: runId,
2687
+ filter,
2688
+ per_page: perPage,
2689
+ page
2690
+ });
2691
+ return {
2692
+ totalCount: data.total_count,
2693
+ jobs: data.jobs.map((job) => ({
2694
+ id: job.id,
2695
+ name: job.name,
2696
+ status: job.status,
2697
+ conclusion: job.conclusion,
2698
+ url: job.html_url,
2699
+ startedAt: job.started_at,
2700
+ completedAt: job.completed_at,
2701
+ runnerName: job.runner_name,
2702
+ steps: job.steps?.map((step) => ({
2703
+ name: step.name,
2704
+ status: step.status,
2705
+ conclusion: step.conclusion,
2706
+ number: step.number,
2707
+ startedAt: step.started_at,
2708
+ completedAt: step.completed_at
2709
+ }))
2710
+ }))
2711
+ };
2316
2712
  });
2713
+ }
2714
+ const getWorkflowJobLogsInputSchema = z.object({
2715
+ owner: z.string().describe("Repository owner"),
2716
+ repo: z.string().describe("Repository name"),
2717
+ jobId: z.number().describe("Workflow job ID (from listWorkflowJobs or getCiFailureContext)"),
2718
+ maxLines: z.number().int().positive().max(2e3).optional().default(200).describe("Return only the last N log lines (default 200, max 2000). Failures surface at the end of a log, so the tail is usually enough")
2719
+ });
2720
+ const getWorkflowJobLogsDescription = "Get the log output of a workflow job to diagnose failures. Returns the last maxLines lines (default 200) with per-line timestamps stripped to save tokens";
2721
+ const LOG_TIMESTAMP_PREFIX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z /;
2722
+ /**
2723
+ * Tail-truncate a raw job log and strip the ISO timestamp GitHub prefixes on
2724
+ * every line (~29 tokens-worth of noise per line the model never needs).
2725
+ */
2726
+ function shapeJobLog(raw, maxLines) {
2727
+ const lines = raw.replace(/\r\n/g, "\n").replace(/\n+$/, "").split("\n");
2728
+ const tail = lines.slice(-maxLines).map((line) => line.replace(LOG_TIMESTAMP_PREFIX, ""));
2317
2729
  return {
2318
- totalCount: data.total_count,
2319
- jobs: data.jobs.map((job) => ({
2320
- id: job.id,
2321
- name: job.name,
2322
- status: job.status,
2323
- conclusion: job.conclusion,
2324
- url: job.html_url,
2325
- startedAt: job.started_at,
2326
- completedAt: job.completed_at,
2327
- runnerName: job.runner_name,
2328
- steps: job.steps?.map((step) => ({
2329
- name: step.name,
2330
- status: step.status,
2331
- conclusion: step.conclusion,
2332
- number: step.number,
2333
- startedAt: step.started_at,
2334
- completedAt: step.completed_at
2335
- }))
2336
- }))
2730
+ totalLines: lines.length,
2731
+ returnedLines: tail.length,
2732
+ omittedLines: lines.length - tail.length,
2733
+ log: tail.join("\n")
2337
2734
  };
2338
2735
  }
2736
+ async function getWorkflowJobLogsCore({ token, owner, repo, jobId, maxLines }) {
2737
+ return withOctokit(token, async (octokit) => {
2738
+ const { data } = await octokit.rest.actions.downloadJobLogsForWorkflowRun({
2739
+ owner,
2740
+ repo,
2741
+ job_id: jobId
2742
+ });
2743
+ return {
2744
+ jobId,
2745
+ ...shapeJobLog(String(data), maxLines)
2746
+ };
2747
+ });
2748
+ }
2339
2749
  const triggerWorkflowInputSchema = z.object({
2340
2750
  owner: z.string().describe("Repository owner"),
2341
2751
  repo: z.string().describe("Repository name"),
@@ -2346,18 +2756,20 @@ const triggerWorkflowInputSchema = z.object({
2346
2756
  const triggerWorkflowDescription = "Trigger a workflow via workflow_dispatch event";
2347
2757
  /** Not idempotent — each call starts a new workflow run. */
2348
2758
  async function triggerWorkflowCore({ token, owner, repo, workflowId, ref, inputs }) {
2349
- await createOctokit(token).rest.actions.createWorkflowDispatch({
2350
- owner,
2351
- repo,
2352
- workflow_id: workflowId,
2353
- ref,
2354
- inputs
2759
+ return withOctokit(token, async (octokit) => {
2760
+ await octokit.rest.actions.createWorkflowDispatch({
2761
+ owner,
2762
+ repo,
2763
+ workflow_id: workflowId,
2764
+ ref,
2765
+ inputs
2766
+ });
2767
+ return {
2768
+ triggered: true,
2769
+ workflowId,
2770
+ ref
2771
+ };
2355
2772
  });
2356
- return {
2357
- triggered: true,
2358
- workflowId,
2359
- ref
2360
- };
2361
2773
  }
2362
2774
  const cancelWorkflowRunInputSchema = z.object({
2363
2775
  owner: z.string().describe("Repository owner"),
@@ -2367,15 +2779,17 @@ const cancelWorkflowRunInputSchema = z.object({
2367
2779
  const cancelWorkflowRunDescription = "Cancel an in-progress workflow run";
2368
2780
  /** Not idempotent — cancelling an already-finished run is a no-op on GitHub but still mutates. */
2369
2781
  async function cancelWorkflowRunCore({ token, owner, repo, runId }) {
2370
- await createOctokit(token).rest.actions.cancelWorkflowRun({
2371
- owner,
2372
- repo,
2373
- run_id: runId
2782
+ return withOctokit(token, async (octokit) => {
2783
+ await octokit.rest.actions.cancelWorkflowRun({
2784
+ owner,
2785
+ repo,
2786
+ run_id: runId
2787
+ });
2788
+ return {
2789
+ cancelled: true,
2790
+ runId
2791
+ };
2374
2792
  });
2375
- return {
2376
- cancelled: true,
2377
- runId
2378
- };
2379
2793
  }
2380
2794
  const rerunWorkflowRunInputSchema = z.object({
2381
2795
  owner: z.string().describe("Repository owner"),
@@ -2386,59 +2800,61 @@ const rerunWorkflowRunInputSchema = z.object({
2386
2800
  const rerunWorkflowRunDescription = "Re-run a workflow run, optionally only the failed jobs";
2387
2801
  /** Not idempotent — each call starts another run attempt. */
2388
2802
  async function rerunWorkflowRunCore({ token, owner, repo, runId, onlyFailedJobs }) {
2389
- const octokit = createOctokit(token);
2390
- if (onlyFailedJobs) await octokit.rest.actions.reRunWorkflowFailedJobs({
2391
- owner,
2392
- repo,
2393
- run_id: runId
2394
- });
2395
- else await octokit.rest.actions.reRunWorkflow({
2396
- owner,
2397
- repo,
2398
- run_id: runId
2803
+ return withOctokit(token, async (octokit) => {
2804
+ if (onlyFailedJobs) await octokit.rest.actions.reRunWorkflowFailedJobs({
2805
+ owner,
2806
+ repo,
2807
+ run_id: runId
2808
+ });
2809
+ else await octokit.rest.actions.reRunWorkflow({
2810
+ owner,
2811
+ repo,
2812
+ run_id: runId
2813
+ });
2814
+ return {
2815
+ rerun: true,
2816
+ runId,
2817
+ onlyFailedJobs
2818
+ };
2399
2819
  });
2400
- return {
2401
- rerun: true,
2402
- runId,
2403
- onlyFailedJobs
2404
- };
2405
2820
  }
2406
2821
  //#endregion
2407
2822
  //#region src/core/checks.ts
2408
2823
  const listCheckRunsInputSchema = z.object({
2409
2824
  owner: z.string().describe("Repository owner"),
2410
- repo: z.string().describe("Repository name"),
2411
- ref: z.string().describe("Git ref: branch, tag, or commit SHA"),
2412
- perPage: z.number().optional().default(30).describe("Number of results to return per page (max 100)"),
2413
- maxPages: maxPagesSchema
2414
- });
2415
- const listCheckRunsDescription = "List check runs (Checks API — GitHub Actions and other CI providers) for a commit, branch, or tag";
2416
- async function listCheckRunsCore({ token, owner, repo, ref, perPage, maxPages }) {
2417
- const octokit = createOctokit(token);
2418
- let totalCount = 0;
2419
- const checkRuns = await fetchAllPages(async (page) => {
2420
- const { data } = await octokit.rest.checks.listForRef({
2421
- owner,
2422
- repo,
2423
- ref,
2424
- per_page: perPage,
2425
- page
2426
- });
2427
- totalCount = data.total_count;
2428
- return data.check_runs;
2429
- }, perPage, maxPages);
2430
- return {
2431
- totalCount,
2432
- checkRuns: checkRuns.map((run) => ({
2433
- id: run.id,
2434
- name: run.name,
2435
- status: run.status,
2436
- conclusion: run.conclusion,
2437
- url: run.html_url,
2438
- startedAt: run.started_at,
2439
- completedAt: run.completed_at
2440
- }))
2441
- };
2825
+ repo: z.string().describe("Repository name"),
2826
+ ref: z.string().describe("Git ref: branch, tag, or commit SHA"),
2827
+ perPage: z.number().optional().default(30).describe("Number of results to return per page (max 100)"),
2828
+ maxPages: maxPagesSchema
2829
+ });
2830
+ const listCheckRunsDescription = "List check runs (Checks API — GitHub Actions and other CI providers) for a commit, branch, or tag";
2831
+ async function listCheckRunsCore({ token, owner, repo, ref, perPage, maxPages }) {
2832
+ return withOctokit(token, async (octokit) => {
2833
+ let totalCount = 0;
2834
+ const checkRuns = await fetchAllPages(async (page) => {
2835
+ const { data } = await octokit.rest.checks.listForRef({
2836
+ owner,
2837
+ repo,
2838
+ ref,
2839
+ per_page: perPage,
2840
+ page
2841
+ });
2842
+ totalCount = data.total_count;
2843
+ return data.check_runs;
2844
+ }, perPage, maxPages);
2845
+ return {
2846
+ totalCount,
2847
+ checkRuns: checkRuns.map((run) => ({
2848
+ id: run.id,
2849
+ name: run.name,
2850
+ status: run.status,
2851
+ conclusion: run.conclusion,
2852
+ url: run.html_url,
2853
+ startedAt: run.started_at,
2854
+ completedAt: run.completed_at
2855
+ }))
2856
+ };
2857
+ });
2442
2858
  }
2443
2859
  const getCombinedStatusInputSchema = z.object({
2444
2860
  owner: z.string().describe("Repository owner"),
@@ -2447,21 +2863,23 @@ const getCombinedStatusInputSchema = z.object({
2447
2863
  });
2448
2864
  const getCombinedStatusDescription = "Get the combined commit status (Statuses API — legacy CI integrations) for a commit, branch, or tag";
2449
2865
  async function getCombinedStatusCore({ token, owner, repo, ref }) {
2450
- const { data } = await createOctokit(token).rest.repos.getCombinedStatusForRef({
2451
- owner,
2452
- repo,
2453
- ref
2866
+ return withOctokit(token, async (octokit) => {
2867
+ const { data } = await octokit.rest.repos.getCombinedStatusForRef({
2868
+ owner,
2869
+ repo,
2870
+ ref
2871
+ });
2872
+ return {
2873
+ state: data.state,
2874
+ totalCount: data.total_count,
2875
+ statuses: data.statuses.map((status) => ({
2876
+ context: status.context,
2877
+ state: status.state,
2878
+ description: status.description,
2879
+ url: status.target_url
2880
+ }))
2881
+ };
2454
2882
  });
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
2883
  }
2466
2884
  //#endregion
2467
2885
  //#region src/core/releases.ts
@@ -2474,27 +2892,28 @@ const listReleasesInputSchema = z.object({
2474
2892
  });
2475
2893
  const listReleasesDescription = "List releases for a GitHub repository, newest first (includes drafts and prereleases). Bodies truncated by default (detail: summary)";
2476
2894
  async function listReleasesCore({ token, owner, repo, perPage, maxPages, detail = "summary" }) {
2477
- const octokit = createOctokit(token);
2478
- return (await fetchAllPages(async (page) => {
2479
- const { data } = await octokit.rest.repos.listReleases({
2480
- owner,
2481
- repo,
2482
- per_page: perPage,
2483
- page
2484
- });
2485
- return data;
2486
- }, perPage, maxPages)).map((release) => ({
2487
- id: release.id,
2488
- tagName: release.tag_name,
2489
- name: release.name,
2490
- body: applyDetailBody(release.body, detail),
2491
- draft: release.draft,
2492
- prerelease: release.prerelease,
2493
- url: release.html_url,
2494
- author: release.author?.login,
2495
- createdAt: release.created_at,
2496
- publishedAt: release.published_at
2497
- }));
2895
+ return withOctokit(token, async (octokit) => {
2896
+ return (await fetchAllPages(async (page) => {
2897
+ const { data } = await octokit.rest.repos.listReleases({
2898
+ owner,
2899
+ repo,
2900
+ per_page: perPage,
2901
+ page
2902
+ });
2903
+ return data;
2904
+ }, perPage, maxPages)).map((release) => ({
2905
+ id: release.id,
2906
+ tagName: release.tag_name,
2907
+ name: release.name,
2908
+ body: applyDetailBody(release.body, detail),
2909
+ draft: release.draft,
2910
+ prerelease: release.prerelease,
2911
+ url: release.html_url,
2912
+ author: release.author?.login,
2913
+ createdAt: release.created_at,
2914
+ publishedAt: release.published_at
2915
+ }));
2916
+ });
2498
2917
  }
2499
2918
  const getLatestReleaseInputSchema = z.object({
2500
2919
  owner: z.string().describe("Repository owner"),
@@ -2503,26 +2922,28 @@ const getLatestReleaseInputSchema = z.object({
2503
2922
  });
2504
2923
  const getLatestReleaseDescription = "Get the latest published release for a GitHub repository (excludes drafts and prereleases). Body truncated by default (detail: summary)";
2505
2924
  async function getLatestReleaseCore({ token, owner, repo, detail = "summary" }) {
2506
- const { data } = await createOctokit(token).rest.repos.getLatestRelease({
2507
- owner,
2508
- repo
2925
+ return withOctokit(token, async (octokit) => {
2926
+ const { data } = await octokit.rest.repos.getLatestRelease({
2927
+ owner,
2928
+ repo
2929
+ });
2930
+ return {
2931
+ id: data.id,
2932
+ tagName: data.tag_name,
2933
+ name: data.name,
2934
+ body: applyDetailBody(data.body, detail),
2935
+ url: data.html_url,
2936
+ author: data.author?.login,
2937
+ createdAt: data.created_at,
2938
+ publishedAt: data.published_at,
2939
+ assets: data.assets.map((asset) => ({
2940
+ name: asset.name,
2941
+ downloadUrl: asset.browser_download_url,
2942
+ size: asset.size,
2943
+ downloadCount: asset.download_count
2944
+ }))
2945
+ };
2509
2946
  });
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
2947
  }
2527
2948
  const getReleaseInputSchema = z.object({
2528
2949
  owner: z.string().describe("Repository owner"),
@@ -2532,29 +2953,31 @@ const getReleaseInputSchema = z.object({
2532
2953
  });
2533
2954
  const getReleaseDescription = "Get a specific release by ID, including its assets. Body truncated by default (detail: summary)";
2534
2955
  async function getReleaseCore({ token, owner, repo, releaseId, detail = "summary" }) {
2535
- const { data } = await createOctokit(token).rest.repos.getRelease({
2536
- owner,
2537
- repo,
2538
- release_id: releaseId
2956
+ return withOctokit(token, async (octokit) => {
2957
+ const { data } = await octokit.rest.repos.getRelease({
2958
+ owner,
2959
+ repo,
2960
+ release_id: releaseId
2961
+ });
2962
+ return {
2963
+ id: data.id,
2964
+ tagName: data.tag_name,
2965
+ name: data.name,
2966
+ body: applyDetailBody(data.body, detail),
2967
+ draft: data.draft,
2968
+ prerelease: data.prerelease,
2969
+ url: data.html_url,
2970
+ author: data.author?.login,
2971
+ createdAt: data.created_at,
2972
+ publishedAt: data.published_at,
2973
+ assets: data.assets.map((asset) => ({
2974
+ name: asset.name,
2975
+ downloadUrl: asset.browser_download_url,
2976
+ size: asset.size,
2977
+ downloadCount: asset.download_count
2978
+ }))
2979
+ };
2539
2980
  });
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
2981
  }
2559
2982
  const createReleaseInputSchema = z.object({
2560
2983
  owner: z.string().describe("Repository owner"),
@@ -2570,27 +2993,29 @@ const createReleaseInputSchema = z.object({
2570
2993
  const createReleaseDescription = "Create a new release (and its tag if needed) in a GitHub repository";
2571
2994
  /** Not idempotent — creating a release with an existing tag name returns an error from GitHub. */
2572
2995
  async function createReleaseCore({ token, owner, repo, tagName, target, name, body, draft, prerelease, generateReleaseNotes }) {
2573
- const { data } = await createOctokit(token).rest.repos.createRelease({
2574
- owner,
2575
- repo,
2576
- tag_name: tagName,
2577
- target_commitish: target,
2578
- name,
2579
- body,
2580
- draft,
2581
- prerelease,
2582
- generate_release_notes: generateReleaseNotes
2996
+ return withOctokit(token, async (octokit) => {
2997
+ const { data } = await octokit.rest.repos.createRelease({
2998
+ owner,
2999
+ repo,
3000
+ tag_name: tagName,
3001
+ target_commitish: target,
3002
+ name,
3003
+ body,
3004
+ draft,
3005
+ prerelease,
3006
+ generate_release_notes: generateReleaseNotes
3007
+ });
3008
+ return {
3009
+ id: data.id,
3010
+ tagName: data.tag_name,
3011
+ name: data.name,
3012
+ body: data.body,
3013
+ url: data.html_url,
3014
+ draft: data.draft,
3015
+ prerelease: data.prerelease,
3016
+ createdAt: data.created_at
3017
+ };
2583
3018
  });
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
3019
  }
2595
3020
  const updateReleaseInputSchema = z.object({
2596
3021
  owner: z.string().describe("Repository owner"),
@@ -2606,27 +3031,29 @@ const updateReleaseInputSchema = z.object({
2606
3031
  const updateReleaseDescription = "Update an existing release — tag, target, title, notes, draft, or prerelease status";
2607
3032
  /** Not idempotent — each call applies a new revision. */
2608
3033
  async function updateReleaseCore({ token, owner, repo, releaseId, tagName, target, name, body, draft, prerelease }) {
2609
- const { data } = await createOctokit(token).rest.repos.updateRelease({
2610
- owner,
2611
- repo,
2612
- release_id: releaseId,
2613
- tag_name: tagName,
2614
- target_commitish: target,
2615
- name,
2616
- body,
2617
- draft,
2618
- prerelease
3034
+ return withOctokit(token, async (octokit) => {
3035
+ const { data } = await octokit.rest.repos.updateRelease({
3036
+ owner,
3037
+ repo,
3038
+ release_id: releaseId,
3039
+ tag_name: tagName,
3040
+ target_commitish: target,
3041
+ name,
3042
+ body,
3043
+ draft,
3044
+ prerelease
3045
+ });
3046
+ return {
3047
+ id: data.id,
3048
+ tagName: data.tag_name,
3049
+ name: data.name,
3050
+ body: data.body,
3051
+ url: data.html_url,
3052
+ draft: data.draft,
3053
+ prerelease: data.prerelease,
3054
+ publishedAt: data.published_at
3055
+ };
2619
3056
  });
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
3057
  }
2631
3058
  const deleteReleaseInputSchema = z.object({
2632
3059
  owner: z.string().describe("Repository owner"),
@@ -2636,15 +3063,17 @@ const deleteReleaseInputSchema = z.object({
2636
3063
  const deleteReleaseDescription = "Delete a release permanently (does not delete the underlying git tag)";
2637
3064
  /** Not idempotent — deleting an already-deleted release returns 404 from GitHub. */
2638
3065
  async function deleteReleaseCore({ token, owner, repo, releaseId }) {
2639
- await createOctokit(token).rest.repos.deleteRelease({
2640
- owner,
2641
- repo,
2642
- release_id: releaseId
3066
+ return withOctokit(token, async (octokit) => {
3067
+ await octokit.rest.repos.deleteRelease({
3068
+ owner,
3069
+ repo,
3070
+ release_id: releaseId
3071
+ });
3072
+ return {
3073
+ deleted: true,
3074
+ releaseId
3075
+ };
2643
3076
  });
2644
- return {
2645
- deleted: true,
2646
- releaseId
2647
- };
2648
3077
  }
2649
3078
  //#endregion
2650
3079
  //#region src/core/bundles.ts
@@ -2703,12 +3132,12 @@ async function getPullRequestContextCore({ token, owner, repo, pullNumber, inclu
2703
3132
  combinedStatus
2704
3133
  })) : Promise.resolve(void 0)
2705
3134
  ]);
2706
- return {
3135
+ return withComposedRateLimit({
2707
3136
  pullRequest,
2708
3137
  ...files !== void 0 ? { files } : {},
2709
3138
  ...reviews !== void 0 ? { reviews } : {},
2710
3139
  ...checks !== void 0 ? { checks } : {}
2711
- };
3140
+ });
2712
3141
  }
2713
3142
  const getIssueContextInputSchema = z.object({
2714
3143
  owner: z.string().describe("Repository owner"),
@@ -2746,11 +3175,11 @@ async function getIssueContextCore({ token, owner, repo, issueNumber, includeLab
2746
3175
  detail
2747
3176
  }) : Promise.resolve(void 0)
2748
3177
  ]);
2749
- return {
3178
+ return withComposedRateLimit({
2750
3179
  issue,
2751
3180
  ...labels !== void 0 ? { labelNames: labels.map((label) => label.name) } : {},
2752
3181
  ...comments !== void 0 ? { comments } : {}
2753
- };
3182
+ });
2754
3183
  }
2755
3184
  const getReleaseContextInputSchema = z.object({
2756
3185
  owner: z.string().describe("Repository owner"),
@@ -2792,11 +3221,11 @@ async function getReleaseContextCore({ token, owner, repo, releaseId, includePre
2792
3221
  head: release.tagName,
2793
3222
  includePatch: false
2794
3223
  });
2795
- return {
3224
+ return withComposedRateLimit({
2796
3225
  release,
2797
3226
  ...previous !== void 0 ? { previousRelease: previous } : {},
2798
3227
  ...comparison !== void 0 ? { comparison } : {}
2799
- };
3228
+ });
2800
3229
  }
2801
3230
  const getCiFailureContextInputSchema = z.object({
2802
3231
  owner: z.string().describe("Repository owner"),
@@ -2864,14 +3293,14 @@ async function getCiFailureContextCore({ token, owner, repo, ref, maxFailedRuns,
2864
3293
  steps: job.steps?.filter((step) => step.conclusion != null && FAILURE_CONCLUSIONS.has(step.conclusion))
2865
3294
  }))
2866
3295
  };
2867
- return {
3296
+ return withComposedRateLimit({
2868
3297
  ref,
2869
3298
  combinedStatus,
2870
3299
  failedCheckRuns,
2871
3300
  checkRunTotalCount: checkRunsResult.totalCount,
2872
3301
  recentFailedRuns: failedRuns.runs,
2873
3302
  ...latestFailure !== void 0 ? { latestFailure } : {}
2874
- };
3303
+ });
2875
3304
  }
2876
3305
  //#endregion
2877
3306
  //#region src/core/context.ts
@@ -2969,10 +3398,10 @@ const PRESET_TOOLS = {
2969
3398
  /**
2970
3399
  * **Code review** — review pull requests and submit feedback.
2971
3400
  *
2972
- * Tools: `getPullRequest`, `listPullRequests`, `listPullRequestFiles`, `listPullRequestReviews`, `getPullRequestContext`,
3401
+ * Tools: `getPullRequest`, `listPullRequests`, `listPullRequestFiles`, `listPullRequestReviews`, `listPullRequestReviewThreads`, `getPullRequestContext`,
2973
3402
  * `getFileContent`, `listCommits`, `getCommit`, `getBlame`, `compareCommits`, `getRepository`, `listBranches`,
2974
3403
  * `searchCode`, `listCheckRuns`, `getCombinedStatus`, `updatePullRequest`, `addPullRequestComment`, `updatePullRequestComment`,
2975
- * `deletePullRequestComment`, `createPullRequestReview`, `requestReviewers`.
3404
+ * `deletePullRequestComment`, `createPullRequestReview`, `replyToReviewComment`, `resolveReviewThread`, `requestReviewers`.
2976
3405
  *
2977
3406
  * Agent prompt: optimized for thorough PR review with inline feedback.
2978
3407
  */
@@ -2981,6 +3410,7 @@ const PRESET_TOOLS = {
2981
3410
  "listPullRequests",
2982
3411
  "listPullRequestFiles",
2983
3412
  "listPullRequestReviews",
3413
+ "listPullRequestReviewThreads",
2984
3414
  "getPullRequestContext",
2985
3415
  "getFileContent",
2986
3416
  "listCommits",
@@ -2997,6 +3427,8 @@ const PRESET_TOOLS = {
2997
3427
  "updatePullRequestComment",
2998
3428
  "deletePullRequestComment",
2999
3429
  "createPullRequestReview",
3430
+ "replyToReviewComment",
3431
+ "resolveReviewThread",
3000
3432
  "requestReviewers"
3001
3433
  ],
3002
3434
  /**
@@ -3044,9 +3476,10 @@ const PRESET_TOOLS = {
3044
3476
  * **CI operations** — monitor and manage GitHub Actions workflows.
3045
3477
  *
3046
3478
  * Tools: `getRepository`, `listBranches`, `listCommits`, `getCommit`,
3047
- * `listWorkflows`, `listWorkflowRuns`, `getWorkflowRun`, `listWorkflowJobs`, `listCheckRuns`, `getCombinedStatus`, `getCiFailureContext`,
3479
+ * `listWorkflows`, `listWorkflowRuns`, `getWorkflowRun`, `listWorkflowJobs`, `getWorkflowJobLogs`, `listCheckRuns`, `getCombinedStatus`, `getCiFailureContext`,
3048
3480
  * `triggerWorkflow`, `cancelWorkflowRun`, `rerunWorkflowRun`.
3049
3481
  *
3482
+ * Diagnose a failure with `getCiFailureContext` first, then read the failing job's output with `getWorkflowJobLogs`.
3050
3483
  * Agent prompt: optimized for diagnosing CI failures and managing workflow runs.
3051
3484
  */
3052
3485
  "ci-ops": [
@@ -3058,6 +3491,7 @@ const PRESET_TOOLS = {
3058
3491
  "listWorkflowRuns",
3059
3492
  "getWorkflowRun",
3060
3493
  "listWorkflowJobs",
3494
+ "getWorkflowJobLogs",
3061
3495
  "listCheckRuns",
3062
3496
  "getCombinedStatus",
3063
3497
  "getCiFailureContext",
@@ -3082,6 +3516,7 @@ const PRESET_TOOLS = {
3082
3516
  "getPullRequest",
3083
3517
  "listPullRequestFiles",
3084
3518
  "listPullRequestReviews",
3519
+ "listPullRequestReviewThreads",
3085
3520
  "getPullRequestContext",
3086
3521
  "listIssues",
3087
3522
  "getIssue",
@@ -3104,6 +3539,7 @@ const PRESET_TOOLS = {
3104
3539
  "listWorkflowRuns",
3105
3540
  "getWorkflowRun",
3106
3541
  "listWorkflowJobs",
3542
+ "getWorkflowJobLogs",
3107
3543
  "listCheckRuns",
3108
3544
  "getCombinedStatus",
3109
3545
  "getCiFailureContext",
@@ -3118,7 +3554,8 @@ const PRESET_TOOLS = {
3118
3554
  * Tools: read-only exploration (`getFileContent`, `getRepositoryTree`, `searchCode`, `searchIssues`, `listCommits`, `getCommit`,
3119
3555
  * `getBlame`, `compareCommits`), PR and CI visibility (`listPullRequests`, `getPullRequest`, `listPullRequestFiles`,
3120
3556
  * `getPullRequestContext`, `listCheckRuns`, `getCombinedStatus`, `getCiFailureContext`, `listWorkflows`, `listWorkflowRuns`,
3121
- * `getWorkflowRun`, `listWorkflowJobs`), plus `createIssue`, `addIssueComment`, and `addLabels` to report findings.
3557
+ * `getWorkflowRun`, `listWorkflowJobs`, `getWorkflowJobLogs` — logs can leak secrets, so auditing them matters),
3558
+ * plus `createIssue`, `addIssueComment`, and `addLabels` to report findings.
3122
3559
  * No destructive writes.
3123
3560
  *
3124
3561
  * Agent prompt: optimized for finding and reporting security risks without making changes.
@@ -3146,6 +3583,7 @@ const PRESET_TOOLS = {
3146
3583
  "listWorkflowRuns",
3147
3584
  "getWorkflowRun",
3148
3585
  "listWorkflowJobs",
3586
+ "getWorkflowJobLogs",
3149
3587
  "listIssues",
3150
3588
  "getIssue",
3151
3589
  "getIssueContext",
@@ -3220,10 +3658,12 @@ const PRESET_TOOLS = {
3220
3658
  /**
3221
3659
  * **PR author** — open pull requests without the full write surface.
3222
3660
  *
3223
- * Tools: `getRepository`, `listBranches`, `getFileContent`, `createBranch`, `createOrUpdateFile`,
3661
+ * Tools: `getRepository`, `listBranches`, `getFileContent`, `createBranch`, `deleteBranch`, `createOrUpdateFile`,
3224
3662
  * `createPullRequest`, `updatePullRequest`, `getPullRequest`, `listPullRequestFiles`,
3663
+ * `listPullRequestReviewThreads`, `replyToReviewComment`, `resolveReviewThread`,
3225
3664
  * `compareCommits`, `getCommit`.
3226
3665
  *
3666
+ * Respond to review feedback with `listPullRequestReviewThreads` → `replyToReviewComment` → `resolveReviewThread`.
3227
3667
  * Agent prompt: optimized for branching, editing files, and opening focused PRs.
3228
3668
  */
3229
3669
  "pr-author": [
@@ -3231,11 +3671,15 @@ const PRESET_TOOLS = {
3231
3671
  "listBranches",
3232
3672
  "getFileContent",
3233
3673
  "createBranch",
3674
+ "deleteBranch",
3234
3675
  "createOrUpdateFile",
3235
3676
  "createPullRequest",
3236
3677
  "updatePullRequest",
3237
3678
  "getPullRequest",
3238
3679
  "listPullRequestFiles",
3680
+ "listPullRequestReviewThreads",
3681
+ "replyToReviewComment",
3682
+ "resolveReviewThread",
3239
3683
  "compareCommits",
3240
3684
  "getCommit"
3241
3685
  ],
@@ -3252,6 +3696,7 @@ const PRESET_TOOLS = {
3252
3696
  "getFileContent",
3253
3697
  "getRepositoryTree",
3254
3698
  "createBranch",
3699
+ "deleteBranch",
3255
3700
  "forkRepository",
3256
3701
  "createRepository",
3257
3702
  "createOrUpdateFile",
@@ -3259,6 +3704,7 @@ const PRESET_TOOLS = {
3259
3704
  "getPullRequest",
3260
3705
  "listPullRequestFiles",
3261
3706
  "listPullRequestReviews",
3707
+ "listPullRequestReviewThreads",
3262
3708
  "getPullRequestContext",
3263
3709
  "createPullRequest",
3264
3710
  "mergePullRequest",
@@ -3267,6 +3713,8 @@ const PRESET_TOOLS = {
3267
3713
  "updatePullRequestComment",
3268
3714
  "deletePullRequestComment",
3269
3715
  "createPullRequestReview",
3716
+ "replyToReviewComment",
3717
+ "resolveReviewThread",
3270
3718
  "requestReviewers",
3271
3719
  "listIssues",
3272
3720
  "getIssue",
@@ -3313,6 +3761,7 @@ const PRESET_TOOLS = {
3313
3761
  "listWorkflowRuns",
3314
3762
  "getWorkflowRun",
3315
3763
  "listWorkflowJobs",
3764
+ "getWorkflowJobLogs",
3316
3765
  "triggerWorkflow",
3317
3766
  "cancelWorkflowRun",
3318
3767
  "rerunWorkflowRun",
@@ -3342,260 +3791,924 @@ function resolvePresetTools(preset) {
3342
3791
  return tools;
3343
3792
  }
3344
3793
  //#endregion
3345
- //#region src/core/tool-names.ts
3794
+ //#region src/core/catalog.ts
3795
+ /**
3796
+ * Vercel Connect scope sets, mirroring GitHub App permissions.
3797
+ * Release tools fall under `contents`, reaction tools under `issues`.
3798
+ * Gist and notification tools are intentionally unscoped: those APIs only
3799
+ * accept user access tokens, never the installation tokens Connect mints.
3800
+ */
3801
+ const CONTENTS_READ = ["contents:read", "metadata:read"];
3802
+ const CONTENTS_WRITE = [
3803
+ "contents:read",
3804
+ "contents:write",
3805
+ "metadata:read"
3806
+ ];
3807
+ const PR_READ = [
3808
+ "contents:read",
3809
+ "metadata:read",
3810
+ "pull_requests:read"
3811
+ ];
3812
+ const PR_WRITE = [
3813
+ "contents:read",
3814
+ "metadata:read",
3815
+ "pull_requests:read",
3816
+ "pull_requests:write"
3817
+ ];
3818
+ /** Read-only PR context (details, files, reviews) plus optional CI checks. */
3819
+ const PR_CONTEXT = [
3820
+ "contents:read",
3821
+ "metadata:read",
3822
+ "pull_requests:read",
3823
+ "checks:read",
3824
+ "statuses:read"
3825
+ ];
3826
+ const ISSUES_READ = [
3827
+ "contents:read",
3828
+ "metadata:read",
3829
+ "issues:read"
3830
+ ];
3831
+ const ISSUES_WRITE = [
3832
+ "contents:read",
3833
+ "metadata:read",
3834
+ "issues:read",
3835
+ "issues:write"
3836
+ ];
3837
+ const DISCUSSIONS_READ = [
3838
+ "contents:read",
3839
+ "metadata:read",
3840
+ "discussions:read"
3841
+ ];
3842
+ const DISCUSSIONS_WRITE = [
3843
+ "contents:read",
3844
+ "metadata:read",
3845
+ "discussions:read",
3846
+ "discussions:write"
3847
+ ];
3848
+ const ACTIONS_READ = [
3849
+ "contents:read",
3850
+ "metadata:read",
3851
+ "actions:read"
3852
+ ];
3853
+ const ACTIONS_WRITE = [
3854
+ "contents:read",
3855
+ "metadata:read",
3856
+ "actions:read",
3857
+ "actions:write"
3858
+ ];
3859
+ const CHECKS = [
3860
+ "contents:read",
3861
+ "metadata:read",
3862
+ "checks:read",
3863
+ "statuses:read"
3864
+ ];
3865
+ const CI_CONTEXT = [
3866
+ "contents:read",
3867
+ "metadata:read",
3868
+ "actions:read",
3869
+ "checks:read",
3870
+ "statuses:read"
3871
+ ];
3872
+ const ADMIN = [
3873
+ "metadata:read",
3874
+ "administration:read",
3875
+ "administration:write"
3876
+ ];
3877
+ const SEARCH_REPOS = ["metadata:read"];
3878
+ const SEARCH_ISSUES = [
3879
+ "metadata:read",
3880
+ "issues:read",
3881
+ "pull_requests:read"
3882
+ ];
3883
+ const UNSCOPED = [];
3346
3884
  /**
3347
- * All GitHub tool names available via {@link createGithubTools}.
3348
- * Each key maps to its own string literal for IDE autocomplete and hover docs.
3885
+ * Single source of truth for every GitHub tool.
3886
+ *
3887
+ * `GITHUB_TOOL_NAMES`, `GITHUB_WRITE_TOOLS`, `TOOL_CONNECT_SCOPES`, and the
3888
+ * eve tool registry are all derived from this catalog. Adding a tool here (plus
3889
+ * its `"use step"` factory in `src/tools/` and `allTools` in `src/index.ts`,
3890
+ * both enforced at compile time) is the only registration needed.
3349
3891
  */
3350
- const GITHUB_TOOL_NAMES = {
3892
+ const GITHUB_TOOL_CATALOG = {
3351
3893
  /** Get information about a GitHub repository including description, stars, forks, language, and default branch. */
3352
- getRepository: "getRepository",
3894
+ getRepository: {
3895
+ description: getRepositoryDescription,
3896
+ inputSchema: getRepositoryInputSchema,
3897
+ get core() {
3898
+ return getRepositoryCore;
3899
+ },
3900
+ connectScopes: CONTENTS_READ
3901
+ },
3353
3902
  /** List branches in a GitHub repository. */
3354
- listBranches: "listBranches",
3903
+ listBranches: {
3904
+ description: listBranchesDescription,
3905
+ inputSchema: listBranchesInputSchema,
3906
+ get core() {
3907
+ return listBranchesCore;
3908
+ },
3909
+ connectScopes: CONTENTS_READ
3910
+ },
3355
3911
  /** Get the content of a file from a GitHub repository. Prefer startLine/endLine or maxLines for large files. */
3356
- getFileContent: "getFileContent",
3912
+ getFileContent: {
3913
+ description: getFileContentDescription,
3914
+ inputSchema: getFileContentInputSchema,
3915
+ get core() {
3916
+ return getFileContentCore;
3917
+ },
3918
+ connectScopes: CONTENTS_READ
3919
+ },
3357
3920
  /** List the file and directory structure of a repository at a given ref. */
3358
- getRepositoryTree: "getRepositoryTree",
3921
+ getRepositoryTree: {
3922
+ description: getRepositoryTreeDescription,
3923
+ inputSchema: getRepositoryTreeInputSchema,
3924
+ get core() {
3925
+ return getRepositoryTreeCore;
3926
+ },
3927
+ connectScopes: CONTENTS_READ
3928
+ },
3359
3929
  /** Create a new branch in a GitHub repository from an existing branch or commit SHA. Requires approval by default. */
3360
- createBranch: "createBranch",
3930
+ createBranch: {
3931
+ description: createBranchDescription,
3932
+ inputSchema: createBranchInputSchema,
3933
+ get core() {
3934
+ return createBranchCore;
3935
+ },
3936
+ write: true,
3937
+ connectScopes: CONTENTS_WRITE
3938
+ },
3939
+ /** Delete a branch from a GitHub repository permanently. Requires approval by default. */
3940
+ deleteBranch: {
3941
+ description: deleteBranchDescription,
3942
+ inputSchema: deleteBranchInputSchema,
3943
+ get core() {
3944
+ return deleteBranchCore;
3945
+ },
3946
+ write: true,
3947
+ connectScopes: CONTENTS_WRITE
3948
+ },
3361
3949
  /** Fork a GitHub repository to the authenticated user account or a specified organization. Requires approval by default. */
3362
- forkRepository: "forkRepository",
3950
+ forkRepository: {
3951
+ description: forkRepositoryDescription,
3952
+ inputSchema: forkRepositoryInputSchema,
3953
+ get core() {
3954
+ return forkRepositoryCore;
3955
+ },
3956
+ write: true,
3957
+ connectScopes: CONTENTS_READ
3958
+ },
3363
3959
  /** Create a new GitHub repository for the authenticated user or a specified organization. Requires approval by default. */
3364
- createRepository: "createRepository",
3960
+ createRepository: {
3961
+ description: createRepositoryDescription,
3962
+ inputSchema: createRepositoryInputSchema,
3963
+ get core() {
3964
+ return createRepositoryCore;
3965
+ },
3966
+ write: true,
3967
+ connectScopes: ADMIN
3968
+ },
3365
3969
  /** Create or update a file in a GitHub repository. Provide the SHA when updating an existing file. Requires approval by default. */
3366
- createOrUpdateFile: "createOrUpdateFile",
3970
+ createOrUpdateFile: {
3971
+ description: createOrUpdateFileDescription,
3972
+ inputSchema: createOrUpdateFileInputSchema,
3973
+ get core() {
3974
+ return createOrUpdateFileCore;
3975
+ },
3976
+ write: true,
3977
+ connectScopes: CONTENTS_WRITE
3978
+ },
3367
3979
  /** List pull requests for a GitHub repository. */
3368
- listPullRequests: "listPullRequests",
3980
+ listPullRequests: {
3981
+ description: listPullRequestsDescription,
3982
+ inputSchema: listPullRequestsInputSchema,
3983
+ get core() {
3984
+ return listPullRequestsCore;
3985
+ },
3986
+ connectScopes: PR_READ
3987
+ },
3369
3988
  /** Get detailed information about a specific pull request. Body truncated by default (detail: summary). */
3370
- getPullRequest: "getPullRequest",
3989
+ getPullRequest: {
3990
+ description: getPullRequestDescription,
3991
+ inputSchema: getPullRequestInputSchema,
3992
+ get core() {
3993
+ return getPullRequestCore;
3994
+ },
3995
+ connectScopes: PR_READ
3996
+ },
3371
3997
  /** Create a new pull request in a GitHub repository. Requires approval by default. */
3372
- createPullRequest: "createPullRequest",
3998
+ createPullRequest: {
3999
+ description: createPullRequestDescription,
4000
+ inputSchema: createPullRequestInputSchema,
4001
+ get core() {
4002
+ return createPullRequestCore;
4003
+ },
4004
+ write: true,
4005
+ connectScopes: PR_WRITE
4006
+ },
3373
4007
  /** Merge a pull request. Requires approval by default. */
3374
- mergePullRequest: "mergePullRequest",
4008
+ mergePullRequest: {
4009
+ description: mergePullRequestDescription,
4010
+ inputSchema: mergePullRequestInputSchema,
4011
+ get core() {
4012
+ return mergePullRequestCore;
4013
+ },
4014
+ write: true,
4015
+ connectScopes: PR_WRITE
4016
+ },
3375
4017
  /** Update a pull request — title, body, state, base branch, or draft status. Requires approval by default. */
3376
- updatePullRequest: "updatePullRequest",
4018
+ updatePullRequest: {
4019
+ description: updatePullRequestDescription,
4020
+ inputSchema: updatePullRequestInputSchema,
4021
+ get core() {
4022
+ return updatePullRequestCore;
4023
+ },
4024
+ write: true,
4025
+ connectScopes: PR_WRITE
4026
+ },
3377
4027
  /** Add a comment to a pull request. Requires approval by default. */
3378
- addPullRequestComment: "addPullRequestComment",
4028
+ addPullRequestComment: {
4029
+ description: addPullRequestCommentDescription,
4030
+ inputSchema: addPullRequestCommentInputSchema,
4031
+ get core() {
4032
+ return addPullRequestCommentCore;
4033
+ },
4034
+ write: true,
4035
+ connectScopes: PR_WRITE
4036
+ },
3379
4037
  /** Update the body of a comment on a pull request. Requires approval by default. */
3380
- updatePullRequestComment: "updatePullRequestComment",
4038
+ updatePullRequestComment: {
4039
+ description: updatePullRequestCommentDescription,
4040
+ inputSchema: updatePullRequestCommentInputSchema,
4041
+ get core() {
4042
+ return updatePullRequestCommentCore;
4043
+ },
4044
+ write: true,
4045
+ connectScopes: PR_WRITE
4046
+ },
3381
4047
  /** Delete a comment from a pull request permanently. Requires approval by default. */
3382
- deletePullRequestComment: "deletePullRequestComment",
4048
+ deletePullRequestComment: {
4049
+ description: deletePullRequestCommentDescription,
4050
+ inputSchema: deletePullRequestCommentInputSchema,
4051
+ get core() {
4052
+ return deletePullRequestCommentCore;
4053
+ },
4054
+ write: true,
4055
+ connectScopes: PR_WRITE
4056
+ },
3383
4057
  /** List files changed in a pull request with status and stats. Patches omitted by default — set includePatch true for diffs. */
3384
- listPullRequestFiles: "listPullRequestFiles",
4058
+ listPullRequestFiles: {
4059
+ description: listPullRequestFilesDescription,
4060
+ inputSchema: listPullRequestFilesInputSchema,
4061
+ get core() {
4062
+ return listPullRequestFilesCore;
4063
+ },
4064
+ connectScopes: PR_READ
4065
+ },
3385
4066
  /** List reviews on a pull request (approvals, change requests, and comments). */
3386
- listPullRequestReviews: "listPullRequestReviews",
4067
+ listPullRequestReviews: {
4068
+ description: listPullRequestReviewsDescription,
4069
+ inputSchema: listPullRequestReviewsInputSchema,
4070
+ get core() {
4071
+ return listPullRequestReviewsCore;
4072
+ },
4073
+ connectScopes: PR_READ
4074
+ },
3387
4075
  /** Submit a pull request review — approve, request changes, or comment with optional inline comments on specific lines. Requires approval by default. */
3388
- createPullRequestReview: "createPullRequestReview",
4076
+ createPullRequestReview: {
4077
+ description: createPullRequestReviewDescription,
4078
+ inputSchema: createPullRequestReviewInputSchema,
4079
+ get core() {
4080
+ return createPullRequestReviewCore;
4081
+ },
4082
+ write: true,
4083
+ connectScopes: PR_WRITE
4084
+ },
4085
+ /** List review threads on a pull request with comments, resolution state, and the IDs needed to reply or resolve. Unresolved only by default. */
4086
+ listPullRequestReviewThreads: {
4087
+ description: listPullRequestReviewThreadsDescription,
4088
+ inputSchema: listPullRequestReviewThreadsInputSchema,
4089
+ get core() {
4090
+ return listPullRequestReviewThreadsCore;
4091
+ },
4092
+ connectScopes: PR_READ
4093
+ },
4094
+ /** Reply to a pull request review comment in its review thread. Requires approval by default. */
4095
+ replyToReviewComment: {
4096
+ description: replyToReviewCommentDescription,
4097
+ inputSchema: replyToReviewCommentInputSchema,
4098
+ get core() {
4099
+ return replyToReviewCommentCore;
4100
+ },
4101
+ write: true,
4102
+ connectScopes: PR_WRITE
4103
+ },
4104
+ /** Mark a pull request review thread as resolved. Requires approval by default. */
4105
+ resolveReviewThread: {
4106
+ description: resolveReviewThreadDescription,
4107
+ inputSchema: resolveReviewThreadInputSchema,
4108
+ get core() {
4109
+ return resolveReviewThreadCore;
4110
+ },
4111
+ write: true,
4112
+ connectScopes: PR_WRITE
4113
+ },
3389
4114
  /** Request reviews from users or teams on a pull request. Requires approval by default. */
3390
- requestReviewers: "requestReviewers",
4115
+ requestReviewers: {
4116
+ description: requestReviewersDescription,
4117
+ inputSchema: requestReviewersInputSchema,
4118
+ get core() {
4119
+ return requestReviewersCore;
4120
+ },
4121
+ write: true,
4122
+ connectScopes: PR_WRITE
4123
+ },
3391
4124
  /** Fetch pull request details plus files, reviews, and optional CI checks in one call. */
3392
- getPullRequestContext: "getPullRequestContext",
4125
+ getPullRequestContext: {
4126
+ description: getPullRequestContextDescription,
4127
+ inputSchema: getPullRequestContextInputSchema,
4128
+ get core() {
4129
+ return getPullRequestContextCore;
4130
+ },
4131
+ connectScopes: PR_CONTEXT
4132
+ },
4133
+ /** Fetch an issue plus available label names and recent comments in one call. */
4134
+ getIssueContext: {
4135
+ description: getIssueContextDescription,
4136
+ inputSchema: getIssueContextInputSchema,
4137
+ get core() {
4138
+ return getIssueContextCore;
4139
+ },
4140
+ connectScopes: ISSUES_READ
4141
+ },
3393
4142
  /** List issues for a GitHub repository (excludes pull requests). */
3394
- listIssues: "listIssues",
4143
+ listIssues: {
4144
+ description: listIssuesDescription,
4145
+ inputSchema: listIssuesInputSchema,
4146
+ get core() {
4147
+ return listIssuesCore;
4148
+ },
4149
+ connectScopes: ISSUES_READ
4150
+ },
3395
4151
  /** Get detailed information about a specific issue. Body truncated by default (detail: summary). */
3396
- getIssue: "getIssue",
3397
- /** Fetch an issue plus available label names and recent comments in one call. */
3398
- getIssueContext: "getIssueContext",
4152
+ getIssue: {
4153
+ description: getIssueDescription,
4154
+ inputSchema: getIssueInputSchema,
4155
+ get core() {
4156
+ return getIssueCore;
4157
+ },
4158
+ connectScopes: ISSUES_READ
4159
+ },
3399
4160
  /** List comments on a GitHub issue. Bodies are truncated by default (detail: summary). Prefer getIssueContext for the first page when triaging. */
3400
- listIssueComments: "listIssueComments",
4161
+ listIssueComments: {
4162
+ description: listIssueCommentsDescription,
4163
+ inputSchema: listIssueCommentsInputSchema,
4164
+ get core() {
4165
+ return listIssueCommentsCore;
4166
+ },
4167
+ connectScopes: ISSUES_READ
4168
+ },
3401
4169
  /** Create a new issue in a GitHub repository. Requires approval by default. */
3402
- createIssue: "createIssue",
4170
+ createIssue: {
4171
+ description: createIssueDescription,
4172
+ inputSchema: createIssueInputSchema,
4173
+ get core() {
4174
+ return createIssueCore;
4175
+ },
4176
+ write: true,
4177
+ connectScopes: ISSUES_WRITE
4178
+ },
3403
4179
  /** Add a comment to a GitHub issue. Requires approval by default. */
3404
- addIssueComment: "addIssueComment",
4180
+ addIssueComment: {
4181
+ description: addIssueCommentDescription,
4182
+ inputSchema: addIssueCommentInputSchema,
4183
+ get core() {
4184
+ return addIssueCommentCore;
4185
+ },
4186
+ write: true,
4187
+ connectScopes: ISSUES_WRITE
4188
+ },
3405
4189
  /** Update the body of a comment on a GitHub issue. Requires approval by default. */
3406
- updateIssueComment: "updateIssueComment",
4190
+ updateIssueComment: {
4191
+ description: updateIssueCommentDescription,
4192
+ inputSchema: updateIssueCommentInputSchema,
4193
+ get core() {
4194
+ return updateIssueCommentCore;
4195
+ },
4196
+ write: true,
4197
+ connectScopes: ISSUES_WRITE
4198
+ },
3407
4199
  /** Delete a comment from a GitHub issue permanently. Requires approval by default. */
3408
- deleteIssueComment: "deleteIssueComment",
4200
+ deleteIssueComment: {
4201
+ description: deleteIssueCommentDescription,
4202
+ inputSchema: deleteIssueCommentInputSchema,
4203
+ get core() {
4204
+ return deleteIssueCommentCore;
4205
+ },
4206
+ write: true,
4207
+ connectScopes: ISSUES_WRITE
4208
+ },
3409
4209
  /** Close an open GitHub issue. Requires approval by default. */
3410
- closeIssue: "closeIssue",
4210
+ closeIssue: {
4211
+ description: closeIssueDescription,
4212
+ inputSchema: closeIssueInputSchema,
4213
+ get core() {
4214
+ return closeIssueCore;
4215
+ },
4216
+ write: true,
4217
+ connectScopes: ISSUES_WRITE
4218
+ },
3411
4219
  /** Update a GitHub issue — title, body, state, labels, milestone, or assignees. Requires approval by default. */
3412
- updateIssue: "updateIssue",
4220
+ updateIssue: {
4221
+ description: updateIssueDescription,
4222
+ inputSchema: updateIssueInputSchema,
4223
+ get core() {
4224
+ return updateIssueCore;
4225
+ },
4226
+ write: true,
4227
+ connectScopes: ISSUES_WRITE
4228
+ },
3413
4229
  /** List labels available in a GitHub repository. */
3414
- listLabels: "listLabels",
4230
+ listLabels: {
4231
+ description: listLabelsDescription,
4232
+ inputSchema: listLabelsInputSchema,
4233
+ get core() {
4234
+ return listLabelsCore;
4235
+ },
4236
+ connectScopes: ISSUES_READ
4237
+ },
3415
4238
  /** Add labels to an issue or pull request. Requires approval by default. */
3416
- addLabels: "addLabels",
4239
+ addLabels: {
4240
+ description: addLabelsDescription,
4241
+ inputSchema: addLabelsInputSchema,
4242
+ get core() {
4243
+ return addLabelsCore;
4244
+ },
4245
+ write: true,
4246
+ connectScopes: ISSUES_WRITE
4247
+ },
3417
4248
  /** Remove a label from an issue or pull request. Requires approval by default. */
3418
- removeLabel: "removeLabel",
4249
+ removeLabel: {
4250
+ description: removeLabelDescription,
4251
+ inputSchema: removeLabelInputSchema,
4252
+ get core() {
4253
+ return removeLabelCore;
4254
+ },
4255
+ write: true,
4256
+ connectScopes: ISSUES_WRITE
4257
+ },
3419
4258
  /** Create a label in a GitHub repository. Requires approval by default. */
3420
- createLabel: "createLabel",
4259
+ createLabel: {
4260
+ description: createLabelDescription,
4261
+ inputSchema: createLabelInputSchema,
4262
+ get core() {
4263
+ return createLabelCore;
4264
+ },
4265
+ write: true,
4266
+ connectScopes: ISSUES_WRITE
4267
+ },
3421
4268
  /** Update a label in a GitHub repository — name, color, or description. Requires approval by default. */
3422
- updateLabel: "updateLabel",
4269
+ updateLabel: {
4270
+ description: updateLabelDescription,
4271
+ inputSchema: updateLabelInputSchema,
4272
+ get core() {
4273
+ return updateLabelCore;
4274
+ },
4275
+ write: true,
4276
+ connectScopes: ISSUES_WRITE
4277
+ },
3423
4278
  /** Delete a label from a GitHub repository permanently. Requires approval by default. */
3424
- deleteLabel: "deleteLabel",
4279
+ deleteLabel: {
4280
+ description: deleteLabelDescription,
4281
+ inputSchema: deleteLabelInputSchema,
4282
+ get core() {
4283
+ return deleteLabelCore;
4284
+ },
4285
+ write: true,
4286
+ connectScopes: ISSUES_WRITE
4287
+ },
3425
4288
  /** Assign users to an issue or pull request. Requires approval by default. */
3426
- addAssignees: "addAssignees",
4289
+ addAssignees: {
4290
+ description: addAssigneesDescription,
4291
+ inputSchema: addAssigneesInputSchema,
4292
+ get core() {
4293
+ return addAssigneesCore;
4294
+ },
4295
+ write: true,
4296
+ connectScopes: ISSUES_WRITE
4297
+ },
3427
4298
  /** Remove assignees from an issue or pull request. Requires approval by default. */
3428
- removeAssignees: "removeAssignees",
4299
+ removeAssignees: {
4300
+ description: removeAssigneesDescription,
4301
+ inputSchema: removeAssigneesInputSchema,
4302
+ get core() {
4303
+ return removeAssigneesCore;
4304
+ },
4305
+ write: true,
4306
+ connectScopes: ISSUES_WRITE
4307
+ },
4308
+ /** List reactions on an issue or pull request conversation, with per-emoji counts. */
4309
+ listIssueReactions: {
4310
+ description: listIssueReactionsDescription,
4311
+ inputSchema: listIssueReactionsInputSchema,
4312
+ get core() {
4313
+ return listIssueReactionsCore;
4314
+ },
4315
+ connectScopes: ISSUES_READ
4316
+ },
4317
+ /** React to an issue or pull request with an emoji. Requires approval by default. */
4318
+ addIssueReaction: {
4319
+ description: addIssueReactionDescription,
4320
+ inputSchema: addIssueReactionInputSchema,
4321
+ get core() {
4322
+ return addIssueReactionCore;
4323
+ },
4324
+ write: true,
4325
+ connectScopes: ISSUES_WRITE
4326
+ },
4327
+ /** List reactions on an issue or pull request comment, with per-emoji counts. */
4328
+ listCommentReactions: {
4329
+ description: listCommentReactionsDescription,
4330
+ inputSchema: listCommentReactionsInputSchema,
4331
+ get core() {
4332
+ return listCommentReactionsCore;
4333
+ },
4334
+ connectScopes: ISSUES_READ
4335
+ },
4336
+ /** React to an issue or pull request comment with an emoji. Requires approval by default. */
4337
+ addCommentReaction: {
4338
+ description: addCommentReactionDescription,
4339
+ inputSchema: addCommentReactionInputSchema,
4340
+ get core() {
4341
+ return addCommentReactionCore;
4342
+ },
4343
+ write: true,
4344
+ connectScopes: ISSUES_WRITE
4345
+ },
4346
+ /** List discussions in a GitHub repository, most recently updated first, optionally filtered by category. */
4347
+ listDiscussions: {
4348
+ description: listDiscussionsDescription,
4349
+ inputSchema: listDiscussionsInputSchema,
4350
+ get core() {
4351
+ return listDiscussionsCore;
4352
+ },
4353
+ connectScopes: DISCUSSIONS_READ
4354
+ },
4355
+ /** Get a GitHub discussion by number. Body truncated by default (detail: summary). */
4356
+ getDiscussion: {
4357
+ description: getDiscussionDescription,
4358
+ inputSchema: getDiscussionInputSchema,
4359
+ get core() {
4360
+ return getDiscussionCore;
4361
+ },
4362
+ connectScopes: DISCUSSIONS_READ
4363
+ },
4364
+ /** Add a comment to a GitHub discussion. Requires approval by default. */
4365
+ addDiscussionComment: {
4366
+ description: addDiscussionCommentDescription,
4367
+ inputSchema: addDiscussionCommentInputSchema,
4368
+ get core() {
4369
+ return addDiscussionCommentCore;
4370
+ },
4371
+ write: true,
4372
+ connectScopes: DISCUSSIONS_WRITE
4373
+ },
4374
+ /** List notification threads for the authenticated user. Requires a token with notifications access. */
4375
+ listNotifications: {
4376
+ description: listNotificationsDescription,
4377
+ inputSchema: listNotificationsInputSchema,
4378
+ get core() {
4379
+ return listNotificationsCore;
4380
+ },
4381
+ connectScopes: UNSCOPED
4382
+ },
4383
+ /** Mark a single notification thread as read. Requires approval by default. */
4384
+ markNotificationRead: {
4385
+ description: markNotificationReadDescription,
4386
+ inputSchema: markNotificationReadInputSchema,
4387
+ get core() {
4388
+ return markNotificationReadCore;
4389
+ },
4390
+ write: true,
4391
+ connectScopes: UNSCOPED
4392
+ },
3429
4393
  /** 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. */
3430
- searchCode: "searchCode",
4394
+ searchCode: {
4395
+ description: searchCodeDescription,
4396
+ inputSchema: searchCodeInputSchema,
4397
+ get core() {
4398
+ return searchCodeCore;
4399
+ },
4400
+ connectScopes: CONTENTS_READ
4401
+ },
3431
4402
  /** Search for GitHub repositories by keyword, topic, language, or other qualifiers. */
3432
- searchRepositories: "searchRepositories",
4403
+ searchRepositories: {
4404
+ description: searchRepositoriesDescription,
4405
+ inputSchema: searchRepositoriesInputSchema,
4406
+ get core() {
4407
+ return searchRepositoriesCore;
4408
+ },
4409
+ connectScopes: SEARCH_REPOS
4410
+ },
3433
4411
  /** Search for issues and pull requests across GitHub using search qualifiers like "repo:owner/name is:open". */
3434
- searchIssues: "searchIssues",
4412
+ searchIssues: {
4413
+ description: searchIssuesDescription,
4414
+ inputSchema: searchIssuesInputSchema,
4415
+ get core() {
4416
+ return searchIssuesCore;
4417
+ },
4418
+ connectScopes: SEARCH_ISSUES
4419
+ },
3435
4420
  /** 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. */
3436
- listCommits: "listCommits",
4421
+ listCommits: {
4422
+ description: listCommitsDescription,
4423
+ inputSchema: listCommitsInputSchema,
4424
+ get core() {
4425
+ return listCommitsCore;
4426
+ },
4427
+ connectScopes: CONTENTS_READ
4428
+ },
3437
4429
  /** Get detailed information about a specific commit, including the list of files changed. Patches omitted by default. */
3438
- getCommit: "getCommit",
4430
+ getCommit: {
4431
+ description: getCommitDescription,
4432
+ inputSchema: getCommitInputSchema,
4433
+ get core() {
4434
+ return getCommitCore;
4435
+ },
4436
+ connectScopes: CONTENTS_READ
4437
+ },
3439
4438
  /** 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. */
3440
- getBlame: "getBlame",
4439
+ getBlame: {
4440
+ description: getBlameDescription,
4441
+ inputSchema: getBlameInputSchema,
4442
+ get core() {
4443
+ return getBlameCore;
4444
+ },
4445
+ connectScopes: CONTENTS_READ
4446
+ },
3441
4447
  /** Compare two branches, tags, or commits — ahead/behind counts, commits in between, and differing files. Patches omitted by default. */
3442
- compareCommits: "compareCommits",
4448
+ compareCommits: {
4449
+ description: compareCommitsDescription,
4450
+ inputSchema: compareCommitsInputSchema,
4451
+ get core() {
4452
+ return compareCommitsCore;
4453
+ },
4454
+ connectScopes: CONTENTS_READ
4455
+ },
3443
4456
  /** List gists for the authenticated user or a specific user. */
3444
- listGists: "listGists",
4457
+ listGists: {
4458
+ description: listGistsDescription,
4459
+ inputSchema: listGistsInputSchema,
4460
+ get core() {
4461
+ return listGistsCore;
4462
+ },
4463
+ connectScopes: UNSCOPED
4464
+ },
3445
4465
  /** Get a gist by ID, including file contents. */
3446
- getGist: "getGist",
4466
+ getGist: {
4467
+ description: getGistDescription,
4468
+ inputSchema: getGistInputSchema,
4469
+ get core() {
4470
+ return getGistCore;
4471
+ },
4472
+ connectScopes: UNSCOPED
4473
+ },
3447
4474
  /** List comments on a gist. */
3448
- listGistComments: "listGistComments",
4475
+ listGistComments: {
4476
+ description: listGistCommentsDescription,
4477
+ inputSchema: listGistCommentsInputSchema,
4478
+ get core() {
4479
+ return listGistCommentsCore;
4480
+ },
4481
+ connectScopes: UNSCOPED
4482
+ },
3449
4483
  /** Create a new gist with one or more files. Requires approval by default. */
3450
- createGist: "createGist",
4484
+ createGist: {
4485
+ description: createGistDescription,
4486
+ inputSchema: createGistInputSchema,
4487
+ get core() {
4488
+ return createGistCore;
4489
+ },
4490
+ write: true,
4491
+ connectScopes: UNSCOPED
4492
+ },
3451
4493
  /** Update an existing gist — edit description, update files, or remove files. Requires approval by default. */
3452
- updateGist: "updateGist",
4494
+ updateGist: {
4495
+ description: updateGistDescription,
4496
+ inputSchema: updateGistInputSchema,
4497
+ get core() {
4498
+ return updateGistCore;
4499
+ },
4500
+ write: true,
4501
+ connectScopes: UNSCOPED
4502
+ },
3453
4503
  /** Delete a gist permanently. Requires approval by default. */
3454
- deleteGist: "deleteGist",
4504
+ deleteGist: {
4505
+ description: deleteGistDescription,
4506
+ inputSchema: deleteGistInputSchema,
4507
+ get core() {
4508
+ return deleteGistCore;
4509
+ },
4510
+ write: true,
4511
+ connectScopes: UNSCOPED
4512
+ },
3455
4513
  /** Add a comment to a gist. Requires approval by default. */
3456
- createGistComment: "createGistComment",
4514
+ createGistComment: {
4515
+ description: createGistCommentDescription,
4516
+ inputSchema: createGistCommentInputSchema,
4517
+ get core() {
4518
+ return createGistCommentCore;
4519
+ },
4520
+ write: true,
4521
+ connectScopes: UNSCOPED
4522
+ },
3457
4523
  /** List GitHub Actions workflows in a repository. */
3458
- listWorkflows: "listWorkflows",
4524
+ listWorkflows: {
4525
+ description: listWorkflowsDescription,
4526
+ inputSchema: listWorkflowsInputSchema,
4527
+ get core() {
4528
+ return listWorkflowsCore;
4529
+ },
4530
+ connectScopes: ACTIONS_READ
4531
+ },
3459
4532
  /** List workflow runs for a repository, optionally filtered by workflow, branch, status, or event. */
3460
- listWorkflowRuns: "listWorkflowRuns",
4533
+ listWorkflowRuns: {
4534
+ description: listWorkflowRunsDescription,
4535
+ inputSchema: listWorkflowRunsInputSchema,
4536
+ get core() {
4537
+ return listWorkflowRunsCore;
4538
+ },
4539
+ connectScopes: ACTIONS_READ
4540
+ },
3461
4541
  /** Get details of a specific workflow run including status, timing, and trigger info. */
3462
- getWorkflowRun: "getWorkflowRun",
4542
+ getWorkflowRun: {
4543
+ description: getWorkflowRunDescription,
4544
+ inputSchema: getWorkflowRunInputSchema,
4545
+ get core() {
4546
+ return getWorkflowRunCore;
4547
+ },
4548
+ connectScopes: ACTIONS_READ
4549
+ },
3463
4550
  /** List jobs for a workflow run, including step-level status and timing. */
3464
- listWorkflowJobs: "listWorkflowJobs",
4551
+ listWorkflowJobs: {
4552
+ description: listWorkflowJobsDescription,
4553
+ inputSchema: listWorkflowJobsInputSchema,
4554
+ get core() {
4555
+ return listWorkflowJobsCore;
4556
+ },
4557
+ connectScopes: ACTIONS_READ
4558
+ },
4559
+ /** Get the log output of a workflow job to diagnose failures. Returns the tail (default 200 lines) with timestamps stripped. */
4560
+ getWorkflowJobLogs: {
4561
+ description: getWorkflowJobLogsDescription,
4562
+ inputSchema: getWorkflowJobLogsInputSchema,
4563
+ get core() {
4564
+ return getWorkflowJobLogsCore;
4565
+ },
4566
+ connectScopes: ACTIONS_READ
4567
+ },
3465
4568
  /** Trigger a workflow via workflow_dispatch event. Requires approval by default. */
3466
- triggerWorkflow: "triggerWorkflow",
4569
+ triggerWorkflow: {
4570
+ description: triggerWorkflowDescription,
4571
+ inputSchema: triggerWorkflowInputSchema,
4572
+ get core() {
4573
+ return triggerWorkflowCore;
4574
+ },
4575
+ write: true,
4576
+ connectScopes: ACTIONS_WRITE
4577
+ },
3467
4578
  /** Cancel an in-progress workflow run. Requires approval by default. */
3468
- cancelWorkflowRun: "cancelWorkflowRun",
4579
+ cancelWorkflowRun: {
4580
+ description: cancelWorkflowRunDescription,
4581
+ inputSchema: cancelWorkflowRunInputSchema,
4582
+ get core() {
4583
+ return cancelWorkflowRunCore;
4584
+ },
4585
+ write: true,
4586
+ connectScopes: ACTIONS_WRITE
4587
+ },
3469
4588
  /** Re-run a workflow run, optionally only the failed jobs. Requires approval by default. */
3470
- rerunWorkflowRun: "rerunWorkflowRun",
4589
+ rerunWorkflowRun: {
4590
+ description: rerunWorkflowRunDescription,
4591
+ inputSchema: rerunWorkflowRunInputSchema,
4592
+ get core() {
4593
+ return rerunWorkflowRunCore;
4594
+ },
4595
+ write: true,
4596
+ connectScopes: ACTIONS_WRITE
4597
+ },
3471
4598
  /** List check runs (Checks API — GitHub Actions and other CI providers) for a commit, branch, or tag. */
3472
- listCheckRuns: "listCheckRuns",
4599
+ listCheckRuns: {
4600
+ description: listCheckRunsDescription,
4601
+ inputSchema: listCheckRunsInputSchema,
4602
+ get core() {
4603
+ return listCheckRunsCore;
4604
+ },
4605
+ connectScopes: CHECKS
4606
+ },
3473
4607
  /** Get the combined commit status (Statuses API — legacy CI integrations) for a commit, branch, or tag. */
3474
- getCombinedStatus: "getCombinedStatus",
4608
+ getCombinedStatus: {
4609
+ description: getCombinedStatusDescription,
4610
+ inputSchema: getCombinedStatusInputSchema,
4611
+ get core() {
4612
+ return getCombinedStatusCore;
4613
+ },
4614
+ connectScopes: CHECKS
4615
+ },
3475
4616
  /** Diagnose CI failures for a ref — combined status, failing checks, and failed workflow jobs in one call. */
3476
- getCiFailureContext: "getCiFailureContext",
3477
- /** List discussions in a GitHub repository, most recently updated first, optionally filtered by category. */
3478
- listDiscussions: "listDiscussions",
3479
- /** Get a GitHub discussion by number. Body truncated by default (detail: summary). */
3480
- getDiscussion: "getDiscussion",
3481
- /** Add a comment to a GitHub discussion. Requires approval by default. */
3482
- addDiscussionComment: "addDiscussionComment",
3483
- /** List notification threads for the authenticated user. Requires a token with notifications access. */
3484
- listNotifications: "listNotifications",
3485
- /** Mark a single notification thread as read. Requires approval by default. */
3486
- markNotificationRead: "markNotificationRead",
3487
- /** List reactions on an issue or pull request conversation, with per-emoji counts. */
3488
- listIssueReactions: "listIssueReactions",
3489
- /** React to an issue or pull request with an emoji. Requires approval by default. */
3490
- addIssueReaction: "addIssueReaction",
3491
- /** List reactions on an issue or pull request comment, with per-emoji counts. */
3492
- listCommentReactions: "listCommentReactions",
3493
- /** React to an issue or pull request comment with an emoji. Requires approval by default. */
3494
- addCommentReaction: "addCommentReaction",
4617
+ getCiFailureContext: {
4618
+ description: getCiFailureContextDescription,
4619
+ inputSchema: getCiFailureContextInputSchema,
4620
+ get core() {
4621
+ return getCiFailureContextCore;
4622
+ },
4623
+ connectScopes: CI_CONTEXT
4624
+ },
3495
4625
  /** List releases for a GitHub repository, newest first (includes drafts and prereleases). */
3496
- listReleases: "listReleases",
4626
+ listReleases: {
4627
+ description: listReleasesDescription,
4628
+ inputSchema: listReleasesInputSchema,
4629
+ get core() {
4630
+ return listReleasesCore;
4631
+ },
4632
+ connectScopes: CONTENTS_READ
4633
+ },
3497
4634
  /** Get the latest published release for a GitHub repository (excludes drafts and prereleases). Body truncated by default. */
3498
- getLatestRelease: "getLatestRelease",
4635
+ getLatestRelease: {
4636
+ description: getLatestReleaseDescription,
4637
+ inputSchema: getLatestReleaseInputSchema,
4638
+ get core() {
4639
+ return getLatestReleaseCore;
4640
+ },
4641
+ connectScopes: CONTENTS_READ
4642
+ },
3499
4643
  /** Get a specific release by ID, including its assets. Body truncated by default. */
3500
- getRelease: "getRelease",
4644
+ getRelease: {
4645
+ description: getReleaseDescription,
4646
+ inputSchema: getReleaseInputSchema,
4647
+ get core() {
4648
+ return getReleaseCore;
4649
+ },
4650
+ connectScopes: CONTENTS_READ
4651
+ },
3501
4652
  /** Fetch a release plus the previous release and tag comparison in one call. */
3502
- getReleaseContext: "getReleaseContext",
4653
+ getReleaseContext: {
4654
+ description: getReleaseContextDescription,
4655
+ inputSchema: getReleaseContextInputSchema,
4656
+ get core() {
4657
+ return getReleaseContextCore;
4658
+ },
4659
+ connectScopes: CONTENTS_READ
4660
+ },
3503
4661
  /** Create a new release (and its tag if needed) in a GitHub repository. Requires approval by default. */
3504
- createRelease: "createRelease",
4662
+ createRelease: {
4663
+ description: createReleaseDescription,
4664
+ inputSchema: createReleaseInputSchema,
4665
+ get core() {
4666
+ return createReleaseCore;
4667
+ },
4668
+ write: true,
4669
+ connectScopes: CONTENTS_WRITE
4670
+ },
3505
4671
  /** Update an existing release — tag, target, title, notes, draft, or prerelease status. Requires approval by default. */
3506
- updateRelease: "updateRelease",
4672
+ updateRelease: {
4673
+ description: updateReleaseDescription,
4674
+ inputSchema: updateReleaseInputSchema,
4675
+ get core() {
4676
+ return updateReleaseCore;
4677
+ },
4678
+ write: true,
4679
+ connectScopes: CONTENTS_WRITE
4680
+ },
3507
4681
  /** Delete a release permanently. Requires approval by default. */
3508
- deleteRelease: "deleteRelease"
4682
+ deleteRelease: {
4683
+ description: deleteReleaseDescription,
4684
+ inputSchema: deleteReleaseInputSchema,
4685
+ get core() {
4686
+ return deleteReleaseCore;
4687
+ },
4688
+ write: true,
4689
+ connectScopes: CONTENTS_WRITE
4690
+ }
3509
4691
  };
3510
- const ALL_GITHUB_TOOL_NAMES = Object.values(GITHUB_TOOL_NAMES);
4692
+ const ALL_GITHUB_TOOL_NAMES = Object.keys(GITHUB_TOOL_CATALOG);
4693
+ const GITHUB_WRITE_TOOL_NAMES = ALL_GITHUB_TOOL_NAMES.filter((name) => "write" in GITHUB_TOOL_CATALOG[name]);
4694
+ function isGithubWriteToolName(name) {
4695
+ return "write" in GITHUB_TOOL_CATALOG[name];
4696
+ }
4697
+ //#endregion
4698
+ //#region src/core/tool-names.ts
4699
+ /**
4700
+ * All GitHub tool names available via {@link createGithubTools}, keyed by name.
4701
+ * Derived from `GITHUB_TOOL_CATALOG` — the single source of truth for tools.
4702
+ */
4703
+ const GITHUB_TOOL_NAMES = Object.fromEntries(ALL_GITHUB_TOOL_NAMES.map((name) => [name, name]));
3511
4704
  //#endregion
3512
4705
  //#region src/core/write-tools.ts
3513
4706
  /**
3514
- * Write tools that mutate GitHub state. All require user approval by default
3515
- * unless overridden via {@link ApprovalConfig}.
4707
+ * GitHub tools that perform write operations and require approval by default.
4708
+ * Derived from the `write: true` entries of `GITHUB_TOOL_CATALOG`.
3516
4709
  */
3517
- const GITHUB_WRITE_TOOLS = {
3518
- /** Create a new branch in a GitHub repository from an existing branch or commit SHA. Requires approval by default. */
3519
- createBranch: "createBranch",
3520
- /** Fork a GitHub repository to the authenticated user account or a specified organization. Requires approval by default. */
3521
- forkRepository: "forkRepository",
3522
- /** Create a new GitHub repository for the authenticated user or a specified organization. Requires approval by default. */
3523
- createRepository: "createRepository",
3524
- /** Create or update a file in a GitHub repository. Requires approval by default. */
3525
- createOrUpdateFile: "createOrUpdateFile",
3526
- /** Create a new pull request in a GitHub repository. Requires approval by default. */
3527
- createPullRequest: "createPullRequest",
3528
- /** Merge a pull request. Requires approval by default. */
3529
- mergePullRequest: "mergePullRequest",
3530
- /** Update a pull request. Requires approval by default. */
3531
- updatePullRequest: "updatePullRequest",
3532
- /** Add a comment to a pull request. Requires approval by default. */
3533
- addPullRequestComment: "addPullRequestComment",
3534
- /** Update a pull request comment. Requires approval by default. */
3535
- updatePullRequestComment: "updatePullRequestComment",
3536
- /** Delete a pull request comment. Requires approval by default. */
3537
- deletePullRequestComment: "deletePullRequestComment",
3538
- /** Submit a pull request review with optional inline comments. Requires approval by default. */
3539
- createPullRequestReview: "createPullRequestReview",
3540
- /** Request reviews from users or teams on a pull request. Requires approval by default. */
3541
- requestReviewers: "requestReviewers",
3542
- /** Create a new issue in a GitHub repository. Requires approval by default. */
3543
- createIssue: "createIssue",
3544
- /** Add a comment to a GitHub issue. Requires approval by default. */
3545
- addIssueComment: "addIssueComment",
3546
- /** Update a GitHub issue comment. Requires approval by default. */
3547
- updateIssueComment: "updateIssueComment",
3548
- /** Delete a GitHub issue comment. Requires approval by default. */
3549
- deleteIssueComment: "deleteIssueComment",
3550
- /** Close an open GitHub issue. Requires approval by default. */
3551
- closeIssue: "closeIssue",
3552
- /** Update a GitHub issue. Requires approval by default. */
3553
- updateIssue: "updateIssue",
3554
- /** Add labels to an issue or pull request. Requires approval by default. */
3555
- addLabels: "addLabels",
3556
- /** Remove a label from an issue or pull request. Requires approval by default. */
3557
- removeLabel: "removeLabel",
3558
- /** Create a label in a GitHub repository. Requires approval by default. */
3559
- createLabel: "createLabel",
3560
- /** Update a label in a GitHub repository. Requires approval by default. */
3561
- updateLabel: "updateLabel",
3562
- /** Delete a label from a GitHub repository permanently. Requires approval by default. */
3563
- deleteLabel: "deleteLabel",
3564
- /** Assign users to an issue or pull request. Requires approval by default. */
3565
- addAssignees: "addAssignees",
3566
- /** Remove assignees from an issue or pull request. Requires approval by default. */
3567
- removeAssignees: "removeAssignees",
3568
- /** Create a new gist with one or more files. Requires approval by default. */
3569
- createGist: "createGist",
3570
- /** Update an existing gist. Requires approval by default. */
3571
- updateGist: "updateGist",
3572
- /** Delete a gist permanently. Requires approval by default. */
3573
- deleteGist: "deleteGist",
3574
- /** Add a comment to a gist. Requires approval by default. */
3575
- createGistComment: "createGistComment",
3576
- /** Add a comment to a GitHub discussion. Requires approval by default. */
3577
- addDiscussionComment: "addDiscussionComment",
3578
- /** Mark a single notification thread as read. Requires approval by default. */
3579
- markNotificationRead: "markNotificationRead",
3580
- /** React to an issue or pull request with an emoji. Requires approval by default. */
3581
- addIssueReaction: "addIssueReaction",
3582
- /** React to an issue or pull request comment with an emoji. Requires approval by default. */
3583
- addCommentReaction: "addCommentReaction",
3584
- /** Trigger a workflow via workflow_dispatch event. Requires approval by default. */
3585
- triggerWorkflow: "triggerWorkflow",
3586
- /** Cancel an in-progress workflow run. Requires approval by default. */
3587
- cancelWorkflowRun: "cancelWorkflowRun",
3588
- /** Re-run a workflow run, optionally only the failed jobs. Requires approval by default. */
3589
- rerunWorkflowRun: "rerunWorkflowRun",
3590
- /** Create a new release (and its tag if needed) in a GitHub repository. Requires approval by default. */
3591
- createRelease: "createRelease",
3592
- /** Update an existing release. Requires approval by default. */
3593
- updateRelease: "updateRelease",
3594
- /** Delete a release permanently. Requires approval by default. */
3595
- deleteRelease: "deleteRelease"
3596
- };
3597
- Object.values(GITHUB_WRITE_TOOLS);
4710
+ const GITHUB_WRITE_TOOLS = Object.fromEntries(GITHUB_WRITE_TOOL_NAMES.map((name) => [name, name]));
3598
4711
  //#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 };
4712
+ export { getWorkflowJobLogsInputSchema as $, listBranchesDescription as $i, deleteIssueCommentInputSchema as $n, listPullRequestReviewsInputSchema as $r, searchCodeInputSchema as $t, getLatestReleaseCore as A, createBranchInputSchema as Ai, listIssueReactionsCore as An, addPullRequestCommentCore as Ar, listGistCommentsCore as At, updateReleaseDescription as B, forkRepositoryCore as Bi, addLabelsDescription as Bn, deletePullRequestCommentDescription as Br, compareCommitsDescription as Bt, getReleaseContextInputSchema as C, compareCommitsToModelOutput as Ci, addCommentReactionInputSchema as Cn, updateIssueCommentInputSchema as Cr, createGistInputSchema as Ct, deleteReleaseCore as D, listPullRequestFilesToModelOutput as Di, listCommentReactionsCore as Dn, updateLabelCore as Dr, getGistCore as Dt, createReleaseInputSchema as E, getPullRequestContextToModelOutput as Ei, addIssueReactionInputSchema as En, updateIssueInputSchema as Er, deleteGistInputSchema as Et, getReleaseInputSchema as F, createRepositoryDescription as Fi, addAssigneesInputSchema as Fn, createPullRequestInputSchema as Fr, listGistsInputSchema as Ft, listCheckRunsCore as G, getFileContentInputSchema as Gi, createIssueCore as Gn, listPullRequestFilesCore as Gr, getCommitCore as Gt, getCombinedStatusCore as H, forkRepositoryInputSchema as Hi, closeIssueCore as Hn, getPullRequestCore as Hr, getBlameCore as Ht, listReleasesCore as I, createRepositoryInputSchema as Ii, addIssueCommentCore as In, createPullRequestReviewCore as Ir, updateGistCore as It, cancelWorkflowRunCore as J, getRepositoryInputSchema as Ji, createLabelCore as Jn, listPullRequestReviewThreadsCore as Jr, listCommitsCore as Jt, listCheckRunsDescription as K, getRepositoryCore as Ki, createIssueDescription as Kn, listPullRequestFilesDescription as Kr, getCommitDescription as Kt, listReleasesDescription as L, deleteBranchCore as Li, addIssueCommentDescription as Ln, createPullRequestReviewDescription as Lr, updateGistDescription as Lt, getLatestReleaseInputSchema as M, createOrUpdateFileDescription as Mi, listIssueReactionsInputSchema as Mn, addPullRequestCommentInputSchema as Mr, listGistCommentsInputSchema as Mt, getReleaseCore as N, createOrUpdateFileInputSchema as Ni, addAssigneesCore as Nn, createPullRequestCore as Nr, listGistsCore as Nt, deleteReleaseDescription as O, createBranchCore as Oi, listCommentReactionsDescription as On, updateLabelDescription as Or, getGistDescription as Ot, getReleaseDescription as P, createRepositoryCore as Pi, addAssigneesDescription as Pn, createPullRequestDescription as Pr, listGistsDescription as Pt, getWorkflowJobLogsDescription as Q, listBranchesCore as Qi, deleteIssueCommentDescription as Qn, listPullRequestReviewsDescription as Qr, searchCodeDescription as Qt, listReleasesInputSchema as R, deleteBranchDescription as Ri, addIssueCommentInputSchema as Rn, createPullRequestReviewInputSchema as Rr, updateGistInputSchema as Rt, getReleaseContextDescription as S, resolveGithubToken as Si, addCommentReactionDescription as Sn, updateIssueCommentDescription as Sr, createGistDescription as St, createReleaseDescription as T, getFileContentToModelOutput as Ti, addIssueReactionDescription as Tn, updateIssueDescription as Tr, deleteGistDescription as Tt, getCombinedStatusDescription as U, getFileContentCore as Ui, closeIssueDescription as Un, getPullRequestDescription as Ur, getBlameDescription as Ut, updateReleaseInputSchema as V, forkRepositoryDescription as Vi, addLabelsInputSchema as Vn, deletePullRequestCommentInputSchema as Vr, compareCommitsInputSchema as Vt, getCombinedStatusInputSchema as W, getFileContentDescription as Wi, closeIssueInputSchema as Wn, getPullRequestInputSchema as Wr, getBlameInputSchema as Wt, cancelWorkflowRunInputSchema as X, getRepositoryTreeDescription as Xi, createLabelInputSchema as Xn, listPullRequestReviewThreadsInputSchema as Xr, listCommitsInputSchema as Xt, cancelWorkflowRunDescription as Y, getRepositoryTreeCore as Yi, createLabelDescription as Yn, listPullRequestReviewThreadsDescription as Yr, listCommitsDescription as Yt, getWorkflowJobLogsCore as Z, getRepositoryTreeInputSchema as Zi, deleteIssueCommentCore as Zn, listPullRequestReviewsCore as Zr, searchCodeCore as Zt, getIssueContextInputSchema as _, updatePullRequestCommentInputSchema as _i, getDiscussionInputSchema as _n, removeAssigneesInputSchema as _r, triggerWorkflowInputSchema as _t, isGithubWriteToolName as a, mergePullRequestInputSchema as ai, searchRepositoriesInputSchema as an, getIssueInputSchema as ar, listWorkflowJobsInputSchema as at, getPullRequestContextInputSchema as b, updatePullRequestInputSchema as bi, listDiscussionsInputSchema as bn, removeLabelInputSchema as br, createGistCommentInputSchema as bt, bindToolsContext as c, replyToReviewCommentInputSchema as ci, listNotificationsInputSchema as cn, listIssueCommentsInputSchema as cr, listWorkflowRunsInputSchema as ct, softenContextSchema as d, requestReviewersInputSchema as di, markNotificationReadInputSchema as dn, listIssuesInputSchema as dr, listWorkflowsInputSchema as dt, listBranchesInputSchema as ea, listPullRequestsCore as ei, searchIssuesCore as en, deleteLabelCore as er, getWorkflowRunCore as et, getCiFailureContextCore as f, resolveReviewThreadCore as fi, addDiscussionCommentCore as fn, listLabelsCore as fr, rerunWorkflowRunCore as ft, getIssueContextDescription as g, updatePullRequestCommentDescription as gi, getDiscussionDescription as gn, removeAssigneesDescription as gr, triggerWorkflowDescription as gt, getIssueContextCore as h, updatePullRequestCommentCore as hi, getDiscussionCore as hn, removeAssigneesCore as hr, triggerWorkflowCore as ht, GITHUB_TOOL_CATALOG as i, mergePullRequestDescription as ii, searchRepositoriesDescription as in, getIssueDescription as ir, listWorkflowJobsDescription as it, getLatestReleaseDescription as j, createOrUpdateFileCore as ji, listIssueReactionsDescription as jn, addPullRequestCommentDescription as jr, listGistCommentsDescription as jt, deleteReleaseInputSchema as k, createBranchDescription as ki, listCommentReactionsInputSchema as kn, updateLabelInputSchema as kr, getGistInputSchema as kt, formatContextInstructions as l, requestReviewersCore as li, markNotificationReadCore as ln, listIssuesCore as lr, listWorkflowsCore as lt, getCiFailureContextInputSchema as m, resolveReviewThreadInputSchema as mi, addDiscussionCommentInputSchema as mn, listLabelsInputSchema as mr, rerunWorkflowRunInputSchema as mt, GITHUB_TOOL_NAMES as n, stripRateLimit as na, listPullRequestsInputSchema as ni, searchIssuesInputSchema as nn, deleteLabelInputSchema as nr, getWorkflowRunInputSchema as nt, PRESET_TOOLS as o, replyToReviewCommentCore as oi, listNotificationsCore as on, listIssueCommentsCore as or, listWorkflowRunsCore as ot, getCiFailureContextDescription as p, resolveReviewThreadDescription as pi, addDiscussionCommentDescription as pn, listLabelsDescription as pr, rerunWorkflowRunDescription as pt, listCheckRunsInputSchema as q, getRepositoryDescription as qi, createIssueInputSchema as qn, listPullRequestFilesInputSchema as qr, getCommitInputSchema as qt, ALL_GITHUB_TOOL_NAMES as r, mergePullRequestCore as ri, searchRepositoriesCore as rn, getIssueCore as rr, listWorkflowJobsCore as rt, resolvePresetTools as s, replyToReviewCommentDescription as si, listNotificationsDescription as sn, listIssueCommentsDescription as sr, listWorkflowRunsDescription as st, GITHUB_WRITE_TOOLS as t, createOctokit as ta, listPullRequestsDescription as ti, searchIssuesDescription as tn, deleteLabelDescription as tr, getWorkflowRunDescription as tt, mergeContextArgs as u, requestReviewersDescription as ui, markNotificationReadDescription as un, listIssuesDescription as ur, listWorkflowsDescription as ut, getPullRequestContextCore as v, updatePullRequestCore as vi, listDiscussionsCore as vn, removeLabelCore as vr, createGistCommentCore as vt, createReleaseCore as w, getCommitToModelOutput as wi, addIssueReactionCore as wn, updateIssueCore as wr, deleteGistCore as wt, getReleaseContextCore as x, createGithubTokenResolver as xi, addCommentReactionCore as xn, updateIssueCommentCore as xr, createGistCore as xt, getPullRequestContextDescription as y, updatePullRequestDescription as yi, listDiscussionsDescription as yn, removeLabelDescription as yr, createGistCommentDescription as yt, updateReleaseCore as z, deleteBranchInputSchema as zi, addLabelsCore as zn, deletePullRequestCommentCore as zr, compareCommitsCore as zt };
3600
4713
 
3601
- //# sourceMappingURL=write-tools-Dk32V9Hl.mjs.map
4714
+ //# sourceMappingURL=write-tools-BEcL5Fv6.mjs.map