@mark1russell7/conventions 0.3.1 → 0.4.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
@@ -34,6 +34,7 @@ The rules come from the invariants audit of 2026-10-26 (strategy item s38). The
34
34
  | `no-build-output` | Git keeps no file in a folder named `dist` or `build`. | client `no-build-output`, `no-dist`, `no-dist-commit`. Only one repository of the audit tells this rule. The `.gitignore` of the template has it for each repository. |
35
35
  | `no-local-paths` | No tracked file has the home folder of a user: `C:\Users\<name>`, `/Users/<name>` or `/home/<name>`. A CI user (`runner`), a name of one character and a placeholder (`<you>`) are not a break. | client `I12`. systems `no-identifying-names`, `no-private-identifiers`, `no-private-names`. coeval `no-private-names`. |
36
36
  | `release-files` | A pull request changes `.github/workflows/release.yml` or `scripts/release/` only with a line `Release-Edit: <reason>` in a commit message or in the body of the pull request. The commits of the release bot (the sync of the template) need no reason. | coeval `no-release-edit`, `no-release-edits`. crawler `no-release-edit`, `no-release-edits`. headroom `no-release-edits`, `release-files-frozen`. |
37
+ | `typed-scripts` | Git keeps no JavaScript source (`.js`, `.mjs`, `.cjs`, `.jsx`, or a file with a `#!` line of `node`) and no shell script (`.sh`, `.bash`, `.zsh`, `.ps1`, or a `#!` line of a shell) of more than one line of code. Each script is TypeScript, which Node 22.18 and later starts directly. A file that must stay (generated output, vendored code, a configuration that a tool reads only as JavaScript) goes in `ignore` with its reason, so the list of exceptions can only get shorter. | fleet `typed-everything` (STRATEGY.md, direction 15). |
37
38
 
38
39
  The rule `release-files` needs the base of the change. On a pull request, the checkout is a merge commit, and the rule reads its two parents (`fetch-depth` 2 or more). In other runs, give `--base <ref>`. Without a base, the rule shows `skip`.
39
40
 
@@ -79,6 +80,9 @@ An unknown rule, an unknown option, or an exception or a changed option without
79
80
  | `release-files.paths` | `[".github/workflows/release.yml", "scripts/release/**"]` | The globs of the files of the release flow. |
80
81
  | `release-files.trailer` | `Release-Edit` | The key of the line that gives the reason. |
81
82
  | `release-files.authors` | `["mark1russell7-release-train[bot]"]` | The authors of the release flow. Their commits need no reason. |
83
+ | `typed-scripts.javascript` | `[".js", ".mjs", ".cjs", ".jsx"]` | The extensions of JavaScript source. |
84
+ | `typed-scripts.shell` | `[".sh", ".bash", ".zsh", ".ps1"]` | The extensions of shell scripts. |
85
+ | `typed-scripts.shellLines` | `1` | The most lines of code of a shell script (a launcher). Empty lines and comments do not count. |
82
86
 
83
87
  ## Commands
84
88
 
package/build/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { c as runCli } from "./run-CH4FTfx2.js";
2
+ import { c as runCli } from "./run-AxDtnOOy.js";
3
3
  // src/cli.ts
