Repository navigation
Description
Problem
The optional write-pr-description helper runs context.sh (172 lines) before drafting. It prints what a drafter needs and nothing else: the branch, the base it compares against, the commits with their messages, the commit types, the changed files, a diff that is omitted past a cap, the template, the available labels, open issues, the published description and the current draft, read-only throughout. It re-derives base selection and the diff cap in shell separately from the pr preflight, so the two can disagree about which commits would land.
Part of #588 and #323. Delivers in Go the behavior of packages/agents/source/skills/write-pr-description/shared/scripts/context.sh. This change adds Go behavior only and switches no caller.
Acceptance criteria
- AC1: Given a base argument, an existing draft with a
basevalue, or neither, when the context prints, then the base is the argument, else the draft's base, else the default branch (the branchorigin/HEADnames, elsemain), and the report states the ref it compares against (origin's copy where one exists, else the local branch). - AC2: Given a draft whose base is the default branch, when the context and the preflight report both run on the same repository, then the set of commits each says would land (the range from the merge base with the compared ref to
HEAD) is the same and both compare against the same ref; the displayed lists keep their own ordering and caps (the preflight report's own order and cap, the context's oldest-first order and 250-line message cap), and below both caps the same commits appear in each. - AC3: Given commits ahead of the base, when the context prints, then it lists them oldest first with each commit's short hash, subject and body (capped at 250 lines) even when
log.showSignatureis on, then the commit types with counts, then the changed files with status and diffstat; given none ahead, then it says there is nothing to describe and to report that and stop, and the type and file sections print(none). - AC4: Given a diff longer than
WRITE_PR_DIFF_LINES(default 800), when the context prints, then the diff is omitted with guidance to read it one path at a time; given a diff within the bound, then it is printed in full. - AC5: Given a template, labels, open issues, a published pull request and a current draft, when the context prints, then each appears in the shell's order; an absent template says to report that and stop, a missing or unauthenticated
ghis stated as unavailable, at most 100 labels and 15 open issues are listed, and an absent draft prints(absent). - AC6: Given an existing draft, when the context prints, then it says the draft is being revised; given none, then it says the first draft is being written.
- AC7: Given a detached
HEAD, an unborn branch or no merge base, when the context runs, then it behaves as the shell does, with no new refusal. - AC8: Non-functional: the run writes nothing and makes no network connection other than the
ghreads above, and the optional writer still works when the helper is not deployed (the "preflight does not require the optional description writer" regression intests/skills/pr/scripts/pr-workflow.batsstill passes).
Scope and non-goals
Scope: the context report as behavior, with its branch-state facts read through the #322 child 01 state reader that child 05 also consumes (one implementation of those reads).
Non-goal: drafting, validation or the writer's scoped Claude permissions, which stay in the skill manifests. Non-goal: the stale-draft sweep, which preflight owns. Non-goal: changing the report layout or wording, or adding refusals. Non-goal: changing the template path the report reads, which stays .github/pull_request_template.md. Non-goal: switching the shell caller, which child 13 does.
Approach
Meet AC1 to AC8 with failing table-driven cases first on scratch repositories, comparing with the captured shell output. The context's own base choice (argument, then draft, then default) and its own display order and caps are kept. The package layout is the implementer's choice within those outcomes.
Dependencies
Blocked by: #910, #914, #850 (child 01 of #322, "Read commit workflow state in Go", also reached through #914), #755. This child adds no second reader of the facts that child supplies; the estimate below depends on that.
Prerequisite: #321.
Size
S. One pull request.
Verify plan
- AC1, AC3, AC4, AC5, AC6, AC7: Go tests over scratch repositories compare the output with the shell's, with a fake
ghthat is present, absent and unauthenticated. - AC2: a test builds one repository and compares the landing range (the set of commit identifiers) behind the context and behind the child 05 report, then a second repository with fewer commits than either cap and compares the printed hashes as sets; a third with more commits than the caps checks each report's own cap separately.
- AC8: a test asserts the set of files written is empty and no connection other than the stubbed
ghcalls is attempted;tests/skills/writersand the named regression inpr-workflow.batsstill pass. - Go tests run in the existing Go CI on macOS, Linux and Windows.
- Definition of done: D1 each AC is verified at the merged head, with the commands and results cited in the pull request's Verification. D2 an independent review approves the exact merged head, and every finding has a recorded disposition. D3 required checks pass with no gate loosened. D4 the leak scans the repository specifies are clean, and every post made for this work passes the per-post leak review before it is posted. D5 every commit is signed. D6 the documentation matches the change or the Verification says why there is no impact. D7 every commit has an
Assisted-bytrailer and the pull request has theprovenance:agent-assistedlabel. D8 the pull request stays within the size limits. D9 follow-ups are filed as issues and listed under Related. D10 the merge closes the issue through a closing reference, the board shows Done, and the finalStatus:comment names the merge commit.
Risks
A drafter that sees a different commit list than the validator writes a title the validator then rejects. The AC2 comparison is the control. Undo: revert the change; nothing calls the Go report yet and the shell prints the context.
Operator authority
None.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Work type
Projects
- StatusShow more project fieldsBacklog
Activity
tbhb-agent commentedon Oct 27, 2026
Refinement: READY — Print the write-pr-description context from agentrepo pr
Model: gpt-6-astra
Child 11 Print the write-pr-description context from agentrepo pr
Verdict: READY
Checked: The binding state-reader decision closes the dependency question. AC2 now compares commit membership separately from each report’s ordering and caps. Base precedence, full messages, oversized-diff omission and existing exceptional-state behavior remain preserved. Evidence:
packages/agents/source/skills/write-pr-description/shared/scripts/context.sh:63,packages/agents/source/skills/write-pr-description/shared/scripts/context.sh:87,packages/agents/source/skills/pr/shared/scripts/preflight.sh:159.Gaps: None.
Split: S remains plausible with state reading supplied by the prerequisite.
Definition of done
The definition of done for this issue (Feature). Tick each item and give its evidence.
check-leaks.shwith the repository's private-strings list, and the leak review of each post.docs/, CHANGELOG or help text), or the Verification section says "No doc impact" and why.provenance:agent-assistedlabel.Status:comment names the merge commit.mise run checkis green, and so are the coverage floorsmise run cover-go-checkandmise run cover-py-check, whichcheckdoesn't run.packages/agents/source/commits whatmise run generate-skills, thenmise run skill-tokens, thenapm installrewrite, in that order, andcheck-generated-skills(part oflint) passes.docs/agent-skills-migration.mdor the adoption docs, or the PR's Verification says "No consumer impact" and why.Round: 3 of 3