@r_masseater/msch 0.8.0 → 0.9.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/dist/cli.mjs CHANGED
@@ -1,11 +1,20 @@
1
1
  #!/usr/bin/env node
2
- import { $ as isTypeAliasDeclaration, A as getTextOfJSDocComment, B as isInterfaceDeclaration, C as API, D as getJSDocTags, E as SyntaxKind, F as isElementAccessExpression, G as isObjectLiteralExpression, H as isModuleDeclaration, I as isEnumDeclaration, J as isSatisfiesExpression, K as isPropertyAccessExpression, L as isExportDeclaration, M as isBinaryExpression, N as isCallExpression, O as getLeadingCommentRanges, P as isClassDeclaration, Q as isStringLiteral, R as isIdentifier, S as uniqueByReference, T as InternalSymbolName, U as isNewExpression, V as isModuleBlock, W as isNumericLiteral, X as isSourceFile, Y as isSignatureDeclaration, Z as isSpreadElement, _ as lineOf, a as problemAt, at as isVariableStatement, b as resolvedSymbol, c as childrenOf$1, d as declarationsOf, et as isTypeLiteralNode, f as descendantsOf, g as isTypeDeclaration, h as isGenericDeclaration, i as formatProblem, it as isVariableDeclarationList, j as isArrayLiteralExpression, k as getNameOfDeclaration, l as columnOf, m as isExternalDeclaration, n as ProblemList, nt as isUnionTypeNode, o as sortProblems, p as importedModulesOf, q as isPropertyAssignment, rt as isVariableDeclaration, s as NODE_MODULES_SEGMENT, tt as isTypeReferenceNode, u as contains, v as propertyNamesOf, w as IndexKind, x as symbolAt, y as referencedSymbols, z as isImportDeclaration } from "./cli-contract-BvrxbrIy.mjs";
2
+ import { $ as isTypeAliasDeclaration, A as getTextOfJSDocComment, B as isInterfaceDeclaration, C as API, D as getJSDocTags, E as SyntaxKind, F as isElementAccessExpression, G as isObjectLiteralExpression, H as isModuleDeclaration, I as isEnumDeclaration, J as isSatisfiesExpression, K as isPropertyAccessExpression, L as isExportDeclaration, M as isBinaryExpression, N as isCallExpression, O as getLeadingCommentRanges, P as isClassDeclaration, Q as isStringLiteral, R as isIdentifier, S as uniqueByReference, T as InternalSymbolName, U as isNewExpression, V as isModuleBlock, W as isNumericLiteral, X as isSourceFile, Y as isSignatureDeclaration, Z as isSpreadElement, _ as lineOf, a as problemAt, at as isVariableStatement, b as resolvedSymbol, c as childrenOf$2, d as declarationsOf, et as isTypeLiteralNode, f as descendantsOf, g as isTypeDeclaration, h as isGenericDeclaration, i as formatProblem, it as isVariableDeclarationList, j as isArrayLiteralExpression, k as getNameOfDeclaration, l as columnOf, m as isExternalDeclaration, n as ProblemList, nt as isUnionTypeNode, o as sortProblems, p as importedModulesOf, q as isPropertyAssignment, rt as isVariableDeclaration, s as NODE_MODULES_SEGMENT, tt as isTypeReferenceNode, u as contains, v as propertyNamesOf, w as IndexKind, x as symbolAt, y as referencedSymbols, z as isImportDeclaration } from "./cli-contract-DlE7gy0b.mjs";
3
3
  import { a as workspaceDependencies, c as nodeServicesLayer, i as readManifest, n as NODE_MODULES, o as RepositoryFiles, r as dependencyEntries, s as nodeRepositoryFiles, t as MANIFEST_FILE } from "./dependencies-x3j9tLcR.mjs";
