@sentry/junior-github 0.300.0 → 0.302.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.
Files changed (54) hide show
  1. package/dist/account-links.d.ts +8 -0
  2. package/dist/{chunk-YUF5P5I7.js → chunk-6SOJ5TN6.js} +142 -31
  3. package/dist/clone-command.d.ts +2 -0
  4. package/dist/configured-repository.d.ts +10 -0
  5. package/dist/db/schema.d.ts +23 -14
  6. package/dist/draft-readiness.d.ts +31 -0
  7. package/dist/events/pull-request.d.ts +1 -1
  8. package/dist/events/repository.d.ts +1 -1
  9. package/dist/graphql-documents.d.ts +13 -0
  10. package/dist/hooks-path-command.d.ts +5 -0
  11. package/dist/images.d.ts +8 -0
  12. package/dist/index.js +2355 -1801
  13. package/dist/merge-conflict-checks/heartbeat.d.ts +9 -5
  14. package/dist/merge-conflict-checks/policy.d.ts +74 -0
  15. package/dist/object-facts.d.ts +14 -3
  16. package/dist/pull-request-outcomes/reconcile.d.ts +2 -1
  17. package/dist/pull-request-outcomes/store.d.ts +15 -10
  18. package/dist/reply-markdown.d.ts +18 -2
  19. package/dist/testing.js +1 -1
  20. package/dist/tool-support/github-api.d.ts +7 -0
  21. package/dist/tool-support/github-text.d.ts +8 -0
  22. package/dist/tools/clone-repository.d.ts +89 -7
  23. package/dist/tools/comment-on-issue.d.ts +87 -3
  24. package/dist/tools/comment-on-pull-request.d.ts +87 -3
  25. package/dist/tools/create-issue.d.ts +86 -4
  26. package/dist/tools/create-pull-request.d.ts +88 -6
  27. package/dist/tools/get-deployment.d.ts +90 -8
  28. package/dist/tools/get-issue.d.ts +98 -16
  29. package/dist/tools/get-pull-request.d.ts +112 -9
  30. package/dist/tools/get-release.d.ts +90 -8
  31. package/dist/tools/get-repository.d.ts +90 -8
  32. package/dist/tools/get-status.d.ts +87 -5
  33. package/dist/tools/react-to-issue.d.ts +87 -3
  34. package/dist/tools/resolve-pull-request-review-thread.d.ts +87 -5
  35. package/dist/tools/submit-pull-request-review.d.ts +87 -3
  36. package/dist/tools/update-issue-comment.d.ts +87 -3
  37. package/dist/tools/update-issue.d.ts +106 -24
  38. package/dist/tools/update-pull-request-feedback.d.ts +87 -5
  39. package/dist/tools/update-pull-request.d.ts +109 -26
  40. package/dist/tools.d.ts +3 -3
  41. package/dist/webhooks/check-suite.d.ts +30 -3
  42. package/dist/webhooks/handler.d.ts +2 -0
  43. package/dist/webhooks/installation-requests.d.ts +8 -1
  44. package/dist/webhooks/merge-conflict.d.ts +7 -2
  45. package/dist/webhooks/pull-request-action.d.ts +37 -0
  46. package/migrations/0012_pull_request_next_action.sql +5 -0
  47. package/migrations/meta/0012_snapshot.json +434 -0
  48. package/migrations/meta/_journal.json +7 -0
  49. package/package.json +7 -2
  50. package/skills/github-code/SKILL.md +1 -1
  51. package/skills/github-code/SPEC.md +2 -2
  52. package/skills/github-code/references/workflow.md +1 -1
  53. package/dist/webhooks/pull-request-ready.d.ts +0 -31
  54. package/dist/webhooks/pull-request-review-request.d.ts +0 -32
@@ -1,30 +1,8 @@
1
1
  import { type Identity, type User, type Actor, type PluginLogger, type PluginDecider, type PluginEgress, type Source } from "@sentry/junior-plugin-api";
2
2
  /** Update mutable PR metadata while preserving runtime-owned body attribution. */
