@r_masseater/msch 0.16.0 → 0.18.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/{problem-xi8VIKs3.mjs → cli-contract-BeVYJPZW.mjs} +9 -4
- package/dist/cli-contract-BeVYJPZW.mjs.map +1 -0
- package/dist/cli.mjs +387 -227
- package/dist/cli.mjs.map +1 -1
- package/dist/lint.d.mts +1 -1
- package/dist/lint.mjs +13 -4
- package/dist/lint.mjs.map +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/{workspace-aMPb8EA_.mjs → workspace-BJk4TcI8.mjs} +23 -2
- package/dist/workspace-BJk4TcI8.mjs.map +1 -0
- package/dist/workspace-settings.mjs +1 -1
- package/package.json +1 -1
- package/dist/problem-xi8VIKs3.mjs.map +0 -1
- package/dist/workspace-aMPb8EA_.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { A as workspaceDependencies, D as MANIFEST_FILE, E as publicEntriesOf, O as dependencyEntries, S as stringsIn, T as publishedWorkspaces, _ as KeySchema, a as definesTask, b as literalOf, g as workspaceConfigOf, i as VERIFY_TASK, k as readManifest, o as hasVerifyTask, r as RUN_TASKS, t as namedWorkspaces, u as workspaceDirectories, v as childrenOf$2, x as nestedValues, y as keyName } from "./workspace-BJk4TcI8.mjs";
|
|
3
|
+
import { $ as isPropertyAssignment, A as getNameOfDeclaration, B as isExportDeclaration, C as API, D as SyntaxKind, E as SignatureKind, F as isBlock, G as isInterfaceDeclaration, H as isFunctionExpression, I as isCallExpression, J as isNewExpression, K as isModuleBlock, L as isClassDeclaration, M as isArrayLiteralExpression, N as isArrowFunction, O as getJSDocTags, P as isBinaryExpression, Q as isPropertyAccessExpression, R as isElementAccessExpression, S as uniqueByReference, T as InternalSymbolName, U as isIdentifier, V as isFunctionDeclaration, W as isImportDeclaration, X as isObjectLiteralExpression, Y as isNumericLiteral, Z as isParenthesizedExpression, _ as lineOf, a as problemAt, at as isStringLiteral, b as resolvedSymbol, c as childrenOf$3, ct as isTypeReferenceNode, d as declarationsOf, dt as isVariableDeclarationList, et as isReturnStatement, f as descendantsOf, ft as isVariableStatement, g as isTypeDeclaration, h as isGenericDeclaration, i as formatProblem, it as isSpreadElement, j as getTextOfJSDocComment, k as getLeadingCommentRanges, l as columnOf, lt as isUnionTypeNode, m as isExternalDeclaration, n as ProblemList, nt as isSignatureDeclaration, o as sortProblems, ot as isTypeAliasDeclaration, p as importedModulesOf, q as isModuleDeclaration, rt as isSourceFile, s as NODE_MODULES_SEGMENT, st as isTypeLiteralNode, tt as isSatisfiesExpression, u as contains, ut as isVariableDeclaration, v as propertyNamesOf, w as IndexKind, x as symbolAt, y as referencedSymbols, z as isEnumDeclaration } from "./cli-contract-BeVYJPZW.mjs";
|
|
3
4
|
import { i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-BiKs7S7N.mjs";
|
|
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";
|
|
6
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";
|
|
7
7
|
import { ChildProcess } from "effect/process";
|
|
@@ -316,7 +316,7 @@ const mentions$1 = (needle) => ({ api }) => (configPath) => Effect.gen(function*
|
|
|
316
316
|
return pipe(texts, Array.some((text) => Option.exists(text, includesNeedle)));
|
|
317
317
|
});
|
|
318
318
|
// src/entities/project/model/inputs.ts
|
|
319
|
-
const SEPARATOR$
|
|
319
|
+
const SEPARATOR$9 = "/";
|
|
320
320
|
const SCOPE_PREFIX$2 = "@";
|
|
321
321
|
const HIDDEN_PREFIX = ".";
|
|
322
322
|
const encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
|
|
@@ -358,14 +358,14 @@ const closureOf$1 = Effect.fn("closureOf")(function* closureOf(root, configPath)
|
|
|
358
358
|
const directories = yield* workspaceClosure(directory);
|
|
359
359
|
return {
|
|
360
360
|
directories,
|
|
361
|
-
prefixes: pipe(directories, Array.map((found) => `${files.relative(root, found)}${SEPARATOR$
|
|
361
|
+
prefixes: pipe(directories, Array.map((found) => `${files.relative(root, found)}${SEPARATOR$9}`))
|
|
362
362
|
};
|
|
363
363
|
});
|
|
364
364
|
const scopedNames = (modules) => (name) => Effect.gen(function* listScope() {
|
|
365
365
|
const files = yield* RepositoryFiles;
|
|
366
366
|
if (!String$1.startsWith(SCOPE_PREFIX$2)(name)) return [name];
|
|
367
367
|
const scoped = yield* files.readDirectory(files.join(modules, name));
|
|
368
|
-
return pipe(scoped, Array.map((entry) => `${name}${SEPARATOR$
|
|
368
|
+
return pipe(scoped, Array.map((entry) => `${name}${SEPARATOR$9}${entry}`));
|
|
369
369
|
});
|
|
370
370
|
const installedNames$1 = Effect.fn("installedNames")(function* installedNames(modules) {
|
|
371
371
|
const listed = yield* (yield* RepositoryFiles).readDirectory(modules);
|
|
@@ -413,9 +413,9 @@ const positionOf = (source) => (index) => {
|
|
|
413
413
|
// src/features/install-size/model/import-graph.ts
|
|
414
414
|
const RELATIVE = /^\.\.?(?:\/|$)/u;
|
|
415
415
|
const SUBPATH_IMPORT = "#";
|
|
416
|
-
const WILDCARD$
|
|
416
|
+
const WILDCARD$2 = "*";
|
|
417
417
|
const SCOPE = "@";
|
|
418
|
-
const SEPARATOR$
|
|
418
|
+
const SEPARATOR$8 = "/";
|
|
419
419
|
const SOURCE_SUFFIXES = [
|
|
420
420
|
"",
|
|
421
421
|
".ts",
|
|
@@ -427,9 +427,9 @@ const PLAIN_SEGMENTS = 1;
|
|
|
427
427
|
const ImportsField = Schema.Struct({ imports: Schema.optional(Schema.Record(Schema.String, Schema.String)) });
|
|
428
428
|
const decodeImports = Schema.decodeOption(Schema.fromJsonString(ImportsField));
|
|
429
429
|
const packageNameOf = (specifier) => {
|
|
430
|
-
const segments = String$1.split(specifier, SEPARATOR$
|
|
431
|
-
if (String$1.startsWith(SCOPE)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS$1), Array.join(SEPARATOR$
|
|
432
|
-
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$
|
|
430
|
+
const segments = String$1.split(specifier, SEPARATOR$8);
|
|
431
|
+
if (String$1.startsWith(SCOPE)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS$1), Array.join(SEPARATOR$8));
|
|
432
|
+
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$8));
|
|
433
433
|
};
|
|
434
434
|
const literalText = (specifier) => pipe(Option.liftPredicate(specifier, isStringLiteral), Option.map((literal) => literal.text));
|
|
435
435
|
const runtimeSpecifierOf = (statement) => {
|
|
@@ -447,9 +447,9 @@ const specifiersIn = (api, file, text) => {
|
|
|
447
447
|
return Array.getSomes(found);
|
|
448
448
|
};
|
|
449
449
|
const subpathTarget = (imports, specifier) => pipe(Record.toEntries(imports), Array.findFirst(([pattern, target]) => {
|
|
450
|
-
if (!String$1.endsWith(WILDCARD$
|
|
451
|
-
const prefix = String$1.replace(WILDCARD$
|
|
452
|
-
return Option.liftPredicate(String$1.replace(WILDCARD$
|
|
450
|
+
if (!String$1.endsWith(WILDCARD$2)(pattern)) return Option.liftPredicate(target, () => pattern === specifier);
|
|
451
|
+
const prefix = String$1.replace(WILDCARD$2, "")(pattern);
|
|
452
|
+
return Option.liftPredicate(String$1.replace(WILDCARD$2, String$1.replace(prefix, "")(specifier))(target), () => String$1.startsWith(prefix)(specifier));
|
|
453
453
|
}));
|
|
454
454
|
const existingSource = Effect.fn("existingSource")(function* existingSource(base) {
|
|
455
455
|
const files = yield* RepositoryFiles;
|
|
@@ -524,7 +524,7 @@ const InstalledManifest = Schema.Struct({
|
|
|
524
524
|
peerDependencies: DependencyMap,
|
|
525
525
|
peerDependenciesMeta: PeerMeta
|
|
526
526
|
});
|
|
527
|
-
const decodeManifest$
|
|
527
|
+
const decodeManifest$2 = Schema.decodeOption(Schema.fromJsonString(InstalledManifest));
|
|
528
528
|
const keysOf$1 = (map) => pipe(Option.fromUndefinedOr(map), Option.map(Record.keys), Option.getOrElse(() => []));
|
|
529
529
|
const isOptionalPeer = (manifest, name) => pipe(Option.fromUndefinedOr(manifest.peerDependenciesMeta), Option.flatMap(Record.get(name)), Option.exists((meta) => meta.optional === true));
|
|
530
530
|
const installedNames = (manifest) => [
|
|
@@ -535,7 +535,7 @@ const installedNames = (manifest) => [
|
|
|
535
535
|
const childrenOf$1 = Effect.fn("childrenOf")(function* childrenOf(directory) {
|
|
536
536
|
const files = yield* RepositoryFiles;
|
|
537
537
|
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));
|
|
538
|
-
return pipe(text, Option.flatMap(decodeManifest$
|
|
538
|
+
return pipe(text, Option.flatMap(decodeManifest$2), Option.map(installedNames), Option.getOrElse(() => []), Array.map((child) => [directory, child]));
|
|
539
539
|
});
|
|
540
540
|
const resolveFrom = (from, name) => Effect.gen(function* resolvePackage() {
|
|
541
541
|
const files = yield* RepositoryFiles;
|
|
@@ -905,7 +905,7 @@ var OverrideResolutionFailed = class extends taggedError$4()("OverrideResolution
|
|
|
905
905
|
override: Schema.String,
|
|
906
906
|
output: Schema.String
|
|
907
907
|
}) {};
|
|
908
|
-
const textOf
|
|
908
|
+
const textOf = (stream) => stream.pipe(Stream.decodeText(), Stream.mkString);
|
|
909
909
|
const resolveIn = Effect.fn("resolveIn")(function* resolveIn(directory, override) {
|
|
910
910
|
const handle = yield* ChildProcess.make("vp", [
|
|
911
911
|
"install",
|
|
@@ -919,7 +919,7 @@ const resolveIn = Effect.fn("resolveIn")(function* resolveIn(directory, override
|
|
|
919
919
|
extendEnv: true,
|
|
920
920
|
stdin: "ignore"
|
|
921
921
|
});
|
|
922
|
-
const [output, status] = yield* Effect.all([textOf
|
|
922
|
+
const [output, status] = yield* Effect.all([textOf(handle.all), handle.exitCode], { concurrency: "unbounded" });
|
|
923
923
|
if (Number(status) !== SUCCEEDED) return yield* OverrideResolutionFailed.make({
|
|
924
924
|
override,
|
|
925
925
|
output
|
|
@@ -936,7 +936,7 @@ const auditIn = Effect.fn("auditIn")(function* auditIn(directory) {
|
|
|
936
936
|
extendEnv: true,
|
|
937
937
|
stdin: "ignore"
|
|
938
938
|
});
|
|
939
|
-
const [report] = yield* Effect.all([textOf
|
|
939
|
+
const [report] = yield* Effect.all([textOf(handle.stdout), handle.exitCode], { concurrency: "unbounded" });
|
|
940
940
|
return advisoriesIn(report);
|
|
941
941
|
}, Effect.scoped);
|
|
942
942
|
const trackedResolutionFiles = Effect.fn("trackedResolutionFiles")(function* trackedFiles(root) {
|
|
@@ -946,7 +946,7 @@ const trackedResolutionFiles = Effect.fn("trackedResolutionFiles")(function* tra
|
|
|
946
946
|
"--",
|
|
947
947
|
...RESOLUTION_FILES
|
|
948
948
|
], { cwd: root });
|
|
949
|
-
const listed = yield* textOf
|
|
949
|
+
const listed = yield* textOf(handle.stdout);
|
|
950
950
|
return pipe(String$1.split(listed, "\0"), Array.filter(String$1.isNonEmpty));
|
|
951
951
|
}, Effect.scoped);
|
|
952
952
|
const copyFiles = Effect.fn("copyFiles")(function* copyFiles(workspace, directory) {
|
|
@@ -1003,123 +1003,20 @@ 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);
|
|
1109
1006
|
// src/features/placement/model/agent-docs-length.ts
|
|
1110
1007
|
const AGENT_DOC = /(?:^|\/)(?:AGENTS|CLAUDE)\.md$/u;
|
|
1111
1008
|
const RECOMMENDED_LINES = 200;
|
|
1112
|
-
const READ_CONCURRENCY$
|
|
1113
|
-
const FIRST$
|
|
1114
|
-
const RULE$
|
|
1009
|
+
const READ_CONCURRENCY$14 = 16;
|
|
1010
|
+
const FIRST$9 = 1;
|
|
1011
|
+
const RULE$16 = "agent-docs-length";
|
|
1115
1012
|
const lineCount = (source) => pipe(String$1.trimEnd(source), String$1.split("\n")).length;
|
|
1116
1013
|
const problemFor$4 = (file) => (lines) => {
|
|
1117
1014
|
if (lines <= RECOMMENDED_LINES) return Option.none();
|
|
1118
1015
|
return Option.some({
|
|
1119
1016
|
file,
|
|
1120
1017
|
line: 201,
|
|
1121
|
-
column: FIRST$
|
|
1122
|
-
rule: RULE$
|
|
1018
|
+
column: FIRST$9,
|
|
1019
|
+
rule: RULE$16,
|
|
1123
1020
|
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.`
|
|
1124
1021
|
});
|
|
1125
1022
|
};
|
|
@@ -1131,13 +1028,13 @@ const checkAgentDocsLength = Effect.fn("checkAgentDocsLength")(function* checkAg
|
|
|
1131
1028
|
const found = yield* Effect.forEach(docs, (name) => {
|
|
1132
1029
|
const file = files.join(root, name);
|
|
1133
1030
|
return files.readFile(file).pipe(Effect.map(Option.flatMap((source) => problemFor$4(file)(lineCount(source)))));
|
|
1134
|
-
}, { concurrency: READ_CONCURRENCY$
|
|
1031
|
+
}, { concurrency: READ_CONCURRENCY$14 });
|
|
1135
1032
|
return Array.getSomes(found);
|
|
1136
1033
|
});
|
|
1137
1034
|
// src/features/placement/model/colocated-tests.ts
|
|
1138
|
-
const RULE$
|
|
1139
|
-
const FIRST$
|
|
1140
|
-
const READ_CONCURRENCY$
|
|
1035
|
+
const RULE$15 = "colocated-test";
|
|
1036
|
+
const FIRST$8 = 1;
|
|
1037
|
+
const READ_CONCURRENCY$13 = 64;
|
|
1141
1038
|
const ROOT_SUBPATH = ".";
|
|
1142
1039
|
const NAME_GROUP = "name";
|
|
1143
1040
|
const SPECIFIER_GROUP = "specifier";
|
|
@@ -1151,17 +1048,17 @@ const MODULE_SPECIFIER = /(?:\bfrom\s+|\bimport\s*\(\s*|\bimport\s+|\bvi\.mock\(
|
|
|
1151
1048
|
const EXCLUDED = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
|
|
1152
1049
|
const DIRECTORY_MESSAGE = "sits in a separate test directory. Put each test next to the module it tests, and test-only helpers next to the tests as <name>.test.support.ts.";
|
|
1153
1050
|
const SIBLING_MESSAGE = "refers to nothing in its own directory. Move the test next to the module it tests and import that module, or a helper beside it, with ./<name>.";
|
|
1154
|
-
const Manifest = Schema.Struct({
|
|
1051
|
+
const Manifest$1 = Schema.Struct({
|
|
1155
1052
|
name: Schema.optional(Schema.String),
|
|
1156
1053
|
exports: Schema.optional(Schema.Unknown)
|
|
1157
1054
|
});
|
|
1158
|
-
const decodeManifest = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest));
|
|
1055
|
+
const decodeManifest$1 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$1));
|
|
1159
1056
|
const byLength = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
1160
1057
|
const problemFor$3 = (test, message) => ({
|
|
1161
1058
|
file: test.file,
|
|
1162
|
-
line: FIRST$
|
|
1163
|
-
column: FIRST$
|
|
1164
|
-
rule: RULE$
|
|
1059
|
+
line: FIRST$8,
|
|
1060
|
+
column: FIRST$8,
|
|
1061
|
+
rule: RULE$15,
|
|
1165
1062
|
message: `${test.base} ${message}`
|
|
1166
1063
|
});
|
|
1167
1064
|
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);
|
|
@@ -1181,7 +1078,7 @@ const ownSpecifiers = Effect.fn("ownSpecifiers")(function* ownSpecifiers(context
|
|
|
1181
1078
|
if (Option.isNone(owner)) return [];
|
|
1182
1079
|
const text = yield* files.readFile(files.join(context.root, owner.value, MANIFEST_FILE));
|
|
1183
1080
|
const join = (target) => files.join(context.root, owner.value, target);
|
|
1184
|
-
return pipe(text, Option.flatMap(decodeManifest), Option.map(specifiersBeside({
|
|
1081
|
+
return pipe(text, Option.flatMap(decodeManifest$1), Option.map(specifiersBeside({
|
|
1185
1082
|
join,
|
|
1186
1083
|
dirname: files.dirname,
|
|
1187
1084
|
directory: test.directory
|
|
@@ -1223,27 +1120,27 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
|
|
|
1223
1120
|
directory: files.dirname(file)
|
|
1224
1121
|
};
|
|
1225
1122
|
}));
|
|
1226
|
-
const found = yield* Effect.forEach(tests, (test) => problemIn$3(context, test), { concurrency: READ_CONCURRENCY$
|
|
1123
|
+
const found = yield* Effect.forEach(tests, (test) => problemIn$3(context, test), { concurrency: READ_CONCURRENCY$13 });
|
|
1227
1124
|
return Array.getSomes(found);
|
|
1228
1125
|
});
|
|
1229
1126
|
// src/features/placement/model/nested-docs.ts
|
|
1230
|
-
const RULE$
|
|
1127
|
+
const RULE$14 = "nested-docs";
|
|
1231
1128
|
const CONFIG_FILE$4 = "vite.config.ts";
|
|
1232
|
-
const SEPARATOR$
|
|
1233
|
-
const FIRST$
|
|
1234
|
-
const READ_CONCURRENCY$
|
|
1129
|
+
const SEPARATOR$7 = "/";
|
|
1130
|
+
const FIRST$7 = 1;
|
|
1131
|
+
const READ_CONCURRENCY$12 = 64;
|
|
1235
1132
|
const AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
|
|
1236
1133
|
const WORKSPACE_AGENT_DOC = "AGENTS.md";
|
|
1237
1134
|
const README = /^README(?:\.[^/]+)?$/iu;
|
|
1238
1135
|
const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
|
|
1239
1136
|
const taggedError$3 = Schema.TaggedError;
|
|
1240
1137
|
var RootConfigUnreadable = class extends taggedError$3()("RootConfigUnreadable", { file: Schema.String }) {};
|
|
1241
|
-
const isNested = (name) => String$1.includes(SEPARATOR$
|
|
1138
|
+
const isNested = (name) => String$1.includes(SEPARATOR$7)(name);
|
|
1242
1139
|
const problemFor$2 = (file, message) => ({
|
|
1243
1140
|
file,
|
|
1244
|
-
line: FIRST$
|
|
1245
|
-
column: FIRST$
|
|
1246
|
-
rule: RULE$
|
|
1141
|
+
line: FIRST$7,
|
|
1142
|
+
column: FIRST$7,
|
|
1143
|
+
rule: RULE$14,
|
|
1247
1144
|
message
|
|
1248
1145
|
});
|
|
1249
1146
|
const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
|
|
@@ -1289,24 +1186,44 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
|
|
|
1289
1186
|
workspaces: pipe(nested, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map((name) => files.dirname(files.join(root, name))), HashSet.fromIterable),
|
|
1290
1187
|
workspaceAgentDocs
|
|
1291
1188
|
};
|
|
1292
|
-
const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$
|
|
1189
|
+
const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$12 });
|
|
1293
1190
|
return Array.getSomes(found);
|
|
1294
1191
|
});
|
|
1192
|
+
// src/features/placement/model/root-docs.ts
|
|
1193
|
+
const RULE$13 = "root-docs";
|
|
1194
|
+
const SEPARATOR$6 = "/";
|
|
1195
|
+
const FIRST$6 = 1;
|
|
1196
|
+
const MARKDOWN = /\.(?:md|mdx|markdown)$/iu;
|
|
1197
|
+
const ALLOWED = /^(?:README(?:\.[^/]+)?|AGENTS|CLAUDE|ARCHITECTURE|DESIGN|CHANGELOG|LICENSE|NOTICE)\.(?:md|mdx|markdown)$/iu;
|
|
1198
|
+
const MESSAGE$4 = "is a hand-written document outside the places documents belong. Hand-written text goes only in the root README.md, AGENTS.md, CLAUDE.md, ARCHITECTURE.md and DESIGN.md, and under docs/. Move what is still true and not already told by the code into one of them, and delete this file.";
|
|
1199
|
+
const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$6)(name) && MARKDOWN.test(name) && !ALLOWED.test(name);
|
|
1200
|
+
/** @internal */
|
|
1201
|
+
const checkRootDocs = Effect.fn("checkRootDocs")(function* checkRootDocs(root) {
|
|
1202
|
+
const files = yield* RepositoryFiles;
|
|
1203
|
+
const names = yield* files.listedFiles(root);
|
|
1204
|
+
return pipe(names, Array.filter(isStrayRootDoc), Array.map((name) => ({
|
|
1205
|
+
file: files.join(root, name),
|
|
1206
|
+
line: FIRST$6,
|
|
1207
|
+
column: FIRST$6,
|
|
1208
|
+
rule: RULE$13,
|
|
1209
|
+
message: `${name} ${MESSAGE$4}`
|
|
1210
|
+
})));
|
|
1211
|
+
});
|
|
1295
1212
|
// src/features/placement/model/root-readme.ts
|
|
1296
|
-
const RULE$
|
|
1213
|
+
const RULE$12 = "root-readme";
|
|
1297
1214
|
const ROOT_DOC = /^(?:README(?:\.[^/]+)?|AGENTS\.md|CLAUDE\.md)$/iu;
|
|
1298
|
-
const READ_CONCURRENCY$
|
|
1215
|
+
const READ_CONCURRENCY$11 = 16;
|
|
1299
1216
|
const START$5 = 0;
|
|
1300
1217
|
const CHECK_POLICY = "@r_masseater/msch";
|
|
1301
1218
|
const isCheckPolicy = ({ packageName }) => Option.contains(packageName, CHECK_POLICY);
|
|
1302
1219
|
const messageFor = (directory) => `names the workspace ${directory}. The root README, AGENTS.md and CLAUDE.md describe the repository as a whole. Write what belongs to the workspace in ${directory}/README.md, or for agents in ${directory}/AGENTS.md.`;
|
|
1303
|
-
const problemsIn$
|
|
1220
|
+
const problemsIn$6 = (file, source) => ({ directory, pattern }) => {
|
|
1304
1221
|
const message = messageFor(directory);
|
|
1305
1222
|
const at = positionOf(source);
|
|
1306
1223
|
return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
|
|
1307
1224
|
file,
|
|
1308
1225
|
...at(found.index ?? START$5),
|
|
1309
|
-
rule: RULE$
|
|
1226
|
+
rule: RULE$12,
|
|
1310
1227
|
message
|
|
1311
1228
|
})));
|
|
1312
1229
|
};
|
|
@@ -1314,7 +1231,7 @@ const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadm
|
|
|
1314
1231
|
const text = yield* (yield* RepositoryFiles).readFile(file);
|
|
1315
1232
|
return pipe(text, Option.match({
|
|
1316
1233
|
onNone: () => [],
|
|
1317
|
-
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$
|
|
1234
|
+
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$6(file, source)))
|
|
1318
1235
|
}));
|
|
1319
1236
|
});
|
|
1320
1237
|
/** @internal */
|
|
@@ -1324,7 +1241,7 @@ const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(r
|
|
|
1324
1241
|
const readmes = pipe(names, Array.filter((name) => ROOT_DOC.test(name)));
|
|
1325
1242
|
const named = yield* namedWorkspaces(root);
|
|
1326
1243
|
const workspaces = pipe(named, Array.filter((workspace) => !isCheckPolicy(workspace)));
|
|
1327
|
-
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$
|
|
1244
|
+
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$11 });
|
|
1328
1245
|
return Array.flatten(found);
|
|
1329
1246
|
});
|
|
1330
1247
|
// src/features/placement/model/placement-checks.ts
|
|
@@ -1333,18 +1250,132 @@ const checkPlacement = Effect.fn("checkPlacement")(function* checkPlacement(root
|
|
|
1333
1250
|
const found = yield* Effect.all([
|
|
1334
1251
|
checkNestedDocs(root),
|
|
1335
1252
|
checkRootReadme(root),
|
|
1253
|
+
checkRootDocs(root),
|
|
1336
1254
|
checkColocatedTests(root),
|
|
1337
1255
|
checkAgentDocsLength(root)
|
|
1338
1256
|
], { concurrency: "unbounded" });
|
|
1339
1257
|
return Array.flatten(found);
|
|
1340
1258
|
});
|
|
1259
|
+
// src/features/repository-layout/model/command-entries.ts
|
|
1260
|
+
const OUTSIDE_BIN = "command-outside-bin";
|
|
1261
|
+
const UNRUN = "unrun-command";
|
|
1262
|
+
const SCRIPTS = "scripts-directory";
|
|
1263
|
+
const BIN = "bin";
|
|
1264
|
+
const SCRIPTS_DIRECTORY = "scripts";
|
|
1265
|
+
const WORKFLOW_DIRECTORY$1 = ".github/";
|
|
1266
|
+
const SEPARATOR$5 = "/";
|
|
1267
|
+
const CURRENT = "./";
|
|
1268
|
+
const READ_CONCURRENCY$10 = 8;
|
|
1269
|
+
const FIRST$5 = 1;
|
|
1270
|
+
const RUN_FILE = /(?:^|[\s;&|(])(?:node|vpx|tsx|bun|deno)\s+(?:-\S+\s+)*(?<file>[^\s;&|)]+\.[cm]?[jt]s)\b/gu;
|
|
1271
|
+
const COMMAND = /^bin\/[^/]+\.[cm]?ts$/u;
|
|
1272
|
+
const NOT_COMMAND = /\.(?:test|d|test\.support)\.[cm]?ts$/u;
|
|
1273
|
+
const Manifest = Schema.Struct({
|
|
1274
|
+
bin: Schema.optional(Schema.Unknown),
|
|
1275
|
+
main: Schema.optional(Schema.Unknown),
|
|
1276
|
+
exports: Schema.optional(Schema.Unknown)
|
|
1277
|
+
});
|
|
1278
|
+
const TargetMap = Schema.Record(Schema.String, Schema.Unknown);
|
|
1279
|
+
const decodeManifest = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest));
|
|
1280
|
+
const decodeTarget = Schema.decodeUnknownOption(Schema.String);
|
|
1281
|
+
const decodeTargetMap = Schema.decodeUnknownOption(TargetMap);
|
|
1282
|
+
const NO_ENTRIES = {
|
|
1283
|
+
all: [],
|
|
1284
|
+
bins: []
|
|
1285
|
+
};
|
|
1286
|
+
const withoutCurrent = (path) => String$1.replace(new RegExp(`^${CURRENT}`, "u"), "")(path);
|
|
1287
|
+
const runsIn = ({ text, start }) => pipe(Array.fromIterable(String$1.matchAll(RUN_FILE)(text)), Array.flatMap((found) => pipe(Option.fromUndefinedOr(found.groups), Option.flatMap(Record.get("file")), Option.map((path) => ({
|
|
1288
|
+
path: withoutCurrent(path),
|
|
1289
|
+
start
|
|
1290
|
+
})), Option.toArray)));
|
|
1291
|
+
const targetsIn = (held) => [...pipe(decodeTarget(held), Option.map(withoutCurrent), Option.toArray), ...pipe(decodeTargetMap(held), Option.map(Record.values), Option.getOrElse(() => []), Array.flatMap(targetsIn))];
|
|
1292
|
+
const entriesOf$1 = (manifest) => {
|
|
1293
|
+
const bins = targetsIn(manifest.bin);
|
|
1294
|
+
return {
|
|
1295
|
+
all: [
|
|
1296
|
+
...bins,
|
|
1297
|
+
...targetsIn(manifest.main),
|
|
1298
|
+
...targetsIn(manifest.exports)
|
|
1299
|
+
],
|
|
1300
|
+
bins
|
|
1301
|
+
};
|
|
1302
|
+
};
|
|
1303
|
+
const declaredEntries = Effect.fn("declaredEntries")(function* declaredEntries(root, directory) {
|
|
1304
|
+
const files = yield* RepositoryFiles;
|
|
1305
|
+
const text = yield* files.readFile(files.join(root, directory, MANIFEST_FILE));
|
|
1306
|
+
return pipe(text, Option.flatMap(decodeManifest), Option.map(entriesOf$1), Option.getOrElse(() => NO_ENTRIES));
|
|
1307
|
+
});
|
|
1308
|
+
const isCommand$1 = (path) => COMMAND.test(path) && !NOT_COMMAND.test(path);
|
|
1309
|
+
const commandFilesIn = Effect.fn("commandFilesIn")(function* commandFilesIn(root, directory) {
|
|
1310
|
+
const files = yield* RepositoryFiles;
|
|
1311
|
+
const names = yield* files.readDirectory(files.join(root, directory, BIN));
|
|
1312
|
+
return pipe(names, Array.map((name) => `${BIN}${SEPARATOR$5}${name}`), Array.filter(isCommand$1));
|
|
1313
|
+
});
|
|
1314
|
+
const workflowText = Effect.fn("workflowText")(function* workflowText(root) {
|
|
1315
|
+
const files = yield* RepositoryFiles;
|
|
1316
|
+
const listed = yield* files.listedFiles(root);
|
|
1317
|
+
const workflows = pipe(listed, Array.filter(String$1.startsWith(WORKFLOW_DIRECTORY$1)));
|
|
1318
|
+
const texts = yield* Effect.forEach(workflows, (file) => files.readFile(files.join(root, file)), { concurrency: READ_CONCURRENCY$10 });
|
|
1319
|
+
return pipe(Array.getSomes(texts), Array.join("\n"));
|
|
1320
|
+
});
|
|
1321
|
+
const workspacePath = (directory, path) => pipe([directory, path], Array.filter(String$1.isNonEmpty), Array.join(SEPARATOR$5));
|
|
1322
|
+
const outsideProblems = ({ file, source, runs, entries }) => pipe(runs, Array.filter(({ path }) => !COMMAND.test(path) && !Array.contains(entries.all, path)), Array.map(({ path, start }) => ({
|
|
1323
|
+
file,
|
|
1324
|
+
...positionOf(source)(start),
|
|
1325
|
+
rule: OUTSIDE_BIN,
|
|
1326
|
+
message: `A task runs ${path}. Put each file that a task runs at ${BIN}/<name>.ts, the one place where every workspace keeps its commands, so that fallow and the other tools find it without a list of files.`
|
|
1327
|
+
})));
|
|
1328
|
+
const runsOf = (program) => pipe(nestedValues(RUN_TASKS)(program), Array.flatMap(stringsIn), Array.flatMap(runsIn));
|
|
1329
|
+
const problemsIn$5 = Effect.fn("problemsIn")(function* problemsIn(root, directory, workflows) {
|
|
1330
|
+
const files = yield* RepositoryFiles;
|
|
1331
|
+
const config = yield* workspaceConfigOf(root, directory);
|
|
1332
|
+
const entries = yield* declaredEntries(root, directory);
|
|
1333
|
+
const commands = yield* commandFilesIn(root, directory);
|
|
1334
|
+
const runs = pipe(config, Option.map(({ program }) => runsOf(program)), Option.getOrElse(() => []));
|
|
1335
|
+
const runPaths = pipe(runs, Array.map(({ path }) => path));
|
|
1336
|
+
const outside = pipe(config, Option.map(({ file, source }) => outsideProblems({
|
|
1337
|
+
file,
|
|
1338
|
+
source,
|
|
1339
|
+
runs,
|
|
1340
|
+
entries
|
|
1341
|
+
})), Option.getOrElse(() => []));
|
|
1342
|
+
const isRun = (path) => Array.contains(runPaths, path) || Array.contains(entries.bins, path) || String$1.includes(workspacePath(directory, path))(workflows);
|
|
1343
|
+
const unrun = pipe(commands, Array.filter((path) => !isRun(path)), Array.map((path) => ({
|
|
1344
|
+
file: files.join(root, directory, path),
|
|
1345
|
+
line: FIRST$5,
|
|
1346
|
+
column: FIRST$5,
|
|
1347
|
+
rule: UNRUN,
|
|
1348
|
+
message: `No task, package.json bin or workflow runs ${workspacePath(directory, path)}. Files in ${BIN}/ are entry points for fallow, so an unused one is never reported. Run it from a task or delete it.`
|
|
1349
|
+
})));
|
|
1350
|
+
return [...outside, ...unrun];
|
|
1351
|
+
});
|
|
1352
|
+
const scriptsProblem = Effect.fn("scriptsProblem")(function* scriptsProblem(root, directory) {
|
|
1353
|
+
const files = yield* RepositoryFiles;
|
|
1354
|
+
const file = files.join(root, directory, SCRIPTS_DIRECTORY);
|
|
1355
|
+
const isDirectory = yield* files.isDirectory(file);
|
|
1356
|
+
return pipe(isDirectory, Option.filter(Boolean), Option.map(() => ({
|
|
1357
|
+
file,
|
|
1358
|
+
line: FIRST$5,
|
|
1359
|
+
column: FIRST$5,
|
|
1360
|
+
rule: SCRIPTS,
|
|
1361
|
+
message: `${workspacePath(directory, SCRIPTS_DIRECTORY)} is a scripts directory. Put each command at ${BIN}/<name>.ts and the code that it shares in the package's own source, so that every workspace runs its commands the same way.`
|
|
1362
|
+
})));
|
|
1363
|
+
});
|
|
1364
|
+
/** @internal */
|
|
1365
|
+
const checkCommandEntries = Effect.fn("checkCommandEntries")(function* checkCommandEntries(root) {
|
|
1366
|
+
const all = ["", ...yield* workspaceDirectories(root)];
|
|
1367
|
+
const workflows = yield* workflowText(root);
|
|
1368
|
+
const found = yield* Effect.forEach(all, (directory) => problemsIn$5(root, directory, workflows), { concurrency: READ_CONCURRENCY$10 });
|
|
1369
|
+
const scripts = yield* Effect.forEach(all, (directory) => scriptsProblem(root, directory), { concurrency: READ_CONCURRENCY$10 });
|
|
1370
|
+
return [...Array.flatten(found), ...Array.getSomes(scripts)];
|
|
1371
|
+
});
|
|
1341
1372
|
// src/features/repository-layout/model/crates.ts
|
|
1342
|
-
const RULE$
|
|
1373
|
+
const RULE$11 = "unverified-crate";
|
|
1343
1374
|
const CARGO_FILE = "Cargo.toml";
|
|
1344
1375
|
const CONFIG_FILE$3 = "vite.config.ts";
|
|
1345
|
-
const SEPARATOR$
|
|
1376
|
+
const SEPARATOR$4 = "/";
|
|
1346
1377
|
const FIRST$4 = 1;
|
|
1347
|
-
const READ_CONCURRENCY$
|
|
1378
|
+
const READ_CONCURRENCY$9 = 8;
|
|
1348
1379
|
const CrateEntry = Schema.Struct({
|
|
1349
1380
|
name: Schema.String,
|
|
1350
1381
|
manifest_path: Schema.String
|
|
@@ -1370,14 +1401,14 @@ const cratesIn = Effect.fn("cratesIn")(function* cratesIn(root) {
|
|
|
1370
1401
|
})));
|
|
1371
1402
|
}, Effect.scoped);
|
|
1372
1403
|
const owningWorkspace = (directories) => (directory) => {
|
|
1373
|
-
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$
|
|
1404
|
+
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$4}`)(directory)));
|
|
1374
1405
|
return Array.last(Array.sort(owners, String$1.Order));
|
|
1375
1406
|
};
|
|
1376
1407
|
const problemFor$1 = (crate, message) => ({
|
|
1377
1408
|
file: crate.manifest,
|
|
1378
1409
|
line: FIRST$4,
|
|
1379
1410
|
column: FIRST$4,
|
|
1380
|
-
rule: RULE$
|
|
1411
|
+
rule: RULE$11,
|
|
1381
1412
|
message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
|
|
1382
1413
|
});
|
|
1383
1414
|
const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
|
|
@@ -1393,11 +1424,53 @@ const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
|
1393
1424
|
if (!(yield* files.exists(files.join(root, CARGO_FILE)))) return [];
|
|
1394
1425
|
const directories = yield* workspaceDirectories(root);
|
|
1395
1426
|
const crates = yield* cratesIn(root);
|
|
1396
|
-
const found = yield* Effect.forEach(crates, (crate) => problemIn$1(root, directories, crate), { concurrency: READ_CONCURRENCY$
|
|
1427
|
+
const found = yield* Effect.forEach(crates, (crate) => problemIn$1(root, directories, crate), { concurrency: READ_CONCURRENCY$9 });
|
|
1397
1428
|
return Array.getSomes(found);
|
|
1398
1429
|
});
|
|
1430
|
+
// src/features/repository-layout/model/fallow-entries.ts
|
|
1431
|
+
const RULE$10 = "listed-entry";
|
|
1432
|
+
const ENTRY_KEYS = [
|
|
1433
|
+
"entry",
|
|
1434
|
+
"entryPoints",
|
|
1435
|
+
"supportEntry"
|
|
1436
|
+
];
|
|
1437
|
+
const FALLOW_CONFIG = /(?:^|\/)(?:\.fallowrc\.jsonc?|fallow-plugin-[^/]+\.jsonc?|\.fallow\/plugins\/[^/]+\.jsonc?)$/u;
|
|
1438
|
+
const WILDCARD$1 = /[*?{[]/u;
|
|
1439
|
+
const SEPARATOR$3 = "/";
|
|
1440
|
+
const WRAP_OFFSET = 1;
|
|
1441
|
+
const READ_CONCURRENCY$8 = 8;
|
|
1442
|
+
const decodeKey = Schema.decodeUnknownOption(KeySchema);
|
|
1443
|
+
const isEntryProperty = (node) => node["type"] === "Property" && pipe(decodeKey(node["key"]), Option.exists((key) => Array.contains(ENTRY_KEYS, keyName(key))));
|
|
1444
|
+
const entryPatternsIn = (node) => {
|
|
1445
|
+
if (Predicate.isReadonlyObject(node) && isEntryProperty(node)) return pipe(stringsIn(node["value"]), Array.map(({ text, start }) => ({
|
|
1446
|
+
text,
|
|
1447
|
+
start: start - WRAP_OFFSET
|
|
1448
|
+
})));
|
|
1449
|
+
return pipe(childrenOf$2(node), Array.flatMap(entryPatternsIn));
|
|
1450
|
+
};
|
|
1451
|
+
const namesOneFile = (directories) => ({ text }) => pipe(directories, Array.some((directory) => String$1.startsWith(`${directory}${SEPARATOR$3}`)(text))) || String$1.includes(SEPARATOR$3)(text) && !WILDCARD$1.test(text);
|
|
1452
|
+
const problemsIn$4 = Effect.fn("problemsIn")(function* problemsIn(root, file, directories) {
|
|
1453
|
+
const files = yield* RepositoryFiles;
|
|
1454
|
+
const path = files.join(root, file);
|
|
1455
|
+
const text = yield* files.readFile(path);
|
|
1456
|
+
if (Option.isNone(text)) return [];
|
|
1457
|
+
const parsed = yield* Effect.promise(() => parse(`${file}.ts`, `(${text.value})`, { lang: "ts" }));
|
|
1458
|
+
return pipe(entryPatternsIn(parsed.program), Array.filter(namesOneFile(directories)), Array.map(({ text: pattern, start }) => ({
|
|
1459
|
+
file: path,
|
|
1460
|
+
...positionOf(text.value)(start),
|
|
1461
|
+
rule: RULE$10,
|
|
1462
|
+
message: `${pattern} names files one by one. Give fallow a place that every workspace uses the same way, such as bin/*.ts or a tool's config file name, or make fallow find the file through package.json.`
|
|
1463
|
+
})));
|
|
1464
|
+
});
|
|
1465
|
+
/** @internal */
|
|
1466
|
+
const checkFallowEntries = Effect.fn("checkFallowEntries")(function* checkFallowEntries(root) {
|
|
1467
|
+
const listed = yield* (yield* RepositoryFiles).listedFiles(root);
|
|
1468
|
+
const directories = yield* workspaceDirectories(root);
|
|
1469
|
+
const found = yield* Effect.forEach(pipe(listed, Array.filter((file) => FALLOW_CONFIG.test(file))), (file) => problemsIn$4(root, file, directories), { concurrency: READ_CONCURRENCY$8 });
|
|
1470
|
+
return Array.flatten(found);
|
|
1471
|
+
});
|
|
1399
1472
|
// src/features/repository-layout/model/hidden-verify.ts
|
|
1400
|
-
const RULE$
|
|
1473
|
+
const RULE$9 = "hidden-verify";
|
|
1401
1474
|
const CONFIG_FILE$2 = "vite.config.ts";
|
|
1402
1475
|
const FIRST$3 = 1;
|
|
1403
1476
|
const READ_CONCURRENCY$7 = 8;
|
|
@@ -1411,7 +1484,7 @@ const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
|
1411
1484
|
file,
|
|
1412
1485
|
line: FIRST$3,
|
|
1413
1486
|
column: FIRST$3,
|
|
1414
|
-
rule: RULE$
|
|
1487
|
+
rule: RULE$9,
|
|
1415
1488
|
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}.`
|
|
1416
1489
|
}).pipe(Option.filter(() => verified));
|
|
1417
1490
|
});
|
|
@@ -1422,32 +1495,12 @@ const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVe
|
|
|
1422
1495
|
return Array.getSomes(found);
|
|
1423
1496
|
});
|
|
1424
1497
|
// src/features/repository-layout/model/root-workspace-paths.ts
|
|
1425
|
-
const RULE$
|
|
1498
|
+
const RULE$8 = "root-workspace-path";
|
|
1426
1499
|
const CONFIG_FILE$1 = "vite.config.ts";
|
|
1427
1500
|
const PATH_CHARACTER = /[\w.@/-]/u;
|
|
1428
1501
|
const NAME_CHARACTER = /[\w.@-]/u;
|
|
1429
1502
|
const FIRST$2 = 0;
|
|
1430
1503
|
const NEXT$2 = 1;
|
|
1431
|
-
const StringNode = Schema.Union([Schema.Struct({
|
|
1432
|
-
type: Schema.Literal("Literal"),
|
|
1433
|
-
value: Schema.String,
|
|
1434
|
-
start: Schema.Finite
|
|
1435
|
-
}), Schema.Struct({
|
|
1436
|
-
type: Schema.Literal("TemplateElement"),
|
|
1437
|
-
value: Schema.Struct({ cooked: Schema.String }),
|
|
1438
|
-
start: Schema.Finite
|
|
1439
|
-
})]);
|
|
1440
|
-
const decodeStringNode = Schema.decodeUnknownOption(StringNode);
|
|
1441
|
-
const textOf = (node) => {
|
|
1442
|
-
if (node.type === "Literal") return node.value;
|
|
1443
|
-
return node.value.cooked;
|
|
1444
|
-
};
|
|
1445
|
-
const stringsIn = (node) => {
|
|
1446
|
-
return [...pipe(decodeStringNode(node), Option.map((found) => ({
|
|
1447
|
-
text: textOf(found),
|
|
1448
|
-
start: found.start
|
|
1449
|
-
})), Option.toArray), ...pipe(childrenOf$3(node), Array.flatMap(stringsIn))];
|
|
1450
|
-
};
|
|
1451
1504
|
const isBoundary = (character, allowed) => character === "" || !allowed.test(character);
|
|
1452
1505
|
const mentions = (directory) => (text) => {
|
|
1453
1506
|
const parts = String$1.split(text, directory);
|
|
@@ -1461,7 +1514,7 @@ const mentions = (directory) => (text) => {
|
|
|
1461
1514
|
const problemsIn$3 = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
|
|
1462
1515
|
file,
|
|
1463
1516
|
...positionOf(source)(found.start),
|
|
1464
|
-
rule: RULE$
|
|
1517
|
+
rule: RULE$8,
|
|
1465
1518
|
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.`
|
|
1466
1519
|
})));
|
|
1467
1520
|
/** @internal */
|
|
@@ -1475,8 +1528,7 @@ const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* c
|
|
|
1475
1528
|
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$3(file, source.value, directories)));
|
|
1476
1529
|
});
|
|
1477
1530
|
// src/features/repository-layout/model/shared-uncached-tasks.ts
|
|
1478
|
-
const RULE$
|
|
1479
|
-
const TASKS_PATH = ["run", "tasks"];
|
|
1531
|
+
const RULE$7 = "shared-uncached-task";
|
|
1480
1532
|
const READ_CONCURRENCY$6 = 8;
|
|
1481
1533
|
const SHARED = 2;
|
|
1482
1534
|
const OWN_PROGRAM = /^(?:node|vpx|bun|deno|tsx)$|\//u;
|
|
@@ -1520,7 +1572,7 @@ const definitionsIn = Effect.fn("definitionsIn")(function* definitionsIn(root, d
|
|
|
1520
1572
|
const config = yield* workspaceConfigOf(root, directory);
|
|
1521
1573
|
if (Option.isNone(config)) return [];
|
|
1522
1574
|
const { file, source, program } = config.value;
|
|
1523
|
-
return pipe(nestedValues(
|
|
1575
|
+
return pipe(nestedValues(RUN_TASKS)(program), Array.flatMap((tasks) => pipe(decodeTaskObject(tasks), Option.map(({ properties }) => properties), Option.getOrElse(() => []))), Array.flatMap((property) => pipe(decodeTaskProperty(property), Option.flatMap(definitionOf({
|
|
1524
1576
|
directory,
|
|
1525
1577
|
file,
|
|
1526
1578
|
source
|
|
@@ -1532,7 +1584,7 @@ const problemsOf = (definitions) => {
|
|
|
1532
1584
|
return pipe(definitions, Array.map(({ file, position, name, command }) => ({
|
|
1533
1585
|
file,
|
|
1534
1586
|
...position,
|
|
1535
|
-
rule: RULE$
|
|
1587
|
+
rule: RULE$7,
|
|
1536
1588
|
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.`
|
|
1537
1589
|
})));
|
|
1538
1590
|
};
|
|
@@ -1678,7 +1730,7 @@ const outputPathsOf = (step) => pipe(stringOf(pathInputOf(step)), Option.toArray
|
|
|
1678
1730
|
/** @internal */
|
|
1679
1731
|
const producedPaths = (source) => pipe(jobsOf(source), Array.flatMap(([, job]) => itemsOf(childOf("steps")(job))), Array.flatMap(outputPathsOf));
|
|
1680
1732
|
// src/features/repository-layout/model/workflow-paths.ts
|
|
1681
|
-
const RULE$
|
|
1733
|
+
const RULE$6 = "workflow-path";
|
|
1682
1734
|
const WORKFLOW_DIRECTORY = ".github/workflows/";
|
|
1683
1735
|
const WORKFLOW_EXTENSIONS = [".yml", ".yaml"];
|
|
1684
1736
|
const READ_CONCURRENCY$5 = 8;
|
|
@@ -1741,10 +1793,10 @@ const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, fou
|
|
|
1741
1793
|
if (yield* RESOLVERS[found.kind](root, found.path)) return false;
|
|
1742
1794
|
return !(yield* isIgnored$1(root, found.path));
|
|
1743
1795
|
});
|
|
1744
|
-
const problemOf$
|
|
1796
|
+
const problemOf$3 = (file, source) => (found) => ({
|
|
1745
1797
|
file,
|
|
1746
1798
|
...positionOf(source)(found.offset),
|
|
1747
|
-
rule: RULE$
|
|
1799
|
+
rule: RULE$6,
|
|
1748
1800
|
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.`
|
|
1749
1801
|
});
|
|
1750
1802
|
const problemsIn$2 = Effect.fn("problemsIn")(function* problemsIn(root, workflow) {
|
|
@@ -1754,7 +1806,7 @@ const problemsIn$2 = Effect.fn("problemsIn")(function* problemsIn(root, workflow
|
|
|
1754
1806
|
if (Option.isNone(source)) return [];
|
|
1755
1807
|
const produced = producedPaths(source.value);
|
|
1756
1808
|
const missing = yield* Effect.filter(workflowReferences(source.value), (found) => isMissing(root, produced, found));
|
|
1757
|
-
return pipe(missing, Array.map(problemOf$
|
|
1809
|
+
return pipe(missing, Array.map(problemOf$3(file, source.value)));
|
|
1758
1810
|
});
|
|
1759
1811
|
/** @internal */
|
|
1760
1812
|
const checkWorkflowPaths = Effect.fn("checkWorkflowPaths")(function* checkWorkflowPaths(root) {
|
|
@@ -1766,7 +1818,9 @@ const checkWorkflowPaths = Effect.fn("checkWorkflowPaths")(function* checkWorkfl
|
|
|
1766
1818
|
/** @internal */
|
|
1767
1819
|
const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(root) {
|
|
1768
1820
|
const found = yield* Effect.all([
|
|
1821
|
+
checkCommandEntries(root),
|
|
1769
1822
|
checkCrates(root),
|
|
1823
|
+
checkFallowEntries(root),
|
|
1770
1824
|
checkHiddenVerify(root),
|
|
1771
1825
|
checkRootWorkspacePaths(root),
|
|
1772
1826
|
checkSharedUncachedTasks(root),
|
|
@@ -1781,7 +1835,7 @@ const EXTENSION = /\.[^./]+$/u;
|
|
|
1781
1835
|
const SETTINGS_FILE = ".claude/settings.json";
|
|
1782
1836
|
const READ_CONCURRENCY$4 = 64;
|
|
1783
1837
|
const FIRST = 1;
|
|
1784
|
-
const RULE$
|
|
1838
|
+
const RULE$5 = "shell-script";
|
|
1785
1839
|
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.";
|
|
1786
1840
|
const HookSchema = Schema.Struct({
|
|
1787
1841
|
command: Schema.optional(Schema.String),
|
|
@@ -1804,7 +1858,7 @@ const problemFor = (file) => ({
|
|
|
1804
1858
|
file,
|
|
1805
1859
|
line: FIRST,
|
|
1806
1860
|
column: FIRST,
|
|
1807
|
-
rule: RULE$
|
|
1861
|
+
rule: RULE$5,
|
|
1808
1862
|
message: MESSAGE$3
|
|
1809
1863
|
});
|
|
1810
1864
|
/** @internal */
|
|
@@ -1844,7 +1898,7 @@ const COMMAND_CHAIN = /&&|\|\||;|\|/u;
|
|
|
1844
1898
|
const QUOTED = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
1845
1899
|
const COMMENT = "#";
|
|
1846
1900
|
const RUN_KEY = "run";
|
|
1847
|
-
const RULE$
|
|
1901
|
+
const RULE$4 = "workflow-script";
|
|
1848
1902
|
const START$4 = 0;
|
|
1849
1903
|
const ONE_COMMAND = 1;
|
|
1850
1904
|
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.";
|
|
@@ -1870,7 +1924,7 @@ const problemsIn$1 = (file) => (source) => {
|
|
|
1870
1924
|
return pipe(runScriptsOf(source), Array.filter(runsMoreThanOneCommand), Array.map(({ start }) => ({
|
|
1871
1925
|
file,
|
|
1872
1926
|
...at(start),
|
|
1873
|
-
rule: RULE$
|
|
1927
|
+
rule: RULE$4,
|
|
1874
1928
|
message: MESSAGE$2
|
|
1875
1929
|
})));
|
|
1876
1930
|
};
|
|
@@ -1885,6 +1939,139 @@ const checkScripts = Effect.fn("checkScripts")(function* checkScripts(root) {
|
|
|
1885
1939
|
const found = yield* Effect.all([checkShellScripts(root), checkWorkflows(root)], { concurrency: "unbounded" });
|
|
1886
1940
|
return Array.flatten(found);
|
|
1887
1941
|
});
|
|
1942
|
+
// src/features/workflow-concurrency/model/workflow-queue.ts
|
|
1943
|
+
const CONCURRENCY_KEY = "concurrency";
|
|
1944
|
+
const QUEUE_KEY = "queue";
|
|
1945
|
+
const RULE$3 = "workflow-queue";
|
|
1946
|
+
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.";
|
|
1947
|
+
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));
|
|
1948
|
+
const queueOffsetsOf = (source) => {
|
|
1949
|
+
const found = [];
|
|
1950
|
+
visit(parseDocument(source), { Pair: (_key, pair) => {
|
|
1951
|
+
if (isPair(pair) && isScalar(pair.key) && pair.key.value === CONCURRENCY_KEY) found.push(...Option.toArray(queueKeyOf(pair.value)));
|
|
1952
|
+
} });
|
|
1953
|
+
return found;
|
|
1954
|
+
};
|
|
1955
|
+
/** @internal */
|
|
1956
|
+
const checkWorkflowQueues = Effect.fn("checkWorkflowQueues")(function* checkWorkflowQueues(root) {
|
|
1957
|
+
const workflows = yield* readWorkflows(root);
|
|
1958
|
+
return pipe(workflows, Array.flatMap(({ file, source }) => {
|
|
1959
|
+
const at = positionOf(source);
|
|
1960
|
+
return pipe(queueOffsetsOf(source), Array.map((offset) => {
|
|
1961
|
+
const { line, column } = at(offset);
|
|
1962
|
+
return {
|
|
1963
|
+
file,
|
|
1964
|
+
line,
|
|
1965
|
+
column,
|
|
1966
|
+
rule: RULE$3,
|
|
1967
|
+
message: MESSAGE$1
|
|
1968
|
+
};
|
|
1969
|
+
}));
|
|
1970
|
+
}));
|
|
1971
|
+
});
|
|
1972
|
+
// src/features/pass-through-wrappers/model/pass-through-wrappers.ts
|
|
1973
|
+
const RULE$2 = "pass-through-wrapper";
|
|
1974
|
+
const SINGLE_STATEMENT = 1;
|
|
1975
|
+
const SINGLE_DECLARATION = 1;
|
|
1976
|
+
const THIS_PARAMETER = "this";
|
|
1977
|
+
const NO_ARGUMENTS = [];
|
|
1978
|
+
const messageOf = (callee) => `This function only passes its parameters to ${callee} unchanged. Call ${callee} directly and delete this function.`;
|
|
1979
|
+
const unwrapped = (expression) => {
|
|
1980
|
+
if (isParenthesizedExpression(expression)) return unwrapped(expression.expression);
|
|
1981
|
+
return expression;
|
|
1982
|
+
};
|
|
1983
|
+
const isWrapperExpression = (expression) => isArrowFunction(expression) || isFunctionExpression(expression);
|
|
1984
|
+
const candidateOf = (node) => {
|
|
1985
|
+
if (isFunctionDeclaration(node)) return pipe(Option.fromUndefinedOr(node.name), Option.map((name) => ({
|
|
1986
|
+
name,
|
|
1987
|
+
wrapper: node
|
|
1988
|
+
})));
|
|
1989
|
+
if (!isVariableDeclaration(node) || !isIdentifier(node.name)) return Option.none();
|
|
1990
|
+
const { name } = node;
|
|
1991
|
+
return pipe(Option.fromUndefinedOr(node.initializer), Option.map(unwrapped), Option.filter(isWrapperExpression), Option.map((wrapper) => ({
|
|
1992
|
+
name,
|
|
1993
|
+
wrapper
|
|
1994
|
+
})));
|
|
1995
|
+
};
|
|
1996
|
+
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));
|
|
1997
|
+
const returnedExpression = (wrapper) => {
|
|
1998
|
+
const { body } = wrapper;
|
|
1999
|
+
if (Predicate.isUndefined(body)) return Option.none();
|
|
2000
|
+
if (!isBlock(body)) return Option.some(body);
|
|
2001
|
+
if (body.statements.length !== SINGLE_STATEMENT) return Option.none();
|
|
2002
|
+
return pipe(Array.head(body.statements), Option.filter((statement) => isReturnStatement(statement)), Option.flatMap((statement) => Option.fromUndefinedOr(statement.expression)));
|
|
2003
|
+
};
|
|
2004
|
+
const callForward = (call) => ({
|
|
2005
|
+
node: call,
|
|
2006
|
+
callee: call.expression,
|
|
2007
|
+
kind: SignatureKind.Call,
|
|
2008
|
+
arguments: call.arguments,
|
|
2009
|
+
typed: Predicate.isNotUndefined(call.typeArguments),
|
|
2010
|
+
optional: Predicate.isNotUndefined(call.questionDotToken)
|
|
2011
|
+
});
|
|
2012
|
+
const forwardOf = (expression) => {
|
|
2013
|
+
const inner = unwrapped(expression);
|
|
2014
|
+
if (isCallExpression(inner)) return Option.some(callForward(inner));
|
|
2015
|
+
if (isNewExpression(inner)) return Option.some({
|
|
2016
|
+
node: inner,
|
|
2017
|
+
callee: inner.expression,
|
|
2018
|
+
kind: SignatureKind.Construct,
|
|
2019
|
+
arguments: inner.arguments ?? NO_ARGUMENTS,
|
|
2020
|
+
typed: Predicate.isNotUndefined(inner.typeArguments),
|
|
2021
|
+
optional: false
|
|
2022
|
+
});
|
|
2023
|
+
return Option.none();
|
|
2024
|
+
};
|
|
2025
|
+
const rootOf = (callee) => {
|
|
2026
|
+
if (isIdentifier(callee)) return Option.some(callee);
|
|
2027
|
+
if (isPropertyAccessExpression(callee) && Predicate.isUndefined(callee.questionDotToken) && isIdentifier(callee.name)) return rootOf(callee.expression);
|
|
2028
|
+
return Option.none();
|
|
2029
|
+
};
|
|
2030
|
+
const parameterName = (parameter) => {
|
|
2031
|
+
const { name } = parameter;
|
|
2032
|
+
if (!isIdentifier(name) || Predicate.isNotUndefined(parameter.initializer) || name.text === THIS_PARAMETER) return Option.none();
|
|
2033
|
+
return Option.some(name.text);
|
|
2034
|
+
};
|
|
2035
|
+
const isRest = (parameter) => Predicate.isNotUndefined(parameter.dotDotDotToken);
|
|
2036
|
+
const forwardsParameter = ([parameter, name, argument]) => {
|
|
2037
|
+
if (!isRest(parameter)) return isIdentifier(argument) && argument.text === name;
|
|
2038
|
+
return isSpreadElement(argument) && isIdentifier(argument.expression) && argument.expression.text === name;
|
|
2039
|
+
};
|
|
2040
|
+
const forwardedNames = (wrapper, forward) => {
|
|
2041
|
+
const { parameters } = wrapper;
|
|
2042
|
+
const names = pipe(parameters, Array.map(parameterName), Array.getSomes);
|
|
2043
|
+
if (names.length !== parameters.length || forward.arguments.length !== parameters.length) return Option.none();
|
|
2044
|
+
const triples = Array.zipWith(Array.zip(parameters, names), forward.arguments, ([parameter, name], argument) => [
|
|
2045
|
+
parameter,
|
|
2046
|
+
name,
|
|
2047
|
+
argument
|
|
2048
|
+
]);
|
|
2049
|
+
return pipe(Option.some(names), Option.filter(() => pipe(triples, Array.every(forwardsParameter))));
|
|
2050
|
+
};
|
|
2051
|
+
const calleeTakesExactly = (checker) => (forward, count) => {
|
|
2052
|
+
const signatures = checker.getSignaturesOfType(checker.getTypeAtLocation(forward.callee), forward.kind);
|
|
2053
|
+
return Array.isReadonlyArrayNonEmpty(signatures) && pipe(signatures, Array.every((signature) => !signature.hasRestParameter && signature.parameters.length === count && !Array.isReadonlyArrayNonEmpty(signature.typeParameters ?? [])));
|
|
2054
|
+
};
|
|
2055
|
+
const keepsTheReturnType = (checker) => (wrapper, forward) => Option.match(Option.fromUndefinedOr(wrapper.type), {
|
|
2056
|
+
onNone: () => true,
|
|
2057
|
+
onSome: (type) => checker.getTypeAtLocation(type).id === checker.getTypeAtLocation(forward.node).id
|
|
2058
|
+
});
|
|
2059
|
+
const isOverloaded = (checker) => (name) => Option.exists(Option.fromUndefinedOr(checker.getSymbolAtLocation(name)), (symbol) => symbol.declarations.length > SINGLE_DECLARATION);
|
|
2060
|
+
const callsAnotherFunction = ({ name }, forward, names) => Option.exists(rootOf(forward.callee), (root) => root.text !== name.text && !names.includes(root.text));
|
|
2061
|
+
const isPassThrough = (checker) => (candidate) => (forward) => {
|
|
2062
|
+
const { wrapper, name } = candidate;
|
|
2063
|
+
if (forward.typed || forward.optional) return false;
|
|
2064
|
+
const restForwarded = pipe(wrapper.parameters, Array.some(isRest));
|
|
2065
|
+
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);
|
|
2066
|
+
};
|
|
2067
|
+
const problemOf$2 = (checker) => (candidate) => {
|
|
2068
|
+
if (changesTheCall(candidate.wrapper)) return Option.none();
|
|
2069
|
+
return pipe(returnedExpression(candidate.wrapper), Option.flatMap(forwardOf), Option.filter(isPassThrough(checker)(candidate)), Option.map((forward) => problemAt({
|
|
2070
|
+
rule: RULE$2,
|
|
2071
|
+
message: messageOf(forward.callee.getText())
|
|
2072
|
+
})(candidate.name)));
|
|
2073
|
+
};
|
|
2074
|
+
const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$2(checker)), Array.getSomes);
|
|
1888
2075
|
// src/features/value-owners/model/slots.ts
|
|
1889
2076
|
const ANNOTATED_KINDS = /* @__PURE__ */ new Set([
|
|
1890
2077
|
SyntaxKind.Parameter,
|
|
@@ -2167,7 +2354,7 @@ const derivationScopeOf = (node) => {
|
|
|
2167
2354
|
};
|
|
2168
2355
|
const sourcesOf = (checker) => (node) => pipe(referencedSymbols(checker)(derivationScopeOf(node)), Array.filter((symbol) => Option.isSome(namedValuesOf(checker)(symbol))));
|
|
2169
2356
|
const sitesUnder = (checker) => (node) => {
|
|
2170
|
-
const nested = pipe(childrenOf$
|
|
2357
|
+
const nested = pipe(childrenOf$3(node), Array.flatMap((child) => sitesUnder(checker)(child)));
|
|
2171
2358
|
if (Array.isReadonlyArrayNonEmpty(nested)) return nested;
|
|
2172
2359
|
return siteValuesOf(checker)(node).pipe(Option.map((values) => ({
|
|
2173
2360
|
node,
|
|
@@ -2531,36 +2718,9 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
|
|
|
2531
2718
|
...duplicateProblems(relative)(unowned)
|
|
2532
2719
|
]);
|
|
2533
2720
|
}, Effect.scoped);
|
|
2534
|
-
// src/
|
|
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
|
-
};
|
|
2721
|
+
// src/app/source-checks.ts
|
|
2547
2722
|
/** @internal */
|
|
2548
|
-
const
|
|
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
|
-
});
|
|
2723
|
+
const checkSources = (root) => checkRepository(root, [passThroughWrappersIn]);
|
|
2564
2724
|
// src/features/comments/model/found-comment.ts
|
|
2565
2725
|
const taggedError$2 = Schema.TaggedError;
|
|
2566
2726
|
var CommentsUnreadable = class extends taggedError$2()("CommentsUnreadable", {
|
|
@@ -3136,7 +3296,7 @@ const checkTrackedText = Effect.fn("checkTrackedText")(function* checkTrackedTex
|
|
|
3136
3296
|
/** @internal */
|
|
3137
3297
|
const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
|
|
3138
3298
|
const found = yield* Effect.all([
|
|
3139
|
-
|
|
3299
|
+
checkSources(root),
|
|
3140
3300
|
checkOverrides(root),
|
|
3141
3301
|
checkTrackedText(root),
|
|
3142
3302
|
checkPlacement(root),
|
|
@@ -3168,7 +3328,7 @@ const runCli = (program) => {
|
|
|
3168
3328
|
const main = Layer.build(services).pipe(Effect.flatMap((context) => Effect.provideContext(program.pipe(Effect.tapCause(reportFailure)), context)), Effect.scoped);
|
|
3169
3329
|
runMain(main, { disableErrorReporting: true });
|
|
3170
3330
|
};
|
|
3171
|
-
//
|
|
3331
|
+
// bin/msch.ts
|
|
3172
3332
|
const NO_PROBLEMS = 0;
|
|
3173
3333
|
const reportText = (root, problems) => Effect.gen(function* report() {
|
|
3174
3334
|
const files = yield* RepositoryFiles;
|