@r_masseater/msch 0.15.0 → 0.16.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,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { $ as isTypeLiteralNode, A as isArrayLiteralExpression, B as isModuleBlock, C as IndexKind, D as getLeadingCommentRanges, E as getJSDocTags, F as isEnumDeclaration, G as isPropertyAccessExpression, H as isNewExpression, I as isExportDeclaration, J as isSignatureDeclaration, K as isPropertyAssignment, L as isIdentifier, M as isCallExpression, N as isClassDeclaration, O as getNameOfDeclaration, P as isElementAccessExpression, Q as isTypeAliasDeclaration, R as isImportDeclaration, S as API, T as SyntaxKind, U as isNumericLiteral, V as isModuleDeclaration, W as isObjectLiteralExpression, X as isSpreadElement, Y as isSourceFile, Z as isStringLiteral, _ as propertyNamesOf, a as sortProblems, b as symbolAt, c as columnOf, d as descendantsOf, et as isTypeReferenceNode, f as importedModulesOf, g as lineOf, h as isTypeDeclaration, i as problemAt, it as isVariableStatement, j as isBinaryExpression, k as getTextOfJSDocComment, l as contains, m as isGenericDeclaration, nt as isVariableDeclaration, o as NODE_MODULES_SEGMENT, p as isExternalDeclaration, q as isSatisfiesExpression, r as formatProblem, rt as isVariableDeclarationList, s as childrenOf$2, t as ProblemList, tt as isUnionTypeNode, u as declarationsOf, v as referencedSymbols, w as InternalSymbolName, x as uniqueByReference, y as resolvedSymbol, z as isInterfaceDeclaration } from "./problem-PUlrIOu9.mjs";
2
+ import { $ as isReturnStatement, A as getTextOfJSDocComment, B as isFunctionDeclaration, C as IndexKind, D as getJSDocTags, E as SyntaxKind, F as isCallExpression, G as isModuleBlock, H as isIdentifier, I as isClassDeclaration, J as isNumericLiteral, K as isModuleDeclaration, L as isElementAccessExpression, M as isArrowFunction, N as isBinaryExpression, O as getLeadingCommentRanges, P as isBlock, Q as isPropertyAssignment, R as isEnumDeclaration, S as API, T as SignatureKind, U as isImportDeclaration, V as isFunctionExpression, W as isInterfaceDeclaration, X as isParenthesizedExpression, Y as isObjectLiteralExpression, Z as isPropertyAccessExpression, _ as propertyNamesOf, a as sortProblems, at as isTypeAliasDeclaration, b as symbolAt, c as columnOf, ct as isUnionTypeNode, d as descendantsOf, dt as isVariableStatement, et as isSatisfiesExpression, f as importedModulesOf, g as lineOf, h as isTypeDeclaration, i as problemAt, it as isStringLiteral, j as isArrayLiteralExpression, k as getNameOfDeclaration, l as contains, lt as isVariableDeclaration, m as isGenericDeclaration, nt as isSourceFile, o as NODE_MODULES_SEGMENT, ot as isTypeLiteralNode, p as isExternalDeclaration, q as isNewExpression, r as formatProblem, rt as isSpreadElement, s as childrenOf$2, st as isTypeReferenceNode, t as ProblemList, tt as isSignatureDeclaration, u as declarationsOf, ut as isVariableDeclarationList, v as referencedSymbols, w as InternalSymbolName, x as uniqueByReference, y as resolvedSymbol, z as isExportDeclaration } from "./problem-xi8VIKs3.mjs";
3
3
  import { i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-BiKs7S7N.mjs";
4
4
  import { C as publishedWorkspaces, D as readManifest, E as dependencyEntries, O as workspaceDependencies, T as MANIFEST_FILE, _ as childrenOf$3, a as hasVerifyTask, b as nestedValues, g as KeySchema, h as workspaceConfigOf, i as definesTask, l as workspaceDirectories, r as VERIFY_TASK, t as namedWorkspaces, v as keyName, w as publicEntriesOf, y as literalOf } from "./workspace-aMPb8EA_.mjs";
5
5
  import { t as COMMENT_DIRECTIVES } from "./comment-directives-WcDqvLwJ.mjs";
@@ -1003,12 +1003,115 @@ const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root
1003
1003
  if (Option.isNone(manifest) || !Array.isReadonlyArrayNonEmpty(keys)) return [];
1004
1004
  return yield* problemsFor(root, manifest.value, keys);
1005
1005
  });