4
- import { _ as publishedWorkspaces, c as programOf, d as childrenOf$2, i as hasVerifyTask, m as workspaceDirectories, n as VERIFY_TASK, r as definesTask, v as publicEntriesOf } from "./workspace-tasks-CRL-gm__.mjs";
5
- import { Array, Cause, Effect, FileSystem, Function, HashMap, HashSet, Layer, Number as Number$1, Option, Order, Path, Record, Result, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
4
+ import { _ as publishedWorkspaces, c as programOf, d as childrenOf$3, i as hasVerifyTask, m as workspaceDirectories, n as VERIFY_TASK, r as definesTask, v as publicEntriesOf } from "./workspace-tasks-CRL-gm__.mjs";
5
+ import { t as COMMENT_DIRECTIVES } from "./comment-directives-DApQXgQf.mjs";
6
+ import { Array, Cause, Effect, FileSystem, Function, HashMap, HashSet, Layer, Number as Number$1, Option, Order, Path, Predicate, Record, Result, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
6
7
  import { ChildProcess } from "effect/process";
7
8
  import { parse, resolveConfigFromFile } from "vite-plus";
8
- import { LineCounter, isMap, isScalar, parseAllDocuments, parseDocument } from "yaml";
9
+ import { LineCounter, Parser, isMap, isScalar, parseAllDocuments, parseDocument } from "yaml";
10
+ import path from "node:path";
11
+ import { fileURLToPath } from "node:url";
12
+ import treeSitter from "@vscode/tree-sitter-wasm";
13
+ import { isComment, isTag, isText } from "domhandler";
14
+ import { DomUtils, parseDocument as parseDocument$1 } from "htmlparser2";
15
+ import { DockerfileParser } from "dockerfile-ast";
16
+ import { parse as parse$2 } from "sql-parser-cst";
17
+ import { parseTOML } from "toml-eslint-parser";
9
18
  import { runMain } from "@effect/platform-node-shared/NodeRuntime";
10
19
  import { FetchHttpClient } from "effect/http";
11
20
  import { Otlp, OtlpSerialization } from "effect/observability";
@@ -458,7 +467,7 @@ const derivationScopeOf = (node) => {
458
467
  };
459
468
  const sourcesOf = (checker) => (node) => pipe(referencedSymbols(checker)(derivationScopeOf(node)), Array.filter((symbol) => Option.isSome(namedValuesOf(checker)(symbol))));
460
469
  const sitesUnder = (checker) => (node) => {
461
- const nested = pipe(childrenOf$1(node), Array.flatMap((child) => sitesUnder(checker)(child)));
470
+ const nested = pipe(childrenOf$2(node), Array.flatMap((child) => sitesUnder(checker)(child)));
462
471
  if (Array.isReadonlyArrayNonEmpty(nested)) return nested;
463
472
  return siteValuesOf(checker)(node).pipe(Option.map((values) => ({
464
473
  node,
@@ -790,54 +799,6 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
790
799
  ...duplicateProblems(relative)(unowned)
791
800
  ]);
792
801
  }, Effect.scoped);
793
- // src/text-position.ts
794
- const START$3 = 0;
795
- const FIRST_COLUMN$1 = 1;
796
- const positionOf = (source) => (index) => {
797
- const before = pipe(source, String$1.slice(START$3, index), String$1.split("\n"));
798
- return {
799
- line: before.length,
800
- column: pipe(Array.last(before), Option.match({
801
- onNone: () => FIRST_COLUMN$1,
802
- onSome: (last) => last.length + FIRST_COLUMN$1
803
- }))
804
- };
805
- };
806
- // src/hidden-unicode.ts
807
- const HIDDEN = /[\u00AD\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]|[\u{E0000}-\u{E007F}]/gu;
808
- const NUL = "\0";
809
- const START$2 = 0;
810
- const HEX = 16;
811
- const CODE_POINT_WIDTH = 4;
812
- const READ_CONCURRENCY$5 = 64;
813
- const RULE$5 = "hidden-unicode";
814
- const hexOf = (character) => pipe(String$1.codePointAt(START$2)(character), Option.getOrElse(() => START$2), (code) => code.toString(HEX), String$1.toUpperCase, String$1.padStart(CODE_POINT_WIDTH, "0"));
815
- const problemOf = (file, source) => (found) => {
816
- const hex = hexOf(found[START$2]);
817
- return {
818
- file,
819
- ...positionOf(source)(found.index ?? START$2),
820
- rule: RULE$5,
821
- message: `U+${hex} is invisible in editors and reviews and can change what the text means. Remove it, or write it as the escape \\u${hex}.`
822
- };
823
- };
824
- const problemsIn$2 = (file, source) => {
825
- if (String$1.includes(NUL)(source)) return [];
826
- return pipe(Array.fromIterable(String$1.matchAll(HIDDEN)(source)), Array.map(problemOf(file, source)));
827
- };
828
- /** @internal */
829
- const checkHiddenUnicode = Effect.fn("checkHiddenUnicode")(function* checkHiddenUnicode(root) {
830
- const files = yield* RepositoryFiles;
831
- const names = yield* files.listedFiles(root);
832
- const found = yield* Effect.forEach(names, (name) => {
833
- const file = files.join(root, name);
834
- return files.readFile(file).pipe(Effect.map(Option.match({
835
- onNone: () => [],
836
- onSome: (source) => problemsIn$2(file, source)
837
- })));
838
- }, { concurrency: READ_CONCURRENCY$5 });
839
- return Array.flatten(found);
840
- });
841
802
  // src/import-graph.ts
842
803
  const RELATIVE = /^\.\.?(?:\/|$)/u;
843
804
  const SUBPATH_IMPORT = "#";
@@ -960,7 +921,7 @@ const installedNames = (manifest) => [
960
921
  ...keysOf$1(manifest.optionalDependencies),
961
922
  ...pipe(keysOf$1(manifest.peerDependencies), Array.filter((name) => !isOptionalPeer(manifest, name)))
962
923
  ];
963
- const childrenOf = Effect.fn("childrenOf")(function* childrenOf(directory) {
924
+ const childrenOf$1 = Effect.fn("childrenOf")(function* childrenOf(directory) {
964
925
  const files = yield* RepositoryFiles;
965
926
  const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));
966
927
  return pipe(text, Option.flatMap(decodeManifest), Option.map(installedNames), Option.getOrElse(() => []), Array.map((child) => [directory, child]));
@@ -989,7 +950,7 @@ const closureOf = (provided, collect) => Array.match(collect.pending, {
989
950
  ...collect,
990
951
  pending: rest
991
952
  });
992
- return childrenOf(resolved.value).pipe(Effect.flatMap((children) => closureOf(provided, {
953
+ return childrenOf$1(resolved.value).pipe(Effect.flatMap((children) => closureOf(provided, {
993
954
  pending: [...rest, ...children],
994
955
  seen: HashSet.add(collect.seen, resolved.value)
995
956
  })));
@@ -1015,6 +976,19 @@ const installedSize = (directory) => {
1015
976
  if (String$1.includes(`/node_modules/`)(directory)) return directorySize(directory);
1016
977
  return Effect.succeed(EMPTY);
1017
978
  };
979
+ // src/text-position.ts
980
+ const START$5 = 0;
981
+ const FIRST_COLUMN$2 = 1;
982
+ const positionOf = (source) => (index) => {
983
+ const before = pipe(source, String$1.slice(START$5, index), String$1.split("\n"));
984
+ return {
985
+ line: before.length,
986
+ column: pipe(Array.last(before), Option.match({
987
+ onNone: () => FIRST_COLUMN$2,
988
+ onSome: (last) => last.length + FIRST_COLUMN$2
989
+ }))
990
+ };
991
+ };
1018
992
  // src/install-size.ts
1019
993
  const INSTALL_SIZE = "install-size";
1020
994
  const STACK_DEPENDENCY = "stack-dependency";
@@ -1025,11 +999,11 @@ const LISTED_LARGEST = 5;
1025
999
  const SIZE_CONCURRENCY = 32;
1026
1000
  const MEGABYTE = 1e6;
1027
1001
  const MEGABYTE_DIGITS = 1;
1028
- const START$1 = 0;
1002
+ const START$4 = 0;
1029
1003
  const SINGLE_ENTRY = 1;
1030
1004
  const megabytes = (bytes) => `${(bytes / MEGABYTE).toFixed(MEGABYTE_DIGITS)} MB`;
1031
1005
  const usageHint = (dependency, entryCount) => {
1032
- if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$1 && dependency.entries.length < entryCount)) return "";
1006
+ if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$4 && dependency.entries.length < entryCount)) return "";
1033
1007
  return ` (imported only from ${Array.join(dependency.entries, ", ")})`;
1034
1008
  };
1035
1009
  const listed = ({ largest, entryCount }) => pipe(largest, Array.map((dependency) => `${dependency.name} ${megabytes(dependency.size)}${usageHint(dependency, entryCount)}`), Array.join(", "));
@@ -1038,7 +1012,7 @@ const budgetProblem = Effect.fn("budgetProblem")(function* budgetProblem(overrun
1038
1012
  const { workspace, total } = overrun;
1039
1013
  const config = yield* files.readFile(workspace.configFile);
1040
1014
  const source = Option.getOrElse(config, () => "");
1041
- const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$1);
1015
+ const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$4);
1042
1016
  return {
1043
1017
  file: workspace.configFile,
1044
1018
  ...positionOf(source)(index),
@@ -1055,7 +1029,7 @@ const measure = Effect.fn("measure")(function* measure({ workspace, provided },
1055
1029
  const everything = pipe(closures, Array.flatMap(([, packages]) => Array.fromIterable(packages)), HashSet.fromIterable);
1056
1030
  const measured = yield* Effect.forEach(everything, (found) => installedSize(found).pipe(Effect.map((size) => [found, size])), { concurrency: SIZE_CONCURRENCY });
1057
1031
  const sizes = HashMap.fromIterable(measured);
1058
- const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$1))));
1032
+ const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$4))));
1059
1033
  return {
1060
1034
  closures,
1061
1035
  sizeOf,
@@ -1088,11 +1062,11 @@ const sizeProblems = Effect.fn("sizeProblems")(function* sizeProblems(published,
1088
1062
  })];
