@sentry/junior-github 0.314.0 → 0.316.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/{events-D51HE9X3.js → events-BoMOs5Rd.js} +75 -23
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4122 -2288
- package/dist/testing.js +1 -1
- package/migrations/20260722180343_pull_request_outcomes/snapshot.json +315 -0
- package/migrations/20260722224832_issue_outcomes/snapshot.json +301 -0
- package/migrations/20260722230324_pull_request_commit_composition/snapshot.json +42 -0
- package/migrations/20260722231413_pull_request_conversations/snapshot.json +42 -0
- package/migrations/20260723023722_marvelous_toad_men/snapshot.json +42 -0
- package/migrations/20260724235000_github_cost_associations/snapshot.json +73 -0
- package/migrations/20260725024522_fat_korvac/snapshot.json +158 -0
- package/migrations/20260811221145_shallow_millenium_guard/snapshot.json +54 -0
- package/migrations/20260824190830_native_code_backfill/snapshot.json +9 -0
- package/migrations/20261028220913_nostalgic_thing/snapshot.json +128 -0
- package/migrations/20261101195735_sleepy_slayback/snapshot.json +169 -0
- package/migrations/20261112142844_pull_request_draft/snapshot.json +42 -0
- package/migrations/20261113213858_pull_request_next_action/snapshot.json +61 -0
- package/migrations/20261119095049_conflict_fixes_resumed_at/snapshot.json +42 -0
- package/migrations/20261119230607_conflict_fixes/snapshot.json +42 -0
- package/migrations/20261120232426_conflict_fix_asked_at/snapshot.json +42 -0
- package/migrations/20261121002146_pull_request_finished_at/snapshot.json +42 -0
- package/migrations/20261121002159_pull_request_lifecycle_copies/snapshot.json +118 -0
- package/migrations/20261123212042_drop_pull_request_issues/snapshot.json +51 -0
- package/migrations/20261123220932_drop_github_issues/snapshot.json +83 -0
- package/migrations/20261123224011_pull_request_lifecycle_backfill/migration.sql +80 -0
- package/migrations/20261123224011_pull_request_lifecycle_backfill/snapshot.json +9 -0
- package/migrations/20261123224012_pull_request_lifecycle_in_code_index/migration.sql +10 -0
- package/migrations/20261123224012_pull_request_lifecycle_in_code_index/snapshot.json +219 -0
- package/package.json +4 -4
- package/skills/github-code/SKILL.md +1 -1
- package/skills/github-code/SPEC.md +1 -1
- package/skills/github-issues/references/api-surface.md +2 -1
- package/migrations/meta/0000_snapshot.json +0 -148
- package/migrations/meta/0001_snapshot.json +0 -256
- package/migrations/meta/0002_snapshot.json +0 -262
- package/migrations/meta/0003_snapshot.json +0 -269
- package/migrations/meta/0004_snapshot.json +0 -275
- package/migrations/meta/0005_snapshot.json +0 -289
- package/migrations/meta/0006_snapshot.json +0 -336
- package/migrations/meta/0007_snapshot.json +0 -352
- package/migrations/meta/0008_snapshot.json +0 -348
- package/migrations/meta/0009_snapshot.json +0 -404
- package/migrations/meta/0010_snapshot.json +0 -427
- package/migrations/meta/0011_snapshot.json +0 -434
- package/migrations/meta/0012_snapshot.json +0 -434
- package/migrations/meta/0013_snapshot.json +0 -448
- package/migrations/meta/0014_snapshot.json +0 -455
- package/migrations/meta/0015_snapshot.json +0 -461
- package/migrations/meta/0016_snapshot.json +0 -467
- package/migrations/meta/0017_snapshot.json +0 -418
- package/migrations/meta/0018_snapshot.json +0 -364
- package/migrations/meta/0019_snapshot.json +0 -243
- package/migrations/meta/_journal.json +0 -146
- /package/migrations/{0000_pull_request_outcomes.sql → 20260722180343_pull_request_outcomes/migration.sql} +0 -0
- /package/migrations/{0001_issue_outcomes.sql → 20260722224832_issue_outcomes/migration.sql} +0 -0
- /package/migrations/{0002_pull_request_commit_composition.sql → 20260722230324_pull_request_commit_composition/migration.sql} +0 -0
- /package/migrations/{0003_pull_request_conversations.sql → 20260722231413_pull_request_conversations/migration.sql} +0 -0
- /package/migrations/{0004_marvelous_toad_men.sql → 20260723023722_marvelous_toad_men/migration.sql} +0 -0
- /package/migrations/{0005_github_cost_associations.sql → 20260724235000_github_cost_associations/migration.sql} +0 -0
- /package/migrations/{0006_fat_korvac.sql → 20260725024522_fat_korvac/migration.sql} +0 -0
- /package/migrations/{0007_shallow_millenium_guard.sql → 20260811221145_shallow_millenium_guard/migration.sql} +0 -0
- /package/migrations/{0008_native_code_backfill.sql → 20260824190830_native_code_backfill/migration.sql} +0 -0
- /package/migrations/{0009_nostalgic_thing.sql → 20261028220913_nostalgic_thing/migration.sql} +0 -0
- /package/migrations/{0010_sleepy_slayback.sql → 20261101195735_sleepy_slayback/migration.sql} +0 -0
- /package/migrations/{0011_pull_request_draft.sql → 20261112142844_pull_request_draft/migration.sql} +0 -0
- /package/migrations/{0012_pull_request_next_action.sql → 20261113213858_pull_request_next_action/migration.sql} +0 -0
- /package/migrations/{0013_conflict_fixes_resumed_at.sql → 20261119095049_conflict_fixes_resumed_at/migration.sql} +0 -0
- /package/migrations/{0014_conflict_fixes.sql → 20261119230607_conflict_fixes/migration.sql} +0 -0
- /package/migrations/{0015_conflict_fix_asked_at.sql → 20261120232426_conflict_fix_asked_at/migration.sql} +0 -0
- /package/migrations/{0016_pull_request_finished_at.sql → 20261121002146_pull_request_finished_at/migration.sql} +0 -0
- /package/migrations/{0017_pull_request_lifecycle_copies.sql → 20261121002159_pull_request_lifecycle_copies/migration.sql} +0 -0
- /package/migrations/{0018_drop_pull_request_issues.sql → 20261123212042_drop_pull_request_issues/migration.sql} +0 -0
- /package/migrations/{0019_drop_github_issues.sql → 20261123220932_drop_github_issues/migration.sql} +0 -0
|
@@ -605,14 +605,19 @@ const GITHUB_PULL_REQUEST_EVENTS = [
|
|
|
605
605
|
"pull_request.checks.recovered",
|
|
606
606
|
"pull_request.comment.created",
|
|
607
607
|
"pull_request.opened",
|
|
608
|
+
"pull_request.reopened",
|
|
608
609
|
"pull_request.ready_for_review",
|
|
610
|
+
"pull_request.converted_to_draft",
|
|
611
|
+
"pull_request.synchronized",
|
|
612
|
+
"pull_request.review_requested",
|
|
609
613
|
"pull_request.review.approved",
|
|
610
614
|
"pull_request.review.changes_requested",
|
|
611
615
|
"pull_request.review.commented",
|
|
612
616
|
"pull_request.review_comment.created",
|
|
613
617
|
"pull_request.merged",
|
|
614
618
|
"pull_request.closed_unmerged",
|
|
615
|
-
"pull_request.merge_conflict"
|
|
619
|
+
"pull_request.merge_conflict",
|
|
620
|
+
"pull_request.merge_conflict.resolved"
|
|
616
621
|
];
|
|
617
622
|
/**
|
|
618
623
|
* A stack merges only with a linear history, so a stacked pull request is
|
|
@@ -624,9 +629,11 @@ const STACK_CONFLICT_STEPS = "run `gh stack rebase`, resolve each conflict so th
|
|
|
624
629
|
/**
|
|
625
630
|
* Every comment on a pull request gets the same feedback status: a
|
|
626
631
|
* conversation comment, an inline review comment, and a review body. A review
|
|
627
|
-
* sets comment_id only when it has a body.
|
|
632
|
+
* sets comment_id only when it has a body. A reply that hands the decision
|
|
633
|
+
* back to the reviewer reaches their Inbox only through the mark
|
|
634
|
+
* (`pull-request-review-again.ts`).
|
|
628
635
|
*/
|
|
629
|
-
const PULL_REQUEST_FEEDBACK = "When Verified details include comment_id, call github_updatePullRequestFeedback after
|
|
636
|
+
const PULL_REQUEST_FEEDBACK = "When Verified details include comment_id, call github_updatePullRequestFeedback after you act on the comment or reply to it, with the exact repo, pull_request, comment_id, and comment_kind from Verified details. Also mark a comment that you push back on, defer, or answer with a question: a change request asks its reviewer to review again only when each of its comments is marked, so an unmarked comment drops the pull request from their Inbox.";
|
|
630
637
|
const GITHUB_PULL_REQUEST_EVENT_GUIDANCE = {
|
|
631
638
|
"pull_request.checks.failed": "Fix only failures that the pull request causes. Do not skip, disable, or weaken a check to make it pass.",
|
|
632
639
|
"pull_request.review.approved": `When the approval includes actionable feedback, address it like any other review feedback. ${PULL_REQUEST_FEEDBACK}`,
|
|
@@ -675,11 +682,22 @@ function gitHubPullRequestSubscription(config) {
|
|
|
675
682
|
* Watch of a draft also gets them. Marking the pull request ready sends the
|
|
676
683
|
* review request. GitHub also asks the code owners then, so a draft with code
|
|
677
684
|
* owners waits for the person who asked for it, unless they said otherwise.
|
|
678
|
-
* A repository's AGENTS.md can also ask that drafts wait for a person.
|
|
685
|
+
* A repository's AGENTS.md can also ask that drafts wait for a person. A
|
|
686
|
+
* draft that waits asks only that person to review it on GitHub, and the
|
|
687
|
+
* Inbox item follows from that request, so the thread gets no message.
|
|
679
688
|
* Each passing suite wakes the Watch, so a suite that leaves the required
|
|
680
689
|
* checks unfinished must stay silent, or every suite posts.
|
|
681
690
|
*/
|
|
682
|
-
const DRAFT_CHECKS_RECOVERED_GUIDANCE = "If the pull request is still a draft, call github_getPullRequest and read its `checks`, `code_owners`, and `agents_md`. When `checks.required` is `passing` and no decision is open, in the pull request body or in an open inbox item that waits on the person who asked for it: mark it ready with github_updatePullRequest and draft false, when the person who asked for it said to mark it ready, or when `code_owners` is empty and `agents_md` does not ask for draft pull requests or say that a person marks them ready. Otherwise keep it a draft
|
|
691
|
+
const DRAFT_CHECKS_RECOVERED_GUIDANCE = "If the pull request is still a draft, call github_getPullRequest and read its `checks`, `code_owners`, and `agents_md`. When `checks.required` is `passing` and no decision is open, in the pull request body or in an open inbox item that waits on the person who asked for it: mark it ready with github_updatePullRequest and draft false, when the person who asked for it said to mark it ready, or when `code_owners` is empty and `agents_md` does not ask for draft pull requests or say that a person marks them ready. Otherwise keep it a draft, because marking it ready would ask the code owners to review or break the AGENTS.md rule, and call github_updatePullRequest with request_review true, so GitHub asks the person who asked for it to review it. Their Inbox then asks them to review it and mark it ready, so stay silent in the thread. When it is `failing`, fix the failing checks like a failed check. When it is `pending` or `not_reported`, stay silent: a later passing suite wakes you again. `not_reported` means the required checks may not have started on the latest commit yet, not that none are required.";
|
|
692
|
+
/**
|
|
693
|
+
* The requester's approval is the review that a held draft waits for. Marking
|
|
694
|
+
* it ready then asks the code owners after the requester has looked. A draft
|
|
695
|
+
* that the requester asked to keep, or that AGENTS.md leaves for a person to
|
|
696
|
+
* mark ready, stays a draft, and its Inbox item asks the requester to mark it
|
|
697
|
+
* ready (`webhooks/pull-request-action.ts`). Whether Junior held the draft, or the requester
|
|
698
|
+
* asked to keep it, is in the Conversation, so the agent decides.
|
|
699
|
+
*/
|
|
700
|
+
const DRAFT_APPROVED_GUIDANCE = "If the pull request is still a draft and `sender_login` in Verified details is `opener_username`, the person who asked for it approved it. Call github_getPullRequest and read its `agents_md`. Mark it ready with github_updatePullRequest and draft false, so GitHub asks its code owners now that this person has looked. Keep it a draft when this person asked to keep it a draft, or when `agents_md` says that a person marks drafts ready: their Inbox then asks them to mark it ready. Stay silent in the thread.";
|
|
683
701
|
/**
|
|
684
702
|
* State changes that need no action but that a later Turn must know, so that
|
|
685
703
|
* it does not call an approved pull request unreviewed, or a merged or
|
|
@@ -697,16 +715,19 @@ const QUIET_PULL_REQUEST_EVENTS = [
|
|
|
697
715
|
* passing check suite.
|
|
698
716
|
*/
|
|
699
717
|
function gitHubPullRequestCreateWatch(config, pullRequest) {
|
|
700
|
-
const quietEvents = [...QUIET_PULL_REQUEST_EVENTS, ...pullRequest.draft ? ["pull_request.ready_for_review"] : []].filter((eventType) => !config.events.includes(eventType));
|
|
718
|
+
const quietEvents = [...QUIET_PULL_REQUEST_EVENTS.filter((eventType) => !pullRequest.draft || eventType !== "pull_request.review.approved"), ...pullRequest.draft ? ["pull_request.ready_for_review"] : []].filter((eventType) => !config.events.includes(eventType));
|
|
701
719
|
return {
|
|
702
720
|
events: [.../* @__PURE__ */ new Set([
|
|
703
721
|
...config.events,
|
|
704
722
|
"pull_request.merge_conflict",
|
|
705
|
-
...pullRequest.draft ? ["pull_request.checks.recovered"] : [],
|
|
723
|
+
...pullRequest.draft ? ["pull_request.checks.recovered", "pull_request.review.approved"] : [],
|
|
706
724
|
...quietEvents
|
|
707
725
|
])],
|
|
708
726
|
...quietEvents.length > 0 ? { quietEvents } : void 0,
|
|
709
|
-
...pullRequest.draft ? { guidance: {
|
|
727
|
+
...pullRequest.draft ? { guidance: {
|
|
728
|
+
"pull_request.checks.recovered": DRAFT_CHECKS_RECOVERED_GUIDANCE,
|
|
729
|
+
"pull_request.review.approved": DRAFT_APPROVED_GUIDANCE
|
|
730
|
+
} } : void 0,
|
|
710
731
|
intent: config.intent
|
|
711
732
|
};
|
|
712
733
|
}
|
|
@@ -722,11 +743,12 @@ const GITHUB_PULL_REQUEST_SUGGESTED_EVENTS = [
|
|
|
722
743
|
"pull_request.merge_conflict"
|
|
723
744
|
];
|
|
724
745
|
/**
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
* pull request for `pull_request.merge_conflict` instead.
|
|
746
|
+
* Merge conflict events. GitHub sends no webhook when a pull request gets a
|
|
747
|
+
* conflict or loses it, so the plugin reads the pull request for them.
|
|
728
748
|
*/
|
|
729
|
-
const
|
|
749
|
+
const GITHUB_MERGE_CONFLICT_EVENTS = /* @__PURE__ */ new Set(["pull_request.merge_conflict", "pull_request.merge_conflict.resolved"]);
|
|
750
|
+
/** Pull request events that a GitHub webhook payload describes. */
|
|
751
|
+
const GITHUB_PULL_REQUEST_PAYLOAD_EVENTS = GITHUB_PULL_REQUEST_EVENTS.filter((eventType) => !GITHUB_MERGE_CONFLICT_EVENTS.has(eventType));
|
|
730
752
|
/** Pull request events that a comment or review starts. */
|
|
731
753
|
const GITHUB_PULL_REQUEST_COMMENT_EVENTS = [
|
|
732
754
|
"pull_request.comment.created",
|
|
@@ -748,7 +770,8 @@ const GITHUB_PULL_REQUEST_CHECK_EVENTS = [
|
|
|
748
770
|
* The pull request comment webhook has no head branch. A check suite result
|
|
749
771
|
* that GitHub links to no pull request has no `pullRequest`. The webhook
|
|
750
772
|
* checks for a Watch or event automation before it reads a pull request for
|
|
751
|
-
* a conflict, so `pull_request.merge_conflict`
|
|
773
|
+
* a conflict, so `pull_request.merge_conflict` and
|
|
774
|
+
* `pull_request.merge_conflict.resolved` match only `repo` and
|
|
752
775
|
* `pullRequest`.
|
|
753
776
|
*/
|
|
754
777
|
const GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema.parse({
|
|
@@ -2840,9 +2863,11 @@ const pullRequestWebhookSchema = z.object({
|
|
|
2840
2863
|
title: z.string().optional(),
|
|
2841
2864
|
updated_at: z.string().optional()
|
|
2842
2865
|
}),
|
|
2843
|
-
repository: repositorySchema
|
|
2866
|
+
repository: repositorySchema,
|
|
2867
|
+
requested_reviewer: z.object({ login: z.string().min(1) }).nullish(),
|
|
2868
|
+
requested_team: z.object({ slug: z.string().min(1) }).nullish()
|
|
2844
2869
|
});
|
|
2845
|
-
/** Normalize pull request
|
|
2870
|
+
/** Normalize pull request lifecycle, push, and review request events. */
|
|
2846
2871
|
function normalizePullRequestEvent(deliveryId, body) {
|
|
2847
2872
|
const parsed = pullRequestWebhookSchema.safeParse(body);
|
|
2848
2873
|
if (!parsed.success) return [];
|
|
@@ -2890,14 +2915,41 @@ function normalizePullRequestEvent(deliveryId, body) {
|
|
|
2890
2915
|
}));
|
|
2891
2916
|
return events;
|
|
2892
2917
|
}
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2918
|
+
const updatedAtMs = providerTime(pullRequest.updated_at) ?? Date.now();
|
|
2919
|
+
switch (parsed.data.action) {
|
|
2920
|
+
case "ready_for_review": return lifecycleEvents({
|
|
2921
|
+
eventType: "pull_request.ready_for_review",
|
|
2922
|
+
isDraft: false,
|
|
2923
|
+
occurredAtMs: updatedAtMs,
|
|
2924
|
+
trustedSummary: `${resource.label} is ready for review.`,
|
|
2925
|
+
untrustedText
|
|
2926
|
+
});
|
|
2927
|
+
case "reopened": return lifecycleEvents({
|
|
2928
|
+
eventType: "pull_request.reopened",
|
|
2929
|
+
occurredAtMs: updatedAtMs,
|
|
2930
|
+
trustedSummary: `${resource.label} was reopened.`,
|
|
2931
|
+
untrustedText
|
|
2932
|
+
});
|
|
2933
|
+
case "converted_to_draft": return lifecycleEvents({
|
|
2934
|
+
eventType: "pull_request.converted_to_draft",
|
|
2935
|
+
occurredAtMs: updatedAtMs,
|
|
2936
|
+
trustedSummary: `${resource.label} was converted to a draft.`
|
|
2937
|
+
});
|
|
2938
|
+
case "review_requested": {
|
|
2939
|
+
const reviewer = nonBlank(parsed.data.requested_reviewer?.login) ?? (parsed.data.requested_team ? `team ${parsed.data.requested_team.slug}` : void 0);
|
|
2940
|
+
return lifecycleEvents({
|
|
2941
|
+
eventType: "pull_request.review_requested",
|
|
2942
|
+
occurredAtMs: updatedAtMs,
|
|
2943
|
+
trustedSummary: reviewer ? `${resource.label} has a review request for ${reviewer}.` : `${resource.label} has a review request.`
|
|
2944
|
+
});
|
|
2945
|
+
}
|
|
2946
|
+
case "synchronize": return lifecycleEvents({
|
|
2947
|
+
eventType: "pull_request.synchronized",
|
|
2948
|
+
occurredAtMs: updatedAtMs,
|
|
2949
|
+
trustedSummary: `${resource.label} has new commits.`
|
|
2950
|
+
});
|
|
2951
|
+
default: return gitHubPullRequestTerminalEvents(body);
|
|
2952
|
+
}
|
|
2901
2953
|
}
|
|
2902
2954
|
/**
|
|
2903
2955
|
* Build the merged or closed_unmerged events of one closed pull request.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PluginRegistration } from "@sentry/junior-plugin-api";
|
|
2
2
|
type GitHubAppPermissionLevel = "admin" | "read" | "write";
|
|
3
3
|
type GitHubAppPermissions = Record<string, GitHubAppPermissionLevel>;
|
|
4
|
-
declare const GITHUB_PULL_REQUEST_EVENTS: readonly ["pull_request.checks.failed", "pull_request.checks.passed", "pull_request.checks.recovered", "pull_request.comment.created", "pull_request.opened", "pull_request.ready_for_review", "pull_request.review.approved", "pull_request.review.changes_requested", "pull_request.review.commented", "pull_request.review_comment.created", "pull_request.merged", "pull_request.closed_unmerged", "pull_request.merge_conflict"];
|
|
4
|
+
declare const GITHUB_PULL_REQUEST_EVENTS: readonly ["pull_request.checks.failed", "pull_request.checks.passed", "pull_request.checks.recovered", "pull_request.comment.created", "pull_request.opened", "pull_request.reopened", "pull_request.ready_for_review", "pull_request.converted_to_draft", "pull_request.synchronized", "pull_request.review_requested", "pull_request.review.approved", "pull_request.review.changes_requested", "pull_request.review.commented", "pull_request.review_comment.created", "pull_request.merged", "pull_request.closed_unmerged", "pull_request.merge_conflict", "pull_request.merge_conflict.resolved"];
|
|
5
5
|
type GitHubPullRequestEvent = (typeof GITHUB_PULL_REQUEST_EVENTS)[number];
|
|
6
6
|
/** App-configured pull request event behavior. */
|
|
7
7
|
interface GitHubPullRequestEventOptions {
|