@kana-ai/edgar-ext-github 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +469 -2
- package/agents/dismiss/agent.toml +4 -0
- package/agents/dismiss/instructions.md +25 -0
- package/dist/src/api/app.d.ts +16 -0
- package/dist/src/api/app.js +32 -0
- package/dist/src/api/client.d.ts +26 -0
- package/dist/src/api/client.js +103 -0
- package/dist/src/api/failures.d.ts +8 -0
- package/dist/src/api/failures.js +31 -0
- package/dist/src/feed/alerts.d.ts +26 -0
- package/dist/src/feed/alerts.js +117 -0
- package/dist/src/feed/cards.d.ts +32 -0
- package/dist/src/feed/cards.js +164 -0
- package/dist/src/feed/service.d.ts +28 -0
- package/dist/src/feed/service.js +163 -0
- package/dist/src/index.d.ts +490 -0
- package/dist/src/index.js +62 -0
- package/dist/src/schemas/config.d.ts +57 -0
- package/dist/src/schemas/config.js +89 -0
- package/dist/src/schemas/github.d.ts +417 -0
- package/dist/src/schemas/github.js +216 -0
- package/dist/src/schemas/tools.d.ts +620 -0
- package/dist/src/schemas/tools.js +501 -0
- package/dist/src/tools/alerts.d.ts +45 -0
- package/dist/src/tools/alerts.js +100 -0
- package/dist/src/tools/branch.d.ts +9 -0
- package/dist/src/tools/branch.js +48 -0
- package/dist/src/tools/checks.d.ts +118 -0
- package/dist/src/tools/checks.js +223 -0
- package/dist/src/tools/discussion.d.ts +41 -0
- package/dist/src/tools/discussion.js +66 -0
- package/dist/src/tools/pull-request.d.ts +195 -0
- package/dist/src/tools/pull-request.js +537 -0
- package/dist/src/tools/repository.d.ts +53 -0
- package/dist/src/tools/repository.js +134 -0
- package/dist/src/tools/screenshot.d.ts +21 -0
- package/dist/src/tools/screenshot.js +99 -0
- package/dist/src/tracker/assignee.d.ts +15 -0
- package/dist/src/tracker/assignee.js +65 -0
- package/dist/src/tracker/cards.d.ts +41 -0
- package/dist/src/tracker/cards.js +361 -0
- package/dist/src/tracker/comments.d.ts +9 -0
- package/dist/src/tracker/comments.js +68 -0
- package/dist/src/tracker/description.d.ts +19 -0
- package/dist/src/tracker/description.js +55 -0
- package/dist/src/tracker/hand-back.d.ts +8 -0
- package/dist/src/tracker/hand-back.js +60 -0
- package/dist/src/tracker/port.d.ts +2 -0
- package/dist/src/tracker/port.js +42 -0
- package/dist/src/tracker/states.d.ts +77 -0
- package/dist/src/tracker/states.js +189 -0
- package/dist/src/tracker/tools.d.ts +143 -0
- package/dist/src/tracker/tools.js +131 -0
- package/dist/src/tracker/transitions.d.ts +12 -0
- package/dist/src/tracker/transitions.js +101 -0
- package/edgar-extension.json +507 -0
- package/package.json +43 -3
- package/schemas/assign.in.json +15 -0
- package/schemas/assign.out.json +14 -0
- package/schemas/attach_screenshot.in.json +44 -0
- package/schemas/attach_screenshot.out.json +31 -0
- package/schemas/batch_cards.in.json +27 -0
- package/schemas/batch_cards.out.json +37 -0
- package/schemas/branch_protection.in.json +15 -0
- package/schemas/branch_protection.out.json +67 -0
- package/schemas/ci_run.in.json +12 -0
- package/schemas/ci_run.out.json +109 -0
- package/schemas/close.in.json +14 -0
- package/schemas/close.out.json +10 -0
- package/schemas/close_pull_request.in.json +21 -0
- package/schemas/close_pull_request.out.json +14 -0
- package/schemas/comment.in.json +19 -0
- package/schemas/comment.out.json +10 -0
- package/schemas/config.json +202 -0
- package/schemas/count_sighting.in.json +17 -0
- package/schemas/count_sighting.out.json +10 -0
- package/schemas/create_card.in.json +108 -0
- package/schemas/create_card.out.json +13 -0
- package/schemas/dependabot_alerts.in.json +49 -0
- package/schemas/dependabot_alerts.out.json +75 -0
- package/schemas/dismiss_dependabot_alert.in.json +26 -0
- package/schemas/dismiss_dependabot_alert.out.json +27 -0
- package/schemas/find_assignee.in.json +15 -0
- package/schemas/find_assignee.out.json +10 -0
- package/schemas/find_cards.in.json +18 -0
- package/schemas/find_cards.out.json +33 -0
- package/schemas/find_dependabot_dismissal.in.json +12 -0
- package/schemas/find_dependabot_dismissal.out.json +27 -0
- package/schemas/find_description.in.json +15 -0
- package/schemas/find_description.out.json +10 -0
- package/schemas/find_pull_request.in.json +25 -0
- package/schemas/find_pull_request.out.json +14 -0
- package/schemas/hand_back.in.json +11 -0
- package/schemas/hand_back.out.json +18 -0
- package/schemas/linked_pull_requests.in.json +15 -0
- package/schemas/linked_pull_requests.out.json +44 -0
- package/schemas/list_pull_requests.in.json +26 -0
- package/schemas/list_pull_requests.out.json +42 -0
- package/schemas/merge_pull_request.in.json +22 -0
- package/schemas/merge_pull_request.out.json +16 -0
- package/schemas/move.in.json +15 -0
- package/schemas/move.out.json +10 -0
- package/schemas/note_pull_request.in.json +15 -0
- package/schemas/note_pull_request.out.json +10 -0
- package/schemas/open_pull_request.in.json +113 -0
- package/schemas/open_pull_request.out.json +15 -0
- package/schemas/pull_request_checks.in.json +11 -0
- package/schemas/pull_request_checks.out.json +72 -0
- package/schemas/pull_request_discussion.in.json +11 -0
- package/schemas/pull_request_discussion.out.json +107 -0
- package/schemas/pull_request_state.in.json +11 -0
- package/schemas/pull_request_state.out.json +52 -0
- package/schemas/push_branch.in.json +21 -0
- package/schemas/push_branch.out.json +13 -0
- package/schemas/release_follow_ups.in.json +15 -0
- package/schemas/release_follow_ups.out.json +13 -0
- package/schemas/reopen_dependabot_alert.in.json +33 -0
- package/schemas/reopen_dependabot_alert.out.json +22 -0
- package/schemas/restore_assignee.in.json +20 -0
- package/schemas/restore_assignee.out.json +10 -0
- package/schemas/restore_description.in.json +20 -0
- package/schemas/restore_description.out.json +10 -0
- package/schemas/update_description.in.json +15 -0
- package/schemas/update_description.out.json +14 -0
- package/schemas/update_pull_request.in.json +81 -0
- package/schemas/update_pull_request.out.json +10 -0
- package/schemas/wait_for_checks.in.json +11 -0
- package/schemas/wait_for_checks.out.json +72 -0
- package/schemas/wait_for_merge.in.json +11 -0
- package/schemas/wait_for_merge.out.json +17 -0
- package/schemas/wait_for_passed_checks.in.json +11 -0
- package/schemas/wait_for_passed_checks.out.json +72 -0
- package/schemas/wait_for_review.in.json +11 -0
- package/schemas/wait_for_review.out.json +52 -0
- package/workflows/resume.toml +17 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
import { cardSpec } from "@kana-ai/edgar-contracts/card";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/** The state of a pull request as a tool answers it. */
|
|
4
|
+
export const state = z.enum(["open", "merged", "closed"]);
|
|
5
|
+
/** The review state from each reviewer's latest deciding review. */
|
|
6
|
+
export const reviewStates = z.enum(["pending", "approved", "changes_requested"]);
|
|
7
|
+
const byUrl = z.object({ url: z.string().min(1) });
|
|
8
|
+
const httpsUrl = z.url({ protocol: /^https$/ });
|
|
9
|
+
const byBranch = z.object({ repo: z.string().min(1), branch: z.string().min(1) });
|
|
10
|
+
/** The input and output of `push_branch`. */
|
|
11
|
+
export const pushBranch = {
|
|
12
|
+
input: z.object({
|
|
13
|
+
repo: z.string().min(1),
|
|
14
|
+
branch: z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1)
|
|
17
|
+
.optional()
|
|
18
|
+
.describe("the edgar/ branch of the sandbox to push under its own name"),
|
|
19
|
+
to: z
|
|
20
|
+
.string()
|
|
21
|
+
.min(1)
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("the edgar/ branch on origin that gets the head of the sandbox: the branch of an open pull request"),
|
|
24
|
+
}),
|
|
25
|
+
output: z.object({ branch: z.string(), commit: z.string() }),
|
|
26
|
+
};
|
|
27
|
+
/** The input and output of `open_pull_request`. */
|
|
28
|
+
export const openPullRequest = {
|
|
29
|
+
input: z.object({
|
|
30
|
+
repo: z.string().min(1),
|
|
31
|
+
branch: z.string().min(1),
|
|
32
|
+
title: z.string().min(1),
|
|
33
|
+
body: z.string(),
|
|
34
|
+
review: z.string(),
|
|
35
|
+
labels: z.array(z.string().min(1)).optional().describe("labels the pull request gets"),
|
|
36
|
+
large_diff_lines: z
|
|
37
|
+
.number()
|
|
38
|
+
.int()
|
|
39
|
+
.positive()
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("the body says the change is large when it changes more lines than this"),
|
|
42
|
+
path_notices: z
|
|
43
|
+
.array(z.object({ prefix: z.string().min(1), notice: z.string().min(1) }))
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("a line the body carries when the change touches a file under prefix"),
|
|
46
|
+
checks: z
|
|
47
|
+
.object({
|
|
48
|
+
results: z.array(z.object({ check: z.string().min(1), exit_code: z.number().int().nullable() })),
|
|
49
|
+
})
|
|
50
|
+
.optional()
|
|
51
|
+
.describe("the output of a check stage: the body lists each check that passed under Verified, and each other check under Not verified"),
|
|
52
|
+
not_verified: z
|
|
53
|
+
.array(z.string())
|
|
54
|
+
.optional()
|
|
55
|
+
.describe("what the author of the change did not check, one line each, under Not verified"),
|
|
56
|
+
related: z
|
|
57
|
+
.union([httpsUrl, z.array(httpsUrl).max(5)])
|
|
58
|
+
.optional()
|
|
59
|
+
.describe("one URL, or at most 5, of the pull requests this one goes with, named after the body; each must be https, which the tool checks when it runs"),
|
|
60
|
+
}),
|
|
61
|
+
output: z.object({ url: z.string(), number: z.number().int() }),
|
|
62
|
+
};
|
|
63
|
+
/** The input and output of `close_pull_request`, which the engine calls with the output of the `open_pull_request` call that it undoes. The sweep adds `text`, the line that says why, when a person closed the card of the pull request. */
|
|
64
|
+
export const closePullRequest = {
|
|
65
|
+
input: z.object({ stage_output: byUrl, text: z.string().min(1).optional() }),
|
|
66
|
+
output: z.object({ url: z.string(), state }),
|
|
67
|
+
};
|
|
68
|
+
/** The input and output of `note_pull_request`: `text` is one new line of EDGAR's note on the pull request, and `url` in the output is the note. */
|
|
69
|
+
export const notePullRequest = {
|
|
70
|
+
input: byUrl.extend({ text: z.string().min(1) }),
|
|
71
|
+
output: z.object({ url: z.string() }),
|
|
72
|
+
};
|
|
73
|
+
/** The input and output of `attach_screenshot`: `shot` is the output of a stage that took a picture, a PNG of the sandbox with what it shows, or why there is none. */
|
|
74
|
+
export const attachScreenshot = {
|
|
75
|
+
input: byUrl.extend({
|
|
76
|
+
shot: z.union([
|
|
77
|
+
z.object({ path: z.string().min(1), bytes: z.int().min(0), caption: z.string().min(1) }),
|
|
78
|
+
z.object({ missing: z.string().min(1) }),
|
|
79
|
+
]),
|
|
80
|
+
}),
|
|
81
|
+
output: z.union([
|
|
82
|
+
z.object({ attached: z.literal(true), image: z.string() }),
|
|
83
|
+
z.object({ attached: z.literal(false), missing: z.string() }),
|
|
84
|
+
]),
|
|
85
|
+
};
|
|
86
|
+
/** The input and output of `update_pull_request`: a new `title` and `body` for an open pull request whose text a later change made untrue. The body gets its notices and proof again, as `open_pull_request` gives them. */
|
|
87
|
+
export const updatePullRequest = {
|
|
88
|
+
input: byUrl.extend(openPullRequest.input.pick({
|
|
89
|
+
title: true,
|
|
90
|
+
body: true,
|
|
91
|
+
large_diff_lines: true,
|
|
92
|
+
path_notices: true,
|
|
93
|
+
checks: true,
|
|
94
|
+
not_verified: true,
|
|
95
|
+
}).shape),
|
|
96
|
+
output: z.object({ url: z.string() }),
|
|
97
|
+
};
|
|
98
|
+
/** The input and output of `linked_pull_requests`: the pull requests of `repo` that `text` links, each with what it changes, so a role with no access to GitHub can tell whether one already fixes a card. */
|
|
99
|
+
export const linkedPullRequests = {
|
|
100
|
+
input: z.object({
|
|
101
|
+
text: z.string(),
|
|
102
|
+
repo: z
|
|
103
|
+
.string()
|
|
104
|
+
.min(1)
|
|
105
|
+
.describe("the repository of the card's service; a link to a pull request elsewhere is left out"),
|
|
106
|
+
}),
|
|
107
|
+
output: z.object({
|
|
108
|
+
pull_requests: z.array(z.object({
|
|
109
|
+
url: z.string(),
|
|
110
|
+
state,
|
|
111
|
+
title: z.string(),
|
|
112
|
+
body: z.string(),
|
|
113
|
+
files: z.array(z.object({ path: z.string(), patch: z.string() })),
|
|
114
|
+
})),
|
|
115
|
+
}),
|
|
116
|
+
};
|
|
117
|
+
/** The input and output of `find_pull_request`, which the engine calls with the input of the `open_pull_request` call whose end it did not see. */
|
|
118
|
+
export const findPullRequest = {
|
|
119
|
+
input: z.object({ operation_id: z.string().min(1), input: byBranch }),
|
|
120
|
+
output: z.object({ url: z.string(), state }),
|
|
121
|
+
};
|
|
122
|
+
/** The input and output of `list_pull_requests`. */
|
|
123
|
+
export const listPullRequests = {
|
|
124
|
+
input: z.object({
|
|
125
|
+
services: z.array(z.object({ repo: z.string().min(1) })),
|
|
126
|
+
merged_within_hours: z
|
|
127
|
+
.number()
|
|
128
|
+
.int()
|
|
129
|
+
.min(1)
|
|
130
|
+
.max(720)
|
|
131
|
+
.optional()
|
|
132
|
+
.describe("with it, the pull requests merged within this many hours, in place of the open ones"),
|
|
133
|
+
}),
|
|
134
|
+
output: z.object({
|
|
135
|
+
pull_requests: z.array(z.object({
|
|
136
|
+
url: z.string(),
|
|
137
|
+
branch: z.string(),
|
|
138
|
+
card: z.string(),
|
|
139
|
+
unmerged: z
|
|
140
|
+
.array(z.object({ url: z.string(), state: z.enum(["open", "closed"]) }))
|
|
141
|
+
.describe("with merged_within_hours, the pull requests of its `Goes with:` line that are not merged; empty otherwise"),
|
|
142
|
+
})),
|
|
143
|
+
}),
|
|
144
|
+
};
|
|
145
|
+
/** The input and output of `wait_for_merge`. */
|
|
146
|
+
export const waitForMerge = {
|
|
147
|
+
input: byUrl,
|
|
148
|
+
output: z.object({
|
|
149
|
+
url: z.string(),
|
|
150
|
+
merged: z.boolean(),
|
|
151
|
+
sha: z.string().optional().describe("the merge commit, once merged"),
|
|
152
|
+
}),
|
|
153
|
+
};
|
|
154
|
+
/** The input and output of `pull_request_state`. */
|
|
155
|
+
export const pullRequestState = {
|
|
156
|
+
input: byUrl,
|
|
157
|
+
output: z.object({
|
|
158
|
+
url: z.string(),
|
|
159
|
+
state,
|
|
160
|
+
merged: z.boolean(),
|
|
161
|
+
review_state: reviewStates,
|
|
162
|
+
approved_by: z
|
|
163
|
+
.array(z.string())
|
|
164
|
+
.describe("the login of each reviewer whose latest deciding review approves"),
|
|
165
|
+
card: z.string().nullable(),
|
|
166
|
+
commit: z.string(),
|
|
167
|
+
branch: z.string().describe("the head branch"),
|
|
168
|
+
head_repo: z
|
|
169
|
+
.string()
|
|
170
|
+
.nullable()
|
|
171
|
+
.describe("the repository of the head branch as owner/name, a fork's for a fork; null when it was deleted"),
|
|
172
|
+
}),
|
|
173
|
+
};
|
|
174
|
+
/** The input and output of `merge_pull_request`. */
|
|
175
|
+
export const mergePullRequest = {
|
|
176
|
+
input: byUrl.extend({
|
|
177
|
+
commit: z
|
|
178
|
+
.string()
|
|
179
|
+
.regex(/^[0-9a-f]{40}$/)
|
|
180
|
+
.describe("the head commit to merge, as pull_request_state gives it; GitHub merges nothing when the head has moved"),
|
|
181
|
+
changed_files: z
|
|
182
|
+
.number()
|
|
183
|
+
.int()
|
|
184
|
+
.min(0)
|
|
185
|
+
.optional()
|
|
186
|
+
.describe("the files the pull request changes at commit, as wait_for_checks gives them; with it, a workflow stage's merge runs with no person under [limits] self_merge_files and is skipped at or past it"),
|
|
187
|
+
}),
|
|
188
|
+
output: z.object({ url: z.string(), merged: z.boolean(), commit: z.string() }),
|
|
189
|
+
};
|
|
190
|
+
/** The state of a commit's checks: `pending` while one runs, `failed` once one failed, else `passed`; `closed` when the pull request is closed or merged, whatever its checks. */
|
|
191
|
+
export const checksState = z.enum(["pending", "passed", "failed", "closed"]);
|
|
192
|
+
/** The input and output of `pull_request_checks` and `wait_for_checks`. */
|
|
193
|
+
export const pullRequestChecks = {
|
|
194
|
+
input: z.object({ url: z.string().min(1) }),
|
|
195
|
+
output: z.object({
|
|
196
|
+
url: z.string(),
|
|
197
|
+
commit: z.string(),
|
|
198
|
+
state: checksState,
|
|
199
|
+
merged: z.boolean(),
|
|
200
|
+
checks: z.number().int(),
|
|
201
|
+
failed: z.array(z.object({ name: z.string(), url: z.string().nullable() })),
|
|
202
|
+
retry_after_seconds: z.number().int().nullable(),
|
|
203
|
+
summary: z.string().describe("one sentence a later stage can post as it is"),
|
|
204
|
+
changed_files: z.number().int().describe("the files the pull request changes at commit"),
|
|
205
|
+
}),
|
|
206
|
+
};
|
|
207
|
+
/** The states of a Dependabot alert. */
|
|
208
|
+
export const alertStates = z.enum(["open", "fixed", "dismissed", "auto_dismissed"]);
|
|
209
|
+
/** The input and output of `dependabot_alerts`. */
|
|
210
|
+
export const dependabotAlerts = {
|
|
211
|
+
input: z.object({
|
|
212
|
+
repo: z.string().min(1),
|
|
213
|
+
number: z
|
|
214
|
+
.number()
|
|
215
|
+
.int()
|
|
216
|
+
.positive()
|
|
217
|
+
.optional()
|
|
218
|
+
.describe("one alert; the filters then must be empty"),
|
|
219
|
+
state: z.array(alertStates).optional().describe("every state when absent"),
|
|
220
|
+
package: z.string().min(1).optional(),
|
|
221
|
+
ghsa: z.array(z.string().regex(/^GHSA(-[0-9a-zA-Z]{4}){3}$/)).optional(),
|
|
222
|
+
cve: z.array(z.string().regex(/^CVE-\d{4}-\d{4,}$/i)).optional(),
|
|
223
|
+
limit: z.number().int().min(1).max(100).optional().describe("30 when absent"),
|
|
224
|
+
}),
|
|
225
|
+
output: z.object({
|
|
226
|
+
alerts: z.array(z.object({
|
|
227
|
+
number: z.number().int(),
|
|
228
|
+
url: z.string(),
|
|
229
|
+
state: z.string(),
|
|
230
|
+
package: z.string().nullable(),
|
|
231
|
+
ecosystem: z.string().nullable(),
|
|
232
|
+
severity: z.string(),
|
|
233
|
+
vulnerable_range: z.string(),
|
|
234
|
+
first_patched: z.string().nullable(),
|
|
235
|
+
manifest: z.string().nullable(),
|
|
236
|
+
scope: z.string().nullable(),
|
|
237
|
+
ghsa: z.string(),
|
|
238
|
+
cve: z.string().nullable(),
|
|
239
|
+
summary: z.string(),
|
|
240
|
+
})),
|
|
241
|
+
complete: z.boolean().describe("false when GitHub may hold more alerts than one page gave"),
|
|
242
|
+
}),
|
|
243
|
+
};
|
|
244
|
+
/** The reasons GitHub takes for the dismissal of a Dependabot alert. */
|
|
245
|
+
const dismissReasons = z.enum([
|
|
246
|
+
"fix_started",
|
|
247
|
+
"inaccurate",
|
|
248
|
+
"no_bandwidth",
|
|
249
|
+
"not_used",
|
|
250
|
+
"tolerable_risk",
|
|
251
|
+
]);
|
|
252
|
+
const dismissal = z.object({
|
|
253
|
+
repo: z.string().describe("owner/name"),
|
|
254
|
+
number: z.number().int(),
|
|
255
|
+
url: z.string(),
|
|
256
|
+
reason: z.string().describe("the reason the alert holds now"),
|
|
257
|
+
reopen: z
|
|
258
|
+
.boolean()
|
|
259
|
+
.describe("true when the alert was open, or held the reason and the comment of this call; reopen_dependabot_alert opens the alert again only then"),
|
|
260
|
+
});
|
|
261
|
+
/** The input and output of `dismiss_dependabot_alert`. */
|
|
262
|
+
export const dismissDependabotAlert = {
|
|
263
|
+
input: z.object({
|
|
264
|
+
repo: z.string().min(1),
|
|
265
|
+
number: z.number().int().positive(),
|
|
266
|
+
reason: dismissReasons,
|
|
267
|
+
comment: z
|
|
268
|
+
.string()
|
|
269
|
+
.min(1)
|
|
270
|
+
.max(280)
|
|
271
|
+
.describe("why, for the people who read the alert; GitHub keeps at most 280 characters"),
|
|
272
|
+
}),
|
|
273
|
+
output: dismissal,
|
|
274
|
+
};
|
|
275
|
+
/** The input and output of `reopen_dependabot_alert`, which the engine calls with the output of the call it undoes. */
|
|
276
|
+
export const reopenDependabotAlert = {
|
|
277
|
+
input: z.object({ stage_output: dismissal }),
|
|
278
|
+
output: z.object({
|
|
279
|
+
repo: z.string(),
|
|
280
|
+
number: z.number().int(),
|
|
281
|
+
url: z.string(),
|
|
282
|
+
reopened: z.boolean().describe("false when there was nothing to open again"),
|
|
283
|
+
}),
|
|
284
|
+
};
|
|
285
|
+
/** The input and output of `find_dependabot_dismissal`: the operation and the input of a `dismiss_dependabot_alert` call. */
|
|
286
|
+
export const findDependabotDismissal = {
|
|
287
|
+
input: z.object({ operation_id: z.string().min(1), input: z.unknown() }),
|
|
288
|
+
output: dismissal,
|
|
289
|
+
};
|
|
290
|
+
const remark = z.object({ by: z.string().nullable(), at: z.string().nullable(), body: z.string() });
|
|
291
|
+
/** The input and output of `pull_request_discussion`. */
|
|
292
|
+
export const pullRequestDiscussion = {
|
|
293
|
+
input: z.object({ url: z.string().min(1) }),
|
|
294
|
+
output: z.object({
|
|
295
|
+
url: z.string(),
|
|
296
|
+
reviews: z.array(remark.extend({ state: z.string() })),
|
|
297
|
+
threads: z.array(remark.extend({
|
|
298
|
+
path: z.string(),
|
|
299
|
+
line: z.number().int().nullable(),
|
|
300
|
+
hunk: z.string(),
|
|
301
|
+
replies: z.array(remark),
|
|
302
|
+
})),
|
|
303
|
+
conversation: z.array(remark),
|
|
304
|
+
complete: z.boolean().describe("false when a list came back a full page of 100"),
|
|
305
|
+
}),
|
|
306
|
+
};
|
|
307
|
+
/** The input and output of `ci_run`. */
|
|
308
|
+
export const ciRun = {
|
|
309
|
+
input: z.object({
|
|
310
|
+
url: z
|
|
311
|
+
.string()
|
|
312
|
+
.min(1)
|
|
313
|
+
.describe("https://github.com/<owner>/<name>/actions/runs/<id>, with /job/<id> to read that job's log"),
|
|
314
|
+
}),
|
|
315
|
+
output: z.object({
|
|
316
|
+
url: z.string(),
|
|
317
|
+
workflow: z.string().nullable(),
|
|
318
|
+
status: z.string().nullable(),
|
|
319
|
+
conclusion: z.string().nullable(),
|
|
320
|
+
commit: z.string(),
|
|
321
|
+
branch: z.string().nullable(),
|
|
322
|
+
attempt: z.number().int(),
|
|
323
|
+
jobs: z.array(z.object({
|
|
324
|
+
id: z.number().int(),
|
|
325
|
+
name: z.string(),
|
|
326
|
+
status: z.string(),
|
|
327
|
+
conclusion: z.string().nullable(),
|
|
328
|
+
failed_steps: z.array(z.string()),
|
|
329
|
+
})),
|
|
330
|
+
logs: z.array(z.object({
|
|
331
|
+
job: z.number().int(),
|
|
332
|
+
name: z.string(),
|
|
333
|
+
gone: z.boolean().describe("true when GitHub no longer keeps the log"),
|
|
334
|
+
errors: z.array(z.string()),
|
|
335
|
+
excerpt: z.string(),
|
|
336
|
+
})),
|
|
337
|
+
unread: z
|
|
338
|
+
.array(z.number().int())
|
|
339
|
+
.describe("failed jobs past the log limit, read with /job/<id>"),
|
|
340
|
+
}),
|
|
341
|
+
};
|
|
342
|
+
/** The input and output of `branch_protection`. */
|
|
343
|
+
export const branchProtection = {
|
|
344
|
+
input: z.object({ repo: z.string().min(1), branch: z.string().min(1) }),
|
|
345
|
+
output: z.object({
|
|
346
|
+
branch: z.string(),
|
|
347
|
+
protected: z.boolean(),
|
|
348
|
+
pull_request_required: z.boolean().nullable(),
|
|
349
|
+
required_approvals: z.number().int().nullable(),
|
|
350
|
+
required_checks: z.array(z.string()),
|
|
351
|
+
rules: z.array(z.object({ type: z.string(), ruleset_id: z.number().int(), source: z.string() })),
|
|
352
|
+
classic: z
|
|
353
|
+
.enum(["read", "none", "unreadable"])
|
|
354
|
+
.describe("unreadable: the classic rule needs an admin token, so the nulls are unknown"),
|
|
355
|
+
}),
|
|
356
|
+
};
|
|
357
|
+
/** The input and output of `comment`. */
|
|
358
|
+
export const commentTool = {
|
|
359
|
+
input: z.object({
|
|
360
|
+
card: z.string().min(1),
|
|
361
|
+
text: z.string().min(1),
|
|
362
|
+
link: z.string().min(1).exactOptional(),
|
|
363
|
+
}),
|
|
364
|
+
output: z.object({ id: z.string() }),
|
|
365
|
+
};
|
|
366
|
+
/** The input and output of `move`. */
|
|
367
|
+
export const moveTool = {
|
|
368
|
+
input: z.object({ card: z.string().min(1), column: z.string().min(1) }),
|
|
369
|
+
output: z.object({ column: z.string() }),
|
|
370
|
+
};
|
|
371
|
+
/** The input and output of `close`. */
|
|
372
|
+
export const closeTool = {
|
|
373
|
+
input: z.object({ card: z.string().min(1), reason: z.string() }),
|
|
374
|
+
output: z.object({ state: z.string() }),
|
|
375
|
+
};
|
|
376
|
+
/** The input and output of `create_card`. */
|
|
377
|
+
export const createCardTool = {
|
|
378
|
+
input: z.object({ spec: cardSpec, parent: z.string().min(1).exactOptional() }),
|
|
379
|
+
output: z.object({ id: z.string(), url: z.string() }),
|
|
380
|
+
};
|
|
381
|
+
/** The input and output of `release_follow_ups`. */
|
|
382
|
+
export const releaseFollowUpsTool = {
|
|
383
|
+
input: z.object({ card: z.string().min(1), pull_request: z.string().min(1) }),
|
|
384
|
+
output: z.object({ released: z.array(z.string()) }),
|
|
385
|
+
};
|
|
386
|
+
/** The input and output of `find_cards`. */
|
|
387
|
+
export const findCardsTool = {
|
|
388
|
+
input: z.object({
|
|
389
|
+
text: z
|
|
390
|
+
.string()
|
|
391
|
+
.min(1)
|
|
392
|
+
.max(1024)
|
|
393
|
+
.describe("words of the fault, such as the error message, the endpoint or the service"),
|
|
394
|
+
except: z
|
|
395
|
+
.string()
|
|
396
|
+
.min(1)
|
|
397
|
+
.exactOptional()
|
|
398
|
+
.describe("the card you work on; it and each card made after it are left out"),
|
|
399
|
+
}),
|
|
400
|
+
output: z.object({
|
|
401
|
+
cards: z
|
|
402
|
+
.array(z.object({
|
|
403
|
+
id: z.string(),
|
|
404
|
+
title: z.string(),
|
|
405
|
+
url: z.string(),
|
|
406
|
+
state: z.string().describe("the engine state of the card, or its column name"),
|
|
407
|
+
created_at: z.string(),
|
|
408
|
+
}))
|
|
409
|
+
.max(10),
|
|
410
|
+
}),
|
|
411
|
+
};
|
|
412
|
+
/** The input and output of `batch_cards`. */
|
|
413
|
+
export const batchCardsTool = {
|
|
414
|
+
input: z.object({
|
|
415
|
+
batch: z
|
|
416
|
+
.string()
|
|
417
|
+
.min(1)
|
|
418
|
+
.max(256)
|
|
419
|
+
.describe("the `decided.batch` of the card you work on, such as its repository"),
|
|
420
|
+
except: z.string().min(1).describe("the card you work on; it is left out"),
|
|
421
|
+
only: z
|
|
422
|
+
.array(z.string().min(1))
|
|
423
|
+
.max(20)
|
|
424
|
+
.optional()
|
|
425
|
+
.describe("only these card ids, each kept only while it is an open card of the batch"),
|
|
426
|
+
}),
|
|
427
|
+
output: z.object({
|
|
428
|
+
cards: z
|
|
429
|
+
.array(z.object({
|
|
430
|
+
id: z.string(),
|
|
431
|
+
title: z.string(),
|
|
432
|
+
url: z.string(),
|
|
433
|
+
description: z.string(),
|
|
434
|
+
}))
|
|
435
|
+
.max(20),
|
|
436
|
+
skipped: z
|
|
437
|
+
.array(z.string())
|
|
438
|
+
.max(20)
|
|
439
|
+
.optional()
|
|
440
|
+
.describe("the ids of `only` that are not open cards of the batch; absent when none is"),
|
|
441
|
+
}),
|
|
442
|
+
};
|
|
443
|
+
/** The input and output of `count_sighting`. */
|
|
444
|
+
export const countSightingTool = {
|
|
445
|
+
input: z.object({
|
|
446
|
+
card: z.string().min(1),
|
|
447
|
+
seen_at: z.iso
|
|
448
|
+
.datetime({ offset: true })
|
|
449
|
+
.exactOptional()
|
|
450
|
+
.describe("when the fault was seen again; a retry with the same time counts nothing"),
|
|
451
|
+
}),
|
|
452
|
+
output: z.object({ id: z.string() }),
|
|
453
|
+
};
|
|
454
|
+
/** The input and output of `update_description` and of its lookup, `find_description`. */
|
|
455
|
+
export const descriptionTool = {
|
|
456
|
+
input: z.object({
|
|
457
|
+
card: z.string().min(1),
|
|
458
|
+
description: z.string().describe("the new description; the card's edgar:v0 block is kept"),
|
|
459
|
+
}),
|
|
460
|
+
output: z.object({
|
|
461
|
+
id: z.string(),
|
|
462
|
+
previous: z
|
|
463
|
+
.string()
|
|
464
|
+
.optional()
|
|
465
|
+
.describe("the description before the write, which restore_description puts back; none when the card already read so"),
|
|
466
|
+
}),
|
|
467
|
+
};
|
|
468
|
+
/** The input and output of `assign` and of its lookup, `find_assignee`. */
|
|
469
|
+
export const assignTool = {
|
|
470
|
+
input: z.object({
|
|
471
|
+
card: z.string().min(1),
|
|
472
|
+
user: z
|
|
473
|
+
.string()
|
|
474
|
+
.describe("the GitHub login, `me` for EDGAR's own login, or an empty text for nobody"),
|
|
475
|
+
}),
|
|
476
|
+
output: z.object({
|
|
477
|
+
id: z.string(),
|
|
478
|
+
previous: z
|
|
479
|
+
.string()
|
|
480
|
+
.optional()
|
|
481
|
+
.describe("the login the card was assigned to before the write, or an empty text for nobody, which restore_assignee sets back; none when the card already had that assignee"),
|
|
482
|
+
}),
|
|
483
|
+
};
|
|
484
|
+
/** The input and output of `restore_description` and of `restore_assignee`, which the engine calls with the undone call's output. */
|
|
485
|
+
export const restoreTool = {
|
|
486
|
+
input: z.object({
|
|
487
|
+
stage_output: z.object({ id: z.string().min(1), previous: z.string().optional() }),
|
|
488
|
+
}),
|
|
489
|
+
output: z.object({ id: z.string() }),
|
|
490
|
+
};
|
|
491
|
+
/** The input and output of `hand_back`. */
|
|
492
|
+
export const handBackTool = {
|
|
493
|
+
input: z.object({ card: z.string().min(1) }),
|
|
494
|
+
output: z.object({
|
|
495
|
+
id: z.string(),
|
|
496
|
+
to: z.string().describe("the login of the person the card is now assigned to"),
|
|
497
|
+
previous: z
|
|
498
|
+
.string()
|
|
499
|
+
.describe("the login the card was assigned to before, or an empty text for nobody"),
|
|
500
|
+
}),
|
|
501
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** The tools that write a person's decision on a Dependabot alert, by the name the manifest gives them. */
|
|
2
|
+
export declare const alertTools: {
|
|
3
|
+
/**
|
|
4
|
+
* Reads the alert first, so a second run writes nothing: an alert that holds this call's reason and comment is taken as this call's own, from an attempt whose answer was lost. An alert that another reason dismissed stays as it is, and the undo leaves it.
|
|
5
|
+
* shortcut: a person who dismissed with the same reason and the same comment is read as this call, so the undo opens that alert again; upgrade when GitHub's answer says which call dismissed it.
|
|
6
|
+
*/
|
|
7
|
+
dismiss_dependabot_alert: import("@kana-ai/edgar-sdk").Tool<{
|
|
8
|
+
repo: string;
|
|
9
|
+
number: number;
|
|
10
|
+
reason: "fix_started" | "inaccurate" | "no_bandwidth" | "not_used" | "tolerable_risk";
|
|
11
|
+
comment: string;
|
|
12
|
+
}, {
|
|
13
|
+
repo: string;
|
|
14
|
+
number: number;
|
|
15
|
+
url: string;
|
|
16
|
+
reason: string;
|
|
17
|
+
reopen: boolean;
|
|
18
|
+
}, "GITHUB_TOKEN">;
|
|
19
|
+
/** The undo of `dismiss_dependabot_alert`. It reads the alert first and opens it only while it is dismissed, so a second run, or an alert that was fixed since, writes nothing. */
|
|
20
|
+
reopen_dependabot_alert: import("@kana-ai/edgar-sdk").Tool<{
|
|
21
|
+
stage_output: {
|
|
22
|
+
repo: string;
|
|
23
|
+
number: number;
|
|
24
|
+
url: string;
|
|
25
|
+
reason: string;
|
|
26
|
+
reopen: boolean;
|
|
27
|
+
};
|
|
28
|
+
}, {
|
|
29
|
+
repo: string;
|
|
30
|
+
number: number;
|
|
31
|
+
url: string;
|
|
32
|
+
reopened: boolean;
|
|
33
|
+
}, "GITHUB_TOKEN">;
|
|
34
|
+
/** The lookup of a `dismiss_dependabot_alert` call that did not end. */
|
|
35
|
+
find_dependabot_dismissal: import("@kana-ai/edgar-sdk").Tool<{
|
|
36
|
+
operation_id: string;
|
|
37
|
+
input: unknown;
|
|
38
|
+
}, {
|
|
39
|
+
repo: string;
|
|
40
|
+
number: number;
|
|
41
|
+
url: string;
|
|
42
|
+
reason: string;
|
|
43
|
+
reopen: boolean;
|
|
44
|
+
}, "GITHUB_TOKEN">;
|
|
45
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { defineTool, done, ok, permanentFailure, skipped } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { apiAccess, github } from "#api/client";
|
|
3
|
+
import { alert } from "#schemas/github";
|
|
4
|
+
import { dismissDependabotAlert, findDependabotDismissal, reopenDependabotAlert, } from "#schemas/tools";
|
|
5
|
+
import { repoOf } from "#tools/pull-request";
|
|
6
|
+
async function standingOf(ctx, repo, number) {
|
|
7
|
+
const name = repoOf(repo);
|
|
8
|
+
if (!name.ok)
|
|
9
|
+
return name;
|
|
10
|
+
const path = `/repos/${name.value}/dependabot/alerts/${String(number)}`;
|
|
11
|
+
const read = await github(ctx, "GET", path, alert);
|
|
12
|
+
return read.ok ? ok({ repo: name.value, path, alert: read.value }) : read;
|
|
13
|
+
}
|
|
14
|
+
/** True when the alert is dismissed with the reason and the comment of `call`: how an attempt of that call leaves it. */
|
|
15
|
+
function holds(now, call) {
|
|
16
|
+
return (now.state === "dismissed" &&
|
|
17
|
+
now.dismissed_reason === call.reason &&
|
|
18
|
+
(now.dismissed_comment ?? "").trim() === call.comment.trim());
|
|
19
|
+
}
|
|
20
|
+
function dismissalOf(repo, now, reopen) {
|
|
21
|
+
return {
|
|
22
|
+
repo,
|
|
23
|
+
number: now.number,
|
|
24
|
+
url: now.html_url,
|
|
25
|
+
reason: now.dismissed_reason ?? "",
|
|
26
|
+
reopen,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** The tools that write a person's decision on a Dependabot alert, by the name the manifest gives them. */
|
|
30
|
+
export const alertTools = {
|
|
31
|
+
/**
|
|
32
|
+
* Reads the alert first, so a second run writes nothing: an alert that holds this call's reason and comment is taken as this call's own, from an attempt whose answer was lost. An alert that another reason dismissed stays as it is, and the undo leaves it.
|
|
33
|
+
* shortcut: a person who dismissed with the same reason and the same comment is read as this call, so the undo opens that alert again; upgrade when GitHub's answer says which call dismissed it.
|
|
34
|
+
*/
|
|
35
|
+
dismiss_dependabot_alert: defineTool({
|
|
36
|
+
description: "Dismiss a Dependabot alert of a repository with one of GitHub's reasons and a comment; every call needs a person's approval",
|
|
37
|
+
input: dismissDependabotAlert.input,
|
|
38
|
+
output: dismissDependabotAlert.output,
|
|
39
|
+
...apiAccess,
|
|
40
|
+
side_effect: true,
|
|
41
|
+
compensate: "reopen_dependabot_alert",
|
|
42
|
+
lookup: "find_dependabot_dismissal",
|
|
43
|
+
approval: "always",
|
|
44
|
+
execute: async (input, ctx) => {
|
|
45
|
+
const at = await standingOf(ctx, input.repo, input.number);
|
|
46
|
+
if (!at.ok)
|
|
47
|
+
return at.error;
|
|
48
|
+
const { repo, path, alert: now } = at.value;
|
|
49
|
+
if (now.state === "dismissed")
|
|
50
|
+
return done(dismissalOf(repo, now, holds(now, input)));
|
|
51
|
+
const set = await github(ctx, "PATCH", path, alert, {
|
|
52
|
+
state: "dismissed",
|
|
53
|
+
dismissed_reason: input.reason,
|
|
54
|
+
dismissed_comment: input.comment,
|
|
55
|
+
});
|
|
56
|
+
if (!set.ok)
|
|
57
|
+
return set.error;
|
|
58
|
+
return done({
|
|
59
|
+
...dismissalOf(repo, set.value, now.state === "open"),
|
|
60
|
+
reason: set.value.dismissed_reason ?? input.reason,
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
}),
|
|
64
|
+
/** The undo of `dismiss_dependabot_alert`. It reads the alert first and opens it only while it is dismissed, so a second run, or an alert that was fixed since, writes nothing. */
|
|
65
|
+
reopen_dependabot_alert: defineTool({
|
|
66
|
+
description: "Open a Dependabot alert again that dismiss_dependabot_alert dismissed; the engine calls it with the output of that call",
|
|
67
|
+
input: reopenDependabotAlert.input,
|
|
68
|
+
output: reopenDependabotAlert.output,
|
|
69
|
+
...apiAccess,
|
|
70
|
+
execute: async ({ stage_output: was }, ctx) => {
|
|
71
|
+
const same = { repo: was.repo, number: was.number, url: was.url };
|
|
72
|
+
if (!was.reopen)
|
|
73
|
+
return done({ ...same, reopened: false });
|
|
74
|
+
const at = await standingOf(ctx, was.repo, was.number);
|
|
75
|
+
if (!at.ok)
|
|
76
|
+
return at.error;
|
|
77
|
+
if (at.value.alert.state !== "dismissed")
|
|
78
|
+
return done({ ...same, reopened: false });
|
|
79
|
+
const set = await github(ctx, "PATCH", at.value.path, alert, { state: "open" });
|
|
80
|
+
return set.ok ? done({ ...same, reopened: true }) : set.error;
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
/** The lookup of a `dismiss_dependabot_alert` call that did not end. */
|
|
84
|
+
find_dependabot_dismissal: defineTool({
|
|
85
|
+
description: "Done when a Dependabot alert holds the reason and the comment of a dismiss_dependabot_alert call; skipped otherwise",
|
|
86
|
+
input: findDependabotDismissal.input,
|
|
87
|
+
output: findDependabotDismissal.output,
|
|
88
|
+
...apiAccess,
|
|
89
|
+
execute: async ({ input }, ctx) => {
|
|
90
|
+
const call = dismissDependabotAlert.input.safeParse(input);
|
|
91
|
+
if (!call.success)
|
|
92
|
+
return permanentFailure("invalid_input", "input is not the input of a dismiss_dependabot_alert call");
|
|
93
|
+
const at = await standingOf(ctx, call.data.repo, call.data.number);
|
|
94
|
+
if (!at.ok)
|
|
95
|
+
return at.error;
|
|
96
|
+
const { repo, alert: now } = at.value;
|
|
97
|
+
return holds(now, call.data) ? done(dismissalOf(repo, now, true)) : skipped();
|
|
98
|
+
},
|
|
99
|
+
}),
|
|
100
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Pushes through the sandbox's git, never forced. With `to`, the head of the sandbox goes to that `edgar/` branch of origin, the branch of an open pull request: what the checks ran on is what is pushed, whatever a role named its own branch. With `branch` alone, that `edgar/` branch goes to origin under its own name. */
|
|
2
|
+
export declare const pushBranch: import("@kana-ai/edgar-sdk").Tool<{
|
|
3
|
+
repo: string;
|
|
4
|
+
branch?: string | undefined;
|
|
5
|
+
to?: string | undefined;
|
|
6
|
+
}, {
|
|
7
|
+
branch: string;
|
|
8
|
+
commit: string;
|
|
9
|
+
}, never>;
|