1089
1063
  });
1090
1064
  const stackProblems = (file, source, dependencies) => {
1091
- const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$1);
1065
+ const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$4);
1092
1066
  const rest = String$1.slice(section)(source);
1093
1067
  return pipe(Record.toEntries(dependencies), Array.filter(([, specifier]) => specifier === STACK_CATALOG), Array.map(([name]) => ({
1094
1068
  file,
1095
- ...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$1)),
1069
+ ...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$4)),
1096
1070
  rule: STACK_DEPENDENCY,
1097
1071
  message: `${name} comes from the stack catalog, so every project that installs this package already has it. Move it to peerDependencies and keep it in devDependencies, so the installing project shares one copy.`
1098
1072
  })));
@@ -1138,23 +1112,23 @@ const checkPublishedPackages = Effect.fn("checkPublishedPackages")(function* che
1138
1112
  return Array.flatten(found);
1139
1113
  });
1140
1114
  // src/nested-docs.ts
1141
- const RULE$4 = "nested-docs";
1142
- const CONFIG_FILE$3 = "vite.config.ts";
1115
+ const RULE$6 = "nested-docs";
1116
+ const CONFIG_FILE$4 = "vite.config.ts";
1143
1117
  const SEPARATOR$2 = "/";
1144
1118
  const FIRST$3 = 1;
1145
- const READ_CONCURRENCY$4 = 64;
1119
+ const READ_CONCURRENCY$6 = 64;
1146
1120
  const AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
1147
1121
  const WORKSPACE_AGENT_DOC = "AGENTS.md";
1148
1122
  const README$1 = /^README(?:\.[^/]+)?$/iu;
1149
- const RootConfig = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
1150
- const taggedError$2 = Schema.TaggedError;
1151
- var RootConfigUnreadable = class extends taggedError$2()("RootConfigUnreadable", { file: Schema.String }) {};
1123
+ const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
1124
+ const taggedError$4 = Schema.TaggedError;
1125
+ var RootConfigUnreadable = class extends taggedError$4()("RootConfigUnreadable", { file: Schema.String }) {};
1152
1126
  const isNested = (name) => String$1.includes(SEPARATOR$2)(name);
1153
1127
  const problemFor$1 = (file, message) => ({
1154
1128
  file,
1155
1129
  line: FIRST$3,
1156
1130
  column: FIRST$3,
1157
- rule: RULE$4,
1131
+ rule: RULE$6,
1158
1132
  message
1159
1133
  });
1160
1134
  const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
@@ -1182,13 +1156,13 @@ const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, allowed, na
1182
1156
  });
1183
1157
  const allowsWorkspaceAgentDocs = Effect.fn("allowsWorkspaceAgentDocs")(function* allowsWorkspaceAgentDocs(root) {
1184
1158
  const files = yield* RepositoryFiles;
1185
- const file = files.join(root, CONFIG_FILE$3);
1159
+ const file = files.join(root, CONFIG_FILE$4);
1186
1160
  if (!(yield* files.exists(file))) return false;
1187
1161
  const config = yield* Effect.tryPromise({
1188
1162
  try: () => resolveConfigFromFile(file),
1189
1163
  catch: () => RootConfigUnreadable.make({ file })
1190
1164
  }).pipe(Effect.option);
1191
- return pipe(config, Option.flatMap(Schema.decodeUnknownOption(RootConfig)), Option.isSome);
1165
+ return pipe(config, Option.flatMap(Schema.decodeUnknownOption(RootConfig$1)), Option.isSome);
1192
1166
  });
1193
1167
  /** @internal */
1194
1168
  const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(root) {
@@ -1200,7 +1174,7 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
1200
1174
  workspaces: pipe(nested, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map((name) => files.dirname(files.join(root, name))), HashSet.fromIterable),
1201
1175
  workspaceAgentDocs
1202
1176
  };
1203
- const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$4 });
1177
+ const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$6 });
1204
1178
  return Array.getSomes(found);
1205
1179
  });
1206
1180
  // src/override-findings.ts
@@ -1394,8 +1368,8 @@ const RESOLUTION_FILES = [
1394
1368
  ];
1395
1369
  const RESOLUTION_CONCURRENCY = 4;
1396
1370
  const SUCCEEDED = 0;
1397
- const taggedError$1 = Schema.TaggedError;
1398
- var OverrideResolutionFailed = class extends taggedError$1()("OverrideResolutionFailed", {
1371
+ const taggedError$3 = Schema.TaggedError;
1372
+ var OverrideResolutionFailed = class extends taggedError$3()("OverrideResolutionFailed", {
1399
1373
  override: Schema.String,
1400
1374
  output: Schema.String
1401
1375
  }) {};
@@ -1497,6 +1471,425 @@ const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root
1497
1471
  if (Option.isNone(manifest) || !Array.isReadonlyArrayNonEmpty(keys)) return [];
1498
1472
  return yield* problemsFor(root, manifest.value, keys);
1499
1473
  });