4
4
  try {
5
5
  process.exitCode = runCli(process.argv.slice(2), {
package/build/index.d.ts CHANGED
@@ -160,6 +160,7 @@ export declare const sourceMain: Rule;
160
160
  /** This function tells if git tracks a test file in the package folder `folder` (`""` is the root). */
161
161
  export declare function hasTests(files: readonly string[], folder: string): boolean;
162
162
  export declare const tsconfigTest: Rule;
163
+ export declare const typedScripts: Rule;
163
164
  export declare const workspaceProtocol: Rule;
164
165
  /** Each rule of the check. */
165
166
  export declare const RULES: readonly Rule[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/rule.ts","../src/config.ts","../src/rules/cue-preset.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/source-main.ts","../src/rules/tsconfig-test.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;;KAIC;;KAGA,UAAU,SAAS,eAAe;;UAG7B;WACN;WACA,SAAS;WACT;;;KAIC,WAAW,SAAS;;UAGf;;WAEN;;WAEA;;WAEA;;WAEA;WACA,UAAU;;;UAIJ;;WAEN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wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBAwBG,OAAO,yBAAyB,IAAI;;;;;;wBCxNpC,aAAa,eAAe;;;;;wBA+C5B,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/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/source-main.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-scripts.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts","../src/workspace.ts"],"mappings":";UASiB;WACN;WACA;WACA;;;UAIM;;WAEN;;WAEA;WACA;;WAEA;;;KAIC;;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;EAC1C,MAAM,SAAS,aAAa,SAAS,UAAU;;;qBAIpC;;wBAGG,aAAa,UAAU,UAAU;;wBAOjC,OAAO,cAAc,gBAAgB;;wBAOrC,QAAQ,cAAc,eAAe;;qBAMxC,WAAY,gBAAgB;;qBAG5B,YAAa;;wBAGV,WAAW,cAAc;;;;;;wBASzB,WAAW;;wBA2BX,UAAU;;wBAUV,OAAO,cAAc;;qBAOxB,UAAW,aAAa;;;;;wBAMrB,aAAa,SAAS,KAAK,oDAAoD;;UC9K9E;;WAEN;;WAEA;;WAEA;;WAEA,SAAS;;;UAIH;;WAEN;;WAEA,OAAO,SAAS,eAAe;;;wBAW1B,eAAe,MAAM,OAAO;;;;;;;wBAU5B,YAAY,gBAAgB,gBAAgB,SAAS;;qBCnCxD;qBA2FA,WAAW;qBC/FX,eAAe;;qBCYf;;qBAGA,wBAAwB;qBAOxB,cAAc;;wBCnBX,eAAe;;;;;wBAaf,SAAS,cAAc;qBAqB1B,eAAe;qBCEf,cAAc;qBCrBd,iBAAiB;;wBCdd,QAAQ;;wBAQR,aAAa;qBAKhB,YAAY;;wBCbT,SAAS,0BAA0B;qBAKtC,cAAc;qBCuBd,cAAc;qBC9Bd,mBAAmB;;qBCQnB,gBAAgB;;UCJZ;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;;wBA0ClC,aAAa,QAAQ;;wBA0BrB,gBAAgB,QAAQ;;wBAsBxB,YAAY,QAAQ;;wBAYpB,UAAU,QAAQ,+BAA+B,iBAAgB;;UAkBhE;WACN;WACA,KAAK,SAAS;WACd,SAAS;WACT,SAAS;;;qBAIP;;wBAwBG,OAAO,yBAAyB,IAAI;;;;;;wBCxNpC,aAAa,eAAe;;;;;wBA+C5B,YAAY,cAAc;;;;;;wBA8B1B,eAAe;;;;;;;wBAwCf,eAAe,cAAc"}
package/build/index.js CHANGED
@@ -1 +1 @@
1
- export { S as DEFAULT_ALLOWED, O as DEPENDENCY_FIELDS, C as HOME_PATTERNS, u as RULES, E as STRICT_OPTIONS, t as USAGE, n as annotations, k as cleanPath, A as codePackages, r as createContext, D as cuePreset, W as defaultOptions, i as formatResult, B as globFolders, V as globToRegExp, j as hasFile, f as hasTests, M as inFolder, y as isGitSpecifier, b as isPinned, m as isSourcePath, N as keyLine, P as lineOf, a as listRules, F as matchesAny, T as noBuildOutput, w as noLocalPaths, H as packageFolders, G as parseConfig, I as parseJsonc, h as pathsOf, x as pinnedGitDeps, o as readConfig, L as readJsonc, v as releaseFiles, _ as requiredScripts, s as runChecks, c as runCli, R as runGit, g as sourceMain, z as specifiersOf, l as summaryMarkdown, p as tsconfigTest, U as workspaceGlobs, d as workspaceProtocol } from "./run-CH4FTfx2.js";
1
+ export { C as DEFAULT_ALLOWED, k as DEPENDENCY_FIELDS, w as HOME_PATTERNS, u as RULES, D as STRICT_OPTIONS, t as USAGE, n as annotations, A as cleanPath, j as codePackages, r as createContext, O as cuePreset, G as defaultOptions, i as formatResult, V as globFolders, H as globToRegExp, M as hasFile, p as hasTests, N as inFolder, b as isGitSpecifier, x as isPinned, h as isSourcePath, P as keyLine, F as lineOf, a as listRules, I as matchesAny, E as noBuildOutput, T as noLocalPaths, U as packageFolders, K as parseConfig, L as parseJsonc, g as pathsOf, S as pinnedGitDeps, o as readConfig, R as readJsonc, y as releaseFiles, v as requiredScripts, s as runChecks, c as runCli, z as runGit, _ as sourceMain, B as specifiersOf, l as summaryMarkdown, m as tsconfigTest, f as typedScripts, W as workspaceGlobs, d as workspaceProtocol } from "./run-AxDtnOOy.js";
@@ -1260,6 +1260,110 @@ const tsconfigTest = {
1260
1260
  return breaks;
1261
1261
  }
1262
1262
  };
1263
+ // src/rules/typed-scripts.ts
1264
+ /**
1265
+ * The rule `typed-scripts`: git keeps no JavaScript source and no shell script with logic. Each
1266
+ * script is TypeScript, which Node starts directly (type stripping), with types and tests like the code.
1267
+ */
1268
+ /** The interpreters of a `#!` line that make a file without an extension a script of a kind. */
1269
+ const SHEBANG = /^#!\s*(?:\S*\/)?(?:env\s+(?:-\S+\s+)*)?(node|bash|sh|zsh|dash|ksh|pwsh)\b/;
1270
+ /** This function gives the extension of a file with its dot, in lower case, or `""`. */
1271
+ function extensionOf(file) {
1272
+ const name = file.slice(file.lastIndexOf("/") + 1);
1273
+ const dot = name.lastIndexOf(".");
1274
+ return dot <= 0 ? "" : name.slice(dot).toLowerCase();
1275
+ }
1276
+ /** This function gives the lines of a shell script that do work: not empty, not a comment, not the `#!` line. */
1277
+ function codeLines(text) {
1278
+ return text.split(/\r?\n/).filter((line) => {
1279
+ const trimmed = line.trim();
1280
+ return trimmed !== "" && !trimmed.startsWith("#");
1281
+ }).length;
1282
+ }
1283
+ /** This function reads the first line of a file, or `""` when the file cannot be read. */
1284
+ function firstLine(path) {
1285
+ try {
1286
+ const text = readFileSync(path, "utf8");
1287
+ const end = text.indexOf("\n");
1288
+ return end < 0 ? text : text.slice(0, end);
1289
+ } catch {
1290
+ return "";
1291
+ }
1292
+ }
1293
+ const typedScripts = {
1294
+ id: "typed-scripts",
1295
+ title: "Git keeps no JavaScript source (`.js`, `.mjs`, `.cjs`, `.jsx`) and no shell script of more than one line of code: each script is TypeScript.",
1296
+ reason: "A script has bugs like the code, and types and tests find them. Node 22.18 and later runs a `.ts` file directly, so a script in JavaScript or in a shell language has no cost to save and no check. A shell file stays only as a launcher of one line.",
1297
+ fix: "Rename the file to `.ts`, add the types, and check it with `tsc --noEmit` and a test. Move the logic of a shell script into a `.ts` file, and keep the shell file as one line that starts it, or remove it. A file that must stay (generated output, vendored code, a configuration that a tool reads only as JavaScript) goes in `ignore` with its reason.",
1298
+ sources: [{
1299
+ repo: "fleet",
1300
+ rule: "typed-everything",
1301
+ doc: "docs/STRATEGY.md:78"
1302
+ }],
1303
+ options: {
1304
+ javascript: {
1305
+ type: "strings",
1306
+ default: [
1307
+ ".js",
1308
+ ".mjs",
1309
+ ".cjs",
1310
+ ".jsx"
1311
+ ],
1312
+ description: "The extensions of JavaScript source."
1313
+ },
1314
+ shell: {
1315
+ type: "strings",
1316
+ default: [
1317
+ ".sh",
1318
+ ".bash",
1319
+ ".zsh",
1320
+ ".ps1"
1321
+ ],
1322
+ description: "The extensions of shell scripts."
1323
+ },
1324
+ shellLines: {
1325
+ type: "number",
1326
+ default: 1,
1327
+ description: "The most lines of code that a shell script can have: a launcher."
1328
+ }
1329
+ },
1330
+ check(context, options) {
1331
+ const files = context.gitFiles();
1332
+ if (files === void 0) return { skipped: "the root is not in a git repository" };
1333
+ const javascript = new Set(Array.isArray(options["javascript"]) ? options["javascript"] : []);
1334
+ const shell = new Set(Array.isArray(options["shell"]) ? options["shell"] : []);
1335
+ const limit = typeof options["shellLines"] === "number" ? options["shellLines"] : 1;
1336
+ const breaks = [];
1337
+ for (const file of [...files].sort(byCode)) {
1338
+ let extension = extensionOf(file);
1339
+ if (extension === "") {
1340
+ const interpreter = SHEBANG.exec(firstLine(join(context.root, file)))?.[1];
1341
+ if (interpreter === void 0) continue;
1342
+ extension = interpreter === "node" ? ".js" : ".sh";
1343
+ if (!javascript.has(extension) && !shell.has(extension)) continue;
1344
+ }
1345
+ if (javascript.has(extension)) breaks.push({
1346
+ file,
1347
+ message: `${file} is JavaScript.`,
1348
+ fix: `Rename ${file} to .ts, add the types, and check it with tsc and a test.`
1349
+ });
1350
+ else if (shell.has(extension)) {
1351
+ let lines = 0;
1352
+ try {
1353
+ lines = codeLines(readFileSync(join(context.root, file), "utf8"));
1354
+ } catch {
1355
+ continue;
1356
+ }
1357
+ if (lines > limit) breaks.push({
1358
+ file,
1359
+ message: `${file} is a shell script with ${lines} lines of code (the most is ${limit}).`,
1360
+ fix: `Move the logic of ${file} into a .ts file, and keep ${file} as a launcher of ${limit} line(s), or remove it.`
1361
+ });
1362
+ }
1363
+ }
1364
+ return breaks;
1365
+ }
1366
+ };
1263
1367
  // src/rules/workspace-protocol.ts
1264
1368
  /**
1265
1369
  * The rule `workspace-protocol`: a package uses another package of the workspace through `workspace:`.
@@ -1335,7 +1439,8 @@ const RULES = [
1335
1439
  requiredScripts,
1336
1440
  noBuildOutput,
1337
1441
  noLocalPaths,
1338
- releaseFiles
1442
+ releaseFiles,
1443
+ typedScripts
1339
1444
  ];
1340
1445
  // src/run.ts
1341
1446
  /**
@@ -1625,6 +1730,6 @@ function runCli(args, io) {
1625
1730
  if (summary) appendFileSync(summary, summaryMarkdown(result));
1626
1731
  return result.failed ? 1 : 0;
1627
1732
  }
1628
- export { codePackages as A, globFolders as B, HOME_PATTERNS as C, cuePreset as D, STRICT_OPTIONS as E, matchesAny as F, parseConfig as G, packageFolders as H, parseJsonc as I, readJsonc as L, inFolder as M, keyLine as N, DEPENDENCY_FIELDS as O, lineOf as P, runGit as R, DEFAULT_ALLOWED as S, noBuildOutput as T, workspaceGlobs as U, globToRegExp as V, defaultOptions as W, requiredScripts as _, listRules as a, isPinned as b, runCli as c, workspaceProtocol as d, hasTests as f, sourceMain as g, pathsOf as h, formatResult as i, hasFile as j, cleanPath as k, summaryMarkdown as l, isSourcePath as m, annotations as n, readConfig as o, tsconfigTest as p, createContext as r, runChecks as s, USAGE as t, RULES as u, releaseFiles as v, noLocalPaths as w, pinnedGitDeps as x, isGitSpecifier as y, specifiersOf as z };
1733
+ export { cleanPath as A, specifiersOf as B, DEFAULT_ALLOWED as C, STRICT_OPTIONS as D, noBuildOutput as E, lineOf as F, defaultOptions as G, globToRegExp as H, matchesAny as I, parseConfig as K, parseJsonc as L, hasFile as M, inFolder as N, cuePreset as O, keyLine as P, readJsonc as R, pinnedGitDeps as S, noLocalPaths as T, packageFolders as U, globFolders as V, workspaceGlobs as W, sourceMain as _, listRules as a, isGitSpecifier as b, runCli as c, workspaceProtocol as d, typedScripts as f, pathsOf as g, isSourcePath as h, formatResult as i, codePackages as j, DEPENDENCY_FIELDS as k, summaryMarkdown as l, tsconfigTest as m, annotations as n, readConfig as o, hasTests as p, createContext as r, runChecks as s, USAGE as t, RULES as u, requiredScripts as v, HOME_PATTERNS as w, isPinned as x, releaseFiles as y, runGit as z };
1629
1734
 
1630
- //# sourceMappingURL=run-CH4FTfx2.js.map
1735
+ //# sourceMappingURL=run-AxDtnOOy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-AxDtnOOy.js","names":[],"sources":["../src/config.ts","../src/workspace.ts","../src/rule.ts","../src/rules/cue-preset.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/source-main.ts","../src/rules/tsconfig-test.ts","../src/rules/typed-scripts.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts"],"sourcesContent":["/**\n * The configuration of the check: the field `conventions` of the root `package.json`. Each exception\n * needs a reason: a rule that is off, files that a rule ignores, and a changed option. Thus each\n * exception is visible.\n */\nimport type { OptionValue, Options, Rule } from \"./rule.ts\";\n\n/** The configuration of one rule, after the check of its fields. */\nexport interface RuleConfig {\n /** The reason why the rule is off. The rule is on when this field is missing. */\n readonly off?: string;\n /** The globs of files that the rule does not report. */\n readonly ignore: readonly string[];\n /** The reason of `ignore` or of the changed options. */\n readonly reason?: string;\n /** The options of the rule, with the defaults. */\n readonly options: Options;\n}\n\n/** The configuration of the check. */\nexport interface ConventionsConfig {\n /** The globs of the package folders. The default is the globs of the workspace. */\n readonly packages?: readonly string[];\n /** The configuration of each rule, by its id. */\n readonly rules: Readonly<Record<string, RuleConfig>>;\n}\n\n/** The fields of the configuration of a rule that are not options. */\nconst RULE_FIELDS = [\"off\", \"ignore\", \"reason\"];\n\nconst isObject = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isStrings = (value: unknown): value is string[] => Array.isArray(value) && value.every((item) => typeof item === \"string\");\n\n/** This function gives the options of a rule with their defaults. */\nexport function defaultOptions(rule: Rule): Options {\n return Object.fromEntries(Object.entries(rule.options).map(([name, spec]) => [name, spec.default]));\n}\n\n/**\n * This function reads the field `conventions` of the root `package.json` (`value`), and gives the\n * configuration of each rule of `rules`.\n *\n * @throws Error when the field has a wrong shape, an unknown rule or option, or an exception or a changed option without a reason\n */\nexport function parseConfig(value: unknown, rules: readonly Rule[]): ConventionsConfig {\n const byId = new Map(rules.map((rule) => [rule.id, rule]));\n const result: Record<string, RuleConfig> = {};\n for (const rule of rules) result[rule.id] = { ignore: [], options: defaultOptions(rule) };\n if (value === undefined) return { rules: result };\n if (!isObject(value)) throw new Error(\"The field conventions of package.json must be an object.\");\n const unknown = Object.keys(value).filter((key) => key !== \"packages\" && key !== \"rules\" && key !== \"$comment\");\n if (unknown.length > 0) throw new Error(`conventions has unknown fields: ${unknown.join(\", \")}.`);\n const packages = value[\"packages\"];\n if (packages !== undefined && !isStrings(packages)) throw new Error(\"conventions.packages must be an array of globs.\");\n const rulesValue = value[\"rules\"] ?? {};\n if (!isObject(rulesValue)) throw new Error(\"conventions.rules must be an object, with a rule id for each key.\");\n for (const [id, entry] of Object.entries(rulesValue)) {\n const rule = byId.get(id);\n if (rule === undefined) throw new Error(`conventions.rules has an unknown rule: ${id}. The rules are: ${[...byId.keys()].join(\", \")}.`);\n const where = `conventions.rules[\"${id}\"]`;\n if (!isObject(entry)) throw new Error(`${where} must be an object, for example { \"off\": \"<reason>\" }.`);\n const off = entry[\"off\"];\n if (off !== undefined && (typeof off !== \"string\" || off.trim() === \"\")) throw new Error(`${where}.off must be the reason why the rule is off, as text.`);\n const ignore = entry[\"ignore\"] ?? [];\n if (!isStrings(ignore)) throw new Error(`${where}.ignore must be an array of globs.`);\n const reason = entry[\"reason\"];\n if (reason !== undefined && (typeof reason !== \"string\" || reason.trim() === \"\")) throw new Error(`${where}.reason must be text.`);\n if (ignore.length > 0 && reason === undefined) throw new Error(`${where}.ignore needs a reason: add \"reason\": \"<why these files are an exception>\".`);\n const options: Record<string, OptionValue> = { ...defaultOptions(rule) };\n const changed: string[] = [];\n for (const [name, option] of Object.entries(entry)) {\n if (RULE_FIELDS.includes(name)) continue;\n const spec = rule.options[name];\n if (spec === undefined) {\n const known = [...RULE_FIELDS, ...Object.keys(rule.options)].join(\", \");\n throw new Error(`${where} has an unknown field: ${name}. The fields are: ${known}.`);\n }\n const good = spec.type === \"strings\" ? isStrings(option) : typeof option === spec.type;\n if (!good) throw new Error(`${where}.${name} must be ${spec.type === \"strings\" ? \"an array of strings\" : `a ${spec.type}`}.`);\n options[name] = option as OptionValue;\n changed.push(name);\n }\n // A changed option can make a rule weaker, so it needs a reason, as `ignore` does\n if (changed.length > 0 && reason === undefined && off === undefined) {\n throw new Error(`${where} changes the option${changed.length > 1 ? \"s\" : \"\"} ${changed.join(\", \")}, and needs a reason: add \"reason\": \"<why this repository changes the default>\".`);\n }\n result[id] = {\n ...(off === undefined ? {} : { off }),\n ignore,\n ...(reason === undefined ? {} : { reason }),\n options,\n };\n }\n return { ...(packages === undefined ? {} : { packages }), rules: result };\n}\n","/**\n * The package folders of a repository: the folders that the globs of the workspace name, with a\n * `package.json` file. This file is a copy of `workspace.ts` of `@mark1russell7/api-report`, so that\n * each tool has no runtime dependency.\n */\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join, relative, sep } from \"node:path\";\n\n/** This function compares two strings by their code units, as the default sort does. */\nexport const byCode = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);\n\n/** This function gives a path relative to `root`, with `/`. */\nexport const relativePath = (root: string, file: string): string => relative(root, file).split(sep).join(\"/\");\n\n/** The characters that have a meaning in a regular expression. */\nconst SPECIAL = new Set([...\"\\\\^$.|+()[]{}*?/\"]);\n\n/**\n * This function gives a regular expression for a glob of `/` paths. `*` matches a part of one path\n * segment, `?` matches one character, `**` matches zero or more segments, and `{a,b}` matches one of\n * its parts. The function escapes each other special character.\n */\nexport function globToRegExp(glob: string): RegExp {\n let source = \"\";\n let braces = 0;\n for (let index = 0; index < glob.length; index++) {\n const char = glob.charAt(index);\n if (char === \"/\" && glob.slice(index + 1) === \"**\") {\n // `a/**` matches `a` and each path under it\n source += \"(?:/.*)?\";\n break;\n }\n if (char === \"*\" && glob.charAt(index + 1) === \"*\") {\n const atStart = index === 0 || glob.charAt(index - 1) === \"/\";\n const after = glob.charAt(index + 2);\n if (atStart && after === \"/\") {\n // `**/` matches zero or more whole segments\n source += \"(?:[^/]+/)*\";\n index += 2;\n } else if (atStart && after === \"\") {\n source += \".*\";\n index += 1;\n } else {\n source += \"[^/]*\";\n index += 1;\n }\n } else if (char === \"*\") source += \"[^/]*\";\n else if (char === \"?\") source += \"[^/]\";\n else if (char === \"{\") {\n braces++;\n source += \"(?:\";\n } else if (char === \"}\" && braces > 0) {\n braces--;\n source += \")\";\n } else if (char === \",\" && braces > 0) source += \"|\";\n else if (SPECIAL.has(char)) source += `\\\\${char}`;\n else source += char;\n }\n if (braces > 0) throw new Error(`A glob with a \"{\" that has no \"}\": ${glob}`);\n return new RegExp(`^${source}$`);\n}\n\n/** The characters that make a path segment a pattern. */\nconst GLOB_CHARS = /[*?{]/;\n\n/**\n * This function gives the folders under `root` that a glob names, as `/` paths relative to `root`,\n * in the order of the code units. It does not go into `node_modules` or a folder that starts with `.`.\n */\nexport function globFolders(root: string, glob: string): string[] {\n const clean = glob.replace(/^\\.\\//, \"\").replace(/\\/+$/, \"\");\n const segments = clean.split(\"/\");\n const firstPattern = segments.findIndex((segment) => GLOB_CHARS.test(segment));\n if (firstPattern < 0) return existsSync(join(root, clean)) ? [clean] : [];\n const base = segments.slice(0, firstPattern).join(\"/\");\n const depth = clean.includes(\"**\") ? Number.POSITIVE_INFINITY : segments.length - firstPattern;\n const pattern = globToRegExp(clean);\n const start = join(root, base);\n if (!existsSync(start)) return [];\n const found: string[] = [];\n const walk = (folder: string, level: number): void => {\n for (const entry of readdirSync(folder, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n const path = join(folder, entry.name);\n if (pattern.test(relativePath(root, path))) found.push(relativePath(root, path));\n if (level < depth) walk(path, level + 1);\n }\n };\n // `a/**` also names `a`\n if (base !== \"\" && pattern.test(base)) found.push(base);\n walk(start, 1);\n return found.sort(byCode);\n}\n\n/**\n * This function gives the globs of the workspace at `root`: the `packages` list of\n * `pnpm-workspace.yaml`, then the `workspaces` field of `package.json`. The result is undefined when\n * the repository has no workspace.\n */\nexport function workspaceGlobs(root: string): string[] | undefined {\n const yaml = join(root, \"pnpm-workspace.yaml\");\n if (existsSync(yaml)) {\n const lines = readFileSync(yaml, \"utf8\").split(/\\r?\\n/);\n const start = lines.findIndex((line) => /^packages\\s*:/.test(line));\n if (start >= 0) {\n const unquote = (text: string): string =>\n text\n .replace(/\\s+#.*$/, \"\")\n .trim()\n .replace(/^[\"']|[\"']$/g, \"\");\n const inline = /^packages\\s*:\\s*\\[(.*)\\]/.exec(lines[start] ?? \"\");\n if (inline) return (inline[1] ?? \"\").split(\",\").map(unquote).filter(Boolean);\n const globs: string[] = [];\n for (const line of lines.slice(start + 1)) {\n if (/^\\s*(#.*)?$/.test(line)) continue;\n const item = /^\\s+-\\s+(.+)$/.exec(line);\n if (!item) break;\n globs.push(unquote(item[1] ?? \"\"));\n }\n return globs;\n }\n }\n const manifestFile = join(root, \"package.json\");\n if (existsSync(manifestFile)) {\n const { workspaces } = JSON.parse(readFileSync(manifestFile, \"utf8\")) as { workspaces?: unknown };\n if (Array.isArray(workspaces)) return workspaces.filter((glob): glob is string => typeof glob === \"string\");\n if (typeof workspaces === \"object\" && workspaces !== null && \"packages\" in workspaces && Array.isArray(workspaces.packages)) {\n return workspaces.packages.filter((glob): glob is string => typeof glob === \"string\");\n }\n }\n return undefined;\n}\n\n/**\n * This function gives the package folders of the repository at `root`: the folders of the globs\n * that have a `package.json` file. A glob that starts with `!` removes folders. Without globs, the\n * function reads the globs of the workspace, and a repository with no workspace is one package.\n * The result has absolute paths, in the order of the code units.\n */\nexport function packageFolders(root: string, globs: readonly string[] | undefined = workspaceGlobs(root)): string[] {\n if (globs === undefined) return existsSync(join(root, \"package.json\")) ? [root] : [];\n const included = new Set<string>();\n // As in pnpm, a `!` glob removes its folders in each position of the list\n for (const glob of globs.filter((item) => !item.startsWith(\"!\"))) for (const folder of globFolders(root, glob)) included.add(folder);\n for (const glob of globs.filter((item) => item.startsWith(\"!\"))) for (const folder of globFolders(root, glob.slice(1))) included.delete(folder);\n return [...included]\n .filter((folder) => existsSync(join(root, folder, \"package.json\")))\n .sort(byCode)\n .map((folder) => join(root, folder));\n}\n","/**\n * The shape of a rule, the facts that a rule reads (the context), and small helpers for the rules.\n */\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { globToRegExp } from \"./workspace.ts\";\n\n/** A row of the invariants audit that a rule comes from: the repository, the id of the rule in that audit, and the document line. */\nexport interface AuditSource {\n readonly repo: string;\n readonly rule: string;\n readonly doc: string;\n}\n\n/** A break of a rule: the file, the line when the rule knows it, and what is wrong. */\nexport interface Break {\n /** The file, relative to the root, with `/`. */\n readonly file: string;\n /** The line in the file, from 1. */\n readonly line?: number;\n readonly message: string;\n /** A fix for this break. The fix of the rule applies when this field is missing. */\n readonly fix?: string;\n}\n\n/** A value of an option of a rule. */\nexport type OptionValue = string | number | boolean | readonly string[];\n\n/** The options of a rule, after the defaults. */\nexport type Options = Readonly<Record<string, OptionValue>>;\n\n/** The description of one option of a rule. */\nexport interface OptionSpec {\n readonly type: \"string\" | \"number\" | \"boolean\" | \"strings\";\n readonly default: OptionValue;\n readonly description: string;\n}\n\n/** A field of `package.json`, as the rules read it. */\nexport type Manifest = Readonly<Record<string, unknown>>;\n\n/** A `package.json` file of the repository. */\nexport interface PackageInfo {\n /** The folder, relative to the root, with `/`. The root is `\"\"`. */\n readonly folder: string;\n /** The absolute path of the folder. */\n readonly dir: string;\n /** The path of the `package.json` file, relative to the root, with `/`. */\n readonly file: string;\n /** The text of the `package.json` file. */\n readonly text: string;\n readonly manifest: Manifest;\n}\n\n/** The facts of the repository that a rule reads. */\nexport interface RuleContext {\n /** The absolute path of the root. */\n readonly root: string;\n /** The root `package.json`. */\n readonly rootPackage: PackageInfo;\n /** The packages of the workspace, without the root. A repository with no workspace has no packages here. */\n readonly packages: readonly PackageInfo[];\n /** The environment variables. */\n readonly env: Readonly<Record<string, string | undefined>>;\n /** The base commit that `--base` gives, if any. */\n readonly base?: string;\n /** This function gives the files that git tracks, relative to the root, or undefined when the root is not in a git repository. */\n gitFiles(): readonly string[] | undefined;\n /** This function starts git in the root, and gives its output, or undefined when git fails. */\n git(args: readonly string[]): string | undefined;\n}\n\n/** The result of a rule: a list of breaks (empty when the rule passes), or the reason why the rule did not start. */\nexport type RuleOutcome = readonly Break[] | { readonly skipped: string };\n\n/** One convention, as a machine check. */\nexport interface Rule {\n /** A short id in kebab case. The configuration names the rule with this id. */\n readonly id: string;\n /** The rule in one sentence. */\n readonly title: string;\n /** Why the rule exists. */\n readonly reason: string;\n /** How to correct a break. */\n readonly fix: string;\n /** The rows of the invariants audit that the rule comes from. */\n readonly sources: readonly AuditSource[];\n /** The options of the rule, with their defaults. */\n readonly options: Readonly<Record<string, OptionSpec>>;\n check(context: RuleContext, options: Options): RuleOutcome;\n}\n\n/** The fields of `package.json` that hold dependencies. */\nexport const DEPENDENCY_FIELDS = [\"dependencies\", \"devDependencies\", \"peerDependencies\", \"optionalDependencies\"] as const;\n\n/** This function gives each entry of a field of `package.json` that maps names to specifiers. */\nexport function specifiersOf(manifest: Manifest, field: string): [string, string][] {\n const value = manifest[field];\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return [];\n return Object.entries(value as Record<string, unknown>).filter((entry): entry is [string, string] => typeof entry[1] === \"string\");\n}\n\n/** This function gives the line (from 1) of the first line of `text` that contains `needle`, from the line `from`. */\nexport function lineOf(text: string, needle: string, from = 1): number | undefined {\n const lines = text.split(/\\r?\\n/);\n for (let index = Math.max(0, from - 1); index < lines.length; index++) if ((lines[index] ?? \"\").includes(needle)) return index + 1;\n return undefined;\n}\n\n/** This function gives the line of the key `\"name\":` in `package.json`, after the line of the field `field`. */\nexport function keyLine(text: string, field: string, name: string): number | undefined {\n const start = lineOf(text, `\"${field}\"`) ?? 1;\n return lineOf(text, `${JSON.stringify(name)}:`, start) ?? lineOf(text, JSON.stringify(name), start);\n}\n\n/** This function joins a folder and a file name as a path relative to the root. */\nexport const inFolder = (folder: string, file: string): string => (folder === \"\" ? file : `${folder}/${file}`);\n\n/** This function removes `./` at the start of a path. */\nexport const cleanPath = (path: string): string => path.replace(/^\\.\\//, \"\");\n\n/** This function tells if a path matches one of the globs. */\nexport function matchesAny(path: string, globs: readonly string[]): boolean {\n return globs.some((glob) => globToRegExp(cleanPath(glob)).test(path));\n}\n\n/**\n * This function reads a JSON file with comments and commas at the end of a list (a `tsconfig.json`).\n *\n * @throws SyntaxError when the text is not JSON after the comments are removed\n */\nexport function parseJsonc(text: string): unknown {\n let out = \"\";\n let inString = false;\n for (let index = 0; index < text.length; index++) {\n const char = text.charAt(index);\n const next = text.charAt(index + 1);\n if (inString) {\n out += char;\n if (char === \"\\\\\") {\n out += next;\n index++;\n } else if (char === '\"') inString = false;\n } else if (char === '\"') {\n inString = true;\n out += char;\n } else if (char === \"/\" && next === \"/\") {\n while (index < text.length && text.charAt(index) !== \"\\n\") index++;\n out += \"\\n\";\n } else if (char === \"/\" && next === \"*\") {\n const end = text.indexOf(\"*/\", index + 2);\n index = end < 0 ? text.length : end + 1;\n } else out += char;\n }\n return JSON.parse(out.replace(/,(\\s*[}\\]])/g, \"$1\"));\n}\n\n/** This function reads a JSON file with comments, or gives undefined when the file does not exist or is not JSON. */\nexport function readJsonc(file: string): unknown {\n if (!existsSync(file)) return undefined;\n try {\n return parseJsonc(readFileSync(file, \"utf8\"));\n } catch {\n return undefined;\n }\n}\n\n/** This function starts git in `root` with `args`, and gives its output, or undefined when git fails. */\nexport function runGit(root: string, args: readonly string[]): string | undefined {\n const result = spawnSync(\"git\", [...args], { cwd: root, encoding: \"utf8\", maxBuffer: 256 * 1024 * 1024, windowsHide: true });\n if (result.error || result.status !== 0) return undefined;\n return result.stdout;\n}\n\n/** This function tells if `file` exists in the folder `dir`. */\nexport const hasFile = (dir: string, file: string): boolean => existsSync(join(dir, file));\n\n/**\n * This function gives the packages that hold code: the packages of the workspace, or the root\n * package when the repository has no workspace packages (a repository of one package).\n */\nexport function codePackages(context: Pick<RuleContext, \"rootPackage\" | \"packages\">): readonly PackageInfo[] {\n return context.packages.length > 0 ? context.packages : [context.rootPackage];\n}\n","/**\n * The rule `cue-preset`: the `tsconfig.json` of each package extends a preset of `@mark1russell7/cue`.\n * No config of a package turns off a strict option of its preset.\n */\nimport { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { codePackages, hasFile, inFolder, lineOf, readJsonc, type Break, type Rule } from \"../rule.ts\";\n\n/** The compiler options that make the type check strict. A package does not turn them off. */\nexport const STRICT_OPTIONS = [\n \"strict\",\n \"noImplicitAny\",\n \"strictNullChecks\",\n \"strictFunctionTypes\",\n \"strictBindCallApply\",\n \"strictPropertyInitialization\",\n \"strictBuiltinIteratorReturn\",\n \"noImplicitThis\",\n \"useUnknownInCatchVariables\",\n \"alwaysStrict\",\n \"noUncheckedIndexedAccess\",\n \"exactOptionalPropertyTypes\",\n \"noImplicitOverride\",\n \"noImplicitReturns\",\n \"noFallthroughCasesInSwitch\",\n \"noPropertyAccessFromIndexSignature\",\n] as const;\n\n/** The options that `strict` turns on when a config does not set them. */\nconst STRICT_FAMILY = new Set<string>([\n \"noImplicitAny\",\n \"strictNullChecks\",\n \"strictFunctionTypes\",\n \"strictBindCallApply\",\n \"strictPropertyInitialization\",\n \"strictBuiltinIteratorReturn\",\n \"noImplicitThis\",\n \"useUnknownInCatchVariables\",\n \"alwaysStrict\",\n]);\n\ntype Json = Readonly<Record<string, unknown>>;\n\nconst asObject = (value: unknown): Json => (typeof value === \"object\" && value !== null && !Array.isArray(value) ? (value as Json) : {});\n\n/** This function gives the `extends` list of a tsconfig. */\nconst extendsOf = (config: Json): string[] => {\n const value = config[\"extends\"];\n if (typeof value === \"string\") return [value];\n return Array.isArray(value) ? value.filter((item): item is string => typeof item === \"string\") : [];\n};\n\n/** The compiler options that a config gets from the configs that it extends. */\ninterface Inherited {\n readonly options: Json;\n /** False when the config extends a config that the rule cannot read. */\n readonly complete: boolean;\n}\n\n/**\n * This function gives the compiler options of the configs that `config` extends, with the options of\n * a later config over an earlier one.\n */\nfunction inheritedOptions(config: Json, dir: string, depth = 0): Inherited {\n if (depth > 10) return { options: {}, complete: false };\n let options: Json = {};\n let complete = true;\n for (const base of extendsOf(config)) {\n let file: string | undefined;\n if (base.startsWith(\".\")) file = resolve(dir, base.endsWith(\".json\") ? base : `${base}.json`);\n else {\n try {\n file = createRequire(join(dir, \"package.json\")).resolve(base);\n } catch {\n file = undefined;\n }\n }\n const parent = file === undefined ? undefined : readJsonc(file);\n if (parent === undefined || file === undefined) {\n complete = false;\n continue;\n }\n const above = inheritedOptions(asObject(parent), dirname(file), depth + 1);\n complete &&= above.complete;\n options = { ...options, ...above.options, ...asObject(asObject(parent)[\"compilerOptions\"]) };\n }\n return { options, complete };\n}\n\n/**\n * This function tells if a config that extends configs with the options `inherited` turns on the\n * option. When the rule cannot read each config, it gives true: the package turns off a strict option.\n */\nfunction inheritedOn(option: string, inherited: Inherited): boolean {\n if (!inherited.complete) return true;\n const value = inherited.options[option];\n if (typeof value === \"boolean\") return value;\n return STRICT_FAMILY.has(option) && inherited.options[\"strict\"] === true;\n}\n\nexport const cuePreset: Rule = {\n id: \"cue-preset\",\n title: \"The `tsconfig.json` of each package extends a preset of `@mark1russell7/cue`, and no config of a package turns off a strict option.\",\n reason:\n \"`pnpm package add` writes the configs from a preset, so each package checks its types with the same strict options. A config by hand or a strict option turned off lets the packages drift apart.\",\n fix: \"Make the package with `pnpm package add <name> --preset=<preset>`, or set `extends` to `@mark1russell7/cue/ts/config/<preset>.json`. Correct the code, not the strict option.\",\n sources: [\n { repo: \"client\", rule: \"cue-config\", doc: \"CLAUDE.md:64\" },\n { repo: \"client\", rule: \"no-manual-tsconfig\", doc: \"CLAUDE.md:64\" },\n { repo: \"Graph\", rule: \"cue-preset-strict\", doc: \"docs/architecture/ecosystem-and-structure.md:58\" },\n { repo: \"Graph\", rule: \"strict-preset\", doc: \"docs/architecture/ecosystem-and-structure.md:58\" },\n { repo: \"Graph\", rule: \"new-package-via-cli\", doc: \"CLAUDE.md:14\" },\n { repo: \"coeval\", rule: \"package-scaffold\", doc: \"CLAUDE.md:16\" },\n { repo: \"crawler\", rule: \"package-scaffold\", doc: \"CLAUDE.md:16\" },\n { repo: \"headroom\", rule: \"package-scaffold\", doc: \"CLAUDE.md:30\" },\n { repo: \"Vex\", rule: \"package-scaffold\", doc: \"CLAUDE.md:22\" },\n ],\n options: {\n prefix: { type: \"string\", default: \"@mark1russell7/cue/\", description: \"The start of the `extends` path of a preset.\" },\n extends: {\n type: \"boolean\",\n default: true,\n description: \"When false, the rule does not examine `extends`. It still reports each strict option that a config turns off. For a package that publishes its own presets.\",\n },\n },\n check(context, options) {\n const prefix = typeof options[\"prefix\"] === \"string\" ? options[\"prefix\"] : \"@mark1russell7/cue/\";\n const breaks: Break[] = [];\n for (const info of codePackages(context)) {\n if (!hasFile(info.dir, \"tsconfig.json\")) continue;\n for (const name of [\"tsconfig.json\", \"tsconfig.test.json\"]) {\n const path = join(info.dir, name);\n const file = inFolder(info.folder, name);\n const value = readJsonc(path);\n if (value === undefined) {\n if (hasFile(info.dir, name)) breaks.push({ file, message: `${name} is not JSON.`, fix: \"Correct the JSON.\" });\n continue;\n }\n const config = asObject(value);\n if (name === \"tsconfig.json\" && options[\"extends\"] !== false && !extendsOf(config).some((base) => base.startsWith(prefix))) {\n const line = lineOf(readFileSync(path, \"utf8\"), '\"extends\"');\n breaks.push({ file, ...(line === undefined ? {} : { line }), message: `tsconfig.json does not extend a preset of ${prefix.replace(/\\/$/, \"\")}.` });\n }\n const own = asObject(config[\"compilerOptions\"]);\n const inherited = inheritedOptions(config, info.dir);\n for (const option of STRICT_OPTIONS) {\n if (own[option] !== false || !inheritedOn(option, inherited)) continue;\n breaks.push({ file, message: `${name} turns off the strict option ${option}.`, fix: `Remove \"${option}\": false, and correct the code that it hides.` });\n }\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `no-build-output`: git does not keep build output.\n */\nimport { byCode } from \"../workspace.ts\";\nimport type { Break, Rule } from \"../rule.ts\";\n\nexport const noBuildOutput: Rule = {\n id: \"no-build-output\",\n title: \"Git keeps no build output: no tracked file is in a folder named `dist` or `build`.\",\n reason:\n \"The release workflow builds each package from the source. Build output in git goes stale, makes noise in each diff, and a user can get old code from a git install.\",\n fix: \"Remove the folder from git with `git rm -r --cached <folder>`, and keep its name in `.gitignore`.\",\n sources: [\n { repo: \"client\", rule: \"no-build-output\", doc: \"CLAUDE.md:48\" },\n { repo: \"client\", rule: \"no-dist\", doc: \"CLAUDE.md:48\" },\n { repo: \"client\", rule: \"no-dist-commit\", doc: \"CLAUDE.md:48\" },\n ],\n options: {\n folders: { type: \"strings\", default: [\"dist\", \"build\"], description: \"The names of the folders of build output.\" },\n },\n check(context, options) {\n const files = context.gitFiles();\n if (files === undefined) return { skipped: \"the root is not in a git repository\" };\n const names = new Set(Array.isArray(options[\"folders\"]) ? options[\"folders\"] : [\"dist\", \"build\"]);\n const counts = new Map<string, number>();\n for (const file of files) {\n const segments = file.split(\"/\");\n const index = segments.slice(0, -1).findIndex((segment) => names.has(segment));\n if (index < 0) continue;\n const folder = segments.slice(0, index + 1).join(\"/\");\n counts.set(folder, (counts.get(folder) ?? 0) + 1);\n }\n return [...counts.keys()].sort(byCode).map(\n (folder): Break => ({\n file: `${folder}/`,\n message: `Git keeps ${counts.get(folder) ?? 0} file(s) in ${folder}/.`,\n fix: `Start \\`git rm -r --cached ${folder}\\`, and keep ${folder.split(\"/\").pop() ?? folder}/ in .gitignore.`,\n }),\n );\n },\n};\n","/**\n * The rule `no-local-paths`: no tracked file names the home folder of a user of a computer.\n */\nimport { readFileSync, statSync } from \"node:fs\";\nimport { extname, join } from \"node:path\";\nimport type { Break, Rule } from \"../rule.ts\";\n\n/** The extensions of files that are not text. The rule does not read them. */\nconst BINARY = new Set(\n \".png .jpg .jpeg .gif .webp .avif .ico .bmp .tiff .pdf .zip .gz .tgz .bz2 .xz .7z .tar .woff .woff2 .ttf .otf .eot .mp3 .mp4 .webm .mov .wav .ogg .wasm .node .exe .dll .so .dylib .bin .db .sqlite .duckdb\".split(\n \" \",\n ),\n);\n\n/** The largest file that the rule reads, in bytes. */\nconst MAX_BYTES = 2 * 1024 * 1024;\n\n/** The names in a home path that do not identify a person: CI users, container users and placeholders. */\nexport const DEFAULT_ALLOWED: readonly string[] = [\"runner\", \"runneradmin\", \"user\", \"username\", \"you\", \"me\", \"name\", \"yourname\", \"your-name\", \"example\", \"node\", \"ubuntu\", \"vscode\", \"codespace\", \"public\", \"default\", \"shared\", \"all users\"];\n\n/** The forms of a home folder: Windows, macOS and Linux. The group `user` is the name of the user. */\nexport const HOME_PATTERNS: readonly RegExp[] = [\n // A Windows path does not depend on case, so `c:/users/<name>` is the same folder\n /\\b[A-Za-z]:(?:\\\\{1,2}|\\/)[Uu][Ss][Ee][Rr][Ss](?:\\\\{1,2}|\\/)(?<user>[^\\\\/\\s\"'`<>|:*?%$(){}[\\],;]+)/g,\n /(?<![\\w.~-])\\/Users\\/(?<user>[^/\\s\"'`<>|:*?%$(){}[\\],;]+)/g,\n /(?<![\\w.~-])\\/home\\/(?<user>[^/\\s\"'`<>|:*?%$(){}[\\],;]+)/g,\n];\n\nexport const noLocalPaths: Rule = {\n id: \"no-local-paths\",\n title: \"No tracked file has the home folder of a user (`C:\\\\Users\\\\<name>`, `/Users/<name>`, `/home/<name>`).\",\n reason: \"A public file must not name a computer, a user or a path of a computer. A local path also works only on one computer.\",\n fix: \"Use a path relative to the repository, `~`, an environment variable, or a placeholder such as `<you>`.\",\n sources: [\n { repo: \"client\", rule: \"I12\", doc: \"packages/documentation/ARCHITECTURE.md:201\" },\n { repo: \"systems\", rule: \"no-identifying-names\", doc: \"CLAUDE.md:12\" },\n { repo: \"systems\", rule: \"no-private-identifiers\", doc: \"CLAUDE.md:12\" },\n { repo: \"systems\", rule: \"no-private-names\", doc: \"CLAUDE.md:12\" },\n { repo: \"coeval\", rule: \"no-private-names\", doc: \"CLAUDE.md:22\" },\n ],\n options: {\n allow: { type: \"strings\", default: [], description: \"More user names that do not identify a person.\" },\n patterns: {\n type: \"strings\",\n default: [],\n description: \"More regular expressions of text that no file has. The environment variable CONVENTIONS_PRIVATE_PATTERNS adds one on each line, so a private name stays out of package.json.\",\n },\n },\n check(context, options) {\n const files = context.gitFiles();\n if (files === undefined) return { skipped: \"the root is not in a git repository\" };\n const allowed = new Set([...DEFAULT_ALLOWED, ...(Array.isArray(options[\"allow\"]) ? options[\"allow\"] : [])].map((name) => name.toLowerCase()));\n // A repository keeps private names out of its public files with the environment variable, for example from a secret of CI\n const fromEnv = (context.env[\"CONVENTIONS_PRIVATE_PATTERNS\"] ?? \"\")\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line !== \"\");\n const sources = [...(Array.isArray(options[\"patterns\"]) ? options[\"patterns\"] : []), ...fromEnv];\n const extra = sources.map((source) => new RegExp(source, \"g\"));\n const rootFile = context.rootPackage.file;\n const breaks: Break[] = [];\n for (const file of files) {\n if (BINARY.has(extname(file).toLowerCase())) continue;\n const path = join(context.root, file);\n let text: string;\n try {\n if (statSync(path).size > MAX_BYTES) continue;\n text = readFileSync(path, \"utf8\");\n } catch {\n // A file of the index that is not in the working tree\n continue;\n }\n if (text.includes(\"\\0\")) continue;\n const lines = text.split(/\\r?\\n/);\n for (let index = 0; index < lines.length; index++) {\n const line = lines[index] ?? \"\";\n // The reason of an exception in the root package.json tells why a text is no home folder, so it can quote one. A private pattern still counts there\n const isReason = file === rootFile && /^\\s*\"(?:reason|off)\"\\s*:/.test(line);\n for (const pattern of isReason ? [] : HOME_PATTERNS) {\n for (const match of line.matchAll(pattern)) {\n const user = match.groups?.[\"user\"] ?? \"\";\n // A name of one character is a placeholder of a test, not a person\n if (user.length < 2 || allowed.has(user.toLowerCase())) continue;\n breaks.push({ file, line: index + 1, message: `The text \"${match[0]}\" is the home folder of a user.` });\n }\n }\n for (const pattern of extra) {\n // The option patterns of the root package.json names the pattern itself\n if (file === rootFile && line.trim().replace(/,$/, \"\") === JSON.stringify(pattern.source)) continue;\n for (const match of line.matchAll(pattern)) breaks.push({ file, line: index + 1, message: `The text \"${match[0]}\" matches the pattern ${pattern.source}.`, fix: \"Remove the text.\" });\n }\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `pinned-git-deps`: a dependency from git names a full commit.\n */\nimport { DEPENDENCY_FIELDS, keyLine, specifiersOf, type Break, type Manifest, type Rule } from \"../rule.ts\";\n\n/** The fields of the root `package.json` that replace the specifiers of dependencies. */\nconst OVERRIDE_FIELDS = [\"overrides\", \"resolutions\"] as const;\n\n/** This function tells if a specifier gets the package from git, not from a registry or the workspace. */\nexport function isGitSpecifier(spec: string): boolean {\n const value = spec.trim();\n if (/^(github|gitlab|bitbucket|gist):/i.test(value)) return true;\n if (/^git(\\+[a-z]+)?:/i.test(value) || /^git@/i.test(value)) return true;\n if (/^https?:\\/\\/(www\\.)?(github\\.com|gitlab\\.com|bitbucket\\.org|codeload\\.github\\.com)\\//i.test(value)) return true;\n // npm and pnpm read `owner/repo` and `owner/repo#ref` as a GitHub repository\n return /^[\\w-][\\w.-]*\\/[\\w.-]+(#.*)?$/.test(value) && !value.startsWith(\"@\");\n}\n\n/**\n * This function tells if a git specifier names a commit. A specifier names a commit when its ref\n * (after `#`) is a commit SHA, or when a tarball URL has the SHA in its path.\n */\nexport function isPinned(spec: string, fullSha: boolean): boolean {\n const sha = fullSha ? /^[0-9a-f]{40}$/i : /^[0-9a-f]{7,40}$/i;\n const hash = spec.indexOf(\"#\");\n if (hash >= 0) {\n // pnpm also knows `#commit=<sha>`, and `&` joins the parts of a ref\n const parts = spec.slice(hash + 1).split(\"&\");\n return parts.some((part) => sha.test(part.replace(/^commit=/, \"\")));\n }\n const path = /^https?:\\/\\/[^/]+\\/(.*)$/i.exec(spec.trim())?.[1];\n return path !== undefined && path.split(/[/.]/).some((part) => sha.test(part));\n}\n\n/** This function gives the specifiers of the fields of overrides, also the field `overrides` of `pnpm`. */\nfunction overridesOf(manifest: Manifest): [string, string, string][] {\n const out: [string, string, string][] = [];\n for (const field of OVERRIDE_FIELDS) for (const [name, spec] of specifiersOf(manifest, field)) out.push([field, name, spec]);\n const pnpm = manifest[\"pnpm\"];\n if (typeof pnpm === \"object\" && pnpm !== null) for (const [name, spec] of specifiersOf(pnpm as Manifest, \"overrides\")) out.push([\"pnpm\", name, spec]);\n return out;\n}\n\nexport const pinnedGitDeps: Rule = {\n id: \"pinned-git-deps\",\n title: \"A dependency from git (github:, git+https: or owner/repo) names a full commit SHA.\",\n reason:\n \"A git ref without a commit moves with the branch. Then an install today and an install tomorrow get different code, and the lockfile hides the change.\",\n fix: 'Use the npm version, `workspace:*` for a package of this repository, or `github:owner/repo#<full commit SHA>`.',\n sources: [\n { repo: \"coeval\", rule: \"pinned-deps\", doc: \"CLAUDE.md:41\" },\n { repo: \"coeval\", rule: \"unpublished-dep-pinned\", doc: \"CLAUDE.md:41\" },\n { repo: \"headroom\", rule: \"non-npm-deps-pinned\", doc: \"CLAUDE.md:38\" },\n { repo: \"headroom\", rule: \"pinned-github-specifier\", doc: \"CLAUDE.md:38\" },\n { repo: \"Graph\", rule: \"github-dep-full-sha\", doc: \"docs/decisions.md:1384\" },\n { repo: \"Graph\", rule: \"github-dep-pinned\", doc: \"docs/decisions.md:1384\" },\n { repo: \"client\", rule: \"general-npm-version\", doc: \"CLAUDE.md:54\" },\n ],\n options: {\n fullSha: { type: \"boolean\", default: true, description: \"When false, a short SHA of 7 or more characters is also a commit.\" },\n },\n check(context, options) {\n const fullSha = options[\"fullSha\"] !== false;\n const breaks: Break[] = [];\n for (const info of [context.rootPackage, ...context.packages]) {\n const found: [string, string, string][] = [];\n for (const field of DEPENDENCY_FIELDS) for (const [name, spec] of specifiersOf(info.manifest, field)) found.push([field, name, spec]);\n found.push(...overridesOf(info.manifest));\n for (const [field, name, spec] of found) {\n if (!isGitSpecifier(spec) || isPinned(spec, fullSha)) continue;\n const line = keyLine(info.text, field, name);\n breaks.push({\n file: info.file,\n ...(line === undefined ? {} : { line }),\n message: `${field} \"${name}\" is \"${spec}\": a git dependency without a ${fullSha ? \"full \" : \"\"}commit SHA.`,\n });\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `release-files`: a pull request changes a file of the release flow only with a reason\n * that everyone can see.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { matchesAny, type Break, type Rule, type RuleContext } from \"../rule.ts\";\n\n/** The range of commits that the rule examines. */\ninterface Range {\n /** The arguments of `git diff --name-only` that give the changed files. */\n readonly diff: readonly string[];\n /** The arguments of `git log` that give the commit messages. */\n readonly log: readonly string[];\n}\n\n/** This function gives the range of the change: the option `--base`, or the merge commit of a pull request. */\nfunction rangeOf(context: RuleContext): Range | { readonly skipped: string } {\n if (context.base !== undefined) {\n if (context.git([\"rev-parse\", \"--verify\", \"--quiet\", `${context.base}^{commit}`]) === undefined) return { skipped: `git does not know the base ${context.base}` };\n return { diff: [`${context.base}...HEAD`], log: [`${context.base}..HEAD`] };\n }\n const event = context.env[\"GITHUB_EVENT_NAME\"];\n if (event !== \"pull_request\" && event !== \"pull_request_target\") return { skipped: \"no base: the rule runs on a pull request, or with --base <ref>\" };\n // The checkout of a pull request is a merge commit: its first parent is the base, its second parent the head\n const parents = context.git([\"rev-list\", \"--parents\", \"-n\", \"1\", \"HEAD\"])?.trim().split(/\\s+/) ?? [];\n if (parents.length !== 3) return { skipped: \"HEAD is not the merge commit of the pull request\" };\n if (context.git([\"cat-file\", \"-e\", \"HEAD^1^{commit}\"]) === undefined) return { skipped: \"the checkout has no parent of HEAD: set fetch-depth to 2 or more\" };\n return { diff: [\"HEAD^1\", \"HEAD\"], log: [\"HEAD^1..HEAD\"] };\n}\n\n/** This function gives the body of the pull request from the event file of GitHub Actions, or an empty string. */\nfunction pullRequestBody(context: RuleContext): string {\n const file = context.env[\"GITHUB_EVENT_PATH\"];\n if (file === undefined || file === \"\" || !existsSync(file)) return \"\";\n try {\n const event = JSON.parse(readFileSync(file, \"utf8\")) as { pull_request?: { body?: unknown } };\n return typeof event.pull_request?.body === \"string\" ? event.pull_request.body : \"\";\n } catch {\n return \"\";\n }\n}\n\n/** This function escapes the special characters of a regular expression. */\nconst escape = (text: string): string => text.replace(/[\\\\^$.|?*+()[\\]{}]/g, \"\\\\$&\");\n\nexport const releaseFiles: Rule = {\n id: \"release-files\",\n title: \"A pull request changes `.github/workflows/release.yml` or `scripts/release/` only with a `Release-Edit: <reason>` line.\",\n reason:\n \"The release flow publishes to npm with trusted publishing. A change of its files by a session that does not own the release can stop or break each release.\",\n fix: \"Revert the change of the release files. When the owner asked for the change, add the line `Release-Edit: <reason>` to the last commit message or to the body of the pull request.\",\n sources: [\n { repo: \"coeval\", rule: \"no-release-edit\", doc: \"CLAUDE.md:40\" },\n { repo: \"coeval\", rule: \"no-release-edits\", doc: \"CLAUDE.md:40\" },\n { repo: \"crawler\", rule: \"no-release-edit\", doc: \"CLAUDE.md:80\" },\n { repo: \"crawler\", rule: \"no-release-edits\", doc: \"CLAUDE.md:80\" },\n { repo: \"headroom\", rule: \"no-release-edits\", doc: \"CLAUDE.md:37\" },\n { repo: \"headroom\", rule: \"release-files-frozen\", doc: \"CLAUDE.md:37\" },\n ],\n options: {\n paths: { type: \"strings\", default: [\".github/workflows/release.yml\", \"scripts/release/**\"], description: \"The globs of the files that the release flow owns.\" },\n trailer: { type: \"string\", default: \"Release-Edit\", description: \"The key of the line that gives the reason of a change.\" },\n authors: {\n type: \"strings\",\n default: [\"mark1russell7-release-train[bot]\"],\n description: \"The authors of the release flow. A change of the release files in commits of only these authors (the sync of the template) needs no reason.\",\n },\n },\n check(context, options) {\n const range = rangeOf(context);\n if (\"skipped\" in range) return range;\n const globs = Array.isArray(options[\"paths\"]) ? options[\"paths\"] : [];\n const changed = (context.git([\"diff\", \"--name-only\", ...range.diff]) ?? \"\")\n .split(/\\r?\\n/)\n .filter((file) => file !== \"\" && matchesAny(file, globs));\n if (changed.length === 0) return [];\n const trailer = typeof options[\"trailer\"] === \"string\" ? options[\"trailer\"] : \"Release-Edit\";\n const line = new RegExp(`^${escape(trailer)}:[ \\\\t]*\\\\S`, \"im\");\n const messages = context.git([\"log\", \"--no-merges\", \"--format=%B\", ...range.log]) ?? \"\";\n if (line.test(messages) || line.test(pullRequestBody(context))) return [];\n const authors = new Set(Array.isArray(options[\"authors\"]) ? options[\"authors\"] : []);\n const changers = (context.git([\"log\", \"--no-merges\", \"--format=%an\", ...range.log, \"--\", ...changed]) ?? \"\").split(/\\r?\\n/).filter((name) => name !== \"\");\n if (changers.length > 0 && changers.every((name) => authors.has(name))) return [];\n return changed.map((file): Break => ({ file, message: `The change edits ${file}, a file of the release flow, with no \"${trailer}: <reason>\" line.` }));\n },\n};\n","/**\n * The rule `required-scripts`: the root `package.json` keeps the scripts that the shared CI starts.\n */\nimport { DEPENDENCY_FIELDS, hasFile, lineOf, specifiersOf, type Break, type RuleContext, type Rule } from \"../rule.ts\";\n\n/** The package of the STE linter. */\nconst STE_LINT = \"@mark1russell7/ste-lint\";\n\n/** The configuration file of the STE linter. */\nconst STE_CONFIG = \"ste.config.json\";\n\n/** The examples of the scripts that the fix shows. */\nconst EXAMPLES: Readonly<Record<string, string>> = { \"lint:ste\": \"ste-lint\", typecheck: \"pnpm -r run typecheck\" };\n\n/**\n * This function tells if the repository uses the STE prose standard: the root `package.json` has a\n * dependency on `@mark1russell7/ste-lint`, or the root has a `ste.config.json`.\n */\nexport function usesSteLint(context: RuleContext): boolean {\n const manifest = context.rootPackage.manifest;\n if (DEPENDENCY_FIELDS.some((field) => specifiersOf(manifest, field).some(([name]) => name === STE_LINT))) return true;\n return hasFile(context.root, STE_CONFIG);\n}\n\nexport const requiredScripts: Rule = {\n id: \"required-scripts\",\n title: \"The root `package.json` has the script `typecheck`, and also `lint:ste` when the repository uses `ste-lint`.\",\n reason:\n \"The shared CI starts each script of its list that `package.json` has, and it skips the others. Thus a removed script turns its check off, and nothing shows it.\",\n fix: 'Add the script, for example `\"lint:ste\": \"ste-lint\"` or `\"typecheck\": \"pnpm -r run typecheck\"`.',\n sources: [\n { repo: \"client\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"coeval\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"crawler\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"Graph\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"headroom\", rule: \"ste-prose\", doc: \"CLAUDE.md:19\" },\n { repo: \"systems\", rule: \"lint-ste-in-ci\", doc: \"CLAUDE.md:24\" },\n { repo: \"Vex\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"coeval\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"crawler\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"headroom\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:32\" },\n { repo: \"Vex\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:23\" },\n ],\n options: {\n scripts: { type: \"strings\", default: [\"typecheck\"], description: \"The scripts that the root `package.json` has.\" },\n steScripts: {\n type: \"strings\",\n default: [\"lint:ste\"],\n description: \"The scripts that the root `package.json` has when the repository uses `ste-lint` (a dependency on `@mark1russell7/ste-lint`, or a `ste.config.json` at the root).\",\n },\n },\n check(context, options) {\n const always = Array.isArray(options[\"scripts\"]) ? options[\"scripts\"] : [\"typecheck\"];\n const ste = Array.isArray(options[\"steScripts\"]) ? options[\"steScripts\"] : [\"lint:ste\"];\n const wanted = [...new Set([...always, ...(usesSteLint(context) ? ste : [])])];\n const value = context.rootPackage.manifest[\"scripts\"];\n const scripts = typeof value === \"object\" && value !== null ? (value as Record<string, unknown>) : {};\n const line = lineOf(context.rootPackage.text, '\"scripts\"');\n return wanted\n .filter((name) => typeof scripts[name] !== \"string\" || scripts[name] === \"\")\n .map((name): Break => {\n const example = EXAMPLES[name];\n const why = ste.includes(name) && !always.includes(name) ? \" The repository uses ste-lint.\" : \"\";\n return {\n file: context.rootPackage.file,\n ...(line === undefined ? {} : { line }),\n message: `The root package.json has no script \"${name}\".${why}`,\n fix: example === undefined ? `Add the script \"${name}\".` : `Add the script, for example \"${name}\": \"${example}\".`,\n };\n });\n },\n};\n","/**\n * The rule `source-main`: a workspace package is a source package, and a public package moves its\n * entries to the build when it is published.\n */\nimport { cleanPath, codePackages, lineOf, type Break, type Manifest, type Rule } from \"../rule.ts\";\n\n/** The fields of `package.json` that name the entries of a package. */\nconst ENTRY_FIELDS = [\"main\", \"module\", \"types\", \"typings\", \"exports\", \"bin\"] as const;\n\n/** This function gives each path in the value of an entry field (a string, or the strings in an object). */\nexport function pathsOf(value: unknown): string[] {\n if (typeof value === \"string\") return [value];\n if (Array.isArray(value)) return value.flatMap(pathsOf);\n if (typeof value === \"object\" && value !== null) return Object.values(value).flatMap(pathsOf);\n return [];\n}\n\n/** This function tells if a path is a source file: a file in `src/`, or a TypeScript file that is not a declaration file. */\nexport function isSourcePath(path: string): boolean {\n const clean = cleanPath(path);\n return clean.startsWith(\"src/\") || (/\\.(c|m)?tsx?$/.test(clean) && !/\\.d\\.(c|m)?ts$/.test(clean));\n}\n\nexport const sourceMain: Rule = {\n id: \"source-main\",\n title: \"Each workspace package is a source package (`main` is `src/index.ts`), and a public package moves its entries to the build in `publishConfig`.\",\n reason:\n \"Other packages of the workspace import the source, so a change is visible at once with no build. A public package that publishes its source entries gives TypeScript files to npm users.\",\n fix: 'Set `\"main\": \"./src/index.ts\"`. In a public package, add `publishConfig` with main, types, exports and bin that point at the build, as `pnpm package add` does.',\n sources: [\n { repo: \"coeval\", rule: \"package-main-source\", doc: \"CLAUDE.md:17\" },\n { repo: \"coeval\", rule: \"source-package-main\", doc: \"CLAUDE.md:17\" },\n { repo: \"crawler\", rule: \"pkg-source-main\", doc: \"CLAUDE.md:17\" },\n { repo: \"crawler\", rule: \"source-package-main\", doc: \"CLAUDE.md:17\" },\n { repo: \"crawler\", rule: \"publish-config-build\", doc: \"CLAUDE.md:41\" },\n { repo: \"Graph\", rule: \"new-package-main-index\", doc: \"CLAUDE.md:15\" },\n { repo: \"Graph\", rule: \"source-package-main\", doc: \"CLAUDE.md:15\" },\n { repo: \"headroom\", rule: \"source-package-main\", doc: \"CLAUDE.md:31\" },\n ],\n options: {\n main: { type: \"string\", default: \"src/index.ts\", description: \"The path of `main` in each package.\" },\n publishConfig: { type: \"boolean\", default: true, description: \"When false, the rule does not examine `publishConfig`.\" },\n },\n check(context, options) {\n const main = cleanPath(typeof options[\"main\"] === \"string\" ? options[\"main\"] : \"src/index.ts\");\n const breaks: Break[] = [];\n for (const info of codePackages(context)) {\n // The root of a repository of one package has no workspace that imports its source, so only its publishConfig counts\n const single = info.folder === \"\";\n const manifest = info.manifest;\n const at = (field: string): { line?: number } => {\n const line = lineOf(info.text, `\"${field}\"`);\n return line === undefined ? {} : { line };\n };\n const value = manifest[\"main\"];\n if (single) {\n // The root of a repository of one package can point main at its build\n } else if (typeof value === \"string\") {\n if (cleanPath(value) !== main) breaks.push({ file: info.file, ...at(\"main\"), message: `\"main\" is \"${value}\", not \"./${main}\".` });\n } else if (ENTRY_FIELDS.some((field) => manifest[field] !== undefined) || manifest[\"private\"] !== true) {\n // A package with only a bin (a CLI) has no entry to import, and a private package with no entry is an app (a site)\n if (manifest[\"bin\"] === undefined) breaks.push({ file: info.file, ...at(\"name\"), message: `The package has no \"main\". A source package has \"main\": \"./${main}\".` });\n }\n if (options[\"publishConfig\"] === false || manifest[\"private\"] === true) continue;\n const published = (typeof manifest[\"publishConfig\"] === \"object\" && manifest[\"publishConfig\"] !== null ? manifest[\"publishConfig\"] : {}) as Manifest;\n for (const field of ENTRY_FIELDS) {\n const source = pathsOf(manifest[field]).filter(isSourcePath);\n if (source.length === 0) continue;\n if (published[field] === undefined) {\n breaks.push({\n file: info.file,\n ...at(field),\n message: `\"${field}\" points at the source (${source[0] ?? \"\"}), and publishConfig has no \"${field}\": npm users get the source.`,\n fix: `Add publishConfig.${field} that points at the build.`,\n });\n continue;\n }\n const still = pathsOf(published[field]).filter(isSourcePath);\n if (still.length > 0) {\n breaks.push({ file: info.file, ...at(\"publishConfig\"), message: `publishConfig.${field} points at the source (${still[0] ?? \"\"}).`, fix: `Point publishConfig.${field} at the build.` });\n }\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `tsconfig-test`: each TypeScript package has a `tsconfig.test.json`, and its typecheck\n * examines it.\n */\nimport { codePackages, hasFile, inFolder, lineOf, type Break, type Rule } from \"../rule.ts\";\n\n/** The path of a test file: `*.test.*` or `*.spec.*` of JavaScript or TypeScript, or a file in a folder `__tests__`. */\nconst TEST_FILE = /(?:^|\\/)(?:[^/]+\\.(?:test|spec)\\.[cm]?[jt]sx?|__tests__\\/.+)$/;\n\n/** This function tells if git tracks a test file in the package folder `folder` (`\"\"` is the root). */\nexport function hasTests(files: readonly string[], folder: string): boolean {\n const prefix = folder === \"\" ? \"\" : `${folder}/`;\n return files.some((path) => path.startsWith(prefix) && TEST_FILE.test(path.slice(prefix.length)));\n}\n\nexport const tsconfigTest: Rule = {\n id: \"tsconfig-test\",\n title: \"Each package with a `tsconfig.json` and test files has a `tsconfig.test.json`, and its `typecheck` script examines it.\",\n reason: \"The build config leaves out the tests. Without a second config, `pnpm typecheck` does not examine the tests, and a type error in a test hides until the test runs.\",\n fix: \"Add `tsconfig.test.json` (extends `./tsconfig.json`, includes the tests, `noEmit`), and set the script `typecheck` to `tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json`. Keep `--noEmit` on the first call when the build config emits, so that a typecheck writes no build output.\",\n sources: [\n { repo: \"coeval\", rule: \"package-tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"coeval\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"crawler\", rule: \"pkg-tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"crawler\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"headroom\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:32\" },\n { repo: \"headroom\", rule: \"tsconfig-test-per-package\", doc: \"CLAUDE.md:32\" },\n { repo: \"Vex\", rule: \"package-tsconfig-test\", doc: \"CLAUDE.md:23\" },\n { repo: \"Vex\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:23\" },\n ],\n options: {\n file: { type: \"string\", default: \"tsconfig.test.json\", description: \"The name of the config of the tests.\" },\n },\n check(context, options) {\n const file = typeof options[\"file\"] === \"string\" ? options[\"file\"] : \"tsconfig.test.json\";\n const tracked = context.gitFiles();\n const breaks: Break[] = [];\n for (const info of codePackages(context)) {\n if (!hasFile(info.dir, \"tsconfig.json\")) continue;\n // A package with no test file has no test to examine. Outside git the rule cannot tell, so it examines the package\n if (tracked !== undefined && !hasTests(tracked, info.folder)) continue;\n if (!hasFile(info.dir, file)) {\n breaks.push({ file: inFolder(info.folder, file), message: `The package has a tsconfig.json and no ${file}.` });\n continue;\n }\n const scripts = info.manifest[\"scripts\"];\n const typecheck = typeof scripts === \"object\" && scripts !== null ? (scripts as Record<string, unknown>)[\"typecheck\"] : undefined;\n if (typeof typecheck === \"string\" && !typecheck.includes(file)) {\n const line = lineOf(info.text, '\"typecheck\"');\n breaks.push({\n file: info.file,\n ...(line === undefined ? {} : { line }),\n message: `The script typecheck (\"${typecheck}\") does not examine ${file}.`,\n fix: `Add \\`tsc -p ${file}\\` to the script typecheck.`,\n });\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `typed-scripts`: git keeps no JavaScript source and no shell script with logic. Each\n * script is TypeScript, which Node starts directly (type stripping), with types and tests like the code.\n */\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { byCode } from \"../workspace.ts\";\nimport type { Break, Rule } from \"../rule.ts\";\n\n/** The interpreters of a `#!` line that make a file without an extension a script of a kind. */\nconst SHEBANG = /^#!\\s*(?:\\S*\\/)?(?:env\\s+(?:-\\S+\\s+)*)?(node|bash|sh|zsh|dash|ksh|pwsh)\\b/;\n\n/** This function gives the extension of a file with its dot, in lower case, or `\"\"`. */\nfunction extensionOf(file: string): string {\n const name = file.slice(file.lastIndexOf(\"/\") + 1);\n const dot = name.lastIndexOf(\".\");\n return dot <= 0 ? \"\" : name.slice(dot).toLowerCase();\n}\n\n/** This function gives the lines of a shell script that do work: not empty, not a comment, not the `#!` line. */\nexport function codeLines(text: string): number {\n return text.split(/\\r?\\n/).filter((line) => {\n const trimmed = line.trim();\n return trimmed !== \"\" && !trimmed.startsWith(\"#\");\n }).length;\n}\n\n/** This function reads the first line of a file, or `\"\"` when the file cannot be read. */\nfunction firstLine(path: string): string {\n try {\n const text = readFileSync(path, \"utf8\");\n const end = text.indexOf(\"\\n\");\n return end < 0 ? text : text.slice(0, end);\n } catch {\n return \"\";\n }\n}\n\nexport const typedScripts: Rule = {\n id: \"typed-scripts\",\n title: \"Git keeps no JavaScript source (`.js`, `.mjs`, `.cjs`, `.jsx`) and no shell script of more than one line of code: each script is TypeScript.\",\n reason:\n \"A script has bugs like the code, and types and tests find them. Node 22.18 and later runs a `.ts` file directly, so a script in JavaScript or in a shell language has no cost to save and no check. A shell file stays only as a launcher of one line.\",\n fix: \"Rename the file to `.ts`, add the types, and check it with `tsc --noEmit` and a test. Move the logic of a shell script into a `.ts` file, and keep the shell file as one line that starts it, or remove it. A file that must stay (generated output, vendored code, a configuration that a tool reads only as JavaScript) goes in `ignore` with its reason.\",\n sources: [{ repo: \"fleet\", rule: \"typed-everything\", doc: \"docs/STRATEGY.md:78\" }],\n options: {\n javascript: { type: \"strings\", default: [\".js\", \".mjs\", \".cjs\", \".jsx\"], description: \"The extensions of JavaScript source.\" },\n shell: { type: \"strings\", default: [\".sh\", \".bash\", \".zsh\", \".ps1\"], description: \"The extensions of shell scripts.\" },\n shellLines: { type: \"number\", default: 1, description: \"The most lines of code that a shell script can have: a launcher.\" },\n },\n check(context, options) {\n const files = context.gitFiles();\n if (files === undefined) return { skipped: \"the root is not in a git repository\" };\n const javascript = new Set(Array.isArray(options[\"javascript\"]) ? options[\"javascript\"] : []);\n const shell = new Set(Array.isArray(options[\"shell\"]) ? options[\"shell\"] : []);\n const limit = typeof options[\"shellLines\"] === \"number\" ? options[\"shellLines\"] : 1;\n const breaks: Break[] = [];\n for (const file of [...files].sort(byCode)) {\n let extension = extensionOf(file);\n if (extension === \"\") {\n const interpreter = SHEBANG.exec(firstLine(join(context.root, file)))?.[1];\n if (interpreter === undefined) continue;\n extension = interpreter === \"node\" ? \".js\" : \".sh\";\n if (!javascript.has(extension) && !shell.has(extension)) continue;\n }\n if (javascript.has(extension)) {\n breaks.push({ file, message: `${file} is JavaScript.`, fix: `Rename ${file} to .ts, add the types, and check it with tsc and a test.` });\n } else if (shell.has(extension)) {\n let lines = 0;\n try {\n lines = codeLines(readFileSync(join(context.root, file), \"utf8\"));\n } catch {\n continue;\n }\n if (lines > limit) {\n breaks.push({\n file,\n message: `${file} is a shell script with ${lines} lines of code (the most is ${limit}).`,\n fix: `Move the logic of ${file} into a .ts file, and keep ${file} as a launcher of ${limit} line(s), or remove it.`,\n });\n }\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `workspace-protocol`: a package uses another package of the workspace through `workspace:`.\n */\nimport { keyLine, specifiersOf, type Break, type Rule } from \"../rule.ts\";\n\n/** The fields that the rule examines. A peer dependency often keeps a range for its users, so the rule does not examine it. */\nconst FIELDS = [\"dependencies\", \"devDependencies\", \"optionalDependencies\"] as const;\n\nexport const workspaceProtocol: Rule = {\n id: \"workspace-protocol\",\n title: \"A dependency on a package of this workspace uses the `workspace:` protocol.\",\n reason:\n \"A version range or a git ref of a package of the same repository gets an old copy from the registry or from git, not the source next to it. Then a change and its test do not meet.\",\n fix: 'Use `\"workspace:*\"`. pnpm writes the real version when it publishes the package.',\n sources: [\n { repo: \"client\", rule: \"workspace-protocol\", doc: \"CLAUDE.md:52\" },\n { repo: \"client\", rule: \"workspace-deps\", doc: \"CLAUDE.md:52\" },\n { repo: \"coeval\", rule: \"pinned-deps\", doc: \"CLAUDE.md:41\" },\n { repo: \"headroom\", rule: \"non-npm-deps-pinned\", doc: \"CLAUDE.md:38\" },\n { repo: \"crawler\", rule: \"mcp-workspace-dep\", doc: \"CLAUDE.md:55\" },\n ],\n options: {\n prefix: { type: \"string\", default: \"workspace:\", description: 'The start of each specifier, for example \"workspace:*\" to refuse \"workspace:^\".' },\n },\n check(context, options) {\n const prefix = typeof options[\"prefix\"] === \"string\" ? options[\"prefix\"] : \"workspace:\";\n const names = new Set(context.packages.map((info) => info.manifest[\"name\"]).filter((name): name is string => typeof name === \"string\"));\n const breaks: Break[] = [];\n for (const info of [context.rootPackage, ...context.packages]) {\n for (const field of FIELDS) {\n for (const [name, spec] of specifiersOf(info.manifest, field)) {\n if (!names.has(name) || name === info.manifest[\"name\"] || spec.startsWith(prefix)) continue;\n const line = keyLine(info.text, field, name);\n breaks.push({\n file: info.file,\n ...(line === undefined ? {} : { line }),\n message: `${field} \"${name}\" is \"${spec}\", but \"${name}\" is a package of this workspace.`,\n fix: `Use \"${prefix === \"workspace:\" ? \"workspace:*\" : prefix}\".`,\n });\n }\n }\n }\n return breaks;\n },\n};\n","/**\n * The list of the rules, in the order of the output.\n */\nimport type { Rule } from \"../rule.ts\";\nimport { cuePreset } from \"./cue-preset.ts\";\nimport { noBuildOutput } from \"./no-build-output.ts\";\nimport { noLocalPaths } from \"./no-local-paths.ts\";\nimport { pinnedGitDeps } from \"./pinned-git-deps.ts\";\nimport { releaseFiles } from \"./release-files.ts\";\nimport { requiredScripts } from \"./required-scripts.ts\";\nimport { sourceMain } from \"./source-main.ts\";\nimport { tsconfigTest } from \"./tsconfig-test.ts\";\nimport { typedScripts } from \"./typed-scripts.ts\";\nimport { workspaceProtocol } from \"./workspace-protocol.ts\";\n\n/** Each rule of the check. */\nexport const RULES: readonly Rule[] = [\n pinnedGitDeps,\n workspaceProtocol,\n sourceMain,\n tsconfigTest,\n cuePreset,\n requiredScripts,\n noBuildOutput,\n noLocalPaths,\n releaseFiles,\n typedScripts,\n];\n\nexport { cuePreset, noBuildOutput, noLocalPaths, pinnedGitDeps, releaseFiles, requiredScripts, sourceMain, tsconfigTest, typedScripts, workspaceProtocol };\n","/**\n * The commands `check` and `--list` of the bin `conventions`, as functions. `runChecks` starts the\n * rules, and `runCli` reads the arguments and writes the result.\n */\nimport { appendFileSync, existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { parseConfig, type ConventionsConfig } from \"./config.ts\";\nimport { matchesAny, runGit, type Break, type Manifest, type PackageInfo, type Rule, type RuleContext } from \"./rule.ts\";\nimport { RULES } from \"./rules/index.ts\";\nimport { packageFolders, relativePath } from \"./workspace.ts\";\n\n/** The result of one rule. */\nexport interface RuleResult {\n readonly id: string;\n readonly title: string;\n readonly fix: string;\n /** `pass`: no break. `break`: one or more breaks. `off`: the configuration turns the rule off. `skipped`: the rule did not start. `error`: the rule threw. */\n readonly status: \"pass\" | \"break\" | \"off\" | \"skipped\" | \"error\";\n readonly breaks: readonly Break[];\n /** The number of breaks in the files of `ignore`. */\n readonly ignored: number;\n /** The reason of `off`, of `ignore`, of `skipped`, or the message of `error`. */\n readonly note?: string;\n}\n\n/** The result of `runChecks`. */\nexport interface CheckResult {\n readonly rules: readonly RuleResult[];\n /** True when a rule has a break or an error. */\n readonly failed: boolean;\n}\n\n/** The options of `runChecks`. */\nexport interface CheckOptions {\n /** The root of the repository. */\n readonly root: string;\n /** Only these rules. The default is each rule. */\n readonly only?: readonly string[];\n /** The base commit of the change, for the rules that examine a change. */\n readonly base?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n /** The rules. The default is `RULES`. */\n readonly rules?: readonly Rule[];\n}\n\n/** This function reads a `package.json` file. */\nfunction readPackage(root: string, dir: string): PackageInfo {\n const path = join(dir, \"package.json\");\n const text = readFileSync(path, \"utf8\");\n const parsed: unknown = JSON.parse(text);\n const manifest = (typeof parsed === \"object\" && parsed !== null ? parsed : {}) as Manifest;\n return { folder: relativePath(root, dir), dir, file: relativePath(root, path), text, manifest };\n}\n\n/** This function reads the configuration of the root `package.json` at `root`. */\nexport function readConfig(root: string, rules: readonly Rule[] = RULES): ConventionsConfig {\n const file = join(root, \"package.json\");\n if (!existsSync(file)) throw new Error(`No package.json in ${root}.`);\n return parseConfig((JSON.parse(readFileSync(file, \"utf8\")) as Manifest)[\"conventions\"], rules);\n}\n\n/** This function gives the facts of the repository at `root` that the rules read. */\nexport function createContext(root: string, config: ConventionsConfig, options: Pick<CheckOptions, \"base\" | \"env\"> = {}): RuleContext {\n const rootPackage = readPackage(root, root);\n const packages = packageFolders(root, config.packages ?? undefined)\n .filter((dir) => resolve(dir) !== resolve(root))\n .map((dir) => readPackage(root, dir));\n let files: readonly string[] | undefined | null = null;\n return {\n root,\n rootPackage,\n packages,\n env: options.env ?? {},\n ...(options.base === undefined ? {} : { base: options.base }),\n gitFiles() {\n if (files === null) {\n const out = runGit(root, [\"ls-files\", \"-z\", \"--cached\"]);\n files = out === undefined ? undefined : out.split(\"\\0\").filter((file) => file !== \"\");\n }\n return files;\n },\n git: (args) => runGit(root, args),\n };\n}\n\n/** This function starts each rule on the repository at `options.root`, and gives the result of each rule. */\nexport function runChecks(options: CheckOptions): CheckResult {\n const root = resolve(options.root);\n const rules = options.rules ?? RULES;\n const unknown = (options.only ?? []).filter((id) => !rules.some((rule) => rule.id === id));\n if (unknown.length > 0) throw new Error(`Unknown rule: ${unknown.join(\", \")}. The rules are: ${rules.map((rule) => rule.id).join(\", \")}.`);\n const config = readConfig(root, rules);\n const context = createContext(root, config, options);\n const results: RuleResult[] = [];\n for (const rule of rules) {\n if (options.only !== undefined && options.only.length > 0 && !options.only.includes(rule.id)) continue;\n const ruleConfig = config.rules[rule.id] ?? { ignore: [], options: {} };\n const base = { id: rule.id, title: rule.title, fix: rule.fix };\n if (ruleConfig.off !== undefined) {\n results.push({ ...base, status: \"off\", breaks: [], ignored: 0, note: ruleConfig.off });\n continue;\n }\n let outcome: ReturnType<Rule[\"check\"]>;\n try {\n outcome = rule.check(context, ruleConfig.options);\n } catch (error) {\n results.push({ ...base, status: \"error\", breaks: [], ignored: 0, note: error instanceof Error ? error.message : String(error) });\n continue;\n }\n if (\"skipped\" in outcome) {\n results.push({ ...base, status: \"skipped\", breaks: [], ignored: 0, note: outcome.skipped });\n continue;\n }\n const breaks = outcome.filter((item) => !matchesAny(item.file, ruleConfig.ignore));\n const ignored = outcome.length - breaks.length;\n const note = ruleConfig.reason === undefined ? {} : { note: ruleConfig.reason };\n results.push({ ...base, status: breaks.length > 0 ? \"break\" : \"pass\", breaks, ignored, ...note });\n }\n return { rules: results, failed: results.some((result) => result.status === \"break\" || result.status === \"error\") };\n}\n\n/** The most breaks of one rule in the text output. The JSON output has each break. */\nconst MAX_SHOWN = 50;\n\n/** This function gives the place of a break as `file:line`. */\nconst placeOf = (item: Break): string => (item.line === undefined ? item.file : `${item.file}:${item.line}`);\n\n/** This function gives the text of a result for a terminal or a CI log. */\nexport function formatResult(result: CheckResult): string {\n const count = (status: RuleResult[\"status\"]): number => result.rules.filter((rule) => rule.status === status).length;\n const breaks = result.rules.reduce((sum, rule) => sum + rule.breaks.length, 0);\n const out: string[] = [\n `conventions: ${result.rules.length} rules: ${count(\"pass\")} pass, ${count(\"break\")} with ${breaks} break(s), ${count(\"off\")} off, ${count(\"skipped\")} skipped, ${count(\"error\")} error(s).`,\n \"\",\n ];\n const label: Record<RuleResult[\"status\"], string> = { pass: \"pass \", break: \"BREAK\", off: \"off \", skipped: \"skip \", error: \"ERROR\" };\n for (const rule of result.rules) {\n const extra = rule.ignored > 0 ? ` (${rule.ignored} ignored: ${rule.note ?? \"\"})` : rule.note !== undefined && rule.status !== \"pass\" ? ` (${rule.note})` : \"\";\n out.push(`${label[rule.status]} ${rule.id}${rule.breaks.length > 0 ? `: ${rule.breaks.length} break(s)` : \"\"}${extra}`);\n for (const item of rule.breaks.slice(0, MAX_SHOWN)) {\n out.push(` ${placeOf(item)} ${item.message}`);\n if (item.fix !== undefined) out.push(` fix: ${item.fix}`);\n }\n if (rule.breaks.length > MAX_SHOWN) out.push(` ... ${rule.breaks.length - MAX_SHOWN} more. Start \\`conventions check --json\\` for each break.`);\n if (rule.breaks.length > 0) out.push(` rule: ${rule.title}`, ` fix: ${rule.fix}`);\n }\n if (result.failed) out.push(\"\", \"To turn a rule off or to keep an exception, add a reason in the field conventions of package.json (`conventions --list`).\");\n return `${out.join(\"\\n\")}\\n`;\n}\n\n/** This function escapes the text of a cell of a Markdown table. */\nconst cell = (text: string): string => text.replace(/\\|/g, \"\\\\|\").replace(/\\r?\\n/g, \" \");\n\n/** This function gives the result as Markdown for the summary of a GitHub Actions run. */\nexport function summaryMarkdown(result: CheckResult): string {\n const out = [\"### Conventions\", \"\", \"| Rule | Result | Note |\", \"|---|---|---|\"];\n for (const rule of result.rules) {\n const shown = rule.status === \"break\" ? `${rule.breaks.length} break(s)` : rule.status;\n const note = rule.ignored > 0 ? `${rule.ignored} ignored: ${rule.note ?? \"\"}` : (rule.note ?? \"\");\n out.push(`| \\`${rule.id}\\` | ${shown} | ${cell(note)} |`);\n }\n const broken = result.rules.filter((rule) => rule.breaks.length > 0);\n for (const rule of broken) {\n out.push(\"\", `<details open><summary><code>${rule.id}</code>: ${rule.breaks.length} break(s)</summary>`, \"\", `${rule.title} Fix: ${rule.fix}`, \"\");\n for (const item of rule.breaks.slice(0, MAX_SHOWN)) out.push(`- \\`${placeOf(item)}\\`: ${item.message}${item.fix === undefined ? \"\" : ` Fix: ${item.fix}`}`);\n if (rule.breaks.length > MAX_SHOWN) out.push(`- ... ${rule.breaks.length - MAX_SHOWN} more`);\n out.push(\"\", \"</details>\");\n }\n return `${out.join(\"\\n\")}\\n`;\n}\n\n/** This function escapes a value of a workflow command of GitHub Actions. */\nconst escapeData = (text: string): string => text.replace(/%/g, \"%25\").replace(/\\r/g, \"%0D\").replace(/\\n/g, \"%0A\");\nconst escapeProperty = (text: string): string => escapeData(text).replace(/:/g, \"%3A\").replace(/,/g, \"%2C\");\n\n/** This function gives an `::error` workflow command for each break, so that GitHub shows each break on its line in the pull request. */\nexport function annotations(result: CheckResult): string {\n const out: string[] = [];\n for (const rule of result.rules) {\n for (const item of rule.breaks) {\n const line = item.line === undefined ? \"\" : `,line=${item.line}`;\n out.push(`::error file=${escapeProperty(item.file)}${line},title=${escapeProperty(`conventions ${rule.id}`)}::${escapeData(`${item.message} Fix: ${item.fix ?? rule.fix}`)}`);\n }\n }\n return out.length === 0 ? \"\" : `${out.join(\"\\n\")}\\n`;\n}\n\n/** This function gives the text of `--list`: each rule, its reason, its fix, its options, its state and its audit sources. */\nexport function listRules(config: ConventionsConfig | undefined, rules: readonly Rule[] = RULES): string {\n const out: string[] = [];\n for (const rule of rules) {\n const ruleConfig = config?.rules[rule.id];\n const state = ruleConfig?.off !== undefined ? `off: ${ruleConfig.off}` : \"on\";\n out.push(`${rule.id} (${state})`, ` ${rule.title}`, ` why: ${rule.reason}`, ` fix: ${rule.fix}`);\n for (const [name, spec] of Object.entries(rule.options)) {\n const value = ruleConfig?.options[name] ?? spec.default;\n out.push(` option ${name} = ${JSON.stringify(value)}: ${spec.description}`);\n }\n if (ruleConfig !== undefined && ruleConfig.ignore.length > 0) out.push(` ignore ${ruleConfig.ignore.join(\", \")}: ${ruleConfig.reason ?? \"\"}`);\n else if (ruleConfig?.reason !== undefined) out.push(` reason: ${ruleConfig.reason}`);\n out.push(` from: ${rule.sources.map((source) => `${source.repo} ${source.rule} (${source.doc})`).join(\"; \")}`, \"\");\n }\n return `${out.join(\"\\n\")}`;\n}\n\n/** The input and output of `runCli`. */\nexport interface CliIo {\n readonly cwd: string;\n readonly env: Readonly<Record<string, string | undefined>>;\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n}\n\n/** The help text of the bin. */\nexport const USAGE: string = `Usage: conventions check [options]\n conventions --list\n\n check Start each rule. Exit code 1 when a rule has a break.\n --list Show each rule: why, fix, options, state and the audit rows that it comes from.\n\n --root <folder> The root of the repository. The default is the current folder.\n --rule <id> Only this rule. Use it again for more rules.\n --base <ref> The base commit of the change, for the rule release-files. On a pull request, the rule finds it.\n --json Write the result as JSON.\n -h, --help Show this text.\n\nThe field \"conventions\" of the root package.json turns a rule off with a reason, keeps an exception\nwith a reason, and sets the options of a rule with a reason:\n\n \"conventions\": { \"rules\": { \"no-build-output\": { \"off\": \"<reason>\" },\n \"cue-preset\": { \"ignore\": [\"packages/web/**\"], \"reason\": \"<reason>\" },\n \"workspace-protocol\": { \"prefix\": \"workspace:*\", \"reason\": \"<reason>\" } } }\n`;\n\n/** An error of the arguments: exit code 2 and the help text. */\nclass UsageError extends Error {}\n\n/** This function starts the bin with the arguments `args`, and gives its exit code. */\nexport function runCli(args: readonly string[], io: CliIo): number {\n let check = false;\n let list = false;\n let json = false;\n let root = io.cwd;\n let base: string | undefined;\n const only: string[] = [];\n try {\n for (let index = 0; index < args.length; index++) {\n const arg = args[index] ?? \"\";\n const value = (): string => {\n const next = args[++index];\n if (next === undefined || next.startsWith(\"-\")) throw new UsageError(`The option ${arg} needs a value.`);\n return next;\n };\n if (arg === \"check\") check = true;\n else if (arg === \"--list\" || arg === \"list\") list = true;\n else if (arg === \"--json\") json = true;\n else if (arg === \"--root\") root = resolve(io.cwd, value());\n else if (arg === \"--rule\") only.push(value());\n else if (arg === \"--base\") base = value();\n else if (arg === \"--help\" || arg === \"-h\") {\n io.stdout(USAGE);\n return 0;\n } else throw new UsageError(`An unknown argument: ${arg}`);\n }\n if (!check && !list) throw new UsageError(\"Give the command check, or --list.\");\n } catch (error) {\n if (!(error instanceof UsageError)) throw error;\n io.stderr(`conventions: ${error.message}\\n\\n${USAGE}`);\n return 2;\n }\n if (list) {\n let config: ConventionsConfig | undefined;\n try {\n config = existsSync(join(root, \"package.json\")) ? readConfig(root) : undefined;\n } catch (error) {\n io.stderr(`conventions: ${error instanceof Error ? error.message : String(error)}\\n`);\n return 1;\n }\n io.stdout(listRules(config));\n return 0;\n }\n let result: CheckResult;\n try {\n result = runChecks({ root, only, env: io.env, ...(base === undefined ? {} : { base }) });\n } catch (error) {\n io.stderr(`conventions: ${error instanceof Error ? error.message : String(error)}\\n`);\n return 1;\n }\n if (json) io.stdout(`${JSON.stringify(result, null, 2)}\\n`);\n else {\n if (io.env[\"GITHUB_ACTIONS\"] === \"true\") io.stdout(annotations(result));\n io.stdout(formatResult(result));\n }\n const summary = io.env[\"GITHUB_STEP_SUMMARY\"];\n if (summary) appendFileSync(summary, summaryMarkdown(result));\n return result.failed ? 1 : 0;\n}\n"],"mappings":";;;;;;AA4BA,MAAM,cAAc;CAAC;CAAO;CAAU;AAAQ;AAE9C,MAAM,YAAY,UAAqD,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAE1I,MAAM,aAAa,UAAsC,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO,SAAS,OAAO,SAAS,QAAQ;;AAG/H,SAAgB,eAAe,MAAqB;CAClD,OAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC;AACpG;;;;;;;AAQA,SAAgB,YAAY,OAAgB,OAA2C;CACrF,MAAM,OAAO,IAAI,IAAI,MAAM,KAAK,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;CACzD,MAAM,SAAqC,CAAC;CAC5C,KAAK,MAAM,QAAQ,OAAO,OAAO,KAAK,MAAM;EAAE,QAAQ,CAAC;EAAG,SAAS,eAAe,IAAI;CAAE;CACxF,IAAI,UAAU,KAAA,GAAW,OAAO,EAAE,OAAO,OAAO;CAChD,IAAI,CAAC,SAAS,KAAK,GAAG,MAAM,IAAI,MAAM,0DAA0D;CAChG,MAAM,UAAU,OAAO,KAAK,KAAK,CAAC,C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,MAAM;IACzC,GAAG,OAAO,KAAK;IACf,OAAO;GACT,OAAO,MAAM,IAAI,WAAW,wBAAwB,KAAK;EAC3D;EACA,IAAI,CAAC,SAAS,CAAC,MAAM,MAAM,IAAI,WAAW,oCAAoC;CAChF,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,aAAa,MAAM;EAC1C,GAAG,OAAO,gBAAgB,MAAM,QAAQ,MAAM,OAAO;EACrD,OAAO;CACT;CACA,IAAI,MAAM;EACR,IAAI;EACJ,IAAI;GACF,SAAS,WAAW,KAAK,MAAM,cAAc,CAAC,IAAI,WAAW,IAAI,IAAI,KAAA;EACvE,SAAS,OAAO;GACd,GAAG,OAAO,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAAG;GACpF,OAAO;EACT;EACA,GAAG,OAAO,UAAU,MAAM,CAAC;EAC3B,OAAO;CACT;CACA,IAAI;CACJ,IAAI;EACF,SAAS,UAAU;GAAE;GAAM;GAAM,KAAK,GAAG;GAAK,GAAI,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,KAAK;EAAG,CAAC;CACzF,SAAS,OAAO;EACd,GAAG,OAAO,gBAAgB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,EAAE,GAAG;EACpF,OAAO;CACT;CACA,IAAI,MAAM,GAAG,OAAO,GAAG,KAAK,UAAU,QAAQ,MAAM,CAAC,EAAE,GAAG;MACrD;EACH,IAAI,GAAG,IAAI,sBAAsB,QAAQ,GAAG,OAAO,YAAY,MAAM,CAAC;EACtE,GAAG,OAAO,aAAa,MAAM,CAAC;CAChC;CACA,MAAM,UAAU,GAAG,IAAI;CACvB,IAAI,SAAS,eAAe,SAAS,gBAAgB,MAAM,CAAC;CAC5D,OAAO,OAAO,SAAS,IAAI;AAC7B"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/conventions",
4
- "version": "0.3.1",
4
+ "version": "0.4.0",
5
5
  "description": "One check in CI for the conventions of a pnpm workspace that docs tell in prose: pinned git dependencies, source packages, tsconfig.test.json, no build output in git and more.",
6
6
  "keywords": [
7
7
  "conventions",
@@ -1 +0,0 @@
1
- {"version":3,"file":"run-CH4FTfx2.js","names":[],"sources":["../src/config.ts","../src/workspace.ts","../src/rule.ts","../src/rules/cue-preset.ts","../src/rules/no-build-output.ts","../src/rules/no-local-paths.ts","../src/rules/pinned-git-deps.ts","../src/rules/release-files.ts","../src/rules/required-scripts.ts","../src/rules/source-main.ts","../src/rules/tsconfig-test.ts","../src/rules/workspace-protocol.ts","../src/rules/index.ts","../src/run.ts"],"sourcesContent":["/**\n * The configuration of the check: the field `conventions` of the root `package.json`. Each exception\n * needs a reason: a rule that is off, files that a rule ignores, and a changed option. Thus each\n * exception is visible.\n */\nimport type { OptionValue, Options, Rule } from \"./rule.ts\";\n\n/** The configuration of one rule, after the check of its fields. */\nexport interface RuleConfig {\n /** The reason why the rule is off. The rule is on when this field is missing. */\n readonly off?: string;\n /** The globs of files that the rule does not report. */\n readonly ignore: readonly string[];\n /** The reason of `ignore` or of the changed options. */\n readonly reason?: string;\n /** The options of the rule, with the defaults. */\n readonly options: Options;\n}\n\n/** The configuration of the check. */\nexport interface ConventionsConfig {\n /** The globs of the package folders. The default is the globs of the workspace. */\n readonly packages?: readonly string[];\n /** The configuration of each rule, by its id. */\n readonly rules: Readonly<Record<string, RuleConfig>>;\n}\n\n/** The fields of the configuration of a rule that are not options. */\nconst RULE_FIELDS = [\"off\", \"ignore\", \"reason\"];\n\nconst isObject = (value: unknown): value is Record<string, unknown> => typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isStrings = (value: unknown): value is string[] => Array.isArray(value) && value.every((item) => typeof item === \"string\");\n\n/** This function gives the options of a rule with their defaults. */\nexport function defaultOptions(rule: Rule): Options {\n return Object.fromEntries(Object.entries(rule.options).map(([name, spec]) => [name, spec.default]));\n}\n\n/**\n * This function reads the field `conventions` of the root `package.json` (`value`), and gives the\n * configuration of each rule of `rules`.\n *\n * @throws Error when the field has a wrong shape, an unknown rule or option, or an exception or a changed option without a reason\n */\nexport function parseConfig(value: unknown, rules: readonly Rule[]): ConventionsConfig {\n const byId = new Map(rules.map((rule) => [rule.id, rule]));\n const result: Record<string, RuleConfig> = {};\n for (const rule of rules) result[rule.id] = { ignore: [], options: defaultOptions(rule) };\n if (value === undefined) return { rules: result };\n if (!isObject(value)) throw new Error(\"The field conventions of package.json must be an object.\");\n const unknown = Object.keys(value).filter((key) => key !== \"packages\" && key !== \"rules\" && key !== \"$comment\");\n if (unknown.length > 0) throw new Error(`conventions has unknown fields: ${unknown.join(\", \")}.`);\n const packages = value[\"packages\"];\n if (packages !== undefined && !isStrings(packages)) throw new Error(\"conventions.packages must be an array of globs.\");\n const rulesValue = value[\"rules\"] ?? {};\n if (!isObject(rulesValue)) throw new Error(\"conventions.rules must be an object, with a rule id for each key.\");\n for (const [id, entry] of Object.entries(rulesValue)) {\n const rule = byId.get(id);\n if (rule === undefined) throw new Error(`conventions.rules has an unknown rule: ${id}. The rules are: ${[...byId.keys()].join(\", \")}.`);\n const where = `conventions.rules[\"${id}\"]`;\n if (!isObject(entry)) throw new Error(`${where} must be an object, for example { \"off\": \"<reason>\" }.`);\n const off = entry[\"off\"];\n if (off !== undefined && (typeof off !== \"string\" || off.trim() === \"\")) throw new Error(`${where}.off must be the reason why the rule is off, as text.`);\n const ignore = entry[\"ignore\"] ?? [];\n if (!isStrings(ignore)) throw new Error(`${where}.ignore must be an array of globs.`);\n const reason = entry[\"reason\"];\n if (reason !== undefined && (typeof reason !== \"string\" || reason.trim() === \"\")) throw new Error(`${where}.reason must be text.`);\n if (ignore.length > 0 && reason === undefined) throw new Error(`${where}.ignore needs a reason: add \"reason\": \"<why these files are an exception>\".`);\n const options: Record<string, OptionValue> = { ...defaultOptions(rule) };\n const changed: string[] = [];\n for (const [name, option] of Object.entries(entry)) {\n if (RULE_FIELDS.includes(name)) continue;\n const spec = rule.options[name];\n if (spec === undefined) {\n const known = [...RULE_FIELDS, ...Object.keys(rule.options)].join(\", \");\n throw new Error(`${where} has an unknown field: ${name}. The fields are: ${known}.`);\n }\n const good = spec.type === \"strings\" ? isStrings(option) : typeof option === spec.type;\n if (!good) throw new Error(`${where}.${name} must be ${spec.type === \"strings\" ? \"an array of strings\" : `a ${spec.type}`}.`);\n options[name] = option as OptionValue;\n changed.push(name);\n }\n // A changed option can make a rule weaker, so it needs a reason, as `ignore` does\n if (changed.length > 0 && reason === undefined && off === undefined) {\n throw new Error(`${where} changes the option${changed.length > 1 ? \"s\" : \"\"} ${changed.join(\", \")}, and needs a reason: add \"reason\": \"<why this repository changes the default>\".`);\n }\n result[id] = {\n ...(off === undefined ? {} : { off }),\n ignore,\n ...(reason === undefined ? {} : { reason }),\n options,\n };\n }\n return { ...(packages === undefined ? {} : { packages }), rules: result };\n}\n","/**\n * The package folders of a repository: the folders that the globs of the workspace name, with a\n * `package.json` file. This file is a copy of `workspace.ts` of `@mark1russell7/api-report`, so that\n * each tool has no runtime dependency.\n */\nimport { existsSync, readdirSync, readFileSync } from \"node:fs\";\nimport { join, relative, sep } from \"node:path\";\n\n/** This function compares two strings by their code units, as the default sort does. */\nexport const byCode = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);\n\n/** This function gives a path relative to `root`, with `/`. */\nexport const relativePath = (root: string, file: string): string => relative(root, file).split(sep).join(\"/\");\n\n/** The characters that have a meaning in a regular expression. */\nconst SPECIAL = new Set([...\"\\\\^$.|+()[]{}*?/\"]);\n\n/**\n * This function gives a regular expression for a glob of `/` paths. `*` matches a part of one path\n * segment, `?` matches one character, `**` matches zero or more segments, and `{a,b}` matches one of\n * its parts. The function escapes each other special character.\n */\nexport function globToRegExp(glob: string): RegExp {\n let source = \"\";\n let braces = 0;\n for (let index = 0; index < glob.length; index++) {\n const char = glob.charAt(index);\n if (char === \"/\" && glob.slice(index + 1) === \"**\") {\n // `a/**` matches `a` and each path under it\n source += \"(?:/.*)?\";\n break;\n }\n if (char === \"*\" && glob.charAt(index + 1) === \"*\") {\n const atStart = index === 0 || glob.charAt(index - 1) === \"/\";\n const after = glob.charAt(index + 2);\n if (atStart && after === \"/\") {\n // `**/` matches zero or more whole segments\n source += \"(?:[^/]+/)*\";\n index += 2;\n } else if (atStart && after === \"\") {\n source += \".*\";\n index += 1;\n } else {\n source += \"[^/]*\";\n index += 1;\n }\n } else if (char === \"*\") source += \"[^/]*\";\n else if (char === \"?\") source += \"[^/]\";\n else if (char === \"{\") {\n braces++;\n source += \"(?:\";\n } else if (char === \"}\" && braces > 0) {\n braces--;\n source += \")\";\n } else if (char === \",\" && braces > 0) source += \"|\";\n else if (SPECIAL.has(char)) source += `\\\\${char}`;\n else source += char;\n }\n if (braces > 0) throw new Error(`A glob with a \"{\" that has no \"}\": ${glob}`);\n return new RegExp(`^${source}$`);\n}\n\n/** The characters that make a path segment a pattern. */\nconst GLOB_CHARS = /[*?{]/;\n\n/**\n * This function gives the folders under `root` that a glob names, as `/` paths relative to `root`,\n * in the order of the code units. It does not go into `node_modules` or a folder that starts with `.`.\n */\nexport function globFolders(root: string, glob: string): string[] {\n const clean = glob.replace(/^\\.\\//, \"\").replace(/\\/+$/, \"\");\n const segments = clean.split(\"/\");\n const firstPattern = segments.findIndex((segment) => GLOB_CHARS.test(segment));\n if (firstPattern < 0) return existsSync(join(root, clean)) ? [clean] : [];\n const base = segments.slice(0, firstPattern).join(\"/\");\n const depth = clean.includes(\"**\") ? Number.POSITIVE_INFINITY : segments.length - firstPattern;\n const pattern = globToRegExp(clean);\n const start = join(root, base);\n if (!existsSync(start)) return [];\n const found: string[] = [];\n const walk = (folder: string, level: number): void => {\n for (const entry of readdirSync(folder, { withFileTypes: true })) {\n if (!entry.isDirectory() || entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n const path = join(folder, entry.name);\n if (pattern.test(relativePath(root, path))) found.push(relativePath(root, path));\n if (level < depth) walk(path, level + 1);\n }\n };\n // `a/**` also names `a`\n if (base !== \"\" && pattern.test(base)) found.push(base);\n walk(start, 1);\n return found.sort(byCode);\n}\n\n/**\n * This function gives the globs of the workspace at `root`: the `packages` list of\n * `pnpm-workspace.yaml`, then the `workspaces` field of `package.json`. The result is undefined when\n * the repository has no workspace.\n */\nexport function workspaceGlobs(root: string): string[] | undefined {\n const yaml = join(root, \"pnpm-workspace.yaml\");\n if (existsSync(yaml)) {\n const lines = readFileSync(yaml, \"utf8\").split(/\\r?\\n/);\n const start = lines.findIndex((line) => /^packages\\s*:/.test(line));\n if (start >= 0) {\n const unquote = (text: string): string =>\n text\n .replace(/\\s+#.*$/, \"\")\n .trim()\n .replace(/^[\"']|[\"']$/g, \"\");\n const inline = /^packages\\s*:\\s*\\[(.*)\\]/.exec(lines[start] ?? \"\");\n if (inline) return (inline[1] ?? \"\").split(\",\").map(unquote).filter(Boolean);\n const globs: string[] = [];\n for (const line of lines.slice(start + 1)) {\n if (/^\\s*(#.*)?$/.test(line)) continue;\n const item = /^\\s+-\\s+(.+)$/.exec(line);\n if (!item) break;\n globs.push(unquote(item[1] ?? \"\"));\n }\n return globs;\n }\n }\n const manifestFile = join(root, \"package.json\");\n if (existsSync(manifestFile)) {\n const { workspaces } = JSON.parse(readFileSync(manifestFile, \"utf8\")) as { workspaces?: unknown };\n if (Array.isArray(workspaces)) return workspaces.filter((glob): glob is string => typeof glob === \"string\");\n if (typeof workspaces === \"object\" && workspaces !== null && \"packages\" in workspaces && Array.isArray(workspaces.packages)) {\n return workspaces.packages.filter((glob): glob is string => typeof glob === \"string\");\n }\n }\n return undefined;\n}\n\n/**\n * This function gives the package folders of the repository at `root`: the folders of the globs\n * that have a `package.json` file. A glob that starts with `!` removes folders. Without globs, the\n * function reads the globs of the workspace, and a repository with no workspace is one package.\n * The result has absolute paths, in the order of the code units.\n */\nexport function packageFolders(root: string, globs: readonly string[] | undefined = workspaceGlobs(root)): string[] {\n if (globs === undefined) return existsSync(join(root, \"package.json\")) ? [root] : [];\n const included = new Set<string>();\n // As in pnpm, a `!` glob removes its folders in each position of the list\n for (const glob of globs.filter((item) => !item.startsWith(\"!\"))) for (const folder of globFolders(root, glob)) included.add(folder);\n for (const glob of globs.filter((item) => item.startsWith(\"!\"))) for (const folder of globFolders(root, glob.slice(1))) included.delete(folder);\n return [...included]\n .filter((folder) => existsSync(join(root, folder, \"package.json\")))\n .sort(byCode)\n .map((folder) => join(root, folder));\n}\n","/**\n * The shape of a rule, the facts that a rule reads (the context), and small helpers for the rules.\n */\nimport { spawnSync } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { globToRegExp } from \"./workspace.ts\";\n\n/** A row of the invariants audit that a rule comes from: the repository, the id of the rule in that audit, and the document line. */\nexport interface AuditSource {\n readonly repo: string;\n readonly rule: string;\n readonly doc: string;\n}\n\n/** A break of a rule: the file, the line when the rule knows it, and what is wrong. */\nexport interface Break {\n /** The file, relative to the root, with `/`. */\n readonly file: string;\n /** The line in the file, from 1. */\n readonly line?: number;\n readonly message: string;\n /** A fix for this break. The fix of the rule applies when this field is missing. */\n readonly fix?: string;\n}\n\n/** A value of an option of a rule. */\nexport type OptionValue = string | number | boolean | readonly string[];\n\n/** The options of a rule, after the defaults. */\nexport type Options = Readonly<Record<string, OptionValue>>;\n\n/** The description of one option of a rule. */\nexport interface OptionSpec {\n readonly type: \"string\" | \"number\" | \"boolean\" | \"strings\";\n readonly default: OptionValue;\n readonly description: string;\n}\n\n/** A field of `package.json`, as the rules read it. */\nexport type Manifest = Readonly<Record<string, unknown>>;\n\n/** A `package.json` file of the repository. */\nexport interface PackageInfo {\n /** The folder, relative to the root, with `/`. The root is `\"\"`. */\n readonly folder: string;\n /** The absolute path of the folder. */\n readonly dir: string;\n /** The path of the `package.json` file, relative to the root, with `/`. */\n readonly file: string;\n /** The text of the `package.json` file. */\n readonly text: string;\n readonly manifest: Manifest;\n}\n\n/** The facts of the repository that a rule reads. */\nexport interface RuleContext {\n /** The absolute path of the root. */\n readonly root: string;\n /** The root `package.json`. */\n readonly rootPackage: PackageInfo;\n /** The packages of the workspace, without the root. A repository with no workspace has no packages here. */\n readonly packages: readonly PackageInfo[];\n /** The environment variables. */\n readonly env: Readonly<Record<string, string | undefined>>;\n /** The base commit that `--base` gives, if any. */\n readonly base?: string;\n /** This function gives the files that git tracks, relative to the root, or undefined when the root is not in a git repository. */\n gitFiles(): readonly string[] | undefined;\n /** This function starts git in the root, and gives its output, or undefined when git fails. */\n git(args: readonly string[]): string | undefined;\n}\n\n/** The result of a rule: a list of breaks (empty when the rule passes), or the reason why the rule did not start. */\nexport type RuleOutcome = readonly Break[] | { readonly skipped: string };\n\n/** One convention, as a machine check. */\nexport interface Rule {\n /** A short id in kebab case. The configuration names the rule with this id. */\n readonly id: string;\n /** The rule in one sentence. */\n readonly title: string;\n /** Why the rule exists. */\n readonly reason: string;\n /** How to correct a break. */\n readonly fix: string;\n /** The rows of the invariants audit that the rule comes from. */\n readonly sources: readonly AuditSource[];\n /** The options of the rule, with their defaults. */\n readonly options: Readonly<Record<string, OptionSpec>>;\n check(context: RuleContext, options: Options): RuleOutcome;\n}\n\n/** The fields of `package.json` that hold dependencies. */\nexport const DEPENDENCY_FIELDS = [\"dependencies\", \"devDependencies\", \"peerDependencies\", \"optionalDependencies\"] as const;\n\n/** This function gives each entry of a field of `package.json` that maps names to specifiers. */\nexport function specifiersOf(manifest: Manifest, field: string): [string, string][] {\n const value = manifest[field];\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return [];\n return Object.entries(value as Record<string, unknown>).filter((entry): entry is [string, string] => typeof entry[1] === \"string\");\n}\n\n/** This function gives the line (from 1) of the first line of `text` that contains `needle`, from the line `from`. */\nexport function lineOf(text: string, needle: string, from = 1): number | undefined {\n const lines = text.split(/\\r?\\n/);\n for (let index = Math.max(0, from - 1); index < lines.length; index++) if ((lines[index] ?? \"\").includes(needle)) return index + 1;\n return undefined;\n}\n\n/** This function gives the line of the key `\"name\":` in `package.json`, after the line of the field `field`. */\nexport function keyLine(text: string, field: string, name: string): number | undefined {\n const start = lineOf(text, `\"${field}\"`) ?? 1;\n return lineOf(text, `${JSON.stringify(name)}:`, start) ?? lineOf(text, JSON.stringify(name), start);\n}\n\n/** This function joins a folder and a file name as a path relative to the root. */\nexport const inFolder = (folder: string, file: string): string => (folder === \"\" ? file : `${folder}/${file}`);\n\n/** This function removes `./` at the start of a path. */\nexport const cleanPath = (path: string): string => path.replace(/^\\.\\//, \"\");\n\n/** This function tells if a path matches one of the globs. */\nexport function matchesAny(path: string, globs: readonly string[]): boolean {\n return globs.some((glob) => globToRegExp(cleanPath(glob)).test(path));\n}\n\n/**\n * This function reads a JSON file with comments and commas at the end of a list (a `tsconfig.json`).\n *\n * @throws SyntaxError when the text is not JSON after the comments are removed\n */\nexport function parseJsonc(text: string): unknown {\n let out = \"\";\n let inString = false;\n for (let index = 0; index < text.length; index++) {\n const char = text.charAt(index);\n const next = text.charAt(index + 1);\n if (inString) {\n out += char;\n if (char === \"\\\\\") {\n out += next;\n index++;\n } else if (char === '\"') inString = false;\n } else if (char === '\"') {\n inString = true;\n out += char;\n } else if (char === \"/\" && next === \"/\") {\n while (index < text.length && text.charAt(index) !== \"\\n\") index++;\n out += \"\\n\";\n } else if (char === \"/\" && next === \"*\") {\n const end = text.indexOf(\"*/\", index + 2);\n index = end < 0 ? text.length : end + 1;\n } else out += char;\n }\n return JSON.parse(out.replace(/,(\\s*[}\\]])/g, \"$1\"));\n}\n\n/** This function reads a JSON file with comments, or gives undefined when the file does not exist or is not JSON. */\nexport function readJsonc(file: string): unknown {\n if (!existsSync(file)) return undefined;\n try {\n return parseJsonc(readFileSync(file, \"utf8\"));\n } catch {\n return undefined;\n }\n}\n\n/** This function starts git in `root` with `args`, and gives its output, or undefined when git fails. */\nexport function runGit(root: string, args: readonly string[]): string | undefined {\n const result = spawnSync(\"git\", [...args], { cwd: root, encoding: \"utf8\", maxBuffer: 256 * 1024 * 1024, windowsHide: true });\n if (result.error || result.status !== 0) return undefined;\n return result.stdout;\n}\n\n/** This function tells if `file` exists in the folder `dir`. */\nexport const hasFile = (dir: string, file: string): boolean => existsSync(join(dir, file));\n\n/**\n * This function gives the packages that hold code: the packages of the workspace, or the root\n * package when the repository has no workspace packages (a repository of one package).\n */\nexport function codePackages(context: Pick<RuleContext, \"rootPackage\" | \"packages\">): readonly PackageInfo[] {\n return context.packages.length > 0 ? context.packages : [context.rootPackage];\n}\n","/**\n * The rule `cue-preset`: the `tsconfig.json` of each package extends a preset of `@mark1russell7/cue`.\n * No config of a package turns off a strict option of its preset.\n */\nimport { readFileSync } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { codePackages, hasFile, inFolder, lineOf, readJsonc, type Break, type Rule } from \"../rule.ts\";\n\n/** The compiler options that make the type check strict. A package does not turn them off. */\nexport const STRICT_OPTIONS = [\n \"strict\",\n \"noImplicitAny\",\n \"strictNullChecks\",\n \"strictFunctionTypes\",\n \"strictBindCallApply\",\n \"strictPropertyInitialization\",\n \"strictBuiltinIteratorReturn\",\n \"noImplicitThis\",\n \"useUnknownInCatchVariables\",\n \"alwaysStrict\",\n \"noUncheckedIndexedAccess\",\n \"exactOptionalPropertyTypes\",\n \"noImplicitOverride\",\n \"noImplicitReturns\",\n \"noFallthroughCasesInSwitch\",\n \"noPropertyAccessFromIndexSignature\",\n] as const;\n\n/** The options that `strict` turns on when a config does not set them. */\nconst STRICT_FAMILY = new Set<string>([\n \"noImplicitAny\",\n \"strictNullChecks\",\n \"strictFunctionTypes\",\n \"strictBindCallApply\",\n \"strictPropertyInitialization\",\n \"strictBuiltinIteratorReturn\",\n \"noImplicitThis\",\n \"useUnknownInCatchVariables\",\n \"alwaysStrict\",\n]);\n\ntype Json = Readonly<Record<string, unknown>>;\n\nconst asObject = (value: unknown): Json => (typeof value === \"object\" && value !== null && !Array.isArray(value) ? (value as Json) : {});\n\n/** This function gives the `extends` list of a tsconfig. */\nconst extendsOf = (config: Json): string[] => {\n const value = config[\"extends\"];\n if (typeof value === \"string\") return [value];\n return Array.isArray(value) ? value.filter((item): item is string => typeof item === \"string\") : [];\n};\n\n/** The compiler options that a config gets from the configs that it extends. */\ninterface Inherited {\n readonly options: Json;\n /** False when the config extends a config that the rule cannot read. */\n readonly complete: boolean;\n}\n\n/**\n * This function gives the compiler options of the configs that `config` extends, with the options of\n * a later config over an earlier one.\n */\nfunction inheritedOptions(config: Json, dir: string, depth = 0): Inherited {\n if (depth > 10) return { options: {}, complete: false };\n let options: Json = {};\n let complete = true;\n for (const base of extendsOf(config)) {\n let file: string | undefined;\n if (base.startsWith(\".\")) file = resolve(dir, base.endsWith(\".json\") ? base : `${base}.json`);\n else {\n try {\n file = createRequire(join(dir, \"package.json\")).resolve(base);\n } catch {\n file = undefined;\n }\n }\n const parent = file === undefined ? undefined : readJsonc(file);\n if (parent === undefined || file === undefined) {\n complete = false;\n continue;\n }\n const above = inheritedOptions(asObject(parent), dirname(file), depth + 1);\n complete &&= above.complete;\n options = { ...options, ...above.options, ...asObject(asObject(parent)[\"compilerOptions\"]) };\n }\n return { options, complete };\n}\n\n/**\n * This function tells if a config that extends configs with the options `inherited` turns on the\n * option. When the rule cannot read each config, it gives true: the package turns off a strict option.\n */\nfunction inheritedOn(option: string, inherited: Inherited): boolean {\n if (!inherited.complete) return true;\n const value = inherited.options[option];\n if (typeof value === \"boolean\") return value;\n return STRICT_FAMILY.has(option) && inherited.options[\"strict\"] === true;\n}\n\nexport const cuePreset: Rule = {\n id: \"cue-preset\",\n title: \"The `tsconfig.json` of each package extends a preset of `@mark1russell7/cue`, and no config of a package turns off a strict option.\",\n reason:\n \"`pnpm package add` writes the configs from a preset, so each package checks its types with the same strict options. A config by hand or a strict option turned off lets the packages drift apart.\",\n fix: \"Make the package with `pnpm package add <name> --preset=<preset>`, or set `extends` to `@mark1russell7/cue/ts/config/<preset>.json`. Correct the code, not the strict option.\",\n sources: [\n { repo: \"client\", rule: \"cue-config\", doc: \"CLAUDE.md:64\" },\n { repo: \"client\", rule: \"no-manual-tsconfig\", doc: \"CLAUDE.md:64\" },\n { repo: \"Graph\", rule: \"cue-preset-strict\", doc: \"docs/architecture/ecosystem-and-structure.md:58\" },\n { repo: \"Graph\", rule: \"strict-preset\", doc: \"docs/architecture/ecosystem-and-structure.md:58\" },\n { repo: \"Graph\", rule: \"new-package-via-cli\", doc: \"CLAUDE.md:14\" },\n { repo: \"coeval\", rule: \"package-scaffold\", doc: \"CLAUDE.md:16\" },\n { repo: \"crawler\", rule: \"package-scaffold\", doc: \"CLAUDE.md:16\" },\n { repo: \"headroom\", rule: \"package-scaffold\", doc: \"CLAUDE.md:30\" },\n { repo: \"Vex\", rule: \"package-scaffold\", doc: \"CLAUDE.md:22\" },\n ],\n options: {\n prefix: { type: \"string\", default: \"@mark1russell7/cue/\", description: \"The start of the `extends` path of a preset.\" },\n extends: {\n type: \"boolean\",\n default: true,\n description: \"When false, the rule does not examine `extends`. It still reports each strict option that a config turns off. For a package that publishes its own presets.\",\n },\n },\n check(context, options) {\n const prefix = typeof options[\"prefix\"] === \"string\" ? options[\"prefix\"] : \"@mark1russell7/cue/\";\n const breaks: Break[] = [];\n for (const info of codePackages(context)) {\n if (!hasFile(info.dir, \"tsconfig.json\")) continue;\n for (const name of [\"tsconfig.json\", \"tsconfig.test.json\"]) {\n const path = join(info.dir, name);\n const file = inFolder(info.folder, name);\n const value = readJsonc(path);\n if (value === undefined) {\n if (hasFile(info.dir, name)) breaks.push({ file, message: `${name} is not JSON.`, fix: \"Correct the JSON.\" });\n continue;\n }\n const config = asObject(value);\n if (name === \"tsconfig.json\" && options[\"extends\"] !== false && !extendsOf(config).some((base) => base.startsWith(prefix))) {\n const line = lineOf(readFileSync(path, \"utf8\"), '\"extends\"');\n breaks.push({ file, ...(line === undefined ? {} : { line }), message: `tsconfig.json does not extend a preset of ${prefix.replace(/\\/$/, \"\")}.` });\n }\n const own = asObject(config[\"compilerOptions\"]);\n const inherited = inheritedOptions(config, info.dir);\n for (const option of STRICT_OPTIONS) {\n if (own[option] !== false || !inheritedOn(option, inherited)) continue;\n breaks.push({ file, message: `${name} turns off the strict option ${option}.`, fix: `Remove \"${option}\": false, and correct the code that it hides.` });\n }\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `no-build-output`: git does not keep build output.\n */\nimport { byCode } from \"../workspace.ts\";\nimport type { Break, Rule } from \"../rule.ts\";\n\nexport const noBuildOutput: Rule = {\n id: \"no-build-output\",\n title: \"Git keeps no build output: no tracked file is in a folder named `dist` or `build`.\",\n reason:\n \"The release workflow builds each package from the source. Build output in git goes stale, makes noise in each diff, and a user can get old code from a git install.\",\n fix: \"Remove the folder from git with `git rm -r --cached <folder>`, and keep its name in `.gitignore`.\",\n sources: [\n { repo: \"client\", rule: \"no-build-output\", doc: \"CLAUDE.md:48\" },\n { repo: \"client\", rule: \"no-dist\", doc: \"CLAUDE.md:48\" },\n { repo: \"client\", rule: \"no-dist-commit\", doc: \"CLAUDE.md:48\" },\n ],\n options: {\n folders: { type: \"strings\", default: [\"dist\", \"build\"], description: \"The names of the folders of build output.\" },\n },\n check(context, options) {\n const files = context.gitFiles();\n if (files === undefined) return { skipped: \"the root is not in a git repository\" };\n const names = new Set(Array.isArray(options[\"folders\"]) ? options[\"folders\"] : [\"dist\", \"build\"]);\n const counts = new Map<string, number>();\n for (const file of files) {\n const segments = file.split(\"/\");\n const index = segments.slice(0, -1).findIndex((segment) => names.has(segment));\n if (index < 0) continue;\n const folder = segments.slice(0, index + 1).join(\"/\");\n counts.set(folder, (counts.get(folder) ?? 0) + 1);\n }\n return [...counts.keys()].sort(byCode).map(\n (folder): Break => ({\n file: `${folder}/`,\n message: `Git keeps ${counts.get(folder) ?? 0} file(s) in ${folder}/.`,\n fix: `Start \\`git rm -r --cached ${folder}\\`, and keep ${folder.split(\"/\").pop() ?? folder}/ in .gitignore.`,\n }),\n );\n },\n};\n","/**\n * The rule `no-local-paths`: no tracked file names the home folder of a user of a computer.\n */\nimport { readFileSync, statSync } from \"node:fs\";\nimport { extname, join } from \"node:path\";\nimport type { Break, Rule } from \"../rule.ts\";\n\n/** The extensions of files that are not text. The rule does not read them. */\nconst BINARY = new Set(\n \".png .jpg .jpeg .gif .webp .avif .ico .bmp .tiff .pdf .zip .gz .tgz .bz2 .xz .7z .tar .woff .woff2 .ttf .otf .eot .mp3 .mp4 .webm .mov .wav .ogg .wasm .node .exe .dll .so .dylib .bin .db .sqlite .duckdb\".split(\n \" \",\n ),\n);\n\n/** The largest file that the rule reads, in bytes. */\nconst MAX_BYTES = 2 * 1024 * 1024;\n\n/** The names in a home path that do not identify a person: CI users, container users and placeholders. */\nexport const DEFAULT_ALLOWED: readonly string[] = [\"runner\", \"runneradmin\", \"user\", \"username\", \"you\", \"me\", \"name\", \"yourname\", \"your-name\", \"example\", \"node\", \"ubuntu\", \"vscode\", \"codespace\", \"public\", \"default\", \"shared\", \"all users\"];\n\n/** The forms of a home folder: Windows, macOS and Linux. The group `user` is the name of the user. */\nexport const HOME_PATTERNS: readonly RegExp[] = [\n // A Windows path does not depend on case, so `c:/users/<name>` is the same folder\n /\\b[A-Za-z]:(?:\\\\{1,2}|\\/)[Uu][Ss][Ee][Rr][Ss](?:\\\\{1,2}|\\/)(?<user>[^\\\\/\\s\"'`<>|:*?%$(){}[\\],;]+)/g,\n /(?<![\\w.~-])\\/Users\\/(?<user>[^/\\s\"'`<>|:*?%$(){}[\\],;]+)/g,\n /(?<![\\w.~-])\\/home\\/(?<user>[^/\\s\"'`<>|:*?%$(){}[\\],;]+)/g,\n];\n\nexport const noLocalPaths: Rule = {\n id: \"no-local-paths\",\n title: \"No tracked file has the home folder of a user (`C:\\\\Users\\\\<name>`, `/Users/<name>`, `/home/<name>`).\",\n reason: \"A public file must not name a computer, a user or a path of a computer. A local path also works only on one computer.\",\n fix: \"Use a path relative to the repository, `~`, an environment variable, or a placeholder such as `<you>`.\",\n sources: [\n { repo: \"client\", rule: \"I12\", doc: \"packages/documentation/ARCHITECTURE.md:201\" },\n { repo: \"systems\", rule: \"no-identifying-names\", doc: \"CLAUDE.md:12\" },\n { repo: \"systems\", rule: \"no-private-identifiers\", doc: \"CLAUDE.md:12\" },\n { repo: \"systems\", rule: \"no-private-names\", doc: \"CLAUDE.md:12\" },\n { repo: \"coeval\", rule: \"no-private-names\", doc: \"CLAUDE.md:22\" },\n ],\n options: {\n allow: { type: \"strings\", default: [], description: \"More user names that do not identify a person.\" },\n patterns: {\n type: \"strings\",\n default: [],\n description: \"More regular expressions of text that no file has. The environment variable CONVENTIONS_PRIVATE_PATTERNS adds one on each line, so a private name stays out of package.json.\",\n },\n },\n check(context, options) {\n const files = context.gitFiles();\n if (files === undefined) return { skipped: \"the root is not in a git repository\" };\n const allowed = new Set([...DEFAULT_ALLOWED, ...(Array.isArray(options[\"allow\"]) ? options[\"allow\"] : [])].map((name) => name.toLowerCase()));\n // A repository keeps private names out of its public files with the environment variable, for example from a secret of CI\n const fromEnv = (context.env[\"CONVENTIONS_PRIVATE_PATTERNS\"] ?? \"\")\n .split(\"\\n\")\n .map((line) => line.trim())\n .filter((line) => line !== \"\");\n const sources = [...(Array.isArray(options[\"patterns\"]) ? options[\"patterns\"] : []), ...fromEnv];\n const extra = sources.map((source) => new RegExp(source, \"g\"));\n const rootFile = context.rootPackage.file;\n const breaks: Break[] = [];\n for (const file of files) {\n if (BINARY.has(extname(file).toLowerCase())) continue;\n const path = join(context.root, file);\n let text: string;\n try {\n if (statSync(path).size > MAX_BYTES) continue;\n text = readFileSync(path, \"utf8\");\n } catch {\n // A file of the index that is not in the working tree\n continue;\n }\n if (text.includes(\"\\0\")) continue;\n const lines = text.split(/\\r?\\n/);\n for (let index = 0; index < lines.length; index++) {\n const line = lines[index] ?? \"\";\n // The reason of an exception in the root package.json tells why a text is no home folder, so it can quote one. A private pattern still counts there\n const isReason = file === rootFile && /^\\s*\"(?:reason|off)\"\\s*:/.test(line);\n for (const pattern of isReason ? [] : HOME_PATTERNS) {\n for (const match of line.matchAll(pattern)) {\n const user = match.groups?.[\"user\"] ?? \"\";\n // A name of one character is a placeholder of a test, not a person\n if (user.length < 2 || allowed.has(user.toLowerCase())) continue;\n breaks.push({ file, line: index + 1, message: `The text \"${match[0]}\" is the home folder of a user.` });\n }\n }\n for (const pattern of extra) {\n // The option patterns of the root package.json names the pattern itself\n if (file === rootFile && line.trim().replace(/,$/, \"\") === JSON.stringify(pattern.source)) continue;\n for (const match of line.matchAll(pattern)) breaks.push({ file, line: index + 1, message: `The text \"${match[0]}\" matches the pattern ${pattern.source}.`, fix: \"Remove the text.\" });\n }\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `pinned-git-deps`: a dependency from git names a full commit.\n */\nimport { DEPENDENCY_FIELDS, keyLine, specifiersOf, type Break, type Manifest, type Rule } from \"../rule.ts\";\n\n/** The fields of the root `package.json` that replace the specifiers of dependencies. */\nconst OVERRIDE_FIELDS = [\"overrides\", \"resolutions\"] as const;\n\n/** This function tells if a specifier gets the package from git, not from a registry or the workspace. */\nexport function isGitSpecifier(spec: string): boolean {\n const value = spec.trim();\n if (/^(github|gitlab|bitbucket|gist):/i.test(value)) return true;\n if (/^git(\\+[a-z]+)?:/i.test(value) || /^git@/i.test(value)) return true;\n if (/^https?:\\/\\/(www\\.)?(github\\.com|gitlab\\.com|bitbucket\\.org|codeload\\.github\\.com)\\//i.test(value)) return true;\n // npm and pnpm read `owner/repo` and `owner/repo#ref` as a GitHub repository\n return /^[\\w-][\\w.-]*\\/[\\w.-]+(#.*)?$/.test(value) && !value.startsWith(\"@\");\n}\n\n/**\n * This function tells if a git specifier names a commit. A specifier names a commit when its ref\n * (after `#`) is a commit SHA, or when a tarball URL has the SHA in its path.\n */\nexport function isPinned(spec: string, fullSha: boolean): boolean {\n const sha = fullSha ? /^[0-9a-f]{40}$/i : /^[0-9a-f]{7,40}$/i;\n const hash = spec.indexOf(\"#\");\n if (hash >= 0) {\n // pnpm also knows `#commit=<sha>`, and `&` joins the parts of a ref\n const parts = spec.slice(hash + 1).split(\"&\");\n return parts.some((part) => sha.test(part.replace(/^commit=/, \"\")));\n }\n const path = /^https?:\\/\\/[^/]+\\/(.*)$/i.exec(spec.trim())?.[1];\n return path !== undefined && path.split(/[/.]/).some((part) => sha.test(part));\n}\n\n/** This function gives the specifiers of the fields of overrides, also the field `overrides` of `pnpm`. */\nfunction overridesOf(manifest: Manifest): [string, string, string][] {\n const out: [string, string, string][] = [];\n for (const field of OVERRIDE_FIELDS) for (const [name, spec] of specifiersOf(manifest, field)) out.push([field, name, spec]);\n const pnpm = manifest[\"pnpm\"];\n if (typeof pnpm === \"object\" && pnpm !== null) for (const [name, spec] of specifiersOf(pnpm as Manifest, \"overrides\")) out.push([\"pnpm\", name, spec]);\n return out;\n}\n\nexport const pinnedGitDeps: Rule = {\n id: \"pinned-git-deps\",\n title: \"A dependency from git (github:, git+https: or owner/repo) names a full commit SHA.\",\n reason:\n \"A git ref without a commit moves with the branch. Then an install today and an install tomorrow get different code, and the lockfile hides the change.\",\n fix: 'Use the npm version, `workspace:*` for a package of this repository, or `github:owner/repo#<full commit SHA>`.',\n sources: [\n { repo: \"coeval\", rule: \"pinned-deps\", doc: \"CLAUDE.md:41\" },\n { repo: \"coeval\", rule: \"unpublished-dep-pinned\", doc: \"CLAUDE.md:41\" },\n { repo: \"headroom\", rule: \"non-npm-deps-pinned\", doc: \"CLAUDE.md:38\" },\n { repo: \"headroom\", rule: \"pinned-github-specifier\", doc: \"CLAUDE.md:38\" },\n { repo: \"Graph\", rule: \"github-dep-full-sha\", doc: \"docs/decisions.md:1384\" },\n { repo: \"Graph\", rule: \"github-dep-pinned\", doc: \"docs/decisions.md:1384\" },\n { repo: \"client\", rule: \"general-npm-version\", doc: \"CLAUDE.md:54\" },\n ],\n options: {\n fullSha: { type: \"boolean\", default: true, description: \"When false, a short SHA of 7 or more characters is also a commit.\" },\n },\n check(context, options) {\n const fullSha = options[\"fullSha\"] !== false;\n const breaks: Break[] = [];\n for (const info of [context.rootPackage, ...context.packages]) {\n const found: [string, string, string][] = [];\n for (const field of DEPENDENCY_FIELDS) for (const [name, spec] of specifiersOf(info.manifest, field)) found.push([field, name, spec]);\n found.push(...overridesOf(info.manifest));\n for (const [field, name, spec] of found) {\n if (!isGitSpecifier(spec) || isPinned(spec, fullSha)) continue;\n const line = keyLine(info.text, field, name);\n breaks.push({\n file: info.file,\n ...(line === undefined ? {} : { line }),\n message: `${field} \"${name}\" is \"${spec}\": a git dependency without a ${fullSha ? \"full \" : \"\"}commit SHA.`,\n });\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `release-files`: a pull request changes a file of the release flow only with a reason\n * that everyone can see.\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { matchesAny, type Break, type Rule, type RuleContext } from \"../rule.ts\";\n\n/** The range of commits that the rule examines. */\ninterface Range {\n /** The arguments of `git diff --name-only` that give the changed files. */\n readonly diff: readonly string[];\n /** The arguments of `git log` that give the commit messages. */\n readonly log: readonly string[];\n}\n\n/** This function gives the range of the change: the option `--base`, or the merge commit of a pull request. */\nfunction rangeOf(context: RuleContext): Range | { readonly skipped: string } {\n if (context.base !== undefined) {\n if (context.git([\"rev-parse\", \"--verify\", \"--quiet\", `${context.base}^{commit}`]) === undefined) return { skipped: `git does not know the base ${context.base}` };\n return { diff: [`${context.base}...HEAD`], log: [`${context.base}..HEAD`] };\n }\n const event = context.env[\"GITHUB_EVENT_NAME\"];\n if (event !== \"pull_request\" && event !== \"pull_request_target\") return { skipped: \"no base: the rule runs on a pull request, or with --base <ref>\" };\n // The checkout of a pull request is a merge commit: its first parent is the base, its second parent the head\n const parents = context.git([\"rev-list\", \"--parents\", \"-n\", \"1\", \"HEAD\"])?.trim().split(/\\s+/) ?? [];\n if (parents.length !== 3) return { skipped: \"HEAD is not the merge commit of the pull request\" };\n if (context.git([\"cat-file\", \"-e\", \"HEAD^1^{commit}\"]) === undefined) return { skipped: \"the checkout has no parent of HEAD: set fetch-depth to 2 or more\" };\n return { diff: [\"HEAD^1\", \"HEAD\"], log: [\"HEAD^1..HEAD\"] };\n}\n\n/** This function gives the body of the pull request from the event file of GitHub Actions, or an empty string. */\nfunction pullRequestBody(context: RuleContext): string {\n const file = context.env[\"GITHUB_EVENT_PATH\"];\n if (file === undefined || file === \"\" || !existsSync(file)) return \"\";\n try {\n const event = JSON.parse(readFileSync(file, \"utf8\")) as { pull_request?: { body?: unknown } };\n return typeof event.pull_request?.body === \"string\" ? event.pull_request.body : \"\";\n } catch {\n return \"\";\n }\n}\n\n/** This function escapes the special characters of a regular expression. */\nconst escape = (text: string): string => text.replace(/[\\\\^$.|?*+()[\\]{}]/g, \"\\\\$&\");\n\nexport const releaseFiles: Rule = {\n id: \"release-files\",\n title: \"A pull request changes `.github/workflows/release.yml` or `scripts/release/` only with a `Release-Edit: <reason>` line.\",\n reason:\n \"The release flow publishes to npm with trusted publishing. A change of its files by a session that does not own the release can stop or break each release.\",\n fix: \"Revert the change of the release files. When the owner asked for the change, add the line `Release-Edit: <reason>` to the last commit message or to the body of the pull request.\",\n sources: [\n { repo: \"coeval\", rule: \"no-release-edit\", doc: \"CLAUDE.md:40\" },\n { repo: \"coeval\", rule: \"no-release-edits\", doc: \"CLAUDE.md:40\" },\n { repo: \"crawler\", rule: \"no-release-edit\", doc: \"CLAUDE.md:80\" },\n { repo: \"crawler\", rule: \"no-release-edits\", doc: \"CLAUDE.md:80\" },\n { repo: \"headroom\", rule: \"no-release-edits\", doc: \"CLAUDE.md:37\" },\n { repo: \"headroom\", rule: \"release-files-frozen\", doc: \"CLAUDE.md:37\" },\n ],\n options: {\n paths: { type: \"strings\", default: [\".github/workflows/release.yml\", \"scripts/release/**\"], description: \"The globs of the files that the release flow owns.\" },\n trailer: { type: \"string\", default: \"Release-Edit\", description: \"The key of the line that gives the reason of a change.\" },\n authors: {\n type: \"strings\",\n default: [\"mark1russell7-release-train[bot]\"],\n description: \"The authors of the release flow. A change of the release files in commits of only these authors (the sync of the template) needs no reason.\",\n },\n },\n check(context, options) {\n const range = rangeOf(context);\n if (\"skipped\" in range) return range;\n const globs = Array.isArray(options[\"paths\"]) ? options[\"paths\"] : [];\n const changed = (context.git([\"diff\", \"--name-only\", ...range.diff]) ?? \"\")\n .split(/\\r?\\n/)\n .filter((file) => file !== \"\" && matchesAny(file, globs));\n if (changed.length === 0) return [];\n const trailer = typeof options[\"trailer\"] === \"string\" ? options[\"trailer\"] : \"Release-Edit\";\n const line = new RegExp(`^${escape(trailer)}:[ \\\\t]*\\\\S`, \"im\");\n const messages = context.git([\"log\", \"--no-merges\", \"--format=%B\", ...range.log]) ?? \"\";\n if (line.test(messages) || line.test(pullRequestBody(context))) return [];\n const authors = new Set(Array.isArray(options[\"authors\"]) ? options[\"authors\"] : []);\n const changers = (context.git([\"log\", \"--no-merges\", \"--format=%an\", ...range.log, \"--\", ...changed]) ?? \"\").split(/\\r?\\n/).filter((name) => name !== \"\");\n if (changers.length > 0 && changers.every((name) => authors.has(name))) return [];\n return changed.map((file): Break => ({ file, message: `The change edits ${file}, a file of the release flow, with no \"${trailer}: <reason>\" line.` }));\n },\n};\n","/**\n * The rule `required-scripts`: the root `package.json` keeps the scripts that the shared CI starts.\n */\nimport { DEPENDENCY_FIELDS, hasFile, lineOf, specifiersOf, type Break, type RuleContext, type Rule } from \"../rule.ts\";\n\n/** The package of the STE linter. */\nconst STE_LINT = \"@mark1russell7/ste-lint\";\n\n/** The configuration file of the STE linter. */\nconst STE_CONFIG = \"ste.config.json\";\n\n/** The examples of the scripts that the fix shows. */\nconst EXAMPLES: Readonly<Record<string, string>> = { \"lint:ste\": \"ste-lint\", typecheck: \"pnpm -r run typecheck\" };\n\n/**\n * This function tells if the repository uses the STE prose standard: the root `package.json` has a\n * dependency on `@mark1russell7/ste-lint`, or the root has a `ste.config.json`.\n */\nexport function usesSteLint(context: RuleContext): boolean {\n const manifest = context.rootPackage.manifest;\n if (DEPENDENCY_FIELDS.some((field) => specifiersOf(manifest, field).some(([name]) => name === STE_LINT))) return true;\n return hasFile(context.root, STE_CONFIG);\n}\n\nexport const requiredScripts: Rule = {\n id: \"required-scripts\",\n title: \"The root `package.json` has the script `typecheck`, and also `lint:ste` when the repository uses `ste-lint`.\",\n reason:\n \"The shared CI starts each script of its list that `package.json` has, and it skips the others. Thus a removed script turns its check off, and nothing shows it.\",\n fix: 'Add the script, for example `\"lint:ste\": \"ste-lint\"` or `\"typecheck\": \"pnpm -r run typecheck\"`.',\n sources: [\n { repo: \"client\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"coeval\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"crawler\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"Graph\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"headroom\", rule: \"ste-prose\", doc: \"CLAUDE.md:19\" },\n { repo: \"systems\", rule: \"lint-ste-in-ci\", doc: \"CLAUDE.md:24\" },\n { repo: \"Vex\", rule: \"ste-prose\", doc: \"CLAUDE.md:5\" },\n { repo: \"coeval\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"crawler\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"headroom\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:32\" },\n { repo: \"Vex\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:23\" },\n ],\n options: {\n scripts: { type: \"strings\", default: [\"typecheck\"], description: \"The scripts that the root `package.json` has.\" },\n steScripts: {\n type: \"strings\",\n default: [\"lint:ste\"],\n description: \"The scripts that the root `package.json` has when the repository uses `ste-lint` (a dependency on `@mark1russell7/ste-lint`, or a `ste.config.json` at the root).\",\n },\n },\n check(context, options) {\n const always = Array.isArray(options[\"scripts\"]) ? options[\"scripts\"] : [\"typecheck\"];\n const ste = Array.isArray(options[\"steScripts\"]) ? options[\"steScripts\"] : [\"lint:ste\"];\n const wanted = [...new Set([...always, ...(usesSteLint(context) ? ste : [])])];\n const value = context.rootPackage.manifest[\"scripts\"];\n const scripts = typeof value === \"object\" && value !== null ? (value as Record<string, unknown>) : {};\n const line = lineOf(context.rootPackage.text, '\"scripts\"');\n return wanted\n .filter((name) => typeof scripts[name] !== \"string\" || scripts[name] === \"\")\n .map((name): Break => {\n const example = EXAMPLES[name];\n const why = ste.includes(name) && !always.includes(name) ? \" The repository uses ste-lint.\" : \"\";\n return {\n file: context.rootPackage.file,\n ...(line === undefined ? {} : { line }),\n message: `The root package.json has no script \"${name}\".${why}`,\n fix: example === undefined ? `Add the script \"${name}\".` : `Add the script, for example \"${name}\": \"${example}\".`,\n };\n });\n },\n};\n","/**\n * The rule `source-main`: a workspace package is a source package, and a public package moves its\n * entries to the build when it is published.\n */\nimport { cleanPath, codePackages, lineOf, type Break, type Manifest, type Rule } from \"../rule.ts\";\n\n/** The fields of `package.json` that name the entries of a package. */\nconst ENTRY_FIELDS = [\"main\", \"module\", \"types\", \"typings\", \"exports\", \"bin\"] as const;\n\n/** This function gives each path in the value of an entry field (a string, or the strings in an object). */\nexport function pathsOf(value: unknown): string[] {\n if (typeof value === \"string\") return [value];\n if (Array.isArray(value)) return value.flatMap(pathsOf);\n if (typeof value === \"object\" && value !== null) return Object.values(value).flatMap(pathsOf);\n return [];\n}\n\n/** This function tells if a path is a source file: a file in `src/`, or a TypeScript file that is not a declaration file. */\nexport function isSourcePath(path: string): boolean {\n const clean = cleanPath(path);\n return clean.startsWith(\"src/\") || (/\\.(c|m)?tsx?$/.test(clean) && !/\\.d\\.(c|m)?ts$/.test(clean));\n}\n\nexport const sourceMain: Rule = {\n id: \"source-main\",\n title: \"Each workspace package is a source package (`main` is `src/index.ts`), and a public package moves its entries to the build in `publishConfig`.\",\n reason:\n \"Other packages of the workspace import the source, so a change is visible at once with no build. A public package that publishes its source entries gives TypeScript files to npm users.\",\n fix: 'Set `\"main\": \"./src/index.ts\"`. In a public package, add `publishConfig` with main, types, exports and bin that point at the build, as `pnpm package add` does.',\n sources: [\n { repo: \"coeval\", rule: \"package-main-source\", doc: \"CLAUDE.md:17\" },\n { repo: \"coeval\", rule: \"source-package-main\", doc: \"CLAUDE.md:17\" },\n { repo: \"crawler\", rule: \"pkg-source-main\", doc: \"CLAUDE.md:17\" },\n { repo: \"crawler\", rule: \"source-package-main\", doc: \"CLAUDE.md:17\" },\n { repo: \"crawler\", rule: \"publish-config-build\", doc: \"CLAUDE.md:41\" },\n { repo: \"Graph\", rule: \"new-package-main-index\", doc: \"CLAUDE.md:15\" },\n { repo: \"Graph\", rule: \"source-package-main\", doc: \"CLAUDE.md:15\" },\n { repo: \"headroom\", rule: \"source-package-main\", doc: \"CLAUDE.md:31\" },\n ],\n options: {\n main: { type: \"string\", default: \"src/index.ts\", description: \"The path of `main` in each package.\" },\n publishConfig: { type: \"boolean\", default: true, description: \"When false, the rule does not examine `publishConfig`.\" },\n },\n check(context, options) {\n const main = cleanPath(typeof options[\"main\"] === \"string\" ? options[\"main\"] : \"src/index.ts\");\n const breaks: Break[] = [];\n for (const info of codePackages(context)) {\n // The root of a repository of one package has no workspace that imports its source, so only its publishConfig counts\n const single = info.folder === \"\";\n const manifest = info.manifest;\n const at = (field: string): { line?: number } => {\n const line = lineOf(info.text, `\"${field}\"`);\n return line === undefined ? {} : { line };\n };\n const value = manifest[\"main\"];\n if (single) {\n // The root of a repository of one package can point main at its build\n } else if (typeof value === \"string\") {\n if (cleanPath(value) !== main) breaks.push({ file: info.file, ...at(\"main\"), message: `\"main\" is \"${value}\", not \"./${main}\".` });\n } else if (ENTRY_FIELDS.some((field) => manifest[field] !== undefined) || manifest[\"private\"] !== true) {\n // A package with only a bin (a CLI) has no entry to import, and a private package with no entry is an app (a site)\n if (manifest[\"bin\"] === undefined) breaks.push({ file: info.file, ...at(\"name\"), message: `The package has no \"main\". A source package has \"main\": \"./${main}\".` });\n }\n if (options[\"publishConfig\"] === false || manifest[\"private\"] === true) continue;\n const published = (typeof manifest[\"publishConfig\"] === \"object\" && manifest[\"publishConfig\"] !== null ? manifest[\"publishConfig\"] : {}) as Manifest;\n for (const field of ENTRY_FIELDS) {\n const source = pathsOf(manifest[field]).filter(isSourcePath);\n if (source.length === 0) continue;\n if (published[field] === undefined) {\n breaks.push({\n file: info.file,\n ...at(field),\n message: `\"${field}\" points at the source (${source[0] ?? \"\"}), and publishConfig has no \"${field}\": npm users get the source.`,\n fix: `Add publishConfig.${field} that points at the build.`,\n });\n continue;\n }\n const still = pathsOf(published[field]).filter(isSourcePath);\n if (still.length > 0) {\n breaks.push({ file: info.file, ...at(\"publishConfig\"), message: `publishConfig.${field} points at the source (${still[0] ?? \"\"}).`, fix: `Point publishConfig.${field} at the build.` });\n }\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `tsconfig-test`: each TypeScript package has a `tsconfig.test.json`, and its typecheck\n * examines it.\n */\nimport { codePackages, hasFile, inFolder, lineOf, type Break, type Rule } from \"../rule.ts\";\n\n/** The path of a test file: `*.test.*` or `*.spec.*` of JavaScript or TypeScript, or a file in a folder `__tests__`. */\nconst TEST_FILE = /(?:^|\\/)(?:[^/]+\\.(?:test|spec)\\.[cm]?[jt]sx?|__tests__\\/.+)$/;\n\n/** This function tells if git tracks a test file in the package folder `folder` (`\"\"` is the root). */\nexport function hasTests(files: readonly string[], folder: string): boolean {\n const prefix = folder === \"\" ? \"\" : `${folder}/`;\n return files.some((path) => path.startsWith(prefix) && TEST_FILE.test(path.slice(prefix.length)));\n}\n\nexport const tsconfigTest: Rule = {\n id: \"tsconfig-test\",\n title: \"Each package with a `tsconfig.json` and test files has a `tsconfig.test.json`, and its `typecheck` script examines it.\",\n reason: \"The build config leaves out the tests. Without a second config, `pnpm typecheck` does not examine the tests, and a type error in a test hides until the test runs.\",\n fix: \"Add `tsconfig.test.json` (extends `./tsconfig.json`, includes the tests, `noEmit`), and set the script `typecheck` to `tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json`. Keep `--noEmit` on the first call when the build config emits, so that a typecheck writes no build output.\",\n sources: [\n { repo: \"coeval\", rule: \"package-tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"coeval\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"crawler\", rule: \"pkg-tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"crawler\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:18\" },\n { repo: \"headroom\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:32\" },\n { repo: \"headroom\", rule: \"tsconfig-test-per-package\", doc: \"CLAUDE.md:32\" },\n { repo: \"Vex\", rule: \"package-tsconfig-test\", doc: \"CLAUDE.md:23\" },\n { repo: \"Vex\", rule: \"tsconfig-test\", doc: \"CLAUDE.md:23\" },\n ],\n options: {\n file: { type: \"string\", default: \"tsconfig.test.json\", description: \"The name of the config of the tests.\" },\n },\n check(context, options) {\n const file = typeof options[\"file\"] === \"string\" ? options[\"file\"] : \"tsconfig.test.json\";\n const tracked = context.gitFiles();\n const breaks: Break[] = [];\n for (const info of codePackages(context)) {\n if (!hasFile(info.dir, \"tsconfig.json\")) continue;\n // A package with no test file has no test to examine. Outside git the rule cannot tell, so it examines the package\n if (tracked !== undefined && !hasTests(tracked, info.folder)) continue;\n if (!hasFile(info.dir, file)) {\n breaks.push({ file: inFolder(info.folder, file), message: `The package has a tsconfig.json and no ${file}.` });\n continue;\n }\n const scripts = info.manifest[\"scripts\"];\n const typecheck = typeof scripts === \"object\" && scripts !== null ? (scripts as Record<string, unknown>)[\"typecheck\"] : undefined;\n if (typeof typecheck === \"string\" && !typecheck.includes(file)) {\n const line = lineOf(info.text, '\"typecheck\"');\n breaks.push({\n file: info.file,\n ...(line === undefined ? {} : { line }),\n message: `The script typecheck (\"${typecheck}\") does not examine ${file}.`,\n fix: `Add \\`tsc -p ${file}\\` to the script typecheck.`,\n });\n }\n }\n return breaks;\n },\n};\n","/**\n * The rule `workspace-protocol`: a package uses another package of the workspace through `workspace:`.\n */\nimport { keyLine, specifiersOf, type Break, type Rule } from \"../rule.ts\";\n\n/** The fields that the rule examines. A peer dependency often keeps a range for its users, so the rule does not examine it. */\nconst FIELDS = [\"dependencies\", \"devDependencies\", \"optionalDependencies\"] as const;\n\nexport const workspaceProtocol: Rule = {\n id: \"workspace-protocol\",\n title: \"A dependency on a package of this workspace uses the `workspace:` protocol.\",\n reason:\n \"A version range or a git ref of a package of the same repository gets an old copy from the registry or from git, not the source next to it. Then a change and its test do not meet.\",\n fix: 'Use `\"workspace:*\"`. pnpm writes the real version when it publishes the package.',\n sources: [\n { repo: \"client\", rule: \"workspace-protocol\", doc: \"CLAUDE.md:52\" },\n { repo: \"client\", rule: \"workspace-deps\", doc: \"CLAUDE.md:52\" },\n { repo: \"coeval\", rule: \"pinned-deps\", doc: \"CLAUDE.md:41\" },\n { repo: \"headroom\", rule: \"non-npm-deps-pinned\", doc: \"CLAUDE.md:38\" },\n { repo: \"crawler\", rule: \"mcp-workspace-dep\", doc: \"CLAUDE.md:55\" },\n ],\n options: {\n prefix: { type: \"string\", default: \"workspace:\", description: 'The start of each specifier, for example \"workspace:*\" to refuse \"workspace:^\".' },\n },\n check(context, options) {\n const prefix = typeof options[\"prefix\"] === \"string\" ? options[\"prefix\"] : \"workspace:\";\n const names = new Set(context.packages.map((info) => info.manifest[\"name\"]).filter((name): name is string => typeof name === \"string\"));\n const breaks: Break[] = [];\n for (const info of [context.rootPackage, ...context.packages]) {\n for (const field of FIELDS) {\n for (const [name, spec] of specifiersOf(info.manifest, field)) {\n if (!names.has(name) || name === info.manifest[\"name\"] || spec.startsWith(prefix)) continue;\n const line = keyLine(info.text, field, name);\n breaks.push({\n file: info.file,\n ...(line === undefined ? {} : { line }),\n message: `${field} \"${name}\" is \"${spec}\", but \"${name}\" is a package of this workspace.`,\n fix: `Use \"${prefix === \"workspace:\" ? \"workspace:*\" : prefix}\".`,\n });\n }\n }\n }\n return breaks;\n },\n};\n","/**\n * The list of the rules, in the order of the output.\n */\nimport type { Rule } from \"../rule.ts\";\nimport { cuePreset } from \"./cue-preset.ts\";\nimport { noBuildOutput } from \"./no-build-output.ts\";\nimport { noLocalPaths } from \"./no-local-paths.ts\";\nimport { pinnedGitDeps } from \"./pinned-git-deps.ts\";\nimport { releaseFiles } from \"./release-files.ts\";\nimport { requiredScripts } from \"./required-scripts.ts\";\nimport { sourceMain } from \"./source-main.ts\";\nimport { tsconfigTest } from \"./tsconfig-test.ts\";\nimport { workspaceProtocol } from \"./workspace-protocol.ts\";\n\n/** Each rule of the check. */\nexport const RULES: readonly Rule[] = [\n pinnedGitDeps,\n workspaceProtocol,\n sourceMain,\n tsconfigTest,\n cuePreset,\n requiredScripts,\n noBuildOutput,\n noLocalPaths,\n releaseFiles,\n];\n\nexport { cuePreset, noBuildOutput, noLocalPaths, pinnedGitDeps, releaseFiles, requiredScripts, sourceMain, tsconfigTest, workspaceProtocol };\n","/**\n * The commands `check` and `--list` of the bin `conventions`, as functions. `runChecks` starts the\n * rules, and `runCli` reads the arguments and writes the result.\n */\nimport { appendFileSync, existsSync, readFileSync } from \"node:fs\";\nimport { join, resolve } from \"node:path\";\nimport { parseConfig, type ConventionsConfig } from \"./config.ts\";\nimport { matchesAny, runGit, type Break, type Manifest, type PackageInfo, type Rule, type RuleContext } from \"./rule.ts\";\nimport { RULES } from \"./rules/index.ts\";\nimport { packageFolders, relativePath } from \"./workspace.ts\";\n\n/** The result of one rule. */\nexport interface RuleResult {\n readonly id: string;\n readonly title: string;\n readonly fix: string;\n /** `pass`: no break. `break`: one or more breaks. `off`: the configuration turns the rule off. `skipped`: the rule did not start. `error`: the rule threw. */\n readonly status: \"pass\" | \"break\" | \"off\" | \"skipped\" | \"error\";\n readonly breaks: readonly Break[];\n /** The number of breaks in the files of `ignore`. */\n readonly ignored: number;\n /** The reason of `off`, of `ignore`, of `skipped`, or the message of `error`. */\n readonly note?: string;\n}\n\n/** The result of `runChecks`. */\nexport interface CheckResult {\n readonly rules: readonly RuleResult[];\n /** True when a rule has a break or an error. */\n readonly failed: boolean;\n}\n\n/** The options of `runChecks`. */\nexport interface CheckOptions {\n /** The root of the repository. */\n readonly root: string;\n /** Only these rules. The default is each rule. */\n readonly only?: readonly string[];\n /** The base commit of the change, for the rules that examine a change. */\n readonly base?: string;\n readonly env?: Readonly<Record<string, string | undefined>>;\n /** The rules. The default is `RULES`. */\n readonly rules?: readonly Rule[];\n}\n\n/** This function reads a `package.json` file. */\nfunction readPackage(root: string, dir: string): PackageInfo {\n const path = join(dir, \"package.json\");\n const text = readFileSync(path, \"utf8\");\n const parsed: unknown = JSON.parse(text);\n const manifest = (typeof parsed === \"object\" && parsed !== null ? parsed : {}) as Manifest;\n return { folder: relativePath(root, dir), dir, file: relativePath(root, path), text, manifest };\n}\n\n/** This function reads the configuration of the root `package.json` at `root`. */\nexport function readConfig(root: string, rules: readonly Rule[] = RULES): ConventionsConfig {\n const file = join(root, \"package.json\");\n if (!existsSync(file)) throw new Error(`No package.json in ${root}.`);\n return parseConfig((JSON.parse(readFileSync(file, \"utf8\")) as Manifest)[\"conventions\"], rules);\n}\n\n/** This function gives the facts of the repository at `root` that the rules read. */\nexport function createContext(root: string, config: ConventionsConfig, options: Pick<CheckOptions, \"base\" | \"env\"> = {}): RuleContext {\n const rootPackage = readPackage(root, root);\n const packages = packageFolders(root, config.packages ?? undefined)\n .filter((dir) => resolve(dir) !== resolve(root))\n .map((dir) => readPackage(root, dir));\n let files: readonly string[] | undefined | null = null;\n return {\n root,\n rootPackage,\n packages,\n env: options.env ?? {},\n ...(options.base === undefined ? {} : { base: options.base }),\n gitFiles() {\n if (files === null) {\n const out = runGit(root, [\"ls-files\", \"-z\", \"--cached\"]);\n files = out === undefined ? undefined : out.split(\"\\0\").filter((file) => file !== \"\");\n }\n return files;\n },\n git: (args) => runGit(root, args),\n };\n}\n\n/** This function starts each rule on the repository at `options.root`, and gives the result of each rule. */\nexport function runChecks(options: CheckOptions): CheckResult {\n const root = resolve(options.root);\n const rules = options.rules ?? RULES;\n const unknown = (options.only ?? []).filter((id) => !rules.some((rule) => rule.id === id));\n if (unknown.length > 0) throw new Error(`Unknown rule: ${unknown.join(\", \")}. The rules are: ${rules.map((rule) => rule.id).join(\", \")}.`);\n const config = readConfig(root, rules);\n const context = createContext(root, config, options);\n const results: RuleResult[] = [];\n for (const rule of rules) {\n if (options.only !== undefined && options.only.length > 0 && !options.only.includes(rule.id)) continue;\n const ruleConfig = config.rules[rule.id] ?? { ignore: [], options: {} };\n const base = { id: rule.id, title: rule.title, fix: rule.fix };\n if (ruleConfig.off !== undefined) {\n results.push({ ...base, status: \"off\", breaks: [], ignored: 0, note: ruleConfig.off });\n continue;\n }\n let outcome: ReturnType<Rule[\"check\"]>;\n try {\n outcome = rule.check(context, ruleConfig.options);\n } catch (error) {\n results.push({ ...base, status: \"error\", breaks: [], ignored: 0, note: error instanceof Error ? error.message : String(error) });\n continue;\n }\n if (\"skipped\" in outcome) {\n results.push({ ...base, status: \"skipped\", breaks: [], ignored: 0, note: outcome.skipped });\n continue;\n }\n const breaks = outcome.filter((item) => !matchesAny(item.file, ruleConfig.ignore));\n const ignored = outcome.length - breaks.length;\n const note = ruleConfig.reason === undefined ? {} : { note: ruleConfig.reason };\n results.push({ ...base, status: breaks.length > 0 ? \"break\" : \"pass\", breaks, ignored, ...note });\n }\n return { rules: results, failed: results.some((result) => result.status === \"break\" || result.status === \"error\") };\n}\n\n/** The most breaks of one rule in the text output. The JSON output has each break. */\nconst MAX_SHOWN = 50;\n\n/** This function gives the place of a break as `file:line`. */\nconst placeOf = (item: Break): string => (item.line === undefined ? item.file : `${item.file}:${item.line}`);\n\n/** This function gives the text of a result for a terminal or a CI log. */\nexport function formatResult(result: CheckResult): string {\n const count = (status: RuleResult[\"status\"]): number => result.rules.filter((rule) => rule.status === status).length;\n const breaks = result.rules.reduce((sum, rule) => sum + rule.breaks.length, 0);\n const out: string[] = [\n `conventions: ${result.rules.length} rules: ${count(\"pass\")} pass, ${count(\"break\")} with ${breaks} break(s), ${count(\"off\")} off, ${count(\"skipped\")} skipped, ${count(\"error\")} error(s).`,\n \"\",\n ];\n const label: Record<RuleResult[\"status\"], string> = { pass: \"pass \", break: \"BREAK\", off: \"off \", skipped: \"skip \", error: \"ERROR\" };\n for (const rule of result.rules) {\n const extra = rule.ignored > 0 ? ` (${rule.ignored} ignored: ${rule.note ?? \"\"})` : rule.note !== undefined && rule.status !== \"pass\" ? ` (${rule.note})` : \"\";\n out.push(`${label[rule.status]} ${rule.id}${rule.breaks.length > 0 ? `: ${rule.breaks.length} break(s)` : \"\"}${extra}`);\n for (const item of rule.breaks.slice(0, MAX_SHOWN)) {\n out.push(` ${placeOf(item)} ${item.message}`);\n if (item.fix !== undefined) out.push(` fix: ${item.fix}`);\n }\n if (rule.breaks.length > MAX_SHOWN) out.push(` ... ${rule.breaks.length - MAX_SHOWN} more. Start \\`conventions check --json\\` for each break.`);\n if (rule.breaks.length > 0) out.push(` rule: ${rule.title}`, ` fix: ${rule.fix}`);\n }\n if (result.failed) out.push(\"\", \"To turn a rule off or to keep an exception, add a reason in the field conventions of package.json (`conventions --list`).\");\n return `${out.join(\"\\n\")}\\n`;\n}\n\n/** This function escapes the text of a cell of a Markdown table. */\nconst cell = (text: string): string => text.replace(/\\|/g, \"\\\\|\").replace(/\\r?\\n/g, \" \");\n\n/** This function gives the result as Markdown for the summary of a GitHub Actions run. */\nexport function summaryMarkdown(result: CheckResult): string {\n const out = [\"### Conventions\", \"\", \"| Rule | Result | Note |\", \"|---|---|---|\"];\n for (const rule of result.rules) {\n const shown = rule.status === \"break\" ? `${rule.breaks.length} break(s)` : rule.status;\n const note = rule.ignored > 0 ? `${rule.ignored} ignored: ${rule.note ?? \"\"}` : (rule.note ?? \"\");\n out.push(`| \\`${rule.id}\\` | ${shown} | ${cell(note)} |`);\n }\n const broken = result.rules.filter((rule) => rule.breaks.length > 0);\n for (const rule of broken) {\n out.push(\"\", `<details open><summary><code>${rule.id}</code>: ${rule.breaks.length} break(s)</summary>`, \"\", `${rule.title} Fix: ${rule.fix}`, \"\");\n for (const item of rule.breaks.slice(0, MAX_SHOWN)) out.push(`- \\`${placeOf(item)}\\`: ${item.message}${item.fix === undefined ? \"\" : ` Fix: ${item.fix}`}`);\n if (rule.breaks.length > MAX_SHOWN) out.push(`- ... ${rule.breaks.length - MAX_SHOWN} more`);\n out.push(\"\", \"</details>\");\n }\n return `${out.join(\"\\n\")}\\n`;\n}\n\n/** This function escapes a value of a workflow command of GitHub Actions. */\nconst escapeData = (text: string): string => text.replace(/%/g, \"%25\").replace(/\\r/g, \"%0D\").replace(/\\n/g, \"%0A\");\nconst escapeProperty = (text: string): string => escapeData(text).replace(/:/g, \"%3A\").replace(/,/g, \"%2C\");\n\n/** This function gives an `::error` workflow command for each break, so that GitHub shows each break on its line in the pull request. */\nexport function annotations(result: CheckResult): string {\n const out: string[] = [];\n for (const rule of result.rules) {\n for (const item of rule.breaks) {\n const line = item.line === undefined ? \"\" : `,line=${item.line}`;\n out.push(`::error file=${escapeProperty(item.file)}${line},title=${escapeProperty(`conventions ${rule.id}`)}::${escapeData(`${item.message} Fix: ${item.fix ?? rule.fix}`)}`);\n }\n }\n return out.length === 0 ? \"\" : `${out.join(\"\\n\")}\\n`;\n}\n\n/** This function gives the text of `--list`: each rule, its reason, its fix, its options, its state and its audit sources. */\nexport function listRules(config: ConventionsConfig | undefined, rules: readonly Rule[] = RULES): string {\n const out: string[] = [];\n for (const rule of rules) {\n const ruleConfig = config?.rules[rule.id];\n const state = ruleConfig?.off !== undefined ? `off: ${ruleConfig.off}` : \"on\";\n out.push(`${rule.id} (${state})`, ` ${rule.title}`, ` why: ${rule.reason}`, ` fix: ${rule.fix}`);\n for (const [name, spec] of Object.entries(rule.options)) {\n const value = ruleConfig?.options[name] ?? spec.default;\n out.push(` option ${name} = ${JSON.stringify(value)}: ${spec.description}`);\n }\n if (ruleConfig !== undefined && ruleConfig.ignore.length > 0) out.push(` ignore ${ruleConfig.ignore.join(\", \")}: ${ruleConfig.reason ?? \"\"}`);\n else if (ruleConfig?.reason !== undefined) out.push(` reason: ${ruleConfig.reason}`);\n out.push(` from: ${rule.sources.map((source) => `${source.repo} ${source.rule} (${source.doc})`).join(\"; \")}`, \"\");\n }\n return `${out.join(\"\\n\")}`;\n}\n\n/** The input and output of `runCli`. */\nexport interface CliIo {\n readonly cwd: string;\n readonly env: Readonly<Record<string, string | undefined>>;\n readonly stdout: (text: string) => void;\n readonly stderr: (text: string) => void;\n}\n\n/** The help text of the bin. */\nexport const USAGE: string = `Usage: conventions check [options]\n conventions --list\n\n check Start each rule. Exit code 1 when a rule has a break.\n --list Show each rule: why, fix, options, state and the audit rows that it comes from.\n\n --root <folder> The root of the repository. The default is the current folder.\n --rule <id> Only this rule. Use it again for more rules.\n --base <ref> The base commit of the change, for the rule release-files. On a pull request, the rule finds it.\n --json Write the result as JSON.\n -h, --help Show this text.\n\nThe field \"conventions\" of the root package.json turns a rule off with a reason, keeps an exception\nwith a reason, and sets the options of a rule with a reason:\n\n \"conventions\": { \"rules\": { \"no-build-output\": { \"off\": \"<reason>\" },\n \"cue-preset\": { \"ignore\": [\"packages/web/**\"], \"reason\": \"<reason>\" },\n \"workspace-protocol\": { \"prefix\": \"workspace:*\", \"reason\": \"<reason>\" } } }\n`;\n\n/** An error of the arguments: exit code 2 and the help text. */\nclass UsageError extends Error {}\n\n/** This function starts the bin with the arguments `args`, and gives its exit code. */\nexport function runCli(args: readonly string[], io: CliIo): number {\n let check = false;\n let list = false;\n let json = false;\n let root = io.cwd;\n let base: string | undefined;\n const only: string[] = [];\n try {\n for (let index = 0; index < args.length; index++) {\n const arg = args[index] ?? \"\";\n const value = (): string => {\n const next = args[++index];\n if (next === undefined || next.startsWith(\"-\")) throw new UsageError(`The option ${arg} needs a value.`);\n return next;\n };\n if (arg === \"check\") check = true;\n else if (arg === \"--list\" || arg === \"list\") list = true;\n else if (arg === \"--json\") json = true;\n else if (arg === \"--root\") root = resolve(io.cwd, value());\n else if (arg === \"--rule\") only.push(value());\n else if (arg === \"--base\") base = value();\n else if (arg === \"--help\" || arg === \"-h\") {\n io.stdout(USAGE);\n return 0;\n } else throw new UsageError(`An unknown argument: ${arg}`);\n }\n if (!check && !list) throw new UsageError(\"Give the command check, or --list.\");\n } catch (error) {\n if (!(error instanceof UsageError)) throw error;\n io.stderr(`conventions: ${error.message}\\n\\n${USAGE}`);\n return 2;\n }\n if (list) {\n let config: ConventionsConfig | undefined;\n try {\n config = existsSync(join(root, \"package.json\")) ? readConfig(root) : undefined;\n } catch (error) {\n io.stderr(`conventions: ${error instanceof Error ? error.message : String(error)}\\n`);\n return 1;\n }\n io.stdout(listRules(config));\n return 0;\n }\n let result: CheckResult;\n try {\n result = runChecks({ root, only, env: io.env, ...(base === undefined ? {} : { base }) });\n } catch (error) {\n io.stderr(`conventions: ${error instanceof Error ? error.message : String(error)}\\n`);\n return 1;\n }\n if (json) io.stdout(`${JSON.stringify(result, null, 2)}\\n`);\n else {\n if (io.env[\"GITHUB_ACTIONS\"] === \"true\") io.stdout(annotations(result));\n io.stdout(formatResult(result));\n }\n const summary = io.env[\"GITHUB_STEP_SUMMARY\"];\n if (summary) appendFileSync(summary, summaryMarkdown(result));\n return result.failed ? 1 : 0;\n}\n"],"mappings":";;;;;;AA4BA,MAAM,cAAc;CAAC;CAAO;CAAU;AAAQ;AAE9C,MAAM,YAAY,UAAqD,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAE1I,MAAM,aAAa,UAAsC,MAAM,QAAQ,KAAK,KAAK,MAAM,OAAO,SAAS,OAAO,SAAS,QAAQ;;AAG/H,SAAgB,eAAe,MAAqB;CAClD,OAAO,OAAO,YAAY,OAAO,QAAQ,KAAK,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,UAAU,CAAC,MAAM,KAAK,OAAO,CAAC,CAAC;AACpG;;;;;;;AAQA,SAAgB,YAAY,OAAgB,OAA2C;CACrF,MAAM,OAAO,IAAI,IAAI,MAAM,KAAK,SAAS,CAAC,KAAK,IAAI,IAAI,CAAC,CAAC;CACzD,MAAM,SAAqC,CAAC;CAC5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