Skip to content

Add mergePullRequest to the github integration client (let agents merge without gh) #147

Description

@khaliqgant

Summary

The github integration client (GithubClient) can createPullRequest, postReview, comment, etc. — but has no merge method. So an agent that wants to merge a PR has to shell out to gh pr merge, which (a) is the lone gh/git use left in the showcase agents, and (b) doesn't fit the sandbox model (the repo is a tarball mount with no .git/gh auth; GitHub writes are meant to go through the integration's writeback).

Add mergePullRequest(...) so agents merge through the integration like every other GitHub write.

Not blocking

The review agent (AgentWorkforce/agents#1, review/agent.tsmergePr) works today via gh pr merge. This is a cleanup that removes the last gh call; nothing depends on it.

Proposed API

// GithubClient
mergePullRequest(args: {
  owner: string;
  repo: string;
  number: number;
  method?: 'merge' | 'squash' | 'rebase'; // default 'squash'
  commitTitle?: string;
  commitMessage?: string;
}): Promise<{ merged: boolean; sha?: string }>;

Usage in the review agent then becomes:

await ctx.github.mergePullRequest({ owner, repo, number, method: 'squash' });

Repos / files to touch

Mirror the createPullRequest path (client writes a VFS draft → writeback worker calls the GitHub REST API):

  1. AgentWorkforce/workforcepackages/runtime/src/clients/github.ts
    Add mergePullRequest to the GithubClient interface + impl (write a draft via writeJsonFile, e.g. to /github/repos/{owner}/{repo}/pulls/{n}/merge.json).
  2. AgentWorkforce/relayfile-adapterspackages/github/src/writeback.ts (GitHubWritebackHandler, today only handles pulls/{n}/reviews/...) + packages/github/github.mapping.yaml (writebacks: block)
    Map the merge draft path → PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge (body: merge_method, optional commit_title/commit_message). Add a writeback.test.ts case.
  3. AgentWorkforce/cloud — verify the relayfile-writeback-consumer executes the new request shape (likely generic — no change, just confirm).
  4. AgentWorkforce/agentsreview/agent.ts mergePr: swap ctx.sandbox.exec('gh pr merge …') for ctx.github.mergePullRequest(...) (drops the last gh).

Acceptance

  • ctx.github.mergePullRequest(...) merges a PR end-to-end via the writeback (no gh).
  • review agent merges on authorized approval with no gh/sandbox shell-out.

🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions