@mark1russell7/conventions 0.26.0 → 0.27.0

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/README.md CHANGED
@@ -24,6 +24,7 @@ Each break shows the file, the line, the rule and the fix. In GitHub Actions, th
24
24
 
25
25
  - `runner-budget`: the minute of a schedule, a `max-parallel` of a matrix, and a concurrency group at the top of a workflow. A new run of a pull request stops the old run. A run of another event waits for the old run.
26
26
  - `main-runs-finish`: a `cancel-in-progress: true` or a concurrency group that ends with `${{ github.ref }}`, in a workflow that starts on `push` or on `workflow_call`. The fix writes `${{ github.event_name == 'pull_request' }}` and `${{ github.event_name == 'pull_request' && github.ref || github.sha }}`.
27
+ - `push-main-only`: a workflow that starts on `push` and on `pull_request`, with no limit of `push` to the default branch or with no `workflow_dispatch`. The fix adds `branches` and `workflow_dispatch`, and keeps the comments and each other trigger. It keeps a tag run when the workflow reads the tag. It does not edit `release.yml`, and a person chooses the change for `branches-ignore` or for another named branch.
27
28
  - `tests-required`: the option `passWithNoTests` in a config or a script, in a package with test files. A package with no tests needs a person, who removes its test script.
28
29
  - `typed-files`: a config file at the root of a package (`vitest.config.ts`). The fix adds `*.config.ts` and `rootDir: "."` to the `tsconfig.test.json` of the package, when that file has no comments.
29
30
  - `trust-policy`: the settings `trustPolicy`, `trustPolicyIgnoreAfter` and `trustPolicyExclude` of `pnpm-workspace.yaml`. The fix makes the file when the repository has none.
@@ -57,6 +58,7 @@ The rules come from the invariants audit of 2026-10-26 (strategy item s38). The
57
58
  | `roadmap-parses` | Each call of the Pages workflow of the template (`reusable-pages.yml`) gives a `roadmap`, or `site-pages: false`. Without it, the Status page shows no item of the plan. Each roadmap that a workflow gives to the Status page (a `roadmap:` key) parses as `@mark1russell7/site-pages` reads it. The rule uses the parser of site-pages. Thus a pull request finds a bad row, and the Pages job on `main` does not stop on it. | fleet `fail-closed` (STRATEGY.md, 2026-10-30). |
58
59
  | `runner-budget` | All repositories of the account share 40 runners. Each `strategy` with a `matrix` has a `max-parallel` of 3 or less. Each workflow has a concurrency group at the top or in each job. A job that calls a shared workflow of the option `grouped` gets its group from that workflow, and each job of that workflow has a group. The minute of each `cron` comes from a hash of the repository and the file (1 to 59), so the schedules of the repositories do not start together. The repository comes from `GITHUB_REPOSITORY` or from the remote `origin`. | fleet `runner-slots` (STRATEGY.md, 2026-10-30). |
59
60
  | `main-runs-finish` | A workflow that starts on `push` or on `workflow_call` does not cancel a run in progress. A called workflow gets the event of its caller. A newer push cancels only the run of a pull request: `cancel-in-progress: ${{ github.event_name == 'pull_request' }}`. Each commit of `main` has its own concurrency group: `${{ github.event_name == 'pull_request' && github.ref || github.sha }}`. In one group, GitHub cancels a run that waits when a newer run comes, whatever `cancel-in-progress` says. On 2026-11-03 four waiting CI runs of `main` in client were cancelled, so its version commit had no result and no release. On 2026-11-03 the next merge cancelled the CI run of a commit on `main`, so the main check of that commit had no result. A bench run on `main` was cancelled too, and its claim had no measurement. | fleet `main-runs-finish` (STRATEGY.md, 2026-11-03). |
61
+ | `push-main-only` | A workflow that starts on `push` and on `pull_request` limits `push` to the default branch with `branches`, and has `workflow_dispatch`. Without the limit, each commit of a pull request starts two runs. A `push` with only a tag filter, a `pull_request` with `types` that do not have `synchronize`, and `pull_request_target` are not breaks. `CI.md` tells each case in "One run for each commit". |
60
62
  | `gate-trigger` | No workflow has `paths` or `paths-ignore` on `on.pull_request` or `on.pull_request_target`. The ruleset needs the summary check `<Name> OK` of each gate, and a workflow with a path filter does not start on each pull request. Then its check is not there, the ruleset cannot ask for it, and a pull request can merge before the gate ends. A gate uses the actions `changes` and `gate-summary` of the template (`CI.md`, "A gate with paths"). | fleet `gate-trigger` (STRATEGY.md, 2026-11-02). |
61
63
  | `license-file` | Each public package has a license field, and a license file with the same license in its own folder. A public repository, or a repository with a public package, has a license file at its root. In a GitHub Actions run, the event file tells if the repository is public, and the option `license` (MIT by default) is the license of a root with no public package. npm packs only the license file of the folder of the package, and GitHub reads only the one of the root: on 2026-11-02 five public repositories showed no license on GitHub while npm said MIT. `conventions fix` writes the missing files. | fleet strategy (2026-11-02). |
62
64
  | `home-package` | A change does not add a function with a signature name of another home of the map (for example `median`, `mulberry32` or `writeFileAtomic`). A local copy drifts from the home and splits the fixes. On 2026-11-02 the fleet had 68 local statistics functions in 14 repositories. The rule examines only the lines that the change adds, so the copies that exist do not break. | fleet direction 18 (STRATEGY.md, 2026-11-02). |
@@ -128,6 +130,7 @@ An unknown rule, an unknown option, or an exception or a changed option without
128
130
  | `runner-budget.minute` | `true` | When `false`, the rule does not examine the minute of the schedules. |
