@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.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,84 @@ 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.75: Determine Review Mode",
5458
+ "",
5459
+ "Before comparing the diff to the acceptance criteria, evaluate the PR",
5460
+ "against the **PR Review Policy** embedded in this repository's",
5461
+ "`CLAUDE.md` (rendered from the `pr-review-policy` rule). The decision",
5462
+ "here governs whether Phase 4 enables auto-merge or hands off to a",
5463
+ "human reviewer.",
5464
+ "",
5465
+ "### Step 1: Load the policy",
5466
+ "",
5467
+ "Read `CLAUDE.md` from the repo root and extract the fenced YAML block",
5468
+ "under the `## PR Review Policy` heading. Parse the block into an",
5469
+ "in-memory object with the following top-level fields: `version`,",
5470
+ "`default`, `human-required`, `auto-merge`.",
5471
+ "",
5472
+ "If the policy section is missing or unparseable, fall back to",
5473
+ "`mode = human-required` with `reason = 'policy missing or unreadable'`",
5474
+ "and skip to Step 3. Do **not** auto-merge when the policy is absent.",
5475
+ "",
5476
+ "### Step 2: Evaluate in precedence order",
5477
+ "",
5478
+ "Walk the following checks in order. The **first match wins** and fixes",
5479
+ "the mode; record the triggering condition as the `reason`. Mixed-match",
5480
+ "PRs (signals from both sides) resolve conservatively to",
5481
+ "`human-required` \u2014 force-auto only wins when it is the single highest",
5482
+ "match and no later human-required signal changes the outcome under",
5483
+ "step 2c.",
5484
+ "",
5485
+ "1. **Force-auto label** \u2014 if the PR carries any label listed under",
5486
+ " `auto-merge.labels-that-force-auto` (e.g. `review:auto-ok`), set",
5487
+ " `mode = auto-merge`.",
5488
+ "2. **Force-human label (reserved)** \u2014 if the PR carries a",
5489
+ " `review:human-required` label, set `mode = human-required`.",
5490
+ "3. **Labels that force human** \u2014 if the PR carries any label listed",
5491
+ " under `human-required.labels-that-force-human` (e.g.",
5492
+ " `priority:critical`), set `mode = human-required`.",
5493
+ "4. **Path globs** \u2014 if any file in the PR diff matches any glob in",
5494
+ " `human-required.paths`, set `mode = human-required`. Record the",
5495
+ " first matching path + glob pair as the reason.",
5496
+ "5. **Issue type** \u2014 if the linked issue's GitHub issue type",
5497
+ " (fetched in Phase 2) matches any entry in",
5498
+ " `human-required.issue-types` (case-insensitive), set",
5499
+ " `mode = human-required`.",
5500
+ "6. **Size thresholds** \u2014 if the PR exceeds either threshold under",
5501
+ " `human-required.size` (`files` count or `insertions` count), set",
5502
+ " `mode = human-required`.",
5503
+ "7. **Default** \u2014 if no rule above matched, apply the `default` field",
5504
+ " from the policy (typically `auto-merge`).",
5505
+ "",
5506
+ "#### Mixed-match resolution",
5507
+ "",
5508
+ "Apart from rule (1), which is an explicit opt-in and wins outright,",
5509
+ "**any** match from rules (2) through (6) forces `human-required` even",
5510
+ "if a non-force-auto signal would otherwise have allowed auto-merge.",
5511
+ "The conservative choice wins. Rule (1) is the sole escape hatch and",
5512
+ "requires a maintainer to have applied the force-auto label.",
5513
+ "",
5514
+ "### Step 3: Record the decision",
5515
+ "",
5516
+ "Persist the evaluated mode and reason for later phases so Phase 4 and",
5517
+ "any downstream summary writer can cite it:",
5518
+ "",
5519
+ "```",
5520
+ "Review mode: <auto-merge | human-required>",
5521
+ "Reason: <short explanation \u2014 label name, path+glob, issue type, size threshold, default>",
5522
+ "```",
5523
+ "",
5524
+ "Phases 3 (acceptance-criteria comparison) and CI verification run",
5525
+ "unchanged regardless of mode. Only the terminal action in Phase 4",
5526
+ "branches on the decided mode.",
5527
+ "",
5456
5528
  "## Phase 3: Compare Diff to Acceptance Criteria",
