Repository navigation
Description
Problem
Junior can't create or manage GitHub stacked PRs. Running gh stack from the sandbox fails with a 403. Junior's GitHub egress proxy returns the error before the request reaches GitHub:
POST /repos/{owner}/{repo}/stacks
403 {"error":"Junior does not support this GitHub write request. Use the matching GitHub tool or a supported REST endpoint."}
Reads work: GET /repos/{owner}/{repo}/stacks returns 200.
Why
packages/junior-github/src/egress-policy.ts only allows the sandbox to make GitHub writes listed in githubApiWriteGrantName. None of the /stacks endpoints are listed.
gh stack (github/gh-stack v0.2.1, internal/github/github.go) also makes calls that remain blocked even if /stacks is allowed:
- REST
POST /repos/{owner}/{repo}/stacks,/stacks/{id}/add, and/stacks/{id}/unstack: not allowlisted - GraphQL mutations
createPullRequest,markPullRequestReadyForReview, anddisablePullRequestAutoMerge: sandbox GraphQL mutations are blocked by design PATCH /repos/{owner}/{repo}/pulls/{number}to change base branches: reserved forgithub_updatePullRequestmerge-async: Junior does not merge, by policy
Proposal
Add a typed host-side tool, for example github_linkPullRequestStack, following Junior's existing pattern for writes that create or reshape issues and PRs (GITHUB_BODY_WRITES plus typed github_* tools). It could:
- accept an ordered list of PR numbers
- verify that each PR's base is the head branch of the PR below it
- call the REST stack endpoints through
ctx.egress.fetch - handle retries safely and record requester attribution like other PR tools
Intended flow: git pushes the branches, github_createPullRequest opens each PR with its base set to the branch below, then github_linkPullRequestStack links them.
Smaller alternative
Allowlist POST /repos/{owner}/{repo}/stacks and /stacks/{id}/(add|unstack) as installation-write in githubApiWriteGrantName, and document them in the github-code skill's api-surface.md. This only enables gh stack link <PR numbers> for PRs that already exist. Passing branch names or using --open would still hit the blocked GraphQL calls, so users would need to know the workaround.
Open question
Not verified: whether GitHub accepts a GitHub App installation token for POST /stacks. The read endpoint asks for pull_requests=read, so writes probably need pull_requests=write, which the App already has for creating PRs. Verify this before implementing either option.
via @szokeasaurusrex.
--
Activity
feat(github): Allow restacking stacked pull requests
feat(github): Allow force-with-lease pushes to owned branches
ref(github): Trim stacked PR skill guidance
feat(github): Support stacked pull requests with gh stack (#2104)