@codedrifters/configulator 0.0.350 → 0.0.351
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.d.mts +103 -11
- package/lib/index.d.ts +103 -11
- package/lib/index.js +233 -7
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +233 -7
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -17782,12 +17782,18 @@ var pnpmBundle = {
|
|
|
17782
17782
|
var DEFAULT_PATHS_EXEMPT_FROM_SIZE = [
|
|
17783
17783
|
"docs/**"
|
|
17784
17784
|
];
|
|
17785
|
+
var DEFAULT_REQUIRED_WORKFLOWS = [];
|
|
17785
17786
|
function resolvePrReviewPolicy(config) {
|
|
17786
17787
|
const pathsExemptFromSize = config?.autoMerge?.pathsExemptFromSize ?? DEFAULT_PATHS_EXEMPT_FROM_SIZE;
|
|
17788
|
+
const requiredWorkflows = config?.ciVerification?.requiredWorkflows ?? DEFAULT_REQUIRED_WORKFLOWS;
|
|
17787
17789
|
assertValidPathsExemptFromSize(pathsExemptFromSize);
|
|
17790
|
+
assertValidRequiredWorkflows(requiredWorkflows);
|
|
17788
17791
|
return {
|
|
17789
17792
|
autoMerge: {
|
|
17790
17793
|
pathsExemptFromSize: [...pathsExemptFromSize]
|
|
17794
|
+
},
|
|
17795
|
+
ciVerification: {
|
|
17796
|
+
requiredWorkflows: [...requiredWorkflows]
|
|
17791
17797
|
}
|
|
17792
17798
|
};
|
|
17793
17799
|
}
|
|
@@ -17803,6 +17809,15 @@ function assertValidPathsExemptFromSize(paths) {
|
|
|
17803
17809
|
}
|
|
17804
17810
|
}
|
|
17805
17811
|
}
|
|
17812
|
+
function assertValidRequiredWorkflows(workflows) {
|
|
17813
|
+
for (const workflow of workflows) {
|
|
17814
|
+
if (typeof workflow !== "string" || workflow.trim().length === 0) {
|
|
17815
|
+
throw new Error(
|
|
17816
|
+
"prReviewPolicy.ciVerification.requiredWorkflows entries must be non-empty strings"
|
|
17817
|
+
);
|
|
17818
|
+
}
|
|
17819
|
+
}
|
|
17820
|
+
}
|
|
17806
17821
|
|
|
17807
17822
|
// src/agent/bundles/pr-review.ts
|
|
17808
17823
|
var prReviewerSubAgent = {
|
|
@@ -17844,6 +17859,125 @@ var prReviewerSubAgent = {
|
|
|
17844
17859
|
"",
|
|
17845
17860
|
"---",
|
|
17846
17861
|
"",
|
|
17862
|
+
"## CI Verification (primary read + Actions-runs fallback)",
|
|
17863
|
+
"",
|
|
17864
|
+
"Every CI-status decision in this agent \u2014 the Phase 1.5 eligibility",
|
|
17865
|
+
"filter, the Phase 3 checklist, the Phase 4 merge gate, the Phase 4",
|
|
17866
|
+
"step (h) re-enable condition, and the Phase 4.5 sticky `CI status`",
|
|
17867
|
+
"field \u2014 resolves CI through the procedure below. It yields one of",
|
|
17868
|
+
"three verdicts: **green** (every required check succeeded),",
|
|
17869
|
+
"**pending** (no failures, but at least one required check is still",
|
|
17870
|
+
"running or queued), or **red** (at least one required check",
|
|
17871
|
+
"failed). Never enable auto-merge unless the verdict is **green**.",
|
|
17872
|
+
"",
|
|
17873
|
+
"### Step 1: Primary read \u2014 check-runs / statusCheckRollup",
|
|
17874
|
+
"",
|
|
17875
|
+
"Read CI from the GitHub check-runs rollup, the canonical source",
|
|
17876
|
+
"GitHub itself uses to gate branch protection:",
|
|
17877
|
+
"",
|
|
17878
|
+
"```bash",
|
|
17879
|
+
"gh pr checks <pr-number>",
|
|
17880
|
+
"# equivalently, the rollup field:",
|
|
17881
|
+
"gh pr view <pr-number> --json statusCheckRollup",
|
|
17882
|
+
"```",
|
|
17883
|
+
"",
|
|
17884
|
+
"This read aggregates **every** check context \u2014 GitHub Actions,",
|
|
17885
|
+
"third-party CI, GitHub Apps, and commit statuses. When it returns",
|
|
17886
|
+
"one or more readable contexts, it is authoritative: map each",
|
|
17887
|
+
"required context's conclusion with the table in Step 4 and do",
|
|
17888
|
+
"**not** fall back. It is strictly more complete than the",
|
|
17889
|
+
"Actions-runs view in Step 3.",
|
|
17890
|
+
"",
|
|
17891
|
+
"### Step 2: Detect the fine-grained-PAT 403",
|
|
17892
|
+
"",
|
|
17893
|
+
"The primary read fails closed for one specific credential: a",
|
|
17894
|
+
"**fine-grained personal access token**. GitHub exposes no `Checks`",
|
|
17895
|
+
"permission for fine-grained PATs (it is GitHub-App-only), so the",
|
|
17896
|
+
"check-runs / `statusCheckRollup` request returns:",
|
|
17897
|
+
"",
|
|
17898
|
+
"```",
|
|
17899
|
+
"HTTP 403: Resource not accessible by personal access token",
|
|
17900
|
+
"```",
|
|
17901
|
+
"",
|
|
17902
|
+
"Trigger the Step 3 fallback **only** when the primary read either:",
|
|
17903
|
+
"",
|
|
17904
|
+
"- returns an explicit **403** (`Resource not accessible by personal",
|
|
17905
|
+
" access token`) on the check-runs / `statusCheckRollup` request,",
|
|
17906
|
+
" **or**",
|
|
17907
|
+
"- returns **no readable check contexts at all** (an empty rollup)",
|
|
17908
|
+
" for a head SHA that does have CI configured.",
|
|
17909
|
+
"",
|
|
17910
|
+
"A primary read that returns one or more readable contexts is",
|
|
17911
|
+
"authoritative \u2014 **never** fall back in that case (GitHub-App and",
|
|
17912
|
+
"classic-PAT consumers keep the complete check-runs view). **Never**",
|
|
17913
|
+
"treat a 403 or an unreadable check as green: the 403 is a",
|
|
17914
|
+
"visibility failure, not a passing signal.",
|
|
17915
|
+
"",
|
|
17916
|
+
"### Step 3: Fallback read \u2014 Actions runs API",
|
|
17917
|
+
"",
|
|
17918
|
+
"A fine-grained PAT with `Actions: Read-only` (which **is**",
|
|
17919
|
+
"grantable) can read workflow-run conclusions even when check-runs",
|
|
17920
|
+
"is denied. Read every workflow run for the PR's head SHA:",
|
|
17921
|
+
"",
|
|
17922
|
+
"```bash",
|
|
17923
|
+
"head_sha=$(gh pr view <pr-number> --json headRefOid --jq '.headRefOid')",
|
|
17924
|
+
'gh api "repos/{{repository.owner}}/{{repository.name}}/actions/runs?head_sha=${head_sha}&per_page=100"',
|
|
17925
|
+
"```",
|
|
17926
|
+
"",
|
|
17927
|
+
"Each run carries a `name`, `status`, and `conclusion`. **Collapse",
|
|
17928
|
+
"re-runs:** when a workflow `name` appears more than once for the",
|
|
17929
|
+
"same head SHA, keep only the most recent run (highest",
|
|
17930
|
+
"`run_number` / latest `created_at`) for that name.",
|
|
17931
|
+
"",
|
|
17932
|
+
"This fallback only sees GitHub Actions runs. It is sound for repos",
|
|
17933
|
+
"whose CI is entirely GitHub Actions; if a consumer adds a",
|
|
17934
|
+
"non-Actions required check, a fine-grained-PAT credential cannot",
|
|
17935
|
+
"see it and the consumer must move the reviewer to a GitHub App /",
|
|
17936
|
+
"classic PAT to regain the complete check-runs view.",
|
|
17937
|
+
"",
|
|
17938
|
+
"### Step 4: Map conclusions to a verdict",
|
|
17939
|
+
"",
|
|
17940
|
+
"Apply this mapping to the set of required checks (Step 5 defines",
|
|
17941
|
+
'"required"):',
|
|
17942
|
+
"",
|
|
17943
|
+
"| status / conclusion | Treatment |",
|
|
17944
|
+
"|---------------------|-----------|",
|
|
17945
|
+
"| `completed` / `success` | pass |",
|
|
17946
|
+
"| `completed` / `skipped` | non-blocking (ignore) |",
|
|
17947
|
+
"| `completed` / `neutral` | non-blocking (ignore) |",
|
|
17948
|
+
"| `completed` / `failure` | **block \u2192 red** |",
|
|
17949
|
+
"| `completed` / `cancelled` | **block \u2192 red** |",
|
|
17950
|
+
"| `completed` / `timed_out` | **block \u2192 red** |",
|
|
17951
|
+
"| `completed` / `action_required` | **block \u2192 red** |",
|
|
17952
|
+
"| `in_progress` / `queued` / `requested` / `waiting` / null conclusion | not-yet-green (pending) |",
|
|
17953
|
+
"",
|
|
17954
|
+
"- If any required check is **red**, the verdict is **red**.",
|
|
17955
|
+
"- Else if any required check is **pending**, the verdict is",
|
|
17956
|
+
" **pending**.",
|
|
17957
|
+
"- Else (every required check passed or was non-blocking) the",
|
|
17958
|
+
" verdict is **green**.",
|
|
17959
|
+
"",
|
|
17960
|
+
'### Step 5: Which workflows are "required"',
|
|
17961
|
+
"",
|
|
17962
|
+
'In the **Step 1 primary path**, "required" means the contexts',
|
|
17963
|
+
"GitHub marks required under branch protection \u2014 the rollup already",
|
|
17964
|
+
"reflects this.",
|
|
17965
|
+
"",
|
|
17966
|
+
"In the **Step 3 fallback path**, the Actions runs API does not say",
|
|
17967
|
+
"which workflows are required, so consult the policy's",
|
|
17968
|
+
"`ci-verification.required-workflows` list (rendered in the",
|
|
17969
|
+
"`PR Review Policy` block in CLAUDE.md):",
|
|
17970
|
+
"",
|
|
17971
|
+
"- **Non-empty list** \u2014 gate only on the workflow `name`s in the",
|
|
17972
|
+
" list. A listed workflow with **no** run for the head SHA is",
|
|
17973
|
+
" treated as not-yet-green (pending), never green.",
|
|
17974
|
+
"- **Empty list (default)** \u2014 treat **every** workflow run observed",
|
|
17975
|
+
" for the head SHA as required. This is the conservative",
|
|
17976
|
+
" zero-config default: an unknown failing workflow blocks rather",
|
|
17977
|
+
" than slips through.",
|
|
17978
|
+
"",
|
|
17979
|
+
"---",
|
|
17980
|
+
"",
|
|
17847
17981
|
"## Phase 1: Identify the PR",
|
|
17848
17982
|
"",
|
|
17849
17983
|
"If a PR number was provided in your instructions, use that. Otherwise stop",
|
|
@@ -17862,7 +17996,12 @@ var prReviewerSubAgent = {
|
|
|
17862
17996
|
'1. `mergeable == "MERGEABLE"` (no merge conflicts).',
|
|
17863
17997
|
"2. No **failing** required checks in `statusCheckRollup` \u2014 CI must be",
|
|
17864
17998
|
" green or still pending. Any `FAILURE`, `TIMED_OUT`, `CANCELLED`, or",
|
|
17865
|
-
" `ERROR` conclusion on a required check disqualifies the PR.",
|
|
17999
|
+
" `ERROR` conclusion on a required check disqualifies the PR. If the",
|
|
18000
|
+
" `statusCheckRollup` read returns a 403 `Resource not accessible by",
|
|
18001
|
+
" personal access token` (fine-grained PAT) or an empty rollup,",
|
|
18002
|
+
" resolve CI via the **CI Verification** section's Actions-runs",
|
|
18003
|
+
" fallback before deciding eligibility \u2014 do **not** treat the 403 as",
|
|
18004
|
+
" either a pass or an automatic disqualification.",
|
|
17866
18005
|
"3. The PR body contains a linked issue via one of the closing keywords:",
|
|
17867
18006
|
" `Closes #N`, `Fixes #N`, or `Resolves #N` (case-insensitive).",
|
|
17868
18007
|
"",
|
|
@@ -18080,7 +18219,9 @@ var prReviewerSubAgent = {
|
|
|
18080
18219
|
"- **Convention compliance** \u2014 PR title uses a conventional commit prefix,",
|
|
18081
18220
|
" body includes a closing keyword, branch name follows project conventions",
|
|
18082
18221
|
"- **Test coverage** \u2014 new or changed behavior has tests",
|
|
18083
|
-
"- **CI status** \u2014
|
|
18222
|
+
"- **CI status** \u2014 resolve CI via the **CI Verification** section",
|
|
18223
|
+
" (primary check-runs read, with the Actions-runs fallback on a",
|
|
18224
|
+
" fine-grained-PAT 403). The verdict must be **green**.",
|
|
18084
18225
|
"- **Scope creep** \u2014 diff stays within the issue's stated scope",
|
|
18085
18226
|
"",
|
|
18086
18227
|
"## Phase 3.5: Classify Comments",
|
|
@@ -18455,7 +18596,9 @@ var prReviewerSubAgent = {
|
|
|
18455
18596
|
" pushbacks added in step (a) and the failure pushbacks added in",
|
|
18456
18597
|
" step (f).",
|
|
18457
18598
|
"4. CI is green or still pending (any failing required check",
|
|
18458
|
-
" disqualifies re-enablement).",
|
|
18599
|
+
" disqualifies re-enablement). Resolve CI via the **CI",
|
|
18600
|
+
" Verification** section, including the Actions-runs fallback on a",
|
|
18601
|
+
" fine-grained-PAT 403.",
|
|
18459
18602
|
"",
|
|
18460
18603
|
"When all four hold, re-enable auto-merge with the same command used",
|
|
18461
18604
|
"in the auto-merge branch below:",
|
|
@@ -18854,7 +18997,9 @@ var prReviewerSubAgent = {
|
|
|
18854
18997
|
"- **AC status** \u2014 the checklist produced in Phase 3 (met, partial,",
|
|
18855
18998
|
" or missing), with links to the files or tests that provide the",
|
|
18856
18999
|
" evidence.",
|
|
18857
|
-
"- **CI status** \u2014
|
|
19000
|
+
"- **CI status** \u2014 the verdict from the **CI Verification** section",
|
|
19001
|
+
" (primary check-runs read, or the Actions-runs fallback when",
|
|
19002
|
+
" check-runs returns a fine-grained-PAT 403).",
|
|
18858
19003
|
"- **Outstanding** \u2014 the comments still carrying a non-terminal",
|
|
18859
19004
|
" reviewer reaction from Phase 3.5 (typically `eyes` for queued",
|
|
18860
19005
|
" in-scope items and `nit` / `question` items that remain open).",
|
|
@@ -18979,7 +19124,11 @@ var prReviewerSubAgent = {
|
|
|
18979
19124
|
"2. **Never merge without a linked issue.** If the PR body has no",
|
|
18980
19125
|
" `Closes #N` / `Fixes #N` / `Resolves #N`, comment and stop.",
|
|
18981
19126
|
"3. **Never merge with failing CI.** Even if every criterion is met,",
|
|
18982
|
-
" block on red checks.",
|
|
19127
|
+
" block on red checks. Resolve CI status via the **CI",
|
|
19128
|
+
" Verification** section: read check-runs first, and only on a",
|
|
19129
|
+
" fine-grained-PAT 403 (or an empty rollup) fall back to the",
|
|
19130
|
+
" Actions runs API. A 403 is a visibility failure, **never** a",
|
|
19131
|
+
" passing check \u2014 do not treat an unreadable check as green.",
|
|
18983
19132
|
"4. **Never bypass review conventions.** Always use `--squash`, `--auto`,",
|
|
18984
19133
|
" and `--delete-branch` for merges. Do not force-merge.",
|
|
18985
19134
|
"5. **Never auto-merge a `human-required` PR.** When Phase 2.75 resolves",
|
|
@@ -19161,7 +19310,10 @@ var reviewPrsSkill = {
|
|
|
19161
19310
|
'2. `mergeable == "MERGEABLE"` (no conflicts).',
|
|
19162
19311
|
"3. No required check in `statusCheckRollup` has a failing conclusion",
|
|
19163
19312
|
" (`FAILURE`, `TIMED_OUT`, `CANCELLED`, `ERROR`). CI green or still",
|
|
19164
|
-
" pending is fine.",
|
|
19313
|
+
" pending is fine. When `statusCheckRollup` is empty or denied with",
|
|
19314
|
+
" a fine-grained-PAT 403, keep the PR in the queue \u2014 the per-PR",
|
|
19315
|
+
" pipeline resolves CI authoritatively via the reviewer's CI",
|
|
19316
|
+
" Verification Actions-runs fallback.",
|
|
19165
19317
|
"4. The PR body contains a linked issue (`Closes #N` / `Fixes #N` /",
|
|
19166
19318
|
" `Resolves #N`, case-insensitive).",
|
|
19167
19319
|
"",
|
|
@@ -19280,6 +19432,12 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
|
|
|
19280
19432
|
...renderPathsExemptFromSizeYaml(
|
|
19281
19433
|
policy.autoMerge.pathsExemptFromSize
|
|
19282
19434
|
),
|
|
19435
|
+
"",
|
|
19436
|
+
"ci-verification:",
|
|
19437
|
+
" required-workflows:",
|
|
19438
|
+
...renderRequiredWorkflowsYaml(
|
|
19439
|
+
policy.ciVerification.requiredWorkflows
|
|
19440
|
+
),
|
|
19283
19441
|
"```",
|
|
19284
19442
|
"",
|
|
19285
19443
|
"## Precedence",
|
|
@@ -19361,7 +19519,69 @@ function buildPrReviewBundle(policy = resolvePrReviewPolicy()) {
|
|
|
19361
19519
|
"out only kicks in for **code-heavy** PRs that legitimately trip",
|
|
19362
19520
|
"rule #6 (mixed-content diffs whose non-doc paths fail the",
|
|
19363
19521
|
"`paths-exempt-from-size` check, or consumers that disable the",
|
|
19364
|
-
"doc-only carve-out entirely)."
|
|
19522
|
+
"doc-only carve-out entirely).",
|
|
19523
|
+
"",
|
|
19524
|
+
"## CI Verification",
|
|
19525
|
+
"",
|
|
19526
|
+
"Before enabling auto-merge the reviewer confirms CI is green.",
|
|
19527
|
+
"The **primary** read is the GitHub check-runs rollup",
|
|
19528
|
+
"(`gh pr checks` / `statusCheckRollup`) \u2014 the same source",
|
|
19529
|
+
"GitHub uses for branch protection, covering **every** check",
|
|
19530
|
+
"context (Actions, third-party CI, GitHub Apps, commit",
|
|
19531
|
+
"statuses). It stays primary for every consumer because it is",
|
|
19532
|
+
"strictly more complete than the Actions-only fallback below.",
|
|
19533
|
+
"",
|
|
19534
|
+
"### Fine-grained-PAT fallback to the Actions runs API",
|
|
19535
|
+
"",
|
|
19536
|
+
"When the reviewer authenticates with a **fine-grained personal",
|
|
19537
|
+
"access token**, the check-runs read returns",
|
|
19538
|
+
"`HTTP 403: Resource not accessible by personal access token`.",
|
|
19539
|
+
"This is not grantable away: GitHub exposes **no `Checks`",
|
|
19540
|
+
"permission for fine-grained tokens** (it is GitHub-App-only),",
|
|
19541
|
+
"so the token permission picker has no entry to add. On that",
|
|
19542
|
+
"specific 403 (or when the rollup returns no readable contexts",
|
|
19543
|
+
"at all), the reviewer falls back to the **Actions runs API**:",
|
|
19544
|
+
"",
|
|
19545
|
+
"```",
|
|
19546
|
+
"GET /repos/{owner}/{repo}/actions/runs?head_sha={head_sha}&per_page=100",
|
|
19547
|
+
"```",
|
|
19548
|
+
"",
|
|
19549
|
+
"which a fine-grained PAT with `Actions: Read-only` **can**",
|
|
19550
|
+
"read. Auto-merge is then gated on the required workflows'",
|
|
19551
|
+
"latest run per workflow name concluding `success`",
|
|
19552
|
+
"(`skipped` / `neutral` are non-blocking; `failure` /",
|
|
19553
|
+
"`cancelled` / `timed_out` / `action_required` block; a run",
|
|
19554
|
+
"still `in_progress` / `queued`, or a required workflow with no",
|
|
19555
|
+
"run at all, counts as not-yet-green). The 403 is detected",
|
|
19556
|
+
"explicitly and is **never** treated as a passing check \u2014 it is",
|
|
19557
|
+
"a visibility failure, not a green signal.",
|
|
19558
|
+
"",
|
|
19559
|
+
"The fallback fires **only** when the primary check-runs read",
|
|
19560
|
+
"is denied, so GitHub-App and classic-PAT consumers (which can",
|
|
19561
|
+
"read check-runs) are unaffected and keep the complete view.",
|
|
19562
|
+
"The fallback only sees GitHub Actions runs; a consumer whose",
|
|
19563
|
+
"CI includes a non-Actions required check cannot verify it on a",
|
|
19564
|
+
"fine-grained PAT and must move the reviewer to a GitHub App /",
|
|
19565
|
+
"classic PAT to regain the complete check-runs view.",
|
|
19566
|
+
"",
|
|
19567
|
+
"### Configuring required workflows",
|
|
19568
|
+
"",
|
|
19569
|
+
"The `ci-verification.required-workflows` list in the policy",
|
|
19570
|
+
"YAML names the workflows the fallback gates on:",
|
|
19571
|
+
"",
|
|
19572
|
+
"- **Non-empty list** \u2014 gate only on those workflow `name`s.",
|
|
19573
|
+
" A listed workflow with no run for the head SHA is treated as",
|
|
19574
|
+
" not-yet-green (pending), never green.",
|
|
19575
|
+
"- **Empty list (the default)** \u2014 treat **every** workflow run",
|
|
19576
|
+
" observed for the head SHA as required. This is the",
|
|
19577
|
+
" conservative zero-config default so an unknown failing",
|
|
19578
|
+
" workflow blocks rather than slips through.",
|
|
19579
|
+
"",
|
|
19580
|
+
"Consumers tune the list via",
|
|
19581
|
+
"`agentConfig.prReviewPolicy.ciVerification.requiredWorkflows`.",
|
|
19582
|
+
"The list governs **only** the fallback path; the primary",
|
|
19583
|
+
'check-runs read derives "required" from branch protection',
|
|
19584
|
+
"directly."
|
|
19365
19585
|
].join("\n"),
|
|
19366
19586
|
tags: ["policy", "review"]
|
|
19367
19587
|
},
|
|
@@ -19647,6 +19867,12 @@ function renderPathsExemptFromSizeYaml(paths) {
|
|
|
19647
19867
|
}
|
|
19648
19868
|
return paths.map((path8) => ` - "${path8}"`);
|
|
19649
19869
|
}
|
|
19870
|
+
function renderRequiredWorkflowsYaml(workflows) {
|
|
19871
|
+
if (workflows.length === 0) {
|
|
19872
|
+
return [" []"];
|
|
19873
|
+
}
|
|
19874
|
+
return workflows.map((workflow) => ` - "${workflow}"`);
|
|
19875
|
+
}
|
|
19650
19876
|
var prReviewBundle = buildPrReviewBundle();
|
|
19651
19877
|
|
|
19652
19878
|
// src/agent/bundles/projen.ts
|