5457
5529
  "",
5458
5530
  "Read the issue body for an **Acceptance Criteria** (or equivalent) section.",
@@ -5474,6 +5546,10 @@ var prReviewerSubAgent = {
5474
5546
  "",
5475
5547
  "### If all acceptance criteria are met and CI is green",
5476
5548
  "",
5549
+ "Branch on the **review mode** decided in Phase 2.75:",
5550
+ "",
5551
+ "#### Mode `auto-merge`",
5552
+ "",
5477
5553
  "Enable squash auto-merge with branch deletion. This queues the merge to",
5478
5554
  "happen once required checks pass; no separate approval review is needed.",
5479
5555
  "",
@@ -5487,6 +5563,27 @@ var prReviewerSubAgent = {
5487
5563
  "`feat(scope): description`). The body should bullet the changes and end",
5488
5564
  "with `Closes #<issue-number>`.",
5489
5565
  "",
5566
+ "#### Mode `human-required`",
5567
+ "",
5568
+ "Do **not** run `gh pr merge --auto`. Instead, hand the PR off to a",
5569
+ "human reviewer:",
5570
+ "",
5571
+ "1. Apply the `review:awaiting-human` label so the PR is discoverable",
5572
+ " in the human-review queue:",
5573
+ "",
5574
+ " ```bash",
5575
+ " gh pr edit <pr-number> --add-label 'review:awaiting-human'",
5576
+ " ```",
5577
+ "",
5578
+ "2. Exit cleanly after the acceptance-criteria check completes and any",
5579
+ " summary comment the reviewer posts. Proceed to Phase 5 only if a",
5580
+ " merge occurred \u2014 in `human-required` mode the reviewer stops at",
5581
+ " the hand-off and does not poll for merge.",
5582
+ "",
5583
+ "The reason captured in Phase 2.75 should be included in any summary",
5584
+ "comment so maintainers know why human review was required (path hit,",
5585
+ "issue type, size threshold, label, or default).",
5586
+ "",
5490
5587
  "### If any criterion is missing, partial, or CI is failing",
5491
5588
  "",
5492
5589
  "Post a plain comment (not a formal review block) with grouped findings:",
@@ -5506,8 +5603,12 @@ var prReviewerSubAgent = {
5506
5603
  "",
5507
5604
  "## Phase 5: Branch Cleanup and Issue Closure Verification",
5508
5605
  "",
5509
- "Auto-merge may not be immediate. Poll the PR state up to 10 times, waiting",
5510
- "30 seconds between polls:",
5606
+ "Skip this phase entirely when the review mode from Phase 2.75 is",
5607
+ "`human-required` \u2014 no merge was initiated, so there is nothing to poll",
5608
+ "and no branch to clean up. Report the hand-off and stop.",
5609
+ "",
5610
+ "In `auto-merge` mode, auto-merge may not be immediate. Poll the PR",
5611
+ "state up to 10 times, waiting 30 seconds between polls:",
5511
5612
  "",
5512
5613
  "```bash",
5513
5614
  "gh pr view <pr-number> --json state --jq '.state'",
@@ -5550,7 +5651,9 @@ var prReviewerSubAgent = {
5550
5651
  "```",
5551
5652
  "PR #<number> \u2014 <title>",
5552
5653
  "Linked issue: #<issue-number>",
5553
- "Verdict: AUTO_MERGE_ENABLED | NEEDS_CHANGES | INELIGIBLE | BLOCKED",
5654
+ "Review mode: <auto-merge | human-required>",
5655
+ "Reason: <short explanation from Phase 2.75>",
5656
+ "Verdict: AUTO_MERGE_ENABLED | AWAITING_HUMAN | NEEDS_CHANGES | INELIGIBLE | BLOCKED",
5554
5657
  "",
5555
5658
  "Acceptance criteria:",
5556
5659
  " [x] <criterion> \u2014 <evidence>",
@@ -5562,7 +5665,7 @@ var prReviewerSubAgent = {
5562
5665
  " - Suggested: <items>",
5563
5666
  " - Nitpick: <items>",
5564
5667
  "",
5565
- "Action taken: <enable-auto-merge | commented-on-the-pr | none>",
5668
+ "Action taken: <enable-auto-merge | label-awaiting-human | commented-on-the-pr | none>",
5566
5669
  "Branch state: <merged | open | closed>",
5567
5670
  "Issue state: <closed | open>",
5568
5671
  "```",
@@ -5580,15 +5683,19 @@ var prReviewerSubAgent = {
5580
5683
  " block on red checks.",
5581
5684
  "4. **Never bypass review conventions.** Always use `--squash`, `--auto`,",
5582
5685
  " and `--delete-branch` for merges. Do not force-merge.",
5583
- "5. **Do not implement code.** You review, decide, and orchestrate. If",
5686
+ "5. **Never auto-merge a `human-required` PR.** When Phase 2.75 resolves",
5687
+ " to `human-required`, Phase 4 applies `review:awaiting-human` and",
5688
+ " exits. Even if every acceptance criterion is met and CI is green,",
5689
+ " `gh pr merge --auto` is forbidden in that mode.",
5690
+ "6. **Do not implement code.** You review, decide, and orchestrate. If",
5584
5691
  " the PR needs changes, comment and stop.",
5585
- "6. **Never push commits to the PR's branch.** If the PR needs changes,",
5692
+ "7. **Never push commits to the PR's branch.** If the PR needs changes,",
5586
5693
  " comment and stop \u2014 do not attempt to fix it yourself. The PR author",
5587
5694
  " 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",
5695
+ "8. **In loop mode (`/review-prs`), never stop early.** If any review",
5589
5696
  " fails, comment and move to the next PR. Only abort the loop on a",
5590
5697
  " fatal error (e.g. `gh` auth failure, network outage).",
5591
- "8. **Follow CLAUDE.md conventions** for all `git` and `gh` operations."
5698
+ "9. **Follow CLAUDE.md conventions** for all `git` and `gh` operations."
5592
5699
  ].join("\n")
5593
5700
  };
5594
5701
  var reviewPrSkill = {
@@ -5756,6 +5863,88 @@ var prReviewBundle = {
5756
5863
  // still exclude it explicitly via `excludeBundles` if desired.
5757
5864
  appliesWhen: () => true,
5758
5865
  rules: [
5866
+ {
5867
+ name: "pr-review-policy",
5868
+ description: "Declarative policy that tells the pr-reviewer which PRs may auto-merge and which must wait for a human reviewer",
5869
+ scope: AGENT_RULE_SCOPE.ALWAYS,
5870
+ content: [
5871
+ "# PR Review Policy",
5872
+ "",
5873
+ "The `pr-reviewer` sub-agent evaluates every PR it reviews against the",
5874
+ "policy below and routes the PR into one of two modes:",
5875
+ "",
5876
+ "- **`auto-merge`** \u2014 the reviewer may enable squash auto-merge once",
5877
+ " all acceptance criteria are met and CI is green.",
5878
+ "- **`human-required`** \u2014 the reviewer runs the full AC/CI check but",
5879
+ " never calls `gh pr merge --auto`. It applies the",
5880
+ " `review:awaiting-human` label and hands off to a human reviewer.",
5881
+ "",
5882
+ "## Policy",
5883
+ "",
5884
+ "```yaml",
5885
+ "version: 1",
5886
+ "default: auto-merge",
5887
+ "",
5888
+ "human-required:",
5889
+ " paths:",
5890
+ ' - "docs/adrs/**"',
5891
+ ' - "docs/project-context.md"',
5892
+ ' - ".github/workflows/**"',
5893
+ ' - ".github/CODEOWNERS"',
5894
+ ' - ".projenrc.ts"',
5895
+ ' - "projenrc/**"',
5896
+ ' - "CLAUDE.md"',
5897
+ ' - ".claude/**"',
5898
+ ' - "packages/**/package.json"',
5899
+ " issue-types:",
5900
+ " - release",
5901
+ " - hotfix",
5902
+ " size:",
5903
+ " files: 10",
5904
+ " insertions: 500",
5905
+ " labels-that-force-human:",
5906
+ ' - "review:human-required"',
5907
+ ' - "priority:critical"',
5908
+ "",
5909
+ "auto-merge:",
5910
+ " labels-that-force-auto:",
5911
+ ' - "review:auto-ok"',
5912
+ "```",
5913
+ "",
5914
+ "## Precedence",
5915
+ "",
5916
+ "The reviewer walks the following checks in order. The **first match**",
5917
+ "fixes the mode; any mixed-match PR (signals from both sides) resolves",
5918
+ "conservatively to `human-required` \u2014 `auto-merge` only wins when the",
5919
+ "force-auto label is the single top-priority match.",
5920
+ "",
5921
+ "1. **`auto-merge.labels-that-force-auto`** \u2014 if the PR carries any of",
5922
+ " these labels (e.g. `review:auto-ok`), the mode is `auto-merge`",
5923
+ " outright. This is the only escape hatch from the conservative",
5924
+ " default; it requires a maintainer to apply the label explicitly.",
5925
+ "2. **`review:human-required` label** \u2014 reserved force-human label;",
5926
+ " if present (and no force-auto label beat it in step 1), the mode",
5927
+ " is `human-required`.",
5928
+ "3. **`human-required.labels-that-force-human`** \u2014 any listed label on",
5929
+ " the PR (e.g. `priority:critical`) forces `human-required`.",
5930
+ "4. **`human-required.paths`** \u2014 if any file in the PR diff matches",
5931
+ " any glob here, the mode is `human-required`. Matching uses",
5932
+ " standard glob semantics (`**` for recursive directories,",
5933
+ " `*` for a single path segment).",
5934
+ "5. **`human-required.issue-types`** \u2014 if the linked issue's GitHub",
5935
+ " issue type matches any entry (case-insensitive), the mode is",
5936
+ " `human-required`.",
5937
+ "6. **`human-required.size`** \u2014 if the PR exceeds either the `files`",
5938
+ " count or the `insertions` count, the mode is `human-required`.",
5939
+ "7. **`default`** \u2014 applied only when no rule above matched",
5940
+ " (normally `auto-merge`).",
5941
+ "",
5942
+ "The `pr-reviewer` sub-agent records the decided mode and the triggering",
5943
+ "reason in its Phase 2.75 output so downstream phases and any sticky",
5944
+ "summary can cite the specific rule that applied."
5945
+ ].join("\n"),
5946
+ tags: ["policy", "review"]
5947
+ },
5759
5948
  {
5760
5949
  name: "pr-review-workflow",
5761
5950
  description: "Describes the /review-pr and /review-prs skills and their delegation to the pr-reviewer sub-agent",
@@ -5776,15 +5965,21 @@ var prReviewBundle = {
5776
5965
  " has a linked issue). Ineligible PRs get a short comment and are",
5777
5966
  " skipped.",
5778
5967
  "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",
5968
+ "3. **Evaluates the PR Review Policy** (see the `PR Review Policy`",
5969
+ " section above) to decide whether the PR is `auto-merge` or",
5970
+ " `human-required`, and records the triggering reason",
5971
+ "4. Builds a checklist from the issue's acceptance criteria",
5972
+ "5. Verifies the diff satisfies each criterion and that CI is green",
5973
+ "6. **Enables squash auto-merge** (with `--delete-branch`) when all",
5974
+ " checks pass **and** the review mode is `auto-merge`",
5975
+ "7. **Applies `review:awaiting-human`** and hands off to a human",
5976
+ " reviewer when the review mode is `human-required` (no auto-merge,",
5977
+ " even if every acceptance criterion is met)",
5978
+ "8. **Comments with grouped findings** when any check fails (plain",
5784
5979
  " `gh pr comment`, not a formal `--request-changes` review)",
5785
- "7. After a successful merge, verifies the linked issue is closed",
5980
+ "9. After a successful merge, verifies the linked issue is closed",
5786
5981
  " and closes it explicitly if the merge commit did not",
5787
- "8. Cleans up the local branch after merge",
5982
+ "10. Cleans up the local branch after merge",
5788
5983
  "",
5789
5984
  "The reviewer **never** implements code and **never** pushes commits",
5790
5985
  "to a PR's branch \u2014 it only reviews, decides, and orchestrates merge",