@sentry/junior-github 0.277.0 → 0.279.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -382,22 +382,117 @@ function createGitHubCloneRepositoryTool(ctx) {
|
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
-
// src/
|
|
385
|
+
// src/tools/comment-on-pull-request.ts
|
|
386
|
+
import {
|
|
387
|
+
definePluginTool as definePluginTool2,
|
|
388
|
+
PluginToolInputError as PluginToolInputError2,
|
|
389
|
+
pluginToolOutputSchema as pluginToolOutputSchema2
|
|
390
|
+
} from "@sentry/junior-plugin-api";
|
|
386
391
|
import { z as z2 } from "zod";
|
|
387
|
-
var
|
|
388
|
-
|
|
389
|
-
|
|
392
|
+
var inputSchema2 = z2.object({
|
|
393
|
+
repo: z2.string().describe('Repository in "owner/name" format.'),
|
|
394
|
+
number: z2.number().int().positive().describe("Pull request number."),
|
|
395
|
+
body: z2.string().trim().min(1).describe("Comment text."),
|
|
396
|
+
in_reply_to: z2.number().int().positive().optional().describe(
|
|
397
|
+
"Inline review comment id. Set it to reply in that comment's thread. Omit it to comment on the pull request."
|
|
398
|
+
)
|
|
399
|
+
}).strict();
|
|
400
|
+
var outputSchema2 = pluginToolOutputSchema2.extend({
|
|
401
|
+
target: z2.literal("commentOnPullRequest"),
|
|
402
|
+
repo: z2.string(),
|
|
403
|
+
number: z2.number(),
|
|
404
|
+
comment_id: z2.number(),
|
|
405
|
+
url: z2.string()
|
|
406
|
+
});
|
|
407
|
+
function parseRepo2(value) {
|
|
408
|
+
const parts = value.split("/").map((part) => part.trim());
|
|
409
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
410
|
+
throw new PluginToolInputError2('repo must use "owner/name" format');
|
|
411
|
+
}
|
|
412
|
+
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
413
|
+
}
|
|
414
|
+
async function readJson(response) {
|
|
415
|
+
const text2 = await response.text();
|
|
416
|
+
if (!text2) return void 0;
|
|
417
|
+
try {
|
|
418
|
+
return JSON.parse(text2);
|
|
419
|
+
} catch {
|
|
420
|
+
return text2;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function githubError(body) {
|
|
424
|
+
if (body && typeof body === "object" && !Array.isArray(body)) {
|
|
425
|
+
const message = body.message;
|
|
426
|
+
if (typeof message === "string" && message.trim()) return message.trim();
|
|
427
|
+
}
|
|
428
|
+
if (typeof body === "string" && body.trim()) return body.trim();
|
|
429
|
+
return "GitHub request failed";
|
|
430
|
+
}
|
|
431
|
+
function createGitHubCommentOnPullRequestTool(egress) {
|
|
432
|
+
return definePluginTool2({
|
|
433
|
+
annotations: {
|
|
434
|
+
destructiveHint: false,
|
|
435
|
+
idempotentHint: false,
|
|
436
|
+
openWorldHint: true,
|
|
437
|
+
readOnlyHint: false
|
|
438
|
+
},
|
|
439
|
+
description: "Post a comment on a GitHub pull request, or reply in an inline review thread with in_reply_to. Use it to answer a question asked in a pull request review or comment. Returns the comment id and URL.",
|
|
440
|
+
exposure: "direct",
|
|
441
|
+
inputSchema: inputSchema2,
|
|
442
|
+
outputSchema: outputSchema2,
|
|
443
|
+
async execute(input) {
|
|
444
|
+
const repo = parseRepo2(input.repo);
|
|
445
|
+
const repoPath = `https://api.github.com/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}`;
|
|
446
|
+
const url = input.in_reply_to === void 0 ? `${repoPath}/issues/${input.number}/comments` : `${repoPath}/pulls/${input.number}/comments/${input.in_reply_to}/replies`;
|
|
447
|
+
const response = await egress.fetch({
|
|
448
|
+
provider: "github",
|
|
449
|
+
operation: "github.pull.comment.create",
|
|
450
|
+
request: new Request(url, {
|
|
451
|
+
method: "POST",
|
|
452
|
+
headers: {
|
|
453
|
+
Accept: "application/vnd.github+json",
|
|
454
|
+
"Content-Type": "application/json",
|
|
455
|
+
"X-GitHub-Api-Version": "2022-11-28"
|
|
456
|
+
},
|
|
457
|
+
body: JSON.stringify({ body: input.body })
|
|
458
|
+
})
|
|
459
|
+
});
|
|
460
|
+
const parsed = await readJson(response);
|
|
461
|
+
if (!response.ok) {
|
|
462
|
+
const message = `GitHub pull request comment failed with HTTP ${response.status}: ${githubError(parsed)}`;
|
|
463
|
+
if (response.status === 404 || response.status === 422) {
|
|
464
|
+
throw new PluginToolInputError2(message);
|
|
465
|
+
}
|
|
466
|
+
throw new Error(message);
|
|
467
|
+
}
|
|
468
|
+
const comment = z2.object({ id: z2.number(), html_url: z2.string() }).parse(parsed);
|
|
469
|
+
return {
|
|
470
|
+
target: "commentOnPullRequest",
|
|
471
|
+
repo: repo.ref,
|
|
472
|
+
number: input.number,
|
|
473
|
+
comment_id: comment.id,
|
|
474
|
+
url: comment.html_url
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
// src/object-facts.ts
|
|
481
|
+
import { z as z3 } from "zod";
|
|
482
|
+
var person = z3.object({ login: z3.string() });
|
|
483
|
+
var responseSchema = z3.object({
|
|
484
|
+
body: z3.string().nullable().optional(),
|
|
390
485
|
user: person.nullable().optional(),
|
|
391
|
-
requested_reviewers:
|
|
392
|
-
assignees:
|
|
393
|
-
labels:
|
|
394
|
-
head:
|
|
395
|
-
base:
|
|
396
|
-
mergeable:
|
|
397
|
-
changed_files:
|
|
398
|
-
additions:
|
|
399
|
-
deletions:
|
|
400
|
-
updated_at:
|
|
486
|
+
requested_reviewers: z3.array(person).optional(),
|
|
487
|
+
assignees: z3.array(person).optional(),
|
|
488
|
+
labels: z3.array(z3.union([z3.string(), z3.object({ name: z3.string() })])).optional(),
|
|
489
|
+
head: z3.object({ ref: z3.string() }).optional(),
|
|
490
|
+
base: z3.object({ ref: z3.string() }).optional(),
|
|
491
|
+
mergeable: z3.boolean().nullable().optional(),
|
|
492
|
+
changed_files: z3.number().int().nonnegative().optional(),
|
|
493
|
+
additions: z3.number().int().nonnegative().optional(),
|
|
494
|
+
deletions: z3.number().int().nonnegative().optional(),
|
|
495
|
+
updated_at: z3.iso.datetime({ offset: true }).optional()
|
|
401
496
|
});
|
|
402
497
|
var short = (value) => {
|
|
403
498
|
const text2 = value?.trim();
|
|
@@ -520,24 +615,24 @@ async function updateGitHubAnnotation(store, input) {
|
|
|
520
615
|
// src/tools/create-issue.ts
|
|
521
616
|
import {
|
|
522
617
|
objectFactsSchema,
|
|
523
|
-
definePluginTool as
|
|
618
|
+
definePluginTool as definePluginTool3,
|
|
524
619
|
EgressAuthRequired,
|
|
525
|
-
PluginToolInputError as
|
|
620
|
+
PluginToolInputError as PluginToolInputError4,
|
|
526
621
|
subscribableResourceSchema,
|
|
527
|
-
pluginToolOutputSchema as
|
|
622
|
+
pluginToolOutputSchema as pluginToolOutputSchema3
|
|
528
623
|
} from "@sentry/junior-plugin-api";
|
|
529
624
|
import { Type } from "@sinclair/typebox";
|
|
530
625
|
import { Value } from "@sinclair/typebox/value";
|
|
531
|
-
import { z as
|
|
626
|
+
import { z as z4 } from "zod";
|
|
532
627
|
|
|
533
628
|
// src/tools/footer.ts
|
|
534
|
-
import { PluginToolInputError as
|
|
629
|
+
import { PluginToolInputError as PluginToolInputError3 } from "@sentry/junior-plugin-api";
|
|
535
630
|
var GITHUB_SESSION_FOOTER_START = "<!-- junior-session-footer:start -->";
|
|
536
631
|
var GITHUB_SESSION_FOOTER_END = "<!-- junior-session-footer:end -->";
|
|
537
632
|
var GITHUB_CONVERSATION_ID_MARKER = "junior-conversation-id:";
|
|
538
633
|
function nonEmptyString(value, name) {
|
|
539
634
|
if (!value?.trim()) {
|
|
540
|
-
throw new
|
|
635
|
+
throw new PluginToolInputError3(`${name} is required`);
|
|
541
636
|
}
|
|
542
637
|
return value.trim();
|
|
543
638
|
}
|
|
@@ -681,11 +776,11 @@ var createIssueInputSchema = Type.Object(
|
|
|
681
776
|
},
|
|
682
777
|
{ additionalProperties: false }
|
|
683
778
|
);
|
|
684
|
-
var createIssueToolInputSchema =
|
|
685
|
-
repo:
|
|
686
|
-
title:
|
|
687
|
-
body:
|
|
688
|
-
labels:
|
|
779
|
+
var createIssueToolInputSchema = z4.object({
|
|
780
|
+
repo: z4.string().describe('Repository in "owner/name" format.'),
|
|
781
|
+
title: z4.string().describe("Issue title."),
|
|
782
|
+
body: z4.string().describe("Issue body. The runtime appends the conversation footer.").optional(),
|
|
783
|
+
labels: z4.array(z4.string()).describe("Labels to apply to the issue.").optional()
|
|
689
784
|
}).strict();
|
|
690
785
|
var createIssueStateSchema = Type.Union([
|
|
691
786
|
Type.Object(
|
|
@@ -710,18 +805,18 @@ var createIssueStateSchema = Type.Union([
|
|
|
710
805
|
{ additionalProperties: false }
|
|
711
806
|
)
|
|
712
807
|
]);
|
|
713
|
-
var gitHubIssueDataSchema =
|
|
714
|
-
number:
|
|
808
|
+
var gitHubIssueDataSchema = z4.object({
|
|
809
|
+
number: z4.number(),
|
|
715
810
|
subscribable: subscribableResourceSchema.optional(),
|
|
716
|
-
url:
|
|
811
|
+
url: z4.string()
|
|
717
812
|
});
|
|
718
|
-
var gitHubIssueOutputSchema =
|
|
813
|
+
var gitHubIssueOutputSchema = pluginToolOutputSchema3.merge(
|
|
719
814
|
gitHubIssueDataSchema.extend({
|
|
720
|
-
target:
|
|
815
|
+
target: z4.literal("createIssue")
|
|
721
816
|
})
|
|
722
817
|
);
|
|
723
818
|
function gitHubIssueToolResult(input, result, canSubscribe) {
|
|
724
|
-
const repo =
|
|
819
|
+
const repo = parseRepo3(input.repo);
|
|
725
820
|
const subscribable = gitHubIssueSubscribable({
|
|
726
821
|
canSubscribe,
|
|
727
822
|
number: result.number,
|
|
@@ -754,22 +849,22 @@ function parseCreateIssueInput(input) {
|
|
|
754
849
|
try {
|
|
755
850
|
return Value.Parse(createIssueInputSchema, input);
|
|
756
851
|
} catch (error) {
|
|
757
|
-
throw new
|
|
852
|
+
throw new PluginToolInputError4("Invalid GitHub createIssue input.", {
|
|
758
853
|
cause: error
|
|
759
854
|
});
|
|
760
855
|
}
|
|
761
856
|
}
|
|
762
857
|
function nonEmptyString2(value, name) {
|
|
763
858
|
if (!value?.trim()) {
|
|
764
|
-
throw new
|
|
859
|
+
throw new PluginToolInputError4(`${name} is required`);
|
|
765
860
|
}
|
|
766
861
|
return value.trim();
|
|
767
862
|
}
|
|
768
|
-
function
|
|
863
|
+
function parseRepo3(value) {
|
|
769
864
|
const repo = nonEmptyString2(value, "repo");
|
|
770
865
|
const parts = repo.split("/");
|
|
771
866
|
if (parts.length !== 2 || !parts[0]?.trim() || !parts[1]?.trim()) {
|
|
772
|
-
throw new
|
|
867
|
+
throw new PluginToolInputError4('repo must use "owner/name" format');
|
|
773
868
|
}
|
|
774
869
|
return {
|
|
775
870
|
owner: parts[0].trim(),
|
|
@@ -821,7 +916,7 @@ function isDefinitiveGitHubIssueCreateRejection(error) {
|
|
|
821
916
|
return [400, 401, 404, 410, 422].includes(error.status);
|
|
822
917
|
}
|
|
823
918
|
async function createGitHubIssueRequest(conversationId, input, ctx, dashboardUrl) {
|
|
824
|
-
const repo =
|
|
919
|
+
const repo = parseRepo3(input.repo);
|
|
825
920
|
const labels = input.labels?.map(
|
|
826
921
|
(label) => nonEmptyString2(label, "labels entry")
|
|
827
922
|
);
|
|
@@ -882,7 +977,7 @@ async function createGitHubIssue(ctx, request) {
|
|
|
882
977
|
};
|
|
883
978
|
}
|
|
884
979
|
function createGitHubIssueTool(ctx) {
|
|
885
|
-
return
|
|
980
|
+
return definePluginTool3({
|
|
886
981
|
annotations: {
|
|
887
982
|
destructiveHint: false,
|
|
888
983
|
idempotentHint: true,
|
|
@@ -975,83 +1070,83 @@ function createGitHubIssueTool(ctx) {
|
|
|
975
1070
|
|
|
976
1071
|
// src/tools/get-deployment.ts
|
|
977
1072
|
import {
|
|
978
|
-
definePluginTool as
|
|
979
|
-
PluginToolInputError as
|
|
980
|
-
pluginToolOutputSchema as
|
|
1073
|
+
definePluginTool as definePluginTool4,
|
|
1074
|
+
PluginToolInputError as PluginToolInputError5,
|
|
1075
|
+
pluginToolOutputSchema as pluginToolOutputSchema4,
|
|
981
1076
|
subscribableResourceSchema as subscribableResourceSchema2
|
|
982
1077
|
} from "@sentry/junior-plugin-api";
|
|
983
|
-
import { z as
|
|
984
|
-
var commitShaSchema =
|
|
985
|
-
var
|
|
986
|
-
repo:
|
|
1078
|
+
import { z as z5 } from "zod";
|
|
1079
|
+
var commitShaSchema = z5.string().regex(/^[0-9a-f]{40}$/i);
|
|
1080
|
+
var inputSchema3 = z5.object({
|
|
1081
|
+
repo: z5.string().describe('Repository in "owner/name" format.'),
|
|
987
1082
|
commit_sha: commitShaSchema.describe(
|
|
988
1083
|
"Full 40-character Git commit SHA recorded by the deployment."
|
|
989
1084
|
),
|
|
990
|
-
environment:
|
|
1085
|
+
environment: z5.string().trim().min(1).describe(
|
|
991
1086
|
'Optional GitHub deployment environment, such as "Production". Omit to inspect and watch deployments for the commit across environments.'
|
|
992
1087
|
).optional()
|
|
993
1088
|
}).strict();
|
|
994
|
-
var statusSchema =
|
|
995
|
-
created_at:
|
|
996
|
-
creator:
|
|
997
|
-
description:
|
|
998
|
-
environment_url:
|
|
999
|
-
id:
|
|
1000
|
-
log_url:
|
|
1001
|
-
state:
|
|
1089
|
+
var statusSchema = z5.object({
|
|
1090
|
+
created_at: z5.string(),
|
|
1091
|
+
creator: z5.string().nullable(),
|
|
1092
|
+
description: z5.string().nullable(),
|
|
1093
|
+
environment_url: z5.string().nullable(),
|
|
1094
|
+
id: z5.number(),
|
|
1095
|
+
log_url: z5.string().nullable(),
|
|
1096
|
+
state: z5.string()
|
|
1002
1097
|
}).strict();
|
|
1003
|
-
var deploymentSchema =
|
|
1004
|
-
created_at:
|
|
1005
|
-
creator:
|
|
1006
|
-
description:
|
|
1007
|
-
environment:
|
|
1008
|
-
id:
|
|
1098
|
+
var deploymentSchema = z5.object({
|
|
1099
|
+
created_at: z5.string(),
|
|
1100
|
+
creator: z5.string().nullable(),
|
|
1101
|
+
description: z5.string().nullable(),
|
|
1102
|
+
environment: z5.string(),
|
|
1103
|
+
id: z5.number(),
|
|
1009
1104
|
latest_status: statusSchema.nullable(),
|
|
1010
|
-
ref:
|
|
1105
|
+
ref: z5.string(),
|
|
1011
1106
|
sha: commitShaSchema,
|
|
1012
|
-
updated_at:
|
|
1013
|
-
url:
|
|
1107
|
+
updated_at: z5.string(),
|
|
1108
|
+
url: z5.string()
|
|
1014
1109
|
}).strict();
|
|
1015
|
-
var deploymentSourceSchema =
|
|
1110
|
+
var deploymentSourceSchema = z5.object({
|
|
1016
1111
|
commit_sha: commitShaSchema,
|
|
1017
1112
|
deployment: deploymentSchema.nullable(),
|
|
1018
|
-
environment:
|
|
1019
|
-
repo:
|
|
1113
|
+
environment: z5.string().nullable(),
|
|
1114
|
+
repo: z5.string(),
|
|
1020
1115
|
subscribable: subscribableResourceSchema2.optional()
|
|
1021
1116
|
}).strict();
|
|
1022
|
-
var
|
|
1117
|
+
var outputSchema3 = pluginToolOutputSchema4.merge(
|
|
1023
1118
|
deploymentSourceSchema.extend({
|
|
1024
|
-
target:
|
|
1119
|
+
target: z5.literal("getDeployment")
|
|
1025
1120
|
})
|
|
1026
1121
|
);
|
|
1027
|
-
var providerCreatorSchema =
|
|
1028
|
-
var providerDeploymentSchema =
|
|
1029
|
-
created_at:
|
|
1122
|
+
var providerCreatorSchema = z5.object({ login: z5.string() }).passthrough().nullable();
|
|
1123
|
+
var providerDeploymentSchema = z5.object({
|
|
1124
|
+
created_at: z5.string(),
|
|
1030
1125
|
creator: providerCreatorSchema,
|
|
1031
|
-
description:
|
|
1032
|
-
environment:
|
|
1033
|
-
id:
|
|
1034
|
-
ref:
|
|
1126
|
+
description: z5.string().nullable(),
|
|
1127
|
+
environment: z5.string(),
|
|
1128
|
+
id: z5.number(),
|
|
1129
|
+
ref: z5.string(),
|
|
1035
1130
|
sha: commitShaSchema,
|
|
1036
|
-
updated_at:
|
|
1131
|
+
updated_at: z5.string()
|
|
1037
1132
|
}).passthrough();
|
|
1038
|
-
var providerStatusSchema =
|
|
1039
|
-
created_at:
|
|
1133
|
+
var providerStatusSchema = z5.object({
|
|
1134
|
+
created_at: z5.string(),
|
|
1040
1135
|
creator: providerCreatorSchema,
|
|
1041
|
-
description:
|
|
1042
|
-
environment_url:
|
|
1043
|
-
id:
|
|
1044
|
-
log_url:
|
|
1045
|
-
state:
|
|
1136
|
+
description: z5.string().nullable().optional(),
|
|
1137
|
+
environment_url: z5.string().nullable().optional(),
|
|
1138
|
+
id: z5.number(),
|
|
1139
|
+
log_url: z5.string().nullable().optional(),
|
|
1140
|
+
state: z5.string()
|
|
1046
1141
|
}).passthrough();
|
|
1047
|
-
function
|
|
1142
|
+
function parseRepo4(value) {
|
|
1048
1143
|
const parts = value.split("/").map((part) => part.trim());
|
|
1049
1144
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
1050
|
-
throw new
|
|
1145
|
+
throw new PluginToolInputError5('repo must use "owner/name" format');
|
|
1051
1146
|
}
|
|
1052
1147
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
1053
1148
|
}
|
|
1054
|
-
async function
|
|
1149
|
+
async function readJson2(response) {
|
|
1055
1150
|
const text2 = await response.text();
|
|
1056
1151
|
if (!text2) return void 0;
|
|
1057
1152
|
try {
|
|
@@ -1064,7 +1159,7 @@ function throwLookupError(target, status, body) {
|
|
|
1064
1159
|
const message = `GitHub ${target} lookup failed with HTTP ${status}`;
|
|
1065
1160
|
const hasValidationErrors = body !== null && typeof body === "object" && !Array.isArray(body) && Array.isArray(body.errors) && body.errors.length > 0;
|
|
1066
1161
|
if (target === "deployment" && (status === 404 || status === 422 && hasValidationErrors)) {
|
|
1067
|
-
throw new
|
|
1162
|
+
throw new PluginToolInputError5(message);
|
|
1068
1163
|
}
|
|
1069
1164
|
throw new Error(message);
|
|
1070
1165
|
}
|
|
@@ -1072,7 +1167,7 @@ function repositoryUrl(repo, path) {
|
|
|
1072
1167
|
return `https://api.github.com/repos/${encodeURIComponent(repo.owner)}/${encodeURIComponent(repo.name)}/${path}`;
|
|
1073
1168
|
}
|
|
1074
1169
|
function createGitHubGetDeploymentTool(ctx) {
|
|
1075
|
-
return
|
|
1170
|
+
return definePluginTool4({
|
|
1076
1171
|
annotations: {
|
|
1077
1172
|
destructiveHint: false,
|
|
1078
1173
|
idempotentHint: true,
|
|
@@ -1080,10 +1175,10 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1080
1175
|
readOnlyHint: true
|
|
1081
1176
|
},
|
|
1082
1177
|
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.",
|
|
1083
|
-
inputSchema:
|
|
1084
|
-
outputSchema:
|
|
1178
|
+
inputSchema: inputSchema3,
|
|
1179
|
+
outputSchema: outputSchema3,
|
|
1085
1180
|
async execute(input) {
|
|
1086
|
-
const repo =
|
|
1181
|
+
const repo = parseRepo4(input.repo);
|
|
1087
1182
|
const commitSha = input.commit_sha.toLowerCase();
|
|
1088
1183
|
const deploymentsUrl = new URL(repositoryUrl(repo, "deployments"));
|
|
1089
1184
|
deploymentsUrl.searchParams.set("sha", commitSha);
|
|
@@ -1101,7 +1196,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1101
1196
|
}
|
|
1102
1197
|
})
|
|
1103
1198
|
});
|
|
1104
|
-
const deploymentsBody = await
|
|
1199
|
+
const deploymentsBody = await readJson2(deploymentsResponse);
|
|
1105
1200
|
if (!deploymentsResponse.ok) {
|
|
1106
1201
|
throwLookupError(
|
|
1107
1202
|
"deployment",
|
|
@@ -1109,7 +1204,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1109
1204
|
deploymentsBody
|
|
1110
1205
|
);
|
|
1111
1206
|
}
|
|
1112
|
-
const providerDeployment =
|
|
1207
|
+
const providerDeployment = z5.array(providerDeploymentSchema).parse(deploymentsBody)[0];
|
|
1113
1208
|
let deployment = null;
|
|
1114
1209
|
if (providerDeployment) {
|
|
1115
1210
|
const statusesResponse = await ctx.egress.fetch({
|
|
@@ -1125,7 +1220,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1125
1220
|
}
|
|
1126
1221
|
)
|
|
1127
1222
|
});
|
|
1128
|
-
const statusesBody = await
|
|
1223
|
+
const statusesBody = await readJson2(statusesResponse);
|
|
1129
1224
|
if (!statusesResponse.ok) {
|
|
1130
1225
|
throwLookupError(
|
|
1131
1226
|
"deployment status",
|
|
@@ -1133,7 +1228,7 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1133
1228
|
statusesBody
|
|
1134
1229
|
);
|
|
1135
1230
|
}
|
|
1136
|
-
const providerStatus =
|
|
1231
|
+
const providerStatus = z5.array(providerStatusSchema).parse(statusesBody)[0];
|
|
1137
1232
|
deployment = {
|
|
1138
1233
|
created_at: providerDeployment.created_at,
|
|
1139
1234
|
creator: providerDeployment.creator?.login ?? null,
|
|
@@ -1179,16 +1274,16 @@ function createGitHubGetDeploymentTool(ctx) {
|
|
|
1179
1274
|
// src/tools/create-pull-request.ts
|
|
1180
1275
|
import {
|
|
1181
1276
|
objectFactsSchema as objectFactsSchema2,
|
|
1182
|
-
definePluginTool as
|
|
1277
|
+
definePluginTool as definePluginTool5,
|
|
1183
1278
|
EgressAuthRequired as EgressAuthRequired2,
|
|
1184
|
-
PluginToolInputError as
|
|
1185
|
-
pluginToolOutputSchema as
|
|
1279
|
+
PluginToolInputError as PluginToolInputError6,
|
|
1280
|
+
pluginToolOutputSchema as pluginToolOutputSchema5,
|
|
1186
1281
|
watchResultSchema,
|
|
1187
1282
|
subscribableResourceSchema as subscribableResourceSchema3
|
|
1188
1283
|
} from "@sentry/junior-plugin-api";
|
|
1189
1284
|
import { Type as Type2 } from "@sinclair/typebox";
|
|
1190
1285
|
import { Value as Value2 } from "@sinclair/typebox/value";
|
|
1191
|
-
import { z as
|
|
1286
|
+
import { z as z8 } from "zod";
|
|
1192
1287
|
|
|
1193
1288
|
// src/pull-request-requesters/store.ts
|
|
1194
1289
|
import { and, asc, eq, inArray, lt } from "drizzle-orm";
|
|
@@ -1203,18 +1298,18 @@ import {
|
|
|
1203
1298
|
text,
|
|
1204
1299
|
timestamp
|
|
1205
1300
|
} from "drizzle-orm/pg-core";
|
|
1206
|
-
import { z as
|
|
1207
|
-
var githubPullRequestStateSchema =
|
|
1301
|
+
import { z as z6 } from "zod";
|
|
1302
|
+
var githubPullRequestStateSchema = z6.enum([
|
|
1208
1303
|
"closed_unmerged",
|
|
1209
1304
|
"merged",
|
|
1210
1305
|
"open"
|
|
1211
1306
|
]);
|
|
1212
|
-
var githubPullRequestCommitCompositionSchema =
|
|
1307
|
+
var githubPullRequestCommitCompositionSchema = z6.enum([
|
|
1213
1308
|
"junior_only",
|
|
1214
1309
|
"mixed"
|
|
1215
1310
|
]);
|
|
1216
|
-
var githubIssueStateSchema =
|
|
1217
|
-
var githubIssueStateReasonSchema =
|
|
1311
|
+
var githubIssueStateSchema = z6.enum(["closed", "open"]);
|
|
1312
|
+
var githubIssueStateReasonSchema = z6.enum([
|
|
1218
1313
|
"completed",
|
|
1219
1314
|
"duplicate",
|
|
1220
1315
|
"not_planned",
|
|
@@ -1375,34 +1470,34 @@ async function listGitHubPullRequestOpeners(db, input) {
|
|
|
1375
1470
|
}
|
|
1376
1471
|
|
|
1377
1472
|
// src/tools/stack-pull-request.ts
|
|
1378
|
-
import { z as
|
|
1473
|
+
import { z as z7 } from "zod";
|
|
1379
1474
|
var MAX_STACK_DEPTH = 10;
|
|
1380
1475
|
var GITHUB_HEADERS = {
|
|
1381
1476
|
Accept: "application/vnd.github+json",
|
|
1382
1477
|
"X-GitHub-Api-Version": "2026-03-10"
|
|
1383
1478
|
};
|
|
1384
|
-
var stackTargetSchema =
|
|
1385
|
-
number:
|
|
1386
|
-
head:
|
|
1387
|
-
repo:
|
|
1479
|
+
var stackTargetSchema = z7.object({
|
|
1480
|
+
number: z7.number().int().positive(),
|
|
1481
|
+
head: z7.object({
|
|
1482
|
+
repo: z7.object({ full_name: z7.string().min(1) }).nullable()
|
|
1388
1483
|
}),
|
|
1389
|
-
base:
|
|
1390
|
-
ref:
|
|
1391
|
-
repo:
|
|
1392
|
-
default_branch:
|
|
1393
|
-
full_name:
|
|
1484
|
+
base: z7.object({
|
|
1485
|
+
ref: z7.string().min(1),
|
|
1486
|
+
repo: z7.object({
|
|
1487
|
+
default_branch: z7.string().min(1),
|
|
1488
|
+
full_name: z7.string().min(1)
|
|
1394
1489
|
})
|
|
1395
1490
|
})
|
|
1396
1491
|
});
|
|
1397
|
-
var openPullRequestsSchema =
|
|
1398
|
-
|
|
1399
|
-
number:
|
|
1400
|
-
base:
|
|
1492
|
+
var openPullRequestsSchema = z7.array(
|
|
1493
|
+
z7.object({
|
|
1494
|
+
number: z7.number().int().positive(),
|
|
1495
|
+
base: z7.object({ ref: z7.string().min(1) })
|
|
1401
1496
|
})
|
|
1402
1497
|
);
|
|
1403
|
-
var stackSchema =
|
|
1404
|
-
number:
|
|
1405
|
-
pull_requests:
|
|
1498
|
+
var stackSchema = z7.object({
|
|
1499
|
+
number: z7.number().int().positive(),
|
|
1500
|
+
pull_requests: z7.array(z7.object({ number: z7.number().int().positive() }))
|
|
1406
1501
|
});
|
|
1407
1502
|
async function stackGitHubPullRequest(ctx, target) {
|
|
1408
1503
|
const repo = target.base.repo.full_name;
|
|
@@ -1451,7 +1546,7 @@ async function stackGitHubPullRequest(ctx, target) {
|
|
|
1451
1546
|
const stacks = await github(
|
|
1452
1547
|
"github.stack.read",
|
|
1453
1548
|
`${api}/stacks?pull_request=${parent.number}`,
|
|
1454
|
-
|
|
1549
|
+
z7.array(stackSchema)
|
|
1455
1550
|
);
|
|
1456
1551
|
if (!stacks) return void 0;
|
|
1457
1552
|
const stack = stacks[0];
|
|
@@ -1526,15 +1621,15 @@ var createPullRequestInputSchema = Type2.Object(
|
|
|
1526
1621
|
},
|
|
1527
1622
|
{ additionalProperties: false }
|
|
1528
1623
|
);
|
|
1529
|
-
var createPullRequestToolInputSchema =
|
|
1530
|
-
repo:
|
|
1531
|
-
title:
|
|
1532
|
-
head:
|
|
1533
|
-
base:
|
|
1534
|
-
body:
|
|
1624
|
+
var createPullRequestToolInputSchema = z8.object({
|
|
1625
|
+
repo: z8.string().describe('Repository in "owner/name" format.'),
|
|
1626
|
+
title: z8.string().describe("Pull request title."),
|
|
1627
|
+
head: z8.string().describe("Head branch or owner:branch ref."),
|
|
1628
|
+
base: z8.string().describe("Base branch."),
|
|
1629
|
+
body: z8.string().describe(
|
|
1535
1630
|
"Pull request body. The runtime appends the conversation footer."
|
|
1536
1631
|
).optional(),
|
|
1537
|
-
draft:
|
|
1632
|
+
draft: z8.boolean().describe("Whether to open the pull request as a draft.").optional()
|
|
1538
1633
|
}).strict();
|
|
1539
1634
|
var createPullRequestStateSchema = Type2.Union([
|
|
1540
1635
|
Type2.Object(
|
|
@@ -1559,38 +1654,38 @@ var createPullRequestStateSchema = Type2.Union([
|
|
|
1559
1654
|
{ additionalProperties: false }
|
|
1560
1655
|
)
|
|
1561
1656
|
]);
|
|
1562
|
-
var gitHubPullRequestDataSchema =
|
|
1563
|
-
number:
|
|
1564
|
-
url:
|
|
1565
|
-
stack:
|
|
1657
|
+
var gitHubPullRequestDataSchema = z8.object({
|
|
1658
|
+
number: z8.number(),
|
|
1659
|
+
url: z8.string(),
|
|
1660
|
+
stack: z8.object({ number: z8.number(), pull_requests: z8.array(z8.number()) }).optional(),
|
|
1566
1661
|
subscribable: subscribableResourceSchema3.optional(),
|
|
1567
1662
|
subscription: watchResultSchema.optional()
|
|
1568
1663
|
});
|
|
1569
|
-
var gitHubPullRequestOutputSchema =
|
|
1664
|
+
var gitHubPullRequestOutputSchema = pluginToolOutputSchema5.merge(
|
|
1570
1665
|
gitHubPullRequestDataSchema.extend({
|
|
1571
|
-
target:
|
|
1666
|
+
target: z8.literal("createPullRequest")
|
|
1572
1667
|
})
|
|
1573
1668
|
);
|
|
1574
1669
|
function parseCreatePullRequestInput(input) {
|
|
1575
1670
|
try {
|
|
1576
1671
|
return Value2.Parse(createPullRequestInputSchema, input);
|
|
1577
1672
|
} catch (error) {
|
|
1578
|
-
throw new
|
|
1673
|
+
throw new PluginToolInputError6("Invalid GitHub createPullRequest input.", {
|
|
1579
1674
|
cause: error
|
|
1580
1675
|
});
|
|
1581
1676
|
}
|
|
1582
1677
|
}
|
|
1583
1678
|
function nonEmptyString3(value, name) {
|
|
1584
1679
|
if (!value?.trim()) {
|
|
1585
|
-
throw new
|
|
1680
|
+
throw new PluginToolInputError6(`${name} is required`);
|
|
1586
1681
|
}
|
|
1587
1682
|
return value.trim();
|
|
1588
1683
|
}
|
|
1589
|
-
function
|
|
1684
|
+
function parseRepo5(value) {
|
|
1590
1685
|
const repo = nonEmptyString3(value, "repo");
|
|
1591
1686
|
const parts = repo.split("/");
|
|
1592
1687
|
if (parts.length !== 2 || !parts[0]?.trim() || !parts[1]?.trim()) {
|
|
1593
|
-
throw new
|
|
1688
|
+
throw new PluginToolInputError6('repo must use "owner/name" format');
|
|
1594
1689
|
}
|
|
1595
1690
|
return {
|
|
1596
1691
|
owner: parts[0].trim(),
|
|
@@ -1661,7 +1756,7 @@ function isDefinitiveGitHubPullRequestCreateRejection(error) {
|
|
|
1661
1756
|
return [400, 401, 404, 410, 422].includes(error.status);
|
|
1662
1757
|
}
|
|
1663
1758
|
function createGitHubPullRequestRequest(conversationId, input, ctx, requester, dashboardUrl) {
|
|
1664
|
-
const repo =
|
|
1759
|
+
const repo = parseRepo5(input.repo);
|
|
1665
1760
|
const payload = {
|
|
1666
1761
|
title: nonEmptyString3(input.title, "title"),
|
|
1667
1762
|
head: nonEmptyString3(input.head, "head"),
|
|
@@ -1727,7 +1822,7 @@ async function createGitHubPullRequest(ctx, request) {
|
|
|
1727
1822
|
async function recordOpener(ctx, input, state, requester) {
|
|
1728
1823
|
const { conversationId, identityId } = requester;
|
|
1729
1824
|
if (!identityId) return;
|
|
1730
|
-
const repo =
|
|
1825
|
+
const repo = parseRepo5(input.repo);
|
|
1731
1826
|
await recordGitHubPullRequestOpener(ctx.db, {
|
|
1732
1827
|
conversationId,
|
|
1733
1828
|
createdAt: new Date(state.createdAtMs),
|
|
@@ -1740,7 +1835,7 @@ async function assignPullRequestRequester(ctx, input, result, requester) {
|
|
|
1740
1835
|
const assignee = linkedGitHubLogin(requester?.user);
|
|
1741
1836
|
if (!assignee) return;
|
|
1742
1837
|
try {
|
|
1743
|
-
const repo =
|
|
1838
|
+
const repo = parseRepo5(input.repo);
|
|
1744
1839
|
const response = await ctx.egress.fetch({
|
|
1745
1840
|
provider: "github",
|
|
1746
1841
|
operation: "github.pull.assign",
|
|
@@ -1773,7 +1868,7 @@ async function assignPullRequestRequester(ctx, input, result, requester) {
|
|
|
1773
1868
|
}
|
|
1774
1869
|
}
|
|
1775
1870
|
function gitHubPullRequestToolResult(input, result, canSubscribe, omitSuggestedEvents) {
|
|
1776
|
-
const repo =
|
|
1871
|
+
const repo = parseRepo5(input.repo);
|
|
1777
1872
|
const subscribable = gitHubPullRequestSubscribable({
|
|
1778
1873
|
canSubscribe,
|
|
1779
1874
|
number: result.number,
|
|
@@ -1847,7 +1942,7 @@ async function gitHubPullRequestStructuredResult(ctx, input, result, subscriptio
|
|
|
1847
1942
|
}
|
|
1848
1943
|
}
|
|
1849
1944
|
function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
1850
|
-
return
|
|
1945
|
+
return definePluginTool5({
|
|
1851
1946
|
annotations: {
|
|
1852
1947
|
destructiveHint: false,
|
|
1853
1948
|
idempotentHint: true,
|
|
@@ -1966,42 +2061,42 @@ function createGitHubPullRequestTool(ctx, subscriptionConfig) {
|
|
|
1966
2061
|
|
|
1967
2062
|
// src/tools/get-pull-request.ts
|
|
1968
2063
|
import {
|
|
1969
|
-
definePluginTool as
|
|
1970
|
-
PluginToolInputError as
|
|
1971
|
-
pluginToolOutputSchema as
|
|
2064
|
+
definePluginTool as definePluginTool6,
|
|
2065
|
+
PluginToolInputError as PluginToolInputError7,
|
|
2066
|
+
pluginToolOutputSchema as pluginToolOutputSchema6
|
|
1972
2067
|
} from "@sentry/junior-plugin-api";
|
|
1973
|
-
import { z as
|
|
2068
|
+
import { z as z9 } from "zod";
|
|
1974
2069
|
import { subscribableResourceSchema as subscribableResourceSchema4 } from "@sentry/junior-plugin-api";
|
|
1975
|
-
var commitShaSchema2 =
|
|
1976
|
-
var
|
|
1977
|
-
repo:
|
|
1978
|
-
number:
|
|
2070
|
+
var commitShaSchema2 = z9.string().regex(/^[0-9a-f]{40}$/i);
|
|
2071
|
+
var inputSchema4 = z9.object({
|
|
2072
|
+
repo: z9.string().describe('Repository in "owner/name" format.'),
|
|
2073
|
+
number: z9.number().int().positive().describe("Pull request number.")
|
|
1979
2074
|
}).strict();
|
|
1980
|
-
var pullRequestSchema =
|
|
1981
|
-
base:
|
|
1982
|
-
draft:
|
|
1983
|
-
head:
|
|
2075
|
+
var pullRequestSchema = z9.object({
|
|
2076
|
+
base: z9.string(),
|
|
2077
|
+
draft: z9.boolean(),
|
|
2078
|
+
head: z9.string(),
|
|
1984
2079
|
head_sha: commitShaSchema2,
|
|
1985
|
-
merged:
|
|
1986
|
-
number:
|
|
1987
|
-
state:
|
|
2080
|
+
merged: z9.boolean(),
|
|
2081
|
+
number: z9.number(),
|
|
2082
|
+
state: z9.string(),
|
|
1988
2083
|
subscribable: subscribableResourceSchema4.optional(),
|
|
1989
|
-
title:
|
|
1990
|
-
url:
|
|
2084
|
+
title: z9.string(),
|
|
2085
|
+
url: z9.string()
|
|
1991
2086
|
});
|
|
1992
|
-
var
|
|
2087
|
+
var outputSchema4 = pluginToolOutputSchema6.merge(
|
|
1993
2088
|
pullRequestSchema.extend({
|
|
1994
|
-
target:
|
|
2089
|
+
target: z9.literal("getPullRequest")
|
|
1995
2090
|
})
|
|
1996
2091
|
);
|
|
1997
|
-
function
|
|
2092
|
+
function parseRepo6(value) {
|
|
1998
2093
|
const parts = value.split("/").map((part) => part.trim());
|
|
1999
2094
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
2000
|
-
throw new
|
|
2095
|
+
throw new PluginToolInputError7('repo must use "owner/name" format');
|
|
2001
2096
|
}
|
|
2002
2097
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
2003
2098
|
}
|
|
2004
|
-
async function
|
|
2099
|
+
async function readJson3(response) {
|
|
2005
2100
|
const text2 = await response.text();
|
|
2006
2101
|
if (!text2) return void 0;
|
|
2007
2102
|
try {
|
|
@@ -2011,7 +2106,7 @@ async function readJson2(response) {
|
|
|
2011
2106
|
}
|
|
2012
2107
|
}
|
|
2013
2108
|
function createGitHubGetPullRequestTool(ctx) {
|
|
2014
|
-
return
|
|
2109
|
+
return definePluginTool6({
|
|
2015
2110
|
annotations: {
|
|
2016
2111
|
destructiveHint: false,
|
|
2017
2112
|
idempotentHint: true,
|
|
@@ -2019,10 +2114,10 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2019
2114
|
readOnlyHint: true
|
|
2020
2115
|
},
|
|
2021
2116
|
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.",
|
|
2022
|
-
inputSchema:
|
|
2023
|
-
outputSchema:
|
|
2117
|
+
inputSchema: inputSchema4,
|
|
2118
|
+
outputSchema: outputSchema4,
|
|
2024
2119
|
async execute(input) {
|
|
2025
|
-
const repo =
|
|
2120
|
+
const repo = parseRepo6(input.repo);
|
|
2026
2121
|
const response = await ctx.egress.fetch({
|
|
2027
2122
|
provider: "github",
|
|
2028
2123
|
operation: "github.pull.get",
|
|
@@ -2036,23 +2131,23 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2036
2131
|
}
|
|
2037
2132
|
)
|
|
2038
2133
|
});
|
|
2039
|
-
const parsed = await
|
|
2134
|
+
const parsed = await readJson3(response);
|
|
2040
2135
|
if (!response.ok) {
|
|
2041
2136
|
const message = `GitHub pull request lookup failed with HTTP ${response.status}`;
|
|
2042
2137
|
if (response.status === 404) {
|
|
2043
|
-
throw new
|
|
2138
|
+
throw new PluginToolInputError7(message);
|
|
2044
2139
|
}
|
|
2045
2140
|
throw new Error(message);
|
|
2046
2141
|
}
|
|
2047
|
-
const providerResult =
|
|
2048
|
-
base:
|
|
2049
|
-
draft:
|
|
2050
|
-
head:
|
|
2051
|
-
html_url:
|
|
2052
|
-
merged:
|
|
2053
|
-
number:
|
|
2054
|
-
state:
|
|
2055
|
-
title:
|
|
2142
|
+
const providerResult = z9.object({
|
|
2143
|
+
base: z9.object({ ref: z9.string() }),
|
|
2144
|
+
draft: z9.boolean(),
|
|
2145
|
+
head: z9.object({ ref: z9.string(), sha: commitShaSchema2 }),
|
|
2146
|
+
html_url: z9.string(),
|
|
2147
|
+
merged: z9.boolean().optional().default(false),
|
|
2148
|
+
number: z9.number(),
|
|
2149
|
+
state: z9.string(),
|
|
2150
|
+
title: z9.string()
|
|
2056
2151
|
}).parse(parsed);
|
|
2057
2152
|
const subscribable = gitHubPullRequestSubscribable({
|
|
2058
2153
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2092,59 +2187,59 @@ function createGitHubGetPullRequestTool(ctx) {
|
|
|
2092
2187
|
|
|
2093
2188
|
// src/tools/get-release.ts
|
|
2094
2189
|
import {
|
|
2095
|
-
definePluginTool as
|
|
2096
|
-
PluginToolInputError as
|
|
2097
|
-
pluginToolOutputSchema as
|
|
2190
|
+
definePluginTool as definePluginTool7,
|
|
2191
|
+
PluginToolInputError as PluginToolInputError8,
|
|
2192
|
+
pluginToolOutputSchema as pluginToolOutputSchema7,
|
|
2098
2193
|
subscribableResourceSchema as subscribableResourceSchema5
|
|
2099
2194
|
} from "@sentry/junior-plugin-api";
|
|
2100
|
-
import { z as
|
|
2101
|
-
var
|
|
2102
|
-
repo:
|
|
2103
|
-
tag:
|
|
2195
|
+
import { z as z10 } from "zod";
|
|
2196
|
+
var inputSchema5 = z10.object({
|
|
2197
|
+
repo: z10.string().describe('Repository in "owner/name" format.'),
|
|
2198
|
+
tag: z10.string().trim().min(1).describe(
|
|
2104
2199
|
"Optional release tag name. Omit to inspect and watch every published release in the repository."
|
|
2105
2200
|
).optional()
|
|
2106
2201
|
}).strict();
|
|
2107
|
-
var releaseSchema =
|
|
2108
|
-
created_at:
|
|
2109
|
-
draft:
|
|
2110
|
-
html_url:
|
|
2111
|
-
id:
|
|
2112
|
-
name:
|
|
2113
|
-
prerelease:
|
|
2114
|
-
published_at:
|
|
2115
|
-
tag_name:
|
|
2116
|
-
target_commitish:
|
|
2202
|
+
var releaseSchema = z10.object({
|
|
2203
|
+
created_at: z10.string(),
|
|
2204
|
+
draft: z10.boolean(),
|
|
2205
|
+
html_url: z10.string(),
|
|
2206
|
+
id: z10.number(),
|
|
2207
|
+
name: z10.string().nullable(),
|
|
2208
|
+
prerelease: z10.boolean(),
|
|
2209
|
+
published_at: z10.string().nullable(),
|
|
2210
|
+
tag_name: z10.string(),
|
|
2211
|
+
target_commitish: z10.string()
|
|
2117
2212
|
}).strict();
|
|
2118
|
-
var releaseSourceSchema =
|
|
2213
|
+
var releaseSourceSchema = z10.object({
|
|
2119
2214
|
release: releaseSchema.nullable(),
|
|
2120
|
-
repo:
|
|
2215
|
+
repo: z10.string(),
|
|
2121
2216
|
subscribable: subscribableResourceSchema5.optional(),
|
|
2122
|
-
tag:
|
|
2217
|
+
tag: z10.string().nullable()
|
|
2123
2218
|
}).strict();
|
|
2124
|
-
var
|
|
2219
|
+
var outputSchema5 = pluginToolOutputSchema7.merge(
|
|
2125
2220
|
releaseSourceSchema.extend({
|
|
2126
|
-
target:
|
|
2221
|
+
target: z10.literal("getRelease")
|
|
2127
2222
|
})
|
|
2128
2223
|
);
|
|
2129
|
-
var providerReleaseSchema =
|
|
2130
|
-
created_at:
|
|
2131
|
-
draft:
|
|
2132
|
-
html_url:
|
|
2133
|
-
id:
|
|
2134
|
-
name:
|
|
2135
|
-
prerelease:
|
|
2136
|
-
published_at:
|
|
2137
|
-
tag_name:
|
|
2138
|
-
target_commitish:
|
|
2224
|
+
var providerReleaseSchema = z10.object({
|
|
2225
|
+
created_at: z10.string(),
|
|
2226
|
+
draft: z10.boolean(),
|
|
2227
|
+
html_url: z10.string(),
|
|
2228
|
+
id: z10.number(),
|
|
2229
|
+
name: z10.string().nullable(),
|
|
2230
|
+
prerelease: z10.boolean(),
|
|
2231
|
+
published_at: z10.string().nullable(),
|
|
2232
|
+
tag_name: z10.string(),
|
|
2233
|
+
target_commitish: z10.string()
|
|
2139
2234
|
}).passthrough();
|
|
2140
|
-
function
|
|
2235
|
+
function parseRepo7(value) {
|
|
2141
2236
|
const parts = value.split("/").map((part) => part.trim());
|
|
2142
2237
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
2143
|
-
throw new
|
|
2238
|
+
throw new PluginToolInputError8('repo must use "owner/name" format');
|
|
2144
2239
|
}
|
|
2145
2240
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
2146
2241
|
}
|
|
2147
|
-
async function
|
|
2242
|
+
async function readJson4(response) {
|
|
2148
2243
|
const text2 = await response.text();
|
|
2149
2244
|
if (!text2) return void 0;
|
|
2150
2245
|
try {
|
|
@@ -2170,7 +2265,7 @@ function mapRelease(providerRelease) {
|
|
|
2170
2265
|
};
|
|
2171
2266
|
}
|
|
2172
2267
|
function createGitHubGetReleaseTool(ctx) {
|
|
2173
|
-
return
|
|
2268
|
+
return definePluginTool7({
|
|
2174
2269
|
annotations: {
|
|
2175
2270
|
destructiveHint: false,
|
|
2176
2271
|
idempotentHint: true,
|
|
@@ -2178,10 +2273,10 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2178
2273
|
readOnlyHint: true
|
|
2179
2274
|
},
|
|
2180
2275
|
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.",
|
|
2181
|
-
inputSchema:
|
|
2182
|
-
outputSchema:
|
|
2276
|
+
inputSchema: inputSchema5,
|
|
2277
|
+
outputSchema: outputSchema5,
|
|
2183
2278
|
async execute(input) {
|
|
2184
|
-
const repo =
|
|
2279
|
+
const repo = parseRepo7(input.repo);
|
|
2185
2280
|
const tag = input.tag?.trim() || void 0;
|
|
2186
2281
|
let release = null;
|
|
2187
2282
|
if (tag) {
|
|
@@ -2198,7 +2293,7 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2198
2293
|
}
|
|
2199
2294
|
)
|
|
2200
2295
|
});
|
|
2201
|
-
const body = await
|
|
2296
|
+
const body = await readJson4(response);
|
|
2202
2297
|
if (response.ok) {
|
|
2203
2298
|
release = mapRelease(providerReleaseSchema.parse(body));
|
|
2204
2299
|
} else if (response.status !== 404) {
|
|
@@ -2217,7 +2312,7 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2217
2312
|
}
|
|
2218
2313
|
})
|
|
2219
2314
|
});
|
|
2220
|
-
const body = await
|
|
2315
|
+
const body = await readJson4(response);
|
|
2221
2316
|
if (response.ok) {
|
|
2222
2317
|
release = mapRelease(providerReleaseSchema.parse(body));
|
|
2223
2318
|
} else if (response.status === 404) {
|
|
@@ -2249,36 +2344,36 @@ function createGitHubGetReleaseTool(ctx) {
|
|
|
2249
2344
|
|
|
2250
2345
|
// src/tools/get-repository.ts
|
|
2251
2346
|
import {
|
|
2252
|
-
definePluginTool as
|
|
2253
|
-
PluginToolInputError as
|
|
2254
|
-
pluginToolOutputSchema as
|
|
2347
|
+
definePluginTool as definePluginTool8,
|
|
2348
|
+
PluginToolInputError as PluginToolInputError9,
|
|
2349
|
+
pluginToolOutputSchema as pluginToolOutputSchema8,
|
|
2255
2350
|
subscribableResourceSchema as subscribableResourceSchema6
|
|
2256
2351
|
} from "@sentry/junior-plugin-api";
|
|
2257
|
-
import { z as
|
|
2258
|
-
var
|
|
2259
|
-
repo:
|
|
2352
|
+
import { z as z11 } from "zod";
|
|
2353
|
+
var inputSchema6 = z11.object({
|
|
2354
|
+
repo: z11.string().describe('Repository in "owner/name" format.')
|
|
2260
2355
|
}).strict();
|
|
2261
|
-
var repositorySchema =
|
|
2262
|
-
default_branch:
|
|
2263
|
-
description:
|
|
2264
|
-
full_name:
|
|
2265
|
-
private:
|
|
2356
|
+
var repositorySchema = z11.object({
|
|
2357
|
+
default_branch: z11.string(),
|
|
2358
|
+
description: z11.string().nullable(),
|
|
2359
|
+
full_name: z11.string(),
|
|
2360
|
+
private: z11.boolean(),
|
|
2266
2361
|
subscribable: subscribableResourceSchema6.optional(),
|
|
2267
|
-
url:
|
|
2362
|
+
url: z11.string()
|
|
2268
2363
|
});
|
|
2269
|
-
var
|
|
2364
|
+
var outputSchema6 = pluginToolOutputSchema8.merge(
|
|
2270
2365
|
repositorySchema.extend({
|
|
2271
|
-
target:
|
|
2366
|
+
target: z11.literal("getRepository")
|
|
2272
2367
|
})
|
|
2273
2368
|
);
|
|
2274
|
-
function
|
|
2369
|
+
function parseRepo8(value) {
|
|
2275
2370
|
const parts = value.split("/").map((part) => part.trim());
|
|
2276
2371
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
2277
|
-
throw new
|
|
2372
|
+
throw new PluginToolInputError9('repo must use "owner/name" format');
|
|
2278
2373
|
}
|
|
2279
2374
|
return { owner: parts[0], name: parts[1] };
|
|
2280
2375
|
}
|
|
2281
|
-
async function
|
|
2376
|
+
async function readJson5(response) {
|
|
2282
2377
|
const text2 = await response.text();
|
|
2283
2378
|
if (!text2) return void 0;
|
|
2284
2379
|
try {
|
|
@@ -2288,7 +2383,7 @@ async function readJson4(response) {
|
|
|
2288
2383
|
}
|
|
2289
2384
|
}
|
|
2290
2385
|
function createGitHubGetRepositoryTool(ctx) {
|
|
2291
|
-
return
|
|
2386
|
+
return definePluginTool8({
|
|
2292
2387
|
annotations: {
|
|
2293
2388
|
destructiveHint: false,
|
|
2294
2389
|
idempotentHint: true,
|
|
@@ -2296,10 +2391,10 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2296
2391
|
readOnlyHint: true
|
|
2297
2392
|
},
|
|
2298
2393
|
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.",
|
|
2299
|
-
inputSchema:
|
|
2300
|
-
outputSchema:
|
|
2394
|
+
inputSchema: inputSchema6,
|
|
2395
|
+
outputSchema: outputSchema6,
|
|
2301
2396
|
async execute(input) {
|
|
2302
|
-
const repo =
|
|
2397
|
+
const repo = parseRepo8(input.repo);
|
|
2303
2398
|
const response = await ctx.egress.fetch({
|
|
2304
2399
|
provider: "github",
|
|
2305
2400
|
operation: "github.repository.get",
|
|
@@ -2313,18 +2408,18 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2313
2408
|
}
|
|
2314
2409
|
)
|
|
2315
2410
|
});
|
|
2316
|
-
const parsed = await
|
|
2411
|
+
const parsed = await readJson5(response);
|
|
2317
2412
|
if (!response.ok) {
|
|
2318
|
-
throw new
|
|
2413
|
+
throw new PluginToolInputError9(
|
|
2319
2414
|
`GitHub repository lookup failed with HTTP ${response.status}`
|
|
2320
2415
|
);
|
|
2321
2416
|
}
|
|
2322
|
-
const providerResult =
|
|
2323
|
-
default_branch:
|
|
2324
|
-
description:
|
|
2325
|
-
full_name:
|
|
2326
|
-
html_url:
|
|
2327
|
-
private:
|
|
2417
|
+
const providerResult = z11.object({
|
|
2418
|
+
default_branch: z11.string(),
|
|
2419
|
+
description: z11.string().nullable(),
|
|
2420
|
+
full_name: z11.string(),
|
|
2421
|
+
html_url: z11.string(),
|
|
2422
|
+
private: z11.boolean()
|
|
2328
2423
|
}).parse(parsed);
|
|
2329
2424
|
const subscribable = gitHubRepositorySubscribable({
|
|
2330
2425
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2348,27 +2443,27 @@ function createGitHubGetRepositoryTool(ctx) {
|
|
|
2348
2443
|
|
|
2349
2444
|
// src/tools/get-status.ts
|
|
2350
2445
|
import {
|
|
2351
|
-
definePluginTool as
|
|
2352
|
-
pluginToolOutputSchema as
|
|
2446
|
+
definePluginTool as definePluginTool9,
|
|
2447
|
+
pluginToolOutputSchema as pluginToolOutputSchema9
|
|
2353
2448
|
} from "@sentry/junior-plugin-api";
|
|
2354
|
-
import { z as
|
|
2449
|
+
import { z as z13 } from "zod";
|
|
2355
2450
|
|
|
2356
2451
|
// src/github-status.ts
|
|
2357
|
-
import { z as
|
|
2452
|
+
import { z as z12 } from "zod";
|
|
2358
2453
|
var GITHUB_STATUS_INCIDENTS_URL = "https://www.githubstatus.com/api/v2/incidents.json";
|
|
2359
2454
|
var GITHUB_STATUS_TTL_MS = 60 * 1e3;
|
|
2360
2455
|
var GITHUB_STATUS_TIMEOUT_MS = 5e3;
|
|
2361
|
-
var incidentsResponseSchema =
|
|
2362
|
-
incidents:
|
|
2363
|
-
|
|
2364
|
-
components:
|
|
2365
|
-
created_at:
|
|
2366
|
-
impact:
|
|
2367
|
-
name:
|
|
2368
|
-
resolved_at:
|
|
2369
|
-
shortlink:
|
|
2370
|
-
started_at:
|
|
2371
|
-
status:
|
|
2456
|
+
var incidentsResponseSchema = z12.object({
|
|
2457
|
+
incidents: z12.array(
|
|
2458
|
+
z12.object({
|
|
2459
|
+
components: z12.array(z12.object({ name: z12.string() })).default([]),
|
|
2460
|
+
created_at: z12.string(),
|
|
2461
|
+
impact: z12.string(),
|
|
2462
|
+
name: z12.string(),
|
|
2463
|
+
resolved_at: z12.string().nullable(),
|
|
2464
|
+
shortlink: z12.string(),
|
|
2465
|
+
started_at: z12.string().nullable().optional(),
|
|
2466
|
+
status: z12.string()
|
|
2372
2467
|
})
|
|
2373
2468
|
)
|
|
2374
2469
|
});
|
|
@@ -2410,22 +2505,22 @@ async function loadGitHubStatusIncidents(cache, withinMs) {
|
|
|
2410
2505
|
|
|
2411
2506
|
// src/tools/get-status.ts
|
|
2412
2507
|
var RECENT_INCIDENT_MS = 24 * 60 * 60 * 1e3;
|
|
2413
|
-
var
|
|
2414
|
-
var incidentSchema =
|
|
2415
|
-
components:
|
|
2416
|
-
impact:
|
|
2417
|
-
name:
|
|
2418
|
-
resolved_at:
|
|
2419
|
-
started_at:
|
|
2420
|
-
status:
|
|
2421
|
-
url:
|
|
2508
|
+
var inputSchema7 = z13.object({}).strict();
|
|
2509
|
+
var incidentSchema = z13.object({
|
|
2510
|
+
components: z13.array(z13.string()),
|
|
2511
|
+
impact: z13.string(),
|
|
2512
|
+
name: z13.string(),
|
|
2513
|
+
resolved_at: z13.string().optional(),
|
|
2514
|
+
started_at: z13.string(),
|
|
2515
|
+
status: z13.string(),
|
|
2516
|
+
url: z13.string()
|
|
2422
2517
|
});
|
|
2423
|
-
var
|
|
2424
|
-
target:
|
|
2425
|
-
incidents:
|
|
2518
|
+
var outputSchema7 = pluginToolOutputSchema9.extend({
|
|
2519
|
+
target: z13.literal("getStatus"),
|
|
2520
|
+
incidents: z13.array(incidentSchema)
|
|
2426
2521
|
});
|
|
2427
2522
|
function createGitHubGetStatusTool(ctx) {
|
|
2428
|
-
return
|
|
2523
|
+
return definePluginTool9({
|
|
2429
2524
|
annotations: {
|
|
2430
2525
|
destructiveHint: false,
|
|
2431
2526
|
idempotentHint: true,
|
|
@@ -2433,8 +2528,8 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2433
2528
|
readOnlyHint: true
|
|
2434
2529
|
},
|
|
2435
2530
|
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.",
|
|
2436
|
-
inputSchema:
|
|
2437
|
-
outputSchema:
|
|
2531
|
+
inputSchema: inputSchema7,
|
|
2532
|
+
outputSchema: outputSchema7,
|
|
2438
2533
|
async execute() {
|
|
2439
2534
|
const incidents = await loadGitHubStatusIncidents(
|
|
2440
2535
|
ctx.cache,
|
|
@@ -2457,49 +2552,49 @@ function createGitHubGetStatusTool(ctx) {
|
|
|
2457
2552
|
|
|
2458
2553
|
// src/tools/update-issue.ts
|
|
2459
2554
|
import {
|
|
2460
|
-
definePluginTool as
|
|
2461
|
-
PluginToolInputError as
|
|
2462
|
-
pluginToolOutputSchema as
|
|
2555
|
+
definePluginTool as definePluginTool10,
|
|
2556
|
+
PluginToolInputError as PluginToolInputError10,
|
|
2557
|
+
pluginToolOutputSchema as pluginToolOutputSchema10,
|
|
2463
2558
|
subscribableResourceSchema as subscribableResourceSchema7
|
|
2464
2559
|
} from "@sentry/junior-plugin-api";
|
|
2465
|
-
import { z as
|
|
2466
|
-
var
|
|
2467
|
-
repo:
|
|
2468
|
-
number:
|
|
2469
|
-
title:
|
|
2470
|
-
body:
|
|
2560
|
+
import { z as z14 } from "zod";
|
|
2561
|
+
var inputSchema8 = z14.object({
|
|
2562
|
+
repo: z14.string().describe('Repository in "owner/name" format.'),
|
|
2563
|
+
number: z14.number().int().positive().describe("Issue number."),
|
|
2564
|
+
title: z14.string().trim().min(1).optional().describe("Replacement issue title."),
|
|
2565
|
+
body: z14.string().optional().describe(
|
|
2471
2566
|
"Replacement issue body. The runtime appends requester attribution and the conversation footer."
|
|
2472
2567
|
),
|
|
2473
|
-
state:
|
|
2568
|
+
state: z14.enum(["open", "closed"]).optional().describe("Replacement issue state.")
|
|
2474
2569
|
}).strict().refine(
|
|
2475
2570
|
({ title, body, state }) => title !== void 0 || body !== void 0 || state !== void 0,
|
|
2476
2571
|
{ message: "At least one issue field must be provided." }
|
|
2477
2572
|
);
|
|
2478
|
-
var issueSchema =
|
|
2479
|
-
body:
|
|
2480
|
-
number:
|
|
2481
|
-
state:
|
|
2573
|
+
var issueSchema = z14.object({
|
|
2574
|
+
body: z14.string().nullable(),
|
|
2575
|
+
number: z14.number(),
|
|
2576
|
+
state: z14.string(),
|
|
2482
2577
|
subscribable: subscribableResourceSchema7.optional(),
|
|
2483
|
-
title:
|
|
2484
|
-
url:
|
|
2578
|
+
title: z14.string(),
|
|
2579
|
+
url: z14.string()
|
|
2485
2580
|
});
|
|
2486
|
-
var
|
|
2581
|
+
var outputSchema8 = pluginToolOutputSchema10.merge(
|
|
2487
2582
|
issueSchema.extend({
|
|
2488
|
-
target:
|
|
2583
|
+
target: z14.literal("updateIssue")
|
|
2489
2584
|
})
|
|
2490
2585
|
);
|
|
2491
2586
|
function nonEmptyString4(value, name) {
|
|
2492
|
-
if (!value?.trim()) throw new
|
|
2587
|
+
if (!value?.trim()) throw new PluginToolInputError10(`${name} is required`);
|
|
2493
2588
|
return value.trim();
|
|
2494
2589
|
}
|
|
2495
|
-
function
|
|
2590
|
+
function parseRepo9(value) {
|
|
2496
2591
|
const parts = value.split("/").map((part) => part.trim());
|
|
2497
2592
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
2498
|
-
throw new
|
|
2593
|
+
throw new PluginToolInputError10('repo must use "owner/name" format');
|
|
2499
2594
|
}
|
|
2500
2595
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
2501
2596
|
}
|
|
2502
|
-
async function
|
|
2597
|
+
async function readJson6(response) {
|
|
2503
2598
|
const text2 = await response.text();
|
|
2504
2599
|
if (!text2) return void 0;
|
|
2505
2600
|
try {
|
|
@@ -2517,7 +2612,7 @@ function githubApiErrorMessage3(payload) {
|
|
|
2517
2612
|
return "GitHub request failed";
|
|
2518
2613
|
}
|
|
2519
2614
|
function createGitHubUpdateIssueTool(ctx) {
|
|
2520
|
-
return
|
|
2615
|
+
return definePluginTool10({
|
|
2521
2616
|
annotations: {
|
|
2522
2617
|
destructiveHint: true,
|
|
2523
2618
|
idempotentHint: true,
|
|
@@ -2525,17 +2620,17 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2525
2620
|
readOnlyHint: false
|
|
2526
2621
|
},
|
|
2527
2622
|
description: "Update an existing GitHub issue's title, body, or open/closed state. Use this instead of raw GitHub API calls when changing issue metadata.",
|
|
2528
|
-
inputSchema:
|
|
2529
|
-
outputSchema:
|
|
2623
|
+
inputSchema: inputSchema8,
|
|
2624
|
+
outputSchema: outputSchema8,
|
|
2530
2625
|
async execute(input) {
|
|
2531
|
-
const parsedInput =
|
|
2626
|
+
const parsedInput = inputSchema8.safeParse(input);
|
|
2532
2627
|
if (!parsedInput.success) {
|
|
2533
|
-
throw new
|
|
2628
|
+
throw new PluginToolInputError10("Invalid GitHub updateIssue input.", {
|
|
2534
2629
|
cause: parsedInput.error
|
|
2535
2630
|
});
|
|
2536
2631
|
}
|
|
2537
2632
|
const update = parsedInput.data;
|
|
2538
|
-
const repo =
|
|
2633
|
+
const repo = parseRepo9(update.repo);
|
|
2539
2634
|
const payload = {
|
|
2540
2635
|
...update.title !== void 0 ? { title: update.title } : void 0,
|
|
2541
2636
|
...update.body !== void 0 ? {
|
|
@@ -2567,18 +2662,18 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2567
2662
|
}
|
|
2568
2663
|
)
|
|
2569
2664
|
});
|
|
2570
|
-
const parsed = await
|
|
2665
|
+
const parsed = await readJson6(response);
|
|
2571
2666
|
if (!response.ok) {
|
|
2572
2667
|
throw new Error(
|
|
2573
2668
|
`GitHub issue update failed with HTTP ${response.status}: ${githubApiErrorMessage3(parsed)}`
|
|
2574
2669
|
);
|
|
2575
2670
|
}
|
|
2576
|
-
const providerResult =
|
|
2577
|
-
body:
|
|
2578
|
-
html_url:
|
|
2579
|
-
number:
|
|
2580
|
-
state:
|
|
2581
|
-
title:
|
|
2671
|
+
const providerResult = z14.object({
|
|
2672
|
+
body: z14.string().nullable().optional().default(null),
|
|
2673
|
+
html_url: z14.string(),
|
|
2674
|
+
number: z14.number(),
|
|
2675
|
+
state: z14.string(),
|
|
2676
|
+
title: z14.string()
|
|
2582
2677
|
}).parse(parsed);
|
|
2583
2678
|
const subscribable = gitHubIssueSubscribable({
|
|
2584
2679
|
canSubscribe: ctx.events.canSubscribe,
|
|
@@ -2611,22 +2706,22 @@ function createGitHubUpdateIssueTool(ctx) {
|
|
|
2611
2706
|
|
|
2612
2707
|
// src/tools/update-pull-request.ts
|
|
2613
2708
|
import {
|
|
2614
|
-
definePluginTool as
|
|
2615
|
-
PluginToolInputError as
|
|
2616
|
-
pluginToolOutputSchema as
|
|
2709
|
+
definePluginTool as definePluginTool11,
|
|
2710
|
+
PluginToolInputError as PluginToolInputError11,
|
|
2711
|
+
pluginToolOutputSchema as pluginToolOutputSchema11
|
|
2617
2712
|
} from "@sentry/junior-plugin-api";
|
|
2618
|
-
import { z as
|
|
2713
|
+
import { z as z15 } from "zod";
|
|
2619
2714
|
import { subscribableResourceSchema as subscribableResourceSchema8 } from "@sentry/junior-plugin-api";
|
|
2620
|
-
var
|
|
2621
|
-
repo:
|
|
2622
|
-
number:
|
|
2623
|
-
title:
|
|
2624
|
-
body:
|
|
2715
|
+
var inputSchema9 = z15.object({
|
|
2716
|
+
repo: z15.string().describe('Repository in "owner/name" format.'),
|
|
2717
|
+
number: z15.number().int().positive().describe("Pull request number."),
|
|
2718
|
+
title: z15.string().trim().min(1).optional().describe("Replacement pull request title."),
|
|
2719
|
+
body: z15.string().optional().describe(
|
|
2625
2720
|
"Replacement pull request body. The runtime appends requester attribution and the conversation footer."
|
|
2626
2721
|
),
|
|
2627
|
-
base:
|
|
2628
|
-
state:
|
|
2629
|
-
draft:
|
|
2722
|
+
base: z15.string().trim().min(1).optional().describe("Replacement base branch."),
|
|
2723
|
+
state: z15.enum(["open", "closed"]).optional().describe("Replacement pull request state."),
|
|
2724
|
+
draft: z15.boolean().optional().describe(
|
|
2630
2725
|
"Set false to mark a draft pull request ready for review, or true to convert it back to a draft."
|
|
2631
2726
|
)
|
|
2632
2727
|
}).strict().refine(
|
|
@@ -2641,43 +2736,43 @@ var CONVERT_TO_DRAFT = {
|
|
|
2641
2736
|
operationName: "ConvertPullRequestToDraft",
|
|
2642
2737
|
query: "mutation ConvertPullRequestToDraft($id: ID!) { result: convertPullRequestToDraft(input: {pullRequestId: $id}) { pullRequest { isDraft } } }"
|
|
2643
2738
|
};
|
|
2644
|
-
var draftMutationResponseSchema =
|
|
2645
|
-
data:
|
|
2646
|
-
result:
|
|
2739
|
+
var draftMutationResponseSchema = z15.object({
|
|
2740
|
+
data: z15.object({
|
|
2741
|
+
result: z15.object({ pullRequest: z15.object({ isDraft: z15.boolean() }) })
|
|
2647
2742
|
})
|
|
2648
2743
|
});
|
|
2649
|
-
var graphqlErrorsSchema =
|
|
2650
|
-
errors:
|
|
2744
|
+
var graphqlErrorsSchema = z15.object({
|
|
2745
|
+
errors: z15.array(z15.object({ message: z15.string() })).min(1)
|
|
2651
2746
|
});
|
|
2652
|
-
var pullRequestSchema2 =
|
|
2653
|
-
base:
|
|
2654
|
-
body:
|
|
2655
|
-
draft:
|
|
2656
|
-
number:
|
|
2657
|
-
state:
|
|
2747
|
+
var pullRequestSchema2 = z15.object({
|
|
2748
|
+
base: z15.string(),
|
|
2749
|
+
body: z15.string().nullable(),
|
|
2750
|
+
draft: z15.boolean(),
|
|
2751
|
+
number: z15.number(),
|
|
2752
|
+
state: z15.string(),
|
|
2658
2753
|
subscribable: subscribableResourceSchema8.optional(),
|
|
2659
|
-
title:
|
|
2660
|
-
url:
|
|
2754
|
+
title: z15.string(),
|
|
2755
|
+
url: z15.string()
|
|
2661
2756
|
});
|
|
2662
|
-
var
|
|
2757
|
+
var outputSchema9 = pluginToolOutputSchema11.merge(
|
|
2663
2758
|
pullRequestSchema2.extend({
|
|
2664
|
-
target:
|
|
2759
|
+
target: z15.literal("updatePullRequest")
|
|
2665
2760
|
})
|
|
2666
2761
|
);
|
|
2667
2762
|
function nonEmptyString5(value, name) {
|
|
2668
2763
|
if (!value?.trim()) {
|
|
2669
|
-
throw new
|
|
2764
|
+
throw new PluginToolInputError11(`${name} is required`);
|
|
2670
2765
|
}
|
|
2671
2766
|
return value.trim();
|
|
2672
2767
|
}
|
|
2673
|
-
function
|
|
2768
|
+
function parseRepo10(value) {
|
|
2674
2769
|
const parts = value.split("/").map((part) => part.trim());
|
|
2675
2770
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
2676
|
-
throw new
|
|
2771
|
+
throw new PluginToolInputError11('repo must use "owner/name" format');
|
|
2677
2772
|
}
|
|
2678
2773
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
2679
2774
|
}
|
|
2680
|
-
async function
|
|
2775
|
+
async function readJson7(response) {
|
|
2681
2776
|
const text2 = await response.text();
|
|
2682
2777
|
if (!text2) return void 0;
|
|
2683
2778
|
try {
|
|
@@ -2709,7 +2804,7 @@ async function setPullRequestDraft(input) {
|
|
|
2709
2804
|
})
|
|
2710
2805
|
})
|
|
2711
2806
|
});
|
|
2712
|
-
const payload = await
|
|
2807
|
+
const payload = await readJson7(response);
|
|
2713
2808
|
const isDraft = draftMutationResponseSchema.safeParse(payload).data?.data.result.pullRequest.isDraft;
|
|
2714
2809
|
if (!response.ok || isDraft !== input.draft) {
|
|
2715
2810
|
throw new Error(
|
|
@@ -2723,7 +2818,7 @@ function githubGraphqlErrorMessage(payload) {
|
|
|
2723
2818
|
return result.success ? result.data.errors.map((error) => error.message).join("; ") : githubApiErrorMessage4(payload);
|
|
2724
2819
|
}
|
|
2725
2820
|
function createGitHubUpdatePullRequestTool(ctx) {
|
|
2726
|
-
return
|
|
2821
|
+
return definePluginTool11({
|
|
2727
2822
|
annotations: {
|
|
2728
2823
|
destructiveHint: true,
|
|
2729
2824
|
idempotentHint: true,
|
|
@@ -2731,18 +2826,18 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2731
2826
|
readOnlyHint: false
|
|
2732
2827
|
},
|
|
2733
2828
|
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.",
|
|
2734
|
-
inputSchema:
|
|
2735
|
-
outputSchema:
|
|
2829
|
+
inputSchema: inputSchema9,
|
|
2830
|
+
outputSchema: outputSchema9,
|
|
2736
2831
|
async execute(input) {
|
|
2737
|
-
const parsedInput =
|
|
2832
|
+
const parsedInput = inputSchema9.safeParse(input);
|
|
2738
2833
|
if (!parsedInput.success) {
|
|
2739
|
-
throw new
|
|
2834
|
+
throw new PluginToolInputError11(
|
|
2740
2835
|
"Invalid GitHub updatePullRequest input.",
|
|
2741
2836
|
{ cause: parsedInput.error }
|
|
2742
2837
|
);
|
|
2743
2838
|
}
|
|
2744
2839
|
const update = parsedInput.data;
|
|
2745
|
-
const repo =
|
|
2840
|
+
const repo = parseRepo10(update.repo);
|
|
2746
2841
|
const requester = await resolveGitHubRequester(ctx);
|
|
2747
2842
|
const payload = {
|
|
2748
2843
|
...update.title !== void 0 ? { title: update.title } : void 0,
|
|
@@ -2771,22 +2866,22 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2771
2866
|
...hasRestUpdate ? { body: JSON.stringify(payload) } : void 0
|
|
2772
2867
|
})
|
|
2773
2868
|
});
|
|
2774
|
-
const parsed = await
|
|
2869
|
+
const parsed = await readJson7(response);
|
|
2775
2870
|
if (!response.ok) {
|
|
2776
2871
|
throw new Error(
|
|
2777
2872
|
`GitHub pull request update failed with HTTP ${response.status}: ${githubApiErrorMessage4(parsed)}`
|
|
2778
2873
|
);
|
|
2779
2874
|
}
|
|
2780
|
-
const providerResult =
|
|
2781
|
-
base:
|
|
2782
|
-
body:
|
|
2783
|
-
draft:
|
|
2784
|
-
html_url:
|
|
2785
|
-
merged:
|
|
2786
|
-
node_id:
|
|
2787
|
-
number:
|
|
2788
|
-
state:
|
|
2789
|
-
title:
|
|
2875
|
+
const providerResult = z15.object({
|
|
2876
|
+
base: z15.object({ ref: z15.string() }),
|
|
2877
|
+
body: z15.string().nullable().optional().default(null),
|
|
2878
|
+
draft: z15.boolean(),
|
|
2879
|
+
html_url: z15.string(),
|
|
2880
|
+
merged: z15.boolean(),
|
|
2881
|
+
node_id: z15.string().optional(),
|
|
2882
|
+
number: z15.number(),
|
|
2883
|
+
state: z15.string(),
|
|
2884
|
+
title: z15.string()
|
|
2790
2885
|
}).parse(parsed);
|
|
2791
2886
|
if (update.draft !== void 0 && update.draft !== providerResult.draft) {
|
|
2792
2887
|
if (!providerResult.node_id) {
|
|
@@ -2847,11 +2942,11 @@ function createGitHubUpdatePullRequestTool(ctx) {
|
|
|
2847
2942
|
|
|
2848
2943
|
// src/tools/update-pull-request-feedback.ts
|
|
2849
2944
|
import {
|
|
2850
|
-
definePluginTool as
|
|
2851
|
-
PluginToolInputError as
|
|
2852
|
-
pluginToolOutputSchema as
|
|
2945
|
+
definePluginTool as definePluginTool12,
|
|
2946
|
+
PluginToolInputError as PluginToolInputError12,
|
|
2947
|
+
pluginToolOutputSchema as pluginToolOutputSchema12
|
|
2853
2948
|
} from "@sentry/junior-plugin-api";
|
|
2854
|
-
import { z as
|
|
2949
|
+
import { z as z16 } from "zod";
|
|
2855
2950
|
var STATUS_TO_REACTION_CONTENT = {
|
|
2856
2951
|
reviewing: "eyes",
|
|
2857
2952
|
addressed: "+1",
|
|
@@ -2860,29 +2955,29 @@ var STATUS_TO_REACTION_CONTENT = {
|
|
|
2860
2955
|
var FEEDBACK_REACTION_CONTENTS = new Set(
|
|
2861
2956
|
Object.values(STATUS_TO_REACTION_CONTENT)
|
|
2862
2957
|
);
|
|
2863
|
-
var
|
|
2864
|
-
repo:
|
|
2865
|
-
comment_kind:
|
|
2958
|
+
var inputSchema10 = z16.object({
|
|
2959
|
+
repo: z16.string().describe('Repository in "owner/name" format.'),
|
|
2960
|
+
comment_kind: z16.enum(["conversation", "review"]).describe(
|
|
2866
2961
|
'Comment kind: "conversation" for a pull request conversation comment, "review" for an inline review comment.'
|
|
2867
2962
|
),
|
|
2868
|
-
comment_id:
|
|
2963
|
+
comment_id: z16.number().int().positive().describe(
|
|
2869
2964
|
"GitHub comment id (conversation comment id or inline review comment id)."
|
|
2870
2965
|
),
|
|
2871
|
-
status:
|
|
2966
|
+
status: z16.enum(["addressed", "declined"]).describe(
|
|
2872
2967
|
"Feedback outcome. Maps to a reaction: addressed -> +1, declined -> -1."
|
|
2873
2968
|
)
|
|
2874
2969
|
}).strict();
|
|
2875
|
-
var
|
|
2876
|
-
target:
|
|
2877
|
-
repo:
|
|
2878
|
-
comment_id:
|
|
2879
|
-
status:
|
|
2880
|
-
reaction_id:
|
|
2970
|
+
var outputSchema10 = pluginToolOutputSchema12.extend({
|
|
2971
|
+
target: z16.literal("updatePullRequestFeedback"),
|
|
2972
|
+
repo: z16.string(),
|
|
2973
|
+
comment_id: z16.number(),
|
|
2974
|
+
status: z16.enum(["addressed", "declined"]),
|
|
2975
|
+
reaction_id: z16.number()
|
|
2881
2976
|
});
|
|
2882
|
-
function
|
|
2977
|
+
function parseRepo11(value) {
|
|
2883
2978
|
const parts = value.split("/").map((part) => part.trim());
|
|
2884
2979
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
2885
|
-
throw new
|
|
2980
|
+
throw new PluginToolInputError12('repo must use "owner/name" format');
|
|
2886
2981
|
}
|
|
2887
2982
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
2888
2983
|
}
|
|
@@ -2896,7 +2991,7 @@ function pullRequestCommentReactionsPath(input) {
|
|
|
2896
2991
|
function pullRequestFeedbackReactionContent(status) {
|
|
2897
2992
|
return STATUS_TO_REACTION_CONTENT[status];
|
|
2898
2993
|
}
|
|
2899
|
-
async function
|
|
2994
|
+
async function readJson8(response) {
|
|
2900
2995
|
const text2 = await response.text();
|
|
2901
2996
|
if (!text2) return void 0;
|
|
2902
2997
|
try {
|
|
@@ -2905,17 +3000,17 @@ async function readJson7(response) {
|
|
|
2905
3000
|
return text2;
|
|
2906
3001
|
}
|
|
2907
3002
|
}
|
|
2908
|
-
function
|
|
3003
|
+
function githubError2(payload) {
|
|
2909
3004
|
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
|
|
2910
3005
|
const message = payload.message;
|
|
2911
3006
|
if (typeof message === "string" && message.trim()) return message.trim();
|
|
2912
3007
|
}
|
|
2913
3008
|
return "GitHub request failed";
|
|
2914
3009
|
}
|
|
2915
|
-
var reactionSchema =
|
|
2916
|
-
id:
|
|
2917
|
-
content:
|
|
2918
|
-
user:
|
|
3010
|
+
var reactionSchema = z16.object({
|
|
3011
|
+
id: z16.number(),
|
|
3012
|
+
content: z16.string(),
|
|
3013
|
+
user: z16.object({ id: z16.number() }).nullable()
|
|
2919
3014
|
});
|
|
2920
3015
|
async function assertBotAuthoredPullRequest(egress, input) {
|
|
2921
3016
|
const headers = {
|
|
@@ -2930,15 +3025,15 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
2930
3025
|
{ headers }
|
|
2931
3026
|
)
|
|
2932
3027
|
});
|
|
2933
|
-
const commentPayload = await
|
|
3028
|
+
const commentPayload = await readJson8(commentResponse);
|
|
2934
3029
|
if (!commentResponse.ok) {
|
|
2935
|
-
const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${
|
|
2936
|
-
if (commentResponse.status === 404) throw new
|
|
3030
|
+
const message = `GitHub comment lookup failed with HTTP ${commentResponse.status}: ${githubError2(commentPayload)}`;
|
|
3031
|
+
if (commentResponse.status === 404) throw new PluginToolInputError12(message);
|
|
2937
3032
|
throw new Error(message);
|
|
2938
3033
|
}
|
|
2939
|
-
const comment =
|
|
2940
|
-
issue_url:
|
|
2941
|
-
pull_request_url:
|
|
3034
|
+
const comment = z16.object({
|
|
3035
|
+
issue_url: z16.string().optional(),
|
|
3036
|
+
pull_request_url: z16.string().optional()
|
|
2942
3037
|
}).safeParse(commentPayload);
|
|
2943
3038
|
const parentUrl = comment.success ? input.commentKind === "conversation" ? comment.data.issue_url : comment.data.pull_request_url : void 0;
|
|
2944
3039
|
const number = /\/(?:issues|pulls)\/(\d+)$/.exec(parentUrl ?? "")?.[1];
|
|
@@ -2953,21 +3048,21 @@ async function assertBotAuthoredPullRequest(egress, input) {
|
|
|
2953
3048
|
{ headers }
|
|
2954
3049
|
)
|
|
2955
3050
|
});
|
|
2956
|
-
const pullPayload = await
|
|
3051
|
+
const pullPayload = await readJson8(pullResponse);
|
|
2957
3052
|
if (!pullResponse.ok && pullResponse.status !== 404) {
|
|
2958
3053
|
throw new Error(
|
|
2959
|
-
`GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${
|
|
3054
|
+
`GitHub pull request lookup failed with HTTP ${pullResponse.status}: ${githubError2(pullPayload)}`
|
|
2960
3055
|
);
|
|
2961
3056
|
}
|
|
2962
|
-
const pull =
|
|
3057
|
+
const pull = z16.object({ user: z16.object({ id: z16.number() }).nullable() }).safeParse(pullPayload);
|
|
2963
3058
|
if (!pullResponse.ok || !pull.success || pull.data.user?.id !== input.botUserId) {
|
|
2964
|
-
throw new
|
|
3059
|
+
throw new PluginToolInputError12(
|
|
2965
3060
|
"This bot can only set feedback status on comments on pull requests it authored."
|
|
2966
3061
|
);
|
|
2967
3062
|
}
|
|
2968
3063
|
}
|
|
2969
3064
|
function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
2970
|
-
return
|
|
3065
|
+
return definePluginTool12({
|
|
2971
3066
|
// No action review: the tool checks in code that the bot authored the pull
|
|
2972
3067
|
// request, and it changes only the bot's own reaction, which is reversible.
|
|
2973
3068
|
approvalMode: "approve",
|
|
@@ -2979,12 +3074,12 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2979
3074
|
},
|
|
2980
3075
|
description: "Set your outcome reaction on GitHub pull request feedback: addressed (+1) or declined (-1). Use the 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.",
|
|
2981
3076
|
exposure: "direct",
|
|
2982
|
-
inputSchema:
|
|
2983
|
-
outputSchema:
|
|
3077
|
+
inputSchema: inputSchema10,
|
|
3078
|
+
outputSchema: outputSchema10,
|
|
2984
3079
|
async execute(input) {
|
|
2985
|
-
const parsedInput =
|
|
3080
|
+
const parsedInput = inputSchema10.safeParse(input);
|
|
2986
3081
|
if (!parsedInput.success) {
|
|
2987
|
-
throw new
|
|
3082
|
+
throw new PluginToolInputError12(
|
|
2988
3083
|
"Invalid GitHub updatePullRequestFeedback input.",
|
|
2989
3084
|
{ cause: parsedInput.error }
|
|
2990
3085
|
);
|
|
@@ -2994,7 +3089,7 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
2994
3089
|
comment_kind: commentKind,
|
|
2995
3090
|
status
|
|
2996
3091
|
} = parsedInput.data;
|
|
2997
|
-
const repo =
|
|
3092
|
+
const repo = parseRepo11(parsedInput.data.repo);
|
|
2998
3093
|
const botUserId = botUserIdFromEmail(botEmail);
|
|
2999
3094
|
if (botUserId === void 0) {
|
|
3000
3095
|
throw new Error("GitHub App bot identity is not configured.");
|
|
@@ -3020,13 +3115,13 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
3020
3115
|
headers: { Accept: "application/vnd.github+json" }
|
|
3021
3116
|
})
|
|
3022
3117
|
});
|
|
3023
|
-
const listPayload = await
|
|
3118
|
+
const listPayload = await readJson8(listResponse);
|
|
3024
3119
|
if (!listResponse.ok) {
|
|
3025
3120
|
throw new Error(
|
|
3026
|
-
`GitHub reaction lookup failed with HTTP ${listResponse.status}: ${
|
|
3121
|
+
`GitHub reaction lookup failed with HTTP ${listResponse.status}: ${githubError2(listPayload)}`
|
|
3027
3122
|
);
|
|
3028
3123
|
}
|
|
3029
|
-
const botReactions =
|
|
3124
|
+
const botReactions = z16.array(reactionSchema).parse(listPayload).filter(
|
|
3030
3125
|
(reaction) => reaction.user?.id === botUserId && FEEDBACK_REACTION_CONTENTS.has(reaction.content)
|
|
3031
3126
|
);
|
|
3032
3127
|
const existing = botReactions.find(
|
|
@@ -3042,9 +3137,9 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
3042
3137
|
})
|
|
3043
3138
|
});
|
|
3044
3139
|
if (!deleteResponse.ok && deleteResponse.status !== 404) {
|
|
3045
|
-
const deletePayload = await
|
|
3140
|
+
const deletePayload = await readJson8(deleteResponse);
|
|
3046
3141
|
throw new Error(
|
|
3047
|
-
`GitHub reaction removal failed with HTTP ${deleteResponse.status}: ${
|
|
3142
|
+
`GitHub reaction removal failed with HTTP ${deleteResponse.status}: ${githubError2(deletePayload)}`
|
|
3048
3143
|
);
|
|
3049
3144
|
}
|
|
3050
3145
|
}
|
|
@@ -3069,10 +3164,10 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
3069
3164
|
body: JSON.stringify({ content: targetContent })
|
|
3070
3165
|
})
|
|
3071
3166
|
});
|
|
3072
|
-
const createPayload = await
|
|
3167
|
+
const createPayload = await readJson8(createResponse);
|
|
3073
3168
|
if (!createResponse.ok) {
|
|
3074
3169
|
throw new Error(
|
|
3075
|
-
`GitHub reaction creation failed with HTTP ${createResponse.status}: ${
|
|
3170
|
+
`GitHub reaction creation failed with HTTP ${createResponse.status}: ${githubError2(createPayload)}`
|
|
3076
3171
|
);
|
|
3077
3172
|
}
|
|
3078
3173
|
const created = reactionSchema.parse(createPayload);
|
|
@@ -3089,34 +3184,34 @@ function createGitHubUpdatePullRequestFeedbackTool(ctx, botEmail) {
|
|
|
3089
3184
|
|
|
3090
3185
|
// src/tools/resolve-pull-request-review-thread.ts
|
|
3091
3186
|
import {
|
|
3092
|
-
definePluginTool as
|
|
3093
|
-
PluginToolInputError as
|
|
3094
|
-
pluginToolOutputSchema as
|
|
3187
|
+
definePluginTool as definePluginTool13,
|
|
3188
|
+
PluginToolInputError as PluginToolInputError13,
|
|
3189
|
+
pluginToolOutputSchema as pluginToolOutputSchema13
|
|
3095
3190
|
} from "@sentry/junior-plugin-api";
|
|
3096
|
-
import { z as
|
|
3097
|
-
var
|
|
3098
|
-
repo:
|
|
3191
|
+
import { z as z17 } from "zod";
|
|
3192
|
+
var inputSchema11 = z17.object({
|
|
3193
|
+
repo: z17.string().describe(
|
|
3099
3194
|
'Repository in "owner/name" format. Required because GraphQL has no repo path.'
|
|
3100
3195
|
),
|
|
3101
|
-
thread_id:
|
|
3196
|
+
thread_id: z17.string().trim().min(1).describe(
|
|
3102
3197
|
"GitHub pull request review thread node ID (the `threadId` / `id` variable used by `gh api graphql` resolveReviewThread)."
|
|
3103
3198
|
)
|
|
3104
3199
|
}).strict();
|
|
3105
|
-
var
|
|
3106
|
-
target:
|
|
3107
|
-
repo:
|
|
3108
|
-
number:
|
|
3109
|
-
thread_id:
|
|
3110
|
-
resolved:
|
|
3200
|
+
var outputSchema11 = pluginToolOutputSchema13.extend({
|
|
3201
|
+
target: z17.literal("resolvePullRequestReviewThread"),
|
|
3202
|
+
repo: z17.string(),
|
|
3203
|
+
number: z17.number(),
|
|
3204
|
+
thread_id: z17.string(),
|
|
3205
|
+
resolved: z17.boolean()
|
|
3111
3206
|
});
|
|
3112
|
-
function
|
|
3207
|
+
function parseRepo12(value) {
|
|
3113
3208
|
const parts = value.split("/").map((part) => part.trim());
|
|
3114
3209
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
3115
|
-
throw new
|
|
3210
|
+
throw new PluginToolInputError13('repo must use "owner/name" format');
|
|
3116
3211
|
}
|
|
3117
3212
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
3118
3213
|
}
|
|
3119
|
-
async function
|
|
3214
|
+
async function readJson9(response) {
|
|
3120
3215
|
const text2 = await response.text();
|
|
3121
3216
|
if (!text2) return void 0;
|
|
3122
3217
|
try {
|
|
@@ -3125,7 +3220,7 @@ async function readJson8(response) {
|
|
|
3125
3220
|
return text2;
|
|
3126
3221
|
}
|
|
3127
3222
|
}
|
|
3128
|
-
function
|
|
3223
|
+
function githubError3(payload) {
|
|
3129
3224
|
if (payload && typeof payload === "object" && !Array.isArray(payload)) {
|
|
3130
3225
|
const message = payload.message;
|
|
3131
3226
|
if (typeof message === "string" && message.trim()) return message.trim();
|
|
@@ -3133,7 +3228,7 @@ function githubError2(payload) {
|
|
|
3133
3228
|
return "GitHub request failed";
|
|
3134
3229
|
}
|
|
3135
3230
|
function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
3136
|
-
return
|
|
3231
|
+
return definePluginTool13({
|
|
3137
3232
|
// No action review: the tool checks in code that the bot authored the pull
|
|
3138
3233
|
// request, and it changes only the thread's resolved state, which is
|
|
3139
3234
|
// reversible.
|
|
@@ -3146,17 +3241,17 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3146
3241
|
},
|
|
3147
3242
|
description: "Resolve a GitHub pull request review thread after acting on its feedback. Only works on pull requests the bot authored.",
|
|
3148
3243
|
exposure: "direct",
|
|
3149
|
-
inputSchema:
|
|
3150
|
-
outputSchema:
|
|
3244
|
+
inputSchema: inputSchema11,
|
|
3245
|
+
outputSchema: outputSchema11,
|
|
3151
3246
|
async execute(input) {
|
|
3152
|
-
const parsedInput =
|
|
3247
|
+
const parsedInput = inputSchema11.safeParse(input);
|
|
3153
3248
|
if (!parsedInput.success) {
|
|
3154
|
-
throw new
|
|
3249
|
+
throw new PluginToolInputError13(
|
|
3155
3250
|
"Invalid GitHub resolvePullRequestReviewThread input.",
|
|
3156
3251
|
{ cause: parsedInput.error }
|
|
3157
3252
|
);
|
|
3158
3253
|
}
|
|
3159
|
-
const repo =
|
|
3254
|
+
const repo = parseRepo12(parsedInput.data.repo);
|
|
3160
3255
|
const botUserId = botUserIdFromEmail(botEmail);
|
|
3161
3256
|
if (botUserId === void 0) {
|
|
3162
3257
|
throw new Error("GitHub App bot identity is not configured.");
|
|
@@ -3187,37 +3282,37 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3187
3282
|
})
|
|
3188
3283
|
})
|
|
3189
3284
|
});
|
|
3190
|
-
const lookupPayload = await
|
|
3285
|
+
const lookupPayload = await readJson9(lookupResponse);
|
|
3191
3286
|
if (!lookupResponse.ok) {
|
|
3192
3287
|
throw new Error(
|
|
3193
|
-
`GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${
|
|
3288
|
+
`GitHub review thread lookup failed with HTTP ${lookupResponse.status}: ${githubError3(lookupPayload)}`
|
|
3194
3289
|
);
|
|
3195
3290
|
}
|
|
3196
|
-
const threadNodeSchema =
|
|
3197
|
-
id:
|
|
3198
|
-
isResolved:
|
|
3199
|
-
pullRequest:
|
|
3200
|
-
author:
|
|
3201
|
-
number:
|
|
3202
|
-
repository:
|
|
3291
|
+
const threadNodeSchema = z17.object({
|
|
3292
|
+
id: z17.string(),
|
|
3293
|
+
isResolved: z17.boolean(),
|
|
3294
|
+
pullRequest: z17.object({
|
|
3295
|
+
author: z17.object({ databaseId: z17.number().optional() }).passthrough().nullable(),
|
|
3296
|
+
number: z17.number(),
|
|
3297
|
+
repository: z17.object({ nameWithOwner: z17.string() }).passthrough()
|
|
3203
3298
|
}).passthrough()
|
|
3204
3299
|
}).passthrough();
|
|
3205
|
-
const lookupResultSchema =
|
|
3206
|
-
data:
|
|
3207
|
-
node:
|
|
3300
|
+
const lookupResultSchema = z17.object({
|
|
3301
|
+
data: z17.object({
|
|
3302
|
+
node: z17.unknown().nullable().optional()
|
|
3208
3303
|
}).passthrough()
|
|
3209
3304
|
}).passthrough();
|
|
3210
3305
|
const lookupResult = lookupResultSchema.safeParse(lookupPayload);
|
|
3211
3306
|
const rawNode = lookupResult.success ? lookupResult.data.data.node : void 0;
|
|
3212
3307
|
const parsedNode = rawNode == null ? void 0 : threadNodeSchema.safeParse(rawNode);
|
|
3213
3308
|
if (!parsedNode?.success) {
|
|
3214
|
-
throw new
|
|
3309
|
+
throw new PluginToolInputError13("GitHub review thread was not found.");
|
|
3215
3310
|
}
|
|
3216
3311
|
const thread = parsedNode.data;
|
|
3217
3312
|
const pullRequest = thread.pullRequest;
|
|
3218
3313
|
const ownsPullRequest = pullRequest.repository.nameWithOwner.toLowerCase() === repo.ref.toLowerCase() && pullRequest.author?.databaseId === botUserId;
|
|
3219
3314
|
if (!ownsPullRequest) {
|
|
3220
|
-
throw new
|
|
3315
|
+
throw new PluginToolInputError13(
|
|
3221
3316
|
"This bot can only resolve review threads on pull requests it authored."
|
|
3222
3317
|
);
|
|
3223
3318
|
}
|
|
@@ -3248,16 +3343,16 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3248
3343
|
})
|
|
3249
3344
|
})
|
|
3250
3345
|
});
|
|
3251
|
-
const resolvePayload = await
|
|
3346
|
+
const resolvePayload = await readJson9(resolveResponse);
|
|
3252
3347
|
if (!resolveResponse.ok) {
|
|
3253
3348
|
throw new Error(
|
|
3254
|
-
`GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${
|
|
3349
|
+
`GitHub review thread resolution failed with HTTP ${resolveResponse.status}: ${githubError3(resolvePayload)}`
|
|
3255
3350
|
);
|
|
3256
3351
|
}
|
|
3257
|
-
const resolveResultSchema =
|
|
3258
|
-
data:
|
|
3259
|
-
resolveReviewThread:
|
|
3260
|
-
thread:
|
|
3352
|
+
const resolveResultSchema = z17.object({
|
|
3353
|
+
data: z17.object({
|
|
3354
|
+
resolveReviewThread: z17.object({
|
|
3355
|
+
thread: z17.object({ id: z17.string(), isResolved: z17.boolean() }).passthrough()
|
|
3261
3356
|
}).passthrough()
|
|
3262
3357
|
}).passthrough()
|
|
3263
3358
|
}).passthrough();
|
|
@@ -3285,45 +3380,45 @@ function createGitHubResolvePullRequestReviewThreadTool(ctx, botEmail) {
|
|
|
3285
3380
|
|
|
3286
3381
|
// src/tools/submit-pull-request-review.ts
|
|
3287
3382
|
import {
|
|
3288
|
-
definePluginTool as
|
|
3289
|
-
PluginToolInputError as
|
|
3290
|
-
pluginToolOutputSchema as
|
|
3383
|
+
definePluginTool as definePluginTool14,
|
|
3384
|
+
PluginToolInputError as PluginToolInputError14,
|
|
3385
|
+
pluginToolOutputSchema as pluginToolOutputSchema14
|
|
3291
3386
|
} from "@sentry/junior-plugin-api";
|
|
3292
|
-
import { z as
|
|
3293
|
-
var reviewCommentSchema =
|
|
3294
|
-
path:
|
|
3295
|
-
body:
|
|
3296
|
-
line:
|
|
3297
|
-
side:
|
|
3298
|
-
start_line:
|
|
3299
|
-
start_side:
|
|
3387
|
+
import { z as z18 } from "zod";
|
|
3388
|
+
var reviewCommentSchema = z18.object({
|
|
3389
|
+
path: z18.string().trim().min(1).describe("File path in the pull request."),
|
|
3390
|
+
body: z18.string().trim().min(1).describe("Inline review comment."),
|
|
3391
|
+
line: z18.number().int().positive().describe("Line in the pull request diff."),
|
|
3392
|
+
side: z18.enum(["LEFT", "RIGHT"]).describe("Side of the pull request diff."),
|
|
3393
|
+
start_line: z18.number().int().positive().optional().describe("First line of a multi-line comment."),
|
|
3394
|
+
start_side: z18.enum(["LEFT", "RIGHT"]).optional().describe("First side of a multi-line comment.")
|
|
3300
3395
|
}).strict().refine(
|
|
3301
3396
|
({ start_line, start_side }) => start_line === void 0 === (start_side === void 0),
|
|
3302
3397
|
{ message: "start_line and start_side must be provided together." }
|
|
3303
3398
|
);
|
|
3304
|
-
var
|
|
3305
|
-
repo:
|
|
3306
|
-
number:
|
|
3307
|
-
event:
|
|
3308
|
-
body:
|
|
3309
|
-
comments:
|
|
3399
|
+
var inputSchema12 = z18.object({
|
|
3400
|
+
repo: z18.string().describe('Repository in "owner/name" format.'),
|
|
3401
|
+
number: z18.number().int().positive().describe("Pull request number."),
|
|
3402
|
+
event: z18.enum(["COMMENT", "REQUEST_CHANGES"]).describe("Review result. You cannot approve pull requests."),
|
|
3403
|
+
body: z18.string().trim().min(1).describe("Review summary."),
|
|
3404
|
+
comments: z18.array(reviewCommentSchema).optional().describe("Optional inline review comments.")
|
|
3310
3405
|
}).strict();
|
|
3311
|
-
var
|
|
3312
|
-
target:
|
|
3313
|
-
repo:
|
|
3314
|
-
number:
|
|
3315
|
-
review_id:
|
|
3316
|
-
state:
|
|
3317
|
-
url:
|
|
3406
|
+
var outputSchema12 = pluginToolOutputSchema14.extend({
|
|
3407
|
+
target: z18.literal("submitPullRequestReview"),
|
|
3408
|
+
repo: z18.string(),
|
|
3409
|
+
number: z18.number(),
|
|
3410
|
+
review_id: z18.number(),
|
|
3411
|
+
state: z18.string(),
|
|
3412
|
+
url: z18.string()
|
|
3318
3413
|
});
|
|
3319
|
-
function
|
|
3414
|
+
function parseRepo13(value) {
|
|
3320
3415
|
const parts = value.split("/").map((part) => part.trim());
|
|
3321
3416
|
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
3322
|
-
throw new
|
|
3417
|
+
throw new PluginToolInputError14('repo must use "owner/name" format');
|
|
3323
3418
|
}
|
|
3324
3419
|
return { owner: parts[0], name: parts[1], ref: `${parts[0]}/${parts[1]}` };
|
|
3325
3420
|
}
|
|
3326
|
-
async function
|
|
3421
|
+
async function readJson10(response) {
|
|
3327
3422
|
const text2 = await response.text();
|
|
3328
3423
|
if (!text2) return void 0;
|
|
3329
3424
|
try {
|
|
@@ -3332,7 +3427,7 @@ async function readJson9(response) {
|
|
|
3332
3427
|
return text2;
|
|
3333
3428
|
}
|
|
3334
3429
|
}
|
|
3335
|
-
function
|
|
3430
|
+
function githubError4(body) {
|
|
3336
3431
|
if (body && typeof body === "object" && !Array.isArray(body)) {
|
|
3337
3432
|
const message = body.message;
|
|
3338
3433
|
if (typeof message === "string" && message.trim()) return message.trim();
|
|
@@ -3341,14 +3436,14 @@ function githubError3(body) {
|
|
|
3341
3436
|
return "GitHub request failed";
|
|
3342
3437
|
}
|
|
3343
3438
|
function throwReviewError(status, body) {
|
|
3344
|
-
const message = `GitHub pull request review failed with HTTP ${status}: ${
|
|
3439
|
+
const message = `GitHub pull request review failed with HTTP ${status}: ${githubError4(body)}`;
|
|
3345
3440
|
if (status === 404 || status === 422) {
|
|
3346
|
-
throw new
|
|
3441
|
+
throw new PluginToolInputError14(message);
|
|
3347
3442
|
}
|
|
3348
3443
|
throw new Error(message);
|
|
3349
3444
|
}
|
|
3350
3445
|
function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
3351
|
-
return
|
|
3446
|
+
return definePluginTool14({
|
|
3352
3447
|
annotations: {
|
|
3353
3448
|
destructiveHint: true,
|
|
3354
3449
|
idempotentHint: false,
|
|
@@ -3357,10 +3452,10 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3357
3452
|
},
|
|
3358
3453
|
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.",
|
|
3359
3454
|
exposure: "direct",
|
|
3360
|
-
inputSchema:
|
|
3361
|
-
outputSchema:
|
|
3455
|
+
inputSchema: inputSchema12,
|
|
3456
|
+
outputSchema: outputSchema12,
|
|
3362
3457
|
async execute(review) {
|
|
3363
|
-
const repo =
|
|
3458
|
+
const repo = parseRepo13(review.repo);
|
|
3364
3459
|
const comments = review.comments?.map((comment) => ({
|
|
3365
3460
|
path: comment.path,
|
|
3366
3461
|
body: comment.body,
|
|
@@ -3389,11 +3484,11 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3389
3484
|
}
|
|
3390
3485
|
)
|
|
3391
3486
|
});
|
|
3392
|
-
const parsed = await
|
|
3487
|
+
const parsed = await readJson10(response);
|
|
3393
3488
|
if (!response.ok) {
|
|
3394
3489
|
throwReviewError(response.status, parsed);
|
|
3395
3490
|
}
|
|
3396
|
-
const providerResult =
|
|
3491
|
+
const providerResult = z18.object({ id: z18.number(), html_url: z18.string(), state: z18.string() }).parse(parsed);
|
|
3397
3492
|
return {
|
|
3398
3493
|
target: "submitPullRequestReview",
|
|
3399
3494
|
repo: repo.ref,
|
|
@@ -3410,6 +3505,7 @@ function createGitHubSubmitPullRequestReviewTool(egress) {
|
|
|
3410
3505
|
function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
3411
3506
|
return {
|
|
3412
3507
|
cloneRepository: createGitHubCloneRepositoryTool(ctx),
|
|
3508
|
+
commentOnPullRequest: createGitHubCommentOnPullRequestTool(ctx.egress),
|
|
3413
3509
|
createIssue: createGitHubIssueTool(ctx),
|
|
3414
3510
|
createPullRequest: createGitHubPullRequestTool(
|
|
3415
3511
|
ctx,
|
|
@@ -3435,26 +3531,26 @@ function createGitHubTools(ctx, botEmail, pullRequestSubscription) {
|
|
|
3435
3531
|
|
|
3436
3532
|
// src/webhooks/handler.ts
|
|
3437
3533
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3438
|
-
import { z as
|
|
3534
|
+
import { z as z28 } from "zod";
|
|
3439
3535
|
|
|
3440
3536
|
// src/issue-outcomes/store.ts
|
|
3441
3537
|
import { and as and2, eq as eq2, lte, sql as sql2 } from "drizzle-orm";
|
|
3442
|
-
import { z as
|
|
3443
|
-
var githubIssueOutcomeInputSchema =
|
|
3444
|
-
candidateOwned:
|
|
3445
|
-
closedAt:
|
|
3446
|
-
issueId:
|
|
3447
|
-
number:
|
|
3448
|
-
openedAt:
|
|
3449
|
-
repositoryFullName:
|
|
3450
|
-
repositoryId:
|
|
3538
|
+
import { z as z19 } from "zod";
|
|
3539
|
+
var githubIssueOutcomeInputSchema = z19.object({
|
|
3540
|
+
candidateOwned: z19.boolean(),
|
|
3541
|
+
closedAt: z19.date().optional(),
|
|
3542
|
+
issueId: z19.string().min(1),
|
|
3543
|
+
number: z19.number().int().positive(),
|
|
3544
|
+
openedAt: z19.date(),
|
|
3545
|
+
repositoryFullName: z19.string().min(1),
|
|
3546
|
+
repositoryId: z19.string().min(1),
|
|
3451
3547
|
state: githubIssueStateSchema,
|
|
3452
3548
|
stateReason: githubIssueStateReasonSchema.optional(),
|
|
3453
|
-
updatedAt:
|
|
3549
|
+
updatedAt: z19.date()
|
|
3454
3550
|
}).strict();
|
|
3455
|
-
var githubIssueConversationsInputSchema =
|
|
3456
|
-
conversationIds:
|
|
3457
|
-
issueId:
|
|
3551
|
+
var githubIssueConversationsInputSchema = z19.object({
|
|
3552
|
+
conversationIds: z19.array(z19.string().min(1)).min(1),
|
|
3553
|
+
issueId: z19.string().min(1)
|
|
3458
3554
|
}).strict();
|
|
3459
3555
|
function projectionValues(input) {
|
|
3460
3556
|
return {
|
|
@@ -3518,33 +3614,33 @@ async function recordGitHubIssueConversations(db, input) {
|
|
|
3518
3614
|
|
|
3519
3615
|
// src/pull-request-outcomes/store.ts
|
|
3520
3616
|
import { and as and3, eq as eq3, lte as lte2, ne, sql as sql3 } from "drizzle-orm";
|
|
3521
|
-
import { z as
|
|
3522
|
-
var githubPullRequestOutcomeInputSchema =
|
|
3523
|
-
candidateOwned:
|
|
3524
|
-
closedAt:
|
|
3617
|
+
import { z as z20 } from "zod";
|
|
3618
|
+
var githubPullRequestOutcomeInputSchema = z20.object({
|
|
3619
|
+
candidateOwned: z20.boolean(),
|
|
3620
|
+
closedAt: z20.date().optional(),
|
|
3525
3621
|
commitComposition: githubPullRequestCommitCompositionSchema.optional(),
|
|
3526
|
-
mergedAt:
|
|
3527
|
-
number:
|
|
3528
|
-
openedAt:
|
|
3529
|
-
pullRequestId:
|
|
3530
|
-
repositoryFullName:
|
|
3531
|
-
repositoryId:
|
|
3622
|
+
mergedAt: z20.date().optional(),
|
|
3623
|
+
number: z20.number().int().positive(),
|
|
3624
|
+
openedAt: z20.date(),
|
|
3625
|
+
pullRequestId: z20.string().min(1),
|
|
3626
|
+
repositoryFullName: z20.string().min(1),
|
|
3627
|
+
repositoryId: z20.string().min(1),
|
|
3532
3628
|
state: githubPullRequestStateSchema,
|
|
3533
|
-
title:
|
|
3534
|
-
updatedAt:
|
|
3629
|
+
title: z20.string().min(1).optional(),
|
|
3630
|
+
updatedAt: z20.date()
|
|
3535
3631
|
}).strict();
|
|
3536
|
-
var githubPullRequestConversationsInputSchema =
|
|
3537
|
-
conversationIds:
|
|
3538
|
-
pullRequestId:
|
|
3632
|
+
var githubPullRequestConversationsInputSchema = z20.object({
|
|
3633
|
+
conversationIds: z20.array(z20.string().min(1)).min(1),
|
|
3634
|
+
pullRequestId: z20.string().min(1)
|
|
3539
3635
|
}).strict();
|
|
3540
|
-
var githubPullRequestLinkedIssuesInputSchema =
|
|
3541
|
-
linkedIssues:
|
|
3542
|
-
|
|
3543
|
-
number:
|
|
3544
|
-
repositoryFullName:
|
|
3636
|
+
var githubPullRequestLinkedIssuesInputSchema = z20.object({
|
|
3637
|
+
linkedIssues: z20.array(
|
|
3638
|
+
z20.object({
|
|
3639
|
+
number: z20.number().int().positive(),
|
|
3640
|
+
repositoryFullName: z20.string().min(1)
|
|
3545
3641
|
}).strict()
|
|
3546
3642
|
).min(1),
|
|
3547
|
-
pullRequestId:
|
|
3643
|
+
pullRequestId: z20.string().min(1)
|
|
3548
3644
|
}).strict();
|
|
3549
3645
|
function projectionValues2(input) {
|
|
3550
3646
|
return {
|
|
@@ -3749,39 +3845,39 @@ async function releaseGitHubPullRequestReadySync(db, target, claim) {
|
|
|
3749
3845
|
}
|
|
3750
3846
|
|
|
3751
3847
|
// src/webhooks/issue-outcome.ts
|
|
3752
|
-
import { z as
|
|
3753
|
-
var canonicalIssueOutcomeSchema =
|
|
3754
|
-
action:
|
|
3755
|
-
issue:
|
|
3756
|
-
body:
|
|
3757
|
-
closed_at:
|
|
3758
|
-
created_at:
|
|
3759
|
-
id:
|
|
3760
|
-
number:
|
|
3848
|
+
import { z as z21 } from "zod";
|
|
3849
|
+
var canonicalIssueOutcomeSchema = z21.object({
|
|
3850
|
+
action: z21.enum(["opened", "closed", "reopened"]),
|
|
3851
|
+
issue: z21.object({
|
|
3852
|
+
body: z21.string().nullable().optional(),
|
|
3853
|
+
closed_at: z21.string().nullable().optional(),
|
|
3854
|
+
created_at: z21.string(),
|
|
3855
|
+
id: z21.number().int().positive(),
|
|
3856
|
+
number: z21.number().int().positive(),
|
|
3761
3857
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3762
|
-
updated_at:
|
|
3763
|
-
user:
|
|
3858
|
+
updated_at: z21.string(),
|
|
3859
|
+
user: z21.object({ login: z21.string().min(1) }).strict()
|
|
3764
3860
|
}).strict(),
|
|
3765
|
-
repository:
|
|
3766
|
-
full_name:
|
|
3767
|
-
id:
|
|
3861
|
+
repository: z21.object({
|
|
3862
|
+
full_name: z21.string().min(1),
|
|
3863
|
+
id: z21.number().int().positive()
|
|
3768
3864
|
}).strict()
|
|
3769
3865
|
}).strict();
|
|
3770
|
-
var issueOutcomeSchema =
|
|
3771
|
-
action:
|
|
3772
|
-
issue:
|
|
3773
|
-
body:
|
|
3774
|
-
closed_at:
|
|
3775
|
-
created_at:
|
|
3776
|
-
id:
|
|
3777
|
-
number:
|
|
3866
|
+
var issueOutcomeSchema = z21.object({
|
|
3867
|
+
action: z21.enum(["opened", "closed", "reopened"]),
|
|
3868
|
+
issue: z21.object({
|
|
3869
|
+
body: z21.string().nullable().optional(),
|
|
3870
|
+
closed_at: z21.string().nullable().optional(),
|
|
3871
|
+
created_at: z21.string(),
|
|
3872
|
+
id: z21.number().int().positive(),
|
|
3873
|
+
number: z21.number().int().positive(),
|
|
3778
3874
|
state_reason: githubIssueStateReasonSchema.nullable().optional(),
|
|
3779
|
-
updated_at:
|
|
3780
|
-
user:
|
|
3875
|
+
updated_at: z21.string(),
|
|
3876
|
+
user: z21.object({ login: z21.string().min(1) }).passthrough()
|
|
3781
3877
|
}).passthrough(),
|
|
3782
|
-
repository:
|
|
3783
|
-
full_name:
|
|
3784
|
-
id:
|
|
3878
|
+
repository: z21.object({
|
|
3879
|
+
full_name: z21.string().min(1),
|
|
3880
|
+
id: z21.number().int().positive()
|
|
3785
3881
|
}).passthrough()
|
|
3786
3882
|
}).passthrough().transform(
|
|
3787
3883
|
(provider) => canonicalIssueOutcomeSchema.parse({
|
|
@@ -3802,7 +3898,7 @@ var issueOutcomeSchema = z20.object({
|
|
|
3802
3898
|
}
|
|
3803
3899
|
})
|
|
3804
3900
|
);
|
|
3805
|
-
var issueLifecycleActionSchema =
|
|
3901
|
+
var issueLifecycleActionSchema = z21.object({ action: z21.string() }).passthrough();
|
|
3806
3902
|
function timestamp2(value) {
|
|
3807
3903
|
if (!value) return void 0;
|
|
3808
3904
|
const parsed = new Date(value);
|
|
@@ -3846,21 +3942,21 @@ function normalizeGitHubIssueOutcome(args) {
|
|
|
3846
3942
|
updatedAt
|
|
3847
3943
|
};
|
|
3848
3944
|
}
|
|
3849
|
-
var canonicalIssueConversationSchema =
|
|
3850
|
-
issue:
|
|
3851
|
-
body:
|
|
3852
|
-
id:
|
|
3853
|
-
user:
|
|
3945
|
+
var canonicalIssueConversationSchema = z21.object({
|
|
3946
|
+
issue: z21.object({
|
|
3947
|
+
body: z21.string().nullable().optional(),
|
|
3948
|
+
id: z21.number().int().positive(),
|
|
3949
|
+
user: z21.object({ login: z21.string().min(1) }).strict()
|
|
3854
3950
|
}).strict(),
|
|
3855
|
-
sender:
|
|
3951
|
+
sender: z21.object({ login: z21.string().min(1) }).strict().optional()
|
|
3856
3952
|
}).strict();
|
|
3857
|
-
var issueConversationSchema =
|
|
3858
|
-
issue:
|
|
3859
|
-
body:
|
|
3860
|
-
id:
|
|
3861
|
-
user:
|
|
3953
|
+
var issueConversationSchema = z21.object({
|
|
3954
|
+
issue: z21.object({
|
|
3955
|
+
body: z21.string().nullable().optional(),
|
|
3956
|
+
id: z21.number().int().positive(),
|
|
3957
|
+
user: z21.object({ login: z21.string().min(1) }).passthrough()
|
|
3862
3958
|
}).passthrough(),
|
|
3863
|
-
sender:
|
|
3959
|
+
sender: z21.object({ login: z21.string().min(1) }).passthrough().optional()
|
|
3864
3960
|
}).passthrough().transform(
|
|
3865
3961
|
(provider) => canonicalIssueConversationSchema.parse({
|
|
3866
3962
|
issue: {
|
|
@@ -3887,43 +3983,43 @@ function normalizeGitHubIssueConversations(args) {
|
|
|
3887
3983
|
}
|
|
3888
3984
|
|
|
3889
3985
|
// src/webhooks/pull-request-outcome.ts
|
|
3890
|
-
import { z as
|
|
3891
|
-
var canonicalPullRequestOutcomeSchema =
|
|
3892
|
-
action:
|
|
3893
|
-
pull_request:
|
|
3894
|
-
body:
|
|
3895
|
-
closed_at:
|
|
3896
|
-
created_at:
|
|
3897
|
-
id:
|
|
3898
|
-
merged:
|
|
3899
|
-
merged_at:
|
|
3900
|
-
number:
|
|
3901
|
-
title:
|
|
3902
|
-
updated_at:
|
|
3903
|
-
user:
|
|
3986
|
+
import { z as z22 } from "zod";
|
|
3987
|
+
var canonicalPullRequestOutcomeSchema = z22.object({
|
|
3988
|
+
action: z22.enum(["opened", "closed", "reopened"]),
|
|
3989
|
+
pull_request: z22.object({
|
|
3990
|
+
body: z22.string().nullable().optional(),
|
|
3991
|
+
closed_at: z22.string().nullable().optional(),
|
|
3992
|
+
created_at: z22.string(),
|
|
3993
|
+
id: z22.number().int().positive(),
|
|
3994
|
+
merged: z22.boolean(),
|
|
3995
|
+
merged_at: z22.string().nullable().optional(),
|
|
3996
|
+
number: z22.number().int().positive(),
|
|
3997
|
+
title: z22.string().min(1).optional(),
|
|
3998
|
+
updated_at: z22.string(),
|
|
3999
|
+
user: z22.object({ login: z22.string().min(1) }).strict()
|
|
3904
4000
|
}).strict(),
|
|
3905
|
-
repository:
|
|
3906
|
-
full_name:
|
|
3907
|
-
id:
|
|
4001
|
+
repository: z22.object({
|
|
4002
|
+
full_name: z22.string().min(1),
|
|
4003
|
+
id: z22.number().int().positive()
|
|
3908
4004
|
}).strict()
|
|
3909
4005
|
}).strict();
|
|
3910
|
-
var pullRequestOutcomeSchema =
|
|
3911
|
-
action:
|
|
3912
|
-
pull_request:
|
|
3913
|
-
body:
|
|
3914
|
-
closed_at:
|
|
3915
|
-
created_at:
|
|
3916
|
-
id:
|
|
3917
|
-
merged:
|
|
3918
|
-
merged_at:
|
|
3919
|
-
number:
|
|
3920
|
-
title:
|
|
3921
|
-
updated_at:
|
|
3922
|
-
user:
|
|
4006
|
+
var pullRequestOutcomeSchema = z22.object({
|
|
4007
|
+
action: z22.enum(["opened", "closed", "reopened"]),
|
|
4008
|
+
pull_request: z22.object({
|
|
4009
|
+
body: z22.string().nullable().optional(),
|
|
4010
|
+
closed_at: z22.string().nullable().optional(),
|
|
4011
|
+
created_at: z22.string(),
|
|
4012
|
+
id: z22.number().int().positive(),
|
|
4013
|
+
merged: z22.boolean(),
|
|
4014
|
+
merged_at: z22.string().nullable().optional(),
|
|
4015
|
+
number: z22.number().int().positive(),
|
|
4016
|
+
title: z22.string().min(1).optional(),
|
|
4017
|
+
updated_at: z22.string(),
|
|
4018
|
+
user: z22.object({ login: z22.string().min(1) }).passthrough()
|
|
3923
4019
|
}).passthrough(),
|
|
3924
|
-
repository:
|
|
3925
|
-
full_name:
|
|
3926
|
-
id:
|
|
4020
|
+
repository: z22.object({
|
|
4021
|
+
full_name: z22.string().min(1),
|
|
4022
|
+
id: z22.number().int().positive()
|
|
3927
4023
|
}).passthrough()
|
|
3928
4024
|
}).passthrough().transform(
|
|
3929
4025
|
(provider) => canonicalPullRequestOutcomeSchema.parse({
|
|
@@ -3946,24 +4042,24 @@ var pullRequestOutcomeSchema = z21.object({
|
|
|
3946
4042
|
}
|
|
3947
4043
|
})
|
|
3948
4044
|
);
|
|
3949
|
-
var pullRequestLifecycleActionSchema =
|
|
3950
|
-
var canonicalPullRequestConversationSchema =
|
|
3951
|
-
pull_request:
|
|
3952
|
-
body:
|
|
3953
|
-
id:
|
|
3954
|
-
user:
|
|
4045
|
+
var pullRequestLifecycleActionSchema = z22.object({ action: z22.string() }).passthrough();
|
|
4046
|
+
var canonicalPullRequestConversationSchema = z22.object({
|
|
4047
|
+
pull_request: z22.object({
|
|
4048
|
+
body: z22.string().nullable().optional(),
|
|
4049
|
+
id: z22.number().int().positive(),
|
|
4050
|
+
user: z22.object({ login: z22.string().min(1) }).strict()
|
|
3955
4051
|
}).strict(),
|
|
3956
|
-
repository:
|
|
3957
|
-
sender:
|
|
4052
|
+
repository: z22.object({ full_name: z22.string().min(1) }).strict(),
|
|
4053
|
+
sender: z22.object({ login: z22.string().min(1) }).strict()
|
|
3958
4054
|
}).strict();
|
|
3959
|
-
var pullRequestConversationSchema =
|
|
3960
|
-
pull_request:
|
|
3961
|
-
body:
|
|
3962
|
-
id:
|
|
3963
|
-
user:
|
|
4055
|
+
var pullRequestConversationSchema = z22.object({
|
|
4056
|
+
pull_request: z22.object({
|
|
4057
|
+
body: z22.string().nullable().optional(),
|
|
4058
|
+
id: z22.number().int().positive(),
|
|
4059
|
+
user: z22.object({ login: z22.string().min(1) }).passthrough()
|
|
3964
4060
|
}).passthrough(),
|
|
3965
|
-
repository:
|
|
3966
|
-
sender:
|
|
4061
|
+
repository: z22.object({ full_name: z22.string().min(1) }).passthrough(),
|
|
4062
|
+
sender: z22.object({ login: z22.string().min(1) }).passthrough()
|
|
3967
4063
|
}).passthrough().transform(
|
|
3968
4064
|
(provider) => canonicalPullRequestConversationSchema.parse({
|
|
3969
4065
|
pull_request: {
|
|
@@ -4050,20 +4146,20 @@ function normalizeGitHubPullRequestLinkedIssues(args) {
|
|
|
4050
4146
|
}
|
|
4051
4147
|
|
|
4052
4148
|
// src/webhooks/merge-conflict.ts
|
|
4053
|
-
import { z as
|
|
4149
|
+
import { z as z23 } from "zod";
|
|
4054
4150
|
var EVENT_TYPE = "pull_request.merge_conflict";
|
|
4055
4151
|
var CLOSED_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
4056
4152
|
"pull_request.closed_unmerged",
|
|
4057
4153
|
"pull_request.merged"
|
|
4058
4154
|
]);
|
|
4059
|
-
var pullRequestSchema3 =
|
|
4060
|
-
base:
|
|
4061
|
-
number:
|
|
4062
|
-
head:
|
|
4063
|
-
html_url:
|
|
4064
|
-
mergeable:
|
|
4065
|
-
mergeable_state:
|
|
4066
|
-
state:
|
|
4155
|
+
var pullRequestSchema3 = z23.object({
|
|
4156
|
+
base: z23.object({ ref: z23.string().min(1) }),
|
|
4157
|
+
number: z23.number().int().positive().optional(),
|
|
4158
|
+
head: z23.object({ sha: z23.string().min(1) }),
|
|
4159
|
+
html_url: z23.string().min(1).optional(),
|
|
4160
|
+
mergeable: z23.boolean().nullable().optional(),
|
|
4161
|
+
mergeable_state: z23.string().optional(),
|
|
4162
|
+
state: z23.string()
|
|
4067
4163
|
});
|
|
4068
4164
|
function gitHubMergeConflictEvents(input) {
|
|
4069
4165
|
const { conflict } = input;
|
|
@@ -4103,7 +4199,7 @@ async function hasMatch(hasMatchEvent, ref) {
|
|
|
4103
4199
|
return false;
|
|
4104
4200
|
}
|
|
4105
4201
|
function deliveredPullRequest(payload, ref) {
|
|
4106
|
-
const parsed =
|
|
4202
|
+
const parsed = z23.object({ pull_request: pullRequestSchema3 }).safeParse(payload);
|
|
4107
4203
|
const pullRequest = parsed.success ? parsed.data.pull_request : void 0;
|
|
4108
4204
|
return pullRequest?.number === ref.number && typeof pullRequest.mergeable === "boolean" ? pullRequest : void 0;
|
|
4109
4205
|
}
|
|
@@ -4141,10 +4237,10 @@ async function loadGitHubMergeConflictEvents(args) {
|
|
|
4141
4237
|
}
|
|
4142
4238
|
|
|
4143
4239
|
// src/webhooks/pull-request-ready.ts
|
|
4144
|
-
import { z as
|
|
4240
|
+
import { z as z25 } from "zod";
|
|
4145
4241
|
|
|
4146
4242
|
// src/webhooks/installation-requests.ts
|
|
4147
|
-
import { z as
|
|
4243
|
+
import { z as z24 } from "zod";
|
|
4148
4244
|
function splitRepository(fullName, label) {
|
|
4149
4245
|
const [owner, name, ...extra] = fullName.split("/");
|
|
4150
4246
|
if (!owner || !name || extra.length > 0) {
|
|
@@ -4205,9 +4301,9 @@ async function markPullRequestFeedbackReviewing(env, target) {
|
|
|
4205
4301
|
}
|
|
4206
4302
|
);
|
|
4207
4303
|
}
|
|
4208
|
-
var repositoryPermissionSchema =
|
|
4209
|
-
permission:
|
|
4210
|
-
role_name:
|
|
4304
|
+
var repositoryPermissionSchema = z24.object({
|
|
4305
|
+
permission: z24.string().min(1),
|
|
4306
|
+
role_name: z24.string().optional()
|
|
4211
4307
|
});
|
|
4212
4308
|
var REPOSITORY_ROLE_TTL_MS = 10 * 60 * 1e3;
|
|
4213
4309
|
async function loadRepositoryRole(env, cache, target) {
|
|
@@ -4237,18 +4333,18 @@ async function loadRepositoryRole(env, cache, target) {
|
|
|
4237
4333
|
}
|
|
4238
4334
|
);
|
|
4239
4335
|
}
|
|
4240
|
-
var pullRequestSchema4 =
|
|
4241
|
-
draft:
|
|
4242
|
-
html_url:
|
|
4243
|
-
mergeable_state:
|
|
4244
|
-
merged:
|
|
4245
|
-
state:
|
|
4246
|
-
title:
|
|
4336
|
+
var pullRequestSchema4 = z24.object({
|
|
4337
|
+
draft: z24.boolean().optional(),
|
|
4338
|
+
html_url: z24.string().url(),
|
|
4339
|
+
mergeable_state: z24.string().nullable().optional(),
|
|
4340
|
+
merged: z24.boolean(),
|
|
4341
|
+
state: z24.enum(["open", "closed"]),
|
|
4342
|
+
title: z24.string()
|
|
4247
4343
|
});
|
|
4248
|
-
var reviewsSchema =
|
|
4249
|
-
|
|
4250
|
-
state:
|
|
4251
|
-
user:
|
|
4344
|
+
var reviewsSchema = z24.array(
|
|
4345
|
+
z24.object({
|
|
4346
|
+
state: z24.string(),
|
|
4347
|
+
user: z24.object({ login: z24.string() }).nullable()
|
|
4252
4348
|
})
|
|
4253
4349
|
);
|
|
4254
4350
|
async function loadPullRequestMergeState(env, pullRequest) {
|
|
@@ -4313,10 +4409,10 @@ var READY_ACTIONS = {
|
|
|
4313
4409
|
]),
|
|
4314
4410
|
pull_request_review: /* @__PURE__ */ new Set(["dismissed", "submitted"])
|
|
4315
4411
|
};
|
|
4316
|
-
var pullRequestWebhookSchema =
|
|
4317
|
-
action:
|
|
4318
|
-
pull_request:
|
|
4319
|
-
repository:
|
|
4412
|
+
var pullRequestWebhookSchema = z25.object({
|
|
4413
|
+
action: z25.string(),
|
|
4414
|
+
pull_request: z25.object({ number: z25.number().int().positive() }),
|
|
4415
|
+
repository: z25.object({ full_name: z25.string().min(1) })
|
|
4320
4416
|
});
|
|
4321
4417
|
function pullRequestReadyTargets(eventName, body) {
|
|
4322
4418
|
if (eventName === "check_suite") return checkSuitePullRequests(body);
|
|
@@ -4411,7 +4507,7 @@ async function syncGitHubPullRequestReadyNotices(args) {
|
|
|
4411
4507
|
}
|
|
4412
4508
|
|
|
4413
4509
|
// src/webhooks/pull-request-match-data.ts
|
|
4414
|
-
import { z as
|
|
4510
|
+
import { z as z26 } from "zod";
|
|
4415
4511
|
var LOOKUPS_BY_MATCH_KEY = {
|
|
4416
4512
|
authors: ["authors"],
|
|
4417
4513
|
openerEmail: ["opener"],
|
|
@@ -4419,16 +4515,16 @@ var LOOKUPS_BY_MATCH_KEY = {
|
|
|
4419
4515
|
openerUsername: ["opener"]
|
|
4420
4516
|
};
|
|
4421
4517
|
var ALL_LOOKUPS = ["authors", "opener", "openerRole"];
|
|
4422
|
-
var lookupDataSchema =
|
|
4423
|
-
authors:
|
|
4424
|
-
openerRole:
|
|
4425
|
-
openerUsername:
|
|
4518
|
+
var lookupDataSchema = z26.object({
|
|
4519
|
+
authors: z26.array(z26.string().min(1)).min(1).optional(),
|
|
4520
|
+
openerRole: z26.string().min(1).optional(),
|
|
4521
|
+
openerUsername: z26.string().min(1).optional()
|
|
4426
4522
|
}).strict();
|
|
4427
4523
|
function lookupData(input) {
|
|
4428
4524
|
return lookupDataSchema.parse(definedValues(input));
|
|
4429
4525
|
}
|
|
4430
|
-
var webhookSchema =
|
|
4431
|
-
repository:
|
|
4526
|
+
var webhookSchema = z26.object({
|
|
4527
|
+
repository: z26.object({ full_name: z26.string().min(1) })
|
|
4432
4528
|
});
|
|
4433
4529
|
function pullRequestNumbers(events) {
|
|
4434
4530
|
const numbers = /* @__PURE__ */ new Map();
|
|
@@ -4571,7 +4667,7 @@ async function withGitHubPullRequestMatchData(args) {
|
|
|
4571
4667
|
}
|
|
4572
4668
|
|
|
4573
4669
|
// src/webhooks/pull-request-people.ts
|
|
4574
|
-
import { z as
|
|
4670
|
+
import { z as z27 } from "zod";
|
|
4575
4671
|
var PEOPLE_EVENTS = /* @__PURE__ */ new Set([
|
|
4576
4672
|
"pull_request.review.approved",
|
|
4577
4673
|
"pull_request.merged"
|
|
@@ -4581,18 +4677,18 @@ var PAGE_SIZE = 100;
|
|
|
4581
4677
|
var MAX_PAGES = 3;
|
|
4582
4678
|
var CO_AUTHOR_TRAILER = /^co-authored-by:[^<\n]*<([^>\s]+@[^>\s]+)>\s*$/gim;
|
|
4583
4679
|
var GITHUB_NOREPLY_EMAIL = /^(?:\d+\+)?(?<login>[^@+]+)@users\.noreply\.github\.com$/i;
|
|
4584
|
-
var webhookSchema2 =
|
|
4585
|
-
pull_request:
|
|
4586
|
-
assignees:
|
|
4587
|
-
number:
|
|
4588
|
-
user:
|
|
4680
|
+
var webhookSchema2 = z27.object({
|
|
4681
|
+
pull_request: z27.object({
|
|
4682
|
+
assignees: z27.array(z27.object({ login: z27.string().min(1) })).nullish(),
|
|
4683
|
+
number: z27.number(),
|
|
4684
|
+
user: z27.object({ login: z27.string().min(1) }).nullish()
|
|
4589
4685
|
}),
|
|
4590
|
-
repository:
|
|
4686
|
+
repository: z27.object({ full_name: z27.string().min(1) })
|
|
4591
4687
|
});
|
|
4592
|
-
var commitPageSchema =
|
|
4593
|
-
|
|
4594
|
-
author:
|
|
4595
|
-
commit:
|
|
4688
|
+
var commitPageSchema = z27.array(
|
|
4689
|
+
z27.object({
|
|
4690
|
+
author: z27.object({ login: z27.string().min(1) }).nullish(),
|
|
4691
|
+
commit: z27.object({ message: z27.string() })
|
|
4596
4692
|
})
|
|
4597
4693
|
);
|
|
4598
4694
|
function shareCommitPages(load) {
|
|
@@ -4737,10 +4833,10 @@ function webhookInstallationId(body) {
|
|
|
4737
4833
|
}
|
|
4738
4834
|
return parseInstallationId(installation.id);
|
|
4739
4835
|
}
|
|
4740
|
-
var feedbackTargetSchema =
|
|
4741
|
-
commentId:
|
|
4742
|
-
commentKind:
|
|
4743
|
-
repo:
|
|
4836
|
+
var feedbackTargetSchema = z28.object({
|
|
4837
|
+
commentId: z28.number(),
|
|
4838
|
+
commentKind: z28.enum(["conversation", "review"]),
|
|
4839
|
+
repo: z28.string().min(1)
|
|
4744
4840
|
});
|
|
4745
4841
|
function pullRequestFeedbackTarget(events) {
|
|
4746
4842
|
const event = events.find(
|
|
@@ -5023,18 +5119,18 @@ function gitHubResourceUrl(input) {
|
|
|
5023
5119
|
}
|
|
5024
5120
|
|
|
5025
5121
|
// src/pull-request-outcomes/commit-composition.ts
|
|
5026
|
-
import { z as
|
|
5027
|
-
var canonicalCommitSchema =
|
|
5028
|
-
authorEmail:
|
|
5029
|
-
authorLogin:
|
|
5122
|
+
import { z as z29 } from "zod";
|
|
5123
|
+
var canonicalCommitSchema = z29.object({
|
|
5124
|
+
authorEmail: z29.string().nullable(),
|
|
5125
|
+
authorLogin: z29.string().nullable()
|
|
5030
5126
|
}).strict();
|
|
5031
|
-
var providerCommitSchema =
|
|
5032
|
-
author:
|
|
5033
|
-
commit:
|
|
5034
|
-
author:
|
|
5127
|
+
var providerCommitSchema = z29.object({
|
|
5128
|
+
author: z29.object({ login: z29.string() }).passthrough().nullable(),
|
|
5129
|
+
commit: z29.object({
|
|
5130
|
+
author: z29.object({ email: z29.string() }).passthrough().nullable()
|
|
5035
5131
|
}).passthrough()
|
|
5036
5132
|
}).passthrough();
|
|
5037
|
-
var commitPageSchema2 =
|
|
5133
|
+
var commitPageSchema2 = z29.array(providerCommitSchema).transform(
|
|
5038
5134
|
(commits) => commits.map(
|
|
5039
5135
|
(commit) => canonicalCommitSchema.parse({
|
|
5040
5136
|
authorEmail: commit.commit.author?.email ?? null,
|
|
@@ -5188,8 +5284,12 @@ if [ -z "$repository_hooks_dir" ]; then
|
|
|
5188
5284
|
repository_hooks_dir="$git_common_dir/hooks"
|
|
5189
5285
|
fi
|
|
5190
5286
|
fi
|
|
5191
|
-
if [ -n "$repository_hooks_dir" ] && [ -x "$repository_hooks_dir/${name}" ]
|
|
5192
|
-
|
|
5287
|
+
if [ -n "$repository_hooks_dir" ] && [ -x "$repository_hooks_dir/${name}" ]; then
|
|
5288
|
+
repository_hooks_real=$(CDPATH='' cd -- "$repository_hooks_dir" && pwd -P) || repository_hooks_real=""
|
|
5289
|
+
junior_hooks_real=$(CDPATH='' cd -- "\${0%/*}" && pwd -P) || junior_hooks_real=""
|
|
5290
|
+
if [ "$repository_hooks_real" != "$junior_hooks_real" ]; then
|
|
5291
|
+
repository_hook="$repository_hooks_dir/${name}"
|
|
5292
|
+
fi
|
|
5193
5293
|
fi`;
|
|
5194
5294
|
}
|
|
5195
5295
|
function repositoryHook(name) {
|
|
@@ -5202,14 +5302,100 @@ if [ -n "$repository_hook" ]; then
|
|
|
5202
5302
|
fi
|
|
5203
5303
|
`;
|
|
5204
5304
|
}
|
|
5305
|
+
var SET_COAUTHOR_TRAILERS_AWK = String.raw`
|
|
5306
|
+
function blank(line) { return line ~ /^[[:space:]]*$/ }
|
|
5307
|
+
function comment(line) { return substr(line, 1, 1) == "#" }
|
|
5308
|
+
function trailer(line) {
|
|
5309
|
+
return coauthor(line) || line ~ /^[A-Z][[:alnum:]-]*: ./ || line ~ /^\(cherry picked from commit [0-9a-f]+\)$/
|
|
5310
|
+
}
|
|
5311
|
+
function coauthor(line) { return tolower(line) ~ /^co-authored-by: / }
|
|
5312
|
+
{ lines[NR] = $0 }
|
|
5313
|
+
END {
|
|
5314
|
+
last = NR
|
|
5315
|
+
while (last > 0 && (blank(lines[last]) || comment(lines[last]))) last--
|
|
5316
|
+
count = 0
|
|
5317
|
+
i = 1
|
|
5318
|
+
while (i <= last) {
|
|
5319
|
+
count++
|
|
5320
|
+
gap[count] = i
|
|
5321
|
+
while (blank(lines[i])) i++
|
|
5322
|
+
first[count] = i
|
|
5323
|
+
while (i <= last && !blank(lines[i])) i++
|
|
5324
|
+
final[count] = i - 1
|
|
5325
|
+
}
|
|
5326
|
+
subject = 0
|
|
5327
|
+
content_count = 0
|
|
5328
|
+
for (p = 1; p <= count; p++) {
|
|
5329
|
+
content = 0
|
|
5330
|
+
trailers = 1
|
|
5331
|
+
for (j = first[p]; j <= final[p]; j++) {
|
|
5332
|
+
if (comment(lines[j])) continue
|
|
5333
|
+
content = 1
|
|
5334
|
+
if (!trailer(lines[j])) trailers = 0
|
|
5335
|
+
}
|
|
5336
|
+
if (content && !subject) subject = p
|
|
5337
|
+
trailer_paragraph[p] = content && trailers
|
|
5338
|
+
kept[p] = 0
|
|
5339
|
+
kept_content[p] = 0
|
|
5340
|
+
for (j = first[p]; j <= final[p]; j++) {
|
|
5341
|
+
drop[j] = trailer_paragraph[p] && coauthor(lines[j])
|
|
5342
|
+
if (drop[j]) continue
|
|
5343
|
+
kept[p]++
|
|
5344
|
+
if (!comment(lines[j])) kept_content[p]++
|
|
5345
|
+
}
|
|
5346
|
+
if (kept_content[p]) content_count++
|
|
5347
|
+
}
|
|
5348
|
+
if (ENVIRON["JUNIOR_COAUTHOR_LIST"] != "") {
|
|
5349
|
+
for (j = 1; j <= last; j++) {
|
|
5350
|
+
if (!drop[j]) continue
|
|
5351
|
+
line = lines[j]
|
|
5352
|
+
sub(/^[^:]*:[[:space:]]*/, "", line)
|
|
5353
|
+
print "Co-Authored-By: " line
|
|
5354
|
+
}
|
|
5355
|
+
exit
|
|
5356
|
+
}
|
|
5357
|
+
last_paragraph = 0
|
|
5358
|
+
for (p = 1; p <= count; p++) {
|
|
5359
|
+
if (!kept[p]) continue
|
|
5360
|
+
for (j = gap[p]; j < first[p]; j++) print lines[j]
|
|
5361
|
+
for (j = first[p]; j <= final[p]; j++) if (!drop[j]) print lines[j]
|
|
5362
|
+
last_paragraph = p
|
|
5363
|
+
}
|
|
5364
|
+
if (content_count) {
|
|
5365
|
+
inline = last_paragraph != subject && trailer_paragraph[last_paragraph] && kept_content[last_paragraph]
|
|
5366
|
+
bot = tolower(ENVIRON["JUNIOR_GIT_AUTHOR_EMAIL"])
|
|
5367
|
+
n = split(ENVIRON["JUNIOR_COAUTHOR_TRAILERS"], wanted, "\n")
|
|
5368
|
+
for (k = 1; k <= n; k++) {
|
|
5369
|
+
line = wanted[k]
|
|
5370
|
+
if (line !~ /^Co-Authored-By: [^<>]+ <[^<>[:space:]]+@[^<>[:space:]]+>$/) continue
|
|
5371
|
+
email = tolower(line)
|
|
5372
|
+
sub(/^[^<]*</, "", email)
|
|
5373
|
+
sub(/>$/, "", email)
|
|
5374
|
+
if (email == bot || seen[email]++) continue
|
|
5375
|
+
if (!inline) print ""
|
|
5376
|
+
inline = 1
|
|
5377
|
+
print line
|
|
5378
|
+
}
|
|
5379
|
+
}
|
|
5380
|
+
for (j = last + 1; j <= NR; j++) print lines[j]
|
|
5381
|
+
}
|
|
5382
|
+
`;
|
|
5205
5383
|
function prepareCommitMsgHook() {
|
|
5206
|
-
return `#!/
|
|
5384
|
+
return `#!/bin/sh
|
|
5207
5385
|
set -eu
|
|
5208
5386
|
|
|
5209
|
-
|
|
5210
|
-
if [ -z "$message_file" ]; then
|
|
5387
|
+
if [ "$#" -lt 1 ] || [ -z "$1" ]; then
|
|
5211
5388
|
exit 1
|
|
5212
5389
|
fi
|
|
5390
|
+
message_file=$1
|
|
5391
|
+
commit_source=""
|
|
5392
|
+
if [ "$#" -ge 2 ]; then
|
|
5393
|
+
commit_source=$2
|
|
5394
|
+
fi
|
|
5395
|
+
source_commit=""
|
|
5396
|
+
if [ "$#" -ge 3 ]; then
|
|
5397
|
+
source_commit=$3
|
|
5398
|
+
fi
|
|
5213
5399
|
|
|
5214
5400
|
# Run the repository hook first so Junior's trailers stay final.
|
|
5215
5401
|
${findRepositoryHook("prepare-commit-msg")}
|
|
@@ -5222,124 +5408,109 @@ if [ -z "\${JUNIOR_GIT_AUTHOR_NAME:-}" ] || [ -z "\${JUNIOR_GIT_AUTHOR_EMAIL:-}"
|
|
|
5222
5408
|
exit 1
|
|
5223
5409
|
fi
|
|
5224
5410
|
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
exit 1
|
|
5228
|
-
fi
|
|
5411
|
+
nl='
|
|
5412
|
+
'
|
|
5229
5413
|
|
|
5230
|
-
#
|
|
5231
|
-
#
|
|
5232
|
-
#
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5414
|
+
# Commits whose changes this commit replaces. Their co-authors stay
|
|
5415
|
+
# credited, so an amend, rebase, cherry-pick, or squash keeps them even when
|
|
5416
|
+
# the current run has other human actors or none.
|
|
5417
|
+
rewritten_commits=""
|
|
5418
|
+
add_rewritten_commit() {
|
|
5419
|
+
if [ -n "$1" ]; then
|
|
5420
|
+
rewritten_commits="$rewritten_commits $1"
|
|
5421
|
+
fi
|
|
5236
5422
|
}
|
|
5237
5423
|
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
add_trailer "$actor_trailer"
|
|
5242
|
-
fi
|
|
5243
|
-
done <<< "$JUNIOR_GIT_ACTOR_COAUTHOR_TRAILERS"
|
|
5424
|
+
# \`--amend\`, \`-c\`, \`-C\`, and rebase \`reword\`.
|
|
5425
|
+
if [ "$commit_source" = "commit" ]; then
|
|
5426
|
+
add_rewritten_commit "$source_commit"
|
|
5244
5427
|
fi
|
|
5245
5428
|
|
|
5246
|
-
#
|
|
5247
|
-
# from the
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
line--
|
|
5256
|
-
}
|
|
5257
|
-
start = line
|
|
5258
|
-
while (start > 0 && lines[start] != "") {
|
|
5259
|
-
start--
|
|
5260
|
-
}
|
|
5261
|
-
valid = line > 0
|
|
5262
|
-
for (i = start + 1; valid && i <= line; i++) {
|
|
5263
|
-
if (lines[i] !~ /^[[:alnum:]-]+: .+/) {
|
|
5264
|
-
valid = 0
|
|
5265
|
-
}
|
|
5266
|
-
}
|
|
5267
|
-
if (!valid) {
|
|
5268
|
-
for (i = 1; i <= NR; i++) {
|
|
5269
|
-
print lines[i]
|
|
5270
|
-
}
|
|
5271
|
-
exit 0
|
|
5272
|
-
}
|
|
5273
|
-
kept = 0
|
|
5274
|
-
for (i = start + 1; i <= line; i++) {
|
|
5275
|
-
if (tolower(lines[i]) !~ /^co-authored-by: /) {
|
|
5276
|
-
kept++
|
|
5277
|
-
}
|
|
5278
|
-
}
|
|
5279
|
-
before = kept > 0 ? start : start - 1
|
|
5280
|
-
for (i = 1; i <= before; i++) {
|
|
5281
|
-
print lines[i]
|
|
5282
|
-
}
|
|
5283
|
-
for (i = start + 1; i <= line; i++) {
|
|
5284
|
-
if (tolower(lines[i]) !~ /^co-authored-by: /) {
|
|
5285
|
-
print lines[i]
|
|
5286
|
-
}
|
|
5287
|
-
}
|
|
5288
|
-
}
|
|
5289
|
-
' "$message_file" > "$tmp_file"
|
|
5290
|
-
cat "$tmp_file" > "$message_file"
|
|
5291
|
-
|
|
5292
|
-
final_trailer_block=$(awk '
|
|
5293
|
-
{ lines[NR] = $0 }
|
|
5294
|
-
END {
|
|
5295
|
-
line = NR
|
|
5296
|
-
while (line > 0 && lines[line] == "") {
|
|
5297
|
-
line--
|
|
5298
|
-
}
|
|
5299
|
-
if (line == 0) {
|
|
5300
|
-
exit 0
|
|
5301
|
-
}
|
|
5302
|
-
start = line
|
|
5303
|
-
while (start > 0 && lines[start] != "") {
|
|
5304
|
-
start--
|
|
5305
|
-
}
|
|
5306
|
-
for (i = start + 1; i <= line; i++) {
|
|
5307
|
-
if (lines[i] !~ /^[[:alnum:]-]+: .+/) {
|
|
5308
|
-
exit 0
|
|
5309
|
-
}
|
|
5310
|
-
}
|
|
5311
|
-
for (i = start + 1; i <= line; i++) {
|
|
5312
|
-
print lines[i]
|
|
5313
|
-
}
|
|
5314
|
-
}
|
|
5315
|
-
' "$message_file")
|
|
5429
|
+
# \`--amend -m\` and \`--amend -F\` give the "message" source, so read the
|
|
5430
|
+
# flag from the parent \`git commit\` process.
|
|
5431
|
+
parent_args=""
|
|
5432
|
+
if [ -r "/proc/$PPID/cmdline" ]; then
|
|
5433
|
+
parent_args=$(tr '\\000' '\\n' < "/proc/$PPID/cmdline") || parent_args=""
|
|
5434
|
+
fi
|
|
5435
|
+
case "$nl$parent_args$nl" in
|
|
5436
|
+
*"$nl--amend$nl"*) add_rewritten_commit HEAD ;;
|
|
5437
|
+
esac
|
|
5316
5438
|
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5439
|
+
git_dir=$(git rev-parse --git-dir 2>/dev/null) || git_dir=""
|
|
5440
|
+
if [ -n "$git_dir" ]; then
|
|
5441
|
+
# Each rebase \`pick\` and each \`git cherry-pick\`.
|
|
5442
|
+
if git rev-parse -q --verify CHERRY_PICK_HEAD >/dev/null 2>&1; then
|
|
5443
|
+
add_rewritten_commit CHERRY_PICK_HEAD
|
|
5321
5444
|
fi
|
|
5322
|
-
}
|
|
5323
5445
|
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5446
|
+
if [ -f "$git_dir/rebase-merge/done" ]; then
|
|
5447
|
+
# A rebase step that stopped on a conflict. An \`edit\` stop writes
|
|
5448
|
+
# \`amend\`, and a new commit there replaces no commit.
|
|
5449
|
+
if [ ! -f "$git_dir/rebase-merge/amend" ] && git rev-parse -q --verify REBASE_HEAD >/dev/null 2>&1; then
|
|
5450
|
+
add_rewritten_commit REBASE_HEAD
|
|
5451
|
+
fi
|
|
5452
|
+
# A \`fixup\` or \`squash\` folds its commit into HEAD. A rebased merge
|
|
5453
|
+
# reuses the commit in \`merge -C\`.
|
|
5454
|
+
rebase_step=$(tail -n 1 "$git_dir/rebase-merge/done")
|
|
5455
|
+
case "$rebase_step" in
|
|
5456
|
+
f\\ *|fixup\\ *|s\\ *|squash\\ *) add_rewritten_commit HEAD ;;
|
|
5457
|
+
esac
|
|
5458
|
+
case "$rebase_step" in
|
|
5459
|
+
f\\ *|fixup\\ *|s\\ *|squash\\ *|m\\ *|merge\\ *)
|
|
5460
|
+
step_commit=$(printf '%s\\n' "$rebase_step" | sed -n 's/^[a-z]* \\(-[Cc] \\)\\{0,1\\}\\([0-9a-f]\\{40,64\\}\\).*/\\2/p')
|
|
5461
|
+
add_rewritten_commit "$step_commit"
|
|
5462
|
+
;;
|
|
5463
|
+
esac
|
|
5327
5464
|
fi
|
|
5328
|
-
done <<< "$desired_trailers"
|
|
5329
5465
|
|
|
5330
|
-
|
|
5331
|
-
|
|
5466
|
+
# \`git merge --squash\` lists the squashed commits in SQUASH_MSG.
|
|
5467
|
+
if [ "$commit_source" = "squash" ] && [ -f "$git_dir/SQUASH_MSG" ]; then
|
|
5468
|
+
squashed_commits=$(sed -n 's/^commit \\([0-9a-f]\\{40,64\\}\\).*/\\1/p' "$git_dir/SQUASH_MSG")
|
|
5469
|
+
for squashed_commit in $squashed_commits; do
|
|
5470
|
+
add_rewritten_commit "$squashed_commit"
|
|
5471
|
+
done
|
|
5472
|
+
fi
|
|
5332
5473
|
fi
|
|
5333
5474
|
|
|
5334
|
-
|
|
5335
|
-
|
|
5475
|
+
# A rewrite keeps the author of the commit it replaces, and Git passes that
|
|
5476
|
+
# author to this hook.
|
|
5477
|
+
if [ "\${GIT_AUTHOR_NAME:-}" != "$JUNIOR_GIT_AUTHOR_NAME" ] || [ "\${GIT_AUTHOR_EMAIL:-}" != "$JUNIOR_GIT_AUTHOR_EMAIL" ]; then
|
|
5478
|
+
kept_author=""
|
|
5479
|
+
for rewritten_commit in $rewritten_commits; do
|
|
5480
|
+
rewritten_author=$(git show -s --format='%an%n%ae' "$rewritten_commit" -- 2>/dev/null) || continue
|
|
5481
|
+
if [ "$rewritten_author" = "\${GIT_AUTHOR_NAME:-}$nl\${GIT_AUTHOR_EMAIL:-}" ]; then
|
|
5482
|
+
kept_author=$rewritten_author
|
|
5483
|
+
fi
|
|
5484
|
+
done
|
|
5485
|
+
if [ -z "$kept_author" ]; then
|
|
5486
|
+
echo "GitHub plugin internal error: Git author was not set to the configured identity. Do not override Git author manually; report this configuration error." >&2
|
|
5487
|
+
exit 1
|
|
5488
|
+
fi
|
|
5336
5489
|
fi
|
|
5337
5490
|
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5491
|
+
set_coauthor_trailers() {
|
|
5492
|
+
awk '${SET_COAUTHOR_TRAILERS_AWK}' "$@"
|
|
5493
|
+
}
|
|
5494
|
+
|
|
5495
|
+
# Existing co-authors first, then the host-derived human run actors.
|
|
5496
|
+
coauthor_trailers=""
|
|
5497
|
+
for rewritten_commit in $rewritten_commits; do
|
|
5498
|
+
rewritten_message=$(git show -s --format=%B "$rewritten_commit" -- 2>/dev/null) || continue
|
|
5499
|
+
coauthors=$(
|
|
5500
|
+
JUNIOR_COAUTHOR_LIST=1
|
|
5501
|
+
export JUNIOR_COAUTHOR_LIST
|
|
5502
|
+
printf '%s\\n' "$rewritten_message" | set_coauthor_trailers
|
|
5503
|
+
)
|
|
5504
|
+
coauthor_trailers="$coauthor_trailers$coauthors$nl"
|
|
5505
|
+
done
|
|
5506
|
+
coauthor_trailers="$coauthor_trailers\${JUNIOR_GIT_ACTOR_COAUTHOR_TRAILERS:-}"
|
|
5507
|
+
|
|
5508
|
+
message=$(
|
|
5509
|
+
JUNIOR_COAUTHOR_TRAILERS=$coauthor_trailers
|
|
5510
|
+
export JUNIOR_COAUTHOR_TRAILERS
|
|
5511
|
+
set_coauthor_trailers "$message_file"
|
|
5512
|
+
)
|
|
5513
|
+
printf '%s\\n' "$message" > "$message_file"
|
|
5343
5514
|
`;
|
|
5344
5515
|
}
|
|
5345
5516
|
var PREPARE_GIT_SCRIPT = `set -eu
|
|
@@ -6103,6 +6274,13 @@ var GITHUB_BODY_WRITES = [
|
|
|
6103
6274
|
operation: "github.pull.review.create",
|
|
6104
6275
|
restPath: /^\/repos\/[^/]+\/[^/]+\/pulls\/[^/]+\/reviews$/
|
|
6105
6276
|
},
|
|
6277
|
+
{
|
|
6278
|
+
denialMessage: `GitHub review thread replies must use the github_commentOnPullRequest tool with in_reply_to. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
|
|
6279
|
+
graphqlField: "addPullRequestReviewThreadReply",
|
|
6280
|
+
method: "POST",
|
|
6281
|
+
operation: "github.pull.comment.create",
|
|
6282
|
+
restPath: /^\/repos\/[^/]+\/[^/]+\/pulls\/[^/]+\/comments\/[^/]+\/replies$/
|
|
6283
|
+
},
|
|
6106
6284
|
{
|
|
6107
6285
|
denialMessage: `GitHub issue updates must use the github_updateIssue tool, which owns requester attribution and the conversation footer. ${CREATE_TOOL_ROUTING_GUIDANCE}`,
|
|
6108
6286
|
graphqlField: "updateIssue",
|