@github-tools/sdk 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,651 +1,5 @@
1
- import { Octokit } from "@octokit/rest";
2
- import { ToolLoopAgent, tool } from "ai";
3
- import { z } from "zod";
1
+ import { A as listPullRequests, C as closeIssue, D as addPullRequestComment, E as listIssues, F as forkRepository, I as getFileContent, L as getRepository, M as createBranch, N as createOrUpdateFile, O as createPullRequest, P as createRepository, R as listBranches, S as addIssueComment, T as getIssue, _ as getBlame, a as listWorkflowJobs, b as searchCode, c as rerunWorkflowRun, d as createGistComment, f as deleteGist, g as updateGist, h as listGists, i as getWorkflowRun, j as mergePullRequest, k as getPullRequest, l as triggerWorkflow, m as listGistComments, o as listWorkflowRuns, p as getGist, r as cancelWorkflowRun, s as listWorkflows, t as createGithubAgent, u as createGist, v as getCommit, w as createIssue, x as searchRepositories, y as listCommits, z as createOctokit } from "./agents-Cdb0a8CP.mjs";
4
2
 
5
- //#region src/client.ts
6
- function createOctokit(token) {
7
- return new Octokit({ auth: token });
8
- }
9
-
10
- //#endregion
11
- //#region src/tools/repository.ts
12
- const getRepository = (octokit) => tool({
13
- description: "Get information about a GitHub repository including description, stars, forks, language, and default branch",
14
- inputSchema: z.object({
15
- owner: z.string().describe("Repository owner (user or organization)"),
16
- repo: z.string().describe("Repository name")
17
- }),
18
- execute: async ({ owner, repo }) => {
19
- const { data } = await octokit.repos.get({
20
- owner,
21
- repo
22
- });
23
- return {
24
- name: data.name,
25
- fullName: data.full_name,
26
- description: data.description,
27
- url: data.html_url,
28
- defaultBranch: data.default_branch,
29
- stars: data.stargazers_count,
30
- forks: data.forks_count,
31
- openIssues: data.open_issues_count,
32
- language: data.language,
33
- private: data.private,
34
- createdAt: data.created_at,
35
- updatedAt: data.updated_at
36
- };
37
- }
38
- });
39
- const listBranches = (octokit) => tool({
40
- description: "List branches in a GitHub repository",
41
- inputSchema: z.object({
42
- owner: z.string().describe("Repository owner"),
43
- repo: z.string().describe("Repository name"),
44
- perPage: z.number().optional().default(30).describe("Number of branches to return (max 100)")
45
- }),
46
- execute: async ({ owner, repo, perPage }) => {
47
- const { data } = await octokit.repos.listBranches({
48
- owner,
49
- repo,
50
- per_page: perPage
51
- });
52
- return data.map((branch) => ({
53
- name: branch.name,
54
- sha: branch.commit.sha,
55
- protected: branch.protected
56
- }));
57
- }
58
- });
59
- const getFileContent = (octokit) => tool({
60
- description: "Get the content of a file from a GitHub repository",
61
- inputSchema: z.object({
62
- owner: z.string().describe("Repository owner"),
63
- repo: z.string().describe("Repository name"),
64
- path: z.string().describe("Path to the file in the repository"),
65
- ref: z.string().optional().describe("Branch, tag, or commit SHA (defaults to the default branch)")
66
- }),
67
- execute: async ({ owner, repo, path, ref }) => {
68
- const { data } = await octokit.repos.getContent({
69
- owner,
70
- repo,
71
- path,
72
- ref
73
- });
74
- if (Array.isArray(data)) return {
75
- type: "directory",
76
- entries: data.map((e) => ({
77
- name: e.name,
78
- type: e.type,
79
- path: e.path
80
- }))
81
- };
82
- if (data.type !== "file") return {
83
- type: data.type,
84
- path: data.path
85
- };
86
- const content = Buffer.from(data.content, "base64").toString("utf-8");
87
- return {
88
- type: "file",
89
- path: data.path,
90
- sha: data.sha,
91
- size: data.size,
92
- content
93
- };
94
- }
95
- });
96
- const createOrUpdateFile = (octokit, { needsApproval = true } = {}) => tool({
97
- description: "Create or update a file in a GitHub repository. Provide the SHA when updating an existing file.",
98
- needsApproval,
99
- inputSchema: z.object({
100
- owner: z.string().describe("Repository owner"),
101
- repo: z.string().describe("Repository name"),
102
- path: z.string().describe("Path to the file in the repository"),
103
- message: z.string().describe("Commit message"),
104
- content: z.string().describe("File content (plain text, will be base64-encoded automatically)"),
105
- branch: z.string().optional().describe("Branch to commit to (defaults to the default branch)"),
106
- sha: z.string().optional().describe("SHA of the file being replaced (required when updating an existing file)")
107
- }),
108
- execute: async ({ owner, repo, path, message, content, branch, sha }) => {
109
- const encoded = Buffer.from(content).toString("base64");
110
- const { data } = await octokit.repos.createOrUpdateFileContents({
111
- owner,
112
- repo,
113
- path,
114
- message,
115
- content: encoded,
116
- branch,
117
- sha
118
- });
119
- return {
120
- path: data.content?.path,
121
- sha: data.content?.sha,
122
- commitSha: data.commit.sha,
123
- commitUrl: data.commit.html_url
124
- };
125
- }
126
- });
127
-
128
- //#endregion
129
- //#region src/tools/pull-requests.ts
130
- const listPullRequests = (octokit) => tool({
131
- description: "List pull requests for a GitHub repository",
132
- inputSchema: z.object({
133
- owner: z.string().describe("Repository owner"),
134
- repo: z.string().describe("Repository name"),
135
- state: z.enum([
136
- "open",
137
- "closed",
138
- "all"
139
- ]).optional().default("open").describe("Filter by state"),
140
- perPage: z.number().optional().default(30).describe("Number of results to return (max 100)")
141
- }),
142
- execute: async ({ owner, repo, state, perPage }) => {
143
- const { data } = await octokit.pulls.list({
144
- owner,
145
- repo,
146
- state,
147
- per_page: perPage
148
- });
149
- return data.map((pr) => ({
150
- number: pr.number,
151
- title: pr.title,
152
- state: pr.state,
153
- url: pr.html_url,
154
- author: pr.user?.login,
155
- branch: pr.head.ref,
156
- base: pr.base.ref,
157
- draft: pr.draft,
158
- createdAt: pr.created_at,
159
- updatedAt: pr.updated_at
160
- }));
161
- }
162
- });
163
- const getPullRequest = (octokit) => tool({
164
- description: "Get detailed information about a specific pull request",
165
- inputSchema: z.object({
166
- owner: z.string().describe("Repository owner"),
167
- repo: z.string().describe("Repository name"),
168
- pullNumber: z.number().describe("Pull request number")
169
- }),
170
- execute: async ({ owner, repo, pullNumber }) => {
171
- const { data } = await octokit.pulls.get({
172
- owner,
173
- repo,
174
- pull_number: pullNumber
175
- });
176
- return {
177
- number: data.number,
178
- title: data.title,
179
- body: data.body,
180
- state: data.state,
181
- url: data.html_url,
182
- author: data.user?.login,
183
- branch: data.head.ref,
184
- base: data.base.ref,
185
- draft: data.draft,
186
- merged: data.merged,
187
- mergeable: data.mergeable,
188
- additions: data.additions,
189
- deletions: data.deletions,
190
- changedFiles: data.changed_files,
191
- createdAt: data.created_at,
192
- updatedAt: data.updated_at,
193
- mergedAt: data.merged_at
194
- };
195
- }
196
- });
197
- const createPullRequest = (octokit, { needsApproval = true } = {}) => tool({
198
- description: "Create a new pull request in a GitHub repository",
199
- needsApproval,
200
- inputSchema: z.object({
201
- owner: z.string().describe("Repository owner"),
202
- repo: z.string().describe("Repository name"),
203
- title: z.string().describe("Pull request title"),
204
- body: z.string().optional().describe("Pull request description (supports Markdown)"),
205
- head: z.string().describe("Branch containing the changes (format: branch or username:branch)"),
206
- base: z.string().describe("Branch to merge into"),
207
- draft: z.boolean().optional().default(false).describe("Create as draft pull request")
208
- }),
209
- execute: async ({ owner, repo, title, body, head, base, draft }) => {
210
- const { data } = await octokit.pulls.create({
211
- owner,
212
- repo,
213
- title,
214
- body,
215
- head,
216
- base,
217
- draft
218
- });
219
- return {
220
- number: data.number,
221
- title: data.title,
222
- url: data.html_url,
223
- state: data.state,
224
- draft: data.draft,
225
- branch: data.head.ref,
226
- base: data.base.ref
227
- };
228
- }
229
- });
230
- const mergePullRequest = (octokit, { needsApproval = true } = {}) => tool({
231
- description: "Merge a pull request",
232
- needsApproval,
233
- inputSchema: z.object({
234
- owner: z.string().describe("Repository owner"),
235
- repo: z.string().describe("Repository name"),
236
- pullNumber: z.number().describe("Pull request number"),
237
- commitTitle: z.string().optional().describe("Title for the automatic merge commit"),
238
- commitMessage: z.string().optional().describe("Extra detail to append to automatic commit message"),
239
- mergeMethod: z.enum([
240
- "merge",
241
- "squash",
242
- "rebase"
243
- ]).optional().default("merge").describe("Merge strategy")
244
- }),
245
- execute: async ({ owner, repo, pullNumber, commitTitle, commitMessage, mergeMethod }) => {
246
- const { data } = await octokit.pulls.merge({
247
- owner,
248
- repo,
249
- pull_number: pullNumber,
250
- commit_title: commitTitle,
251
- commit_message: commitMessage,
252
- merge_method: mergeMethod
253
- });
254
- return {
255
- merged: data.merged,
256
- message: data.message,
257
- sha: data.sha
258
- };
259
- }
260
- });
261
- const addPullRequestComment = (octokit, { needsApproval = true } = {}) => tool({
262
- description: "Add a comment to a pull request",
263
- needsApproval,
264
- inputSchema: z.object({
265
- owner: z.string().describe("Repository owner"),
266
- repo: z.string().describe("Repository name"),
267
- pullNumber: z.number().describe("Pull request number"),
268
- body: z.string().describe("Comment text (supports Markdown)")
269
- }),
270
- execute: async ({ owner, repo, pullNumber, body }) => {
271
- const { data } = await octokit.issues.createComment({
272
- owner,
273
- repo,
274
- issue_number: pullNumber,
275
- body
276
- });
277
- return {
278
- id: data.id,
279
- url: data.html_url,
280
- body: data.body,
281
- author: data.user?.login,
282
- createdAt: data.created_at
283
- };
284
- }
285
- });
286
-
287
- //#endregion
288
- //#region src/tools/issues.ts
289
- const listIssues = (octokit) => tool({
290
- description: "List issues for a GitHub repository (excludes pull requests)",
291
- inputSchema: z.object({
292
- owner: z.string().describe("Repository owner"),
293
- repo: z.string().describe("Repository name"),
294
- state: z.enum([
295
- "open",
296
- "closed",
297
- "all"
298
- ]).optional().default("open").describe("Filter by state"),
299
- labels: z.string().optional().describe("Comma-separated list of label names to filter by"),
300
- perPage: z.number().optional().default(30).describe("Number of results to return (max 100)")
301
- }),
302
- execute: async ({ owner, repo, state, labels, perPage }) => {
303
- const { data } = await octokit.issues.listForRepo({
304
- owner,
305
- repo,
306
- state,
307
- labels,
308
- per_page: perPage
309
- });
310
- return data.filter((issue) => !issue.pull_request).map((issue) => ({
311
- number: issue.number,
312
- title: issue.title,
313
- state: issue.state,
314
- url: issue.html_url,
315
- author: issue.user?.login,
316
- labels: issue.labels.map((l) => typeof l === "string" ? l : l.name),
317
- createdAt: issue.created_at,
318
- updatedAt: issue.updated_at
319
- }));
320
- }
321
- });
322
- const getIssue = (octokit) => tool({
323
- description: "Get detailed information about a specific issue",
324
- inputSchema: z.object({
325
- owner: z.string().describe("Repository owner"),
326
- repo: z.string().describe("Repository name"),
327
- issueNumber: z.number().describe("Issue number")
328
- }),
329
- execute: async ({ owner, repo, issueNumber }) => {
330
- const { data } = await octokit.issues.get({
331
- owner,
332
- repo,
333
- issue_number: issueNumber
334
- });
335
- return {
336
- number: data.number,
337
- title: data.title,
338
- body: data.body,
339
- state: data.state,
340
- url: data.html_url,
341
- author: data.user?.login,
342
- assignees: data.assignees?.map((a) => a.login),
343
- labels: data.labels.map((l) => typeof l === "string" ? l : l.name),
344
- comments: data.comments,
345
- createdAt: data.created_at,
346
- updatedAt: data.updated_at,
347
- closedAt: data.closed_at
348
- };
349
- }
350
- });
351
- const createIssue = (octokit, { needsApproval = true } = {}) => tool({
352
- description: "Create a new issue in a GitHub repository",
353
- needsApproval,
354
- inputSchema: z.object({
355
- owner: z.string().describe("Repository owner"),
356
- repo: z.string().describe("Repository name"),
357
- title: z.string().describe("Issue title"),
358
- body: z.string().optional().describe("Issue description (supports Markdown)"),
359
- labels: z.array(z.string()).optional().describe("Labels to apply to the issue"),
360
- assignees: z.array(z.string()).optional().describe("GitHub usernames to assign to the issue")
361
- }),
362
- execute: async ({ owner, repo, title, body, labels, assignees }) => {
363
- const { data } = await octokit.issues.create({
364
- owner,
365
- repo,
366
- title,
367
- body,
368
- labels,
369
- assignees
370
- });
371
- return {
372
- number: data.number,
373
- title: data.title,
374
- url: data.html_url,
375
- state: data.state,
376
- labels: data.labels.map((l) => typeof l === "string" ? l : l.name)
377
- };
378
- }
379
- });
380
- const addIssueComment = (octokit, { needsApproval = true } = {}) => tool({
381
- description: "Add a comment to a GitHub issue",
382
- needsApproval,
383
- inputSchema: z.object({
384
- owner: z.string().describe("Repository owner"),
385
- repo: z.string().describe("Repository name"),
386
- issueNumber: z.number().describe("Issue number"),
387
- body: z.string().describe("Comment text (supports Markdown)")
388
- }),
389
- execute: async ({ owner, repo, issueNumber, body }) => {
390
- const { data } = await octokit.issues.createComment({
391
- owner,
392
- repo,
393
- issue_number: issueNumber,
394
- body
395
- });
396
- return {
397
- id: data.id,
398
- url: data.html_url,
399
- body: data.body,
400
- author: data.user?.login,
401
- createdAt: data.created_at
402
- };
403
- }
404
- });
405
- const closeIssue = (octokit, { needsApproval = true } = {}) => tool({
406
- description: "Close an open GitHub issue",
407
- needsApproval,
408
- inputSchema: z.object({
409
- owner: z.string().describe("Repository owner"),
410
- repo: z.string().describe("Repository name"),
411
- issueNumber: z.number().describe("Issue number to close"),
412
- stateReason: z.enum(["completed", "not_planned"]).optional().default("completed").describe("Reason for closing")
413
- }),
414
- execute: async ({ owner, repo, issueNumber, stateReason }) => {
415
- const { data } = await octokit.issues.update({
416
- owner,
417
- repo,
418
- issue_number: issueNumber,
419
- state: "closed",
420
- state_reason: stateReason
421
- });
422
- return {
423
- number: data.number,
424
- title: data.title,
425
- state: data.state,
426
- url: data.html_url,
427
- closedAt: data.closed_at
428
- };
429
- }
430
- });
431
-
432
- //#endregion
433
- //#region src/tools/search.ts
434
- const searchCode = (octokit) => tool({
435
- description: "Search for code in GitHub repositories. Use qualifiers like \"repo:owner/name\" to scope the search.",
436
- inputSchema: z.object({
437
- query: z.string().describe("Search query. Supports GitHub search qualifiers, e.g. \"useState repo:facebook/react\""),
438
- perPage: z.number().optional().default(10).describe("Number of results to return (max 30)")
439
- }),
440
- execute: async ({ query, perPage }) => {
441
- const { data } = await octokit.search.code({
442
- q: query,
443
- per_page: perPage
444
- });
445
- return {
446
- totalCount: data.total_count,
447
- items: data.items.map((item) => ({
448
- name: item.name,
449
- path: item.path,
450
- url: item.html_url,
451
- repository: item.repository.full_name,
452
- sha: item.sha
453
- }))
454
- };
455
- }
456
- });
457
- const searchRepositories = (octokit) => tool({
458
- description: "Search for GitHub repositories by keyword, topic, language, or other qualifiers",
459
- inputSchema: z.object({
460
- query: z.string().describe("Search query. Supports GitHub search qualifiers, e.g. \"nuxt language:typescript stars:>1000\""),
461
- perPage: z.number().optional().default(10).describe("Number of results to return (max 30)"),
462
- sort: z.enum([
463
- "stars",
464
- "forks",
465
- "help-wanted-issues",
466
- "updated"
467
- ]).optional().describe("Sort field"),
468
- order: z.enum(["asc", "desc"]).optional().default("desc").describe("Sort order")
469
- }),
470
- execute: async ({ query, perPage, sort, order }) => {
471
- const { data } = await octokit.search.repos({
472
- q: query,
473
- per_page: perPage,
474
- sort,
475
- order
476
- });
477
- return {
478
- totalCount: data.total_count,
479
- items: data.items.map((repo) => ({
480
- name: repo.name,
481
- fullName: repo.full_name,
482
- description: repo.description,
483
- url: repo.html_url,
484
- stars: repo.stargazers_count,
485
- forks: repo.forks_count,
486
- language: repo.language,
487
- topics: repo.topics
488
- }))
489
- };
490
- }
491
- });
492
-
493
- //#endregion
494
- //#region src/tools/commits.ts
495
- const listCommits = (octokit) => tool({
496
- description: "List commits for a GitHub repository. Filter by file path to see who changed a specific file and when (git blame alternative). Filter by author, branch, or date range.",
497
- inputSchema: z.object({
498
- owner: z.string().describe("Repository owner"),
499
- repo: z.string().describe("Repository name"),
500
- path: z.string().optional().describe("Only commits containing this file path"),
501
- sha: z.string().optional().describe("Branch name or commit SHA to start listing from"),
502
- author: z.string().optional().describe("GitHub username or email to filter commits by"),
503
- since: z.string().optional().describe("Only commits after this date (ISO 8601 format)"),
504
- until: z.string().optional().describe("Only commits before this date (ISO 8601 format)"),
505
- perPage: z.number().optional().default(30).describe("Number of results to return (max 100)")
506
- }),
507
- execute: async ({ owner, repo, path, sha, author, since, until, perPage }) => {
508
- const { data } = await octokit.repos.listCommits({
509
- owner,
510
- repo,
511
- path,
512
- sha,
513
- author,
514
- since,
515
- until,
516
- per_page: perPage
517
- });
518
- return data.map((commit) => ({
519
- sha: commit.sha,
520
- message: commit.commit.message,
521
- author: commit.commit.author?.name,
522
- authorLogin: commit.author?.login,
523
- date: commit.commit.author?.date,
524
- url: commit.html_url
525
- }));
526
- }
527
- });
528
- const getCommit = (octokit) => tool({
529
- description: "Get detailed information about a specific commit, including the list of files changed with additions and deletions",
530
- inputSchema: z.object({
531
- owner: z.string().describe("Repository owner"),
532
- repo: z.string().describe("Repository name"),
533
- ref: z.string().describe("Commit SHA, branch name, or tag")
534
- }),
535
- execute: async ({ owner, repo, ref }) => {
536
- const { data } = await octokit.repos.getCommit({
537
- owner,
538
- repo,
539
- ref
540
- });
541
- return {
542
- sha: data.sha,
543
- message: data.commit.message,
544
- author: data.commit.author?.name,
545
- authorLogin: data.author?.login,
546
- date: data.commit.author?.date,
547
- url: data.html_url,
548
- stats: data.stats ? {
549
- additions: data.stats.additions,
550
- deletions: data.stats.deletions,
551
- total: data.stats.total
552
- } : null,
553
- files: data.files?.map((file) => ({
554
- filename: file.filename,
555
- status: file.status,
556
- additions: file.additions,
557
- deletions: file.deletions,
558
- patch: file.patch
559
- }))
560
- };
561
- }
562
- });
563
-
564
- //#endregion
565
- //#region src/agents.ts
566
- const SHARED_RULES = `When a tool execution is denied by the user, do not retry it. Briefly acknowledge the decision and move on.`;
567
- const DEFAULT_INSTRUCTIONS = `You are a helpful GitHub assistant. You can read and explore repositories, issues, pull requests, commits, and code. You can also create issues, pull requests, comments, and update files when asked.
568
-
569
- ${SHARED_RULES}`;
570
- const PRESET_INSTRUCTIONS = {
571
- "code-review": `You are a code review assistant. Your job is to review pull requests thoroughly and provide constructive feedback.
572
-
573
- When reviewing a PR:
574
- - Read the PR description and changed files carefully
575
- - Check for bugs, logic errors, and edge cases
576
- - Suggest improvements when you spot issues
577
- - Be constructive — explain why something is a problem and how to fix it
578
- - Post your review as PR comments when asked
579
-
580
- ${SHARED_RULES}`,
581
- "issue-triage": `You are an issue triage assistant. Your job is to help manage and organize GitHub issues.
582
-
583
- When triaging issues:
584
- - Read issue descriptions carefully to understand the problem
585
- - Identify duplicates when possible
586
- - Help categorize and prioritize issues
587
- - Respond to users with clear, helpful information
588
- - Create new issues when asked, with clear titles and descriptions
589
-
590
- ${SHARED_RULES}`,
591
- "repo-explorer": `You are a repository explorer. Your job is to help users understand codebases and find information across GitHub repositories.
592
-
593
- When exploring repos:
594
- - Answer questions about code structure and organization
595
- - Summarize recent activity (commits, PRs, issues)
596
- - Find specific files, functions, or patterns in code
597
- - Explain how different parts of the codebase work together
598
- - You have read-only access — you cannot make changes
599
-
600
- ${SHARED_RULES}`,
601
- "maintainer": `You are a repository maintainer assistant. You have full access to manage repositories, issues, and pull requests.
602
-
603
- When maintaining repos:
604
- - Be careful with write operations — review before acting
605
- - Create well-structured issues and PRs with clear descriptions
606
- - Use merge strategies appropriate for the repository
607
- - Keep commit messages clean and descriptive
608
- - When closing issues, provide a clear reason
609
-
610
- ${SHARED_RULES}`
611
- };
612
- /**
613
- * Create a pre-configured GitHub agent powered by the AI SDK's `ToolLoopAgent`.
614
- *
615
- * Returns a `ToolLoopAgent` instance with `.generate()` and `.stream()` methods.
616
- *
617
- * @example
618
- * ```ts
619
- * import { createGithubAgent } from '@github-tools/sdk'
620
- *
621
- * const agent = createGithubAgent({
622
- * model: 'anthropic/claude-sonnet-4-6',
623
- * token: process.env.GITHUB_TOKEN!,
624
- * preset: 'code-review',
625
- * })
626
- *
627
- * const result = await agent.generate({ prompt: 'Review PR #42 on vercel/ai' })
628
- * ```
629
- */
630
- function createGithubAgent({ token, preset, requireApproval, instructions, additionalInstructions, ...agentOptions }) {
631
- const tools = createGithubTools({
632
- token,
633
- requireApproval,
634
- preset
635
- });
636
- const defaultPrompt = preset && !Array.isArray(preset) ? PRESET_INSTRUCTIONS[preset] : DEFAULT_INSTRUCTIONS;
637
- let resolvedInstructions;
638
- if (instructions) resolvedInstructions = instructions;
639
- else if (additionalInstructions) resolvedInstructions = `${defaultPrompt}\n\n${additionalInstructions}`;
640
- else resolvedInstructions = defaultPrompt;
641
- return new ToolLoopAgent({
642
- ...agentOptions,
643
- tools,
644
- instructions: resolvedInstructions
645
- });
646
- }
647
-
648
- //#endregion
649
3
  //#region src/index.ts
