@codedrifters/configulator 0.0.221 → 0.0.222

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.mjs CHANGED
@@ -5362,7 +5362,7 @@ var prReviewerSubAgent = {
5362
5362
  "## Phase 2: Gather Context",
5363
5363
  "",
5364
5364
  "```bash",
5365
- "gh pr view <pr-number> --json number,title,body,headRefName,baseRefName,isDraft,state,labels,reviews",
5365
+ "gh pr view <pr-number> --json number,title,body,headRefName,baseRefName,isDraft,state,labels,reviews,files,additions,deletions",
5366
5366
  "gh pr diff <pr-number>",
5367
5367
  "gh pr checks <pr-number>",
5368
5368
  "```",
@@ -5370,12 +5370,84 @@ var prReviewerSubAgent = {
5370
5370
  "Extract the linked issue number from the PR body using the closing keywords",
5371
5371
  "(`Closes #N`, `Fixes #N`, or `Resolves #N`) identified in Phase 1.5.",
5372
5372
  "",
5373
- "Then fetch the linked issue:",
5373
+ "Then fetch the linked issue, including its `issueType` so Phase 2.75 can",
5374
+ "evaluate the issue-type portion of the review policy:",
5374
5375
  "",
5375
5376
  "```bash",
5376
- "gh issue view <issue-number>",
5377
+ "gh issue view <issue-number> --json number,title,body,labels,state,issueType",
5377
5378
  "```",
5378
5379
  "",
5380
+ "## Phase 2.75: Determine Review Mode",
5381
+ "",
5382
+ "Before comparing the diff to the acceptance criteria, evaluate the PR",
5383
+ "against the **PR Review Policy** embedded in this repository's",
5384
+ "`CLAUDE.md` (rendered from the `pr-review-policy` rule). The decision",
5385
+ "here governs whether Phase 4 enables auto-merge or hands off to a",
5386
+ "human reviewer.",
5387
+ "",
5388
+ "### Step 1: Load the policy",
5389
+ "",
5390
+ "Read `CLAUDE.md` from the repo root and extract the fenced YAML block",
5391
+ "under the `## PR Review Policy` heading. Parse the block into an",
5392
+ "in-memory object with the following top-level fields: `version`,",
5393
+ "`default`, `human-required`, `auto-merge`.",
5394
+ "",
5395
+ "If the policy section is missing or unparseable, fall back to",
5396
+ "`mode = human-required` with `reason = 'policy missing or unreadable'`",
5397
+ "and skip to Step 3. Do **not** auto-merge when the policy is absent.",
5398
+ "",
5399
+ "### Step 2: Evaluate in precedence order",
5400
+ "",
5401
+ "Walk the following checks in order. The **first match wins** and fixes",
5402
+ "the mode; record the triggering condition as the `reason`. Mixed-match",
5403
+ "PRs (signals from both sides) resolve conservatively to",
5404
+ "`human-required` \u2014 force-auto only wins when it is the single highest",
5405
+ "match and no later human-required signal changes the outcome under",
5406
+ "step 2c.",
5407
+ "",
5408
+ "1. **Force-auto label** \u2014 if the PR carries any label listed under",
5409
+ " `auto-merge.labels-that-force-auto` (e.g. `review:auto-ok`), set",
5410
+ " `mode = auto-merge`.",
5411
+ "2. **Force-human label (reserved)** \u2014 if the PR carries a",
5412
+ " `review:human-required` label, set `mode = human-required`.",
5413
+ "3. **Labels that force human** \u2014 if the PR carries any label listed",
5414
+ " under `human-required.labels-that-force-human` (e.g.",
5415
+ " `priority:critical`), set `mode = human-required`.",
5416
+ "4. **Path globs** \u2014 if any file in the PR diff matches any glob in",
5417
+ " `human-required.paths`, set `mode = human-required`. Record the",
5418
+ " first matching path + glob pair as the reason.",
5419
+ "5. **Issue type** \u2014 if the linked issue's GitHub issue type",
5420
+ " (fetched in Phase 2) matches any entry in",
5421
+ " `human-required.issue-types` (case-insensitive), set",
5422
+ " `mode = human-required`.",
5423
+ "6. **Size thresholds** \u2014 if the PR exceeds either threshold under",
5424
+ " `human-required.size` (`files` count or `insertions` count), set",
5425
+ " `mode = human-required`.",
5426
+ "7. **Default** \u2014 if no rule above matched, apply the `default` field",
5427
+ " from the policy (typically `auto-merge`).",
5428
+ "",
5429
+ "#### Mixed-match resolution",
5430
+ "",
5431
+ "Apart from rule (1), which is an explicit opt-in and wins outright,",
5432
+ "**any** match from rules (2) through (6) forces `human-required` even",
5433
+ "if a non-force-auto signal would otherwise have allowed auto-merge.",
5434
+ "The conservative choice wins. Rule (1) is the sole escape hatch and",
5435
+ "requires a maintainer to have applied the force-auto label.",
5436
+ "",
5437
+ "### Step 3: Record the decision",
5438
+ "",
5439
+ "Persist the evaluated mode and reason for later phases so Phase 4 and",
5440
+ "any downstream summary writer can cite it:",
5441
+ "",
5442
+ "```",
5443
+ "Review mode: <auto-merge | human-required>",
5444
+ "Reason: <short explanation \u2014 label name, path+glob, issue type, size threshold, default>",
5445
+ "```",
5446
+ "",
5447
+ "Phases 3 (acceptance-criteria comparison) and CI verification run",
5448
+ "unchanged regardless of mode. Only the terminal action in Phase 4",
5449
+ "branches on the decided mode.",
5450
+ "",
5379
5451
  "## Phase 3: Compare Diff to Acceptance Criteria",
5380
5452
  "",
5381
5453
  "Read the issue body for an **Acceptance Criteria** (or equivalent) section.",
@@ -5397,6 +5469,10 @@ var prReviewerSubAgent = {
5397
5469
  "",
5398
5470
  "### If all acceptance criteria are met and CI is green",
5399
5471
  "",
5472
+ "Branch on the **review mode** decided in Phase 2.75:",
5473
+ "",
5474
+ "#### Mode `auto-merge`",
5475
+ "",
5400
5476
  "Enable squash auto-merge with branch deletion. This queues the merge to",
5401
5477
  "happen once required checks pass; no separate approval review is needed.",
5402
5478
  "",
@@ -5410,6 +5486,27 @@ var prReviewerSubAgent = {
5410
5486
  "`feat(scope): description`). The body should bullet the changes and end",
5411
5487
  "with `Closes #<issue-number>`.",
5412
5488
  "",
5489
+ "#### Mode `human-required`",
5490
+ "",
5491
+ "Do **not** run `gh pr merge --auto`. Instead, hand the PR off to a",
5492
+ "human reviewer:",
5493
+ "",
5494
+ "1. Apply the `review:awaiting-human` label so the PR is discoverable",
5495
+ " in the human-review queue:",
5496
+ "",
5497
+ " ```bash",
5498
+ " gh pr edit <pr-number> --add-label 'review:awaiting-human'",
5499
+ " ```",
5500
+ "",
5501
+ "2. Exit cleanly after the acceptance-criteria check completes and any",
5502
+ " summary comment the reviewer posts. Proceed to Phase 5 only if a",
5503
+ " merge occurred \u2014 in `human-required` mode the reviewer stops at",
5504
+ " the hand-off and does not poll for merge.",
5505
+ "",
5506
+ "The reason captured in Phase 2.75 should be included in any summary",
5507
+ "comment so maintainers know why human review was required (path hit,",
5508
+ "issue type, size threshold, label, or default).",
5509
+ "",
5413
5510
  "### If any criterion is missing, partial, or CI is failing",
5414
5511
  "",
5415
5512
  "Post a plain comment (not a formal review block) with grouped findings:",
@@ -5429,8 +5526,12 @@ var prReviewerSubAgent = {
5429
5526
  "",
5430
5527
  "## Phase 5: Branch Cleanup and Issue Closure Verification",
5431
5528
  "",
5432
- "Auto-merge may not be immediate. Poll the PR state up to 10 times, waiting",
5433
- "30 seconds between polls:",
5529
+ "Skip this phase entirely when the review mode from Phase 2.75 is",
5530
+ "`human-required` \u2014 no merge was initiated, so there is nothing to poll",
5531
+ "and no branch to clean up. Report the hand-off and stop.",
5532
+ "",
5533
+ "In `auto-merge` mode, auto-merge may not be immediate. Poll the PR",
5534
+ "state up to 10 times, waiting 30 seconds between polls:",
5434
5535
  "",
5435
5536
  "```bash",
5436
5537
  "gh pr view <pr-number> --json state --jq '.state'",
@@ -5473,7 +5574,9 @@ var prReviewerSubAgent = {
5473
5574
  "```",
5474
5575
  "PR #<number> \u2014 <title>",
5475
5576
  "Linked issue: #<issue-number>",
5476
- "Verdict: AUTO_MERGE_ENABLED | NEEDS_CHANGES | INELIGIBLE | BLOCKED",
5577
+ "Review mode: <auto-merge | human-required>",
5578
+ "Reason: <short explanation from Phase 2.75>",
5579
+ "Verdict: AUTO_MERGE_ENABLED | AWAITING_HUMAN | NEEDS_CHANGES | INELIGIBLE | BLOCKED",
5477
5580
  "",
5478
5581
  "Acceptance criteria:",
5479
5582
  " [x] <criterion> \u2014 <evidence>",
@@ -5485,7 +5588,7 @@ var prReviewerSubAgent = {
5485
5588
  " - Suggested: <items>",
5486
5589
  " - Nitpick: <items>",
5487
5590
  "",
5488
- "Action taken: <enable-auto-merge | commented-on-the-pr | none>",
5591
+ "Action taken: <enable-auto-merge | label-awaiting-human | commented-on-the-pr | none>",
5489
5592
  "Branch state: <merged | open | closed>",
5490
5593
  "Issue state: <closed | open>",
5491
5594
  "```",
@@ -5503,15 +5606,19 @@ var prReviewerSubAgent = {
5503
5606
  " block on red checks.",
5504
5607
  "4. **Never bypass review conventions.** Always use `--squash`, `--auto`,",
5505
5608
  " and `--delete-branch` for merges. Do not force-merge.",
5506
- "5. **Do not implement code.** You review, decide, and orchestrate. If",
5609
+ "5. **Never auto-merge a `human-required` PR.** When Phase 2.75 resolves",
5610
+ " to `human-required`, Phase 4 applies `review:awaiting-human` and",
5611
+ " exits. Even if every acceptance criterion is met and CI is green,",
5612
+ " `gh pr merge --auto` is forbidden in that mode.",
5613
+ "6. **Do not implement code.** You review, decide, and orchestrate. If",
5507
5614
  " the PR needs changes, comment and stop.",
5508
- "6. **Never push commits to the PR's branch.** If the PR needs changes,",
5615
+ "7. **Never push commits to the PR's branch.** If the PR needs changes,",
5509
5616
  " comment and stop \u2014 do not attempt to fix it yourself. The PR author",
5510
5617
  " owns the branch; pushing to someone else's branch is out of scope.",
5511
- "7. **In loop mode (`/review-prs`), never stop early.** If any review",
5618
+ "8. **In loop mode (`/review-prs`), never stop early.** If any review",
5512
5619
  " fails, comment and move to the next PR. Only abort the loop on a",
5513
5620
  " fatal error (e.g. `gh` auth failure, network outage).",
5514
- "8. **Follow CLAUDE.md conventions** for all `git` and `gh` operations."
5621
+ "9. **Follow CLAUDE.md conventions** for all `git` and `gh` operations."
5515
5622
  ].join("\n")
5516
5623
  };
5517
5624
  var reviewPrSkill = {
@@ -5679,6 +5786,88 @@ var prReviewBundle = {
5679
5786
  // still exclude it explicitly via `excludeBundles` if desired.
5680
5787
  appliesWhen: () => true,
5681
5788
  rules: [
5789
+ {
5790
+ name: "pr-review-policy",
5791
+ description: "Declarative policy that tells the pr-reviewer which PRs may auto-merge and which must wait for a human reviewer",
5792
+ scope: AGENT_RULE_SCOPE.ALWAYS,
5793
+ content: [
5794
+ "# PR Review Policy",
5795
+ "",
5796
+ "The `pr-reviewer` sub-agent evaluates every PR it reviews against the",
5797
+ "policy below and routes the PR into one of two modes:",
5798
+ "",
5799
+ "- **`auto-merge`** \u2014 the reviewer may enable squash auto-merge once",
5800
+ " all acceptance criteria are met and CI is green.",
5801
+ "- **`human-required`** \u2014 the reviewer runs the full AC/CI check but",
5802
+ " never calls `gh pr merge --auto`. It applies the",
5803
+ " `review:awaiting-human` label and hands off to a human reviewer.",
5804
+ "",
5805
+ "## Policy",
5806
+ "",
5807
+ "```yaml",
5808
+ "version: 1",
5809
+ "default: auto-merge",
5810
+ "",
5811
+ "human-required:",
5812
+ " paths:",
5813
+ ' - "docs/adrs/**"',
5814
+ ' - "docs/project-context.md"',
5815
+ ' - ".github/workflows/**"',
5816
+ ' - ".github/CODEOWNERS"',
5817
+ ' - ".projenrc.ts"',
5818
+ ' - "projenrc/**"',
5819
+ ' - "CLAUDE.md"',
5820
+ ' - ".claude/**"',
5821
+ ' - "packages/**/package.json"',
5822
+ " issue-types:",
5823
+ " - release",
5824
+ " - hotfix",
5825
+ " size:",
5826
+ " files: 10",
5827
+ " insertions: 500",
5828
+ " labels-that-force-human:",
5829
+ ' - "review:human-required"',
5830
+ ' - "priority:critical"',
5831
+ "",
5832
+ "auto-merge:",
5833
+ " labels-that-force-auto:",
5834
+ ' - "review:auto-ok"',
5835
+ "```",
5836
+ "",
5837
+ "## Precedence",
5838
+ "",
5839
+ "The reviewer walks the following checks in order. The **first match**",
5840
+ "fixes the mode; any mixed-match PR (signals from both sides) resolves",
5841
+ "conservatively to `human-required` \u2014 `auto-merge` only wins when the",
5842
+ "force-auto label is the single top-priority match.",
5843
+ "",
5844
+ "1. **`auto-merge.labels-that-force-auto`** \u2014 if the PR carries any of",
5845
+ " these labels (e.g. `review:auto-ok`), the mode is `auto-merge`",
5846
+ " outright. This is the only escape hatch from the conservative",
5847
+ " default; it requires a maintainer to apply the label explicitly.",
5848
+ "2. **`review:human-required` label** \u2014 reserved force-human label;",
5849
+ " if present (and no force-auto label beat it in step 1), the mode",
5850
+ " is `human-required`.",
5851
+ "3. **`human-required.labels-that-force-human`** \u2014 any listed label on",
5852
+ " the PR (e.g. `priority:critical`) forces `human-required`.",
5853
+ "4. **`human-required.paths`** \u2014 if any file in the PR diff matches",
5854
+ " any glob here, the mode is `human-required`. Matching uses",
5855
+ " standard glob semantics (`**` for recursive directories,",
5856
+ " `*` for a single path segment).",
5857
+ "5. **`human-required.issue-types`** \u2014 if the linked issue's GitHub",
5858
+ " issue type matches any entry (case-insensitive), the mode is",
5859
+ " `human-required`.",
5860
+ "6. **`human-required.size`** \u2014 if the PR exceeds either the `files`",
5861
+ " count or the `insertions` count, the mode is `human-required`.",
5862
+ "7. **`default`** \u2014 applied only when no rule above matched",
5863
+ " (normally `auto-merge`).",
5864
+ "",
5865
+ "The `pr-reviewer` sub-agent records the decided mode and the triggering",
5866
+ "reason in its Phase 2.75 output so downstream phases and any sticky",
5867
+ "summary can cite the specific rule that applied."
5868
+ ].join("\n"),
5869
+ tags: ["policy", "review"]
5870
+ },
5682
5871
  {
5683
5872
  name: "pr-review-workflow",
5684
5873
  description: "Describes the /review-pr and /review-prs skills and their delegation to the pr-reviewer sub-agent",
@@ -5699,15 +5888,21 @@ var prReviewBundle = {
5699
5888
  " has a linked issue). Ineligible PRs get a short comment and are",
5700
5889
  " skipped.",
5701
5890
  "2. Fetches the PR, its diff, CI status, and the linked issue",
5702
- "3. Builds a checklist from the issue's acceptance criteria",
5703
- "4. Verifies the diff satisfies each criterion and that CI is green",
5704
- "5. **Enables squash auto-merge** (with `--delete-branch`) when all",
5705
- " checks pass \u2014 no explicit approval review",
5706
- "6. **Comments with grouped findings** when any check fails (plain",
5891
+ "3. **Evaluates the PR Review Policy** (see the `PR Review Policy`",
5892
+ " section above) to decide whether the PR is `auto-merge` or",
5893
+ " `human-required`, and records the triggering reason",
5894
+ "4. Builds a checklist from the issue's acceptance criteria",
5895
+ "5. Verifies the diff satisfies each criterion and that CI is green",
5896
+ "6. **Enables squash auto-merge** (with `--delete-branch`) when all",
5897
+ " checks pass **and** the review mode is `auto-merge`",
5898
+ "7. **Applies `review:awaiting-human`** and hands off to a human",
5899
+ " reviewer when the review mode is `human-required` (no auto-merge,",
5900
+ " even if every acceptance criterion is met)",
5901
+ "8. **Comments with grouped findings** when any check fails (plain",
5707
5902
  " `gh pr comment`, not a formal `--request-changes` review)",
5708
- "7. After a successful merge, verifies the linked issue is closed",
5903
+ "9. After a successful merge, verifies the linked issue is closed",
5709
5904
  " and closes it explicitly if the merge commit did not",
5710
- "8. Cleans up the local branch after merge",
5905
+ "10. Cleans up the local branch after merge",
5711
5906
  "",
5712
5907
  "The reviewer **never** implements code and **never** pushes commits",
5713
5908
  "to a PR's branch \u2014 it only reviews, decides, and orchestrates merge",