1006
+ // src/features/pass-through-wrappers/model/pass-through-wrappers.ts
1007
+ const RULE$14 = "pass-through-wrapper";
1008
+ const SINGLE_STATEMENT = 1;
1009
+ const SINGLE_DECLARATION = 1;
1010
+ const THIS_PARAMETER = "this";
1011
+ const NO_ARGUMENTS = [];
1012
+ const messageOf = (callee) => `This function only passes its parameters to ${callee} unchanged. Call ${callee} directly and delete this function.`;
1013
+ const unwrapped = (expression) => {
1014
+ if (isParenthesizedExpression(expression)) return unwrapped(expression.expression);
1015
+ return expression;
1016
+ };
1017
+ const isWrapperExpression = (expression) => isArrowFunction(expression) || isFunctionExpression(expression);
1018
+ const candidateOf = (node) => {
1019
+ if (isFunctionDeclaration(node)) return pipe(Option.fromUndefinedOr(node.name), Option.map((name) => ({
1020
+ name,
1021
+ wrapper: node
1022
+ })));
1023
+ if (!isVariableDeclaration(node) || !isIdentifier(node.name)) return Option.none();
1024
+ const { name } = node;
1025
+ return pipe(Option.fromUndefinedOr(node.initializer), Option.map(unwrapped), Option.filter(isWrapperExpression), Option.map((wrapper) => ({
1026
+ name,
1027
+ wrapper
1028
+ })));
1029
+ };
1030
+ const changesTheCall = (wrapper) => Predicate.isNotUndefined(wrapper.asteriskToken) || Option.exists(Option.fromUndefinedOr(wrapper.type), (type) => type.kind === SyntaxKind.TypePredicate) || pipe(wrapper.modifiers ?? [], Array.some((modifier) => modifier.kind === SyntaxKind.AsyncKeyword));
1031
+ const returnedExpression = (wrapper) => {
1032
+ const { body } = wrapper;
1033
+ if (Predicate.isUndefined(body)) return Option.none();
1034
+ if (!isBlock(body)) return Option.some(body);
1035
+ if (body.statements.length !== SINGLE_STATEMENT) return Option.none();
1036
+ return pipe(Array.head(body.statements), Option.filter((statement) => isReturnStatement(statement)), Option.flatMap((statement) => Option.fromUndefinedOr(statement.expression)));
1037
+ };
1038
+ const callForward = (call) => ({
1039
+ node: call,
1040
+ callee: call.expression,
1041
+ kind: SignatureKind.Call,
1042
+ arguments: call.arguments,
1043
+ typed: Predicate.isNotUndefined(call.typeArguments),
1044
+ optional: Predicate.isNotUndefined(call.questionDotToken)
1045
+ });
1046
+ const forwardOf = (expression) => {
1047
+ const inner = unwrapped(expression);
1048
+ if (isCallExpression(inner)) return Option.some(callForward(inner));
1049
+ if (isNewExpression(inner)) return Option.some({
1050
+ node: inner,
1051
+ callee: inner.expression,
1052
+ kind: SignatureKind.Construct,
1053
+ arguments: inner.arguments ?? NO_ARGUMENTS,
1054
+ typed: Predicate.isNotUndefined(inner.typeArguments),
1055
+ optional: false
1056
+ });
1057
+ return Option.none();
1058
+ };
1059
+ const rootOf = (callee) => {
1060
+ if (isIdentifier(callee)) return Option.some(callee);
1061
+ if (isPropertyAccessExpression(callee) && Predicate.isUndefined(callee.questionDotToken) && isIdentifier(callee.name)) return rootOf(callee.expression);
1062
+ return Option.none();
1063
+ };
1064
+ const parameterName = (parameter) => {
1065
+ const { name } = parameter;
1066
+ if (!isIdentifier(name) || Predicate.isNotUndefined(parameter.initializer) || name.text === THIS_PARAMETER) return Option.none();
1067
+ return Option.some(name.text);
1068
+ };
1069
+ const isRest = (parameter) => Predicate.isNotUndefined(parameter.dotDotDotToken);
1070
+ const forwardsParameter = ([parameter, name, argument]) => {
1071
+ if (!isRest(parameter)) return isIdentifier(argument) && argument.text === name;
1072
+ return isSpreadElement(argument) && isIdentifier(argument.expression) && argument.expression.text === name;
1073
+ };
1074
+ const forwardedNames = (wrapper, forward) => {
1075
+ const { parameters } = wrapper;
1076
+ const names = pipe(parameters, Array.map(parameterName), Array.getSomes);
1077
+ if (names.length !== parameters.length || forward.arguments.length !== parameters.length) return Option.none();
1078
+ const triples = Array.zipWith(Array.zip(parameters, names), forward.arguments, ([parameter, name], argument) => [
1079
+ parameter,
1080
+ name,
1081
+ argument
1082
+ ]);
1083
+ return pipe(Option.some(names), Option.filter(() => pipe(triples, Array.every(forwardsParameter))));
1084
+ };
1085
+ const calleeTakesExactly = (checker) => (forward, count) => {
1086
+ const signatures = checker.getSignaturesOfType(checker.getTypeAtLocation(forward.callee), forward.kind);
1087
+ return Array.isReadonlyArrayNonEmpty(signatures) && pipe(signatures, Array.every((signature) => !signature.hasRestParameter && signature.parameters.length === count && !Array.isReadonlyArrayNonEmpty(signature.typeParameters ?? [])));
1088
+ };
1089
+ const keepsTheReturnType = (checker) => (wrapper, forward) => Option.match(Option.fromUndefinedOr(wrapper.type), {
1090
+ onNone: () => true,
1091
+ onSome: (type) => checker.getTypeAtLocation(type).id === checker.getTypeAtLocation(forward.node).id
1092
+ });
1093
+ const isOverloaded = (checker) => (name) => Option.exists(Option.fromUndefinedOr(checker.getSymbolAtLocation(name)), (symbol) => symbol.declarations.length > SINGLE_DECLARATION);
1094
+ const callsAnotherFunction = ({ name }, forward, names) => Option.exists(rootOf(forward.callee), (root) => root.text !== name.text && !names.includes(root.text));
1095
+ const isPassThrough = (checker) => (candidate) => (forward) => {
1096
+ const { wrapper, name } = candidate;
1097
+ if (forward.typed || forward.optional) return false;
1098
+ const restForwarded = pipe(wrapper.parameters, Array.some(isRest));
1099
+ return Option.exists(forwardedNames(wrapper, forward), (names) => callsAnotherFunction(candidate, forward, names)) && (restForwarded || calleeTakesExactly(checker)(forward, wrapper.parameters.length)) && keepsTheReturnType(checker)(wrapper, forward) && !isOverloaded(checker)(name);
1100
+ };
1101
+ const problemOf$3 = (checker) => (candidate) => {
1102
+ if (changesTheCall(candidate.wrapper)) return Option.none();
1103
+ return pipe(returnedExpression(candidate.wrapper), Option.flatMap(forwardOf), Option.filter(isPassThrough(checker)(candidate)), Option.map((forward) => problemAt({
1104
+ rule: RULE$14,
1105
+ message: messageOf(forward.callee.getText())
1106
+ })(candidate.name)));
1107
+ };
1108
+ const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$3(checker)), Array.getSomes);
1006
1109
  // src/features/placement/model/agent-docs-length.ts
