@sentry/junior-github 0.184.0 → 0.185.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 +3 -4
- package/SETUP.md +10 -10
- package/dist/{chunk-KXAUXJ3Q.js → chunk-QWTU33O7.js} +2 -15
- package/dist/credential-support.d.ts +1 -9
- package/dist/index.js +39 -1124
- package/dist/testing.js +1 -1
- package/dist/tools/footer.d.ts +3 -3
- package/dist/tools/resolve-pull-request-review-thread.d.ts +1 -1
- package/dist/tools/update-issue.d.ts +1 -1
- package/dist/tools/update-pull-request.d.ts +1 -1
- package/package.json +2 -2
- package/skills/github-code/SKILL.md +24 -70
- package/skills/github-code/SPEC.md +15 -19
- package/skills/github-code/references/api-surface.md +56 -86
- package/skills/github-code/references/troubleshooting-workarounds.md +30 -34
- package/skills/github-code/references/workflow.md +47 -0
- package/skills/github-issues/SKILL.md +2 -2
- package/skills/github-issues/references/api-surface.md +1 -1
- package/skills/github-issues/references/troubleshooting-workarounds.md +1 -1
- package/dist/outcomes/cost.d.ts +0 -56
- package/dist/outcomes/profile-report.d.ts +0 -11
- package/dist/outcomes/report.d.ts +0 -7
package/README.md
CHANGED
|
@@ -26,8 +26,7 @@ export const plugins = defineJuniorPlugins([
|
|
|
26
26
|
Full setup guide: https://junior.sentry.dev/extend/github-plugin/
|
|
27
27
|
|
|
28
28
|
The plugin owns its signed webhook route, deployment, pull request, and release
|
|
29
|
-
resource events, normalized pull request and issue outcome projections
|
|
30
|
-
|
|
29
|
+
resource events, and normalized pull request and issue outcome projections.
|
|
30
|
+
Those projections also feed native code-change records used by the dashboard
|
|
31
|
+
Code page and person profiles. Core only owns delivery from plugin-published
|
|
31
32
|
resource events into matching conversation subscriptions.
|
|
32
|
-
|
|
33
|
-
Person profiles call `hooks.profileReport` for Junior-owned GitHub work attributed through conversation actors.
|
package/SETUP.md
CHANGED
|
@@ -111,9 +111,9 @@ pnpm exec junior upgrade
|
|
|
111
111
|
```
|
|
112
112
|
|
|
113
113
|
The migrations create `junior_github_pull_requests` and
|
|
114
|
-
`junior_github_issues`, which back webhook ingestion and
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
`junior_github_issues`, which back webhook ingestion and outcome projections.
|
|
115
|
+
When a tracked pull request merges, Junior also reads its commit list and
|
|
116
|
+
records whether every Git author was Junior's configured bot or whether the
|
|
117
117
|
pull request contained non-Junior-authored commits.
|
|
118
118
|
The pull request projection also stores associated native Junior conversation
|
|
119
119
|
ids as an opaque, deduplicated `text[]` without a foreign key.
|
|
@@ -138,7 +138,7 @@ githubPlugin({
|
|
|
138
138
|
|
|
139
139
|
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.
|
|
140
140
|
|
|
141
|
-
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.
|
|
141
|
+
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.
|
|
142
142
|
|
|
143
143
|
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:
|
|
144
144
|
|
|
@@ -148,16 +148,16 @@ githubPlugin({
|
|
|
148
148
|
});
|
|
149
149
|
```
|
|
150
150
|
|
|
151
|
-
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
|
|
151
|
+
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.
|
|
152
152
|
|
|
153
153
|
## 3) Runtime behavior
|
|
154
154
|
|
|
155
155
|
- When either GitHub skill is active, authenticated `gh` and `git` commands cause the runtime to inject GitHub credentials automatically for the current turn.
|
|
156
|
-
- 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
|
|
156
|
+
- 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.
|
|
157
157
|
- `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.
|
|
158
|
-
- Headless resource-event turns use the `resource-event` system actor and may receive the same
|
|
158
|
+
- Headless resource-event turns use the `resource-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.
|
|
159
159
|
- Git commits use Junior as author and committer. Resolvable human run actors are credited once with `Co-Authored-By` trailers.
|
|
160
|
-
-
|
|
160
|
+
- 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.
|
|
161
161
|
- Sandbox does not receive raw tokens via env; host applies Authorization header transforms for GitHub API and upload calls.
|
|
162
162
|
|
|
163
163
|
## 4) CLI usage
|
|
@@ -188,14 +188,14 @@ The plugin uses installation credentials for read-only GitHub traffic, workflow
|
|
|
188
188
|
Committing and pushing code uses more than one GitHub surface:
|
|
189
189
|
|
|
190
190
|
- 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.
|
|
191
|
-
- Pushing a branch with Git smart HTTP (`git push`) uses the
|
|
191
|
+
- 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`.
|
|
192
192
|
- 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.
|
|
193
193
|
- REST Git database and ref writes are denied by the current write allowlist. Use Git smart HTTP (`git push`) for branch updates instead.
|
|
194
194
|
- 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.
|
|
195
195
|
|
|
196
196
|
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.
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
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.
|
|
199
199
|
|
|
200
200
|
Be careful with mixed-surface PR commands. Use the allowlisted REST endpoints
|
|
201
201
|
rather than GraphQL-backed `gh pr` mutation commands. PR-native title, body,
|
|
@@ -578,18 +578,6 @@ function githubRepositoryFromUrl(upstreamUrl) {
|
|
|
578
578
|
const name = rawName ? decodeGitHubPathSegment(rawName) : void 0;
|
|
579
579
|
return owner && name ? { owner, name } : void 0;
|
|
580
580
|
}
|
|
581
|
-
function githubRepositoryLeaseScope(repository) {
|
|
582
|
-
return `repository:${repository.owner.toLowerCase()}/${repository.name.toLowerCase()}`;
|
|
583
|
-
}
|
|
584
|
-
function githubRepositoryFromLeaseScope(leaseScope) {
|
|
585
|
-
const match = /^repository:([^/]+)\/([^/]+)$/.exec(leaseScope ?? "");
|
|
586
|
-
if (!match?.[1] || !match[2]) {
|
|
587
|
-
throw new GitHubPluginSetupError(
|
|
588
|
-
"GitHub installation write grant is missing a repository lease scope."
|
|
589
|
-
);
|
|
590
|
-
}
|
|
591
|
-
return { owner: match[1], name: match[2] };
|
|
592
|
-
}
|
|
593
581
|
async function resolveUserAccount(tokens) {
|
|
594
582
|
const account = await githubRequest("https://api.github.com", "/user", {
|
|
595
583
|
token: tokens.accessToken
|
|
@@ -769,9 +757,10 @@ async function issueInstallationToken(options) {
|
|
|
769
757
|
}
|
|
770
758
|
const appJwt = createAppJwt(appId, options.privateKeyEnv);
|
|
771
759
|
const permissions = "permissions" in options ? options.permissions : typeof options.loadPermissions === "function" ? await options.loadPermissions({ appJwt, installationId }) : void 0;
|
|
760
|
+
const repositories = "repositories" in options ? options.repositories : void 0;
|
|
772
761
|
const body = {
|
|
773
762
|
...permissions ? { permissions } : void 0,
|
|
774
|
-
...
|
|
763
|
+
...repositories ? { repositories } : void 0
|
|
775
764
|
};
|
|
776
765
|
const accessTokenResponse = await githubRequest(
|
|
777
766
|
"https://api.github.com",
|
|
@@ -1794,8 +1783,6 @@ export {
|
|
|
1794
1783
|
githubRequest,
|
|
1795
1784
|
credentialUnavailable,
|
|
1796
1785
|
githubRepositoryFromUrl,
|
|
1797
|
-
githubRepositoryLeaseScope,
|
|
1798
|
-
githubRepositoryFromLeaseScope,
|
|
1799
1786
|
resolveUserAccount,
|
|
1800
1787
|
issueUserCredential,
|
|
1801
1788
|
issueInstallationToken,
|
|
@@ -25,11 +25,7 @@ interface InstallationCredentialBaseOptions {
|
|
|
25
25
|
type InstallationCredentialOptions = InstallationCredentialBaseOptions & ({
|
|
26
26
|
loadPermissions?: never;
|
|
27
27
|
permissions?: GitHubAppPermissions;
|
|
28
|
-
repositories
|
|
29
|
-
} | {
|
|
30
|
-
loadPermissions?: never;
|
|
31
|
-
permissions: GitHubAppPermissions;
|
|
32
|
-
repositories?: never;
|
|
28
|
+
repositories?: string[];
|
|
33
29
|
} | {
|
|
34
30
|
loadPermissions: LoadInstallationReadPermissions;
|
|
35
31
|
permissions?: never;
|
|
@@ -70,10 +66,6 @@ export declare function githubRequest(apiBase: string, path: string, params: Git
|
|
|
70
66
|
export declare function credentialUnavailable(message: string): PluginCredentialResult;
|
|
71
67
|
/** Parse a GitHub repository from an API or Git URL. */
|
|
72
68
|
export declare function githubRepositoryFromUrl(upstreamUrl: URL): GitHubRepository | undefined;
|
|
73
|
-
/** Build the stable lease scope for a GitHub repository. */
|
|
74
|
-
export declare function githubRepositoryLeaseScope(repository: GitHubRepository): string;
|
|
75
|
-
/** Parse the repository bound to an installation-write lease. */
|
|
76
|
-
export declare function githubRepositoryFromLeaseScope(leaseScope: string | undefined): GitHubRepository;
|
|
77
69
|
/** Resolve the GitHub account associated with stored user tokens. */
|
|
78
70
|
export declare function resolveUserAccount(tokens: PluginStoredTokens): Promise<PluginProviderAccount>;
|
|
79
71
|
/** Issue a bounded GitHub user credential for an approved grant. */
|