1474
+ // src/root-readme.ts
1475
+ const RULE$5 = "root-readme";
1476
+ const SEPARATOR$1 = "/";
1477
+ const ALTERNATIVE = "|";
1478
+ const SCOPE = /^@[^/]+\//u;
1479
+ const README = /^README(?:\.[^/]+)?$/iu;
1480
+ const SPECIAL = /[$()*+.?[\\\]^{|}]/gu;
1481
+ const READ_CONCURRENCY$5 = 16;
1482
+ const START$3 = 0;
1483
+ const NamedManifest = Schema.fromJsonString(Schema.Struct({ name: Schema.optional(Schema.String) }));
1484
+ const patternOf = (names) => {
1485
+ const alternatives = pipe(names, Array.map(String$1.replaceAll(SPECIAL, String.raw`\$&`)));
1486
+ return new RegExp(`(?<![\\p{L}\\p{N}_-])(?:${Array.join(alternatives, ALTERNATIVE)})(?![\\p{L}\\p{N}_-])`, "gu");
1487
+ };
1488
+ const packageNameIn = (text) => pipe(text, Option.flatMap(Schema.decodeOption(NamedManifest)), Option.flatMap((manifest) => Option.fromUndefinedOr(manifest.name)));
1489
+ const workspaceIn = Effect.fn("workspaceIn")(function* workspaceIn(root, name) {
1490
+ const files = yield* RepositoryFiles;
1491
+ const directory = files.dirname(name);
1492
+ const text = yield* files.readFile(files.join(root, name));
1493
+ const packageName = packageNameIn(text);
1494
+ const unscoped = pipe(packageName, Option.map(String$1.replace(SCOPE, "")));
1495
+ const names = pipe([
1496
+ Option.some(directory),
1497
+ Option.some(files.basename(directory)),
1498
+ packageName,
1499
+ unscoped
1500
+ ], Array.getSomes, Array.dedupe);
1501
+ return {
1502
+ directory,
1503
+ pattern: patternOf(names)
1504
+ };
1505
+ });
1506
+ const messageFor = (directory) => `names the workspace ${directory}. The root README describes the repository as a whole. Write what belongs to the workspace in ${directory}/README.md.`;
1507
+ const problemsIn$2 = (file, source) => ({ directory, pattern }) => {
1508
+ const message = messageFor(directory);
1509
+ const at = positionOf(source);
1510
+ return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
1511
+ file,
1512
+ ...at(found.index ?? START$3),
1513
+ rule: RULE$5,
1514
+ message
1515
+ })));
1516
+ };
1517
+ const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadme(file, workspaces) {
1518
+ const text = yield* (yield* RepositoryFiles).readFile(file);
1519
+ return pipe(text, Option.match({
1520
+ onNone: () => [],
1521
+ onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$2(file, source)))
1522
+ }));
1523
+ });
1524
+ /** @internal */
1525
+ const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(root) {
1526
+ const files = yield* RepositoryFiles;
1527
+ const names = yield* files.listedFiles(root);
1528
+ const readmes = pipe(names, Array.filter((name) => README.test(name)));
1529
+ const manifests = pipe(names, Array.filter((name) => String$1.includes(SEPARATOR$1)(name) && files.basename(name) === "package.json"));
1530
+ const workspaces = yield* Effect.forEach(manifests, (name) => workspaceIn(root, name), { concurrency: READ_CONCURRENCY$5 });
1531
+ const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$5 });
1532
+ return Array.flatten(found);
1533
+ });
1534
+ // src/found-comment.ts
1535
+ const taggedError$2 = Schema.TaggedError;
1536
+ var CommentsUnreadable = class extends taggedError$2()("CommentsUnreadable", {
1537
+ reader: Schema.String,
1538
+ message: Schema.String
1539
+ }) {};
1540
+ const unreadable = (reader) => (cause) => CommentsUnreadable.make({
1541
+ reader,
1542
+ message: String(cause)
1543
+ });
1544
+ const trimmed = ({ index, text }) => ({
1545
+ index,
1546
+ text: String$1.trimEnd(text)
1547
+ });
1548
+ // src/config-comments.ts
1549
+ const NEXT$2 = 1;
1550
+ const isRecord = (value) => typeof value === "object" && value !== null;
1551
+ const childrenOf = (value) => {
1552
+ if (Array.isArray(value)) return value;
1553
+ if (isRecord(value)) return Record.values(value);
1554
+ return [];
1555
+ };
1556
+ const collect = (isItem) => (value) => {
1557
+ if (isItem(value)) return [value];
1558
+ return pipe(childrenOf(value), Array.flatMap(collect(isItem)));
1559
+ };
1560
+ const isYamlComment = (value) => isRecord(value) && value["type"] === "comment" && typeof value["offset"] === "number" && typeof value["source"] === "string";
1561
+ const yamlComments = (source) => Effect.try({
1562
+ try: () => pipe(Array.fromIterable(new Parser().parse(source)), Array.flatMap(collect(isYamlComment)), Array.map((token) => trimmed({
1563
+ index: token.offset,
1564
+ text: token.source
1565
+ }))),
1566
+ catch: unreadable("yaml")
1567
+ });
1568
+ const tomlComments = (source) => Effect.try({
1569
+ try: () => pipe(parseTOML(source).comments, Array.map(({ range: [start, end] }) => trimmed({
1570
+ index: start,
1571
+ text: String$1.slice(start, end)(source)
1572
+ }))),
1573
+ catch: unreadable("toml")
1574
+ });
1575
+ const isSqlComment = (value) => isRecord(value) && (value["type"] === "line_comment" || value["type"] === "block_comment") && typeof value["text"] === "string" && Array.isArray(value["range"]);
1576
+ const sqlComments = (source) => Effect.try({
1577
+ try: () => {
1578
+ const program = parse$2(source, {
1579
+ dialect: "sqlite",
1580
+ includeComments: true,
1581
+ includeRange: true,
1582
+ paramTypes: []
1583
+ });
1584
+ return pipe(collect(isSqlComment)(program), Array.map(({ range: [start], text }) => trimmed({
1585
+ index: start,
1586
+ text
1587
+ })));
1588
+ },
1589
+ catch: unreadable("sql")
1590
+ });
1591
+ const offsetAt = (lines) => ({ line, character }) => character + pipe(lines, Array.take(line), Array.map((text) => text.length + NEXT$2), Number$1.sumAll);
1592
+ const dockerfileComments = (source) => Effect.try({
1593
+ try: () => {
1594
+ const lines = String$1.split(source, "\n");
1595
+ return pipe(DockerfileParser.parse(source).getComments(), Array.map((comment) => trimmed({
1596
+ index: offsetAt(lines)(comment.getRange().start),
1597
+ text: comment.toString()
1598
+ })));
1599
+ },
1600
+ catch: unreadable("dockerfile")
1601
+ });
1602
+ // src/comment-readers.ts
1603
+ const GRAMMARS = [
1604
+ "bash",
1605
+ "c-sharp",
1606
+ "cpp",
1607
+ "css",
1608
+ "go",
1609
+ "java",
1610
+ "javascript",
1611
+ "php",
1612
+ "powershell",
1613
+ "ruby",
1614
+ "rust",
1615
+ "tsx",
1616
+ "typescript"
1617
+ ];
1618
+ const COMMENT_NODES = [
1619
+ "comment",
1620
+ "line_comment",
1621
+ "block_comment",
1622
+ "multiline_comment"
1623
+ ];
1624
+ const START$2 = 0;
1625
+ const NEXT$1 = 1;
1626
+ const NONE$1 = [];
1627
+ const grammarFile = (grammar) => fileURLToPath(import.meta.resolve(`@vscode/tree-sitter-wasm/wasm/tree-sitter-${grammar}.wasm`));
1628
+ const loadGrammar = (grammar) => Effect.tryPromise({
1629
+ try: () => treeSitter.Language.load(grammarFile(grammar)),
1630
+ catch: unreadable(grammar)
1631
+ }).pipe(Effect.map((language) => [grammar, language]));
1632
+ const loadGrammars = Effect.fn("loadGrammars")(function* loadGrammars() {
1633
+ yield* Effect.tryPromise({
1634
+ try: () => treeSitter.Parser.init(),
1635
+ catch: unreadable("javascript")
1636
+ });
1637
+ const loaded = yield* pipe(GRAMMARS, Effect.forEach((grammar) => loadGrammar(grammar)));
1638
+ const languages = Record.fromEntries(loaded);
1639
+ const grammars = (grammar) => Record.get(languages, grammar);
1640
+ return grammars;
1641
+ });
1642
+ const commentNodesIn = (language, source) => {
1643
+ const parser = new treeSitter.Parser();
1644
+ parser.setLanguage(language);
1645
+ const tree = parser.parse(source);
1646
+ parser.delete();
1647
+ if (tree === null) return NONE$1;
1648
+ const found = pipe(tree.rootNode.descendantsOfType(COMMENT_NODES), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.map((node) => trimmed({
1649
+ index: node.startIndex,
1650
+ text: node.text
1651
+ })));
1652
+ tree.delete();
1653
+ return found;
1654
+ };
1655
+ const syntaxComments = (grammars, grammar) => (source) => Option.match(grammars(grammar), {
1656
+ onNone: () => Effect.fail(unreadable(grammar)("the grammar is not loaded")),
1657
+ onSome: (language) => Effect.try({
1658
+ try: () => commentNodesIn(language, source),
1659
+ catch: unreadable(grammar)
1660
+ })
1661
+ });
1662
+ const SCRIPT_TYPE = /^(?:|module|text\/javascript|application\/javascript)$/iu;
1663
+ const SHADER_TYPE = /shader|glsl/iu;
1664
+ const scriptGrammar = (attribs) => {
1665
+ const type = String$1.trim(Option.getOrElse(Record.get(attribs, "type"), () => ""));
1666
+ if (Record.get(attribs, "lang").pipe(Option.contains("ts"))) return Option.some("typescript");
1667
+ if (SHADER_TYPE.test(type)) return Option.some("cpp");
1668
+ return Option.liftPredicate("javascript", () => SCRIPT_TYPE.test(type));
1669
+ };
1670
+ const embeddedGrammar = ({ name, attribs }) => {
1671
+ if (name === "style") return Option.some("css");
1672
+ if (name === "script") return scriptGrammar(attribs);
1673
+ return Option.none();
1674
+ };
1675
+ const shifted = (offset) => ({ index, text }) => ({
1676
+ index: index + offset,
1677
+ text
1678
+ });
1679
+ const markupComment = (source) => (node) => {
1680
+ if (!isComment(node) || node.startIndex === null || node.endIndex === null) return NONE$1;
1681
+ return [{
1682
+ index: node.startIndex,
1683
+ text: String$1.slice(node.startIndex, node.endIndex + NEXT$1)(source)
1684
+ }];
1685
+ };
1686
+ const textComments = (grammars, grammar) => (text) => {
1687
+ const shift = shifted(text.startIndex ?? START$2);
1688
+ return syntaxComments(grammars, grammar)(text.data).pipe(Effect.map(Array.map(shift)));
1689
+ };
1690
+ const embeddedComments = (grammars) => (node) => {
1691
+ if (!isTag(node)) return Effect.succeed(NONE$1);
1692
+ const texts = pipe(node.children, Array.filter(isText));
1693
+ return Option.match(embeddedGrammar(node), {
1694
+ onNone: () => Effect.succeed(NONE$1),
1695
+ onSome: (grammar) => pipe(texts, Effect.forEach(textComments(grammars, grammar)), Effect.map(Array.flatten))
1696
+ });
1697
+ };
1698
+ const markupComments = (grammars, markup) => (source) => Effect.gen(function* readMarkup() {
1699
+ const document = parseDocument$1(source, {
1700
+ xmlMode: markup === "xml",
1701
+ withStartIndices: true,
1702
+ withEndIndices: true
1703
+ });
1704
+ const nodes = DomUtils.filter(() => true, document.children, true);
1705
+ const own = pipe(nodes, Array.flatMap(markupComment(source)));
1706
+ if (markup === "xml") return own;
1707
+ const embedded = yield* pipe(nodes, Effect.forEach(embeddedComments(grammars)));
1708
+ return [...own, ...Array.flatten(embedded)];
1709
+ });
1710
+ const isGrammar = (reader) => pipe(GRAMMARS, Array.contains(reader));
1711
+ const commentsWith = (grammars) => (reader, source) => {
1712
+ if (isGrammar(reader)) return syntaxComments(grammars, reader)(source);
1713
+ return {
1714
+ html: markupComments(grammars, "html"),
1715
+ xml: markupComments(grammars, "xml"),
1716
+ yaml: yamlComments,
1717
+ toml: tomlComments,
1718
+ sql: sqlComments,
1719
+ dockerfile: dockerfileComments
1720
+ }[reader](source);
1721
+ };
1722
+ // src/comments.ts
1723
+ const RULE$4 = "comment";
1724
+ const CONFIG_FILE$3 = "vite.config.ts";
1725
+ const VENDORED_PATHSPEC = ":(attr:linguist-vendored)";
1726
+ const READ_CONCURRENCY$4 = 64;
1727
+ const START$1 = 0;
1728
+ const FIRST_LINE$1 = 1;
1729
+ const FIRST_COLUMN$1 = 1;
1730
+ const READERS = [
1731
+ [/\.(?:[cm]?jsx?)$/u, "javascript"],
1732
+ [/\.(?:[cm]?ts)$/u, "typescript"],
1733
+ [/\.tsx$/u, "tsx"],
1734
+ [/\.rs$/u, "rust"],
1735
+ [/\.(?:cs|csx)$/u, "c-sharp"],
1736
+ [/\.(?:sh|bash|zsh|ksh)$/u, "bash"],
1737
+ [/(?:^|\/)\.(?:vite-hooks|husky|githooks)\/[^./][^/]*$/u, "bash"],
1738
+ [/\.(?:ps1|psm1|psd1)$/u, "powershell"],
1739
+ [/\.go$/u, "go"],
1740
+ [/\.(?:java|kt|kts)$/u, "java"],
1741
+ [/\.(?:rb|rake)$/u, "ruby"],
1742
+ [/\.php$/u, "php"],
1743
+ [/\.(?:c|h|cc|cpp|cxx|hpp|hh|m|mm|glsl|frag|vert|comp|wgsl|hlsl|metal)$/u, "cpp"],
1744
+ [/\.(?:css|pcss)$/u, "css"],
1745
+ [/\.(?:html?|vue|svelte|astro)$/u, "html"],
1746
+ [/\.(?:xml|xaml|plist|resx|props|targets|[a-z]+proj|manifest|nuspec)$/u, "xml"],
1747
+ [/\.ya?ml$/u, "yaml"],
1748
+ [/\.toml$/u, "toml"],
1749
+ [/\.sql$/u, "sql"],
1750
+ [/(?:^|\/)(?:Dockerfile|Containerfile)(?:\.[^/]+)?$|\.dockerfile$/u, "dockerfile"]
1751
+ ];
1752
+ const SHEBANG_READERS = [
1753
+ [/^#!.*\b(?:ba|z|k|da)?sh\b/u, "bash"],
1754
+ [/^#!.*\b(?:node|bun|deno|tsx)\b/u, "javascript"],
1755
+ [/^#!.*\bpwsh\b/u, "powershell"]
1756
+ ];
1757
+ const SHEBANG = "#!";
1758
+ const PIN = /@(?:[0-9a-f]{40}|sha256:[0-9a-f]{64})\s*$/u;
1759
+ const VERSION = /^\s?v?\d[\w.+-]*$/u;
1760
+ const DELIMITERS = /^(?:\/\/|\/\*|<!--|<#|#|--)|(?:\*\/|-->|#>)$/gu;
1761
+ const MESSAGE = "Comments are not written in this repository. Say it with names and types in the code, put the reason in the commit message, and delete the comment.";
1762
+ const Patterns = Schema.Array(Schema.String);
1763
+ const CommentSettings = Schema.Struct({ allow: Patterns });
1764
+ const MschSettings = Schema.Struct({ comments: Schema.optional(CommentSettings) });
1765
+ const LintSettings = Schema.Struct({ ignorePatterns: Schema.optional(Patterns) });
1766
+ const RootConfig = Schema.Struct({
1767
+ msch: Schema.optional(MschSettings),
1768
+ lint: Schema.optional(LintSettings)
1769
+ });
1770
+ const NO_SETTINGS = {
1771
+ allow: [],
1772
+ ignorePatterns: []
1773
+ };
1774
+ const NONE = [];
1775
+ const taggedError$1 = Schema.TaggedError;
1776
+ var CommentConfigUnreadable = class extends taggedError$1()("CommentConfigUnreadable", { file: Schema.String }) {};
1777
+ const shebangReader = (source) => {
1778
+ if (!String$1.startsWith(SHEBANG)(source)) return Option.none();
1779
+ return pipe(SHEBANG_READERS, Array.findFirst(([pattern]) => pattern.test(source)));
1780
+ };
1781
+ const readerOf = (name, source) => pipe(READERS, Array.findFirst(([pattern]) => pattern.test(name)), Option.orElse(() => shebangReader(source)), Option.map(([, reader]) => reader));
1782
+ const valueOf = (text) => String$1.replaceAll(DELIMITERS, "")(text);
1783
+ const lineBefore = (source, index) => {
1784
+ const lines = pipe(source, String$1.slice(START$1, index), String$1.split("\n"));
1785
+ return Option.getOrElse(Array.last(lines), () => "");
1786
+ };
1787
+ const isPinVersion = (source, { index, text }) => PIN.test(lineBefore(source, index)) && VERSION.test(valueOf(text));
1788
+ const isShebang = ({ index, text }) => index === START$1 && String$1.startsWith(SHEBANG)(text);
1789
+ const isAllowed = (source, directives) => (comment) => isShebang(comment) || directives.test(valueOf(comment.text)) || isPinVersion(source, comment);
1790
+ const problemOf$1 = (file, source) => ({ index }) => ({
1791
+ file,
1792
+ ...positionOf(source)(index),
1793
+ rule: RULE$4,
1794
+ message: MESSAGE
1795
+ });
1796
+ const unreadableProblem = (file, message) => ({
1797
+ file,
1798
+ line: FIRST_LINE$1,
1799
+ column: FIRST_COLUMN$1,
1800
+ rule: RULE$4,
1801
+ message: `msch could not read the comments in this file: ${message}`
1802
+ });
1803
+ const settingsOf = ({ msch, lint }) => ({
1804
+ allow: pipe(Option.fromUndefinedOr(msch), Option.flatMap(({ comments }) => Option.fromUndefinedOr(comments)), Option.match({
1805
+ onNone: () => NO_SETTINGS.allow,
1806
+ onSome: ({ allow }) => allow
1807
+ })),
1808
+ ignorePatterns: pipe(Option.fromUndefinedOr(lint), Option.flatMap(({ ignorePatterns }) => Option.fromUndefinedOr(ignorePatterns)), Option.getOrElse(() => NO_SETTINGS.ignorePatterns))
1809
+ });
1810
+ const rootSettings = Effect.fn("rootSettings")(function* rootSettings(root) {
1811
+ const files = yield* RepositoryFiles;
1812
+ const file = files.join(root, CONFIG_FILE$3);
1813
+ if (!(yield* files.exists(file))) return NO_SETTINGS;
1814
+ const config = yield* Effect.tryPromise({
1815
+ try: () => resolveConfigFromFile(file),
1816
+ catch: () => CommentConfigUnreadable.make({ file })
1817
+ }).pipe(Effect.option);
1818
+ return pipe(config, Option.flatMap(Schema.decodeUnknownOption(RootConfig)), Option.match({
1819
+ onNone: () => NO_SETTINGS,
1820
+ onSome: settingsOf
1821
+ }));
1822
+ });
1823
+ const directivePattern = (directives) => new RegExp(String.raw`^\s?(?:${Array.join(directives, "|")})`, "u");
1824
+ const isIgnored = (patterns) => (name) => pipe(patterns, Array.some((pattern) => path.matchesGlob(name, pattern)));
1825
+ const scannedFiles = Effect.fn("scannedFiles")(function* scannedFiles(root, settings) {
1826
+ const files = yield* RepositoryFiles;
1827
+ const listed = yield* files.listedFiles(root);
1828
+ const generated = yield* files.generatedFiles(root);
1829
+ const vendored = yield* files.matchingFiles(root, [VENDORED_PATHSPEC]);
1830
+ const skipped = HashSet.fromIterable([...generated, ...pipe(vendored, Array.map((name) => files.join(root, name)))]);
1831
+ return pipe(listed, Array.filter((name) => !isIgnored(settings.ignorePatterns)(name)), Array.map((name) => ({
1832
+ name,
1833
+ file: files.join(root, name)
1834
+ })), Array.filter(({ file }) => !HashSet.has(skipped, file)));
1835
+ });
1836
+ /** @internal */
1837
+ const checkComments = Effect.fn("checkComments")(function* checkComments(root) {
1838
+ const files = yield* RepositoryFiles;
1839
+ const settings = yield* rootSettings(root);
1840
+ const scanned = yield* scannedFiles(root, settings);
1841
+ const directives = directivePattern([...COMMENT_DIRECTIVES, ...settings.allow]);
1842
+ const grammars = yield* loadGrammars();
1843
+ const comments = commentsWith(grammars);
1844
+ const problemsIn = ({ name, file }, source) => {
1845
+ const kept = Predicate.not(isAllowed(source, directives));
1846
+ const toProblem = problemOf$1(file, source);
1847
+ return Option.match(readerOf(name, source), {
1848
+ onNone: () => Effect.succeed(NONE),
1849
+ onSome: (reader) => comments(reader, source).pipe(Effect.map(Array.filter(kept)), Effect.map(Array.map(toProblem)), Effect.catchTag("CommentsUnreadable", ({ message }) => Effect.succeed([unreadableProblem(file, message)])))
1850
+ });
1851
+ };
1852
+ const found = yield* Effect.forEach(scanned, (entry) => files.readFile(entry.file).pipe(Effect.flatMap(Option.match({
1853
+ onNone: () => Effect.succeed(NONE),
1854
+ onSome: (source) => problemsIn(entry, source)
1855
+ }))), { concurrency: READ_CONCURRENCY$4 });
1856
+ return Array.flatten(found);
1857
+ });
1858
+ // src/hidden-unicode.ts
1859
+ const HIDDEN = /[\u00AD\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]|[\u{E0000}-\u{E007F}]/gu;
1860
+ const NUL = "\0";
1861
+ const START = 0;
1862
+ const HEX = 16;
1863
+ const CODE_POINT_WIDTH = 4;
1864
+ const READ_CONCURRENCY$3 = 64;
1865
+ const RULE$3 = "hidden-unicode";
1866
+ const hexOf = (character) => pipe(String$1.codePointAt(START)(character), Option.getOrElse(() => START), (code) => code.toString(HEX), String$1.toUpperCase, String$1.padStart(CODE_POINT_WIDTH, "0"));
1867
+ const problemOf = (file, source) => (found) => {
1868
+ const hex = hexOf(found[START]);
1869
+ return {
1870
+ file,
1871
+ ...positionOf(source)(found.index ?? START),
1872
+ rule: RULE$3,
1873
+ message: `U+${hex} is invisible in editors and reviews and can change what the text means. Remove it, or write it as the escape \\u${hex}.`
1874
+ };
1875
+ };
1876
+ const problemsIn$1 = (file, source) => {
1877
+ if (String$1.includes(NUL)(source)) return [];
1878
+ return pipe(Array.fromIterable(String$1.matchAll(HIDDEN)(source)), Array.map(problemOf(file, source)));
1879
+ };
1880
+ /** @internal */
1881
+ const checkHiddenUnicode = Effect.fn("checkHiddenUnicode")(function* checkHiddenUnicode(root) {
1882
+ const files = yield* RepositoryFiles;
1883
+ const names = yield* files.listedFiles(root);
1884
+ const found = yield* Effect.forEach(names, (name) => {
1885
+ const file = files.join(root, name);
1886
+ return files.readFile(file).pipe(Effect.map(Option.match({
1887
+ onNone: () => [],
1888
+ onSome: (source) => problemsIn$1(file, source)
1889
+ })));
1890
+ }, { concurrency: READ_CONCURRENCY$3 });
1891
+ return Array.flatten(found);
1892
+ });
1500
1893
  // src/python.ts
1501
1894
  const PYTHON_FILE = /(?:\.(?:py|pyi|pyw|pyx|ipynb)|(?:^|\/)(?:pyproject\.toml|uv\.lock|uv\.toml|poetry\.lock|Pipfile|Pipfile\.lock|setup\.cfg|tox\.ini|pytest\.ini|\.python-version|requirements[^/]*\.txt))$/u;
1502
1895
  const SCANNED_FILE = /(?:\.(?:[cm]?[jt]sx?|jsonc?|toml|ya?ml|sh|bash|zsh|fish|rs|cs|go|mk)|(?:^|\/)(?:Dockerfile[^/]*|Makefile|justfile|\.tool-versions|[^./][^./]*))$/u;
@@ -1513,7 +1906,7 @@ const COMMAND_PATTERNS = [
1513
1906
  /\buses:\s*["']?(?:actions\/setup-python|astral-sh\/setup-uv|astral-sh\/ruff-action|pypa\/[\w.-]+|snok\/install-poetry|abatilo\/actions-poetry|conda-incubator\/setup-miniconda|mamba-org\/setup-micromamba|pdm-project\/setup-pdm)\b/gu
1514
1907
  ];
1515
1908
  const TOOL_PATTERNS = [/^[ \t]*["']?(?:python|uv|pipx|poetry|ruff|pdm|hatch|pipx:[^"'\s=]+)["']?[ \t]*(?:=|[ \t]+\S)/gmu];
1516
- const READ_CONCURRENCY$3 = 64;
1909
+ const READ_CONCURRENCY$2 = 64;
1517
1910
  const FIRST_LINE = 1;
1518
1911
  const FIRST_COLUMN = 1;
1519
1912
  const WHOLE_MATCH = 0;
@@ -1551,68 +1944,18 @@ const checkPython = Effect.fn("checkPython")(function* checkPython(root) {
1551
1944
  onNone: () => [],
1552
1945
  onSome: (source) => commandProblems(entry, source)
1553
1946
  })));
1554
- const scanned = yield* Effect.forEach(pipe(listed, Array.filter(isScanned)), problemsIn, { concurrency: READ_CONCURRENCY$3 });
1947
+ const scanned = yield* Effect.forEach(pipe(listed, Array.filter(isScanned)), problemsIn, { concurrency: READ_CONCURRENCY$2 });
1555
1948
  const present = yield* Effect.filter(pipe(listed, Array.filter(isPython)), ({ file }) => files.exists(file));
1556
1949
  return [...pipe(present, Array.map(fileProblem)), ...Array.flatten(scanned)];
1557
1950
  });
1558
- // src/root-readme.ts
1559
- const RULE$3 = "root-readme";
1560
- const SEPARATOR$1 = "/";
1561
- const ALTERNATIVE = "|";
1562
- const SCOPE = /^@[^/]+\//u;
1563
- const README = /^README(?:\.[^/]+)?$/iu;
1564
- const SPECIAL = /[$()*+.?[\\\]^{|}]/gu;
1565
- const READ_CONCURRENCY$2 = 16;
1566
- const START = 0;
1567
- const NamedManifest = Schema.fromJsonString(Schema.Struct({ name: Schema.optional(Schema.String) }));
1568
- const patternOf = (names) => {
1569
- const alternatives = pipe(names, Array.map(String$1.replaceAll(SPECIAL, String.raw`\$&`)));
1570
- return new RegExp(`(?<![\\p{L}\\p{N}_-])(?:${Array.join(alternatives, ALTERNATIVE)})(?![\\p{L}\\p{N}_-])`, "gu");
1571
- };
1572
- const packageNameIn = (text) => pipe(text, Option.flatMap(Schema.decodeOption(NamedManifest)), Option.flatMap((manifest) => Option.fromUndefinedOr(manifest.name)));
1573
- const workspaceIn = Effect.fn("workspaceIn")(function* workspaceIn(root, name) {
1574
- const files = yield* RepositoryFiles;
1575
- const directory = files.dirname(name);
1576
- const text = yield* files.readFile(files.join(root, name));
1577
- const packageName = packageNameIn(text);
1578
- const unscoped = pipe(packageName, Option.map(String$1.replace(SCOPE, "")));
1579
- const names = pipe([
1580
- Option.some(directory),
1581
- Option.some(files.basename(directory)),
1582
- packageName,
1583
- unscoped
1584
- ], Array.getSomes, Array.dedupe);
1585
- return {
1586
- directory,
1587
- pattern: patternOf(names)
1588
- };
1589
- });
1590
- const messageFor = (directory) => `names the workspace ${directory}. The root README describes the repository as a whole. Write what belongs to the workspace in ${directory}/README.md.`;
1591
- const problemsIn$1 = (file, source) => ({ directory, pattern }) => {
1592
- const message = messageFor(directory);
1593
- const at = positionOf(source);
1594
- return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
1595
- file,
1596
- ...at(found.index ?? START),
1597
- rule: RULE$3,
1598
- message
1599
- })));
1600
- };
1601
- const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadme(file, workspaces) {
1602
- const text = yield* (yield* RepositoryFiles).readFile(file);
1603
- return pipe(text, Option.match({
1604
- onNone: () => [],
1605
- onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$1(file, source)))
1606
- }));
1607
- });
1951
+ // src/tracked-text.ts
1608
1952
  /** @internal */
