@r_masseater/msch 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { $ as isTypeLiteralNode, A as isArrayLiteralExpression, B as isModuleBlock, C as IndexKind, D as getLeadingCommentRanges, E as getJSDocTags, F as isEnumDeclaration, G as isPropertyAccessExpression, H as isNewExpression, I as isExportDeclaration, J as isSignatureDeclaration, K as isPropertyAssignment, L as isIdentifier, M as isCallExpression, N as isClassDeclaration, O as getNameOfDeclaration, P as isElementAccessExpression, Q as isTypeAliasDeclaration, R as isImportDeclaration, S as API, T as SyntaxKind, U as isNumericLiteral, V as isModuleDeclaration, W as isObjectLiteralExpression, X as isSpreadElement, Y as isSourceFile, Z as isStringLiteral, _ as propertyNamesOf, a as sortProblems, b as symbolAt, c as columnOf, d as descendantsOf, et as isTypeReferenceNode, f as importedModulesOf, g as lineOf, h as isTypeDeclaration, i as problemAt, it as isVariableStatement, j as isBinaryExpression, k as getTextOfJSDocComment, l as contains, m as isGenericDeclaration, nt as isVariableDeclaration, o as NODE_MODULES_SEGMENT, p as isExternalDeclaration, q as isSatisfiesExpression, r as formatProblem, rt as isVariableDeclarationList, s as childrenOf$2, t as ProblemList, tt as isUnionTypeNode, u as declarationsOf, v as referencedSymbols, w as InternalSymbolName, x as uniqueByReference, y as resolvedSymbol, z as isInterfaceDeclaration } from "./problem-BeBSq75T.mjs";
3
- import { i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-CfhXZQrO.mjs";
4
- import { C as publicEntriesOf, D as workspaceDependencies, E as readManifest, S as publishedWorkspaces, T as dependencyEntries, _ as keyName, c as workspaceDirectories, g as childrenOf$3, h as KeySchema, i as hasVerifyTask, m as workspaceConfigOf, n as VERIFY_TASK, r as definesTask, v as literalOf, w as MANIFEST_FILE, y as nestedValues } from "./workspace-jN1GGTGn.mjs";
2
+ import { $ as isTypeLiteralNode, A as isArrayLiteralExpression, B as isModuleBlock, C as IndexKind, D as getLeadingCommentRanges, E as getJSDocTags, F as isEnumDeclaration, G as isPropertyAccessExpression, H as isNewExpression, I as isExportDeclaration, J as isSignatureDeclaration, K as isPropertyAssignment, L as isIdentifier, M as isCallExpression, N as isClassDeclaration, O as getNameOfDeclaration, P as isElementAccessExpression, Q as isTypeAliasDeclaration, R as isImportDeclaration, S as API, T as SyntaxKind, U as isNumericLiteral, V as isModuleDeclaration, W as isObjectLiteralExpression, X as isSpreadElement, Y as isSourceFile, Z as isStringLiteral, _ as propertyNamesOf, a as sortProblems, b as symbolAt, c as columnOf, d as descendantsOf, et as isTypeReferenceNode, f as importedModulesOf, g as lineOf, h as isTypeDeclaration, i as problemAt, it as isVariableStatement, j as isBinaryExpression, k as getTextOfJSDocComment, l as contains, m as isGenericDeclaration, nt as isVariableDeclaration, o as NODE_MODULES_SEGMENT, p as isExternalDeclaration, q as isSatisfiesExpression, r as formatProblem, rt as isVariableDeclarationList, s as childrenOf$2, t as ProblemList, tt as isUnionTypeNode, u as declarationsOf, v as referencedSymbols, w as InternalSymbolName, x as uniqueByReference, y as resolvedSymbol, z as isInterfaceDeclaration } from "./problem-B5LCnsRC.mjs";
3
+ import { i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-DcTnXciI.mjs";
4
+ import { C as publishedWorkspaces, D as readManifest, E as dependencyEntries, O as workspaceDependencies, T as MANIFEST_FILE, _ as childrenOf$3, a as hasVerifyTask, b as nestedValues, g as KeySchema, h as workspaceConfigOf, i as definesTask, l as workspaceDirectories, r as VERIFY_TASK, t as namedWorkspaces, v as keyName, w as publicEntriesOf, y as literalOf } from "./workspace-B1-fCPnh.mjs";
5
5
  import { t as COMMENT_DIRECTIVES } from "./comment-directives-TN0dNEbg.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";
8
8
  import { parse, resolveConfigFromFile } from "vite-plus";
9
- import { LineCounter, Parser, isMap, isScalar, parse as parse$1, parseAllDocuments, parseDocument } from "yaml";
9
+ import { LineCounter, Parser, isMap, isPair, isScalar, isSeq, parse as parse$1, parseAllDocuments, parseDocument, visit } from "yaml";
10
10
  import path from "node:path";
11
11
  import { fileURLToPath } from "node:url";
12
12
  import treeSitter from "@vscode/tree-sitter-wasm";
@@ -315,10 +315,10 @@ const mentions$1 = (needle) => ({ api }) => (configPath) => Effect.gen(function*
315
315
  return pipe(texts, Array.some((text) => Option.exists(text, includesNeedle)));
316
316
  });
317
317
  // src/shared/lib/text-position.ts
318
- const START$6 = 0;
318
+ const START$7 = 0;
319
319
  const FIRST_COLUMN$3 = 1;
320
320
  const positionOf = (source) => (index) => {
321
- const before = pipe(source, String$1.slice(START$6, index), String$1.split("\n"));
321
+ const before = pipe(source, String$1.slice(START$7, index), String$1.split("\n"));
322
322
  return {
323
323
  line: before.length,
324
324
  column: pipe(Array.last(before), Option.match({
@@ -330,9 +330,9 @@ const positionOf = (source) => (index) => {
330
330
  // src/features/install-size/model/import-graph.ts
331
331
  const RELATIVE = /^\.\.?(?:\/|$)/u;
332
332
  const SUBPATH_IMPORT = "#";
333
- const WILDCARD = "*";
334
- const SCOPE$1 = "@";
335
- const SEPARATOR$4 = "/";
333
+ const WILDCARD$1 = "*";
334
+ const SCOPE = "@";
335
+ const SEPARATOR$5 = "/";
336
336
  const SOURCE_SUFFIXES = [
337
337
  "",
338
338
  ".ts",
@@ -344,9 +344,9 @@ const PLAIN_SEGMENTS = 1;
344
344
  const ImportsField = Schema.Struct({ imports: Schema.optional(Schema.Record(Schema.String, Schema.String)) });
345
345
  const decodeImports = Schema.decodeOption(Schema.fromJsonString(ImportsField));
346
346
  const packageNameOf = (specifier) => {
347
- const segments = String$1.split(specifier, SEPARATOR$4);
348
- if (String$1.startsWith(SCOPE$1)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS$1), Array.join(SEPARATOR$4));
349
- return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$4));
347
+ const segments = String$1.split(specifier, SEPARATOR$5);
348
+ if (String$1.startsWith(SCOPE)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS$1), Array.join(SEPARATOR$5));
349
+ return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$5));
350
350
  };
351
351
  const literalText = (specifier) => pipe(Option.liftPredicate(specifier, isStringLiteral), Option.map((literal) => literal.text));
352
352
  const runtimeSpecifierOf = (statement) => {
@@ -364,9 +364,9 @@ const specifiersIn = (api, file, text) => {
364
364
  return Array.getSomes(found);
365
365
  };
366
366
  const subpathTarget = (imports, specifier) => pipe(Record.toEntries(imports), Array.findFirst(([pattern, target]) => {
367
- if (!String$1.endsWith(WILDCARD)(pattern)) return Option.liftPredicate(target, () => pattern === specifier);
368
- const prefix = String$1.replace(WILDCARD, "")(pattern);
369
- return Option.liftPredicate(String$1.replace(WILDCARD, String$1.replace(prefix, "")(specifier))(target), () => String$1.startsWith(prefix)(specifier));
367
+ if (!String$1.endsWith(WILDCARD$1)(pattern)) return Option.liftPredicate(target, () => pattern === specifier);
368
+ const prefix = String$1.replace(WILDCARD$1, "")(pattern);
369
+ return Option.liftPredicate(String$1.replace(WILDCARD$1, String$1.replace(prefix, "")(specifier))(target), () => String$1.startsWith(prefix)(specifier));
370
370
  }));
371
371
  const existingSource = Effect.fn("existingSource")(function* existingSource(base) {
372
372
  const files = yield* RepositoryFiles;
@@ -514,11 +514,11 @@ const LISTED_LARGEST = 5;
514
514
  const SIZE_CONCURRENCY = 32;
515
515
  const MEGABYTE = 1e6;
516
516
  const MEGABYTE_DIGITS = 1;
517
- const START$5 = 0;
517
+ const START$6 = 0;
518
518
  const SINGLE_ENTRY = 1;
519
519
  const megabytes = (bytes) => `${(bytes / MEGABYTE).toFixed(MEGABYTE_DIGITS)} MB`;
520
520
  const usageHint = (dependency, entryCount) => {
521
- if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$5 && dependency.entries.length < entryCount)) return "";
521
+ if (!(entryCount > SINGLE_ENTRY && dependency.entries.length > START$6 && dependency.entries.length < entryCount)) return "";
522
522
  return ` (imported only from ${Array.join(dependency.entries, ", ")})`;
523
523
  };
524
524
  const listed = ({ largest, entryCount }) => pipe(largest, Array.map((dependency) => `${dependency.name} ${megabytes(dependency.size)}${usageHint(dependency, entryCount)}`), Array.join(", "));
@@ -527,7 +527,7 @@ const budgetProblem = Effect.fn("budgetProblem")(function* budgetProblem(overrun
527
527
  const { workspace, total } = overrun;
528
528
  const config = yield* files.readFile(workspace.configFile);
529
529
  const source = Option.getOrElse(config, () => "");
530
- const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$5);
530
+ const index = Option.getOrElse(String$1.indexOf(BUDGET_KEY)(source), () => START$6);
531
531
  return {
532
532
  file: workspace.configFile,
533
533
  ...positionOf(source)(index),
@@ -544,7 +544,7 @@ const measure = Effect.fn("measure")(function* measure({ workspace, provided },
544
544
  const everything = pipe(closures, Array.flatMap(([, packages]) => Array.fromIterable(packages)), HashSet.fromIterable);
545
545
  const measured = yield* Effect.forEach(everything, (found) => installedSize(found).pipe(Effect.map((size) => [found, size])), { concurrency: SIZE_CONCURRENCY });
546
546
  const sizes = HashMap.fromIterable(measured);
547
- const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$5))));
547
+ const sizeOf = (packages) => Number$1.sumAll(pipe(Array.fromIterable(packages), Array.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START$6))));
548
548
  return {
549
549
  closures,
550
550
  sizeOf,
@@ -577,11 +577,11 @@ const sizeProblems = Effect.fn("sizeProblems")(function* sizeProblems(published,
577
577
  })];
578
578
  });