129
131
  | `runner-budget.grouped` | `["reusable-ai-review.yml", "reusable-codex-review.yml"]` | The shared workflows that give a concurrency group in each of their jobs. |
130
132
  | `gate-trigger.allow` | `[]` | The file names of the workflows that can filter pull requests by path, because they are not a gate (for example a preview). |
133
+ | `push-main-only.branches` | `[]` | More branches that `on.push.branches` can name, for example a long-lived release branch. |
131
134
  | `home-package.scope` | `"change"` | `"change"`: only the lines that a pull request or `--base` adds. `"all"`: each line of each tracked file, for a sweep of the copies that exist. |
132
135
  | `shared-docs.locks` | `[]` | The lock files to check. With no value, the rule checks each tracked file `shared.lock.json`. |
133
136
  | `shared-docs.remote` | `"ci"` | When the rule downloads the homes of the linked blocks: `"ci"` (only when `CI` is `"true"`), `"always"` or `"never"`. |
package/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as runCli } from "./run-DORqvzBZ.js";
2
+ import { c as runCli } from "./run-DRAlJPKd.js";
3
3
  // src/cli.ts
4
4
  try {
5
5
  process.exitCode = runCli(process.argv.slice(2), {
package/build/index.d.ts CHANGED
@@ -279,6 +279,7 @@ export declare function isGitSpecifier(spec: string): boolean;
279
279
  */
280
280
  export declare function isPinned(spec: string, fullSha: boolean): boolean;
281
281
  export declare const pinnedGitDeps: Rule;
282
+ export declare const pushMainOnly: Rule;
282
283
  export declare const releaseFiles: Rule;
283
284
  export declare const requiredScripts: Rule;
284
285
  /** This function gives the value of a `roadmap: <file>` line, or undefined for another line, an empty value or an expression. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/gate-trigger.ts","../src/map.ts","../src/rules/home-package.ts","../src/rules/license-file.ts","../src/rules/main-check.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pages-site.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/runner-budget.ts","../src/rules/shared-docs.ts","../src/rules/source-main.ts","../src/rules/tests-required.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-files.ts","../src/rules/typed-scripts.ts","../src/rules/trust-policy.ts","../src/rules/unreleased-change.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/home-exports.ts","../src/workflow.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;WAEA,iBAAiB;;;;;;UAOX;;WAEN;;WAEA;;WAEA;;;wBAIK,YAAY,cAAc,cAAc;;KAQ5C;;KAGA,UAAU,SAAS,eAAe;;UAG7B;WACN;WACA,SAAS;WACT;;;KAIC,WAAW,SAAS;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,UAAU;;;UAIJ;;WAEN;;WAEA,aAAa;;WAEb,mBAAmB;;WAEnB,KAAK,SAAS;;WAEd;;EAET;;EAEA,IAAI;;;KAIM,uBAAuB;WAAqB;;;UAGvC;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,kBAAkB;;WAElB,SAAS,SAAS,eAAe;;;;;WAKjC;EACT,MAAM,SAAS,aAAa,SAAS,UAAU;;;qBAIpC;;wBAGG,aAAa,UAAU,UAAU;;wBAOjC,OAAO,cAAc,gBAAgB;;wBAOrC,QAAQ,cAAc,eAAe;;qBAMxC,WAAY,gBAAgB;;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EN;;WAEA;;WAEA,QAAQ;;;;;;;wBAWH,OAAO,SAAS,eAAe;;wBAyC/B,aAAa,QAAQ;;wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBA6BG,OAAO,yBAAyB,IAAI;;;;;;wBClSpC,aAAa,eAAe;;;;;wBAsD5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/gate-trigger.ts","../src/map.ts","../src/rules/home-package.ts","../src/rules/license-file.ts","../src/rules/main-check.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pages-site.ts","../src/rules/pinned-git-deps.ts","../src/rules/push-main-only.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/roadmap-parses.ts","../src/rules/runner-budget.ts","../src/rules/shared-docs.ts","../src/rules/source-main.ts","../src/rules/tests-required.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-files.ts","../src/rules/typed-scripts.ts","../src/rules/trust-policy.ts","../src/rules/unreleased-change.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/home-exports.ts","../src/workflow.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;WAEA,iBAAiB;;;;;;UAOX;;WAEN;;WAEA;;WAEA;;;wBAIK,YAAY,cAAc,cAAc;;KAQ5C;;KAGA,UAAU,SAAS,eAAe;;UAG7B;WACN;WACA,SAAS;WACT;;;KAIC,WAAW,SAAS;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,UAAU;;;UAIJ;;WAEN;;WAEA,aAAa;;WAEb,mBAAmB;;WA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B;WACjB,eAAe;;;wBAgGV,aAAa,cAAc,eAAe;;UCrMzC;WACN;WACA;WACA;;WAEA;WACA,iBAAiB;;WAEjB;;WAEA;;;UAIM;WACN,gBAAgB;;WAEhB;;;UAIM;;WAEN;;WAEA;;WAEA;WACA,MAAM,SAAS;;WAEf,iBAAiB;;;wBAaZ,WAAW,cAAc,iBAAgB,SAAiB;;wBAO1D,cAAc,cAAc,QAAQ,mBAAmB,UAAS,KAAK,gCAAqC;;wBAwB1G,UAAU,SAAS,eAAe;;UAmDjC;;WAEN;;WAEA;;WAEA,QAAQ;;;;;;;wBAWH,OAAO,SAAS,eAAe;;wBAyC/B,aAAa,QAAQ;;wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBA6BG,OAAO,yBAAyB,IAAI;;;;;;wBClSpC,aAAa,eAAe;;;;;wBAsD5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
package/build/index.js CHANGED
@@ -1 +1 @@
1
- export { xt as ACTIONS_COMMIT, Y as DEFAULT_ALLOWED, kt as DEPENDENCY_FIELDS, pt as HOMES, bt as HOME_EXPORTS, X as HOME_PATTERNS, M as HOME_TIMEOUT_MS, y as IGNORE_AFTER, nt as LICENSE_TEXTS, mt as MAP_RULE, p as NPM_REGISTRY, K as PAGES_WORKFLOWS, $ as REAL_COMPARE, d as RULES, m as SHIPPED_FIELDS, Dt as STRICT_OPTIONS, b as TRAIN_SCOPES, h as UNSHIPPED_FILES, t as USAGE, n as annotations, rt as authorOf, N as blockHash, At as cleanPath, jt as codePackages, C as configsOfScript, St as convertGate, r as createContext, Ot as cuePreset, ct as declaredName, Kt as defaultOptions, ht as findHomes, i as formatResult, Ct as gateTrigger, P as githubFetch, Ht as globFolders, Ut as globToRegExp, Mt as hasFile, et as hasImportMetaMain, D as hasTests, lt as homePackage, Nt as inFolder, U as isGitSpecifier, W as isPinned, k as isSourcePath, Pt as keyLine, it as licenseFile, at as licenseFileOf, Ft as lineOf, a as listRules, tt as mainCheck, gt as mapMarkdown, _t as mapText, It as matchesAny, vt as mergeHomes, ut as messageOf, ot as mitText, Q as noBuildOutput, Z as noLocalPaths, g as npmLookup, Wt as packageFolders, q as pagesCalls, J as pagesSite, qt as parseConfig, Lt as parseJsonc, A as pathsOf, G as pinnedGitDeps, wt as prPathFilters, o as readConfig, Rt as readJsonc, yt as readOverlay, Et as readWorkflow, H as releaseFiles, zt as replaceLine, dt as repoOf, st as repositoryIsPublic, I as repositoryOfRemote, V as requiredScripts, z as roadmapOfLine, B as roadmapParses, s as runChecks, c as runCli, l as runFix, Bt as runGit, L as runnerBudget, R as scheduleMinute, w as scriptsOf, F as sharedDocsRule, ft as signaturesOf, j as sourceMain, Vt as specifiersOf, u as summaryMarkdown, Tt as summaryName, E as testsRequired, x as trustPolicy, O as tsconfigTest, T as typedFiles, S as typedScripts, _ as unreleasedChange, v as unreleasedChangeRule, Gt as workspaceGlobs, f as workspaceProtocol } from "./run-DORqvzBZ.js";
1
+ export { St as ACTIONS_COMMIT, X as DEFAULT_ALLOWED, At as DEPENDENCY_FIELDS, mt as HOMES, xt as HOME_EXPORTS, Z as HOME_PATTERNS, M as HOME_TIMEOUT_MS, y as IGNORE_AFTER, rt as LICENSE_TEXTS, ht as MAP_RULE, p as NPM_REGISTRY, q as PAGES_WORKFLOWS, et as REAL_COMPARE, d as RULES, m as SHIPPED_FIELDS, Ot as STRICT_OPTIONS, b as TRAIN_SCOPES, h as UNSHIPPED_FILES, t as USAGE, n as annotations, it as authorOf, N as blockHash, jt as cleanPath, Mt as codePackages, C as configsOfScript, Ct as convertGate, r as createContext, kt as cuePreset, lt as declaredName, qt as defaultOptions, gt as findHomes, i as formatResult, wt as gateTrigger, P as githubFetch, Ut as globFolders, Wt as globToRegExp, Nt as hasFile, tt as hasImportMetaMain, D as hasTests, ut as homePackage, Pt as inFolder, W as isGitSpecifier, G as isPinned, k as isSourcePath, Ft as keyLine, at as licenseFile, ot as licenseFileOf, It as lineOf, a as listRules, nt as mainCheck, _t as mapMarkdown, vt as mapText, Lt as matchesAny, yt as mergeHomes, dt as messageOf, st as mitText, $ as noBuildOutput, Q as noLocalPaths, g as npmLookup, Gt as packageFolders, J as pagesCalls, Y as pagesSite, Jt as parseConfig, Rt as parseJsonc, A as pathsOf, K as pinnedGitDeps, Tt as prPathFilters, U as pushMainOnly, o as readConfig, zt as readJsonc, bt as readOverlay, Dt as readWorkflow, H as releaseFiles, Bt as replaceLine, ft as repoOf, ct as repositoryIsPublic, I as repositoryOfRemote, V as requiredScripts, z as roadmapOfLine, B as roadmapParses, s as runChecks, c as runCli, l as runFix, Vt as runGit, L as runnerBudget, R as scheduleMinute, w as scriptsOf, F as sharedDocsRule, pt as signaturesOf, j as sourceMain, Ht as specifiersOf, u as summaryMarkdown, Et as summaryName, E as testsRequired, x as trustPolicy, O as tsconfigTest, T as typedFiles, S as typedScripts, _ as unreleasedChange, v as unreleasedChangeRule, Kt as workspaceGlobs, f as workspaceProtocol } from "./run-DRAlJPKd.js";
@@ -1351,6 +1351,20 @@ function childKeys(lines, index) {
1351
1351
  for (let i = index + 1; i < blockEnd(lines, index); i++) if ((lines[i] ?? "").trim() !== "" && indentOf$1(lines[i] ?? "") === indent) keys.push(i);
1352
1352
  return keys;
1353
1353
  }
1354
+ /**
1355
+ * This function applies changes to the lines of `text`, and keeps its line ends. The changes go from the end to the
1356
+ * start, so each index stays correct. At one index, a splice that removes lines goes first, so it removes only the old
1357
+ * lines. Then the inserts go in, the later one first, so they keep their order.
1358
+ */
1359
+ function applySplices(text, splices) {
1360
+ const eol = text.includes("\r\n") ? "\r\n" : "\n";
1361
+ const out = text.split(/\r?\n/);
1362
+ for (const item of splices.map((value, order) => ({
1363
+ ...value,
1364
+ order
1365
+ })).sort((a, b) => b.at - a.at || b.remove - a.remove || b.order - a.order)) out.splice(item.at, item.remove, ...item.insert);
1366
+ return out.join(eol);
1367
+ }
1354
1368
  /** This function gives the text of a block scalar (`|`, `|-`, `>`, `>-`) under the line `index`. */
1355
1369
  function scalar(lines, index, style) {
1356
1370
  const body = lines.slice(index + 1, blockEnd(lines, index));
@@ -1669,8 +1683,6 @@ const ifValue = (expression) => {
1669
1683
  * person must convert the workflow.
1670
1684
  */
1671
1685
  function convertGate(text, file, commit = ACTIONS_COMMIT) {
1672
- const eol = text.includes("\r\n") ? "\r\n" : "\n";
1673
- const original = text.split(/\r?\n/);
1674
1686
  const lines = workflowLines(text);
1675
1687
  const top = (key) => lines.findIndex((line) => indentOf$1(line) === 0 && keyValue(line, key) !== void 0);
1676
1688
  const on = top("on");
@@ -1838,12 +1850,7 @@ function convertGate(text, file, commit = ACTIONS_COMMIT) {
1838
1850
  remove: 0,
1839
1851
  insert: summary
1840
1852
  });
1841
- const out = [...original];
1842
- for (const item of splices.map((value, order) => ({
1843
- ...value,
1844
- order
1845
- })).sort((a, b) => b.at - a.at || b.remove - a.remove || b.order - a.order)) out.splice(item.at, item.remove, ...item.insert);
1846
- return { text: out.join(eol) };
1853
+ return { text: applySplices(text, splices) };
1847
1854
  }
1848
1855
  const gateTrigger = {
1849
1856
  id: "gate-trigger",
@@ -8292,6 +8299,404 @@ const pinnedGitDeps = {
8292
8299
  return breaks;
8293
8300
  }
8294
8301
  };
8302
+ // src/rules/push-main-only.ts
8303
+ /**
8304
+ * The rule `push-main-only`: a workflow that starts on `push` and on `pull_request` limits `push` to the default branch.
8305
+ * It also has `workflow_dispatch`. Then a commit of a branch with an open pull request starts one run, not two. A person
8306
+ * can still start a run on a branch with no pull request.
8307
+ */
8308
+ /** The file of the release flow. A person changes it, with the rule `release-files`, so the fix does not write it. */
8309
+ const RELEASE_FILE = "release.yml";
8310
+ /** The patterns that match each branch. */
8311
+ const EACH_BRANCH = /* @__PURE__ */ new Set(["*", "**"]);
8312
+ /** A key of a block, in the quoted forms too. */
8313
+ const KEY = /^\s*(?:"([^"]*)"|'([^']*)'|([^\s:]+))\s*:(\s.*)?$/;
8314
+ /** A value with no filters: `{}`, `~` or `null`. */
8315
+ const NO_FILTERS = /^(\{\s*\}|~|null)$/;
8316
+ /** A text that shows that a workflow reads the tag of a run. */
8317
+ const READS_TAGS = /refs\/tags|ref_type/i;
8318
+ /** A workflow of the repository that a job calls. */
8319
+ const LOCAL_CALL = /uses:\s*["']?\.\/(\.github\/workflows\/[^\s"'@]+)/g;
8320
+ /** A text that names a branch: `refs/heads/<branch>`, or `ref_name == '<branch>'`. */
8321
+ const NAMED_BRANCH = /refs\/heads\/([\w./-]+)|ref_name\s*[!=]=\s*["']([^"']+)["']/gi;
8322
+ /** This function tells if the brackets of a flow value are closed. */
8323
+ function closed(text) {
8324
+ let depth = 0;
8325
+ let quote = "";
8326
+ for (const char of text) if (quote !== "") {
8327
+ if (char === quote) quote = "";
8328
+ } else if (char === "\"" || char === "'") quote = char;
8329
+ else if (char === "[" || char === "{") depth += 1;
8330
+ else if (char === "]" || char === "}") depth -= 1;
8331
+ return depth <= 0;
8332
+ }
8333
+ /** This function gives the whole text of a flow value that starts on the line `index`, and the index after its last line. */
8334
+ function flowValue(lines, index, value) {
8335
+ let text = value;
8336
+ let end = index + 1;
8337
+ while (!closed(text) && end < lines.length) {
8338
+ text += ` ${valueOf$1(lines[end] ?? "")}`;
8339
+ end += 1;
8340
+ }
8341
+ return {
8342
+ text,
8343
+ end
8344
+ };
8345
+ }
8346
+ /** This function splits the text in the outer brackets of a flow value, at each comma of the first level. */
8347
+ function flowParts(text) {
8348
+ const parts = [];
8349
+ let depth = 0;
8350
+ let quote = "";
8351
+ let part = "";
8352
+ for (const char of text.slice(1, -1)) {
8353
+ if (quote !== "") {
8354
+ if (char === quote) quote = "";
8355
+ } else if (char === "\"" || char === "'") quote = char;
8356
+ else if (char === "[" || char === "{") depth += 1;
8357
+ else if (char === "]" || char === "}") depth -= 1;
8358
+ else if (char === "," && depth === 0) {
8359
+ parts.push(part);
8360
+ part = "";
8361
+ continue;
8362
+ }
8363
+ part += char;
8364
+ }
8365
+ parts.push(part);
8366
+ return parts.map((item) => item.trim()).filter((item) => item !== "");
8367
+ }
8368
+ /** This function gives the key and the value of an entry of a flow map. */
8369
+ function flowEntry(part) {
8370
+ const colon = part.search(/:(\s|$)/);
8371
+ return colon < 0 ? {
8372
+ key: valueOf$1(part),
8373
+ value: ""
8374
+ } : {
8375
+ key: valueOf$1(part.slice(0, colon)),
8376
+ value: valueOf$1(part.slice(colon + 1))
8377
+ };
8378
+ }
8379
+ /** This function gives the key and the value of a line of a block. */
8380
+ function keyOf(line) {
8381
+ const found = KEY.exec(line);
8382
+ if (found === null) return void 0;
8383
+ return {
8384
+ key: found[1] ?? found[2] ?? found[3] ?? "",
8385
+ value: valueOf$1(found[4] ?? "")
8386
+ };
8387
+ }
8388
+ const isItem = (line) => line.trimStart().startsWith("- ");
8389
+ /** This function reads the triggers of a workflow, in each form of `on`. */
8390
+ function readTriggers(lines) {
8391
+ const on = lines.findIndex((line) => indentOf$1(line) === 0 && keyValue(line, "on") !== void 0);
8392
+ if (on < 0) return void 0;
8393
+ const value = keyValue(lines[on] ?? "", "on") ?? "";
8394
+ if (value === "") {
8395
+ const next = lines.findIndex((line, index) => index > on && line.trim() !== "");
8396
+ const first = lines[next] ?? "";
8397
+ if (next >= 0 && isItem(first)) {
8398
+ const list = [];
8399
+ for (let index = next; index < lines.length; index++) {
8400
+ const line = lines[index] ?? "";
8401
+ if (line.trim() === "") continue;
8402
+ if (!isItem(line) || indentOf$1(line) !== indentOf$1(first)) break;
8403
+ list.push({
8404
+ name: valueOf$1(line.trimStart().slice(2)),
8405
+ at: index,
8406
+ value: ""
8407
+ });
8408
+ }
8409
+ return {
8410
+ form: "items",
8411
+ on,
8412
+ end: on + 1,
8413
+ list
8414
+ };
8415
+ }
8416
+ const list = childKeys(lines, on).flatMap((at) => {
8417
+ const entry = keyOf(lines[at] ?? "");
8418
+ return entry === void 0 ? [] : [{
8419
+ name: entry.key,
8420
+ at,
8421
+ value: entry.value
8422
+ }];
8423
+ });
8424
+ return {
8425
+ form: "keys",
8426
+ on,
8427
+ end: on + 1,
8428
+ list
8429
+ };
8430
+ }
8431
+ const flow = flowValue(lines, on, value);
8432
+ if (value.startsWith("[")) return {
8433
+ form: "flow",
8434
+ on,
8435
+ end: flow.end,
8436
+ list: flowParts(flow.text).map((part) => ({
8437
+ name: valueOf$1(part),
8438
+ at: on,
8439
+ value: ""
8440
+ }))
8441
+ };
8442
+ if (value.startsWith("{")) {
8443
+ const list = flowParts(flow.text).map((part) => {
8444
+ const entry = flowEntry(part);
8445
+ return {
8446
+ name: entry.key,
8447
+ at: on,
8448
+ value: entry.value
8449
+ };
8450
+ });
8451
+ return {
8452
+ form: "map",
8453
+ on,
8454
+ end: flow.end,
8455
+ list
8456
+ };
8457
+ }
8458
+ return {
8459
+ form: "flow",
8460
+ on,
8461
+ end: on + 1,
8462
+ list: [{
8463
+ name: value,
8464
+ at: on,
8465
+ value: ""
8466
+ }]
8467
+ };
8468
+ }
8469
+ /** This function gives the filters of a trigger, in the block form and in the flow form. */
8470
+ function filtersOf(lines, trigger) {
8471
+ if (trigger.value.startsWith("{")) {
8472
+ const flow = flowValue(lines, trigger.at, trigger.value);
8473
+ return flowParts(flow.text).map((part) => {
8474
+ const entry = flowEntry(part);
8475
+ const items = entry.value.startsWith("[") ? flowParts(entry.value).map(valueOf$1) : [entry.value];
8476
+ return {
8477
+ key: entry.key,
8478
+ at: trigger.at,
8479
+ end: flow.end,
8480
+ items
8481
+ };
8482
+ });
8483
+ }
8484
+ if (trigger.value !== "") return [];
8485
+ return childKeys(lines, trigger.at).flatMap((at) => {
8486
+ const entry = keyOf(lines[at] ?? "");
8487
+ if (entry === void 0) return [];
8488
+ const list = listItems(lines, at, entry.value);
8489
+ if (list !== void 0) return [{
8490
+ key: entry.key,
8491
+ at,
8492
+ end: list.end,
8493
+ items: list.items
8494
+ }];
8495
+ return [{
8496
+ key: entry.key,
8497
+ at,
8498
+ end: at + 1,
8499
+ items: /^[[{]/.test(entry.value) ? void 0 : [entry.value]
8500
+ }];
8501
+ });
8502
+ }
8503
+ /** This function gives the break of a workflow, or undefined when the rule leaves the workflow alone. */
8504
+ function findBreak(text, facts) {
8505
+ const lines = workflowLines(text);
8506
+ const triggers = readTriggers(lines);
8507
+ if (triggers === void 0) return void 0;
8508
+ const push = triggers.list.find((trigger) => trigger.name === "push");
8509
+ const pull = triggers.list.find((trigger) => trigger.name === "pull_request");
8510
+ if (push === void 0 || pull === void 0) return void 0;
8511
+ const types = filtersOf(lines, pull).find((filter) => filter.key === "types");
8512
+ if (types?.items !== void 0 && !types.items.includes("synchronize")) return void 0;
8513
+ const filters = filtersOf(lines, push);
8514
+ const has = (key) => filters.find((filter) => filter.key === key);
8515
+ const branches = has("branches");
8516
+ if (branches === void 0 && has("branches-ignore") === void 0 && (has("tags") ?? has("tags-ignore")) !== void 0) return void 0;
8517
+ const allowed = [facts.branch, ...facts.more];
8518
+ const items = branches?.items;
8519
+ const wide = items === void 0 || items.length === 0 || !items.every((item) => allowed.includes(item));
8520
+ const noDispatch = !triggers.list.some((trigger) => trigger.name === "workflow_dispatch");
8521
+ if (!wide && !noDispatch) return void 0;
8522
+ return {
8523
+ lines,
8524
+ triggers,
8525
+ push,
8526
+ filters,
8527
+ wide,
8528
+ noDispatch
8529
+ };
8530
+ }
8531
+ /** This function gives the reason why a person must change the workflow, or undefined when the fix can write it. */
8532
+ function refusal(file, text, finding, facts) {
8533
+ if (file.slice(file.lastIndexOf("/") + 1) === RELEASE_FILE) return `${RELEASE_FILE} belongs to the release flow`;
8534
+ const { triggers, filters, wide } = finding;
8535
+ if (triggers.form === "map") return "on has the flow form of a map";
8536
+ if (triggers.end > triggers.on + 1) return "on is a flow value of more than one line";
8537
+ if (!wide) return void 0;
8538
+ if (filters.some((filter) => filter.key === "branches-ignore")) return "on.push has branches-ignore, and only a person can tell which ignored branches stay";
8539
+ const allowed = [facts.branch, ...facts.more];
8540
+ const branches = filters.find((filter) => filter.key === "branches");
8541
+ if (branches !== void 0) {
8542
+ if (branches.items === void 0) return "the rule cannot read on.push.branches";
8543
+ if (branches.at === finding.push.at) return "on.push.branches is in the flow form of a map";
8544
+ const named = branches.items.filter((item) => !EACH_BRANCH.has(item) && !allowed.includes(item));
8545
+ if (named.length > 0 || branches.items.length === 0) return `on.push.branches names ${named.join(", ") || "no branch"}. Remove them, or add them to the option branches of the rule`;
8546
+ }
8547
+ const others = [...`${workflowLines(text).join("\n")}\n${facts.called(text)}`.matchAll(NAMED_BRANCH)].map((match) => match[1] ?? match[2] ?? "").filter((name) => !allowed.includes(name));
8548
+ if (others.length > 0) return `the workflow reads the branch ${[...new Set(others)].join(", ")}, so a limit on push can stop a job`;
8549
+ }
8550
+ /** This function gives a comment at the end of a line, with its space, or an empty text. */
8551
+ const commentOf = (line) => /\s+#.*$/.exec(line)?.[0] ?? "";
8552
+ /** This function writes the fix of a break: the new filter of `push`, and `workflow_dispatch`. Each other line stays. */
8553
+ function convert(text, file, finding, facts) {
8554
+ const { lines, triggers, push, filters, wide, noDispatch } = finding;
8555
+ const original = text.split(/\r?\n/);
8556
+ const branches = filters.find((filter) => filter.key === "branches");
8557
+ const tags = wide && branches === void 0 && READS_TAGS.test(`${workflowLines(text).join("\n")}\n${facts.called(text)}`);
8558
+ const limit = `branches: [${facts.branch}]`;
8559
+ const limits = (pad) => wide ? [`${pad}${limit}`, ...tags ? [`${pad}tags: ["**"]`] : []] : [];
8560
+ const name = file.slice(file.lastIndexOf("/") + 1);
8561
+ const dispatch = (pad) => noDispatch ? [`${pad}# A person starts a run on a branch with no pull request: gh workflow run ${name} --ref <branch>`, `${pad}workflow_dispatch:`] : [];
8562
+ const splices = [];
8563
+ if (triggers.form === "flow") {
8564
+ const line = original[triggers.on] ?? "";
8565
+ const body = triggers.list.flatMap((trigger) => [` ${trigger.name}:`, ...trigger === push ? limits(" ") : []]);
8566
+ splices.push({
8567
+ at: triggers.on,
8568
+ remove: 1,
8569
+ insert: [
8570
+ `${line.slice(0, line.indexOf(":") + 1)}${commentOf(line)}`,
8571
+ ...body,
8572
+ ...dispatch(" ")
8573
+ ]
8574
+ });
8575
+ } else if (triggers.form === "items") {
8576
+ const pad = " ".repeat(Math.max(indentOf$1(lines[triggers.list[0]?.at ?? 0] ?? ""), 2));
8577
+ for (const trigger of triggers.list) splices.push({
8578
+ at: trigger.at,
8579
+ remove: 1,
8580
+ insert: [`${pad}${trigger.name}:${commentOf(original[trigger.at] ?? "")}`, ...trigger === push ? limits(`${pad} `) : []]
8581
+ });
8582
+ splices.push({
8583
+ at: (triggers.list.at(-1)?.at ?? triggers.on) + 1,
8584
+ remove: 0,
8585
+ insert: dispatch(pad)
8586
+ });
8587
+ } else {
8588
+ const line = original[push.at] ?? "";
8589
+ const pad = indentOf$1(lines[push.at] ?? "");
8590
+ const inner = " ".repeat(childIndent(lines, push.at) ?? pad + Math.max(pad - indentOf$1(lines[triggers.on] ?? ""), 2));
8591
+ if (wide && branches !== void 0) splices.push({
8592
+ at: branches.at,
8593
+ remove: branches.end - branches.at,
8594
+ insert: [`${" ".repeat(indentOf$1(lines[branches.at] ?? ""))}${limit}${commentOf(original[branches.at] ?? "")}`]
8595
+ });
8596
+ else if (wide && push.value !== "" && !NO_FILTERS.test(push.value)) {
8597
+ const added = [limit, ...tags ? ["tags: [\"**\"]"] : []].join(", ");
8598
+ splices.push({
8599
+ at: push.at,
8600
+ remove: 1,
8601
+ insert: [line.replace(/\{\s*/, () => `{ ${added}, `)]
8602
+ });
8603
+ } else if (wide) splices.push({
8604
+ at: push.at,
8605
+ remove: 1,
8606
+ insert: [line.replace(/:\s+(\{\s*\}|~|null)/, ":"), ...limits(inner)]
8607
+ });
8608
+ const last = triggers.list.at(-1)?.at ?? triggers.on;
8609
+ let end = blockEnd(lines, last);
8610
+ while (end > last + 1 && (lines[end - 1] ?? "").trim() === "") end -= 1;
8611
+ splices.push({
8612
+ at: end,
8613
+ remove: 0,
8614
+ insert: dispatch(" ".repeat(pad))
8615
+ });
8616
+ }
8617
+ return applySplices(text, splices);
8618
+ }
8619
+ /** This function gives the default branch: the event file of GitHub Actions, the `HEAD` of the remote, or else `main`. */
8620
+ function defaultBranch(context) {
8621
+ const file = context.env["GITHUB_EVENT_PATH"];
8622
+ if (file !== void 0 && file !== "") try {
8623
+ const branch = JSON.parse(readFileSync(file, "utf8")).repository?.default_branch;
8624
+ if (typeof branch === "string" && branch !== "") return branch;
8625
+ } catch {}
8626
+ const head = context.git([
8627
+ "symbolic-ref",
8628
+ "--quiet",
8629
+ "--short",
8630
+ "refs/remotes/origin/HEAD"
8631
+ ])?.trim();
8632
+ return head === void 0 || head === "" ? "main" : head.replace(/^origin\//, "");
8633
+ }
8634
+ const pushMainOnly = {
8635
+ id: "push-main-only",
8636
+ title: "A workflow that starts on push and on pull_request limits push to the default branch with branches, and has workflow_dispatch.",
8637
+ reason: "A commit on a branch with an open pull request starts such a workflow two times: one run for push and one run for pull_request. On 2026-11-04 the CI queue held about 263 jobs, and a rough estimate puts about 65 of them in such second runs. The run for pull_request gives the required checks, so the run for push adds nothing. With workflow_dispatch, a person can still start a run on a branch with no pull request.",
8638
+ fix: "Add `branches: [<default branch>]` under `on.push`, and add `workflow_dispatch:` under `on` (CI.md, \"One run for each commit\"). A push with only a tag filter, or a pull request trigger with no `synchronize`, is not a break. For a long-lived branch, add the branch to the option branches.",
8639
+ sources: [
8640
+ {
8641
+ repo: "template",
8642
+ rule: "push-main-only",
8643
+ doc: ".github/workflows/security.yml (push has branches: [main], and the file has workflow_dispatch)"
8644
+ },
8645
+ {
8646
+ repo: "crawler",
8647
+ rule: "push-main-only",
8648
+ doc: ".github/workflows/ci.yml (push has branches: [main], and the file has workflow_dispatch)"
8649
+ },
8650
+ {
8651
+ repo: "systems",
8652
+ rule: "push-main-only",
8653
+ doc: ".github/workflows/process.yml (push has branches: [main], and the file has workflow_dispatch)"
8654
+ }
8655
+ ],
8656
+ options: { branches: {
8657
+ type: "strings",
8658
+ default: [],
8659
+ description: "More branches that `on.push.branches` can name, for example a long-lived release branch."
8660
+ } },
8661
+ check(context, options) {
8662
+ const files = context.gitFiles();
8663
+ if (files === void 0) return { skipped: "the root is not in a git repository" };
8664
+ const workflows = files.filter((path) => WORKFLOW$1.test(path)).sort(byCode);
8665
+ if (workflows.length === 0) return { skipped: "the repository has no workflow" };
8666
+ const read = (file) => {
8667
+ try {
8668
+ return readFileSync(join(context.root, file), "utf8");
8669
+ } catch {
8670
+ return "";
8671
+ }
8672
+ };
8673
+ const facts = {
8674
+ branch: defaultBranch(context),
8675
+ more: Array.isArray(options["branches"]) ? options["branches"] : [],
8676
+ called: (text) => [...text.matchAll(LOCAL_CALL)].map((match) => workflowLines(read(match[1] ?? "")).join("\n")).join("\n")
8677
+ };
8678
+ const breaks = [];
8679
+ for (const file of workflows) {
8680
+ const text = read(file);
8681
+ const finding = findBreak(text, facts);
8682
+ if (finding === void 0) continue;
8683
+ const parts = [...finding.wide ? [`push starts on more branches than ${[facts.branch, ...facts.more].join(", ")}, so a commit of a pull request starts it two times`] : [], ...finding.noDispatch ? ["it has no workflow_dispatch, so a person cannot start a run on a branch"] : []];
8684
+ const reason = refusal(file, text, finding, facts);
8685
+ const after = reason === void 0 ? convert(text, file, finding, facts) : void 0;
8686
+ breaks.push({
8687
+ file,
8688
+ line: finding.push.at + 1,
8689
+ message: `${file} starts on push and on pull_request: ${parts.join(", and ")}.`,
8690
+ ...after !== void 0 && findBreak(after, facts) === void 0 ? { edits: [{
8691
+ file,
8692
+ before: text,
8693
+ after
8694
+ }] } : { fix: `A person must change it, because ${reason ?? "the fix does not end the break"}. ${pushMainOnly.fix}` }
8695
+ });
8696
+ }
8697
+ return breaks;
8698
+ }
8699
+ };
8295
8700
  // src/rules/release-files.ts
8296
8701
  /**
8297
8702
  * The rule `release-files`: a pull request changes a file of the release flow only with a reason
@@ -10502,6 +10907,7 @@ const RULES = [
10502
10907
  roadmapParses,
10503
10908
  runnerBudget,
10504
10909
  mainRunsFinish,
10910
+ pushMainOnly,
10505
10911
  gateTrigger,
10506
10912
  homePackage,
10507
10913
  licenseFile,
@@ -10909,6 +11315,6 @@ function runMap(args, io) {
10909
11315
  else io.stdout(mapText(found));
10910
11316
  return 0;
10911
11317
  }
10912
- export { REAL_COMPARE as $, pathsOf as A, cleanPath as At, roadmapParses as B, runGit as Bt, configsOfScript as C, gateTrigger as Ct, hasTests as D, STRICT_OPTIONS as Dt, testsRequired as E, readWorkflow as Et, sharedDocsRule as F, lineOf as Ft, pinnedGitDeps as G, workspaceGlobs as Gt, releaseFiles as H, globFolders as Ht, repositoryOfRemote as I, matchesAny as It, pagesSite as J, PAGES_WORKFLOWS as K, defaultOptions as Kt, runnerBudget as L, parseJsonc as Lt, HOME_TIMEOUT_MS as M, hasFile as Mt, blockHash as N, inFolder as Nt, tsconfigTest as O, cuePreset as Ot, githubFetch as P, keyLine as Pt, noBuildOutput as Q, scheduleMinute as R, readJsonc as Rt, typedScripts as S, convertGate as St, typedFiles as T, summaryName as Tt, isGitSpecifier as U, globToRegExp as Ut, requiredScripts as V, specifiersOf as Vt, isPinned as W, packageFolders as Wt, HOME_PATTERNS as X, DEFAULT_ALLOWED as Y, noLocalPaths as Z, unreleasedChange as _, mapText as _t, listRules as a, licenseFileOf as at, TRAIN_SCOPES as b, HOME_EXPORTS as bt, runCli as c, declaredName as ct, RULES as d, repoOf as dt, hasImportMetaMain as et, workspaceProtocol as f, signaturesOf as ft, npmLookup as g, mapMarkdown as gt, UNSHIPPED_FILES as h, findHomes as ht, formatResult as i, licenseFile as it, sourceMain as j, codePackages as jt, isSourcePath as k, DEPENDENCY_FIELDS as kt, runFix as l, homePackage as lt, SHIPPED_FIELDS as m, MAP_RULE as mt, annotations as n, LICENSE_TEXTS as nt, readConfig as o, mitText as ot, NPM_REGISTRY as p, HOMES as pt, pagesCalls as q, parseConfig as qt, createContext as r, authorOf as rt, runChecks as s, repositoryIsPublic as st, USAGE as t, mainCheck as tt, summaryMarkdown as u, messageOf as ut, unreleasedChangeRule as v, mergeHomes as vt, scriptsOf as w, prPathFilters as wt, trustPolicy as x, ACTIONS_COMMIT as xt, IGNORE_AFTER as y, readOverlay as yt, roadmapOfLine as z, replaceLine as zt };
11318
+ export { noBuildOutput as $, pathsOf as A, DEPENDENCY_FIELDS as At, roadmapParses as B, replaceLine as Bt, configsOfScript as C, convertGate as Ct, hasTests as D, readWorkflow as Dt, testsRequired as E, summaryName as Et, sharedDocsRule as F, keyLine as Ft, isPinned as G, packageFolders as Gt, releaseFiles as H, specifiersOf as Ht, repositoryOfRemote as I, lineOf as It, pagesCalls as J, parseConfig as Jt, pinnedGitDeps as K, workspaceGlobs as Kt, runnerBudget as L, matchesAny as Lt, HOME_TIMEOUT_MS as M, codePackages as Mt, blockHash as N, hasFile as Nt, tsconfigTest as O, STRICT_OPTIONS as Ot, githubFetch as P, inFolder as Pt, noLocalPaths as Q, scheduleMinute as R, parseJsonc as Rt, typedScripts as S, ACTIONS_COMMIT as St, typedFiles as T, prPathFilters as Tt, pushMainOnly as U, globFolders as Ut, requiredScripts as V, runGit as Vt, isGitSpecifier as W, globToRegExp as Wt, DEFAULT_ALLOWED as X, pagesSite as Y, HOME_PATTERNS as Z, unreleasedChange as _, mapMarkdown as _t, listRules as a, licenseFile as at, TRAIN_SCOPES as b, readOverlay as bt, runCli as c, repositoryIsPublic as ct, RULES as d, messageOf as dt, REAL_COMPARE as et, workspaceProtocol as f, repoOf as ft, npmLookup as g, findHomes as gt, UNSHIPPED_FILES as h, MAP_RULE as ht, formatResult as i, authorOf as it, sourceMain as j, cleanPath as jt, isSourcePath as k, cuePreset as kt, runFix as l, declaredName as lt, SHIPPED_FIELDS as m, HOMES as mt, annotations as n, mainCheck as nt, readConfig as o, licenseFileOf as ot, NPM_REGISTRY as p, signaturesOf as pt, PAGES_WORKFLOWS as q, defaultOptions as qt, createContext as r, LICENSE_TEXTS as rt, runChecks as s, mitText as st, USAGE as t, hasImportMetaMain as tt, summaryMarkdown as u, homePackage as ut, unreleasedChangeRule as v, mapText as vt, scriptsOf as w, gateTrigger as wt, trustPolicy as x, HOME_EXPORTS as xt, IGNORE_AFTER as y, mergeHomes as yt, roadmapOfLine as z, readJsonc as zt };
10913
11319
 
10914
- //# sourceMappingURL=run-DORqvzBZ.js.map
11320
+ //# sourceMappingURL=run-DRAlJPKd.js.map