@sentry/junior-github 0.303.0 → 0.305.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-CrbJHQ0w.js → events-DGd7UVVs.js} +8 -22
- package/dist/index.js +23 -16
- package/dist/testing.js +1 -1
- package/package.json +2 -2
|
@@ -286,7 +286,7 @@ const GITHUB_PULL_REQUEST_EVENTS = [
|
|
|
286
286
|
* after a merge, but it stops at a conflict and sends no event for it.
|
|
287
287
|
*/
|
|
288
288
|
const STACK_CHECK = "Check if the pull request is in a stack: `gh api 'repos/OWNER/REPO/stacks?pull_request=NUMBER'`.";
|
|
289
|
-
const STACK_CONFLICT_STEPS = "run `gh stack rebase`, resolve each conflict so that both changes stay intact, stage the files, and run `gh stack rebase --continue`. Run the checks again, run `gh stack push`, and confirm that each open pull request in the stack can merge.
|
|
289
|
+
const STACK_CONFLICT_STEPS = "run `gh stack rebase`, resolve each conflict so that both changes stay intact, stage the files, and run `gh stack rebase --continue`. Run the checks again, run `gh stack push`, and confirm that each open pull request in the stack can merge.";
|
|
290
290
|
/**
|
|
291
291
|
* Every comment on a pull request gets the same feedback status: a
|
|
292
292
|
* conversation comment, an inline review comment, and a review body. A review
|
|
@@ -300,7 +300,7 @@ const GITHUB_PULL_REQUEST_EVENT_GUIDANCE = {
|
|
|
300
300
|
"pull_request.review.commented": PULL_REQUEST_FEEDBACK,
|
|
301
301
|
"pull_request.comment.created": PULL_REQUEST_FEEDBACK,
|
|
302
302
|
"pull_request.review_comment.created": `${PULL_REQUEST_FEEDBACK} Then resolve the thread with github_resolvePullRequestReviewThread.`,
|
|
303
|
-
"pull_request.merge_conflict": `${STACK_CHECK} If it is, run \`gh stack checkout NUMBER\`, then ${STACK_CONFLICT_STEPS} If it is not, fetch base_branch from Verified details and merge it into the pull request branch. Do not rebase. Resolve each conflict so that both the pull request change and the base branch change stay intact. Run the checks again, push, and confirm that the pull request can merge
|
|
303
|
+
"pull_request.merge_conflict": `${STACK_CHECK} If it is, run \`gh stack checkout NUMBER\`, then ${STACK_CONFLICT_STEPS} If it is not, fetch base_branch from Verified details and merge it into the pull request branch. Do not rebase. Resolve each conflict so that both the pull request change and the base branch change stay intact. Run the checks again, push, and confirm that the pull request can merge.`
|
|
304
304
|
};
|
|
305
305
|
/** Combine provider defaults with app guidance for pull request events. */
|
|
306
306
|
function gitHubPullRequestEventGuidance(guidance) {
|
|
@@ -316,17 +316,19 @@ function gitHubPullRequestEventGuidance(guidance) {
|
|
|
316
316
|
/**
|
|
317
317
|
* Junior maintains the pull requests it creates. The pull request is its own
|
|
318
318
|
* work, so it answers and fixes review feedback without asking first.
|
|
319
|
+
* GitHub already tells people about reviews, approvals, merges, and closes,
|
|
320
|
+
* and the review desk shows the next action. So the Watch skips those
|
|
321
|
+
* outcomes and posts in the thread only when a person must act.
|
|
319
322
|
*/
|
|
320
323
|
const DEFAULT_PULL_REQUEST_SUBSCRIPTION = {
|
|
321
324
|
events: [
|
|
322
325
|
"pull_request.checks.failed",
|
|
323
|
-
"pull_request.closed_unmerged",
|
|
324
326
|
"pull_request.comment.created",
|
|
325
327
|
"pull_request.review.changes_requested",
|
|
326
328
|
"pull_request.review.commented",
|
|
327
329
|
"pull_request.review_comment.created"
|
|
328
330
|
],
|
|
329
|
-
intent: "Maintain pull requests
|
|
331
|
+
intent: "Maintain pull requests that you create. For actionable review feedback, failed checks, or merge conflicts, inspect the evidence, make scoped fixes, verify them, and push, without asking first. Do not merge it: a person merges it, even when a review says to ship it. Reply on GitHub to review comments and questions, in the thread where they were asked. Post in the originating thread only when a person must decide or act, such as a blocker that you cannot fix. Do not post status updates: GitHub already shows reviews, approvals, fixes, and replies."
|
|
330
332
|
};
|
|
331
333
|
/** Resolve the Watch to create after Junior creates a pull request, if any. */
|
|
332
334
|
function gitHubPullRequestSubscription(config) {
|
|
@@ -334,17 +336,6 @@ function gitHubPullRequestSubscription(config) {
|
|
|
334
336
|
return config ?? DEFAULT_PULL_REQUEST_SUBSCRIPTION;
|
|
335
337
|
}
|
|
336
338
|
/**
|
|
337
|
-
* Watch guidance for outcomes that the people involved need to hear about.
|
|
338
|
-
* The Watch made after Junior creates a pull request always receives these
|
|
339
|
-
* events. The webhook adds the people involved in the pull request to them.
|
|
340
|
-
* A merge does not ask the agent to check for a stack: GitHub rebases the
|
|
341
|
-
* next pull request in a stack itself, and most merges are not stacked.
|
|
342
|
-
*/
|
|
343
|
-
const GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE = {
|
|
344
|
-
"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. 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.`,
|
|
345
|
-
"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."
|
|
346
|
-
};
|
|
347
|
-
/**
|
|
348
339
|
* Junior finishes its own drafts. Passing checks start no other step, so the
|
|
349
340
|
* Watch of a draft also gets them. Marking the pull request ready sends the
|
|
350
341
|
* review request. GitHub also asks the code owners then, so a draft with code
|
|
@@ -353,25 +344,20 @@ const GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE = {
|
|
|
353
344
|
* Each passing suite wakes the Watch, so a suite that leaves the required
|
|
354
345
|
* checks unfinished must stay silent, or every suite posts.
|
|
355
346
|
*/
|
|
356
|
-
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 review item that waits on the person who asked for it: mark it ready with github_updatePullRequest and draft false,
|
|
347
|
+
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 review 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: marking it ready would ask the code owners to review, or break the AGENTS.md rule. Tell the person who asked for it in the originating thread that the checks pass and the draft waits for their review, and name why: the code owners that marking it ready asks, or the AGENTS.md rule. If you already told them for this head commit, stay silent. 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.";
|
|
357
348
|
/**
|
|
358
349
|
* Build the Watch created after Junior creates a pull request. Only a draft
|
|
359
350
|
* Watch gets passing checks, so a ready pull request is not woken by each
|
|
360
351
|
* passing check suite.
|
|
361
352
|
*/
|
|
362
353
|
function gitHubPullRequestCreateWatch(config, pullRequest) {
|
|
363
|
-
const outcomeEvents = Object.keys(GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE);
|
|
364
354
|
return {
|
|
365
355
|
events: [.../* @__PURE__ */ new Set([
|
|
366
356
|
...config.events,
|
|
367
357
|
"pull_request.merge_conflict",
|
|
368
|
-
...outcomeEvents,
|
|
369
358
|
...pullRequest.draft ? ["pull_request.checks.recovered"] : []
|
|
370
359
|
])],
|
|
371
|
-
|
|
372
|
-
...GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE,
|
|
373
|
-
"pull_request.checks.recovered": DRAFT_CHECKS_RECOVERED_GUIDANCE
|
|
374
|
-
} : GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE,
|
|
360
|
+
...pullRequest.draft ? { guidance: { "pull_request.checks.recovered": DRAFT_CHECKS_RECOVERED_GUIDANCE } } : void 0,
|
|
375
361
|
intent: config.intent
|
|
376
362
|
};
|
|
377
363
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as GITHUB_DEPLOYMENT_EVENTS, A as requireEnv, B as GITHUB_RELEASE_MATCH_FIELDS, C as githubRequest, D as listVerifiedUserEmails, E as issueInstallationToken, F as GITHUB_REPOSITORY_EVENTS, G as GITHUB_PULL_REQUEST_IDENTIFIER, H as GITHUB_RELEASE_SUGGESTED_EVENTS, I as GITHUB_REPOSITORY_IDENTIFIER, J as gitHubPullRequestCreateWatch, K as GITHUB_PULL_REQUEST_MATCH_FIELDS, L as GITHUB_REPOSITORY_SUGGESTED_EVENTS, M as botLoginFromEmail, N as botUserIdFromEmail, O as normalizeScopeList, P as isBotLogin, Q as gitHubPullRequestSubscription, R as gitHubRepositorySubscribable, S as githubRepositoryFromUrl, T as issueGitHubCredential, U as gitHubReleaseSourceSubscribable, V as GITHUB_RELEASE_SOURCE_IDENTIFIER, W as GITHUB_PULL_REQUEST_EVENTS, X as gitHubPullRequestResource, Y as gitHubPullRequestEventGuidance, Z as gitHubPullRequestSubscribable, a as needsCheckSuitePullRequestFacts, at as GITHUB_ISSUE_IDENTIFIER, b as USER_WRITE_REQUIREMENTS, c as logFailOpenFailure, ct as gitHubIssueSubscribable, d as CREATE_TOOL_ROUTING_GUIDANCE, dt as readGrantPermissions, et as GITHUB_DEPLOYMENT_MATCH_FIELDS, g as GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES, h as GITHUB_AUTH_TOKEN_PLACEHOLDER, i as loadCheckSuiteFacts, it as GITHUB_ISSUE_EVENTS, j as resolveUserAccount, k as readEnv, l as definedValues, lt as gitHubRepoDataSchema, m as GITHUB_AUTH_TOKEN_ENV, n as normalizeGitHubEvents, nt as GITHUB_DEPLOYMENT_SUGGESTED_EVENTS, o as parseCheckSuitePublishTargets, ot as GITHUB_ISSUE_MATCH_FIELDS, q as GITHUB_PULL_REQUEST_SUGGESTED_EVENTS, r as checkSuitePullRequests, rt as gitHubDeploymentSourceSubscribable, s as wantsCheckSuitePassed, st as GITHUB_ISSUE_SUGGESTED_EVENTS, t as gitHubPullRequestTerminalEvents, tt as GITHUB_DEPLOYMENT_SOURCE_IDENTIFIER, u as pullRequestTargets, ut as normalizePermissions, v as GitHubRequestError, w as isRecord$1, x as createPermissionCache, y as HTTP_READ_METHODS, z as GITHUB_RELEASE_EVENTS } from "./events-
|
|
1
|
+
import { $ as GITHUB_DEPLOYMENT_EVENTS, A as requireEnv, B as GITHUB_RELEASE_MATCH_FIELDS, C as githubRequest, D as listVerifiedUserEmails, E as issueInstallationToken, F as GITHUB_REPOSITORY_EVENTS, G as GITHUB_PULL_REQUEST_IDENTIFIER, H as GITHUB_RELEASE_SUGGESTED_EVENTS, I as GITHUB_REPOSITORY_IDENTIFIER, J as gitHubPullRequestCreateWatch, K as GITHUB_PULL_REQUEST_MATCH_FIELDS, L as GITHUB_REPOSITORY_SUGGESTED_EVENTS, M as botLoginFromEmail, N as botUserIdFromEmail, O as normalizeScopeList, P as isBotLogin, Q as gitHubPullRequestSubscription, R as gitHubRepositorySubscribable, S as githubRepositoryFromUrl, T as issueGitHubCredential, U as gitHubReleaseSourceSubscribable, V as GITHUB_RELEASE_SOURCE_IDENTIFIER, W as GITHUB_PULL_REQUEST_EVENTS, X as gitHubPullRequestResource, Y as gitHubPullRequestEventGuidance, Z as gitHubPullRequestSubscribable, a as needsCheckSuitePullRequestFacts, at as GITHUB_ISSUE_IDENTIFIER, b as USER_WRITE_REQUIREMENTS, c as logFailOpenFailure, ct as gitHubIssueSubscribable, d as CREATE_TOOL_ROUTING_GUIDANCE, dt as readGrantPermissions, et as GITHUB_DEPLOYMENT_MATCH_FIELDS, g as GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES, h as GITHUB_AUTH_TOKEN_PLACEHOLDER, i as loadCheckSuiteFacts, it as GITHUB_ISSUE_EVENTS, j as resolveUserAccount, k as readEnv, l as definedValues, lt as gitHubRepoDataSchema, m as GITHUB_AUTH_TOKEN_ENV, n as normalizeGitHubEvents, nt as GITHUB_DEPLOYMENT_SUGGESTED_EVENTS, o as parseCheckSuitePublishTargets, ot as GITHUB_ISSUE_MATCH_FIELDS, q as GITHUB_PULL_REQUEST_SUGGESTED_EVENTS, r as checkSuitePullRequests, rt as gitHubDeploymentSourceSubscribable, s as wantsCheckSuitePassed, st as GITHUB_ISSUE_SUGGESTED_EVENTS, t as gitHubPullRequestTerminalEvents, tt as GITHUB_DEPLOYMENT_SOURCE_IDENTIFIER, u as pullRequestTargets, ut as normalizePermissions, v as GitHubRequestError, w as isRecord$1, x as createPermissionCache, y as HTTP_READ_METHODS, z as GITHUB_RELEASE_EVENTS } from "./events-DGd7UVVs.js";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import { EgressAuthRequired, EgressPolicyDenied, OBJECT_FACTS_MAX_BYTES, PluginToolInputError, decodeObjectImageRef, defineJuniorPlugin, definePluginTool, enforceEgressPolicy, mergeEventMatchFields, objectFactsBytes, objectFactsMatchType, objectFactsSchema, parseShellCommands, pluginToolOutputSchema, subscribableResourceSchema, watchResultSchema } from "@sentry/junior-plugin-api";
|
|
4
4
|
import { lexer, walkTokens } from "marked";
|
|
@@ -98,17 +98,24 @@ function repositoryName(annotation) {
|
|
|
98
98
|
/** Return GitHub annotations for a conversation row, newest first. */
|
|
99
99
|
function githubSidebarAnnotations(annotations) {
|
|
100
100
|
return annotations.flatMap((annotation) => {
|
|
101
|
-
const status = annotation.status;
|
|
102
101
|
const label = repositoryName(annotation);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
if (!label) return [];
|
|
103
|
+
const sidebar = {
|
|
104
|
+
objectType: githubObjectType(annotation),
|
|
105
|
+
status: annotation.status,
|
|
106
|
+
key: annotation.key,
|
|
107
|
+
label
|
|
108
|
+
};
|
|
109
|
+
if (annotation.kind === "object") {
|
|
110
|
+
sidebar.title = annotation.title;
|
|
111
|
+
const image = annotation.facts?.type === "code_change" ? annotation.facts.previewImageUrls?.[0] : void 0;
|
|
112
|
+
if (image) sidebar.imageUrl = image;
|
|
113
|
+
}
|
|
114
|
+
if (annotation.url) sidebar.url = annotation.url;
|
|
115
|
+
return [{
|
|
116
|
+
annotation: sidebar,
|
|
110
117
|
updatedAt: annotation.updatedAt
|
|
111
|
-
}]
|
|
118
|
+
}];
|
|
112
119
|
}).sort((left, right) => right.updatedAt.localeCompare(left.updatedAt)).map(({ annotation }) => annotation);
|
|
113
120
|
}
|
|
114
121
|
/** Return the Annotation key of a GitHub issue or pull request. */
|
|
@@ -1886,7 +1893,7 @@ var GitHubPullRequestCreateRejectedError = class extends Error {
|
|
|
1886
1893
|
this.status = status;
|
|
1887
1894
|
}
|
|
1888
1895
|
};
|
|
1889
|
-
const REVIEWERS_DESCRIPTION = "GitHub logins to ask for a review. Set this only when the person names who should review. Without it,
|
|
1896
|
+
const REVIEWERS_DESCRIPTION = "GitHub logins to ask for a review. Set this only when the person names who should review. Without it, the tool asks the requester's linked GitHub account. A draft gets the request when it becomes ready for review.";
|
|
1890
1897
|
const createPullRequestInputSchema = Type.Object({
|
|
1891
1898
|
repo: Type.String({ description: "Repository in \"owner/name\" format." }),
|
|
1892
1899
|
title: Type.String({ description: "Pull request title." }),
|
|
@@ -3078,7 +3085,7 @@ const gitHubUpdateIssueTool = definePluginTool({
|
|
|
3078
3085
|
const repo = parseRepo$1(update.repo);
|
|
3079
3086
|
const requester = update.body !== void 0 || update.assign_requester ? await resolveGitHubRequester(ctx) : void 0;
|
|
3080
3087
|
const assignee = update.assign_requester ? linkedGitHubLogin(requester?.user) : void 0;
|
|
3081
|
-
if (update.assign_requester && !assignee) throw new PluginToolInputError("The requester has no linked GitHub account, so
|
|
3088
|
+
if (update.assign_requester && !assignee) throw new PluginToolInputError("The requester has no linked GitHub account, so the issue cannot be assigned to them.");
|
|
3082
3089
|
const currentBody = update.body !== void 0 ? await readGitHubBody(ctx.egress, {
|
|
3083
3090
|
operation: "github.issue.get",
|
|
3084
3091
|
path: `${repoPath(repo)}/issues/${update.number}`
|
|
@@ -4660,10 +4667,10 @@ async function addNotice(args, fixes) {
|
|
|
4660
4667
|
if (!opener?.conversationId) return;
|
|
4661
4668
|
const url = conflict.url ?? `https://github.com/${ref.repositoryFullName}/pull/${ref.number}`;
|
|
4662
4669
|
const name = title ? `**${title}**` : "This pull request";
|
|
4663
|
-
const reason = fixes >= MAX_FIXES ? `
|
|
4670
|
+
const reason = fixes >= MAX_FIXES ? `conflicts were already fixed ${fixes} times` : "nobody worked on it in the last 2 days";
|
|
4664
4671
|
await args.reviewItems.forConversation(opener.conversationId).upsert({
|
|
4665
4672
|
assigneeIdentityIds: [opener.identityId],
|
|
4666
|
-
body: `${name} has merge conflicts with \`${conflict.baseBranch}\`.
|
|
4673
|
+
body: `${name} has merge conflicts with \`${conflict.baseBranch}\`. Automatic fixes stopped, because ${reason}. If they are still there, ask in this thread to fix them: ${url}`,
|
|
4667
4674
|
dedupeKey: gitHubConflictNoticeKey(ref),
|
|
4668
4675
|
subject: {
|
|
4669
4676
|
id: url,
|
|
@@ -6695,7 +6702,7 @@ if [ "$#" -ge 3 ]; then
|
|
|
6695
6702
|
source_commit=$3
|
|
6696
6703
|
fi
|
|
6697
6704
|
|
|
6698
|
-
# Run the repository hook first so
|
|
6705
|
+
# Run the repository hook first so the runtime's trailers stay final.
|
|
6699
6706
|
${findRepositoryHook("prepare-commit-msg")}
|
|
6700
6707
|
if [ -n "$repository_hook" ]; then
|
|
6701
6708
|
"$repository_hook" "$@"
|
|
@@ -7344,7 +7351,7 @@ function isGitHubRemote(arg) {
|
|
|
7344
7351
|
* command text only, so it is steering for the model, not a security
|
|
7345
7352
|
* boundary.
|
|
7346
7353
|
*/
|
|
7347
|
-
const HOOKS_PATH_REDIRECT_MESSAGE = "Do not override core.hooksPath.
|
|
7354
|
+
const HOOKS_PATH_REDIRECT_MESSAGE = "Do not override core.hooksPath. The runtime's Git hooks set commit attribution. To skip the repository's pre-commit and commit-msg hooks, use `git commit --no-verify`.";
|
|
7348
7355
|
/**
|
|
7349
7356
|
* Return a redirect message when a bash command overrides `core.hooksPath`
|
|
7350
7357
|
* for a Git command. Return undefined for other commands.
|
package/dist/testing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as normalizeGitHubEvents } from "./events-
|
|
1
|
+
export { n as normalizeGitHubEvents } from "./events-DGd7UVVs.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.305.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@0no-co/graphql.web": "^1.3.4",
|
|
32
|
-
"@sentry/junior-plugin-api": "0.
|
|
32
|
+
"@sentry/junior-plugin-api": "0.305.0",
|
|
33
33
|
"@sinclair/typebox": "^0.34.49",
|
|
34
34
|
"drizzle-orm": "^0.45.4",
|
|
35
35
|
"ignore": "^7.0.5",
|