Skip to content

Print the write-pr-description context from agentrepo pr #920

Description

@tbhb-agent

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

  1. AC1: Given a base argument, an existing draft with a base value, or neither, when the context prints, then the base is the argument, else the draft's base, else the default branch (the branch origin/HEAD names, else main), and the report states the ref it compares against (origin's copy where one exists, else the local branch).
  2. 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.
  3. 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.showSignature is 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).
  4. 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.
  5. 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 gh is stated as unavailable, at most 100 labels and 15 open issues are listed, and an absent draft prints (absent).
  6. 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.
  7. 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.
  8. AC8: Non-functional: the run writes nothing and makes no network connection other than the gh reads above, and the optional writer still works when the helper is not deployed (the "preflight does not require the optional description writer" regression in tests/skills/pr/scripts/pr-workflow.bats still 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 gh that 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 gh calls is attempted; tests/skills/writers and the named regression in pr-workflow.bats still 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-by trailer and the pull request has the provenance:agent-assisted label. 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 final Status: 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.

Activity

  1. tbhb-agent commented on Oct 27, 2026

    @tbhb-agent
    ContributorAuthor

    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.

    • D1 The author verified each AC on the merged head, and the Verification section of the pull request cites each AC ID with its evidence: the command and its result, or a link.
    • D2 An independent reviewer approved the exact merged head, and the author resolved each finding or filed it as a follow-up.
    • D3 The required checks pass on that head, and any loosened gate has the owner's approval of that exact head.
    • D4 The leak scans come back clean: gitleaks, devtools' check-leaks.sh with the repository's private-strings list, and the leak review of each post.
    • D5 The author signed each commit, the squash included.
    • D6 The docs match the change (README, docs/, CHANGELOG or help text), or the Verification section says "No doc impact" and why.
    • D7 The commits and the squash have Assisted-by trailers, and the pull request has the provenance:agent-assisted label.
    • D8 The pull request stays within the size limits, or the owner approved its exact head over the hard limit.
    • D9 The author files follow-ups and deferred findings as issues with at least a Problem and numbered AC and lists them under the Related section of the pull request. Any work left in the code links its issue.
    • D10 The merge closes the issue through a closing reference and the board shows Done. The final Status: comment names the merge commit.
    • devtools-1 mise run check is green, and so are the coverage floors mise run cover-go-check and mise run cover-py-check, which check doesn't run.
    • devtools-2 A change to skill sources under packages/agents/source/ commits what mise run generate-skills, then mise run skill-tokens, then apm install rewrite, in that order, and check-generated-skills (part of lint) passes.
    • devtools-3 A consumer-visible change (the vendored payload, a skill, a reusable workflow, a task or a pin) has its consumer steps in docs/agent-skills-migration.md or the adoption docs, or the PR's Verification says "No consumer impact" and why.

    Round: 3 of 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    refinement:readyPassed the Definition of Ready; may be picked up

    Fields

    Priority

    None yet

    Work type

    None yet

    Projects

    • Status
      Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions