@sentry/junior-github 0.268.0 → 0.270.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/README.md +2 -73
- package/SETUP.md +13 -258
- package/dist/{chunk-PQFFT2UO.js → chunk-MUWR6X24.js} +38 -10
- package/dist/db/schema.d.ts +170 -0
- package/dist/events/pull-request.d.ts +8 -5
- package/dist/events/repository.d.ts +2 -2
- package/dist/index.js +580 -138
- package/dist/pull-request-outcomes/store.d.ts +36 -0
- package/dist/pull-request-requesters/store.d.ts +11 -4
- package/dist/testing.js +1 -1
- package/dist/tools/update-pull-request-feedback.d.ts +4 -3
- package/dist/webhooks/check-suite.d.ts +5 -0
- package/dist/webhooks/handler.d.ts +5 -1
- package/dist/webhooks/installation-requests.d.ts +34 -0
- package/dist/webhooks/merge-conflict.d.ts +46 -0
- package/dist/webhooks/pull-request-ready.d.ts +29 -0
- package/migrations/0010_sleepy_slayback.sql +5 -0
- package/migrations/meta/0010_snapshot.json +427 -0
- package/migrations/meta/_journal.json +8 -1
- package/package.json +2 -2
- package/skills/github-code/SKILL.md +1 -1
- package/skills/github-code/SPEC.md +1 -1
- package/skills/github-code/references/workflow.md +3 -4
package/README.md
CHANGED
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
# @sentry/junior-github
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
repository, and user-attachment workflows to Junior using a GitHub App.
|
|
5
|
-
|
|
6
|
-
Install it alongside `@sentry/junior`:
|
|
3
|
+
GitHub repository, issue, pull request, deployment, and release workflows for Junior through a GitHub App.
|
|
7
4
|
|
|
8
5
|
```bash
|
|
9
6
|
pnpm add @sentry/junior @sentry/junior-github
|
|
10
7
|
```
|
|
11
8
|
|
|
12
|
-
Add the plugin factory to the plugin set exported from `plugins.ts`:
|
|
13
|
-
|
|
14
9
|
```ts
|
|
15
10
|
import { defineJuniorPlugins } from "@sentry/junior";
|
|
16
11
|
import { githubPlugin } from "@sentry/junior-github";
|
|
@@ -23,70 +18,4 @@ export const plugins = defineJuniorPlugins([
|
|
|
23
18
|
]);
|
|
24
19
|
```
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
The plugin tries to assign new pull requests to the current requester's linked
|
|
29
|
-
GitHub account. Assignment is optional. Missing handles, system actors, identity
|
|
30
|
-
lookup errors, and assignment failures do not stop creation or fail the tool.
|
|
31
|
-
If assignment is not possible, the pull request can remain unassigned.
|
|
32
|
-
|
|
33
|
-
The plugin saves the created pull request before it tries assignment. Retrying
|
|
34
|
-
the same tool call returns the saved pull request without retrying assignment,
|
|
35
|
-
creating another pull request, or replacing existing assignees.
|
|
36
|
-
|
|
37
|
-
The plugin saves each person who asks Junior to open or update a pull request in
|
|
38
|
-
`junior_github_pull_request_requesters`. Each row has only the core Junior
|
|
39
|
-
identity id of that person. The plugin does not copy the user or GitHub login.
|
|
40
|
-
When a webhook needs the GitHub login, it reads the identity through
|
|
41
|
-
`ctx.users.readIdentity()` and uses the GitHub identity of the linked user. So a
|
|
42
|
-
person who links GitHub later is found on their older pull requests too. The
|
|
43
|
-
create tool saves the opener after GitHub opens the pull request. The first row
|
|
44
|
-
for a pull request is the opener. Later updates never replace it. When the
|
|
45
|
-
create has no Junior identity, the first person who asks Junior to update the
|
|
46
|
-
pull request is the opener. A retry of the same tool call saves the opener
|
|
47
|
-
again, in case the first call stopped before it did.
|
|
48
|
-
|
|
49
|
-
Pull request events have two kinds of people fields. `openerUsername`,
|
|
50
|
-
`openerEmail`, and `openerRole` name who opened the pull request. On a pull
|
|
51
|
-
request that Junior's bot opened, the opener is the person who asked Junior to
|
|
52
|
-
open it: the linked GitHub login of the saved opener row. With no saved row, no
|
|
53
|
-
linked GitHub login, or a failed identity lookup, the opener is unknown and the
|
|
54
|
-
event has no opener fields, so filters on them do not match. The bot is never
|
|
55
|
-
used in its place. An `opened` event can arrive before the create tool saves
|
|
56
|
-
the row. `authors` lists the GitHub logins of the commit authors and of the
|
|
57
|
-
`Co-authored-by` trailers with GitHub noreply emails, bots included. Webhooks
|
|
58
|
-
never read the pull request body.
|
|
59
|
-
|
|
60
|
-
The opener on Junior's pull requests, `openerRole`, and `authors` need database
|
|
61
|
-
or GitHub calls. A webhook loads the values that a Watch or event automation
|
|
62
|
-
filters on before it decides on a match. It loads the other values only when an
|
|
63
|
-
event matches, so the agent sees all of them. A failed load leaves the value
|
|
64
|
-
out. `authors` and the people involved in approvals and merges share one read of
|
|
65
|
-
the commits per delivery.
|
|
66
|
-
|
|
67
|
-
Deployment events come from GitHub `deployment` and `deployment_status`
|
|
68
|
-
webhooks:
|
|
69
|
-
|
|
70
|
-
| Event | GitHub source |
|
|
71
|
-
| ------------------------ | --------------------------- |
|
|
72
|
-
| `deployment.created` | `deployment` with `created` |
|
|
73
|
-
| `deployment.queued` | status `queued` |
|
|
74
|
-
| `deployment.pending` | status `pending` |
|
|
75
|
-
| `deployment.in_progress` | status `in_progress` |
|
|
76
|
-
| `deployment.succeeded` | status `success` |
|
|
77
|
-
| `deployment.failed` | status `failure` |
|
|
78
|
-
| `deployment.error` | status `error` |
|
|
79
|
-
|
|
80
|
-
GitHub has two failure states. `failure` means that the deployment ran and
|
|
81
|
-
failed. `error` means that the deploy tool reported an error. The deploy tool
|
|
82
|
-
sets the status, so the difference depends on that tool. Vercel
|
|
83
|
-
`deployment.error` is a failed deployment, so it is the same as GitHub
|
|
84
|
-
`deployment.failed`, not GitHub `deployment.error`. `succeeded`, `failed`, and
|
|
85
|
-
`error` end a watch on one commit and environment. Watches on a commit or a
|
|
86
|
-
repository stay active.
|
|
87
|
-
|
|
88
|
-
The plugin owns its signed webhook route, deployment, pull request, and release
|
|
89
|
-
events, and normalized pull request and issue outcome projections.
|
|
90
|
-
Those projections also feed native code-change records used by the dashboard
|
|
91
|
-
Code page and person profiles. Core only owns delivery from plugin-published
|
|
92
|
-
events into matching conversation subscriptions.
|
|
21
|
+
Setup and configuration: https://junior.sentry.dev/extend/github-plugin/
|
package/SETUP.md
CHANGED
|
@@ -1,269 +1,24 @@
|
|
|
1
1
|
# GitHub plugin setup
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The full setup guide is at https://junior.sentry.dev/extend/github-plugin/. It
|
|
4
|
+
covers the GitHub App, permissions, environment variables, webhooks,
|
|
5
|
+
migrations, and verification.
|
|
4
6
|
|
|
5
|
-
##
|
|
7
|
+
## Private key on Vercel
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
1. Go to `Settings -> Developer settings -> GitHub Apps -> New GitHub App`.
|
|
10
|
-
2. Set app name and callback URL to `https://<junior-host>/api/oauth/callback/github`.
|
|
11
|
-
3. Under repository permissions, grant:
|
|
12
|
-
|
|
13
|
-
- Issues: Read and write
|
|
14
|
-
- Contents: Read and write
|
|
15
|
-
- Pull requests: Read and write
|
|
16
|
-
- Actions: Read and write
|
|
17
|
-
- Checks: Read
|
|
18
|
-
- Deployments: Read
|
|
19
|
-
- Workflows: Write
|
|
20
|
-
- Metadata: Read
|
|
21
|
-
|
|
22
|
-
Optional: under account permissions, grant Email addresses: Read. Junior then
|
|
23
|
-
reads the verified emails of a connected GitHub account to link it to a
|
|
24
|
-
person. Without it, Junior links the account only through the person who
|
|
25
|
-
connected it.
|
|
26
|
-
|
|
27
|
-
4. Create the app and generate a private key.
|
|
28
|
-
5. Install the app on the target org/repo(s).
|
|
29
|
-
|
|
30
|
-
Install the app on target repos/orgs and collect:
|
|
31
|
-
|
|
32
|
-
- `GITHUB_APP_ID`
|
|
33
|
-
- `GITHUB_APP_CLIENT_ID`
|
|
34
|
-
- `GITHUB_APP_CLIENT_SECRET`
|
|
35
|
-
- `GITHUB_APP_PRIVATE_KEY` (PEM)
|
|
36
|
-
|
|
37
|
-
## 2) Configure host runtime
|
|
38
|
-
|
|
39
|
-
Set on the harness host (never in skill files):
|
|
40
|
-
|
|
41
|
-
- `GITHUB_APP_ID`
|
|
42
|
-
- `GITHUB_APP_CLIENT_ID`
|
|
43
|
-
- `GITHUB_APP_CLIENT_SECRET`
|
|
44
|
-
- `GITHUB_APP_PRIVATE_KEY`
|
|
45
|
-
- `GITHUB_INSTALLATION_ID`
|
|
46
|
-
- `GITHUB_APP_BOT_NAME` (Git author and committer display name)
|
|
47
|
-
- `GITHUB_APP_BOT_EMAIL`
|
|
48
|
-
|
|
49
|
-
Current limitation: one Junior deployment uses one GitHub App installation ID.
|
|
50
|
-
That works for repositories covered by the same installation, but not for repositories that live
|
|
51
|
-
under different app installations across orgs/accounts.
|
|
52
|
-
|
|
53
|
-
### Vercel env setup (multiline-safe)
|
|
54
|
-
|
|
55
|
-
`GITHUB_APP_PRIVATE_KEY` must be the PEM private key generated by GitHub for
|
|
56
|
-
this app.
|
|
57
|
-
|
|
58
|
-
For Vercel, prefer CLI file input so newlines are preserved exactly:
|
|
9
|
+
`GITHUB_APP_PRIVATE_KEY` is a multiline PEM key. Add it from the file so that
|
|
10
|
+
Vercel keeps the newlines:
|
|
59
11
|
|
|
60
12
|
```bash
|
|
61
|
-
vercel env add GITHUB_APP_ID production
|
|
62
|
-
vercel env add GITHUB_APP_CLIENT_ID production
|
|
63
|
-
vercel env add GITHUB_APP_CLIENT_SECRET production
|
|
64
|
-
vercel env add GITHUB_INSTALLATION_ID production
|
|
65
|
-
vercel env add GITHUB_APP_BOT_NAME production
|
|
66
|
-
vercel env add GITHUB_APP_BOT_EMAIL production
|
|
67
13
|
vercel env add GITHUB_APP_PRIVATE_KEY production --sensitive < ./github-app-private-key.pem
|
|
68
14
|
```
|
|
69
15
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
```bash
|
|
73
|
-
vercel env update GITHUB_APP_PRIVATE_KEY production --sensitive < ./github-app-private-key.pem
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Repeat for `preview` and `development` as needed. After env changes, redeploy so the new deployment picks up updated values.
|
|
77
|
-
|
|
78
|
-
### Optional GitHub webhooks and outcome reporting
|
|
79
|
-
|
|
80
|
-
To report Junior-created pull request and issue outcomes, use the standard
|
|
81
|
-
GitHub noreply format `<bot-user-id>+<app-slug>[bot]@users.noreply.github.com` for
|
|
82
|
-
`GITHUB_APP_BOT_EMAIL` and configure `GITHUB_WEBHOOK_SECRET`. Junior derives
|
|
83
|
-
the App bot login from that email. Set the GitHub App webhook URL to
|
|
84
|
-
`https://<junior-host>/api/webhooks/github` and subscribe to Pull request
|
|
85
|
-
and Issues events. The secret in GitHub must match the deployment environment.
|
|
86
|
-
|
|
87
|
-
Conversation watches additionally use Check suite, Deployment, Deployment
|
|
88
|
-
status, Issue comment, Pull request review, Pull request review comment, and
|
|
89
|
-
Release events.
|
|
90
|
-
|
|
91
|
-
`github_getDeployment` reads the latest deployment and status for an exact
|
|
92
|
-
repository and commit SHA, optionally limited to one environment. When
|
|
93
|
-
webhooks are configured, its result can subscribe the current conversation to
|
|
94
|
-
deployment creation, progress, success, failure, and error events. Omitting the
|
|
95
|
-
environment watches deployments for that commit across environments. The
|
|
96
|
-
subscription remains available when GitHub has not created the deployment yet.
|
|
97
|
-
Commit-wide watches remain active across terminal outcomes so later
|
|
98
|
-
environments for the same commit can also notify the conversation.
|
|
99
|
-
|
|
100
|
-
`github_getRelease` reads a release for an exact repository, optionally limited
|
|
101
|
-
to one tag. When webhooks are configured, its result can subscribe the current
|
|
102
|
-
conversation to `release.published`. Omitting the tag watches every published
|
|
103
|
-
release in the repository. The subscription remains available when GitHub has
|
|
104
|
-
not published the release yet. Tag-specific watches complete after publish;
|
|
105
|
-
repository-wide release watches remain active across later tags.
|
|
106
|
-
|
|
107
|
-
```bash
|
|
108
|
-
vercel env add GITHUB_WEBHOOK_SECRET production
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
After installing or upgrading the plugin, apply its packaged migration from the
|
|
112
|
-
deployed app environment:
|
|
113
|
-
|
|
114
|
-
```bash
|
|
115
|
-
pnpm exec junior upgrade
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
The migrations create `junior_github_pull_requests` and
|
|
119
|
-
`junior_github_issues`, which back webhook ingestion and outcome projections.
|
|
120
|
-
When a tracked pull request merges, Junior also reads its commit list and
|
|
121
|
-
records whether every Git author was Junior's configured bot or whether the
|
|
122
|
-
pull request contained non-Junior-authored commits.
|
|
123
|
-
The pull request projection also stores associated native Junior conversation
|
|
124
|
-
ids as an opaque, deduplicated `text[]` without a foreign key.
|
|
125
|
-
|
|
126
|
-
### Optional permission declaration
|
|
127
|
-
|
|
128
|
-
By default, `installation-read` grants read the app installation's current permission envelope once per process and scopes read-capable permissions down to `read` when requesting a token. To declare the GitHub App permission envelope in the plugin and avoid that installation lookup, pass `appPermissions` when registering the plugin:
|
|
129
|
-
|
|
130
|
-
```ts
|
|
131
|
-
githubPlugin({
|
|
132
|
-
appPermissions: {
|
|
133
|
-
actions: "write",
|
|
134
|
-
contents: "write",
|
|
135
|
-
deployments: "read",
|
|
136
|
-
issues: "write",
|
|
137
|
-
metadata: "read",
|
|
138
|
-
pull_requests: "write",
|
|
139
|
-
workflows: "write",
|
|
140
|
-
},
|
|
141
|
-
});
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
Installation-read token requests remain read-only by requesting read-capable configured permissions at `read` level and omitting GitHub permission fields that have no `read` value. Installation-write token requests intentionally omit the `permissions` field, so GitHub applies the complete permission envelope approved on the App installation. GitHub remains the source of truth for whether a permission name or level exists.
|
|
145
|
-
|
|
146
|
-
GitHub App user-to-server tokens do not use OAuth scopes as their permission model. Their effective access is limited by the GitHub App's installed permissions, the app installation's repository access, and the requesting user's own GitHub access. Installation tokens use the App permissions and installation repository access without borrowing the requesting user's authority. GitHub returns an empty `scope` value for user-to-server tokens, so Junior cannot verify granted scopes from the token response.
|
|
147
|
-
|
|
148
|
-
If you pass `additionalUserScopes`, Junior includes those values in the authorization URL and records the requested scope string as a local reauthorization contract. This does not expand or prove GitHub API permissions. Configure provider-enforced access in the GitHub App settings; `appPermissions` only controls read-token downscoping:
|
|
149
|
-
|
|
150
|
-
```ts
|
|
151
|
-
githubPlugin({
|
|
152
|
-
additionalUserScopes: ["read:org", "workflow"],
|
|
153
|
-
});
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
Use `additionalUserScopes` only when a human-identity integration flow requires specific GitHub OAuth scope parameters in the authorization URL. Do not rely on it to authorize Junior-owned repository or workflow writes — those use installation tokens and the permissions approved on the GitHub App installation.
|
|
157
|
-
|
|
158
|
-
## 3) Runtime behavior
|
|
159
|
-
|
|
160
|
-
- When either GitHub skill is active, authenticated `gh` and `git` commands cause the runtime to inject GitHub credentials automatically for the current turn.
|
|
161
|
-
- The plugin classifies GitHub traffic from the forwarded HTTP request. Reads use `installation-read`, while `GET /user` uses `user-read`. Allowlisted App-owned mutations and Git smart-HTTP pushes use `installation-write`. User-attachment uploads to `uploads.github.com/user-attachments/assets` use `user-write`. Unknown REST writes and GraphQL mutations are denied.
|
|
162
|
-
- `user-read` and explicitly human `user-write` operations require the actor, or an explicitly delegated user subject, to authorize the GitHub App through the private OAuth flow. Junior-owned issue, pull request, review, inline review comment, and branch operations do not fall back to user OAuth.
|
|
163
|
-
- Headless event turns use the `event` system actor and may receive the same installation grants. This lets Junior respond to subscribed pull request events by committing and pushing fixes without inheriting a subscriber's OAuth credential.
|
|
164
|
-
- Git commits use Junior as author and committer. Resolvable human run actors are credited once with `Co-Authored-By` trailers. When the current actor has a linked GitHub identity, Junior prefers a GitHub noreply address so external automation can resolve a login for assignment.
|
|
165
|
-
- Junior points `core.hooksPath` at its own hooks directory for every sandbox command. It sets the value in the command env, so it also wins over a repository `core.hooksPath` such as husky's. That directory runs Junior's commit attribution hook and passes every other client hook to the repository's own hooks directory: its `core.hooksPath` if set, or `.git/hooks` (simple-git-hooks, Git LFS). A failing repository hook stops the commit or push.
|
|
166
|
-
- Installation credential leases are cached on the host by grant name and reused across sandboxes until near expiry. User grants stay actor-scoped. Upstream 403 after injection clears the cached lease, issues a new token, and retries the hop once before recording permission denied.
|
|
167
|
-
- Sandbox does not receive raw tokens via env; host applies Authorization header transforms for GitHub API and upload calls.
|
|
168
|
-
|
|
169
|
-
## 4) CLI usage
|
|
170
|
-
|
|
171
|
-
Run as a regular sandbox `bash` command while the relevant skill is active:
|
|
172
|
-
|
|
173
|
-
Clone a repository with the `github_cloneRepository` tool. It makes a shallow
|
|
174
|
-
checkout. It first checks for a matching Workspace. Do not use `git clone` or
|
|
175
|
-
`gh repo clone`, because they skip that check.
|
|
176
|
-
|
|
177
|
-
Deepen later only if the task needs more history:
|
|
178
|
-
|
|
179
|
-
```bash
|
|
180
|
-
git -C repo fetch --depth=50 origin
|
|
181
|
-
git -C repo fetch --unshallow
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Load the relevant GitHub skill for command guidance and repo context. Create
|
|
185
|
-
new resources through the typed tools, for example
|
|
186
|
-
`github_createIssue({ repo: "owner/repo", title: "Example issue", body: "..." })`.
|
|
187
|
-
Use `gh` for the allowlisted lifecycle operations described by the skill.
|
|
188
|
-
|
|
189
|
-
`gh` supports either direct `GITHUB_TOKEN` (for local debugging) or sandbox-level header injection.
|
|
190
|
-
The plugin uses installation credentials for read-only GitHub traffic, workflow dispatches, reruns, and cancellations, allowlisted issue and pull request mutations (including reviews and inline review comments), and Git smart-HTTP pushes. The installed GitHub App permissions still need to cover the operation: actions for workflow dispatches, reruns, and cancellations, issues for issue edits/comments/labels, contents for pushes, pull requests for PR mutations/reviews/inline comments, and workflows for workflow-file pushes.
|
|
191
|
-
|
|
192
|
-
Committing and pushing code uses more than one GitHub surface:
|
|
193
|
-
|
|
194
|
-
- Creating the local Git commit does not call GitHub. Junior sets the GitHub App bot as author and committer and credits resolvable human actors with `Co-Authored-By` trailers, preferring a linked GitHub noreply email for the current actor when present.
|
|
195
|
-
- Pushing a branch with Git smart HTTP (`git push`) uses the `installation-write` grant and requires the App installation to have `Contents: write`. Workflow-file changes also require the installation to have `Workflows: write`.
|
|
196
|
-
- The smart-HTTP classifier does not distinguish Junior-managed branches or independently detect force updates or ref deletion. Use GitHub branch protection and limit the App installation to repositories where Junior may push.
|
|
197
|
-
- REST Git database and ref writes are denied by the current write allowlist. Use Git smart HTTP (`git push`) for branch updates instead.
|
|
198
|
-
- Opening the PR after the branch exists is separate: `github_createPullRequest` needs pull-request write permission, but it should not create or push commits itself.
|
|
199
|
-
|
|
200
|
-
Fork creation is not part of the default PR path and is denied by the current write allowlist. Do not grant `Administration: write` for routine PR creation; push a branch explicitly and create the PR with `github_createPullRequest` instead.
|
|
201
|
-
|
|
202
|
-
The egress allowlist and App installation repositories are the write boundaries. Credential injection is provider-domain scoped for sandbox traffic to `api.github.com` and `github.com` during turns with a signed credential context. Keep repo context explicit, and let the plugin choose the grant for the outbound request.
|
|
203
|
-
|
|
204
|
-
Be careful with mixed-surface PR commands. Use the allowlisted REST endpoints
|
|
205
|
-
rather than GraphQL-backed `gh pr` mutation commands. PR-native title, body,
|
|
206
|
-
base, state, ready-for-review, and requested-reviewer changes use pull request
|
|
207
|
-
endpoints. Comments, labels, and assignees use GitHub's issue endpoints. All
|
|
208
|
-
allowlisted bot writes share `installation-write`; merge, branch deletion, REST ref
|
|
209
|
-
mutation, and administration remain unsupported API operations.
|
|
210
|
-
|
|
211
|
-
For PR creation in automation, push explicitly and pass that branch as `head`:
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
git -C repo push -u origin BRANCH
|
|
215
|
-
gh repo view owner/repo --json defaultBranchRef --jq .defaultBranchRef.name
|
|
216
|
-
```
|
|
217
|
-
|
|
218
|
-
```ts
|
|
219
|
-
github_createPullRequest({
|
|
220
|
-
repo: "owner/repo",
|
|
221
|
-
head: "BRANCH",
|
|
222
|
-
base: "<DEFAULT_BRANCH>",
|
|
223
|
-
title: "Example PR",
|
|
224
|
-
body: "Example body",
|
|
225
|
-
draft: true,
|
|
226
|
-
});
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
Optional: set a default repository once per channel/thread context so `--repo` is not needed each turn:
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
jr-rpc config set github.repo getsentry/junior
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
## 5) Quick verification
|
|
236
|
-
|
|
237
|
-
- `pnpm skills:check`
|
|
238
|
-
- Create issue in a test repo.
|
|
239
|
-
- Update/comment/label the same issue.
|
|
240
|
-
- Push a test branch and create a draft PR with `github_createPullRequest`.
|
|
241
|
-
- Use read-only commands (`gh issue view`, `gh api .../comments`, `gh pr view`) for issue inspection.
|
|
242
|
-
|
|
243
|
-
## 6) Production verification (step-by-step)
|
|
244
|
-
|
|
245
|
-
1. Confirm host env vars are present in prod:
|
|
246
|
-
- `GITHUB_APP_ID`
|
|
247
|
-
- `GITHUB_APP_CLIENT_ID`
|
|
248
|
-
- `GITHUB_APP_CLIENT_SECRET`
|
|
249
|
-
- `GITHUB_APP_PRIVATE_KEY`
|
|
250
|
-
- `GITHUB_INSTALLATION_ID`
|
|
251
|
-
- `GITHUB_APP_BOT_NAME`
|
|
252
|
-
- `GITHUB_APP_BOT_EMAIL`
|
|
253
|
-
2. Confirm the GitHub App is installed on your test repo with the permissions above.
|
|
254
|
-
3. Deploy `main` to prod.
|
|
255
|
-
4. Exercise `github-issues` to create an issue in a safe test repo.
|
|
256
|
-
5. Verify the issue is authored by the GitHub App bot and includes `Requested by` attribution.
|
|
257
|
-
6. Exercise `github-issues` to update title/body, add/remove labels, and add a comment.
|
|
258
|
-
7. Push a test branch and exercise `github-code` to create a draft PR using explicit repo targeting and `--head`.
|
|
259
|
-
8. Verify allowlisted mutations, including pull request reviews and inline review comments, are attributed to the GitHub App bot. Confirm merge remains unsupported.
|
|
260
|
-
9. Verify GitHub API calls succeed while this skill is active without writing tokens into sandbox env/files.
|
|
261
|
-
10. Verify raw token values are never printed in output or logs.
|
|
262
|
-
11. Check logs for:
|
|
16
|
+
Use `vercel env update` when the variable already exists. Redeploy after each
|
|
17
|
+
change.
|
|
263
18
|
|
|
264
|
-
|
|
265
|
-
- `sandbox_egress_credential_needed`
|
|
266
|
-
- `sandbox_egress_upstream_auth_rejected`
|
|
19
|
+
## Write limits
|
|
267
20
|
|
|
268
|
-
|
|
269
|
-
|
|
21
|
+
- Do not grant `Administration: write`. Junior pushes a branch and opens the
|
|
22
|
+
pull request with `github_createPullRequest`. It does not create forks.
|
|
23
|
+
- Junior cannot detect force pushes or ref deletion. Use branch protection,
|
|
24
|
+
and install the App only on repositories where Junior may push.
|
|
@@ -184,11 +184,13 @@ var GITHUB_PULL_REQUEST_EVENTS = [
|
|
|
184
184
|
"pull_request.review.commented",
|
|
185
185
|
"pull_request.review_comment.created",
|
|
186
186
|
"pull_request.merged",
|
|
187
|
-
"pull_request.closed_unmerged"
|
|
187
|
+
"pull_request.closed_unmerged",
|
|
188
|
+
"pull_request.merge_conflict"
|
|
188
189
|
];
|
|
189
190
|
var GITHUB_PULL_REQUEST_EVENT_GUIDANCE = {
|
|
190
191
|
"pull_request.comment.created": 'After acting on actionable feedback, call github_updatePullRequestFeedback with the exact repo, commentId, and commentKind from Verified details, and status "addressed" or "declined".',
|
|
191
|
-
"pull_request.review_comment.created": 'After acting on actionable feedback, call github_updatePullRequestFeedback with the exact repo, commentId, and commentKind from Verified details, and status "addressed" or "declined". Then resolve the thread with github_resolvePullRequestReviewThread.'
|
|
192
|
+
"pull_request.review_comment.created": 'After acting on actionable feedback, call github_updatePullRequestFeedback with the exact repo, commentId, and commentKind from Verified details, and status "addressed" or "declined". Then resolve the thread with github_resolvePullRequestReviewThread.',
|
|
193
|
+
"pull_request.merge_conflict": "Fetch baseBranch 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. Report the files that had conflicts."
|
|
192
194
|
};
|
|
193
195
|
function gitHubPullRequestEventGuidance(guidance) {
|
|
194
196
|
const merged = { ...GITHUB_PULL_REQUEST_EVENT_GUIDANCE };
|
|
@@ -209,7 +211,15 @@ function gitHubPullRequestCreateWatch(config) {
|
|
|
209
211
|
GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE
|
|
210
212
|
);
|
|
211
213
|
return {
|
|
212
|
-
events: [
|
|
214
|
+
events: [
|
|
215
|
+
.../* @__PURE__ */ new Set([
|
|
216
|
+
...config.events,
|
|
217
|
+
// GitHub sends no webhook for a new conflict, so keep the pull
|
|
218
|
+
// request ready to merge even when the app config omits this event.
|
|
219
|
+
"pull_request.merge_conflict",
|
|
220
|
+
...outcomeEvents
|
|
221
|
+
])
|
|
222
|
+
],
|
|
213
223
|
guidance: GITHUB_PULL_REQUEST_OUTCOME_GUIDANCE,
|
|
214
224
|
intent: config.intent
|
|
215
225
|
};
|
|
@@ -222,8 +232,12 @@ var GITHUB_PULL_REQUEST_SUGGESTED_EVENTS = [
|
|
|
222
232
|
"pull_request.review.commented",
|
|
223
233
|
"pull_request.review_comment.created",
|
|
224
234
|
"pull_request.merged",
|
|
225
|
-
"pull_request.closed_unmerged"
|
|
235
|
+
"pull_request.closed_unmerged",
|
|
236
|
+
"pull_request.merge_conflict"
|
|
226
237
|
];
|
|
238
|
+
var GITHUB_PULL_REQUEST_PAYLOAD_EVENTS = GITHUB_PULL_REQUEST_EVENTS.filter(
|
|
239
|
+
(eventType) => eventType !== "pull_request.merge_conflict"
|
|
240
|
+
);
|
|
227
241
|
var GITHUB_PULL_REQUEST_COMMENT_EVENTS = [
|
|
228
242
|
"pull_request.comment.created",
|
|
229
243
|
"pull_request.review.approved",
|
|
@@ -248,34 +262,34 @@ var GITHUB_PULL_REQUEST_MATCH_FIELDS = eventMatchFieldsSchema5.parse({
|
|
|
248
262
|
kind: "string",
|
|
249
263
|
list: true,
|
|
250
264
|
description: "GitHub logins of the commit authors and Co-authored-by people, including bots such as this GitHub App",
|
|
251
|
-
events: [...
|
|
265
|
+
events: [...GITHUB_PULL_REQUEST_PAYLOAD_EVENTS]
|
|
252
266
|
},
|
|
253
267
|
headBranch: {
|
|
254
268
|
kind: "string",
|
|
255
269
|
description: "head branch name from the webhook",
|
|
256
|
-
events:
|
|
270
|
+
events: GITHUB_PULL_REQUEST_PAYLOAD_EVENTS.filter(
|
|
257
271
|
(eventType) => eventType !== "pull_request.comment.created"
|
|
258
272
|
)
|
|
259
273
|
},
|
|
260
274
|
isDraft: {
|
|
261
275
|
kind: "boolean",
|
|
262
276
|
description: "true when the pull request is a draft",
|
|
263
|
-
events: [...
|
|
277
|
+
events: [...GITHUB_PULL_REQUEST_PAYLOAD_EVENTS]
|
|
264
278
|
},
|
|
265
279
|
openerEmail: {
|
|
266
280
|
kind: "string",
|
|
267
281
|
description: "opener email when GitHub sends it; missing on pull requests that this GitHub App opened",
|
|
268
|
-
events: [...
|
|
282
|
+
events: [...GITHUB_PULL_REQUEST_PAYLOAD_EVENTS]
|
|
269
283
|
},
|
|
270
284
|
openerUsername: {
|
|
271
285
|
kind: "string",
|
|
272
286
|
description: "login of who opened the pull request; on pull requests that this GitHub App opened, the person who asked for it, missing until that person is saved",
|
|
273
|
-
events: [...
|
|
287
|
+
events: [...GITHUB_PULL_REQUEST_PAYLOAD_EVENTS]
|
|
274
288
|
},
|
|
275
289
|
openerRole: {
|
|
276
290
|
kind: "string",
|
|
277
291
|
description: "opener's repository role: admin, maintain, write, triage, read, none (no access, such as most bots), or a custom role name",
|
|
278
|
-
events: [...
|
|
292
|
+
events: [...GITHUB_PULL_REQUEST_PAYLOAD_EVENTS]
|
|
279
293
|
}
|
|
280
294
|
});
|
|
281
295
|
var GITHUB_PULL_REQUEST_IDENTIFIER = {
|
|
@@ -1321,6 +1335,17 @@ function normalizeCheckSuiteEvents(deliveryId, body, options) {
|
|
|
1321
1335
|
);
|
|
1322
1336
|
});
|
|
1323
1337
|
}
|
|
1338
|
+
function checkSuitePullRequests(body) {
|
|
1339
|
+
const parsed = checkSuiteWebhookSchema.safeParse(body);
|
|
1340
|
+
if (!parsed.success || parsed.data.action !== "completed") return [];
|
|
1341
|
+
const repository = parsed.data.repository;
|
|
1342
|
+
return parsed.data.check_suite.pull_requests.filter(
|
|
1343
|
+
(pullRequest) => isCheckSuiteRepositoryPullRequest(pullRequest, repository.id)
|
|
1344
|
+
).map((pullRequest) => ({
|
|
1345
|
+
number: pullRequest.number,
|
|
1346
|
+
repositoryFullName: repository.full_name
|
|
1347
|
+
}));
|
|
1348
|
+
}
|
|
1324
1349
|
function parseCheckSuitePublishTargets(body) {
|
|
1325
1350
|
const parsed = checkSuiteWebhookSchema.safeParse(body);
|
|
1326
1351
|
if (!parsed.success || parsed.data.action !== "completed") return void 0;
|
|
@@ -2183,6 +2208,7 @@ export {
|
|
|
2183
2208
|
GITHUB_PULL_REQUEST_SUGGESTED_EVENTS,
|
|
2184
2209
|
GITHUB_PULL_REQUEST_MATCH_FIELDS,
|
|
2185
2210
|
GITHUB_PULL_REQUEST_IDENTIFIER,
|
|
2211
|
+
gitHubPullRequestResource,
|
|
2186
2212
|
gitHubPullRequestSubscribable,
|
|
2187
2213
|
GITHUB_RELEASE_EVENTS,
|
|
2188
2214
|
GITHUB_RELEASE_MATCH_FIELDS,
|
|
@@ -2217,6 +2243,8 @@ export {
|
|
|
2217
2243
|
issueGitHubCredential,
|
|
2218
2244
|
createPermissionCache,
|
|
2219
2245
|
definedValues,
|
|
2246
|
+
pullRequestTargets,
|
|
2247
|
+
checkSuitePullRequests,
|
|
2220
2248
|
parseCheckSuitePublishTargets,
|
|
2221
2249
|
needsCheckSuitePullRequestFacts,
|
|
2222
2250
|
loadCheckSuiteFacts,
|