1007
1110
  const AGENT_DOC = /(?:^|\/)(?:AGENTS|CLAUDE)\.md$/u;
1008
1111
  const RECOMMENDED_LINES = 200;
1009
1112
  const READ_CONCURRENCY$12 = 16;
1010
1113
  const FIRST$7 = 1;
1011
- const RULE$12 = "agent-docs-length";
1114
+ const RULE$13 = "agent-docs-length";
1012
1115
  const lineCount = (source) => pipe(String$1.trimEnd(source), String$1.split("\n")).length;
1013
1116
  const problemFor$4 = (file) => (lines) => {
1014
1117
  if (lines <= RECOMMENDED_LINES) return Option.none();
@@ -1016,7 +1119,7 @@ const problemFor$4 = (file) => (lines) => {
1016
1119
  file,
1017
1120
  line: 201,
1018
1121
  column: FIRST$7,
1019
- rule: RULE$12,
1122
+ rule: RULE$13,
1020
1123
  message: `has ${String(lines)} lines. Claude Code recommends under ${String(RECOMMENDED_LINES)} lines per file: longer files cost context and are followed less reliably. Cut what the code already tells, and move rules shared across repositories into skills.`
1021
1124
  });
1022
1125
  };
@@ -1032,7 +1135,7 @@ const checkAgentDocsLength = Effect.fn("checkAgentDocsLength")(function* checkAg
1032
1135
  return Array.getSomes(found);
1033
1136
  });
1034
1137
  // src/features/placement/model/colocated-tests.ts
1035
- const RULE$11 = "colocated-test";
1138
+ const RULE$12 = "colocated-test";
1036
1139
  const FIRST$6 = 1;
1037
1140
  const READ_CONCURRENCY$11 = 64;
1038
1141
  const ROOT_SUBPATH = ".";
