@codedrifters/configulator 0.0.221 → 0.0.223

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -5439,7 +5439,7 @@ var prReviewerSubAgent = {
5439
5439
  "## Phase 2: Gather Context",
5440
5440
  "",
5441
5441
  "```bash",
5442
- "gh pr view <pr-number> --json number,title,body,headRefName,baseRefName,isDraft,state,labels,reviews",
5442
+ "gh pr view <pr-number> --json number,title,body,headRefName,baseRefName,isDraft,state,labels,reviews,files,additions,deletions",
5443
5443
  "gh pr diff <pr-number>",
5444
5444
  "gh pr checks <pr-number>",
5445
5445
  "```",
@@ -5447,12 +5447,159 @@ var prReviewerSubAgent = {
5447
5447
  "Extract the linked issue number from the PR body using the closing keywords",
5448
5448
  "(`Closes #N`, `Fixes #N`, or `Resolves #N`) identified in Phase 1.5.",
5449
5449
  "",
5450
- "Then fetch the linked issue:",
5450
+ "Then fetch the linked issue, including its `issueType` so Phase 2.75 can",
5451
+ "evaluate the issue-type portion of the review policy:",
5451
5452
  "",
5452
5453
  "```bash",
5453
- "gh issue view <issue-number>",
5454
+ "gh issue view <issue-number> --json number,title,body,labels,state,issueType",
5454
5455
  "```",
5455
5456
  "",
5457
+ "## Phase 2.5: Gather Comments",
5458
+ "",
5459
+ "Before deciding review mode, collect every human comment on the PR so",
5460
+ "that Phase 3.5 can classify each one and Phase 4.5 can render the",
5461
+ "sticky **Reviewer notes** summary. GitHub exposes PR comments across",
5462
+ "three distinct endpoints; the reviewer merges all three into a single",
5463
+ "queue.",
5464
+ "",
5465
+ "### Step 1: Fetch all three comment sources",
5466
+ "",
5467
+ "```bash",
5468
+ "# PR-level issue comments (top-level discussion thread)",
5469
+ "gh pr view <pr-number> --json comments",
5470
+ "",
5471
+ "# Inline code-review comments (line-anchored in the diff)",
5472
+ "gh api repos/{{repository.owner}}/{{repository.name}}/pulls/<pr-number>/comments",
5473
+ "",
5474
+ "# Formal review bodies and their APPROVED / CHANGES_REQUESTED / COMMENTED state",
5475
+ "gh api repos/{{repository.owner}}/{{repository.name}}/pulls/<pr-number>/reviews",
5476
+ "```",
5477
+ "",
5478
+ "For each item, capture: the comment id, author login, body, creation",
5479
+ "time, the URL, and any reactions already present (including which",
5480
+ "reactions the reviewer itself has previously applied). For inline",
5481
+ "review comments, also capture the thread / conversation resolution",
5482
+ "state so Step 2 can drop resolved threads.",
5483
+ "",
5484
+ "### Step 2: Apply filtering rules",
5485
+ "",
5486
+ "Drop a comment from classification when **any** of the following hold:",
5487
+ "",
5488
+ "1. **Reviewer's own comments.** The author login matches the invoking",
5489
+ " agent identity (for example, the bot account used to post prior",
5490
+ " reviewer replies, sticky summaries, or fix-list comments). The",
5491
+ " reviewer never classifies or reacts to its own output.",
5492
+ "2. **Bot authors.** The author login matches `*[bot]` \u2014 CI bots,",
5493
+ " Dependabot, CodeRabbit, GitHub Actions, and similar automation.",
5494
+ "3. **Terminal reviewer reactions already present.** The comment",
5495
+ " already carries a reaction **authored by the reviewer** in the set",
5496
+ " `+1` (accepted), `rocket` (landed), or `-1` (declined as",
5497
+ " out-of-scope). These signal the item has reached a terminal state",
5498
+ " on a previous pass and requires no further action.",
5499
+ "4. **Resolved threads.** Inline comments belonging to a conversation",
5500
+ " that GitHub marks as resolved.",
5501
+ "",
5502
+ "A comment whose only reviewer-authored reaction is `eyes` is **not**",
5503
+ 'terminal. `eyes` means "seen on a previous pass but not yet resolved"',
5504
+ "\u2014 keep it in the queue so Phase 3.5 can re-evaluate and possibly",
5505
+ "promote it to a terminal state once the corresponding action",
5506
+ "completes.",
5507
+ "",
5508
+ "A comment whose only reviewer-authored reaction is `thinking_face` is",
5509
+ "also **not** terminal \u2014 it indicates an open dispute the reviewer",
5510
+ "raised on a prior pass that has not yet been resolved by the human.",
5511
+ "Phase 4 uses the presence of unresolved `thinking_face` reactions as",
5512
+ "the pushback gate.",
5513
+ "",
5514
+ "### Step 3: Record the gathered set",
5515
+ "",
5516
+ "Persist the filtered comment list in memory for Phase 3.5 and Phase",
5517
+ "4.5. For each surviving comment record at minimum:",
5518
+ "",
5519
+ "```",
5520
+ "- id: <comment or review id>",
5521
+ " source: <pr-comment | inline-comment | review-body>",
5522
+ " author: <login>",
5523
+ " url: <html_url>",
5524
+ " body: <text>",
5525
+ " reactions: <list of reactions with authors>",
5526
+ "```",
5527
+ "",
5528
+ "If there are no unhandled comments after filtering, record that fact",
5529
+ "and proceed \u2014 Phase 3.5 will short-circuit, and the Phase 4.5 sticky",
5530
+ "summary will simply list no outstanding items.",
5531
+ "",
5532
+ "## Phase 2.75: Determine Review Mode",
5533
+ "",
5534
+ "Before comparing the diff to the acceptance criteria, evaluate the PR",
5535
+ "against the **PR Review Policy** embedded in this repository's",
5536
+ "`CLAUDE.md` (rendered from the `pr-review-policy` rule). The decision",
5537
+ "here governs whether Phase 4 enables auto-merge or hands off to a",
5538
+ "human reviewer.",
5539
+ "",
5540
+ "### Step 1: Load the policy",
5541
+ "",
5542
+ "Read `CLAUDE.md` from the repo root and extract the fenced YAML block",
5543
+ "under the `## PR Review Policy` heading. Parse the block into an",
5544
+ "in-memory object with the following top-level fields: `version`,",
5545
+ "`default`, `human-required`, `auto-merge`.",
5546
+ "",
5547
+ "If the policy section is missing or unparseable, fall back to",
5548
+ "`mode = human-required` with `reason = 'policy missing or unreadable'`",
5549
+ "and skip to Step 3. Do **not** auto-merge when the policy is absent.",
5550
+ "",
5551
+ "### Step 2: Evaluate in precedence order",
5552
+ "",
5553
+ "Walk the following checks in order. The **first match wins** and fixes",
5554
+ "the mode; record the triggering condition as the `reason`. Mixed-match",
5555
+ "PRs (signals from both sides) resolve conservatively to",
5556
+ "`human-required` \u2014 force-auto only wins when it is the single highest",
5557
+ "match and no later human-required signal changes the outcome under",
5558
+ "step 2c.",
5559
+ "",
5560
+ "1. **Force-auto label** \u2014 if the PR carries any label listed under",
5561
+ " `auto-merge.labels-that-force-auto` (e.g. `review:auto-ok`), set",
5562
+ " `mode = auto-merge`.",
5563
+ "2. **Force-human label (reserved)** \u2014 if the PR carries a",
5564
+ " `review:human-required` label, set `mode = human-required`.",
5565
+ "3. **Labels that force human** \u2014 if the PR carries any label listed",
5566
+ " under `human-required.labels-that-force-human` (e.g.",
5567
+ " `priority:critical`), set `mode = human-required`.",
5568
+ "4. **Path globs** \u2014 if any file in the PR diff matches any glob in",
5569
+ " `human-required.paths`, set `mode = human-required`. Record the",
5570
+ " first matching path + glob pair as the reason.",
5571
+ "5. **Issue type** \u2014 if the linked issue's GitHub issue type",
5572
+ " (fetched in Phase 2) matches any entry in",
5573
+ " `human-required.issue-types` (case-insensitive), set",
5574
+ " `mode = human-required`.",
5575
+ "6. **Size thresholds** \u2014 if the PR exceeds either threshold under",
5576
+ " `human-required.size` (`files` count or `insertions` count), set",
5577
+ " `mode = human-required`.",
5578
+ "7. **Default** \u2014 if no rule above matched, apply the `default` field",
5579
+ " from the policy (typically `auto-merge`).",
5580
+ "",
5581
+ "#### Mixed-match resolution",
5582
+ "",
5583
+ "Apart from rule (1), which is an explicit opt-in and wins outright,",
5584
+ "**any** match from rules (2) through (6) forces `human-required` even",
5585
+ "if a non-force-auto signal would otherwise have allowed auto-merge.",
5586
+ "The conservative choice wins. Rule (1) is the sole escape hatch and",
5587
+ "requires a maintainer to have applied the force-auto label.",
5588
+ "",
5589
+ "### Step 3: Record the decision",
5590
+ "",
5591
+ "Persist the evaluated mode and reason for later phases so Phase 4 and",
5592
+ "any downstream summary writer can cite it:",
5593
+ "",
5594
+ "```",
5595
+ "Review mode: <auto-merge | human-required>",
5596
+ "Reason: <short explanation \u2014 label name, path+glob, issue type, size threshold, default>",
5597
+ "```",
5598
+ "",
5599
+ "Phases 3 (acceptance-criteria comparison) and CI verification run",
5600
+ "unchanged regardless of mode. Only the terminal action in Phase 4",
5601
+ "branches on the decided mode.",
5602
+ "",
5456
5603
  "## Phase 3: Compare Diff to Acceptance Criteria",
5457
5604
  "",
5458
5605
  "Read the issue body for an **Acceptance Criteria** (or equivalent) section.",
@@ -5470,10 +5617,181 @@ var prReviewerSubAgent = {
5470
5617
  "- **CI status** \u2014 `gh pr checks` reports all required checks passing",
5471
5618
  "- **Scope creep** \u2014 diff stays within the issue's stated scope",
5472
5619
  "",
5620
+ "## Phase 3.5: Classify Comments",
5621
+ "",
5622
+ "For every comment that survived Phase 2.5 filtering, assign exactly",
5623
+ "one classification and take the corresponding action. The reviewer",
5624
+ "acts only on unhandled comments; anything already in a terminal state",
5625
+ "was dropped in Phase 2.5 and is left alone.",
5626
+ "",
5627
+ "### Classifications",
5628
+ "",
5629
+ "#### `in-scope`",
5630
+ "",
5631
+ "The comment requests a change that falls **inside** the linked",
5632
+ "issue's acceptance criteria (or is an obvious defect in code the PR",
5633
+ "itself introduced).",
5634
+ "",
5635
+ "Action on this pass:",
5636
+ "",
5637
+ "- React `eyes` on the comment to mark it seen.",
5638
+ "- Queue the comment for later delegation. **Delegation wiring is out",
5639
+ " of scope for this phase** \u2014 the fix-list comment and the",
5640
+ " issue-worker hand-off land in a follow-up issue. For now, record",
5641
+ " the queued items in memory so Phase 4.5 can list them as",
5642
+ " outstanding.",
5643
+ "- Do **not** apply `+1` or `rocket` yet. Those are terminal",
5644
+ " reactions reserved for later passes once the fix has been accepted",
5645
+ " into the PR (`+1`) and actually landed on the branch (`rocket`).",
5646
+ "",
5647
+ "```bash",
5648
+ "# React eyes on a PR-level issue comment",
5649
+ "gh api repos/{{repository.owner}}/{{repository.name}}/issues/comments/<comment-id>/reactions \\",
5650
+ " -X POST -f content=eyes",
5651
+ "",
5652
+ "# React eyes on an inline code-review comment",
5653
+ "gh api repos/{{repository.owner}}/{{repository.name}}/pulls/comments/<comment-id>/reactions \\",
5654
+ " -X POST -f content=eyes",
5655
+ "```",
5656
+ "",
5657
+ "#### `out-of-scope`",
5658
+ "",
5659
+ "The comment requests work that falls **outside** the linked issue's",
5660
+ "acceptance criteria \u2014 new functionality, a refactor that would",
5661
+ "expand the diff, a cleanup in a neighbouring module, and so on. It",
5662
+ "is a legitimate request, just not for this PR.",
5663
+ "",
5664
+ "Action:",
5665
+ "",
5666
+ "1. Create a new tracking issue following the `Create Issue Workflow`",
5667
+ " in CLAUDE.md. Derive the title prefix (`feat:`, `fix:`, `chore:`,",
5668
+ " etc.) from the content of the comment. Apply the correct",
5669
+ " `type:*`, `priority:*`, and `status:*` labels and assign the",
5670
+ " GitHub issue type via the documented GraphQL mutation.",
5671
+ "2. Reply to the original comment with a link to the new issue:",
5672
+ " `Tracked separately in #<new-issue>.`",
5673
+ "3. React `-1` on the original comment. `-1` is the terminal",
5674
+ " reaction for out-of-scope and is only applied **after** the new",
5675
+ " issue has been successfully created and the reply posted.",
5676
+ "",
5677
+ "```bash",
5678
+ "# Reply on the same thread",
5679
+ "gh pr comment <pr-number> --body 'Tracked separately in #<new-issue>.'",
5680
+ "",
5681
+ "# React -1 on the original comment once the new issue exists",
5682
+ "gh api repos/{{repository.owner}}/{{repository.name}}/issues/comments/<comment-id>/reactions \\",
5683
+ " -X POST -f content=-1",
5684
+ "```",
5685
+ "",
5686
+ "#### `dispute`",
5687
+ "",
5688
+ "The comment conflicts with an acceptance criterion, a documented",
5689
+ "CLAUDE.md convention, or the project-context doc; or it is ambiguous",
5690
+ "enough that implementation would require guessing at intent. The",
5691
+ "reviewer pushes back rather than silently complying.",
5692
+ "",
5693
+ "Action:",
5694
+ "",
5695
+ "1. React `thinking_face` on the comment to mark it as disputed.",
5696
+ " This reaction is **not** terminal \u2014 it persists until the human",
5697
+ " resolves the dispute.",
5698
+ "2. Post a reply on the same thread explaining the pushback. Cite",
5699
+ " the specific acceptance criterion, convention, or project-context",
5700
+ " section that the comment conflicts with, or name the ambiguity",
5701
+ " that needs resolution.",
5702
+ "3. The presence of an unresolved `thinking_face` reaction by the",
5703
+ " reviewer blocks auto-merge in Phase 4 regardless of the review",
5704
+ " mode decided in Phase 2.75.",
5705
+ "",
5706
+ "```bash",
5707
+ "# React thinking_face on the disputed comment",
5708
+ "gh api repos/{{repository.owner}}/{{repository.name}}/issues/comments/<comment-id>/reactions \\",
5709
+ " -X POST -f content=confused",
5710
+ "",
5711
+ "# Post the pushback reply",
5712
+ "gh pr comment <pr-number> --body '<pushback explanation>'",
5713
+ "```",
5714
+ "",
5715
+ "Note: GitHub's reactions API uses `confused` as the content string",
5716
+ "for the `thinking_face` reaction; use `content=confused` when",
5717
+ "POSTing the reaction.",
5718
+ "",
5719
+ "#### `nit` / `question`",
5720
+ "",
5721
+ "The comment is a minor stylistic preference, a clarifying question",
5722
+ "with a short answer, or a drive-by note that does not request a",
5723
+ "code change.",
5724
+ "",
5725
+ "Action:",
5726
+ "",
5727
+ "- React `eyes` to mark the comment seen.",
5728
+ "- Optionally post a brief reply when the question has a short,",
5729
+ " factual answer. Skip the reply when there is nothing useful to",
5730
+ " add \u2014 an `eyes` reaction alone is sufficient.",
5731
+ "- Never apply `+1`, `rocket`, or `-1` to a `nit` / `question`",
5732
+ " comment; those reactions are reserved for their documented",
5733
+ " terminal meanings.",
5734
+ "",
5735
+ "### Reaction protocol summary",
5736
+ "",
5737
+ "| Reaction | Meaning | Terminal? |",
5738
+ "|----------|---------|-----------|",
5739
+ "| `eyes` | Seen by reviewer; awaiting further action | No |",
5740
+ "| `thinking_face` (`confused`) | Reviewer disputes this comment | No |",
5741
+ "| `+1` | Reviewer accepts the comment's request | **Yes** |",
5742
+ "| `rocket` | The accepted change has landed on the branch | **Yes** |",
5743
+ "| `-1` | Reviewer declined as out-of-scope; tracked in a new issue | **Yes** |",
5744
+ "",
5745
+ "Terminal reactions (`+1`, `rocket`, `-1`) **must only be applied**",
5746
+ "when the corresponding action is truly complete:",
5747
+ "",
5748
+ "- `+1` \u2014 only after the reviewer has confirmed the comment's",
5749
+ " request is in-scope and the fix has been accepted for this PR.",
5750
+ "- `rocket` \u2014 only after the accepted fix has actually landed on the",
5751
+ " PR's branch (a commit addressing the comment is present).",
5752
+ "- `-1` \u2014 only after a new tracking issue has been successfully",
5753
+ " created for the out-of-scope request and the reply linking to it",
5754
+ " has been posted.",
5755
+ "",
5756
+ "Never pre-emptively apply a terminal reaction. Applying one signals",
5757
+ "to humans and to future reviewer passes that the item is closed;",
5758
+ "applying it early creates a false record of completion.",
5759
+ "",
5473
5760
  "## Phase 4: Decide and Act",
5474
5761
  "",
5762
+ "### Pushback gate (runs before every merge decision)",
5763
+ "",
5764
+ "Before taking any merge-enabling action in this phase, verify that no",
5765
+ "**unresolved `thinking_face` reactions by the reviewer** remain on",
5766
+ "any comment gathered in Phase 2.5.",
5767
+ "",
5768
+ "A `thinking_face` reaction is considered **unresolved** when:",
5769
+ "",
5770
+ "- The reviewer applied it on this pass or a prior pass, and",
5771
+ "- The underlying comment has not since received a resolution signal",
5772
+ " from the human \u2014 for example, the comment has not been withdrawn,",
5773
+ " the human has not posted a clarifying reply that the reviewer has",
5774
+ " since marked `+1`, and no `review:auto-ok` label has been applied",
5775
+ " to the PR as an explicit override.",
5776
+ "",
5777
+ "If any unresolved `thinking_face` reaction exists, **do not enable",
5778
+ "auto-merge** and **do not apply `review:awaiting-human` as a success",
5779
+ "hand-off**. This gate fires regardless of the review mode decided in",
5780
+ "Phase 2.75 \u2014 pushback blocks the merge pathway even when the mode is",
5781
+ "`auto-merge`. Skip straight to Phase 4.5 to update the sticky summary",
5782
+ "with the outstanding pushbacks, then stop. A downstream issue",
5783
+ "refines this gate further; for now, pushback simply blocks the",
5784
+ "merge pathway.",
5785
+ "",
5786
+ "If no unresolved `thinking_face` reactions exist, proceed with the",
5787
+ "branches below based on the review mode decided in Phase 2.75.",
5788
+ "",
5475
5789
  "### If all acceptance criteria are met and CI is green",
5476
5790
  "",
5791
+ "Branch on the **review mode** decided in Phase 2.75:",
5792
+ "",
5793
+ "#### Mode `auto-merge`",
5794
+ "",
5477
5795
  "Enable squash auto-merge with branch deletion. This queues the merge to",
5478
5796
  "happen once required checks pass; no separate approval review is needed.",
5479
5797
  "",
@@ -5487,6 +5805,27 @@ var prReviewerSubAgent = {
5487
5805
  "`feat(scope): description`). The body should bullet the changes and end",
5488
5806
  "with `Closes #<issue-number>`.",
5489
5807
  "",
5808
+ "#### Mode `human-required`",
5809
+ "",
5810
+ "Do **not** run `gh pr merge --auto`. Instead, hand the PR off to a",
5811
+ "human reviewer:",
5812
+ "",
5813
+ "1. Apply the `review:awaiting-human` label so the PR is discoverable",
5814
+ " in the human-review queue:",
5815
+ "",
5816
+ " ```bash",
5817
+ " gh pr edit <pr-number> --add-label 'review:awaiting-human'",
5818
+ " ```",
5819
+ "",
5820
+ "2. Exit cleanly after the acceptance-criteria check completes and any",
5821
+ " summary comment the reviewer posts. Proceed to Phase 5 only if a",
5822
+ " merge occurred \u2014 in `human-required` mode the reviewer stops at",
5823
+ " the hand-off and does not poll for merge.",
5824
+ "",
5825
+ "The reason captured in Phase 2.75 should be included in any summary",
5826
+ "comment so maintainers know why human review was required (path hit,",
5827
+ "issue type, size threshold, label, or default).",
5828
+ "",
5490
5829
  "### If any criterion is missing, partial, or CI is failing",
5491
5830
  "",
5492
5831
  "Post a plain comment (not a formal review block) with grouped findings:",
@@ -5504,10 +5843,90 @@ var prReviewerSubAgent = {
5504
5843
  "--request-changes`: it is lighter-weight, doesn't require the author to",
5505
5844
  "dismiss a formal review, and composes cleanly with the multi-PR loop.",
5506
5845
  "",
5846
+ "## Phase 4.5: Update Sticky Summary",
5847
+ "",
5848
+ "On **every pass**, create or update a single **`## Reviewer notes`**",
5849
+ "comment on the PR. This sticky comment is the human-facing single",
5850
+ "source of truth for the PR's state \u2014 one comment per PR, edited in",
5851
+ "place across passes, never duplicated. Do not post a fresh",
5852
+ '"pass N summary" on each iteration.',
5853
+ "",
5854
+ "### Step 1: Find the existing sticky comment (if any)",
5855
+ "",
5856
+ "List PR-level comments and look for one authored by the reviewer",
5857
+ "whose body starts with `## Reviewer notes`:",
5858
+ "",
5859
+ "```bash",
5860
+ "gh api repos/{{repository.owner}}/{{repository.name}}/issues/<pr-number>/comments",
5861
+ "```",
5862
+ "",
5863
+ "If multiple candidates exist (an older run double-posted before this",
5864
+ "phase existed), keep the earliest and plan to delete the duplicates",
5865
+ "on a later pass. Never delete another author's comment.",
5866
+ "",
5867
+ "### Step 2: Compose the sticky body",
5868
+ "",
5869
+ "The body uses the following shape:",
5870
+ "",
5871
+ "```",
5872
+ "## Reviewer notes",
5873
+ "",
5874
+ "**Mode:** auto-merge | human-required \u2014 <reason from Phase 2.75>",
5875
+ "**AC status:** <met / partial / missing> (evidence links)",
5876
+ "**CI status:** green | pending | red",
5877
+ "**Outstanding:** <list of comments still open with their classification and author>",
5878
+ "**Pushbacks:** <list of disputes with reasons>",
5879
+ "**Last pass:** <ISO timestamp>",
5880
+ "```",
5881
+ "",
5882
+ "Populate each field from the phases above:",
5883
+ "",
5884
+ "- **Mode / reason** \u2014 the mode and reason recorded in Phase 2.75.",
5885
+ "- **AC status** \u2014 the checklist produced in Phase 3 (met, partial,",
5886
+ " or missing), with links to the files or tests that provide the",
5887
+ " evidence.",
5888
+ "- **CI status** \u2014 derived from `gh pr checks`.",
5889
+ "- **Outstanding** \u2014 the comments still carrying a non-terminal",
5890
+ " reviewer reaction from Phase 3.5 (typically `eyes` for queued",
5891
+ " in-scope items and `nit` / `question` items that remain open).",
5892
+ " List each as `<classification>: <author> \u2014 <short summary> (<url>)`.",
5893
+ "- **Pushbacks** \u2014 every comment the reviewer reacted",
5894
+ " `thinking_face` to on this or any prior pass, with the reason",
5895
+ " captured in the pushback reply. Empty list when there are none.",
5896
+ "- **Last pass** \u2014 the ISO 8601 timestamp of this run.",
5897
+ "",
5898
+ "### Step 3: Create or edit in place",
5899
+ "",
5900
+ "If no existing sticky comment was found in Step 1, create one:",
5901
+ "",
5902
+ "```bash",
5903
+ "gh pr comment <pr-number> --body '<sticky body>'",
5904
+ "```",
5905
+ "",
5906
+ "If an existing sticky comment was found, edit it in place using the",
5907
+ "comment id. Do not delete and re-create \u2014 editing preserves the",
5908
+ "comment's URL and any reactions humans have added to the summary:",
5909
+ "",
5910
+ "```bash",
5911
+ "gh api repos/{{repository.owner}}/{{repository.name}}/issues/comments/<sticky-comment-id> \\",
5912
+ " -X PATCH -f body='<sticky body>'",
5913
+ "```",
5914
+ "",
5915
+ "The sticky summary must be updated on every pass through Phase 4.5,",
5916
+ "including passes that ended in a pushback-gated skip, a",
5917
+ "`NEEDS_CHANGES` findings comment, or the `human-required` hand-off.",
5918
+ "Humans rely on the sticky comment to see the current state of the",
5919
+ "PR at a glance \u2014 it must never go stale while the reviewer is",
5920
+ "actively processing the PR.",
5921
+ "",
5507
5922
  "## Phase 5: Branch Cleanup and Issue Closure Verification",
5508
5923
  "",
5509
- "Auto-merge may not be immediate. Poll the PR state up to 10 times, waiting",
5510
- "30 seconds between polls:",
5924
+ "Skip this phase entirely when the review mode from Phase 2.75 is",
5925
+ "`human-required` \u2014 no merge was initiated, so there is nothing to poll",
5926
+ "and no branch to clean up. Report the hand-off and stop.",
5927
+ "",
5928
+ "In `auto-merge` mode, auto-merge may not be immediate. Poll the PR",
5929
+ "state up to 10 times, waiting 30 seconds between polls:",
5511
5930
  "",
5512
5931
  "```bash",
5513
5932
  "gh pr view <pr-number> --json state --jq '.state'",
@@ -5550,7 +5969,9 @@ var prReviewerSubAgent = {
5550
5969
  "```",
5551
5970
  "PR #<number> \u2014 <title>",
5552
5971
  "Linked issue: #<issue-number>",
5553
- "Verdict: AUTO_MERGE_ENABLED | NEEDS_CHANGES | INELIGIBLE | BLOCKED",
5972
+ "Review mode: <auto-merge | human-required>",
5973
+ "Reason: <short explanation from Phase 2.75>",
5974
+ "Verdict: AUTO_MERGE_ENABLED | AWAITING_HUMAN | NEEDS_CHANGES | INELIGIBLE | BLOCKED",
5554
5975
  "",
5555
5976
  "Acceptance criteria:",
5556
5977
  " [x] <criterion> \u2014 <evidence>",
@@ -5562,7 +5983,7 @@ var prReviewerSubAgent = {
5562
5983
  " - Suggested: <items>",
5563
5984
  " - Nitpick: <items>",
5564
5985
  "",
5565
- "Action taken: <enable-auto-merge | commented-on-the-pr | none>",
5986
+ "Action taken: <enable-auto-merge | label-awaiting-human | commented-on-the-pr | none>",
5566
5987
  "Branch state: <merged | open | closed>",
5567
5988
  "Issue state: <closed | open>",
5568
5989
  "```",
@@ -5580,15 +6001,47 @@ var prReviewerSubAgent = {
5580
6001
  " block on red checks.",
5581
6002
  "4. **Never bypass review conventions.** Always use `--squash`, `--auto`,",
5582
6003
  " and `--delete-branch` for merges. Do not force-merge.",
5583
- "5. **Do not implement code.** You review, decide, and orchestrate. If",
6004
+ "5. **Never auto-merge a `human-required` PR.** When Phase 2.75 resolves",
6005
+ " to `human-required`, Phase 4 applies `review:awaiting-human` and",
6006
+ " exits. Even if every acceptance criterion is met and CI is green,",
6007
+ " `gh pr merge --auto` is forbidden in that mode.",
6008
+ "6. **Do not implement code.** You review, decide, and orchestrate. If",
5584
6009
  " the PR needs changes, comment and stop.",
5585
- "6. **Never push commits to the PR's branch.** If the PR needs changes,",
6010
+ "7. **Never push commits to the PR's branch.** If the PR needs changes,",
5586
6011
  " comment and stop \u2014 do not attempt to fix it yourself. The PR author",
5587
6012
  " owns the branch; pushing to someone else's branch is out of scope.",
5588
- "7. **In loop mode (`/review-prs`), never stop early.** If any review",
6013
+ "8. **In loop mode (`/review-prs`), never stop early.** If any review",
5589
6014
  " fails, comment and move to the next PR. Only abort the loop on a",
5590
6015
  " fatal error (e.g. `gh` auth failure, network outage).",
5591
- "8. **Follow CLAUDE.md conventions** for all `git` and `gh` operations."
6016
+ "9. **Follow CLAUDE.md conventions** for all `git` and `gh` operations.",
6017
+ "10. **Follow the reaction protocol.** Use `eyes` to mark a comment",
6018
+ " seen, `thinking_face` (`confused`) to dispute it, `+1` to accept",
6019
+ " its request, `rocket` when the accepted change has landed, and",
6020
+ " `-1` when the request is out-of-scope and has been tracked in a",
6021
+ " new issue. Apply reactions on the same comment endpoint the",
6022
+ " comment came from (`issues/comments/...` for PR-level, ",
6023
+ " `pulls/comments/...` for inline).",
6024
+ "11. **Terminal reactions require completed actions.** `+1`, `rocket`,",
6025
+ " and `-1` must only be applied once the corresponding action is",
6026
+ " truly complete (respectively: the fix accepted, the fix landed,",
6027
+ " or the new out-of-scope issue created and linked in a reply).",
6028
+ " Never apply a terminal reaction pre-emptively; doing so falsely",
6029
+ " signals to humans and to future reviewer passes that the item",
6030
+ " is closed.",
6031
+ "12. **Maintain one sticky `## Reviewer notes` comment per PR.** On",
6032
+ " each pass, find the existing sticky comment authored by the",
6033
+ " reviewer and edit it in place with `gh api ... -X PATCH`;",
6034
+ " create it only when none exists. Never post per-pass summary",
6035
+ " comments alongside the sticky \u2014 the sticky is the single",
6036
+ " human-facing source of truth for PR state.",
6037
+ "13. **Pushback blocks auto-merge.** Any unresolved `thinking_face`",
6038
+ " reaction authored by the reviewer on any comment must prevent",
6039
+ " Phase 4 from enabling auto-merge, regardless of the review mode",
6040
+ " decided in Phase 2.75. The gate clears only when the human has",
6041
+ " resolved the dispute \u2014 by withdrawing the comment, by replying",
6042
+ " in a way that satisfies the reviewer (who then replaces the",
6043
+ " `thinking_face` with `+1`), or by applying the `review:auto-ok`",
6044
+ " label as an explicit override."
5592
6045
  ].join("\n")
5593
6046
  };
5594
6047
  var reviewPrSkill = {
@@ -5756,6 +6209,88 @@ var prReviewBundle = {
5756
6209
  // still exclude it explicitly via `excludeBundles` if desired.
5757
6210
  appliesWhen: () => true,
5758
6211
  rules: [
6212
+ {
6213
+ name: "pr-review-policy",
6214
+ description: "Declarative policy that tells the pr-reviewer which PRs may auto-merge and which must wait for a human reviewer",
6215
+ scope: AGENT_RULE_SCOPE.ALWAYS,
6216
+ content: [
6217
+ "# PR Review Policy",
6218
+ "",
6219
+ "The `pr-reviewer` sub-agent evaluates every PR it reviews against the",
6220
+ "policy below and routes the PR into one of two modes:",
6221
+ "",
6222
+ "- **`auto-merge`** \u2014 the reviewer may enable squash auto-merge once",
6223
+ " all acceptance criteria are met and CI is green.",
6224
+ "- **`human-required`** \u2014 the reviewer runs the full AC/CI check but",
6225
+ " never calls `gh pr merge --auto`. It applies the",
6226
+ " `review:awaiting-human` label and hands off to a human reviewer.",
6227
+ "",
6228
+ "## Policy",
6229
+ "",
6230
+ "```yaml",
6231
+ "version: 1",
6232
+ "default: auto-merge",
6233
+ "",
6234
+ "human-required:",
6235
+ " paths:",
6236
+ ' - "docs/adrs/**"',
6237
+ ' - "docs/project-context.md"',
6238
+ ' - ".github/workflows/**"',
6239
+ ' - ".github/CODEOWNERS"',
6240
+ ' - ".projenrc.ts"',
6241
+ ' - "projenrc/**"',
6242
+ ' - "CLAUDE.md"',
6243
+ ' - ".claude/**"',
6244
+ ' - "packages/**/package.json"',
6245
+ " issue-types:",
6246
+ " - release",
6247
+ " - hotfix",
6248
+ " size:",
6249
+ " files: 10",
6250
+ " insertions: 500",
6251
+ " labels-that-force-human:",
6252
+ ' - "review:human-required"',
6253
+ ' - "priority:critical"',
6254
+ "",
6255
+ "auto-merge:",
6256
+ " labels-that-force-auto:",
6257
+ ' - "review:auto-ok"',
6258
+ "```",
6259
+ "",
6260
+ "## Precedence",
6261
+ "",
6262
+ "The reviewer walks the following checks in order. The **first match**",
6263
+ "fixes the mode; any mixed-match PR (signals from both sides) resolves",
6264
+ "conservatively to `human-required` \u2014 `auto-merge` only wins when the",
6265
+ "force-auto label is the single top-priority match.",
6266
+ "",
6267
+ "1. **`auto-merge.labels-that-force-auto`** \u2014 if the PR carries any of",
6268
+ " these labels (e.g. `review:auto-ok`), the mode is `auto-merge`",
6269
+ " outright. This is the only escape hatch from the conservative",
6270
+ " default; it requires a maintainer to apply the label explicitly.",
6271
+ "2. **`review:human-required` label** \u2014 reserved force-human label;",
6272
+ " if present (and no force-auto label beat it in step 1), the mode",
6273
+ " is `human-required`.",
6274
+ "3. **`human-required.labels-that-force-human`** \u2014 any listed label on",
6275
+ " the PR (e.g. `priority:critical`) forces `human-required`.",
6276
+ "4. **`human-required.paths`** \u2014 if any file in the PR diff matches",
6277
+ " any glob here, the mode is `human-required`. Matching uses",
6278
+ " standard glob semantics (`**` for recursive directories,",
6279
+ " `*` for a single path segment).",
6280
+ "5. **`human-required.issue-types`** \u2014 if the linked issue's GitHub",
6281
+ " issue type matches any entry (case-insensitive), the mode is",
6282
+ " `human-required`.",
6283
+ "6. **`human-required.size`** \u2014 if the PR exceeds either the `files`",
6284
+ " count or the `insertions` count, the mode is `human-required`.",
6285
+ "7. **`default`** \u2014 applied only when no rule above matched",
6286
+ " (normally `auto-merge`).",
6287
+ "",
6288
+ "The `pr-reviewer` sub-agent records the decided mode and the triggering",
6289
+ "reason in its Phase 2.75 output so downstream phases and any sticky",
6290
+ "summary can cite the specific rule that applied."
6291
+ ].join("\n"),
6292
+ tags: ["policy", "review"]
6293
+ },
5759
6294
  {
5760
6295
  name: "pr-review-workflow",
5761
6296
  description: "Describes the /review-pr and /review-prs skills and their delegation to the pr-reviewer sub-agent",
@@ -5776,15 +6311,21 @@ var prReviewBundle = {
5776
6311
  " has a linked issue). Ineligible PRs get a short comment and are",
5777
6312
  " skipped.",
5778
6313
  "2. Fetches the PR, its diff, CI status, and the linked issue",
5779
- "3. Builds a checklist from the issue's acceptance criteria",
5780
- "4. Verifies the diff satisfies each criterion and that CI is green",
5781
- "5. **Enables squash auto-merge** (with `--delete-branch`) when all",
5782
- " checks pass \u2014 no explicit approval review",
5783
- "6. **Comments with grouped findings** when any check fails (plain",
6314
+ "3. **Evaluates the PR Review Policy** (see the `PR Review Policy`",
6315
+ " section above) to decide whether the PR is `auto-merge` or",
6316
+ " `human-required`, and records the triggering reason",
6317
+ "4. Builds a checklist from the issue's acceptance criteria",
6318
+ "5. Verifies the diff satisfies each criterion and that CI is green",
6319
+ "6. **Enables squash auto-merge** (with `--delete-branch`) when all",
6320
+ " checks pass **and** the review mode is `auto-merge`",
6321
+ "7. **Applies `review:awaiting-human`** and hands off to a human",
6322
+ " reviewer when the review mode is `human-required` (no auto-merge,",
6323
+ " even if every acceptance criterion is met)",
6324
+ "8. **Comments with grouped findings** when any check fails (plain",
5784
6325
  " `gh pr comment`, not a formal `--request-changes` review)",
5785
- "7. After a successful merge, verifies the linked issue is closed",
6326
+ "9. After a successful merge, verifies the linked issue is closed",
5786
6327
  " and closes it explicitly if the merge commit did not",
5787
- "8. Cleans up the local branch after merge",
6328
+ "10. Cleans up the local branch after merge",
5788
6329
  "",
5789
6330
  "The reviewer **never** implements code and **never** pushes commits",
5790
6331
  "to a PR's branch \u2014 it only reviews, decides, and orchestrates merge",