@github-tools/sdk 1.8.2 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +247 -78
- package/dist/connect/eve.d.mts +18 -7
- package/dist/connect/eve.d.mts.map +1 -1
- package/dist/connect/eve.mjs +17 -4
- package/dist/connect/eve.mjs.map +1 -1
- package/dist/connect.d.mts +31 -11
- package/dist/connect.d.mts.map +1 -1
- package/dist/connect.mjs +6 -3
- package/dist/connect.mjs.map +1 -1
- package/dist/eve-runtime-CI4dR_hI.d.mts +54 -0
- package/dist/eve-runtime-CI4dR_hI.d.mts.map +1 -0
- package/dist/eve-runtime-CIcrt7MD.mjs +674 -0
- package/dist/eve-runtime-CIcrt7MD.mjs.map +1 -0
- package/dist/eve-runtime.d.mts +4 -0
- package/dist/eve-runtime.mjs +3 -0
- package/dist/eve.d.mts +331 -112
- package/dist/eve.d.mts.map +1 -1
- package/dist/eve.mjs +356 -3
- package/dist/eve.mjs.map +1 -0
- package/dist/index-B0nL0C00.d.mts +746 -0
- package/dist/index-B0nL0C00.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +3 -3
- package/dist/src-v-LjzPpR.mjs +1371 -0
- package/dist/src-v-LjzPpR.mjs.map +1 -0
- package/dist/{token-CW8lQBND.mjs → token-DDMlEkK-.mjs} +74 -7
- package/dist/token-DDMlEkK-.mjs.map +1 -0
- package/dist/types-VW0m0Uxl.d.mts +39 -0
- package/dist/types-VW0m0Uxl.d.mts.map +1 -0
- package/dist/{types-B0mvQgJf.d.mts → types-Ygt1pw1N.d.mts} +30 -9
- package/dist/types-Ygt1pw1N.d.mts.map +1 -0
- package/dist/workflow.d.mts +7 -7
- package/dist/workflow.d.mts.map +1 -1
- package/dist/workflow.mjs +6 -4
- package/dist/workflow.mjs.map +1 -1
- package/dist/write-tools-uIVfURVp.mjs +3509 -0
- package/dist/write-tools-uIVfURVp.mjs.map +1 -0
- package/package.json +17 -13
- package/dist/eve-UPaHEGVi.mjs +0 -512
- package/dist/eve-UPaHEGVi.mjs.map +0 -1
- package/dist/index-Cs1Kebmt.d.mts +0 -463
- package/dist/index-Cs1Kebmt.d.mts.map +0 -1
- package/dist/src-CfzZfU82.mjs +0 -812
- package/dist/src-CfzZfU82.mjs.map +0 -1
- package/dist/token-CW8lQBND.mjs.map +0 -1
- package/dist/types-B0mvQgJf.d.mts.map +0 -1
- package/dist/types-DwHrGKWO.d.mts +0 -27
- package/dist/types-DwHrGKWO.d.mts.map +0 -1
- package/dist/write-tools-Dx9LfYlU.mjs +0 -1840
- package/dist/write-tools-Dx9LfYlU.mjs.map +0 -1
|
@@ -0,0 +1,1371 @@
|
|
|
1
|
+
import { $ as listWorkflowJobsDescription, $n as listLabelsDescription, $r as getFileContentToModelOutput, $t as searchRepositoriesDescription, A as getLatestReleaseInputSchema, An as addAssigneesInputSchema, Ar as listPullRequestFilesInputSchema, At as listGistsInputSchema, B as getCombinedStatusCore, Bn as createIssueCore, Br as requestReviewersCore, Bt as getCommitCore, C as createReleaseDescription, Ci as listBranchesCore, Cn as listCommentReactionsDescription, Cr as deletePullRequestCommentDescription, Ct as getGistDescription, D as deleteReleaseInputSchema, Dn as listIssueReactionsInputSchema, Dr as getPullRequestInputSchema, Dt as listGistCommentsInputSchema, E as deleteReleaseDescription, En as listIssueReactionsDescription, Er as getPullRequestDescription, Et as listGistCommentsDescription, F as listReleasesDescription, Fn as addLabelsDescription, Fr as listPullRequestsDescription, Ft as compareCommitsDescription, G as listCheckRunsInputSchema, Gn as deleteIssueCommentInputSchema, Gr as updatePullRequestCommentInputSchema, Gt as listCommitsInputSchema, H as getCombinedStatusInputSchema, Hn as createIssueInputSchema, Hr as requestReviewersInputSchema, Ht as getCommitInputSchema, I as listReleasesInputSchema, In as addLabelsInputSchema, Ir as listPullRequestsInputSchema, It as compareCommitsInputSchema, J as cancelWorkflowRunInputSchema, Jn as getIssueInputSchema, Jr as updatePullRequestInputSchema, Jt as searchCodeInputSchema, K as cancelWorkflowRunCore, Kn as getIssueCore, Kr as updatePullRequestCore, Kt as searchCodeCore, L as updateReleaseCore, Ln as closeIssueCore, Lr as mergePullRequestCore, Lt as getBlameCore, M as getReleaseDescription, Mn as addIssueCommentDescription, Mr as listPullRequestReviewsDescription, Mt as updateGistDescription, N as getReleaseInputSchema, Nn as addIssueCommentInputSchema, Nr as listPullRequestReviewsInputSchema, Nt as updateGistInputSchema, O as getLatestReleaseCore, On as addAssigneesCore, Or as listPullRequestFilesCore, Ot as listGistsCore, P as listReleasesCore, Pn as addLabelsCore, Pr as listPullRequestsCore, Pt as compareCommitsCore, Q as listWorkflowJobsCore, Qn as listLabelsCore, Qr as getCommitToModelOutput, Qt as searchRepositoriesCore, R as updateReleaseDescription, Rn as closeIssueDescription, Rr as mergePullRequestDescription, Rt as getBlameDescription, S as createReleaseCore, Si as getRepositoryTreeInputSchema, Sn as listCommentReactionsCore, Sr as deletePullRequestCommentCore, St as getGistCore, T as deleteReleaseCore, Ti as listBranchesInputSchema, Tn as listIssueReactionsCore, Tr as getPullRequestCore, Tt as listGistCommentsCore, U as listCheckRunsCore, Un as deleteIssueCommentCore, Ur as updatePullRequestCommentCore, Ut as listCommitsCore, V as getCombinedStatusDescription, Vn as createIssueDescription, Vr as requestReviewersDescription, Vt as getCommitDescription, W as listCheckRunsDescription, Wn as deleteIssueCommentDescription, Wr as updatePullRequestCommentDescription, Wt as listCommitsDescription, X as getWorkflowRunDescription, Xn as listIssuesDescription, Xr as resolveGithubToken, Xt as searchIssuesDescription, Y as getWorkflowRunCore, Yn as listIssuesCore, Yr as createGithubTokenResolver, Yt as searchIssuesCore, Z as getWorkflowRunInputSchema, Zn as listIssuesInputSchema, Zr as compareCommitsToModelOutput, Zt as searchIssuesInputSchema, _ as getPullRequestContextDescription, _i as getRepositoryCore, _n as addCommentReactionDescription, _r as createPullRequestDescription, _t as createGistDescription, a as resolvePresetTools, ai as createOrUpdateFileCore, an as markNotificationReadDescription, ar as removeLabelDescription, at as listWorkflowsDescription, b as getReleaseContextDescription, bi as getRepositoryTreeCore, bn as addIssueReactionDescription, br as createPullRequestReviewDescription, bt as deleteGistDescription, ci as createRepositoryCore, cn as addDiscussionCommentDescription, cr as updateIssueCommentDescription, ct as rerunWorkflowRunDescription, d as getCiFailureContextDescription, di as forkRepositoryCore, dn as getDiscussionDescription, dr as updateIssueDescription, dt as triggerWorkflowDescription, ei as getPullRequestContextToModelOutput, en as searchRepositoriesInputSchema, er as listLabelsInputSchema, et as listWorkflowJobsInputSchema, f as getCiFailureContextInputSchema, fi as forkRepositoryDescription, fn as getDiscussionInputSchema, fr as updateIssueInputSchema, ft as triggerWorkflowInputSchema, g as getPullRequestContextCore, gi as getFileContentInputSchema, gn as addCommentReactionCore, gr as createPullRequestCore, gt as createGistCore, h as getIssueContextInputSchema, hi as getFileContentDescription, hn as listDiscussionsInputSchema, hr as addPullRequestCommentInputSchema, ht as createGistCommentInputSchema, ii as createBranchInputSchema, in as markNotificationReadCore, ir as removeLabelCore, it as listWorkflowsCore, j as getReleaseCore, jn as addIssueCommentCore, jr as listPullRequestReviewsCore, jt as updateGistCore, k as getLatestReleaseDescription, kn as addAssigneesDescription, kr as listPullRequestFilesDescription, kt as listGistsDescription, li as createRepositoryDescription, ln as addDiscussionCommentInputSchema, lr as updateIssueCommentInputSchema, lt as rerunWorkflowRunInputSchema, m as getIssueContextDescription, mi as getFileContentCore, mn as listDiscussionsDescription, mr as addPullRequestCommentDescription, mt as createGistCommentDescription, ni as createBranchCore, nn as listNotificationsDescription, nr as removeAssigneesDescription, nt as listWorkflowRunsDescription, o as bindToolsContext, oi as createOrUpdateFileDescription, on as markNotificationReadInputSchema, or as removeLabelInputSchema, ot as listWorkflowsInputSchema, p as getIssueContextCore, pi as forkRepositoryInputSchema, pn as listDiscussionsCore, pr as addPullRequestCommentCore, pt as createGistCommentCore, q as cancelWorkflowRunDescription, qn as getIssueDescription, qr as updatePullRequestDescription, qt as searchCodeDescription, ri as createBranchDescription, rn as listNotificationsInputSchema, rr as removeAssigneesInputSchema, rt as listWorkflowRunsInputSchema, s as formatContextInstructions, si as createOrUpdateFileInputSchema, sn as addDiscussionCommentCore, sr as updateIssueCommentCore, st as rerunWorkflowRunCore, ti as listPullRequestFilesToModelOutput, tn as listNotificationsCore, tr as removeAssigneesCore, tt as listWorkflowRunsCore, u as getCiFailureContextCore, ui as createRepositoryInputSchema, un as getDiscussionCore, ur as updateIssueCore, ut as triggerWorkflowCore, v as getPullRequestContextInputSchema, vi as getRepositoryDescription, vn as addCommentReactionInputSchema, vr as createPullRequestInputSchema, vt as createGistInputSchema, w as createReleaseInputSchema, wi as listBranchesDescription, wn as listCommentReactionsInputSchema, wr as deletePullRequestCommentInputSchema, wt as getGistInputSchema, x as getReleaseContextInputSchema, xi as getRepositoryTreeDescription, xn as addIssueReactionInputSchema, xr as createPullRequestReviewInputSchema, xt as deleteGistInputSchema, y as getReleaseContextCore, yi as getRepositoryInputSchema, yn as addIssueReactionCore, yr as createPullRequestReviewCore, yt as deleteGistCore, z as updateReleaseInputSchema, zn as closeIssueInputSchema, zr as mergePullRequestInputSchema, zt as getBlameInputSchema } from "./write-tools-uIVfURVp.mjs";
|
|
2
|
+
import { ToolLoopAgent, tool } from "ai";
|
|
3
|
+
//#region src/tools/repository.ts
|
|
4
|
+
async function getRepositoryStep(args) {
|
|
5
|
+
"use step";
|
|
6
|
+
return getRepositoryCore(args);
|
|
7
|
+
}
|
|
8
|
+
/** Get information about a GitHub repository including description, stars, forks, language, and default branch. */
|
|
9
|
+
const getRepository = (token) => tool({
|
|
10
|
+
description: getRepositoryDescription,
|
|
11
|
+
inputSchema: getRepositoryInputSchema,
|
|
12
|
+
execute: async (args) => getRepositoryStep({
|
|
13
|
+
token: await resolveGithubToken(token),
|
|
14
|
+
...args
|
|
15
|
+
})
|
|
16
|
+
});
|
|
17
|
+
async function listBranchesStep(args) {
|
|
18
|
+
"use step";
|
|
19
|
+
return listBranchesCore(args);
|
|
20
|
+
}
|
|
21
|
+
/** List branches in a GitHub repository. */
|
|
22
|
+
const listBranches = (token) => tool({
|
|
23
|
+
description: listBranchesDescription,
|
|
24
|
+
inputSchema: listBranchesInputSchema,
|
|
25
|
+
execute: async (args) => listBranchesStep({
|
|
26
|
+
token: await resolveGithubToken(token),
|
|
27
|
+
...args
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
async function getFileContentStep(args) {
|
|
31
|
+
"use step";
|
|
32
|
+
return getFileContentCore(args);
|
|
33
|
+
}
|
|
34
|
+
/** Get the content of a file from a GitHub repository. */
|
|
35
|
+
const getFileContent = (token) => tool({
|
|
36
|
+
description: getFileContentDescription,
|
|
37
|
+
inputSchema: getFileContentInputSchema,
|
|
38
|
+
toModelOutput: getFileContentToModelOutput,
|
|
39
|
+
execute: async (args) => getFileContentStep({
|
|
40
|
+
token: await resolveGithubToken(token),
|
|
41
|
+
...args
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
async function getRepositoryTreeStep(args) {
|
|
45
|
+
"use step";
|
|
46
|
+
return getRepositoryTreeCore(args);
|
|
47
|
+
}
|
|
48
|
+
/** List the file and directory structure of a repository at a given ref. */
|
|
49
|
+
const getRepositoryTree = (token) => tool({
|
|
50
|
+
description: getRepositoryTreeDescription,
|
|
51
|
+
inputSchema: getRepositoryTreeInputSchema,
|
|
52
|
+
execute: async (args) => getRepositoryTreeStep({
|
|
53
|
+
token: await resolveGithubToken(token),
|
|
54
|
+
...args
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
async function createBranchStep(args) {
|
|
58
|
+
"use step";
|
|
59
|
+
return createBranchCore(args);
|
|
60
|
+
}
|
|
61
|
+
/** Create a new branch in a GitHub repository from an existing branch or commit SHA. Requires approval by default. */
|
|
62
|
+
const createBranch = (token, { needsApproval = true } = {}) => tool({
|
|
63
|
+
description: createBranchDescription,
|
|
64
|
+
needsApproval,
|
|
65
|
+
inputSchema: createBranchInputSchema,
|
|
66
|
+
execute: async (args) => createBranchStep({
|
|
67
|
+
token: await resolveGithubToken(token),
|
|
68
|
+
...args
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
async function forkRepositoryStep(args) {
|
|
72
|
+
"use step";
|
|
73
|
+
return forkRepositoryCore(args);
|
|
74
|
+
}
|
|
75
|
+
/** Fork a GitHub repository to the authenticated user account or a specified organization. Requires approval by default. */
|
|
76
|
+
const forkRepository = (token, { needsApproval = true } = {}) => tool({
|
|
77
|
+
description: forkRepositoryDescription,
|
|
78
|
+
needsApproval,
|
|
79
|
+
inputSchema: forkRepositoryInputSchema,
|
|
80
|
+
execute: async (args) => forkRepositoryStep({
|
|
81
|
+
token: await resolveGithubToken(token),
|
|
82
|
+
...args
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
async function createRepositoryStep(args) {
|
|
86
|
+
"use step";
|
|
87
|
+
return createRepositoryCore(args);
|
|
88
|
+
}
|
|
89
|
+
/** Create a new GitHub repository for the authenticated user or a specified organization. Requires approval by default. */
|
|
90
|
+
const createRepository = (token, { needsApproval = true } = {}) => tool({
|
|
91
|
+
description: createRepositoryDescription,
|
|
92
|
+
needsApproval,
|
|
93
|
+
inputSchema: createRepositoryInputSchema,
|
|
94
|
+
execute: async (args) => createRepositoryStep({
|
|
95
|
+
token: await resolveGithubToken(token),
|
|
96
|
+
...args
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
async function createOrUpdateFileStep(args) {
|
|
100
|
+
"use step";
|
|
101
|
+
return createOrUpdateFileCore(args);
|
|
102
|
+
}
|
|
103
|
+
/** Create or update a file in a GitHub repository. Provide the SHA when updating an existing file. Requires approval by default. */
|
|
104
|
+
const createOrUpdateFile = (token, { needsApproval = true, author, committer, coAuthors } = {}) => tool({
|
|
105
|
+
description: createOrUpdateFileDescription,
|
|
106
|
+
needsApproval,
|
|
107
|
+
inputSchema: createOrUpdateFileInputSchema,
|
|
108
|
+
execute: async (args) => createOrUpdateFileStep({
|
|
109
|
+
token: await resolveGithubToken(token),
|
|
110
|
+
author,
|
|
111
|
+
committer,
|
|
112
|
+
coAuthors,
|
|
113
|
+
...args
|
|
114
|
+
})
|
|
115
|
+
});
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/tools/pull-requests.ts
|
|
118
|
+
async function listPullRequestsStep(args) {
|
|
119
|
+
"use step";
|
|
120
|
+
return listPullRequestsCore(args);
|
|
121
|
+
}
|
|
122
|
+
/** List pull requests for a GitHub repository. */
|
|
123
|
+
const listPullRequests = (token) => tool({
|
|
124
|
+
description: listPullRequestsDescription,
|
|
125
|
+
inputSchema: listPullRequestsInputSchema,
|
|
126
|
+
execute: async (args) => listPullRequestsStep({
|
|
127
|
+
token: await resolveGithubToken(token),
|
|
128
|
+
...args
|
|
129
|
+
})
|
|
130
|
+
});
|
|
131
|
+
async function getPullRequestStep(args) {
|
|
132
|
+
"use step";
|
|
133
|
+
return getPullRequestCore(args);
|
|
134
|
+
}
|
|
135
|
+
/** Get detailed information about a specific pull request. */
|
|
136
|
+
const getPullRequest = (token) => tool({
|
|
137
|
+
description: getPullRequestDescription,
|
|
138
|
+
inputSchema: getPullRequestInputSchema,
|
|
139
|
+
execute: async (args) => getPullRequestStep({
|
|
140
|
+
token: await resolveGithubToken(token),
|
|
141
|
+
...args
|
|
142
|
+
})
|
|
143
|
+
});
|
|
144
|
+
async function createPullRequestStep(args) {
|
|
145
|
+
"use step";
|
|
146
|
+
return createPullRequestCore(args);
|
|
147
|
+
}
|
|
148
|
+
/** Create a new pull request in a GitHub repository. Requires approval by default. */
|
|
149
|
+
const createPullRequest = (token, { needsApproval = true } = {}) => tool({
|
|
150
|
+
description: createPullRequestDescription,
|
|
151
|
+
needsApproval,
|
|
152
|
+
inputSchema: createPullRequestInputSchema,
|
|
153
|
+
execute: async (args) => createPullRequestStep({
|
|
154
|
+
token: await resolveGithubToken(token),
|
|
155
|
+
...args
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
async function mergePullRequestStep(args) {
|
|
159
|
+
"use step";
|
|
160
|
+
return mergePullRequestCore(args);
|
|
161
|
+
}
|
|
162
|
+
/** Merge a pull request. Requires approval by default. */
|
|
163
|
+
const mergePullRequest = (token, { needsApproval = true, coAuthors } = {}) => tool({
|
|
164
|
+
description: mergePullRequestDescription,
|
|
165
|
+
needsApproval,
|
|
166
|
+
inputSchema: mergePullRequestInputSchema,
|
|
167
|
+
execute: async (args) => mergePullRequestStep({
|
|
168
|
+
token: await resolveGithubToken(token),
|
|
169
|
+
coAuthors,
|
|
170
|
+
...args
|
|
171
|
+
})
|
|
172
|
+
});
|
|
173
|
+
async function updatePullRequestStep(args) {
|
|
174
|
+
"use step";
|
|
175
|
+
return updatePullRequestCore(args);
|
|
176
|
+
}
|
|
177
|
+
/** Update a pull request — title, body, state, base branch, or draft status. Requires approval by default. */
|
|
178
|
+
const updatePullRequest = (token, { needsApproval = true } = {}) => tool({
|
|
179
|
+
description: updatePullRequestDescription,
|
|
180
|
+
needsApproval,
|
|
181
|
+
inputSchema: updatePullRequestInputSchema,
|
|
182
|
+
execute: async (args) => updatePullRequestStep({
|
|
183
|
+
token: await resolveGithubToken(token),
|
|
184
|
+
...args
|
|
185
|
+
})
|
|
186
|
+
});
|
|
187
|
+
async function addPullRequestCommentStep(args) {
|
|
188
|
+
"use step";
|
|
189
|
+
return addPullRequestCommentCore(args);
|
|
190
|
+
}
|
|
191
|
+
/** Add a comment to a pull request. Requires approval by default. */
|
|
192
|
+
const addPullRequestComment = (token, { needsApproval = true } = {}) => tool({
|
|
193
|
+
description: addPullRequestCommentDescription,
|
|
194
|
+
needsApproval,
|
|
195
|
+
inputSchema: addPullRequestCommentInputSchema,
|
|
196
|
+
execute: async (args) => addPullRequestCommentStep({
|
|
197
|
+
token: await resolveGithubToken(token),
|
|
198
|
+
...args
|
|
199
|
+
})
|
|
200
|
+
});
|
|
201
|
+
async function updatePullRequestCommentStep(args) {
|
|
202
|
+
"use step";
|
|
203
|
+
return updatePullRequestCommentCore(args);
|
|
204
|
+
}
|
|
205
|
+
/** Update the body of a comment on a pull request. Requires approval by default. */
|
|
206
|
+
const updatePullRequestComment = (token, { needsApproval = true } = {}) => tool({
|
|
207
|
+
description: updatePullRequestCommentDescription,
|
|
208
|
+
needsApproval,
|
|
209
|
+
inputSchema: updatePullRequestCommentInputSchema,
|
|
210
|
+
execute: async (args) => updatePullRequestCommentStep({
|
|
211
|
+
token: await resolveGithubToken(token),
|
|
212
|
+
...args
|
|
213
|
+
})
|
|
214
|
+
});
|
|
215
|
+
async function deletePullRequestCommentStep(args) {
|
|
216
|
+
"use step";
|
|
217
|
+
return deletePullRequestCommentCore(args);
|
|
218
|
+
}
|
|
219
|
+
/** Delete a comment from a pull request permanently. Requires approval by default. */
|
|
220
|
+
const deletePullRequestComment = (token, { needsApproval = true } = {}) => tool({
|
|
221
|
+
description: deletePullRequestCommentDescription,
|
|
222
|
+
needsApproval,
|
|
223
|
+
inputSchema: deletePullRequestCommentInputSchema,
|
|
224
|
+
execute: async (args) => deletePullRequestCommentStep({
|
|
225
|
+
token: await resolveGithubToken(token),
|
|
226
|
+
...args
|
|
227
|
+
})
|
|
228
|
+
});
|
|
229
|
+
async function listPullRequestFilesStep(args) {
|
|
230
|
+
"use step";
|
|
231
|
+
return listPullRequestFilesCore(args);
|
|
232
|
+
}
|
|
233
|
+
/** List files changed in a pull request with status and stats. Patches omitted by default. */
|
|
234
|
+
const listPullRequestFiles = (token) => tool({
|
|
235
|
+
description: listPullRequestFilesDescription,
|
|
236
|
+
inputSchema: listPullRequestFilesInputSchema,
|
|
237
|
+
toModelOutput: listPullRequestFilesToModelOutput,
|
|
238
|
+
execute: async (args) => listPullRequestFilesStep({
|
|
239
|
+
token: await resolveGithubToken(token),
|
|
240
|
+
...args
|
|
241
|
+
})
|
|
242
|
+
});
|
|
243
|
+
async function listPullRequestReviewsStep(args) {
|
|
244
|
+
"use step";
|
|
245
|
+
return listPullRequestReviewsCore(args);
|
|
246
|
+
}
|
|
247
|
+
/** List reviews on a pull request (approvals, change requests, and comments). */
|
|
248
|
+
const listPullRequestReviews = (token) => tool({
|
|
249
|
+
description: listPullRequestReviewsDescription,
|
|
250
|
+
inputSchema: listPullRequestReviewsInputSchema,
|
|
251
|
+
execute: async (args) => listPullRequestReviewsStep({
|
|
252
|
+
token: await resolveGithubToken(token),
|
|
253
|
+
...args
|
|
254
|
+
})
|
|
255
|
+
});
|
|
256
|
+
async function createPullRequestReviewStep(args) {
|
|
257
|
+
"use step";
|
|
258
|
+
return createPullRequestReviewCore(args);
|
|
259
|
+
}
|
|
260
|
+
/** Submit a pull request review with optional inline comments. Requires approval by default. */
|
|
261
|
+
const createPullRequestReview = (token, { needsApproval = true } = {}) => tool({
|
|
262
|
+
description: createPullRequestReviewDescription,
|
|
263
|
+
needsApproval,
|
|
264
|
+
inputSchema: createPullRequestReviewInputSchema,
|
|
265
|
+
execute: async (args) => createPullRequestReviewStep({
|
|
266
|
+
token: await resolveGithubToken(token),
|
|
267
|
+
...args
|
|
268
|
+
})
|
|
269
|
+
});
|
|
270
|
+
async function requestReviewersStep(args) {
|
|
271
|
+
"use step";
|
|
272
|
+
return requestReviewersCore(args);
|
|
273
|
+
}
|
|
274
|
+
/** Request reviews from users or teams on a pull request. Requires approval by default. */
|
|
275
|
+
const requestReviewers = (token, { needsApproval = true } = {}) => tool({
|
|
276
|
+
description: requestReviewersDescription,
|
|
277
|
+
needsApproval,
|
|
278
|
+
inputSchema: requestReviewersInputSchema,
|
|
279
|
+
execute: async (args) => requestReviewersStep({
|
|
280
|
+
token: await resolveGithubToken(token),
|
|
281
|
+
...args
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/tools/issues.ts
|
|
286
|
+
async function listIssuesStep(args) {
|
|
287
|
+
"use step";
|
|
288
|
+
return listIssuesCore(args);
|
|
289
|
+
}
|
|
290
|
+
/** List issues for a GitHub repository (excludes pull requests). */
|
|
291
|
+
const listIssues = (token) => tool({
|
|
292
|
+
description: listIssuesDescription,
|
|
293
|
+
inputSchema: listIssuesInputSchema,
|
|
294
|
+
execute: async (args) => listIssuesStep({
|
|
295
|
+
token: await resolveGithubToken(token),
|
|
296
|
+
...args
|
|
297
|
+
})
|
|
298
|
+
});
|
|
299
|
+
async function getIssueStep(args) {
|
|
300
|
+
"use step";
|
|
301
|
+
return getIssueCore(args);
|
|
302
|
+
}
|
|
303
|
+
/** Get detailed information about a specific issue. */
|
|
304
|
+
const getIssue = (token) => tool({
|
|
305
|
+
description: getIssueDescription,
|
|
306
|
+
inputSchema: getIssueInputSchema,
|
|
307
|
+
execute: async (args) => getIssueStep({
|
|
308
|
+
token: await resolveGithubToken(token),
|
|
309
|
+
...args
|
|
310
|
+
})
|
|
311
|
+
});
|
|
312
|
+
async function createIssueStep(args) {
|
|
313
|
+
"use step";
|
|
314
|
+
return createIssueCore(args);
|
|
315
|
+
}
|
|
316
|
+
/** Create a new issue in a GitHub repository. Requires approval by default. */
|
|
317
|
+
const createIssue = (token, { needsApproval = true } = {}) => tool({
|
|
318
|
+
description: createIssueDescription,
|
|
319
|
+
needsApproval,
|
|
320
|
+
inputSchema: createIssueInputSchema,
|
|
321
|
+
execute: async (args) => createIssueStep({
|
|
322
|
+
token: await resolveGithubToken(token),
|
|
323
|
+
...args
|
|
324
|
+
})
|
|
325
|
+
});
|
|
326
|
+
async function addIssueCommentStep(args) {
|
|
327
|
+
"use step";
|
|
328
|
+
return addIssueCommentCore(args);
|
|
329
|
+
}
|
|
330
|
+
/** Add a comment to a GitHub issue. Requires approval by default. */
|
|
331
|
+
const addIssueComment = (token, { needsApproval = true } = {}) => tool({
|
|
332
|
+
description: addIssueCommentDescription,
|
|
333
|
+
needsApproval,
|
|
334
|
+
inputSchema: addIssueCommentInputSchema,
|
|
335
|
+
execute: async (args) => addIssueCommentStep({
|
|
336
|
+
token: await resolveGithubToken(token),
|
|
337
|
+
...args
|
|
338
|
+
})
|
|
339
|
+
});
|
|
340
|
+
async function closeIssueStep(args) {
|
|
341
|
+
"use step";
|
|
342
|
+
return closeIssueCore(args);
|
|
343
|
+
}
|
|
344
|
+
/** Close an open GitHub issue. Requires approval by default. */
|
|
345
|
+
const closeIssue = (token, { needsApproval = true } = {}) => tool({
|
|
346
|
+
description: closeIssueDescription,
|
|
347
|
+
needsApproval,
|
|
348
|
+
inputSchema: closeIssueInputSchema,
|
|
349
|
+
execute: async (args) => closeIssueStep({
|
|
350
|
+
token: await resolveGithubToken(token),
|
|
351
|
+
...args
|
|
352
|
+
})
|
|
353
|
+
});
|
|
354
|
+
async function updateIssueStep(args) {
|
|
355
|
+
"use step";
|
|
356
|
+
return updateIssueCore(args);
|
|
357
|
+
}
|
|
358
|
+
/** Update a GitHub issue — title, body, state, labels, milestone, or assignees. Requires approval by default. */
|
|
359
|
+
const updateIssue = (token, { needsApproval = true } = {}) => tool({
|
|
360
|
+
description: updateIssueDescription,
|
|
361
|
+
needsApproval,
|
|
362
|
+
inputSchema: updateIssueInputSchema,
|
|
363
|
+
execute: async (args) => updateIssueStep({
|
|
364
|
+
token: await resolveGithubToken(token),
|
|
365
|
+
...args
|
|
366
|
+
})
|
|
367
|
+
});
|
|
368
|
+
async function updateIssueCommentStep(args) {
|
|
369
|
+
"use step";
|
|
370
|
+
return updateIssueCommentCore(args);
|
|
371
|
+
}
|
|
372
|
+
/** Update the body of a comment on a GitHub issue. Requires approval by default. */
|
|
373
|
+
const updateIssueComment = (token, { needsApproval = true } = {}) => tool({
|
|
374
|
+
description: updateIssueCommentDescription,
|
|
375
|
+
needsApproval,
|
|
376
|
+
inputSchema: updateIssueCommentInputSchema,
|
|
377
|
+
execute: async (args) => updateIssueCommentStep({
|
|
378
|
+
token: await resolveGithubToken(token),
|
|
379
|
+
...args
|
|
380
|
+
})
|
|
381
|
+
});
|
|
382
|
+
async function deleteIssueCommentStep(args) {
|
|
383
|
+
"use step";
|
|
384
|
+
return deleteIssueCommentCore(args);
|
|
385
|
+
}
|
|
386
|
+
/** Delete a comment from a GitHub issue permanently. Requires approval by default. */
|
|
387
|
+
const deleteIssueComment = (token, { needsApproval = true } = {}) => tool({
|
|
388
|
+
description: deleteIssueCommentDescription,
|
|
389
|
+
needsApproval,
|
|
390
|
+
inputSchema: deleteIssueCommentInputSchema,
|
|
391
|
+
execute: async (args) => deleteIssueCommentStep({
|
|
392
|
+
token: await resolveGithubToken(token),
|
|
393
|
+
...args
|
|
394
|
+
})
|
|
395
|
+
});
|
|
396
|
+
async function listLabelsStep(args) {
|
|
397
|
+
"use step";
|
|
398
|
+
return listLabelsCore(args);
|
|
399
|
+
}
|
|
400
|
+
/** List labels available in a GitHub repository. */
|
|
401
|
+
const listLabels = (token) => tool({
|
|
402
|
+
description: listLabelsDescription,
|
|
403
|
+
inputSchema: listLabelsInputSchema,
|
|
404
|
+
execute: async (args) => listLabelsStep({
|
|
405
|
+
token: await resolveGithubToken(token),
|
|
406
|
+
...args
|
|
407
|
+
})
|
|
408
|
+
});
|
|
409
|
+
async function addLabelsStep(args) {
|
|
410
|
+
"use step";
|
|
411
|
+
return addLabelsCore(args);
|
|
412
|
+
}
|
|
413
|
+
/** Add labels to an issue or pull request. Requires approval by default. */
|
|
414
|
+
const addLabels = (token, { needsApproval = true } = {}) => tool({
|
|
415
|
+
description: addLabelsDescription,
|
|
416
|
+
needsApproval,
|
|
417
|
+
inputSchema: addLabelsInputSchema,
|
|
418
|
+
execute: async (args) => addLabelsStep({
|
|
419
|
+
token: await resolveGithubToken(token),
|
|
420
|
+
...args
|
|
421
|
+
})
|
|
422
|
+
});
|
|
423
|
+
async function removeLabelStep(args) {
|
|
424
|
+
"use step";
|
|
425
|
+
return removeLabelCore(args);
|
|
426
|
+
}
|
|
427
|
+
/** Remove a label from an issue or pull request. Requires approval by default. */
|
|
428
|
+
const removeLabel = (token, { needsApproval = true } = {}) => tool({
|
|
429
|
+
description: removeLabelDescription,
|
|
430
|
+
needsApproval,
|
|
431
|
+
inputSchema: removeLabelInputSchema,
|
|
432
|
+
execute: async (args) => removeLabelStep({
|
|
433
|
+
token: await resolveGithubToken(token),
|
|
434
|
+
...args
|
|
435
|
+
})
|
|
436
|
+
});
|
|
437
|
+
async function addAssigneesStep(args) {
|
|
438
|
+
"use step";
|
|
439
|
+
return addAssigneesCore(args);
|
|
440
|
+
}
|
|
441
|
+
/** Assign users to an issue or pull request. Requires approval by default. */
|
|
442
|
+
const addAssignees = (token, { needsApproval = true } = {}) => tool({
|
|
443
|
+
description: addAssigneesDescription,
|
|
444
|
+
needsApproval,
|
|
445
|
+
inputSchema: addAssigneesInputSchema,
|
|
446
|
+
execute: async (args) => addAssigneesStep({
|
|
447
|
+
token: await resolveGithubToken(token),
|
|
448
|
+
...args
|
|
449
|
+
})
|
|
450
|
+
});
|
|
451
|
+
async function removeAssigneesStep(args) {
|
|
452
|
+
"use step";
|
|
453
|
+
return removeAssigneesCore(args);
|
|
454
|
+
}
|
|
455
|
+
/** Remove assignees from an issue or pull request. Requires approval by default. */
|
|
456
|
+
const removeAssignees = (token, { needsApproval = true } = {}) => tool({
|
|
457
|
+
description: removeAssigneesDescription,
|
|
458
|
+
needsApproval,
|
|
459
|
+
inputSchema: removeAssigneesInputSchema,
|
|
460
|
+
execute: async (args) => removeAssigneesStep({
|
|
461
|
+
token: await resolveGithubToken(token),
|
|
462
|
+
...args
|
|
463
|
+
})
|
|
464
|
+
});
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/tools/reactions.ts
|
|
467
|
+
async function listIssueReactionsStep(args) {
|
|
468
|
+
"use step";
|
|
469
|
+
return listIssueReactionsCore(args);
|
|
470
|
+
}
|
|
471
|
+
/** List reactions on an issue or pull request conversation. */
|
|
472
|
+
const listIssueReactions = (token) => tool({
|
|
473
|
+
description: listIssueReactionsDescription,
|
|
474
|
+
inputSchema: listIssueReactionsInputSchema,
|
|
475
|
+
execute: async (args) => listIssueReactionsStep({
|
|
476
|
+
token: await resolveGithubToken(token),
|
|
477
|
+
...args
|
|
478
|
+
})
|
|
479
|
+
});
|
|
480
|
+
async function addIssueReactionStep(args) {
|
|
481
|
+
"use step";
|
|
482
|
+
return addIssueReactionCore(args);
|
|
483
|
+
}
|
|
484
|
+
/** React to an issue or pull request with an emoji. Requires approval by default. */
|
|
485
|
+
const addIssueReaction = (token, { needsApproval = true } = {}) => tool({
|
|
486
|
+
description: addIssueReactionDescription,
|
|
487
|
+
needsApproval,
|
|
488
|
+
inputSchema: addIssueReactionInputSchema,
|
|
489
|
+
execute: async (args) => addIssueReactionStep({
|
|
490
|
+
token: await resolveGithubToken(token),
|
|
491
|
+
...args
|
|
492
|
+
})
|
|
493
|
+
});
|
|
494
|
+
async function listCommentReactionsStep(args) {
|
|
495
|
+
"use step";
|
|
496
|
+
return listCommentReactionsCore(args);
|
|
497
|
+
}
|
|
498
|
+
/** List reactions on an issue or pull request comment. */
|
|
499
|
+
const listCommentReactions = (token) => tool({
|
|
500
|
+
description: listCommentReactionsDescription,
|
|
501
|
+
inputSchema: listCommentReactionsInputSchema,
|
|
502
|
+
execute: async (args) => listCommentReactionsStep({
|
|
503
|
+
token: await resolveGithubToken(token),
|
|
504
|
+
...args
|
|
505
|
+
})
|
|
506
|
+
});
|
|
507
|
+
async function addCommentReactionStep(args) {
|
|
508
|
+
"use step";
|
|
509
|
+
return addCommentReactionCore(args);
|
|
510
|
+
}
|
|
511
|
+
/** React to an issue or pull request comment with an emoji. Requires approval by default. */
|
|
512
|
+
const addCommentReaction = (token, { needsApproval = true } = {}) => tool({
|
|
513
|
+
description: addCommentReactionDescription,
|
|
514
|
+
needsApproval,
|
|
515
|
+
inputSchema: addCommentReactionInputSchema,
|
|
516
|
+
execute: async (args) => addCommentReactionStep({
|
|
517
|
+
token: await resolveGithubToken(token),
|
|
518
|
+
...args
|
|
519
|
+
})
|
|
520
|
+
});
|
|
521
|
+
//#endregion
|
|
522
|
+
//#region src/tools/discussions.ts
|
|
523
|
+
async function listDiscussionsStep(args) {
|
|
524
|
+
"use step";
|
|
525
|
+
return listDiscussionsCore(args);
|
|
526
|
+
}
|
|
527
|
+
/** List discussions in a repository, optionally filtered by category. */
|
|
528
|
+
const listDiscussions = (token) => tool({
|
|
529
|
+
description: listDiscussionsDescription,
|
|
530
|
+
inputSchema: listDiscussionsInputSchema,
|
|
531
|
+
execute: async (args) => listDiscussionsStep({
|
|
532
|
+
token: await resolveGithubToken(token),
|
|
533
|
+
...args
|
|
534
|
+
})
|
|
535
|
+
});
|
|
536
|
+
async function getDiscussionStep(args) {
|
|
537
|
+
"use step";
|
|
538
|
+
return getDiscussionCore(args);
|
|
539
|
+
}
|
|
540
|
+
/** Get a discussion by number. */
|
|
541
|
+
const getDiscussion = (token) => tool({
|
|
542
|
+
description: getDiscussionDescription,
|
|
543
|
+
inputSchema: getDiscussionInputSchema,
|
|
544
|
+
execute: async (args) => getDiscussionStep({
|
|
545
|
+
token: await resolveGithubToken(token),
|
|
546
|
+
...args
|
|
547
|
+
})
|
|
548
|
+
});
|
|
549
|
+
async function addDiscussionCommentStep(args) {
|
|
550
|
+
"use step";
|
|
551
|
+
return addDiscussionCommentCore(args);
|
|
552
|
+
}
|
|
553
|
+
/** Add a comment to a discussion. Requires approval by default. */
|
|
554
|
+
const addDiscussionComment = (token, { needsApproval = true } = {}) => tool({
|
|
555
|
+
description: addDiscussionCommentDescription,
|
|
556
|
+
needsApproval,
|
|
557
|
+
inputSchema: addDiscussionCommentInputSchema,
|
|
558
|
+
execute: async (args) => addDiscussionCommentStep({
|
|
559
|
+
token: await resolveGithubToken(token),
|
|
560
|
+
...args
|
|
561
|
+
})
|
|
562
|
+
});
|
|
563
|
+
//#endregion
|
|
564
|
+
//#region src/tools/notifications.ts
|
|
565
|
+
async function listNotificationsStep(args) {
|
|
566
|
+
"use step";
|
|
567
|
+
return listNotificationsCore(args);
|
|
568
|
+
}
|
|
569
|
+
/** List notification threads for the authenticated user. */
|
|
570
|
+
const listNotifications = (token) => tool({
|
|
571
|
+
description: listNotificationsDescription,
|
|
572
|
+
inputSchema: listNotificationsInputSchema,
|
|
573
|
+
execute: async (args) => listNotificationsStep({
|
|
574
|
+
token: await resolveGithubToken(token),
|
|
575
|
+
...args
|
|
576
|
+
})
|
|
577
|
+
});
|
|
578
|
+
async function markNotificationReadStep(args) {
|
|
579
|
+
"use step";
|
|
580
|
+
return markNotificationReadCore(args);
|
|
581
|
+
}
|
|
582
|
+
/** Mark a notification thread as read. Requires approval by default. */
|
|
583
|
+
const markNotificationRead = (token, { needsApproval = true } = {}) => tool({
|
|
584
|
+
description: markNotificationReadDescription,
|
|
585
|
+
needsApproval,
|
|
586
|
+
inputSchema: markNotificationReadInputSchema,
|
|
587
|
+
execute: async (args) => markNotificationReadStep({
|
|
588
|
+
token: await resolveGithubToken(token),
|
|
589
|
+
...args
|
|
590
|
+
})
|
|
591
|
+
});
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/tools/search.ts
|
|
594
|
+
async function searchCodeStep(args) {
|
|
595
|
+
"use step";
|
|
596
|
+
return searchCodeCore(args);
|
|
597
|
+
}
|
|
598
|
+
/** 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. */
|
|
599
|
+
const searchCode = (token) => tool({
|
|
600
|
+
description: searchCodeDescription,
|
|
601
|
+
inputSchema: searchCodeInputSchema,
|
|
602
|
+
execute: async (args) => searchCodeStep({
|
|
603
|
+
token: await resolveGithubToken(token),
|
|
604
|
+
...args
|
|
605
|
+
})
|
|
606
|
+
});
|
|
607
|
+
async function searchRepositoriesStep(args) {
|
|
608
|
+
"use step";
|
|
609
|
+
return searchRepositoriesCore(args);
|
|
610
|
+
}
|
|
611
|
+
/** Search for GitHub repositories by keyword, topic, language, or other qualifiers. */
|
|
612
|
+
const searchRepositories = (token) => tool({
|
|
613
|
+
description: searchRepositoriesDescription,
|
|
614
|
+
inputSchema: searchRepositoriesInputSchema,
|
|
615
|
+
execute: async (args) => searchRepositoriesStep({
|
|
616
|
+
token: await resolveGithubToken(token),
|
|
617
|
+
...args
|
|
618
|
+
})
|
|
619
|
+
});
|
|
620
|
+
async function searchIssuesStep(args) {
|
|
621
|
+
"use step";
|
|
622
|
+
return searchIssuesCore(args);
|
|
623
|
+
}
|
|
624
|
+
/** Search for issues and pull requests across GitHub using search qualifiers like "repo:owner/name is:open". */
|
|
625
|
+
const searchIssues = (token) => tool({
|
|
626
|
+
description: searchIssuesDescription,
|
|
627
|
+
inputSchema: searchIssuesInputSchema,
|
|
628
|
+
execute: async (args) => searchIssuesStep({
|
|
629
|
+
token: await resolveGithubToken(token),
|
|
630
|
+
...args
|
|
631
|
+
})
|
|
632
|
+
});
|
|
633
|
+
//#endregion
|
|
634
|
+
//#region src/tools/commits.ts
|
|
635
|
+
async function listCommitsStep(args) {
|
|
636
|
+
"use step";
|
|
637
|
+
return listCommitsCore(args);
|
|
638
|
+
}
|
|
639
|
+
/** List commits for a GitHub repository. Filter by file path to see commits that touched a file. */
|
|
640
|
+
const listCommits = (token) => tool({
|
|
641
|
+
description: listCommitsDescription,
|
|
642
|
+
inputSchema: listCommitsInputSchema,
|
|
643
|
+
execute: async (args) => listCommitsStep({
|
|
644
|
+
token: await resolveGithubToken(token),
|
|
645
|
+
...args
|
|
646
|
+
})
|
|
647
|
+
});
|
|
648
|
+
async function getCommitStep(args) {
|
|
649
|
+
"use step";
|
|
650
|
+
return getCommitCore(args);
|
|
651
|
+
}
|
|
652
|
+
/** Get detailed information about a specific commit. Patches omitted by default. */
|
|
653
|
+
const getCommit = (token) => tool({
|
|
654
|
+
description: getCommitDescription,
|
|
655
|
+
inputSchema: getCommitInputSchema,
|
|
656
|
+
toModelOutput: getCommitToModelOutput,
|
|
657
|
+
execute: async (args) => getCommitStep({
|
|
658
|
+
token: await resolveGithubToken(token),
|
|
659
|
+
...args
|
|
660
|
+
})
|
|
661
|
+
});
|
|
662
|
+
async function getBlameStep(args) {
|
|
663
|
+
"use step";
|
|
664
|
+
return getBlameCore(args);
|
|
665
|
+
}
|
|
666
|
+
/** Line-level git blame for a file at a commit-like ref (branch, tag, or SHA). */
|
|
667
|
+
const getBlame = (token) => tool({
|
|
668
|
+
description: getBlameDescription,
|
|
669
|
+
inputSchema: getBlameInputSchema,
|
|
670
|
+
execute: async (args) => getBlameStep({
|
|
671
|
+
token: await resolveGithubToken(token),
|
|
672
|
+
...args
|
|
673
|
+
})
|
|
674
|
+
});
|
|
675
|
+
async function compareCommitsStep(args) {
|
|
676
|
+
"use step";
|
|
677
|
+
return compareCommitsCore(args);
|
|
678
|
+
}
|
|
679
|
+
/** Compare two branches, tags, or commits. Patches omitted by default. */
|
|
680
|
+
const compareCommits = (token) => tool({
|
|
681
|
+
description: compareCommitsDescription,
|
|
682
|
+
inputSchema: compareCommitsInputSchema,
|
|
683
|
+
toModelOutput: compareCommitsToModelOutput,
|
|
684
|
+
execute: async (args) => compareCommitsStep({
|
|
685
|
+
token: await resolveGithubToken(token),
|
|
686
|
+
...args
|
|
687
|
+
})
|
|
688
|
+
});
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region src/tools/gists.ts
|
|
691
|
+
async function listGistsStep(args) {
|
|
692
|
+
"use step";
|
|
693
|
+
return listGistsCore(args);
|
|
694
|
+
}
|
|
695
|
+
/** List gists for the authenticated user or a specific user. */
|
|
696
|
+
const listGists = (token) => tool({
|
|
697
|
+
description: listGistsDescription,
|
|
698
|
+
inputSchema: listGistsInputSchema,
|
|
699
|
+
execute: async (args) => listGistsStep({
|
|
700
|
+
token: await resolveGithubToken(token),
|
|
701
|
+
...args
|
|
702
|
+
})
|
|
703
|
+
});
|
|
704
|
+
async function getGistStep(args) {
|
|
705
|
+
"use step";
|
|
706
|
+
return getGistCore(args);
|
|
707
|
+
}
|
|
708
|
+
/** Get a gist by ID, including file contents. */
|
|
709
|
+
const getGist = (token) => tool({
|
|
710
|
+
description: getGistDescription,
|
|
711
|
+
inputSchema: getGistInputSchema,
|
|
712
|
+
execute: async (args) => getGistStep({
|
|
713
|
+
token: await resolveGithubToken(token),
|
|
714
|
+
...args
|
|
715
|
+
})
|
|
716
|
+
});
|
|
717
|
+
async function listGistCommentsStep(args) {
|
|
718
|
+
"use step";
|
|
719
|
+
return listGistCommentsCore(args);
|
|
720
|
+
}
|
|
721
|
+
/** List comments on a gist. */
|
|
722
|
+
const listGistComments = (token) => tool({
|
|
723
|
+
description: listGistCommentsDescription,
|
|
724
|
+
inputSchema: listGistCommentsInputSchema,
|
|
725
|
+
execute: async (args) => listGistCommentsStep({
|
|
726
|
+
token: await resolveGithubToken(token),
|
|
727
|
+
...args
|
|
728
|
+
})
|
|
729
|
+
});
|
|
730
|
+
async function createGistStep(args) {
|
|
731
|
+
"use step";
|
|
732
|
+
return createGistCore(args);
|
|
733
|
+
}
|
|
734
|
+
/** Create a new gist with one or more files. Requires approval by default. */
|
|
735
|
+
const createGist = (token, { needsApproval = true } = {}) => tool({
|
|
736
|
+
description: createGistDescription,
|
|
737
|
+
needsApproval,
|
|
738
|
+
inputSchema: createGistInputSchema,
|
|
739
|
+
execute: async (args) => createGistStep({
|
|
740
|
+
token: await resolveGithubToken(token),
|
|
741
|
+
...args
|
|
742
|
+
})
|
|
743
|
+
});
|
|
744
|
+
async function updateGistStep(args) {
|
|
745
|
+
"use step";
|
|
746
|
+
return updateGistCore(args);
|
|
747
|
+
}
|
|
748
|
+
/** Update an existing gist. Requires approval by default. */
|
|
749
|
+
const updateGist = (token, { needsApproval = true } = {}) => tool({
|
|
750
|
+
description: updateGistDescription,
|
|
751
|
+
needsApproval,
|
|
752
|
+
inputSchema: updateGistInputSchema,
|
|
753
|
+
execute: async (args) => updateGistStep({
|
|
754
|
+
token: await resolveGithubToken(token),
|
|
755
|
+
...args
|
|
756
|
+
})
|
|
757
|
+
});
|
|
758
|
+
async function deleteGistStep(args) {
|
|
759
|
+
"use step";
|
|
760
|
+
return deleteGistCore(args);
|
|
761
|
+
}
|
|
762
|
+
/** Delete a gist permanently. Requires approval by default. */
|
|
763
|
+
const deleteGist = (token, { needsApproval = true } = {}) => tool({
|
|
764
|
+
description: deleteGistDescription,
|
|
765
|
+
needsApproval,
|
|
766
|
+
inputSchema: deleteGistInputSchema,
|
|
767
|
+
execute: async (args) => deleteGistStep({
|
|
768
|
+
token: await resolveGithubToken(token),
|
|
769
|
+
...args
|
|
770
|
+
})
|
|
771
|
+
});
|
|
772
|
+
async function createGistCommentStep(args) {
|
|
773
|
+
"use step";
|
|
774
|
+
return createGistCommentCore(args);
|
|
775
|
+
}
|
|
776
|
+
/** Add a comment to a gist. Requires approval by default. */
|
|
777
|
+
const createGistComment = (token, { needsApproval = true } = {}) => tool({
|
|
778
|
+
description: createGistCommentDescription,
|
|
779
|
+
needsApproval,
|
|
780
|
+
inputSchema: createGistCommentInputSchema,
|
|
781
|
+
execute: async (args) => createGistCommentStep({
|
|
782
|
+
token: await resolveGithubToken(token),
|
|
783
|
+
...args
|
|
784
|
+
})
|
|
785
|
+
});
|
|
786
|
+
//#endregion
|
|
787
|
+
//#region src/tools/workflows.ts
|
|
788
|
+
async function listWorkflowsStep(args) {
|
|
789
|
+
"use step";
|
|
790
|
+
return listWorkflowsCore(args);
|
|
791
|
+
}
|
|
792
|
+
/** List GitHub Actions workflows in a repository. */
|
|
793
|
+
const listWorkflows = (token) => tool({
|
|
794
|
+
description: listWorkflowsDescription,
|
|
795
|
+
inputSchema: listWorkflowsInputSchema,
|
|
796
|
+
execute: async (args) => listWorkflowsStep({
|
|
797
|
+
token: await resolveGithubToken(token),
|
|
798
|
+
...args
|
|
799
|
+
})
|
|
800
|
+
});
|
|
801
|
+
async function listWorkflowRunsStep(args) {
|
|
802
|
+
"use step";
|
|
803
|
+
return listWorkflowRunsCore(args);
|
|
804
|
+
}
|
|
805
|
+
/** List workflow runs for a repository, optionally filtered by workflow, branch, status, or event. */
|
|
806
|
+
const listWorkflowRuns = (token) => tool({
|
|
807
|
+
description: listWorkflowRunsDescription,
|
|
808
|
+
inputSchema: listWorkflowRunsInputSchema,
|
|
809
|
+
execute: async (args) => listWorkflowRunsStep({
|
|
810
|
+
token: await resolveGithubToken(token),
|
|
811
|
+
...args
|
|
812
|
+
})
|
|
813
|
+
});
|
|
814
|
+
async function getWorkflowRunStep(args) {
|
|
815
|
+
"use step";
|
|
816
|
+
return getWorkflowRunCore(args);
|
|
817
|
+
}
|
|
818
|
+
/** Get details of a specific workflow run including status, timing, and trigger info. */
|
|
819
|
+
const getWorkflowRun = (token) => tool({
|
|
820
|
+
description: getWorkflowRunDescription,
|
|
821
|
+
inputSchema: getWorkflowRunInputSchema,
|
|
822
|
+
execute: async (args) => getWorkflowRunStep({
|
|
823
|
+
token: await resolveGithubToken(token),
|
|
824
|
+
...args
|
|
825
|
+
})
|
|
826
|
+
});
|
|
827
|
+
async function listWorkflowJobsStep(args) {
|
|
828
|
+
"use step";
|
|
829
|
+
return listWorkflowJobsCore(args);
|
|
830
|
+
}
|
|
831
|
+
/** List jobs for a workflow run, including step-level status and timing. */
|
|
832
|
+
const listWorkflowJobs = (token) => tool({
|
|
833
|
+
description: listWorkflowJobsDescription,
|
|
834
|
+
inputSchema: listWorkflowJobsInputSchema,
|
|
835
|
+
execute: async (args) => listWorkflowJobsStep({
|
|
836
|
+
token: await resolveGithubToken(token),
|
|
837
|
+
...args
|
|
838
|
+
})
|
|
839
|
+
});
|
|
840
|
+
async function triggerWorkflowStep(args) {
|
|
841
|
+
"use step";
|
|
842
|
+
return triggerWorkflowCore(args);
|
|
843
|
+
}
|
|
844
|
+
/** Trigger a workflow via workflow_dispatch event. Requires approval by default. */
|
|
845
|
+
const triggerWorkflow = (token, { needsApproval = true } = {}) => tool({
|
|
846
|
+
description: triggerWorkflowDescription,
|
|
847
|
+
needsApproval,
|
|
848
|
+
inputSchema: triggerWorkflowInputSchema,
|
|
849
|
+
execute: async (args) => triggerWorkflowStep({
|
|
850
|
+
token: await resolveGithubToken(token),
|
|
851
|
+
...args
|
|
852
|
+
})
|
|
853
|
+
});
|
|
854
|
+
async function cancelWorkflowRunStep(args) {
|
|
855
|
+
"use step";
|
|
856
|
+
return cancelWorkflowRunCore(args);
|
|
857
|
+
}
|
|
858
|
+
/** Cancel an in-progress workflow run. Requires approval by default. */
|
|
859
|
+
const cancelWorkflowRun = (token, { needsApproval = true } = {}) => tool({
|
|
860
|
+
description: cancelWorkflowRunDescription,
|
|
861
|
+
needsApproval,
|
|
862
|
+
inputSchema: cancelWorkflowRunInputSchema,
|
|
863
|
+
execute: async (args) => cancelWorkflowRunStep({
|
|
864
|
+
token: await resolveGithubToken(token),
|
|
865
|
+
...args
|
|
866
|
+
})
|
|
867
|
+
});
|
|
868
|
+
async function rerunWorkflowRunStep(args) {
|
|
869
|
+
"use step";
|
|
870
|
+
return rerunWorkflowRunCore(args);
|
|
871
|
+
}
|
|
872
|
+
/** Re-run a workflow run, optionally only the failed jobs. Requires approval by default. */
|
|
873
|
+
const rerunWorkflowRun = (token, { needsApproval = true } = {}) => tool({
|
|
874
|
+
description: rerunWorkflowRunDescription,
|
|
875
|
+
needsApproval,
|
|
876
|
+
inputSchema: rerunWorkflowRunInputSchema,
|
|
877
|
+
execute: async (args) => rerunWorkflowRunStep({
|
|
878
|
+
token: await resolveGithubToken(token),
|
|
879
|
+
...args
|
|
880
|
+
})
|
|
881
|
+
});
|
|
882
|
+
//#endregion
|
|
883
|
+
//#region src/tools/checks.ts
|
|
884
|
+
async function listCheckRunsStep(args) {
|
|
885
|
+
"use step";
|
|
886
|
+
return listCheckRunsCore(args);
|
|
887
|
+
}
|
|
888
|
+
/** List check runs (Checks API — GitHub Actions and other CI providers) for a commit, branch, or tag. */
|
|
889
|
+
const listCheckRuns = (token) => tool({
|
|
890
|
+
description: listCheckRunsDescription,
|
|
891
|
+
inputSchema: listCheckRunsInputSchema,
|
|
892
|
+
execute: async (args) => listCheckRunsStep({
|
|
893
|
+
token: await resolveGithubToken(token),
|
|
894
|
+
...args
|
|
895
|
+
})
|
|
896
|
+
});
|
|
897
|
+
async function getCombinedStatusStep(args) {
|
|
898
|
+
"use step";
|
|
899
|
+
return getCombinedStatusCore(args);
|
|
900
|
+
}
|
|
901
|
+
/** Get the combined commit status (Statuses API — legacy CI integrations) for a commit, branch, or tag. */
|
|
902
|
+
const getCombinedStatus = (token) => tool({
|
|
903
|
+
description: getCombinedStatusDescription,
|
|
904
|
+
inputSchema: getCombinedStatusInputSchema,
|
|
905
|
+
execute: async (args) => getCombinedStatusStep({
|
|
906
|
+
token: await resolveGithubToken(token),
|
|
907
|
+
...args
|
|
908
|
+
})
|
|
909
|
+
});
|
|
910
|
+
//#endregion
|
|
911
|
+
//#region src/tools/releases.ts
|
|
912
|
+
async function listReleasesStep(args) {
|
|
913
|
+
"use step";
|
|
914
|
+
return listReleasesCore(args);
|
|
915
|
+
}
|
|
916
|
+
/** List releases for a GitHub repository, newest first (includes drafts and prereleases). */
|
|
917
|
+
const listReleases = (token) => tool({
|
|
918
|
+
description: listReleasesDescription,
|
|
919
|
+
inputSchema: listReleasesInputSchema,
|
|
920
|
+
execute: async (args) => listReleasesStep({
|
|
921
|
+
token: await resolveGithubToken(token),
|
|
922
|
+
...args
|
|
923
|
+
})
|
|
924
|
+
});
|
|
925
|
+
async function getLatestReleaseStep(args) {
|
|
926
|
+
"use step";
|
|
927
|
+
return getLatestReleaseCore(args);
|
|
928
|
+
}
|
|
929
|
+
/** Get the latest published release for a GitHub repository (excludes drafts and prereleases). */
|
|
930
|
+
const getLatestRelease = (token) => tool({
|
|
931
|
+
description: getLatestReleaseDescription,
|
|
932
|
+
inputSchema: getLatestReleaseInputSchema,
|
|
933
|
+
execute: async (args) => getLatestReleaseStep({
|
|
934
|
+
token: await resolveGithubToken(token),
|
|
935
|
+
...args
|
|
936
|
+
})
|
|
937
|
+
});
|
|
938
|
+
async function getReleaseStep(args) {
|
|
939
|
+
"use step";
|
|
940
|
+
return getReleaseCore(args);
|
|
941
|
+
}
|
|
942
|
+
/** Get a specific release by ID, including its assets. */
|
|
943
|
+
const getRelease = (token) => tool({
|
|
944
|
+
description: getReleaseDescription,
|
|
945
|
+
inputSchema: getReleaseInputSchema,
|
|
946
|
+
execute: async (args) => getReleaseStep({
|
|
947
|
+
token: await resolveGithubToken(token),
|
|
948
|
+
...args
|
|
949
|
+
})
|
|
950
|
+
});
|
|
951
|
+
async function createReleaseStep(args) {
|
|
952
|
+
"use step";
|
|
953
|
+
return createReleaseCore(args);
|
|
954
|
+
}
|
|
955
|
+
/** Create a new release (and its tag if needed) in a GitHub repository. Requires approval by default. */
|
|
956
|
+
const createRelease = (token, { needsApproval = true } = {}) => tool({
|
|
957
|
+
description: createReleaseDescription,
|
|
958
|
+
needsApproval,
|
|
959
|
+
inputSchema: createReleaseInputSchema,
|
|
960
|
+
execute: async (args) => createReleaseStep({
|
|
961
|
+
token: await resolveGithubToken(token),
|
|
962
|
+
...args
|
|
963
|
+
})
|
|
964
|
+
});
|
|
965
|
+
async function updateReleaseStep(args) {
|
|
966
|
+
"use step";
|
|
967
|
+
return updateReleaseCore(args);
|
|
968
|
+
}
|
|
969
|
+
/** Update an existing release — tag, target, title, notes, draft, or prerelease status. Requires approval by default. */
|
|
970
|
+
const updateRelease = (token, { needsApproval = true } = {}) => tool({
|
|
971
|
+
description: updateReleaseDescription,
|
|
972
|
+
needsApproval,
|
|
973
|
+
inputSchema: updateReleaseInputSchema,
|
|
974
|
+
execute: async (args) => updateReleaseStep({
|
|
975
|
+
token: await resolveGithubToken(token),
|
|
976
|
+
...args
|
|
977
|
+
})
|
|
978
|
+
});
|
|
979
|
+
async function deleteReleaseStep(args) {
|
|
980
|
+
"use step";
|
|
981
|
+
return deleteReleaseCore(args);
|
|
982
|
+
}
|
|
983
|
+
/** Delete a release permanently. Requires approval by default. */
|
|
984
|
+
const deleteRelease = (token, { needsApproval = true } = {}) => tool({
|
|
985
|
+
description: deleteReleaseDescription,
|
|
986
|
+
needsApproval,
|
|
987
|
+
inputSchema: deleteReleaseInputSchema,
|
|
988
|
+
execute: async (args) => deleteReleaseStep({
|
|
989
|
+
token: await resolveGithubToken(token),
|
|
990
|
+
...args
|
|
991
|
+
})
|
|
992
|
+
});
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/tools/bundles.ts
|
|
995
|
+
async function getPullRequestContextStep(args) {
|
|
996
|
+
"use step";
|
|
997
|
+
return getPullRequestContextCore(args);
|
|
998
|
+
}
|
|
999
|
+
/** Fetch pull request details plus files, reviews, and optional CI checks in one call. */
|
|
1000
|
+
const getPullRequestContext = (token) => tool({
|
|
1001
|
+
description: getPullRequestContextDescription,
|
|
1002
|
+
inputSchema: getPullRequestContextInputSchema,
|
|
1003
|
+
toModelOutput: getPullRequestContextToModelOutput,
|
|
1004
|
+
execute: async (args) => getPullRequestContextStep({
|
|
1005
|
+
token: await resolveGithubToken(token),
|
|
1006
|
+
...args
|
|
1007
|
+
})
|
|
1008
|
+
});
|
|
1009
|
+
async function getIssueContextStep(args) {
|
|
1010
|
+
"use step";
|
|
1011
|
+
return getIssueContextCore(args);
|
|
1012
|
+
}
|
|
1013
|
+
/** Fetch an issue plus available label names and recent comments in one call. */
|
|
1014
|
+
const getIssueContext = (token) => tool({
|
|
1015
|
+
description: getIssueContextDescription,
|
|
1016
|
+
inputSchema: getIssueContextInputSchema,
|
|
1017
|
+
execute: async (args) => getIssueContextStep({
|
|
1018
|
+
token: await resolveGithubToken(token),
|
|
1019
|
+
...args
|
|
1020
|
+
})
|
|
1021
|
+
});
|
|
1022
|
+
async function getReleaseContextStep(args) {
|
|
1023
|
+
"use step";
|
|
1024
|
+
return getReleaseContextCore(args);
|
|
1025
|
+
}
|
|
1026
|
+
/** Fetch a release plus the previous release and tag comparison in one call. */
|
|
1027
|
+
const getReleaseContext = (token) => tool({
|
|
1028
|
+
description: getReleaseContextDescription,
|
|
1029
|
+
inputSchema: getReleaseContextInputSchema,
|
|
1030
|
+
execute: async (args) => getReleaseContextStep({
|
|
1031
|
+
token: await resolveGithubToken(token),
|
|
1032
|
+
...args
|
|
1033
|
+
})
|
|
1034
|
+
});
|
|
1035
|
+
async function getCiFailureContextStep(args) {
|
|
1036
|
+
"use step";
|
|
1037
|
+
return getCiFailureContextCore(args);
|
|
1038
|
+
}
|
|
1039
|
+
/** Diagnose CI failures for a ref — combined status, failing checks, and failed workflow jobs. */
|
|
1040
|
+
const getCiFailureContext = (token) => tool({
|
|
1041
|
+
description: getCiFailureContextDescription,
|
|
1042
|
+
inputSchema: getCiFailureContextInputSchema,
|
|
1043
|
+
execute: async (args) => getCiFailureContextStep({
|
|
1044
|
+
token: await resolveGithubToken(token),
|
|
1045
|
+
...args
|
|
1046
|
+
})
|
|
1047
|
+
});
|
|
1048
|
+
//#endregion
|
|
1049
|
+
//#region src/core/approval.ts
|
|
1050
|
+
/**
|
|
1051
|
+
* Resolve whether a write tool requires approval for the AI SDK.
|
|
1052
|
+
*
|
|
1053
|
+
* @param toolName - The write tool to check.
|
|
1054
|
+
* @param config - Global or per-tool approval config.
|
|
1055
|
+
* @returns `true` when approval is required; defaults to `true` for unspecified write tools in object mode.
|
|
1056
|
+
*/
|
|
1057
|
+
function resolveAiSdkApproval(toolName, config) {
|
|
1058
|
+
if (typeof config === "boolean") return config;
|
|
1059
|
+
return config[toolName] ?? true;
|
|
1060
|
+
}
|
|
1061
|
+
//#endregion
|
|
1062
|
+
//#region src/agents.ts
|
|
1063
|
+
const SHARED_RULES = `When a tool execution is denied by the user, do not retry it. Briefly acknowledge the decision and move on.
|
|
1064
|
+
Call independent read tools in the same step when you already know the arguments — never serialize reads that could run in parallel.
|
|
1065
|
+
Bodies default to detail summary; patches default to includePatch false; prefer getFileContent with startLine/endLine or maxLines for large files.`;
|
|
1066
|
+
const DEFAULT_INSTRUCTIONS = `You are a helpful GitHub assistant. You can read and explore repositories, issues, pull requests, discussions, commits, code, gists, and workflows. You can also create issues, pull requests, comments, gists, reactions, trigger workflows, and update files when asked.
|
|
1067
|
+
|
|
1068
|
+
Prefer getPullRequestContext, getIssueContext, getReleaseContext, or getCiFailureContext for multi-part reads instead of chaining separate tools.
|
|
1069
|
+
|
|
1070
|
+
${SHARED_RULES}`;
|
|
1071
|
+
const PRESET_INSTRUCTIONS = {
|
|
1072
|
+
"code-review": `You are a code review assistant. Your job is to review pull requests thoroughly and provide constructive feedback.
|
|
1073
|
+
|
|
1074
|
+
When reviewing a PR:
|
|
1075
|
+
- Start with getPullRequestContext (set includeChecks true when CI matters)
|
|
1076
|
+
- Then listPullRequestFiles with includePatch true and filenames for only the files you need — in the same step as any getFileContent / getBlame calls when possible
|
|
1077
|
+
- Use getBlame then getCommit(includePatch true) only when line history matters
|
|
1078
|
+
- Check for bugs, logic errors, and edge cases; be constructive
|
|
1079
|
+
- Use createPullRequestReview for formal reviews when asked
|
|
1080
|
+
- Use updatePullRequest to change title, body, base branch, or draft status; addPullRequestComment / updatePullRequestComment / deletePullRequestComment to manage comments
|
|
1081
|
+
|
|
1082
|
+
${SHARED_RULES}`,
|
|
1083
|
+
"issue-triage": `You are an issue triage assistant. Your job is to help manage and organize GitHub issues.
|
|
1084
|
+
|
|
1085
|
+
When triaging issues:
|
|
1086
|
+
- Call getIssueContext exactly once (full body + labelNames + recent comments). In that same step, call listIssues or searchIssues if you need duplicate checks
|
|
1087
|
+
- Never re-call getIssueContext for the same issue
|
|
1088
|
+
- Pick labels from labelNames; use addLabels / removeLabel to apply them
|
|
1089
|
+
- Create issues with clear titles and descriptions when asked
|
|
1090
|
+
- Use updateIssue to edit title, body, labels, milestone, or assignees, and to reopen a closed issue (state: 'open') — there is no separate reopen tool
|
|
1091
|
+
- Use updateIssueComment / deleteIssueComment to correct or remove existing comments
|
|
1092
|
+
- Acknowledge a report or a comment with addIssueReaction / addCommentReaction instead of posting a comment that says nothing new
|
|
1093
|
+
|
|
1094
|
+
${SHARED_RULES}`,
|
|
1095
|
+
"ci-ops": `You are a CI/CD operations assistant. Your job is to help monitor and manage GitHub Actions workflows.
|
|
1096
|
+
|
|
1097
|
+
When working with workflows:
|
|
1098
|
+
- Prefer getCiFailureContext first when diagnosing a failing ref
|
|
1099
|
+
- Use listCheckRuns / getCombinedStatus for narrower follow-ups
|
|
1100
|
+
- Inspect job steps to find the failing step; confirm before cancel/re-run
|
|
1101
|
+
- Trigger workflow_dispatch with the correct inputs and branch when asked
|
|
1102
|
+
|
|
1103
|
+
${SHARED_RULES}`,
|
|
1104
|
+
"security-audit": `You are a security audit assistant. Your job is to review repositories for security risks and report findings clearly — you never make destructive changes.
|
|
1105
|
+
|
|
1106
|
+
When auditing a repository:
|
|
1107
|
+
- Use searchCode for secrets and unsafe patterns; getBlame / listCommits to trace introductions
|
|
1108
|
+
- Use searchIssues to check for prior reports of the same vulnerability before filing a duplicate
|
|
1109
|
+
- Prefer getCiFailureContext or getPullRequestContext for CI / PR context
|
|
1110
|
+
- Use compareCommits to scope changes (includePatch only when you need diffs)
|
|
1111
|
+
- Report findings as issues with reproduction, impact, and severity
|
|
1112
|
+
- Read-only plus createIssue / addIssueComment / addLabels — never assume you can fix code directly
|
|
1113
|
+
|
|
1114
|
+
${SHARED_RULES}`,
|
|
1115
|
+
"repo-explorer": `You are a repository explorer. Your job is to help users understand codebases and find information across GitHub repositories.
|
|
1116
|
+
|
|
1117
|
+
When exploring repos:
|
|
1118
|
+
- Answer questions about structure and organization; find files and patterns with searchCode / getFileContent
|
|
1119
|
+
- Use searchIssues to find issues or pull requests by qualifier across a repository or organization
|
|
1120
|
+
- Use listDiscussions / getDiscussion for questions answered in the repository's discussions rather than its issues
|
|
1121
|
+
- Prefer getPullRequestContext or getCiFailureContext when summarizing a PR or failing CI
|
|
1122
|
+
- Use getBlame for line ownership; summarize recent commits / PRs / issues when asked
|
|
1123
|
+
- Read-only — you cannot make changes
|
|
1124
|
+
|
|
1125
|
+
${SHARED_RULES}`,
|
|
1126
|
+
"release-manager": `You are a release management assistant. Your job is to help prepare and publish GitHub releases.
|
|
1127
|
+
|
|
1128
|
+
When preparing a release:
|
|
1129
|
+
- Prefer getReleaseContext first (current/latest release, previous release, tag compare)
|
|
1130
|
+
- Use compareCommits / listCommits for more changelog detail; getCiFailureContext before cutting
|
|
1131
|
+
- createRelease with generateReleaseNotes when there is no manual changelog
|
|
1132
|
+
- Double-check the target branch or SHA — releases and tags are hard to undo
|
|
1133
|
+
- Use updateRelease to fix notes or toggle draft/prerelease after publishing; deleteRelease only when explicitly asked — it does not delete the underlying tag
|
|
1134
|
+
|
|
1135
|
+
${SHARED_RULES}`,
|
|
1136
|
+
"discussion-moderator": `You are a discussion moderator. Your job is to answer and guide repository Discussions clearly and on-topic.
|
|
1137
|
+
|
|
1138
|
+
When working in discussions:
|
|
1139
|
+
- Use listDiscussions / getDiscussion to load the thread before replying
|
|
1140
|
+
- Prefer addDiscussionComment for answers that belong in Discussions
|
|
1141
|
+
- Use searchIssues / getIssueContext when the question overlaps an existing issue; addIssueComment only when the follow-up belongs on that issue
|
|
1142
|
+
- Keep replies concise and point to docs or code when helpful
|
|
1143
|
+
|
|
1144
|
+
${SHARED_RULES}`,
|
|
1145
|
+
"notification-inbox": `You are a notification inbox assistant. Your job is to help triage GitHub notification threads for the authenticated user.
|
|
1146
|
+
|
|
1147
|
+
When clearing the inbox:
|
|
1148
|
+
- Use listNotifications to see unread threads (set all true only when asked)
|
|
1149
|
+
- Open the related getIssue or getPullRequest when you need context before acting
|
|
1150
|
+
- Use markNotificationRead once a thread is handled or is noise
|
|
1151
|
+
- These tools need a user PAT with Notifications access — say so if calls fail for that reason
|
|
1152
|
+
|
|
1153
|
+
${SHARED_RULES}`,
|
|
1154
|
+
"pr-author": `You are a pull request authoring assistant. Your job is to prepare branches, edit files, and open focused PRs.
|
|
1155
|
+
|
|
1156
|
+
When opening a PR:
|
|
1157
|
+
- Inspect the repo with getRepository / listBranches / getFileContent before editing
|
|
1158
|
+
- createBranch from a sensible base, then createOrUpdateFile for the change set
|
|
1159
|
+
- createPullRequest with a clear title and body; updatePullRequest if the draft or description needs a fix
|
|
1160
|
+
- Use listPullRequestFiles / compareCommits / getCommit to verify what will land
|
|
1161
|
+
- Stay scoped to authoring — you do not review, merge, or manage issues
|
|
1162
|
+
|
|
1163
|
+
${SHARED_RULES}`,
|
|
1164
|
+
"maintainer": `You are a repository maintainer assistant. You have full access to manage repositories, issues, pull requests, discussions, notifications, gists, and workflows.
|
|
1165
|
+
|
|
1166
|
+
When maintaining repos:
|
|
1167
|
+
- Prefer getPullRequestContext or getCiFailureContext for multi-part reads
|
|
1168
|
+
- Be careful with writes — review before acting
|
|
1169
|
+
- Keep issues, PRs, and commits clear and well-structured
|
|
1170
|
+
- Use listNotifications to find what needs attention, then markNotificationRead once a thread is handled
|
|
1171
|
+
- Acknowledge a thread with addIssueReaction / addCommentReaction instead of a comment that adds nothing
|
|
1172
|
+
- Answer questions in discussions with addDiscussionComment
|
|
1173
|
+
|
|
1174
|
+
${SHARED_RULES}`
|
|
1175
|
+
};
|
|
1176
|
+
function resolveInstructions(options) {
|
|
1177
|
+
const defaultPrompt = options.preset && !Array.isArray(options.preset) ? PRESET_INSTRUCTIONS[options.preset] : DEFAULT_INSTRUCTIONS;
|
|
1178
|
+
let prompt;
|
|
1179
|
+
if (options.instructions) prompt = options.instructions;
|
|
1180
|
+
else if (options.additionalInstructions) prompt = `${defaultPrompt}\n\n${options.additionalInstructions}`;
|
|
1181
|
+
else prompt = defaultPrompt;
|
|
1182
|
+
const contextBlock = options.context ? formatContextInstructions(options.context) : "";
|
|
1183
|
+
if (contextBlock) return `${prompt}\n\n${contextBlock}`;
|
|
1184
|
+
return prompt;
|
|
1185
|
+
}
|
|
1186
|
+
/**
|
|
1187
|
+
* Create a pre-configured GitHub agent powered by the AI SDK's `ToolLoopAgent`.
|
|
1188
|
+
*
|
|
1189
|
+
* Returns a `ToolLoopAgent` instance with `.generate()` and `.stream()` methods.
|
|
1190
|
+
*
|
|
1191
|
+
* @example
|
|
1192
|
+
* ```ts
|
|
1193
|
+
* import { createGithubAgent } from '@github-tools/sdk'
|
|
1194
|
+
*
|
|
1195
|
+
* const agent = createGithubAgent({
|
|
1196
|
+
* model: 'anthropic/claude-sonnet-4.6',
|
|
1197
|
+
* token: process.env.GITHUB_TOKEN!,
|
|
1198
|
+
* preset: 'code-review',
|
|
1199
|
+
* context: { owner: 'vercel', repo: 'ai', pullNumber: 42 },
|
|
1200
|
+
* })
|
|
1201
|
+
*
|
|
1202
|
+
* const result = await agent.generate({ prompt: 'Review this PR' })
|
|
1203
|
+
* ```
|
|
1204
|
+
*/
|
|
1205
|
+
function createGithubAgent({ token, preset, requireApproval, context, instructions, additionalInstructions, author, committer, coAuthors, ...agentOptions }) {
|
|
1206
|
+
const tools = createGithubTools({
|
|
1207
|
+
token,
|
|
1208
|
+
requireApproval,
|
|
1209
|
+
preset,
|
|
1210
|
+
context,
|
|
1211
|
+
author,
|
|
1212
|
+
committer,
|
|
1213
|
+
coAuthors
|
|
1214
|
+
});
|
|
1215
|
+
return new ToolLoopAgent({
|
|
1216
|
+
...agentOptions,
|
|
1217
|
+
tools,
|
|
1218
|
+
instructions: resolveInstructions({
|
|
1219
|
+
preset,
|
|
1220
|
+
instructions,
|
|
1221
|
+
additionalInstructions,
|
|
1222
|
+
context
|
|
1223
|
+
})
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
//#endregion
|
|
1227
|
+
//#region src/index.ts
|
|
1228
|
+
/**
|
|
1229
|
+
* Create a set of GitHub tools for the Vercel AI SDK.
|
|
1230
|
+
*
|
|
1231
|
+
* Write operations require user approval by default.
|
|
1232
|
+
* Control this globally or per-tool via `requireApproval`.
|
|
1233
|
+
* Prefer `preset` to expose only the tools your agent needs.
|
|
1234
|
+
* Pass `context` to default owner/repo/PR/issue/ref on tool inputs.
|
|
1235
|
+
*
|
|
1236
|
+
* @example
|
|
1237
|
+
* ```ts
|
|
1238
|
+
* // Code-review agent — only PR & commit tools
|
|
1239
|
+
* createGithubTools({ token, preset: 'code-review' })
|
|
1240
|
+
*
|
|
1241
|
+
* // Scoped to a repo / PR
|
|
1242
|
+
* createGithubTools({
|
|
1243
|
+
* token,
|
|
1244
|
+
* preset: 'code-review',
|
|
1245
|
+
* context: { owner: 'vercel', repo: 'ai', pullNumber: 42 },
|
|
1246
|
+
* })
|
|
1247
|
+
*
|
|
1248
|
+
* // Combine presets
|
|
1249
|
+
* createGithubTools({ token, preset: ['code-review', 'issue-triage'] })
|
|
1250
|
+
*
|
|
1251
|
+
* // Full catalog (same as omitting preset)
|
|
1252
|
+
* createGithubTools({ token, preset: 'maintainer' })
|
|
1253
|
+
*
|
|
1254
|
+
* // Granular approval
|
|
1255
|
+
* createGithubTools({
|
|
1256
|
+
* token,
|
|
1257
|
+
* preset: 'maintainer',
|
|
1258
|
+
* requireApproval: {
|
|
1259
|
+
* mergePullRequest: true,
|
|
1260
|
+
* createOrUpdateFile: true,
|
|
1261
|
+
* addPullRequestComment: false,
|
|
1262
|
+
* }
|
|
1263
|
+
* })
|
|
1264
|
+
* ```
|
|
1265
|
+
*/
|
|
1266
|
+
function createGithubTools({ token, requireApproval = true, preset, context, overrides, author, committer, coAuthors } = {}) {
|
|
1267
|
+
const resolveToken = createGithubTokenResolver(token);
|
|
1268
|
+
const approval = (name) => ({ needsApproval: resolveAiSdkApproval(name, requireApproval) });
|
|
1269
|
+
const allowed = preset ? resolvePresetTools(preset) : null;
|
|
1270
|
+
const allTools = {
|
|
1271
|
+
getRepository: getRepository(resolveToken),
|
|
1272
|
+
listBranches: listBranches(resolveToken),
|
|
1273
|
+
getFileContent: getFileContent(resolveToken),
|
|
1274
|
+
getRepositoryTree: getRepositoryTree(resolveToken),
|
|
1275
|
+
listPullRequests: listPullRequests(resolveToken),
|
|
1276
|
+
getPullRequest: getPullRequest(resolveToken),
|
|
1277
|
+
listIssues: listIssues(resolveToken),
|
|
1278
|
+
getIssue: getIssue(resolveToken),
|
|
1279
|
+
searchCode: searchCode(resolveToken),
|
|
1280
|
+
searchRepositories: searchRepositories(resolveToken),
|
|
1281
|
+
searchIssues: searchIssues(resolveToken),
|
|
1282
|
+
listCommits: listCommits(resolveToken),
|
|
1283
|
+
getCommit: getCommit(resolveToken),
|
|
1284
|
+
getBlame: getBlame(resolveToken),
|
|
1285
|
+
compareCommits: compareCommits(resolveToken),
|
|
1286
|
+
createBranch: createBranch(resolveToken, approval("createBranch")),
|
|
1287
|
+
forkRepository: forkRepository(resolveToken, approval("forkRepository")),
|
|
1288
|
+
createRepository: createRepository(resolveToken, approval("createRepository")),
|
|
1289
|
+
createOrUpdateFile: createOrUpdateFile(resolveToken, {
|
|
1290
|
+
...approval("createOrUpdateFile"),
|
|
1291
|
+
author,
|
|
1292
|
+
committer,
|
|
1293
|
+
coAuthors
|
|
1294
|
+
}),
|
|
1295
|
+
createPullRequest: createPullRequest(resolveToken, approval("createPullRequest")),
|
|
1296
|
+
mergePullRequest: mergePullRequest(resolveToken, {
|
|
1297
|
+
...approval("mergePullRequest"),
|
|
1298
|
+
coAuthors
|
|
1299
|
+
}),
|
|
1300
|
+
updatePullRequest: updatePullRequest(resolveToken, approval("updatePullRequest")),
|
|
1301
|
+
addPullRequestComment: addPullRequestComment(resolveToken, approval("addPullRequestComment")),
|
|
1302
|
+
updatePullRequestComment: updatePullRequestComment(resolveToken, approval("updatePullRequestComment")),
|
|
1303
|
+
deletePullRequestComment: deletePullRequestComment(resolveToken, approval("deletePullRequestComment")),
|
|
1304
|
+
listPullRequestFiles: listPullRequestFiles(resolveToken),
|
|
1305
|
+
listPullRequestReviews: listPullRequestReviews(resolveToken),
|
|
1306
|
+
createPullRequestReview: createPullRequestReview(resolveToken, approval("createPullRequestReview")),
|
|
1307
|
+
requestReviewers: requestReviewers(resolveToken, approval("requestReviewers")),
|
|
1308
|
+
getPullRequestContext: getPullRequestContext(resolveToken),
|
|
1309
|
+
getIssueContext: getIssueContext(resolveToken),
|
|
1310
|
+
createIssue: createIssue(resolveToken, approval("createIssue")),
|
|
1311
|
+
addIssueComment: addIssueComment(resolveToken, approval("addIssueComment")),
|
|
1312
|
+
updateIssueComment: updateIssueComment(resolveToken, approval("updateIssueComment")),
|
|
1313
|
+
deleteIssueComment: deleteIssueComment(resolveToken, approval("deleteIssueComment")),
|
|
1314
|
+
closeIssue: closeIssue(resolveToken, approval("closeIssue")),
|
|
1315
|
+
updateIssue: updateIssue(resolveToken, approval("updateIssue")),
|
|
1316
|
+
listLabels: listLabels(resolveToken),
|
|
1317
|
+
addLabels: addLabels(resolveToken, approval("addLabels")),
|
|
1318
|
+
removeLabel: removeLabel(resolveToken, approval("removeLabel")),
|
|
1319
|
+
addAssignees: addAssignees(resolveToken, approval("addAssignees")),
|
|
1320
|
+
removeAssignees: removeAssignees(resolveToken, approval("removeAssignees")),
|
|
1321
|
+
listIssueReactions: listIssueReactions(resolveToken),
|
|
1322
|
+
addIssueReaction: addIssueReaction(resolveToken, approval("addIssueReaction")),
|
|
1323
|
+
listCommentReactions: listCommentReactions(resolveToken),
|
|
1324
|
+
addCommentReaction: addCommentReaction(resolveToken, approval("addCommentReaction")),
|
|
1325
|
+
listDiscussions: listDiscussions(resolveToken),
|
|
1326
|
+
getDiscussion: getDiscussion(resolveToken),
|
|
1327
|
+
addDiscussionComment: addDiscussionComment(resolveToken, approval("addDiscussionComment")),
|
|
1328
|
+
listNotifications: listNotifications(resolveToken),
|
|
1329
|
+
markNotificationRead: markNotificationRead(resolveToken, approval("markNotificationRead")),
|
|
1330
|
+
listGists: listGists(resolveToken),
|
|
1331
|
+
getGist: getGist(resolveToken),
|
|
1332
|
+
listGistComments: listGistComments(resolveToken),
|
|
1333
|
+
createGist: createGist(resolveToken, approval("createGist")),
|
|
1334
|
+
updateGist: updateGist(resolveToken, approval("updateGist")),
|
|
1335
|
+
deleteGist: deleteGist(resolveToken, approval("deleteGist")),
|
|
1336
|
+
createGistComment: createGistComment(resolveToken, approval("createGistComment")),
|
|
1337
|
+
listWorkflows: listWorkflows(resolveToken),
|
|
1338
|
+
listWorkflowRuns: listWorkflowRuns(resolveToken),
|
|
1339
|
+
getWorkflowRun: getWorkflowRun(resolveToken),
|
|
1340
|
+
listWorkflowJobs: listWorkflowJobs(resolveToken),
|
|
1341
|
+
triggerWorkflow: triggerWorkflow(resolveToken, approval("triggerWorkflow")),
|
|
1342
|
+
cancelWorkflowRun: cancelWorkflowRun(resolveToken, approval("cancelWorkflowRun")),
|
|
1343
|
+
rerunWorkflowRun: rerunWorkflowRun(resolveToken, approval("rerunWorkflowRun")),
|
|
1344
|
+
listCheckRuns: listCheckRuns(resolveToken),
|
|
1345
|
+
getCombinedStatus: getCombinedStatus(resolveToken),
|
|
1346
|
+
getCiFailureContext: getCiFailureContext(resolveToken),
|
|
1347
|
+
listReleases: listReleases(resolveToken),
|
|
1348
|
+
getLatestRelease: getLatestRelease(resolveToken),
|
|
1349
|
+
getRelease: getRelease(resolveToken),
|
|
1350
|
+
getReleaseContext: getReleaseContext(resolveToken),
|
|
1351
|
+
createRelease: createRelease(resolveToken, approval("createRelease")),
|
|
1352
|
+
updateRelease: updateRelease(resolveToken, approval("updateRelease")),
|
|
1353
|
+
deleteRelease: deleteRelease(resolveToken, approval("deleteRelease"))
|
|
1354
|
+
};
|
|
1355
|
+
if (overrides) {
|
|
1356
|
+
for (const [name, toolOverrides] of Object.entries(overrides)) if (name in allTools && toolOverrides) {
|
|
1357
|
+
const key = name;
|
|
1358
|
+
Object.assign(allTools, { [key]: {
|
|
1359
|
+
...allTools[key],
|
|
1360
|
+
...toolOverrides
|
|
1361
|
+
} });
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
const scoped = bindToolsContext(allTools, context);
|
|
1365
|
+
if (!allowed) return scoped;
|
|
1366
|
+
return Object.fromEntries(Object.entries(scoped).filter(([name]) => allowed.has(name)));
|
|
1367
|
+
}
|
|
1368
|
+
//#endregion
|
|
1369
|
+
export { listIssues as $, compareCommits as A, getDiscussion as B, createGist as C, getRepositoryTree as Ct, listGistComments as D, getGist as E, searchIssues as F, listIssueReactions as G, addCommentReaction as H, searchRepositories as I, addLabels as J, addAssignees as K, listNotifications as L, getCommit as M, listCommits as N, listGists as O, searchCode as P, getIssue as Q, markNotificationRead as R, triggerWorkflow as S, getRepository as St, deleteGist as T, addIssueReaction as U, listDiscussions as V, listCommentReactions as W, createIssue as X, closeIssue as Y, deleteIssueComment as Z, getWorkflowRun as _, createBranch as _t, getIssueContext as a, addPullRequestComment as at, listWorkflows as b, forkRepository as bt, createRelease as c, deletePullRequestComment as ct, getRelease as d, listPullRequestReviews as dt, listLabels as et, listReleases as f, listPullRequests as ft, cancelWorkflowRun as g, updatePullRequestComment as gt, listCheckRuns as h, updatePullRequest as ht, getCiFailureContext as i, updateIssueComment as it, getBlame as j, updateGist as k, deleteRelease as l, getPullRequest as lt, getCombinedStatus as m, requestReviewers as mt, createGithubAgent as n, removeLabel as nt, getPullRequestContext as o, createPullRequest as ot, updateRelease as p, mergePullRequest as pt, addIssueComment as q, resolveInstructions as r, updateIssue as rt, getReleaseContext as s, createPullRequestReview as st, createGithubTools as t, removeAssignees as tt, getLatestRelease as u, listPullRequestFiles as ut, listWorkflowJobs as v, createOrUpdateFile as vt, createGistComment as w, listBranches as wt, rerunWorkflowRun as x, getFileContent as xt, listWorkflowRuns as y, createRepository as yt, addDiscussionComment as z };
|
|
1370
|
+
|
|
1371
|
+
//# sourceMappingURL=src-v-LjzPpR.mjs.map
|