@sentry/junior-github 0.297.0 → 0.299.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OK6BNAGC.js → chunk-O74CQGTZ.js} +50 -20
- package/dist/credential-support.d.ts +7 -0
- package/dist/db/schema.d.ts +34 -0
- package/dist/events/pull-request.d.ts +8 -2
- package/dist/graphql-documents.d.ts +31 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1917 -999
- package/dist/object-facts.d.ts +16 -1
- package/dist/plugin.d.ts +3 -0
- package/dist/pull-request-outcomes/apply.d.ts +3 -1
- package/dist/pull-request-outcomes/reconcile.d.ts +10 -5
- package/dist/pull-request-outcomes/store.d.ts +5 -0
- package/dist/pull-request-requesters/draft-reviewers.d.ts +15 -0
- package/dist/testing.js +1 -1
- package/dist/tool-support/attribution.d.ts +4 -2
- package/dist/tool-support/pull-request-description.d.ts +8 -0
- package/dist/tools/clone-repository.d.ts +34 -2
- package/dist/tools/comment-on-issue.d.ts +34 -2
- package/dist/tools/comment-on-pull-request.d.ts +34 -2
- package/dist/tools/create-issue.d.ts +34 -2
- package/dist/tools/create-pull-request.d.ts +39 -4
- package/dist/tools/get-deployment.d.ts +34 -2
- package/dist/tools/get-issue.d.ts +34 -2
- package/dist/tools/get-pull-request.d.ts +54 -2
- package/dist/tools/get-release.d.ts +34 -2
- package/dist/tools/get-repository.d.ts +34 -2
- package/dist/tools/get-status.d.ts +34 -2
- package/dist/tools/react-to-issue.d.ts +169 -0
- package/dist/tools/resolve-pull-request-review-thread.d.ts +34 -2
- package/dist/tools/submit-pull-request-review.d.ts +34 -2
- package/dist/tools/update-issue-comment.d.ts +170 -0
- package/dist/tools/update-issue.d.ts +34 -2
- package/dist/tools/update-pull-request-feedback.d.ts +34 -4
- package/dist/tools/update-pull-request.d.ts +38 -4
- package/dist/tools.d.ts +10 -1
- package/dist/webhooks/check-suite.d.ts +2 -4
- package/dist/webhooks/fail-open-log.d.ts +10 -0
- package/dist/webhooks/handler.d.ts +1 -1
- package/dist/webhooks/installation-requests.d.ts +12 -1
- package/dist/webhooks/merge-conflict.d.ts +1 -1
- package/dist/webhooks/pull-request-preview.d.ts +12 -0
- package/dist/webhooks/pull-request-ready-reviewers.d.ts +25 -0
- package/dist/webhooks/pull-request-ready.d.ts +1 -1
- package/migrations/0011_pull_request_draft.sql +1 -0
- package/migrations/meta/0011_snapshot.json +434 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +5 -2
- package/skills/github-code/SKILL.md +1 -1
- package/skills/github-code/SPEC.md +1 -1
- package/skills/github-issues/SKILL.md +1 -1
- package/skills/github-issues/references/api-surface.md +3 -1
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
GITHUB_REPOSITORY_EVENTS,
|
|
26
26
|
GITHUB_REPOSITORY_IDENTIFIER,
|
|
27
27
|
GITHUB_REPOSITORY_SUGGESTED_EVENTS,
|
|
28
|
+
GitHubRequestError,
|
|
28
29
|
HTTP_READ_METHODS,
|
|
29
30
|
USER_WRITE_REQUIREMENTS,
|
|
30
31
|
botLoginFromEmail,
|
|
@@ -51,6 +52,7 @@ import {
|
|
|
51
52
|
issueInstallationToken,
|
|
52
53
|
listVerifiedUserEmails,
|
|
53
54
|
loadCheckSuiteFacts,
|
|
55
|
+
logFailOpenFailure,
|
|
54
56
|
needsCheckSuitePullRequestFacts,
|
|
55
57
|
normalizeGitHubEvents,
|
|
56
58
|
normalizePermissions,
|
|
@@ -61,7 +63,7 @@ import {
|
|
|
61
63
|
readGrantPermissions,
|
|
62
64
|
requireEnv,
|
|
63
65
|
resolveUserAccount
|
|
64
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-O74CQGTZ.js";
|
|
65
67
|
|
|
66
68
|
// src/tool-support/attribution.ts
|
|
67
69
|
import * as z from "zod";
|
|
@@ -157,10 +159,15 @@ var GITHUB_REQUEST_ATTRIBUTION_START = "<!-- junior-request-attribution:start --
|
|
|
157
159
|
var GITHUB_REQUEST_ATTRIBUTION_END = "<!-- junior-request-attribution:end -->";
|
|
158
160
|
var SLACK_USER_ID_DISPLAY_PATTERN = /^[UW][A-Z0-9]{5,}$/;
|
|
159
161
|
var GITHUB_LOGIN_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/;
|
|
160
|
-
function
|
|
161
|
-
const login2 =
|
|
162
|
+
function parseGitHubLogin(value) {
|
|
163
|
+
const login2 = value?.trim().replace(/^@/, "");
|
|
162
164
|
return login2 && GITHUB_LOGIN_PATTERN.test(login2) ? login2 : void 0;
|
|
163
165
|
}
|
|
166
|
+
function linkedGitHubLogin(user) {
|
|
167
|
+
return parseGitHubLogin(
|
|
168
|
+
user?.identities.find((identity) => identity.provider === "github")?.handle
|
|
169
|
+
);
|
|
170
|
+
}
|
|
164
171
|
function cleanDisplayValue(value, userId) {
|
|
165
172
|
const cleaned = value?.replace(/[\r\n<>]/g, " ").trim();
|
|
166
173
|
if (!cleaned) {
|
|
@@ -282,13 +289,81 @@ import {
|
|
|
282
289
|
mergeEventMatchFields
|
|
283
290
|
} from "@sentry/junior-plugin-api";
|
|
284
291
|
|
|
285
|
-
// src/tools/
|
|
292
|
+
// src/tools/react-to-issue.ts
|
|
286
293
|
import {
|
|
287
294
|
definePluginTool,
|
|
288
295
|
PluginToolInputError as PluginToolInputError2,
|
|
289
296
|
pluginToolOutputSchema
|
|
290
297
|
} from "@sentry/junior-plugin-api";
|
|
291
298
|
import * as z2 from "zod";
|
|
299
|
+
var REACTION_CONTENTS = [
|
|
300
|
+
"+1",
|
|
301
|
+
"-1",
|
|
302
|
+
"laugh",
|
|
303
|
+
"confused",
|
|
304
|
+
"heart",
|
|
305
|
+
"hooray",
|
|
306
|
+
"rocket",
|
|
307
|
+
"eyes"
|
|
308
|
+
];
|
|
309
|
+
var inputSchema = z2.object({
|
|
310
|
+
repo: z2.string().describe('Repository in "owner/name" format.'),
|
|
311
|
+
number: z2.number().int().positive().describe("Issue or pull request number."),
|
|
312
|
+
content: z2.enum(REACTION_CONTENTS).describe("Reaction to add.")
|
|
313
|
+
}).strict();
|
|
314
|
+
var outputSchema = pluginToolOutputSchema.extend({
|
|
315
|
+
target: z2.literal("reactToIssue"),
|
|
316
|
+
repo: z2.string(),
|
|
317
|
+
number: z2.number(),
|
|
318
|
+
content: z2.enum(REACTION_CONTENTS),
|
|
319
|
+
reaction_id: z2.number()
|
|
320
|
+
});
|
|
321
|
+
function createGitHubReactToIssueTool(egress) {
|
|
322
|
+
return definePluginTool({
|
|
323
|
+
annotations: {
|
|
324
|
+
destructiveHint: false,
|
|
325
|
+
// GitHub returns the existing reaction when the bot already added it.
|
|
326
|
+
idempotentHint: true,
|
|
327
|
+
openWorldHint: true,
|
|
328
|
+
readOnlyHint: false
|
|
329
|
+
},
|
|
330
|
+
description: "React with an emoji to a GitHub issue or pull request itself, for example to show that you started work on it. Reacting again with the same content changes nothing.",
|
|
331
|
+
inputSchema,
|
|
332
|
+
outputSchema,
|
|
333
|
+
async execute(input) {
|
|
334
|
+
const repo = parseRepo(input.repo);
|
|
335
|
+
const response = await githubApi(egress, {
|
|
336
|
+
operation: "github.issue.reaction.create",
|
|
337
|
+
method: "POST",
|
|
338
|
+
path: `${repoPath(repo)}/issues/${input.number}/reactions`,
|
|
339
|
+
body: { content: input.content }
|
|
340
|
+
});
|
|
341
|
+
if (!response.ok) {
|
|
342
|
+
const message = `GitHub issue reaction failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
343
|
+
if (response.status === 404 || response.status === 422) {
|
|
344
|
+
throw new PluginToolInputError2(message);
|
|
345
|
+
}
|
|
346
|
+
throw new Error(message);
|
|
347
|
+
}
|
|
348
|
+
const reaction = z2.object({ id: z2.number() }).parse(response.body);
|
|
349
|
+
return {
|
|
350
|
+
target: "reactToIssue",
|
|
351
|
+
repo: repo.ref,
|
|
352
|
+
number: input.number,
|
|
353
|
+
content: input.content,
|
|
354
|
+
reaction_id: reaction.id
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// src/tools/clone-repository.ts
|
|
361
|
+
import {
|
|
362
|
+
definePluginTool as definePluginTool2,
|
|
363
|
+
PluginToolInputError as PluginToolInputError3,
|
|
364
|
+
pluginToolOutputSchema as pluginToolOutputSchema2
|
|
365
|
+
} from "@sentry/junior-plugin-api";
|
|
366
|
+
import * as z3 from "zod";
|
|
292
367
|
|
|
293
368
|
// src/sandbox-paths.ts
|
|
294
369
|
var RESERVED_SANDBOX_DIRECTORIES = /* @__PURE__ */ new Set([
|
|
@@ -301,9 +376,9 @@ function isReservedSandboxDirectory(path) {
|
|
|
301
376
|
}
|
|
302
377
|
|
|
303
378
|
// src/tools/clone-repository.ts
|
|
304
|
-
var
|
|
305
|
-
repo:
|
|
306
|
-
directory:
|
|
379
|
+
var inputSchema2 = z3.object({
|
|
380
|
+
repo: z3.string().describe('Repository in "owner/name" format.'),
|
|
381
|
+
directory: z3.string().regex(/^(?:[A-Za-z0-9._-]+(?:\/[A-Za-z0-9._-]+)*)$/).refine(
|
|
307
382
|
(value) => !value.split("/").some((part) => part === "." || part === ".."),
|
|
308
383
|
{
|
|
309
384
|
message: "Directory must be a relative path without . or .. segments."
|
|
@@ -311,24 +386,24 @@ var inputSchema = z2.object({
|
|
|
311
386
|
).describe(
|
|
312
387
|
"Optional destination directory under the sandbox root. Defaults to repos/{name}."
|
|
313
388
|
).optional(),
|
|
314
|
-
allow_ad_hoc:
|
|
389
|
+
allow_ad_hoc: z3.boolean().optional().describe(
|
|
315
390
|
"Set true in the default Sandbox to keep an intentional ad-hoc checkout when matching Workspaces exist. Prefer switchWorkspace; the checkout is already present after a successful switch."
|
|
316
391
|
)
|
|
317
392
|
}).strict();
|
|
318
|
-
var cloneSchema =
|
|
319
|
-
path:
|
|
320
|
-
repo:
|
|
321
|
-
note:
|
|
393
|
+
var cloneSchema = z3.object({
|
|
394
|
+
path: z3.string(),
|
|
395
|
+
repo: z3.string(),
|
|
396
|
+
note: z3.string().optional()
|
|
322
397
|
});
|
|
323
|
-
var
|
|
398
|
+
var outputSchema2 = pluginToolOutputSchema2.merge(
|
|
324
399
|
cloneSchema.extend({
|
|
325
|
-
target:
|
|
400
|
+
target: z3.literal("cloneRepository")
|
|
326
401
|
})
|
|
327
402
|
);
|
|
328
403
|
function parseRepo2(value) {
|
|
329
404
|
const parts = value.split("/").map((part) => part.trim());
|
|
330
405
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
331
|
-
throw new
|
|
406
|
+
throw new PluginToolInputError3('repo must use "owner/name" format');
|
|
332
407
|
}
|
|
333
408
|
return { owner: parts[0], name: parts[1] };
|
|
334
409
|
}
|
|
@@ -338,11 +413,11 @@ function quotedNames(workspaces) {
|
|
|
338
413
|
function workspaceRequiredError(repoId, workspaces) {
|
|
339
414
|
const names = quotedNames(workspaces);
|
|
340
415
|
if (workspaces.length === 1) {
|
|
341
|
-
return new
|
|
416
|
+
return new PluginToolInputError3(
|
|
342
417
|
`Repository ${repoId} is part of Workspace ${names}. Call switchWorkspace with that name; the checkout is already present after the switch. Pass allow_ad_hoc=true only for an intentional ad-hoc checkout.`
|
|
343
418
|
);
|
|
344
419
|
}
|
|
345
|
-
return new
|
|
420
|
+
return new PluginToolInputError3(
|
|
346
421
|
`Repository ${repoId} is part of Workspaces ${names}. Call switchWorkspace with one of those names; the checkout is already present after the switch. Pass allow_ad_hoc=true only for an intentional ad-hoc checkout.`
|
|
347
422
|
);
|
|
348
423
|
}
|
|
@@ -380,7 +455,7 @@ async function removePartialClone(ctx, path) {
|
|
|
380
455
|
}
|
|
381
456
|
}
|
|
382
457
|
function createGitHubCloneRepositoryTool(ctx) {
|
|
383
|
-
return
|
|
458
|
+
return definePluginTool2({
|
|
384
459
|
annotations: {
|
|
385
460
|
// Remote GitHub effect is contents-read only. Sandbox checkout creation is
|
|
386
461
|
// the same class of ephemeral local materialization as webFetch artifacts,
|
|
@@ -397,8 +472,8 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
397
472
|
return directory ? `Shallow-clone ${input.repo} into the local sandbox at ${directory}${adHoc} for inspection (no GitHub mutation).` : `Shallow-clone ${input.repo} into the local sandbox${adHoc} for inspection (no GitHub mutation).`;
|
|
398
473
|
},
|
|
399
474
|
executionMode: "sequential",
|
|
400
|
-
inputSchema,
|
|
401
|
-
outputSchema,
|
|
475
|
+
inputSchema: inputSchema2,
|
|
476
|
+
outputSchema: outputSchema2,
|
|
402
477
|
async execute(input, options) {
|
|
403
478
|
const repo = parseRepo2(input.repo);
|
|
404
479
|
const repoId = `${repo.owner}/${repo.name}`;
|
|
@@ -428,7 +503,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
428
503
|
const directory = input.directory ?? defaultDirectory(repo.name);
|
|
429
504
|
const rootSegment = directory.split("/")[0] ?? directory;
|
|
430
505
|
if (isReservedSandboxDirectory(rootSegment)) {
|
|
431
|
-
throw new
|
|
506
|
+
throw new PluginToolInputError3(
|
|
432
507
|
`Directory conflicts with a reserved sandbox path: ${directory}`
|
|
433
508
|
);
|
|
434
509
|
}
|
|
@@ -442,7 +517,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
442
517
|
signal: commandSignal(options.signal, 3e4)
|
|
443
518
|
});
|
|
444
519
|
if (mkdir.exitCode !== 0) {
|
|
445
|
-
throw new
|
|
520
|
+
throw new PluginToolInputError3(
|
|
446
521
|
`Failed to create clone parent directory: ${parentDirectory}`
|
|
447
522
|
);
|
|
448
523
|
}
|
|
@@ -454,7 +529,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
454
529
|
signal: commandSignal(options.signal, 3e4)
|
|
455
530
|
});
|
|
456
531
|
if (exists.exitCode === 0) {
|
|
457
|
-
throw new
|
|
532
|
+
throw new PluginToolInputError3(`destination already exists: ${path}`);
|
|
458
533
|
}
|
|
459
534
|
let clone;
|
|
460
535
|
try {
|
|
@@ -477,7 +552,7 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
477
552
|
}
|
|
478
553
|
if (clone.exitCode !== 0) {
|
|
479
554
|
await removePartialClone(ctx, path);
|
|
480
|
-
throw new
|
|
555
|
+
throw new PluginToolInputError3(
|
|
481
556
|
`GitHub repository clone failed: ${clone.stderr.trim() || `exit ${clone.exitCode}`}`
|
|
482
557
|
);
|
|
483
558
|
}
|
|
@@ -493,25 +568,25 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
493
568
|
|
|
494
569
|
// src/tools/comment-on-issue.ts
|
|
495
570
|
import {
|
|
496
|
-
definePluginTool as
|
|
497
|
-
PluginToolInputError as
|
|
498
|
-
pluginToolOutputSchema as
|
|
571
|
+
definePluginTool as definePluginTool3,
|
|
572
|
+
PluginToolInputError as PluginToolInputError4,
|
|
573
|
+
pluginToolOutputSchema as pluginToolOutputSchema3
|
|
499
574
|
} from "@sentry/junior-plugin-api";
|
|
500
|
-
import * as
|
|
501
|
-
var
|
|
502
|
-
repo:
|
|
503
|
-
number:
|
|
504
|
-
body:
|
|
575
|
+
import * as z4 from "zod";
|
|
576
|
+
var inputSchema3 = z4.object({
|
|
577
|
+
repo: z4.string().describe('Repository in "owner/name" format.'),
|
|
578
|
+
number: z4.number().int().positive().describe("Issue number."),
|
|
579
|
+
body: z4.string().trim().min(1).describe("Comment text.")
|
|
505
580
|
}).strict();
|
|
506
|
-
var
|
|
507
|
-
target:
|
|
508
|
-
repo:
|
|
509
|
-
number:
|
|
510
|
-
comment_id:
|
|
511
|
-
url:
|
|
581
|
+
var outputSchema3 = pluginToolOutputSchema3.extend({
|
|
582
|
+
target: z4.literal("commentOnIssue"),
|
|
583
|
+
repo: z4.string(),
|
|
584
|
+
number: z4.number(),
|
|
585
|
+
comment_id: z4.number(),
|
|
586
|
+
url: z4.string()
|
|
512
587
|
});
|
|
513
588
|
function createGitHubCommentOnIssueTool(egress) {
|
|
514
|
-
return
|
|
589
|
+
return definePluginTool3({
|
|
515
590
|
annotations: {
|
|
516
591
|
destructiveHint: false,
|
|
517
592
|
idempotentHint: false,
|
|
@@ -519,8 +594,8 @@ function createGitHubCommentOnIssueTool(egress) {
|
|
|
519
594
|
readOnlyHint: false
|
|
520
595
|
},
|
|
521
596
|
description: "Post a comment on a GitHub issue. Returns the comment id and URL.",
|
|
522
|
-
inputSchema:
|
|
523
|
-
outputSchema:
|
|
597
|
+
inputSchema: inputSchema3,
|
|
598
|
+
outputSchema: outputSchema3,
|
|
524
599
|
async execute(input) {
|
|
525
600
|
const repo = parseRepo(input.repo);
|
|
526
601
|
const response = await githubApi(egress, {
|
|
@@ -532,11 +607,11 @@ function createGitHubCommentOnIssueTool(egress) {
|
|
|
532
607
|
if (!response.ok) {
|
|
533
608
|
const message = `GitHub issue comment failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
534
609
|
if (response.status === 404 || response.status === 422) {
|
|
535
|
-
throw new
|
|
610
|
+
throw new PluginToolInputError4(message);
|
|
536
611
|
}
|
|
537
612
|
throw new Error(message);
|
|
538
613
|
}
|
|
539
|
-
const comment =
|
|
614
|
+
const comment = z4.object({ id: z4.number(), html_url: z4.string() }).parse(response.body);
|
|
540
615
|
return {
|
|
541
616
|
target: "commentOnIssue",
|
|
542
617
|
repo: repo.ref,
|
|
@@ -550,25 +625,25 @@ function createGitHubCommentOnIssueTool(egress) {
|
|
|
550
625
|
|
|
551
626
|
// src/tools/comment-on-pull-request.ts
|
|
552
627
|
import {
|
|
553
|
-
definePluginTool as
|
|
554
|
-
PluginToolInputError as
|
|
555
|
-
pluginToolOutputSchema as
|
|
628
|
+
definePluginTool as definePluginTool4,
|
|
629
|
+
PluginToolInputError as PluginToolInputError5,
|
|
630
|
+
pluginToolOutputSchema as pluginToolOutputSchema4
|
|
556
631
|
} from "@sentry/junior-plugin-api";
|
|
557
|
-
import * as
|
|
558
|
-
var
|
|
559
|
-
repo:
|
|
560
|
-
number:
|
|
561
|
-
body:
|
|
562
|
-
in_reply_to:
|
|
632
|
+
import * as z5 from "zod";
|
|
633
|
+
var inputSchema4 = z5.object({
|
|
634
|
+
repo: z5.string().describe('Repository in "owner/name" format.'),
|
|
635
|
+
number: z5.number().int().positive().describe("Pull request number."),
|
|
636
|
+
body: z5.string().trim().min(1).describe("Comment text."),
|
|
637
|
+
in_reply_to: z5.number().int().positive().optional().describe(
|
|
563
638
|
"Inline review comment id. Set it to reply in that comment's thread. Omit it to comment on the pull request."
|
|
564
639
|
)
|
|
565
640
|
}).strict();
|
|
566
|
-
var
|
|
567
|
-
target:
|
|
568
|
-
repo:
|
|
569
|
-
number:
|
|
570
|
-
comment_id:
|
|
571
|
-
url:
|
|
641
|
+
var outputSchema4 = pluginToolOutputSchema4.extend({
|
|
642
|
+
target: z5.literal("commentOnPullRequest"),
|
|
643
|
+
repo: z5.string(),
|
|
644
|
+
number: z5.number(),
|
|
645
|
+
comment_id: z5.number(),
|
|
646
|
+
url: z5.string()
|
|
572
647
|
});
|
|
573
648
|
async function threadRootId(egress, prefix, commentId) {
|
|
574
649
|
const response = await githubApi(egress, {
|
|
@@ -577,14 +652,14 @@ async function threadRootId(egress, prefix, commentId) {
|
|
|
577
652
|
});
|
|
578
653
|
if (!response.ok) {
|
|
579
654
|
const message = `GitHub review comment lookup failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
580
|
-
if (response.status === 404) throw new
|
|
655
|
+
if (response.status === 404) throw new PluginToolInputError5(message);
|
|
581
656
|
throw new Error(message);
|
|
582
657
|
}
|
|
583
|
-
const comment =
|
|
658
|
+
const comment = z5.object({ in_reply_to_id: z5.number().nullish() }).parse(response.body);
|
|
584
659
|
return comment.in_reply_to_id ?? commentId;
|
|
585
660
|
}
|
|
586
661
|
function createGitHubCommentOnPullRequestTool(egress) {
|
|
587
|
-
return
|
|
662
|
+
return definePluginTool4({
|
|
588
663
|
annotations: {
|
|
589
664
|
destructiveHint: false,
|
|
590
665
|
idempotentHint: false,
|
|
@@ -592,8 +667,8 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
592
667
|
readOnlyHint: false
|
|
593
668
|
},
|
|
594
669
|
description: "Post a conversation comment on a GitHub pull request, or reply in an inline review thread with in_reply_to. For issues, use github_commentOnIssue. Use it to answer a question asked in a pull request review or comment. Returns the comment id and URL.",
|
|
595
|
-
inputSchema:
|
|
596
|
-
outputSchema:
|
|
670
|
+
inputSchema: inputSchema4,
|
|
671
|
+
outputSchema: outputSchema4,
|
|
597
672
|
async execute(input) {
|
|
598
673
|
const repo = parseRepo(input.repo);
|
|
599
674
|
const prefix = repoPath(repo);
|
|
@@ -607,11 +682,11 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
607
682
|
if (!response.ok) {
|
|
608
683
|
const message = `GitHub pull request comment failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
609
684
|
if (response.status === 404 || response.status === 422) {
|
|
610
|
-
throw new
|
|
685
|
+
throw new PluginToolInputError5(message);
|
|
611
686
|
}
|
|
612
687
|
throw new Error(message);
|
|
613
688
|
}
|
|
614
|
-
const comment =
|
|
689
|
+
const comment = z5.object({ id: z5.number(), html_url: z5.string() }).parse(response.body);
|
|
615
690
|
return {
|
|
616
691
|
target: "commentOnPullRequest",
|
|
617
692
|
repo: repo.ref,
|
|
@@ -625,27 +700,33 @@ function createGitHubCommentOnPullRequestTool(egress) {
|
|
|
625
700
|
}
|
|
626
701
|
|
|
627
702
|
// src/object-facts.ts
|
|
628
|
-
import
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
703
|
+
import {
|
|
704
|
+
OBJECT_FACTS_MAX_BYTES,
|
|
705
|
+
objectFactsBytes
|
|
706
|
+
} from "@sentry/junior-plugin-api";
|
|
707
|
+
import { lexer, walkTokens } from "marked";
|
|
708
|
+
import { parseFragment } from "parse5";
|
|
709
|
+
import * as z6 from "zod";
|
|
710
|
+
var person = z6.object({ login: z6.string() });
|
|
711
|
+
var responseSchema = z6.object({
|
|
712
|
+
body: z6.string().nullable().optional(),
|
|
632
713
|
user: person.nullable().optional(),
|
|
633
|
-
requested_reviewers:
|
|
634
|
-
assignees:
|
|
635
|
-
labels:
|
|
636
|
-
head:
|
|
637
|
-
base:
|
|
638
|
-
mergeable:
|
|
639
|
-
changed_files:
|
|
640
|
-
additions:
|
|
641
|
-
deletions:
|
|
642
|
-
updated_at:
|
|
714
|
+
requested_reviewers: z6.array(person).optional(),
|
|
715
|
+
assignees: z6.array(person).optional(),
|
|
716
|
+
labels: z6.array(z6.union([z6.string(), z6.object({ name: z6.string() })])).optional(),
|
|
717
|
+
head: z6.object({ ref: z6.string() }).optional(),
|
|
718
|
+
base: z6.object({ ref: z6.string() }).optional(),
|
|
719
|
+
mergeable: z6.boolean().nullable().optional(),
|
|
720
|
+
changed_files: z6.number().int().nonnegative().optional(),
|
|
721
|
+
additions: z6.number().int().nonnegative().optional(),
|
|
722
|
+
deletions: z6.number().int().nonnegative().optional(),
|
|
723
|
+
updated_at: z6.iso.datetime({ offset: true }).optional()
|
|
643
724
|
});
|
|
644
725
|
var short = (value) => {
|
|
645
726
|
const text2 = value?.trim();
|
|
646
727
|
return text2 ? text2.length > 64 ? `${text2.slice(0, 63)}\u2026` : text2 : void 0;
|
|
647
728
|
};
|
|
648
|
-
function
|
|
729
|
+
function visibleBody(body) {
|
|
649
730
|
let text2 = (body ?? "").replace(
|
|
650
731
|
/<!-- junior-(session-footer|request-attribution):start -->[\s\S]*?<!-- junior-\1:end -->/g,
|
|
651
732
|
""
|
|
@@ -653,26 +734,80 @@ function description(body) {
|
|
|
653
734
|
while (text2.includes("<!--")) {
|
|
654
735
|
text2 = text2.replace(/<!--[\s\S]*?(?:-->|$)/g, "");
|
|
655
736
|
}
|
|
656
|
-
|
|
737
|
+
return text2.trim();
|
|
738
|
+
}
|
|
739
|
+
function description(body) {
|
|
740
|
+
const text2 = visibleBody(body);
|
|
657
741
|
if (!text2) return void 0;
|
|
658
742
|
return text2.length > 4e3 ? `${text2.slice(0, 3999)}\u2026` : text2;
|
|
659
743
|
}
|
|
744
|
+
function htmlImageSources(html) {
|
|
745
|
+
const sources = [];
|
|
746
|
+
const visit2 = (node) => {
|
|
747
|
+
if ("tagName" in node && node.tagName === "img") {
|
|
748
|
+
const src = node.attrs.find((attr) => attr.name === "src")?.value;
|
|
749
|
+
if (src) sources.push(src);
|
|
750
|
+
}
|
|
751
|
+
if ("childNodes" in node) node.childNodes.forEach(visit2);
|
|
752
|
+
if ("content" in node) visit2(node.content);
|
|
753
|
+
};
|
|
754
|
+
visit2(parseFragment(html));
|
|
755
|
+
return sources;
|
|
756
|
+
}
|
|
757
|
+
function publicArtifactUrl(value) {
|
|
758
|
+
const baseUrl = process.env.JUNIOR_BASE_URL?.trim().replace(/\/+$/, "");
|
|
759
|
+
if (!baseUrl) return void 0;
|
|
760
|
+
let url;
|
|
761
|
+
let prefix;
|
|
762
|
+
try {
|
|
763
|
+
url = new URL(value);
|
|
764
|
+
prefix = new URL(`${baseUrl}/public/artifacts/`);
|
|
765
|
+
} catch {
|
|
766
|
+
return void 0;
|
|
767
|
+
}
|
|
768
|
+
return (url.protocol === "https:" || url.protocol === "http:") && url.origin === prefix.origin && url.pathname.length > prefix.pathname.length && url.pathname.startsWith(prefix.pathname) && !url.username && !url.password && url.href.length <= 512 ? url.href : void 0;
|
|
769
|
+
}
|
|
770
|
+
function githubPreviewImageUrls(body) {
|
|
771
|
+
const sources = [];
|
|
772
|
+
walkTokens(lexer(visibleBody(body), { gfm: true }), (token) => {
|
|
773
|
+
if (token.type === "image") sources.push(token.href);
|
|
774
|
+
if (token.type === "html") sources.push(...htmlImageSources(token.raw));
|
|
775
|
+
});
|
|
776
|
+
return [
|
|
777
|
+
...new Set(
|
|
778
|
+
sources.map(publicArtifactUrl).filter((url) => url !== void 0)
|
|
779
|
+
)
|
|
780
|
+
];
|
|
781
|
+
}
|
|
782
|
+
function withGitHubPreviewImages(facts, urls) {
|
|
783
|
+
let bytes = objectFactsBytes(facts) + ',"previewImageUrls":[]'.length;
|
|
784
|
+
const previewImageUrls = [];
|
|
785
|
+
for (const url of urls) {
|
|
786
|
+
bytes += JSON.stringify(url).length + (previewImageUrls.length ? 1 : 0);
|
|
787
|
+
if (bytes > OBJECT_FACTS_MAX_BYTES) break;
|
|
788
|
+
previewImageUrls.push(url);
|
|
789
|
+
}
|
|
790
|
+
return previewImageUrls.length > 0 ? { ...facts, previewImageUrls } : facts;
|
|
791
|
+
}
|
|
660
792
|
function githubObjectFacts(type, response) {
|
|
661
793
|
const data = responseSchema.parse(response);
|
|
662
794
|
const result = {
|
|
663
795
|
sourceUpdatedAt: data.updated_at,
|
|
664
796
|
description: description(data.body),
|
|
665
|
-
facts: type === "code_change" ?
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
797
|
+
facts: type === "code_change" ? withGitHubPreviewImages(
|
|
798
|
+
{
|
|
799
|
+
type,
|
|
800
|
+
author: short(data.user?.login),
|
|
801
|
+
reviewers: data.requested_reviewers?.slice(0, 5).map((user) => short(user.login)).filter(Boolean),
|
|
802
|
+
sourceBranch: short(data.head?.ref),
|
|
803
|
+
targetBranch: short(data.base?.ref),
|
|
804
|
+
mergeable: data.mergeable ?? void 0,
|
|
805
|
+
changedFiles: data.changed_files,
|
|
806
|
+
additions: data.additions,
|
|
807
|
+
deletions: data.deletions
|
|
808
|
+
},
|
|
809
|
+
githubPreviewImageUrls(data.body)
|
|
810
|
+
) : {
|
|
676
811
|
type,
|
|
677
812
|
assignees: data.assignees?.slice(0, 5).map((user) => short(user.login)).filter(Boolean),
|
|
678
813
|
labels: data.labels?.slice(0, 5).map(
|
|
@@ -787,24 +922,24 @@ async function updateGitHubAnnotations(args) {
|
|
|
787
922
|
// src/tools/create-issue.ts
|
|
788
923
|
import {
|
|
789
924
|
objectFactsSchema,
|
|
790
|
-
definePluginTool as
|
|
925
|
+
definePluginTool as definePluginTool5,
|
|
791
926
|
EgressAuthRequired,
|
|
792
|
-
PluginToolInputError as
|
|
927
|
+
PluginToolInputError as PluginToolInputError7,
|
|
793
928
|
subscribableResourceSchema,
|
|
794
|
-
pluginToolOutputSchema as
|
|
929
|
+
pluginToolOutputSchema as pluginToolOutputSchema5
|
|
795
930
|
} from "@sentry/junior-plugin-api";
|
|
796
931
|
import { Type } from "@sinclair/typebox";
|
|
797
932
|
import { Value } from "@sinclair/typebox/value";
|
|
798
|
-
import * as
|
|
933
|
+
import * as z7 from "zod";
|
|
799
934
|
|
|
800
935
|
// src/tools/footer.ts
|
|
801
|
-
import { PluginToolInputError as
|
|
936
|
+
import { PluginToolInputError as PluginToolInputError6 } from "@sentry/junior-plugin-api";
|
|
802
937
|
var GITHUB_SESSION_FOOTER_START = "<!-- junior-session-footer:start -->";
|
|
803
938
|
var GITHUB_SESSION_FOOTER_END = "<!-- junior-session-footer:end -->";
|
|
804
939
|
var GITHUB_CONVERSATION_ID_MARKER = "junior-conversation-id:";
|
|
805
940
|
function nonEmptyString(value, name) {
|
|
806
941
|
if (!value?.trim()) {
|
|
807
|
-
throw new
|
|
942
|
+
throw new PluginToolInputError6(`${name} is required`);
|
|
808
943
|
}
|
|
809
944
|
return value.trim();
|
|
810
945
|
}
|
|
@@ -881,11 +1016,11 @@ function githubLinkedIssues(body, repositoryFullName) {
|
|
|
881
1016
|
if (!body) return [];
|
|
882
1017
|
const references = /* @__PURE__ */ new Map();
|
|
883
1018
|
const add = (linkedRepository, rawNumber) => {
|
|
884
|
-
const
|
|
885
|
-
if (!Number.isInteger(
|
|
1019
|
+
const number33 = Number.parseInt(rawNumber, 10);
|
|
1020
|
+
if (!Number.isInteger(number33) || number33 <= 0) return;
|
|
886
1021
|
const normalizedRepository = linkedRepository.toLowerCase();
|
|
887
|
-
references.set(`${normalizedRepository}#${
|
|
888
|
-
number:
|
|
1022
|
+
references.set(`${normalizedRepository}#${number33}`, {
|
|
1023
|
+
number: number33,
|
|
889
1024
|
repositoryFullName: linkedRepository
|
|
890
1025
|
});
|
|
891
1026
|
};
|
|
@@ -948,11 +1083,11 @@ var createIssueInputSchema = Type.Object(
|
|
|
948
1083
|
},
|
|
949
1084
|
{ additionalProperties: false }
|
|
950
1085
|
);
|
|
951
|
-
var createIssueToolInputSchema =
|
|
952
|
-
repo:
|
|
953
|
-
title:
|
|
954
|
-
body:
|
|
955
|
-
labels:
|
|
1086
|
+
var createIssueToolInputSchema = z7.object({
|
|
1087
|
+
repo: z7.string().describe('Repository in "owner/name" format.'),
|
|
1088
|
+
title: z7.string().describe("Issue title."),
|
|
1089
|
+
body: z7.string().describe("Issue body. The runtime appends the conversation footer.").optional(),
|
|
1090
|
+
labels: z7.array(z7.string()).describe("Labels to apply to the issue.").optional()
|
|
956
1091
|
}).strict();
|
|
957
1092
|
var createIssueStateSchema = Type.Union([
|
|
958
1093
|
Type.Object(
|
|
@@ -977,14 +1112,14 @@ var createIssueStateSchema = Type.Union([
|
|
|
977
1112
|
{ additionalProperties: false }
|
|
978
1113
|
)
|
|
979
1114
|
]);
|
|
980
|
-
var gitHubIssueDataSchema =
|
|
981
|
-
number:
|
|
1115
|
+
var gitHubIssueDataSchema = z7.object({
|
|
1116
|
+
number: z7.number(),
|
|
982
1117
|
subscribable: subscribableResourceSchema.optional(),
|
|
983
|
-
url:
|
|
1118
|
+
url: z7.string()
|
|
984
1119
|
});
|
|
985
|
-
var gitHubIssueOutputSchema =
|
|
1120
|
+
var gitHubIssueOutputSchema = pluginToolOutputSchema5.merge(
|
|
986
1121
|
gitHubIssueDataSchema.extend({
|
|
987
|
-
target:
|
|
1122
|
+
target: z7.literal("createIssue")
|
|
988
1123
|
})
|
|
989
1124
|
);
|
|
990
1125
|
function gitHubIssueToolResult(input, result, canSubscribe) {
|
|
@@ -1021,14 +1156,14 @@ function parseCreateIssueInput(input) {
|
|
|
1021
1156
|
try {
|
|
1022
1157
|
return Value.Parse(createIssueInputSchema, input);
|
|
1023
1158
|
} catch (error) {
|
|
1024
|
-
throw new
|
|
1159
|
+
throw new PluginToolInputError7("Invalid GitHub createIssue input.", {
|
|
1025
1160
|
cause: error
|
|
1026
1161
|
});
|
|
1027
1162
|
}
|
|
1028
1163
|
}
|
|
1029
1164
|
function nonEmptyString2(value, name) {
|
|
1030
1165
|
if (!value?.trim()) {
|
|
1031
|
-
throw new
|
|
1166
|
+
throw new PluginToolInputError7(`${name} is required`);
|
|
1032
1167
|
}
|
|
1033
1168
|
return value.trim();
|
|
1034
1169
|
}
|
|
@@ -1102,7 +1237,7 @@ async function createGitHubIssue(ctx, request) {
|
|
|
1102
1237
|
};
|
|
1103
1238
|
}
|
|
1104
1239
|
function createGitHubIssueTool(ctx) {
|
|
1105
|
-
return
|
|
1240
|
+
return definePluginTool5({
|
|
1106
1241
|
annotations: {
|
|
1107
1242
|
destructiveHint: false,
|
|
1108
1243
|
idempotentHint: true,
|
|
@@ -1195,85 +1330,85 @@ function createGitHubIssueTool(ctx) {
|
|
|
1195
1330
|
|
|
1196
1331
|
// src/tools/get-deployment.ts
|
|
1197
1332
|
import {
|
|
1198
|
-
definePluginTool as
|
|
1199
|
-
PluginToolInputError as
|
|
1200
|
-
pluginToolOutputSchema as
|
|
1333
|
+
definePluginTool as definePluginTool6,
|
|
1334
|
+
PluginToolInputError as PluginToolInputError8,
|
|
1335
|
+
pluginToolOutputSchema as pluginToolOutputSchema6,
|
|
1201
1336
|
subscribableResourceSchema as subscribableResourceSchema2
|
|
1202
1337
|
} from "@sentry/junior-plugin-api";
|
|
1203
|
-
import * as
|
|
1204
|
-
var commitShaSchema =
|
|
1205
|
-
var
|
|
1206
|
-
repo:
|
|
1338
|
+
import * as z8 from "zod";
|
|
1339
|
+
var commitShaSchema = z8.string().regex(/^[0-9a-f]{40}$/i);
|
|
1340
|
+
var inputSchema5 = z8.object({
|
|
1341
|
+
repo: z8.string().describe('Repository in "owner/name" format.'),
|
|
1207
1342
|
commit_sha: commitShaSchema.describe(
|
|
1208
1343
|
"Full 40-character Git commit SHA recorded by the deployment."
|
|
1209
1344
|
),
|
|
1210
|
-
environment:
|
|
1345
|
+
environment: z8.string().trim().min(1).describe(
|
|
1211
1346
|
'Optional GitHub deployment environment, such as "Production". Omit to inspect and watch deployments for the commit across environments.'
|
|
1212
1347
|
).optional()
|
|
1213
1348
|
}).strict();
|
|
1214
|
-
var statusSchema =
|
|
1215
|
-
created_at:
|
|
1216
|
-
creator:
|
|
1217
|
-
description:
|
|
1218
|
-
environment_url:
|
|
1219
|
-
id:
|
|
1220
|
-
log_url:
|
|
1221
|
-
state:
|
|
1349
|
+
var statusSchema = z8.object({
|
|
1350
|
+
created_at: z8.string(),
|
|
1351
|
+
creator: z8.string().nullable(),
|
|
1352
|
+
description: z8.string().nullable(),
|
|
1353
|
+
environment_url: z8.string().nullable(),
|
|
1354
|
+
id: z8.number(),
|
|
1355
|
+
log_url: z8.string().nullable(),
|
|
1356
|
+
state: z8.string()
|
|
1222
1357
|
}).strict();
|
|
1223
|
-
var deploymentSchema =
|
|
1224
|
-
created_at:
|
|
1225
|
-
creator:
|
|
1226
|
-
description:
|
|
1227
|
-
environment:
|
|
1228
|
-
id:
|
|
1358
|
+
var deploymentSchema = z8.object({
|
|
1359
|
+
created_at: z8.string(),
|
|
1360
|
+
creator: z8.string().nullable(),
|
|
1361
|
+
description: z8.string().nullable(),
|
|
1362
|
+
environment: z8.string(),
|
|
1363
|
+
id: z8.number(),
|
|
1229
1364
|
latest_status: statusSchema.nullable(),
|
|
1230
|
-
ref:
|
|
1365
|
+
ref: z8.string(),
|
|
1231
1366
|
sha: commitShaSchema,
|
|
1232
|
-
updated_at:
|
|
1233
|
-
url:
|
|
1367
|
+
updated_at: z8.string(),
|
|
1368
|
+
url: z8.string()
|
|
1234
1369
|
}).strict();
|
|
1235
|
-
var deploymentSourceSchema =
|
|
1370
|
+
var deploymentSourceSchema = z8.object({
|
|
1236
1371
|
commit_sha: commitShaSchema,
|
|
1237
1372
|
deployment: deploymentSchema.nullable(),
|
|
1238
|
-
environment:
|
|
1239
|
-
repo:
|
|
1373
|
+
environment: z8.string().nullable(),
|
|
1374
|
+
repo: z8.string(),
|
|
1240
1375
|
subscribable: subscribableResourceSchema2.optional()
|
|
1241
1376
|
}).strict();
|
|
1242
|
-
var
|
|
1377
|
+
var outputSchema5 = pluginToolOutputSchema6.merge(
|
|
1243
1378
|
deploymentSourceSchema.extend({
|
|
1244
|
-
target:
|
|
1379
|
+
target: z8.literal("getDeployment")
|
|
1245
1380
|
})
|
|
1246
1381
|
);
|
|
1247
|
-
var providerCreatorSchema =
|
|
1248
|
-
var providerDeploymentSchema =
|
|
1249
|
-
created_at:
|
|
1382
|
+
var providerCreatorSchema = z8.object({ login: z8.string() }).passthrough().nullable();
|
|
1383
|
+
var providerDeploymentSchema = z8.object({
|
|
1384
|
+
created_at: z8.string(),
|
|
1250
1385
|
creator: providerCreatorSchema,
|
|
1251
|
-
description:
|
|
1252
|
-
environment:
|
|
1253
|
-
id:
|
|
1254
|
-
ref:
|
|
1386
|
+
description: z8.string().nullable(),
|
|
1387
|
+
environment: z8.string(),
|
|
1388
|
+
id: z8.number(),
|
|
1389
|
+
ref: z8.string(),
|
|
1255
1390
|
sha: commitShaSchema,
|
|
1256
|
-
updated_at:
|
|
1391
|
+
updated_at: z8.string()
|
|
1257
1392
|
}).passthrough();
|
|
1258
|
-
var providerStatusSchema =
|
|
1259
|
-
created_at:
|
|
1393
|
+
var providerStatusSchema = z8.object({
|
|
1394
|
+
created_at: z8.string(),
|
|
1260
1395
|
creator: providerCreatorSchema,
|
|
1261
|
-
description:
|
|
1262
|
-
environment_url:
|
|
1263
|
-
id:
|
|
1264
|
-
log_url:
|
|
1265
|
-
state:
|
|
1396
|
+
description: z8.string().nullable().optional(),
|
|
1397
|
+
environment_url: z8.string().nullable().optional(),
|
|
1398
|
+
id: z8.number(),
|
|
1399
|
+
log_url: z8.string().nullable().optional(),
|
|
1400
|
+
state: z8.string()
|
|
1266
1401
|
}).passthrough();
|
|
1267
1402
|
function throwLookupError(target, status, body) {
|
|
1268
1403
|
const message = `GitHub ${target} lookup failed with HTTP ${status}`;
|
|
1269
1404
|
const hasValidationErrors = body !== null && typeof body === "object" && !Array.isArray(body) && Array.isArray(body.errors) && body.errors.length > 0;
|
|
1270
1405
|
if (target === "deployment" && (status === 404 || status === 422 && hasValidationErrors)) {
|
|
1271
|
-
throw new
|
|
1406
|
+
throw new PluginToolInputError8(message);
|
|
1272
1407
|
}
|
|
1273
1408
|
throw new Error(message);
|
|
1274
1409
|
}
|
|
1275
1410
|
function createGitHubGetDeploymentTool(ctx) {
|
|
1276
|
-
return
|
|
1411
|
+
return definePluginTool6({
|
|
1277
1412
|
annotations: {
|
|
1278
1413
|
destructiveHint: false,
|
|
1279
1414
|
idempotentHint: true,
|
|
@@ -1281,8 +1416,8 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1281
1416
|
readOnlyHint: true
|
|
1282
1417
|
},
|
|
1283
1418
|
description: "Get the latest GitHub deployment and status for an exact repository and full commit SHA, optionally limited to one environment. The result remains subscribable when no deployment exists yet, so use it before waiting for a deployment outcome.",
|
|
1284
|
-
inputSchema:
|
|
1285
|
-
outputSchema:
|
|
1419
|
+
inputSchema: inputSchema5,
|
|
1420
|
+
outputSchema: outputSchema5,
|
|
1286
1421
|
async execute(input) {
|
|
1287
1422
|
const repo = parseRepo(input.repo);
|
|
1288
1423
|
const commitSha = input.commit_sha.toLowerCase();
|
|
@@ -1298,7 +1433,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1298
1433
|
if (!deployments.ok) {
|
|
1299
1434
|
throwLookupError("deployment", deployments.status, deployments.body);
|
|
1300
1435
|
}
|
|
1301
|
-
const providerDeployment =
|
|
1436
|
+
const providerDeployment = z8.array(providerDeploymentSchema).parse(deployments.body)[0];
|
|
1302
1437
|
let deployment = null;
|
|
1303
1438
|
if (providerDeployment) {
|
|
1304
1439
|
const statuses = await githubApi(ctx.egress, {
|
|
@@ -1308,7 +1443,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1308
1443
|
if (!statuses.ok) {
|
|
1309
1444
|
throwLookupError("deployment status", statuses.status, statuses.body);
|
|
1310
1445
|
}
|
|
1311
|
-
const providerStatus =
|
|
1446
|
+
const providerStatus = z8.array(providerStatusSchema).parse(statuses.body)[0];
|
|
1312
1447
|
deployment = {
|
|
1313
1448
|
created_at: providerDeployment.created_at,
|
|
1314
1449
|
creator: providerDeployment.creator?.login ?? null,
|
|
@@ -1353,47 +1488,47 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1353
1488
|
|
|
1354
1489
|
// src/tools/get-issue.ts
|
|
1355
1490
|
import {
|
|
1356
|
-
definePluginTool as
|
|
1357
|
-
PluginToolInputError as
|
|
1358
|
-
pluginToolOutputSchema as
|
|
1491
|
+
definePluginTool as definePluginTool7,
|
|
1492
|
+
PluginToolInputError as PluginToolInputError9,
|
|
1493
|
+
pluginToolOutputSchema as pluginToolOutputSchema7,
|
|
1359
1494
|
subscribableResourceSchema as subscribableResourceSchema3
|
|
1360
1495
|
} from "@sentry/junior-plugin-api";
|
|
1361
|
-
import * as
|
|
1496
|
+
import * as z9 from "zod";
|
|
1362
1497
|
var CLAIM_NOTE = "If you start work on this issue, first claim it with github_updateIssue and assign_requester: true.";
|
|
1363
|
-
var
|
|
1364
|
-
repo:
|
|
1365
|
-
number:
|
|
1498
|
+
var inputSchema6 = z9.object({
|
|
1499
|
+
repo: z9.string().describe('Repository in "owner/name" format.'),
|
|
1500
|
+
number: z9.number().int().positive().describe("Issue number.")
|
|
1366
1501
|
}).strict();
|
|
1367
|
-
var issueSchema =
|
|
1368
|
-
assignees:
|
|
1369
|
-
author:
|
|
1370
|
-
body:
|
|
1371
|
-
comments:
|
|
1372
|
-
labels:
|
|
1373
|
-
note:
|
|
1374
|
-
number:
|
|
1375
|
-
state:
|
|
1502
|
+
var issueSchema = z9.object({
|
|
1503
|
+
assignees: z9.array(z9.string()),
|
|
1504
|
+
author: z9.string().optional(),
|
|
1505
|
+
body: z9.string().nullable(),
|
|
1506
|
+
comments: z9.number(),
|
|
1507
|
+
labels: z9.array(z9.string()),
|
|
1508
|
+
note: z9.string().optional(),
|
|
1509
|
+
number: z9.number(),
|
|
1510
|
+
state: z9.string(),
|
|
1376
1511
|
subscribable: subscribableResourceSchema3.optional(),
|
|
1377
|
-
title:
|
|
1378
|
-
url:
|
|
1512
|
+
title: z9.string(),
|
|
1513
|
+
url: z9.string()
|
|
1379
1514
|
});
|
|
1380
|
-
var
|
|
1381
|
-
issueSchema.extend({ target:
|
|
1515
|
+
var outputSchema6 = pluginToolOutputSchema7.merge(
|
|
1516
|
+
issueSchema.extend({ target: z9.literal("getIssue") })
|
|
1382
1517
|
);
|
|
1383
|
-
var providerIssueSchema =
|
|
1384
|
-
assignees:
|
|
1385
|
-
body:
|
|
1386
|
-
comments:
|
|
1387
|
-
html_url:
|
|
1388
|
-
labels:
|
|
1389
|
-
number:
|
|
1390
|
-
repository_url:
|
|
1391
|
-
state:
|
|
1392
|
-
title:
|
|
1393
|
-
user:
|
|
1518
|
+
var providerIssueSchema = z9.object({
|
|
1519
|
+
assignees: z9.array(z9.object({ login: z9.string() })).nullish().transform((assignees) => assignees?.map(({ login: login2 }) => login2) ?? []),
|
|
1520
|
+
body: z9.string().nullable().optional().default(null),
|
|
1521
|
+
comments: z9.number().optional().default(0),
|
|
1522
|
+
html_url: z9.string(),
|
|
1523
|
+
labels: z9.array(z9.object({ name: z9.string() })).optional().default([]).transform((labels) => labels.map(({ name }) => name)),
|
|
1524
|
+
number: z9.number(),
|
|
1525
|
+
repository_url: z9.string().optional(),
|
|
1526
|
+
state: z9.string(),
|
|
1527
|
+
title: z9.string(),
|
|
1528
|
+
user: z9.object({ login: z9.string() }).nullish()
|
|
1394
1529
|
});
|
|
1395
1530
|
function createGitHubGetIssueTool(ctx) {
|
|
1396
|
-
return
|
|
1531
|
+
return definePluginTool7({
|
|
1397
1532
|
annotations: {
|
|
1398
1533
|
destructiveHint: false,
|
|
1399
1534
|
idempotentHint: true,
|
|
@@ -1401,8 +1536,8 @@ function createGitHubGetIssueTool(ctx) {
|
|
|
1401
1536
|
readOnlyHint: true
|
|
1402
1537
|
},
|
|
1403
1538
|
description: "Get a GitHub issue. Read its comments with gh api repos/OWNER/REPO/issues/NUMBER/comments.",
|
|
1404
|
-
inputSchema:
|
|
1405
|
-
outputSchema:
|
|
1539
|
+
inputSchema: inputSchema6,
|
|
1540
|
+
outputSchema: outputSchema6,
|
|
1406
1541
|
async execute(input) {
|
|
1407
1542
|
const repo = parseRepo(input.repo);
|
|
1408
1543
|
const [response, requester] = await Promise.all([
|
|
@@ -1416,7 +1551,7 @@ function createGitHubGetIssueTool(ctx) {
|
|
|
1416
1551
|
if (!response.ok) {
|
|
1417
1552
|
const message = `GitHub issue lookup failed with HTTP ${response.status}`;
|
|
1418
1553
|
if (response.status === 404) {
|
|
1419
|
-
throw new
|
|
1554
|
+
throw new PluginToolInputError9(message);
|
|
1420
1555
|
}
|
|
1421
1556
|
throw new Error(message);
|
|
1422
1557
|
}
|
|
@@ -1467,16 +1602,35 @@ function issueRepoRef(repositoryUrl) {
|
|
|
1467
1602
|
// src/tools/create-pull-request.ts
|
|
1468
1603
|
import {
|
|
1469
1604
|
objectFactsSchema as objectFactsSchema2,
|
|
1470
|
-
definePluginTool as
|
|
1605
|
+
definePluginTool as definePluginTool8,
|
|
1471
1606
|
EgressAuthRequired as EgressAuthRequired2,
|
|
1472
|
-
PluginToolInputError as
|
|
1473
|
-
pluginToolOutputSchema as
|
|
1607
|
+
PluginToolInputError as PluginToolInputError11,
|
|
1608
|
+
pluginToolOutputSchema as pluginToolOutputSchema8,
|
|
1474
1609
|
watchResultSchema,
|
|
1475
1610
|
subscribableResourceSchema as subscribableResourceSchema4
|
|
1476
1611
|
} from "@sentry/junior-plugin-api";
|
|
1477
1612
|
import { Type as Type2 } from "@sinclair/typebox";
|
|
1478
1613
|
import { Value as Value2 } from "@sinclair/typebox/value";
|
|
1479
|
-
import * as
|
|
1614
|
+
import * as z13 from "zod";
|
|
1615
|
+
|
|
1616
|
+
// src/pull-request-requesters/draft-reviewers.ts
|
|
1617
|
+
import * as z10 from "zod";
|
|
1618
|
+
var DRAFT_REVIEWERS_TTL_MS = 14 * 24 * 60 * 60 * 1e3;
|
|
1619
|
+
var reviewersSchema = z10.array(z10.string().min(1)).min(1);
|
|
1620
|
+
function draftReviewersKey(target) {
|
|
1621
|
+
return `pull-request-draft-reviewers:${target.repositoryFullName.toLowerCase()}#${target.number}`;
|
|
1622
|
+
}
|
|
1623
|
+
async function saveGitHubDraftReviewers(state, target, reviewers) {
|
|
1624
|
+
await state.set(
|
|
1625
|
+
draftReviewersKey(target),
|
|
1626
|
+
reviewersSchema.parse(reviewers),
|
|
1627
|
+
DRAFT_REVIEWERS_TTL_MS
|
|
1628
|
+
);
|
|
1629
|
+
}
|
|
1630
|
+
async function readGitHubDraftReviewers(state, target) {
|
|
1631
|
+
const saved = await state.get(draftReviewersKey(target));
|
|
1632
|
+
return saved === void 0 ? void 0 : reviewersSchema.parse(saved);
|
|
1633
|
+
}
|
|
1480
1634
|
|
|
1481
1635
|
// src/pull-request-requesters/store.ts
|
|
1482
1636
|
import { and, asc, eq, inArray, lt } from "drizzle-orm";
|
|
@@ -1484,6 +1638,7 @@ import { and, asc, eq, inArray, lt } from "drizzle-orm";
|
|
|
1484
1638
|
// src/db/schema.ts
|
|
1485
1639
|
import { sql } from "drizzle-orm";
|
|
1486
1640
|
import {
|
|
1641
|
+
boolean as boolean3,
|
|
1487
1642
|
index,
|
|
1488
1643
|
integer,
|
|
1489
1644
|
pgTable,
|
|
@@ -1491,18 +1646,18 @@ import {
|
|
|
1491
1646
|
text,
|
|
1492
1647
|
timestamp
|
|
1493
1648
|
} from "drizzle-orm/pg-core";
|
|
1494
|
-
import * as
|
|
1495
|
-
var githubPullRequestStateSchema =
|
|
1649
|
+
import * as z11 from "zod";
|
|
1650
|
+
var githubPullRequestStateSchema = z11.enum([
|
|
1496
1651
|
"closed_unmerged",
|
|
1497
1652
|
"merged",
|
|
1498
1653
|
"open"
|
|
1499
1654
|
]);
|
|
1500
|
-
var githubPullRequestCommitCompositionSchema =
|
|
1655
|
+
var githubPullRequestCommitCompositionSchema = z11.enum([
|
|
1501
1656
|
"junior_only",
|
|
1502
1657
|
"mixed"
|
|
1503
1658
|
]);
|
|
1504
|
-
var githubIssueStateSchema =
|
|
1505
|
-
var githubIssueStateReasonSchema =
|
|
1659
|
+
var githubIssueStateSchema = z11.enum(["closed", "open"]);
|
|
1660
|
+
var githubIssueStateReasonSchema = z11.enum([
|
|
1506
1661
|
"completed",
|
|
1507
1662
|
"duplicate",
|
|
1508
1663
|
"not_planned",
|
|
@@ -1538,6 +1693,8 @@ var juniorGitHubPullRequests = pgTable(
|
|
|
1538
1693
|
state: text("state").$type().notNull(),
|
|
1539
1694
|
commitComposition: text("commit_composition").$type(),
|
|
1540
1695
|
conversationIds: text("conversation_ids").array().notNull().default(sql`ARRAY[]::text[]`),
|
|
1696
|
+
/** The daily reconcile compares this with GitHub. */
|
|
1697
|
+
draft: boolean3("draft").notNull().default(false),
|
|
1541
1698
|
openedAt: timestamp("opened_at", { withTimezone: true }).notNull(),
|
|
1542
1699
|
mergedAt: timestamp("merged_at", { withTimezone: true }),
|
|
1543
1700
|
closedAt: timestamp("closed_at", { withTimezone: true }),
|
|
@@ -1663,32 +1820,32 @@ async function listGitHubPullRequestOpeners(db, input) {
|
|
|
1663
1820
|
}
|
|
1664
1821
|
|
|
1665
1822
|
// src/tools/stack-pull-request.ts
|
|
1666
|
-
import * as
|
|
1823
|
+
import * as z12 from "zod";
|
|
1667
1824
|
var MAX_STACK_DEPTH = 10;
|
|
1668
1825
|
var GITHUB_STACKS_API_VERSION = "2026-03-10";
|
|
1669
|
-
var stackTargetSchema =
|
|
1670
|
-
number:
|
|
1671
|
-
head:
|
|
1672
|
-
ref:
|
|
1673
|
-
repo:
|
|
1826
|
+
var stackTargetSchema = z12.object({
|
|
1827
|
+
number: z12.number().int().positive(),
|
|
1828
|
+
head: z12.object({
|
|
1829
|
+
ref: z12.string().min(1),
|
|
1830
|
+
repo: z12.object({ full_name: z12.string().min(1) }).nullable()
|
|
1674
1831
|
}),
|
|
1675
|
-
base:
|
|
1676
|
-
ref:
|
|
1677
|
-
repo:
|
|
1678
|
-
default_branch:
|
|
1679
|
-
full_name:
|
|
1832
|
+
base: z12.object({
|
|
1833
|
+
ref: z12.string().min(1),
|
|
1834
|
+
repo: z12.object({
|
|
1835
|
+
default_branch: z12.string().min(1),
|
|
1836
|
+
full_name: z12.string().min(1)
|
|
1680
1837
|
})
|
|
1681
1838
|
})
|
|
1682
1839
|
});
|
|
1683
|
-
var openPullRequestsSchema =
|
|
1684
|
-
|
|
1685
|
-
number:
|
|
1686
|
-
base:
|
|
1840
|
+
var openPullRequestsSchema = z12.array(
|
|
1841
|
+
z12.object({
|
|
1842
|
+
number: z12.number().int().positive(),
|
|
1843
|
+
base: z12.object({ ref: z12.string().min(1) })
|
|
1687
1844
|
})
|
|
1688
1845
|
);
|
|
1689
|
-
var stackSchema =
|
|
1690
|
-
number:
|
|
1691
|
-
pull_requests:
|
|
1846
|
+
var stackSchema = z12.object({
|
|
1847
|
+
number: z12.number().int().positive(),
|
|
1848
|
+
pull_requests: z12.array(z12.object({ number: z12.number().int().positive() }))
|
|
1692
1849
|
});
|
|
1693
1850
|
async function stackGitHubPullRequest(ctx, target) {
|
|
1694
1851
|
const repo = target.base.repo.full_name;
|
|
@@ -1698,17 +1855,17 @@ async function stackGitHubPullRequest(ctx, target) {
|
|
|
1698
1855
|
}
|
|
1699
1856
|
const [owner, name] = repo.split("/");
|
|
1700
1857
|
const api = repoPath({ owner, name });
|
|
1701
|
-
const github = async (
|
|
1858
|
+
const github = async (operation2, path, schema, body) => {
|
|
1702
1859
|
const response = await githubApi(ctx.egress, {
|
|
1703
1860
|
apiVersion: GITHUB_STACKS_API_VERSION,
|
|
1704
|
-
operation,
|
|
1861
|
+
operation: operation2,
|
|
1705
1862
|
path,
|
|
1706
1863
|
...body === void 0 ? void 0 : { method: "POST", body }
|
|
1707
1864
|
});
|
|
1708
1865
|
if (!response.ok) {
|
|
1709
1866
|
ctx.log.warn("github.pull_request.stack_after_create.rejected", {
|
|
1710
1867
|
number: target.number,
|
|
1711
|
-
operation,
|
|
1868
|
+
operation: operation2,
|
|
1712
1869
|
repo,
|
|
1713
1870
|
status: response.status
|
|
1714
1871
|
});
|
|
@@ -1736,7 +1893,7 @@ async function stackGitHubPullRequest(ctx, target) {
|
|
|
1736
1893
|
const stacks = await github(
|
|
1737
1894
|
"github.stack.read",
|
|
1738
1895
|
`${api}/stacks?pull_request=${parent.number}`,
|
|
1739
|
-
|
|
1896
|
+
z12.array(stackSchema)
|
|
1740
1897
|
);
|
|
1741
1898
|
if (!stacks) return void 0;
|
|
1742
1899
|
const stack = stacks[0];
|
|
@@ -1773,6 +1930,59 @@ async function stackGitHubPullRequest(ctx, target) {
|
|
|
1773
1930
|
}
|
|
1774
1931
|
}
|
|
1775
1932
|
|
|
1933
|
+
// src/tool-support/pull-request-description.ts
|
|
1934
|
+
import {
|
|
1935
|
+
PluginToolInputError as PluginToolInputError10
|
|
1936
|
+
} from "@sentry/junior-plugin-api";
|
|
1937
|
+
var MISSING_REASON_FIX = "Say why the change is needed.";
|
|
1938
|
+
var DESCRIPTION_CHECKS = [
|
|
1939
|
+
{
|
|
1940
|
+
question: "Does the description report how tests, lint, typecheck, or CI went when the author ran them, passing or failing, locally or in CI, or describe a test plan or test coverage, including what has no tests? Text about what the product does with such commands does not count.",
|
|
1941
|
+
fix: "Remove check results, test plans, test coverage notes, and commands. Reviewers see checks on the pull request."
|
|
1942
|
+
},
|
|
1943
|
+
{
|
|
1944
|
+
question: "Does the description narrate the author's own work session, such as what the author investigated, approaches or names the author tried first and dropped, or how many runs the author looked at? Old behavior compared with new behavior does not count.",
|
|
1945
|
+
fix: "Remove the work log. Describe the change as it is now."
|
|
1946
|
+
},
|
|
1947
|
+
{
|
|
1948
|
+
question: "Does the description mention the request for this pull request, such as who asked for it or a chat message about it? A product feature that involves Slack or chat does not count.",
|
|
1949
|
+
fix: "Remove the conversation. The runtime adds who asked."
|
|
1950
|
+
},
|
|
1951
|
+
{
|
|
1952
|
+
question: "Does the description leave out why the change is needed or what problem it fixes?",
|
|
1953
|
+
fix: MISSING_REASON_FIX
|
|
1954
|
+
}
|
|
1955
|
+
];
|
|
1956
|
+
async function pullRequestDescriptionFixes(decider, body) {
|
|
1957
|
+
if (!body.trim()) {
|
|
1958
|
+
return [MISSING_REASON_FIX];
|
|
1959
|
+
}
|
|
1960
|
+
const answers = await Promise.all(
|
|
1961
|
+
DESCRIPTION_CHECKS.map(
|
|
1962
|
+
({ question }) => decider.decide({
|
|
1963
|
+
criteria: { no: "No.", yes: "Yes." },
|
|
1964
|
+
instructions: `Judge this GitHub pull request description. ${question}`,
|
|
1965
|
+
state: body
|
|
1966
|
+
})
|
|
1967
|
+
)
|
|
1968
|
+
);
|
|
1969
|
+
return DESCRIPTION_CHECKS.filter(
|
|
1970
|
+
(_, index2) => answers[index2].choice === "yes"
|
|
1971
|
+
).map(({ fix }) => fix);
|
|
1972
|
+
}
|
|
1973
|
+
async function checkPullRequestDescription(decider, body) {
|
|
1974
|
+
const fixes = await pullRequestDescriptionFixes(decider, body);
|
|
1975
|
+
if (fixes.length > 0) {
|
|
1976
|
+
throw new PluginToolInputError10(
|
|
1977
|
+
[
|
|
1978
|
+
"Pull request description rejected. Fix it and call the tool again:",
|
|
1979
|
+
...fixes.map((fix) => `- ${fix}`),
|
|
1980
|
+
"Write for a reviewer with no context: what changes and why, whether anything breaks and what to do, linked issues, and open questions. Keep it short."
|
|
1981
|
+
].join("\n")
|
|
1982
|
+
);
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1776
1986
|
// src/tools/create-pull-request.ts
|
|
1777
1987
|
var GITHUB_PULL_REQUEST_CREATE_IDEMPOTENCY_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
1778
1988
|
var GITHUB_PULL_REQUEST_CREATE_LOCK_TTL_MS = 6e4;
|
|
@@ -1784,6 +1994,7 @@ var GitHubPullRequestCreateRejectedError = class extends Error {
|
|
|
1784
1994
|
this.status = status;
|
|
1785
1995
|
}
|
|
1786
1996
|
};
|
|
1997
|
+
var REVIEWERS_DESCRIPTION = "GitHub logins to ask for a review. Set this only when the person names who should review. Without it, Junior asks the requester's linked GitHub account. A draft gets the request when it becomes ready for review.";
|
|
1787
1998
|
var createPullRequestInputSchema = Type2.Object(
|
|
1788
1999
|
{
|
|
1789
2000
|
repo: Type2.String({
|
|
@@ -1807,19 +2018,26 @@ var createPullRequestInputSchema = Type2.Object(
|
|
|
1807
2018
|
Type2.Boolean({
|
|
1808
2019
|
description: "Whether to open the pull request as a draft."
|
|
1809
2020
|
})
|
|
2021
|
+
),
|
|
2022
|
+
reviewers: Type2.Optional(
|
|
2023
|
+
Type2.Array(Type2.String(), {
|
|
2024
|
+
description: REVIEWERS_DESCRIPTION,
|
|
2025
|
+
minItems: 1
|
|
2026
|
+
})
|
|
1810
2027
|
)
|
|
1811
2028
|
},
|
|
1812
2029
|
{ additionalProperties: false }
|
|
1813
2030
|
);
|
|
1814
|
-
var createPullRequestToolInputSchema =
|
|
1815
|
-
repo:
|
|
1816
|
-
title:
|
|
1817
|
-
head:
|
|
1818
|
-
base:
|
|
1819
|
-
body:
|
|
2031
|
+
var createPullRequestToolInputSchema = z13.object({
|
|
2032
|
+
repo: z13.string().describe('Repository in "owner/name" format.'),
|
|
2033
|
+
title: z13.string().describe("Pull request title."),
|
|
2034
|
+
head: z13.string().describe("Head branch or owner:branch ref."),
|
|
2035
|
+
base: z13.string().describe("Base branch."),
|
|
2036
|
+
body: z13.string().describe(
|
|
1820
2037
|
"Pull request body. The runtime appends the conversation footer."
|
|
1821
2038
|
).optional(),
|
|
1822
|
-
draft:
|
|
2039
|
+
draft: z13.boolean().describe("Whether to open the pull request as a draft.").optional(),
|
|
2040
|
+
reviewers: z13.array(z13.string()).min(1).describe(REVIEWERS_DESCRIPTION).optional()
|
|
1823
2041
|
}).strict();
|
|
1824
2042
|
var createPullRequestStateSchema = Type2.Union([
|
|
1825
2043
|
Type2.Object(
|
|
@@ -1844,30 +2062,30 @@ var createPullRequestStateSchema = Type2.Union([
|
|
|
1844
2062
|
{ additionalProperties: false }
|
|
1845
2063
|
)
|
|
1846
2064
|
]);
|
|
1847
|
-
var gitHubPullRequestDataSchema =
|
|
1848
|
-
number:
|
|
1849
|
-
url:
|
|
1850
|
-
stack:
|
|
2065
|
+
var gitHubPullRequestDataSchema = z13.object({
|
|
2066
|
+
number: z13.number(),
|
|
2067
|
+
url: z13.string(),
|
|
2068
|
+
stack: z13.object({ number: z13.number(), pull_requests: z13.array(z13.number()) }).optional(),
|
|
1851
2069
|
subscribable: subscribableResourceSchema4.optional(),
|
|
1852
2070
|
subscription: watchResultSchema.optional()
|
|
1853
2071
|
});
|
|
1854
|
-
var gitHubPullRequestOutputSchema =
|
|
2072
|
+
var gitHubPullRequestOutputSchema = pluginToolOutputSchema8.merge(
|
|
1855
2073
|
gitHubPullRequestDataSchema.extend({
|
|
1856
|
-
target:
|
|
2074
|
+
target: z13.literal("createPullRequest")
|
|
1857
2075
|
})
|
|
1858
2076
|
);
|
|
1859
2077
|
function parseCreatePullRequestInput(input) {
|
|
1860
2078
|
try {
|
|
1861
2079
|
return Value2.Parse(createPullRequestInputSchema, input);
|
|
1862
2080
|
} catch (error) {
|
|
1863
|
-
throw new
|
|
2081
|
+
throw new PluginToolInputError11("Invalid GitHub createPullRequest input.", {
|
|
1864
2082
|
cause: error
|
|
1865
2083
|
});
|
|
1866
2084
|
}
|
|
1867
2085
|
}
|
|
1868
2086
|
function nonEmptyString3(value, name) {
|
|
1869
2087
|
if (!value?.trim()) {
|
|
1870
|
-
throw new
|
|
2088
|
+
throw new PluginToolInputError11(`${name} is required`);
|
|
1871
2089
|
}
|
|
1872
2090
|
return value.trim();
|
|
1873
2091
|
}
|
|
@@ -1887,10 +2105,13 @@ function isEgressAuthRequired2(error) {
|
|
|
1887
2105
|
return error instanceof EgressAuthRequired2 || error instanceof Error && error.name === "EgressAuthRequired";
|
|
1888
2106
|
}
|
|
1889
2107
|
function isDefinitiveGitHubPullRequestCreateRejection(error) {
|
|
2108
|
+
if (error instanceof PluginToolInputError11) {
|
|
2109
|
+
return true;
|
|
2110
|
+
}
|
|
1890
2111
|
if (!(error instanceof GitHubPullRequestCreateRejectedError)) {
|
|
1891
2112
|
return false;
|
|
1892
2113
|
}
|
|
1893
|
-
return [400, 401,
|
|
2114
|
+
return [400, 401, 410].includes(error.status);
|
|
1894
2115
|
}
|
|
1895
2116
|
function createGitHubPullRequestRequest(conversationId, input, ctx, requester, dashboardUrl) {
|
|
1896
2117
|
const repo = parseRepo(input.repo);
|
|
@@ -1915,12 +2136,13 @@ async function createGitHubPullRequest(ctx, request) {
|
|
|
1915
2136
|
});
|
|
1916
2137
|
const parsed = response.body;
|
|
1917
2138
|
if (!response.ok) {
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
2139
|
+
const message = `GitHub pull request creation failed with HTTP ${response.status}: ${githubErrorMessage(
|
|
2140
|
+
parsed
|
|
2141
|
+
)}`;
|
|
2142
|
+
if (response.status === 404 || response.status === 422) {
|
|
2143
|
+
throw new PluginToolInputError11(message);
|
|
2144
|
+
}
|
|
2145
|
+
throw new GitHubPullRequestCreateRejectedError(message, response.status);
|
|
1924
2146
|
}
|
|
1925
2147
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1926
2148
|
throw new Error(
|
|
@@ -1981,6 +2203,59 @@ async function assignPullRequestRequester(ctx, input, result, requester) {
|
|
|
1981
2203
|
});
|
|
1982
2204
|
}
|
|
1983
2205
|
}
|
|
2206
|
+
function namedReviewers(input) {
|
|
2207
|
+
return input.reviewers?.map((value) => {
|
|
2208
|
+
const login2 = parseGitHubLogin(value);
|
|
2209
|
+
if (!login2) {
|
|
2210
|
+
throw new PluginToolInputError11(`Invalid GitHub reviewer login: ${value}`);
|
|
2211
|
+
}
|
|
2212
|
+
return login2;
|
|
2213
|
+
});
|
|
2214
|
+
}
|
|
2215
|
+
async function saveNamedDraftReviewers(ctx, input, number33) {
|
|
2216
|
+
const named = namedReviewers(input);
|
|
2217
|
+
if (!input.draft || !named) return;
|
|
2218
|
+
await saveGitHubDraftReviewers(
|
|
2219
|
+
ctx.state,
|
|
2220
|
+
{ number: number33, repositoryFullName: parseRepo(input.repo).ref },
|
|
2221
|
+
named
|
|
2222
|
+
);
|
|
2223
|
+
}
|
|
2224
|
+
async function requestPullRequestReviewers(ctx, input, result, requester) {
|
|
2225
|
+
const named = namedReviewers(input);
|
|
2226
|
+
const repo = parseRepo(input.repo);
|
|
2227
|
+
try {
|
|
2228
|
+
if (input.draft) {
|
|
2229
|
+
await saveNamedDraftReviewers(ctx, input, result.number);
|
|
2230
|
+
return;
|
|
2231
|
+
}
|
|
2232
|
+
const requesterLogin = linkedGitHubLogin(requester?.user);
|
|
2233
|
+
const reviewers = named ?? (requesterLogin ? [requesterLogin] : []);
|
|
2234
|
+
if (reviewers.length === 0) return;
|
|
2235
|
+
const response = await githubApi(ctx.egress, {
|
|
2236
|
+
operation: "github.pull.request_reviewers",
|
|
2237
|
+
method: "POST",
|
|
2238
|
+
path: `${repoPath(repo)}/pulls/${result.number}/requested_reviewers`,
|
|
2239
|
+
body: { reviewers }
|
|
2240
|
+
});
|
|
2241
|
+
if (!response.ok) {
|
|
2242
|
+
ctx.log.warn(
|
|
2243
|
+
"github.pull_request.request_reviewers_after_create.rejected",
|
|
2244
|
+
{
|
|
2245
|
+
number: result.number,
|
|
2246
|
+
repo: input.repo,
|
|
2247
|
+
status: response.status
|
|
2248
|
+
}
|
|
2249
|
+
);
|
|
2250
|
+
}
|
|
2251
|
+
} catch (error) {
|
|
2252
|
+
ctx.log.warn("github.pull_request.request_reviewers_after_create.failed", {
|
|
2253
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2254
|
+
number: result.number,
|
|
2255
|
+
repo: input.repo
|
|
2256
|
+
});
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
1984
2259
|
function gitHubPullRequestToolResult(input, result, canSubscribe, omitSuggestedEvents) {
|
|
1985
2260
|
const repo = parseRepo(input.repo);
|
|
1986
2261
|
const subscribable = gitHubPullRequestSubscribable({
|
|
@@ -2022,7 +2297,9 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
|
|
|
2022
2297
|
...stack ? { stack } : void 0
|
|
2023
2298
|
};
|
|
2024
2299
|
}
|
|
2025
|
-
const watch = gitHubPullRequestCreateWatch(subscriptionConfig
|
|
2300
|
+
const watch = gitHubPullRequestCreateWatch(subscriptionConfig, {
|
|
2301
|
+
draft: input.draft === true
|
|
2302
|
+
});
|
|
2026
2303
|
try {
|
|
2027
2304
|
const subscription = await ctx.events.subscribe({
|
|
2028
2305
|
...watch,
|
|
@@ -2055,20 +2332,21 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
|
|
|
2055
2332
|
};
|
|
2056
2333
|
}
|
|
2057
2334
|
}
|
|
2058
|
-
function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
2059
|
-
return
|
|
2335
|
+
function createGitHubPullRequestTool(ctx, subscriptionConfig, descriptionDecider) {
|
|
2336
|
+
return definePluginTool8({
|
|
2060
2337
|
annotations: {
|
|
2061
2338
|
destructiveHint: false,
|
|
2062
2339
|
idempotentHint: true,
|
|
2063
2340
|
openWorldHint: true,
|
|
2064
2341
|
readOnlyHint: false
|
|
2065
2342
|
},
|
|
2066
|
-
description: "Create a GitHub pull request with a runtime-owned conversation footer
|
|
2343
|
+
description: "Create a GitHub pull request with a runtime-owned conversation footer. It assigns the pull request to the requester's linked GitHub account and asks for a review when available. Use this instead of shelling out to gh pr create when creating pull requests.",
|
|
2067
2344
|
exposure: "direct",
|
|
2068
2345
|
inputSchema: createPullRequestToolInputSchema,
|
|
2069
2346
|
outputSchema: gitHubPullRequestOutputSchema,
|
|
2070
2347
|
async execute(input, options) {
|
|
2071
2348
|
const parsedInput = parseCreatePullRequestInput(input);
|
|
2349
|
+
namedReviewers(parsedInput);
|
|
2072
2350
|
const conversationId = nonEmptyString3(
|
|
2073
2351
|
ctx.conversationId,
|
|
2074
2352
|
"conversationId"
|
|
@@ -2086,6 +2364,7 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
2086
2364
|
conversationId,
|
|
2087
2365
|
identityId: (await resolveGitHubRequester(ctx))?.identity?.id
|
|
2088
2366
|
});
|
|
2367
|
+
await saveNamedDraftReviewers(ctx, completedInput, state.number);
|
|
2089
2368
|
const completedResult = {
|
|
2090
2369
|
facts: state.facts === void 0 ? void 0 : objectFactsSchema2.parse(state.facts),
|
|
2091
2370
|
sourceUpdatedAt: state.sourceUpdatedAt,
|
|
@@ -2105,6 +2384,12 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
2105
2384
|
"GitHub pull request creation for this tool call has an uncertain pending result; refusing to create a duplicate pull request."
|
|
2106
2385
|
);
|
|
2107
2386
|
}
|
|
2387
|
+
if (descriptionDecider) {
|
|
2388
|
+
await checkPullRequestDescription(
|
|
2389
|
+
descriptionDecider,
|
|
2390
|
+
parsedInput.body ?? ""
|
|
2391
|
+
);
|
|
2392
|
+
}
|
|
2108
2393
|
const requester = await resolveGitHubRequester(ctx);
|
|
2109
2394
|
const identityId = requester?.identity?.id;
|
|
2110
2395
|
const request = createGitHubPullRequestRequest(
|
|
@@ -2159,6 +2444,12 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
2159
2444
|
identityId
|
|
2160
2445
|
});
|
|
2161
2446
|
await assignPullRequestRequester(ctx, parsedInput, result, requester);
|
|
2447
|
+
await requestPullRequestReviewers(
|
|
2448
|
+
ctx,
|
|
2449
|
+
parsedInput,
|
|
2450
|
+
result,
|
|
2451
|
+
requester
|
|
2452
|
+
);
|
|
2162
2453
|
const stack = stackTarget ? await stackGitHubPullRequest(ctx, stackTarget) : void 0;
|
|
2163
2454
|
return await gitHubPullRequestStructuredResult(
|
|
2164
2455
|
ctx,
|
|
@@ -2175,45 +2466,334 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
2175
2466
|
|
|
2176
2467
|
// src/tools/get-pull-request.ts
|
|
2177
2468
|
import {
|
|
2178
|
-
definePluginTool as
|
|
2179
|
-
PluginToolInputError as
|
|
2180
|
-
pluginToolOutputSchema as
|
|
2469
|
+
definePluginTool as definePluginTool9,
|
|
2470
|
+
PluginToolInputError as PluginToolInputError12,
|
|
2471
|
+
pluginToolOutputSchema as pluginToolOutputSchema9
|
|
2181
2472
|
} from "@sentry/junior-plugin-api";
|
|
2182
|
-
import * as
|
|
2473
|
+
import * as z14 from "zod";
|
|
2183
2474
|
import { subscribableResourceSchema as subscribableResourceSchema5 } from "@sentry/junior-plugin-api";
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2475
|
+
|
|
2476
|
+
// src/graphql-documents.ts
|
|
2477
|
+
import {
|
|
2478
|
+
Kind,
|
|
2479
|
+
parse,
|
|
2480
|
+
print,
|
|
2481
|
+
visit
|
|
2482
|
+
} from "@0no-co/graphql.web";
|
|
2483
|
+
function operation(document) {
|
|
2484
|
+
const [definition] = document.definitions;
|
|
2485
|
+
if (definition?.kind !== Kind.OPERATION_DEFINITION || !definition.name) {
|
|
2486
|
+
throw new Error(
|
|
2487
|
+
"GitHub GraphQL document must start with a named operation"
|
|
2488
|
+
);
|
|
2489
|
+
}
|
|
2490
|
+
return { operationName: definition.name.value, query: print(document) };
|
|
2491
|
+
}
|
|
2492
|
+
function githubGraphql(source) {
|
|
2493
|
+
return operation(parse(source));
|
|
2494
|
+
}
|
|
2495
|
+
var ADD_REVIEW_REACTION = githubGraphql(`
|
|
2496
|
+
mutation AddReviewReaction($subjectId: ID!, $content: ReactionContent!) {
|
|
2497
|
+
addReaction(input: { subjectId: $subjectId, content: $content }) {
|
|
2498
|
+
reaction { content }
|
|
2499
|
+
}
|
|
2500
|
+
}
|
|
2501
|
+
`);
|
|
2502
|
+
var REMOVE_REVIEW_REACTION = githubGraphql(`
|
|
2503
|
+
mutation RemoveReviewReaction($subjectId: ID!, $content: ReactionContent!) {
|
|
2504
|
+
removeReaction(input: { subjectId: $subjectId, content: $content }) {
|
|
2505
|
+
reaction { content }
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
`);
|
|
2509
|
+
var REVIEW_REACTIONS = githubGraphql(`
|
|
2510
|
+
query ReviewReactions($subjectId: ID!) {
|
|
2511
|
+
node(id: $subjectId) {
|
|
2512
|
+
... on PullRequestReview {
|
|
2513
|
+
reactionGroups {
|
|
2514
|
+
content
|
|
2515
|
+
reactors(first: 100) { nodes { ... on Bot { databaseId } } }
|
|
2516
|
+
}
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
`);
|
|
2521
|
+
var MARK_PULL_REQUEST_READY_FOR_REVIEW = githubGraphql(`
|
|
2522
|
+
mutation MarkPullRequestReadyForReview($id: ID!) {
|
|
2523
|
+
result: markPullRequestReadyForReview(input: { pullRequestId: $id }) {
|
|
2524
|
+
pullRequest { isDraft }
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
`);
|
|
2528
|
+
var CONVERT_PULL_REQUEST_TO_DRAFT = githubGraphql(`
|
|
2529
|
+
mutation ConvertPullRequestToDraft($id: ID!) {
|
|
2530
|
+
result: convertPullRequestToDraft(input: { pullRequestId: $id }) {
|
|
2531
|
+
pullRequest { isDraft }
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
`);
|
|
2535
|
+
var REVIEW_THREAD_OWNERSHIP = githubGraphql(`
|
|
2536
|
+
query ReviewThreadOwnership($threadId: ID!) {
|
|
2537
|
+
node(id: $threadId) {
|
|
2538
|
+
... on PullRequestReviewThread {
|
|
2539
|
+
id
|
|
2540
|
+
isResolved
|
|
2541
|
+
pullRequest {
|
|
2542
|
+
number
|
|
2543
|
+
repository { nameWithOwner }
|
|
2544
|
+
author { ... on Bot { databaseId } }
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
`);
|
|
2550
|
+
var RESOLVE_REVIEW_THREAD = githubGraphql(`
|
|
2551
|
+
mutation ResolveReviewThread($threadId: ID!) {
|
|
2552
|
+
resolveReviewThread(input: { threadId: $threadId }) {
|
|
2553
|
+
thread { id isResolved }
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
`);
|
|
2557
|
+
var PULL_REQUEST_CHECKS = githubGraphql(`
|
|
2558
|
+
query PullRequestChecks($owner: String!, $name: String!, $number: Int!) {
|
|
2559
|
+
repository(owner: $owner, name: $name) {
|
|
2560
|
+
pullRequest(number: $number) {
|
|
2561
|
+
mergeStateStatus
|
|
2562
|
+
reviewDecision
|
|
2563
|
+
autoMergeRequest { enabledAt }
|
|
2564
|
+
commits(last: 1) {
|
|
2565
|
+
nodes {
|
|
2566
|
+
commit {
|
|
2567
|
+
statusCheckRollup {
|
|
2568
|
+
contexts(first: 100) {
|
|
2569
|
+
pageInfo { hasNextPage }
|
|
2570
|
+
nodes {
|
|
2571
|
+
__typename
|
|
2572
|
+
... on CheckRun {
|
|
2573
|
+
name
|
|
2574
|
+
status
|
|
2575
|
+
conclusion
|
|
2576
|
+
isRequired(pullRequestNumber: $number)
|
|
2577
|
+
}
|
|
2578
|
+
... on StatusContext {
|
|
2579
|
+
context
|
|
2580
|
+
state
|
|
2581
|
+
isRequired(pullRequestNumber: $number)
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
}
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
`);
|
|
2593
|
+
var OPEN_PULL_REQUEST_MERGEABILITY = githubGraphql(`
|
|
2594
|
+
query OpenPullRequestMergeability($query: String!, $after: String) {
|
|
2595
|
+
search(query: $query, type: ISSUE, first: 100, after: $after) {
|
|
2596
|
+
pageInfo { hasNextPage endCursor }
|
|
2597
|
+
nodes {
|
|
2598
|
+
... on PullRequest { number state mergeable headRefOid baseRefName url }
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
`);
|
|
2603
|
+
var PULL_REQUEST_LIFECYCLE = githubGraphql(`
|
|
2604
|
+
query PullRequestLifecycles($owner: String!, $name: String!, $number: Int!) {
|
|
2605
|
+
repository(owner: $owner, name: $name) {
|
|
2606
|
+
databaseId
|
|
2607
|
+
nameWithOwner
|
|
2608
|
+
pullRequest(number: $number) { ...Lifecycle }
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
fragment Lifecycle on PullRequest {
|
|
2613
|
+
assignees(first: 20) { nodes { login } }
|
|
2614
|
+
author { __typename login }
|
|
2615
|
+
closedAt
|
|
2616
|
+
createdAt
|
|
2617
|
+
databaseId
|
|
2618
|
+
headRefName
|
|
2619
|
+
isDraft
|
|
2620
|
+
merged
|
|
2621
|
+
mergedAt
|
|
2622
|
+
number
|
|
2623
|
+
state
|
|
2624
|
+
title
|
|
2625
|
+
updatedAt
|
|
2626
|
+
}
|
|
2627
|
+
`);
|
|
2628
|
+
function pullRequestLifecycles(count) {
|
|
2629
|
+
const indexes = Array.from({ length: count }, (_, index2) => index2);
|
|
2630
|
+
const variable = (index2) => ({
|
|
2631
|
+
kind: Kind.VARIABLE,
|
|
2632
|
+
name: { kind: Kind.NAME, value: `n${index2}` }
|
|
2633
|
+
});
|
|
2634
|
+
return operation(
|
|
2635
|
+
visit(parse(PULL_REQUEST_LIFECYCLE.query), {
|
|
2636
|
+
OperationDefinition: (node) => ({
|
|
2637
|
+
...node,
|
|
2638
|
+
variableDefinitions: node.variableDefinitions?.flatMap(
|
|
2639
|
+
(definition) => definition.variable.name.value === "number" ? indexes.map((index2) => ({
|
|
2640
|
+
...definition,
|
|
2641
|
+
variable: variable(index2)
|
|
2642
|
+
})) : [definition]
|
|
2643
|
+
)
|
|
2644
|
+
}),
|
|
2645
|
+
SelectionSet: (node) => ({
|
|
2646
|
+
...node,
|
|
2647
|
+
selections: node.selections.flatMap(
|
|
2648
|
+
(selection) => selection.kind === Kind.FIELD && selection.name.value === "pullRequest" ? indexes.map((index2) => ({
|
|
2649
|
+
...selection,
|
|
2650
|
+
alias: { kind: Kind.NAME, value: `pr${index2}` },
|
|
2651
|
+
arguments: selection.arguments?.map((argument) => ({
|
|
2652
|
+
...argument,
|
|
2653
|
+
value: variable(index2)
|
|
2654
|
+
}))
|
|
2655
|
+
})) : [selection]
|
|
2656
|
+
)
|
|
2657
|
+
})
|
|
2658
|
+
})
|
|
2659
|
+
);
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
// src/tools/get-pull-request.ts
|
|
2663
|
+
var commitShaSchema2 = z14.string().regex(/^[0-9a-f]{40}$/i);
|
|
2664
|
+
var inputSchema7 = z14.object({
|
|
2665
|
+
repo: z14.string().describe('Repository in "owner/name" format.'),
|
|
2666
|
+
number: z14.number().int().positive().describe("Pull request number.")
|
|
2188
2667
|
}).strict();
|
|
2189
|
-
var
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2668
|
+
var checksSchema = z14.object({
|
|
2669
|
+
required: z14.enum(["passing", "failing", "pending", "not_reported"]).describe(
|
|
2670
|
+
"State of the required checks on the head commit. not_reported means no required check has reported yet; it does not mean that none are required."
|
|
2671
|
+
),
|
|
2672
|
+
failing: z14.array(z14.string()).describe("Required checks that failed."),
|
|
2673
|
+
pending: z14.array(z14.string()).describe("Required checks that have not finished."),
|
|
2674
|
+
passing: z14.array(z14.string()).describe("Required checks that passed."),
|
|
2675
|
+
incomplete: z14.literal(true).optional().describe(
|
|
2676
|
+
"Set when the head commit has more than 100 checks, so some required checks are not listed."
|
|
2677
|
+
),
|
|
2678
|
+
merge_state: z14.string().describe(
|
|
2679
|
+
"GitHub mergeStateStatus, such as CLEAN, BLOCKED, BEHIND, DIRTY, UNSTABLE, DRAFT, or UNKNOWN. BLOCKED while the listed required checks pass means a required check that has not started, a review, or another rule blocks the merge."
|
|
2680
|
+
),
|
|
2681
|
+
review_decision: z14.string().nullable().describe(
|
|
2682
|
+
"GitHub reviewDecision: APPROVED, CHANGES_REQUESTED, REVIEW_REQUIRED, or null when no review is required."
|
|
2683
|
+
),
|
|
2684
|
+
auto_merge: z14.boolean().describe("true when auto-merge is on for the pull request.")
|
|
2685
|
+
});
|
|
2686
|
+
var pullRequestSchema = z14.object({
|
|
2687
|
+
base: z14.string(),
|
|
2688
|
+
checks: checksSchema,
|
|
2689
|
+
draft: z14.boolean(),
|
|
2690
|
+
head: z14.string(),
|
|
2193
2691
|
head_sha: commitShaSchema2,
|
|
2194
|
-
merged:
|
|
2195
|
-
number:
|
|
2196
|
-
state:
|
|
2692
|
+
merged: z14.boolean(),
|
|
2693
|
+
number: z14.number(),
|
|
2694
|
+
state: z14.string(),
|
|
2197
2695
|
subscribable: subscribableResourceSchema5.optional(),
|
|
2198
|
-
title:
|
|
2199
|
-
url:
|
|
2696
|
+
title: z14.string(),
|
|
2697
|
+
url: z14.string()
|
|
2200
2698
|
});
|
|
2201
|
-
var
|
|
2699
|
+
var outputSchema7 = pluginToolOutputSchema9.merge(
|
|
2202
2700
|
pullRequestSchema.extend({
|
|
2203
|
-
target:
|
|
2701
|
+
target: z14.literal("getPullRequest")
|
|
2204
2702
|
})
|
|
2205
2703
|
);
|
|
2704
|
+
var checkContextSchema = z14.union([
|
|
2705
|
+
z14.object({
|
|
2706
|
+
__typename: z14.literal("CheckRun"),
|
|
2707
|
+
conclusion: z14.string().nullable(),
|
|
2708
|
+
isRequired: z14.boolean(),
|
|
2709
|
+
name: z14.string(),
|
|
2710
|
+
status: z14.string()
|
|
2711
|
+
}),
|
|
2712
|
+
z14.object({
|
|
2713
|
+
__typename: z14.literal("StatusContext"),
|
|
2714
|
+
context: z14.string(),
|
|
2715
|
+
isRequired: z14.boolean(),
|
|
2716
|
+
state: z14.string()
|
|
2717
|
+
})
|
|
2718
|
+
]);
|
|
2719
|
+
var checksResponseSchema = z14.object({
|
|
2720
|
+
data: z14.object({
|
|
2721
|
+
repository: z14.object({
|
|
2722
|
+
pullRequest: z14.object({
|
|
2723
|
+
autoMergeRequest: z14.object({}).passthrough().nullable(),
|
|
2724
|
+
commits: z14.object({
|
|
2725
|
+
nodes: z14.array(
|
|
2726
|
+
z14.object({
|
|
2727
|
+
commit: z14.object({
|
|
2728
|
+
statusCheckRollup: z14.object({
|
|
2729
|
+
contexts: z14.object({
|
|
2730
|
+
nodes: z14.array(checkContextSchema),
|
|
2731
|
+
pageInfo: z14.object({ hasNextPage: z14.boolean() })
|
|
2732
|
+
})
|
|
2733
|
+
}).nullable()
|
|
2734
|
+
})
|
|
2735
|
+
})
|
|
2736
|
+
)
|
|
2737
|
+
}),
|
|
2738
|
+
mergeStateStatus: z14.string(),
|
|
2739
|
+
reviewDecision: z14.string().nullable()
|
|
2740
|
+
})
|
|
2741
|
+
})
|
|
2742
|
+
})
|
|
2743
|
+
});
|
|
2744
|
+
var PASSING_CONCLUSIONS = /* @__PURE__ */ new Set(["SUCCESS", "NEUTRAL", "SKIPPED"]);
|
|
2745
|
+
function contextState(context) {
|
|
2746
|
+
if (context.__typename === "CheckRun") {
|
|
2747
|
+
if (context.status !== "COMPLETED") return "pending";
|
|
2748
|
+
return PASSING_CONCLUSIONS.has(context.conclusion ?? "") ? "passing" : "failing";
|
|
2749
|
+
}
|
|
2750
|
+
if (context.state === "SUCCESS") return "passing";
|
|
2751
|
+
return context.state === "PENDING" || context.state === "EXPECTED" ? "pending" : "failing";
|
|
2752
|
+
}
|
|
2753
|
+
async function readPullRequestChecks(egress, repo, number33) {
|
|
2754
|
+
const response = await githubApi(egress, {
|
|
2755
|
+
operation: "github.pull.checks.get",
|
|
2756
|
+
method: "POST",
|
|
2757
|
+
path: "/graphql",
|
|
2758
|
+
body: {
|
|
2759
|
+
...PULL_REQUEST_CHECKS,
|
|
2760
|
+
variables: { name: repo.name, number: number33, owner: repo.owner }
|
|
2761
|
+
}
|
|
2762
|
+
});
|
|
2763
|
+
if (!response.ok) {
|
|
2764
|
+
throw new Error(
|
|
2765
|
+
`GitHub pull request checks lookup failed with HTTP ${response.status}`
|
|
2766
|
+
);
|
|
2767
|
+
}
|
|
2768
|
+
const pullRequest = checksResponseSchema.parse(response.body).data.repository.pullRequest;
|
|
2769
|
+
const rollup = pullRequest.commits.nodes[0]?.commit.statusCheckRollup;
|
|
2770
|
+
const checks = { failing: [], pending: [], passing: [] };
|
|
2771
|
+
for (const context of rollup?.contexts.nodes ?? []) {
|
|
2772
|
+
if (!context.isRequired) continue;
|
|
2773
|
+
checks[contextState(context)].push(
|
|
2774
|
+
context.__typename === "CheckRun" ? context.name : context.context
|
|
2775
|
+
);
|
|
2776
|
+
}
|
|
2777
|
+
return {
|
|
2778
|
+
required: checks.failing.length > 0 ? "failing" : checks.pending.length > 0 ? "pending" : checks.passing.length > 0 ? "passing" : "not_reported",
|
|
2779
|
+
...checks,
|
|
2780
|
+
...rollup?.contexts.pageInfo.hasNextPage ? { incomplete: true } : void 0,
|
|
2781
|
+
merge_state: pullRequest.mergeStateStatus,
|
|
2782
|
+
review_decision: pullRequest.reviewDecision,
|
|
2783
|
+
auto_merge: pullRequest.autoMergeRequest !== null
|
|
2784
|
+
};
|
|
2785
|
+
}
|
|
2206
2786
|
function createGitHubGetPullRequestTool(ctx) {
|
|
2207
|
-
return
|
|
2787
|
+
return definePluginTool9({
|
|
2208
2788
|
annotations: {
|
|
2209
2789
|
destructiveHint: false,
|
|
2210
2790
|
idempotentHint: true,
|
|
2211
2791
|
openWorldHint: true,
|
|
2212
2792
|
readOnlyHint: true
|
|
2213
2793
|
},
|
|
2214
|
-
description: "Get a GitHub pull request. Use this when an existing PR may need event monitoring; the result includes a subscribable hint when GitHub webhooks are configured.",
|
|
2215
|
-
inputSchema:
|
|
2216
|
-
outputSchema:
|
|
2794
|
+
description: "Get a GitHub pull request with its required checks and merge state. Use this when an existing PR may need event monitoring; the result includes a subscribable hint when GitHub webhooks are configured.",
|
|
2795
|
+
inputSchema: inputSchema7,
|
|
2796
|
+
outputSchema: outputSchema7,
|
|
2217
2797
|
async execute(input) {
|
|
2218
2798
|
const repo = parseRepo(input.repo);
|
|
2219
2799
|
const response = await githubApi(ctx.egress, {
|
|
@@ -2223,20 +2803,25 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2223
2803
|
if (!response.ok) {
|
|
2224
2804
|
const message = `GitHub pull request lookup failed with HTTP ${response.status}`;
|
|
2225
2805
|
if (response.status === 404) {
|
|
2226
|
-
throw new
|
|
2806
|
+
throw new PluginToolInputError12(message);
|
|
2227
2807
|
}
|
|
2228
2808
|
throw new Error(message);
|
|
2229
2809
|
}
|
|
2230
|
-
const providerResult =
|
|
2231
|
-
base:
|
|
2232
|
-
draft:
|
|
2233
|
-
head:
|
|
2234
|
-
html_url:
|
|
2235
|
-
merged:
|
|
2236
|
-
number:
|
|
2237
|
-
state:
|
|
2238
|
-
title:
|
|
2810
|
+
const providerResult = z14.object({
|
|
2811
|
+
base: z14.object({ ref: z14.string() }),
|
|
2812
|
+
draft: z14.boolean(),
|
|
2813
|
+
head: z14.object({ ref: z14.string(), sha: commitShaSchema2 }),
|
|
2814
|
+
html_url: z14.string(),
|
|
2815
|
+
merged: z14.boolean().optional().default(false),
|
|
2816
|
+
number: z14.number(),
|
|
2817
|
+
state: z14.string(),
|
|
2818
|
+
title: z14.string()
|
|
2239
2819
|
}).parse(response.body);
|
|
2820
|
+
const checks = await readPullRequestChecks(
|
|
2821
|
+
ctx.egress,
|
|
2822
|
+
repo,
|
|
2823
|
+
providerResult.number
|
|
2824
|
+
);
|
|
2240
2825
|
const subscribable = gitHubPullRequestSubscribable({
|
|
2241
2826
|
canSubscribe: ctx.events.canSubscribe,
|
|
2242
2827
|
number: providerResult.number,
|
|
@@ -2244,6 +2829,7 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2244
2829
|
});
|
|
2245
2830
|
const data = {
|
|
2246
2831
|
base: providerResult.base.ref,
|
|
2832
|
+
checks,
|
|
2247
2833
|
draft: providerResult.draft,
|
|
2248
2834
|
head: providerResult.head.ref,
|
|
2249
2835
|
head_sha: providerResult.head.sha.toLowerCase(),
|
|
@@ -2275,49 +2861,49 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2275
2861
|
|
|
2276
2862
|
// src/tools/get-release.ts
|
|
2277
2863
|
import {
|
|
2278
|
-
definePluginTool as
|
|
2279
|
-
pluginToolOutputSchema as
|
|
2864
|
+
definePluginTool as definePluginTool10,
|
|
2865
|
+
pluginToolOutputSchema as pluginToolOutputSchema10,
|
|
2280
2866
|
subscribableResourceSchema as subscribableResourceSchema6
|
|
2281
2867
|
} from "@sentry/junior-plugin-api";
|
|
2282
|
-
import * as
|
|
2283
|
-
var
|
|
2284
|
-
repo:
|
|
2285
|
-
tag:
|
|
2868
|
+
import * as z15 from "zod";
|
|
2869
|
+
var inputSchema8 = z15.object({
|
|
2870
|
+
repo: z15.string().describe('Repository in "owner/name" format.'),
|
|
2871
|
+
tag: z15.string().trim().min(1).describe(
|
|
2286
2872
|
"Optional release tag name. Omit to inspect and watch every published release in the repository."
|
|
2287
2873
|
).optional()
|
|
2288
2874
|
}).strict();
|
|
2289
|
-
var releaseSchema =
|
|
2290
|
-
created_at:
|
|
2291
|
-
draft:
|
|
2292
|
-
html_url:
|
|
2293
|
-
id:
|
|
2294
|
-
name:
|
|
2295
|
-
prerelease:
|
|
2296
|
-
published_at:
|
|
2297
|
-
tag_name:
|
|
2298
|
-
target_commitish:
|
|
2875
|
+
var releaseSchema = z15.object({
|
|
2876
|
+
created_at: z15.string(),
|
|
2877
|
+
draft: z15.boolean(),
|
|
2878
|
+
html_url: z15.string(),
|
|
2879
|
+
id: z15.number(),
|
|
2880
|
+
name: z15.string().nullable(),
|
|
2881
|
+
prerelease: z15.boolean(),
|
|
2882
|
+
published_at: z15.string().nullable(),
|
|
2883
|
+
tag_name: z15.string(),
|
|
2884
|
+
target_commitish: z15.string()
|
|
2299
2885
|
}).strict();
|
|
2300
|
-
var releaseSourceSchema =
|
|
2886
|
+
var releaseSourceSchema = z15.object({
|
|
2301
2887
|
release: releaseSchema.nullable(),
|
|
2302
|
-
repo:
|
|
2888
|
+
repo: z15.string(),
|
|
2303
2889
|
subscribable: subscribableResourceSchema6.optional(),
|
|
2304
|
-
tag:
|
|
2890
|
+
tag: z15.string().nullable()
|
|
2305
2891
|
}).strict();
|
|
2306
|
-
var
|
|
2892
|
+
var outputSchema8 = pluginToolOutputSchema10.merge(
|
|
2307
2893
|
releaseSourceSchema.extend({
|
|
2308
|
-
target:
|
|
2894
|
+
target: z15.literal("getRelease")
|
|
2309
2895
|
})
|
|
2310
2896
|
);
|
|
2311
|
-
var providerReleaseSchema =
|
|
2312
|
-
created_at:
|
|
2313
|
-
draft:
|
|
2314
|
-
html_url:
|
|
2315
|
-
id:
|
|
2316
|
-
name:
|
|
2317
|
-
prerelease:
|
|
2318
|
-
published_at:
|
|
2319
|
-
tag_name:
|
|
2320
|
-
target_commitish:
|
|
2897
|
+
var providerReleaseSchema = z15.object({
|
|
2898
|
+
created_at: z15.string(),
|
|
2899
|
+
draft: z15.boolean(),
|
|
2900
|
+
html_url: z15.string(),
|
|
2901
|
+
id: z15.number(),
|
|
2902
|
+
name: z15.string().nullable(),
|
|
2903
|
+
prerelease: z15.boolean(),
|
|
2904
|
+
published_at: z15.string().nullable(),
|
|
2905
|
+
tag_name: z15.string(),
|
|
2906
|
+
target_commitish: z15.string()
|
|
2321
2907
|
}).passthrough();
|
|
2322
2908
|
function mapRelease(providerRelease) {
|
|
2323
2909
|
return {
|
|
@@ -2333,7 +2919,7 @@ function mapRelease(providerRelease) {
|
|
|
2333
2919
|
};
|
|
2334
2920
|
}
|
|
2335
2921
|
function createGitHubGetReleaseTool(ctx) {
|
|
2336
|
-
return
|
|
2922
|
+
return definePluginTool10({
|
|
2337
2923
|
annotations: {
|
|
2338
2924
|
destructiveHint: false,
|
|
2339
2925
|
idempotentHint: true,
|
|
@@ -2341,8 +2927,8 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2341
2927
|
readOnlyHint: true
|
|
2342
2928
|
},
|
|
2343
2929
|
description: "Get a GitHub release for an exact repository, optionally limited to one tag. The result remains subscribable when no release exists yet, so use it before waiting for a published release. Omit the tag to watch every published release in the repository.",
|
|
2344
|
-
inputSchema:
|
|
2345
|
-
outputSchema:
|
|
2930
|
+
inputSchema: inputSchema8,
|
|
2931
|
+
outputSchema: outputSchema8,
|
|
2346
2932
|
async execute(input) {
|
|
2347
2933
|
const repo = parseRepo(input.repo);
|
|
2348
2934
|
const tag = input.tag?.trim() || void 0;
|
|
@@ -2395,30 +2981,30 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2395
2981
|
|
|
2396
2982
|
// src/tools/get-repository.ts
|
|
2397
2983
|
import {
|
|
2398
|
-
definePluginTool as
|
|
2399
|
-
PluginToolInputError as
|
|
2400
|
-
pluginToolOutputSchema as
|
|
2984
|
+
definePluginTool as definePluginTool11,
|
|
2985
|
+
PluginToolInputError as PluginToolInputError13,
|
|
2986
|
+
pluginToolOutputSchema as pluginToolOutputSchema11,
|
|
2401
2987
|
subscribableResourceSchema as subscribableResourceSchema7
|
|
2402
2988
|
} from "@sentry/junior-plugin-api";
|
|
2403
|
-
import * as
|
|
2404
|
-
var
|
|
2405
|
-
repo:
|
|
2989
|
+
import * as z16 from "zod";
|
|
2990
|
+
var inputSchema9 = z16.object({
|
|
2991
|
+
repo: z16.string().describe('Repository in "owner/name" format.')
|
|
2406
2992
|
}).strict();
|
|
2407
|
-
var repositorySchema =
|
|
2408
|
-
default_branch:
|
|
2409
|
-
description:
|
|
2410
|
-
full_name:
|
|
2411
|
-
private:
|
|
2993
|
+
var repositorySchema = z16.object({
|
|
2994
|
+
default_branch: z16.string(),
|
|
2995
|
+
description: z16.string().nullable(),
|
|
2996
|
+
full_name: z16.string(),
|
|
2997
|
+
private: z16.boolean(),
|
|
2412
2998
|
subscribable: subscribableResourceSchema7.optional(),
|
|
2413
|
-
url:
|
|
2999
|
+
url: z16.string()
|
|
2414
3000
|
});
|
|
2415
|
-
var
|
|
3001
|
+
var outputSchema9 = pluginToolOutputSchema11.merge(
|
|
2416
3002
|
repositorySchema.extend({
|
|
2417
|
-
target:
|
|
3003
|
+
target: z16.literal("getRepository")
|
|
2418
3004
|
})
|
|
2419
3005
|
);
|
|
2420
3006
|
function createGitHubGetRepositoryTool(ctx) {
|
|
2421
|
-
return
|
|
3007
|
+
return definePluginTool11({
|
|
2422
3008
|
annotations: {
|
|
2423
3009
|
destructiveHint: false,
|
|
2424
3010
|
idempotentHint: true,
|
|
@@ -2426,8 +3012,8 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2426
3012
|
readOnlyHint: true
|
|
2427
3013
|
},
|
|
2428
3014
|
description: "Get a GitHub repository. Use this when repository-wide issue activity may need event monitoring; the result includes a subscribable hint when GitHub webhooks are configured.",
|
|
2429
|
-
inputSchema:
|
|
2430
|
-
outputSchema:
|
|
3015
|
+
inputSchema: inputSchema9,
|
|
3016
|
+
outputSchema: outputSchema9,
|
|
2431
3017
|
async execute(input) {
|
|
2432
3018
|
const repo = parseRepo(input.repo);
|
|
2433
3019
|
const response = await githubApi(ctx.egress, {
|
|
@@ -2435,16 +3021,16 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2435
3021
|
path: repoPath(repo)
|
|
2436
3022
|
});
|
|
2437
3023
|
if (!response.ok) {
|
|
2438
|
-
throw new
|
|
3024
|
+
throw new PluginToolInputError13(
|
|
2439
3025
|
`GitHub repository lookup failed with HTTP ${response.status}`
|
|
2440
3026
|
);
|
|
2441
3027
|
}
|
|
2442
|
-
const providerResult =
|
|
2443
|
-
default_branch:
|
|
2444
|
-
description:
|
|
2445
|
-
full_name:
|
|
2446
|
-
html_url:
|
|
2447
|
-
private:
|
|
3028
|
+
const providerResult = z16.object({
|
|
3029
|
+
default_branch: z16.string(),
|
|
3030
|
+
description: z16.string().nullable(),
|
|
3031
|
+
full_name: z16.string(),
|
|
3032
|
+
html_url: z16.string(),
|
|
3033
|
+
private: z16.boolean()
|
|
2448
3034
|
}).parse(response.body);
|
|
2449
3035
|
const subscribable = gitHubRepositorySubscribable({
|
|
2450
3036
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2468,27 +3054,27 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2468
3054
|
|
|
2469
3055
|
// src/tools/get-status.ts
|
|
2470
3056
|
import {
|
|
2471
|
-
definePluginTool as
|
|
2472
|
-
pluginToolOutputSchema as
|
|
3057
|
+
definePluginTool as definePluginTool12,
|
|
3058
|
+
pluginToolOutputSchema as pluginToolOutputSchema12
|
|
2473
3059
|
} from "@sentry/junior-plugin-api";
|
|
2474
|
-
import * as
|
|
3060
|
+
import * as z18 from "zod";
|
|
2475
3061
|
|
|
2476
3062
|
// src/github-status.ts
|
|
2477
|
-
import * as
|
|
3063
|
+
import * as z17 from "zod";
|
|
2478
3064
|
var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
|
|
2479
3065
|
var GITHUB_STATUS_TTL_MS = 60 * 1e3;
|
|
2480
3066
|
var GITHUB_STATUS_TIMEOUT_MS = 5e3;
|
|
2481
|
-
var incidentsResponseSchema =
|
|
2482
|
-
incidents:
|
|
2483
|
-
|
|
2484
|
-
components:
|
|
2485
|
-
created_at:
|
|
2486
|
-
impact:
|
|
2487
|
-
name:
|
|
2488
|
-
resolved_at:
|
|
2489
|
-
shortlink:
|
|
2490
|
-
started_at:
|
|
2491
|
-
status:
|
|
3067
|
+
var incidentsResponseSchema = z17.object({
|
|
3068
|
+
incidents: z17.array(
|
|
3069
|
+
z17.object({
|
|
3070
|
+
components: z17.array(z17.object({ name: z17.string() })).default([]),
|
|
3071
|
+
created_at: z17.string(),
|
|
3072
|
+
impact: z17.string(),
|
|
3073
|
+
name: z17.string(),
|
|
3074
|
+
resolved_at: z17.string().nullable(),
|
|
3075
|
+
shortlink: z17.string(),
|
|
3076
|
+
started_at: z17.string().nullable().optional(),
|
|
3077
|
+
status: z17.string()
|
|
2492
3078
|
})
|
|
2493
3079
|
)
|
|
2494
3080
|
});
|
|
@@ -2530,22 +3116,22 @@ async function loadGitHubStatusIncidents(cache, withinMs) {
|
|
|
2530
3116
|
|
|
2531
3117
|
// src/tools/get-status.ts
|
|
2532
3118
|
var RECENT_INCIDENT_MS = 24 * 60 * 60 * 1e3;
|
|
2533
|
-
var
|
|
2534
|
-
var incidentSchema =
|
|
2535
|
-
components:
|
|
2536
|
-
impact:
|
|
2537
|
-
name:
|
|
2538
|
-
resolved_at:
|
|
2539
|
-
started_at:
|
|
2540
|
-
status:
|
|
2541
|
-
url:
|
|
3119
|
+
var inputSchema10 = z18.object({}).strict();
|
|
3120
|
+
var incidentSchema = z18.object({
|
|
3121
|
+
components: z18.array(z18.string()),
|
|
3122
|
+
impact: z18.string(),
|
|
3123
|
+
name: z18.string(),
|
|
3124
|
+
resolved_at: z18.string().optional(),
|
|
3125
|
+
started_at: z18.string(),
|
|
3126
|
+
status: z18.string(),
|
|
3127
|
+
url: z18.string()
|
|
2542
3128
|
});
|
|
2543
|
-
var
|
|
2544
|
-
target:
|
|
2545
|
-
incidents:
|
|
3129
|
+
var outputSchema10 = pluginToolOutputSchema12.extend({
|
|
3130
|
+
target: z18.literal("getStatus"),
|
|
3131
|
+
incidents: z18.array(incidentSchema)
|
|
2546
3132
|
});
|
|
2547
3133
|
function createGitHubGetStatusTool(ctx) {
|
|
2548
|
-
return
|
|
3134
|
+
return definePluginTool12({
|
|
2549
3135
|
annotations: {
|
|
2550
3136
|
destructiveHint: false,
|
|
2551
3137
|
idempotentHint: true,
|
|
@@ -2553,8 +3139,8 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2553
3139
|
readOnlyHint: true
|
|
2554
3140
|
},
|
|
2555
3141
|
description: "List GitHub incidents from githubstatus.com that are open or were resolved in the last 24 hours, with their affected components. Use when a GitHub request fails with a 5xx, a timeout, or a dropped connection, or when checks stay queued or fail with no cause in the logs.",
|
|
2556
|
-
inputSchema:
|
|
2557
|
-
outputSchema:
|
|
3142
|
+
inputSchema: inputSchema10,
|
|
3143
|
+
outputSchema: outputSchema10,
|
|
2558
3144
|
async execute() {
|
|
2559
3145
|
const incidents = await loadGitHubStatusIncidents(
|
|
2560
3146
|
ctx.cache,
|
|
@@ -2577,55 +3163,55 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2577
3163
|
|
|
2578
3164
|
// src/tools/update-issue.ts
|
|
2579
3165
|
import {
|
|
2580
|
-
definePluginTool as
|
|
2581
|
-
PluginToolInputError as
|
|
2582
|
-
pluginToolOutputSchema as
|
|
3166
|
+
definePluginTool as definePluginTool13,
|
|
3167
|
+
PluginToolInputError as PluginToolInputError14,
|
|
3168
|
+
pluginToolOutputSchema as pluginToolOutputSchema13,
|
|
2583
3169
|
subscribableResourceSchema as subscribableResourceSchema8
|
|
2584
3170
|
} from "@sentry/junior-plugin-api";
|
|
2585
|
-
import * as
|
|
2586
|
-
var
|
|
2587
|
-
repo:
|
|
2588
|
-
number:
|
|
2589
|
-
title:
|
|
2590
|
-
body:
|
|
3171
|
+
import * as z19 from "zod";
|
|
3172
|
+
var inputSchema11 = z19.object({
|
|
3173
|
+
repo: z19.string().describe('Repository in "owner/name" format.'),
|
|
3174
|
+
number: z19.number().int().positive().describe("Issue number."),
|
|
3175
|
+
title: z19.string().trim().min(1).optional().describe("Replacement issue title."),
|
|
3176
|
+
body: z19.string().optional().describe(
|
|
2591
3177
|
"Replacement issue body. The runtime appends requester attribution and the conversation footer."
|
|
2592
3178
|
),
|
|
2593
|
-
state:
|
|
2594
|
-
assign_requester:
|
|
3179
|
+
state: z19.enum(["open", "closed"]).optional().describe("Replacement issue state."),
|
|
3180
|
+
assign_requester: z19.boolean().optional().describe(
|
|
2595
3181
|
"Set true to add the requester's linked GitHub account as an assignee. Other assignees stay."
|
|
2596
3182
|
)
|
|
2597
3183
|
}).strict().refine(
|
|
2598
3184
|
({ title, body, state, assign_requester }) => title !== void 0 || body !== void 0 || state !== void 0 || assign_requester === true,
|
|
2599
3185
|
{ message: "At least one issue field must be provided." }
|
|
2600
3186
|
);
|
|
2601
|
-
var issueSchema2 =
|
|
2602
|
-
assignees:
|
|
2603
|
-
body:
|
|
2604
|
-
number:
|
|
2605
|
-
state:
|
|
3187
|
+
var issueSchema2 = z19.object({
|
|
3188
|
+
assignees: z19.array(z19.string()),
|
|
3189
|
+
body: z19.string().nullable(),
|
|
3190
|
+
number: z19.number(),
|
|
3191
|
+
state: z19.string(),
|
|
2606
3192
|
subscribable: subscribableResourceSchema8.optional(),
|
|
2607
|
-
title:
|
|
2608
|
-
url:
|
|
3193
|
+
title: z19.string(),
|
|
3194
|
+
url: z19.string()
|
|
2609
3195
|
});
|
|
2610
|
-
var
|
|
3196
|
+
var outputSchema11 = pluginToolOutputSchema13.merge(
|
|
2611
3197
|
issueSchema2.extend({
|
|
2612
|
-
target:
|
|
3198
|
+
target: z19.literal("updateIssue")
|
|
2613
3199
|
})
|
|
2614
3200
|
);
|
|
2615
|
-
var providerIssueSchema2 =
|
|
2616
|
-
assignees:
|
|
2617
|
-
body:
|
|
2618
|
-
html_url:
|
|
2619
|
-
number:
|
|
2620
|
-
state:
|
|
2621
|
-
title:
|
|
3201
|
+
var providerIssueSchema2 = z19.object({
|
|
3202
|
+
assignees: z19.array(z19.object({ login: z19.string() })).nullish().transform((assignees) => assignees?.map(({ login: login2 }) => login2) ?? []),
|
|
3203
|
+
body: z19.string().nullable().optional().default(null),
|
|
3204
|
+
html_url: z19.string(),
|
|
3205
|
+
number: z19.number(),
|
|
3206
|
+
state: z19.string(),
|
|
3207
|
+
title: z19.string()
|
|
2622
3208
|
});
|
|
2623
3209
|
function nonEmptyString4(value, name) {
|
|
2624
|
-
if (!value?.trim()) throw new
|
|
3210
|
+
if (!value?.trim()) throw new PluginToolInputError14(`${name} is required`);
|
|
2625
3211
|
return value.trim();
|
|
2626
3212
|
}
|
|
2627
3213
|
function createGitHubUpdateIssueTool(ctx) {
|
|
2628
|
-
return
|
|
3214
|
+
return definePluginTool13({
|
|
2629
3215
|
annotations: {
|
|
2630
3216
|
destructiveHint: true,
|
|
2631
3217
|
idempotentHint: true,
|
|
@@ -2633,12 +3219,12 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2633
3219
|
readOnlyHint: false
|
|
2634
3220
|
},
|
|
2635
3221
|
description: "Update an existing GitHub issue's title, body, or open/closed state, or assign it to the requester. Use this instead of raw GitHub API calls when changing issue metadata.",
|
|
2636
|
-
inputSchema:
|
|
2637
|
-
outputSchema:
|
|
3222
|
+
inputSchema: inputSchema11,
|
|
3223
|
+
outputSchema: outputSchema11,
|
|
2638
3224
|
async execute(input) {
|
|
2639
|
-
const parsedInput =
|
|
3225
|
+
const parsedInput = inputSchema11.safeParse(input);
|
|
2640
3226
|
if (!parsedInput.success) {
|
|
2641
|
-
throw new
|
|
3227
|
+
throw new PluginToolInputError14("Invalid GitHub updateIssue input.", {
|
|
2642
3228
|
cause: parsedInput.error
|
|
2643
3229
|
});
|
|
2644
3230
|
}
|
|
@@ -2647,7 +3233,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2647
3233
|
const requester = update.body !== void 0 || update.assign_requester ? await resolveGitHubRequester(ctx) : void 0;
|
|
2648
3234
|
const assignee = update.assign_requester ? linkedGitHubLogin(requester?.user) : void 0;
|
|
2649
3235
|
if (update.assign_requester && !assignee) {
|
|
2650
|
-
throw new
|
|
3236
|
+
throw new PluginToolInputError14(
|
|
2651
3237
|
"The requester has no linked GitHub account, so Junior cannot assign the issue to them."
|
|
2652
3238
|
);
|
|
2653
3239
|
}
|
|
@@ -2697,7 +3283,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2697
3283
|
if (!response.ok) {
|
|
2698
3284
|
const message = `GitHub issue assignment failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`;
|
|
2699
3285
|
if (response.status === 404 || response.status === 422) {
|
|
2700
|
-
throw new
|
|
3286
|
+
throw new PluginToolInputError14(message);
|
|
2701
3287
|
}
|
|
2702
3288
|
throw new Error(message);
|
|
2703
3289
|
}
|
|
@@ -2706,7 +3292,7 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2706
3292
|
if (assignee && !providerResult.assignees.some(
|
|
2707
3293
|
(login2) => login2.toLowerCase() === assignee.toLowerCase()
|
|
2708
3294
|
)) {
|
|
2709
|
-
throw new
|
|
3295
|
+
throw new PluginToolInputError14(
|
|
2710
3296
|
`GitHub did not assign @${assignee} to the issue. They may not have access to ${repo.ref}.`
|
|
2711
3297
|
);
|
|
2712
3298
|
}
|
|
@@ -2740,73 +3326,139 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2740
3326
|
});
|
|
2741
3327
|
}
|
|
2742
3328
|
|
|
3329
|
+
// src/tools/update-issue-comment.ts
|
|
3330
|
+
import {
|
|
3331
|
+
definePluginTool as definePluginTool14,
|
|
3332
|
+
PluginToolInputError as PluginToolInputError15,
|
|
3333
|
+
pluginToolOutputSchema as pluginToolOutputSchema14
|
|
3334
|
+
} from "@sentry/junior-plugin-api";
|
|
3335
|
+
import * as z20 from "zod";
|
|
3336
|
+
var inputSchema12 = z20.object({
|
|
3337
|
+
repo: z20.string().describe('Repository in "owner/name" format.'),
|
|
3338
|
+
comment_id: z20.number().int().positive().describe("Issue comment id, as returned by github_commentOnIssue."),
|
|
3339
|
+
body: z20.string().trim().min(1).describe("Replacement comment text.")
|
|
3340
|
+
}).strict();
|
|
3341
|
+
var outputSchema12 = pluginToolOutputSchema14.extend({
|
|
3342
|
+
target: z20.literal("updateIssueComment"),
|
|
3343
|
+
repo: z20.string(),
|
|
3344
|
+
comment_id: z20.number(),
|
|
3345
|
+
url: z20.string()
|
|
3346
|
+
});
|
|
3347
|
+
function createGitHubUpdateIssueCommentTool(egress, botEmail) {
|
|
3348
|
+
return definePluginTool14({
|
|
3349
|
+
annotations: {
|
|
3350
|
+
destructiveHint: true,
|
|
3351
|
+
idempotentHint: true,
|
|
3352
|
+
openWorldHint: true,
|
|
3353
|
+
readOnlyHint: false
|
|
3354
|
+
},
|
|
3355
|
+
description: "Replace the text of a GitHub issue or pull request conversation comment that you posted, for example to update a progress comment. Only works on your own comments.",
|
|
3356
|
+
inputSchema: inputSchema12,
|
|
3357
|
+
outputSchema: outputSchema12,
|
|
3358
|
+
async execute(input) {
|
|
3359
|
+
const repo = parseRepo(input.repo);
|
|
3360
|
+
const botUserId = botUserIdFromEmail(botEmail);
|
|
3361
|
+
if (botUserId === void 0) {
|
|
3362
|
+
throw new Error("GitHub App bot identity is not configured.");
|
|
3363
|
+
}
|
|
3364
|
+
const path = `${repoPath(repo)}/issues/comments/${input.comment_id}`;
|
|
3365
|
+
const lookup = await githubApi(egress, {
|
|
3366
|
+
operation: "github.issue.comment.get",
|
|
3367
|
+
path
|
|
3368
|
+
});
|
|
3369
|
+
if (!lookup.ok) {
|
|
3370
|
+
const message = `GitHub issue comment lookup failed with HTTP ${lookup.status}: ${githubErrorMessage(lookup.body)}`;
|
|
3371
|
+
if (lookup.status === 404) throw new PluginToolInputError15(message);
|
|
3372
|
+
throw new Error(message);
|
|
3373
|
+
}
|
|
3374
|
+
const author = z20.object({ user: z20.object({ id: z20.number() }).nullable() }).safeParse(lookup.body);
|
|
3375
|
+
if (!author.success || author.data.user?.id !== botUserId) {
|
|
3376
|
+
throw new PluginToolInputError15(
|
|
3377
|
+
"This bot can only edit issue comments it posted."
|
|
3378
|
+
);
|
|
3379
|
+
}
|
|
3380
|
+
const response = await githubApi(egress, {
|
|
3381
|
+
operation: "github.issue.comment.update",
|
|
3382
|
+
method: "PATCH",
|
|
3383
|
+
path,
|
|
3384
|
+
body: { body: input.body }
|
|
3385
|
+
});
|
|
3386
|
+
if (!response.ok) {
|
|
3387
|
+
const message = `GitHub issue comment update failed with HTTP ${response.status}: ${githubErrorMessage(response.body)}`;
|
|
3388
|
+
if (response.status === 404 || response.status === 422) {
|
|
3389
|
+
throw new PluginToolInputError15(message);
|
|
3390
|
+
}
|
|
3391
|
+
throw new Error(message);
|
|
3392
|
+
}
|
|
3393
|
+
const comment = z20.object({ id: z20.number(), html_url: z20.string() }).parse(response.body);
|
|
3394
|
+
return {
|
|
3395
|
+
target: "updateIssueComment",
|
|
3396
|
+
repo: repo.ref,
|
|
3397
|
+
comment_id: comment.id,
|
|
3398
|
+
url: comment.html_url
|
|
3399
|
+
};
|
|
3400
|
+
}
|
|
3401
|
+
});
|
|
3402
|
+
}
|
|
3403
|
+
|
|
2743
3404
|
// src/tools/update-pull-request.ts
|
|
2744
3405
|
import {
|
|
2745
|
-
definePluginTool as
|
|
2746
|
-
PluginToolInputError as
|
|
2747
|
-
pluginToolOutputSchema as
|
|
3406
|
+
definePluginTool as definePluginTool15,
|
|
3407
|
+
PluginToolInputError as PluginToolInputError16,
|
|
3408
|
+
pluginToolOutputSchema as pluginToolOutputSchema15
|
|
2748
3409
|
} from "@sentry/junior-plugin-api";
|
|
2749
|
-
import * as
|
|
3410
|
+
import * as z21 from "zod";
|
|
2750
3411
|
import { subscribableResourceSchema as subscribableResourceSchema9 } from "@sentry/junior-plugin-api";
|
|
2751
|
-
var
|
|
2752
|
-
repo:
|
|
2753
|
-
number:
|
|
2754
|
-
title:
|
|
2755
|
-
body:
|
|
3412
|
+
var inputSchema13 = z21.object({
|
|
3413
|
+
repo: z21.string().describe('Repository in "owner/name" format.'),
|
|
3414
|
+
number: z21.number().int().positive().describe("Pull request number."),
|
|
3415
|
+
title: z21.string().trim().min(1).optional().describe("Replacement pull request title."),
|
|
3416
|
+
body: z21.string().optional().describe(
|
|
2756
3417
|
"Replacement pull request body. The runtime appends requester attribution and the conversation footer."
|
|
2757
3418
|
),
|
|
2758
|
-
base:
|
|
2759
|
-
state:
|
|
2760
|
-
draft:
|
|
3419
|
+
base: z21.string().trim().min(1).optional().describe("Replacement base branch."),
|
|
3420
|
+
state: z21.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
|
|
3421
|
+
draft: z21.boolean().optional().describe(
|
|
2761
3422
|
"Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
|
|
2762
3423
|
)
|
|
2763
3424
|
}).strict().refine(
|
|
2764
3425
|
({ title, body, base, state, draft }) => title !== void 0 || body !== void 0 || base !== void 0 || state !== void 0 || draft !== void 0,
|
|
2765
3426
|
{ message: "At least one pull request field must be provided." }
|
|
2766
3427
|
);
|
|
2767
|
-
var
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
};
|
|
2771
|
-
var CONVERT_TO_DRAFT = {
|
|
2772
|
-
operationName: "ConvertPullRequestToDraft",
|
|
2773
|
-
query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
|
|
2774
|
-
};
|
|
2775
|
-
var draftMutationResponseSchema = z18.object({
|
|
2776
|
-
data: z18.object({
|
|
2777
|
-
result: z18.object({ pullRequest: z18.object({ isDraft: z18.boolean() }) })
|
|
3428
|
+
var draftMutationResponseSchema = z21.object({
|
|
3429
|
+
data: z21.object({
|
|
3430
|
+
result: z21.object({ pullRequest: z21.object({ isDraft: z21.boolean() }) })
|
|
2778
3431
|
})
|
|
2779
3432
|
});
|
|
2780
|
-
var pullRequestSchema2 =
|
|
2781
|
-
base:
|
|
2782
|
-
body:
|
|
2783
|
-
draft:
|
|
2784
|
-
number:
|
|
2785
|
-
state:
|
|
3433
|
+
var pullRequestSchema2 = z21.object({
|
|
3434
|
+
base: z21.string(),
|
|
3435
|
+
body: z21.string().nullable(),
|
|
3436
|
+
draft: z21.boolean(),
|
|
3437
|
+
number: z21.number(),
|
|
3438
|
+
state: z21.string(),
|
|
2786
3439
|
subscribable: subscribableResourceSchema9.optional(),
|
|
2787
|
-
title:
|
|
2788
|
-
url:
|
|
3440
|
+
title: z21.string(),
|
|
3441
|
+
url: z21.string()
|
|
2789
3442
|
});
|
|
2790
|
-
var
|
|
3443
|
+
var outputSchema13 = pluginToolOutputSchema15.merge(
|
|
2791
3444
|
pullRequestSchema2.extend({
|
|
2792
|
-
target:
|
|
3445
|
+
target: z21.literal("updatePullRequest")
|
|
2793
3446
|
})
|
|
2794
3447
|
);
|
|
2795
3448
|
function nonEmptyString5(value, name) {
|
|
2796
3449
|
if (!value?.trim()) {
|
|
2797
|
-
throw new
|
|
3450
|
+
throw new PluginToolInputError16(`${name} is required`);
|
|
2798
3451
|
}
|
|
2799
3452
|
return value.trim();
|
|
2800
3453
|
}
|
|
2801
3454
|
async function setPullRequestDraft(input) {
|
|
2802
|
-
const mutation = input.draft ?
|
|
3455
|
+
const mutation = input.draft ? CONVERT_PULL_REQUEST_TO_DRAFT : MARK_PULL_REQUEST_READY_FOR_REVIEW;
|
|
2803
3456
|
const response = await githubApi(input.egress, {
|
|
2804
3457
|
operation: `github.pull.draft.update:${input.repo.toLowerCase()}`,
|
|
2805
3458
|
method: "POST",
|
|
2806
3459
|
path: "/graphql",
|
|
2807
3460
|
body: {
|
|
2808
|
-
|
|
2809
|
-
query: mutation.query,
|
|
3461
|
+
...mutation,
|
|
2810
3462
|
variables: { id: input.nodeId }
|
|
2811
3463
|
}
|
|
2812
3464
|
});
|
|
@@ -2819,8 +3471,8 @@ async function setPullRequestDraft(input) {
|
|
|
2819
3471
|
}
|
|
2820
3472
|
return isDraft;
|
|
2821
3473
|
}
|
|
2822
|
-
function createGitHubUpdatePullRequestTool(ctx) {
|
|
2823
|
-
return
|
|
3474
|
+
function createGitHubUpdatePullRequestTool(ctx, descriptionDecider) {
|
|
3475
|
+
return definePluginTool15({
|
|
2824
3476
|
annotations: {
|
|
2825
3477
|
destructiveHint: true,
|
|
2826
3478
|
idempotentHint: true,
|
|
@@ -2828,17 +3480,20 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2828
3480
|
readOnlyHint: false
|
|
2829
3481
|
},
|
|
2830
3482
|
description: "Update an existing GitHub pull request's title, body, base branch, open/closed state, or draft state. Use this instead of raw GitHub API calls when changing PR metadata or marking a PR ready for review.",
|
|
2831
|
-
inputSchema:
|
|
2832
|
-
outputSchema:
|
|
3483
|
+
inputSchema: inputSchema13,
|
|
3484
|
+
outputSchema: outputSchema13,
|
|
2833
3485
|
async execute(input) {
|
|
2834
|
-
const parsedInput =
|
|
3486
|
+
const parsedInput = inputSchema13.safeParse(input);
|
|
2835
3487
|
if (!parsedInput.success) {
|
|
2836
|
-
throw new
|
|
3488
|
+
throw new PluginToolInputError16(
|
|
2837
3489
|
"Invalid GitHub updatePullRequest input.",
|
|
2838
3490
|
{ cause: parsedInput.error }
|
|
2839
3491
|
);
|
|
2840
3492
|
}
|
|
2841
3493
|
const update = parsedInput.data;
|
|
3494
|
+
if (descriptionDecider && update.body !== void 0) {
|
|
3495
|
+
await checkPullRequestDescription(descriptionDecider, update.body);
|
|
3496
|
+
}
|
|
2842
3497
|
const repo = parseRepo(update.repo);
|
|
2843
3498
|
const requester = await resolveGitHubRequester(ctx);
|
|
2844
3499
|
const currentBody = update.body !== void 0 ? await readGitHubBody(ctx.egress, {
|
|
@@ -2870,20 +3525,22 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2870
3525
|
});
|
|
2871
3526
|
const parsed = response.body;
|
|
2872
3527
|
if (!response.ok) {
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
3528
|
+
const message = `GitHub pull request update failed with HTTP ${response.status}: ${githubErrorMessage(parsed)}`;
|
|
3529
|
+
if (response.status === 404 || response.status === 422) {
|
|
3530
|
+
throw new PluginToolInputError16(message);
|
|
3531
|
+
}
|
|
3532
|
+
throw new Error(message);
|
|
2876
3533
|
}
|
|
2877
|
-
const providerResult =
|
|
2878
|
-
base:
|
|
2879
|
-
body:
|
|
2880
|
-
draft:
|
|
2881
|
-
html_url:
|
|
2882
|
-
merged:
|
|
2883
|
-
node_id:
|
|
2884
|
-
number:
|
|
2885
|
-
state:
|
|
2886
|
-
title:
|
|
3534
|
+
const providerResult = z21.object({
|
|
3535
|
+
base: z21.object({ ref: z21.string() }),
|
|
3536
|
+
body: z21.string().nullable().optional().default(null),
|
|
3537
|
+
draft: z21.boolean(),
|
|
3538
|
+
html_url: z21.string(),
|
|
3539
|
+
merged: z21.boolean(),
|
|
3540
|
+
node_id: z21.string().optional(),
|
|
3541
|
+
number: z21.number(),
|
|
3542
|
+
state: z21.string(),
|
|
3543
|
+
title: z21.string()
|
|
2887
3544
|
}).parse(parsed);
|
|
2888
3545
|
if (update.draft !== void 0 && update.draft !== providerResult.draft) {
|
|
2889
3546
|
if (!providerResult.node_id) {
|
|
@@ -2944,11 +3601,11 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2944
3601
|
|
|
2945
3602
|
// src/tools/update-pull-request-feedback.ts
|
|
2946
3603
|
import {
|
|
2947
|
-
definePluginTool as
|
|
2948
|
-
PluginToolInputError as
|
|
2949
|
-
pluginToolOutputSchema as
|
|
3604
|
+
definePluginTool as definePluginTool16,
|
|
3605
|
+
PluginToolInputError as PluginToolInputError17,
|
|
3606
|
+
pluginToolOutputSchema as pluginToolOutputSchema16
|
|
2950
3607
|
} from "@sentry/junior-plugin-api";
|
|
2951
|
-
import * as
|
|
3608
|
+
import * as z22 from "zod";
|
|
2952
3609
|
var STATUS_TO_REACTION_CONTENT = {
|
|
2953
3610
|
reviewing: "eyes",
|
|
2954
3611
|
addressed: "+1",
|
|
@@ -2968,24 +3625,24 @@ var REST_REACTION_CONTENT = new Map(
|
|
|
2968
3625
|
rest
|
|
2969
3626
|
])
|
|
2970
3627
|
);
|
|
2971
|
-
var
|
|
2972
|
-
repo:
|
|
2973
|
-
comment_kind:
|
|
3628
|
+
var inputSchema14 = z22.object({
|
|
3629
|
+
repo: z22.string().describe('Repository in "owner/name" format.'),
|
|
3630
|
+
comment_kind: z22.enum(["conversation", "review", "review_body"]).describe(
|
|
2974
3631
|
'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment, "review_body" for the body of a submitted review.'
|
|
2975
3632
|
),
|
|
2976
|
-
comment_id:
|
|
3633
|
+
comment_id: z22.number().int().positive().describe(
|
|
2977
3634
|
"GitHub comment id (conversation comment id, inline review comment id, or review id)."
|
|
2978
3635
|
),
|
|
2979
|
-
pull_request:
|
|
2980
|
-
status:
|
|
3636
|
+
pull_request: z22.number().int().positive().describe("Pull request number that the comment is on."),
|
|
3637
|
+
status: z22.enum(["addressed", "declined"]).describe(
|
|
2981
3638
|
"Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
|
|
2982
3639
|
)
|
|
2983
3640
|
}).strict();
|
|
2984
|
-
var
|
|
2985
|
-
target:
|
|
2986
|
-
repo:
|
|
2987
|
-
comment_id:
|
|
2988
|
-
status:
|
|
3641
|
+
var outputSchema14 = pluginToolOutputSchema16.extend({
|
|
3642
|
+
target: z22.literal("updatePullRequestFeedback"),
|
|
3643
|
+
repo: z22.string(),
|
|
3644
|
+
comment_id: z22.number(),
|
|
3645
|
+
status: z22.enum(["addressed", "declined"])
|
|
2989
3646
|
});
|
|
2990
3647
|
function pullRequestCommentPath(input) {
|
|
2991
3648
|
const segment = input.commentKind === "conversation" ? "issues" : "pulls";
|
|
@@ -2997,10 +3654,10 @@ function pullRequestCommentReactionsPath(input) {
|
|
|
2997
3654
|
function pullRequestFeedbackReactionContent(status) {
|
|
2998
3655
|
return STATUS_TO_REACTION_CONTENT[status];
|
|
2999
3656
|
}
|
|
3000
|
-
var reactionSchema =
|
|
3001
|
-
id:
|
|
3002
|
-
content:
|
|
3003
|
-
user:
|
|
3657
|
+
var reactionSchema = z22.object({
|
|
3658
|
+
id: z22.number(),
|
|
3659
|
+
content: z22.string(),
|
|
3660
|
+
user: z22.object({ id: z22.number() }).nullable()
|
|
3004
3661
|
});
|
|
3005
3662
|
async function commentParentNumber(egress, input) {
|
|
3006
3663
|
const commentResponse = await githubApi(egress, {
|
|
@@ -3010,25 +3667,25 @@ async function commentParentNumber(egress, input) {
|
|
|
3010
3667
|
const commentPayload = commentResponse.body;
|
|
3011
3668
|
if (!commentResponse.ok) {
|
|
3012
3669
|
const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${githubErrorMessage(commentPayload)}`;
|
|
3013
|
-
if (commentResponse.status === 404) throw new
|
|
3670
|
+
if (commentResponse.status === 404) throw new PluginToolInputError17(message);
|
|
3014
3671
|
throw new Error(message);
|
|
3015
3672
|
}
|
|
3016
|
-
const comment =
|
|
3017
|
-
issue_url:
|
|
3018
|
-
pull_request_url:
|
|
3673
|
+
const comment = z22.object({
|
|
3674
|
+
issue_url: z22.string().optional(),
|
|
3675
|
+
pull_request_url: z22.string().optional()
|
|
3019
3676
|
}).safeParse(commentPayload);
|
|
3020
3677
|
const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
|
|
3021
|
-
const
|
|
3022
|
-
if (!
|
|
3678
|
+
const number33 = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
|
|
3679
|
+
if (!number33) {
|
|
3023
3680
|
throw new Error("GitHub comment did not name its issue or pull request.");
|
|
3024
3681
|
}
|
|
3025
|
-
return
|
|
3682
|
+
return number33;
|
|
3026
3683
|
}
|
|
3027
3684
|
async function assertBotAuthoredPullRequest(egress, input) {
|
|
3028
|
-
const { number:
|
|
3685
|
+
const { number: number33 } = input;
|
|
3029
3686
|
const pullResponse = await githubApi(egress, {
|
|
3030
3687
|
operation: "github.pull.get",
|
|
3031
|
-
path: `${repoPath(input)}/pulls/${
|
|
3688
|
+
path: `${repoPath(input)}/pulls/${number33}`
|
|
3032
3689
|
});
|
|
3033
3690
|
const pullPayload = pullResponse.body;
|
|
3034
3691
|
if (!pullResponse.ok && pullResponse.status !== 404) {
|
|
@@ -3036,9 +3693,9 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
3036
3693
|
`GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubErrorMessage(pullPayload)}`
|
|
3037
3694
|
);
|
|
3038
3695
|
}
|
|
3039
|
-
const pull =
|
|
3696
|
+
const pull = z22.object({ user: z22.object({ id: z22.number() }).nullable() }).safeParse(pullPayload);
|
|
3040
3697
|
if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
|
|
3041
|
-
throw new
|
|
3698
|
+
throw new PluginToolInputError17(
|
|
3042
3699
|
"This bot can only set feedback status on comments on pull requests it authored."
|
|
3043
3700
|
);
|
|
3044
3701
|
}
|
|
@@ -3049,34 +3706,14 @@ function pullRequestReviewPath(input) {
|
|
|
3049
3706
|
function graphqlReactionContent(content) {
|
|
3050
3707
|
return GRAPHQL_REACTION_CONTENT[content] ?? content;
|
|
3051
3708
|
}
|
|
3052
|
-
var
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
}
|
|
3061
|
-
}`;
|
|
3062
|
-
var REVIEW_REACTIONS_QUERY = `query ReviewReactions($subjectId: ID!) {
|
|
3063
|
-
node(id: $subjectId) {
|
|
3064
|
-
... on PullRequestReview {
|
|
3065
|
-
reactionGroups {
|
|
3066
|
-
content
|
|
3067
|
-
reactors(first: 100) { nodes { ... on Bot { databaseId } } }
|
|
3068
|
-
}
|
|
3069
|
-
}
|
|
3070
|
-
}
|
|
3071
|
-
}`;
|
|
3072
|
-
var reviewReactionsSchema = z19.object({
|
|
3073
|
-
data: z19.object({
|
|
3074
|
-
node: z19.object({
|
|
3075
|
-
reactionGroups: z19.array(
|
|
3076
|
-
z19.object({
|
|
3077
|
-
content: z19.string(),
|
|
3078
|
-
reactors: z19.object({
|
|
3079
|
-
nodes: z19.array(z19.object({ databaseId: z19.number().optional() }))
|
|
3709
|
+
var reviewReactionsSchema = z22.object({
|
|
3710
|
+
data: z22.object({
|
|
3711
|
+
node: z22.object({
|
|
3712
|
+
reactionGroups: z22.array(
|
|
3713
|
+
z22.object({
|
|
3714
|
+
content: z22.string(),
|
|
3715
|
+
reactors: z22.object({
|
|
3716
|
+
nodes: z22.array(z22.object({ databaseId: z22.number().optional() }))
|
|
3080
3717
|
})
|
|
3081
3718
|
})
|
|
3082
3719
|
)
|
|
@@ -3086,7 +3723,7 @@ var reviewReactionsSchema = z19.object({
|
|
|
3086
3723
|
async function commentReactions(egress, input) {
|
|
3087
3724
|
const parentNumber = await commentParentNumber(egress, input);
|
|
3088
3725
|
if (parentNumber !== String(input.pullRequest)) {
|
|
3089
|
-
throw new
|
|
3726
|
+
throw new PluginToolInputError17(
|
|
3090
3727
|
`GitHub comment ${input.commentId} is not on pull request ${input.pullRequest}.`
|
|
3091
3728
|
);
|
|
3092
3729
|
}
|
|
@@ -3096,7 +3733,7 @@ async function commentReactions(egress, input) {
|
|
|
3096
3733
|
operation: "github.pull.comment-reaction.list",
|
|
3097
3734
|
path: `${path}?per_page=100`
|
|
3098
3735
|
}),
|
|
3099
|
-
botReactions: (body) =>
|
|
3736
|
+
botReactions: (body) => z22.array(reactionSchema).parse(body).filter((reaction) => reaction.user?.id === input.botUserId),
|
|
3100
3737
|
remove: (reaction) => githubApi(egress, {
|
|
3101
3738
|
operation: "github.pull.comment-reaction.delete",
|
|
3102
3739
|
method: "DELETE",
|
|
@@ -3117,24 +3754,21 @@ async function reviewBodyReactions(egress, input) {
|
|
|
3117
3754
|
});
|
|
3118
3755
|
if (!reviewResponse.ok) {
|
|
3119
3756
|
const message = `GitHub review lookup failed with HTTP ${reviewResponse.status}: ${githubErrorMessage(reviewResponse.body)}`;
|
|
3120
|
-
if (reviewResponse.status === 404) throw new
|
|
3757
|
+
if (reviewResponse.status === 404) throw new PluginToolInputError17(message);
|
|
3121
3758
|
throw new Error(message);
|
|
3122
3759
|
}
|
|
3123
|
-
const subjectId =
|
|
3124
|
-
const graphql = (
|
|
3125
|
-
operation,
|
|
3760
|
+
const subjectId = z22.object({ node_id: z22.string().min(1) }).parse(reviewResponse.body).node_id;
|
|
3761
|
+
const graphql = (operation2, document, variables) => githubApi(egress, {
|
|
3762
|
+
operation: operation2,
|
|
3126
3763
|
method: "POST",
|
|
3127
3764
|
path: "/graphql",
|
|
3128
|
-
body: {
|
|
3765
|
+
body: { ...document, variables }
|
|
3129
3766
|
});
|
|
3130
3767
|
const update = `github.pull.review-reaction.update:${input.owner}/${input.name}`.toLowerCase();
|
|
3131
3768
|
return {
|
|
3132
|
-
list: () => graphql(
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
REVIEW_REACTIONS_QUERY,
|
|
3136
|
-
{ subjectId }
|
|
3137
|
-
),
|
|
3769
|
+
list: () => graphql("github.pull.review-reaction.list", REVIEW_REACTIONS, {
|
|
3770
|
+
subjectId
|
|
3771
|
+
}),
|
|
3138
3772
|
botReactions: (body) => reviewReactionsSchema.parse(body).data.node.reactionGroups.filter(
|
|
3139
3773
|
(group) => group.reactors.nodes.some(
|
|
3140
3774
|
(reactor) => reactor.databaseId === input.botUserId
|
|
@@ -3142,11 +3776,11 @@ async function reviewBodyReactions(egress, input) {
|
|
|
3142
3776
|
).map((group) => ({
|
|
3143
3777
|
content: REST_REACTION_CONTENT.get(group.content) ?? group.content
|
|
3144
3778
|
})),
|
|
3145
|
-
remove: (reaction) => graphql(update,
|
|
3779
|
+
remove: (reaction) => graphql(update, REMOVE_REVIEW_REACTION, {
|
|
3146
3780
|
subjectId,
|
|
3147
3781
|
content: graphqlReactionContent(reaction.content)
|
|
3148
3782
|
}),
|
|
3149
|
-
add: (content) => graphql(update,
|
|
3783
|
+
add: (content) => graphql(update, ADD_REVIEW_REACTION, {
|
|
3150
3784
|
subjectId,
|
|
3151
3785
|
content: graphqlReactionContent(content)
|
|
3152
3786
|
})
|
|
@@ -3157,7 +3791,7 @@ function failed(response) {
|
|
|
3157
3791
|
return !response.ok || Array.isArray(errors) && errors.length > 0;
|
|
3158
3792
|
}
|
|
3159
3793
|
function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
3160
|
-
return
|
|
3794
|
+
return definePluginTool16({
|
|
3161
3795
|
// No action review: the tool checks in code that the bot authored the pull
|
|
3162
3796
|
// request, and it changes only the bot's own reaction, which is reversible.
|
|
3163
3797
|
approvalMode: "approve",
|
|
@@ -3169,12 +3803,12 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
3169
3803
|
},
|
|
3170
3804
|
description: "Set your outcome reaction on GitHub pull request feedback: addressed (+1) or declined (-1). Use the pull_request, comment_id, and comment_kind from the event after acting on the feedback. Replaces only your prior status reaction on that comment. Only works on pull requests the bot authored.",
|
|
3171
3805
|
exposure: "direct",
|
|
3172
|
-
inputSchema:
|
|
3173
|
-
outputSchema:
|
|
3806
|
+
inputSchema: inputSchema14,
|
|
3807
|
+
outputSchema: outputSchema14,
|
|
3174
3808
|
async execute(input) {
|
|
3175
|
-
const parsedInput =
|
|
3809
|
+
const parsedInput = inputSchema14.safeParse(input);
|
|
3176
3810
|
if (!parsedInput.success) {
|
|
3177
|
-
throw new
|
|
3811
|
+
throw new PluginToolInputError17(
|
|
3178
3812
|
"Invalid GitHub updatePullRequestFeedback input.",
|
|
3179
3813
|
{ cause: parsedInput.error }
|
|
3180
3814
|
);
|
|
@@ -3249,28 +3883,28 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
3249
3883
|
|
|
3250
3884
|
// src/tools/resolve-pull-request-review-thread.ts
|
|
3251
3885
|
import {
|
|
3252
|
-
definePluginTool as
|
|
3253
|
-
PluginToolInputError as
|
|
3254
|
-
pluginToolOutputSchema as
|
|
3886
|
+
definePluginTool as definePluginTool17,
|
|
3887
|
+
PluginToolInputError as PluginToolInputError18,
|
|
3888
|
+
pluginToolOutputSchema as pluginToolOutputSchema17
|
|
3255
3889
|
} from "@sentry/junior-plugin-api";
|
|
3256
|
-
import * as
|
|
3257
|
-
var
|
|
3258
|
-
repo:
|
|
3890
|
+
import * as z23 from "zod";
|
|
3891
|
+
var inputSchema15 = z23.object({
|
|
3892
|
+
repo: z23.string().describe(
|
|
3259
3893
|
'Repository in "owner/name" format. Required because GraphQL has no repo path.'
|
|
3260
3894
|
),
|
|
3261
|
-
thread_id:
|
|
3895
|
+
thread_id: z23.string().trim().min(1).describe(
|
|
3262
3896
|
"GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
|
|
3263
3897
|
)
|
|
3264
3898
|
}).strict();
|
|
3265
|
-
var
|
|
3266
|
-
target:
|
|
3267
|
-
repo:
|
|
3268
|
-
number:
|
|
3269
|
-
thread_id:
|
|
3270
|
-
resolved:
|
|
3899
|
+
var outputSchema15 = pluginToolOutputSchema17.extend({
|
|
3900
|
+
target: z23.literal("resolvePullRequestReviewThread"),
|
|
3901
|
+
repo: z23.string(),
|
|
3902
|
+
number: z23.number(),
|
|
3903
|
+
thread_id: z23.string(),
|
|
3904
|
+
resolved: z23.boolean()
|
|
3271
3905
|
});
|
|
3272
3906
|
function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
3273
|
-
return
|
|
3907
|
+
return definePluginTool17({
|
|
3274
3908
|
// No action review: the tool checks in code that the bot authored the pull
|
|
3275
3909
|
// request, and it changes only the thread's resolved state, which is
|
|
3276
3910
|
// reversible.
|
|
@@ -3283,12 +3917,12 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3283
3917
|
},
|
|
3284
3918
|
description: "Resolve a GitHub pull request review thread after acting on its feedback. Only works on pull requests the bot authored.",
|
|
3285
3919
|
exposure: "direct",
|
|
3286
|
-
inputSchema:
|
|
3287
|
-
outputSchema:
|
|
3920
|
+
inputSchema: inputSchema15,
|
|
3921
|
+
outputSchema: outputSchema15,
|
|
3288
3922
|
async execute(input) {
|
|
3289
|
-
const parsedInput =
|
|
3923
|
+
const parsedInput = inputSchema15.safeParse(input);
|
|
3290
3924
|
if (!parsedInput.success) {
|
|
3291
|
-
throw new
|
|
3925
|
+
throw new PluginToolInputError18(
|
|
3292
3926
|
"Invalid GitHub resolvePullRequestReviewThread input.",
|
|
3293
3927
|
{ cause: parsedInput.error }
|
|
3294
3928
|
);
|
|
@@ -3298,26 +3932,12 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3298
3932
|
if (botUserId === void 0) {
|
|
3299
3933
|
throw new Error("GitHub App bot identity is not configured.");
|
|
3300
3934
|
}
|
|
3301
|
-
const query = `query ReviewThreadOwnership($threadId: ID!) {
|
|
3302
|
-
node(id: $threadId) {
|
|
3303
|
-
... on PullRequestReviewThread {
|
|
3304
|
-
id
|
|
3305
|
-
isResolved
|
|
3306
|
-
pullRequest {
|
|
3307
|
-
number
|
|
3308
|
-
repository { nameWithOwner }
|
|
3309
|
-
author { ... on Bot { databaseId } }
|
|
3310
|
-
}
|
|
3311
|
-
}
|
|
3312
|
-
}
|
|
3313
|
-
}`;
|
|
3314
3935
|
const lookupResponse = await githubApi(ctx.egress, {
|
|
3315
3936
|
operation: "github.pull.review-thread.get",
|
|
3316
3937
|
method: "POST",
|
|
3317
3938
|
path: "/graphql",
|
|
3318
3939
|
body: {
|
|
3319
|
-
|
|
3320
|
-
query,
|
|
3940
|
+
...REVIEW_THREAD_OWNERSHIP,
|
|
3321
3941
|
variables: { threadId: parsedInput.data.thread_id }
|
|
3322
3942
|
}
|
|
3323
3943
|
});
|
|
@@ -3327,31 +3947,31 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3327
3947
|
`GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubErrorMessage(lookupPayload)}`
|
|
3328
3948
|
);
|
|
3329
3949
|
}
|
|
3330
|
-
const threadNodeSchema =
|
|
3331
|
-
id:
|
|
3332
|
-
isResolved:
|
|
3333
|
-
pullRequest:
|
|
3334
|
-
author:
|
|
3335
|
-
number:
|
|
3336
|
-
repository:
|
|
3950
|
+
const threadNodeSchema = z23.object({
|
|
3951
|
+
id: z23.string(),
|
|
3952
|
+
isResolved: z23.boolean(),
|
|
3953
|
+
pullRequest: z23.object({
|
|
3954
|
+
author: z23.object({ databaseId: z23.number().optional() }).passthrough().nullable(),
|
|
3955
|
+
number: z23.number(),
|
|
3956
|
+
repository: z23.object({ nameWithOwner: z23.string() }).passthrough()
|
|
3337
3957
|
}).passthrough()
|
|
3338
3958
|
}).passthrough();
|
|
3339
|
-
const lookupResultSchema =
|
|
3340
|
-
data:
|
|
3341
|
-
node:
|
|
3959
|
+
const lookupResultSchema = z23.object({
|
|
3960
|
+
data: z23.object({
|
|
3961
|
+
node: z23.unknown().nullable().optional()
|
|
3342
3962
|
}).passthrough()
|
|
3343
3963
|
}).passthrough();
|
|
3344
3964
|
const lookupResult = lookupResultSchema.safeParse(lookupPayload);
|
|
3345
3965
|
const rawNode = lookupResult.success ? lookupResult.data.data.node : void 0;
|
|
3346
3966
|
const parsedNode = rawNode == null ? void 0 : threadNodeSchema.safeParse(rawNode);
|
|
3347
3967
|
if (!parsedNode?.success) {
|
|
3348
|
-
throw new
|
|
3968
|
+
throw new PluginToolInputError18("GitHub review thread was not found.");
|
|
3349
3969
|
}
|
|
3350
3970
|
const thread = parsedNode.data;
|
|
3351
3971
|
const pullRequest = thread.pullRequest;
|
|
3352
3972
|
const ownsPullRequest = pullRequest.repository.nameWithOwner.toLowerCase() === repo.ref.toLowerCase() && pullRequest.author?.databaseId === botUserId;
|
|
3353
3973
|
if (!ownsPullRequest) {
|
|
3354
|
-
throw new
|
|
3974
|
+
throw new PluginToolInputError18(
|
|
3355
3975
|
"This bot can only resolve review threads on pull requests it authored."
|
|
3356
3976
|
);
|
|
3357
3977
|
}
|
|
@@ -3364,18 +3984,12 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3364
3984
|
resolved: true
|
|
3365
3985
|
};
|
|
3366
3986
|
}
|
|
3367
|
-
const mutation = `mutation ResolveReviewThread($threadId: ID!) {
|
|
3368
|
-
resolveReviewThread(input: {threadId: $threadId}) {
|
|
3369
|
-
thread { id isResolved }
|
|
3370
|
-
}
|
|
3371
|
-
}`;
|
|
3372
3987
|
const resolveResponse = await githubApi(ctx.egress, {
|
|
3373
3988
|
operation: `github.pull.review-thread.resolve:${repo.ref.toLowerCase()}`,
|
|
3374
3989
|
method: "POST",
|
|
3375
3990
|
path: "/graphql",
|
|
3376
3991
|
body: {
|
|
3377
|
-
|
|
3378
|
-
query: mutation,
|
|
3992
|
+
...RESOLVE_REVIEW_THREAD,
|
|
3379
3993
|
variables: { threadId: thread.id }
|
|
3380
3994
|
}
|
|
3381
3995
|
});
|
|
@@ -3385,10 +3999,10 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3385
3999
|
`GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubErrorMessage(resolvePayload)}`
|
|
3386
4000
|
);
|
|
3387
4001
|
}
|
|
3388
|
-
const resolveResultSchema =
|
|
3389
|
-
data:
|
|
3390
|
-
resolveReviewThread:
|
|
3391
|
-
thread:
|
|
4002
|
+
const resolveResultSchema = z23.object({
|
|
4003
|
+
data: z23.object({
|
|
4004
|
+
resolveReviewThread: z23.object({
|
|
4005
|
+
thread: z23.object({ id: z23.string(), isResolved: z23.boolean() }).passthrough()
|
|
3392
4006
|
}).passthrough()
|
|
3393
4007
|
}).passthrough()
|
|
3394
4008
|
}).passthrough();
|
|
@@ -3416,46 +4030,46 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3416
4030
|
|
|
3417
4031
|
// src/tools/submit-pull-request-review.ts
|
|
3418
4032
|
import {
|
|
3419
|
-
definePluginTool as
|
|
3420
|
-
PluginToolInputError as
|
|
3421
|
-
pluginToolOutputSchema as
|
|
4033
|
+
definePluginTool as definePluginTool18,
|
|
4034
|
+
PluginToolInputError as PluginToolInputError19,
|
|
4035
|
+
pluginToolOutputSchema as pluginToolOutputSchema18
|
|
3422
4036
|
} from "@sentry/junior-plugin-api";
|
|
3423
|
-
import * as
|
|
3424
|
-
var reviewCommentSchema =
|
|
3425
|
-
path:
|
|
3426
|
-
body:
|
|
3427
|
-
line:
|
|
3428
|
-
side:
|
|
3429
|
-
start_line:
|
|
3430
|
-
start_side:
|
|
4037
|
+
import * as z24 from "zod";
|
|
4038
|
+
var reviewCommentSchema = z24.object({
|
|
4039
|
+
path: z24.string().trim().min(1).describe("File path in the pull request."),
|
|
4040
|
+
body: z24.string().trim().min(1).describe("Inline review comment."),
|
|
4041
|
+
line: z24.number().int().positive().describe("Line in the pull request diff."),
|
|
4042
|
+
side: z24.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
|
|
4043
|
+
start_line: z24.number().int().positive().optional().describe("First line of a multi-line comment."),
|
|
4044
|
+
start_side: z24.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
|
|
3431
4045
|
}).strict().refine(
|
|
3432
4046
|
({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
|
|
3433
4047
|
{ message: "start_line and start_side must be provided together." }
|
|
3434
4048
|
);
|
|
3435
|
-
var
|
|
3436
|
-
repo:
|
|
3437
|
-
number:
|
|
3438
|
-
event:
|
|
3439
|
-
body:
|
|
3440
|
-
comments:
|
|
4049
|
+
var inputSchema16 = z24.object({
|
|
4050
|
+
repo: z24.string().describe('Repository in "owner/name" format.'),
|
|
4051
|
+
number: z24.number().int().positive().describe("Pull request number."),
|
|
4052
|
+
event: z24.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
|
|
4053
|
+
body: z24.string().trim().min(1).describe("Review summary."),
|
|
4054
|
+
comments: z24.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
|
|
3441
4055
|
}).strict();
|
|
3442
|
-
var
|
|
3443
|
-
target:
|
|
3444
|
-
repo:
|
|
3445
|
-
number:
|
|
3446
|
-
review_id:
|
|
3447
|
-
state:
|
|
3448
|
-
url:
|
|
4056
|
+
var outputSchema16 = pluginToolOutputSchema18.extend({
|
|
4057
|
+
target: z24.literal("submitPullRequestReview"),
|
|
4058
|
+
repo: z24.string(),
|
|
4059
|
+
number: z24.number(),
|
|
4060
|
+
review_id: z24.number(),
|
|
4061
|
+
state: z24.string(),
|
|
4062
|
+
url: z24.string()
|
|
3449
4063
|
});
|
|
3450
4064
|
function throwReviewError(status, body) {
|
|
3451
4065
|
const message = `GitHub pull request review failed with HTTP ${status}: ${githubErrorMessage(body)}`;
|
|
3452
4066
|
if (status === 404 || status === 422) {
|
|
3453
|
-
throw new
|
|
4067
|
+
throw new PluginToolInputError19(message);
|
|
3454
4068
|
}
|
|
3455
4069
|
throw new Error(message);
|
|
3456
4070
|
}
|
|
3457
4071
|
function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
3458
|
-
return
|
|
4072
|
+
return definePluginTool18({
|
|
3459
4073
|
annotations: {
|
|
3460
4074
|
destructiveHint: true,
|
|
3461
4075
|
idempotentHint: false,
|
|
@@ -3463,8 +4077,8 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3463
4077
|
readOnlyHint: false
|
|
3464
4078
|
},
|
|
3465
4079
|
description: "Submit a GitHub pull request review as a comment or change request. Use this instead of `gh pr review`, GraphQL, or direct REST calls. You cannot approve pull requests.",
|
|
3466
|
-
inputSchema:
|
|
3467
|
-
outputSchema:
|
|
4080
|
+
inputSchema: inputSchema16,
|
|
4081
|
+
outputSchema: outputSchema16,
|
|
3468
4082
|
async execute(review) {
|
|
3469
4083
|
const repo = parseRepo(review.repo);
|
|
3470
4084
|
const comments = review.comments?.map((comment) => ({
|
|
@@ -3488,7 +4102,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3488
4102
|
if (!response.ok) {
|
|
3489
4103
|
throwReviewError(response.status, response.body);
|
|
3490
4104
|
}
|
|
3491
|
-
const providerResult =
|
|
4105
|
+
const providerResult = z24.object({ id: z24.number(), html_url: z24.string(), state: z24.string() }).parse(response.body);
|
|
3492
4106
|
return {
|
|
3493
4107
|
target: "submitPullRequestReview",
|
|
3494
4108
|
repo: repo.ref,
|
|
@@ -3503,15 +4117,18 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3503
4117
|
}
|
|
3504
4118
|
|
|
3505
4119
|
// src/tools.ts
|
|
3506
|
-
function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
4120
|
+
function createGitHubTools(ctx, botEmail, pullRequestSubscription, experimental = {}) {
|
|
4121
|
+
const descriptionDecider = experimental.pullRequestDescriptionChecks ? ctx.decider : void 0;
|
|
3507
4122
|
return {
|
|
4123
|
+
reactToIssue: createGitHubReactToIssueTool(ctx.egress),
|
|
3508
4124
|
cloneRepository: createGitHubCloneRepositoryTool(ctx),
|
|
3509
4125
|
commentOnIssue: createGitHubCommentOnIssueTool(ctx.egress),
|
|
3510
4126
|
commentOnPullRequest: createGitHubCommentOnPullRequestTool(ctx.egress),
|
|
3511
4127
|
createIssue: createGitHubIssueTool(ctx),
|
|
3512
4128
|
createPullRequest: createGitHubPullRequestTool(
|
|
3513
4129
|
ctx,
|
|
3514
|
-
pullRequestSubscription
|
|
4130
|
+
pullRequestSubscription,
|
|
4131
|
+
descriptionDecider
|
|
3515
4132
|
),
|
|
3516
4133
|
getDeployment: createGitHubGetDeploymentTool(ctx),
|
|
3517
4134
|
getIssue: createGitHubGetIssueTool(ctx),
|
|
@@ -3524,7 +4141,14 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3524
4141
|
ctx.egress
|
|
3525
4142
|
),
|
|
3526
4143
|
updateIssue: createGitHubUpdateIssueTool(ctx),
|
|
3527
|
-
|
|
4144
|
+
updateIssueComment: createGitHubUpdateIssueCommentTool(
|
|
4145
|
+
ctx.egress,
|
|
4146
|
+
botEmail
|
|
4147
|
+
),
|
|
4148
|
+
updatePullRequest: createGitHubUpdatePullRequestTool(
|
|
4149
|
+
ctx,
|
|
4150
|
+
descriptionDecider
|
|
4151
|
+
),
|
|
3528
4152
|
updatePullRequestFeedback: createGitHubUpdatePullRequestFeedbackTool(
|
|
3529
4153
|
ctx,
|
|
3530
4154
|
botEmail
|
|
@@ -3534,26 +4158,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3534
4158
|
|
|
3535
4159
|
// src/webhooks/handler.ts
|
|
3536
4160
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3537
|
-
import * as
|
|
4161
|
+
import * as z40 from "zod";
|
|
3538
4162
|
|
|
3539
4163
|
// src/issue-outcomes/store.ts
|
|
3540
4164
|
import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
|
|
3541
|
-
import * as
|
|
3542
|
-
var githubIssueOutcomeInputSchema =
|
|
3543
|
-
candidateOwned:
|
|
3544
|
-
closedAt:
|
|
3545
|
-
issueId:
|
|
3546
|
-
number:
|
|
3547
|
-
openedAt:
|
|
3548
|
-
repositoryFullName:
|
|
3549
|
-
repositoryId:
|
|
4165
|
+
import * as z25 from "zod";
|
|
4166
|
+
var githubIssueOutcomeInputSchema = z25.object({
|
|
4167
|
+
candidateOwned: z25.boolean(),
|
|
4168
|
+
closedAt: z25.date().optional(),
|
|
4169
|
+
issueId: z25.string().min(1),
|
|
4170
|
+
number: z25.number().int().positive(),
|
|
4171
|
+
openedAt: z25.date(),
|
|
4172
|
+
repositoryFullName: z25.string().min(1),
|
|
4173
|
+
repositoryId: z25.string().min(1),
|
|
3550
4174
|
state: githubIssueStateSchema,
|
|
3551
4175
|
stateReason: githubIssueStateReasonSchema.optional(),
|
|
3552
|
-
updatedAt:
|
|
4176
|
+
updatedAt: z25.date()
|
|
3553
4177
|
}).strict();
|
|
3554
|
-
var githubIssueConversationsInputSchema =
|
|
3555
|
-
conversationIds:
|
|
3556
|
-
issueId:
|
|
4178
|
+
var githubIssueConversationsInputSchema = z25.object({
|
|
4179
|
+
conversationIds: z25.array(z25.string().min(1)).min(1),
|
|
4180
|
+
issueId: z25.string().min(1)
|
|
3557
4181
|
}).strict();
|
|
3558
4182
|
function projectionValues(input) {
|
|
3559
4183
|
return {
|
|
@@ -3617,38 +4241,41 @@ async function recordGitHubIssueConversations(db, input) {
|
|
|
3617
4241
|
|
|
3618
4242
|
// src/pull-request-outcomes/store.ts
|
|
3619
4243
|
import { and as and3, eq as eq3, lt as lt2, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
|
|
3620
|
-
import * as
|
|
3621
|
-
var githubPullRequestOutcomeInputSchema =
|
|
3622
|
-
candidateOwned:
|
|
3623
|
-
closedAt:
|
|
4244
|
+
import * as z26 from "zod";
|
|
4245
|
+
var githubPullRequestOutcomeInputSchema = z26.object({
|
|
4246
|
+
candidateOwned: z26.boolean(),
|
|
4247
|
+
closedAt: z26.date().optional(),
|
|
3624
4248
|
commitComposition: githubPullRequestCommitCompositionSchema.optional(),
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
4249
|
+
/** When omitted, the stored draft state does not change. */
|
|
4250
|
+
draft: z26.boolean().optional(),
|
|
4251
|
+
mergedAt: z26.date().optional(),
|
|
4252
|
+
number: z26.number().int().positive(),
|
|
4253
|
+
openedAt: z26.date(),
|
|
4254
|
+
pullRequestId: z26.string().min(1),
|
|
4255
|
+
repositoryFullName: z26.string().min(1),
|
|
4256
|
+
repositoryId: z26.string().min(1),
|
|
3631
4257
|
state: githubPullRequestStateSchema,
|
|
3632
|
-
title:
|
|
3633
|
-
updatedAt:
|
|
4258
|
+
title: z26.string().min(1).optional(),
|
|
4259
|
+
updatedAt: z26.date()
|
|
3634
4260
|
}).strict();
|
|
3635
|
-
var githubPullRequestConversationsInputSchema =
|
|
3636
|
-
conversationIds:
|
|
3637
|
-
pullRequestId:
|
|
4261
|
+
var githubPullRequestConversationsInputSchema = z26.object({
|
|
4262
|
+
conversationIds: z26.array(z26.string().min(1)).min(1),
|
|
4263
|
+
pullRequestId: z26.string().min(1)
|
|
3638
4264
|
}).strict();
|
|
3639
|
-
var githubPullRequestLinkedIssuesInputSchema =
|
|
3640
|
-
linkedIssues:
|
|
3641
|
-
|
|
3642
|
-
number:
|
|
3643
|
-
repositoryFullName:
|
|
4265
|
+
var githubPullRequestLinkedIssuesInputSchema = z26.object({
|
|
4266
|
+
linkedIssues: z26.array(
|
|
4267
|
+
z26.object({
|
|
4268
|
+
number: z26.number().int().positive(),
|
|
4269
|
+
repositoryFullName: z26.string().min(1)
|
|
3644
4270
|
}).strict()
|
|
3645
4271
|
).min(1),
|
|
3646
|
-
pullRequestId:
|
|
4272
|
+
pullRequestId: z26.string().min(1)
|
|
3647
4273
|
}).strict();
|
|
3648
4274
|
function projectionValues2(input) {
|
|
3649
4275
|
return {
|
|
3650
4276
|
closedAt: input.closedAt ?? null,
|
|
3651
4277
|
...input.commitComposition ? { commitComposition: input.commitComposition } : void 0,
|
|
4278
|
+
...input.draft !== void 0 ? { draft: input.draft } : void 0,
|
|
3652
4279
|
mergedAt: input.mergedAt ?? null,
|
|
3653
4280
|
number: input.number,
|
|
3654
4281
|
openedAt: input.openedAt,
|
|
@@ -3755,7 +4382,12 @@ async function listGitHubFinishedWork(db, conversationIds) {
|
|
|
3755
4382
|
}
|
|
3756
4383
|
async function listGitHubStaleOpenPullRequests(db, before) {
|
|
3757
4384
|
const t = juniorGitHubPullRequests;
|
|
3758
|
-
return await db.select({
|
|
4385
|
+
return await db.select({
|
|
4386
|
+
draft: t.draft,
|
|
4387
|
+
number: t.number,
|
|
4388
|
+
repositoryFullName: t.repositoryFullName,
|
|
4389
|
+
repositoryId: t.repositoryId
|
|
4390
|
+
}).from(t).where(and3(eq3(t.state, "open"), lt2(t.updatedAt, before))).orderBy(t.updatedAt);
|
|
3759
4391
|
}
|
|
3760
4392
|
async function listGitHubAssignedWork(db, conversationIds) {
|
|
3761
4393
|
if (conversationIds.length === 0) return [];
|
|
@@ -3768,6 +4400,10 @@ async function listGitHubAssignedWork(db, conversationIds) {
|
|
|
3768
4400
|
);
|
|
3769
4401
|
return conversationIdsForPullRequests(rows, conversationIds);
|
|
3770
4402
|
}
|
|
4403
|
+
async function readGitHubPullRequestConversationIds(db, pullRequestId) {
|
|
4404
|
+
const [row] = await db.select({ conversationIds: juniorGitHubPullRequests.conversationIds }).from(juniorGitHubPullRequests).where(eq3(juniorGitHubPullRequests.pullRequestId, pullRequestId)).limit(1);
|
|
4405
|
+
return row?.conversationIds ?? [];
|
|
4406
|
+
}
|
|
3771
4407
|
async function recordGitHubPullRequestConversations(db, input) {
|
|
3772
4408
|
const association = githubPullRequestConversationsInputSchema.parse(input);
|
|
3773
4409
|
const conversationIds = sql3.join(
|
|
@@ -3856,6 +4492,7 @@ function githubCodeChange(outcome, conversationIds) {
|
|
|
3856
4492
|
return {
|
|
3857
4493
|
closedAt: outcome.closedAt,
|
|
3858
4494
|
conversationIds,
|
|
4495
|
+
draft: outcome.draft,
|
|
3859
4496
|
mergedAt: outcome.mergedAt,
|
|
3860
4497
|
number: outcome.number,
|
|
3861
4498
|
openedAt: outcome.openedAt,
|
|
@@ -3895,39 +4532,39 @@ async function applyGitHubPullRequestOutcome(args) {
|
|
|
3895
4532
|
}
|
|
3896
4533
|
|
|
3897
4534
|
// src/webhooks/issue-outcome.ts
|
|
3898
|
-
import * as
|
|
3899
|
-
var canonicalIssueOutcomeSchema =
|
|
3900
|
-
action:
|
|
3901
|
-
issue:
|
|
3902
|
-
body:
|
|
3903
|
-
closed_at:
|
|
3904
|
-
created_at:
|
|
3905
|
-
id:
|
|
3906
|
-
number:
|
|
4535
|
+
import * as z27 from "zod";
|
|
4536
|
+
var canonicalIssueOutcomeSchema = z27.object({
|
|
4537
|
+
action: z27.enum(["opened", "closed", "reopened"]),
|
|
4538
|
+
issue: z27.object({
|
|
4539
|
+
body: z27.string().nullable().optional(),
|
|
4540
|
+
closed_at: z27.string().nullable().optional(),
|
|
4541
|
+
created_at: z27.string(),
|
|
4542
|
+
id: z27.number().int().positive(),
|
|
4543
|
+
number: z27.number().int().positive(),
|
|
3907
4544
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3908
|
-
updated_at:
|
|
3909
|
-
user:
|
|
4545
|
+
updated_at: z27.string(),
|
|
4546
|
+
user: z27.object({ login: z27.string().min(1) }).strict()
|
|
3910
4547
|
}).strict(),
|
|
3911
|
-
repository:
|
|
3912
|
-
full_name:
|
|
3913
|
-
id:
|
|
4548
|
+
repository: z27.object({
|
|
4549
|
+
full_name: z27.string().min(1),
|
|
4550
|
+
id: z27.number().int().positive()
|
|
3914
4551
|
}).strict()
|
|
3915
4552
|
}).strict();
|
|
3916
|
-
var issueOutcomeSchema =
|
|
3917
|
-
action:
|
|
3918
|
-
issue:
|
|
3919
|
-
body:
|
|
3920
|
-
closed_at:
|
|
3921
|
-
created_at:
|
|
3922
|
-
id:
|
|
3923
|
-
number:
|
|
4553
|
+
var issueOutcomeSchema = z27.object({
|
|
4554
|
+
action: z27.enum(["opened", "closed", "reopened"]),
|
|
4555
|
+
issue: z27.object({
|
|
4556
|
+
body: z27.string().nullable().optional(),
|
|
4557
|
+
closed_at: z27.string().nullable().optional(),
|
|
4558
|
+
created_at: z27.string(),
|
|
4559
|
+
id: z27.number().int().positive(),
|
|
4560
|
+
number: z27.number().int().positive(),
|
|
3924
4561
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3925
|
-
updated_at:
|
|
3926
|
-
user:
|
|
4562
|
+
updated_at: z27.string(),
|
|
4563
|
+
user: z27.object({ login: z27.string().min(1) }).passthrough()
|
|
3927
4564
|
}).passthrough(),
|
|
3928
|
-
repository:
|
|
3929
|
-
full_name:
|
|
3930
|
-
id:
|
|
4565
|
+
repository: z27.object({
|
|
4566
|
+
full_name: z27.string().min(1),
|
|
4567
|
+
id: z27.number().int().positive()
|
|
3931
4568
|
}).passthrough()
|
|
3932
4569
|
}).passthrough().transform(
|
|
3933
4570
|
(provider) => canonicalIssueOutcomeSchema.parse({
|
|
@@ -3948,7 +4585,7 @@ var issueOutcomeSchema = z24.object({
|
|
|
3948
4585
|
}
|
|
3949
4586
|
})
|
|
3950
4587
|
);
|
|
3951
|
-
var issueLifecycleActionSchema =
|
|
4588
|
+
var issueLifecycleActionSchema = z27.object({ action: z27.string() }).passthrough();
|
|
3952
4589
|
function timestamp2(value) {
|
|
3953
4590
|
if (!value) return void 0;
|
|
3954
4591
|
const parsed = new Date(value);
|
|
@@ -3992,21 +4629,21 @@ function normalizeGitHubIssueOutcome(args) {
|
|
|
3992
4629
|
updatedAt
|
|
3993
4630
|
};
|
|
3994
4631
|
}
|
|
3995
|
-
var canonicalIssueConversationSchema =
|
|
3996
|
-
issue:
|
|
3997
|
-
body:
|
|
3998
|
-
id:
|
|
3999
|
-
user:
|
|
4632
|
+
var canonicalIssueConversationSchema = z27.object({
|
|
4633
|
+
issue: z27.object({
|
|
4634
|
+
body: z27.string().nullable().optional(),
|
|
4635
|
+
id: z27.number().int().positive(),
|
|
4636
|
+
user: z27.object({ login: z27.string().min(1) }).strict()
|
|
4000
4637
|
}).strict(),
|
|
4001
|
-
sender:
|
|
4638
|
+
sender: z27.object({ login: z27.string().min(1) }).strict().optional()
|
|
4002
4639
|
}).strict();
|
|
4003
|
-
var issueConversationSchema =
|
|
4004
|
-
issue:
|
|
4005
|
-
body:
|
|
4006
|
-
id:
|
|
4007
|
-
user:
|
|
4640
|
+
var issueConversationSchema = z27.object({
|
|
4641
|
+
issue: z27.object({
|
|
4642
|
+
body: z27.string().nullable().optional(),
|
|
4643
|
+
id: z27.number().int().positive(),
|
|
4644
|
+
user: z27.object({ login: z27.string().min(1) }).passthrough()
|
|
4008
4645
|
}).passthrough(),
|
|
4009
|
-
sender:
|
|
4646
|
+
sender: z27.object({ login: z27.string().min(1) }).passthrough().optional()
|
|
4010
4647
|
}).passthrough().transform(
|
|
4011
4648
|
(provider) => canonicalIssueConversationSchema.parse({
|
|
4012
4649
|
issue: {
|
|
@@ -4033,43 +4670,52 @@ function normalizeGitHubIssueConversations(args) {
|
|
|
4033
4670
|
}
|
|
4034
4671
|
|
|
4035
4672
|
// src/webhooks/pull-request-outcome.ts
|
|
4036
|
-
import * as
|
|
4037
|
-
var
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4673
|
+
import * as z28 from "zod";
|
|
4674
|
+
var pullRequestLifecycleActionsSchema = z28.enum([
|
|
4675
|
+
"opened",
|
|
4676
|
+
"closed",
|
|
4677
|
+
"reopened",
|
|
4678
|
+
"ready_for_review",
|
|
4679
|
+
"converted_to_draft"
|
|
4680
|
+
]);
|
|
4681
|
+
var canonicalPullRequestOutcomeSchema = z28.object({
|
|
4682
|
+
action: pullRequestLifecycleActionsSchema,
|
|
4683
|
+
pull_request: z28.object({
|
|
4684
|
+
body: z28.string().nullable().optional(),
|
|
4685
|
+
closed_at: z28.string().nullable().optional(),
|
|
4686
|
+
created_at: z28.string(),
|
|
4687
|
+
draft: z28.boolean().optional(),
|
|
4688
|
+
id: z28.number().int().positive(),
|
|
4689
|
+
merged: z28.boolean(),
|
|
4690
|
+
merged_at: z28.string().nullable().optional(),
|
|
4691
|
+
number: z28.number().int().positive(),
|
|
4692
|
+
title: z28.string().min(1).optional(),
|
|
4693
|
+
updated_at: z28.string(),
|
|
4694
|
+
user: z28.object({ login: z28.string().min(1) }).strict()
|
|
4050
4695
|
}).strict(),
|
|
4051
|
-
repository:
|
|
4052
|
-
full_name:
|
|
4053
|
-
id:
|
|
4696
|
+
repository: z28.object({
|
|
4697
|
+
full_name: z28.string().min(1),
|
|
4698
|
+
id: z28.number().int().positive()
|
|
4054
4699
|
}).strict()
|
|
4055
4700
|
}).strict();
|
|
4056
|
-
var pullRequestOutcomeSchema =
|
|
4057
|
-
action:
|
|
4058
|
-
pull_request:
|
|
4059
|
-
body:
|
|
4060
|
-
closed_at:
|
|
4061
|
-
created_at:
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
-
|
|
4701
|
+
var pullRequestOutcomeSchema = z28.object({
|
|
4702
|
+
action: pullRequestLifecycleActionsSchema,
|
|
4703
|
+
pull_request: z28.object({
|
|
4704
|
+
body: z28.string().nullable().optional(),
|
|
4705
|
+
closed_at: z28.string().nullable().optional(),
|
|
4706
|
+
created_at: z28.string(),
|
|
4707
|
+
draft: z28.boolean().optional(),
|
|
4708
|
+
id: z28.number().int().positive(),
|
|
4709
|
+
merged: z28.boolean(),
|
|
4710
|
+
merged_at: z28.string().nullable().optional(),
|
|
4711
|
+
number: z28.number().int().positive(),
|
|
4712
|
+
title: z28.string().min(1).optional(),
|
|
4713
|
+
updated_at: z28.string(),
|
|
4714
|
+
user: z28.object({ login: z28.string().min(1) }).passthrough()
|
|
4069
4715
|
}).passthrough(),
|
|
4070
|
-
repository:
|
|
4071
|
-
full_name:
|
|
4072
|
-
id:
|
|
4716
|
+
repository: z28.object({
|
|
4717
|
+
full_name: z28.string().min(1),
|
|
4718
|
+
id: z28.number().int().positive()
|
|
4073
4719
|
}).passthrough()
|
|
4074
4720
|
}).passthrough().transform(
|
|
4075
4721
|
(provider) => canonicalPullRequestOutcomeSchema.parse({
|
|
@@ -4078,6 +4724,7 @@ var pullRequestOutcomeSchema = z25.object({
|
|
|
4078
4724
|
body: provider.pull_request.body,
|
|
4079
4725
|
closed_at: provider.pull_request.closed_at,
|
|
4080
4726
|
created_at: provider.pull_request.created_at,
|
|
4727
|
+
draft: provider.pull_request.draft,
|
|
4081
4728
|
id: provider.pull_request.id,
|
|
4082
4729
|
merged: provider.pull_request.merged,
|
|
4083
4730
|
merged_at: provider.pull_request.merged_at,
|
|
@@ -4092,24 +4739,24 @@ var pullRequestOutcomeSchema = z25.object({
|
|
|
4092
4739
|
}
|
|
4093
4740
|
})
|
|
4094
4741
|
);
|
|
4095
|
-
var pullRequestLifecycleActionSchema =
|
|
4096
|
-
var canonicalPullRequestConversationSchema =
|
|
4097
|
-
pull_request:
|
|
4098
|
-
body:
|
|
4099
|
-
id:
|
|
4100
|
-
user:
|
|
4742
|
+
var pullRequestLifecycleActionSchema = z28.object({ action: z28.string() }).passthrough();
|
|
4743
|
+
var canonicalPullRequestConversationSchema = z28.object({
|
|
4744
|
+
pull_request: z28.object({
|
|
4745
|
+
body: z28.string().nullable().optional(),
|
|
4746
|
+
id: z28.number().int().positive(),
|
|
4747
|
+
user: z28.object({ login: z28.string().min(1) }).strict()
|
|
4101
4748
|
}).strict(),
|
|
4102
|
-
repository:
|
|
4103
|
-
sender:
|
|
4749
|
+
repository: z28.object({ full_name: z28.string().min(1) }).strict(),
|
|
4750
|
+
sender: z28.object({ login: z28.string().min(1) }).strict()
|
|
4104
4751
|
}).strict();
|
|
4105
|
-
var pullRequestConversationSchema =
|
|
4106
|
-
pull_request:
|
|
4107
|
-
body:
|
|
4108
|
-
id:
|
|
4109
|
-
user:
|
|
4752
|
+
var pullRequestConversationSchema = z28.object({
|
|
4753
|
+
pull_request: z28.object({
|
|
4754
|
+
body: z28.string().nullable().optional(),
|
|
4755
|
+
id: z28.number().int().positive(),
|
|
4756
|
+
user: z28.object({ login: z28.string().min(1) }).passthrough()
|
|
4110
4757
|
}).passthrough(),
|
|
4111
|
-
repository:
|
|
4112
|
-
sender:
|
|
4758
|
+
repository: z28.object({ full_name: z28.string().min(1) }).passthrough(),
|
|
4759
|
+
sender: z28.object({ login: z28.string().min(1) }).passthrough()
|
|
4113
4760
|
}).passthrough().transform(
|
|
4114
4761
|
(provider) => canonicalPullRequestConversationSchema.parse({
|
|
4115
4762
|
pull_request: {
|
|
@@ -4128,7 +4775,7 @@ function timestamp3(value) {
|
|
|
4128
4775
|
}
|
|
4129
4776
|
function normalizeGitHubPullRequestOutcome(args) {
|
|
4130
4777
|
const lifecycle = pullRequestLifecycleActionSchema.safeParse(args.body);
|
|
4131
|
-
if (!lifecycle.success || !
|
|
4778
|
+
if (!lifecycle.success || !pullRequestLifecycleActionsSchema.safeParse(lifecycle.data.action).success) {
|
|
4132
4779
|
return void 0;
|
|
4133
4780
|
}
|
|
4134
4781
|
const parsed = pullRequestOutcomeSchema.parse(args.body);
|
|
@@ -4154,6 +4801,8 @@ function normalizeGitHubPullRequestOutcome(args) {
|
|
|
4154
4801
|
return {
|
|
4155
4802
|
candidateOwned,
|
|
4156
4803
|
closedAt,
|
|
4804
|
+
// A close keeps the stored draft state.
|
|
4805
|
+
draft: closed ? void 0 : pullRequest.draft,
|
|
4157
4806
|
mergedAt,
|
|
4158
4807
|
number: pullRequest.number,
|
|
4159
4808
|
openedAt,
|
|
@@ -4194,17 +4843,17 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
|
|
|
4194
4843
|
}
|
|
4195
4844
|
|
|
4196
4845
|
// src/webhooks/pull-request-activity.ts
|
|
4197
|
-
import * as
|
|
4198
|
-
var timestampSchema =
|
|
4199
|
-
var numberSchema =
|
|
4200
|
-
var repositorySchema2 =
|
|
4201
|
-
var senderSchema =
|
|
4846
|
+
import * as z29 from "zod";
|
|
4847
|
+
var timestampSchema = z29.iso.datetime({ offset: true });
|
|
4848
|
+
var numberSchema = z29.number().int().positive();
|
|
4849
|
+
var repositorySchema2 = z29.object({ id: numberSchema });
|
|
4850
|
+
var senderSchema = z29.object({ type: z29.string() });
|
|
4202
4851
|
var activitySchemas = {
|
|
4203
|
-
issue_comment:
|
|
4204
|
-
action:
|
|
4205
|
-
comment:
|
|
4852
|
+
issue_comment: z29.object({
|
|
4853
|
+
action: z29.literal("created"),
|
|
4854
|
+
comment: z29.object({ created_at: timestampSchema }),
|
|
4206
4855
|
// Only comments on a pull request carry `issue.pull_request`.
|
|
4207
|
-
issue:
|
|
4856
|
+
issue: z29.object({ number: numberSchema, pull_request: z29.object({}) }),
|
|
4208
4857
|
repository: repositorySchema2,
|
|
4209
4858
|
sender: senderSchema
|
|
4210
4859
|
}).transform((event) => ({
|
|
@@ -4213,9 +4862,9 @@ var activitySchemas = {
|
|
|
4213
4862
|
repositoryProviderId: String(event.repository.id),
|
|
4214
4863
|
senderType: event.sender.type
|
|
4215
4864
|
})),
|
|
4216
|
-
pull_request:
|
|
4217
|
-
action:
|
|
4218
|
-
pull_request:
|
|
4865
|
+
pull_request: z29.object({
|
|
4866
|
+
action: z29.literal("synchronize"),
|
|
4867
|
+
pull_request: z29.object({
|
|
4219
4868
|
number: numberSchema,
|
|
4220
4869
|
updated_at: timestampSchema
|
|
4221
4870
|
}),
|
|
@@ -4227,11 +4876,11 @@ var activitySchemas = {
|
|
|
4227
4876
|
repositoryProviderId: String(event.repository.id),
|
|
4228
4877
|
senderType: event.sender.type
|
|
4229
4878
|
})),
|
|
4230
|
-
pull_request_review:
|
|
4231
|
-
action:
|
|
4232
|
-
pull_request:
|
|
4879
|
+
pull_request_review: z29.object({
|
|
4880
|
+
action: z29.literal("submitted"),
|
|
4881
|
+
pull_request: z29.object({ number: numberSchema }),
|
|
4233
4882
|
repository: repositorySchema2,
|
|
4234
|
-
review:
|
|
4883
|
+
review: z29.object({ submitted_at: timestampSchema }),
|
|
4235
4884
|
sender: senderSchema
|
|
4236
4885
|
}).transform((event) => ({
|
|
4237
4886
|
at: new Date(event.review.submitted_at),
|
|
@@ -4239,10 +4888,10 @@ var activitySchemas = {
|
|
|
4239
4888
|
repositoryProviderId: String(event.repository.id),
|
|
4240
4889
|
senderType: event.sender.type
|
|
4241
4890
|
})),
|
|
4242
|
-
pull_request_review_comment:
|
|
4243
|
-
action:
|
|
4244
|
-
comment:
|
|
4245
|
-
pull_request:
|
|
4891
|
+
pull_request_review_comment: z29.object({
|
|
4892
|
+
action: z29.literal("created"),
|
|
4893
|
+
comment: z29.object({ created_at: timestampSchema }),
|
|
4894
|
+
pull_request: z29.object({ number: numberSchema }),
|
|
4246
4895
|
repository: repositorySchema2,
|
|
4247
4896
|
sender: senderSchema
|
|
4248
4897
|
}).transform((event) => ({
|
|
@@ -4260,21 +4909,84 @@ function normalizeGitHubPullRequestActivity(input) {
|
|
|
4260
4909
|
return senderType === "Bot" ? void 0 : activity;
|
|
4261
4910
|
}
|
|
4262
4911
|
|
|
4912
|
+
// src/webhooks/pull-request-preview.ts
|
|
4913
|
+
import * as z30 from "zod";
|
|
4914
|
+
var previewWebhookSchema = z30.object({
|
|
4915
|
+
action: z30.enum(["opened", "edited", "synchronize", "ready_for_review"]),
|
|
4916
|
+
pull_request: z30.object({
|
|
4917
|
+
body: z30.string().nullable().optional(),
|
|
4918
|
+
id: z30.number().int().positive(),
|
|
4919
|
+
number: z30.number().int().positive(),
|
|
4920
|
+
updated_at: z30.iso.datetime({ offset: true })
|
|
4921
|
+
}),
|
|
4922
|
+
repository: z30.object({ full_name: z30.string().min(1) })
|
|
4923
|
+
});
|
|
4924
|
+
async function refreshGitHubPullRequestPreview(args) {
|
|
4925
|
+
const parsed = previewWebhookSchema.safeParse(args.body);
|
|
4926
|
+
if (!parsed.success) return;
|
|
4927
|
+
const { pull_request: pullRequest, repository: repository2 } = parsed.data;
|
|
4928
|
+
const conversationIds = await readGitHubPullRequestConversationIds(
|
|
4929
|
+
args.db,
|
|
4930
|
+
String(pullRequest.id)
|
|
4931
|
+
);
|
|
4932
|
+
if (conversationIds.length === 0) return;
|
|
4933
|
+
const key = `${repository2.full_name.toLowerCase()}#${pullRequest.number}`;
|
|
4934
|
+
const previewImageUrls = githubPreviewImageUrls(pullRequest.body);
|
|
4935
|
+
const updatedAt = Date.parse(pullRequest.updated_at);
|
|
4936
|
+
const results = await Promise.allSettled(
|
|
4937
|
+
conversationIds.map(async (conversationId) => {
|
|
4938
|
+
const store = args.annotations.forConversation(conversationId);
|
|
4939
|
+
const current = (await store.list()).find(
|
|
4940
|
+
(annotation2) => annotation2.key === key
|
|
4941
|
+
);
|
|
4942
|
+
if (current?.kind !== "object" || current.facts?.type !== "code_change") {
|
|
4943
|
+
return;
|
|
4944
|
+
}
|
|
4945
|
+
const storedAt = current.sourceUpdatedAt ? Date.parse(current.sourceUpdatedAt) : void 0;
|
|
4946
|
+
if (storedAt !== void 0 && storedAt > updatedAt) return;
|
|
4947
|
+
const {
|
|
4948
|
+
plugin: _plugin,
|
|
4949
|
+
createdAt: _createdAt,
|
|
4950
|
+
updatedAt: _updatedAt,
|
|
4951
|
+
facts: { previewImageUrls: previous, ...facts },
|
|
4952
|
+
...annotation
|
|
4953
|
+
} = current;
|
|
4954
|
+
const next = withGitHubPreviewImages(facts, previewImageUrls);
|
|
4955
|
+
if (previous?.join("\n") === next.previewImageUrls?.join("\n") && storedAt === updatedAt) {
|
|
4956
|
+
return;
|
|
4957
|
+
}
|
|
4958
|
+
await store.upsert({
|
|
4959
|
+
...annotation,
|
|
4960
|
+
facts: next,
|
|
4961
|
+
sourceUpdatedAt: pullRequest.updated_at
|
|
4962
|
+
});
|
|
4963
|
+
})
|
|
4964
|
+
);
|
|
4965
|
+
for (const result of results) {
|
|
4966
|
+
if (result.status === "fulfilled") continue;
|
|
4967
|
+
args.log?.error("GitHub pull request preview update failed", {
|
|
4968
|
+
errorType: result.reason instanceof Error ? result.reason.name : "UnknownError",
|
|
4969
|
+
number: pullRequest.number,
|
|
4970
|
+
repository: repository2.full_name
|
|
4971
|
+
});
|
|
4972
|
+
}
|
|
4973
|
+
}
|
|
4974
|
+
|
|
4263
4975
|
// src/webhooks/merge-conflict.ts
|
|
4264
|
-
import * as
|
|
4976
|
+
import * as z31 from "zod";
|
|
4265
4977
|
var EVENT_TYPE = "pull_request.merge_conflict";
|
|
4266
4978
|
var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
4267
4979
|
"pull_request.closed_unmerged",
|
|
4268
4980
|
"pull_request.merged"
|
|
4269
4981
|
]);
|
|
4270
|
-
var pullRequestSchema3 =
|
|
4271
|
-
base:
|
|
4272
|
-
number:
|
|
4273
|
-
head:
|
|
4274
|
-
html_url:
|
|
4275
|
-
mergeable:
|
|
4276
|
-
mergeable_state:
|
|
4277
|
-
state:
|
|
4982
|
+
var pullRequestSchema3 = z31.object({
|
|
4983
|
+
base: z31.object({ ref: z31.string().min(1) }),
|
|
4984
|
+
number: z31.number().int().positive().optional(),
|
|
4985
|
+
head: z31.object({ sha: z31.string().min(1) }),
|
|
4986
|
+
html_url: z31.string().min(1).optional(),
|
|
4987
|
+
mergeable: z31.boolean().nullable().optional(),
|
|
4988
|
+
mergeable_state: z31.string().optional(),
|
|
4989
|
+
state: z31.string()
|
|
4278
4990
|
});
|
|
4279
4991
|
function gitHubMergeConflictEvents(input) {
|
|
4280
4992
|
const { conflict } = input;
|
|
@@ -4308,7 +5020,7 @@ function pullRequestRefs(events) {
|
|
|
4308
5020
|
return [...refs.values()];
|
|
4309
5021
|
}
|
|
4310
5022
|
function deliveredPullRequest(payload, ref) {
|
|
4311
|
-
const parsed =
|
|
5023
|
+
const parsed = z31.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
|
|
4312
5024
|
const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
|
|
4313
5025
|
return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
|
|
4314
5026
|
}
|
|
@@ -4334,28 +5046,32 @@ async function loadGitHubMergeConflictEvents(args) {
|
|
|
4334
5046
|
})
|
|
4335
5047
|
);
|
|
4336
5048
|
} catch (error) {
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
5049
|
+
logFailOpenFailure(
|
|
5050
|
+
args.log,
|
|
5051
|
+
"GitHub pull request merge conflict check failed",
|
|
5052
|
+
error,
|
|
5053
|
+
{
|
|
5054
|
+
deliveryId: args.deliveryId,
|
|
5055
|
+
pullRequest: ref.number,
|
|
5056
|
+
repository: ref.repositoryFullName
|
|
5057
|
+
}
|
|
5058
|
+
);
|
|
4343
5059
|
}
|
|
4344
5060
|
}
|
|
4345
5061
|
return conflicts;
|
|
4346
5062
|
}
|
|
4347
5063
|
|
|
4348
5064
|
// src/merge-conflict-checks/webhooks.ts
|
|
4349
|
-
import * as
|
|
5065
|
+
import * as z33 from "zod";
|
|
4350
5066
|
|
|
4351
5067
|
// src/merge-conflict-checks/store.ts
|
|
4352
5068
|
import { and as and4, eq as eq4 } from "drizzle-orm";
|
|
4353
|
-
import * as
|
|
5069
|
+
import * as z32 from "zod";
|
|
4354
5070
|
var CHECK_TTL_MS = 30 * 6e4;
|
|
4355
|
-
var repeatSchema =
|
|
5071
|
+
var repeatSchema = z32.object({
|
|
4356
5072
|
/** Checks since the last push that ended with an unknown answer. */
|
|
4357
|
-
attempts:
|
|
4358
|
-
dueAtMs:
|
|
5073
|
+
attempts: z32.number().int().positive(),
|
|
5074
|
+
dueAtMs: z32.number()
|
|
4359
5075
|
});
|
|
4360
5076
|
function pushKey(repositoryFullName) {
|
|
4361
5077
|
return `merge-conflict-check:push:${repositoryFullName}`;
|
|
@@ -4423,12 +5139,12 @@ async function settleGitHubConflictCheck(state, check, retryAtMs) {
|
|
|
4423
5139
|
|
|
4424
5140
|
// src/merge-conflict-checks/webhooks.ts
|
|
4425
5141
|
var CONFLICT_CHECK_DELAY_MS = 2 * 6e4;
|
|
4426
|
-
var pushSchema =
|
|
4427
|
-
deleted:
|
|
4428
|
-
ref:
|
|
4429
|
-
repository:
|
|
4430
|
-
default_branch:
|
|
4431
|
-
full_name:
|
|
5142
|
+
var pushSchema = z33.object({
|
|
5143
|
+
deleted: z33.boolean().optional(),
|
|
5144
|
+
ref: z33.string(),
|
|
5145
|
+
repository: z33.object({
|
|
5146
|
+
default_branch: z33.string().min(1),
|
|
5147
|
+
full_name: z33.string().min(1)
|
|
4432
5148
|
})
|
|
4433
5149
|
});
|
|
4434
5150
|
async function scheduleGitHubPushConflictCheck(args) {
|
|
@@ -4445,10 +5161,10 @@ async function scheduleGitHubPushConflictCheck(args) {
|
|
|
4445
5161
|
}
|
|
4446
5162
|
|
|
4447
5163
|
// src/webhooks/pull-request-ready.ts
|
|
4448
|
-
import * as
|
|
5164
|
+
import * as z35 from "zod";
|
|
4449
5165
|
|
|
4450
5166
|
// src/webhooks/installation-requests.ts
|
|
4451
|
-
import * as
|
|
5167
|
+
import * as z34 from "zod";
|
|
4452
5168
|
function splitRepository(fullName, label) {
|
|
4453
5169
|
const [owner, name, ...extra] = fullName.split("/");
|
|
4454
5170
|
if (!owner || !name || extra.length > 0) {
|
|
@@ -4488,28 +5204,46 @@ async function loadPullRequest(env, pullRequest) {
|
|
|
4488
5204
|
{ token: token.token }
|
|
4489
5205
|
);
|
|
4490
5206
|
}
|
|
5207
|
+
var GitHubRepositoryUnreachableError = class extends Error {
|
|
5208
|
+
constructor(repositoryId) {
|
|
5209
|
+
super(`GitHub repository ${repositoryId} is not reachable`);
|
|
5210
|
+
this.name = "GitHubRepositoryUnreachableError";
|
|
5211
|
+
}
|
|
5212
|
+
};
|
|
5213
|
+
var UNREACHABLE_REPOSITORY_MESSAGE = /does not exist or is not accessible/i;
|
|
4491
5214
|
async function loadPullRequestLifecycles(env, input) {
|
|
5215
|
+
let token;
|
|
5216
|
+
try {
|
|
5217
|
+
token = await issueInstallationToken({
|
|
5218
|
+
...env,
|
|
5219
|
+
permissions: { pull_requests: "read" },
|
|
5220
|
+
repositoryIds: [input.repositoryId]
|
|
5221
|
+
});
|
|
5222
|
+
} catch (error) {
|
|
5223
|
+
if (error instanceof GitHubRequestError && error.status === 422 && UNREACHABLE_REPOSITORY_MESSAGE.test(error.message)) {
|
|
5224
|
+
throw new GitHubRepositoryUnreachableError(input.repositoryId);
|
|
5225
|
+
}
|
|
5226
|
+
throw error;
|
|
5227
|
+
}
|
|
5228
|
+
const repository2 = z34.object({ full_name: z34.string().min(1) }).parse(
|
|
5229
|
+
await githubRequest(
|
|
5230
|
+
"https://api.github.com",
|
|
5231
|
+
`/repositories/${input.repositoryId}`,
|
|
5232
|
+
{ token: token.token }
|
|
5233
|
+
)
|
|
5234
|
+
);
|
|
4492
5235
|
const { owner, name } = splitRepository(
|
|
4493
|
-
|
|
5236
|
+
repository2.full_name,
|
|
4494
5237
|
"pull request lifecycle"
|
|
4495
5238
|
);
|
|
4496
|
-
const token = await issueInstallationToken({
|
|
4497
|
-
...env,
|
|
4498
|
-
permissions: { pull_requests: "read" },
|
|
4499
|
-
repositories: [name]
|
|
4500
|
-
});
|
|
4501
|
-
const variables = input.numbers.map((_, index2) => `$n${index2}: Int!`);
|
|
4502
|
-
const pullRequests = input.numbers.map(
|
|
4503
|
-
(_, index2) => `pr${index2}: pullRequest(number: $n${index2}) { ...lifecycle }`
|
|
4504
|
-
);
|
|
4505
5239
|
return await githubRequest("https://api.github.com", "/graphql", {
|
|
4506
5240
|
body: {
|
|
4507
|
-
|
|
5241
|
+
...pullRequestLifecycles(input.numbers.length),
|
|
4508
5242
|
variables: {
|
|
4509
5243
|
name,
|
|
4510
5244
|
owner,
|
|
4511
5245
|
...Object.fromEntries(
|
|
4512
|
-
input.numbers.map((
|
|
5246
|
+
input.numbers.map((number33, index2) => [`n${index2}`, number33])
|
|
4513
5247
|
)
|
|
4514
5248
|
}
|
|
4515
5249
|
},
|
|
@@ -4529,7 +5263,7 @@ async function searchOpenPullRequestMergeability(env, input) {
|
|
|
4529
5263
|
});
|
|
4530
5264
|
return await githubRequest("https://api.github.com", "/graphql", {
|
|
4531
5265
|
body: {
|
|
4532
|
-
|
|
5266
|
+
...OPEN_PULL_REQUEST_MERGEABILITY,
|
|
4533
5267
|
variables: {
|
|
4534
5268
|
after: input.after ?? null,
|
|
4535
5269
|
query: `repo:${input.repositoryFullName} is:pr is:open author:${input.author}`
|
|
@@ -4539,6 +5273,26 @@ async function searchOpenPullRequestMergeability(env, input) {
|
|
|
4539
5273
|
token: token.token
|
|
4540
5274
|
});
|
|
4541
5275
|
}
|
|
5276
|
+
async function requestPullRequestReviewers2(env, input) {
|
|
5277
|
+
const { owner, name } = splitRepository(
|
|
5278
|
+
input.repositoryFullName,
|
|
5279
|
+
"pull request review request"
|
|
5280
|
+
);
|
|
5281
|
+
const token = await issueInstallationToken({
|
|
5282
|
+
...env,
|
|
5283
|
+
permissions: { pull_requests: "write" },
|
|
5284
|
+
repositories: [name]
|
|
5285
|
+
});
|
|
5286
|
+
await githubRequest(
|
|
5287
|
+
"https://api.github.com",
|
|
5288
|
+
`/repos/${encodeURIComponent(owner)}/${encodeURIComponent(name)}/pulls/${input.number}/requested_reviewers`,
|
|
5289
|
+
{
|
|
5290
|
+
body: { reviewers: input.reviewers },
|
|
5291
|
+
method: "POST",
|
|
5292
|
+
token: token.token
|
|
5293
|
+
}
|
|
5294
|
+
);
|
|
5295
|
+
}
|
|
4542
5296
|
async function markPullRequestFeedbackReviewing(env, target) {
|
|
4543
5297
|
const { owner, name } = splitRepository(target.repo, "pull request feedback");
|
|
4544
5298
|
const token = await issueInstallationToken({
|
|
@@ -4547,7 +5301,7 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
4547
5301
|
});
|
|
4548
5302
|
const content = pullRequestFeedbackReactionContent("reviewing");
|
|
4549
5303
|
if (target.commentKind === "review_body") {
|
|
4550
|
-
const review =
|
|
5304
|
+
const review = z34.object({ node_id: z34.string().min(1) }).parse(
|
|
4551
5305
|
await githubRequest(
|
|
4552
5306
|
"https://api.github.com",
|
|
4553
5307
|
pullRequestReviewPath({
|
|
@@ -4559,11 +5313,10 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
4559
5313
|
{ token: token.token }
|
|
4560
5314
|
)
|
|
4561
5315
|
);
|
|
4562
|
-
const result =
|
|
5316
|
+
const result = z34.object({ errors: z34.array(z34.unknown()).optional() }).parse(
|
|
4563
5317
|
await githubRequest("https://api.github.com", "/graphql", {
|
|
4564
5318
|
body: {
|
|
4565
|
-
|
|
4566
|
-
query: ADD_REVIEW_REACTION_MUTATION,
|
|
5319
|
+
...ADD_REVIEW_REACTION,
|
|
4567
5320
|
variables: {
|
|
4568
5321
|
content: graphqlReactionContent(content),
|
|
4569
5322
|
subjectId: review.node_id
|
|
@@ -4595,9 +5348,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
4595
5348
|
}
|
|
4596
5349
|
);
|
|
4597
5350
|
}
|
|
4598
|
-
var repositoryPermissionSchema =
|
|
4599
|
-
permission:
|
|
4600
|
-
role_name:
|
|
5351
|
+
var repositoryPermissionSchema = z34.object({
|
|
5352
|
+
permission: z34.string().min(1),
|
|
5353
|
+
role_name: z34.string().optional()
|
|
4601
5354
|
});
|
|
4602
5355
|
var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
|
|
4603
5356
|
async function loadRepositoryRole(env, cache, target) {
|
|
@@ -4627,19 +5380,19 @@ async function loadRepositoryRole(env, cache, target) {
|
|
|
4627
5380
|
}
|
|
4628
5381
|
);
|
|
4629
5382
|
}
|
|
4630
|
-
var pullRequestSchema4 =
|
|
4631
|
-
auto_merge:
|
|
4632
|
-
draft:
|
|
4633
|
-
html_url:
|
|
4634
|
-
mergeable_state:
|
|
4635
|
-
merged:
|
|
4636
|
-
state:
|
|
4637
|
-
title:
|
|
5383
|
+
var pullRequestSchema4 = z34.object({
|
|
5384
|
+
auto_merge: z34.object({}).nullable().optional(),
|
|
5385
|
+
draft: z34.boolean().optional(),
|
|
5386
|
+
html_url: z34.string().url(),
|
|
5387
|
+
mergeable_state: z34.string().nullable().optional(),
|
|
5388
|
+
merged: z34.boolean(),
|
|
5389
|
+
state: z34.enum(["open", "closed"]),
|
|
5390
|
+
title: z34.string()
|
|
4638
5391
|
});
|
|
4639
|
-
var reviewsSchema =
|
|
4640
|
-
|
|
4641
|
-
state:
|
|
4642
|
-
user:
|
|
5392
|
+
var reviewsSchema = z34.array(
|
|
5393
|
+
z34.object({
|
|
5394
|
+
state: z34.string(),
|
|
5395
|
+
user: z34.object({ login: z34.string() }).nullable()
|
|
4643
5396
|
})
|
|
4644
5397
|
);
|
|
4645
5398
|
async function loadPullRequestMergeState(env, pullRequest) {
|
|
@@ -4707,10 +5460,10 @@ var READY_ACTIONS = {
|
|
|
4707
5460
|
]),
|
|
4708
5461
|
pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
|
|
4709
5462
|
};
|
|
4710
|
-
var pullRequestWebhookSchema =
|
|
4711
|
-
action:
|
|
4712
|
-
pull_request:
|
|
4713
|
-
repository:
|
|
5463
|
+
var pullRequestWebhookSchema = z35.object({
|
|
5464
|
+
action: z35.string(),
|
|
5465
|
+
pull_request: z35.object({ number: z35.number().int().positive() }),
|
|
5466
|
+
repository: z35.object({ full_name: z35.string().min(1) })
|
|
4714
5467
|
});
|
|
4715
5468
|
function pullRequestReadyTargets(eventName, body) {
|
|
4716
5469
|
if (eventName === "check_suite") return checkSuitePullRequests(body);
|
|
@@ -4773,7 +5526,12 @@ async function syncOne(args, target) {
|
|
|
4773
5526
|
assigneeIdentityIds: [opener.identityId],
|
|
4774
5527
|
body: `**${state.title}** is approved, and GitHub says that it can merge: ${state.url}`,
|
|
4775
5528
|
dedupeKey,
|
|
4776
|
-
|
|
5529
|
+
// The number stays visible where a view shows only the subject.
|
|
5530
|
+
subject: {
|
|
5531
|
+
id: state.url,
|
|
5532
|
+
title: `${state.title} (#${target.number})`,
|
|
5533
|
+
url: state.url
|
|
5534
|
+
},
|
|
4777
5535
|
title: `Ready to merge \xB7 #${target.number}`,
|
|
4778
5536
|
waitsOnAssignees: true
|
|
4779
5537
|
});
|
|
@@ -4798,43 +5556,83 @@ async function syncGitHubPullRequestReadyNotices(args) {
|
|
|
4798
5556
|
try {
|
|
4799
5557
|
await syncOne(args, target);
|
|
4800
5558
|
} catch (error) {
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
5559
|
+
logFailOpenFailure(
|
|
5560
|
+
args.log,
|
|
5561
|
+
"GitHub pull request ready notice failed",
|
|
5562
|
+
error,
|
|
5563
|
+
{
|
|
5564
|
+
deliveryId: args.deliveryId,
|
|
5565
|
+
number: target.number,
|
|
5566
|
+
repository: target.repositoryFullName
|
|
5567
|
+
}
|
|
5568
|
+
);
|
|
4807
5569
|
}
|
|
4808
5570
|
}
|
|
4809
5571
|
}
|
|
4810
5572
|
|
|
5573
|
+
// src/webhooks/pull-request-ready-reviewers.ts
|
|
5574
|
+
import * as z36 from "zod";
|
|
5575
|
+
var readyForReviewSchema = z36.object({
|
|
5576
|
+
action: z36.literal("ready_for_review"),
|
|
5577
|
+
pull_request: z36.object({ number: z36.number().int().positive() }),
|
|
5578
|
+
repository: z36.object({ full_name: z36.string().min(1) })
|
|
5579
|
+
});
|
|
5580
|
+
async function requestGitHubReviewersWhenReady(args) {
|
|
5581
|
+
if (args.eventName !== "pull_request") return;
|
|
5582
|
+
const parsed = readyForReviewSchema.safeParse(args.body);
|
|
5583
|
+
if (!parsed.success) return;
|
|
5584
|
+
const target = {
|
|
5585
|
+
number: parsed.data.pull_request.number,
|
|
5586
|
+
repositoryFullName: parsed.data.repository.full_name
|
|
5587
|
+
};
|
|
5588
|
+
try {
|
|
5589
|
+
const opener = (await listGitHubPullRequestOpeners(args.db, {
|
|
5590
|
+
numbers: [target.number],
|
|
5591
|
+
repositoryFullName: target.repositoryFullName
|
|
5592
|
+
})).get(target.number);
|
|
5593
|
+
if (!opener?.conversationId) return;
|
|
5594
|
+
const named = await readGitHubDraftReviewers(args.state, target);
|
|
5595
|
+
const requester = named ? void 0 : await args.loadGitHubLogin?.(opener.identityId);
|
|
5596
|
+
const reviewers = named ?? (requester ? [requester] : []);
|
|
5597
|
+
if (reviewers.length === 0) return;
|
|
5598
|
+
await requestPullRequestReviewers2(args.env, { ...target, reviewers });
|
|
5599
|
+
} catch (error) {
|
|
5600
|
+
args.log?.warn("GitHub pull request review request failed", {
|
|
5601
|
+
deliveryId: args.deliveryId,
|
|
5602
|
+
errorType: error instanceof Error ? error.name : "UnknownError",
|
|
5603
|
+
number: target.number,
|
|
5604
|
+
repository: target.repositoryFullName
|
|
5605
|
+
});
|
|
5606
|
+
}
|
|
5607
|
+
}
|
|
5608
|
+
|
|
4811
5609
|
// src/webhooks/pull-request-review-request.ts
|
|
4812
|
-
import * as
|
|
4813
|
-
var login =
|
|
4814
|
-
var pullRequestEventSchema =
|
|
4815
|
-
action:
|
|
5610
|
+
import * as z37 from "zod";
|
|
5611
|
+
var login = z37.object({ login: z37.string().min(1) });
|
|
5612
|
+
var pullRequestEventSchema = z37.object({
|
|
5613
|
+
action: z37.enum([
|
|
4816
5614
|
"closed",
|
|
4817
5615
|
"reopened",
|
|
4818
5616
|
"review_request_removed",
|
|
4819
5617
|
"review_requested"
|
|
4820
5618
|
]),
|
|
4821
|
-
pull_request:
|
|
4822
|
-
html_url:
|
|
4823
|
-
merged:
|
|
4824
|
-
number:
|
|
5619
|
+
pull_request: z37.object({
|
|
5620
|
+
html_url: z37.string().url(),
|
|
5621
|
+
merged: z37.boolean().optional(),
|
|
5622
|
+
number: z37.number().int().positive(),
|
|
4825
5623
|
// The people whose review is still requested. Teams are listed apart.
|
|
4826
|
-
requested_reviewers:
|
|
4827
|
-
title:
|
|
5624
|
+
requested_reviewers: z37.array(login).optional(),
|
|
5625
|
+
title: z37.string()
|
|
4828
5626
|
}),
|
|
4829
|
-
repository:
|
|
5627
|
+
repository: z37.object({ full_name: z37.string().min(1) }),
|
|
4830
5628
|
// A team request has `requested_team` instead.
|
|
4831
5629
|
requested_reviewer: login.optional()
|
|
4832
5630
|
});
|
|
4833
|
-
var reviewEventSchema =
|
|
4834
|
-
action:
|
|
4835
|
-
pull_request:
|
|
4836
|
-
repository:
|
|
4837
|
-
review:
|
|
5631
|
+
var reviewEventSchema = z37.object({
|
|
5632
|
+
action: z37.literal("submitted"),
|
|
5633
|
+
pull_request: z37.object({ number: z37.number().int().positive() }),
|
|
5634
|
+
repository: z37.object({ full_name: z37.string().min(1) }),
|
|
5635
|
+
review: z37.object({ user: login })
|
|
4838
5636
|
});
|
|
4839
5637
|
function reviewRequestChange(eventName, body) {
|
|
4840
5638
|
if (eventName === "pull_request_review") {
|
|
@@ -4915,14 +5713,14 @@ function sameLogin(left, right) {
|
|
|
4915
5713
|
async function syncGitHubPullRequestReviewRequest(args) {
|
|
4916
5714
|
const parsed = reviewRequestChange(args.eventName, args.body);
|
|
4917
5715
|
if (!parsed) return;
|
|
4918
|
-
const { change, number:
|
|
5716
|
+
const { change, number: number33, repository: repository2 } = parsed;
|
|
4919
5717
|
try {
|
|
4920
5718
|
const opener = (await listGitHubPullRequestOpeners(args.db, {
|
|
4921
|
-
numbers: [
|
|
5719
|
+
numbers: [number33],
|
|
4922
5720
|
repositoryFullName: repository2
|
|
4923
|
-
})).get(
|
|
5721
|
+
})).get(number33);
|
|
4924
5722
|
if (!opener?.conversationId) return;
|
|
4925
|
-
const name = `${repository2}#${
|
|
5723
|
+
const name = `${repository2}#${number33}`;
|
|
4926
5724
|
const dedupeKey = `pull-request-review-requested:${name.toLowerCase()}`;
|
|
4927
5725
|
const items = args.reviewItems.forConversation(opener.conversationId);
|
|
4928
5726
|
const reviewers = change.kind === "requested" ? change.reviewers : change.reviewer === void 0 ? void 0 : [change.reviewer];
|
|
@@ -4944,22 +5742,27 @@ async function syncGitHubPullRequestReviewRequest(args) {
|
|
|
4944
5742
|
assigneeIdentityIds: [opener.identityId],
|
|
4945
5743
|
body: `GitHub asks you to review **${change.title}**: ${change.url}`,
|
|
4946
5744
|
dedupeKey,
|
|
4947
|
-
|
|
4948
|
-
|
|
5745
|
+
// The number stays visible where a view shows only the subject title.
|
|
5746
|
+
subject: {
|
|
5747
|
+
id: change.url,
|
|
5748
|
+
title: `${change.title} (#${number33})`,
|
|
5749
|
+
url: change.url
|
|
5750
|
+
},
|
|
5751
|
+
title: `Review requested \xB7 #${number33}`,
|
|
4949
5752
|
waitsOnAssignees: true
|
|
4950
5753
|
});
|
|
4951
5754
|
} catch (error) {
|
|
4952
5755
|
args.log?.error("GitHub pull request review request failed", {
|
|
4953
5756
|
deliveryId: args.deliveryId,
|
|
4954
5757
|
errorType: error instanceof Error ? error.name : "UnknownError",
|
|
4955
|
-
number:
|
|
5758
|
+
number: number33,
|
|
4956
5759
|
repository: repository2
|
|
4957
5760
|
});
|
|
4958
5761
|
}
|
|
4959
5762
|
}
|
|
4960
5763
|
|
|
4961
5764
|
// src/webhooks/pull-request-match-data.ts
|
|
4962
|
-
import * as
|
|
5765
|
+
import * as z38 from "zod";
|
|
4963
5766
|
var LOOKUPS_BY_MATCH_KEY = {
|
|
4964
5767
|
authors: ["authors"],
|
|
4965
5768
|
openerEmail: ["opener"],
|
|
@@ -4967,22 +5770,22 @@ var LOOKUPS_BY_MATCH_KEY = {
|
|
|
4967
5770
|
openerUsername: ["opener"]
|
|
4968
5771
|
};
|
|
4969
5772
|
var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
|
|
4970
|
-
var lookupDataSchema =
|
|
4971
|
-
authors:
|
|
4972
|
-
openerRole:
|
|
4973
|
-
openerUsername:
|
|
5773
|
+
var lookupDataSchema = z38.object({
|
|
5774
|
+
authors: z38.array(z38.string().min(1)).min(1).optional(),
|
|
5775
|
+
openerRole: z38.string().min(1).optional(),
|
|
5776
|
+
openerUsername: z38.string().min(1).optional()
|
|
4974
5777
|
}).strict();
|
|
4975
5778
|
function lookupData(input) {
|
|
4976
5779
|
return lookupDataSchema.parse(definedValues(input));
|
|
4977
5780
|
}
|
|
4978
|
-
var webhookSchema =
|
|
4979
|
-
repository:
|
|
5781
|
+
var webhookSchema = z38.object({
|
|
5782
|
+
repository: z38.object({ full_name: z38.string().min(1) })
|
|
4980
5783
|
});
|
|
4981
5784
|
function pullRequestNumbers(events) {
|
|
4982
5785
|
const numbers = /* @__PURE__ */ new Map();
|
|
4983
5786
|
for (const event of events) {
|
|
4984
|
-
const
|
|
4985
|
-
if (typeof
|
|
5787
|
+
const number33 = event.data?.pullRequest;
|
|
5788
|
+
if (typeof number33 === "number") numbers.set(event.eventKey, number33);
|
|
4986
5789
|
}
|
|
4987
5790
|
return numbers;
|
|
4988
5791
|
}
|
|
@@ -4996,8 +5799,8 @@ function logFailure(context, lookup, error) {
|
|
|
4996
5799
|
}
|
|
4997
5800
|
async function withJuniorOpeners(context, events) {
|
|
4998
5801
|
const botNumber = (event) => {
|
|
4999
|
-
const
|
|
5000
|
-
return
|
|
5802
|
+
const number33 = context.numbers.get(event.eventKey);
|
|
5803
|
+
return number33 !== void 0 && isBotLogin(event.data?.openerUsername, context.botEmail) ? number33 : void 0;
|
|
5001
5804
|
};
|
|
5002
5805
|
const numbers = events.flatMap((event) => botNumber(event) ?? []);
|
|
5003
5806
|
if (numbers.length === 0) return events;
|
|
@@ -5016,9 +5819,9 @@ async function withJuniorOpeners(context, events) {
|
|
|
5016
5819
|
}
|
|
5017
5820
|
}
|
|
5018
5821
|
return events.map((event) => {
|
|
5019
|
-
const
|
|
5020
|
-
if (
|
|
5021
|
-
const identityId = openers.get(
|
|
5822
|
+
const number33 = botNumber(event);
|
|
5823
|
+
if (number33 === void 0) return event;
|
|
5824
|
+
const identityId = openers.get(number33)?.identityId;
|
|
5022
5825
|
const login2 = identityId ? logins.get(identityId) : void 0;
|
|
5023
5826
|
const {
|
|
5024
5827
|
openerEmail: _email,
|
|
@@ -5040,8 +5843,8 @@ async function withRolesAndAuthors(context, events, lookups) {
|
|
|
5040
5843
|
if (!loadRole && !loadAuthors) return events;
|
|
5041
5844
|
return await Promise.all(
|
|
5042
5845
|
events.map(async (event) => {
|
|
5043
|
-
const
|
|
5044
|
-
if (
|
|
5846
|
+
const number33 = context.numbers.get(event.eventKey);
|
|
5847
|
+
if (number33 === void 0) return event;
|
|
5045
5848
|
const login2 = event.data?.openerUsername;
|
|
5046
5849
|
if (loadRole && typeof login2 === "string" && !roles.has(login2)) {
|
|
5047
5850
|
roles.set(
|
|
@@ -5051,16 +5854,16 @@ async function withRolesAndAuthors(context, events, lookups) {
|
|
|
5051
5854
|
)
|
|
5052
5855
|
);
|
|
5053
5856
|
}
|
|
5054
|
-
if (loadAuthors && !authors.has(
|
|
5857
|
+
if (loadAuthors && !authors.has(number33)) {
|
|
5055
5858
|
authors.set(
|
|
5056
|
-
|
|
5057
|
-
loadAuthors({ number:
|
|
5859
|
+
number33,
|
|
5860
|
+
loadAuthors({ number: number33, repositoryFullName }).catch(
|
|
5058
5861
|
(error) => logFailure(context, "authors", error)
|
|
5059
5862
|
)
|
|
5060
5863
|
);
|
|
5061
5864
|
}
|
|
5062
5865
|
const role = loadRole && typeof login2 === "string" ? await roles.get(login2) : void 0;
|
|
5063
|
-
const logins = loadAuthors ? await authors.get(
|
|
5866
|
+
const logins = loadAuthors ? await authors.get(number33) : void 0;
|
|
5064
5867
|
if (!role && !logins?.length) return event;
|
|
5065
5868
|
return {
|
|
5066
5869
|
...event,
|
|
@@ -5117,7 +5920,7 @@ async function withGitHubPullRequestMatchData(args) {
|
|
|
5117
5920
|
}
|
|
5118
5921
|
|
|
5119
5922
|
// src/webhooks/pull-request-people.ts
|
|
5120
|
-
import * as
|
|
5923
|
+
import * as z39 from "zod";
|
|
5121
5924
|
var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
|
|
5122
5925
|
"pull_request.review.approved",
|
|
5123
5926
|
"pull_request.merged"
|
|
@@ -5127,18 +5930,18 @@ var PAGE_SIZE = 100;
|
|
|
5127
5930
|
var MAX_PAGES = 3;
|
|
5128
5931
|
var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
|
|
5129
5932
|
var GITHUB_NOREPLY_EMAIL = /^(?:\d+\+)?(?<login>[^@+]+)@users\.noreply\.github\.com$/i;
|
|
5130
|
-
var webhookSchema2 =
|
|
5131
|
-
pull_request:
|
|
5132
|
-
assignees:
|
|
5133
|
-
number:
|
|
5134
|
-
user:
|
|
5933
|
+
var webhookSchema2 = z39.object({
|
|
5934
|
+
pull_request: z39.object({
|
|
5935
|
+
assignees: z39.array(z39.object({ login: z39.string().min(1) })).nullish(),
|
|
5936
|
+
number: z39.number(),
|
|
5937
|
+
user: z39.object({ login: z39.string().min(1) }).nullish()
|
|
5135
5938
|
}),
|
|
5136
|
-
repository:
|
|
5939
|
+
repository: z39.object({ full_name: z39.string().min(1) })
|
|
5137
5940
|
});
|
|
5138
|
-
var commitPageSchema =
|
|
5139
|
-
|
|
5140
|
-
author:
|
|
5141
|
-
commit:
|
|
5941
|
+
var commitPageSchema = z39.array(
|
|
5942
|
+
z39.object({
|
|
5943
|
+
author: z39.object({ login: z39.string().min(1) }).nullish(),
|
|
5944
|
+
commit: z39.object({ message: z39.string() })
|
|
5142
5945
|
})
|
|
5143
5946
|
);
|
|
5144
5947
|
function shareCommitPages(load) {
|
|
@@ -5160,11 +5963,11 @@ function shareCommitPages(load) {
|
|
|
5160
5963
|
return await result;
|
|
5161
5964
|
};
|
|
5162
5965
|
}
|
|
5163
|
-
async function forEachCommit(loadPage,
|
|
5966
|
+
async function forEachCommit(loadPage, visit2) {
|
|
5164
5967
|
for (let page = 1; page <= MAX_PAGES; page += 1) {
|
|
5165
5968
|
const commits = commitPageSchema.parse(await loadPage(page, PAGE_SIZE));
|
|
5166
5969
|
for (const commit of commits) {
|
|
5167
|
-
|
|
5970
|
+
visit2({
|
|
5168
5971
|
coAuthorEmails: [
|
|
5169
5972
|
...commit.commit.message.matchAll(CO_AUTHOR_TRAILER)
|
|
5170
5973
|
].map((match) => match[1]),
|
|
@@ -5280,11 +6083,11 @@ function webhookInstallationId(body) {
|
|
|
5280
6083
|
}
|
|
5281
6084
|
return parseInstallationId(installation.id);
|
|
5282
6085
|
}
|
|
5283
|
-
var feedbackTargetSchema =
|
|
5284
|
-
commentId:
|
|
5285
|
-
commentKind:
|
|
5286
|
-
pullRequest:
|
|
5287
|
-
repo:
|
|
6086
|
+
var feedbackTargetSchema = z40.object({
|
|
6087
|
+
commentId: z40.number(),
|
|
6088
|
+
commentKind: z40.enum(["conversation", "review", "review_body"]),
|
|
6089
|
+
pullRequest: z40.number(),
|
|
6090
|
+
repo: z40.string().min(1)
|
|
5288
6091
|
});
|
|
5289
6092
|
function pullRequestFeedbackTarget(events) {
|
|
5290
6093
|
for (const event of events) {
|
|
@@ -5397,6 +6200,14 @@ function createGitHubWebhookRoute(args) {
|
|
|
5397
6200
|
providerId: pullRequestConversations.pullRequestId
|
|
5398
6201
|
});
|
|
5399
6202
|
}
|
|
6203
|
+
if (eventName === "pull_request") {
|
|
6204
|
+
await refreshGitHubPullRequestPreview({
|
|
6205
|
+
annotations: args.annotations,
|
|
6206
|
+
body,
|
|
6207
|
+
db: args.db,
|
|
6208
|
+
log: args.log
|
|
6209
|
+
});
|
|
6210
|
+
}
|
|
5400
6211
|
const pullRequestActivity = normalizeGitHubPullRequestActivity({
|
|
5401
6212
|
body,
|
|
5402
6213
|
eventName
|
|
@@ -5498,6 +6309,20 @@ function createGitHubWebhookRoute(args) {
|
|
|
5498
6309
|
reviewItems: args.reviewItems,
|
|
5499
6310
|
targets: pullRequestReadyTargets(eventName, body)
|
|
5500
6311
|
});
|
|
6312
|
+
await requestGitHubReviewersWhenReady({
|
|
6313
|
+
body,
|
|
6314
|
+
db: args.db,
|
|
6315
|
+
deliveryId,
|
|
6316
|
+
env: {
|
|
6317
|
+
appIdEnv: args.appIdEnv,
|
|
6318
|
+
installationIdEnv: args.installationIdEnv,
|
|
6319
|
+
privateKeyEnv: args.privateKeyEnv
|
|
6320
|
+
},
|
|
6321
|
+
eventName,
|
|
6322
|
+
loadGitHubLogin: args.loadGitHubLogin,
|
|
6323
|
+
log: args.log,
|
|
6324
|
+
state: args.state
|
|
6325
|
+
});
|
|
5501
6326
|
await syncGitHubPullRequestReviewRequest({
|
|
5502
6327
|
body,
|
|
5503
6328
|
db: args.db,
|
|
@@ -5516,30 +6341,30 @@ function createGitHubWebhookRoute(args) {
|
|
|
5516
6341
|
}
|
|
5517
6342
|
|
|
5518
6343
|
// src/merge-conflict-checks/heartbeat.ts
|
|
5519
|
-
import * as
|
|
6344
|
+
import * as z41 from "zod";
|
|
5520
6345
|
var CHECK_LIMIT = 10;
|
|
5521
6346
|
var MAX_PAGES2 = 5;
|
|
5522
6347
|
var CLAIM_MS = 5 * 6e4;
|
|
5523
6348
|
var UNKNOWN_RETRY_MS = 6e4;
|
|
5524
6349
|
var MAX_ATTEMPTS = 5;
|
|
5525
|
-
var searchNodeSchema =
|
|
5526
|
-
|
|
5527
|
-
baseRefName:
|
|
5528
|
-
headRefOid:
|
|
5529
|
-
mergeable:
|
|
5530
|
-
number:
|
|
5531
|
-
state:
|
|
5532
|
-
url:
|
|
6350
|
+
var searchNodeSchema = z41.union([
|
|
6351
|
+
z41.object({
|
|
6352
|
+
baseRefName: z41.string().min(1),
|
|
6353
|
+
headRefOid: z41.string().min(1),
|
|
6354
|
+
mergeable: z41.enum(["CONFLICTING", "MERGEABLE", "UNKNOWN"]),
|
|
6355
|
+
number: z41.number().int().positive(),
|
|
6356
|
+
state: z41.string(),
|
|
6357
|
+
url: z41.string().min(1)
|
|
5533
6358
|
}),
|
|
5534
|
-
|
|
6359
|
+
z41.object({}).strict()
|
|
5535
6360
|
]);
|
|
5536
|
-
var searchResponseSchema =
|
|
5537
|
-
data:
|
|
5538
|
-
search:
|
|
5539
|
-
nodes:
|
|
5540
|
-
pageInfo:
|
|
5541
|
-
endCursor:
|
|
5542
|
-
hasNextPage:
|
|
6361
|
+
var searchResponseSchema = z41.object({
|
|
6362
|
+
data: z41.object({
|
|
6363
|
+
search: z41.object({
|
|
6364
|
+
nodes: z41.array(searchNodeSchema.nullable()),
|
|
6365
|
+
pageInfo: z41.object({
|
|
6366
|
+
endCursor: z41.string().nullable(),
|
|
6367
|
+
hasNextPage: z41.boolean()
|
|
5543
6368
|
})
|
|
5544
6369
|
})
|
|
5545
6370
|
})
|
|
@@ -5613,40 +6438,40 @@ async function runGitHubConflictChecks(args) {
|
|
|
5613
6438
|
}
|
|
5614
6439
|
|
|
5615
6440
|
// src/pull-request-outcomes/reconcile.ts
|
|
5616
|
-
import * as
|
|
6441
|
+
import * as z42 from "zod";
|
|
5617
6442
|
var RECONCILE_MS = 24 * 60 * 6e4;
|
|
5618
6443
|
var REPOSITORY_LIMIT = 1;
|
|
5619
6444
|
var PULL_REQUESTS_PER_QUERY = 100;
|
|
5620
|
-
var lifecycleSchema =
|
|
5621
|
-
assignees:
|
|
5622
|
-
nodes:
|
|
6445
|
+
var lifecycleSchema = z42.object({
|
|
6446
|
+
assignees: z42.object({
|
|
6447
|
+
nodes: z42.array(z42.object({ login: z42.string().min(1) }).nullable())
|
|
5623
6448
|
}),
|
|
5624
6449
|
// GraphQL omits the `[bot]` suffix that REST and webhooks give an app.
|
|
5625
|
-
author:
|
|
5626
|
-
closedAt:
|
|
5627
|
-
createdAt:
|
|
5628
|
-
databaseId:
|
|
5629
|
-
headRefName:
|
|
5630
|
-
isDraft:
|
|
5631
|
-
merged:
|
|
5632
|
-
mergedAt:
|
|
5633
|
-
number:
|
|
5634
|
-
state:
|
|
5635
|
-
title:
|
|
5636
|
-
updatedAt:
|
|
6450
|
+
author: z42.object({ __typename: z42.string(), login: z42.string().min(1) }).nullable(),
|
|
6451
|
+
closedAt: z42.string().nullable(),
|
|
6452
|
+
createdAt: z42.string(),
|
|
6453
|
+
databaseId: z42.number().int().positive(),
|
|
6454
|
+
headRefName: z42.string(),
|
|
6455
|
+
isDraft: z42.boolean(),
|
|
6456
|
+
merged: z42.boolean(),
|
|
6457
|
+
mergedAt: z42.string().nullable(),
|
|
6458
|
+
number: z42.number().int().positive(),
|
|
6459
|
+
state: z42.enum(["OPEN", "CLOSED", "MERGED"]),
|
|
6460
|
+
title: z42.string(),
|
|
6461
|
+
updatedAt: z42.string()
|
|
5637
6462
|
});
|
|
5638
|
-
var lifecyclesResponseSchema =
|
|
5639
|
-
data:
|
|
5640
|
-
repository:
|
|
5641
|
-
databaseId:
|
|
5642
|
-
nameWithOwner:
|
|
6463
|
+
var lifecyclesResponseSchema = z42.object({
|
|
6464
|
+
data: z42.object({
|
|
6465
|
+
repository: z42.object({
|
|
6466
|
+
databaseId: z42.number().int().positive(),
|
|
6467
|
+
nameWithOwner: z42.string().min(1)
|
|
5643
6468
|
}).catchall(lifecycleSchema.nullable())
|
|
5644
6469
|
})
|
|
5645
6470
|
});
|
|
5646
|
-
function
|
|
6471
|
+
function webhookBody(action, repository2, pullRequest) {
|
|
5647
6472
|
const login2 = pullRequest.author?.login ?? "ghost";
|
|
5648
6473
|
return {
|
|
5649
|
-
action
|
|
6474
|
+
action,
|
|
5650
6475
|
pull_request: {
|
|
5651
6476
|
assignees: pullRequest.assignees.nodes.flatMap(
|
|
5652
6477
|
(assignee) => assignee ? [{ login: assignee.login }] : []
|
|
@@ -5671,17 +6496,65 @@ function closedWebhookBody(repository2, pullRequest) {
|
|
|
5671
6496
|
}
|
|
5672
6497
|
};
|
|
5673
6498
|
}
|
|
5674
|
-
async function
|
|
6499
|
+
async function reconcileDraft(args, repository2, pullRequest) {
|
|
6500
|
+
const outcome = normalizeGitHubPullRequestOutcome({
|
|
6501
|
+
body: webhookBody(
|
|
6502
|
+
pullRequest.isDraft ? "converted_to_draft" : "ready_for_review",
|
|
6503
|
+
repository2,
|
|
6504
|
+
pullRequest
|
|
6505
|
+
),
|
|
6506
|
+
botEmail: args.botEmail
|
|
6507
|
+
});
|
|
6508
|
+
if (!outcome) return;
|
|
6509
|
+
await applyGitHubPullRequestOutcome({
|
|
6510
|
+
annotations: args.annotations,
|
|
6511
|
+
codeChanges: args.codeChanges,
|
|
6512
|
+
db: args.db,
|
|
6513
|
+
log: args.log,
|
|
6514
|
+
outcome
|
|
6515
|
+
});
|
|
6516
|
+
}
|
|
6517
|
+
async function reconcileRepository(args, repositoryId, drafts) {
|
|
6518
|
+
const numbers = [...drafts.keys()];
|
|
5675
6519
|
for (let start = 0; start < numbers.length; start += PULL_REQUESTS_PER_QUERY) {
|
|
5676
6520
|
const { databaseId, nameWithOwner, ...pullRequests } = lifecyclesResponseSchema.parse(
|
|
5677
6521
|
await args.loadLifecycles({
|
|
5678
6522
|
numbers: numbers.slice(start, start + PULL_REQUESTS_PER_QUERY),
|
|
5679
|
-
|
|
6523
|
+
repositoryId
|
|
5680
6524
|
})
|
|
5681
6525
|
).data.repository;
|
|
5682
6526
|
for (const pullRequest of Object.values(pullRequests)) {
|
|
5683
|
-
if (!pullRequest
|
|
5684
|
-
|
|
6527
|
+
if (!pullRequest) continue;
|
|
6528
|
+
if (pullRequest.state === "OPEN") {
|
|
6529
|
+
if (pullRequest.isDraft !== drafts.get(pullRequest.number)) {
|
|
6530
|
+
await reconcileDraft(
|
|
6531
|
+
args,
|
|
6532
|
+
{ databaseId, nameWithOwner },
|
|
6533
|
+
pullRequest
|
|
6534
|
+
);
|
|
6535
|
+
continue;
|
|
6536
|
+
}
|
|
6537
|
+
await args.codeChanges.record(
|
|
6538
|
+
githubCodeChange(
|
|
6539
|
+
{
|
|
6540
|
+
candidateOwned: false,
|
|
6541
|
+
draft: pullRequest.isDraft,
|
|
6542
|
+
number: pullRequest.number,
|
|
6543
|
+
openedAt: new Date(pullRequest.createdAt),
|
|
6544
|
+
pullRequestId: String(pullRequest.databaseId),
|
|
6545
|
+
repositoryFullName: nameWithOwner,
|
|
6546
|
+
repositoryId: String(databaseId),
|
|
6547
|
+
state: "open",
|
|
6548
|
+
title: pullRequest.title,
|
|
6549
|
+
updatedAt: new Date(pullRequest.updatedAt)
|
|
6550
|
+
},
|
|
6551
|
+
[]
|
|
6552
|
+
)
|
|
6553
|
+
);
|
|
6554
|
+
continue;
|
|
6555
|
+
}
|
|
6556
|
+
const body = webhookBody(
|
|
6557
|
+
"closed",
|
|
5685
6558
|
{ databaseId, nameWithOwner },
|
|
5686
6559
|
pullRequest
|
|
5687
6560
|
);
|
|
@@ -5715,32 +6588,45 @@ async function reconcileRepository(args, repositoryFullName, numbers) {
|
|
|
5715
6588
|
}
|
|
5716
6589
|
}
|
|
5717
6590
|
async function reconcileGitHubPullRequests(args) {
|
|
5718
|
-
const
|
|
6591
|
+
const repositories = /* @__PURE__ */ new Map();
|
|
5719
6592
|
for (const row of await listGitHubStaleOpenPullRequests(
|
|
5720
6593
|
args.db,
|
|
5721
6594
|
new Date(args.nowMs - RECONCILE_MS)
|
|
5722
6595
|
)) {
|
|
5723
|
-
const
|
|
5724
|
-
|
|
5725
|
-
|
|
6596
|
+
const repository2 = repositories.get(row.repositoryId) ?? {
|
|
6597
|
+
drafts: /* @__PURE__ */ new Map(),
|
|
6598
|
+
name: row.repositoryFullName
|
|
6599
|
+
};
|
|
6600
|
+
repository2.drafts.set(row.number, row.draft);
|
|
6601
|
+
repositories.set(row.repositoryId, repository2);
|
|
5726
6602
|
}
|
|
5727
6603
|
let reconciled = 0;
|
|
5728
|
-
for (const [
|
|
6604
|
+
for (const [
|
|
6605
|
+
repositoryId,
|
|
6606
|
+
{ drafts, name: repositoryFullName }
|
|
6607
|
+
] of repositories) {
|
|
5729
6608
|
if (reconciled >= REPOSITORY_LIMIT) break;
|
|
5730
6609
|
const claimed = await args.state.setIfNotExists(
|
|
5731
|
-
`pull-request-reconcile:${
|
|
6610
|
+
`pull-request-reconcile:${repositoryId}`,
|
|
5732
6611
|
args.nowMs,
|
|
5733
6612
|
RECONCILE_MS
|
|
5734
6613
|
);
|
|
5735
6614
|
if (!claimed) continue;
|
|
5736
6615
|
reconciled += 1;
|
|
5737
6616
|
try {
|
|
5738
|
-
await reconcileRepository(args,
|
|
6617
|
+
await reconcileRepository(args, Number(repositoryId), drafts);
|
|
5739
6618
|
} catch (error) {
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
6619
|
+
if (error instanceof GitHubRepositoryUnreachableError) {
|
|
6620
|
+
args.log.warn("GitHub pull request reconcile skipped a repository", {
|
|
6621
|
+
repository: repositoryFullName,
|
|
6622
|
+
repositoryId
|
|
6623
|
+
});
|
|
6624
|
+
} else {
|
|
6625
|
+
args.log.error("GitHub pull request reconcile failed", {
|
|
6626
|
+
errorType: error instanceof Error ? error.name : "UnknownError",
|
|
6627
|
+
repository: repositoryFullName
|
|
6628
|
+
});
|
|
6629
|
+
}
|
|
5744
6630
|
}
|
|
5745
6631
|
}
|
|
5746
6632
|
}
|
|
@@ -5769,30 +6655,30 @@ function gitHubResourceUrl(input) {
|
|
|
5769
6655
|
if (input.resourceType === "repository") {
|
|
5770
6656
|
return `https://github.com/${input.identifier}`;
|
|
5771
6657
|
}
|
|
5772
|
-
const [repo,
|
|
5773
|
-
if (!repo || !
|
|
6658
|
+
const [repo, number33] = input.identifier.split("#");
|
|
6659
|
+
if (!repo || !number33) return void 0;
|
|
5774
6660
|
if (input.resourceType === "pull_request") {
|
|
5775
|
-
return `https://github.com/${repo}/pull/${
|
|
6661
|
+
return `https://github.com/${repo}/pull/${number33}`;
|
|
5776
6662
|
}
|
|
5777
6663
|
if (input.resourceType === "issue") {
|
|
5778
|
-
return `https://github.com/${repo}/issues/${
|
|
6664
|
+
return `https://github.com/${repo}/issues/${number33}`;
|
|
5779
6665
|
}
|
|
5780
6666
|
return void 0;
|
|
5781
6667
|
}
|
|
5782
6668
|
|
|
5783
6669
|
// src/pull-request-outcomes/commit-composition.ts
|
|
5784
|
-
import * as
|
|
5785
|
-
var canonicalCommitSchema =
|
|
5786
|
-
authorEmail:
|
|
5787
|
-
authorLogin:
|
|
6670
|
+
import * as z43 from "zod";
|
|
6671
|
+
var canonicalCommitSchema = z43.object({
|
|
6672
|
+
authorEmail: z43.string().nullable(),
|
|
6673
|
+
authorLogin: z43.string().nullable()
|
|
5788
6674
|
}).strict();
|
|
5789
|
-
var providerCommitSchema =
|
|
5790
|
-
author:
|
|
5791
|
-
commit:
|
|
5792
|
-
author:
|
|
6675
|
+
var providerCommitSchema = z43.object({
|
|
6676
|
+
author: z43.object({ login: z43.string() }).passthrough().nullable(),
|
|
6677
|
+
commit: z43.object({
|
|
6678
|
+
author: z43.object({ email: z43.string() }).passthrough().nullable()
|
|
5793
6679
|
}).passthrough()
|
|
5794
6680
|
}).passthrough();
|
|
5795
|
-
var commitPageSchema2 =
|
|
6681
|
+
var commitPageSchema2 = z43.array(providerCommitSchema).transform(
|
|
5796
6682
|
(commits) => commits.map(
|
|
5797
6683
|
(commit) => canonicalCommitSchema.parse({
|
|
5798
6684
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -6299,8 +7185,8 @@ function linkifyLine(line) {
|
|
|
6299
7185
|
if (isReferenceBoundary(index2 === 0 ? void 0 : line[index2 - 1])) {
|
|
6300
7186
|
const match = GITHUB_ISSUE_REFERENCE_PATTERN.exec(line.slice(index2));
|
|
6301
7187
|
if (match) {
|
|
6302
|
-
const [reference, owner, repository2,
|
|
6303
|
-
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${
|
|
7188
|
+
const [reference, owner, repository2, number33] = match;
|
|
7189
|
+
output += `[${reference}](https://github.com/${owner}/${repository2}/issues/${number33})`;
|
|
6304
7190
|
index2 += reference.length;
|
|
6305
7191
|
continue;
|
|
6306
7192
|
}
|
|
@@ -6442,9 +7328,9 @@ function parseGitHubReferences(text2, config) {
|
|
|
6442
7328
|
}
|
|
6443
7329
|
return [...references.values()];
|
|
6444
7330
|
}
|
|
6445
|
-
function objectTitle(kind,
|
|
6446
|
-
if (!isRecord(
|
|
6447
|
-
const raw = kind === "commit" ? isRecord(
|
|
7331
|
+
function objectTitle(kind, object43) {
|
|
7332
|
+
if (!isRecord(object43)) return void 0;
|
|
7333
|
+
const raw = kind === "commit" ? isRecord(object43.commit) && typeof object43.commit.message === "string" ? object43.commit.message.split("\n")[0] : void 0 : typeof object43.title === "string" ? object43.title : void 0;
|
|
6448
7334
|
return raw?.replace(/\s+/g, " ").trim() || void 0;
|
|
6449
7335
|
}
|
|
6450
7336
|
async function loadGitHubConversationTitleContext(args) {
|
|
@@ -6723,9 +7609,9 @@ import {
|
|
|
6723
7609
|
} from "@sentry/junior-plugin-api";
|
|
6724
7610
|
|
|
6725
7611
|
// src/default-branch.ts
|
|
6726
|
-
import * as
|
|
7612
|
+
import * as z44 from "zod";
|
|
6727
7613
|
var DEFAULT_BRANCH_TTL_MS = 10 * 60 * 1e3;
|
|
6728
|
-
var repositorySchema3 =
|
|
7614
|
+
var repositorySchema3 = z44.object({ default_branch: z44.string().min(1) });
|
|
6729
7615
|
async function loadDefaultBranch(env, cache, repository2) {
|
|
6730
7616
|
const { owner, name } = repository2;
|
|
6731
7617
|
return await cache.getOrLoad(
|
|
@@ -6940,14 +7826,35 @@ var ISSUE_PATH = /^\/repos\/[^/]+\/[^/]+\/issues\/\d+$/;
|
|
|
6940
7826
|
var ISSUE_READ_DENIAL = `Use github_getIssue to read a GitHub issue, not gh issue view or gh api. Read comments with gh api repos/OWNER/REPO/issues/NUMBER/comments. ${CREATE_TOOL_ROUTING_GUIDANCE}`;
|
|
6941
7827
|
function isGitHubIssueRead(input) {
|
|
6942
7828
|
if (isGitHubGraphqlUrl(input.upstreamUrl)) {
|
|
6943
|
-
const
|
|
6944
|
-
return
|
|
7829
|
+
const operation2 = input.method === "POST" ? githubGraphqlOperation(input.graphql) : void 0;
|
|
7830
|
+
return operation2?.fields.some(
|
|
6945
7831
|
(field) => (field.name === "issue" || field.name === "issueOrPullRequest") && field.arguments.length > 0
|
|
6946
7832
|
) ?? false;
|
|
6947
7833
|
}
|
|
6948
7834
|
return isGitHubApiUrl(input.upstreamUrl) && HTTP_READ_METHODS.has(input.method) && ISSUE_PATH.test(input.upstreamUrl.pathname.toLowerCase());
|
|
6949
7835
|
}
|
|
6950
7836
|
var PULL_REQUEST_COMMENT_REACTIONS_PATH = /^\/repos\/[^/]+\/[^/]+\/(issues|pulls)\/comments\/[^/]+\/reactions(?:\/[^/]+)?$/;
|
|
7837
|
+
var TOOL_ONLY_REST_WRITES = [
|
|
7838
|
+
{
|
|
7839
|
+
denialMessage: "GitHub issue comment edits must use the github_updateIssueComment tool, which only edits comments the bot posted.",
|
|
7840
|
+
method: "PATCH",
|
|
7841
|
+
operation: "github.issue.comment.update",
|
|
7842
|
+
restPath: /^\/repos\/[^/]+\/[^/]+\/issues\/comments\/\d+$/
|
|
7843
|
+
},
|
|
7844
|
+
{
|
|
7845
|
+
denialMessage: "Reactions on a GitHub issue or pull request must use the github_reactToIssue tool.",
|
|
7846
|
+
method: "POST",
|
|
7847
|
+
operation: "github.issue.reaction.create",
|
|
7848
|
+
restPath: /^\/repos\/[^/]+\/[^/]+\/issues\/\d+\/reactions$/
|
|
7849
|
+
}
|
|
7850
|
+
];
|
|
7851
|
+
function toolOnlyRestWrite(method, upstreamUrl) {
|
|
7852
|
+
if (!isGitHubApiUrl(upstreamUrl)) return void 0;
|
|
7853
|
+
const pathname = upstreamUrl.pathname.toLowerCase();
|
|
7854
|
+
return TOOL_ONLY_REST_WRITES.find(
|
|
7855
|
+
(write) => write.method === method && write.restPath.test(pathname)
|
|
7856
|
+
);
|
|
7857
|
+
}
|
|
6951
7858
|
var GITHUB_BODY_WRITES = [
|
|
6952
7859
|
{
|
|
6953
7860
|
denialMessage: `GitHub issue creation must use the github_createIssue tool, which owns idempotency and the conversation footer. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
|
|
@@ -7042,6 +7949,9 @@ function githubApiWriteGrantName(method, upstreamUrl) {
|
|
|
7042
7949
|
if ((method === "POST" || method === "DELETE") && PULL_REQUEST_COMMENT_REACTIONS_PATH.test(pathname)) {
|
|
7043
7950
|
return "installation-write";
|
|
7044
7951
|
}
|
|
7952
|
+
if (toolOnlyRestWrite(method, upstreamUrl)) {
|
|
7953
|
+
return "installation-write";
|
|
7954
|
+
}
|
|
7045
7955
|
return void 0;
|
|
7046
7956
|
}
|
|
7047
7957
|
var HOST_GRAPHQL_MUTATIONS = [
|
|
@@ -7072,16 +7982,16 @@ var HOST_GRAPHQL_MUTATIONS = [
|
|
|
7072
7982
|
operationPrefix: "github.pull.review-reaction.update:"
|
|
7073
7983
|
}
|
|
7074
7984
|
];
|
|
7075
|
-
function hostGraphqlMutationRepository(
|
|
7076
|
-
if (method !== "POST" || !isGitHubGraphqlUrl(upstreamUrl) || !
|
|
7985
|
+
function hostGraphqlMutationRepository(operation2, method, upstreamUrl, graphql) {
|
|
7986
|
+
if (method !== "POST" || !isGitHubGraphqlUrl(upstreamUrl) || !operation2) {
|
|
7077
7987
|
return void 0;
|
|
7078
7988
|
}
|
|
7079
7989
|
const parsed = githubGraphqlOperation(graphql);
|
|
7080
7990
|
const mutation = HOST_GRAPHQL_MUTATIONS.find(
|
|
7081
|
-
(candidate) =>
|
|
7991
|
+
(candidate) => operation2.startsWith(candidate.operationPrefix) && parsed?.type === "mutation" && parsed.name === candidate.operationName && parsed.rootFields.length === 1 && parsed.rootFields[0] === candidate.field
|
|
7082
7992
|
);
|
|
7083
7993
|
if (!mutation) return void 0;
|
|
7084
|
-
const repository2 =
|
|
7994
|
+
const repository2 = operation2.slice(mutation.operationPrefix.length);
|
|
7085
7995
|
return /^[^/]+\/[^/]+$/.test(repository2) ? repository2 : void 0;
|
|
7086
7996
|
}
|
|
7087
7997
|
function isGitHubGraphqlMutation(method, upstreamUrl, graphql, field) {
|
|
@@ -7105,6 +8015,13 @@ function applyGitHubEgressPolicy(input) {
|
|
|
7105
8015
|
denialMessage: "GitHub pull request feedback reactions must use the github_updatePullRequestFeedback tool."
|
|
7106
8016
|
});
|
|
7107
8017
|
}
|
|
8018
|
+
const toolOnlyWrite = toolOnlyRestWrite(input.method, input.upstreamUrl);
|
|
8019
|
+
if (toolOnlyWrite) {
|
|
8020
|
+
enforceEgressPolicy({
|
|
8021
|
+
allowed: input.operation === toolOnlyWrite.operation,
|
|
8022
|
+
denialMessage: toolOnlyWrite.denialMessage
|
|
8023
|
+
});
|
|
8024
|
+
}
|
|
7108
8025
|
if (isGitHubIssueRead(input)) {
|
|
7109
8026
|
enforceEgressPolicy({
|
|
7110
8027
|
allowed: input.operation === "github.issue.get",
|
|
@@ -7377,7 +8294,7 @@ function githubPlugin(options = {}) {
|
|
|
7377
8294
|
log: ctx.log,
|
|
7378
8295
|
text: ctx.text,
|
|
7379
8296
|
loadObject: async (reference) => {
|
|
7380
|
-
const { collection, operation } = {
|
|
8297
|
+
const { collection, operation: operation2 } = {
|
|
7381
8298
|
commit: {
|
|
7382
8299
|
collection: "commits",
|
|
7383
8300
|
operation: "github.commit.get"
|
|
@@ -7389,7 +8306,7 @@ function githubPlugin(options = {}) {
|
|
|
7389
8306
|
}
|
|
7390
8307
|
}[reference.kind];
|
|
7391
8308
|
const response = await githubApi(ctx.egress, {
|
|
7392
|
-
operation,
|
|
8309
|
+
operation: operation2,
|
|
7393
8310
|
path: `${repoPath(reference)}/${collection}/${encodeURIComponent(reference.id)}`,
|
|
7394
8311
|
signal: ctx.signal
|
|
7395
8312
|
});
|
|
@@ -7515,7 +8432,8 @@ function githubPlugin(options = {}) {
|
|
|
7515
8432
|
readEnv(botEmailEnv),
|
|
7516
8433
|
gitHubPullRequestSubscription(
|
|
7517
8434
|
options.pullRequestEvents?.subscribeAfterCreate
|
|
7518
|
-
)
|
|
8435
|
+
),
|
|
8436
|
+
options.experimental
|
|
7519
8437
|
);
|
|
7520
8438
|
},
|
|
7521
8439
|
workspacePrepare: prepareWorkspace,
|