@@ -1058,7 +1161,7 @@ const problemFor$3 = (test, message) => ({
1058
1161
  file: test.file,
1059
1162
  line: FIRST$6,
1060
1163
  column: FIRST$6,
1061
- rule: RULE$11,
1164
+ rule: RULE$12,
1062
1165
  message: `${test.base} ${message}`
1063
1166
  });
1064
1167
  const groupsOf$1 = (source, pattern, group) => pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((match) => pipe(Option.fromUndefinedOr(match.groups), Option.flatMap((groups) => Option.fromUndefinedOr(groups[group])))), Array.getSomes);
@@ -1124,7 +1227,7 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
1124
1227
  return Array.getSomes(found);
1125
1228
  });
1126
1229
  // src/features/placement/model/nested-docs.ts
1127
- const RULE$10 = "nested-docs";
1230
+ const RULE$11 = "nested-docs";
1128
1231
  const CONFIG_FILE$4 = "vite.config.ts";
1129
1232
  const SEPARATOR$4 = "/";
1130
1233
  const FIRST$5 = 1;
@@ -1140,7 +1243,7 @@ const problemFor$2 = (file, message) => ({
1140
1243
  file,
1141
1244
  line: FIRST$5,
1142
1245
  column: FIRST$5,
1143
- rule: RULE$10,
1246
+ rule: RULE$11,
1144
1247
  message
1145
1248
  });
1146
1249
  const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
@@ -1190,7 +1293,7 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
1190
1293
  return Array.getSomes(found);
1191
1294
  });
1192
1295
  // src/features/placement/model/root-readme.ts
1193
- const RULE$9 = "root-readme";
1296
+ const RULE$10 = "root-readme";
1194
1297
  const ROOT_DOC = /^(?:README(?:\.[^/]+)?|AGENTS\.md|CLAUDE\.md)$/iu;
1195
1298
  const READ_CONCURRENCY$9 = 16;
1196
1299
  const START$5 = 0;
@@ -1203,7 +1306,7 @@ const problemsIn$4 = (file, source) => ({ directory, pattern }) => {
1203
1306
  return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
1204
1307
  file,
1205
1308
  ...at(found.index ?? START$5),
1206
- rule: RULE$9,
1309
+ rule: RULE$10,
1207
1310
  message
1208
1311
  })));
1209
1312
  };
@@ -1236,7 +1339,7 @@ const checkPlacement = Effect.fn("checkPlacement")(function* checkPlacement(root
1236
1339
  return Array.flatten(found);
1237
1340
  });
1238
1341
  // src/features/repository-layout/model/crates.ts
1239
- const RULE$8 = "unverified-crate";
1342
+ const RULE$9 = "unverified-crate";
1240
1343
  const CARGO_FILE = "Cargo.toml";
1241
1344
  const CONFIG_FILE$3 = "vite.config.ts";
1242
1345
  const SEPARATOR$3 = "/";
@@ -1274,7 +1377,7 @@ const problemFor$1 = (crate, message) => ({
1274
1377
  file: crate.manifest,
1275
1378
  line: FIRST$4,
1276
1379
  column: FIRST$4,
1277
- rule: RULE$8,
1380
+ rule: RULE$9,
1278
1381
  message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
1279
1382
  });
1280
1383
  const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
@@ -1294,7 +1397,7 @@ const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
1294
1397
  return Array.getSomes(found);
1295
1398
  });
1296
1399
  // src/features/repository-layout/model/hidden-verify.ts
1297
- const RULE$7 = "hidden-verify";
1400
+ const RULE$8 = "hidden-verify";
1298
1401
  const CONFIG_FILE$2 = "vite.config.ts";
1299
1402
  const FIRST$3 = 1;
1300
1403
  const READ_CONCURRENCY$7 = 8;
@@ -1308,7 +1411,7 @@ const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
1308
1411
  file,
1309
1412
  line: FIRST$3,
1310
1413
  column: FIRST$3,
1311
- rule: RULE$7,
1414
+ rule: RULE$8,
1312
1415
  message: `${directory} gets its verify task from code outside ${CONFIG_FILE$2}. The root verify reads ${CONFIG_FILE$2} without running it, so it never runs this verify. Write run.tasks.verify in ${directory}/${CONFIG_FILE$2}.`
1313
1416
  }).pipe(Option.filter(() => verified));
1314
1417
  });
@@ -1319,7 +1422,7 @@ const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVe
1319
1422
  return Array.getSomes(found);
1320
1423
  });
1321
1424
  // src/features/repository-layout/model/root-workspace-paths.ts
1322
- const RULE$6 = "root-workspace-path";
1425
+ const RULE$7 = "root-workspace-path";
1323
1426
  const CONFIG_FILE$1 = "vite.config.ts";
1324
1427
  const PATH_CHARACTER = /[\w.@/-]/u;