3
- export declare function createGitHubUpdatePullRequestTool(ctx: {
4
- actor?: Actor;
5
- automationLink?: {
6
- url: string;
7
- };
8
- conversationId?: string;
9
- db: unknown;
10
- egress: PluginEgress;
11
- log: PluginLogger;
12
- events: {
13
- canSubscribe: boolean;
14
- };
15
- conversationLink?: {
16
- url: string;
17
- };
18
- source?: Source;
19
- users: {
20
- resolveActor(): Promise<{
21
- identity?: Identity;
22
- user?: User;
23
- } | undefined>;
24
- };
25
- },
3
+ export declare function createGitHubUpdatePullRequestTool(
26
4
  /** Set when the description check experiment is on. */
27
- descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginToolDefinition<{
5
+ descriptionChecks?: boolean): import("@sentry/junior-plugin-api").PluginToolDefinition<{
28
6
  repo: string;
29
7
  number: number;
30
8
  title?: string | undefined;
@@ -37,7 +15,7 @@ descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginT
37
15
  kind: "object";
38
16
  key: string;
39
17
  label: string;
40
- objectType: "automation" | "calendar_event" | "code_change" | "conversation" | "deployment" | "document" | "item" | "message" | "person" | "task" | "web_page";
18
+ objectType: "automation" | "calendar_event" | "chart" | "code_change" | "conversation" | "deployment" | "document" | "event" | "item" | "message" | "person" | "task" | "trace" | "web_page";
41
19
  title: string;
42
20
  url: string | null;
43
21
  description?: string | undefined;
@@ -73,6 +51,10 @@ descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginT
73
51
  cycle?: string | undefined;
74
52
  dueDate?: string | undefined;
75
53
  labels?: string[] | undefined;
54
+ trend?: {
55
+ label: string;
56
+ points: number[];
57
+ } | undefined;
76
58
  } | {
77
59
  type: "deployment";
78
60
  summary?: string | undefined;
@@ -95,6 +77,7 @@ descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginT
95
77
  summary?: string | undefined;
96
78
  owner?: string | undefined;
97
79
  modifiedAt?: string | undefined;
80
+ thumbnailUrl?: string | undefined;
98
81
  } | {
99
82
  type: "message";
100
83
  summary?: string | undefined;
@@ -106,7 +89,43 @@ descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginT
106
89
  summary?: string | undefined;
107
90
  siteName?: string | undefined;
108
91
  author?: string | undefined;
92
+ media?: "image" | "video" | undefined;
109
93
  thumbnailUrl?: string | undefined;
94
+ } | {
95
+ type: "chart";
96
+ summary?: string | undefined;
97
+ display: "area" | "bar" | "line";
98
+ yAxis: string;
99
+ range: string;
100
+ series: {
101
+ label: string;
102
+ points: number[];
103
+ }[];
104
+ } | {
105
+ type: "event";
106
+ summary?: string | undefined;
107
+ level?: string | undefined;
108
+ project?: string | undefined;
109
+ release?: string | undefined;
110
+ environment?: string | undefined;
111
+ occurredAt?: string | undefined;
112
+ } | {
113
+ type: "trace";
114
+ summary?: string | undefined;
115
+ rootOp?: string | undefined;
116
+ rootName?: string | undefined;
117
+ durationMs: number;
118
+ spanCount: number;
119
+ errorCount: number;
120
+ performanceIssueCount: number;
121
+ projects: string[];
122
+ spans: {
123
+ op?: string | undefined;
124
+ name: string;
125
+ startMs: number;
126
+ durationMs: number;
127
+ issue?: boolean | undefined;
128
+ }[];
110
129
  } | {
111
130
  type: "person";
112
131
  summary?: string | undefined;
@@ -147,7 +166,7 @@ descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginT
147
166
  kind: "object";
148
167
  key: string;
149
168
  label: string;
150
- objectType: "automation" | "calendar_event" | "code_change" | "conversation" | "deployment" | "document" | "item" | "message" | "person" | "task" | "web_page";
169
+ objectType: "automation" | "calendar_event" | "chart" | "code_change" | "conversation" | "deployment" | "document" | "event" | "item" | "message" | "person" | "task" | "trace" | "web_page";
151
170
  title: string;
152
171
  url: string | null;
153
172
  description?: string | undefined;
@@ -183,6 +202,10 @@ descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginT
183
202
  cycle?: string | undefined;
184
203
  dueDate?: string | undefined;
185
204
  labels?: string[] | undefined;
205
+ trend?: {
206
+ label: string;
207
+ points: number[];
208
+ } | undefined;
186
209
  } | {
187
210
  type: "deployment";
188
211
  summary?: string | undefined;
@@ -205,6 +228,7 @@ descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginT
205
228
  summary?: string | undefined;
206
229
  owner?: string | undefined;
207
230
  modifiedAt?: string | undefined;
231
+ thumbnailUrl?: string | undefined;
208
232
  } | {
209
233
  type: "message";
210
234
  summary?: string | undefined;
@@ -216,7 +240,43 @@ descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginT
216
240
  summary?: string | undefined;
217
241
  siteName?: string | undefined;
218
242
  author?: string | undefined;
243
+ media?: "image" | "video" | undefined;
219
244
  thumbnailUrl?: string | undefined;
245
+ } | {
246
+ type: "chart";
247
+ summary?: string | undefined;
248
+ display: "area" | "bar" | "line";
249
+ yAxis: string;
250
+ range: string;
251
+ series: {
252
+ label: string;
253
+ points: number[];
254
+ }[];
255
+ } | {
256
+ type: "event";
257
+ summary?: string | undefined;
258
+ level?: string | undefined;
259
+ project?: string | undefined;
260
+ release?: string | undefined;
261
+ environment?: string | undefined;
262
+ occurredAt?: string | undefined;
263
+ } | {
264
+ type: "trace";
265
+ summary?: string | undefined;
266
+ rootOp?: string | undefined;
267
+ rootName?: string | undefined;
268
+ durationMs: number;
269
+ spanCount: number;
270
+ errorCount: number;
271
+ performanceIssueCount: number;
272
+ projects: string[];
273
+ spans: {
274
+ op?: string | undefined;
275
+ name: string;
276
+ startMs: number;
277
+ durationMs: number;
278
+ issue?: boolean | undefined;
279
+ }[];
220
280
  } | {
221
281
  type: "person";
222
282
  summary?: string | undefined;
@@ -252,4 +312,27 @@ descriptionDecider?: PluginDecider): import("@sentry/junior-plugin-api").PluginT
252
312
  title: string;
253
313
  url: string;
254
314
  target: "updatePullRequest";
315
+ }, {
316
+ actor?: Actor;
317
+ automationLink?: {
318
+ url: string;
319
+ };
320
+ conversationId?: string;
321
+ db: unknown;
322
+ decider: PluginDecider;
323
+ egress: PluginEgress;
324
+ log: PluginLogger;
325
+ events: {
326
+ canSubscribe: boolean;
327
+ };
328
+ conversationLink?: {
329
+ url: string;
330
+ };
331
+ source?: Source;
332
+ users: {
333
+ resolveActor(): Promise<{
334
+ identity?: Identity;
335
+ user?: User;
336
+ } | undefined>;
337
+ };
255
338
  }>;
package/dist/tools.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { PluginToolDefinition, ToolRegistrationHookContext } from "@sentry/junior-plugin-api";
1
+ import type { PluginToolDefinition } from "@sentry/junior-plugin-api";
2
2
  import type { GitHubPullRequestSubscriptionConfig } from "./events/pull-request.js";
3
3
  /** Opt-ins for GitHub plugin behavior that is still being tested. */
4
4
  export interface GitHubPluginExperiments {
@@ -9,5 +9,5 @@ export interface GitHubPluginExperiments {
9
9
  */
10
10
  pullRequestDescriptionChecks?: boolean;
11
11
  }
12
- /** Build the GitHub plugin's runtime tools from their per-tool modules. */
13
- export declare function createGitHubTools(ctx: ToolRegistrationHookContext, botEmail?: string, pullRequestSubscription?: GitHubPullRequestSubscriptionConfig, experimental?: GitHubPluginExperiments): Record<string, PluginToolDefinition>;
12
+ /** The GitHub plugin's tools for one deployment configuration. */
13
+ export declare function createGitHubTools(botEmail?: string, pullRequestSubscription?: GitHubPullRequestSubscriptionConfig, experimental?: GitHubPluginExperiments): Record<string, PluginToolDefinition>;
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * GitHub check suite events.
3
3
  */
4
- import type { EventInput, PluginLogger } from "@sentry/junior-plugin-api";
4
+ import type { EventInput, EventPublisher, PluginLogger } from "@sentry/junior-plugin-api";
5
5
  import type { GitHubStatusIncident } from "../github-status.js";
6
+ type CheckSuiteEventType = "pull_request.checks.failed" | "pull_request.checks.passed" | "pull_request.checks.recovered";
6
7
  export type GitHubFailingCheck = {
7
8
  checkRunId: number;
8
9
  conclusion: string;
@@ -20,6 +21,12 @@ export type GitHubCheckSuiteFacts = {
20
21
  failingChecks?: GitHubFailingCheck[];
21
22
  /** Open or recent githubstatus.com incidents when the suite failed. */
22
23
  githubIncidents?: GitHubStatusIncident[];
24
+ /**
25
+ * True when this suite passed and every other check suite on its head
26
+ * commit passed too. Set only when something listens for
27
+ * `pull_request.checks.passed`.
28
+ */
29
+ allCheckSuitesPassed?: boolean;
23
30
  /** Pull request values by number when a match filter needs them. */
24
31
  pullRequestFactsByNumber?: Record<number, GitHubCheckSuitePullRequestFacts>;
25
32
  };
@@ -36,7 +43,7 @@ export declare function buildCheckSuiteEvent(args: {
36
43
  openerUsername?: string;
37
44
  checkSuiteId?: number;
38
45
  deliveryId: string;
39
- eventType: "pull_request.checks.failed" | "pull_request.checks.recovered";
46
+ eventType: CheckSuiteEventType;
40
47
  failingChecks?: GitHubFailingCheck[];
41
48
  githubIncidents?: GitHubStatusIncident[];
42
49
  headBranch?: string;
@@ -67,12 +74,26 @@ export declare function parseCheckSuitePublishTargets(body: unknown): {
67
74
  eventTypes: string[];
68
75
  identifiers: string[];
69
76
  } | undefined;
77
+ /**
78
+ * True when a Watch or event automation may want `pull_request.checks.passed`
79
+ * for this check suite, so the webhook reads the other suites on the commit
80
+ * only then. A filter on a value that loads later counts as a match, so the
81
+ * check never drops an Event that someone wants.
82
+ */
83
+ export declare function wantsCheckSuitePassed(args: {
84
+ body: unknown;
85
+ deliveryId: string;
86
+ hasMatch: EventPublisher["hasMatch"];
87
+ neededMatchKeys: EventPublisher["neededMatchKeys"];
88
+ }): Promise<boolean>;
70
89
  /** Read which check suite values still need a GitHub API load. */
71
90
  export declare function parseCheckSuiteFactsTarget(body: unknown, options?: {
91
+ loadCheckSuites?: boolean;
72
92
  loadPullRequestFacts?: boolean;
73
93
  }): {
74
94
  checkSuiteId: number;
75
95
  headSha: string;
96
+ loadCheckSuites: boolean;
76
97
  loadFailingChecks: boolean;
77
98
  loadPullRequestFacts: boolean;
78
99
  owner: string;
@@ -81,14 +102,20 @@ export declare function parseCheckSuiteFactsTarget(body: unknown, options?: {
81
102
  } | undefined;
82
103
  /** True when active match filters need pull request fields from the API. */
83
104
  export declare function needsCheckSuitePullRequestFacts(matchKeys: Iterable<string>): boolean;
84
- /** Load failed check runs and optional pull request match fields. */
105
+ /**
106
+ * Load failed check runs, whether every check suite on the commit passed,
107
+ * and optional pull request match fields.
108
+ */
85
109
  export declare function loadCheckSuiteFacts(args: {
86
110
  appIdEnv: string;
87
111
  body: unknown;
88
112
  installationIdEnv: string;
113
+ /** Read the other suites on the commit for `pull_request.checks.passed`. */
114
+ loadCheckSuites?: boolean;
89
115
  /** Open or recent githubstatus.com incidents, shared through a cache. */
90
116
  loadGitHubIncidents?(): Promise<GitHubStatusIncident[]>;
91
117
  loadPullRequestFacts?: boolean;
92
118
  log?: Pick<PluginLogger, "error" | "warn">;
93
119
  privateKeyEnv: string;
94
120
  }): Promise<GitHubCheckSuiteFacts | undefined>;
121
+ export {};
@@ -40,6 +40,8 @@ export declare function createGitHubWebhookRoute(args: {
40
40
  loadGitHubIncidents?(): Promise<GitHubStatusIncident[]>;
41
41
  /** Read one pull request for its mergeability. */
42
42
  loadPullRequest?(pullRequest: GitHubPullRequestRef): Promise<unknown>;
43
+ /** Read one pull request's history for the merge conflict policy. */
44
+ loadPullRequestConflictHistory?(pullRequest: GitHubPullRequestRef): Promise<unknown>;
43
45
  /** Load a repository role for `openerRole`. */
44
46
  loadRepositoryRole?(target: GitHubRoleTarget): Promise<string>;
45
47
  /** Linked GitHub login of the user of one Junior identity, if any. */
@@ -43,6 +43,11 @@ export declare function searchOpenPullRequestMergeability(env: GitHubInstallatio
43
43
  author: string;
44
44
  repositoryFullName: string;
45
45
  }): Promise<unknown>;
46
+ /** Read the merge conflict history of one pull request, with a read-only token. */
47
+ export declare function loadPullRequestConflictHistory(env: GitHubInstallationEnv, pullRequest: {
48
+ number: number;
49
+ repositoryFullName: string;
50
+ }): Promise<unknown>;
46
51
  /** Ask people to review one pull request, with a pull request write token. */
47
52
  export declare function requestPullRequestReviewers(env: GitHubInstallationEnv, input: {
48
53
  number: number;
@@ -65,7 +70,7 @@ export declare function loadRepositoryRole(env: GitHubInstallationEnv, cache: Pl
65
70
  login: string;
66
71
  repositoryFullName: string;
67
72
  }): Promise<string>;
68
- /** The pull request facts that decide whether it is ready to merge. */
73
+ /** The pull request facts that decide its next action. */
69
74
  export interface GitHubPullRequestMergeState {
70
75
  /**
71
76
  * At least one approval, and no reviewer still requests changes. Read
@@ -81,6 +86,8 @@ export interface GitHubPullRequestMergeState {
81
86
  * are no conflicts. Undefined when GitHub has not computed it yet.
82
87
  */
83
88
  mergeableState?: string;
89
+ /** Logins of the people whose review GitHub still requests. */
90
+ requestedReviewers: string[];
84
91
  state: "closed" | "merged" | "open";
85
92
  title: string;
86
93
  url: string;
@@ -9,7 +9,8 @@
9
9
  * check of the repository's open Junior pull requests. See
10
10
  * `merge-conflict-checks/`.
11
11
  */
12
- import type { EventInput, EventPublisher, PluginLogger } from "@sentry/junior-plugin-api";
12
+ import type { EventInput, EventPublisher, PluginConversationReviewItems, PluginLogger } from "@sentry/junior-plugin-api";
13
+ import type { GitHubDb } from "../db/database.js";
13
14
  /** Values that GitHub reports for a conflicted pull request. */
14
15
  export interface GitHubMergeConflict {
15
16
  baseBranch: string;
@@ -35,14 +36,18 @@ export declare function gitHubMergeConflictEvents(input: GitHubPullRequestRef &
35
36
  * GitHub reports a conflict. A `pull_request` webhook payload gives the
36
37
  * mergeability when GitHub knows it. Otherwise the check reads the pull
37
38
  * request, which also makes GitHub calculate its mergeability. When GitHub
38
- * does not know it yet, a later event reads it again.
39
+ * does not know it yet, a later event reads it again. The policy in
40
+ * `merge-conflict-checks/policy.ts` decides if a conflict publishes.
39
41
  */
40
42
  export declare function loadGitHubMergeConflictEvents(args: {
43
+ db: GitHubDb;
41
44
  deliveryId: string;
42
45
  events: EventInput[];
43
46
  hasMatch: EventPublisher["hasMatch"];
44
47
  loadPullRequest?(ref: GitHubPullRequestRef): Promise<unknown>;
48
+ loadConflictHistory?(ref: GitHubPullRequestRef): Promise<unknown>;
45
49
  log?: Pick<PluginLogger, "error" | "warn">;
46
50
  /** The body of a `pull_request` webhook. */
47
51
  pullRequestPayload?: unknown;
52
+ reviewItems: PluginConversationReviewItems;
48
53
  }): Promise<EventInput[]>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The next action of a Junior pull request for its requester, and its one
3
+ * item on the review desk.
4
+ *
5
+ * The action derives from GitHub state. It is "merge" when the pull request
6
+ * is open, not a draft, approved, auto-merge is off, and GitHub's merge state
7
+ * is `clean`. Otherwise it is "review" when GitHub still asks the requester
8
+ * for a review. The requester takes one of them, not both, so one item per
9
+ * pull request shows the action. Each webhook that can change one of these
10
+ * facts reads them again from GitHub. Junior saves the derived action and
11
+ * changes the item only when the action changes.
12
+ *
13
+ * The item goes to the Conversation where a person asked Junior to open the
14
+ * pull request. It is assigned to that person only when they are in that
15
+ * Conversation, and it waits on them. Junior maps a GitHub login to a person
16
+ * only through the requester's linked GitHub account.
17
+ */
18
+ import type { PluginConversationReviewItems, PluginLogger } from "@sentry/junior-plugin-api";
19
+ import type { GitHubDb } from "../db/database.js";
20
+ import { type GitHubInstallationEnv } from "./installation-requests.js";
21
+ import type { GitHubPullRequestTarget } from "./pull-request-people.js";
22
+ /** Return the pull requests whose next action one webhook delivery can change. */
23
+ export declare function pullRequestActionTargets(eventName: string, body: unknown): GitHubPullRequestTarget[];
24
+ /**
25
+ * Add, change, or close the next-action item of each Junior pull request that
26
+ * a webhook delivery can change. The item is optional, so a failure is logged
27
+ * and does not fail the delivery.
28
+ */
29
+ export declare function syncGitHubPullRequestActions(args: {
30
+ db: GitHubDb;
31
+ deliveryId: string;
32
+ env: GitHubInstallationEnv;
33
+ loadGitHubLogin?(identityId: string): Promise<string | undefined>;
34
+ log?: Pick<PluginLogger, "error" | "warn">;
35
+ reviewItems: PluginConversationReviewItems;
36
+ targets: GitHubPullRequestTarget[];
37
+ }): Promise<void>;
@@ -0,0 +1,5 @@
1
+ -- `ready_to_merge_at` stays for one release, so workers from before this
2
+ -- migration keep working during the rollout. A later migration drops it.
3
+ -- `next_action` starts empty: the next check of each pull request derives
4
+ -- its action and moves an open item from the old keys to the new one.
5
+ ALTER TABLE "junior_github_pull_requests" ADD COLUMN "next_action" text;