Skip to content

Pull requests and GitHub ​

Yi Code reads repositories through its GitHub App and publishes with your own GitHub authorization. It opens one draft pull request per session, and only after you confirm. It never merges.

Connect GitHub ​

  1. Click "Connect GitHub" on a new task, or "Manage GitHub repositories" under the message box once connected.
  2. On GitHub, choose the account or organization and the repositories. "Only select repositories" keeps the agent to the ones you pick.
  3. After you install, GitHub asks you to authorize the app.

The authorization step is an ownership check. Anyone can type an installation ID into a URL, so Yi Code asks GitHub which installations your GitHub account can actually see, and connects the installation only if it is one of them. The request is tied to your signed-in user and organization, expires quickly and can be used once. No personal GitHub token is kept from this step.

Rules that follow from this:

  • An installation belongs to one Yi Code organization. Connecting it to a second one is refused with "This installation is already connected to another organization".
  • If you uninstall the app on GitHub, Yi Code marks the installation as removed. Turns on its repositories then fail with "The GitHub installation is unavailable. Reconnect GitHub." and are not charged.
  • If you reinstall from the same GitHub account, existing sessions on those repositories continue. A different GitHub account can't take over repositories connected through another account.

Any member of the organization can connect GitHub. Each signed-in member then sees the repositories of the organization's installations.

What the app is allowed to do ​

The app asks for read access to repository metadata and read and write access to contents and pull requests, only on the repositories you select. Yi Code uses the installation to:

  • List repositories and branches, and resolve a branch to a commit.
  • Fetch the pinned commit for a turn.

For reading, Yi Code uses short-lived installation tokens, limited to the one repository and the purpose at hand. Pushing the session's branch and opening its draft pull request use your own GitHub authorization, see Publish with your own GitHub account. No GitHub token ever appears in repository URLs, command arguments, turn snapshots, events or the sandbox.

The branch is pinned ​

When a session starts, the branch you picked is resolved to its current commit. Every turn in the session starts from that commit plus the session's own changes. The pull request's description names that commit as the pinned base.

Create the draft pull request ​

You can publish when:

  • The session is yours.
  • Its latest turn is a Code turn that succeeded.
  • The session has changes.
  • Your own GitHub account is connected and has write access to the repository.

Click "Create draft PR" in "Session details" and confirm "Publish the reviewed changes as a GitHub draft PR?". Yi Code then:

  1. Checks again that your GitHub account has write access to the repository.
  2. Fetches the pinned commit and applies the session's patch to it.
  3. Commits it as "Yi Code" and pushes it with your GitHub authorization to the branch preworld/{thread_id}, where {thread_id} is the session's ID.
  4. Opens a draft pull request as you, from that branch into the branch you picked, titled "Yi Code:" and the session's title.

"View draft PR" then links to it.

Update it ​

After a follow-up Code turn, the button reads "Update draft PR". The update is a new commit whose parent is the branch's current head, an ordinary fast-forward push. History is never rewritten and nothing is force-pushed. If the branch already matches, nothing is pushed.

If the connection drops while publishing, try again. Yi Code looks up the session's branch and pull request first and recovers the same pull request instead of opening a second one.

When it can't update ​

The session's branch belongs to the session. Yi Code stops instead of overwriting someone else's work:

MessageWhat happenedWhat to do
"The PR branch has external changes; start a new session"Someone pushed to preworld/… outside Yi Code.Start a new session.
"The session PR is closed; start a new session"The pull request was closed on GitHub.Start a new session.
"The session branch was removed; start a new session"The branch was deleted on GitHub.Start a new session.

Never merged for you ​

Yi Code creates pull requests as drafts and never marks them ready, approves or merges them. Review, CI and merging stay with your team on GitHub.

Who can publish ​

For repositories connected through the GitHub App, any member can publish their own sessions, as long as their own GitHub account has write access to the repository. Nobody can publish someone else's session, not even an owner. For projects an administrator added by URL in "Settings", only owners and administrators can publish, again only their own sessions. Every publication is recorded in the organization's audit log, and the turn keeps a record of the Yi Code user, the GitHub account, the repository, the commit and the pull request.

Publish with your own GitHub account ​

Publishing uses your own GitHub authorization, so a pull request is opened by you and GitHub applies your own permissions to it.

  1. Open "Session details". Under "GitHub publishing identity", click "Connect personal GitHub".
  2. Authorize the app on GitHub. You come back to Yi Code, and "Session details" shows your GitHub login.

As the panel says, "This account's repository write permission is checked before publication." Yi Code asks GitHub each time whether your account can push to the repository. If it can't, publishing stops with "Your GitHub account does not have write access to this repository."

  • One GitHub account can be connected to one Yi Code user. Connecting an account that another user already uses is refused.
  • The authorization is stored encrypted, with a key that only the API holds, and is refreshed as GitHub requires. It is never given to the sandbox or the execution hosts.
  • "Disconnect personal GitHub" stops publication at once and revokes the authorization on GitHub. If GitHub doesn't confirm the revocation, the page says "Publication is disabled. GitHub authorization revocation is still pending." and offers "Retry GitHub disconnection" and "Manage authorizations on GitHub".
  • "Reverify GitHub" connects again, for example after you changed accounts on GitHub.

Other Git servers ​

Draft pull requests are created only for repositories on github.com. With another Git server, which is possible in a private deployment, take the changes from changes.patch under "Raw logs and artifacts".