1325
1428
  const NAME_CHARACTER = /[\w.@-]/u;
@@ -1358,7 +1461,7 @@ const mentions = (directory) => (text) => {
1358
1461
  const problemsIn$3 = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
1359
1462
  file,
1360
1463
  ...positionOf(source)(found.start),
1361
- rule: RULE$6,
1464
+ rule: RULE$7,
1362
1465
  message: `${directory} is a workspace. The root ${CONFIG_FILE$1} holds what applies to every workspace, so move what only ${directory} needs into ${directory}/${CONFIG_FILE$1}: msch.lint, msch.devDependencies or its verify task.`
1363
1466
  })));
1364
1467
  /** @internal */
@@ -1372,7 +1475,7 @@ const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* c
1372
1475
  return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$3(file, source.value, directories)));
1373
1476
  });
1374
1477
  // src/features/repository-layout/model/shared-uncached-tasks.ts
1375
- const RULE$5 = "shared-uncached-task";
1478
+ const RULE$6 = "shared-uncached-task";
1376
1479
  const TASKS_PATH = ["run", "tasks"];
1377
1480
  const READ_CONCURRENCY$6 = 8;
1378
1481
  const SHARED = 2;
@@ -1429,7 +1532,7 @@ const problemsOf = (definitions) => {
1429
1532
  return pipe(definitions, Array.map(({ file, position, name, command }) => ({
1430
1533
  file,
1431
1534
  ...position,
1432
- rule: RULE$5,
1535
+ rule: RULE$6,
1433
1536
  message: `The uncached task ${name} (${command}) is written the same way in ${Array.join(directories, ", ")}. Write it once in a shared helper and spread it into each run.tasks, so that a change to it reaches every workspace.`
1434
1537
  })));
1435
1538
  };
