@r_masseater/msch 0.18.0 → 0.19.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-contract-BeVYJPZW.mjs → cli-contract-C0YCHq4g.mjs} +13 -2
- package/dist/{cli-contract-BeVYJPZW.mjs.map → cli-contract-C0YCHq4g.mjs.map} +1 -1
- package/dist/cli.mjs +1008 -373
- package/dist/cli.mjs.map +1 -1
- package/dist/decision-rules.d.mts +3 -2
- package/dist/lint.d.mts +18 -9
- package/dist/lint.mjs +244 -184
- package/dist/lint.mjs.map +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/{repository-files-BiKs7S7N.mjs → repository-files-B11FFAIk.mjs} +10 -3
- package/dist/repository-files-B11FFAIk.mjs.map +1 -0
- package/dist/{workspace-BJk4TcI8.mjs → workspace-CMPDXFWk.mjs} +44 -21
- package/dist/workspace-CMPDXFWk.mjs.map +1 -0
- package/dist/workspace-settings.mjs +2 -2
- package/package.json +3 -1
- package/skills/msch-checks/SKILL.md +22 -0
- package/dist/decision-rules-BFywSPLT.d.mts +0 -3
- package/dist/repository-files-BiKs7S7N.mjs.map +0 -1
- package/dist/workspace-BJk4TcI8.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as
|
|
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-
|
|
4
|
-
import { i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-
|
|
2
|
+
import { A as dependencyEntries, C as propertyValue, D as publishedWorkspaces, M as workspaceDependencies, O as publicEntriesOf, S as nestedValues, _ as workspaceConfigOf, a as runTasksOf, b as keyName, c as VERIFY_TASK, i as workspaceDirectories, j as readManifest, k as MANIFEST_FILE, l as definesTask, s as RUN_TASKS, t as namedWorkspaces, u as hasVerifyTask, v as KeySchema, w as stringsIn, x as literalOf, y as childrenOf$2 } from "./workspace-CMPDXFWk.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$1, 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-C0YCHq4g.mjs";
|
|
4
|
+
import { a as groupOf, i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-B11FFAIk.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$12 = "/";
|
|
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$12}`))
|
|
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$12}${entry}`));
|
|
369
369
|
});
|
|
370
370
|
const installedNames$1 = Effect.fn("installedNames")(function* installedNames(modules) {
|
|
371
371
|
const listed = yield* (yield* RepositoryFiles).readDirectory(modules);
|
|
@@ -398,10 +398,10 @@ const projectInputs = ({ workspace: { compiler, root }, listed }) => (configPath
|
|
|
398
398
|
});
|
|
399
399
|
});
|
|
400
400
|
// src/shared/lib/text-position.ts
|
|
401
|
-
const START$
|
|
401
|
+
const START$12 = 0;
|
|
402
402
|
const FIRST_COLUMN$3 = 1;
|
|
403
403
|
const positionOf = (source) => (index) => {
|
|
404
|
-
const before = pipe(source, String$1.slice(START$
|
|
404
|
+
const before = pipe(source, String$1.slice(START$12, index), String$1.split("\n"));
|
|
405
405
|
return {
|
|
406
406
|
line: before.length,
|
|
407
407
|
column: pipe(Array.last(before), Option.match({
|
|
@@ -415,7 +415,7 @@ const RELATIVE = /^\.\.?(?:\/|$)/u;
|
|
|
415
415
|
const SUBPATH_IMPORT = "#";
|
|
416
416
|
const WILDCARD$2 = "*";
|
|
417
417
|
const SCOPE = "@";
|
|
418
|
-
const SEPARATOR$
|
|
418
|
+
const SEPARATOR$11 = "/";
|
|
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$11);
|
|
431
|
+
if (String$1.startsWith(SCOPE)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS$1), Array.join(SEPARATOR$11));
|
|
432
|
+
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$11));
|
|
433
433
|
};
|
|
434
434
|
const literalText = (specifier) => pipe(Option.liftPredicate(specifier, isStringLiteral), Option.map((literal) => literal.text));
|
|
435
435
|
const runtimeSpecifierOf = (statement) => {
|
|
@@ -466,18 +466,18 @@ const localFile = Effect.fn("localFile")(function* localFile({ directory, import
|
|
|
466
466
|
if (Option.isNone(target)) return Option.none();
|
|
467
467
|
return yield* existingSource(files.resolve(directory, target.value));
|
|
468
468
|
});
|
|
469
|
-
const referenceOf = (graph, from, specifier) => {
|
|
469
|
+
const referenceOf$1 = (graph, from, specifier) => {
|
|
470
470
|
if (RELATIVE.test(specifier) || String$1.startsWith(SUBPATH_IMPORT)(specifier)) return localFile(graph, from, specifier).pipe(Effect.map(Option.map(Result.succeed)));
|
|
471
471
|
const name = packageNameOf(specifier);
|
|
472
472
|
return Effect.succeedSome(Result.fail(name));
|
|
473
473
|
};
|
|
474
|
-
const referencesIn = Effect.fn("referencesIn")(function* referencesIn(graph, file) {
|
|
474
|
+
const referencesIn$1 = Effect.fn("referencesIn")(function* referencesIn(graph, file) {
|
|
475
475
|
const text = yield* (yield* RepositoryFiles).readFile(file);
|
|
476
476
|
const specifiers = Option.match(text, {
|
|
477
477
|
onNone: () => [],
|
|
478
478
|
onSome: (source) => specifiersIn(graph.api, file, source)
|
|
479
479
|
});
|
|
480
|
-
const references = yield* pipe(specifiers, Effect.forEach((specifier) => referenceOf(graph, file, specifier)));
|
|
480
|
+
const references = yield* pipe(specifiers, Effect.forEach((specifier) => referenceOf$1(graph, file, specifier)));
|
|
481
481
|
const found = Array.getSomes(references);
|
|
482
482
|
return {
|
|
483
483
|
packages: Array.getFailures(found),
|
|
@@ -491,7 +491,7 @@ const packagesFrom = (graph, walk) => Array.match(walk.pending, {
|
|
|
491
491
|
...walk,
|
|
492
492
|
pending: rest
|
|
493
493
|
});
|
|
494
|
-
return referencesIn(graph, next).pipe(Effect.flatMap(({ packages, sources }) => packagesFrom(graph, {
|
|
494
|
+
return referencesIn$1(graph, next).pipe(Effect.flatMap(({ packages, sources }) => packagesFrom(graph, {
|
|
495
495
|
pending: [...rest, ...sources],
|
|
496
496
|
visited: HashSet.add(walk.visited, next),
|
|
497
497
|
packages: HashSet.union(walk.packages, HashSet.fromIterable(packages))
|
|
@@ -524,7 +524,7 @@ const InstalledManifest = Schema.Struct({
|
|
|
524
524
|
peerDependencies: DependencyMap,
|
|
525
525
|
peerDependenciesMeta: PeerMeta
|
|
526
526
|
});
|
|
527
|
-
const decodeManifest$
|
|
527
|
+
const decodeManifest$3 = 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$3), 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;
|
|
@@ -597,11 +597,11 @@ const LISTED_LARGEST = 5;
|
|
|
597
597
|
const SIZE_CONCURRENCY = 32;
|
|
598
598
|
const MEGABYTE = 1e6;
|
|
599
599
|
const MEGABYTE_DIGITS = 1;
|
|
600
|
-
const START$
|
|
600
|
+
const START$11 = 0;
|
|
601
601
|
const SINGLE_ENTRY = 1;
|
|
602
602
|
const megabytes = (bytes) => `${(bytes / MEGABYTE).toFixed(MEGABYTE_DIGITS)} MB`;
|
|
603
603
|
const usageHint = (dependency, entryCount) => {
|
|
604
|
-
if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$
|
|
604
|
+
if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$11 && dependency.entries.length < entryCount)) return "";
|
|
605
605
|
return ` (imported only from ${Array.join(dependency.entries, ", ")})`;
|
|
606
606
|
};
|
|
607
607
|
const listed = ({ largest, entryCount }) => pipe(largest, Array.map((dependency) => `${dependency.name} ${megabytes(dependency.size)}${usageHint(dependency, entryCount)}`), Array.join(", "));
|
|
@@ -610,7 +610,7 @@ const budgetProblem = Effect.fn("budgetProblem")(function* budgetProblem(overrun
|
|
|
610
610
|
const { workspace, total } = overrun;
|
|
611
611
|
const config = yield* files.readFile(workspace.configFile);
|
|
612
612
|
const source = Option.getOrElse(config, () => "");
|
|
613
|
-
const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$
|
|
613
|
+
const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$11);
|
|
614
614
|
return {
|
|
615
615
|
file: workspace.configFile,
|
|
616
616
|
...positionOf(source)(index),
|
|
@@ -627,7 +627,7 @@ const measure = Effect.fn("measure")(function* measure({ workspace, provided },
|
|
|
627
627
|
const everything = pipe(closures, Array.flatMap(([, packages]) => Array.fromIterable(packages)), HashSet.fromIterable);
|
|
628
628
|
const measured = yield* Effect.forEach(everything, (found) => installedSize(found).pipe(Effect.map((size) => [found, size])), { concurrency: SIZE_CONCURRENCY });
|
|
629
629
|
const sizes = HashMap.fromIterable(measured);
|
|
630
|
-
const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$
|
|
630
|
+
const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$11))));
|
|
631
631
|
return {
|
|
632
632
|
closures,
|
|
633
633
|
sizeOf,
|
|
@@ -660,11 +660,11 @@ const sizeProblems = Effect.fn("sizeProblems")(function* sizeProblems(published,
|
|
|
660
660
|
})];
|
|
661
661
|
});
|
|
662
662
|
const stackProblems = (file, source, dependencies) => {
|
|
663
|
-
const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$
|
|
663
|
+
const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$11);
|
|
664
664
|
const rest = String$1.slice(section)(source);
|
|
665
665
|
return pipe(Record.toEntries(dependencies), Array.filter(([, specifier]) => specifier === STACK_CATALOG), Array.map(([name]) => ({
|
|
666
666
|
file,
|
|
667
|
-
...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$
|
|
667
|
+
...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$11)),
|
|
668
668
|
rule: STACK_DEPENDENCY,
|
|
669
669
|
message: `${name} comes from the stack catalog, so every project that installs this package already has it. Move it to peerDependencies and keep it in devDependencies, so the installing project shares one copy.`
|
|
670
670
|
})));
|
|
@@ -676,7 +676,7 @@ const PublishedManifest = Schema.Struct({
|
|
|
676
676
|
exports: Schema.optional(Schema.Unknown),
|
|
677
677
|
bin: Schema.optional(Schema.Unknown)
|
|
678
678
|
});
|
|
679
|
-
const problemsOf$
|
|
679
|
+
const problemsOf$2 = Effect.fn("problemsOf")(function* problemsOf(workspace, file, source) {
|
|
680
680
|
const files = yield* RepositoryFiles;
|
|
681
681
|
const manifest = Schema.decodeOption(Schema.fromJsonString(PublishedManifest))(source);
|
|
682
682
|
if (Option.isNone(manifest)) return [];
|
|
@@ -700,7 +700,7 @@ const workspaceProblems = Effect.fn("workspaceProblems")(function* workspaceProb
|
|
|
700
700
|
const source = yield* files.readFile(file);
|
|
701
701
|
return yield* Option.match(source, {
|
|
702
702
|
onNone: () => Effect.succeed([]),
|
|
703
|
-
onSome: (text) => problemsOf$
|
|
703
|
+
onSome: (text) => problemsOf$2(workspace, file, text)
|
|
704
704
|
});
|
|
705
705
|
});
|
|
706
706
|
/** @internal */
|
|
@@ -889,11 +889,11 @@ const withBaselineProbe = (manifest) => {
|
|
|
889
889
|
return document.toString();
|
|
890
890
|
};
|
|
891
891
|
// src/features/overrides/model/overrides.ts
|
|
892
|
-
const WORKSPACE_FILE$
|
|
892
|
+
const WORKSPACE_FILE$2 = "pnpm-workspace.yaml";
|
|
893
893
|
const LOCKFILE$1 = "pnpm-lock.yaml";
|
|
894
894
|
const RESOLUTION_FILES = [
|
|
895
895
|
"*package.json",
|
|
896
|
-
WORKSPACE_FILE$
|
|
896
|
+
WORKSPACE_FILE$2,
|
|
897
897
|
LOCKFILE$1,
|
|
898
898
|
".npmrc",
|
|
899
899
|
"patches/*"
|
|
@@ -964,7 +964,7 @@ const resolutionWith = Effect.fn("resolutionWith")(function* resolutionWith(work
|
|
|
964
964
|
const path = yield* Path.Path;
|
|
965
965
|
const directory = yield* fs.makeTempDirectoryScoped({ prefix: "msch-overrides-" });
|
|
966
966
|
yield* copyFiles(workspace, directory);
|
|
967
|
-
yield* fs.writeFileString(path.join(directory, WORKSPACE_FILE$
|
|
967
|
+
yield* fs.writeFileString(path.join(directory, WORKSPACE_FILE$2), manifest);
|
|
968
968
|
const output = yield* resolveIn(directory, override);
|
|
969
969
|
const lockfile = yield* fs.readFileString(path.join(directory, LOCKFILE$1));
|
|
970
970
|
yield* Effect.annotateCurrentSpan({ "msch.override": override });
|
|
@@ -983,7 +983,7 @@ const problemsFor = Effect.fn("problemsFor")(function* problemsFor(root, manifes
|
|
|
983
983
|
};
|
|
984
984
|
const baseline = yield* resolutionWith(workspace, BASELINE_PROBE, withBaselineProbe(manifest));
|
|
985
985
|
const judgeAgainstBaseline = judge(baseline);
|
|
986
|
-
const file = path.join(root, WORKSPACE_FILE$
|
|
986
|
+
const file = path.join(root, WORKSPACE_FILE$2);
|
|
987
987
|
const problemOf = (located) => resolutionWith(workspace, located.key, withoutOverride(located.key)(manifest)).pipe(Effect.map((candidate) => overrideProblem({
|
|
988
988
|
...located,
|
|
989
989
|
file
|
|
@@ -995,7 +995,7 @@ const problemsFor = Effect.fn("problemsFor")(function* problemsFor(root, manifes
|
|
|
995
995
|
const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root) {
|
|
996
996
|
const fs = yield* FileSystem.FileSystem;
|
|
997
997
|
const path = yield* Path.Path;
|
|
998
|
-
const manifest = yield* fs.readFileString(path.join(root, WORKSPACE_FILE$
|
|
998
|
+
const manifest = yield* fs.readFileString(path.join(root, WORKSPACE_FILE$2)).pipe(Effect.option);
|
|
999
999
|
const keys = Option.match(manifest, {
|
|
1000
1000
|
onNone: () => [],
|
|
1001
1001
|
onSome: overrideKeysOf
|
|
@@ -1003,38 +1003,41 @@ 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/
|
|
1006
|
+
// src/shared/lib/agent-docs.ts
|
|
1007
1007
|
const AGENT_DOC = /(?:^|\/)(?:AGENTS|CLAUDE)\.md$/u;
|
|
1008
|
+
const READ_CONCURRENCY$18 = 16;
|
|
1009
|
+
const agentDocProblems = Effect.fn("agentDocProblems")(function* agentDocProblems(root, problemIn) {
|
|
1010
|
+
const files = yield* RepositoryFiles;
|
|
1011
|
+
const listed = yield* files.listedFiles(root);
|
|
1012
|
+
const docs = pipe(listed, Array.filter((name) => AGENT_DOC.test(name)));
|
|
1013
|
+
const found = yield* Effect.forEach(docs, (name) => {
|
|
1014
|
+
const file = files.join(root, name);
|
|
1015
|
+
const problemOf = Option.flatMap(problemIn(file));
|
|
1016
|
+
return files.readFile(file).pipe(Effect.map(problemOf));
|
|
1017
|
+
}, { concurrency: READ_CONCURRENCY$18 });
|
|
1018
|
+
return Array.getSomes(found);
|
|
1019
|
+
});
|
|
1020
|
+
// src/features/placement/model/agent-docs-length.ts
|
|
1008
1021
|
const RECOMMENDED_LINES = 200;
|
|
1009
|
-
const
|
|
1010
|
-
const
|
|
1011
|
-
const RULE$16 = "agent-docs-length";
|
|
1022
|
+
const FIRST$13 = 1;
|
|
1023
|
+
const RULE$24 = "agent-docs-length";
|
|
1012
1024
|
const lineCount = (source) => pipe(String$1.trimEnd(source), String$1.split("\n")).length;
|
|
1013
|
-
const problemFor$
|
|
1025
|
+
const problemFor$5 = (file) => (lines) => {
|
|
1014
1026
|
if (lines <= RECOMMENDED_LINES) return Option.none();
|
|
1015
1027
|
return Option.some({
|
|
1016
1028
|
file,
|
|
1017
1029
|
line: 201,
|
|
1018
|
-
column: FIRST$
|
|
1019
|
-
rule: RULE$
|
|
1030
|
+
column: FIRST$13,
|
|
1031
|
+
rule: RULE$24,
|
|
1020
1032
|
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
1033
|
});
|
|
1022
1034
|
};
|
|
1023
1035
|
/** @internal */
|
|
1024
|
-
const checkAgentDocsLength =
|
|
1025
|
-
const files = yield* RepositoryFiles;
|
|
1026
|
-
const listed = yield* files.listedFiles(root);
|
|
1027
|
-
const docs = pipe(listed, Array.filter((name) => AGENT_DOC.test(name)));
|
|
1028
|
-
const found = yield* Effect.forEach(docs, (name) => {
|
|
1029
|
-
const file = files.join(root, name);
|
|
1030
|
-
return files.readFile(file).pipe(Effect.map(Option.flatMap((source) => problemFor$4(file)(lineCount(source)))));
|
|
1031
|
-
}, { concurrency: READ_CONCURRENCY$14 });
|
|
1032
|
-
return Array.getSomes(found);
|
|
1033
|
-
});
|
|
1036
|
+
const checkAgentDocsLength = (root) => agentDocProblems(root, (file) => (source) => problemFor$5(file)(lineCount(source)));
|
|
1034
1037
|
// src/features/placement/model/colocated-tests.ts
|
|
1035
|
-
const RULE$
|
|
1036
|
-
const FIRST$
|
|
1037
|
-
const READ_CONCURRENCY$
|
|
1038
|
+
const RULE$23 = "colocated-test";
|
|
1039
|
+
const FIRST$12 = 1;
|
|
1040
|
+
const READ_CONCURRENCY$17 = 64;
|
|
1038
1041
|
const ROOT_SUBPATH = ".";
|
|
1039
1042
|
const NAME_GROUP = "name";
|
|
1040
1043
|
const SPECIFIER_GROUP = "specifier";
|
|
@@ -1045,20 +1048,20 @@ const SEPARATE_TEST_DIRECTORY = /(?:^|\/)(?:__tests__|__mocks__|tests?|specs?)\/
|
|
|
1045
1048
|
const RELATIVE_REFERENCE = /["'`]\.\/(?<name>[^/"'`]+)/gu;
|
|
1046
1049
|
const DIRNAME_REFERENCE = /import\.meta\.dirname\s*,\s*["'](?<name>[^/"']+)["']/gu;
|
|
1047
1050
|
const MODULE_SPECIFIER = /(?:\bfrom\s+|\bimport\s*\(\s*|\bimport\s+|\bvi\.mock\(\s*)["'](?<specifier>[^"'.#][^"']*)["']/gu;
|
|
1048
|
-
const EXCLUDED = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
|
|
1051
|
+
const EXCLUDED$2 = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
|
|
1049
1052
|
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.";
|
|
1050
1053
|
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>.";
|
|
1051
|
-
const Manifest$
|
|
1054
|
+
const Manifest$2 = Schema.Struct({
|
|
1052
1055
|
name: Schema.optional(Schema.String),
|
|
1053
1056
|
exports: Schema.optional(Schema.Unknown)
|
|
1054
1057
|
});
|
|
1055
|
-
const decodeManifest$
|
|
1058
|
+
const decodeManifest$2 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$2));
|
|
1056
1059
|
const byLength = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
1057
|
-
const problemFor$
|
|
1060
|
+
const problemFor$4 = (test, message) => ({
|
|
1058
1061
|
file: test.file,
|
|
1059
|
-
line: FIRST$
|
|
1060
|
-
column: FIRST$
|
|
1061
|
-
rule: RULE$
|
|
1062
|
+
line: FIRST$12,
|
|
1063
|
+
column: FIRST$12,
|
|
1064
|
+
rule: RULE$23,
|
|
1062
1065
|
message: `${test.base} ${message}`
|
|
1063
1066
|
});
|
|
1064
1067
|
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);
|
|
@@ -1078,7 +1081,7 @@ const ownSpecifiers = Effect.fn("ownSpecifiers")(function* ownSpecifiers(context
|
|
|
1078
1081
|
if (Option.isNone(owner)) return [];
|
|
1079
1082
|
const text = yield* files.readFile(files.join(context.root, owner.value, MANIFEST_FILE));
|
|
1080
1083
|
const join = (target) => files.join(context.root, owner.value, target);
|
|
1081
|
-
return pipe(text, Option.flatMap(decodeManifest$
|
|
1084
|
+
return pipe(text, Option.flatMap(decodeManifest$2), Option.map(specifiersBeside({
|
|
1082
1085
|
join,
|
|
1083
1086
|
dirname: files.dirname,
|
|
1084
1087
|
directory: test.directory
|
|
@@ -1096,16 +1099,16 @@ const refersIn = Effect.fn("refersIn")(function* refersIn(context, test) {
|
|
|
1096
1099
|
if (Option.isNone(source)) return true;
|
|
1097
1100
|
return yield* refersToOwnDirectory(context, test, source.value);
|
|
1098
1101
|
});
|
|
1099
|
-
const problemIn$
|
|
1100
|
-
if (SEPARATE_TEST_DIRECTORY.test(test.name)) return Option.some(problemFor$
|
|
1102
|
+
const problemIn$4 = Effect.fn("problemIn")(function* problemIn(context, test) {
|
|
1103
|
+
if (SEPARATE_TEST_DIRECTORY.test(test.name)) return Option.some(problemFor$4(test, DIRECTORY_MESSAGE));
|
|
1101
1104
|
if (!TEST_FILE.test(test.name)) return Option.none();
|
|
1102
1105
|
if (yield* refersIn(context, test)) return Option.none();
|
|
1103
|
-
return Option.some(problemFor$
|
|
1106
|
+
return Option.some(problemFor$4(test, SIBLING_MESSAGE));
|
|
1104
1107
|
});
|
|
1105
1108
|
/** @internal */
|
|
1106
1109
|
const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColocatedTests(root) {
|
|
1107
1110
|
const files = yield* RepositoryFiles;
|
|
1108
|
-
const listed = yield* files.matchingFiles(root, EXCLUDED);
|
|
1111
|
+
const listed = yield* files.matchingFiles(root, EXCLUDED$2);
|
|
1109
1112
|
const names = pipe(listed, Array.filter(String$1.isNonEmpty));
|
|
1110
1113
|
const context = {
|
|
1111
1114
|
root,
|
|
@@ -1120,42 +1123,66 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
|
|
|
1120
1123
|
directory: files.dirname(file)
|
|
1121
1124
|
};
|
|
1122
1125
|
}));
|
|
1123
|
-
const found = yield* Effect.forEach(tests, (test) => problemIn$
|
|
1126
|
+
const found = yield* Effect.forEach(tests, (test) => problemIn$4(context, test), { concurrency: READ_CONCURRENCY$17 });
|
|
1127
|
+
return Array.getSomes(found);
|
|
1128
|
+
});
|
|
1129
|
+
// src/features/placement/model/dangling-links.ts
|
|
1130
|
+
const RULE$22 = "dangling-link";
|
|
1131
|
+
const SEPARATOR$10 = "/";
|
|
1132
|
+
const FIRST$11 = 1;
|
|
1133
|
+
const READ_CONCURRENCY$16 = 16;
|
|
1134
|
+
const holds = (target) => (name) => name === target || String$1.startsWith(`${target}${SEPARATOR$10}`)(name);
|
|
1135
|
+
/** @internal */
|
|
1136
|
+
const checkDanglingLinks = Effect.fn("checkDanglingLinks")(function* checkDanglingLinks(root) {
|
|
1137
|
+
const files = yield* RepositoryFiles;
|
|
1138
|
+
const [links, listed] = yield* Effect.all([files.linkedFiles(root), files.listedFiles(root)], { concurrency: "unbounded" });
|
|
1139
|
+
const problemOf = Effect.fn("problemOf")(function* problemOf(name) {
|
|
1140
|
+
const file = files.join(root, name);
|
|
1141
|
+
const link = yield* files.readLink(file);
|
|
1142
|
+
return pipe(link, Option.map((target) => files.relative(root, files.resolve(files.dirname(file), target))), Option.filter((target) => !pipe(listed, Array.some(holds(target)))), Option.map((target) => ({
|
|
1143
|
+
file,
|
|
1144
|
+
line: FIRST$11,
|
|
1145
|
+
column: FIRST$11,
|
|
1146
|
+
rule: RULE$22,
|
|
1147
|
+
message: `is a link to ${target}, where no file is tracked. A fresh checkout gets a link to nothing, and GitHub Actions fails to load the repository's actions. Track a file there, such as .gitkeep, or delete the link.`
|
|
1148
|
+
})));
|
|
1149
|
+
});
|
|
1150
|
+
const found = yield* Effect.forEach(links, problemOf, { concurrency: READ_CONCURRENCY$16 });
|
|
1124
1151
|
return Array.getSomes(found);
|
|
1125
1152
|
});
|
|
1126
1153
|
// src/features/placement/model/nested-docs.ts
|
|
1127
|
-
const RULE$
|
|
1154
|
+
const RULE$21 = "nested-docs";
|
|
1128
1155
|
const CONFIG_FILE$4 = "vite.config.ts";
|
|
1129
|
-
const SEPARATOR$
|
|
1130
|
-
const FIRST$
|
|
1131
|
-
const READ_CONCURRENCY$
|
|
1156
|
+
const SEPARATOR$9 = "/";
|
|
1157
|
+
const FIRST$10 = 1;
|
|
1158
|
+
const READ_CONCURRENCY$15 = 64;
|
|
1132
1159
|
const AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
|
|
1133
1160
|
const WORKSPACE_AGENT_DOC = "AGENTS.md";
|
|
1134
1161
|
const README = /^README(?:\.[^/]+)?$/iu;
|
|
1135
1162
|
const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
|
|
1136
1163
|
const taggedError$3 = Schema.TaggedError;
|
|
1137
1164
|
var RootConfigUnreadable = class extends taggedError$3()("RootConfigUnreadable", { file: Schema.String }) {};
|
|
1138
|
-
const isNested = (name) => String$1.includes(SEPARATOR$
|
|
1139
|
-
const problemFor$
|
|
1165
|
+
const isNested = (name) => String$1.includes(SEPARATOR$9)(name);
|
|
1166
|
+
const problemFor$3 = (file, message) => ({
|
|
1140
1167
|
file,
|
|
1141
|
-
line: FIRST$
|
|
1142
|
-
column: FIRST$
|
|
1143
|
-
rule: RULE$
|
|
1168
|
+
line: FIRST$10,
|
|
1169
|
+
column: FIRST$10,
|
|
1170
|
+
rule: RULE$21,
|
|
1144
1171
|
message
|
|
1145
1172
|
});
|
|
1146
1173
|
const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
|
|
1147
1174
|
const WORKSPACE_AGENT_DOCS_MESSAGE = "belongs only at the repository root or as AGENTS.md directly in a workspace, the directory that holds its package.json. Move what agents need there and delete this file.";
|
|
1148
1175
|
const README_MESSAGE = "is allowed below the root only in a workspace, the directory that holds its package.json. Move it into the workspace it describes.";
|
|
1149
1176
|
const agentDocProblem = ({ file, base, directory }, allowed) => {
|
|
1150
|
-
if (!allowed.workspaceAgentDocs) return Option.some(problemFor$
|
|
1177
|
+
if (!allowed.workspaceAgentDocs) return Option.some(problemFor$3(file, `${base} ${AGENT_DOCS_MESSAGE}`));
|
|
1151
1178
|
if (base === WORKSPACE_AGENT_DOC && HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
1152
|
-
return Option.some(problemFor$
|
|
1179
|
+
return Option.some(problemFor$3(file, `${base} ${WORKSPACE_AGENT_DOCS_MESSAGE}`));
|
|
1153
1180
|
};
|
|
1154
1181
|
const readmeProblem = ({ file, base, directory }, allowed) => {
|
|
1155
1182
|
if (!README.test(base) || HashSet.has(allowed.workspaces, directory)) return Option.none();
|
|
1156
|
-
return Option.some(problemFor$
|
|
1183
|
+
return Option.some(problemFor$3(file, `${base} ${README_MESSAGE}`));
|
|
1157
1184
|
};
|
|
1158
|
-
const problemIn$
|
|
1185
|
+
const problemIn$3 = Effect.fn("problemIn")(function* problemIn(root, allowed, name) {
|
|
1159
1186
|
const files = yield* RepositoryFiles;
|
|
1160
1187
|
const file = files.join(root, name);
|
|
1161
1188
|
const doc = {
|
|
@@ -1186,44 +1213,44 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
|
|
|
1186
1213
|
workspaces: pipe(nested, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map((name) => files.dirname(files.join(root, name))), HashSet.fromIterable),
|
|
1187
1214
|
workspaceAgentDocs
|
|
1188
1215
|
};
|
|
1189
|
-
const found = yield* Effect.forEach(nested, (name) => problemIn$
|
|
1216
|
+
const found = yield* Effect.forEach(nested, (name) => problemIn$3(root, allowed, name), { concurrency: READ_CONCURRENCY$15 });
|
|
1190
1217
|
return Array.getSomes(found);
|
|
1191
1218
|
});
|
|
1192
1219
|
// src/features/placement/model/root-docs.ts
|
|
1193
|
-
const RULE$
|
|
1194
|
-
const SEPARATOR$
|
|
1195
|
-
const FIRST$
|
|
1196
|
-
const MARKDOWN = /\.(?:md|mdx|markdown)$/iu;
|
|
1220
|
+
const RULE$20 = "root-docs";
|
|
1221
|
+
const SEPARATOR$8 = "/";
|
|
1222
|
+
const FIRST$9 = 1;
|
|
1223
|
+
const MARKDOWN$1 = /\.(?:md|mdx|markdown)$/iu;
|
|
1197
1224
|
const ALLOWED = /^(?:README(?:\.[^/]+)?|AGENTS|CLAUDE|ARCHITECTURE|DESIGN|CHANGELOG|LICENSE|NOTICE)\.(?:md|mdx|markdown)$/iu;
|
|
1198
|
-
const MESSAGE$
|
|
1199
|
-
const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$
|
|
1225
|
+
const MESSAGE$5 = "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.";
|
|
1226
|
+
const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$8)(name) && MARKDOWN$1.test(name) && !ALLOWED.test(name);
|
|
1200
1227
|
/** @internal */
|
|
1201
1228
|
const checkRootDocs = Effect.fn("checkRootDocs")(function* checkRootDocs(root) {
|
|
1202
1229
|
const files = yield* RepositoryFiles;
|
|
1203
1230
|
const names = yield* files.listedFiles(root);
|
|
1204
1231
|
return pipe(names, Array.filter(isStrayRootDoc), Array.map((name) => ({
|
|
1205
1232
|
file: files.join(root, name),
|
|
1206
|
-
line: FIRST$
|
|
1207
|
-
column: FIRST$
|
|
1208
|
-
rule: RULE$
|
|
1209
|
-
message: `${name} ${MESSAGE$
|
|
1233
|
+
line: FIRST$9,
|
|
1234
|
+
column: FIRST$9,
|
|
1235
|
+
rule: RULE$20,
|
|
1236
|
+
message: `${name} ${MESSAGE$5}`
|
|
1210
1237
|
})));
|
|
1211
1238
|
});
|
|
1212
1239
|
// src/features/placement/model/root-readme.ts
|
|
1213
|
-
const RULE$
|
|
1240
|
+
const RULE$19 = "root-readme";
|
|
1214
1241
|
const ROOT_DOC = /^(?:README(?:\.[^/]+)?|AGENTS\.md|CLAUDE\.md)$/iu;
|
|
1215
|
-
const READ_CONCURRENCY$
|
|
1216
|
-
const START$
|
|
1242
|
+
const READ_CONCURRENCY$14 = 16;
|
|
1243
|
+
const START$10 = 0;
|
|
1217
1244
|
const CHECK_POLICY = "@r_masseater/msch";
|
|
1218
1245
|
const isCheckPolicy = ({ packageName }) => Option.contains(packageName, CHECK_POLICY);
|
|
1219
1246
|
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.`;
|
|
1220
|
-
const problemsIn$
|
|
1247
|
+
const problemsIn$10 = (file, source) => ({ directory, pattern }) => {
|
|
1221
1248
|
const message = messageFor(directory);
|
|
1222
1249
|
const at = positionOf(source);
|
|
1223
1250
|
return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
|
|
1224
1251
|
file,
|
|
1225
|
-
...at(found.index ?? START$
|
|
1226
|
-
rule: RULE$
|
|
1252
|
+
...at(found.index ?? START$10),
|
|
1253
|
+
rule: RULE$19,
|
|
1227
1254
|
message
|
|
1228
1255
|
})));
|
|
1229
1256
|
};
|
|
@@ -1231,7 +1258,7 @@ const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadm
|
|
|
1231
1258
|
const text = yield* (yield* RepositoryFiles).readFile(file);
|
|
1232
1259
|
return pipe(text, Option.match({
|
|
1233
1260
|
onNone: () => [],
|
|
1234
|
-
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$
|
|
1261
|
+
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$10(file, source)))
|
|
1235
1262
|
}));
|
|
1236
1263
|
});
|
|
1237
1264
|
/** @internal */
|
|
@@ -1241,7 +1268,7 @@ const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(r
|
|
|
1241
1268
|
const readmes = pipe(names, Array.filter((name) => ROOT_DOC.test(name)));
|
|
1242
1269
|
const named = yield* namedWorkspaces(root);
|
|
1243
1270
|
const workspaces = pipe(named, Array.filter((workspace) => !isCheckPolicy(workspace)));
|
|
1244
|
-
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$
|
|
1271
|
+
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$14 });
|
|
1245
1272
|
return Array.flatten(found);
|
|
1246
1273
|
});
|
|
1247
1274
|
// src/features/placement/model/placement-checks.ts
|
|
@@ -1252,7 +1279,8 @@ const checkPlacement = Effect.fn("checkPlacement")(function* checkPlacement(root
|
|
|
1252
1279
|
checkRootReadme(root),
|
|
1253
1280
|
checkRootDocs(root),
|
|
1254
1281
|
checkColocatedTests(root),
|
|
1255
|
-
checkAgentDocsLength(root)
|
|
1282
|
+
checkAgentDocsLength(root),
|
|
1283
|
+
checkDanglingLinks(root)
|
|
1256
1284
|
], { concurrency: "unbounded" });
|
|
1257
1285
|
return Array.flatten(found);
|
|
1258
1286
|
});
|
|
@@ -1263,20 +1291,20 @@ const SCRIPTS = "scripts-directory";
|
|
|
1263
1291
|
const BIN = "bin";
|
|
1264
1292
|
const SCRIPTS_DIRECTORY = "scripts";
|
|
1265
1293
|
const WORKFLOW_DIRECTORY$1 = ".github/";
|
|
1266
|
-
const SEPARATOR$
|
|
1294
|
+
const SEPARATOR$7 = "/";
|
|
1267
1295
|
const CURRENT = "./";
|
|
1268
|
-
const READ_CONCURRENCY$
|
|
1269
|
-
const FIRST$
|
|
1296
|
+
const READ_CONCURRENCY$13 = 8;
|
|
1297
|
+
const FIRST$8 = 1;
|
|
1270
1298
|
const RUN_FILE = /(?:^|[\s;&|(])(?:node|vpx|tsx|bun|deno)\s+(?:-\S+\s+)*(?<file>[^\s;&|)]+\.[cm]?[jt]s)\b/gu;
|
|
1271
1299
|
const COMMAND = /^bin\/[^/]+\.[cm]?ts$/u;
|
|
1272
1300
|
const NOT_COMMAND = /\.(?:test|d|test\.support)\.[cm]?ts$/u;
|
|
1273
|
-
const Manifest = Schema.Struct({
|
|
1301
|
+
const Manifest$1 = Schema.Struct({
|
|
1274
1302
|
bin: Schema.optional(Schema.Unknown),
|
|
1275
1303
|
main: Schema.optional(Schema.Unknown),
|
|
1276
1304
|
exports: Schema.optional(Schema.Unknown)
|
|
1277
1305
|
});
|
|
1278
1306
|
const TargetMap = Schema.Record(Schema.String, Schema.Unknown);
|
|
1279
|
-
const decodeManifest = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest));
|
|
1307
|
+
const decodeManifest$1 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$1));
|
|
1280
1308
|
const decodeTarget = Schema.decodeUnknownOption(Schema.String);
|
|
1281
1309
|
const decodeTargetMap = Schema.decodeUnknownOption(TargetMap);
|
|
1282
1310
|
const NO_ENTRIES = {
|
|
@@ -1303,22 +1331,22 @@ const entriesOf$1 = (manifest) => {
|
|
|
1303
1331
|
const declaredEntries = Effect.fn("declaredEntries")(function* declaredEntries(root, directory) {
|
|
1304
1332
|
const files = yield* RepositoryFiles;
|
|
1305
1333
|
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));
|
|
1334
|
+
return pipe(text, Option.flatMap(decodeManifest$1), Option.map(entriesOf$1), Option.getOrElse(() => NO_ENTRIES));
|
|
1307
1335
|
});
|
|
1308
1336
|
const isCommand$1 = (path) => COMMAND.test(path) && !NOT_COMMAND.test(path);
|
|
1309
1337
|
const commandFilesIn = Effect.fn("commandFilesIn")(function* commandFilesIn(root, directory) {
|
|
1310
1338
|
const files = yield* RepositoryFiles;
|
|
1311
1339
|
const names = yield* files.readDirectory(files.join(root, directory, BIN));
|
|
1312
|
-
return pipe(names, Array.map((name) => `${BIN}${SEPARATOR$
|
|
1340
|
+
return pipe(names, Array.map((name) => `${BIN}${SEPARATOR$7}${name}`), Array.filter(isCommand$1));
|
|
1313
1341
|
});
|
|
1314
1342
|
const workflowText = Effect.fn("workflowText")(function* workflowText(root) {
|
|
1315
1343
|
const files = yield* RepositoryFiles;
|
|
1316
1344
|
const listed = yield* files.listedFiles(root);
|
|
1317
1345
|
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$
|
|
1346
|
+
const texts = yield* Effect.forEach(workflows, (file) => files.readFile(files.join(root, file)), { concurrency: READ_CONCURRENCY$13 });
|
|
1319
1347
|
return pipe(Array.getSomes(texts), Array.join("\n"));
|
|
1320
1348
|
});
|
|
1321
|
-
const workspacePath = (directory, path) => pipe([directory, path], Array.filter(String$1.isNonEmpty), Array.join(SEPARATOR$
|
|
1349
|
+
const workspacePath = (directory, path) => pipe([directory, path], Array.filter(String$1.isNonEmpty), Array.join(SEPARATOR$7));
|
|
1322
1350
|
const outsideProblems = ({ file, source, runs, entries }) => pipe(runs, Array.filter(({ path }) => !COMMAND.test(path) && !Array.contains(entries.all, path)), Array.map(({ path, start }) => ({
|
|
1323
1351
|
file,
|
|
1324
1352
|
...positionOf(source)(start),
|
|
@@ -1326,7 +1354,7 @@ const outsideProblems = ({ file, source, runs, entries }) => pipe(runs, Array.fi
|
|
|
1326
1354
|
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
1355
|
})));
|
|
1328
1356
|
const runsOf = (program) => pipe(nestedValues(RUN_TASKS)(program), Array.flatMap(stringsIn), Array.flatMap(runsIn));
|
|
1329
|
-
const problemsIn$
|
|
1357
|
+
const problemsIn$9 = Effect.fn("problemsIn")(function* problemsIn(root, directory, workflows) {
|
|
1330
1358
|
const files = yield* RepositoryFiles;
|
|
1331
1359
|
const config = yield* workspaceConfigOf(root, directory);
|
|
1332
1360
|
const entries = yield* declaredEntries(root, directory);
|
|
@@ -1342,8 +1370,8 @@ const problemsIn$5 = Effect.fn("problemsIn")(function* problemsIn(root, director
|
|
|
1342
1370
|
const isRun = (path) => Array.contains(runPaths, path) || Array.contains(entries.bins, path) || String$1.includes(workspacePath(directory, path))(workflows);
|
|
1343
1371
|
const unrun = pipe(commands, Array.filter((path) => !isRun(path)), Array.map((path) => ({
|
|
1344
1372
|
file: files.join(root, directory, path),
|
|
1345
|
-
line: FIRST$
|
|
1346
|
-
column: FIRST$
|
|
1373
|
+
line: FIRST$8,
|
|
1374
|
+
column: FIRST$8,
|
|
1347
1375
|
rule: UNRUN,
|
|
1348
1376
|
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
1377
|
})));
|
|
@@ -1355,8 +1383,8 @@ const scriptsProblem = Effect.fn("scriptsProblem")(function* scriptsProblem(root
|
|
|
1355
1383
|
const isDirectory = yield* files.isDirectory(file);
|
|
1356
1384
|
return pipe(isDirectory, Option.filter(Boolean), Option.map(() => ({
|
|
1357
1385
|
file,
|
|
1358
|
-
line: FIRST$
|
|
1359
|
-
column: FIRST$
|
|
1386
|
+
line: FIRST$8,
|
|
1387
|
+
column: FIRST$8,
|
|
1360
1388
|
rule: SCRIPTS,
|
|
1361
1389
|
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
1390
|
})));
|
|
@@ -1365,17 +1393,17 @@ const scriptsProblem = Effect.fn("scriptsProblem")(function* scriptsProblem(root
|
|
|
1365
1393
|
const checkCommandEntries = Effect.fn("checkCommandEntries")(function* checkCommandEntries(root) {
|
|
1366
1394
|
const all = ["", ...yield* workspaceDirectories(root)];
|
|
1367
1395
|
const workflows = yield* workflowText(root);
|
|
1368
|
-
const found = yield* Effect.forEach(all, (directory) => problemsIn$
|
|
1369
|
-
const scripts = yield* Effect.forEach(all, (directory) => scriptsProblem(root, directory), { concurrency: READ_CONCURRENCY$
|
|
1396
|
+
const found = yield* Effect.forEach(all, (directory) => problemsIn$9(root, directory, workflows), { concurrency: READ_CONCURRENCY$13 });
|
|
1397
|
+
const scripts = yield* Effect.forEach(all, (directory) => scriptsProblem(root, directory), { concurrency: READ_CONCURRENCY$13 });
|
|
1370
1398
|
return [...Array.flatten(found), ...Array.getSomes(scripts)];
|
|
1371
1399
|
});
|
|
1372
1400
|
// src/features/repository-layout/model/crates.ts
|
|
1373
|
-
const RULE$
|
|
1401
|
+
const RULE$18 = "unverified-crate";
|
|
1374
1402
|
const CARGO_FILE = "Cargo.toml";
|
|
1375
1403
|
const CONFIG_FILE$3 = "vite.config.ts";
|
|
1376
|
-
const SEPARATOR$
|
|
1377
|
-
const FIRST$
|
|
1378
|
-
const READ_CONCURRENCY$
|
|
1404
|
+
const SEPARATOR$6 = "/";
|
|
1405
|
+
const FIRST$7 = 1;
|
|
1406
|
+
const READ_CONCURRENCY$12 = 8;
|
|
1379
1407
|
const CrateEntry = Schema.Struct({
|
|
1380
1408
|
name: Schema.String,
|
|
1381
1409
|
manifest_path: Schema.String
|
|
@@ -1401,22 +1429,22 @@ const cratesIn = Effect.fn("cratesIn")(function* cratesIn(root) {
|
|
|
1401
1429
|
})));
|
|
1402
1430
|
}, Effect.scoped);
|
|
1403
1431
|
const owningWorkspace = (directories) => (directory) => {
|
|
1404
|
-
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$
|
|
1432
|
+
const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$6}`)(directory)));
|
|
1405
1433
|
return Array.last(Array.sort(owners, String$1.Order));
|
|
1406
1434
|
};
|
|
1407
|
-
const problemFor$
|
|
1435
|
+
const problemFor$2 = (crate, message) => ({
|
|
1408
1436
|
file: crate.manifest,
|
|
1409
|
-
line: FIRST$
|
|
1410
|
-
column: FIRST$
|
|
1411
|
-
rule: RULE$
|
|
1437
|
+
line: FIRST$7,
|
|
1438
|
+
column: FIRST$7,
|
|
1439
|
+
rule: RULE$18,
|
|
1412
1440
|
message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
|
|
1413
1441
|
});
|
|
1414
|
-
const problemIn$
|
|
1442
|
+
const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
|
|
1415
1443
|
const files = yield* RepositoryFiles;
|
|
1416
1444
|
const workspace = owningWorkspace(directories)(files.relative(root, files.dirname(crate.manifest)));
|
|
1417
|
-
if (Option.isNone(workspace)) return Option.some(problemFor$
|
|
1445
|
+
if (Option.isNone(workspace)) return Option.some(problemFor$2(crate, "is outside every workspace package"));
|
|
1418
1446
|
if (yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE$3))) return Option.none();
|
|
1419
|
-
return Option.some(problemFor$
|
|
1447
|
+
return Option.some(problemFor$2(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$3} has no verify task`));
|
|
1420
1448
|
});
|
|
1421
1449
|
/** @internal */
|
|
1422
1450
|
const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
@@ -1424,11 +1452,11 @@ const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
|
1424
1452
|
if (!(yield* files.exists(files.join(root, CARGO_FILE)))) return [];
|
|
1425
1453
|
const directories = yield* workspaceDirectories(root);
|
|
1426
1454
|
const crates = yield* cratesIn(root);
|
|
1427
|
-
const found = yield* Effect.forEach(crates, (crate) => problemIn$
|
|
1455
|
+
const found = yield* Effect.forEach(crates, (crate) => problemIn$2(root, directories, crate), { concurrency: READ_CONCURRENCY$12 });
|
|
1428
1456
|
return Array.getSomes(found);
|
|
1429
1457
|
});
|
|
1430
1458
|
// src/features/repository-layout/model/fallow-entries.ts
|
|
1431
|
-
const RULE$
|
|
1459
|
+
const RULE$17 = "listed-entry";
|
|
1432
1460
|
const ENTRY_KEYS = [
|
|
1433
1461
|
"entry",
|
|
1434
1462
|
"entryPoints",
|
|
@@ -1436,9 +1464,9 @@ const ENTRY_KEYS = [
|
|
|
1436
1464
|
];
|
|
1437
1465
|
const FALLOW_CONFIG = /(?:^|\/)(?:\.fallowrc\.jsonc?|fallow-plugin-[^/]+\.jsonc?|\.fallow\/plugins\/[^/]+\.jsonc?)$/u;
|
|
1438
1466
|
const WILDCARD$1 = /[*?{[]/u;
|
|
1439
|
-
const SEPARATOR$
|
|
1467
|
+
const SEPARATOR$5 = "/";
|
|
1440
1468
|
const WRAP_OFFSET = 1;
|
|
1441
|
-
const READ_CONCURRENCY$
|
|
1469
|
+
const READ_CONCURRENCY$11 = 8;
|
|
1442
1470
|
const decodeKey = Schema.decodeUnknownOption(KeySchema);
|
|
1443
1471
|
const isEntryProperty = (node) => node["type"] === "Property" && pipe(decodeKey(node["key"]), Option.exists((key) => Array.contains(ENTRY_KEYS, keyName(key))));
|
|
1444
1472
|
const entryPatternsIn = (node) => {
|
|
@@ -1448,8 +1476,8 @@ const entryPatternsIn = (node) => {
|
|
|
1448
1476
|
})));
|
|
1449
1477
|
return pipe(childrenOf$2(node), Array.flatMap(entryPatternsIn));
|
|
1450
1478
|
};
|
|
1451
|
-
const namesOneFile = (directories) => ({ text }) => pipe(directories, Array.some((directory) => String$1.startsWith(`${directory}${SEPARATOR$
|
|
1452
|
-
const problemsIn$
|
|
1479
|
+
const namesOneFile = (directories) => ({ text }) => pipe(directories, Array.some((directory) => String$1.startsWith(`${directory}${SEPARATOR$5}`)(text))) || String$1.includes(SEPARATOR$5)(text) && !WILDCARD$1.test(text);
|
|
1480
|
+
const problemsIn$8 = Effect.fn("problemsIn")(function* problemsIn(root, file, directories) {
|
|
1453
1481
|
const files = yield* RepositoryFiles;
|
|
1454
1482
|
const path = files.join(root, file);
|
|
1455
1483
|
const text = yield* files.readFile(path);
|
|
@@ -1458,7 +1486,7 @@ const problemsIn$4 = Effect.fn("problemsIn")(function* problemsIn(root, file, di
|
|
|
1458
1486
|
return pipe(entryPatternsIn(parsed.program), Array.filter(namesOneFile(directories)), Array.map(({ text: pattern, start }) => ({
|
|
1459
1487
|
file: path,
|
|
1460
1488
|
...positionOf(text.value)(start),
|
|
1461
|
-
rule: RULE$
|
|
1489
|
+
rule: RULE$17,
|
|
1462
1490
|
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
1491
|
})));
|
|
1464
1492
|
});
|
|
@@ -1466,15 +1494,15 @@ const problemsIn$4 = Effect.fn("problemsIn")(function* problemsIn(root, file, di
|
|
|
1466
1494
|
const checkFallowEntries = Effect.fn("checkFallowEntries")(function* checkFallowEntries(root) {
|
|
1467
1495
|
const listed = yield* (yield* RepositoryFiles).listedFiles(root);
|
|
1468
1496
|
const directories = yield* workspaceDirectories(root);
|
|
1469
|
-
const found = yield* Effect.forEach(pipe(listed, Array.filter((file) => FALLOW_CONFIG.test(file))), (file) => problemsIn$
|
|
1497
|
+
const found = yield* Effect.forEach(pipe(listed, Array.filter((file) => FALLOW_CONFIG.test(file))), (file) => problemsIn$8(root, file, directories), { concurrency: READ_CONCURRENCY$11 });
|
|
1470
1498
|
return Array.flatten(found);
|
|
1471
1499
|
});
|
|
1472
1500
|
// src/features/repository-layout/model/hidden-verify.ts
|
|
1473
|
-
const RULE$
|
|
1501
|
+
const RULE$16 = "hidden-verify";
|
|
1474
1502
|
const CONFIG_FILE$2 = "vite.config.ts";
|
|
1475
|
-
const FIRST$
|
|
1476
|
-
const READ_CONCURRENCY$
|
|
1477
|
-
const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
1503
|
+
const FIRST$6 = 1;
|
|
1504
|
+
const READ_CONCURRENCY$10 = 8;
|
|
1505
|
+
const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
1478
1506
|
const config = yield* workspaceConfigOf(root, directory);
|
|
1479
1507
|
if (Option.isNone(config)) return Option.none();
|
|
1480
1508
|
const { file, program } = config.value;
|
|
@@ -1482,24 +1510,24 @@ const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
|
1482
1510
|
const verified = yield* hasVerifyTask(file);
|
|
1483
1511
|
return Option.some({
|
|
1484
1512
|
file,
|
|
1485
|
-
line: FIRST$
|
|
1486
|
-
column: FIRST$
|
|
1487
|
-
rule: RULE$
|
|
1513
|
+
line: FIRST$6,
|
|
1514
|
+
column: FIRST$6,
|
|
1515
|
+
rule: RULE$16,
|
|
1488
1516
|
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}.`
|
|
1489
1517
|
}).pipe(Option.filter(() => verified));
|
|
1490
1518
|
});
|
|
1491
1519
|
/** @internal */
|
|
1492
1520
|
const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVerify(root) {
|
|
1493
1521
|
const directories = yield* workspaceDirectories(root);
|
|
1494
|
-
const found = yield* Effect.forEach(directories, (directory) => problemIn(root, directory), { concurrency: READ_CONCURRENCY$
|
|
1522
|
+
const found = yield* Effect.forEach(directories, (directory) => problemIn$1(root, directory), { concurrency: READ_CONCURRENCY$10 });
|
|
1495
1523
|
return Array.getSomes(found);
|
|
1496
1524
|
});
|
|
1497
1525
|
// src/features/repository-layout/model/root-workspace-paths.ts
|
|
1498
|
-
const RULE$
|
|
1526
|
+
const RULE$15 = "root-workspace-path";
|
|
1499
1527
|
const CONFIG_FILE$1 = "vite.config.ts";
|
|
1500
1528
|
const PATH_CHARACTER = /[\w.@/-]/u;
|
|
1501
1529
|
const NAME_CHARACTER = /[\w.@-]/u;
|
|
1502
|
-
const FIRST$
|
|
1530
|
+
const FIRST$5 = 0;
|
|
1503
1531
|
const NEXT$2 = 1;
|
|
1504
1532
|
const isBoundary = (character, allowed) => character === "" || !allowed.test(character);
|
|
1505
1533
|
const mentions = (directory) => (text) => {
|
|
@@ -1507,14 +1535,14 @@ const mentions = (directory) => (text) => {
|
|
|
1507
1535
|
return pipe(Array.drop(parts, NEXT$2), Array.some((after, index) => {
|
|
1508
1536
|
const before = parts[index] ?? "";
|
|
1509
1537
|
const previous = String$1.slice(before.length - NEXT$2)(before);
|
|
1510
|
-
const following = String$1.slice(FIRST$
|
|
1538
|
+
const following = String$1.slice(FIRST$5, NEXT$2)(after);
|
|
1511
1539
|
return isBoundary(previous, PATH_CHARACTER) && (following === "/" || isBoundary(following, NAME_CHARACTER));
|
|
1512
1540
|
}));
|
|
1513
1541
|
};
|
|
1514
|
-
const problemsIn$
|
|
1542
|
+
const problemsIn$7 = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
|
|
1515
1543
|
file,
|
|
1516
1544
|
...positionOf(source)(found.start),
|
|
1517
|
-
rule: RULE$
|
|
1545
|
+
rule: RULE$15,
|
|
1518
1546
|
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.`
|
|
1519
1547
|
})));
|
|
1520
1548
|
/** @internal */
|
|
@@ -1525,30 +1553,17 @@ const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* c
|
|
|
1525
1553
|
if (Option.isNone(source)) return [];
|
|
1526
1554
|
const directories = yield* workspaceDirectories(root);
|
|
1527
1555
|
const parsed = yield* Effect.promise(() => parse(file, source.value, { lang: "ts" }));
|
|
1528
|
-
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$
|
|
1556
|
+
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$7(file, source.value, directories)));
|
|
1529
1557
|
});
|
|
1530
1558
|
// src/features/repository-layout/model/shared-uncached-tasks.ts
|
|
1531
|
-
const RULE$
|
|
1532
|
-
const READ_CONCURRENCY$
|
|
1559
|
+
const RULE$14 = "shared-uncached-task";
|
|
1560
|
+
const READ_CONCURRENCY$9 = 8;
|
|
1533
1561
|
const SHARED = 2;
|
|
1534
1562
|
const OWN_PROGRAM = /^(?:node|vpx|bun|deno|tsx)$|\//u;
|
|
1535
|
-
const TaskProperty = Schema.Struct({
|
|
1536
|
-
type: Schema.Literal("Property"),
|
|
1537
|
-
computed: Schema.Literal(false),
|
|
1538
|
-
key: KeySchema,
|
|
1539
|
-
value: Schema.Unknown,
|
|
1540
|
-
start: Schema.Finite
|
|
1541
|
-
});
|
|
1542
|
-
const TaskObject = Schema.Struct({
|
|
1543
|
-
type: Schema.Literal("ObjectExpression"),
|
|
1544
|
-
properties: Schema.Array(Schema.Unknown)
|
|
1545
|
-
});
|
|
1546
1563
|
const UncachedTask = Schema.Struct({
|
|
1547
1564
|
cache: Schema.Literal(false),
|
|
1548
1565
|
command: Schema.Union([Schema.String, Schema.NonEmptyArray(Schema.String)])
|
|
1549
1566
|
});
|
|
1550
|
-
const decodeTaskProperty = Schema.decodeUnknownOption(TaskProperty);
|
|
1551
|
-
const decodeTaskObject = Schema.decodeUnknownOption(TaskObject);
|
|
1552
1567
|
const decodeUncachedTask = Schema.decodeUnknownOption(UncachedTask);
|
|
1553
1568
|
const encodeDefinition = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));
|
|
1554
1569
|
const commandText$1 = (command) => Array.join(Array.ensure(command), " && ");
|
|
@@ -1569,30 +1584,30 @@ const definitionOf = ({ directory, file, source }) => (task) => Option.gen(funct
|
|
|
1569
1584
|
};
|
|
1570
1585
|
});
|
|
1571
1586
|
const definitionsIn = Effect.fn("definitionsIn")(function* definitionsIn(root, directory) {
|
|
1572
|
-
const
|
|
1573
|
-
if (Option.isNone(
|
|
1574
|
-
const { file, source,
|
|
1575
|
-
return pipe(
|
|
1587
|
+
const found = yield* runTasksOf(root, directory);
|
|
1588
|
+
if (Option.isNone(found)) return [];
|
|
1589
|
+
const { file, source, tasks } = found.value;
|
|
1590
|
+
return pipe(tasks, Array.flatMap((task) => Option.toArray(definitionOf({
|
|
1576
1591
|
directory,
|
|
1577
1592
|
file,
|
|
1578
1593
|
source
|
|
1579
|
-
}))
|
|
1594
|
+
})(task))));
|
|
1580
1595
|
});
|
|
1581
|
-
const problemsOf = (definitions) => {
|
|
1596
|
+
const problemsOf$1 = (definitions) => {
|
|
1582
1597
|
const directories = pipe(definitions, Array.map(({ directory }) => directory), Array.dedupe);
|
|
1583
1598
|
if (directories.length < SHARED) return [];
|
|
1584
1599
|
return pipe(definitions, Array.map(({ file, position, name, command }) => ({
|
|
1585
1600
|
file,
|
|
1586
1601
|
...position,
|
|
1587
|
-
rule: RULE$
|
|
1602
|
+
rule: RULE$14,
|
|
1588
1603
|
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.`
|
|
1589
1604
|
})));
|
|
1590
1605
|
};
|
|
1591
1606
|
/** @internal */
|
|
1592
1607
|
const checkSharedUncachedTasks = Effect.fn("checkSharedUncachedTasks")(function* checkSharedUncachedTasks(root) {
|
|
1593
1608
|
const directories = yield* workspaceDirectories(root);
|
|
1594
|
-
const found = yield* Effect.forEach(directories, (directory) => definitionsIn(root, directory), { concurrency: READ_CONCURRENCY$
|
|
1595
|
-
return pipe(Array.flatten(found), Array.groupBy(({ name, definition }) => `${name}\u0000${definition}`), Record.values, Array.flatMap(problemsOf));
|
|
1609
|
+
const found = yield* Effect.forEach(directories, (directory) => definitionsIn(root, directory), { concurrency: READ_CONCURRENCY$9 });
|
|
1610
|
+
return pipe(Array.flatten(found), Array.groupBy(({ name, definition }) => `${name}\u0000${definition}`), Record.values, Array.flatMap(problemsOf$1));
|
|
1596
1611
|
});
|
|
1597
1612
|
// src/features/repository-layout/model/workflow-nodes.ts
|
|
1598
1613
|
const MISSING_OFFSET = 0;
|
|
@@ -1600,11 +1615,11 @@ const isRanged = (node) => isScalar(node) || isMap(node) || isSeq(node);
|
|
|
1600
1615
|
/** @internal */
|
|
1601
1616
|
const isText$1 = (node) => isScalar(node) && typeof node.value === "string";
|
|
1602
1617
|
const isTextPair = (pair) => isPair(pair) && isText$1(pair.key);
|
|
1603
|
-
const offsetOf = (node) => pipe(Option.liftPredicate(node, isRanged), Option.flatMap((ranged) => Option.fromNullishOr(ranged.range)), Option.map(([start]) => start), Option.getOrElse(() => MISSING_OFFSET));
|
|
1618
|
+
const offsetOf$3 = (node) => pipe(Option.liftPredicate(node, isRanged), Option.flatMap((ranged) => Option.fromNullishOr(ranged.range)), Option.map(([start]) => start), Option.getOrElse(() => MISSING_OFFSET));
|
|
1604
1619
|
/** @internal */
|
|
1605
1620
|
const stringOf = (node) => pipe(Option.liftPredicate(node, isText$1), Option.map((scalar) => ({
|
|
1606
1621
|
text: scalar.value,
|
|
1607
|
-
offset: offsetOf(scalar)
|
|
1622
|
+
offset: offsetOf$3(scalar)
|
|
1608
1623
|
})));
|
|
1609
1624
|
/** @internal */
|
|
1610
1625
|
const childOf = (key) => (node) => pipe(Option.liftPredicate(node, isMap), Option.map((map) => map.get(key, true)), Option.getOrUndefined);
|
|
@@ -1630,8 +1645,8 @@ const scalarsIn = (source) => {
|
|
|
1630
1645
|
const ROOT = ".";
|
|
1631
1646
|
const LOCAL = "./";
|
|
1632
1647
|
const NEGATION = "!";
|
|
1633
|
-
const SEPARATOR$
|
|
1634
|
-
const LINE = "\n";
|
|
1648
|
+
const SEPARATOR$4 = "/";
|
|
1649
|
+
const LINE$1 = "\n";
|
|
1635
1650
|
const UNRESOLVED_MARKERS = [
|
|
1636
1651
|
"${{",
|
|
1637
1652
|
"$",
|
|
@@ -1642,7 +1657,7 @@ const FILE_INPUT_SUFFIX = "-file";
|
|
|
1642
1657
|
const DEPENDENCY_PATH_INPUT = "cache-dependency-path";
|
|
1643
1658
|
const FILTER_KEYS = ["paths", "paths-ignore"];
|
|
1644
1659
|
const HASH_FILES = /hashFiles\((?<arguments>[^)]*)\)/gu;
|
|
1645
|
-
const QUOTED$
|
|
1660
|
+
const QUOTED$2 = /'(?<path>[^']*)'/gu;
|
|
1646
1661
|
const SCRIPT = /^[\w.@/-]+\.(?:ts|mts|cts|sh)$/u;
|
|
1647
1662
|
const TOKEN_SEPARATOR = /[\s;&|()<>"'`=]+/u;
|
|
1648
1663
|
/** @internal */
|
|
@@ -1657,7 +1672,7 @@ const withoutLocal = (path) => {
|
|
|
1657
1672
|
const joinPath = (base, path) => {
|
|
1658
1673
|
const relative = withoutLocal(String$1.trim(path));
|
|
1659
1674
|
if (base === ROOT) return relative;
|
|
1660
|
-
return `${base}${SEPARATOR$
|
|
1675
|
+
return `${base}${SEPARATOR$4}${relative}`;
|
|
1661
1676
|
};
|
|
1662
1677
|
const reference = (kind, field, base = ROOT) => ({ text, offset }) => {
|
|
1663
1678
|
const path = String$1.trim(text);
|
|
@@ -1680,7 +1695,7 @@ const scriptsIn = (field, base) => ({ text, offset }) => pipe(String$1.split(tex
|
|
|
1680
1695
|
offset
|
|
1681
1696
|
})));
|
|
1682
1697
|
const isFileInput = ([key]) => String$1.endsWith(FILE_INPUT_SUFFIX)(key) || key === DEPENDENCY_PATH_INPUT;
|
|
1683
|
-
const linesOf = ({ text, offset }) => pipe(String$1.split(text, LINE), Array.map((line) => ({
|
|
1698
|
+
const linesOf = ({ text, offset }) => pipe(String$1.split(text, LINE$1), Array.map((line) => ({
|
|
1684
1699
|
text: line,
|
|
1685
1700
|
offset
|
|
1686
1701
|
})));
|
|
@@ -1711,7 +1726,7 @@ const groupsOf = (pattern, group) => ({ text, offset }) => pipe(Array.fromIterab
|
|
|
1711
1726
|
text: value,
|
|
1712
1727
|
offset
|
|
1713
1728
|
})));
|
|
1714
|
-
const hashFilesIn = (source) => pipe(scalarsIn(source), Array.flatMap(groupsOf(HASH_FILES, "arguments")), Array.flatMap(groupsOf(QUOTED$
|
|
1729
|
+
const hashFilesIn = (source) => pipe(scalarsIn(source), Array.flatMap(groupsOf(HASH_FILES, "arguments")), Array.flatMap(groupsOf(QUOTED$2, "path")), Array.filter(isPositive), Array.flatMap(reference("glob", "hashFiles")));
|
|
1715
1730
|
const jobsOf = (source) => entriesOf(childOf("jobs")(parseDocument(source).contents));
|
|
1716
1731
|
/** @internal */
|
|
1717
1732
|
const workflowReferences = (source) => {
|
|
@@ -1730,13 +1745,13 @@ const outputPathsOf = (step) => pipe(stringOf(pathInputOf(step)), Option.toArray
|
|
|
1730
1745
|
/** @internal */
|
|
1731
1746
|
const producedPaths = (source) => pipe(jobsOf(source), Array.flatMap(([, job]) => itemsOf(childOf("steps")(job))), Array.flatMap(outputPathsOf));
|
|
1732
1747
|
// src/features/repository-layout/model/workflow-paths.ts
|
|
1733
|
-
const RULE$
|
|
1748
|
+
const RULE$13 = "workflow-path";
|
|
1734
1749
|
const WORKFLOW_DIRECTORY = ".github/workflows/";
|
|
1735
1750
|
const WORKFLOW_EXTENSIONS = [".yml", ".yaml"];
|
|
1736
|
-
const READ_CONCURRENCY$
|
|
1751
|
+
const READ_CONCURRENCY$8 = 8;
|
|
1737
1752
|
const WILDCARD = /[*?[]/u;
|
|
1738
|
-
const SEPARATOR$
|
|
1739
|
-
const FIRST$
|
|
1753
|
+
const SEPARATOR$3 = "/";
|
|
1754
|
+
const FIRST$4 = 0;
|
|
1740
1755
|
const EXPECTED = {
|
|
1741
1756
|
action: "a directory with action.yml",
|
|
1742
1757
|
directory: "a directory",
|
|
@@ -1760,10 +1775,10 @@ const isDirectoryAt = Effect.fn("isDirectoryAt")(function* isDirectoryAt(root, p
|
|
|
1760
1775
|
return Option.getOrElse(directory, () => false);
|
|
1761
1776
|
});
|
|
1762
1777
|
const hasAction = Effect.fn("hasAction")(function* hasAction(root, path) {
|
|
1763
|
-
const found = yield* pipe(ACTION_DEFINITIONS, Effect.forEach((name) => existsAt(root, `${path}${SEPARATOR$
|
|
1778
|
+
const found = yield* pipe(ACTION_DEFINITIONS, Effect.forEach((name) => existsAt(root, `${path}${SEPARATOR$3}${name}`)));
|
|
1764
1779
|
return pipe(found, Array.some(Boolean));
|
|
1765
1780
|
});
|
|
1766
|
-
const suffixAt = (segments) => (index) => `:(glob)**/${pipe(segments, Array.drop(index), Array.join(SEPARATOR$
|
|
1781
|
+
const suffixAt = (segments) => (index) => `:(glob)**/${pipe(segments, Array.drop(index), Array.join(SEPARATOR$3))}`;
|
|
1767
1782
|
const RESOLVERS = {
|
|
1768
1783
|
action: hasAction,
|
|
1769
1784
|
directory: isDirectoryAt,
|
|
@@ -1771,13 +1786,13 @@ const RESOLVERS = {
|
|
|
1771
1786
|
glob: matchesGlob,
|
|
1772
1787
|
script: Effect.fn("findsScript")(function* findsScript(root, path) {
|
|
1773
1788
|
if (yield* existsAt(root, path)) return true;
|
|
1774
|
-
const segments = String$1.split(path, SEPARATOR$
|
|
1789
|
+
const segments = String$1.split(path, SEPARATOR$3);
|
|
1775
1790
|
return yield* matchesAny(root, Array.makeBy(segments.length, suffixAt(segments)));
|
|
1776
1791
|
})
|
|
1777
1792
|
};
|
|
1778
1793
|
const staticPrefix = (path) => {
|
|
1779
1794
|
const prefix = Array.headNonEmpty(String$1.split(path, WILDCARD));
|
|
1780
|
-
if (String$1.endsWith(SEPARATOR$
|
|
1795
|
+
if (String$1.endsWith(SEPARATOR$3)(prefix)) return String$1.slice(FIRST$4, -1)(prefix);
|
|
1781
1796
|
return prefix;
|
|
1782
1797
|
};
|
|
1783
1798
|
const isIgnored$1 = Effect.fn("isIgnored")(function* isIgnored(root, path) {
|
|
@@ -1786,32 +1801,32 @@ const isIgnored$1 = Effect.fn("isIgnored")(function* isIgnored(root, path) {
|
|
|
1786
1801
|
const ignored = yield* (yield* RepositoryFiles).ignoredPaths(root, [prefix]);
|
|
1787
1802
|
return Array.isReadonlyArrayNonEmpty(ignored);
|
|
1788
1803
|
});
|
|
1789
|
-
const overlaps = (path) => (produced) => produced === path || String$1.startsWith(`${path}${SEPARATOR$
|
|
1804
|
+
const overlaps = (path) => (produced) => produced === path || String$1.startsWith(`${path}${SEPARATOR$3}`)(produced) || String$1.startsWith(`${produced}${SEPARATOR$3}`)(path);
|
|
1790
1805
|
const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, found) {
|
|
1791
1806
|
const prefix = staticPrefix(found.path);
|
|
1792
1807
|
if (pipe(produced, Array.some(overlaps(prefix)))) return false;
|
|
1793
1808
|
if (yield* RESOLVERS[found.kind](root, found.path)) return false;
|
|
1794
1809
|
return !(yield* isIgnored$1(root, found.path));
|
|
1795
1810
|
});
|
|
1796
|
-
const problemOf$
|
|
1811
|
+
const problemOf$5 = (file, source) => (found) => ({
|
|
1797
1812
|
file,
|
|
1798
1813
|
...positionOf(source)(found.offset),
|
|
1799
|
-
rule: RULE$
|
|
1814
|
+
rule: RULE$13,
|
|
1800
1815
|
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.`
|
|
1801
1816
|
});
|
|
1802
|
-
const problemsIn$
|
|
1817
|
+
const problemsIn$6 = Effect.fn("problemsIn")(function* problemsIn(root, workflow) {
|
|
1803
1818
|
const files = yield* RepositoryFiles;
|
|
1804
1819
|
const file = files.join(root, workflow);
|
|
1805
1820
|
const source = yield* files.readFile(file);
|
|
1806
1821
|
if (Option.isNone(source)) return [];
|
|
1807
1822
|
const produced = producedPaths(source.value);
|
|
1808
1823
|
const missing = yield* Effect.filter(workflowReferences(source.value), (found) => isMissing(root, produced, found));
|
|
1809
|
-
return pipe(missing, Array.map(problemOf$
|
|
1824
|
+
return pipe(missing, Array.map(problemOf$5(file, source.value)));
|
|
1810
1825
|
});
|
|
1811
1826
|
/** @internal */
|
|
1812
1827
|
const checkWorkflowPaths = Effect.fn("checkWorkflowPaths")(function* checkWorkflowPaths(root) {
|
|
1813
1828
|
const listed = yield* (yield* RepositoryFiles).listedFiles(root);
|
|
1814
|
-
const found = yield* Effect.forEach(pipe(listed, Array.filter(isWorkflow)), (workflow) => problemsIn$
|
|
1829
|
+
const found = yield* Effect.forEach(pipe(listed, Array.filter(isWorkflow)), (workflow) => problemsIn$6(root, workflow), { concurrency: READ_CONCURRENCY$8 });
|
|
1815
1830
|
return Array.flatten(found);
|
|
1816
1831
|
});
|
|
1817
1832
|
// src/features/repository-layout/model/workspace-checks.ts
|
|
@@ -1828,149 +1843,8 @@ const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(r
|
|
|
1828
1843
|
], { concurrency: "unbounded" });
|
|
1829
1844
|
return Array.flatten(found);
|
|
1830
1845
|
});
|
|
1831
|
-
// src/features/scripts/model/shell-scripts.ts
|
|
1832
|
-
const SHELL_FILE = /\.(?:sh|bash|zsh|ksh|fish|command)$/u;
|
|
1833
|
-
const SHELL_SHEBANG = /^#!\S*(?:\/|\s)(?:env\s+)?(?:-\S+\s+)*(?:ba|z|k|da)?sh\b|^#!\S*fish\b/u;
|
|
1834
|
-
const EXTENSION = /\.[^./]+$/u;
|
|
1835
|
-
const SETTINGS_FILE = ".claude/settings.json";
|
|
1836
|
-
const READ_CONCURRENCY$4 = 64;
|
|
1837
|
-
const FIRST = 1;
|
|
1838
|
-
const RULE$5 = "shell-script";
|
|
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.";
|
|
1840
|
-
const HookSchema = Schema.Struct({
|
|
1841
|
-
command: Schema.optional(Schema.String),
|
|
1842
|
-
args: Schema.optional(Schema.Array(Schema.String))
|
|
1843
|
-
});
|
|
1844
|
-
const MatcherSchema = Schema.Struct({ hooks: Schema.Array(HookSchema) });
|
|
1845
|
-
const HooksSchema = Schema.Struct({ SessionStart: Schema.optional(Schema.Array(MatcherSchema)) });
|
|
1846
|
-
const SettingsSchema = Schema.Struct({ hooks: Schema.optional(HooksSchema) });
|
|
1847
|
-
const decodeSettings = Schema.decodeOption(Schema.fromJsonString(SettingsSchema));
|
|
1848
|
-
const NO_TEXT = [];
|
|
1849
|
-
const commandText = ({ command, args }) => [...Option.toArray(Option.fromUndefinedOr(command)), ...pipe(Option.fromUndefinedOr(args), Option.getOrElse(() => NO_TEXT))];
|
|
1850
|
-
const matcherText = ({ hooks }) => pipe(hooks, Array.flatMap((hook) => commandText(hook)));
|
|
1851
|
-
const sessionStartCommands = (source) => {
|
|
1852
|
-
const matchers = pipe(decodeSettings(source), Option.flatMap(({ hooks }) => Option.fromUndefinedOr(hooks)), Option.flatMap(({ SessionStart }) => Option.fromUndefinedOr(SessionStart)));
|
|
1853
|
-
return pipe(matchers, Option.map(Array.flatMap((matcher) => matcherText(matcher))), Option.getOrElse(() => NO_TEXT));
|
|
1854
|
-
};
|
|
1855
|
-
const baseName = (name) => pipe(String$1.split("/")(name), Array.last, Option.getOrElse(() => name));
|
|
1856
|
-
const hasExtension = (name) => EXTENSION.test(baseName(name));
|
|
1857
|
-
const problemFor = (file) => ({
|
|
1858
|
-
file,
|
|
1859
|
-
line: FIRST,
|
|
1860
|
-
column: FIRST,
|
|
1861
|
-
rule: RULE$5,
|
|
1862
|
-
message: MESSAGE$3
|
|
1863
|
-
});
|
|
1864
|
-
/** @internal */
|
|
1865
|
-
const checkShellScripts = Effect.fn("checkShellScripts")(function* checkShellScripts(root) {
|
|
1866
|
-
const files = yield* RepositoryFiles;
|
|
1867
|
-
const names = yield* files.listedFiles(root);
|
|
1868
|
-
const settings = yield* files.readFile(files.join(root, SETTINGS_FILE));
|
|
1869
|
-
const commands = pipe(settings, Option.map(sessionStartCommands), Option.getOrElse(() => NO_TEXT));
|
|
1870
|
-
const isSessionStartHook = (name) => pipe(commands, Array.some(String$1.includes(name)));
|
|
1871
|
-
const isShell = (name) => {
|
|
1872
|
-
const file = files.join(root, name);
|
|
1873
|
-
if (SHELL_FILE.test(name)) return files.exists(file);
|
|
1874
|
-
if (hasExtension(name)) return Effect.succeed(false);
|
|
1875
|
-
return files.readFile(file).pipe(Effect.map(Option.exists((source) => SHELL_SHEBANG.test(source))));
|
|
1876
|
-
};
|
|
1877
|
-
const candidates = pipe(names, Array.filter((name) => !isSessionStartHook(name)));
|
|
1878
|
-
const shell = yield* Effect.filter(candidates, isShell, { concurrency: READ_CONCURRENCY$4 });
|
|
1879
|
-
return pipe(shell, Array.map((name) => problemFor(files.join(root, name))));
|
|
1880
|
-
});
|
|
1881
|
-
// src/shared/lib/workflow-files.ts
|
|
1882
|
-
const WORKFLOW_FILE = /^\.github\/workflows\/[^/]+\.ya?ml$/u;
|
|
1883
|
-
const READ_CONCURRENCY$3 = 16;
|
|
1884
|
-
const readWorkflows = Effect.fn("readWorkflows")(function* readWorkflows(root) {
|
|
1885
|
-
const files = yield* RepositoryFiles;
|
|
1886
|
-
const names = yield* files.listedFiles(root);
|
|
1887
|
-
const found = yield* Effect.forEach(pipe(names, Array.filter((name) => WORKFLOW_FILE.test(name))), (name) => {
|
|
1888
|
-
const file = files.join(root, name);
|
|
1889
|
-
return files.readFile(file).pipe(Effect.map(Option.map((source) => ({
|
|
1890
|
-
file,
|
|
1891
|
-
source
|
|
1892
|
-
}))));
|
|
1893
|
-
}, { concurrency: READ_CONCURRENCY$3 });
|
|
1894
|
-
return Array.getSomes(found);
|
|
1895
|
-
});
|
|
1896
|
-
// src/features/scripts/model/workflows.ts
|
|
1897
|
-
const COMMAND_CHAIN = /&&|\|\||;|\|/u;
|
|
1898
|
-
const QUOTED = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
1899
|
-
const COMMENT = "#";
|
|
1900
|
-
const RUN_KEY = "run";
|
|
1901
|
-
const RULE$4 = "workflow-script";
|
|
1902
|
-
const START$4 = 0;
|
|
1903
|
-
const ONE_COMMAND = 1;
|
|
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.";
|
|
1905
|
-
const startOf = (range) => pipe(Option.fromNullishOr(range), Option.map(([start]) => start), Option.getOrElse(() => START$4));
|
|
1906
|
-
const runScriptsOf = (source) => {
|
|
1907
|
-
const found = [];
|
|
1908
|
-
visit(parseDocument(source), { Pair: (_key, pair) => {
|
|
1909
|
-
if (isPair(pair) && isScalar(pair.key) && pair.key.value === RUN_KEY && isScalar(pair.value) && typeof pair.value.value === "string") found.push({
|
|
1910
|
-
text: pair.value.value,
|
|
1911
|
-
start: startOf(pair.value.range)
|
|
1912
|
-
});
|
|
1913
|
-
} });
|
|
1914
|
-
return found;
|
|
1915
|
-
};
|
|
1916
|
-
const isCommand = (line) => String$1.isNonEmpty(line) && !String$1.startsWith(COMMENT)(line);
|
|
1917
|
-
const chainsCommands = (line) => COMMAND_CHAIN.test(String$1.replaceAll(QUOTED, "")(line));
|
|
1918
|
-
const runsMoreThanOneCommand = ({ text }) => {
|
|
1919
|
-
const lines = pipe(String$1.split("\n")(text), Array.map(String$1.trim), Array.filter(isCommand));
|
|
1920
|
-
return lines.length > ONE_COMMAND || pipe(lines, Array.some(chainsCommands));
|
|
1921
|
-
};
|
|
1922
|
-
const problemsIn$1 = (file) => (source) => {
|
|
1923
|
-
const at = positionOf(source);
|
|
1924
|
-
return pipe(runScriptsOf(source), Array.filter(runsMoreThanOneCommand), Array.map(({ start }) => ({
|
|
1925
|
-
file,
|
|
1926
|
-
...at(start),
|
|
1927
|
-
rule: RULE$4,
|
|
1928
|
-
message: MESSAGE$2
|
|
1929
|
-
})));
|
|
1930
|
-
};
|
|
1931
|
-
/** @internal */
|
|
1932
|
-
const checkWorkflows = Effect.fn("checkWorkflows")(function* checkWorkflows(root) {
|
|
1933
|
-
const workflows = yield* readWorkflows(root);
|
|
1934
|
-
return pipe(workflows, Array.flatMap(({ file, source }) => problemsIn$1(file)(source)));
|
|
1935
|
-
});
|
|
1936
|
-
// src/features/scripts/model/script-checks.ts
|
|
1937
|
-
/** @internal */
|
|
1938
|
-
const checkScripts = Effect.fn("checkScripts")(function* checkScripts(root) {
|
|
1939
|
-
const found = yield* Effect.all([checkShellScripts(root), checkWorkflows(root)], { concurrency: "unbounded" });
|
|
1940
|
-
return Array.flatten(found);
|
|
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
1846
|
// src/features/pass-through-wrappers/model/pass-through-wrappers.ts
|
|
1973
|
-
const RULE$
|
|
1847
|
+
const RULE$12 = "pass-through-wrapper";
|
|
1974
1848
|
const SINGLE_STATEMENT = 1;
|
|
1975
1849
|
const SINGLE_DECLARATION = 1;
|
|
1976
1850
|
const THIS_PARAMETER = "this";
|
|
@@ -2064,14 +1938,14 @@ const isPassThrough = (checker) => (candidate) => (forward) => {
|
|
|
2064
1938
|
const restForwarded = pipe(wrapper.parameters, Array.some(isRest));
|
|
2065
1939
|
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
1940
|
};
|
|
2067
|
-
const problemOf$
|
|
1941
|
+
const problemOf$4 = (checker) => (candidate) => {
|
|
2068
1942
|
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$
|
|
1943
|
+
return pipe(returnedExpression(candidate.wrapper), Option.flatMap(forwardOf), Option.filter(isPassThrough(checker)(candidate)), Option.map((forward) => problemAt$1({
|
|
1944
|
+
rule: RULE$12,
|
|
2071
1945
|
message: messageOf(forward.callee.getText())
|
|
2072
1946
|
})(candidate.name)));
|
|
2073
1947
|
};
|
|
2074
|
-
const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$
|
|
1948
|
+
const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$4(checker)), Array.getSomes);
|
|
2075
1949
|
// src/features/value-owners/model/slots.ts
|
|
2076
1950
|
const ANNOTATED_KINDS = /* @__PURE__ */ new Set([
|
|
2077
1951
|
SyntaxKind.Parameter,
|
|
@@ -2168,7 +2042,7 @@ const ownerValuesOf = (checker) => (declaration) => {
|
|
|
2168
2042
|
const type = checker.getTypeAtLocation(declaration.name);
|
|
2169
2043
|
return finiteValuesOf(checker)(type).pipe(Option.orElse(() => objectValuesOf(checker)(type)));
|
|
2170
2044
|
};
|
|
2171
|
-
const annotationProblem = (message) => problemAt({
|
|
2045
|
+
const annotationProblem = (message) => problemAt$1({
|
|
2172
2046
|
rule: "owner-annotation",
|
|
2173
2047
|
message
|
|
2174
2048
|
});
|
|
@@ -2293,7 +2167,7 @@ const shapeProblem = (site, matches) => {
|
|
|
2293
2167
|
onNone: () => "Derive it from the library type, for example with Pick, instead of copying its properties.",
|
|
2294
2168
|
onSome: () => "Use the library type instead of copying it."
|
|
2295
2169
|
});
|
|
2296
|
-
return problemAt({
|
|
2170
|
+
return problemAt$1({
|
|
2297
2171
|
rule: "library-shape",
|
|
2298
2172
|
message: `This shape copies ${shown}. ${advice}`
|
|
2299
2173
|
})(site.node);
|
|
@@ -2387,7 +2261,7 @@ const derivedVerdict = (context) => (site) => {
|
|
|
2387
2261
|
const added = pipe(site.values, Array.filter((value) => !isSubsetOf([value], held)));
|
|
2388
2262
|
if (!Array.isReadonlyArrayNonEmpty(owners) || !Array.isReadonlyArrayNonEmpty(added)) return verdict([], []);
|
|
2389
2263
|
const message = `This set adds ${formatValues(added)} to ${describeOwners(owners)}. Add the values to the owner, or register the wider set as its own concept.`;
|
|
2390
|
-
return verdict([problemAt({
|
|
2264
|
+
return verdict([problemAt$1({
|
|
2391
2265
|
rule: "owner-extension",
|
|
2392
2266
|
message
|
|
2393
2267
|
})(site.node)], []);
|
|
@@ -2409,7 +2283,7 @@ const originalVerdict = (context) => (site) => {
|
|
|
2409
2283
|
const owners = pipe(context.owners, Array.filter((owner) => isSubsetOf(site.values, owner.values)));
|
|
2410
2284
|
if (Array.isReadonlyArrayNonEmpty(owners)) {
|
|
2411
2285
|
const message = `The values ${formatValues(site.values)} are owned by ${describeOwners(owners)}. Derive this set from the owner instead of restating it.`;
|
|
2412
|
-
return verdict([problemAt({
|
|
2286
|
+
return verdict([problemAt$1({
|
|
2413
2287
|
rule: "owner-value-set",
|
|
2414
2288
|
message
|
|
2415
2289
|
})(site.node)], []);
|
|
@@ -2417,7 +2291,7 @@ const originalVerdict = (context) => (site) => {
|
|
|
2417
2291
|
const candidates = libraryCandidates(context)(site);
|
|
2418
2292
|
if (Array.isReadonlyArrayNonEmpty(candidates)) {
|
|
2419
2293
|
const message = `The values ${formatValues(site.values)} restate a dependency type: ${listCandidates(candidates)}. Derive this set from the library type.`;
|
|
2420
|
-
return verdict([problemAt({
|
|
2294
|
+
return verdict([problemAt$1({
|
|
2421
2295
|
rule: "library-value-set",
|
|
2422
2296
|
message
|
|
2423
2297
|
})(site.node)], []);
|
|
@@ -2448,7 +2322,7 @@ const isValuePosition = (node) => {
|
|
|
2448
2322
|
const { parent } = node;
|
|
2449
2323
|
return VALUE_PARENT_KINDS.has(parent.kind) || pipe(VALUE_SLOTS, Array.some((isSlot) => isSlot(node, parent)));
|
|
2450
2324
|
};
|
|
2451
|
-
const ownedLiteralProblem = (context) => (literal) => Option.fromUndefinedOr(context.checker.getContextualType(literal)).pipe(Option.filter((contextual) => vocabularyOf(context.checker)(contextual).pipe(Option.exists((vocabulary) => !vocabulary.admitsUnnamedValues))), Option.map(() => pipe(contextSymbolsOf(context.checker)(literal), Array.flatMap((symbol) => ownersBehind(context)(symbol, [])), uniqueByReference, Array.filter((owner) => isSubsetOf([literal.text], pipe(owner.values, Array.map(String)))))), Option.filter((owners) => Array.isReadonlyArrayNonEmpty(owners)), Option.map((owners) => problemAt({
|
|
2325
|
+
const ownedLiteralProblem = (context) => (literal) => Option.fromUndefinedOr(context.checker.getContextualType(literal)).pipe(Option.filter((contextual) => vocabularyOf(context.checker)(contextual).pipe(Option.exists((vocabulary) => !vocabulary.admitsUnnamedValues))), Option.map(() => pipe(contextSymbolsOf(context.checker)(literal), Array.flatMap((symbol) => ownersBehind(context)(symbol, [])), uniqueByReference, Array.filter((owner) => isSubsetOf([literal.text], pipe(owner.values, Array.map(String)))))), Option.filter((owners) => Array.isReadonlyArrayNonEmpty(owners)), Option.map((owners) => problemAt$1({
|
|
2452
2326
|
rule: "owned-literal",
|
|
2453
2327
|
message: `${literal.getText()} is a value of ${describeOwners(owners)}. Write it through the owner's binding instead of as a literal.`
|
|
2454
2328
|
})(literal)));
|
|
@@ -2721,6 +2595,444 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
|
|
|
2721
2595
|
// src/app/source-checks.ts
|
|
2722
2596
|
/** @internal */
|
|
2723
2597
|
const checkSources = (root) => checkRepository(root, [passThroughWrappersIn]);
|
|
2598
|
+
// src/features/agent-settings/model/missing-hooks.ts
|
|
2599
|
+
const RULE$11 = "missing-hook";
|
|
2600
|
+
const SETTINGS_FILE$1 = /^\.claude\/settings\.json$/u;
|
|
2601
|
+
const PLUGIN_HOOKS_FILE = /(?:^|\/)hooks\/hooks\.json$/u;
|
|
2602
|
+
const PROJECT_PATH = /(?<optional>--env-file-if-exists=)?\$\{?CLAUDE_PROJECT_DIR\}?(?:\\")?\/(?<path>[\w.@/-]+)/gu;
|
|
2603
|
+
const PLUGIN_PATH = /(?<optional>--env-file-if-exists=)?\$\{?CLAUDE_PLUGIN_ROOT\}?(?:\\")?\/(?<path>[\w.@/-]+)/gu;
|
|
2604
|
+
const PLUGIN_ROOT = "..";
|
|
2605
|
+
const READ_CONCURRENCY$7 = 16;
|
|
2606
|
+
const START$9 = 0;
|
|
2607
|
+
const referenceOf = (found) => pipe(groupOf("path")(found), Option.filter(() => Option.isNone(groupOf("optional")(found))), Option.map((path) => ({
|
|
2608
|
+
path,
|
|
2609
|
+
index: found.index ?? START$9
|
|
2610
|
+
})), Option.toArray);
|
|
2611
|
+
const referencesIn = (pattern, source) => pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.flatMap(referenceOf));
|
|
2612
|
+
const problemsIn$5 = Effect.fn("problemsIn")(function* problemsIn({ root, file, base, pattern }) {
|
|
2613
|
+
const files = yield* RepositoryFiles;
|
|
2614
|
+
const text = yield* files.readFile(file);
|
|
2615
|
+
if (Option.isNone(text)) return [];
|
|
2616
|
+
const source = text.value;
|
|
2617
|
+
const absent = yield* Effect.filter(referencesIn(pattern, source), ({ path }) => files.exists(files.join(base, path)).pipe(Effect.map((exists) => !exists)));
|
|
2618
|
+
const targetOf = ({ path }) => files.join(base, path);
|
|
2619
|
+
const built = yield* files.ignoredPaths(root, pipe(absent, Array.map(targetOf)));
|
|
2620
|
+
const missing = pipe(absent, Array.filter((reference) => !Array.contains(built, targetOf(reference))));
|
|
2621
|
+
return pipe(missing, Array.map(({ path, index }) => ({
|
|
2622
|
+
file,
|
|
2623
|
+
...positionOf(source)(index),
|
|
2624
|
+
rule: RULE$11,
|
|
2625
|
+
message: `runs ${path}, which does not exist. The hook fails every time it fires. Point it at a file that exists or remove the hook.`
|
|
2626
|
+
})));
|
|
2627
|
+
});
|
|
2628
|
+
/** @internal */
|
|
2629
|
+
const checkMissingHooks = Effect.fn("checkMissingHooks")(function* checkMissingHooks(root) {
|
|
2630
|
+
const files = yield* RepositoryFiles;
|
|
2631
|
+
const listed = yield* files.listedFiles(root);
|
|
2632
|
+
const hookFiles = pipe(listed, Array.flatMap((name) => {
|
|
2633
|
+
const file = files.join(root, name);
|
|
2634
|
+
if (SETTINGS_FILE$1.test(name)) return [{
|
|
2635
|
+
root,
|
|
2636
|
+
file,
|
|
2637
|
+
base: root,
|
|
2638
|
+
pattern: PROJECT_PATH
|
|
2639
|
+
}];
|
|
2640
|
+
if (PLUGIN_HOOKS_FILE.test(name)) return [{
|
|
2641
|
+
root,
|
|
2642
|
+
file,
|
|
2643
|
+
base: files.join(files.dirname(file), PLUGIN_ROOT),
|
|
2644
|
+
pattern: PLUGIN_PATH
|
|
2645
|
+
}];
|
|
2646
|
+
return [];
|
|
2647
|
+
}));
|
|
2648
|
+
const found = yield* Effect.forEach(hookFiles, problemsIn$5, { concurrency: READ_CONCURRENCY$7 });
|
|
2649
|
+
return Array.flatten(found);
|
|
2650
|
+
});
|
|
2651
|
+
// src/features/scripts/model/shell-scripts.ts
|
|
2652
|
+
const SHELL_FILE = /\.(?:sh|bash|zsh|ksh|fish|command)$/u;
|
|
2653
|
+
const SHELL_SHEBANG = /^#!\S*(?:\/|\s)(?:env\s+)?(?:-\S+\s+)*(?:ba|z|k|da)?sh\b|^#!\S*fish\b/u;
|
|
2654
|
+
const EXTENSION = /\.[^./]+$/u;
|
|
2655
|
+
const SETTINGS_FILE = ".claude/settings.json";
|
|
2656
|
+
const READ_CONCURRENCY$6 = 64;
|
|
2657
|
+
const FIRST$3 = 1;
|
|
2658
|
+
const RULE$10 = "shell-script";
|
|
2659
|
+
const MESSAGE$4 = "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.";
|
|
2660
|
+
const HookSchema = Schema.Struct({
|
|
2661
|
+
command: Schema.optional(Schema.String),
|
|
2662
|
+
args: Schema.optional(Schema.Array(Schema.String))
|
|
2663
|
+
});
|
|
2664
|
+
const MatcherSchema = Schema.Struct({ hooks: Schema.Array(HookSchema) });
|
|
2665
|
+
const HooksSchema = Schema.Struct({ SessionStart: Schema.optional(Schema.Array(MatcherSchema)) });
|
|
2666
|
+
const SettingsSchema = Schema.Struct({ hooks: Schema.optional(HooksSchema) });
|
|
2667
|
+
const decodeSettings = Schema.decodeOption(Schema.fromJsonString(SettingsSchema));
|
|
2668
|
+
const NO_TEXT = [];
|
|
2669
|
+
const commandText = ({ command, args }) => [...Option.toArray(Option.fromUndefinedOr(command)), ...pipe(Option.fromUndefinedOr(args), Option.getOrElse(() => NO_TEXT))];
|
|
2670
|
+
const matcherText = ({ hooks }) => pipe(hooks, Array.flatMap((hook) => commandText(hook)));
|
|
2671
|
+
const sessionStartCommands = (source) => {
|
|
2672
|
+
const matchers = pipe(decodeSettings(source), Option.flatMap(({ hooks }) => Option.fromUndefinedOr(hooks)), Option.flatMap(({ SessionStart }) => Option.fromUndefinedOr(SessionStart)));
|
|
2673
|
+
return pipe(matchers, Option.map(Array.flatMap((matcher) => matcherText(matcher))), Option.getOrElse(() => NO_TEXT));
|
|
2674
|
+
};
|
|
2675
|
+
const baseName = (name) => pipe(String$1.split("/")(name), Array.last, Option.getOrElse(() => name));
|
|
2676
|
+
const hasExtension = (name) => EXTENSION.test(baseName(name));
|
|
2677
|
+
const problemFor$1 = (file) => ({
|
|
2678
|
+
file,
|
|
2679
|
+
line: FIRST$3,
|
|
2680
|
+
column: FIRST$3,
|
|
2681
|
+
rule: RULE$10,
|
|
2682
|
+
message: MESSAGE$4
|
|
2683
|
+
});
|
|
2684
|
+
/** @internal */
|
|
2685
|
+
const checkShellScripts = Effect.fn("checkShellScripts")(function* checkShellScripts(root) {
|
|
2686
|
+
const files = yield* RepositoryFiles;
|
|
2687
|
+
const names = yield* files.listedFiles(root);
|
|
2688
|
+
const settings = yield* files.readFile(files.join(root, SETTINGS_FILE));
|
|
2689
|
+
const commands = pipe(settings, Option.map(sessionStartCommands), Option.getOrElse(() => NO_TEXT));
|
|
2690
|
+
const isSessionStartHook = (name) => pipe(commands, Array.some(String$1.includes(name)));
|
|
2691
|
+
const isShell = (name) => {
|
|
2692
|
+
const file = files.join(root, name);
|
|
2693
|
+
if (SHELL_FILE.test(name)) return files.exists(file);
|
|
2694
|
+
if (hasExtension(name)) return Effect.succeed(false);
|
|
2695
|
+
return files.readFile(file).pipe(Effect.map(Option.exists((source) => SHELL_SHEBANG.test(source))));
|
|
2696
|
+
};
|
|
2697
|
+
const candidates = pipe(names, Array.filter((name) => !isSessionStartHook(name)));
|
|
2698
|
+
const shell = yield* Effect.filter(candidates, isShell, { concurrency: READ_CONCURRENCY$6 });
|
|
2699
|
+
return pipe(shell, Array.map((name) => problemFor$1(files.join(root, name))));
|
|
2700
|
+
});
|
|
2701
|
+
// src/shared/lib/workflow-files.ts
|
|
2702
|
+
const WORKFLOW_FILE = /^\.github\/workflows\/[^/]+\.ya?ml$/u;
|
|
2703
|
+
const READ_CONCURRENCY$5 = 16;
|
|
2704
|
+
const readWorkflows = Effect.fn("readWorkflows")(function* readWorkflows(root) {
|
|
2705
|
+
const files = yield* RepositoryFiles;
|
|
2706
|
+
const names = yield* files.listedFiles(root);
|
|
2707
|
+
const found = yield* Effect.forEach(pipe(names, Array.filter((name) => WORKFLOW_FILE.test(name))), (name) => {
|
|
2708
|
+
const file = files.join(root, name);
|
|
2709
|
+
return files.readFile(file).pipe(Effect.map(Option.map((source) => ({
|
|
2710
|
+
file,
|
|
2711
|
+
source
|
|
2712
|
+
}))));
|
|
2713
|
+
}, { concurrency: READ_CONCURRENCY$5 });
|
|
2714
|
+
return Array.getSomes(found);
|
|
2715
|
+
});
|
|
2716
|
+
// src/shared/lib/workflow-run.ts
|
|
2717
|
+
const RUN_KEY = "run";
|
|
2718
|
+
const START$8 = 0;
|
|
2719
|
+
const startOf = (range) => pipe(Option.fromNullishOr(range), Option.map(([start]) => start), Option.getOrElse(() => START$8));
|
|
2720
|
+
const runScriptsOf = (source) => {
|
|
2721
|
+
const found = [];
|
|
2722
|
+
visit(parseDocument(source), { Pair: (_key, pair) => {
|
|
2723
|
+
if (isPair(pair) && isScalar(pair.key) && pair.key.value === RUN_KEY && isScalar(pair.value) && typeof pair.value.value === "string") found.push({
|
|
2724
|
+
text: pair.value.value,
|
|
2725
|
+
start: startOf(pair.value.range)
|
|
2726
|
+
});
|
|
2727
|
+
} });
|
|
2728
|
+
return found;
|
|
2729
|
+
};
|
|
2730
|
+
// src/features/scripts/model/workflows.ts
|
|
2731
|
+
const COMMAND_CHAIN = /&&|\|\||;|\|/u;
|
|
2732
|
+
const QUOTED$1 = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
2733
|
+
const COMMENT = "#";
|
|
2734
|
+
const RULE$9 = "workflow-script";
|
|
2735
|
+
const ONE_COMMAND = 1;
|
|
2736
|
+
const MESSAGE$3 = "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.";
|
|
2737
|
+
const isCommand = (line) => String$1.isNonEmpty(line) && !String$1.startsWith(COMMENT)(line);
|
|
2738
|
+
const chainsCommands = (line) => COMMAND_CHAIN.test(String$1.replaceAll(QUOTED$1, "")(line));
|
|
2739
|
+
const runsMoreThanOneCommand = ({ text }) => {
|
|
2740
|
+
const lines = pipe(String$1.split("\n")(text), Array.map(String$1.trim), Array.filter(isCommand));
|
|
2741
|
+
return lines.length > ONE_COMMAND || pipe(lines, Array.some(chainsCommands));
|
|
2742
|
+
};
|
|
2743
|
+
const problemsIn$4 = (file) => (source) => {
|
|
2744
|
+
const at = positionOf(source);
|
|
2745
|
+
return pipe(runScriptsOf(source), Array.filter(runsMoreThanOneCommand), Array.map(({ start }) => ({
|
|
2746
|
+
file,
|
|
2747
|
+
...at(start),
|
|
2748
|
+
rule: RULE$9,
|
|
2749
|
+
message: MESSAGE$3
|
|
2750
|
+
})));
|
|
2751
|
+
};
|
|
2752
|
+
/** @internal */
|
|
2753
|
+
const checkWorkflows = Effect.fn("checkWorkflows")(function* checkWorkflows(root) {
|
|
2754
|
+
const workflows = yield* readWorkflows(root);
|
|
2755
|
+
return pipe(workflows, Array.flatMap(({ file, source }) => problemsIn$4(file)(source)));
|
|
2756
|
+
});
|
|
2757
|
+
// src/features/scripts/model/script-checks.ts
|
|
2758
|
+
/** @internal */
|
|
2759
|
+
const checkScripts = Effect.fn("checkScripts")(function* checkScripts(root) {
|
|
2760
|
+
const found = yield* Effect.all([checkShellScripts(root), checkWorkflows(root)], { concurrency: "unbounded" });
|
|
2761
|
+
return Array.flatten(found);
|
|
2762
|
+
});
|
|
2763
|
+
// src/features/vite-plus/model/command-words.ts
|
|
2764
|
+
const CONTINUATION = /\\\n/gu;
|
|
2765
|
+
const QUOTED = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
2766
|
+
const SEPARATOR$2 = /&&|\|\||[;|\n`]|\$\(/u;
|
|
2767
|
+
const BLANK$1 = /\s+/u;
|
|
2768
|
+
const ASSIGNMENT = /^[A-Za-z_][A-Za-z0-9_]*=/u;
|
|
2769
|
+
const QUOTE = "\"\"";
|
|
2770
|
+
const wordsOf = (segment) => pipe(String$1.split(String$1.trim(segment), BLANK$1), Array.filter(String$1.isNonEmpty), Array.dropWhile((word) => ASSIGNMENT.test(word)));
|
|
2771
|
+
const simpleCommands = (text) => pipe(text, String$1.replaceAll(CONTINUATION, " "), String$1.replaceAll(QUOTED, QUOTE), String$1.split(SEPARATOR$2), Array.map(wordsOf), Array.filter(Array.isReadonlyArrayNonEmpty));
|
|
2772
|
+
// src/features/vite-plus/model/command-problems.ts
|
|
2773
|
+
const PACKAGE_MANAGERS = [
|
|
2774
|
+
"pnpm",
|
|
2775
|
+
"pnpx",
|
|
2776
|
+
"npm",
|
|
2777
|
+
"npx",
|
|
2778
|
+
"yarn",
|
|
2779
|
+
"bun",
|
|
2780
|
+
"bunx"
|
|
2781
|
+
];
|
|
2782
|
+
const VITE_PLUS = "vp";
|
|
2783
|
+
const RUN = "run";
|
|
2784
|
+
const GIT = "git";
|
|
2785
|
+
const GITHUB$1 = "gh";
|
|
2786
|
+
const MERGE = "merge";
|
|
2787
|
+
const SKIP_HOOKS = "--no-verify";
|
|
2788
|
+
const BYPASS_RULESET = "--admin";
|
|
2789
|
+
const FILTER = /^(?:--filter(?:=.*)?|-F)$/u;
|
|
2790
|
+
const TASK_KINDS = ["script", "task"];
|
|
2791
|
+
const SECOND = 1;
|
|
2792
|
+
const programOf = (words) => Array.headNonEmpty(words);
|
|
2793
|
+
const subcommandOf = (words) => Array.get(words, SECOND);
|
|
2794
|
+
const RULES = [
|
|
2795
|
+
{
|
|
2796
|
+
rule: "package-manager-command",
|
|
2797
|
+
applies: (_source, words) => Array.contains(PACKAGE_MANAGERS, programOf(words)),
|
|
2798
|
+
message: (command) => `\`${command}\` calls the package manager directly. Run it through vp (vp install, vp add, vp exec, vp dlx, vp run), so that hooks, CI and sessions all use the toolchain Vite+ pins.`
|
|
2799
|
+
},
|
|
2800
|
+
{
|
|
2801
|
+
rule: "skipped-gate",
|
|
2802
|
+
applies: (_source, words) => programOf(words) === GIT && Array.contains(words, SKIP_HOOKS) || programOf(words) === GITHUB$1 && Array.contains(words, MERGE) && Array.contains(words, BYPASS_RULESET),
|
|
2803
|
+
message: (command) => `\`${command}\` skips a gate: ${SKIP_HOOKS} skips the hooks that run verify, and ${BYPASS_RULESET} bypasses the ruleset. Remove the flag and fix what the gate reports.`
|
|
2804
|
+
},
|
|
2805
|
+
{
|
|
2806
|
+
rule: "filter-task",
|
|
2807
|
+
applies: (source, words) => Array.contains(TASK_KINDS, source.kind) && programOf(words) === VITE_PLUS && Option.contains(subcommandOf(words), RUN) && pipe(words, Array.some((word) => FILTER.test(word))),
|
|
2808
|
+
message: (command) => `\`${command}\` wraps one package's task in another task. Write <package>#<task> in dependsOn instead, so that Vite+ sees the dependency and caches it.`
|
|
2809
|
+
}
|
|
2810
|
+
];
|
|
2811
|
+
const problemsOf = (source) => pipe(simpleCommands(source.text), Array.flatMap((words) => pipe(RULES, Array.filter(({ applies }) => applies(source, words)), Array.map(({ rule, message }) => ({
|
|
2812
|
+
file: source.file,
|
|
2813
|
+
...source.position,
|
|
2814
|
+
rule,
|
|
2815
|
+
message: message(String$1.trim(Array.join(words, " ")))
|
|
2816
|
+
})))));
|
|
2817
|
+
const commandProblems$1 = (sources) => pipe(sources, Array.flatMap(problemsOf));
|
|
2818
|
+
// src/features/vite-plus/model/command-sources.ts
|
|
2819
|
+
const ROOT_DIRECTORY = ".";
|
|
2820
|
+
const COMMAND_KEY = "command";
|
|
2821
|
+
const ARGUMENTS_KEY = "args";
|
|
2822
|
+
const EXCLUDED$1 = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
|
|
2823
|
+
const MANIFESTS = [`:(glob)**/${MANIFEST_FILE}`, ...EXCLUDED$1];
|
|
2824
|
+
const STEP_FILES = [
|
|
2825
|
+
":(glob).github/workflows/*.yml",
|
|
2826
|
+
":(glob).github/workflows/*.yaml",
|
|
2827
|
+
":(glob)**/action.yml",
|
|
2828
|
+
":(glob)**/action.yaml",
|
|
2829
|
+
...EXCLUDED$1
|
|
2830
|
+
];
|
|
2831
|
+
const HOOK_FILES = [":(glob).vite-hooks/*"];
|
|
2832
|
+
const AGENT_FILES = [".claude/settings.json", ".mcp.json"];
|
|
2833
|
+
const READ_CONCURRENCY$4 = 16;
|
|
2834
|
+
const START$7 = 0;
|
|
2835
|
+
const FIRST$2 = 1;
|
|
2836
|
+
const LINE = "\n";
|
|
2837
|
+
const CommandText = Schema.Union([Schema.String, Schema.Array(Schema.String)]);
|
|
2838
|
+
const decodeCommandText = Schema.decodeUnknownOption(CommandText);
|
|
2839
|
+
const Scripts = Schema.Struct({ scripts: Schema.optional(Schema.Record(Schema.String, Schema.String)) });
|
|
2840
|
+
const decodeScripts = Schema.decodeUnknownOption(Schema.fromJsonString(Scripts));
|
|
2841
|
+
const decodeJson = Schema.decodeUnknownOption(Schema.fromJsonString(Schema.Unknown));
|
|
2842
|
+
const decodeArguments = Schema.decodeUnknownOption(Schema.Array(Schema.String));
|
|
2843
|
+
const NO_SOURCES = [];
|
|
2844
|
+
const offsetOf$2 = (source, text) => pipe(String$1.indexOf(text)(source), Option.getOrElse(() => START$7));
|
|
2845
|
+
const scriptSources = (file) => (source) => pipe(decodeScripts(source), Option.flatMap(({ scripts }) => Option.fromUndefinedOr(scripts)), Option.map(Record.toEntries), Option.getOrElse(() => []), Array.map(([name, text]) => {
|
|
2846
|
+
const offset = offsetOf$2(source, `"${name}"`);
|
|
2847
|
+
return {
|
|
2848
|
+
kind: "script",
|
|
2849
|
+
file,
|
|
2850
|
+
position: positionOf(source)(offset),
|
|
2851
|
+
name,
|
|
2852
|
+
text
|
|
2853
|
+
};
|
|
2854
|
+
}));
|
|
2855
|
+
const stepSources = (file) => (source) => pipe(runScriptsOf(source), Array.map(({ text, start }) => ({
|
|
2856
|
+
kind: "step",
|
|
2857
|
+
file,
|
|
2858
|
+
position: positionOf(source)(start),
|
|
2859
|
+
name: "run",
|
|
2860
|
+
text
|
|
2861
|
+
})));
|
|
2862
|
+
const hookSources = (file, name) => (source) => pipe(String$1.split(source, LINE), Array.map((text, index) => ({
|
|
2863
|
+
kind: "hook",
|
|
2864
|
+
file,
|
|
2865
|
+
position: {
|
|
2866
|
+
line: index + FIRST$2,
|
|
2867
|
+
column: FIRST$2
|
|
2868
|
+
},
|
|
2869
|
+
name,
|
|
2870
|
+
text
|
|
2871
|
+
})));
|
|
2872
|
+
const commandIn = (node) => {
|
|
2873
|
+
if (!Predicate.isReadonlyObject(node)) return Option.none();
|
|
2874
|
+
const record = node;
|
|
2875
|
+
return pipe(Option.fromUndefinedOr(record[COMMAND_KEY]), Option.filter(Predicate.isString), Option.map((command) => pipe(decodeArguments(record[ARGUMENTS_KEY]), Option.getOrElse(() => []), Array.prepend(command), Array.join(" "))));
|
|
2876
|
+
};
|
|
2877
|
+
const commandsIn = (node) => [...Option.toArray(commandIn(node)), ...pipe(childrenOf$2(node), Array.flatMap(commandsIn))];
|
|
2878
|
+
const agentSources = (file) => (source) => pipe(decodeJson(source), Option.map(commandsIn), Option.getOrElse(() => []), Array.map((text) => {
|
|
2879
|
+
const program = Array.headNonEmpty(String$1.split(text, " "));
|
|
2880
|
+
const offset = offsetOf$2(source, `"${program}"`);
|
|
2881
|
+
return {
|
|
2882
|
+
kind: "agent",
|
|
2883
|
+
file,
|
|
2884
|
+
position: positionOf(source)(offset),
|
|
2885
|
+
name: COMMAND_KEY,
|
|
2886
|
+
text
|
|
2887
|
+
};
|
|
2888
|
+
}));
|
|
2889
|
+
const taskCommand = (value) => pipe(propertyValue(COMMAND_KEY)(value), Option.orElse(() => Option.some(value)), Option.flatMap(literalOf), Option.flatMap(decodeCommandText), Option.map((command) => Array.join(Array.ensure(command), LINE)));
|
|
2890
|
+
const taskSource = (file, source) => (task) => pipe(taskCommand(task.value), Option.map((text) => ({
|
|
2891
|
+
kind: "task",
|
|
2892
|
+
file,
|
|
2893
|
+
position: positionOf(source)(task.start),
|
|
2894
|
+
name: keyName(task.key),
|
|
2895
|
+
text
|
|
2896
|
+
})));
|
|
2897
|
+
const taskSources = Effect.fn("taskSources")(function* taskSources(root, directory) {
|
|
2898
|
+
const found = yield* runTasksOf(root, directory);
|
|
2899
|
+
if (Option.isNone(found)) return NO_SOURCES;
|
|
2900
|
+
const { file, source, tasks } = found.value;
|
|
2901
|
+
return pipe(tasks, Array.flatMap((task) => Option.toArray(taskSource(file, source)(task))));
|
|
2902
|
+
});
|
|
2903
|
+
const workspaceTasks = Effect.fn("workspaceTasks")(function* workspaceTasks(root, directories) {
|
|
2904
|
+
const found = yield* Effect.forEach(directories, (directory) => taskSources(root, directory), { concurrency: READ_CONCURRENCY$4 });
|
|
2905
|
+
return Array.flatten(found);
|
|
2906
|
+
});
|
|
2907
|
+
const readSources = Effect.fn("readSources")(function* readSources(root, names, sourcesOf) {
|
|
2908
|
+
const files = yield* RepositoryFiles;
|
|
2909
|
+
const found = yield* Effect.forEach(names, (name) => {
|
|
2910
|
+
const file = files.join(root, name);
|
|
2911
|
+
const sourcesIn = Option.match({
|
|
2912
|
+
onNone: () => NO_SOURCES,
|
|
2913
|
+
onSome: sourcesOf(file, name)
|
|
2914
|
+
});
|
|
2915
|
+
return files.readFile(file).pipe(Effect.map(sourcesIn));
|
|
2916
|
+
}, { concurrency: READ_CONCURRENCY$4 });
|
|
2917
|
+
return Array.flatten(found);
|
|
2918
|
+
});
|
|
2919
|
+
/** @internal */
|
|
2920
|
+
const commandSources = Effect.fn("commandSources")(function* commandSources(root) {
|
|
2921
|
+
const files = yield* RepositoryFiles;
|
|
2922
|
+
const [manifests, steps, hooks, workspaces] = yield* Effect.all([
|
|
2923
|
+
files.matchingFiles(root, MANIFESTS),
|
|
2924
|
+
files.matchingFiles(root, STEP_FILES),
|
|
2925
|
+
files.matchingFiles(root, HOOK_FILES),
|
|
2926
|
+
workspaceDirectories(root)
|
|
2927
|
+
], { concurrency: "unbounded" });
|
|
2928
|
+
const found = yield* Effect.all([
|
|
2929
|
+
readSources(root, manifests, scriptSources),
|
|
2930
|
+
readSources(root, steps, stepSources),
|
|
2931
|
+
readSources(root, hooks, hookSources),
|
|
2932
|
+
readSources(root, AGENT_FILES, agentSources),
|
|
2933
|
+
workspaceTasks(root, Array.dedupe([ROOT_DIRECTORY, ...workspaces]))
|
|
2934
|
+
], { concurrency: "unbounded" });
|
|
2935
|
+
return Array.flatten(found);
|
|
2936
|
+
});
|
|
2937
|
+
// src/features/vite-plus/model/package-scripts.ts
|
|
2938
|
+
const RULE$8 = "package-script";
|
|
2939
|
+
const LIFECYCLE = [
|
|
2940
|
+
"preinstall",
|
|
2941
|
+
"install",
|
|
2942
|
+
"postinstall",
|
|
2943
|
+
"preprepare",
|
|
2944
|
+
"prepare",
|
|
2945
|
+
"postprepare",
|
|
2946
|
+
"prepublish",
|
|
2947
|
+
"prepublishOnly",
|
|
2948
|
+
"prepack",
|
|
2949
|
+
"postpack",
|
|
2950
|
+
"publish",
|
|
2951
|
+
"postpublish",
|
|
2952
|
+
"preversion",
|
|
2953
|
+
"version",
|
|
2954
|
+
"postversion",
|
|
2955
|
+
"dependencies",
|
|
2956
|
+
"pnpm:devPreinstall"
|
|
2957
|
+
];
|
|
2958
|
+
const problemOf$3 = ({ file, position, name }) => ({
|
|
2959
|
+
file,
|
|
2960
|
+
...position,
|
|
2961
|
+
rule: RULE$8,
|
|
2962
|
+
message: `The script ${name} is not a lifecycle script. package.json scripts hold only the scripts the package manager runs by itself, such as prepare and prepack. Write ${name} as a task in run.tasks of this package's vite.config.ts, where its shape is type-checked.`
|
|
2963
|
+
});
|
|
2964
|
+
const packageScriptProblems = (sources) => pipe(sources, Array.filter(({ kind, name }) => kind === "script" && !Array.contains(LIFECYCLE, name)), Array.map(problemOf$3));
|
|
2965
|
+
// src/features/vite-plus/model/vite-plus-block.ts
|
|
2966
|
+
const RULE$7 = "vite-plus-block";
|
|
2967
|
+
const MARKER = Array.join([
|
|
2968
|
+
"<!--",
|
|
2969
|
+
"VITE PLUS START",
|
|
2970
|
+
"-->"
|
|
2971
|
+
], "");
|
|
2972
|
+
const MESSAGE$2 = "holds the Vite+ block that `vp create --agent` and `vp migrate --agent` write, and every `vp config` rewrites it. Delete the block with its markers. The vite-plus skill reads the same guidance from node_modules/vite-plus/AGENTS.md.";
|
|
2973
|
+
const problemIn = (file) => (source) => {
|
|
2974
|
+
const index = String$1.indexOf(MARKER)(source);
|
|
2975
|
+
if (Option.isNone(index)) return Option.none();
|
|
2976
|
+
return Option.some({
|
|
2977
|
+
file,
|
|
2978
|
+
...positionOf(source)(index.value),
|
|
2979
|
+
rule: RULE$7,
|
|
2980
|
+
message: MESSAGE$2
|
|
2981
|
+
});
|
|
2982
|
+
};
|
|
2983
|
+
/** @internal */
|
|
2984
|
+
const checkVitePlusBlock = (root) => agentDocProblems(root, problemIn);
|
|
2985
|
+
// src/features/vite-plus/model/vite-plus-checks.ts
|
|
2986
|
+
/** @internal */
|
|
2987
|
+
const checkVitePlus = Effect.fn("checkVitePlus")(function* checkVitePlus(root) {
|
|
2988
|
+
const [sources, blocks] = yield* Effect.all([commandSources(root), checkVitePlusBlock(root)], { concurrency: "unbounded" });
|
|
2989
|
+
return [
|
|
2990
|
+
...packageScriptProblems(sources),
|
|
2991
|
+
...commandProblems$1(sources),
|
|
2992
|
+
...blocks
|
|
2993
|
+
];
|
|
2994
|
+
});
|
|
2995
|
+
// src/features/workflow-concurrency/model/workflow-queue.ts
|
|
2996
|
+
const CONCURRENCY_KEY = "concurrency";
|
|
2997
|
+
const QUEUE_KEY = "queue";
|
|
2998
|
+
const RULE$6 = "workflow-queue";
|
|
2999
|
+
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.";
|
|
3000
|
+
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));
|
|
3001
|
+
const queueOffsetsOf = (source) => {
|
|
3002
|
+
const found = [];
|
|
3003
|
+
visit(parseDocument(source), { Pair: (_key, pair) => {
|
|
3004
|
+
if (isPair(pair) && isScalar(pair.key) && pair.key.value === CONCURRENCY_KEY) found.push(...Option.toArray(queueKeyOf(pair.value)));
|
|
3005
|
+
} });
|
|
3006
|
+
return found;
|
|
3007
|
+
};
|
|
3008
|
+
/** @internal */
|
|
3009
|
+
const checkWorkflowQueues = Effect.fn("checkWorkflowQueues")(function* checkWorkflowQueues(root) {
|
|
3010
|
+
const workflows = yield* readWorkflows(root);
|
|
3011
|
+
return pipe(workflows, Array.flatMap(({ file, source }) => {
|
|
3012
|
+
const at = positionOf(source);
|
|
3013
|
+
return pipe(queueOffsetsOf(source), Array.map((offset) => {
|
|
3014
|
+
const { line, column } = at(offset);
|
|
3015
|
+
return {
|
|
3016
|
+
file,
|
|
3017
|
+
line,
|
|
3018
|
+
column,
|
|
3019
|
+
rule: RULE$6,
|
|
3020
|
+
message: MESSAGE$1
|
|
3021
|
+
};
|
|
3022
|
+
}));
|
|
3023
|
+
}));
|
|
3024
|
+
});
|
|
3025
|
+
// src/app/tool-use.ts
|
|
3026
|
+
/** @internal */
|
|
3027
|
+
const checkToolUse = Effect.fn("checkToolUse")(function* checkToolUse(root) {
|
|
3028
|
+
const found = yield* Effect.all([
|
|
3029
|
+
checkVitePlus(root),
|
|
3030
|
+
checkMissingHooks(root),
|
|
3031
|
+
checkScripts(root),
|
|
3032
|
+
checkWorkflowQueues(root)
|
|
3033
|
+
], { concurrency: "unbounded" });
|
|
3034
|
+
return Array.flatten(found);
|
|
3035
|
+
});
|
|
2724
3036
|
// src/features/comments/model/found-comment.ts
|
|
2725
3037
|
const taggedError$2 = Schema.TaggedError;
|
|
2726
3038
|
var CommentsUnreadable = class extends taggedError$2()("CommentsUnreadable", {
|
|
@@ -2811,7 +3123,7 @@ const COMMENT_NODES = [
|
|
|
2811
3123
|
"block_comment",
|
|
2812
3124
|
"multiline_comment"
|
|
2813
3125
|
];
|
|
2814
|
-
const START$
|
|
3126
|
+
const START$6 = 0;
|
|
2815
3127
|
const NEXT = 1;
|
|
2816
3128
|
const NONE$1 = [];
|
|
2817
3129
|
const grammarFile = (grammar) => fileURLToPath(import.meta.resolve(`@vscode/tree-sitter-wasm/wasm/tree-sitter-${grammar}.wasm`));
|
|
@@ -2874,7 +3186,7 @@ const markupComment = (source) => (node) => {
|
|
|
2874
3186
|
}];
|
|
2875
3187
|
};
|
|
2876
3188
|
const textComments = (grammars, grammar) => (text) => {
|
|
2877
|
-
const shift = shifted(text.startIndex ?? START$
|
|
3189
|
+
const shift = shifted(text.startIndex ?? START$6);
|
|
2878
3190
|
return syntaxComments(grammars, grammar)(text.data).pipe(Effect.map(Array.map(shift)));
|
|
2879
3191
|
};
|
|
2880
3192
|
const embeddedComments = (grammars) => (node) => {
|
|
@@ -2910,11 +3222,11 @@ const commentsWith = (grammars) => (reader, source) => {
|
|
|
2910
3222
|
}[reader](source);
|
|
2911
3223
|
};
|
|
2912
3224
|
// src/features/comments/model/comments.ts
|
|
2913
|
-
const RULE$
|
|
3225
|
+
const RULE$5 = "comment";
|
|
2914
3226
|
const CONFIG_FILE = "vite.config.ts";
|
|
2915
3227
|
const VENDORED_PATHSPEC = ":(attr:linguist-vendored)";
|
|
2916
|
-
const READ_CONCURRENCY$
|
|
2917
|
-
const START$
|
|
3228
|
+
const READ_CONCURRENCY$3 = 64;
|
|
3229
|
+
const START$5 = 0;
|
|
2918
3230
|
const FIRST_LINE$2 = 1;
|
|
2919
3231
|
const FIRST_COLUMN$2 = 1;
|
|
2920
3232
|
const READERS = [
|
|
@@ -2971,23 +3283,23 @@ const shebangReader = (source) => {
|
|
|
2971
3283
|
const readerOf = (name, source) => pipe(READERS, Array.findFirst(([pattern]) => pattern.test(name)), Option.orElse(() => shebangReader(source)), Option.map(([, reader]) => reader));
|
|
2972
3284
|
const valueOf = (text) => String$1.replaceAll(DELIMITERS, "")(text);
|
|
2973
3285
|
const lineBefore = (source, index) => {
|
|
2974
|
-
const lines = pipe(source, String$1.slice(START$
|
|
3286
|
+
const lines = pipe(source, String$1.slice(START$5, index), String$1.split("\n"));
|
|
2975
3287
|
return Option.getOrElse(Array.last(lines), () => "");
|
|
2976
3288
|
};
|
|
2977
3289
|
const isPinVersion = (source, { index, text }) => PIN.test(lineBefore(source, index)) && VERSION.test(valueOf(text));
|
|
2978
|
-
const isShebang = ({ index, text }) => index === START$
|
|
3290
|
+
const isShebang = ({ index, text }) => index === START$5 && String$1.startsWith(SHEBANG)(text);
|
|
2979
3291
|
const isAllowed = (source, directives) => (comment) => isShebang(comment) || directives.test(valueOf(comment.text)) || isPinVersion(source, comment);
|
|
2980
|
-
const problemOf$
|
|
3292
|
+
const problemOf$2 = (file, source) => ({ index }) => ({
|
|
2981
3293
|
file,
|
|
2982
3294
|
...positionOf(source)(index),
|
|
2983
|
-
rule: RULE$
|
|
3295
|
+
rule: RULE$5,
|
|
2984
3296
|
message: MESSAGE
|
|
2985
3297
|
});
|
|
2986
3298
|
const unreadableProblem = (file, message) => ({
|
|
2987
3299
|
file,
|
|
2988
3300
|
line: FIRST_LINE$2,
|
|
2989
3301
|
column: FIRST_COLUMN$2,
|
|
2990
|
-
rule: RULE$
|
|
3302
|
+
rule: RULE$5,
|
|
2991
3303
|
message: `msch could not read the comments in this file: ${message}`
|
|
2992
3304
|
});
|
|
2993
3305
|
const settingsOf = ({ msch, lint }) => ({
|
|
@@ -3033,7 +3345,7 @@ const checkComments = Effect.fn("checkComments")(function* checkComments(root) {
|
|
|
3033
3345
|
const comments = commentsWith(grammars);
|
|
3034
3346
|
const problemsIn = ({ name, file }, source) => {
|
|
3035
3347
|
const kept = Predicate.not(isAllowed(source, directives));
|
|
3036
|
-
const toProblem = problemOf$
|
|
3348
|
+
const toProblem = problemOf$2(file, source);
|
|
3037
3349
|
return Option.match(readerOf(name, source), {
|
|
3038
3350
|
onNone: () => Effect.succeed(NONE),
|
|
3039
3351
|
onSome: (reader) => comments(reader, source).pipe(Effect.map(Array.filter(kept)), Effect.map(Array.map(toProblem)), Effect.catchTag("CommentsUnreadable", ({ message }) => Effect.succeed([unreadableProblem(file, message)])))
|
|
@@ -3042,30 +3354,30 @@ const checkComments = Effect.fn("checkComments")(function* checkComments(root) {
|
|
|
3042
3354
|
const found = yield* Effect.forEach(scanned, (entry) => files.readFile(entry.file).pipe(Effect.flatMap(Option.match({
|
|
3043
3355
|
onNone: () => Effect.succeed(NONE),
|
|
3044
3356
|
onSome: (source) => problemsIn(entry, source)
|
|
3045
|
-
}))), { concurrency: READ_CONCURRENCY$
|
|
3357
|
+
}))), { concurrency: READ_CONCURRENCY$3 });
|
|
3046
3358
|
return Array.flatten(found);
|
|
3047
3359
|
});
|
|
3048
3360
|
// src/features/invisible-characters/model/hidden-unicode.ts
|
|
3049
3361
|
const HIDDEN = /[\u00AD\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u2069\uFEFF]|[\u{E0000}-\u{E007F}]/gu;
|
|
3050
3362
|
const NUL = "\0";
|
|
3051
|
-
const START$
|
|
3363
|
+
const START$4 = 0;
|
|
3052
3364
|
const HEX = 16;
|
|
3053
3365
|
const CODE_POINT_WIDTH = 4;
|
|
3054
|
-
const READ_CONCURRENCY$
|
|
3055
|
-
const RULE = "hidden-unicode";
|
|
3056
|
-
const hexOf = (character) => pipe(String$1.codePointAt(START$
|
|
3057
|
-
const problemOf = (file, source) => (found) => {
|
|
3058
|
-
const hex = hexOf(found[START$
|
|
3366
|
+
const READ_CONCURRENCY$2 = 64;
|
|
3367
|
+
const RULE$4 = "hidden-unicode";
|
|
3368
|
+
const hexOf = (character) => pipe(String$1.codePointAt(START$4)(character), Option.getOrElse(() => START$4), (code) => code.toString(HEX), String$1.toUpperCase, String$1.padStart(CODE_POINT_WIDTH, "0"));
|
|
3369
|
+
const problemOf$1 = (file, source) => (found) => {
|
|
3370
|
+
const hex = hexOf(found[START$4]);
|
|
3059
3371
|
return {
|
|
3060
3372
|
file,
|
|
3061
|
-
...positionOf(source)(found.index ?? START$
|
|
3062
|
-
rule: RULE,
|
|
3373
|
+
...positionOf(source)(found.index ?? START$4),
|
|
3374
|
+
rule: RULE$4,
|
|
3063
3375
|
message: `U+${hex} is invisible in editors and reviews and can change what the text means. Remove it, or write it as the escape \\u${hex}.`
|
|
3064
3376
|
};
|
|
3065
3377
|
};
|
|
3066
|
-
const problemsIn = (file, source) => {
|
|
3378
|
+
const problemsIn$3 = (file, source) => {
|
|
3067
3379
|
if (String$1.includes(NUL)(source)) return [];
|
|
3068
|
-
return pipe(Array.fromIterable(String$1.matchAll(HIDDEN)(source)), Array.map(problemOf(file, source)));
|
|
3380
|
+
return pipe(Array.fromIterable(String$1.matchAll(HIDDEN)(source)), Array.map(problemOf$1(file, source)));
|
|
3069
3381
|
};
|
|
3070
3382
|
/** @internal */
|
|
3071
3383
|
const checkHiddenUnicode = Effect.fn("checkHiddenUnicode")(function* checkHiddenUnicode(root) {
|
|
@@ -3075,16 +3387,16 @@ const checkHiddenUnicode = Effect.fn("checkHiddenUnicode")(function* checkHidden
|
|
|
3075
3387
|
const file = files.join(root, name);
|
|
3076
3388
|
return files.readFile(file).pipe(Effect.map(Option.match({
|
|
3077
3389
|
onNone: () => [],
|
|
3078
|
-
onSome: (source) => problemsIn(file, source)
|
|
3390
|
+
onSome: (source) => problemsIn$3(file, source)
|
|
3079
3391
|
})));
|
|
3080
|
-
}, { concurrency: READ_CONCURRENCY$
|
|
3392
|
+
}, { concurrency: READ_CONCURRENCY$2 });
|
|
3081
3393
|
return Array.flatten(found);
|
|
3082
3394
|
});
|
|
3083
3395
|
// src/shared/lib/scanned-files.ts
|
|
3084
3396
|
const SCANNED_FILE = /(?:\.(?:[cm]?[jt]sx?|jsonc?|toml|ya?ml|sh|bash|zsh|fish|rs|cs|go|mk)|(?:^|\/)(?:Dockerfile[^/]*|Makefile|justfile|\.tool-versions|[^./][^./]*))$/u;
|
|
3085
3397
|
const LOCKFILE = /(?:^|\/)(?:[^/]*\.lock|[^/]*-lock\.(?:json|ya?ml))$/u;
|
|
3086
3398
|
const TOOL_VERSIONS = /(?:^|\/)(?:\.?mise(?:\.[^/]+)?\.toml|\.tool-versions)$/u;
|
|
3087
|
-
const READ_CONCURRENCY = 64;
|
|
3399
|
+
const READ_CONCURRENCY$1 = 64;
|
|
3088
3400
|
const isScannedText = ({ name }) => SCANNED_FILE.test(name) && !LOCKFILE.test(name);
|
|
3089
3401
|
const isToolVersions = ({ name }) => TOOL_VERSIONS.test(name);
|
|
3090
3402
|
/** @internal */
|
|
@@ -3107,7 +3419,7 @@ const scanText = Effect.fn("scanText")(function* scanText(listed, problemsIn) {
|
|
|
3107
3419
|
const found = yield* Effect.forEach(listed, (entry) => files.readFile(entry.file).pipe(Effect.map(Option.match({
|
|
3108
3420
|
onNone: () => [],
|
|
3109
3421
|
onSome: (source) => problemsIn(entry, source)
|
|
3110
|
-
}))), { concurrency: READ_CONCURRENCY });
|
|
3422
|
+
}))), { concurrency: READ_CONCURRENCY$1 });
|
|
3111
3423
|
return Array.flatten(found);
|
|
3112
3424
|
});
|
|
3113
3425
|
// src/features/python/model/python.ts
|
|
@@ -3155,6 +3467,326 @@ const checkPython = Effect.fn("checkPython")(function* checkPython(root) {
|
|
|
3155
3467
|
const present = yield* presentFiles(pipe(listed, Array.filter(isPython)));
|
|
3156
3468
|
return [...pipe(present, Array.map(fileProblem)), ...scanned];
|
|
3157
3469
|
});
|
|
3470
|
+
// src/features/runtime-version/model/node-version.ts
|
|
3471
|
+
const RULE$3 = "node-version";
|
|
3472
|
+
const MINIMUM = 26;
|
|
3473
|
+
const SUPPORTED = `Node.js ${String(MINIMUM)} or later is the only supported runtime.`;
|
|
3474
|
+
const MANIFEST = /(?:^|\/)package\.json$/u;
|
|
3475
|
+
const VERSION_FILE = /(?:^|\/)(?:\.node-version|\.nvmrc)$/u;
|
|
3476
|
+
const DOCKERFILE = /(?:^|\/)Dockerfile[^/]*$/u;
|
|
3477
|
+
const STEP_FILE = /^\.github\/.*\.ya?ml$|(?:^|\/)action\.ya?ml$/u;
|
|
3478
|
+
const PINNED_VERSION = /^\s*v?(?<major>\d+)/u;
|
|
3479
|
+
const BASE_IMAGE = /^FROM[ \t]+(?:--\S+[ \t]+)*(?:[\w.-]+(?::\d+)?\/)*node:(?<major>\d+)/gimu;
|
|
3480
|
+
const SETUP_INPUT = /\bnode-version:[ \t]*["']?v?(?<major>\d+)/gu;
|
|
3481
|
+
const TOOL_VERSION = /^[ \t]*["']?(?:node|nodejs)["']?[ \t]*(?:=[ \t]*["']?|[ \t]+)v?(?<major>\d+)/gmu;
|
|
3482
|
+
const RANGE_FLOOR = /^(?:>=|\^|~|=)?[ \t]*v?(?<major>\d+)/u;
|
|
3483
|
+
const ALTERNATIVE = "||";
|
|
3484
|
+
const ENGINES_KEY = "\"engines\"";
|
|
3485
|
+
const START$3 = 0;
|
|
3486
|
+
const EXCLUDED = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
|
|
3487
|
+
const Engines = Schema.Struct({ node: Schema.optional(Schema.String) });
|
|
3488
|
+
const Manifest = Schema.Struct({
|
|
3489
|
+
private: Schema.optional(Schema.Boolean),
|
|
3490
|
+
publishConfig: Schema.optional(Schema.Unknown),
|
|
3491
|
+
engines: Schema.optional(Engines)
|
|
3492
|
+
});
|
|
3493
|
+
const decodeManifest = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest));
|
|
3494
|
+
const majorOf = (found) => pipe(groupOf("major")(found), Option.map(Number));
|
|
3495
|
+
const isOld = (major) => major < MINIMUM;
|
|
3496
|
+
const floorOf = (alternative) => majorOf(RANGE_FLOOR.exec(String$1.trim(alternative)));
|
|
3497
|
+
const floorIsOld = (alternative) => pipe(floorOf(alternative), Option.match({
|
|
3498
|
+
onNone: () => true,
|
|
3499
|
+
onSome: isOld
|
|
3500
|
+
}));
|
|
3501
|
+
const admitsOld = (range) => pipe(String$1.split(range, ALTERNATIVE), Array.some(floorIsOld));
|
|
3502
|
+
const problemAt = ({ entry, source, index }, message) => ({
|
|
3503
|
+
file: entry.file,
|
|
3504
|
+
...positionOf(source)(index),
|
|
3505
|
+
rule: RULE$3,
|
|
3506
|
+
message
|
|
3507
|
+
});
|
|
3508
|
+
const offsetOf$1 = (source, text) => pipe(String$1.indexOf(text)(source), Option.getOrElse(() => START$3));
|
|
3509
|
+
const unstatedProblem = (entry, source) => problemAt({
|
|
3510
|
+
entry,
|
|
3511
|
+
source,
|
|
3512
|
+
index: START$3
|
|
3513
|
+
}, `${SUPPORTED} This package is published without engines.node, so its users cannot tell. Set engines.node to ">=${String(MINIMUM)}".`);
|
|
3514
|
+
const rangeProblem = (entry, source) => (range) => problemAt({
|
|
3515
|
+
entry,
|
|
3516
|
+
source,
|
|
3517
|
+
index: offsetOf$1(source, ENGINES_KEY)
|
|
3518
|
+
}, `${SUPPORTED} engines.node is "${range}", which admits an older one. Set it to ">=${String(MINIMUM)}".`);
|
|
3519
|
+
const isPublished = (manifest) => manifest.private !== true && Predicate.isNotUndefined(manifest.publishConfig);
|
|
3520
|
+
const rangeOf$1 = (manifest) => pipe(Option.fromUndefinedOr(manifest.engines), Option.flatMap(({ node }) => Option.fromUndefinedOr(node)));
|
|
3521
|
+
const manifestProblems = (entry, source) => {
|
|
3522
|
+
const manifest = decodeManifest(source);
|
|
3523
|
+
if (Option.isNone(manifest)) return [];
|
|
3524
|
+
const range = rangeOf$1(manifest.value);
|
|
3525
|
+
if (Option.isNone(range) && isPublished(manifest.value)) return [unstatedProblem(entry, source)];
|
|
3526
|
+
return pipe(range, Option.filter(admitsOld), Option.map(rangeProblem(entry, source)), Option.toArray);
|
|
3527
|
+
};
|
|
3528
|
+
const pinnedProblems = (pattern) => (entry, source) => pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.filter((found) => Option.exists(majorOf(found), isOld)), Array.map((found) => problemAt({
|
|
3529
|
+
entry,
|
|
3530
|
+
source,
|
|
3531
|
+
index: found.index ?? START$3
|
|
3532
|
+
}, `${SUPPORTED} \`${String$1.trim(found[START$3])}\` pins an older one. Raise it to ${String(MINIMUM)} or later.`)));
|
|
3533
|
+
const versionFileProblems = (entry, source) => pipe(majorOf(PINNED_VERSION.exec(source)), Option.filter(isOld), Option.map((major) => problemAt({
|
|
3534
|
+
entry,
|
|
3535
|
+
source,
|
|
3536
|
+
index: START$3
|
|
3537
|
+
}, `${SUPPORTED} This file pins ${String(major)}. Raise it to ${String(MINIMUM)} or later.`)), Option.toArray);
|
|
3538
|
+
const problemsIn$2 = (entry, source) => {
|
|
3539
|
+
if (MANIFEST.test(entry.name)) return manifestProblems(entry, source);
|
|
3540
|
+
if (VERSION_FILE.test(entry.name)) return versionFileProblems(entry, source);
|
|
3541
|
+
if (DOCKERFILE.test(entry.name)) return pinnedProblems(BASE_IMAGE)(entry, source);
|
|
3542
|
+
if (isToolVersions(entry)) return pinnedProblems(TOOL_VERSION)(entry, source);
|
|
3543
|
+
return pinnedProblems(SETUP_INPUT)(entry, source);
|
|
3544
|
+
};
|
|
3545
|
+
const isVersionSource = (entry) => VERSION_FILE.test(entry.name) || DOCKERFILE.test(entry.name) || STEP_FILE.test(entry.name) || isToolVersions(entry);
|
|
3546
|
+
/** @internal */
|
|
3547
|
+
const checkNodeVersion = Effect.fn("checkNodeVersion")(function* checkNodeVersion(root) {
|
|
3548
|
+
const files = yield* RepositoryFiles;
|
|
3549
|
+
const listed = yield* listedFiles(root);
|
|
3550
|
+
const manifests = yield* files.matchingFiles(root, [`:(glob)**/${MANIFEST_FILE}`, ...EXCLUDED]);
|
|
3551
|
+
const sources = [...pipe(listed, Array.filter(isVersionSource)), ...pipe(manifests, Array.map((name) => ({
|
|
3552
|
+
name,
|
|
3553
|
+
file: files.join(root, name)
|
|
3554
|
+
})))];
|
|
3555
|
+
return yield* scanText(sources, problemsIn$2);
|
|
3556
|
+
});
|
|
3557
|
+
// src/features/skills/model/skill-files.ts
|
|
3558
|
+
const RULE$2 = "skill-file";
|
|
3559
|
+
const SKILL_FILE = /(?:^|\/)SKILL\.md$/u;
|
|
3560
|
+
const INSTALLED = /(?:^|\/)\.(?:agents|claude|codex)\/skills\//u;
|
|
3561
|
+
const MARKDOWN = ".md";
|
|
3562
|
+
const LICENSE_FILE = /^LICEN[CS]E(?:\.[^/]+)?$/iu;
|
|
3563
|
+
const FRONTMATTER = /^---\n(?<yaml>[\s\S]*?)\n---\n/u;
|
|
3564
|
+
const HEADING = /^# (?<title>.+)$/mu;
|
|
3565
|
+
const NAME_KEY = /^name:/mu;
|
|
3566
|
+
const LICENSE_KEY = /^license:/mu;
|
|
3567
|
+
const CODE = /```[\s\S]*?```|`[^`\n]*`/gu;
|
|
3568
|
+
const LINK = /\]\((?<target>[^)\s]+)\)/gu;
|
|
3569
|
+
const EXTERNAL = /^(?:[a-z][a-z0-9+.-]*:|#|\/)|[<>{}]/iu;
|
|
3570
|
+
const FRAGMENT = /#.*$/u;
|
|
3571
|
+
const GITHUB = "https://github.com/";
|
|
3572
|
+
const COMMIT_LINK = /\/(?:blob|tree)\/[0-9a-f]{40}(?:\/|$)/u;
|
|
3573
|
+
const BLANK = /\s+/u;
|
|
3574
|
+
const SEPARATOR$1 = "/";
|
|
3575
|
+
const START$2 = 0;
|
|
3576
|
+
const FIRST$1 = 1;
|
|
3577
|
+
const READ_CONCURRENCY = 16;
|
|
3578
|
+
const Metadata = Schema.Struct({ "derived-from": Schema.optional(Schema.String) });
|
|
3579
|
+
const Frontmatter = Schema.Struct({
|
|
3580
|
+
name: Schema.optional(Schema.String),
|
|
3581
|
+
license: Schema.optional(Schema.Unknown),
|
|
3582
|
+
metadata: Schema.optional(Metadata)
|
|
3583
|
+
});
|
|
3584
|
+
const decodeFrontmatter = Schema.decodeUnknownOption(Frontmatter);
|
|
3585
|
+
const offsetOf = (source, pattern) => pipe(String$1.search(pattern)(source), Option.getOrElse(() => START$2));
|
|
3586
|
+
const frontmatterOf = (source) => pipe(groupOf("yaml")(FRONTMATTER.exec(source)), Option.flatMap((yaml) => decodeFrontmatter(parse$1(yaml))));
|
|
3587
|
+
const bodyStartOf = (source) => pipe(Option.fromNullishOr(FRONTMATTER.exec(source)), Option.map((found) => found[START$2].length), Option.getOrElse(() => START$2));
|
|
3588
|
+
const headingText = (heading) => pipe(heading, Option.map((title) => `"# ${title}"`), Option.getOrElse(() => "missing"));
|
|
3589
|
+
const nameProblems = ({ source, directory }, name, folder) => {
|
|
3590
|
+
const bodyStart = bodyStartOf(source);
|
|
3591
|
+
const body = String$1.slice(bodyStart)(source);
|
|
3592
|
+
const heading = groupOf("title")(HEADING.exec(body));
|
|
3593
|
+
return [...pipe(Option.liftPredicate(name, (found) => found !== folder), Option.map((found) => ({
|
|
3594
|
+
index: offsetOf(source, NAME_KEY),
|
|
3595
|
+
message: `The frontmatter name "${found}" differs from the directory ${directory}. Give the skill the name of its directory.`
|
|
3596
|
+
})), Option.toArray), ...pipe(Option.liftPredicate(heading, (found) => !Option.contains(found, name)), Option.map((found) => ({
|
|
3597
|
+
index: bodyStart + offsetOf(body, HEADING),
|
|
3598
|
+
message: `The first heading is ${headingText(found)}. Start the body with "# ${name}", the frontmatter name.`
|
|
3599
|
+
})), Option.toArray)];
|
|
3600
|
+
};
|
|
3601
|
+
const derivedProblems = (source, derived) => pipe(String$1.split(String$1.trim(derived), BLANK), Array.filter((url) => String$1.startsWith(GITHUB)(url) && !COMMIT_LINK.test(url)), Array.map((url) => ({
|
|
3602
|
+
index: offsetOf(source, url),
|
|
3603
|
+
message: `metadata.derived-from holds ${url}, which does not name a commit, so what it shows changes. Write a permalink: ${GITHUB}<owner>/<repo>/blob/<commit>/<path>.`
|
|
3604
|
+
})));
|
|
3605
|
+
const frontmatterProblems = (skill, folder) => pipe(frontmatterOf(skill.source), Option.map((frontmatter) => [
|
|
3606
|
+
...pipe(Option.fromUndefinedOr(frontmatter.name), Option.map((name) => nameProblems(skill, name, folder)), Option.getOrElse(() => [])),
|
|
3607
|
+
...pipe(Option.fromUndefinedOr(frontmatter.license), Option.map(() => ({
|
|
3608
|
+
index: offsetOf(skill.source, LICENSE_KEY),
|
|
3609
|
+
message: "The frontmatter has license. Skills here carry neither a license field nor a LICENSE file. Remove it."
|
|
3610
|
+
})), Option.toArray),
|
|
3611
|
+
...pipe(Option.fromUndefinedOr(frontmatter.metadata), Option.flatMap((metadata) => Option.fromUndefinedOr(metadata["derived-from"])), Option.map((derived) => derivedProblems(skill.source, derived)), Option.getOrElse(() => []))
|
|
3612
|
+
]), Option.getOrElse(() => []), Array.map(({ index, message }) => ({
|
|
3613
|
+
file: skill.file,
|
|
3614
|
+
...positionOf(skill.source)(index),
|
|
3615
|
+
rule: RULE$2,
|
|
3616
|
+
message
|
|
3617
|
+
})));
|
|
3618
|
+
const linkOf = (found) => pipe(groupOf("target")(found), Option.filter((target) => !EXTERNAL.test(target)), Option.map((target) => String$1.replace(FRAGMENT, "")(target)), Option.filter(String$1.isNonEmpty), Option.map((target) => ({
|
|
3619
|
+
target,
|
|
3620
|
+
index: found.index ?? START$2
|
|
3621
|
+
})), Option.toArray);
|
|
3622
|
+
const rangeOf = (found) => {
|
|
3623
|
+
const start = found.index ?? START$2;
|
|
3624
|
+
return [start, start + found[START$2].length];
|
|
3625
|
+
};
|
|
3626
|
+
const isOutside = (ranges) => ({ index }) => !pipe(ranges, Array.some(([start, end]) => index >= start && index < end));
|
|
3627
|
+
const linksIn = (source) => {
|
|
3628
|
+
const code = pipe(Array.fromIterable(String$1.matchAll(CODE)(source)), Array.map(rangeOf));
|
|
3629
|
+
return pipe(Array.fromIterable(String$1.matchAll(LINK)(source)), Array.flatMap(linkOf), Array.filter(isOutside(code)));
|
|
3630
|
+
};
|
|
3631
|
+
const linkProblems = Effect.fn("linkProblems")(function* linkProblems(file) {
|
|
3632
|
+
const files = yield* RepositoryFiles;
|
|
3633
|
+
const text = yield* files.readFile(file);
|
|
3634
|
+
if (Option.isNone(text)) return [];
|
|
3635
|
+
const source = text.value;
|
|
3636
|
+
const directory = files.dirname(file);
|
|
3637
|
+
const isMissing = ({ target }) => files.exists(files.join(directory, target)).pipe(Effect.map((exists) => !exists));
|
|
3638
|
+
const missing = yield* Effect.filter(linksIn(source), isMissing);
|
|
3639
|
+
return pipe(missing, Array.map(({ target, index }) => ({
|
|
3640
|
+
file,
|
|
3641
|
+
...positionOf(source)(index),
|
|
3642
|
+
rule: RULE$2,
|
|
3643
|
+
message: `links to ${target}, which does not exist. Fix the path or remove the link.`
|
|
3644
|
+
})));
|
|
3645
|
+
});
|
|
3646
|
+
const problemsIn$1 = Effect.fn("problemsIn")(function* problemsIn(root, listed, name) {
|
|
3647
|
+
const files = yield* RepositoryFiles;
|
|
3648
|
+
const file = files.join(root, name);
|
|
3649
|
+
const directory = files.dirname(name);
|
|
3650
|
+
const inside = pipe(listed, Array.filter(String$1.startsWith(`${directory}${SEPARATOR$1}`)));
|
|
3651
|
+
const text = yield* files.readFile(file);
|
|
3652
|
+
const documents = pipe(inside, Array.filter(String$1.endsWith(MARKDOWN)), Array.map((entry) => files.join(root, entry)));
|
|
3653
|
+
const links = yield* Effect.forEach(documents, linkProblems, { concurrency: READ_CONCURRENCY });
|
|
3654
|
+
const licenses = pipe(inside, Array.filter((entry) => files.dirname(entry) === directory), Array.filter((entry) => LICENSE_FILE.test(files.basename(entry))), Array.map((entry) => ({
|
|
3655
|
+
file: files.join(root, entry),
|
|
3656
|
+
line: FIRST$1,
|
|
3657
|
+
column: FIRST$1,
|
|
3658
|
+
rule: RULE$2,
|
|
3659
|
+
message: "is a license file inside a skill. Skills here carry neither a license field nor a LICENSE file. Delete it."
|
|
3660
|
+
})));
|
|
3661
|
+
return [
|
|
3662
|
+
...pipe(text, Option.map((source) => frontmatterProblems({
|
|
3663
|
+
file,
|
|
3664
|
+
directory,
|
|
3665
|
+
source
|
|
3666
|
+
}, files.basename(directory))), Option.getOrElse(() => [])),
|
|
3667
|
+
...licenses,
|
|
3668
|
+
...Array.flatten(links)
|
|
3669
|
+
];
|
|
3670
|
+
});
|
|
3671
|
+
/** @internal */
|
|
3672
|
+
const checkSkillFiles = Effect.fn("checkSkillFiles")(function* checkSkillFiles(root) {
|
|
3673
|
+
const listed = yield* (yield* RepositoryFiles).listedFiles(root);
|
|
3674
|
+
const skills = pipe(listed, Array.filter((name) => SKILL_FILE.test(name) && !INSTALLED.test(name)));
|
|
3675
|
+
const found = yield* Effect.forEach(skills, (name) => problemsIn$1(root, listed, name), { concurrency: READ_CONCURRENCY });
|
|
3676
|
+
return Array.flatten(found);
|
|
3677
|
+
});
|
|
3678
|
+
// src/features/unneeded-files/model/alchemy-patch.ts
|
|
3679
|
+
const RULE$1 = "alchemy-patch";
|
|
3680
|
+
const WORKSPACE_FILE$1 = "pnpm-workspace.yaml";
|
|
3681
|
+
const ALCHEMY$1 = /^(?:alchemy|@alchemy\.run\/[^@]+)(?:@.*)?$/u;
|
|
3682
|
+
const START$1 = 0;
|
|
3683
|
+
const WorkspaceFile$1 = Schema.Struct({ patchedDependencies: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown)) });
|
|
3684
|
+
const decodeWorkspaceFile$1 = Schema.decodeUnknownOption(WorkspaceFile$1);
|
|
3685
|
+
const patchedIn = (source) => pipe(decodeWorkspaceFile$1(parse$1(source)), Option.flatMap(({ patchedDependencies }) => Option.fromUndefinedOr(patchedDependencies)), Option.map(Record.keys), Option.getOrElse(() => []));
|
|
3686
|
+
const problemOf = (file, position, name) => ({
|
|
3687
|
+
file,
|
|
3688
|
+
...position,
|
|
3689
|
+
rule: RULE$1,
|
|
3690
|
+
message: `patches ${name}. A patch breaks on every Alchemy release. Define the missing setting as a custom resource in the stack and delete the patch.`
|
|
3691
|
+
});
|
|
3692
|
+
const problemsIn = (file) => (source) => {
|
|
3693
|
+
const at = positionOf(source);
|
|
3694
|
+
const offsetOf = (name) => pipe(String$1.indexOf(name)(source), Option.getOrElse(() => START$1));
|
|
3695
|
+
return pipe(patchedIn(source), Array.filter((name) => ALCHEMY$1.test(name)), Array.map((name) => problemOf(file, at(offsetOf(name)), name)));
|
|
3696
|
+
};
|
|
3697
|
+
/** @internal */
|
|
3698
|
+
const checkAlchemyPatch = Effect.fn("checkAlchemyPatch")(function* checkAlchemyPatch(root) {
|
|
3699
|
+
const files = yield* RepositoryFiles;
|
|
3700
|
+
const file = files.join(root, WORKSPACE_FILE$1);
|
|
3701
|
+
const text = yield* files.readFile(file);
|
|
3702
|
+
return pipe(text, Option.map(problemsIn(file)), Option.getOrElse(() => []));
|
|
3703
|
+
});
|
|
3704
|
+
// src/features/unneeded-files/model/replaced-tools.ts
|
|
3705
|
+
const RULE = "replaced-tool";
|
|
3706
|
+
const FIRST = 1;
|
|
3707
|
+
const TASKS = "Vite+ tasks in run.tasks of vite.config.ts, run with `vp run`";
|
|
3708
|
+
const HOOKS = "the hooks in .vite-hooks/ that `vp config` installs";
|
|
3709
|
+
const ALCHEMY = "the Alchemy stack in alchemy.run.ts";
|
|
3710
|
+
const REPLACED = [
|
|
3711
|
+
{
|
|
3712
|
+
pattern: /(?:^|\/)turbo\.jsonc?$/u,
|
|
3713
|
+
tool: "Turborepo",
|
|
3714
|
+
replacement: TASKS
|
|
3715
|
+
},
|
|
3716
|
+
{
|
|
3717
|
+
pattern: /(?:^|\/)nx\.json$/u,
|
|
3718
|
+
tool: "Nx",
|
|
3719
|
+
replacement: TASKS
|
|
3720
|
+
},
|
|
3721
|
+
{
|
|
3722
|
+
pattern: /(?:^|\/)\.husky\//u,
|
|
3723
|
+
tool: "husky",
|
|
3724
|
+
replacement: HOOKS
|
|
3725
|
+
},
|
|
3726
|
+
{
|
|
3727
|
+
pattern: /(?:^|\/)(?:\.?lefthook(?:-local)?\.(?:ya?ml|toml|json)|\.lefthook\/)/u,
|
|
3728
|
+
tool: "lefthook",
|
|
3729
|
+
replacement: HOOKS
|
|
3730
|
+
},
|
|
3731
|
+
{
|
|
3732
|
+
pattern: /(?:^|\/)\.?knip\.(?:jsonc?|[cm]?[jt]s)$/u,
|
|
3733
|
+
tool: "knip",
|
|
3734
|
+
replacement: "fallow"
|
|
3735
|
+
},
|
|
3736
|
+
{
|
|
3737
|
+
pattern: /(?:^|\/)\.jscpd\.json$/u,
|
|
3738
|
+
tool: "jscpd",
|
|
3739
|
+
replacement: "fallow"
|
|
3740
|
+
},
|
|
3741
|
+
{
|
|
3742
|
+
pattern: /(?:^|\/)(?:\.eslintrc(?:\.\w+)?|\.eslintignore|eslint\.config\.[cm]?[jt]s)$/u,
|
|
3743
|
+
tool: "ESLint",
|
|
3744
|
+
replacement: "`lint` in vite.config.ts, run with `vp check`"
|
|
3745
|
+
},
|
|
3746
|
+
{
|
|
3747
|
+
pattern: /(?:^|\/)(?:\.prettierrc(?:\.\w+)?|\.prettierignore|prettier\.config\.[cm]?[jt]s)$/u,
|
|
3748
|
+
tool: "Prettier",
|
|
3749
|
+
replacement: "`fmt` in vite.config.ts, run with `vp check`"
|
|
3750
|
+
},
|
|
3751
|
+
{
|
|
3752
|
+
pattern: /(?:^|\/)jest\.config\.(?:json|[cm]?[jt]s)$/u,
|
|
3753
|
+
tool: "Jest",
|
|
3754
|
+
replacement: "`test` in vite.config.ts, run with `vp test`"
|
|
3755
|
+
},
|
|
3756
|
+
{
|
|
3757
|
+
pattern: /(?:^|\/)wrangler\.(?:toml|jsonc?)$/u,
|
|
3758
|
+
tool: "wrangler",
|
|
3759
|
+
replacement: ALCHEMY
|
|
3760
|
+
},
|
|
3761
|
+
{
|
|
3762
|
+
pattern: /(?:^|\/)Pulumi(?:\.[\w-]+)?\.ya?ml$/u,
|
|
3763
|
+
tool: "Pulumi",
|
|
3764
|
+
replacement: ALCHEMY
|
|
3765
|
+
},
|
|
3766
|
+
{
|
|
3767
|
+
pattern: /\.tf(?:vars)?$/u,
|
|
3768
|
+
tool: "Terraform",
|
|
3769
|
+
replacement: ALCHEMY
|
|
3770
|
+
},
|
|
3771
|
+
{
|
|
3772
|
+
pattern: /(?:^|\/)\.claude\/rules\//u,
|
|
3773
|
+
tool: ".claude/rules",
|
|
3774
|
+
replacement: "the root AGENTS.md and the skills in masseater/skills"
|
|
3775
|
+
}
|
|
3776
|
+
];
|
|
3777
|
+
const problemFor = ({ name, file }) => pipe(REPLACED, Array.findFirst(({ pattern }) => pattern.test(name)), Option.map(({ tool, replacement }) => ({
|
|
3778
|
+
file,
|
|
3779
|
+
line: FIRST,
|
|
3780
|
+
column: FIRST,
|
|
3781
|
+
rule: RULE,
|
|
3782
|
+
message: `belongs to ${tool}, which this repository replaced with ${replacement}. Move what is still needed there and delete this file.`
|
|
3783
|
+
})));
|
|
3784
|
+
/** @internal */
|
|
3785
|
+
const checkReplacedTools = Effect.fn("checkReplacedTools")(function* checkReplacedTools(root) {
|
|
3786
|
+
const listed = yield* listedFiles(root);
|
|
3787
|
+
const present = yield* presentFiles(pipe(listed, Array.filter((entry) => Option.isSome(problemFor(entry)))));
|
|
3788
|
+
return pipe(present, Array.flatMap((entry) => Option.toArray(problemFor(entry))));
|
|
3789
|
+
});
|
|
3158
3790
|
// src/features/unneeded-files/model/unneeded-files.ts
|
|
3159
3791
|
const WORKSPACE_FILE = "pnpm-workspace.yaml";
|
|
3160
3792
|
const PNPM_DIRECTORY = ".pnpm/";
|
|
@@ -3288,6 +3920,10 @@ const checkTrackedText = Effect.fn("checkTrackedText")(function* checkTrackedTex
|
|
|
3288
3920
|
checkHiddenUnicode(root),
|
|
3289
3921
|
checkPython(root),
|
|
3290
3922
|
checkUnneededFiles(root),
|
|
3923
|
+
checkReplacedTools(root),
|
|
3924
|
+
checkAlchemyPatch(root),
|
|
3925
|
+
checkNodeVersion(root),
|
|
3926
|
+
checkSkillFiles(root),
|
|
3291
3927
|
checkComments(root)
|
|
3292
3928
|
], { concurrency: "unbounded" });
|
|
3293
3929
|
return Array.flatten(found);
|
|
@@ -3300,10 +3936,9 @@ const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
|
|
|
3300
3936
|
checkOverrides(root),
|
|
3301
3937
|
checkTrackedText(root),
|
|
3302
3938
|
checkPlacement(root),
|
|
3303
|
-
checkScripts(root),
|
|
3304
3939
|
checkPublishedPackages(root),
|
|
3305
3940
|
checkWorkspaces(root),
|
|
3306
|
-
|
|
3941
|
+
checkToolUse(root)
|
|
3307
3942
|
], { concurrency: "unbounded" });
|
|
3308
3943
|
return Array.flatten(found);
|
|
3309
3944
|
});
|