@sentry/junior-github 0.275.0 → 0.277.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.
@@ -2,6 +2,7 @@
2
2
  * GitHub check suite events.
3
3
  */
4
4
  import type { EventInput } from "@sentry/junior-plugin-api";
5
+ import type { GitHubStatusIncident } from "../github-status.js";
5
6
  export type GitHubFailingCheck = {
6
7
  checkRunId: number;
7
8
  conclusion: string;
@@ -17,6 +18,8 @@ export type GitHubCheckSuitePullRequestFacts = {
17
18
  /** Optional values for one check suite event. */
18
19
  export type GitHubCheckSuiteFacts = {
19
20
  failingChecks?: GitHubFailingCheck[];
21
+ /** Open or recent githubstatus.com incidents when the suite failed. */
22
+ githubIncidents?: GitHubStatusIncident[];
20
23
  /** Pull request values by number when a match filter needs them. */
21
24
  pullRequestFactsByNumber?: Record<number, GitHubCheckSuitePullRequestFacts>;
22
25
  };
@@ -35,6 +38,7 @@ export declare function buildCheckSuiteEvent(args: {
35
38
  deliveryId: string;
36
39
  eventType: "pull_request.checks.failed" | "pull_request.checks.recovered";
37
40
  failingChecks?: GitHubFailingCheck[];
41
+ githubIncidents?: GitHubStatusIncident[];
38
42
  headBranch?: string;
39
43
  headSha?: string;
40
44
  isDraft?: boolean;
@@ -82,6 +86,8 @@ export declare function loadCheckSuiteFacts(args: {
82
86
  appIdEnv: string;
83
87
  body: unknown;
84
88
  installationIdEnv: string;
89
+ /** Open or recent githubstatus.com incidents, shared through a cache. */
90
+ loadGitHubIncidents?(): Promise<GitHubStatusIncident[]>;
85
91
  loadPullRequestFacts?: boolean;
86
92
  log?: {
87
93
  error(message: string, metadata?: Record<string, unknown>): void;
@@ -1,3 +1,4 @@
1
+ import type { GitHubStatusIncident } from "../github-status.js";
1
2
  import type { CodeChangePublisher, PluginConversationAnnotations, PluginConversationReviewItems, PluginLogger, PluginRoute, EventPublisher } from "@sentry/junior-plugin-api";
2
3
  import { z } from "zod";
3
4
  import type { GitHubDb } from "../db/database.js";
@@ -33,6 +34,8 @@ export declare function createGitHubWebhookRoute(args: {
33
34
  * involved.
34
35
  */
35
36
  loadPullRequestCommitPages?(target: GitHubPullRequestTarget): Promise<GitHubCommitPageLoader>;
37
+ /** Read open and recent GitHub incidents for failed check suites. */
38
+ loadGitHubIncidents?(): Promise<GitHubStatusIncident[]>;
36
39
  /** Read one pull request for its mergeability. */
37
40
  loadPullRequest?(pullRequest: GitHubPullRequestRef): Promise<unknown>;
38
41
  /** Load a repository role for `openerRole`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-github",
3
- "version": "0.275.0",
3
+ "version": "0.277.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -32,7 +32,7 @@
32
32
  "drizzle-orm": "^0.45.2",
33
33
  "marked": "^18.1.2",
34
34
  "zod": "^4.5.4",
35
- "@sentry/junior-plugin-api": "0.275.0"
35
+ "@sentry/junior-plugin-api": "0.277.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@oxlint/plugins": "1.79.0",
@@ -18,11 +18,11 @@ Use `git` and `gh` for repository work.
18
18
 
19
19
  ## Open when needed
20
20
 
21
- | Need | Read |
22
- | ----------------------------- | -------------------------------------------------------------------------------------- |
23
- | Commands and permissions | [references/api-surface.md](references/api-surface.md) |
24
- | Edit, verify, and open a PR | [references/workflow.md](references/workflow.md) |
25
- | Command or permission failure | [references/troubleshooting-workarounds.md](references/troubleshooting-workarounds.md) |
21
+ | Need | Read |
22
+ | ---------------------------------- | -------------------------------------------------------------------------------------- |
23
+ | Commands and permissions | [references/api-surface.md](references/api-surface.md) |
24
+ | Edit, verify, and open a PR | [references/workflow.md](references/workflow.md) |
25
+ | Command, permission, or CI failure | [references/troubleshooting-workarounds.md](references/troubleshooting-workarounds.md) |
26
26
 
27
27
  ## Always
28
28
 
@@ -14,6 +14,7 @@ Guide evidence-first GitHub repository work from inspection through a reviewable
14
14
  - After each push to a branch with an open PR, check mergeability. Resolve conflicts without asking, by merging the PR base branch (usually the default branch). Never rebase for this, except in a stack: a stack merges only with a linear history, so stacked PRs restack with `gh stack`. When a stacked PR merges, restack the open PRs above it, because GitHub sends them no event when its own rebase stops at a conflict. GitHub sends no event for a new conflict, and conflicted PRs get no new checks. The plugin publishes `pull_request.merge_conflict` for a watched PR only when another webhook event arrives for it, so the post-push check stays.
15
15
  - Write conventional PR titles and short plain-English bodies; keep check results out of the PR body.
16
16
  - Report exact validation and permission failures.
17
+ - For 5xx, timeout, and connection failures, and for stalled or unexplained check failures, check GitHub status with `github_getStatus` (or the incidents on a `pull_request.checks.failed` event) before diagnosing. Report a matching incident as the likely cause; with no match, do not blame an outage.
17
18
 
18
19
  ## Runtime architecture
19
20
 
@@ -56,7 +56,7 @@ If the user omits `owner/repo`, run `jr-rpc config get github.repo`. Then pass `
56
56
  - A local commit does not call GitHub. A push uses installation credentials. Workflow changes also need `workflows.write`.
57
57
  - Deepen a shallow clone before work that needs old history. Do not force-push to work around missing history.
58
58
  - Push `head` and read the default `base` before `github_createPullRequest`.
59
- - Stacks: open each PR with `github_createPullRequest`, based on the branch below, before `gh stack link`. Without local stack state, run `gh stack checkout STACK_NUMBER` first. Do not pass `--open`.
59
+ - Stacks: open each PR with `github_createPullRequest`, based on the branch below. When its base is the head of another open PR, the tool links it into a GitHub stack and returns `stack`; do not run `gh stack link` for it. No `stack` means GitHub could not stack it. Without local stack state, run `gh stack checkout STACK_NUMBER` first. Do not pass `--open`.
60
60
  - Junior does not support merges, forks, repository administration, REST content or Git database writes, direct PR update or review writes, auto-merge, or GraphQL mutations.
61
61
  - Reviews and inline comments use the App bot.
62
62
  - PR comments/labels/assignees use issue endpoints; load `github-issues` for those.
@@ -21,11 +21,25 @@
21
21
  | Dependencies are missing | Run the frozen install. Do not change the lockfile. |
22
22
  | Frozen install fails | Report the exact failure. |
23
23
  | Plugin setup fails | Report the setup failure. Do not repair it from the skill. |
24
+ | GitHub returns 5xx, times out, or drops the connection | Check GitHub status. |
25
+ | Checks stay queued, stall, or fail with no cause in logs | Check GitHub status. |
24
26
 
25
27
  ## Retry rules
26
28
 
27
- - Retry a transport failure once after you check the repository.
29
+ - Retry a transport failure once after you check the repository. If it fails again, check GitHub status.
28
30
  - Do not repeat 401, 403, 404, or validation failures.
29
31
  - A `user-read` or `user-write` failure needs private App OAuth.
30
32
  - An `installation-*` access denial needs an App permission or installation fix.
31
33
  - Use structured `permission_denied` details when present.
34
+
35
+ ## GitHub status
36
+
37
+ Call `github_getStatus`. It lists GitHub incidents that are open or were resolved in the last 24 hours. All callers share one cached read of githubstatus.com. Do not read the status page another way.
38
+
39
+ A `pull_request.checks.failed` event already lists incidents that are open or ended in the last hour. Use that list before you call the tool.
40
+
41
+ - An incident matches when its time covers the failure and its components cover the failing operation: `Git Operations` for clone, fetch, and push; `API Requests` for `gh` and GitHub tools; `Actions` for workflow runs; `Pull Requests`, `Issues`, or `Webhooks` for those features and missing events.
42
+ - Match: say the failure is likely from that incident, and link it. Do not keep retrying. Do not change code, permissions, or workflows to work around it.
43
+ - No match: say GitHub status shows no related incident, and continue from the error. Do not blame an outage.
44
+ - If `github_getStatus` fails, say that GitHub status is unknown. Do not guess.
45
+ - A 401, 403, 404, or 422 usually gives its own cause. Check status for one only when that cause does not fit, such as a 404 for a repository you just read.
@@ -6,7 +6,7 @@ Open this when making repository edits, not for read-only inspection.
6
6
 
7
7
  1. Identify repo, checkout, branches, worktree, package manager, and relevant checks.
8
8
  2. Prefer an existing checkout or matching Workspace; otherwise clone with `github_cloneRepository`.
9
- 3. If clone returns a Workspace match error, switch Workspace or pass `allowAdHoc=true`.
9
+ 3. If clone returns a Workspace match error, switch Workspace or pass `allow_ad_hoc=true`.
10
10
  4. Shallow clones are for fast inspection. Before rebase, merge-base, blame, or base comparison, fetch/deepen the needed refs. Never force-push around missing history.
11
11
  5. For edits, pick the smallest credible validation path. Capture a baseline when a failure may be pre-existing.
12
12
 
@@ -37,8 +37,10 @@ Open this when making repository edits, not for read-only inspection.
37
37
  If the branch has an open PR, check that it can merge. Do this after every push, including fixes for review feedback or failed checks. A conflicted PR gets no new checks. A watched PR gets `pull_request.merge_conflict` only with its next event, so do not wait for it.
38
38
  - Run `gh pr view NUMBER --repo owner/repo --json mergeable,baseRefName`.
39
39
  - `UNKNOWN`: GitHub is still calculating it. Wait about 5 seconds and check again, up to 3 times. If it stays `UNKNOWN`, report that and continue.
40
- - `CONFLICTING`: resolve it now. Do not ask first. GitHub checks mergeability against the PR base (`baseRefName`), which is usually the default branch. Fetch the base and merge `origin/BASE` into the PR branch. Do not rebase. Resolve each conflict so that both the PR change and the base branch change stay intact. Run the checks again, push, and check mergeability again.
41
- - Stacked PR (`gh api 'repos/owner/repo/stacks?pull_request=NUMBER'` returns a stack): a stack merges only with a linear history, so rebase instead of merge. Run `gh stack checkout NUMBER` and `gh stack rebase`, resolve each conflict, run `gh stack rebase --continue`, run the checks, and `gh stack push`.
40
+ - `CONFLICTING`: resolve it now. Do not ask first. First check if the PR is in a stack: `gh api 'repos/owner/repo/stacks?pull_request=NUMBER'`.
41
+ - In a stack: a stack merges only with a linear history, so do not merge the base. Run `gh stack checkout NUMBER` and `gh stack rebase`, resolve each conflict, run `gh stack rebase --continue`, run the checks, and `gh stack push`.
42
+ - Not in a stack: GitHub checks mergeability against the PR base (`baseRefName`), which is usually the default branch. Fetch the base and merge `origin/BASE` into the PR branch. Do not rebase. Resolve each conflict so that both the PR change and the base branch change stay intact. Run the checks again and push.
43
+ - Then check mergeability again.
42
44
  4. Resolve the actual default branch.
43
45
  5. Update an existing PR for the branch with `github_updatePullRequest`, or create with `github_createPullRequest` (`draft: true` only when work, checks, or decisions remain; otherwise ready for review).
44
46
  6. PR title matches the current dominant change, same conventional form as commits.
@@ -18,7 +18,7 @@ Use this table to recover quickly while keeping operations deterministic.
18
18
 
19
19
  ## Retry guidance
20
20
 
21
- - Retry once for transient transport failures after verifying repo context.
21
+ - Retry once for transient transport failures after verifying repo context. If it fails again, call `github_getStatus`. Report a related open or recent incident with its link. With no related incident, do not blame an outage.
22
22
  - Do not loop retries on repeated 401/403/404 validation errors.
23
23
  - Treat missing or stale `user-read`/`user-write` grants as private GitHub App OAuth work. Treat all `installation-*` failures as App permission, installation scope, or host environment setup; they do not fall back to user OAuth.
24
24
  - For persistent permission problems, return explicit remediation and stop.