579
579
  const stackProblems = (file, source, dependencies) => {
580
- const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$5);
580
+ const section = Option.getOrElse(String$1.indexOf(DEPENDENCIES_KEY)(source), () => START$6);
581
581
  const rest = String$1.slice(section)(source);
582
582
  return pipe(Record.toEntries(dependencies), Array.filter(([, specifier]) => specifier === STACK_CATALOG), Array.map(([name]) => ({
583
583
  file,
584
- ...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$5)),
584
+ ...positionOf(source)(section + Option.getOrElse(String$1.indexOf(`"${name}"`)(rest), () => START$6)),
585
585
  rule: STACK_DEPENDENCY,
586
586
  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.`
587
587
  })));
@@ -920,14 +920,42 @@ const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root
920
920
  if (Option.isNone(manifest) || !Array.isReadonlyArrayNonEmpty(keys)) return [];
921
921
  return yield* problemsFor(root, manifest.value, keys);
922
922
  });
923
+ // src/features/placement/model/agent-docs-length.ts
924
+ const AGENT_DOC = /(?:^|\/)(?:AGENTS|CLAUDE)\.md$/u;
925
+ const RECOMMENDED_LINES = 200;
926
+ const READ_CONCURRENCY$12 = 16;
927
+ const FIRST$7 = 1;
928
+ const RULE$12 = "agent-docs-length";
929
+ const lineCount = (source) => pipe(String$1.trimEnd(source), String$1.split("\n")).length;
930
+ const problemFor$4 = (file) => (lines) => {
931
+ if (lines <= RECOMMENDED_LINES) return Option.none();
932
+ return Option.some({
933
+ file,
934
+ line: 201,
935
+ column: FIRST$7,
936
+ rule: RULE$12,
937
+ 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.`
938
+ });
939
+ };
940
+ /** @internal */
941
+ const checkAgentDocsLength = Effect.fn("checkAgentDocsLength")(function* checkAgentDocsLength(root) {
942
+ const files = yield* RepositoryFiles;
943
+ const listed = yield* files.listedFiles(root);
944
+ const docs = pipe(listed, Array.filter((name) => AGENT_DOC.test(name)));
945
+ const found = yield* Effect.forEach(docs, (name) => {
946
+ const file = files.join(root, name);
947
+ return files.readFile(file).pipe(Effect.map(Option.flatMap((source) => problemFor$4(file)(lineCount(source)))));
948
+ }, { concurrency: READ_CONCURRENCY$12 });
949
+ return Array.getSomes(found);
950
+ });
923
951
  // src/features/placement/model/colocated-tests.ts
924
- const RULE$8 = "colocated-test";
925
- const FIRST$4 = 1;
926
- const READ_CONCURRENCY$8 = 64;
952
+ const RULE$11 = "colocated-test";
953
+ const FIRST$6 = 1;
954
+ const READ_CONCURRENCY$11 = 64;
927
955
  const ROOT_SUBPATH = ".";
928
956
  const NAME_GROUP = "name";
929
957
  const SPECIFIER_GROUP = "specifier";
930
- const SCRIPT = /\.[cm]?[jt]sx?$/u;
958
+ const SCRIPT$1 = /\.[cm]?[jt]sx?$/u;
931
959
  const TEST_FILE = /\.test\.[cm]?[jt]sx?$/u;
932
960
  const MANIFEST_NAME = /package\.json$/u;
933
961
  const SEPARATE_TEST_DIRECTORY = /(?:^|\/)(?:__tests__|__mocks__|tests?|specs?)\//u;
@@ -943,15 +971,15 @@ const Manifest = Schema.Struct({
943
971
  });
944
972
  const decodeManifest = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest));
945
973
  const byLength = Order.mapInput(Order.Number, (directory) => directory.length);