1609
- const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(root) {
1610
- const files = yield* RepositoryFiles;
1611
- const names = yield* files.listedFiles(root);
1612
- const readmes = pipe(names, Array.filter((name) => README.test(name)));
1613
- const manifests = pipe(names, Array.filter((name) => String$1.includes(SEPARATOR$1)(name) && files.basename(name) === "package.json"));
1614
- const workspaces = yield* Effect.forEach(manifests, (name) => workspaceIn(root, name), { concurrency: READ_CONCURRENCY$2 });
1615
- const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$2 });
1953
+ const checkTrackedText = Effect.fn("checkTrackedText")(function* checkTrackedText(root) {
1954
+ const found = yield* Effect.all([
1955
+ checkHiddenUnicode(root),
1956
+ checkPython(root),
1957
+ checkComments(root)
1958
+ ], { concurrency: "unbounded" });
1616
1959
  return Array.flatten(found);
1617
1960
  });
1618
1961
  // src/crates.ts
@@ -1725,7 +2068,7 @@ const stringsIn = (node) => {
1725
2068
  return [...pipe(decodeStringNode(node), Option.map((found) => ({
1726
2069
  text: textOf(found),
1727
2070
  start: found.start
1728
- })), Option.toArray), ...pipe(childrenOf$2(node), Array.flatMap(stringsIn))];
2071
+ })), Option.toArray), ...pipe(childrenOf$3(node), Array.flatMap(stringsIn))];
1729
2072
  };
1730
2073
  const isBoundary = (character, allowed) => character === "" || !allowed.test(character);
1731
2074
  const mentions = (directory) => (text) => {
@@ -1769,8 +2112,7 @@ const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
1769
2112
  const found = yield* Effect.all([
1770
2113
  checkRepository(root),
1771
2114
  checkOverrides(root),
1772
- checkHiddenUnicode(root),
1773
- checkPython(root),
2115
+ checkTrackedText(root),
1774
2116
  checkNestedDocs(root),
1775
2117
  checkRootReadme(root),
1776
2118
  checkPublishedPackages(root),