@sentry/junior-github 0.81.0 → 0.83.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/SETUP.md CHANGED
@@ -135,9 +135,9 @@ Committing and pushing code uses more than one GitHub surface:
135
135
  - Creating the local Git commit does not call GitHub. Junior sets the requester as author and the GitHub App bot as committer in the sandbox.
136
136
  - Pushing a branch with Git smart HTTP (`git push`) uses the `user-write` grant and requires the GitHub App to have `Contents: write` on the target repository. The requesting user must also have write access to that repository.
137
137
  - REST Git database writes used by some `gh` flows also require `Contents: write`: create blob (`POST /git/blobs`), create tree (`POST /git/trees`), create commit (`POST /git/commits`), and create/update refs (`POST /git/refs`, `PATCH /git/refs/{ref}`). Changes to workflow files may also require `Workflows: write`.
138
- - Opening the PR after the branch exists is separate: `gh pr create --head` needs pull-request write permission, but it should not create or push commits itself.
138
+ - 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.
139
139
 
140
- Fork creation is not part of the default PR path. `POST /repos/{owner}/{repo}/forks` uses the `user-write` grant, but GitHub requires `Administration: write` and `Contents: read`, and the app must be installed on both the source and destination accounts. Do not grant `Administration: write` for routine PR creation; push a branch explicitly and create the PR with `--head` instead.
140
+ Fork creation is not part of the default PR path. `POST /repos/{owner}/{repo}/forks` uses the `user-write` grant, but GitHub requires `Administration: write` and `Contents: read`, and the app must be installed on both the source and destination accounts. Do not grant `Administration: write` for routine PR creation; push a branch explicitly and create the PR with `github_createPullRequest` instead.
141
141
 
142
142
  GitHub App permission scoping is a safety rail, not a hard sandbox boundary. It helps prevent accidental write scope and wrong-repo mutations, and the host runtime still decides when to mint credentials. 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 required grant for the outbound request.
143
143
 
@@ -149,11 +149,21 @@ Be careful with mixed-surface PR commands:
149
149
  - `gh pr close --comment` may need `github.issues.write`.
150
150
  - `gh pr close --delete-branch` needs `github.contents.write`.
151
151
 
152
- For PR creation in automation, push explicitly and use `--head`:
152
+ For PR creation in automation, push explicitly and pass that branch as `head`:
153
153
 
154
154
  ```bash
155
155
  git -C repo push -u origin BRANCH
156
- gh pr create --repo owner/repo --head BRANCH --base main --title "Example PR" --body-file /vercel/sandbox/tmp/pr.md
156
+ ```
157
+
158
+ ```ts
159
+ github_createPullRequest({
160
+ repo: "owner/repo",
161
+ head: "BRANCH",
162
+ base: "main",
163
+ title: "Example PR",
164
+ body: "Example body",
165
+ draft: true,
166
+ });
157
167
  ```
158
168
 
159
169
  Optional: set a default repository once per channel/thread context so `--repo` is not needed each turn:
@@ -167,7 +177,7 @@ jr-rpc config set github.repo getsentry/junior
167
177
  - `pnpm skills:check`
168
178
  - Create issue in a test repo.
169
179
  - Update/comment/label the same issue.
170
- - Push a test branch and create a draft PR with `--head`.
180
+ - Push a test branch and create a draft PR with `github_createPullRequest`.
171
181
  - Use read-only commands (`gh issue view`, `gh api .../comments`, `gh pr view`) for issue inspection.
172
182
 
173
183
  ## 6) Production verification (step-by-step)
@@ -0,0 +1,39 @@
1
+ import { type PluginRegistration } from "@sentry/junior-plugin-api";
2
+ import { type GitHubAppPermissions } from "./permissions.js";
3
+ export type { GitHubAppPermissionLevel } from "./permissions.js";
4
+ /** Configure the built-in GitHub plugin manifest and hooks. */
5
+ export interface GitHubPluginOptions {
6
+ /**
7
+ * Extra OAuth `scope` values to request during GitHub App user authorization.
8
+ *
9
+ * GitHub App user tokens report empty scopes, so Junior treats this as a
10
+ * local reauthorization contract only. Effective access still comes from the
11
+ * app permissions, installation repositories, and requesting user's access.
12
+ */
13
+ additionalUserScopes?: string[];
14
+ /**
15
+ * GitHub App installation permissions Junior should request for app tokens.
16
+ *
17
+ * Keys may use GitHub permission names with underscores or hyphens. Junior
18
+ * records these as plugin capabilities and requests read-only installation
19
+ * tokens by scoping read-capable permissions down to `read`.
20
+ * GitHub remains the source of truth for whether a permission exists.
21
+ */
22
+ appPermissions?: GitHubAppPermissions;
23
+ /** Environment variable containing the GitHub App id. */
24
+ appIdEnv?: string;
25
+ /** Environment variable containing Junior's Git committer email. */
26
+ botEmailEnv?: string;
27
+ /** Environment variable containing Junior's Git committer name. */
28
+ botNameEnv?: string;
29
+ /** Environment variable containing the GitHub App OAuth client id. */
30
+ clientIdEnv?: string;
31
+ /** Environment variable containing the GitHub App OAuth client secret. */
32
+ clientSecretEnv?: string;
33
+ /** Environment variable containing the GitHub App installation id. */
34
+ installationIdEnv?: string;
35
+ /** Environment variable containing the GitHub App private key. */
36
+ privateKeyEnv?: string;
37
+ }
38
+ /** Register GitHub runtime hooks for repository workflows. */
39
+ export declare function githubPlugin(options?: GitHubPluginOptions): PluginRegistration;