946
- const problemFor$2 = (test, message) => ({
974
+ const problemFor$3 = (test, message) => ({
947
975
  file: test.file,
948
- line: FIRST$4,
949
- column: FIRST$4,
950
- rule: RULE$8,
976
+ line: FIRST$6,
977
+ column: FIRST$6,
978
+ rule: RULE$11,
951
979
  message: `${test.base} ${message}`
952
980
  });
953
- const groupsOf = (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);
954
- const namesSibling = (source) => pipe([...groupsOf(source, RELATIVE_REFERENCE, NAME_GROUP), ...groupsOf(source, DIRNAME_REFERENCE, NAME_GROUP)], Array.some((name) => !TEST_FILE.test(name)));
981
+ 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);
982
+ const namesSibling = (source) => pipe([...groupsOf$1(source, RELATIVE_REFERENCE, NAME_GROUP), ...groupsOf$1(source, DIRNAME_REFERENCE, NAME_GROUP)], Array.some((name) => !TEST_FILE.test(name)));
955
983
  const ownerOf$1 = (packages, name) => {
956
984
  const owners = pipe(packages, Array.filter((directory) => String$1.startsWith(directory)(name)));
957
985
  return Array.last(Array.sort(owners, byLength));
@@ -975,7 +1003,7 @@ const ownSpecifiers = Effect.fn("ownSpecifiers")(function* ownSpecifiers(context
975
1003
  });
976
1004
  const refersToOwnDirectory = Effect.fn("refersToOwnDirectory")(function* refersToOwnDirectory(context, test, source) {
977
1005
  if (namesSibling(source)) return true;
978
- const specifiers = groupsOf(source, MODULE_SPECIFIER, SPECIFIER_GROUP);
1006
+ const specifiers = groupsOf$1(source, MODULE_SPECIFIER, SPECIFIER_GROUP);
979
1007
  if (Array.isReadonlyArrayEmpty(specifiers)) return false;
980
1008
  const own = yield* ownSpecifiers(context, test);
981
1009
  return pipe(specifiers, Array.some((specifier) => pipe(own, Array.contains(specifier))));
@@ -986,10 +1014,10 @@ const refersIn = Effect.fn("refersIn")(function* refersIn(context, test) {
986
1014
  return yield* refersToOwnDirectory(context, test, source.value);
987
1015
  });
988
1016
  const problemIn$3 = Effect.fn("problemIn")(function* problemIn(context, test) {
989
- if (SEPARATE_TEST_DIRECTORY.test(test.name)) return Option.some(problemFor$2(test, DIRECTORY_MESSAGE));
1017
+ if (SEPARATE_TEST_DIRECTORY.test(test.name)) return Option.some(problemFor$3(test, DIRECTORY_MESSAGE));
990
1018
  if (!TEST_FILE.test(test.name)) return Option.none();
991
1019
  if (yield* refersIn(context, test)) return Option.none();
992
- return Option.some(problemFor$2(test, SIBLING_MESSAGE));
1020
+ return Option.some(problemFor$3(test, SIBLING_MESSAGE));
993
1021
  });
994
1022
  /** @internal */
995
1023
  const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColocatedTests(root) {
@@ -1000,7 +1028,7 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
1000
1028
  root,
1001
1029
  packages: pipe(names, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map(String$1.replace(MANIFEST_NAME, "")))
1002
1030
  };
1003
- const tests = pipe(names, Array.filter((name) => SCRIPT.test(name)), Array.map((name) => {
1031
+ const tests = pipe(names, Array.filter((name) => SCRIPT$1.test(name)), Array.map((name) => {
1004
1032
  const file = files.join(root, name);
1005
1033
  return {
1006
1034
  name,
@@ -1009,40 +1037,40 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
1009
1037
  directory: files.dirname(file)
1010
1038
  };
1011
1039
  }));
1012
- const found = yield* Effect.forEach(tests, (test) => problemIn$3(context, test), { concurrency: READ_CONCURRENCY$8 });
1040
+ const found = yield* Effect.forEach(tests, (test) => problemIn$3(context, test), { concurrency: READ_CONCURRENCY$11 });
1013
1041
  return Array.getSomes(found);
1014
1042
  });
1015
1043
  // src/features/placement/model/nested-docs.ts
1016
- const RULE$7 = "nested-docs";
1044
+ const RULE$10 = "nested-docs";
1017
1045
  const CONFIG_FILE$4 = "vite.config.ts";
1018
- const SEPARATOR$3 = "/";
1019
- const FIRST$3 = 1;
1020
- const READ_CONCURRENCY$7 = 64;
1046
+ const SEPARATOR$4 = "/";
1047
+ const FIRST$5 = 1;
1048
+ const READ_CONCURRENCY$10 = 64;
1021
1049
  const AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
1022
1050
  const WORKSPACE_AGENT_DOC = "AGENTS.md";
1023
- const README$1 = /^README(?:\.[^/]+)?$/iu;
1051
+ const README = /^README(?:\.[^/]+)?$/iu;
1024
1052
  const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
1025
1053
  const taggedError$3 = Schema.TaggedError;
1026
1054
  var RootConfigUnreadable = class extends taggedError$3()("RootConfigUnreadable", { file: Schema.String }) {};
1027
- const isNested = (name) => String$1.includes(SEPARATOR$3)(name);
1028
- const problemFor$1 = (file, message) => ({
1055
+ const isNested = (name) => String$1.includes(SEPARATOR$4)(name);
1056
+ const problemFor$2 = (file, message) => ({
1029
1057
  file,
1030
- line: FIRST$3,
1031
- column: FIRST$3,
1032
- rule: RULE$7,
1058
+ line: FIRST$5,
1059
+ column: FIRST$5,
1060
+ rule: RULE$10,
1033
1061
  message
1034
1062
  });
1035
1063
  const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
1036
1064
  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.";
1037
1065
  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.";
1038
1066
  const agentDocProblem = ({ file, base, directory }, allowed) => {
1039
- if (!allowed.workspaceAgentDocs) return Option.some(problemFor$1(file, `${base} ${AGENT_DOCS_MESSAGE}`));
1067
+ if (!allowed.workspaceAgentDocs) return Option.some(problemFor$2(file, `${base} ${AGENT_DOCS_MESSAGE}`));
1040
1068
  if (base === WORKSPACE_AGENT_DOC && HashSet.has(allowed.workspaces, directory)) return Option.none();
1041
- return Option.some(problemFor$1(file, `${base} ${WORKSPACE_AGENT_DOCS_MESSAGE}`));
1069
+ return Option.some(problemFor$2(file, `${base} ${WORKSPACE_AGENT_DOCS_MESSAGE}`));
1042
1070
  };
1043
1071
  const readmeProblem = ({ file, base, directory }, allowed) => {
1044
- if (!README$1.test(base) || HashSet.has(allowed.workspaces, directory)) return Option.none();
1045
- return Option.some(problemFor$1(file, `${base} ${README_MESSAGE}`));
1072
+ if (!README.test(base) || HashSet.has(allowed.workspaces, directory)) return Option.none();
1073
+ return Option.some(problemFor$2(file, `${base} ${README_MESSAGE}`));
1046
1074
  };
1047
1075
  const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, allowed, name) {
1048
1076
  const files = yield* RepositoryFiles;
@@ -1075,49 +1103,22 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
1075
1103
  workspaces: pipe(nested, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map((name) => files.dirname(files.join(root, name))), HashSet.fromIterable),
1076
1104
  workspaceAgentDocs
1077
1105
  };
1078
- const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$7 });
1106
+ const found = yield* Effect.forEach(nested, (name) => problemIn$2(root, allowed, name), { concurrency: READ_CONCURRENCY$10 });
1079
1107
  return Array.getSomes(found);
1080
1108
  });
1081
1109
  // src/features/placement/model/root-readme.ts
1082
- const RULE$6 = "root-readme";
1083
- const SEPARATOR$2 = "/";
1084
- const ALTERNATIVE = "|";
1085
- const SCOPE = /^@[^/]+\//u;
1086
- const README = /^README(?:\.[^/]+)?$/iu;
1087
- const SPECIAL = /[$()*+.?[\\\]^{|}]/gu;
1088
- const READ_CONCURRENCY$6 = 16;
1089
- const START$4 = 0;
1090
- const NamedManifest = Schema.fromJsonString(Schema.Struct({ name: Schema.optional(Schema.String) }));
1091
- const patternOf = (names) => {
1092
- const alternatives = pipe(names, Array.map(String$1.replaceAll(SPECIAL, String.raw`\$&`)));
1093
- return new RegExp(`(?<![\\p{L}\\p{N}_-])(?:${Array.join(alternatives, ALTERNATIVE)})(?![\\p{L}\\p{N}_-])`, "gu");
1094
- };
1095
- const packageNameIn = (text) => pipe(text, Option.flatMap(Schema.decodeOption(NamedManifest)), Option.flatMap((manifest) => Option.fromUndefinedOr(manifest.name)));
1096
- const workspaceIn = Effect.fn("workspaceIn")(function* workspaceIn(root, name) {
1097
- const files = yield* RepositoryFiles;
1098
- const directory = files.dirname(name);
1099
- const text = yield* files.readFile(files.join(root, name));
1100
- const packageName = packageNameIn(text);
1101
- const unscoped = pipe(packageName, Option.map(String$1.replace(SCOPE, "")));
1102
- const names = pipe([
1103
- Option.some(directory),
1104
- Option.some(files.basename(directory)),
1105
- packageName,
1106
- unscoped
1107
- ], Array.getSomes, Array.dedupe);
1108
- return {
1109
- directory,
1110
- pattern: patternOf(names)
1111
- };
1112
- });
1113
- const messageFor = (directory) => `names the workspace ${directory}. The root README describes the repository as a whole. Write what belongs to the workspace in ${directory}/README.md.`;
1114
- const problemsIn$2 = (file, source) => ({ directory, pattern }) => {
1110
+ const RULE$9 = "root-readme";
1111
+ const ROOT_DOC = /^(?:README(?:\.[^/]+)?|AGENTS\.md|CLAUDE\.md)$/iu;
1112
+ const READ_CONCURRENCY$9 = 16;
1113
+ const START$5 = 0;
1114
+ 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.`;
1115
+ const problemsIn$4 = (file, source) => ({ directory, pattern }) => {
1115
1116
  const message = messageFor(directory);
1116
1117
  const at = positionOf(source);
1117
1118
  return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
1118
1119
  file,
1119
- ...at(found.index ?? START$4),
1120
- rule: RULE$6,
1120
+ ...at(found.index ?? START$5),
1121
+ rule: RULE$9,
1121
1122
  message
1122
1123
  })));
1123
1124
  };
@@ -1125,17 +1126,16 @@ const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadm
1125
1126
  const text = yield* (yield* RepositoryFiles).readFile(file);
1126
1127
  return pipe(text, Option.match({
1127
1128
  onNone: () => [],
1128
- onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$2(file, source)))
1129
+ onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$4(file, source)))
1129
1130
  }));
1130
1131
  });
1131
1132
  /** @internal */
1132
1133
  const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(root) {
1133
1134
  const files = yield* RepositoryFiles;
1134
1135
  const names = yield* files.listedFiles(root);
1135
- const readmes = pipe(names, Array.filter((name) => README.test(name)));
1136
- const manifests = pipe(names, Array.filter((name) => String$1.includes(SEPARATOR$2)(name) && files.basename(name) === "package.json"));
1137
- const workspaces = yield* Effect.forEach(manifests, (name) => workspaceIn(root, name), { concurrency: READ_CONCURRENCY$6 });
1138
- const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$6 });
1136
+ const readmes = pipe(names, Array.filter((name) => ROOT_DOC.test(name)));
1137
+ const workspaces = yield* namedWorkspaces(root);
1138
+ const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces), { concurrency: READ_CONCURRENCY$9 });
1139
1139
  return Array.flatten(found);
1140
1140
  });
1141
1141
  // src/features/placement/model/placement-checks.ts
@@ -1144,17 +1144,18 @@ const checkPlacement = Effect.fn("checkPlacement")(function* checkPlacement(root
1144
1144
  const found = yield* Effect.all([
1145
1145
  checkNestedDocs(root),
1146
1146
  checkRootReadme(root),
1147
- checkColocatedTests(root)
1147
+ checkColocatedTests(root),
1148
+ checkAgentDocsLength(root)
1148
1149
  ], { concurrency: "unbounded" });
1149
1150
  return Array.flatten(found);
1150
1151
  });
1151
1152
  // src/features/repository-layout/model/crates.ts
1152
- const RULE$5 = "unverified-crate";
1153
+ const RULE$8 = "unverified-crate";
1153
1154
  const CARGO_FILE = "Cargo.toml";
1154
1155
  const CONFIG_FILE$3 = "vite.config.ts";
1155
- const SEPARATOR$1 = "/";
1156
- const FIRST$2 = 1;
1157
- const READ_CONCURRENCY$5 = 8;
1156
+ const SEPARATOR$3 = "/";
1157
+ const FIRST$4 = 1;
1158
+ const READ_CONCURRENCY$8 = 8;
1158
1159
  const CrateEntry = Schema.Struct({
1159
1160
  name: Schema.String,
1160
1161
  manifest_path: Schema.String
@@ -1180,22 +1181,22 @@ const cratesIn = Effect.fn("cratesIn")(function* cratesIn(root) {
1180
1181
  })));
1181
1182
  }, Effect.scoped);
1182
1183
  const owningWorkspace = (directories) => (directory) => {
1183
- const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$1}`)(directory)));
1184
+ const owners = pipe(directories, Array.filter((workspace) => directory === workspace || String$1.startsWith(`${workspace}${SEPARATOR$3}`)(directory)));
1184
1185
  return Array.last(Array.sort(owners, String$1.Order));
