@sentry/junior-github 0.298.0 → 0.300.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OK6BNAGC.js → chunk-YUF5P5I7.js} +50 -20
- package/dist/credential-support.d.ts +7 -0
- package/dist/db/schema.d.ts +34 -0
- package/dist/events/pull-request.d.ts +8 -2
- package/dist/graphql-documents.d.ts +31 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1532 -785
- package/dist/object-facts.d.ts +16 -1
- package/dist/plugin.d.ts +3 -0
- package/dist/pull-request-outcomes/apply.d.ts +3 -1
- package/dist/pull-request-outcomes/reconcile.d.ts +10 -5
- package/dist/pull-request-outcomes/store.d.ts +5 -0
- package/dist/pull-request-requesters/draft-reviewers.d.ts +15 -0
- package/dist/testing.js +1 -1
- package/dist/tool-support/attribution.d.ts +4 -2
- package/dist/tool-support/pull-request-description.d.ts +8 -0
- package/dist/tools/clone-repository.d.ts +70 -2
- package/dist/tools/comment-on-issue.d.ts +70 -2
- package/dist/tools/comment-on-pull-request.d.ts +70 -2
- package/dist/tools/create-issue.d.ts +70 -2
- package/dist/tools/create-pull-request.d.ts +75 -4
- package/dist/tools/get-deployment.d.ts +70 -2
- package/dist/tools/get-issue.d.ts +70 -2
- package/dist/tools/get-pull-request.d.ts +90 -2
- package/dist/tools/get-release.d.ts +70 -2
- package/dist/tools/get-repository.d.ts +70 -2
- package/dist/tools/get-status.d.ts +70 -2
- package/dist/tools/react-to-issue.d.ts +70 -2
- package/dist/tools/resolve-pull-request-review-thread.d.ts +70 -2
- package/dist/tools/submit-pull-request-review.d.ts +70 -2
- package/dist/tools/update-issue-comment.d.ts +70 -2
- package/dist/tools/update-issue.d.ts +70 -2
- package/dist/tools/update-pull-request-feedback.d.ts +70 -4
- package/dist/tools/update-pull-request.d.ts +74 -4
- package/dist/tools.d.ts +10 -1
- package/dist/webhooks/check-suite.d.ts +2 -4
- package/dist/webhooks/fail-open-log.d.ts +10 -0
- package/dist/webhooks/handler.d.ts +1 -1
- package/dist/webhooks/installation-requests.d.ts +12 -1
- package/dist/webhooks/merge-conflict.d.ts +1 -1
- package/dist/webhooks/pull-request-preview.d.ts +12 -0
- package/dist/webhooks/pull-request-ready-reviewers.d.ts +25 -0
- package/dist/webhooks/pull-request-ready.d.ts +1 -1
- package/migrations/0011_pull_request_draft.sql +1 -0
- package/migrations/meta/0011_snapshot.json +434 -0
- package/migrations/meta/_journal.json +7 -0
- package/package.json +7 -4
- package/skills/github-code/SKILL.md +1 -1
- package/skills/github-code/SPEC.md +1 -1
|
@@ -268,12 +268,13 @@ function gitHubPullRequestSubscription(config) {
|
|
|
268
268
|
if (config === false) return void 0;
|
|
269
269
|
return config ?? DEFAULT_PULL_REQUEST_SUBSCRIPTION;
|
|
270
270
|
}
|
|
271
|
-
var MERGE_STATE_CHECK = "Do not guess whether it can merge. Before you say anything about that,
|
|
271
|
+
var MERGE_STATE_CHECK = "Do not guess whether it can merge. Before you say anything about that, call github_getPullRequest and read its `checks`. If `checks.required` is `not_reported`, the required checks may not have started on the latest commit yet. It does not mean that none are required. If `checks.auto_merge` is true and only required checks remain, say only that it merges when they pass. If `checks.merge_state` shows that GitHub blocks it for another reason, run `gh api repos/OWNER/REPO/rules/branches/BASE` and name the rule that blocks it. Do not say that you did not merge it.";
|
|
272
272
|
var GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE = {
|
|
273
273
|
"pull_request.review.approved": `Mention each person in People involved, or the person who asked for the pull request if that line is missing. Say who approved it and link it. Do not merge it unless asked. ${MERGE_STATE_CHECK}`,
|
|
274
274
|
"pull_request.merged": "Mention each person in People involved, or the person who asked for the pull request if that line is missing. Say that it merged and link it."
|
|
275
275
|
};
|
|
276
|
-
|
|
276
|
+
var DRAFT_CHECKS_RECOVERED_GUIDANCE = "If the pull request is still a draft, call github_getPullRequest and read its `checks`. When `checks.required` is `passing` and no decision is open, in the pull request body or in an open review item that waits on the person who asked for it, mark it ready with github_updatePullRequest and draft false, and report that in the originating 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.";
|
|
277
|
+
function gitHubPullRequestCreateWatch(config, pullRequest) {
|
|
277
278
|
const outcomeEvents = Object.keys(
|
|
278
279
|
GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE
|
|
279
280
|
);
|
|
@@ -284,10 +285,14 @@ function gitHubPullRequestCreateWatch(config) {
|
|
|
284
285
|
// GitHub sends no webhook for a new conflict, so keep the pull
|
|
285
286
|
// request ready to merge even when the app config omits this event.
|
|
286
287
|
"pull_request.merge_conflict",
|
|
287
|
-
...outcomeEvents
|
|
288
|
+
...outcomeEvents,
|
|
289
|
+
...pullRequest.draft ? ["pull_request.checks.recovered"] : []
|
|
288
290
|
])
|
|
289
291
|
],
|
|
290
|
-
guidance:
|
|
292
|
+
guidance: pullRequest.draft ? {
|
|
293
|
+
...GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE,
|
|
294
|
+
"pull_request.checks.recovered": DRAFT_CHECKS_RECOVERED_GUIDANCE
|
|
295
|
+
} : GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE,
|
|
291
296
|
intent: config.intent
|
|
292
297
|
};
|
|
293
298
|
}
|
|
@@ -1076,9 +1081,11 @@ async function issueInstallationToken(options) {
|
|
|
1076
1081
|
const appJwt = createAppJwt(appId, options.privateKeyEnv);
|
|
1077
1082
|
const permissions = "permissions" in options ? options.permissions : typeof options.loadPermissions === "function" ? await options.loadPermissions({ appJwt, installationId }) : void 0;
|
|
1078
1083
|
const repositories = "repositories" in options ? options.repositories : void 0;
|
|
1084
|
+
const repositoryIds = "repositoryIds" in options ? options.repositoryIds : void 0;
|
|
1079
1085
|
const body = {
|
|
1080
1086
|
...permissions ? { permissions } : void 0,
|
|
1081
|
-
...repositories ? { repositories } : void 0
|
|
1087
|
+
...repositories ? { repositories } : void 0,
|
|
1088
|
+
...repositoryIds ? { repository_ids: repositoryIds } : void 0
|
|
1082
1089
|
};
|
|
1083
1090
|
const accessTokenResponse = await githubRequest(
|
|
1084
1091
|
"https://api.github.com",
|
|
@@ -1203,6 +1210,22 @@ function pullRequestTargets(event, repo) {
|
|
|
1203
1210
|
];
|
|
1204
1211
|
}
|
|
1205
1212
|
|
|
1213
|
+
// src/webhooks/fail-open-log.ts
|
|
1214
|
+
function logFailOpenFailure(log, message, error, metadata) {
|
|
1215
|
+
const attributes = {
|
|
1216
|
+
...metadata,
|
|
1217
|
+
errorType: error instanceof Error ? error.name : "UnknownError"
|
|
1218
|
+
};
|
|
1219
|
+
if (error instanceof GitHubRequestError && error.status >= 500) {
|
|
1220
|
+
log?.warn(message, {
|
|
1221
|
+
...attributes,
|
|
1222
|
+
"http.response.status_code": error.status
|
|
1223
|
+
});
|
|
1224
|
+
return;
|
|
1225
|
+
}
|
|
1226
|
+
log?.error(message, attributes);
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1206
1229
|
// src/webhooks/check-suite.ts
|
|
1207
1230
|
var CHECK_SUITE_PULL_REQUEST_MATCH_KEYS = /* @__PURE__ */ new Set([
|
|
1208
1231
|
"isDraft",
|
|
@@ -1580,9 +1603,8 @@ async function loadCheckSuiteFacts(args) {
|
|
|
1580
1603
|
});
|
|
1581
1604
|
if (failing.length > 0) facts.failingChecks = failing;
|
|
1582
1605
|
} catch (error) {
|
|
1583
|
-
args.log
|
|
1606
|
+
logFailOpenFailure(args.log, "GitHub check suite load failed", error, {
|
|
1584
1607
|
checkSuiteId: target.checkSuiteId,
|
|
1585
|
-
errorType: error instanceof Error ? error.name : "UnknownError",
|
|
1586
1608
|
repository: `${target.owner}/${target.repoName}`
|
|
1587
1609
|
});
|
|
1588
1610
|
}
|
|
@@ -1592,9 +1614,7 @@ async function loadCheckSuiteFacts(args) {
|
|
|
1592
1614
|
const incidents = await args.loadGitHubIncidents();
|
|
1593
1615
|
if (incidents.length > 0) facts.githubIncidents = incidents;
|
|
1594
1616
|
} catch (error) {
|
|
1595
|
-
args.log
|
|
1596
|
-
errorType: error instanceof Error ? error.name : "UnknownError"
|
|
1597
|
-
});
|
|
1617
|
+
logFailOpenFailure(args.log, "GitHub status load failed", error, {});
|
|
1598
1618
|
}
|
|
1599
1619
|
}
|
|
1600
1620
|
if (target.loadPullRequestFacts) {
|
|
@@ -1618,11 +1638,15 @@ async function loadCheckSuiteFacts(args) {
|
|
|
1618
1638
|
return loadedFacts ? [number5, loadedFacts] : void 0;
|
|
1619
1639
|
} catch (error) {
|
|
1620
1640
|
if (!isGitHubNotFoundError(error)) {
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1641
|
+
logFailOpenFailure(
|
|
1642
|
+
args.log,
|
|
1643
|
+
"GitHub pull request data load failed",
|
|
1644
|
+
error,
|
|
1645
|
+
{
|
|
1646
|
+
pullRequest: number5,
|
|
1647
|
+
repository: `${target.owner}/${target.repoName}`
|
|
1648
|
+
}
|
|
1649
|
+
);
|
|
1626
1650
|
}
|
|
1627
1651
|
return void 0;
|
|
1628
1652
|
}
|
|
@@ -1637,11 +1661,15 @@ async function loadCheckSuiteFacts(args) {
|
|
|
1637
1661
|
facts.pullRequestFactsByNumber = pullRequestFactsByNumber;
|
|
1638
1662
|
}
|
|
1639
1663
|
} catch (error) {
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1664
|
+
logFailOpenFailure(
|
|
1665
|
+
args.log,
|
|
1666
|
+
"GitHub check suite pull request data load failed",
|
|
1667
|
+
error,
|
|
1668
|
+
{
|
|
1669
|
+
checkSuiteId: target.checkSuiteId,
|
|
1670
|
+
repository: `${target.owner}/${target.repoName}`
|
|
1671
|
+
}
|
|
1672
|
+
);
|
|
1645
1673
|
}
|
|
1646
1674
|
}
|
|
1647
1675
|
return facts.failingChecks || facts.pullRequestFactsByNumber ? facts : void 0;
|
|
@@ -2455,6 +2483,7 @@ export {
|
|
|
2455
2483
|
HTTP_READ_METHODS,
|
|
2456
2484
|
CREATE_TOOL_ROUTING_GUIDANCE,
|
|
2457
2485
|
USER_WRITE_REQUIREMENTS,
|
|
2486
|
+
GitHubRequestError,
|
|
2458
2487
|
isRecord,
|
|
2459
2488
|
readEnv,
|
|
2460
2489
|
requireEnv,
|
|
@@ -2468,6 +2497,7 @@ export {
|
|
|
2468
2497
|
createPermissionCache,
|
|
2469
2498
|
definedValues,
|
|
2470
2499
|
pullRequestTargets,
|
|
2500
|
+
logFailOpenFailure,
|
|
2471
2501
|
checkSuitePullRequests,
|
|
2472
2502
|
parseCheckSuitePublishTargets,
|
|
2473
2503
|
needsCheckSuitePullRequestFacts,
|
|
@@ -26,10 +26,12 @@ type InstallationCredentialOptions = InstallationCredentialBaseOptions & ({
|
|
|
26
26
|
loadPermissions?: never;
|
|
27
27
|
permissions?: GitHubAppPermissions;
|
|
28
28
|
repositories?: string[];
|
|
29
|
+
repositoryIds?: number[];
|
|
29
30
|
} | {
|
|
30
31
|
loadPermissions: LoadInstallationReadPermissions;
|
|
31
32
|
permissions?: never;
|
|
32
33
|
repositories?: never;
|
|
34
|
+
repositoryIds?: never;
|
|
33
35
|
});
|
|
34
36
|
type LoadInstallationReadPermissions = (input: {
|
|
35
37
|
appJwt: string;
|
|
@@ -50,6 +52,11 @@ export declare const HTTP_READ_METHODS: Set<string>;
|
|
|
50
52
|
export declare const USER_TOKEN_GRANTS: Set<string>;
|
|
51
53
|
export declare const CREATE_TOOL_ROUTING_GUIDANCE = "This is a tool-routing denial, not a GitHub permission failure. Do not ask the user for GitHub permissions; retry with the required tool.";
|
|
52
54
|
export declare const USER_WRITE_REQUIREMENTS: string[];
|
|
55
|
+
/** A GitHub API response with an error status. */
|
|
56
|
+
export declare class GitHubRequestError extends Error {
|
|
57
|
+
status: number;
|
|
58
|
+
constructor(message: string, status: number);
|
|
59
|
+
}
|
|
53
60
|
export declare class GitHubPluginSetupError extends Error {
|
|
54
61
|
constructor(message: string);
|
|
55
62
|
}
|
package/dist/db/schema.d.ts
CHANGED
|
@@ -384,6 +384,23 @@ export declare const juniorGitHubPullRequests: import("drizzle-orm/pg-core").PgT
|
|
|
384
384
|
}, {}, {}, import("drizzle-orm").ColumnBuilderExtraConfig>;
|
|
385
385
|
size: undefined;
|
|
386
386
|
}>;
|
|
387
|
+
draft: import("drizzle-orm/pg-core").PgColumn<{
|
|
388
|
+
name: "draft";
|
|
389
|
+
tableName: "junior_github_pull_requests";
|
|
390
|
+
dataType: "boolean";
|
|
391
|
+
columnType: "PgBoolean";
|
|
392
|
+
data: boolean;
|
|
393
|
+
driverParam: boolean;
|
|
394
|
+
notNull: true;
|
|
395
|
+
hasDefault: true;
|
|
396
|
+
isPrimaryKey: false;
|
|
397
|
+
isAutoincrement: false;
|
|
398
|
+
hasRuntimeDefault: false;
|
|
399
|
+
enumValues: undefined;
|
|
400
|
+
baseColumn: never;
|
|
401
|
+
identity: undefined;
|
|
402
|
+
generated: undefined;
|
|
403
|
+
}, {}, {}>;
|
|
387
404
|
openedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
388
405
|
name: "opened_at";
|
|
389
406
|
tableName: "junior_github_pull_requests";
|
|
@@ -1227,6 +1244,23 @@ export declare const githubSqlSchema: {
|
|
|
1227
1244
|
}, {}, {}, import("drizzle-orm").ColumnBuilderExtraConfig>;
|
|
1228
1245
|
size: undefined;
|
|
1229
1246
|
}>;
|
|
1247
|
+
draft: import("drizzle-orm/pg-core").PgColumn<{
|
|
1248
|
+
name: "draft";
|
|
1249
|
+
tableName: "junior_github_pull_requests";
|
|
1250
|
+
dataType: "boolean";
|
|
1251
|
+
columnType: "PgBoolean";
|
|
1252
|
+
data: boolean;
|
|
1253
|
+
driverParam: boolean;
|
|
1254
|
+
notNull: true;
|
|
1255
|
+
hasDefault: true;
|
|
1256
|
+
isPrimaryKey: false;
|
|
1257
|
+
isAutoincrement: false;
|
|
1258
|
+
hasRuntimeDefault: false;
|
|
1259
|
+
enumValues: undefined;
|
|
1260
|
+
baseColumn: never;
|
|
1261
|
+
identity: undefined;
|
|
1262
|
+
generated: undefined;
|
|
1263
|
+
}, {}, {}>;
|
|
1230
1264
|
openedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
1231
1265
|
name: "opened_at";
|
|
1232
1266
|
tableName: "junior_github_pull_requests";
|
|
@@ -20,8 +20,14 @@ export interface GitHubPullRequestSubscriptionConfig {
|
|
|
20
20
|
}
|
|
21
21
|
/** Resolve the Watch to create after Junior creates a pull request, if any. */
|
|
22
22
|
export declare function gitHubPullRequestSubscription(config: GitHubPullRequestSubscriptionConfig | false | undefined): GitHubPullRequestSubscriptionConfig | undefined;
|
|
23
|
-
/**
|
|
24
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Build the Watch created after Junior creates a pull request. Only a draft
|
|
25
|
+
* Watch gets passing checks, so a ready pull request is not woken by each
|
|
26
|
+
* passing check suite.
|
|
27
|
+
*/
|
|
28
|
+
export declare function gitHubPullRequestCreateWatch(config: GitHubPullRequestSubscriptionConfig, pullRequest: {
|
|
29
|
+
draft: boolean;
|
|
30
|
+
}): {
|
|
25
31
|
events: GitHubPullRequestEvent[];
|
|
26
32
|
guidance: Partial<Record<GitHubPullRequestEvent, string>>;
|
|
27
33
|
intent: string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The `operationName` and `query` of one GraphQL request body. */
|
|
2
|
+
export interface GitHubGraphqlOperation {
|
|
3
|
+
operationName: string;
|
|
4
|
+
query: string;
|
|
5
|
+
}
|
|
6
|
+
/** Add one reaction to a review body. */
|
|
7
|
+
export declare const ADD_REVIEW_REACTION: GitHubGraphqlOperation;
|
|
8
|
+
/** Remove one reaction from a review body. */
|
|
9
|
+
export declare const REMOVE_REVIEW_REACTION: GitHubGraphqlOperation;
|
|
10
|
+
/** Read the reactions of a review body, with the bots that added them. */
|
|
11
|
+
export declare const REVIEW_REACTIONS: GitHubGraphqlOperation;
|
|
12
|
+
/** Mark a draft pull request ready for review. */
|
|
13
|
+
export declare const MARK_PULL_REQUEST_READY_FOR_REVIEW: GitHubGraphqlOperation;
|
|
14
|
+
/** Convert a pull request to a draft. */
|
|
15
|
+
export declare const CONVERT_PULL_REQUEST_TO_DRAFT: GitHubGraphqlOperation;
|
|
16
|
+
/** Read a review thread with the pull request that owns it. */
|
|
17
|
+
export declare const REVIEW_THREAD_OWNERSHIP: GitHubGraphqlOperation;
|
|
18
|
+
/** Resolve a review thread. */
|
|
19
|
+
export declare const RESOLVE_REVIEW_THREAD: GitHubGraphqlOperation;
|
|
20
|
+
/**
|
|
21
|
+
* Read the merge state of one pull request and the checks of its head
|
|
22
|
+
* commit, with whether each check is required.
|
|
23
|
+
*/
|
|
24
|
+
export declare const PULL_REQUEST_CHECKS: GitHubGraphqlOperation;
|
|
25
|
+
/** Read one page of a pull request search, with mergeability. */
|
|
26
|
+
export declare const OPEN_PULL_REQUEST_MERGEABILITY: GitHubGraphqlOperation;
|
|
27
|
+
/**
|
|
28
|
+
* Return the query that reads the lifecycle of `count` pull requests of one
|
|
29
|
+
* repository. Pull request `i` has the alias `pr<i>` and the variable `$n<i>`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function pullRequestLifecycles(count: number): GitHubGraphqlOperation;
|
package/dist/index.d.ts
CHANGED