650
4
  const PRESET_TOOLS = {
651
5
  "code-review": [
@@ -654,6 +8,7 @@ const PRESET_TOOLS = {
654
8
  "getFileContent",
655
9
  "listCommits",
656
10
  "getCommit",
11
+ "getBlame",
657
12
  "getRepository",
658
13
  "listBranches",
659
14
  "searchCode",
@@ -669,6 +24,19 @@ const PRESET_TOOLS = {
669
24
  "searchRepositories",
670
25
  "searchCode"
671
26
  ],
27
+ "ci-ops": [
28
+ "getRepository",
29
+ "listBranches",
30
+ "listCommits",
31
+ "getCommit",
32
+ "listWorkflows",
33
+ "listWorkflowRuns",
34
+ "getWorkflowRun",
35
+ "listWorkflowJobs",
36
+ "triggerWorkflow",
37
+ "cancelWorkflowRun",
38
+ "rerunWorkflowRun"
39
+ ],
672
40
  "repo-explorer": [
673
41
  "getRepository",
674
42
  "listBranches",
@@ -679,13 +47,24 @@ const PRESET_TOOLS = {
679
47
  "getIssue",
680
48
  "listCommits",
681
49
  "getCommit",
50
+ "getBlame",
682
51
  "searchCode",
683
- "searchRepositories"
52
+ "searchRepositories",
53
+ "listGists",
54
+ "getGist",
55
+ "listGistComments",
56
+ "listWorkflows",
57
+ "listWorkflowRuns",
58
+ "getWorkflowRun",
59
+ "listWorkflowJobs"
684
60
  ],
685
61
  "maintainer": [
686
62
  "getRepository",
687
63
  "listBranches",
688
64
  "getFileContent",
65
+ "createBranch",
66
+ "forkRepository",
67
+ "createRepository",
689
68
  "createOrUpdateFile",
690
69
  "listPullRequests",
691
70
  "getPullRequest",
@@ -699,8 +78,23 @@ const PRESET_TOOLS = {
699
78
  "closeIssue",
700
79
  "listCommits",
701
80
  "getCommit",
81
+ "getBlame",
702
82
  "searchCode",
703
- "searchRepositories"
83
+ "searchRepositories",
84
+ "listGists",
85
+ "getGist",
86
+ "listGistComments",
87
+ "createGist",
88
+ "updateGist",
89
+ "deleteGist",
90
+ "createGistComment",
91
+ "listWorkflows",
92
+ "listWorkflowRuns",
93
+ "getWorkflowRun",
94
+ "listWorkflowJobs",
95
+ "triggerWorkflow",
96
+ "cancelWorkflowRun",
97
+ "rerunWorkflowRun"
704
98
  ]
705
99
  };
706
100
  function resolveApproval(toolName, config) {
@@ -747,33 +141,50 @@ function resolvePresetTools(preset) {
747
141
  function createGithubTools({ token, requireApproval = true, preset } = {}) {
748
142
  const resolvedToken = token || process.env.GITHUB_TOKEN;
749
143
  if (!resolvedToken) throw new Error("GitHub token is required. Pass it as `token` or set the GITHUB_TOKEN environment variable.");
750
- const octokit = createOctokit(resolvedToken);
751
144
  const approval = (name) => ({ needsApproval: resolveApproval(name, requireApproval) });
752
145
  const allowed = preset ? resolvePresetTools(preset) : null;
753
146
  const allTools = {
754
- getRepository: getRepository(octokit),
755
- listBranches: listBranches(octokit),
756
- getFileContent: getFileContent(octokit),
757
- listPullRequests: listPullRequests(octokit),
758
- getPullRequest: getPullRequest(octokit),
759
- listIssues: listIssues(octokit),
760
- getIssue: getIssue(octokit),
761
- searchCode: searchCode(octokit),
762
- searchRepositories: searchRepositories(octokit),
763
- listCommits: listCommits(octokit),
764
- getCommit: getCommit(octokit),
765
- createOrUpdateFile: createOrUpdateFile(octokit, approval("createOrUpdateFile")),
766
- createPullRequest: createPullRequest(octokit, approval("createPullRequest")),
767
- mergePullRequest: mergePullRequest(octokit, approval("mergePullRequest")),
768
- addPullRequestComment: addPullRequestComment(octokit, approval("addPullRequestComment")),
769
- createIssue: createIssue(octokit, approval("createIssue")),
770
- addIssueComment: addIssueComment(octokit, approval("addIssueComment")),
771
- closeIssue: closeIssue(octokit, approval("closeIssue"))
147
+ getRepository: getRepository(resolvedToken),
148
+ listBranches: listBranches(resolvedToken),
149
+ getFileContent: getFileContent(resolvedToken),
150
+ listPullRequests: listPullRequests(resolvedToken),
151
+ getPullRequest: getPullRequest(resolvedToken),
152
+ listIssues: listIssues(resolvedToken),
153
+ getIssue: getIssue(resolvedToken),
154
+ searchCode: searchCode(resolvedToken),
155
+ searchRepositories: searchRepositories(resolvedToken),
156
+ listCommits: listCommits(resolvedToken),
157
+ getCommit: getCommit(resolvedToken),
158
+ getBlame: getBlame(resolvedToken),
159
+ createBranch: createBranch(resolvedToken, approval("createBranch")),
160
+ forkRepository: forkRepository(resolvedToken, approval("forkRepository")),
161
+ createRepository: createRepository(resolvedToken, approval("createRepository")),
162
+ createOrUpdateFile: createOrUpdateFile(resolvedToken, approval("createOrUpdateFile")),
163
+ createPullRequest: createPullRequest(resolvedToken, approval("createPullRequest")),
164
+ mergePullRequest: mergePullRequest(resolvedToken, approval("mergePullRequest")),
165
+ addPullRequestComment: addPullRequestComment(resolvedToken, approval("addPullRequestComment")),
166
+ createIssue: createIssue(resolvedToken, approval("createIssue")),
167
+ addIssueComment: addIssueComment(resolvedToken, approval("addIssueComment")),
168
+ closeIssue: closeIssue(resolvedToken, approval("closeIssue")),
169
+ listGists: listGists(resolvedToken),
170
+ getGist: getGist(resolvedToken),
171
+ listGistComments: listGistComments(resolvedToken),
172
+ createGist: createGist(resolvedToken, approval("createGist")),
173
+ updateGist: updateGist(resolvedToken, approval("updateGist")),
174
+ deleteGist: deleteGist(resolvedToken, approval("deleteGist")),
175
+ createGistComment: createGistComment(resolvedToken, approval("createGistComment")),
176
+ listWorkflows: listWorkflows(resolvedToken),
177
+ listWorkflowRuns: listWorkflowRuns(resolvedToken),
178
+ getWorkflowRun: getWorkflowRun(resolvedToken),
179
+ listWorkflowJobs: listWorkflowJobs(resolvedToken),
180
+ triggerWorkflow: triggerWorkflow(resolvedToken, approval("triggerWorkflow")),
181
+ cancelWorkflowRun: cancelWorkflowRun(resolvedToken, approval("cancelWorkflowRun")),
182
+ rerunWorkflowRun: rerunWorkflowRun(resolvedToken, approval("rerunWorkflowRun"))
772
183
  };
773
184
  if (!allowed) return allTools;
774
185
  return Object.fromEntries(Object.entries(allTools).filter(([name]) => allowed.has(name)));
775
186
  }
776
187
 
777
188
  //#endregion
778
- export { addIssueComment, addPullRequestComment, closeIssue, createGithubAgent, createGithubTools, createIssue, createOctokit, createOrUpdateFile, createPullRequest, getCommit, getFileContent, getIssue, getPullRequest, getRepository, listBranches, listCommits, listIssues, listPullRequests, mergePullRequest, searchCode, searchRepositories };
189
+ export { addIssueComment, addPullRequestComment, cancelWorkflowRun, closeIssue, createBranch, createGist, createGistComment, createGithubAgent, createGithubTools, createIssue, createOctokit, createOrUpdateFile, createPullRequest, createRepository, deleteGist, forkRepository, getBlame, getCommit, getFileContent, getGist, getIssue, getPullRequest, getRepository, getWorkflowRun, listBranches, listCommits, listGistComments, listGists, listIssues, listPullRequests, listWorkflowJobs, listWorkflowRuns, listWorkflows, mergePullRequest, rerunWorkflowRun, searchCode, searchRepositories, triggerWorkflow, updateGist };
779
190
  //# sourceMappingURL=index.mjs.map