1185
1186
  };
1186
- const problemFor = (crate, message) => ({
1187
+ const problemFor$1 = (crate, message) => ({
1187
1188
  file: crate.manifest,
1188
- line: FIRST$2,
1189
- column: FIRST$2,
1190
- rule: RULE$5,
1189
+ line: FIRST$4,
1190
+ column: FIRST$4,
1191
+ rule: RULE$8,
1191
1192
  message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
1192
1193
  });
1193
1194
  const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
1194
1195
  const files = yield* RepositoryFiles;
1195
1196
  const workspace = owningWorkspace(directories)(files.relative(root, files.dirname(crate.manifest)));
1196
- if (Option.isNone(workspace)) return Option.some(problemFor(crate, "is outside every workspace package"));
1197
+ if (Option.isNone(workspace)) return Option.some(problemFor$1(crate, "is outside every workspace package"));
1197
1198
  if (yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE$3))) return Option.none();
1198
- return Option.some(problemFor(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$3} has no verify task`));
1199
+ return Option.some(problemFor$1(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$3} has no verify task`));
1199
1200
  });
1200
1201
  /** @internal */
1201
1202
  const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
@@ -1203,14 +1204,14 @@ const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
1203
1204
  if (!(yield* files.exists(files.join(root, CARGO_FILE)))) return [];
1204
1205
  const directories = yield* workspaceDirectories(root);
1205
1206
  const crates = yield* cratesIn(root);
1206
- const found = yield* Effect.forEach(crates, (crate) => problemIn$1(root, directories, crate), { concurrency: READ_CONCURRENCY$5 });
1207
+ const found = yield* Effect.forEach(crates, (crate) => problemIn$1(root, directories, crate), { concurrency: READ_CONCURRENCY$8 });
1207
1208
  return Array.getSomes(found);
1208
1209
  });
1209
1210
  // src/features/repository-layout/model/hidden-verify.ts
1210
- const RULE$4 = "hidden-verify";
1211
+ const RULE$7 = "hidden-verify";
1211
1212
  const CONFIG_FILE$2 = "vite.config.ts";