@@ -1575,7 +1678,7 @@ const outputPathsOf = (step) => pipe(stringOf(pathInputOf(step)), Option.toArray
1575
1678
  /** @internal */
1576
1679
  const producedPaths = (source) => pipe(jobsOf(source), Array.flatMap(([, job]) => itemsOf(childOf("steps")(job))), Array.flatMap(outputPathsOf));
1577
1680
  // src/features/repository-layout/model/workflow-paths.ts
1578
- const RULE$4 = "workflow-path";
1681
+ const RULE$5 = "workflow-path";
1579
1682
  const WORKFLOW_DIRECTORY = ".github/workflows/";
1580
1683
  const WORKFLOW_EXTENSIONS = [".yml", ".yaml"];
1581
1684
  const READ_CONCURRENCY$5 = 8;
@@ -1641,7 +1744,7 @@ const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, fou
1641
1744
  const problemOf$2 = (file, source) => (found) => ({
1642
1745
  file,
1643
1746
  ...positionOf(source)(found.offset),
1644
- rule: RULE$4,
1747
+ rule: RULE$5,
1645
1748
  message: `${found.field} names ${found.path}, which is not ${EXPECTED[found.kind]} in this repository. Point it at a path that exists or remove it.`
1646
1749
  });
1647
1750
  const problemsIn$2 = Effect.fn("problemsIn")(function* problemsIn(root, workflow) {
@@ -1678,8 +1781,8 @@ const EXTENSION = /\.[^./]+$/u;
1678
1781
  const SETTINGS_FILE = ".claude/settings.json";
1679
1782
  const READ_CONCURRENCY$4 = 64;
1680
1783
  const FIRST = 1;
1681
- const RULE$3 = "shell-script";
1682
- const MESSAGE$2 = "is a shell script. Do the work in TypeScript as a Vite+ task in vite.config.ts, a test, or the tool's own hook, and delete this file. Only the SessionStart hook in .claude/settings.json, which installs the toolchain before TypeScript can run, stays a shell script.";
1784
+ const RULE$4 = "shell-script";
1785
+ const MESSAGE$3 = "is a shell script. Do the work in TypeScript as a Vite+ task in vite.config.ts, a test, or the tool's own hook, and delete this file. Only the SessionStart hook in .claude/settings.json, which installs the toolchain before TypeScript can run, stays a shell script.";
1683
1786
  const HookSchema = Schema.Struct({
1684
1787
  command: Schema.optional(Schema.String),
1685
1788
  args: Schema.optional(Schema.Array(Schema.String))
@@ -1697,13 +1800,12 @@ const sessionStartCommands = (source) => {
1697
1800
  };
1698
1801
  const baseName = (name) => pipe(String$1.split("/")(name), Array.last, Option.getOrElse(() => name));
1699
1802
  const hasExtension = (name) => EXTENSION.test(baseName(name));
1700
- const startsWithShellShebang = (source) => SHELL_SHEBANG.test(source);
1701
1803
  const problemFor = (file) => ({
1702
1804
  file,
1703
1805
  line: FIRST,
1704
1806
  column: FIRST,
1705
- rule: RULE$3,
1706
- message: MESSAGE$2
1807
+ rule: RULE$4,
1808
+ message: MESSAGE$3
1707
1809
  });
1708
1810
  /** @internal */
1709
1811
  const checkShellScripts = Effect.fn("checkShellScripts")(function* checkShellScripts(root) {
@@ -1716,23 +1818,36 @@ const checkShellScripts = Effect.fn("checkShellScripts")(function* checkShellScr
1716
1818
  const file = files.join(root, name);
1717
1819
  if (SHELL_FILE.test(name)) return files.exists(file);
1718
1820
  if (hasExtension(name)) return Effect.succeed(false);
1719
- return files.readFile(file).pipe(Effect.map(Option.exists(startsWithShellShebang)));
1821
+ return files.readFile(file).pipe(Effect.map(Option.exists((source) => SHELL_SHEBANG.test(source))));
1720
1822
  };
1721
1823
  const candidates = pipe(names, Array.filter((name) => !isSessionStartHook(name)));
1722
1824
  const shell = yield* Effect.filter(candidates, isShell, { concurrency: READ_CONCURRENCY$4 });
1723
1825
  return pipe(shell, Array.map((name) => problemFor(files.join(root, name))));
1724
1826
  });
1725
- // src/features/scripts/model/workflows.ts
1827
+ // src/shared/lib/workflow-files.ts
1726
1828
  const WORKFLOW_FILE = /^\.github\/workflows\/[^/]+\.ya?ml$/u;
1829
+ const READ_CONCURRENCY$3 = 16;
1830
+ const readWorkflows = Effect.fn("readWorkflows")(function* readWorkflows(root) {
1831
+ const files = yield* RepositoryFiles;
1832
+ const names = yield* files.listedFiles(root);
1833
+ const found = yield* Effect.forEach(pipe(names, Array.filter((name) => WORKFLOW_FILE.test(name))), (name) => {
1834
+ const file = files.join(root, name);
1835
+ return files.readFile(file).pipe(Effect.map(Option.map((source) => ({
1836
+ file,
1837
+ source
1838
+ }))));
1839
+ }, { concurrency: READ_CONCURRENCY$3 });
1840
+ return Array.getSomes(found);
1841
+ });
1842
+ // src/features/scripts/model/workflows.ts
1727
1843
  const COMMAND_CHAIN = /&&|\|\||;|\|/u;
1728
1844
  const QUOTED = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
1729
1845
  const COMMENT = "#";
1730
1846
  const RUN_KEY = "run";
1731
- const RULE$2 = "workflow-script";
1732
- const READ_CONCURRENCY$3 = 16;
1847
+ const RULE$3 = "workflow-script";
1733
1848
  const START$4 = 0;
1734
1849
  const ONE_COMMAND = 1;
1735
- const MESSAGE$1 = "runs more than one command. Keep a step to one command, `vp run <task>` or `vp exec <bin>`, and put the logic in a Vite+ task in TypeScript.";
1850
+ const MESSAGE$2 = "runs more than one command. Keep a step to one command, `vp run <task>` or `vp exec <bin>`, and put the logic in a Vite+ task in TypeScript.";
1736
1851
  const startOf = (range) => pipe(Option.fromNullishOr(range), Option.map(([start]) => start), Option.getOrElse(() => START$4));
1737
1852
  const runScriptsOf = (source) => {
1738
1853
  const found = [];
@@ -1755,20 +1870,14 @@ const problemsIn$1 = (file) => (source) => {
1755
1870
  return pipe(runScriptsOf(source), Array.filter(runsMoreThanOneCommand), Array.map(({ start }) => ({
1756
1871
  file,
1757
1872
  ...at(start),
1758
- rule: RULE$2,
1759
- message: MESSAGE$1
1873
+ rule: RULE$3,
1874
+ message: MESSAGE$2
1760
1875
  })));
1761
1876
  };
1762
1877
  /** @internal */
1763
1878
  const checkWorkflows = Effect.fn("checkWorkflows")(function* checkWorkflows(root) {
1764
- const files = yield* RepositoryFiles;
1765
- const names = yield* files.listedFiles(root);
1766
- const workflows = pipe(names, Array.filter((name) => WORKFLOW_FILE.test(name)));
1767
- const found = yield* Effect.forEach(workflows, (name) => {
1768
- const file = files.join(root, name);
1769
- return files.readFile(file).pipe(Effect.map((text) => pipe(text, Option.map(problemsIn$1(file)), Option.getOrElse(() => []))));
1770
- }, { concurrency: READ_CONCURRENCY$3 });
1771
- return Array.flatten(found);
1879
+ const workflows = yield* readWorkflows(root);
1880
+ return pipe(workflows, Array.flatMap(({ file, source }) => problemsIn$1(file)(source)));
1772
1881
  });
1773
1882
  // src/features/scripts/model/script-checks.ts
1774
1883
  /** @internal */
@@ -2166,7 +2275,7 @@ const ownerDeclarationsIn = (project, owners) => {
2166
2275
  const isInside = (outers) => (node) => pipe(outers, Array.some((outer) => contains(outer)(node)));
2167
2276
  const sitesOutside = (checker) => (project, outers) => pipe(project.sourceFiles, Array.flatMap((sourceFile) => sitesUnder(checker)(sourceFile)), Array.filter((site) => !isInside(outers)(site.node)));
2168
2277
  const nodesOf = (sites) => pipe(sites, Array.map((site) => site.node));
2169
- const analyzeProject = (owners) => (project) => {
2278
+ const analyzeProject = ({ owners, sourceChecks }) => (project) => {
2170
2279
  const { checker } = project;
2171
2280
  const ownerDeclarations = ownerDeclarationsIn(project, owners);
2172
2281
  const sites = sitesOutside(checker)(project, ownerDeclarations);
@@ -2189,7 +2298,11 @@ const analyzeProject = (owners) => (project) => {
2189
2298
  shapes: project.library.shapes
2190
2299
  };
2191
2300
  return {
2192
- problems: [...pipe(verdicts, Array.flatMap((found) => found.problems)), ...pipe(project.sourceFiles, Array.flatMap((sourceFile) => [...ownedLiteralProblems(context)(sourceFile, excluded), ...shapeProblemsIn(shapeContext)(sourceFile)]))],
2301
+ problems: [...pipe(verdicts, Array.flatMap((found) => found.problems)), ...pipe(project.sourceFiles, Array.flatMap((sourceFile) => [
2302
+ ...ownedLiteralProblems(context)(sourceFile, excluded),
2303
+ ...shapeProblemsIn(shapeContext)(sourceFile),
2304
+ ...pipe(sourceChecks, Array.flatMap((check) => check(checker)(sourceFile)))
2305
+ ]))],
2193
2306
  unowned: pipe(verdicts, Array.flatMap((found) => found.unowned))
2194
2307
  };
2195
2308
  };
@@ -2345,8 +2458,11 @@ const scopeOf = (project, configPath) => ({
2345
2458
  name: Option.getOrElse(project.packageName, () => configPath),
2346
2459
  dependencies: project.workspaceDependencies
2347
2460
  });
2348
- const freshAnalysis = ({ workspace, owners }) => (configPath) => withProject(workspace)(configPath)((project) => Effect.sync(() => {
2349
- const analysis = analyzeProject(owners)(project);
2461
+ const freshAnalysis = ({ workspace, owners, sourceChecks }) => (configPath) => withProject(workspace)(configPath)((project) => Effect.sync(() => {
2462
+ const analysis = analyzeProject({
2463
+ owners,
2464
+ sourceChecks
2465
+ })(project);
2350
2466
  const scope = scopeOf(project, configPath);
2351
2467
  return {
2352
2468
  problems: analysis.problems,
@@ -2379,13 +2495,14 @@ const cacheFor = Effect.fn("cacheFor")(function* cacheFor(root, owners) {
2379
2495
  const encoded = yield* encodeOwners(plain).pipe(Effect.orElseSucceed(() => ""));
2380
2496
  return yield* analysisCache(root, encoded);
2381
2497
  });
2382
- const analyzeProjects = Effect.fn("analyzeProjects")(function* analyzeProjects(workspace, owners, configPaths) {
2498
+ const analyzeProjects = Effect.fn("analyzeProjects")(function* analyzeProjects(workspace, { owners, sourceChecks }, configPaths) {
2383
2499
  const files = yield* RepositoryFiles;
2384
2500
  const cache = yield* cacheFor(workspace.root, owners);
2385
2501
  const listed = yield* files.listedFiles(workspace.root);
2386
2502
  const keyed = yield* pipe(configPaths, Effect.forEach(analyzeConfig({
2387
2503
  workspace,
2388
2504
  owners,
2505
+ sourceChecks,
2389
2506
  cache,
2390
2507
  listed
2391
2508
  })));
@@ -2393,7 +2510,7 @@ const analyzeProjects = Effect.fn("analyzeProjects")(function* analyzeProjects(w
2393
2510
  yield* pruneAnalyses(cache)(pipe(found, Array.map(([key]) => key)));
2394
2511
  return pipe(found, Array.map(([, analysis]) => analysis));
2395
2512
  });
2396
- const checkRepository = Effect.fn("checkRepository")(function* checkRepository(root) {
2513
+ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(root, sourceChecks = []) {
2397
2514
  const files = yield* RepositoryFiles;
2398
2515
  const workspace = {
2399
2516
  compiler: yield* typeScriptCompiler,
@@ -2402,7 +2519,10 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
2402
2519
  };
2403
2520
  const configPaths = yield* listConfigFiles(root);
2404
2521
  const ownerScan = yield* scanOwners(workspace, configPaths);
2405
- const analyses = yield* analyzeProjects(workspace, ownerScan.owners, configPaths);
2522
+ const analyses = yield* analyzeProjects(workspace, {
2523
+ owners: ownerScan.owners,
2524
+ sourceChecks
2525
+ }, configPaths);
2406
2526
  const relative = (file) => files.relative(root, file);
2407
2527
  const unowned = pipe(analyses, Array.flatMap((analysis) => analysis.unowned));
2408
2528
  return sortProblems([
@@ -2411,6 +2531,36 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
2411
2531
  ...duplicateProblems(relative)(unowned)
2412
2532
  ]);
2413
2533
  }, Effect.scoped);
2534
+ // src/features/workflow-concurrency/model/workflow-queue.ts
2535
+ const CONCURRENCY_KEY = "concurrency";
2536
+ const QUEUE_KEY = "queue";
2537
+ const RULE$2 = "workflow-queue";
2538
+ const MESSAGE$1 = "queues runs with `queue`. A queued group runs every old push one by one, so a long run holds back the newest commit for hours. Drop `queue`: a job that later pushes redo gets `cancel-in-progress: true`, and a deploy or release job keeps the default, which lets the running one finish and replaces the waiting one with the newest run.";
2539
+ const queueKeyOf = (node) => pipe(Option.liftPredicate(node, isMap), Option.flatMap((map) => Array.findFirst(map.items, (item) => isScalar(item.key) && item.key.value === QUEUE_KEY)), Option.flatMap(({ key }) => Option.liftPredicate(key, isScalar)), Option.flatMap((key) => Option.fromNullishOr(key.range)), Option.map(([start]) => start));
2540
+ const queueOffsetsOf = (source) => {
2541
+ const found = [];
2542
+ visit(parseDocument(source), { Pair: (_key, pair) => {
2543
+ if (isPair(pair) && isScalar(pair.key) && pair.key.value === CONCURRENCY_KEY) found.push(...Option.toArray(queueKeyOf(pair.value)));
2544
+ } });
2545
+ return found;
2546
+ };
2547
+ /** @internal */
2548
+ const checkWorkflowQueues = Effect.fn("checkWorkflowQueues")(function* checkWorkflowQueues(root) {
2549
+ const workflows = yield* readWorkflows(root);
2550
+ return pipe(workflows, Array.flatMap(({ file, source }) => {
2551
+ const at = positionOf(source);
2552
+ return pipe(queueOffsetsOf(source), Array.map((offset) => {
2553
+ const { line, column } = at(offset);
2554
+ return {
2555
+ file,
2556
+ line,
2557
+ column,
2558
+ rule: RULE$2,
2559
+ message: MESSAGE$1
2560
+ };
2561
+ }));
2562
+ }));
2563
+ });
2414
2564
  // src/features/comments/model/found-comment.ts
2415
2565
  const taggedError$2 = Schema.TaggedError;
2416
2566
  var CommentsUnreadable = class extends taggedError$2()("CommentsUnreadable", {
@@ -2986,13 +3136,14 @@ const checkTrackedText = Effect.fn("checkTrackedText")(function* checkTrackedTex
2986
3136
  /** @internal */
2987
3137
  const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
2988
3138
  const found = yield* Effect.all([
2989
- checkRepository(root),
3139
+ checkRepository(root, [passThroughWrappersIn]),
2990
3140
  checkOverrides(root),
2991
3141
  checkTrackedText(root),
2992
3142
  checkPlacement(root),
2993
3143
  checkScripts(root),
2994
3144
  checkPublishedPackages(root),
2995
- checkWorkspaces(root)
3145
+ checkWorkspaces(root),
3146
+ checkWorkflowQueues(root)
2996
3147
  ], { concurrency: "unbounded" });
2997
3148
  return Array.flatten(found);
2998
3149
  });