@sentry/junior-github 0.183.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/dist/testing.js
CHANGED
package/dist/tools/footer.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const GITHUB_SESSION_FOOTER_START = "<!-- junior-session-footer:start -->";
|
|
2
2
|
export declare const GITHUB_SESSION_FOOTER_END = "<!-- junior-session-footer:end -->";
|
|
3
3
|
export declare function sentryConversationUrl(conversationId: string): string | undefined;
|
|
4
|
-
/** Build the
|
|
4
|
+
/** Build the conversation session footer, preferring a host-provided dashboard link. */
|
|
5
5
|
export declare function githubConversationFooter(conversationId: string, dashboardUrl?: string): string | undefined;
|
|
6
|
-
/** Read opaque native conversation ids from
|
|
6
|
+
/** Read opaque native conversation ids from runtime-owned GitHub footers. */
|
|
7
7
|
export declare function githubConversationIds(body: string | null | undefined): string[];
|
|
8
8
|
/** Read same- and cross-repository issue references from a pull request body. */
|
|
9
9
|
export declare function githubLinkedIssues(body: string | null | undefined, repositoryFullName: string): {
|
|
@@ -11,7 +11,7 @@ export declare function githubLinkedIssues(body: string | null | undefined, repo
|
|
|
11
11
|
repositoryFullName: string;
|
|
12
12
|
}[];
|
|
13
13
|
/**
|
|
14
|
-
* Append (or replace an existing)
|
|
14
|
+
* Append (or replace an existing) conversation session footer to a GitHub body string.
|
|
15
15
|
* Without a dashboard or Sentry link, returns the body unchanged (existing footer stripped).
|
|
16
16
|
*/
|
|
17
17
|
export declare function appendGitHubFooter(body: string, conversationId: string, dashboardUrl?: string): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PluginEgress } from "@sentry/junior-plugin-api";
|
|
2
|
-
/** Resolve one review thread after GitHub proves it belongs to a
|
|
2
|
+
/** Resolve one review thread after GitHub proves it belongs to a bot-authored PR. */
|
|
3
3
|
export declare function createGitHubResolvePullRequestReviewThreadTool(ctx: {
|
|
4
4
|
egress: PluginEgress;
|
|
5
5
|
}, botEmail: string | undefined): import("@sentry/junior-plugin-api").PluginToolDefinition<{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Identity, type User, type Actor, type PluginLogger, type PluginEgress } from "@sentry/junior-plugin-api";
|
|
2
|
-
/** Update mutable issue metadata while preserving
|
|
2
|
+
/** Update mutable issue metadata while preserving runtime-owned body attribution. */
|
|
3
3
|
export declare function createGitHubUpdateIssueTool(ctx: {
|
|
4
4
|
actor?: Actor;
|
|
5
5
|
conversationId?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Identity, type User, type Actor, type PluginLogger, type PluginEgress } from "@sentry/junior-plugin-api";
|
|
2
|
-
/** Update mutable PR metadata while preserving
|
|
2
|
+
/** Update mutable PR metadata while preserving runtime-owned body attribution. */
|
|
3
3
|
export declare function createGitHubUpdatePullRequestTool(ctx: {
|
|
4
4
|
actor?: Actor;
|
|
5
5
|
conversationId?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.185.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@sinclair/typebox": "^0.34.49",
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
33
|
"zod": "^4.4.3",
|
|
34
|
-
"@sentry/junior-plugin-api": "0.
|
|
34
|
+
"@sentry/junior-plugin-api": "0.185.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@oxlint/plugins": "1.79.0",
|
|
@@ -5,80 +5,34 @@ description: Work with GitHub repositories, source code, branches, commits, pull
|
|
|
5
5
|
|
|
6
6
|
# GitHub Code Operations
|
|
7
7
|
|
|
8
|
-
Use `git` and `gh` for repository work.
|
|
8
|
+
Use `git` and `gh` for repository work.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
| Action | Tool / command |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| Create PR | `github_createPullRequest` (not `gh pr create`) |
|
|
13
|
+
| Update PR title/body/base/state | `github_updatePullRequest` (not raw PATCH / `gh pr edit`) |
|
|
14
|
+
| Resolve review thread | `github_resolvePullRequestReviewThread` (not raw GraphQL) |
|
|
15
|
+
| Clone missing repo | `github_cloneRepository`; on Workspace match error use `switchWorkspace` |
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
| -------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
14
|
-
| Command syntax, permissions, config | [references/api-surface.md](references/api-surface.md) |
|
|
15
|
-
| Failed commands or permission recovery | [references/troubleshooting-workarounds.md](references/troubleshooting-workarounds.md) |
|
|
17
|
+
## Open when needed
|
|
16
18
|
|
|
17
|
-
|
|
19
|
+
| Need | Read |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| Commands, permissions, allowlist | [references/api-surface.md](references/api-surface.md) |
|
|
22
|
+
| Edit → verify → PR packaging | [references/workflow.md](references/workflow.md) |
|
|
23
|
+
| Failed command or permission recovery | [references/troubleshooting-workarounds.md](references/troubleshooting-workarounds.md) |
|
|
18
24
|
|
|
19
|
-
|
|
25
|
+
## Always
|
|
26
|
+
|
|
27
|
+
- Resolve repo from the request, then `github.repo`. Run `jr-rpc config get github.repo` standalone.
|
|
20
28
|
- Keep `--repo owner/repo` explicit on `gh`; use `git -C PATH` for local repos.
|
|
21
|
-
- Read applicable `AGENTS.md`
|
|
22
|
-
- Preserve unrelated work. Never force-push, delete refs, or
|
|
29
|
+
- Read applicable `AGENTS.md` before editing. Narrower repo/task instructions win.
|
|
30
|
+
- Preserve unrelated work. Never force-push, delete refs, or do destructive merges.
|
|
23
31
|
- Base conclusions on repository evidence. Do not claim a check ran unless it did.
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
## Workflow
|
|
31
|
-
|
|
32
|
-
### 1. Resolve and inspect
|
|
33
|
-
|
|
34
|
-
Identify the repo, checkout, default/current branches, worktree state, repo instructions, package manager, and relevant checks. Prefer an existing checkout or matching Workspace; otherwise clone shallowly. If clone returns a Workspace tool input error, switch Workspace instead of cloning again, or pass `allowAdHoc=true`.
|
|
35
|
-
|
|
36
|
-
A shallow clone is for fast inspection, not history rewriting. Before rebasing, merge-base analysis, blame/history work, or comparing against a base absent locally, fetch the needed refs and deepen incrementally. Use `--unshallow` only when bounded deepening is insufficient. Never use a force push to compensate for incomplete history.
|
|
37
|
-
|
|
38
|
-
For edits, choose the smallest credible validation path before changing files. Capture a baseline when a failure may be pre-existing.
|
|
39
|
-
|
|
40
|
-
### 2. Investigate
|
|
41
|
-
|
|
42
|
-
Establish where the behavior lives, current versus requested behavior, root cause or gap, and the smallest proof of correctness. Read linked issues, PRs, specs, and failing output when provided. For pull requests, inspect conversation comments, inline review comments, reviews, the diff, and checks. If the request is investigation-only, report evidence without editing.
|
|
43
|
-
|
|
44
|
-
### 3. Edit
|
|
45
|
-
|
|
46
|
-
Make the smallest coherent change. Follow local patterns and avoid speculative cleanup. After a failed attempt, re-check the root cause before patching again.
|
|
47
|
-
|
|
48
|
-
Before running repo checks, ensure project dependencies are available:
|
|
49
|
-
|
|
50
|
-
1. Detect the package manager and lockfile from repo evidence.
|
|
51
|
-
2. If dependencies are missing or the check reports missing packages, run the repo-native frozen/immutable install (`pnpm install --frozen-lockfile`, `npm ci`, `yarn install --immutable`, `bun install --frozen-lockfile`, or the documented equivalent).
|
|
52
|
-
3. Do not regenerate or modify a lockfile merely to make verification run. If the locked install fails, report the exact failure unless dependency changes are part of the task.
|
|
53
|
-
|
|
54
|
-
Do not install or repair the GitHub plugin runtime itself; that is manifest-owned setup.
|
|
55
|
-
|
|
56
|
-
### 4. Verify and review
|
|
57
|
-
|
|
58
|
-
Run targeted changed-file/package checks before broad suites. Separate regressions from baseline failures. For instruction-only changes, run available structural checks and perform a content-consistency review.
|
|
59
|
-
|
|
60
|
-
### 5. Package every completed edit
|
|
61
|
-
|
|
62
|
-
Unless the user explicitly says not to create a PR, every completed repository edit must end in a pushed branch and PR. Default to draft; honor an explicit user or repo instruction to open it ready for review. Do not stop at local changes or a commit.
|
|
63
|
-
|
|
64
|
-
1. Reuse the current non-default branch or create a focused branch.
|
|
65
|
-
2. Commit using repo conventions; otherwise use `<type>(<scope>): <Subject>` in imperative present tense, with no agent branding.
|
|
66
|
-
3. Push explicitly with `git push -u origin BRANCH`.
|
|
67
|
-
4. Resolve the actual default branch.
|
|
68
|
-
5. Reuse and update an existing PR for the branch with `github_updatePullRequest`; otherwise call `github_createPullRequest` with explicit repo, head, base, title, body, and `draft: true` unless the user or repo explicitly requires ready-for-review.
|
|
69
|
-
|
|
70
|
-
PR titles use the same conventional form as commits: `<type>(<scope>): <Subject>` or `<type>: <Subject>`. Match the current dominant change, not the latest commit or a stale title.
|
|
71
|
-
|
|
72
|
-
Write the PR body for a reviewer who knows the product but not this change. Use ASD-STE100 English: short sentences, common words, active voice, and one idea per sentence. Avoid dense academic prose and unnecessary jargon.
|
|
73
|
-
|
|
74
|
-
Explain what this PR changes and why it matters. Add only context the diff cannot show. Keep the body short by default; add structure only when it helps. Omit empty or `N/A` sections, file-by-file narration, copied commit logs, and redundant diff summaries. Do not put `Checks`, `Verification`, `Test plan`, or similar validation sections in the PR body; put local check results only in the final user report.
|
|
75
|
-
|
|
76
|
-
Treat the current title, body, and commit messages as fallible context. After material follow-up commits, re-check the title and rewrite the body against the current diff with `github_updatePullRequest`. Never include customer data, PII, secrets, or sensitive thread context, especially in public repositories. Resolve requested assignee/reviewer handles from evidence; skip unconfirmed identities.
|
|
77
|
-
|
|
78
|
-
If PR creation or update is blocked, report the exact failed command/tool call and leave the committed branch intact.
|
|
79
|
-
|
|
80
|
-
### 6. Follow and report
|
|
81
|
-
|
|
82
|
-
When PR creation returns a subscribable resource hint, subscribe to suggested review/CI events. Report only actionable feedback addressed, build failures fixed, fully green/ready state, or merge.
|
|
32
|
+
- Push the branch before creating a bot-owned PR. Runtime injects installation credentials; never ask for a user token for bot pushes.
|
|
33
|
+
- Tool-routing denials need the named tool. Only upstream denials justify permission remediation.
|
|
34
|
+
- Stop for ambiguous targets, missing access, destructive ops, or unresolved upstream permission failures.
|
|
35
|
+
- Unless the user opts out, finish completed edits with a pushed branch and PR (draft by default).
|
|
36
|
+
- Report to the user: repo, branch, PR URL/number, local check results, and anything not run.
|
|
83
37
|
|
|
84
|
-
|
|
38
|
+
Do not install or repair the GitHub plugin runtime from this skill. The plugin manifest owns that.
|
|
@@ -2,44 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
## Intent
|
|
4
4
|
|
|
5
|
-
Guide evidence-first GitHub repository work from inspection through a reviewable result without
|
|
5
|
+
Guide evidence-first GitHub repository work from inspection through a reviewable result without loading command and packaging detail on every run.
|
|
6
6
|
|
|
7
7
|
## Behavioral contract
|
|
8
8
|
|
|
9
9
|
- Resolve and inspect the repository before acting.
|
|
10
|
-
- Preserve unrelated work
|
|
11
|
-
- Treat shallow clones as inspection checkouts;
|
|
12
|
-
- Install
|
|
13
|
-
-
|
|
14
|
-
- Write conventional PR titles
|
|
15
|
-
-
|
|
16
|
-
- Treat existing PR metadata and commit messages as fallible context, and refresh the title/body against the current diff after material changes.
|
|
17
|
-
- Report exact validation and permission failures without claiming partial work is complete.
|
|
10
|
+
- Preserve unrelated work; reject destructive Git operations.
|
|
11
|
+
- Treat shallow clones as inspection checkouts; deepen before history work; never force-push around missing ancestry.
|
|
12
|
+
- Install dependencies with the lockfile frozen mode before verification when needed.
|
|
13
|
+
- Finish completed edits with a pushed PR unless the user opts out; default draft.
|
|
14
|
+
- Write conventional PR titles and short plain-English bodies; keep check results out of the PR body.
|
|
15
|
+
- Report exact validation and permission failures.
|
|
18
16
|
|
|
19
17
|
## Runtime architecture
|
|
20
18
|
|
|
21
|
-
- `SKILL.md`:
|
|
19
|
+
- `SKILL.md`: always-on rules and reference router.
|
|
22
20
|
- `references/api-surface.md`: command and permission lookup.
|
|
21
|
+
- `references/workflow.md`: edit, verify, and PR packaging.
|
|
23
22
|
- `references/troubleshooting-workarounds.md`: failure recovery.
|
|
24
23
|
|
|
25
|
-
|
|
24
|
+
The GitHub plugin manifest owns runtime install, OAuth, and env setup. Do not move those into this skill.
|
|
26
25
|
|
|
27
|
-
##
|
|
26
|
+
## Triggers
|
|
28
27
|
|
|
29
28
|
Should trigger for implementation, source inspection, clone/fetch/branch work, commits, PRs, reviews, CI, and repository credential failures.
|
|
30
29
|
|
|
31
|
-
Should not trigger for
|
|
30
|
+
Should not trigger for issue-only ops, non-GitHub ticketing, product telemetry, or docs with no repository task.
|
|
32
31
|
|
|
33
32
|
## Validation
|
|
34
33
|
|
|
35
|
-
After material edits:
|
|
36
|
-
|
|
37
34
|
1. Run the repository skill validator.
|
|
38
|
-
2.
|
|
39
|
-
3. Confirm
|
|
35
|
+
2. Confirm all referenced files exist.
|
|
36
|
+
3. Confirm `SKILL.md` stays a router (workflow detail lives in references).
|
|
40
37
|
4. Confirm code-edit completion defaults to a draft PR.
|
|
41
|
-
5. Confirm dependency installation and shallow-history recovery do not permit lockfile mutation or force-push shortcuts.
|
|
42
38
|
|
|
43
39
|
## Maintenance
|
|
44
40
|
|
|
45
|
-
Keep
|
|
41
|
+
Keep always-on policy in `SKILL.md`. Move syntax matrices, packaging steps, and failure tables to routed references. Delete duplicates instead of restating them.
|
|
@@ -1,86 +1,56 @@
|
|
|
1
|
-
# GitHub API
|
|
2
|
-
|
|
3
|
-
PR
|
|
4
|
-
|
|
5
|
-
## Repo
|
|
6
|
-
|
|
7
|
-
When the user omits `owner/repo`, resolve
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
| `github.
|
|
16
|
-
| `github.
|
|
17
|
-
| `github.
|
|
18
|
-
| `github.
|
|
19
|
-
| `github.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
|
26
|
-
|
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
| Check pull request status | `gh pr checks NUMBER --repo owner/repo` |
|
|
58
|
-
| View PR review comments | `gh api repos/{owner}/{repo}/pulls/{number}/comments` |
|
|
59
|
-
| View PR reviews | `gh api repos/{owner}/{repo}/pulls/{number}/reviews` |
|
|
60
|
-
| List workflow runs | `gh run list -R owner/repo --workflow WORKFLOW [--limit N] [--json ...]` |
|
|
61
|
-
| View workflow run | `gh run view RUN_ID -R owner/repo [--json ...] [--log-failed]` |
|
|
62
|
-
| Watch workflow run | `gh run watch RUN_ID -R owner/repo --exit-status` |
|
|
63
|
-
|
|
64
|
-
## Config helpers
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
jr-rpc config get github.repo
|
|
68
|
-
jr-rpc config set github.repo owner/repo
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Behavior notes
|
|
72
|
-
|
|
73
|
-
- Prefer `--json` output for machine-readable parsing where available.
|
|
74
|
-
- Pass extra `git clone` flags after `--` (e.g. `gh repo clone owner/repo -- --depth=1`).
|
|
75
|
-
- A local `git commit` does not call GitHub. Pushing that commit uses Junior's repository-scoped installation credential and requires `github.contents.write` on the target repo.
|
|
76
|
-
- If the commit changes workflow files under `.github/workflows`, the App installation needs Workflows write in addition to Contents write.
|
|
77
|
-
- Before rebasing, merge-base analysis, blame/history inspection, or a base comparison, check whether the repository is shallow. Fetch a bounded depth of the base into `refs/remotes/origin/BASE`, deepen incrementally until the needed ancestry is present, and compare against `origin/BASE`; use `--unshallow` only when bounded deepening is insufficient. Never force-push to work around missing ancestry.
|
|
78
|
-
- Before `github_createPullRequest`, push the head branch explicitly and resolve the target repo's default branch for `base`. That push requires GitHub write access to the remote.
|
|
79
|
-
- Use `github_updatePullRequest` for title, body, base, or open/closed state changes. Do not raw-`PATCH` `/repos/.../pulls/NUMBER`; that path is denied so Junior can keep the conversation footer.
|
|
80
|
-
- Merge, fork creation, REST contents/Git database writes, and repository administration are outside the current write allowlist.
|
|
81
|
-
- Pull request reviews and inline review comments use the same repository-scoped `installation-write` credential as other bot-owned PR writes, so they post as Junior even on headless turns. Merge remains denied.
|
|
82
|
-
- Resolve review threads with `github_resolvePullRequestReviewThread`. That tool is the Junior equivalent of `gh api graphql` `resolveReviewThread`; raw GraphQL mutations stay denied, and the tool only succeeds on Junior-authored PRs.
|
|
83
|
-
- If the explicit `git push` fails with 401/403 or another access/permission error, verify the repo context and retry once. If it still fails, load troubleshooting guidance and report the exact command failure.
|
|
84
|
-
- PR comments, labels, and assignees use GitHub's issue endpoints; use the `github-issues` REST guidance for those operations. All allowlisted bot writes share the same repository-scoped `installation-write` credential.
|
|
85
|
-
- To embed a local image in a GitHub issue, pull request, review, or comment, call `publishImage` first. That tool returns a durable public URL. The published image is public to anyone on the internet who has the URL. Embed the URL with normal GitHub Markdown. Do not use private Slack file links or conversation attachment URLs.
|
|
86
|
-
- Return actionable errors for access, permission, not-found, and validation failures.
|
|
1
|
+
# GitHub API surface — code and pull requests
|
|
2
|
+
|
|
3
|
+
PR create/update and review-thread resolve use the tools named in `SKILL.md`. Other supported mutations use allowlisted REST through `gh api`. Generic GraphQL-backed `gh pr` mutations are not supported.
|
|
4
|
+
|
|
5
|
+
## Repo targeting
|
|
6
|
+
|
|
7
|
+
When the user omits `owner/repo`, resolve with standalone `jr-rpc config get github.repo`, then pass `--repo owner/repo` on the next `gh`/`git` command. Explicit repo flags target the command; they are not a credential scope.
|
|
8
|
+
|
|
9
|
+
## Permissions
|
|
10
|
+
|
|
11
|
+
| Capability | Commands |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `github.actions.read` | `gh run list`, `gh run view`, `gh run watch`, `gh workflow list`, `gh workflow view` |
|
|
14
|
+
| `github.actions.write` | `gh workflow run`, `gh run rerun`, `gh run cancel` |
|
|
15
|
+
| `github.contents.read` | `gh repo clone`, `git fetch` |
|
|
16
|
+
| `github.contents.write` | Git smart-HTTP `git push` only |
|
|
17
|
+
| `github.workflows.write` | Workflow-file changes on push |
|
|
18
|
+
| `github.pull-requests.read` | `gh pr view`, `gh pr list`, `gh pr diff`, `gh pr checks` |
|
|
19
|
+
| `github.pull-requests.write` | Typed PR create and allowlisted REST PR lifecycle |
|
|
20
|
+
|
|
21
|
+
## Commands
|
|
22
|
+
|
|
23
|
+
| Operation | Command |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| Clone (default shallow) | `gh repo clone owner/repo [DIR] -- --depth=1` |
|
|
26
|
+
| Fetch bounded base | `git -C DIR fetch --depth=N origin BASE:refs/remotes/origin/BASE` |
|
|
27
|
+
| Deepen base | `git -C DIR fetch --deepen=N origin BASE:refs/remotes/origin/BASE` |
|
|
28
|
+
| Unshallow | `git -C DIR fetch --unshallow origin` |
|
|
29
|
+
| Shallow check | `git -C DIR rev-parse --is-shallow-repository` |
|
|
30
|
+
| Branch / status | `git -C DIR branch --show-current` / `git -C DIR status --short --branch` |
|
|
31
|
+
| Log / diff vs base | `git -C DIR log origin/BASE..HEAD --oneline` / `git -C DIR diff origin/BASE...HEAD` |
|
|
32
|
+
| Default branch | `gh repo view owner/repo --json defaultBranchRef --jq .defaultBranchRef.name` |
|
|
33
|
+
| Create branch | `git -C DIR checkout -b BRANCH` |
|
|
34
|
+
| Commit | `git -C DIR add -A && git -C DIR commit -m "message"` |
|
|
35
|
+
| Push | `git -C DIR push -u origin BRANCH` |
|
|
36
|
+
| Workflow dispatch | `gh workflow run WORKFLOW --repo owner/repo --ref REF [-f key=value]` |
|
|
37
|
+
| Rerun / cancel | `gh run rerun RUN_ID -R owner/repo [--failed]` / `gh run cancel RUN_ID -R owner/repo` |
|
|
38
|
+
| Ready for review | `gh api repos/owner/repo/pulls/NUMBER/ready_for_review --method POST` |
|
|
39
|
+
| Request reviewers | `gh api repos/owner/repo/pulls/NUMBER/requested_reviewers --method POST --input reviewers.json` |
|
|
40
|
+
| Submit review | `gh api repos/owner/repo/pulls/NUMBER/reviews --method POST --input review.json` |
|
|
41
|
+
| Inline review comment | `gh api repos/owner/repo/pulls/NUMBER/comments --method POST --input comment.json` |
|
|
42
|
+
| View PR / checks | `gh pr view NUMBER --repo owner/repo` / `gh pr checks NUMBER --repo owner/repo` |
|
|
43
|
+
| Diff PR | `gh pr diff NUMBER --repo owner/repo` |
|
|
44
|
+
| List runs | `gh run list -R owner/repo --workflow WORKFLOW` |
|
|
45
|
+
| View / watch run | `gh run view RUN_ID -R owner/repo` / `gh run watch RUN_ID -R owner/repo --exit-status` |
|
|
46
|
+
|
|
47
|
+
## Notes
|
|
48
|
+
|
|
49
|
+
- Prefer `--json` where available. Pass clone flags after `--`.
|
|
50
|
+
- Local commit does not call GitHub. Push uses installation credentials (`contents.write`; workflow files also need `workflows.write`).
|
|
51
|
+
- Before history-dependent git work, deepen shallow clones; never force-push around missing ancestry.
|
|
52
|
+
- Push head and resolve default `base` before `github_createPullRequest`.
|
|
53
|
+
- Denied: merge, forks, REST contents/Git database writes, repo admin, raw PR PATCH, raw GraphQL mutations.
|
|
54
|
+
- Reviews and inline comments post as the App bot via `installation-write`.
|
|
55
|
+
- PR comments/labels/assignees use issue endpoints; load `github-issues` for those.
|
|
56
|
+
- Embed local images with `publishImage` first (public URL). Do not use private Slack file links.
|
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
# GitHub CLI
|
|
1
|
+
# GitHub CLI troubleshooting — code and pull requests
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
| Symptom | Likely cause | Fix |
|
|
4
|
+
| --- | --- | --- |
|
|
5
|
+
| `unknown command` from `gh` | Runtime `gh` missing or too old | Report GitHub plugin runtime dependency unavailable |
|
|
6
|
+
| `unknown flag: --depth` on clone | Clone flags before `--` | `gh repo clone owner/repo -- --depth=1` |
|
|
7
|
+
| Missing `--repo` | No explicit target | Resolve `github.repo`, pass `--repo owner/repo` |
|
|
8
|
+
| Wrong repo authenticated | Stale default | Pass `--repo owner/repo` or update `github.repo` |
|
|
9
|
+
| GraphQL: could not resolve repository | Bad slug or no access | Validate `owner/repo` and App install |
|
|
10
|
+
| 401 Unauthorized | Credential rejected | Confirm target; distinguish user OAuth vs installation setup |
|
|
11
|
+
| `junior-auth-required` `user-write` | Missing/stale user OAuth | Follow private OAuth prompt; never ask for pasted tokens |
|
|
12
|
+
| `git push` 401/403 | Install scope, remote, or permissions | Verify remote/repo, retry once, then report install scope |
|
|
13
|
+
| `permission_denied` `source: "upstream"` | GitHub 403 after inject | Not a local runtime block; use grant/account/SSO fields |
|
|
14
|
+
| 403 without upstream `permission_denied` | Local policy denial | Read body; follow required-tool guidance |
|
|
15
|
+
| `Token scopes: none` on `gh auth status` | Normal for App user tokens | Use App permissions / accepted-permissions headers |
|
|
16
|
+
| `github_createPullRequest` 401/403 | Install/repo lacks write | Report install scope; do not fall back to user OAuth |
|
|
17
|
+
| Create PR 422 on `head` | Branch not pushed | Push branch; retry with explicit head/base |
|
|
18
|
+
| Create/update PR 422 on `base` | Base missing | Resolve default branch; retry |
|
|
19
|
+
| 403 names `github_updatePullRequest` | Raw PR PATCH blocked | Use `github_updatePullRequest` |
|
|
20
|
+
| GraphQL mutations not enabled | Raw resolve blocked | Use `github_resolvePullRequestReviewThread` (bot-authored PRs only) |
|
|
21
|
+
| Missing blame/old history | Shallow clone | Deepen needed refs; `--unshallow` only if required |
|
|
22
|
+
| Odd ancestry / rebase fails | Base ref missing locally | Fetch `BASE:refs/remotes/origin/BASE`, deepen, use `origin/BASE` |
|
|
23
|
+
| Missing deps in tests | Not installed | Frozen/immutable install for the lockfile; do not rewrite lockfile |
|
|
24
|
+
| Frozen install fails | Drift or registry | Report exact failure |
|
|
25
|
+
| `dnf install gh failed` | Plugin bootstrap | Report runtime bootstrap failure; do not repair from skill |
|
|
4
26
|
|
|
5
|
-
|
|
6
|
-
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
7
|
-
| `unknown command "..."` from `gh` | CLI version too old or wrong binary in the plugin runtime. | Verify `gh --version`; if it is unavailable or too old, report that the GitHub plugin runtime dependency is not available. |
|
|
8
|
-
| `unknown flag: --depth` from `gh repo clone` | `git clone` flags were passed before `--`. | Pass clone flags after `--`, for example `gh repo clone owner/repo -- --depth=1`. |
|
|
9
|
-
| `Missing required option --repo` | Repo not passed and no default was resolved. | Resolve with `jr-rpc config get github.repo`; pass `--repo owner/repo` explicitly when missing. |
|
|
10
|
-
| Command affects or authenticates against the wrong repo | Stale `github.repo` default or authenticated command missing explicit repo. | Pass `--repo owner/repo` for the target repository, or update `github.repo` before retrying. |
|
|
11
|
-
| `GraphQL: Could not resolve to a Repository` | Repo slug is wrong or inaccessible. | Validate `owner/repo` and confirm app installation on target repository. |
|
|
12
|
-
| 401 Unauthorized | Issued GitHub credentials were rejected upstream. | Verify the target repo, then use the grant/auth signal to distinguish stale user OAuth from app installation or host env setup. |
|
|
13
|
-
| `junior-auth-required provider=github grant=user-write` | User-to-server OAuth is missing or stale for a human-identity operation. | Follow the private OAuth prompt; do not ask the user to paste or manage tokens manually. |
|
|
14
|
-
| `git push` fails with 401/403 or auth/permission output | Write permission is missing, app installation is too narrow, or remote is wrong. | Verify the remote and repo context, retry once, then confirm app permissions and installation scope if it still fails. |
|
|
15
|
-
| Bash result includes `permission_denied` with `source: "upstream"` | GitHub returned 403 after Junior injected the named grant. | Do not call this a Junior runtime block. Use the message, connected account, upstream target, grant requirements, accepted-permissions, and SSO fields to explain the GitHub denial. |
|
|
16
|
-
| 403 without `permission_denied` where `source: "upstream"` | Junior may have rejected an unsupported route before contacting GitHub. | Read the response body. Follow any required-tool instruction; do not ask for GitHub permissions unless the failure is confirmed upstream. |
|
|
17
|
-
| `gh auth status` shows `Token scopes: none` | Expected for GitHub App user-to-server tokens. | Do not treat this as read-only proof. Use the failed command, `permission_denied.acceptedPermissions`, and GitHub App permissions instead. |
|
|
18
|
-
| `github_createPullRequest` returns upstream 401/403 | The App installation or target repository does not permit the operation. | Use the structured upstream denial to verify installation scope and accepted permissions; do not request user OAuth for this bot-owned operation. |
|
|
19
|
-
| `github_createPullRequest` returns 422 for `head` | The head branch was not pushed or the explicit head ref is wrong. | Push the branch, then retry with explicit `repo`, `head`, and `base` values. |
|
|
20
|
-
| `github_createPullRequest` fails with 422 validation on `base` | The `base` branch does not exist in the target repo. | Resolve the default branch with `gh repo view owner/repo --json defaultBranchRef --jq .defaultBranchRef.name`, then retry with that value as `base`. |
|
|
21
|
-
| `403` names `github_updatePullRequest` | Raw PR title/body/base/state PATCH was blocked so Junior can own the footer. | Retry with `github_updatePullRequest`; do not use `gh api .../pulls/NUMBER --method PATCH` or `gh pr edit`. |
|
|
22
|
-
| `GraphQL mutations are not enabled` / resolve thread denied | Raw `gh api graphql` `resolveReviewThread` is blocked. | Retry with `github_resolvePullRequestReviewThread({ repo, threadId })`. Only Junior-authored PRs are allowed. |
|
|
23
|
-
| `github_updatePullRequest` returns upstream 401/403 | The App installation or target repository does not permit the operation. | Use the structured upstream denial to verify installation scope and accepted permissions; do not request user OAuth for this bot-owned operation. |
|
|
24
|
-
| `git blame`, long log history, or old commits are missing after clone | Repo was cloned shallow by design. | Fetch the required ref and deepen it incrementally; use `--unshallow` only when bounded deepening is insufficient. |
|
|
25
|
-
| Rebase, merge-base, or `origin/BASE...HEAD` comparison fails or gives odd ancestry | Required ancestry or the remote-tracking base ref is absent from the shallow clone. | Fetch a bounded depth into `BASE:refs/remotes/origin/BASE`, deepen that base ref until the merge base exists, and compare or rebase against `origin/BASE`. Never force-push around incomplete history. |
|
|
26
|
-
| Tests fail because dependencies or executables are missing | Repository dependencies were not installed. | Detect the lockfile and run the repo-native frozen/immutable install. Do not rewrite the lockfile unless dependency changes are part of the task. |
|
|
27
|
-
| Frozen/immutable dependency install fails | Lockfile drift, unavailable registry, incompatible runtime, or environment issue. | Report the exact install failure. Do not fall back to a lockfile-updating install unless the requested work intentionally changes dependencies. |
|
|
28
|
-
| `sandbox setup failed (dnf install gh failed ...)` | `gh` package not available from the plugin runtime dependency bootstrap. | Report the plugin runtime bootstrap failure; do not try to repair package installation from the skill workflow. |
|
|
27
|
+
## Retry rules
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
- Do not describe `permission_denied` with `source: "upstream"` as Junior blocking the request. It means the egress proxy injected a credential, forwarded the request, and recorded GitHub's upstream 403. Prefer its `account` and `grant.requirements` fields over inference when explaining what to fix.
|
|
36
|
-
- Do not infer permission level from OAuth scopes. GitHub App user tokens report no OAuth scopes; GitHub App permissions and accepted-permissions headers are the useful evidence.
|
|
37
|
-
- For persistent permission problems, return explicit remediation and stop.
|
|
29
|
+
- Retry once for transient transport after verifying repo context.
|
|
30
|
+
- Do not loop on repeated 401/403/404 validation errors.
|
|
31
|
+
- `user-read`/`user-write` gaps → private App OAuth. `installation-*` failures → App permission/install/host setup only.
|
|
32
|
+
- Prefer `permission_denied` structured fields over guessing.
|
|
33
|
+
- Persistent permission problems: report remediation and stop.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Edit and PR packaging
|
|
2
|
+
|
|
3
|
+
Open this when making repository edits, not for read-only inspection.
|
|
4
|
+
|
|
5
|
+
## Resolve and inspect
|
|
6
|
+
|
|
7
|
+
1. Identify repo, checkout, branches, worktree, package manager, and relevant checks.
|
|
8
|
+
2. Prefer an existing checkout or matching Workspace; otherwise clone shallowly.
|
|
9
|
+
3. If clone returns a Workspace match error, switch Workspace or pass `allowAdHoc=true`.
|
|
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
|
+
5. For edits, pick the smallest credible validation path. Capture a baseline when a failure may be pre-existing.
|
|
12
|
+
|
|
13
|
+
## Investigate
|
|
14
|
+
|
|
15
|
+
1. Find where the behavior lives, current vs requested, root cause or gap, and the smallest proof.
|
|
16
|
+
2. Read linked issues, PRs, specs, and failing output when provided.
|
|
17
|
+
3. For PRs, inspect conversation, inline comments, reviews, diff, and checks.
|
|
18
|
+
4. Investigation-only requests: report evidence; do not edit.
|
|
19
|
+
|
|
20
|
+
## Edit
|
|
21
|
+
|
|
22
|
+
1. Make the smallest coherent change. Follow local patterns. Avoid speculative cleanup.
|
|
23
|
+
2. After a failed attempt, re-check root cause before patching again.
|
|
24
|
+
3. Before repo checks, ensure dependencies with the lockfile-native frozen install. Do not rewrite the lockfile unless dependency changes are part of the task.
|
|
25
|
+
|
|
26
|
+
## Verify
|
|
27
|
+
|
|
28
|
+
1. Run targeted changed-file/package checks before broad suites.
|
|
29
|
+
2. Separate regressions from baseline failures.
|
|
30
|
+
3. Instruction-only changes: structural checks plus content review.
|
|
31
|
+
|
|
32
|
+
## Package
|
|
33
|
+
|
|
34
|
+
1. Reuse the current non-default branch or create a focused branch.
|
|
35
|
+
2. Commit with repo conventions, else `<type>(<scope>): <Subject>` imperative present, no agent branding.
|
|
36
|
+
3. Push with `git push -u origin BRANCH`.
|
|
37
|
+
4. Resolve the actual default branch.
|
|
38
|
+
5. Update an existing PR for the branch with `github_updatePullRequest`, or create with `github_createPullRequest` (`draft: true` unless ready-for-review is required).
|
|
39
|
+
6. PR title matches the current dominant change, same conventional form as commits.
|
|
40
|
+
7. PR body: short, plain English, what changed and why. Only context the diff cannot show. No empty sections, file lists, commit logs, or Checks/Verification/Test plan blocks. Put local check results in the user report only.
|
|
41
|
+
8. After material follow-up commits, refresh title and body against the current diff.
|
|
42
|
+
9. Never put customer data, PII, secrets, or sensitive thread context in public PR text.
|
|
43
|
+
10. If PR create/update is blocked, report the exact failure and leave the committed branch intact.
|
|
44
|
+
|
|
45
|
+
## Follow
|
|
46
|
+
|
|
47
|
+
When PR creation returns a subscribable hint, subscribe to suggested review/CI events. Report only actionable feedback fixed, build failures fixed, green/ready, or merge.
|
|
@@ -92,8 +92,8 @@ Run [references/issue-quality-checklist.md](references/issue-quality-checklist.m
|
|
|
92
92
|
|
|
93
93
|
### 5. Execute
|
|
94
94
|
|
|
95
|
-
- Use `github_createIssue` for new issues so
|
|
96
|
-
- Use `github_updateIssue` for issue title, body, or state changes so
|
|
95
|
+
- Use `github_createIssue` for new issues so the runtime owns idempotency and session-link footers.
|
|
96
|
+
- Use `github_updateIssue` for issue title, body, or state changes so the runtime preserves requester attribution and the session footer.
|
|
97
97
|
- Use `gh` commands from [references/api-surface.md](references/api-surface.md) for comments, labels, assignees, and read-only operations.
|
|
98
98
|
- For issue listing or other read-only inspection, prefer `--json` output so empty results still produce deterministic stdout.
|
|
99
99
|
- Check duplicates silently before creating a new issue. Do not mention this check in the final reply unless a duplicate blocks creation.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# GitHub Issue API Surface
|
|
2
2
|
|
|
3
|
-
Issue creation uses `github_createIssue`. Issue title, body, and state updates use `github_updateIssue` so
|
|
3
|
+
Issue creation uses `github_createIssue`. Issue title, body, and state updates use `github_updateIssue` so the runtime keeps requester attribution and the conversation footer. Comments, labels, assignees, and reads use allowlisted REST endpoints through `gh api`; generic GraphQL-backed `gh issue` mutations are not supported.
|
|
4
4
|
|
|
5
5
|
## Repo scoping
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ Use this table to recover quickly while keeping operations deterministic.
|
|
|
10
10
|
| `GraphQL: Could not resolve to a Repository` | Repo slug is wrong or inaccessible. | Validate `owner/repo` and confirm app installation on target repository. |
|
|
11
11
|
| 401 Unauthorized | Issued GitHub credentials were rejected upstream. | Verify the target repo, then use the grant/auth signal to distinguish stale user OAuth from app installation or host env setup. |
|
|
12
12
|
| `junior-auth-required provider=github grant=user-write` | User-to-server OAuth is missing or stale for a human-identity operation. | Follow the private OAuth prompt; do not ask the user to paste or manage tokens manually. |
|
|
13
|
-
| 403 without `permission_denied` where `source: "upstream"` |
|
|
13
|
+
| 403 without `permission_denied` where `source: "upstream"` | The runtime may have rejected an unsupported route before contacting GitHub. | Read the response body. Follow any required-tool instruction; do not ask for GitHub permissions unless the failure is confirmed upstream. |
|
|
14
14
|
| `permission_denied` with `source: "upstream"` | GitHub rejected the injected installation credential. | Verify the target, accepted permissions, and App installation scope; do not request user OAuth for a bot-owned issue operation. |
|
|
15
15
|
| 404 Not Found | Issue number or repo is wrong. | Validate repo + issue ID with `gh issue view NUMBER --repo owner/repo`. |
|
|
16
16
|
| Issue label mutation fails | Wrong REST payload or wrong repo context. | Use the allowlisted issue labels endpoint with an explicit `owner/repo` path and valid JSON input. |
|