@github-tools/sdk 1.3.0 → 1.5.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 +64 -11
- package/dist/{agents-CnwdZ0Wk.d.mts → agents-C6nqZiYp.d.mts} +95 -6
- package/dist/agents-C6nqZiYp.d.mts.map +1 -0
- package/dist/{agents-Cdb0a8CP.mjs → agents-D9aKsd_7.mjs} +196 -2
- package/dist/agents-D9aKsd_7.mjs.map +1 -0
- package/dist/index.d.mts +99 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +34 -4
- package/dist/index.mjs.map +1 -1
- package/dist/workflow.d.mts +176 -11
- package/dist/workflow.d.mts.map +1 -1
- package/dist/workflow.mjs +99 -6
- package/dist/workflow.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/agents-Cdb0a8CP.mjs.map +0 -1
- package/dist/agents-CnwdZ0Wk.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
GitHub tools for the [AI SDK](https://ai-sdk.dev) — wrap GitHub's REST API as ready-to-use tools for any agent or `generateText` / `streamText` call.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
42 tools covering repositories, branches, pull requests, issues, commits, search, gists, and workflows. Write operations support granular approval control out of the box.
|
|
13
13
|
|
|
14
14
|
## Installation
|
|
15
15
|
|
|
@@ -62,11 +62,11 @@ createGithubTools({ token, preset: ['code-review', 'issue-triage'] })
|
|
|
62
62
|
|
|
63
63
|
| Preset | Tools included |
|
|
64
64
|
|---|---|
|
|
65
|
-
| `code-review` | `getPullRequest`, `listPullRequests`, `getFileContent`, `listCommits`, `getCommit`, `getBlame`, `getRepository`, `listBranches`, `searchCode`, `addPullRequestComment` |
|
|
66
|
-
| `issue-triage` | `listIssues`, `getIssue`, `createIssue`, `addIssueComment`, `closeIssue`, `getRepository`, `searchRepositories`, `searchCode` |
|
|
65
|
+
| `code-review` | `getPullRequest`, `listPullRequests`, `listPullRequestFiles`, `listPullRequestReviews`, `getFileContent`, `listCommits`, `getCommit`, `getBlame`, `getRepository`, `listBranches`, `searchCode`, `addPullRequestComment`, `createPullRequestReview` |
|
|
66
|
+
| `issue-triage` | `listIssues`, `getIssue`, `createIssue`, `addIssueComment`, `closeIssue`, `listLabels`, `addLabels`, `removeLabel`, `getRepository`, `searchRepositories`, `searchCode` |
|
|
67
67
|
| `repo-explorer` | All read-only tools including gists and workflows (no write operations) |
|
|
68
68
|
| `ci-ops` | `listWorkflows`, `listWorkflowRuns`, `getWorkflowRun`, `listWorkflowJobs`, `triggerWorkflow`, `cancelWorkflowRun`, `rerunWorkflowRun`, `getRepository`, `listBranches`, `listCommits`, `getCommit` |
|
|
69
|
-
| `maintainer` | All
|
|
69
|
+
| `maintainer` | All 42 tools |
|
|
70
70
|
|
|
71
71
|
Omit `preset` to get all tools (same as `maintainer`).
|
|
72
72
|
|
|
@@ -113,10 +113,34 @@ createGithubTools({
|
|
|
113
113
|
})
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
Write tools: `createOrUpdateFile`, `createPullRequest`, `mergePullRequest`, `addPullRequestComment`, `createIssue`, `addIssueComment`, `closeIssue`, `createGist`, `updateGist`, `deleteGist`, `createGistComment`, `triggerWorkflow`, `cancelWorkflowRun`, `rerunWorkflowRun`.
|
|
116
|
+
Write tools: `createOrUpdateFile`, `createPullRequest`, `mergePullRequest`, `addPullRequestComment`, `createPullRequestReview`, `createIssue`, `addIssueComment`, `closeIssue`, `addLabels`, `removeLabel`, `createGist`, `updateGist`, `deleteGist`, `createGistComment`, `triggerWorkflow`, `cancelWorkflowRun`, `rerunWorkflowRun`.
|
|
117
117
|
|
|
118
118
|
All other tools are read-only and never require approval.
|
|
119
119
|
|
|
120
|
+
### Tool overrides
|
|
121
|
+
|
|
122
|
+
The `overrides` option lets you customize any AI SDK [`tool()`](https://ai-sdk.dev/docs/ai-sdk-core/tools-and-tool-calling) property on a per-tool basis, keyed by tool name.
|
|
123
|
+
|
|
124
|
+
```ts
|
|
125
|
+
import type { ToolOverrides } from "@github-tools/sdk";
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Supported override properties:
|
|
129
|
+
|
|
130
|
+
| Property | Type | Description |
|
|
131
|
+
|----------|------|-------------|
|
|
132
|
+
| `description` | `string` | Custom tool description for the model |
|
|
133
|
+
| `title` | `string` | Human-readable title |
|
|
134
|
+
| `strict` | `boolean` | Strict mode for input generation |
|
|
135
|
+
| `needsApproval` | `boolean \| function` | Gate execution behind approval |
|
|
136
|
+
| `providerOptions` | `ProviderOptions` | Provider-specific metadata |
|
|
137
|
+
| `onInputStart` | `function` | Callback when argument streaming starts |
|
|
138
|
+
| `onInputDelta` | `function` | Callback on each streaming delta |
|
|
139
|
+
| `onInputAvailable` | `function` | Callback when full input is available |
|
|
140
|
+
| `toModelOutput` | `function` | Custom mapping of tool result to model output |
|
|
141
|
+
|
|
142
|
+
Core properties (`execute`, `inputSchema`, `outputSchema`) cannot be overridden.
|
|
143
|
+
|
|
120
144
|
## Tool Selection with toolpick
|
|
121
145
|
|
|
122
146
|
With dozens of tools, context window usage adds up. [toolpick](https://github.com/pontusab/toolpick) selects only the most relevant tools per step so the model sees what it needs:
|
|
@@ -181,9 +205,12 @@ All presets work with `createDurableGithubAgent`.
|
|
|
181
205
|
|---|---|
|
|
182
206
|
| `listPullRequests` | List PRs filtered by state |
|
|
183
207
|
| `getPullRequest` | Get a PR's full details (diff stats, body, merge status) |
|
|
208
|
+
| `listPullRequestFiles` | List files changed in a PR with diff status and patches |
|
|
209
|
+
| `listPullRequestReviews` | List reviews on a PR (approvals, change requests, comments) |
|
|
184
210
|
| `createPullRequest` | Open a new PR |
|
|
185
211
|
| `mergePullRequest` | Merge a PR (merge, squash, or rebase) |
|
|
186
212
|
| `addPullRequestComment` | Post a comment on a PR |
|
|
213
|
+
| `createPullRequestReview` | Submit a formal review (approve, request changes, or comment) with inline comments |
|
|
187
214
|
|
|
188
215
|
### Issues
|
|
189
216
|
|
|
@@ -194,6 +221,9 @@ All presets work with `createDurableGithubAgent`.
|
|
|
194
221
|
| `createIssue` | Open a new issue |
|
|
195
222
|
| `addIssueComment` | Post a comment on an issue |
|
|
196
223
|
| `closeIssue` | Close an issue (completed or not planned) |
|
|
224
|
+
| `listLabels` | List labels available in a repository |
|
|
225
|
+
| `addLabels` | Add labels to an issue or pull request |
|
|
226
|
+
| `removeLabel` | Remove a label from an issue or pull request |
|
|
197
227
|
|
|
198
228
|
### Gists
|
|
199
229
|
|
|
@@ -247,10 +277,10 @@ Create one at **GitHub → Settings → Developer settings → Personal access t
|
|
|
247
277
|
| **Metadata** | Read-only | Always required (auto-included) |
|
|
248
278
|
| **Contents** | Read-only | `getRepository`, `listBranches`, `getFileContent`, `listCommits`, `getCommit`, `getBlame` |
|
|
249
279
|
| **Contents** | Read and write | `createOrUpdateFile` |
|
|
250
|
-
| **Pull requests** | Read-only | `listPullRequests`, `getPullRequest` |
|
|
251
|
-
| **Pull requests** | Read and write | `createPullRequest`, `mergePullRequest`, `addPullRequestComment` |
|
|
252
|
-
| **Issues** | Read-only | `listIssues`, `getIssue` |
|
|
253
|
-
| **Issues** | Read and write | `createIssue`, `addIssueComment`, `closeIssue` |
|
|
280
|
+
| **Pull requests** | Read-only | `listPullRequests`, `getPullRequest`, `listPullRequestFiles`, `listPullRequestReviews` |
|
|
281
|
+
| **Pull requests** | Read and write | `createPullRequest`, `mergePullRequest`, `addPullRequestComment`, `createPullRequestReview` |
|
|
282
|
+
| **Issues** | Read-only | `listIssues`, `getIssue`, `listLabels` |
|
|
283
|
+
| **Issues** | Read and write | `createIssue`, `addIssueComment`, `closeIssue`, `addLabels`, `removeLabel` |
|
|
254
284
|
|
|
255
285
|
| **Gists** | Read-only | `listGists`, `getGist`, `listGistComments` |
|
|
256
286
|
| **Gists** | Read and write | `createGist`, `updateGist`, `deleteGist`, `createGistComment` |
|
|
@@ -335,7 +365,9 @@ All other `ToolLoopAgent` options (`stopWhen`, `toolChoice`, `onStepFinish`, etc
|
|
|
335
365
|
|
|
336
366
|
### `createDurableGithubAgent(options)`
|
|
337
367
|
|
|
338
|
-
Returns a `
|
|
368
|
+
Returns a `DurableGithubAgent` instance for use inside Vercel Workflow SDK functions. Every LLM call and tool execution runs as a durable step with automatic retries and crash recovery.
|
|
369
|
+
|
|
370
|
+
Supports both `.stream()` (real-time output to a writable) and `.generate()` (non-streaming, returns the full text response).
|
|
339
371
|
|
|
340
372
|
Requires the optional peer dependencies `workflow` and `@workflow/ai`:
|
|
341
373
|
|
|
@@ -343,6 +375,8 @@ Requires the optional peer dependencies `workflow` and `@workflow/ai`:
|
|
|
343
375
|
pnpm add workflow @workflow/ai
|
|
344
376
|
```
|
|
345
377
|
|
|
378
|
+
#### Streaming (chat UI)
|
|
379
|
+
|
|
346
380
|
```ts
|
|
347
381
|
import { createDurableGithubAgent } from '@github-tools/sdk/workflow'
|
|
348
382
|
import { getWritable } from 'workflow'
|
|
@@ -360,7 +394,26 @@ async function chatWorkflow(messages: ModelMessage[], token: string) {
|
|
|
360
394
|
}
|
|
361
395
|
```
|
|
362
396
|
|
|
363
|
-
|
|
397
|
+
#### Non-streaming (bot / background job — needs `"use step"`)
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
import { createGithubAgent } from '@github-tools/sdk'
|
|
401
|
+
|
|
402
|
+
async function agentTurn(prompt: string) {
|
|
403
|
+
"use step"
|
|
404
|
+
const agent = createGithubAgent({
|
|
405
|
+
model: 'anthropic/claude-sonnet-4.6',
|
|
406
|
+
preset: 'code-review',
|
|
407
|
+
requireApproval: false,
|
|
408
|
+
})
|
|
409
|
+
const { text } = await agent.generate({ prompt })
|
|
410
|
+
return text
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
> See [`examples/pr-review-bot`](../../examples/pr-review-bot) for a complete PR review bot built with Chat SDK and Vercel Workflow.
|
|
415
|
+
|
|
416
|
+
All presets (`code-review`, `issue-triage`, `ci-ops`, `repo-explorer`, `maintainer`) work with `createDurableGithubAgent`. Options mirror `createGithubAgent` with additional pass-through for `DurableAgentOptions` fields like `experimental_telemetry`, `onStepFinish`, `onFinish`, and `prepareStep`.
|
|
364
417
|
|
|
365
418
|
> **Note:** `requireApproval` is accepted but currently ignored by `DurableAgent` — the Workflow SDK does not yet support interactive tool approval.
|
|
366
419
|
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { ApprovalConfig, GithubToolPreset } from "./index.mjs";
|
|
2
2
|
import * as ai from "ai";
|
|
3
|
-
import { ToolLoopAgent, ToolLoopAgentSettings } from "ai";
|
|
3
|
+
import { Tool, ToolLoopAgent, ToolLoopAgentSettings } from "ai";
|
|
4
4
|
import { Octokit, Octokit as Octokit$1 } from "octokit";
|
|
5
5
|
|
|
6
|
-
//#region src/client.d.ts
|
|
7
|
-
declare function createOctokit(token: string): Octokit;
|
|
8
|
-
//#endregion
|
|
9
6
|
//#region src/types.d.ts
|
|
10
7
|
type ToolOptions = {
|
|
11
8
|
needsApproval?: boolean;
|
|
12
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Per-tool overrides for customizing tool behavior without changing the underlying implementation.
|
|
12
|
+
* Properties like `execute`, `inputSchema`, and `outputSchema` are intentionally excluded.
|
|
13
|
+
*/
|
|
14
|
+
type ToolOverrides = Partial<Pick<Tool, 'description' | 'needsApproval' | 'onInputAvailable' | 'onInputDelta' | 'onInputStart' | 'providerOptions' | 'strict' | 'title' | 'toModelOutput'>>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/client.d.ts
|
|
17
|
+
declare function createOctokit(token: string): Octokit;
|
|
13
18
|
//#endregion
|
|
14
19
|
//#region src/tools/repository.d.ts
|
|
15
20
|
declare const getRepository: (token: string) => ai.Tool<{
|
|
@@ -227,6 +232,56 @@ declare const addPullRequestComment: (token: string, {
|
|
|
227
232
|
author: string | undefined;
|
|
228
233
|
createdAt: string;
|
|
229
234
|
}>;
|
|
235
|
+
declare const listPullRequestFiles: (token: string) => ai.Tool<{
|
|
236
|
+
owner: string;
|
|
237
|
+
repo: string;
|
|
238
|
+
pullNumber: number;
|
|
239
|
+
perPage: number;
|
|
240
|
+
page: number;
|
|
241
|
+
}, {
|
|
242
|
+
filename: string;
|
|
243
|
+
status: "added" | "removed" | "modified" | "renamed" | "copied" | "changed" | "unchanged";
|
|
244
|
+
additions: number;
|
|
245
|
+
deletions: number;
|
|
246
|
+
changes: number;
|
|
247
|
+
patch: string | undefined;
|
|
248
|
+
}[]>;
|
|
249
|
+
declare const listPullRequestReviews: (token: string) => ai.Tool<{
|
|
250
|
+
owner: string;
|
|
251
|
+
repo: string;
|
|
252
|
+
pullNumber: number;
|
|
253
|
+
perPage: number;
|
|
254
|
+
page: number;
|
|
255
|
+
}, {
|
|
256
|
+
id: number;
|
|
257
|
+
state: string;
|
|
258
|
+
body: string;
|
|
259
|
+
author: string | undefined;
|
|
260
|
+
url: string;
|
|
261
|
+
submittedAt: string | undefined;
|
|
262
|
+
}[]>;
|
|
263
|
+
declare const createPullRequestReview: (token: string, {
|
|
264
|
+
needsApproval
|
|
265
|
+
}?: ToolOptions) => ai.Tool<{
|
|
266
|
+
owner: string;
|
|
267
|
+
repo: string;
|
|
268
|
+
pullNumber: number;
|
|
269
|
+
event: "APPROVE" | "REQUEST_CHANGES" | "COMMENT";
|
|
270
|
+
body?: string | undefined;
|
|
271
|
+
comments?: {
|
|
272
|
+
path: string;
|
|
273
|
+
body: string;
|
|
274
|
+
line?: number | undefined;
|
|
275
|
+
side?: "LEFT" | "RIGHT" | undefined;
|
|
276
|
+
}[] | undefined;
|
|
277
|
+
}, {
|
|
278
|
+
id: number;
|
|
279
|
+
state: string;
|
|
280
|
+
body: string;
|
|
281
|
+
url: string;
|
|
282
|
+
author: string | undefined;
|
|
283
|
+
submittedAt: string | undefined;
|
|
284
|
+
}>;
|
|
230
285
|
//#endregion
|
|
231
286
|
//#region src/tools/issues.d.ts
|
|
232
287
|
declare const listIssues: (token: string) => ai.Tool<{
|
|
@@ -307,6 +362,40 @@ declare const closeIssue: (token: string, {
|
|
|
307
362
|
url: string;
|
|
308
363
|
closedAt: string | null;
|
|
309
364
|
}>;
|
|
365
|
+
declare const listLabels: (token: string) => ai.Tool<{
|
|
366
|
+
owner: string;
|
|
367
|
+
repo: string;
|
|
368
|
+
perPage: number;
|
|
369
|
+
page: number;
|
|
370
|
+
}, {
|
|
371
|
+
name: string;
|
|
372
|
+
color: string;
|
|
373
|
+
description: string | null;
|
|
374
|
+
}[]>;
|
|
375
|
+
declare const addLabels: (token: string, {
|
|
376
|
+
needsApproval
|
|
377
|
+
}?: ToolOptions) => ai.Tool<{
|
|
378
|
+
owner: string;
|
|
379
|
+
repo: string;
|
|
380
|
+
issueNumber: number;
|
|
381
|
+
labels: string[];
|
|
382
|
+
}, {
|
|
383
|
+
name: string;
|
|
384
|
+
color: string;
|
|
385
|
+
description: string | null;
|
|
386
|
+
}[]>;
|
|
387
|
+
declare const removeLabel: (token: string, {
|
|
388
|
+
needsApproval
|
|
389
|
+
}?: ToolOptions) => ai.Tool<{
|
|
390
|
+
owner: string;
|
|
391
|
+
repo: string;
|
|
392
|
+
issueNumber: number;
|
|
393
|
+
label: string;
|
|
394
|
+
}, {
|
|
395
|
+
removed: boolean;
|
|
396
|
+
label: string;
|
|
397
|
+
issueNumber: number;
|
|
398
|
+
}>;
|
|
310
399
|
//#endregion
|
|
311
400
|
//#region src/tools/search.d.ts
|
|
312
401
|
declare const searchCode: (token: string) => ai.Tool<{
|
|
@@ -688,5 +777,5 @@ declare function createGithubAgent({
|
|
|
688
777
|
...agentOptions
|
|
689
778
|
}: CreateGithubAgentOptions): ToolLoopAgent<never, {}, never>;
|
|
690
779
|
//#endregion
|
|
691
|
-
export {
|
|
692
|
-
//# sourceMappingURL=agents-
|
|
780
|
+
export { addPullRequestComment as A, createRepository as B, addLabels as C, listIssues as D, getIssue as E, listPullRequestReviews as F, createOctokit as G, getFileContent as H, listPullRequests as I, ToolOverrides as J, Octokit$1 as K, mergePullRequest as L, createPullRequestReview as M, getPullRequest as N, listLabels as O, listPullRequestFiles as P, createBranch as R, addIssueComment as S, createIssue as T, getRepository as U, forkRepository as V, listBranches as W, getBlame as _, listWorkflowJobs as a, searchCode as b, rerunWorkflowRun as c, createGistComment as d, deleteGist as f, updateGist as g, listGists as h, getWorkflowRun as i, createPullRequest as j, removeLabel as k, triggerWorkflow as l, listGistComments as m, createGithubAgent as n, listWorkflowRuns as o, getGist as p, ToolOptions as q, cancelWorkflowRun as r, listWorkflows as s, CreateGithubAgentOptions as t, createGist as u, getCommit as v, closeIssue as w, searchRepositories as x, listCommits as y, createOrUpdateFile as z };
|
|
781
|
+
//# sourceMappingURL=agents-C6nqZiYp.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-C6nqZiYp.d.mts","names":[],"sources":["../src/types.ts","../src/client.ts","../src/tools/repository.ts","../src/tools/pull-requests.ts","../src/tools/issues.ts","../src/tools/search.ts","../src/tools/commits.ts","../src/tools/gists.ts","../src/tools/workflows.ts","../src/agents.ts"],"mappings":";;;;;;KAIY,WAAA;EAAgB,aAAA;AAAA;;AAA5B;;;KAMY,aAAA,GAAgB,OAAA,CAC1B,IAAA,CACE,IAAA;;;iBCVY,aAAA,CAAc,KAAA,WAAgB,OAAA;;;cCuBjC,aAAA,GAAiB,KAAA,aAQ1B,EAAA,CARuC,IAAA;;;;;;;;;;;;;;;;;cAqB9B,YAAA,GAAgB,KAAA,aASzB,EAAA,CATsC,IAAA;;;;;;;;;cA+B7B,cAAA,GAAkB,KAAA,aAU3B,EAAA,CAVwC,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqC/B,YAAA,GAAgB,KAAA;EAAe;AAAA,IAA0B,WAAA,KAAgB,EAAA,CAAA,IAAA;;;;;;;;;;cAkCzE,cAAA,GAAkB,KAAA;EAAe;AAAA,IAA0B,WAAA,KAAgB,EAAA,CAAA,IAAA;;;;;;;;;;;;;;;;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AAA;;;;;;;;;;;;cCpK9E,aAAA,GAAiB,KAAA,aAU1B,EAAA,CAVuC,IAAA;;;;;;;;;;;;;;;;;cAwC9B,gBAAA,GAAoB,KAAA,aAc7B,EAAA,CAd0C,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;cAsCjC,cAAA,GAAkB,KAAA,aAS3B,EAAA,CATwC,IAAA;;;;;;;;;;;;;;;;;;;;cAsC/B,gBAAA,GAAoB,KAAA,aAY7B,EAAA,CAZ0C,IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2BjC,eAAA,GAAmB,KAAA;EAAe;AAAA,IAA0B,WAAA,QAAgB,IAAA;;;;;;;;;;;cAqB5E,iBAAA,GAAqB,KAAA;EAAe;AAAA,IAA0B,WAAA,KAAgB,EAAA,CAAA,IAAA;;;;;;;;cAuB9E,gBAAA,GAAoB,KAAA;EAAe;AAAA,IAA0B,WAAA,KAAgB,EAAA,CAAA,IAAA;;;;;;;;;;;;KC1HrF,YAAA,GAAe,IAAA,CAAK,qBAAA;AAAA,KAEb,wBAAA,GAA2B,YAAA;EACrC,KAAA,EAAO,qBAAA;ETjFG;;;;ESsFV,KAAA;EACA,MAAA,GAAS,gBAAA,GAAmB,gBAAA;EAC5B,eAAA,GAAkB,cAAA;EAClB,YAAA;EACA,sBAAA;AAAA;;;;;;;ARlGF;;;;;;;;ACuBA;;;;iBOgGgB,iBAAA,CAAA;EACd,KAAA;EACA,MAAA;EACA,eAAA;EACA,YAAA;EACA,sBAAA;EAAA,GACG;AAAA,GACF,wBAAA,GAAwB,aAAA"}
|
|
@@ -451,6 +451,114 @@ const addPullRequestComment = (token, { needsApproval = true } = {}) => tool({
|
|
|
451
451
|
...args
|
|
452
452
|
})
|
|
453
453
|
});
|
|
454
|
+
async function listPullRequestFilesStep({ token, owner, repo, pullNumber, perPage, page }) {
|
|
455
|
+
"use step";
|
|
456
|
+
const { data } = await createOctokit(token).rest.pulls.listFiles({
|
|
457
|
+
owner,
|
|
458
|
+
repo,
|
|
459
|
+
pull_number: pullNumber,
|
|
460
|
+
per_page: perPage,
|
|
461
|
+
page
|
|
462
|
+
});
|
|
463
|
+
return data.map((file) => ({
|
|
464
|
+
filename: file.filename,
|
|
465
|
+
status: file.status,
|
|
466
|
+
additions: file.additions,
|
|
467
|
+
deletions: file.deletions,
|
|
468
|
+
changes: file.changes,
|
|
469
|
+
patch: file.patch
|
|
470
|
+
}));
|
|
471
|
+
}
|
|
472
|
+
const listPullRequestFiles = (token) => tool({
|
|
473
|
+
description: "List files changed in a pull request, including diff status and patch content",
|
|
474
|
+
inputSchema: z.object({
|
|
475
|
+
owner: z.string().describe("Repository owner"),
|
|
476
|
+
repo: z.string().describe("Repository name"),
|
|
477
|
+
pullNumber: z.number().describe("Pull request number"),
|
|
478
|
+
perPage: z.number().optional().default(30).describe("Number of results to return (max 100)"),
|
|
479
|
+
page: z.number().optional().default(1).describe("Page number for pagination")
|
|
480
|
+
}),
|
|
481
|
+
execute: async (args) => listPullRequestFilesStep({
|
|
482
|
+
token,
|
|
483
|
+
...args
|
|
484
|
+
})
|
|
485
|
+
});
|
|
486
|
+
async function listPullRequestReviewsStep({ token, owner, repo, pullNumber, perPage, page }) {
|
|
487
|
+
"use step";
|
|
488
|
+
const { data } = await createOctokit(token).rest.pulls.listReviews({
|
|
489
|
+
owner,
|
|
490
|
+
repo,
|
|
491
|
+
pull_number: pullNumber,
|
|
492
|
+
per_page: perPage,
|
|
493
|
+
page
|
|
494
|
+
});
|
|
495
|
+
return data.map((review) => ({
|
|
496
|
+
id: review.id,
|
|
497
|
+
state: review.state,
|
|
498
|
+
body: review.body,
|
|
499
|
+
author: review.user?.login,
|
|
500
|
+
url: review.html_url,
|
|
501
|
+
submittedAt: review.submitted_at
|
|
502
|
+
}));
|
|
503
|
+
}
|
|
504
|
+
const listPullRequestReviews = (token) => tool({
|
|
505
|
+
description: "List reviews on a pull request (approvals, change requests, and comments)",
|
|
506
|
+
inputSchema: z.object({
|
|
507
|
+
owner: z.string().describe("Repository owner"),
|
|
508
|
+
repo: z.string().describe("Repository name"),
|
|
509
|
+
pullNumber: z.number().describe("Pull request number"),
|
|
510
|
+
perPage: z.number().optional().default(30).describe("Number of results to return (max 100)"),
|
|
511
|
+
page: z.number().optional().default(1).describe("Page number for pagination")
|
|
512
|
+
}),
|
|
513
|
+
execute: async (args) => listPullRequestReviewsStep({
|
|
514
|
+
token,
|
|
515
|
+
...args
|
|
516
|
+
})
|
|
517
|
+
});
|
|
518
|
+
async function createPullRequestReviewStep({ token, owner, repo, pullNumber, body, event, comments }) {
|
|
519
|
+
"use step";
|
|
520
|
+
const { data } = await createOctokit(token).rest.pulls.createReview({
|
|
521
|
+
owner,
|
|
522
|
+
repo,
|
|
523
|
+
pull_number: pullNumber,
|
|
524
|
+
body,
|
|
525
|
+
event,
|
|
526
|
+
comments
|
|
527
|
+
});
|
|
528
|
+
return {
|
|
529
|
+
id: data.id,
|
|
530
|
+
state: data.state,
|
|
531
|
+
body: data.body,
|
|
532
|
+
url: data.html_url,
|
|
533
|
+
author: data.user?.login,
|
|
534
|
+
submittedAt: data.submitted_at
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
const createPullRequestReview = (token, { needsApproval = true } = {}) => tool({
|
|
538
|
+
description: "Submit a pull request review — approve, request changes, or comment with optional inline comments on specific lines",
|
|
539
|
+
needsApproval,
|
|
540
|
+
inputSchema: z.object({
|
|
541
|
+
owner: z.string().describe("Repository owner"),
|
|
542
|
+
repo: z.string().describe("Repository name"),
|
|
543
|
+
pullNumber: z.number().describe("Pull request number"),
|
|
544
|
+
body: z.string().optional().describe("Review body text (supports Markdown)"),
|
|
545
|
+
event: z.enum([
|
|
546
|
+
"APPROVE",
|
|
547
|
+
"REQUEST_CHANGES",
|
|
548
|
+
"COMMENT"
|
|
549
|
+
]).describe("Review action: approve, request changes, or comment"),
|
|
550
|
+
comments: z.array(z.object({
|
|
551
|
+
path: z.string().describe("File path relative to the repository root"),
|
|
552
|
+
body: z.string().describe("Inline comment text"),
|
|
553
|
+
line: z.number().optional().describe("Line number in the file to comment on"),
|
|
554
|
+
side: z.enum(["LEFT", "RIGHT"]).optional().describe("Which side of the diff to comment on (LEFT = base, RIGHT = head)")
|
|
555
|
+
})).optional().describe("Inline review comments on specific files and lines")
|
|
556
|
+
}),
|
|
557
|
+
execute: async (args) => createPullRequestReviewStep({
|
|
558
|
+
token,
|
|
559
|
+
...args
|
|
560
|
+
})
|
|
561
|
+
});
|
|
454
562
|
|
|
455
563
|
//#endregion
|
|
456
564
|
//#region src/tools/issues.ts
|
|
@@ -621,6 +729,89 @@ const closeIssue = (token, { needsApproval = true } = {}) => tool({
|
|
|
621
729
|
...args
|
|
622
730
|
})
|
|
623
731
|
});
|
|
732
|
+
async function listLabelsStep({ token, owner, repo, perPage, page }) {
|
|
733
|
+
"use step";
|
|
734
|
+
const { data } = await createOctokit(token).rest.issues.listLabelsForRepo({
|
|
735
|
+
owner,
|
|
736
|
+
repo,
|
|
737
|
+
per_page: perPage,
|
|
738
|
+
page
|
|
739
|
+
});
|
|
740
|
+
return data.map((label) => ({
|
|
741
|
+
name: label.name,
|
|
742
|
+
color: label.color,
|
|
743
|
+
description: label.description
|
|
744
|
+
}));
|
|
745
|
+
}
|
|
746
|
+
const listLabels = (token) => tool({
|
|
747
|
+
description: "List labels available in a GitHub repository",
|
|
748
|
+
inputSchema: z.object({
|
|
749
|
+
owner: z.string().describe("Repository owner"),
|
|
750
|
+
repo: z.string().describe("Repository name"),
|
|
751
|
+
perPage: z.number().optional().default(30).describe("Number of results to return (max 100)"),
|
|
752
|
+
page: z.number().optional().default(1).describe("Page number for pagination")
|
|
753
|
+
}),
|
|
754
|
+
execute: async (args) => listLabelsStep({
|
|
755
|
+
token,
|
|
756
|
+
...args
|
|
757
|
+
})
|
|
758
|
+
});
|
|
759
|
+
async function addLabelsStep({ token, owner, repo, issueNumber, labels }) {
|
|
760
|
+
"use step";
|
|
761
|
+
const { data } = await createOctokit(token).rest.issues.addLabels({
|
|
762
|
+
owner,
|
|
763
|
+
repo,
|
|
764
|
+
issue_number: issueNumber,
|
|
765
|
+
labels
|
|
766
|
+
});
|
|
767
|
+
return data.map((label) => ({
|
|
768
|
+
name: label.name,
|
|
769
|
+
color: label.color,
|
|
770
|
+
description: label.description
|
|
771
|
+
}));
|
|
772
|
+
}
|
|
773
|
+
const addLabels = (token, { needsApproval = true } = {}) => tool({
|
|
774
|
+
description: "Add labels to an issue or pull request",
|
|
775
|
+
needsApproval,
|
|
776
|
+
inputSchema: z.object({
|
|
777
|
+
owner: z.string().describe("Repository owner"),
|
|
778
|
+
repo: z.string().describe("Repository name"),
|
|
779
|
+
issueNumber: z.number().describe("Issue or pull request number"),
|
|
780
|
+
labels: z.array(z.string()).describe("Label names to add")
|
|
781
|
+
}),
|
|
782
|
+
execute: async (args) => addLabelsStep({
|
|
783
|
+
token,
|
|
784
|
+
...args
|
|
785
|
+
})
|
|
786
|
+
});
|
|
787
|
+
async function removeLabelStep({ token, owner, repo, issueNumber, label }) {
|
|
788
|
+
"use step";
|
|
789
|
+
await createOctokit(token).rest.issues.removeLabel({
|
|
790
|
+
owner,
|
|
791
|
+
repo,
|
|
792
|
+
issue_number: issueNumber,
|
|
793
|
+
name: label
|
|
794
|
+
});
|
|
795
|
+
return {
|
|
796
|
+
removed: true,
|
|
797
|
+
label,
|
|
798
|
+
issueNumber
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
const removeLabel = (token, { needsApproval = true } = {}) => tool({
|
|
802
|
+
description: "Remove a label from an issue or pull request",
|
|
803
|
+
needsApproval,
|
|
804
|
+
inputSchema: z.object({
|
|
805
|
+
owner: z.string().describe("Repository owner"),
|
|
806
|
+
repo: z.string().describe("Repository name"),
|
|
807
|
+
issueNumber: z.number().describe("Issue or pull request number"),
|
|
808
|
+
label: z.string().describe("Label name to remove")
|
|
809
|
+
}),
|
|
810
|
+
execute: async (args) => removeLabelStep({
|
|
811
|
+
token,
|
|
812
|
+
...args
|
|
813
|
+
})
|
|
814
|
+
});
|
|
624
815
|
|
|
625
816
|
//#endregion
|
|
626
817
|
//#region src/tools/search.ts
|
|
@@ -1363,6 +1554,8 @@ When reviewing a PR:
|
|
|
1363
1554
|
- Check for bugs, logic errors, and edge cases
|
|
1364
1555
|
- Suggest improvements when you spot issues
|
|
1365
1556
|
- Be constructive — explain why something is a problem and how to fix it
|
|
1557
|
+
- Use listPullRequestFiles to see exactly which files changed before diving into details
|
|
1558
|
+
- Use createPullRequestReview to submit a formal review with inline comments on specific lines
|
|
1366
1559
|
- Post your review as PR comments when asked
|
|
1367
1560
|
|
|
1368
1561
|
${SHARED_RULES}`,
|
|
@@ -1373,6 +1566,7 @@ When triaging issues:
|
|
|
1373
1566
|
- Identify duplicates when possible
|
|
1374
1567
|
- Help categorize and prioritize issues
|
|
1375
1568
|
- Respond to users with clear, helpful information
|
|
1569
|
+
- Use listLabels to see available labels, then addLabels and removeLabel to categorize issues
|
|
1376
1570
|
- Create new issues when asked, with clear titles and descriptions
|
|
1377
1571
|
|
|
1378
1572
|
${SHARED_RULES}`,
|
|
@@ -1451,5 +1645,5 @@ function createGithubAgent({ token, preset, requireApproval, instructions, addit
|
|
|
1451
1645
|
}
|
|
1452
1646
|
|
|
1453
1647
|
//#endregion
|
|
1454
|
-
export {
|
|
1455
|
-
//# sourceMappingURL=agents-
|
|
1648
|
+
export { addPullRequestComment as A, createRepository as B, addLabels as C, listIssues as D, getIssue as E, listPullRequestReviews as F, createOctokit as G, getFileContent as H, listPullRequests as I, mergePullRequest as L, createPullRequestReview as M, getPullRequest as N, listLabels as O, listPullRequestFiles as P, createBranch as R, addIssueComment as S, createIssue as T, getRepository as U, forkRepository as V, listBranches as W, getBlame as _, listWorkflowJobs as a, searchCode as b, rerunWorkflowRun as c, createGistComment as d, deleteGist as f, updateGist as g, listGists as h, getWorkflowRun as i, createPullRequest as j, removeLabel as k, triggerWorkflow as l, listGistComments as m, resolveInstructions as n, listWorkflowRuns as o, getGist as p, cancelWorkflowRun as r, listWorkflows as s, createGithubAgent as t, createGist as u, getCommit as v, closeIssue as w, searchRepositories as x, listCommits as y, createOrUpdateFile as z };
|
|
1649
|
+
//# sourceMappingURL=agents-D9aKsd_7.mjs.map
|