1212
- const FIRST$1 = 1;
1213
- const READ_CONCURRENCY$4 = 8;
1213
+ const FIRST$3 = 1;
1214
+ const READ_CONCURRENCY$7 = 8;
1214
1215
  const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
1215
1216
  const config = yield* workspaceConfigOf(root, directory);
1216
1217
  if (Option.isNone(config)) return Option.none();
@@ -1219,24 +1220,24 @@ const problemIn = Effect.fn("problemIn")(function* problemIn(root, directory) {
1219
1220
  const verified = yield* hasVerifyTask(file);
1220
1221
  return Option.some({
1221
1222
  file,
1222
- line: FIRST$1,
1223
- column: FIRST$1,
1224
- rule: RULE$4,
1223
+ line: FIRST$3,
1224
+ column: FIRST$3,
1225
+ rule: RULE$7,
1225
1226
  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}.`
1226
1227
  }).pipe(Option.filter(() => verified));
1227
1228
  });
1228
1229
  /** @internal */
1229
1230
  const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVerify(root) {
1230
1231
  const directories = yield* workspaceDirectories(root);
1231
- const found = yield* Effect.forEach(directories, (directory) => problemIn(root, directory), { concurrency: READ_CONCURRENCY$4 });
1232
+ const found = yield* Effect.forEach(directories, (directory) => problemIn(root, directory), { concurrency: READ_CONCURRENCY$7 });
1232
1233
  return Array.getSomes(found);
1233
1234
  });
1234
1235
  // src/features/repository-layout/model/root-workspace-paths.ts
1235
- const RULE$3 = "root-workspace-path";
1236
+ const RULE$6 = "root-workspace-path";
1236
1237
  const CONFIG_FILE$1 = "vite.config.ts";
1237
1238
  const PATH_CHARACTER = /[\w.@/-]/u;
1238
1239
  const NAME_CHARACTER = /[\w.@-]/u;
1239
- const FIRST = 0;
1240
+ const FIRST$2 = 0;
1240
1241
  const NEXT$2 = 1;
1241
1242
  const StringNode = Schema.Union([Schema.Struct({
1242
1243
  type: Schema.Literal("Literal"),
@@ -1264,14 +1265,14 @@ const mentions = (directory) => (text) => {
1264
1265
  return pipe(Array.drop(parts, NEXT$2), Array.some((after, index) => {
1265
1266
  const before = parts[index] ?? "";
1266
1267
  const previous = String$1.slice(before.length - NEXT$2)(before);
1267
- const following = String$1.slice(FIRST, NEXT$2)(after);
1268
+ const following = String$1.slice(FIRST$2, NEXT$2)(after);
1268
1269
  return isBoundary(previous, PATH_CHARACTER) && (following === "/" || isBoundary(following, NAME_CHARACTER));
1269
1270
  }));
1270
1271
  };
1271
- const problemsIn$1 = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
1272
+ const problemsIn$3 = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
1272
1273
  file,
1273
1274
  ...positionOf(source)(found.start),
1274
- rule: RULE$3,
1275
+ rule: RULE$6,
1275
1276
  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.`
1276
1277
  })));
1277
1278
  /** @internal */
@@ -1282,12 +1283,12 @@ const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* c
1282
1283
  if (Option.isNone(source)) return [];
1283
1284
  const directories = yield* workspaceDirectories(root);
1284
1285
  const parsed = yield* Effect.promise(() => parse(file, source.value, { lang: "ts" }));
1285
- return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$1(file, source.value, directories)));
1286
+ return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$3(file, source.value, directories)));
1286
1287
  });
1287
1288
  // src/features/repository-layout/model/shared-uncached-tasks.ts
1288
- const RULE$2 = "shared-uncached-task";
1289
+ const RULE$5 = "shared-uncached-task";
1289
1290
  const TASKS_PATH = ["run", "tasks"];
1290
- const READ_CONCURRENCY$3 = 8;
1291
+ const READ_CONCURRENCY$6 = 8;
1291
1292
  const SHARED = 2;
1292
1293
  const OWN_PROGRAM = /^(?:node|vpx|bun|deno|tsx)$|\//u;
1293
1294
  const TaskProperty = Schema.Struct({
@@ -1309,12 +1310,12 @@ const decodeTaskProperty = Schema.decodeUnknownOption(TaskProperty);
1309
1310
  const decodeTaskObject = Schema.decodeUnknownOption(TaskObject);
1310
1311
  const decodeUncachedTask = Schema.decodeUnknownOption(UncachedTask);
1311
1312
  const encodeDefinition = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));
1312
- const commandText = (command) => Array.join(Array.ensure(command), " && ");
1313
+ const commandText$1 = (command) => Array.join(Array.ensure(command), " && ");
1313
1314
  const runsOwnProgram = (command) => pipe(String$1.trim(command), String$1.split(/\s+/u), Array.head, Option.exists((program) => OWN_PROGRAM.test(program)));
