oliver-zehentleitner / maity

tools: open pull requests and edit their title and body over REST from cloud sessions

Sign in to report

tsk-b3mzbvb9mzgf Done An agent

Adopted by the maintainer from the jour fixe of 2026-11-08 (round jfx-x83wyff3vxm0, req-8pbgznkgfmkt). Cloud members (eyqf, unr9) cannot open a PR or change its body: the GitHub tool says 'invalid session', GraphQL is refused. Build a small tool next to tools/overlap.sh (or a maity command) using gh api repos/{o}/{r}/pulls POST and PATCH, host from remote.origin.url, with fake-gh tests like #1475. First step: one cloud member tries one write, to see whether its token may write pulls at all; if not, report and stop. eyqf offered to take it.

Notes

  1. An agent · Nov 8, 2026, 14:09 UTC

    Step 1, the write probe: works. From this cloud session (eyqf), gh api -X PATCH repos/oliver-zehentleitner/maity/pulls/1490 -f title=<its current title> answered 200 (a no-op: same title, updated_at unchanged). Without write permission GitHub answers 403, so the session's token may write pulls. (GraphQL stays refused; REST is not.)

    Plan (before code):

    • tools/pr.sh, bash beside tools/overlap.sh, same style. Owner, repo and host are taken from remote.origin.url exactly as overlap.sh does it (with the loopback-proxy rule, --hostname); gh only sends.
    • tools/pr.sh open --title T --body-file F [--base main] [--draft] [<branch>] → POST repos/{o}/{r}/pulls, head = the branch (default: checked out), base main. It refuses unless the branch exists on origin with the same head as local (no PR for unpushed work). It prints the number, URL and head sha.
    • tools/pr.sh edit <n> [--title T] [--body-file F] → PATCH repos/{o}/{r}/pulls/<n>. It refuses an edit that changes nothing, and refuses a PR whose head ref is not the checked-out branch (--branch B names another). All agents push as one GitHub account, so authorship cannot tell PRs apart, and the head ref is what keeps an agent to its own PR. It prints the fields as GitHub answered them.
    • The body always comes from a file (-F body=@file): no shell quoting of Markdown. Exit codes as overlap.sh: 0 done, 1 refused, 2 could not run.
    • Tests tools/test_pr.py with a fake gh, like #1475: what is sent (method, path, host, fields), both refusals, the origin URL forms, and a failed gh call → exit 2. CI already runs tools/test_*.py.
    • Docs: CONTRIBUTING.md (opening and editing a PR from a cloud session), a context/process.md entry (why REST and why the head-ref guard), changelog.d.
    • Out of scope: review threads, labels, merging (the lead's). overlap.sh stays unchanged: the origin parsing is copied, not shared, so this PR doesn't touch a tool in daily use; moving both onto one shared file can be a P3.

    Questions: (a) bash beside overlap.sh rather than a maity command (the CLI is the agents' tool for the hub, not GitHub)? (b) the head-ref guard on edit: OK?

  2. An agent · Nov 8, 2026, 14:09 UTC

    Boundary for tools/pr.sh (addendum to the plan nte-1yrvrtjjxmbf):
    Guaranteed:

    • It opens or edits a pull request of this checkout's origin repository only: owner, repo and host come from remote.origin.url, never from gh's defaults (GH_REPO, gh repo set-default, another logged-in host).
    • open opens a PR only for the given (or checked-out) branch, and only when origin has that branch at the same head as local. edit changes only the PR whose head ref is the checked-out branch (or --branch B), and only the fields given (title, body).
    • It sends exactly the title and the body file's bytes, adds nothing (no attribution line, no footer, no label), and changes nothing else on the PR.
    • It fails visibly: every refusal or failed gh call prints why on stderr and exits non-zero (1 refused, 2 could not run). A run that did not reach GitHub never exits 0. On success it prints what GitHub answered (number, URL, title, head sha), not what was asked.

    Not guaranteed / out of scope:

    • Not a review or merge tool: no review threads, labels, reviewers, merge, close or reopen.
    • It trusts the caller's gh login and clone configuration, as overlap.sh does. That one GitHub account is shared by all agents, so the head-ref check is what keeps an agent to its own PR. It is a guard against mistakes, not an access control.
    • No check that the body follows a template or the PR rules. The author and the lead stay responsible for the text.
    • Fork PRs (a head in another repository) are not supported.