1314
1315
  const definitionOf = ({ directory, file, source }) => (task) => Option.gen(function* uncachedDefinition() {
1315
1316
  const literal = yield* literalOf(task.value);
1316
1317
  const { command } = yield* decodeUncachedTask(literal);
1317
- const text = commandText(command);
1318
+ const text = commandText$1(command);
1318
1319
  if (runsOwnProgram(text)) return yield* Option.none();
1319
1320
  const definition = yield* encodeDefinition(literal);
1320
1321
  return {
@@ -1342,16 +1343,236 @@ const problemsOf = (definitions) => {
1342
1343
  return pipe(definitions, Array.map(({ file, position, name, command }) => ({
1343
1344
  file,
1344
1345
  ...position,
1345
- rule: RULE$2,
1346
+ rule: RULE$5,
1346
1347
  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.`
1347
1348
  })));
1348
1349
  };
1349
1350
  /** @internal */
1350
1351
  const checkSharedUncachedTasks = Effect.fn("checkSharedUncachedTasks")(function* checkSharedUncachedTasks(root) {
1351
1352
  const directories = yield* workspaceDirectories(root);
1352
- const found = yield* Effect.forEach(directories, (directory) => definitionsIn(root, directory), { concurrency: READ_CONCURRENCY$3 });
1353
+ const found = yield* Effect.forEach(directories, (directory) => definitionsIn(root, directory), { concurrency: READ_CONCURRENCY$6 });
1353
1354
  return pipe(Array.flatten(found), Array.groupBy(({ name, definition }) => `${name}\u0000${definition}`), Record.values, Array.flatMap(problemsOf));
1354
1355
  });
1356
+ // src/features/repository-layout/model/workflow-nodes.ts
1357
+ const MISSING_OFFSET = 0;
1358
+ const isRanged = (node) => isScalar(node) || isMap(node) || isSeq(node);
1359
+ /** @internal */
1360
+ const isText$1 = (node) => isScalar(node) && typeof node.value === "string";
1361
+ const isTextPair = (pair) => isPair(pair) && isText$1(pair.key);
1362
+ const offsetOf = (node) => pipe(Option.liftPredicate(node, isRanged), Option.flatMap((ranged) => Option.fromNullishOr(ranged.range)), Option.map(([start]) => start), Option.getOrElse(() => MISSING_OFFSET));
1363
+ /** @internal */
1364
+ const stringOf = (node) => pipe(Option.liftPredicate(node, isText$1), Option.map((scalar) => ({
1365
+ text: scalar.value,
1366
+ offset: offsetOf(scalar)
1367
+ })));
1368
+ /** @internal */
1369
+ const childOf = (key) => (node) => pipe(Option.liftPredicate(node, isMap), Option.map((map) => map.get(key, true)), Option.getOrUndefined);
1370
+ /** @internal */
1371
+ const workingDirectoryOf = (owner) => {
1372
+ const run = childOf("run")(childOf("defaults")(owner));
1373
+ return stringOf(childOf("working-directory")(run));
1374
+ };
1375
+ /** @internal */
1376
+ const itemsOf = (node) => pipe(Option.liftPredicate(node, isSeq), Option.map((seq) => seq.items), Option.getOrElse(() => []));
1377
+ const pairsOf = (node) => pipe(Option.liftPredicate(node, isMap), Option.map((map) => map.items), Option.getOrElse(() => []));
1378
+ /** @internal */
1379
+ const entriesOf = (node) => pipe(pairsOf(node), Array.filter(isTextPair), Array.map((pair) => [pair.key.value, pair.value]));
1380
+ /** @internal */
1381
+ const scalarsIn = (source) => {
1382
+ const found = [];
1383
+ visit(parseDocument(source), { Scalar: (_key, node) => {
1384
+ found.push(...Option.toArray(stringOf(node)));
1385
+ } });
1386
+ return found;
1387
+ };
1388
+ // src/features/repository-layout/model/workflow-references.ts
1389
+ const ROOT = ".";
1390
+ const LOCAL = "./";
1391
+ const NEGATION = "!";
1392
+ const SEPARATOR$2 = "/";
1393
+ const LINE = "\n";
1394
+ const UNRESOLVED_MARKERS = [
1395
+ "${{",
1396
+ "$",
1397
+ "{"
1398
+ ];
1399
+ const ABSOLUTE_MARKERS = ["/", "~"];
1400
+ const FILE_INPUT_SUFFIX = "-file";
1401
+ const DEPENDENCY_PATH_INPUT = "cache-dependency-path";
1402
+ const FILTER_KEYS = ["paths", "paths-ignore"];
1403
+ const HASH_FILES = /hashFiles\((?<arguments>[^)]*)\)/gu;
1404
+ const QUOTED$1 = /'(?<path>[^']*)'/gu;
1405
+ const SCRIPT = /^[\w.@/-]+\.(?:ts|mts|cts|sh)$/u;
1406
+ const TOKEN_SEPARATOR = /[\s;&|()<>"'`=]+/u;
1407
+ /** @internal */
1408
+ const ACTION_DEFINITIONS = ["action.yml", "action.yaml"];
1409
+ const containsAny = (markers) => (path) => pipe(markers, Array.some((marker) => String$1.includes(marker)(path)));
1410
+ const startsWithAny = (markers) => (path) => pipe(markers, Array.some((marker) => String$1.startsWith(marker)(path)));
1411
+ const isLiteralPath = (path) => String$1.isNonEmpty(path) && !containsAny(UNRESOLVED_MARKERS)(path) && !startsWithAny(ABSOLUTE_MARKERS)(path);
1412
+ const withoutLocal = (path) => {
1413
+ if (String$1.startsWith(LOCAL)(path)) return String$1.slice(2)(path);
1414
+ return path;
1415
+ };
1416
+ const joinPath = (base, path) => {
1417
+ const relative = withoutLocal(String$1.trim(path));
1418
+ if (base === ROOT) return relative;
1419
+ return `${base}${SEPARATOR$2}${relative}`;
1420
+ };
1421
+ const reference = (kind, field, base = ROOT) => ({ text, offset }) => {
1422
+ const path = String$1.trim(text);
1423
+ if (!isLiteralPath(path) || !isLiteralPath(base)) return [];
1424
+ return [{
1425
+ kind,
1426
+ field,
1427
+ path: joinPath(base, path),
1428
+ offset
1429
+ }];
1430
+ };
1431
+ const isPositive = ({ text }) => !String$1.startsWith(NEGATION)(String$1.trim(text));
1432
+ const globsIn = (field, node) => pipe(itemsOf(node), Array.flatMap((item) => Option.toArray(stringOf(item))), Array.filter(isPositive), Array.flatMap(reference("glob", field)));
1433
+ const filtersOf = ([event, filters]) => pipe(FILTER_KEYS, Array.flatMap((key) => globsIn(`on.${event}.${key}`, childOf(key)(filters))));
1434
+ const directoryOf$1 = (located, base) => pipe(located, Option.map(({ text }) => joinPath(ROOT, text)), Option.getOrElse(() => base));
1435
+ const located = (kind, field, base = ROOT) => (found) => pipe(found, Option.toArray, Array.flatMap(reference(kind, field, base)));
1436
+ const localUses = (node) => pipe(stringOf(childOf("uses")(node)), Option.filter(({ text }) => String$1.startsWith(LOCAL)(text)));
1437
+ const scriptsIn = (field, base) => ({ text, offset }) => pipe(String$1.split(text, TOKEN_SEPARATOR), Array.filter((token) => SCRIPT.test(token)), Array.dedupe, Array.flatMap((token) => reference("script", field, base)({
1438
+ text: token,
1439
+ offset
1440
+ })));
1441
+ const isFileInput = ([key]) => String$1.endsWith(FILE_INPUT_SUFFIX)(key) || key === DEPENDENCY_PATH_INPUT;
1442
+ const linesOf = ({ text, offset }) => pipe(String$1.split(text, LINE), Array.map((line) => ({
1443
+ text: line,
1444
+ offset
1445
+ })));
1446
+ const fileInputOf = (field) => ([key, value]) => pipe(stringOf(value), Option.toArray, Array.flatMap(linesOf), Array.flatMap(reference("glob", `${field}.with.${key}`)));
1447
+ const fileInputsIn = (field, step) => pipe(entriesOf(childOf("with")(step)), Array.filter(isFileInput), Array.flatMap(fileInputOf(field)));
1448
+ const stepReferences = (job, base) => (step, index) => {
1449
+ const field = `jobs.${job}.steps[${index}]`;
1450
+ const own = stringOf(childOf("working-directory")(step));
1451
+ const directory = directoryOf$1(own, base);
1452
+ return [
1453
+ ...located("action", `${field}.uses`)(localUses(step)),
1454
+ ...located("directory", `${field}.working-directory`)(own),
1455
+ ...pipe(stringOf(childOf("run")(step)), Option.toArray, Array.flatMap(scriptsIn(`${field}.run`, directory))),
1456
+ ...fileInputsIn(field, step)
1457
+ ];
1458
+ };
1459
+ const jobReferences = (base) => ([job, node]) => {
1460
+ const own = workingDirectoryOf(node);
1461
+ const steps = itemsOf(childOf("steps")(node));
1462
+ const directory = directoryOf$1(own, base);
1463
+ return [
1464
+ ...located("file", `jobs.${job}.uses`)(localUses(node)),
1465
+ ...located("directory", `jobs.${job}.defaults.run.working-directory`)(own),
1466
+ ...pipe(steps, Array.flatMap(stepReferences(job, directory)))
1467
+ ];
1468
+ };
1469
+ const groupsOf = (pattern, group) => ({ text, offset }) => pipe(Array.fromIterable(String$1.matchAll(pattern)(text)), Array.flatMap((match) => pipe(Option.fromNullishOr(match.groups), Option.flatMap((groups) => Option.fromNullishOr(groups[group])), Option.toArray)), Array.map((value) => ({
1470
+ text: value,
1471
+ offset
1472
+ })));
1473
+ const hashFilesIn = (source) => pipe(scalarsIn(source), Array.flatMap(groupsOf(HASH_FILES, "arguments")), Array.flatMap(groupsOf(QUOTED$1, "path")), Array.filter(isPositive), Array.flatMap(reference("glob", "hashFiles")));
1474
+ const jobsOf = (source) => entriesOf(childOf("jobs")(parseDocument(source).contents));
1475
+ /** @internal */
1476
+ const workflowReferences = (source) => {
1477
+ const root = parseDocument(source).contents;
1478
+ const workflowDefault = workingDirectoryOf(root);
1479
+ const base = directoryOf$1(workflowDefault, ROOT);
1480
+ return [
1481
+ ...pipe(entriesOf(childOf("on")(root)), Array.flatMap(filtersOf)),
1482
+ ...located("directory", "defaults.run.working-directory")(workflowDefault),
1483
+ ...pipe(jobsOf(source), Array.flatMap(jobReferences(base))),
1484
+ ...hashFilesIn(source)
1485
+ ];
1486
+ };
1487
+ const pathInputOf = (step) => childOf("path")(childOf("with")(step));
1488
+ const outputPathsOf = (step) => pipe(stringOf(pathInputOf(step)), Option.toArray, Array.flatMap(linesOf), Array.map(({ text }) => joinPath(ROOT, text)), Array.filter(isLiteralPath));
1489
+ /** @internal */
1490
+ const producedPaths = (source) => pipe(jobsOf(source), Array.flatMap(([, job]) => itemsOf(childOf("steps")(job))), Array.flatMap(outputPathsOf));
1491
+ // src/features/repository-layout/model/workflow-paths.ts
1492
+ const RULE$4 = "workflow-path";
1493
+ const WORKFLOW_DIRECTORY = ".github/workflows/";
1494
+ const WORKFLOW_EXTENSIONS = [".yml", ".yaml"];
1495
+ const READ_CONCURRENCY$5 = 8;
1496
+ const WILDCARD = /[*?[]/u;
1497
+ const SEPARATOR$1 = "/";
1498
+ const FIRST$1 = 0;
1499
+ const EXPECTED = {
1500
+ action: "a directory with action.yml",
1501
+ directory: "a directory",
1502
+ file: "a file",
1503
+ glob: "a pattern that matches a tracked file",
1504
+ script: "a file"
1505
+ };
1506
+ const isWorkflow = (file) => String$1.startsWith(WORKFLOW_DIRECTORY)(file) && pipe(WORKFLOW_EXTENSIONS, Array.some((extension) => String$1.endsWith(extension)(file)));
1507
+ const matchesAny = Effect.fn("matchesAny")(function* matchesAny(root, pathspecs) {
1508
+ const matched = yield* (yield* RepositoryFiles).matchingFiles(root, pathspecs);
1509
+ return Array.isReadonlyArrayNonEmpty(matched);
1510
+ });
1511
+ const existsAt = Effect.fn("existsAt")(function* existsAt(root, path) {
1512
+ const files = yield* RepositoryFiles;
1513
+ return yield* files.exists(files.join(root, path));
1514
+ });
1515
+ const matchesGlob = (root, path) => matchesAny(root, [`:(glob)${path}`]);
1516
+ const isDirectoryAt = Effect.fn("isDirectoryAt")(function* isDirectoryAt(root, path) {
1517
+ const files = yield* RepositoryFiles;
1518
+ const directory = yield* files.isDirectory(files.join(root, path));
1519
+ return Option.getOrElse(directory, () => false);
1520
+ });
1521
+ const hasAction = Effect.fn("hasAction")(function* hasAction(root, path) {
1522
+ const found = yield* pipe(ACTION_DEFINITIONS, Effect.forEach((name) => existsAt(root, `${path}${SEPARATOR$1}${name}`)));
1523
+ return pipe(found, Array.some(Boolean));
1524
+ });
1525
+ const suffixAt = (segments) => (index) => `:(glob)**/${pipe(segments, Array.drop(index), Array.join(SEPARATOR$1))}`;
1526
+ const RESOLVERS = {
1527
+ action: hasAction,
1528
+ directory: isDirectoryAt,
1529
+ file: existsAt,
1530
+ glob: matchesGlob,
1531
+ script: Effect.fn("findsScript")(function* findsScript(root, path) {
1532
+ if (yield* existsAt(root, path)) return true;
1533
+ const segments = String$1.split(path, SEPARATOR$1);
1534
+ return yield* matchesAny(root, Array.makeBy(segments.length, suffixAt(segments)));
1535
+ })
1536
+ };
1537
+ const staticPrefix = (path) => {
1538
+ const prefix = Array.headNonEmpty(String$1.split(path, WILDCARD));
1539
+ if (String$1.endsWith(SEPARATOR$1)(prefix)) return String$1.slice(FIRST$1, -1)(prefix);
1540
+ return prefix;
1541
+ };
1542
+ const isIgnored$1 = Effect.fn("isIgnored")(function* isIgnored(root, path) {
1543
+ const prefix = staticPrefix(path);
1544
+ if (String$1.isEmpty(prefix)) return false;
1545
+ const ignored = yield* (yield* RepositoryFiles).ignoredPaths(root, [prefix]);
1546
+ return Array.isReadonlyArrayNonEmpty(ignored);
1547
+ });
1548
+ const overlaps = (path) => (produced) => produced === path || String$1.startsWith(`${path}${SEPARATOR$1}`)(produced) || String$1.startsWith(`${produced}${SEPARATOR$1}`)(path);
1549
+ const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, found) {
1550
+ const prefix = staticPrefix(found.path);
1551
+ if (pipe(produced, Array.some(overlaps(prefix)))) return false;
1552
+ if (yield* RESOLVERS[found.kind](root, found.path)) return false;
1553
+ return !(yield* isIgnored$1(root, found.path));
1554
+ });
1555
+ const problemOf$2 = (file, source) => (found) => ({
1556
+ file,
1557
+ ...positionOf(source)(found.offset),
1558
+ rule: RULE$4,
1559
+ 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.`
1560
+ });
1561
+ const problemsIn$2 = Effect.fn("problemsIn")(function* problemsIn(root, workflow) {
1562
+ const files = yield* RepositoryFiles;
1563
+ const file = files.join(root, workflow);
1564
+ const source = yield* files.readFile(file);
1565
+ if (Option.isNone(source)) return [];
1566
+ const produced = producedPaths(source.value);
1567
+ const missing = yield* Effect.filter(workflowReferences(source.value), (found) => isMissing(root, produced, found));
1568
+ return pipe(missing, Array.map(problemOf$2(file, source.value)));
1569
+ });
1570
+ /** @internal */
1571
+ const checkWorkflowPaths = Effect.fn("checkWorkflowPaths")(function* checkWorkflowPaths(root) {
1572
+ const listed = yield* (yield* RepositoryFiles).listedFiles(root);
1573
+ const found = yield* Effect.forEach(pipe(listed, Array.filter(isWorkflow)), (workflow) => problemsIn$2(root, workflow), { concurrency: READ_CONCURRENCY$5 });
1574
+ return Array.flatten(found);
1575
+ });
1355
1576
  // src/features/repository-layout/model/workspace-checks.ts
1356
1577
  /** @internal */
1357
1578
  const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(root) {
@@ -1359,10 +1580,116 @@ const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(r
1359
1580
  checkCrates(root),
1360
1581
  checkHiddenVerify(root),
1361
1582
  checkRootWorkspacePaths(root),
1362
- checkSharedUncachedTasks(root)
1583
+ checkSharedUncachedTasks(root),
1584
+ checkWorkflowPaths(root)
1363
1585
  ], { concurrency: "unbounded" });
1364
1586
  return Array.flatten(found);
1365
1587
  });
1588
+ // src/features/scripts/model/shell-scripts.ts
1589
+ const SHELL_FILE = /\.(?:sh|bash|zsh|ksh|fish|command)$/u;
1590
+ const SHELL_SHEBANG = /^#!\S*(?:\/|\s)(?:env\s+)?(?:-\S+\s+)*(?:ba|z|k|da)?sh\b|^#!\S*fish\b/u;
1591
+ const EXTENSION = /\.[^./]+$/u;
1592
+ const SETTINGS_FILE = ".claude/settings.json";
1593
+ const READ_CONCURRENCY$4 = 64;
1594
+ const FIRST = 1;
1595
+ const RULE$3 = "shell-script";
1596
+ const MESSAGE$2 = "is a shell script. Do the work in TypeScript as a Vite+ task in vite.config.ts, a test, or the tool's own hook, and delete this file. Only the SessionStart hook in .claude/settings.json, which installs the toolchain before TypeScript can run, stays a shell script.";
1597
+ const HookSchema = Schema.Struct({
1598
+ command: Schema.optional(Schema.String),
1599
+ args: Schema.optional(Schema.Array(Schema.String))
1600
+ });
1601
+ const MatcherSchema = Schema.Struct({ hooks: Schema.Array(HookSchema) });
1602
+ const HooksSchema = Schema.Struct({ SessionStart: Schema.optional(Schema.Array(MatcherSchema)) });
1603
+ const SettingsSchema = Schema.Struct({ hooks: Schema.optional(HooksSchema) });
1604
+ const decodeSettings = Schema.decodeOption(Schema.fromJsonString(SettingsSchema));
1605
+ const NO_TEXT = [];
1606
+ const commandText = ({ command, args }) => [...Option.toArray(Option.fromUndefinedOr(command)), ...pipe(Option.fromUndefinedOr(args), Option.getOrElse(() => NO_TEXT))];
1607
+ const matcherText = ({ hooks }) => pipe(hooks, Array.flatMap((hook) => commandText(hook)));
1608
+ const sessionStartCommands = (source) => {
1609
+ const matchers = pipe(decodeSettings(source), Option.flatMap(({ hooks }) => Option.fromUndefinedOr(hooks)), Option.flatMap(({ SessionStart }) => Option.fromUndefinedOr(SessionStart)));
1610
+ return pipe(matchers, Option.map(Array.flatMap((matcher) => matcherText(matcher))), Option.getOrElse(() => NO_TEXT));
1611
+ };
1612
+ const baseName = (name) => pipe(String$1.split("/")(name), Array.last, Option.getOrElse(() => name));
1613
+ const hasExtension = (name) => EXTENSION.test(baseName(name));
1614
+ const startsWithShellShebang = (source) => SHELL_SHEBANG.test(source);
1615
+ const problemFor = (file) => ({
1616
+ file,
1617
+ line: FIRST,
1618
+ column: FIRST,
1619
+ rule: RULE$3,
1620
+ message: MESSAGE$2
1621
+ });
1622
+ /** @internal */
1623
+ const checkShellScripts = Effect.fn("checkShellScripts")(function* checkShellScripts(root) {
1624
+ const files = yield* RepositoryFiles;
1625
+ const names = yield* files.listedFiles(root);
1626
+ const settings = yield* files.readFile(files.join(root, SETTINGS_FILE));
1627
+ const commands = pipe(settings, Option.map(sessionStartCommands), Option.getOrElse(() => NO_TEXT));
1628
+ const isSessionStartHook = (name) => pipe(commands, Array.some(String$1.includes(name)));
1629
+ const isShell = (name) => {
1630
+ const file = files.join(root, name);
1631
+ if (SHELL_FILE.test(name)) return files.exists(file);
1632
+ if (hasExtension(name)) return Effect.succeed(false);
1633
+ return files.readFile(file).pipe(Effect.map(Option.exists(startsWithShellShebang)));
1634
+ };
1635
+ const candidates = pipe(names, Array.filter((name) => !isSessionStartHook(name)));
1636
+ const shell = yield* Effect.filter(candidates, isShell, { concurrency: READ_CONCURRENCY$4 });
1637
+ return pipe(shell, Array.map((name) => problemFor(files.join(root, name))));
1638
+ });
1639
+ // src/features/scripts/model/workflows.ts
1640
+ const WORKFLOW_FILE = /^\.github\/workflows\/[^/]+\.ya?ml$/u;
1641
+ const COMMAND_CHAIN = /&&|\|\||;|\|/u;
1642
+ const QUOTED = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
1643
+ const COMMENT = "#";
1644
+ const RUN_KEY = "run";
1645
+ const RULE$2 = "workflow-script";
1646
+ const READ_CONCURRENCY$3 = 16;
1647
+ const START$4 = 0;
1648
+ const ONE_COMMAND = 1;
1649
+ const MESSAGE$1 = "runs more than one command. Keep a step to one command, `vp run <task>` or `vp exec <bin>`, and put the logic in a Vite+ task in TypeScript.";
1650
+ const startOf = (range) => pipe(Option.fromNullishOr(range), Option.map(([start]) => start), Option.getOrElse(() => START$4));
1651
+ const runScriptsOf = (source) => {
1652
+ const found = [];
1653
+ visit(parseDocument(source), { Pair: (_key, pair) => {
1654
+ if (isPair(pair) && isScalar(pair.key) && pair.key.value === RUN_KEY && isScalar(pair.value) && typeof pair.value.value === "string") found.push({
1655
+ text: pair.value.value,
1656
+ start: startOf(pair.value.range)
1657
+ });
1658
+ } });
1659
+ return found;
1660
+ };
1661
+ const isCommand = (line) => String$1.isNonEmpty(line) && !String$1.startsWith(COMMENT)(line);
1662
+ const chainsCommands = (line) => COMMAND_CHAIN.test(String$1.replaceAll(QUOTED, "")(line));
1663
+ const runsMoreThanOneCommand = ({ text }) => {
1664
+ const lines = pipe(String$1.split("\n")(text), Array.map(String$1.trim), Array.filter(isCommand));
1665
+ return lines.length > ONE_COMMAND || pipe(lines, Array.some(chainsCommands));
1666
+ };
1667
+ const problemsIn$1 = (file) => (source) => {
1668
+ const at = positionOf(source);
1669
+ return pipe(runScriptsOf(source), Array.filter(runsMoreThanOneCommand), Array.map(({ start }) => ({
1670
+ file,
1671
+ ...at(start),
1672
+ rule: RULE$2,
1673
+ message: MESSAGE$1
1674
+ })));
1675
+ };
1676
+ /** @internal */
1677
+ const checkWorkflows = Effect.fn("checkWorkflows")(function* checkWorkflows(root) {
1678
+ const files = yield* RepositoryFiles;
1679
+ const names = yield* files.listedFiles(root);
1680
+ const workflows = pipe(names, Array.filter((name) => WORKFLOW_FILE.test(name)));
1681
+ const found = yield* Effect.forEach(workflows, (name) => {
1682
+ const file = files.join(root, name);
1683
+ return files.readFile(file).pipe(Effect.map((text) => pipe(text, Option.map(problemsIn$1(file)), Option.getOrElse(() => []))));
1684
+ }, { concurrency: READ_CONCURRENCY$3 });
1685
+ return Array.flatten(found);
1686
+ });
1687
+ // src/features/scripts/model/script-checks.ts
1688
+ /** @internal */
1689
+ const checkScripts = Effect.fn("checkScripts")(function* checkScripts(root) {
1690
+ const found = yield* Effect.all([checkShellScripts(root), checkWorkflows(root)], { concurrency: "unbounded" });
1691
+ return Array.flatten(found);
1692
+ });
1366
1693
  // src/features/value-owners/model/slots.ts
1367
1694
  const ANNOTATED_KINDS = /* @__PURE__ */ new Set([
1368
1695
  SyntaxKind.Parameter,
@@ -2419,6 +2746,7 @@ const checkAll = Effect.fn("checkAll")(function* checkAll(root) {
2419
2746
  checkOverrides(root),
2420
2747
  checkTrackedText(root),
2421
2748
  checkPlacement(root),
2749
+ checkScripts(root),
2422
2750
  checkPublishedPackages(root),
2423
2751
  checkWorkspaces(root)
2424
2752
  ], { concurrency: "unbounded" });