@r_masseater/msch 0.38.1 → 0.40.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,19 +1,20 @@
1
1
  #!/usr/bin/env node
2
- import { B as stringsIn, E as hasVerifyTask, F as childrenOf$2, I as keyName, L as literalOf, N as workspaceConfigOf, P as KeySchema, R as nestedValues, S as RUN_TASKS, T as definesTask, _ as publishedProjects, a as publicEntriesOf, b as runTasksOf, c as readManifest, d as lockedPackages, f as deployEntries, i as EntryManifestJson, l as workspaceDependencies, m as patternOf$1, o as MANIFEST_FILE$1, p as namedWorkspaces, r as publishedWorkspaces, s as dependencyEntries, u as lockedGraph, v as workspaceDirectories, w as VERIFY_TASK, y as workspaceManifest, z as propertyValue } from "./package-DnxpBVTG.mjs";
3
- import { a as groupOf$2, i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-R0NW0NE9.mjs";
2
+ import { B as stringsIn, E as hasVerifyTask, F as childrenOf$2, I as keyName, L as literalOf, N as workspaceConfigOf, P as KeySchema, R as nestedValues, S as RUN_TASKS, T as definesTask, _ as publishedProjects, a as publicEntriesOf, b as runTasksOf, c as readManifest, d as lockedPackages, f as deployEntries, i as EntryManifestJson, l as workspaceDependencies, m as patternOf$1, o as MANIFEST_FILE$1, p as namedWorkspaces, r as publishedWorkspaces, s as dependencyEntries, u as lockedGraph, v as workspaceDirectories, w as VERIFY_TASK, y as workspaceManifest, z as propertyValue } from "./package-A62qq8pE.mjs";
3
+ import { a as groupOf$2, i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-CorshdqY.mjs";
4
4
  import { n as JAPANESE, t as COMMENT_DIRECTIVES } from "./comment-directives-5-f_qs1E.mjs";
5
- import { $ as isPropertyAccessExpression, A as getLeadingCommentRanges, B as isEnumDeclaration, C as uniqueByReference, D as SignatureKind, E as InternalSymbolName, F as isBinaryExpression, G as isImportDeclaration, H as isFunctionDeclaration, I as isBlock, J as isModuleDeclaration, K as isInterfaceDeclaration, L as isCallExpression, M as getTextOfJSDocComment, N as isArrayLiteralExpression, O as SyntaxKind, P as isArrowFunction, Q as isParenthesizedExpression, R as isClassDeclaration, S as symbolAt, T as IndexKind, U as isFunctionExpression, V as isExportDeclaration, W as isIdentifier, X as isNumericLiteral, Y as isNewExpression, Z as isObjectLiteralExpression, _ as lineOf$3, a as problemAt$9, at as isSpreadElement, b as referencedSymbols, c as columnOf, ct as isTypeLiteralNode, d as descendantsOf, dt as isVariableDeclaration, et as isPropertyAssignment, f as importedModulesOf, ft as isVariableDeclarationList, g as isTypeDeclaration, h as isInsideAny, i as formatProblem, it as isSourceFile, j as getNameOfDeclaration, k as getJSDocTags, l as contains, lt as isTypeReferenceNode, m as isGenericDeclaration, n as ProblemList, nt as isSatisfiesExpression, o as sortProblems, ot as isStringLiteral, p as isExternalDeclaration, pt as isVariableStatement, q as isModuleBlock, rt as isSignatureDeclaration, s as childrenOf$3, st as isTypeAliasDeclaration, tt as isReturnStatement, u as declarationsOf, ut as isUnionTypeNode, v as packageOf$1, w as API, x as resolvedSymbol, y as propertyNamesOf, z as isElementAccessExpression } from "./cli-contract-mzluqQvf.mjs";
5
+ import { $ as isPropertyAccessExpression, A as getLeadingCommentRanges, B as isEnumDeclaration, C as uniqueByReference, D as SignatureKind, E as InternalSymbolName, F as isBinaryExpression, G as isImportDeclaration, H as isFunctionDeclaration, I as isBlock, J as isModuleDeclaration, K as isInterfaceDeclaration, L as isCallExpression, M as getTextOfJSDocComment, N as isArrayLiteralExpression, O as SyntaxKind, P as isArrowFunction, Q as isParenthesizedExpression, R as isClassDeclaration, S as symbolAt, T as IndexKind, U as isFunctionExpression, V as isExportDeclaration, W as isIdentifier, X as isNumericLiteral, Y as isNewExpression, Z as isObjectLiteralExpression, _ as lineOf$3, a as problemAt$9, at as isSpreadElement, b as referencedSymbols, c as columnOf, ct as isTypeLiteralNode, d as descendantsOf, dt as isVariableDeclaration, et as isPropertyAssignment, f as importedModulesOf, ft as isVariableDeclarationList, g as isTypeDeclaration, h as isInsideAny, i as formatProblem, it as isSourceFile, j as getNameOfDeclaration, k as getJSDocTags, l as contains, lt as isTypeReferenceNode, m as isGenericDeclaration, n as ProblemList, nt as isSatisfiesExpression, o as sortProblems, ot as isStringLiteral, p as isExternalDeclaration, pt as isVariableStatement, q as isModuleBlock, rt as isSignatureDeclaration, s as childrenOf$3, st as isTypeAliasDeclaration, tt as isReturnStatement, u as declarationsOf, ut as isUnionTypeNode, v as packageOf$1, w as API, x as resolvedSymbol, y as propertyNamesOf, z as isElementAccessExpression } from "./cli-contract-8SnKqhGw.mjs";
6
6
  import { VpToolsError, runVpa } from "@r_masseater/vite-plus-adopt";
7
7
  import { Array, Cause, Config, 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";
8
8
  import { updateWorkspaceManifest } from "@pnpm/workspace.workspace-manifest-writer";
9
9
  import { ChildProcess } from "effect/process";
10
10
  import { parse, resolveConfigFromFile } from "vite-plus";
11
11
  import { parse as parse$1 } from "@pnpm/deps.path";
12
+ import { fileURLToPath } from "node:url";
13
+ import treeSitter from "@vscode/tree-sitter-wasm";
12
14
  import { Parser, isMap, isPair, isScalar, isSeq, parse as parse$2, parseDocument, visit } from "yaml";
13
15
  import semver from "semver";
16
+ import { diagnosticDetail, lint, markdownPathspecs, y8Section } from "@r_masseater/y8";
14
17
  import path from "node:path";
15
- import { fileURLToPath } from "node:url";
16
- import treeSitter from "@vscode/tree-sitter-wasm";
17
18
  import { isComment, isTag, isText } from "domhandler";
18
19
  import { DomUtils, parseDocument as parseDocument$1 } from "htmlparser2";
19
20
  import { DockerfileParser } from "dockerfile-ast";
@@ -49,10 +50,10 @@ const overrideProblem = (located) => (report) => {
49
50
  return Option.none();
50
51
  };
51
52
  // src/shared/lib/text-position.ts
52
- const START$14 = 0;
53
+ const START$15 = 0;
53
54
  const FIRST_COLUMN$4 = 1;
54
55
  const positionOf = (source) => (index) => {
55
- const before = pipe(source, String$1.slice(START$14, index), String$1.split("\n"));
56
+ const before = pipe(source, String$1.slice(START$15, index), String$1.split("\n"));
56
57
  return {
57
58
  line: before.length,
58
59
  column: pipe(Array.last(before), Option.match({
@@ -197,18 +198,18 @@ const withBaselineProbe = (overrides) => ({
197
198
  [BASELINE_PROBE]: REMOVED_DEPENDENCY
198
199
  });
199
200
  // src/features/check-overrides/model/overrides.ts
200
- const WORKSPACE_FILE$4 = "pnpm-workspace.yaml";
201
+ const WORKSPACE_FILE$5 = "pnpm-workspace.yaml";
201
202
  const RESOLUTION_FILES = [
202
203
  "*package.json",
203
- WORKSPACE_FILE$4,
204
+ WORKSPACE_FILE$5,
204
205
  "pnpm-lock.yaml",
205
206
  ".npmrc",
206
207
  "patches/*"
207
208
  ];
208
209
  const RESOLUTION_CONCURRENCY = 4;
209
210
  const SUCCEEDED$1 = 0;
210
- const taggedError$5 = Schema.TaggedError;
211
- var OverrideResolutionFailed = class extends taggedError$5()("OverrideResolutionFailed", {
211
+ const taggedError$7 = Schema.TaggedError;
212
+ var OverrideResolutionFailed = class extends taggedError$7()("OverrideResolutionFailed", {
212
213
  override: Schema.String,
213
214
  output: Schema.String
214
215
  }) {};
@@ -260,9 +261,11 @@ const copyFiles = Effect.fn("copyFiles")(function* copyFiles(workspace, director
260
261
  const fs = yield* FileSystem.FileSystem;
261
262
  const path = yield* Path.Path;
262
263
  const copyOne = (file) => {
264
+ const source = path.join(workspace.root, file);
263
265
  const target = path.join(directory, file);
264
- const copy = fs.copyFile(path.join(workspace.root, file), target);
265
- return fs.makeDirectory(path.dirname(target), { recursive: true }).pipe(Effect.andThen(copy));
266
+ const copy = fs.copyFile(source, target);
267
+ const write = fs.makeDirectory(path.dirname(target), { recursive: true }).pipe(Effect.andThen(copy));
268
+ return Effect.when(write, fs.exists(source));
266
269
  };
267
270
  yield* Effect.forEach(workspace.files, copyOne, {
268
271
  concurrency: 1,
@@ -304,7 +307,7 @@ const problemsFor = Effect.fn("problemsFor")(function* problemsFor(root, overrid
304
307
  };
305
308
  const baseline = yield* resolutionWith(workspace, BASELINE_PROBE, withBaselineProbe(overrides));
306
309
  const judgeAgainstBaseline = judge(baseline);
307
- const file = path.join(root, WORKSPACE_FILE$4);
310
+ const file = path.join(root, WORKSPACE_FILE$5);
308
311
  const problemOf = (located) => resolutionWith(workspace, located.key, withoutOverride(located.key)(overrides)).pipe(Effect.map((candidate) => overrideProblem({
309
312
  ...located,
310
313
  file
@@ -316,7 +319,7 @@ const problemsFor = Effect.fn("problemsFor")(function* problemsFor(root, overrid
316
319
  const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root) {
317
320
  const fs = yield* FileSystem.FileSystem;
318
321
  const path = yield* Path.Path;
319
- const source = yield* fs.readFileString(path.join(root, WORKSPACE_FILE$4)).pipe(Effect.option);
322
+ const source = yield* fs.readFileString(path.join(root, WORKSPACE_FILE$5)).pipe(Effect.option);
320
323
  const manifest = yield* workspaceManifest(root);
321
324
  const overrides = pipe(manifest, Option.flatMap((found) => Option.fromUndefinedOr(found.overrides)), Option.getOrElse(() => ({})));
322
325
  const keys = pipe(source, Option.map((text) => overrideKeysOf(text)(overrides)), Option.getOrElse(() => []));
@@ -327,7 +330,7 @@ const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root
327
330
  const SCANNED_FILE = /(?:\.(?:[cm]?[jt]sx?|jsonc?|toml|ya?ml|sh|bash|zsh|fish|rs|cs|go|mk)|(?:^|\/)(?:(?:Dockerfile|Containerfile)[^/]*|Makefile|justfile|\.tool-versions|[^./][^./]*))$/u;
328
331
  const LOCKFILE$1 = /(?:^|\/)(?:[^/]*\.lock|[^/]*-lock\.(?:json|ya?ml))$/u;
329
332
  const TOOL_VERSIONS = /(?:^|\/)(?:\.?mise(?:\.[^/]+)?\.toml|\.tool-versions)$/u;
330
- const READ_CONCURRENCY$26 = 64;
333
+ const READ_CONCURRENCY$27 = 64;
331
334
  const isScannedText = ({ name }) => SCANNED_FILE.test(name) && !LOCKFILE$1.test(name);
332
335
  const isToolVersions = ({ name }) => TOOL_VERSIONS.test(name);
333
336
  /** @internal */
@@ -350,18 +353,18 @@ const scanText = Effect.fn("scanText")(function* scanText(listed, problemsIn) {
350
353
  const found = yield* Effect.forEach(listed, (entry) => files.readFile(entry.file).pipe(Effect.map(Option.match({
351
354
  onNone: () => [],
352
355
  onSome: (source) => problemsIn(entry, source)
353
- }))), { concurrency: READ_CONCURRENCY$26 });
356
+ }))), { concurrency: READ_CONCURRENCY$27 });
354
357
  return Array.flatten(found);
355
358
  });
356
359
  // src/features/check-overrides/model/git-subpath.ts
357
360
  const DEPENDENCY_FILE = /(?:^|\/)(?:package\.json|pnpm-workspace\.ya?ml)$/u;
358
361
  const GIT_SUBPATH = /(?<![^\s"':])[^\s"'#]+#(?:[^\s"'&]*&)*path:[^\s"']*/gu;
359
- const RULE$40 = "git-subpath-dependency";
362
+ const RULE$42 = "git-subpath-dependency";
360
363
  const WHOLE_MATCH$3 = 0;
361
364
  const problemAt$8 = ({ file }, source) => (found) => ({
362
365
  file,
363
366
  ...positionOf(source)(found.index ?? WHOLE_MATCH$3),
364
- rule: RULE$40,
367
+ rule: RULE$42,
365
368
  message: `Git subpath dependencies are banned. Publish the package to npm and depend on a released version instead of \`${String$1.trim(found[WHOLE_MATCH$3])}\`.`
366
369
  });
367
370
  const problemsIn$15 = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(GIT_SUBPATH)(source)), Array.map(problemAt$8(entry, source)));
@@ -372,13 +375,13 @@ const checkGitSubpath = Effect.fn("checkGitSubpath")(function* checkGitSubpath(r
372
375
  return yield* scanText(pipe(listed, Array.filter(isDependencyFile)), problemsIn$15);
373
376
  });
374
377
  // src/features/check-overrides/model/restricted-rules.ts
375
- const RULE$39 = "unnamed-restriction";
378
+ const RULE$41 = "unnamed-restriction";
376
379
  const WHOLE_MATCH$2 = 0;
377
380
  const UNNAMED = new RegExp(`(?:[\\w@-]+/)?no-restricted-(?:imports|properties)\\b`, "gu");
378
381
  const problemsIn$14 = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(UNNAMED)(source)), Array.map((found) => ({
379
382
  file: entry.file,
380
383
  ...positionOf(source)(found.index ?? WHOLE_MATCH$2),
381
- rule: RULE$39,
384
+ rule: RULE$41,
382
385
  message: `${found[WHOLE_MATCH$2]} is not used in this repository, because its name does not say what an entry protects. Ban a package in dependencyRules.banned, and write any other restriction as a rule in msch-lint whose name states the intent.`
383
386
  })));
384
387
  /** @internal */
@@ -386,37 +389,83 @@ const checkRestrictedRules = Effect.fn("checkRestrictedRules")(function* checkRe
386
389
  const listed = yield* listedFiles(root);
387
390
  return yield* scanText(pipe(listed, Array.filter(isScannedText)), problemsIn$14);
388
391
  });
392
+ // src/features/check-overrides/model/package-registry.ts
393
+ const RULE$40 = "package-registry";
394
+ const REGISTRY = "https://npm.flatt.tech/";
395
+ const TRAILING_SLASH = /\/$/u;
396
+ const WORKSPACE_FILE$4 = "pnpm-workspace.yaml";
397
+ const NPMRC = /(?:^|\/)\.npmrc$/u;
398
+ const WORKSPACE_REGISTRY = /^registry:/mu;
399
+ const NPMRC_REGISTRY = /^[ \t]*registry[ \t]*=[ \t]*(?<value>\S*)/gmu;
400
+ const START$14 = 0;
401
+ const REASON = `Installs go through Takumi Guard (${REGISTRY}), which blocks known-malicious packages before they are installed.`;
402
+ const decodeRegistry = Schema.decodeUnknownOption(Schema.Struct({ registry: Schema.optional(Schema.String) }));
403
+ const registryOf = (manifest) => pipe(decodeRegistry(manifest), Option.flatMap(({ registry }) => Option.fromUndefinedOr(registry)));
404
+ const withoutSlash = String$1.replace(TRAILING_SLASH, "");
405
+ const isGuarded = (registry) => withoutSlash(registry) === withoutSlash(REGISTRY);
406
+ const offsetIn = (found) => pipe(Option.fromNullishOr(found), Option.map(({ index }) => index), Option.getOrElse(() => START$14));
407
+ const workspaceProblem = (file, source, registry) => ({
408
+ file,
409
+ ...positionOf(source)(offsetIn(WORKSPACE_REGISTRY.exec(source))),
410
+ rule: RULE$40,
411
+ message: Option.match(registry, {
412
+ onNone: () => `${REASON} Set \`registry: ${REGISTRY}\` in ${WORKSPACE_FILE$4}.`,
413
+ onSome: (value) => `${REASON} \`registry\` is ${value}. Set it to ${REGISTRY}.`
414
+ })
415
+ });
416
+ const npmrcProblems = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(NPMRC_REGISTRY)(source)), Array.filter((found) => !Option.exists(groupOf$2("value")(found), isGuarded)), Array.map((found) => ({
417
+ file: entry.file,
418
+ ...positionOf(source)(found.index ?? START$14),
419
+ rule: RULE$40,
420
+ message: `${REASON} This .npmrc overrides it with \`${String$1.trim(found[START$14])}\`. Remove the line.`
421
+ })));
422
+ const checkWorkspace = Effect.fn("checkWorkspace")(function* checkWorkspace(root) {
423
+ const files = yield* RepositoryFiles;
424
+ const manifest = yield* workspaceManifest(root);
425
+ if (Option.isNone(manifest) || Option.exists(registryOf(manifest.value), isGuarded)) return [];
426
+ const registry = registryOf(manifest.value);
427
+ const file = files.join(root, WORKSPACE_FILE$4);
428
+ const read = yield* files.readFile(file);
429
+ const source = Option.getOrElse(read, () => "");
430
+ return [workspaceProblem(file, source, registry)];
431
+ });
432
+ /** @internal */
433
+ const checkPackageRegistry = Effect.fn("checkPackageRegistry")(function* checkPackageRegistry(root) {
434
+ const listed = yield* listedFiles(root);
435
+ const overrides = yield* scanText(pipe(listed, Array.filter(({ name }) => NPMRC.test(name))), npmrcProblems);
436
+ return [...yield* checkWorkspace(root), ...overrides];
437
+ });
389
438
  // src/features/check-placement/model/colocated-git-patterns.ts
390
- const RULE$38 = "colocated-git-patterns";
439
+ const RULE$39 = "colocated-git-patterns";
391
440
  const PATTERN_FILES = [":(glob)**/.gitignore", ":(glob)**/.gitattributes"];
392
441
  const ROOT$2 = ".";
393
- const SEPARATOR$21 = "/";
442
+ const SEPARATOR$22 = "/";
394
443
  const NEGATION$1 = "!";
395
444
  const COMMENT$1 = "#";
396
445
  const ANY_DEPTH = "**";
397
- const FLOATING_PREFIX = `${ANY_DEPTH}${SEPARATOR$21}`;
446
+ const FLOATING_PREFIX = `${ANY_DEPTH}${SEPARATOR$22}`;
398
447
  const LEADING_SLASHES = /^\/+/u;
399
448
  const TRAILING_SLASHES = /\/+$/u;
400
449
  const SPACES = /\s+/u;
401
- const FIRST$19 = 1;
402
- const READ_CONCURRENCY$25 = 16;
403
- const isInside = (directory) => (inner) => inner !== directory && (directory === ROOT$2 || String$1.startsWith(`${directory}${SEPARATOR$21}`)(inner));
450
+ const FIRST$20 = 1;
451
+ const READ_CONCURRENCY$26 = 16;
452
+ const isInside = (directory) => (inner) => inner !== directory && (directory === ROOT$2 || String$1.startsWith(`${directory}${SEPARATOR$22}`)(inner));
404
453
  const withoutPrefix = (prefix, text) => {
405
454
  if (String$1.startsWith(prefix)(text)) return String$1.slice(prefix.length)(text);
406
455
  return text;
407
456
  };
408
457
  const isAnchored = (pattern) => {
409
458
  const body = withoutPrefix(NEGATION$1, pattern);
410
- return pipe(body, String$1.replace(TRAILING_SLASHES, ""), String$1.includes(SEPARATOR$21));
459
+ return pipe(body, String$1.replace(TRAILING_SLASHES, ""), String$1.includes(SEPARATOR$22));
411
460
  };
412
- const segmentsOf = ({ directory, pattern }) => {
461
+ const segmentsOf$1 = ({ directory, pattern }) => {
413
462
  const body = withoutPrefix(NEGATION$1, pattern);
414
463
  const trimmed = pipe(body, String$1.replace(LEADING_SLASHES, ""), String$1.replace(TRAILING_SLASHES, ""));
415
- const own = String$1.split(SEPARATOR$21)(trimmed);
464
+ const own = String$1.split(SEPARATOR$22)(trimmed);
416
465
  if (directory === ROOT$2) return own;
417
- return [...String$1.split(SEPARATOR$21)(directory), ...own];
466
+ return [...String$1.split(SEPARATOR$22)(directory), ...own];
418
467
  };
419
- const depthOf = (directory) => String$1.split(SEPARATOR$21)(directory).length;
468
+ const depthOf = (directory) => String$1.split(SEPARATOR$22)(directory).length;
420
469
  const entryOf$1 = (file, kind, directory) => (line, index) => {
421
470
  const [pattern, ...values] = pipe(String$1.trim(line), String$1.split(SPACES));
422
471
  if (String$1.isEmpty(pattern) || String$1.startsWith(COMMENT$1)(pattern)) return Option.none();
@@ -424,7 +473,7 @@ const entryOf$1 = (file, kind, directory) => (line, index) => {
424
473
  file,
425
474
  kind,
426
475
  directory,
427
- line: index + FIRST$19,
476
+ line: index + FIRST$20,
428
477
  pattern,
429
478
  values: Array.join(values, " ")
430
479
  });
@@ -439,12 +488,12 @@ const entriesIn$1 = Effect.fn("entriesIn")(function* entriesIn(root, file) {
439
488
  const problemAt$7 = (entry, message) => ({
440
489
  file: entry.file,
441
490
  line: entry.line,
442
- column: FIRST$19,
443
- rule: RULE$38,
491
+ column: FIRST$20,
492
+ rule: RULE$39,
444
493
  message
445
494
  });
446
495
  const misplacedMessage = (kind, workspaces) => {
447
- if (workspaces.length === FIRST$19) {
496
+ if (workspaces.length === FIRST$20) {
448
497
  const workspace = Array.join(workspaces, "");
449
498
  return `matches only paths inside the workspace ${workspace}. Move it to ${workspace}/${kind} and write it relative to that directory.`;
450
499
  }
@@ -454,12 +503,12 @@ const matchedAtDepth = Effect.fn("matchedAtDepth")(function* matchedAtDepth(root
454
503
  const files = yield* RepositoryFiles;
455
504
  const leading = Array.take(segments, depth);
456
505
  if (Array.contains(leading, ANY_DEPTH)) return [];
457
- const manifests = yield* files.matchingFiles(root, [`:(glob)${Array.join(leading, SEPARATOR$21)}${SEPARATOR$21}${MANIFEST_FILE$1}`]);
506
+ const manifests = yield* files.matchingFiles(root, [`:(glob)${Array.join(leading, SEPARATOR$22)}${SEPARATOR$22}${MANIFEST_FILE$1}`]);
458
507
  return pipe(manifests, Array.map((manifest) => files.dirname(manifest)));
459
508
  });
460
509
  const deepestOf = (inner) => pipe(inner, Array.filter((workspace) => !pipe(inner, Array.some(isInside(workspace)))));
461
510
  const matchedWorkspaces = Effect.fn("matchedWorkspaces")(function* matchedWorkspaces(root, workspaces, entry) {
462
- const segments = segmentsOf(entry);
511
+ const segments = segmentsOf$1(entry);
463
512
  const candidates = pipe(workspaces, Array.filter(isInside(entry.directory)), Array.filter((workspace) => depthOf(workspace) < segments.length));
464
513
  const depths = pipe(candidates, Array.map(depthOf), Array.dedupe);
465
514
  const matched = yield* Effect.forEach(depths, (depth) => matchedAtDepth(root, segments, depth), { concurrency: 1 });
@@ -475,12 +524,12 @@ const misplaced = Effect.fn("misplaced")(function* misplaced(root, workspaces, e
475
524
  const isFloating = (pattern) => !String$1.startsWith(NEGATION$1)(pattern) && (!isAnchored(pattern) || String$1.startsWith(FLOATING_PREFIX)(pattern));
476
525
  const ownLevelName = (pattern) => {
477
526
  if (isFloating(pattern)) return Option.some(pattern);
478
- const name = withoutPrefix(SEPARATOR$21, pattern);
527
+ const name = withoutPrefix(SEPARATOR$22, pattern);
479
528
  return Option.liftPredicate(name, (own) => isFloating(own) && !isAnchored(own));
480
529
  };
481
530
  const sameName = (outer, name) => {
482
531
  if (outer === name) return true;
483
- return String$1.endsWith(SEPARATOR$21)(name) && `${outer}${SEPARATOR$21}` === name;
532
+ return String$1.endsWith(SEPARATOR$22)(name) && `${outer}${SEPARATOR$22}` === name;
484
533
  };
485
534
  const coveredBy = (entry, name) => (outer) => outer.kind === entry.kind && outer.values === entry.values && isFloating(outer.pattern) && isInside(outer.directory)(entry.directory) && sameName(outer.pattern, name);
486
535
  const outerName = ({ directory, kind }) => {
@@ -494,21 +543,21 @@ const repeated = (entries) => (entry) => {
494
543
  /** @internal */
495
544
  const checkColocatedGitPatterns = Effect.fn("checkColocatedGitPatterns")(function* checkColocatedGitPatterns(root) {
496
545
  const patternFiles = yield* (yield* RepositoryFiles).matchingFiles(root, PATTERN_FILES);
497
- const read = yield* Effect.forEach(patternFiles, (file) => entriesIn$1(root, file), { concurrency: READ_CONCURRENCY$25 });
546
+ const read = yield* Effect.forEach(patternFiles, (file) => entriesIn$1(root, file), { concurrency: READ_CONCURRENCY$26 });
498
547
  const entries = Array.flatten(read);
499
548
  const workspaces = yield* workspaceDirectories(root);
500
- const misplacedFound = yield* Effect.forEach(entries, (entry) => misplaced(root, workspaces, entry), { concurrency: READ_CONCURRENCY$25 });
549
+ const misplacedFound = yield* Effect.forEach(entries, (entry) => misplaced(root, workspaces, entry), { concurrency: READ_CONCURRENCY$26 });
501
550
  const repeatedFound = pipe(entries, Array.map(repeated(entries)));
502
551
  return Array.getSomes([...misplacedFound, ...repeatedFound]);
503
552
  });
504
553
  // src/features/check-placement/model/colocated-tests.ts
505
- const RULE$37 = "colocated-test";
506
- const FIRST$18 = 1;
507
- const READ_CONCURRENCY$24 = 64;
554
+ const RULE$38 = "colocated-test";
555
+ const FIRST$19 = 1;
556
+ const READ_CONCURRENCY$25 = 64;
508
557
  const ROOT_SUBPATH = ".";
509
558
  const NAME_GROUP = "name";
510
559
  const SPECIFIER_GROUP = "specifier";
511
- const SCRIPT$2 = /\.[cm]?[jt]sx?$/u;
560
+ const SCRIPT$3 = /\.[cm]?[jt]sx?$/u;
512
561
  const TEST_FILE$1 = /\.test\.[cm]?[jt]sx?$/u;
513
562
  const MANIFEST_NAME = /package\.json$/u;
514
563
  const SEPARATE_TEST_DIRECTORY = /(?:^|\/)(?:__tests__|__mocks__|tests?)\//u;
@@ -517,7 +566,7 @@ const SPEC_FILE = /\.spec\.[cm]?[jt]sx?$/u;
517
566
  const RELATIVE_REFERENCE = /["'`]\.\/(?<name>[^/"'`]+)/gu;
518
567
  const DIRNAME_REFERENCE = /import\.meta\.dirname\s*,\s*["'](?<name>[^/"']+)["']/gu;
519
568
  const MODULE_SPECIFIER = /(?:\bfrom\s+|\bimport\s*\(\s*|\bimport\s+|\bvi\.mock\(\s*)["'](?<specifier>[^"'.#][^"']*)["']/gu;
520
- const EXCLUDED$3 = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
569
+ const EXCLUDED$4 = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
521
570
  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.";
522
571
  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>.";
523
572
  const Manifest$3 = Schema.Struct({
@@ -525,19 +574,19 @@ const Manifest$3 = Schema.Struct({
525
574
  exports: Schema.optional(Schema.Unknown)
526
575
  });
527
576
  const decodeManifest$6 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$3));
528
- const byLength$1 = Order.mapInput(Order.Number, (directory) => directory.length);
577
+ const byLength$2 = Order.mapInput(Order.Number, (directory) => directory.length);
529
578
  const problemFor$6 = (test, message) => ({
530
579
  file: test.file,
531
- line: FIRST$18,
532
- column: FIRST$18,
533
- rule: RULE$37,
580
+ line: FIRST$19,
581
+ column: FIRST$19,
582
+ rule: RULE$38,
534
583
  message: `${test.base} ${message}`
535
584
  });
536
585
  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);
537
586
  const namesSibling = (source) => pipe([...groupsOf$1(source, RELATIVE_REFERENCE, NAME_GROUP), ...groupsOf$1(source, DIRNAME_REFERENCE, NAME_GROUP)], Array.some((name) => !TEST_FILE$1.test(name)));
538
587
  const ownerOf$4 = (packages, name) => {
539
588
  const owners = pipe(packages, Array.filter((directory) => String$1.startsWith(directory)(name)));
540
- return Array.last(Array.sort(owners, byLength$1));
589
+ return Array.last(Array.sort(owners, byLength$2));
541
590
  };
542
591
  const specifiersBeside = ({ join, dirname, directory }) => (manifest) => pipe(Option.fromUndefinedOr(manifest.name), Option.map((name) => pipe(publicEntriesOf({
543
592
  manifest,
@@ -578,13 +627,13 @@ const problemIn$6 = Effect.fn("problemIn")(function* problemIn(context, test) {
578
627
  /** @internal */
579
628
  const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColocatedTests(root) {
580
629
  const files = yield* RepositoryFiles;
581
- const listed = yield* files.matchingFiles(root, EXCLUDED$3);
630
+ const listed = yield* files.matchingFiles(root, EXCLUDED$4);
582
631
  const names = pipe(listed, Array.filter(String$1.isNonEmpty));
583
632
  const context = {
584
633
  root,
585
634
  packages: pipe(names, Array.filter((name) => files.basename(name) === MANIFEST_FILE$1), Array.map(String$1.replace(MANIFEST_NAME, "")))
586
635
  };
587
- const tests = pipe(names, Array.filter((name) => SCRIPT$2.test(name)), Array.map((name) => {
636
+ const tests = pipe(names, Array.filter((name) => SCRIPT$3.test(name)), Array.map((name) => {
588
637
  const file = files.join(root, name);
589
638
  return {
590
639
  name,
@@ -593,12 +642,12 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
593
642
  directory: files.dirname(file)
594
643
  };
595
644
  }));
596
- const found = yield* Effect.forEach(tests, (test) => problemIn$6(context, test), { concurrency: READ_CONCURRENCY$24 });
645
+ const found = yield* Effect.forEach(tests, (test) => problemIn$6(context, test), { concurrency: READ_CONCURRENCY$25 });
597
646
  return Array.getSomes(found);
598
647
  });
599
648
  // src/shared/lib/agent-docs.ts
600
649
  const AGENT_DOC = /(?:^|\/)(?:AGENTS|CLAUDE)\.md$/u;
601
- const READ_CONCURRENCY$23 = 16;
650
+ const READ_CONCURRENCY$24 = 16;
602
651
  const agentDocProblems = Effect.fn("agentDocProblems")(function* agentDocProblems(root, problemIn) {
603
652
  const files = yield* RepositoryFiles;
604
653
  const listed = yield* files.listedFiles(root);
@@ -607,32 +656,32 @@ const agentDocProblems = Effect.fn("agentDocProblems")(function* agentDocProblem
607
656
  const file = files.join(root, name);
608
657
  const problemOf = Option.flatMap(problemIn(file));
609
658
  return files.readFile(file).pipe(Effect.map(problemOf));
610
- }, { concurrency: READ_CONCURRENCY$23 });
659
+ }, { concurrency: READ_CONCURRENCY$24 });
611
660
  return Array.getSomes(found);
612
661
  });
613
662
  // src/features/check-placement/model/agent-docs-length.ts
614
663
  const RECOMMENDED_LINES = 200;
615
- const FIRST$17 = 1;
616
- const RULE$36 = "agent-docs-length";
664
+ const FIRST$18 = 1;
665
+ const RULE$37 = "agent-docs-length";
617
666
  const lineCount = (source) => pipe(String$1.trimEnd(source), String$1.split("\n")).length;
618
667
  const problemFor$5 = (file) => (lines) => {
619
668
  if (lines <= RECOMMENDED_LINES) return Option.none();
620
669
  return Option.some({
621
670
  file,
622
671
  line: 201,
623
- column: FIRST$17,
624
- rule: RULE$36,
672
+ column: FIRST$18,
673
+ rule: RULE$37,
625
674
  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.`
626
675
  });
627
676
  };
628
677
  /** @internal */
629
678
  const checkAgentDocsLength = (root) => agentDocProblems(root, (file) => (source) => problemFor$5(file)(lineCount(source)));
630
679
  // src/features/check-placement/model/dangling-links.ts
631
- const RULE$35 = "dangling-link";
632
- const SEPARATOR$20 = "/";
633
- const FIRST$16 = 1;
634
- const READ_CONCURRENCY$22 = 16;
635
- const holds = (target) => (name) => name === target || String$1.startsWith(`${target}${SEPARATOR$20}`)(name);
680
+ const RULE$36 = "dangling-link";
681
+ const SEPARATOR$21 = "/";
682
+ const FIRST$17 = 1;
683
+ const READ_CONCURRENCY$23 = 16;
684
+ const holds = (target) => (name) => name === target || String$1.startsWith(`${target}${SEPARATOR$21}`)(name);
636
685
  /** @internal */
637
686
  const checkDanglingLinks = Effect.fn("checkDanglingLinks")(function* checkDanglingLinks(root) {
638
687
  const files = yield* RepositoryFiles;
@@ -642,33 +691,33 @@ const checkDanglingLinks = Effect.fn("checkDanglingLinks")(function* checkDangli
642
691
  const link = yield* files.readLink(file);
643
692
  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) => ({
644
693
  file,
645
- line: FIRST$16,
646
- column: FIRST$16,
647
- rule: RULE$35,
694
+ line: FIRST$17,
695
+ column: FIRST$17,
696
+ rule: RULE$36,
648
697
  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.`
649
698
  })));
650
699
  });
651
- const found = yield* Effect.forEach(links, problemOf, { concurrency: READ_CONCURRENCY$22 });
700
+ const found = yield* Effect.forEach(links, problemOf, { concurrency: READ_CONCURRENCY$23 });
652
701
  return Array.getSomes(found);
653
702
  });
654
703
  // src/features/check-placement/model/nested-docs.ts
655
- const RULE$34 = "nested-docs";
656
- const CONFIG_FILE$5 = "vite.config.ts";
657
- const SEPARATOR$19 = "/";
658
- const FIRST$15 = 1;
659
- const READ_CONCURRENCY$21 = 64;
704
+ const RULE$35 = "nested-docs";
705
+ const CONFIG_FILE$6 = "vite.config.ts";
706
+ const SEPARATOR$20 = "/";
707
+ const FIRST$16 = 1;
708
+ const READ_CONCURRENCY$22 = 64;
660
709
  const AGENT_DOCS$1 = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
661
710
  const WORKSPACE_AGENT_DOC = "AGENTS.md";
662
711
  const README = /^README(?:\.[^/]+)?$/iu;
663
712
  const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
664
- const taggedError$4 = Schema.TaggedError;
665
- var RootConfigUnreadable = class extends taggedError$4()("RootConfigUnreadable", { file: Schema.String }) {};
666
- const isNested = (name) => String$1.includes(SEPARATOR$19)(name);
713
+ const taggedError$6 = Schema.TaggedError;
714
+ var RootConfigUnreadable = class extends taggedError$6()("RootConfigUnreadable", { file: Schema.String }) {};
715
+ const isNested = (name) => String$1.includes(SEPARATOR$20)(name);
667
716
  const problemFor$4 = (file, message) => ({
668
717
  file,
669
- line: FIRST$15,
670
- column: FIRST$15,
671
- rule: RULE$34,
718
+ line: FIRST$16,
719
+ column: FIRST$16,
720
+ rule: RULE$35,
672
721
  message
673
722
  });
674
723
  const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
@@ -696,7 +745,7 @@ const problemIn$5 = Effect.fn("problemIn")(function* problemIn(root, allowed, na
696
745
  });
697
746
  const allowsWorkspaceAgentDocs = Effect.fn("allowsWorkspaceAgentDocs")(function* allowsWorkspaceAgentDocs(root) {
698
747
  const files = yield* RepositoryFiles;
699
- const file = files.join(root, CONFIG_FILE$5);
748
+ const file = files.join(root, CONFIG_FILE$6);
700
749
  if (!(yield* files.exists(file))) return false;
701
750
  const config = yield* Effect.tryPromise({
702
751
  try: () => resolveConfigFromFile(file),
@@ -715,13 +764,13 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
715
764
  workspaces: pipe(directories, Array.map((directory) => files.join(root, directory)), HashSet.fromIterable),
716
765
  workspaceAgentDocs
717
766
  };
718
- const found = yield* Effect.forEach(nested, (name) => problemIn$5(root, allowed, name), { concurrency: READ_CONCURRENCY$21 });
767
+ const found = yield* Effect.forEach(nested, (name) => problemIn$5(root, allowed, name), { concurrency: READ_CONCURRENCY$22 });
719
768
  return Array.getSomes(found);
720
769
  });
721
770
  // src/features/check-placement/model/published-readme.ts
722
- const RULE$33 = "published-readme";
771
+ const RULE$34 = "published-readme";
723
772
  const README_FILE = "README.md";
724
- const READ_CONCURRENCY$20 = 16;
773
+ const READ_CONCURRENCY$21 = 16;
725
774
  const MESSAGE$11 = "contains Japanese. This package is published to npm, so write its README in English.";
726
775
  const problemIn$4 = Effect.fn("problemIn")(function* problemIn(root, { directory }) {
727
776
  const files = yield* RepositoryFiles;
@@ -733,7 +782,7 @@ const problemIn$4 = Effect.fn("problemIn")(function* problemIn(root, { directory
733
782
  file,
734
783
  line,
735
784
  column,
736
- rule: RULE$33,
785
+ rule: RULE$34,
737
786
  message: MESSAGE$11
738
787
  };
739
788
  }))));
@@ -741,38 +790,38 @@ const problemIn$4 = Effect.fn("problemIn")(function* problemIn(root, { directory
741
790
  /** @internal */
742
791
  const checkPublishedReadme = Effect.fn("checkPublishedReadme")(function* checkPublishedReadme(root) {
743
792
  const projects = yield* publishedProjects(root);
744
- const found = yield* Effect.forEach(projects, (project) => problemIn$4(root, project), { concurrency: READ_CONCURRENCY$20 });
793
+ const found = yield* Effect.forEach(projects, (project) => problemIn$4(root, project), { concurrency: READ_CONCURRENCY$21 });
745
794
  return Array.getSomes(found);
746
795
  });
747
796
  // src/features/check-placement/model/root-docs.ts
748
- const RULE$32 = "root-docs";
749
- const SEPARATOR$18 = "/";
750
- const FIRST$14 = 1;
797
+ const RULE$33 = "root-docs";
798
+ const SEPARATOR$19 = "/";
799
+ const FIRST$15 = 1;
751
800
  const MARKDOWN$1 = /\.(?:md|mdx|markdown)$/iu;
752
801
  const ALLOWED = /^(?:README(?:\.[^/]+)?|AGENTS|CLAUDE|ARCHITECTURE|DESIGN|CHANGELOG|LICENSE|NOTICE)\.(?:md|mdx|markdown)$/iu;
753
802
  const MESSAGE$10 = "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.";
754
- const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$18)(name) && MARKDOWN$1.test(name) && !ALLOWED.test(name);
803
+ const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$19)(name) && MARKDOWN$1.test(name) && !ALLOWED.test(name);
755
804
  /** @internal */
756
805
  const checkRootDocs = Effect.fn("checkRootDocs")(function* checkRootDocs(root) {
757
806
  const files = yield* RepositoryFiles;
758
807
  const names = yield* files.listedFiles(root);
759
808
  return pipe(names, Array.filter(isStrayRootDoc), Array.map((name) => ({
760
809
  file: files.join(root, name),
761
- line: FIRST$14,
762
- column: FIRST$14,
763
- rule: RULE$32,
810
+ line: FIRST$15,
811
+ column: FIRST$15,
812
+ rule: RULE$33,
764
813
  message: `${name} ${MESSAGE$10}`
765
814
  })));
766
815
  });
767
816
  // src/features/check-placement/model/root-readme.ts
768
- const RULE$31 = "root-readme";
817
+ const RULE$32 = "root-readme";
769
818
  const ROOT_DOC = /^(?:README(?:\.[^/]+)?|AGENTS\.md|CLAUDE\.md)$/iu;
770
- const READ_CONCURRENCY$19 = 16;
819
+ const READ_CONCURRENCY$20 = 16;
771
820
  const START$13 = 0;
772
821
  const CHECK_POLICY = "@r_masseater/msch";
773
822
  const MARKETPLACE = ".claude-plugin/marketplace.json";
774
823
  const RELATIVE$1 = /^\.\//u;
775
- const SEPARATOR$17 = "/";
824
+ const SEPARATOR$18 = "/";
776
825
  const MarketplacePlugin = Schema.Struct({
777
826
  name: Schema.optional(Schema.String),
778
827
  source: Schema.Unknown
@@ -784,7 +833,7 @@ const NO_PLUGINS = {
784
833
  };
785
834
  const isCheckPolicy = ({ packageName }) => Option.contains(packageName, CHECK_POLICY);
786
835
  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.`;
787
- const lastSegment = (directory) => pipe(String$1.split(SEPARATOR$17)(directory), Array.last, Option.getOrElse(() => directory));
836
+ const lastSegment = (directory) => pipe(String$1.split(SEPARATOR$18)(directory), Array.last, Option.getOrElse(() => directory));
788
837
  const pluginsOf = (plugins) => {
789
838
  const directories = pipe(plugins, Array.map(({ source }) => source), Array.filter(Predicate.isString), Array.map(String$1.replace(RELATIVE$1, "")));
790
839
  const segments = pipe(directories, Array.map(lastSegment));
@@ -814,7 +863,7 @@ const problemsIn$13 = (file, source, plugins) => (workspace) => {
814
863
  return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
815
864
  file,
816
865
  ...at(found.index ?? START$13),
817
- rule: RULE$31,
866
+ rule: RULE$32,
818
867
  message
819
868
  })));
820
869
  };
@@ -833,7 +882,7 @@ const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(r
833
882
  const named = yield* namedWorkspaces(root);
834
883
  const workspaces = pipe(named, Array.filter((workspace) => !isCheckPolicy(workspace)));
835
884
  const plugins = yield* marketplacePlugins(root);
836
- const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces, plugins), { concurrency: READ_CONCURRENCY$19 });
885
+ const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces, plugins), { concurrency: READ_CONCURRENCY$20 });
837
886
  return Array.flatten(found);
838
887
  });
839
888
  // src/features/check-placement/model/doc-placement.ts
@@ -850,10 +899,10 @@ const checkDocPlacement = Effect.fn("checkDocPlacement")(function* checkDocPlace
850
899
  return Array.flatten(found);
851
900
  });
852
901
  // src/features/check-placement/model/docs-mirror.ts
853
- const RULE$30 = "docs-mirror";
902
+ const RULE$31 = "docs-mirror";
854
903
  const DOC = /(?:^|\/)(?:README|AGENTS|ARCHITECTURE|CLAUDE|SKILL)\.md$/u;
855
904
  const MIRROR_LIMIT = 3;
856
- const READ_CONCURRENCY$18 = 16;
905
+ const READ_CONCURRENCY$19 = 16;
857
906
  const SPECIAL = /[$()*+.?[\\\]^{|}]/gu;
858
907
  const BEFORE = String.raw`(?<![\w@/.-])`;
859
908
  const AFTER = String.raw`(?![\w@.-])`;
@@ -875,7 +924,7 @@ const problemFor$3 = (file, source, mentions) => pipe(Array.head(mentions), Opti
875
924
  file,
876
925
  line,
877
926
  column,
878
- rule: RULE$30,
927
+ rule: RULE$31,
879
928
  message: `names ${String(mentions.length)} other workspaces (${describe(mentions)}). The workspace list and each package.json already declare them, so this copy goes stale. Point at the declaration instead of listing it.`
880
929
  };
881
930
  }), Option.toArray);
@@ -890,7 +939,7 @@ const workspacesOf = Effect.fn("workspacesOf")(function* workspacesOf(root) {
890
939
  return yield* Effect.forEach(directories, (directory) => readManifest(files.join(root, directory)).pipe(Effect.map((manifest) => ({
891
940
  directory,
892
941
  names: [directory, ...pipe(manifest, Option.flatMap(({ name }) => Option.fromUndefinedOr(name)), Option.toArray)]
893
- }))), { concurrency: READ_CONCURRENCY$18 });
942
+ }))), { concurrency: READ_CONCURRENCY$19 });
894
943
  });
895
944
  /** @internal */
896
945
  const checkDocsMirror = Effect.fn("checkDocsMirror")(function* checkDocsMirror(root) {
@@ -903,13 +952,13 @@ const checkDocsMirror = Effect.fn("checkDocsMirror")(function* checkDocsMirror(r
903
952
  onNone: () => [],
904
953
  onSome: (text) => problemIn$3(workspaces)(doc, file, text)
905
954
  })));
906
- }, { concurrency: READ_CONCURRENCY$18 });
955
+ }, { concurrency: READ_CONCURRENCY$19 });
907
956
  return Array.flatten(found);
908
957
  });
909
958
  // src/features/check-placement/model/ignored-sources.ts
910
- const RULE$29 = "ignored-sources";
959
+ const RULE$30 = "ignored-sources";
911
960
  const SOURCES = [":(glob)**/src/**", ":(exclude,glob)**/node_modules/**"];
912
- const FIRST$13 = 1;
961
+ const FIRST$14 = 1;
913
962
  const MESSAGE$9 = "is under src/ but .gitignore ignores it, so verify passes here while the file never reaches the commit. Narrow the pattern in .gitignore.";
914
963
  /** @internal */
915
964
  const checkIgnoredSources = Effect.fn("checkIgnoredSources")(function* checkIgnoredSources(root) {
@@ -917,17 +966,17 @@ const checkIgnoredSources = Effect.fn("checkIgnoredSources")(function* checkIgno
917
966
  const ignored = yield* files.ignoredFiles(root, SOURCES);
918
967
  return pipe(ignored, Array.map((file) => ({
919
968
  file: files.join(root, file),
920
- line: FIRST$13,
921
- column: FIRST$13,
922
- rule: RULE$29,
969
+ line: FIRST$14,
970
+ column: FIRST$14,
971
+ rule: RULE$30,
923
972
  message: MESSAGE$9
924
973
  })));
925
974
  });
926
975
  // src/features/check-placement/model/member-sources.ts
927
976
  const ROOT_WORKSPACE$1 = ".";
928
- const FIRST$12 = 1;
929
- const SEPARATOR$16 = "/";
930
- const EXCLUDED$2 = [
977
+ const FIRST$13 = 1;
978
+ const SEPARATOR$17 = "/";
979
+ const EXCLUDED$3 = [
931
980
  ":(exclude,attr:linguist-vendored)",
932
981
  ":(exclude,attr:linguist-generated)",
933
982
  ":(exclude,attr:linguist-documentation)"
@@ -940,28 +989,28 @@ const memberSources = Effect.fn("memberSources")(function* memberSources(root) {
940
989
  const files = yield* RepositoryFiles;
941
990
  return {
942
991
  workspaces: yield* memberWorkspaces(root),
943
- listed: yield* files.matchingFiles(root, EXCLUDED$2)
992
+ listed: yield* files.matchingFiles(root, EXCLUDED$3)
944
993
  };
945
994
  });
946
- const byLength = Order.mapInput(Order.Number, (directory) => directory.length);
995
+ const byLength$1 = Order.mapInput(Order.Number, (directory) => directory.length);
947
996
  const fileProblem$1 = ({ file, rule, message }) => ({
948
997
  file,
949
- line: FIRST$12,
950
- column: FIRST$12,
998
+ line: FIRST$13,
999
+ column: FIRST$13,
951
1000
  rule,
952
1001
  message
953
1002
  });
954
- const ownerOf$2 = (workspaces) => (name) => pipe(workspaces, Array.filter((workspace) => String$1.startsWith(`${workspace}${SEPARATOR$16}`)(name)), (owners) => Array.last(Array.sort(owners, byLength)), Option.map((workspace) => ({
1003
+ const ownerOf$2 = (workspaces) => (name) => pipe(workspaces, Array.filter((workspace) => String$1.startsWith(`${workspace}${SEPARATOR$17}`)(name)), (owners) => Array.last(Array.sort(owners, byLength$1)), Option.map((workspace) => ({
955
1004
  workspace,
956
1005
  inner: String$1.slice(workspace.length + 1)(name)
957
1006
  })));
958
1007
  // src/features/check-placement/model/layered-source.ts
959
- const LAYERED_RULE = "layered-source";
960
- const ENTRY_RULE$2 = "public-entry";
961
- const SOURCE_DIRECTORY = "src";
962
- const SEPARATOR$15 = "/";
1008
+ const LAYERED_RULE$1 = "layered-source";
1009
+ const ENTRY_RULE$3 = "public-entry";
1010
+ const SOURCE_DIRECTORY$1 = "src";
1011
+ const SEPARATOR$16 = "/";
963
1012
  const LOOSE_DEPTH = 2;
964
- const LAYERS = [
1013
+ const LAYERS$1 = [
965
1014
  "app",
966
1015
  "pages",
967
1016
  "widgets",
@@ -969,22 +1018,22 @@ const LAYERS = [
969
1018
  "entities",
970
1019
  "shared"
971
1020
  ];
972
- const SCRIPT$1 = /\.[cm]?[jt]sx?$/u;
1021
+ const SCRIPT$2 = /\.[cm]?[jt]sx?$/u;
973
1022
  const ROOT_ALLOWED = /^(?:[^/]+\.config\.[cm]?[jt]s|alchemy\.[^/]+\.ts|[^/]+\.d\.[cm]?ts|bin\/.+)$/u;
974
1023
  const PUBLIC_ENTRY = /^(?:bin\/[^/]+|src\/(?:app\/[^/]+|(?:pages|widgets|features|entities)\/[^/]+\/index(?:\.[a-z]+)*\.tsx?|shared\/[^/]+\/index(?:\.[a-z]+)*\.tsx?|shared\/(?:ui|lib)\/.+))$/u;
975
- const OUTSIDE_MESSAGE = "sits outside src/. Put every module of a workspace under src/ in an FSD layer; only bin/, *.config.ts, alchemy.*.ts and *.d.ts may stay at the workspace root.";
1024
+ const OUTSIDE_MESSAGE$1 = "sits outside src/. Put every module of a workspace under src/ in an FSD layer; only bin/, *.config.ts, alchemy.*.ts and *.d.ts may stay at the workspace root.";
976
1025
  const LOOSE_MESSAGE = "sits directly in src/. Put it in a layer: app/ for entry points and wiring, features/<verb>-<object>/ for one operation, entities/<noun>/ for a shared domain object, or shared/<segment>/ for code without domain rules.";
977
- const LAYER_MESSAGE = `is not an FSD layer. src/ holds only ${Array.join(LAYERS, ", ")}.`;
978
- const ENTRY_MESSAGE$1 = "is a package entry that points inside a slice. Point exports and bin at bin/<name>.ts, src/app/<entry>.ts or a slice's index.ts.";
1026
+ const LAYER_MESSAGE$1 = `is not an FSD layer. src/ holds only ${Array.join(LAYERS$1, ", ")}.`;
1027
+ const ENTRY_MESSAGE$2 = "is a package entry that points inside a slice. Point exports and bin at bin/<name>.ts, src/app/<entry>.ts or a slice's index.ts.";
979
1028
  const decodeEntryManifest = Schema.decodeUnknownOption(EntryManifestJson);
980
1029
  const layerProblemOf = (owned) => {
981
- const parts = String$1.split(owned.inner, SEPARATOR$15);
1030
+ const parts = String$1.split(owned.inner, SEPARATOR$16);
982
1031
  const [top, layer] = parts;
983
- if (top !== SOURCE_DIRECTORY) return Option.liftPredicate([`${owned.workspace}${SEPARATOR$15}${owned.inner}`, OUTSIDE_MESSAGE], () => !ROOT_ALLOWED.test(owned.inner));
984
- if (parts.length === LOOSE_DEPTH) return Option.some([`${owned.workspace}${SEPARATOR$15}${owned.inner}`, LOOSE_MESSAGE]);
985
- return Option.liftPredicate([`${owned.workspace}${SEPARATOR$15}${SOURCE_DIRECTORY}${SEPARATOR$15}${layer}`, LAYER_MESSAGE], () => !pipe(LAYERS, Array.contains(layer ?? "")));
1032
+ if (top !== SOURCE_DIRECTORY$1) return Option.liftPredicate([`${owned.workspace}${SEPARATOR$16}${owned.inner}`, OUTSIDE_MESSAGE$1], () => !ROOT_ALLOWED.test(owned.inner));
1033
+ if (parts.length === LOOSE_DEPTH) return Option.some([`${owned.workspace}${SEPARATOR$16}${owned.inner}`, LOOSE_MESSAGE]);
1034
+ return Option.liftPredicate([`${owned.workspace}${SEPARATOR$16}${SOURCE_DIRECTORY$1}${SEPARATOR$16}${layer}`, LAYER_MESSAGE$1], () => !pipe(LAYERS$1, Array.contains(layer ?? "")));
986
1035
  };
987
- const entryProblems$1 = Effect.fn("entryProblems")(function* entryProblems(root, workspace) {
1036
+ const entryProblems$2 = Effect.fn("entryProblems")(function* entryProblems(root, workspace) {
988
1037
  const files = yield* RepositoryFiles;
989
1038
  const directory = files.join(root, workspace);
990
1039
  const text = yield* files.readFile(files.join(directory, MANIFEST_FILE$1));
@@ -995,55 +1044,257 @@ const entryProblems$1 = Effect.fn("entryProblems")(function* entryProblems(root,
995
1044
  packEntries: []
996
1045
  })), Option.getOrElse(() => []), Array.filter(({ source }) => !PUBLIC_ENTRY.test(files.relative(directory, source))), Array.map(({ label, source }) => fileProblem$1({
997
1046
  file: source,
998
- rule: ENTRY_RULE$2,
999
- message: `${label} ${ENTRY_MESSAGE$1}`
1047
+ rule: ENTRY_RULE$3,
1048
+ message: `${label} ${ENTRY_MESSAGE$2}`
1000
1049
  })));
1001
1050
  });
1002
1051
  /** @internal */
1003
1052
  const checkLayeredSource = Effect.fn("checkLayeredSource")(function* checkLayeredSource(root) {
1004
1053
  const files = yield* RepositoryFiles;
1005
1054
  const { workspaces, listed } = yield* memberSources(root);
1006
- const layered = pipe(listed, Array.filter((name) => SCRIPT$1.test(name)), Array.map(ownerOf$2(workspaces)), Array.getSomes, Array.map(layerProblemOf), Array.getSomes, Array.dedupeWith(([left], [right]) => left === right), Array.map(([file, message]) => fileProblem$1({
1055
+ const layered = pipe(listed, Array.filter((name) => SCRIPT$2.test(name)), Array.map(ownerOf$2(workspaces)), Array.getSomes, Array.map(layerProblemOf), Array.getSomes, Array.dedupeWith(([left], [right]) => left === right), Array.map(([file, message]) => fileProblem$1({
1007
1056
  file: files.join(root, file),
1008
- rule: LAYERED_RULE,
1057
+ rule: LAYERED_RULE$1,
1009
1058
  message
1010
1059
  })));
1011
- const entries = yield* Effect.forEach(workspaces, (workspace) => entryProblems$1(root, workspace), { concurrency: 1 });
1060
+ const entries = yield* Effect.forEach(workspaces, (workspace) => entryProblems$2(root, workspace), { concurrency: 1 });
1012
1061
  return [...layered, ...Array.flatten(entries)];
1013
1062
  });
1014
- // src/features/check-placement/model/source-aliases.ts
1015
- const ALIAS_RULE = "source-alias";
1016
- const FIRST$11 = 1;
1017
- const SOURCE_ALIAS = "#/*";
1018
- const SOURCE_TARGET = "./src/*";
1019
- const SOURCE_PREFIX = /^\.\/src(?:\/|$)/u;
1020
- const ALIAS_MESSAGE = `points into src/ under its own name. Import source through "${SOURCE_ALIAS}": "${SOURCE_TARGET}" only, so an import names the layer and slice it uses instead of a folder alias.`;
1021
- const Manifest$2 = Schema.Struct({ imports: Schema.optional(Schema.Unknown) });
1022
- const decodeManifest$5 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$2));
1023
- const problemAt$6 = (file, rule, message) => ({
1024
- file,
1025
- line: FIRST$11,
1026
- column: FIRST$11,
1027
- rule,
1028
- message
1029
- });
1030
- const targetsOf = (target) => {
1031
- if (Predicate.isString(target)) return [target];
1032
- if (Predicate.isObject(target)) return pipe(Record.values(target), Array.flatMap(targetsOf));
1033
- return [];
1063
+ // src/shared/lib/tree-sitter.ts
1064
+ const taggedError$5 = Schema.TaggedError;
1065
+ var GrammarUnreadable = class extends taggedError$5()("GrammarUnreadable", {
1066
+ grammar: Schema.String,
1067
+ message: Schema.String
1068
+ }) {};
1069
+ const PARSER_KEY = "parser";
1070
+ const cache = () => {
1071
+ const started = /* @__PURE__ */ new Map();
1072
+ return (key, start) => Option.getOrElse(Option.fromNullishOr(started.get(key)), () => {
1073
+ const promise = start();
1074
+ started.set(key, promise);
1075
+ return promise;
1076
+ });
1034
1077
  };
1035
- const intoSource = ([key, target]) => !(key === SOURCE_ALIAS && pipe(targetsOf(target), Array.every((path) => path === SOURCE_TARGET))) && pipe(targetsOf(target), Array.some((path) => SOURCE_PREFIX.test(path)));
1036
- const aliasProblems = Effect.fn("aliasProblems")(function* aliasProblems(root, workspace) {
1037
- const files = yield* RepositoryFiles;
1038
- const manifest = files.join(root, workspace, MANIFEST_FILE$1);
1039
- const text = yield* files.readFile(manifest);
1040
- return pipe(text, Option.flatMap(decodeManifest$5), Option.flatMap(({ imports }) => Option.liftPredicate(imports, Predicate.isObject)), Option.map((imports) => Record.toEntries(imports)), Option.getOrElse(() => Array.empty()), Array.filter(intoSource), Array.map(([key]) => problemAt$6(manifest, ALIAS_RULE, `"${key}" ${ALIAS_MESSAGE}`)));
1041
- });
1042
- /** @internal */
1043
- const checkSourceAliases = Effect.fn("checkSourceAliases")(function* checkSourceAliases(root) {
1044
- const workspaces = yield* memberWorkspaces(root);
1045
- const aliases = yield* Effect.forEach(workspaces, (workspace) => aliasProblems(root, workspace), { concurrency: 1 });
1046
- return Array.flatten(aliases);
1078
+ const initParser = cache();
1079
+ const loadOnce = cache();
1080
+ const grammarFile = (grammar) => fileURLToPath(import.meta.resolve(`@vscode/tree-sitter-wasm/wasm/tree-sitter-${grammar}.wasm`));
1081
+ const loadLanguage = (grammar) => {
1082
+ const unreadable = (cause) => GrammarUnreadable.make({
1083
+ grammar,
1084
+ message: String(cause)
1085
+ });
1086
+ return Effect.tryPromise({
1087
+ try: () => initParser(PARSER_KEY, () => treeSitter.Parser.init()),
1088
+ catch: unreadable
1089
+ }).pipe(Effect.andThen(Effect.tryPromise({
1090
+ try: () => loadOnce(grammar, () => treeSitter.Language.load(grammarFile(grammar))),
1091
+ catch: unreadable
1092
+ })));
1093
+ };
1094
+ const readTree = ({ language, source, read }) => {
1095
+ const parser = new treeSitter.Parser();
1096
+ parser.setLanguage(language);
1097
+ const tree = parser.parse(source);
1098
+ parser.delete();
1099
+ return Option.map(Option.fromNullishOr(tree), (parsed) => {
1100
+ const result = read(parsed.rootNode);
1101
+ parsed.delete();
1102
+ return result;
1103
+ });
1104
+ };
1105
+ // src/features/check-placement/model/rust-layout.ts
1106
+ const LAYERS = [
1107
+ "app",
1108
+ "pages",
1109
+ "widgets",
1110
+ "features",
1111
+ "entities",
1112
+ "shared"
1113
+ ];
1114
+ const RUST_FILE = /\.rs$/u;
1115
+ const BINARY = /^src\/bin\/[^/]+\.rs$/u;
1116
+ const MANIFEST$3 = /(?:^|\/)Cargo\.toml$/u;
1117
+ const MODULE_INDEX = "mod";
1118
+ const CRATE_ROOTS = ["src/lib.rs", "src/main.rs"];
1119
+ const OUTSIDE_ALLOWED = /^(?:build\.rs|benches\/.+)$/u;
1120
+ const SEPARATE_TEST = /^tests\/.+$/u;
1121
+ const SHARED_SLICES = ["app", "shared"];
1122
+ const SLICED_LAYERS = [
1123
+ "pages",
1124
+ "widgets",
1125
+ "features",
1126
+ "entities",
1127
+ "shared"
1128
+ ];
1129
+ const LAYER_DEPTH = 1;
1130
+ const SOURCE_PREFIX$1 = `src/`;
1131
+ const ROOT_CRATE = "";
1132
+ const NO_RANK = -1;
1133
+ const LAYER_INDEX = 0;
1134
+ const SLICE_INDEX = 1;
1135
+ const upwardMessage = (target, source) => `uses the ${target} layer from the ${source} layer. A layer may only use the layers below it (${Array.join(LAYERS, ", ")}).`;
1136
+ const crossMessage = (layer, target, source) => `uses the ${layer} slice ${target} from the slice ${source}. Slices of one layer must not use each other; move what they share down a layer.`;
1137
+ const byLength = Order.mapInput(Order.Number, (directory) => directory.length);
1138
+ const crateDirectories = (listed) => pipe(listed, Array.filter((name) => MANIFEST$3.test(name)), Array.map((name) => String$1.replace(MANIFEST$3, "")(name)));
1139
+ const ownedBy = (crate, name) => {
1140
+ if (crate === ROOT_CRATE) return {
1141
+ crate,
1142
+ inner: name
1143
+ };
1144
+ return {
1145
+ crate,
1146
+ inner: String$1.slice(crate.length + 1)(name)
1147
+ };
1148
+ };
1149
+ const crateOf = (crates) => (name) => pipe(crates, Array.filter((crate) => crate === ROOT_CRATE || String$1.startsWith(`${crate}/`)(name)), Array.match({
1150
+ onEmpty: () => Option.none(),
1151
+ onNonEmpty: (owners) => Option.some(Array.max(owners, byLength))
1152
+ }), Option.map((crate) => ownedBy(crate, name)));
1153
+ const modulePathOf = (inner) => {
1154
+ const parts = String$1.split(String$1.replace(RUST_FILE, "")(String$1.slice(SOURCE_PREFIX$1.length)(inner)), "/");
1155
+ if (Option.contains(Array.last(parts), MODULE_INDEX)) return Array.dropRight(parts, 1);
1156
+ return parts;
1157
+ };
1158
+ const sourceKindOf = (inner) => {
1159
+ const path = modulePathOf(inner);
1160
+ if (!Option.exists(Array.head(path), (layer) => Array.contains(LAYERS, layer))) return "misplaced";
1161
+ if (path.length === LAYER_DEPTH) return "layer";
1162
+ return "module";
1163
+ };
1164
+ const kindOf$1 = (inner) => {
1165
+ if (Array.contains(CRATE_ROOTS, inner) || BINARY.test(inner)) return "root";
1166
+ if (SEPARATE_TEST.test(inner)) return "test";
1167
+ if (OUTSIDE_ALLOWED.test(inner)) return "skipped";
1168
+ if (!String$1.startsWith(SOURCE_PREFIX$1)(inner)) return "misplaced";
1169
+ return sourceKindOf(inner);
1170
+ };
1171
+ const isInsideSource = (inner) => String$1.startsWith(SOURCE_PREFIX$1)(inner);
1172
+ const resolvedFrom = ({ segments, current }) => {
1173
+ const first = Array.head(segments);
1174
+ const rest = Array.drop(segments, 1);
1175
+ if (Option.contains(first, "crate")) return Option.some(rest);
1176
+ if (Option.contains(first, "self")) return resolvedFrom({
1177
+ segments: rest,
1178
+ current
1179
+ });
1180
+ if (Option.contains(first, "super")) return pipe(Option.liftPredicate(current, Array.isReadonlyArrayNonEmpty), Option.flatMap((parent) => resolvedFrom({
1181
+ segments: rest,
1182
+ current: Array.dropRight(parent, 1)
1183
+ })));
1184
+ return Option.some([...current, ...segments]);
1185
+ };
1186
+ const rankOf = (layer) => pipe(Array.findFirstIndex(LAYERS, (name) => name === layer), Option.getOrElse(() => NO_RANK));
1187
+ const partOf = (path, index) => Option.getOrElse(Array.get(path, index), () => "");
1188
+ const importMessage = ({ source, target }) => {
1189
+ const [sourceLayer, sourceSlice] = [partOf(source, LAYER_INDEX), partOf(source, SLICE_INDEX)];
1190
+ const [targetLayer, targetSlice] = [partOf(target, LAYER_INDEX), partOf(target, SLICE_INDEX)];
1191
+ if (!Array.contains(LAYERS, targetLayer) || target.length < 2) return Option.none();
1192
+ if (rankOf(targetLayer) < rankOf(sourceLayer)) return Option.some(upwardMessage(targetLayer, sourceLayer));
1193
+ if (targetLayer === sourceLayer && targetSlice !== sourceSlice && !Array.contains(SHARED_SLICES, targetLayer)) return Option.some(crossMessage(targetLayer, targetSlice, sourceSlice));
1194
+ return Option.none();
1195
+ };
1196
+ const isSliceIndex = (modulePath) => modulePath.length === 2 && Option.exists(Array.head(modulePath), (layer) => Array.contains(SLICED_LAYERS, layer));
1197
+ // src/features/check-placement/model/rust-syntax.ts
1198
+ const ANCHORS = [
1199
+ "crate",
1200
+ "super",
1201
+ "self"
1202
+ ];
1203
+ const SCOPED = ["scoped_identifier", "scoped_type_identifier"];
1204
+ const IGNORED_ITEMS = ["line_comment", "block_comment"];
1205
+ const PATH_SEPARATOR = "::";
1206
+ const SELF = "self";
1207
+ const NEXT$4 = 1;
1208
+ const ALLOCATOR = "global_allocator";
1209
+ const field = (node, name) => Option.fromNullishOr(node.childForFieldName(name));
1210
+ const namedChildren = (node) => pipe(node.namedChildren, Array.flatMap((child) => Option.toArray(Option.fromNullishOr(child))));
1211
+ const sameNode = (left, right) => Option.exists(left, (node) => node.id === right.id);
1212
+ const segmentsOf = (node) => {
1213
+ if (Array.contains(SCOPED, node.type)) return [...Option.match(field(node, "path"), {
1214
+ onNone: () => [],
1215
+ onSome: segmentsOf
1216
+ }), ...Option.match(field(node, "name"), {
1217
+ onNone: () => [],
1218
+ onSome: (name) => [name.text]
1219
+ })];
1220
+ if (node.type === "generic_type") return Option.match(field(node, "type"), {
1221
+ onNone: () => [],
1222
+ onSome: segmentsOf
1223
+ });
1224
+ return [node.text];
1225
+ };
1226
+ const extendsPath = (parent, node) => Array.contains(SCOPED, parent.type) && sameNode(field(parent, "path"), node) || parent.type === "generic_type" && sameNode(field(parent, "type"), node);
1227
+ const outermostPath = (node) => pipe(Option.fromNullishOr(node.parent), Option.filter((parent) => extendsPath(parent, node)), Option.match({
1228
+ onNone: () => node,
1229
+ onSome: outermostPath
1230
+ }));
1231
+ const tokenSegments = (node) => pipe(Option.fromNullishOr(node.nextSibling), Option.filter((separator) => separator.type === PATH_SEPARATOR), Option.flatMap((separator) => Option.fromNullishOr(separator.nextSibling)), Option.filter((next) => next.type === "identifier" || Array.contains(ANCHORS, next.type)), Option.match({
1232
+ onNone: () => [node.text],
1233
+ onSome: (next) => [node.text, ...tokenSegments(next)]
1234
+ }));
1235
+ const ancestors = (node) => pipe(Option.fromNullishOr(node.parent), Option.match({
1236
+ onNone: () => [],
1237
+ onSome: (parent) => [parent, ...ancestors(parent)]
1238
+ }));
1239
+ const scopeOf$1 = (node) => pipe(ancestors(node), Array.filter((ancestor) => ancestor.type === "mod_item"), Array.flatMap((module) => Option.toArray(field(module, "name"))), Array.map((name) => name.text), Array.reverse);
1240
+ const pathAt = (node, segments) => ({
1241
+ segments,
1242
+ scope: scopeOf$1(node),
1243
+ line: node.startPosition.row + NEXT$4,
1244
+ column: node.startPosition.column + NEXT$4
1245
+ });
1246
+ const insideAny = (node, kinds) => Array.some(ancestors(node), (ancestor) => Array.contains(kinds, ancestor.type));
1247
+ const anchoredPaths = (root) => pipe(root.descendantsOfType([...ANCHORS]), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.filter((node) => !insideAny(node, ["use_declaration", "visibility_modifier"])), Array.map((node) => {
1248
+ if (Option.exists(Option.fromNullishOr(node.parent), (parent) => parent.type === "token_tree")) return pathAt(node, tokenSegments(node));
1249
+ const outer = outermostPath(node);
1250
+ return pathAt(node, segmentsOf(outer));
1251
+ }));
1252
+ const joined = (prefix, node) => {
1253
+ const own = segmentsOf(node);
1254
+ if (own.length === NEXT$4 && Option.contains(Array.head(own), SELF) && Array.isReadonlyArrayNonEmpty(prefix)) return prefix;
1255
+ return [...prefix, ...own];
1256
+ };
1257
+ const treesOfUse = (prefix, node) => {
1258
+ switch (node.type) {
1259
+ case "scoped_use_list": {
1260
+ const base = Option.match(field(node, "path"), {
1261
+ onNone: () => prefix,
1262
+ onSome: (path) => joined(prefix, path)
1263
+ });
1264
+ return Option.match(field(node, "list"), {
1265
+ onNone: () => [base],
1266
+ onSome: (list) => treesOfUse(base, list)
1267
+ });
1268
+ }
1269
+ case "use_list": return Array.flatMap(namedChildren(node), (child) => treesOfUse(prefix, child));
1270
+ case "use_as_clause": return Option.match(field(node, "path"), {
1271
+ onNone: () => [],
1272
+ onSome: (path) => [joined(prefix, path)]
1273
+ });
1274
+ case "use_wildcard": return pipe(Array.head(namedChildren(node)), Option.match({
1275
+ onNone: () => [prefix],
1276
+ onSome: (path) => [joined(prefix, path)]
1277
+ }));
1278
+ default: return [joined(prefix, node)];
1279
+ }
1280
+ };
1281
+ const importedPaths = (root) => pipe(root.descendantsOfType("use_declaration"), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.flatMap((declaration) => pipe(field(declaration, "argument"), Option.match({
1282
+ onNone: () => [],
1283
+ onSome: (argument) => Array.map(treesOfUse([], argument), (segments) => pathAt(declaration, segments))
1284
+ }))), Array.filter(({ segments }) => Option.exists(Array.head(segments), (first) => Array.contains(ANCHORS, first))));
1285
+ const itemOf = (node) => ({
1286
+ kind: node.type,
1287
+ name: Option.map(field(node, "name"), (name) => name.text),
1288
+ inline: Option.isSome(field(node, "body")),
1289
+ visible: Array.some(namedChildren(node), (child) => child.type === "visibility_modifier"),
1290
+ line: node.startPosition.row + NEXT$4,
1291
+ column: node.startPosition.column + NEXT$4
1292
+ });
1293
+ const replacesAllocator = (root) => pipe(root.descendantsOfType("attribute"), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.some((attribute) => Option.exists(Array.head(namedChildren(attribute)), (name) => name.text === ALLOCATOR)));
1294
+ const readRustFile = (root) => ({
1295
+ paths: [...importedPaths(root), ...anchoredPaths(root)],
1296
+ items: pipe(namedChildren(root), Array.filter((node) => !Array.contains(IGNORED_ITEMS, node.type)), Array.map(itemOf)),
1297
+ replacesAllocator: replacesAllocator(root)
1047
1298
  });
1048
1299
  // src/features/check-placement/model/english-verbs.json
1049
1300
  var english_verbs_default = [
@@ -9480,23 +9731,25 @@ var english_verbs_default = [
9480
9731
  "zoom"
9481
9732
  ];
9482
9733
  // src/features/check-placement/model/source-names.ts
9483
- const SLICE_RULE = "feature-slice-name";
9484
- const ENTRY_RULE$1 = "deploy-entry-name";
9734
+ const SLICE_RULE$1 = "feature-slice-name";
9735
+ const ENTRY_RULE$2 = "deploy-entry-name";
9485
9736
  const SEPARATOR$14 = "/";
9486
9737
  const NEXT$3 = 1;
9487
- const WORD_SEPARATOR = "-";
9738
+ const WORD_SEPARATOR$1 = "-";
9488
9739
  const MINIMUM_WORDS = 2;
9489
- const FEATURES = "src/features/";
9740
+ const FEATURES$1 = "src/features/";
9490
9741
  const SOURCE$1 = "src/";
9491
9742
  const DEPLOY_MARKER = /(?:^|[.-])entrypoints?(?=[.-]|$)|\.worker(?=\.)/iu;
9743
+ const SCRIPT$1 = /\.[cm]?[jt]sx?$/u;
9492
9744
  const VERBS = new Set(english_verbs_default);
9493
- const SLICE_MESSAGE = "is not named <verb>-<object>. Name a feature slice after the one operation it performs, starting with an English verb (for example check-layout, sync-manuscripts).";
9494
- const ENTRY_MESSAGE = "is named after where it is deployed. Name it after what the code does; the Alchemy resource that deploys it decides which file is the entry.";
9495
- const isVerbObject = (slice) => {
9496
- const words = String$1.split(slice, WORD_SEPARATOR);
9745
+ const SLICE_MESSAGE$1 = "is not named <verb>-<object>. Name a feature slice after the one operation it performs, starting with an English verb (for example check-layout, sync-manuscripts).";
9746
+ const ENTRY_MESSAGE$1 = "is named after where it is deployed. Name it after what the code does; the Alchemy resource that deploys it decides which file is the entry.";
9747
+ const isVerbObjectBy = (separator) => (slice) => {
9748
+ const words = String$1.split(slice, separator);
9497
9749
  return words.length >= MINIMUM_WORDS && Option.exists(Array.head(words), (word) => VERBS.has(word));
9498
9750
  };
9499
- const misnamedSlice = ({ workspace, inner }) => pipe(Option.liftPredicate(inner, String$1.startsWith(FEATURES)), Option.flatMap((path) => Array.head(String$1.split(String$1.slice(13)(path), SEPARATOR$14))), Option.filter((slice) => !isVerbObject(slice)), Option.map((slice) => `${workspace}${SEPARATOR$14}${FEATURES}${slice}`));
9751
+ const isVerbObject = isVerbObjectBy(WORD_SEPARATOR$1);
9752
+ const misnamedSlice$1 = ({ workspace, inner }) => pipe(Option.liftPredicate(inner, (path) => String$1.startsWith(FEATURES$1)(path) && SCRIPT$1.test(path)), Option.flatMap((path) => Array.head(String$1.split(String$1.slice(13)(path), SEPARATOR$14))), Option.filter((slice) => !isVerbObject(slice)), Option.map((slice) => `${workspace}${SEPARATOR$14}${FEATURES$1}${slice}`));
9500
9753
  const deployNamed = ({ workspace, inner }) => {
9501
9754
  if (!String$1.startsWith(SOURCE$1)(inner)) return Option.none();
9502
9755
  const segments = String$1.split(inner, SEPARATOR$14);
@@ -9512,7 +9765,178 @@ const checkSourceNames = Effect.fn("checkSourceNames")(function* checkSourceName
9512
9765
  rule,
9513
9766
  message
9514
9767
  })));
9515
- return [...report(SLICE_RULE, SLICE_MESSAGE)(pipe(owned, Array.map(misnamedSlice), Array.getSomes)), ...report(ENTRY_RULE$1, ENTRY_MESSAGE)(pipe(owned, Array.map(deployNamed), Array.getSomes))];
9768
+ return [...report(SLICE_RULE$1, SLICE_MESSAGE$1)(pipe(owned, Array.map(misnamedSlice$1), Array.getSomes)), ...report(ENTRY_RULE$2, ENTRY_MESSAGE$1)(pipe(owned, Array.map(deployNamed), Array.getSomes))];
9769
+ });
9770
+ // src/features/check-placement/model/rust-modules.ts
9771
+ const LAYERED_RULE = "layered-source";
9772
+ const ENTRY_RULE$1 = "public-entry";
9773
+ const TEST_RULE = "colocated-test";
9774
+ const SLICE_RULE = "feature-slice-name";
9775
+ const IMPORT_RULE = "layer-import";
9776
+ const GRAMMAR = "rust";
9777
+ const WORD_SEPARATOR = "_";
9778
+ const FEATURES = "features";
9779
+ const MAIN = "main";
9780
+ const MAIN_FILE = "src/main.rs";
9781
+ const ROOT_ITEMS = [
9782
+ "use_declaration",
9783
+ "attribute_item",
9784
+ "inner_attribute_item",
9785
+ "extern_crate_declaration"
9786
+ ];
9787
+ const LAYER_ITEMS = [
9788
+ "use_declaration",
9789
+ "attribute_item",
9790
+ "inner_attribute_item"
9791
+ ];
9792
+ const READ_CONCURRENCY$18 = 64;
9793
+ const EXCLUDED$2 = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
9794
+ const NONE$2 = [];
9795
+ const OUTSIDE_MESSAGE = "sits outside src/. Put every module of a crate under src/ in an FSD layer; only build.rs and benches/ may stay outside.";
9796
+ const LAYER_MESSAGE = `is not an FSD layer. A crate's src/ holds only lib.rs, main.rs, bin/ and the layers ${Array.join(LAYERS, ", ")}.`;
9797
+ const ROOT_MESSAGE = "defines code in the crate root. Keep lib.rs and main.rs to mod declarations of layers, use, pub use and fn main, and put the code in a layer.";
9798
+ const LAYER_INDEX_MESSAGE = "defines code in a layer module. A layer module holds only mod declarations of its slices and use; put the code in a slice.";
9799
+ const ENTRY_MESSAGE = "makes an inner module of a slice public. Declare it with plain mod and re-export what other slices use with pub use from the slice module.";
9800
+ const TEST_MESSAGE = "sits in a separate test directory. Put the test next to the code it tests as a #[cfg(test)] module; only a test that replaces the global allocator needs its own binary in tests/.";
9801
+ const SLICE_MESSAGE = "is not named <verb>_<object>. Name a feature slice after the one operation it performs, starting with an English verb (for example check_layout, sync_manuscripts).";
9802
+ const isFeatureName = isVerbObjectBy(WORD_SEPARATOR);
9803
+ const placementProblem = ({ crate, inner, file }, root, join) => {
9804
+ if (!isInsideSource(inner)) return fileProblem$1({
9805
+ file,
9806
+ rule: LAYERED_RULE,
9807
+ message: OUTSIDE_MESSAGE
9808
+ });
9809
+ const top = Option.getOrElse(Array.head(modulePathOf(inner)), () => "");
9810
+ return fileProblem$1({
9811
+ file: join(root, crate, "src", top),
9812
+ rule: LAYERED_RULE,
9813
+ message: LAYER_MESSAGE
9814
+ });
9815
+ };
9816
+ const itemProblem = (file, rule, message) => ({ line, column }) => ({
9817
+ file,
9818
+ line,
9819
+ column,
9820
+ rule,
9821
+ message
9822
+ });
9823
+ const isRootItem = (inner) => (item) => {
9824
+ if (Array.contains(ROOT_ITEMS, item.kind)) return true;
9825
+ if (item.kind === "mod_item") return !item.inline && Option.exists(item.name, (name) => Array.contains(LAYERS, name));
9826
+ return item.kind === "function_item" && (inner === MAIN_FILE || BINARY.test(inner)) && Option.contains(item.name, MAIN);
9827
+ };
9828
+ const isLayerItem = (item) => Array.contains(LAYER_ITEMS, item.kind) || item.kind === "mod_item" && !item.inline;
9829
+ const importProblems = (file, modulePath, paths) => pipe(paths, Array.flatMap((path) => pipe(resolvedFrom({
9830
+ segments: path.segments,
9831
+ current: [...modulePath, ...path.scope]
9832
+ }), Option.flatMap((target) => importMessage({
9833
+ source: modulePath,
9834
+ target
9835
+ })), Option.map((message) => itemProblem(file, IMPORT_RULE, message)(path)), Option.toArray)), Array.dedupeWith((left, right) => left.line === right.line && left.column === right.column && left.message === right.message));
9836
+ const entryProblems$1 = (file, modulePath, parsed) => {
9837
+ if (!isSliceIndex(modulePath)) return NONE$2;
9838
+ return pipe(parsed.items, Array.filter((item) => item.kind === "mod_item" && item.visible), Array.map(itemProblem(file, ENTRY_RULE$1, ENTRY_MESSAGE)));
9839
+ };
9840
+ const moduleProblems = ({ source, parsed }) => {
9841
+ const modulePath = modulePathOf(source.inner);
9842
+ return [...entryProblems$1(source.file, modulePath, parsed), ...importProblems(source.file, modulePath, parsed.paths)];
9843
+ };
9844
+ const testProblems = ({ source, parsed }) => {
9845
+ if (parsed.replacesAllocator) return NONE$2;
9846
+ return [fileProblem$1({
9847
+ file: source.file,
9848
+ rule: TEST_RULE,
9849
+ message: TEST_MESSAGE
9850
+ })];
9851
+ };
9852
+ const strayItems = ({ source, parsed }, allowed, message) => pipe(parsed.items, Array.filter((item) => !allowed(item)), Array.map(itemProblem(source.file, LAYERED_RULE, message)));
9853
+ const PROBLEMS = {
9854
+ root: (read) => strayItems(read, isRootItem(read.source.inner), ROOT_MESSAGE),
9855
+ layer: (read) => strayItems(read, isLayerItem, LAYER_INDEX_MESSAGE),
9856
+ test: testProblems,
9857
+ module: moduleProblems,
9858
+ skipped: () => NONE$2,
9859
+ misplaced: () => NONE$2
9860
+ };
9861
+ const problemsOf$3 = (read) => PROBLEMS[kindOf$1(read.source.inner)](read);
9862
+ const misnamedSlice = ({ crate, inner }, root, join) => {
9863
+ const modulePath = modulePathOf(inner);
9864
+ return pipe(Option.liftPredicate(modulePath, (path) => path.length >= 2), Option.filter((path) => Option.contains(Array.head(path), FEATURES)), Option.flatMap((path) => Array.last(Array.take(path, 2))), Option.filter((slice) => !isFeatureName(slice)), Option.map((slice) => join(root, crate, "src", FEATURES, slice)));
9865
+ };
9866
+ const sliceNameProblems = (root, join, sources) => pipe(sources, Array.filter(({ inner }) => kindOf$1(inner) === "module"), Array.flatMap((source) => Option.toArray(misnamedSlice(source, root, join))), Array.dedupe, Array.map((file) => fileProblem$1({
9867
+ file,
9868
+ rule: SLICE_RULE,
9869
+ message: SLICE_MESSAGE
9870
+ })));
9871
+ const misplacedProblems = (root, join, sources) => pipe(sources, Array.filter(({ inner }) => kindOf$1(inner) === "misplaced"), Array.map((source) => placementProblem(source, root, join)), Array.dedupeWith((left, right) => left.file === right.file));
9872
+ const parsedWith = (language) => (source, text) => Option.map(readTree({
9873
+ language,
9874
+ source: text,
9875
+ read: readRustFile
9876
+ }), (parsed) => ({
9877
+ source,
9878
+ parsed
9879
+ }));
9880
+ const isRead = ({ inner }) => {
9881
+ const kind = kindOf$1(inner);
9882
+ return kind !== "misplaced" && kind !== "skipped";
9883
+ };
9884
+ const rustSources = Effect.fn("rustSources")(function* rustSources(root) {
9885
+ const files = yield* RepositoryFiles;
9886
+ const listed = yield* files.matchingFiles(root, EXCLUDED$2);
9887
+ const owner = crateOf(crateDirectories(listed));
9888
+ return pipe(listed, Array.filter((name) => RUST_FILE.test(name)), Array.flatMap((name) => Option.toArray(Option.map(owner(name), (owned) => ({
9889
+ ...owned,
9890
+ file: files.join(root, name)
9891
+ })))));
9892
+ });
9893
+ /** @internal */
9894
+ const checkRustModules = Effect.fn("checkRustModules")(function* checkRustModules(root) {
9895
+ const files = yield* RepositoryFiles;
9896
+ const sources = yield* rustSources(root);
9897
+ if (!Array.isReadonlyArrayNonEmpty(sources)) return NONE$2;
9898
+ const language = yield* loadLanguage(GRAMMAR).pipe(Effect.orDie);
9899
+ const parse = parsedWith(language);
9900
+ const read = yield* Effect.forEach(pipe(sources, Array.filter(isRead)), (source) => files.readFile(source.file).pipe(Effect.map(Option.flatMap((text) => parse(source, text)))), { concurrency: READ_CONCURRENCY$18 });
9901
+ return [
9902
+ ...misplacedProblems(root, files.join, sources),
9903
+ ...sliceNameProblems(root, files.join, sources),
9904
+ ...Array.flatMap(Array.getSomes(read), problemsOf$3)
9905
+ ];
9906
+ });
9907
+ // src/features/check-placement/model/source-aliases.ts
9908
+ const ALIAS_RULE = "source-alias";
9909
+ const FIRST$12 = 1;
9910
+ const SOURCE_ALIAS = "#/*";
9911
+ const SOURCE_TARGET = "./src/*";
9912
+ const SOURCE_PREFIX = /^\.\/src(?:\/|$)/u;
9913
+ const ALIAS_MESSAGE = `points into src/ under its own name. Import source through "${SOURCE_ALIAS}": "${SOURCE_TARGET}" only, so an import names the layer and slice it uses instead of a folder alias.`;
9914
+ const Manifest$2 = Schema.Struct({ imports: Schema.optional(Schema.Unknown) });
9915
+ const decodeManifest$5 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$2));
9916
+ const problemAt$6 = (file, rule, message) => ({
9917
+ file,
9918
+ line: FIRST$12,
9919
+ column: FIRST$12,
9920
+ rule,
9921
+ message
9922
+ });
9923
+ const targetsOf = (target) => {
9924
+ if (Predicate.isString(target)) return [target];
9925
+ if (Predicate.isObject(target)) return pipe(Record.values(target), Array.flatMap(targetsOf));
9926
+ return [];
9927
+ };
9928
+ const intoSource = ([key, target]) => !(key === SOURCE_ALIAS && pipe(targetsOf(target), Array.every((path) => path === SOURCE_TARGET))) && pipe(targetsOf(target), Array.some((path) => SOURCE_PREFIX.test(path)));
9929
+ const aliasProblems = Effect.fn("aliasProblems")(function* aliasProblems(root, workspace) {
9930
+ const files = yield* RepositoryFiles;
9931
+ const manifest = files.join(root, workspace, MANIFEST_FILE$1);
9932
+ const text = yield* files.readFile(manifest);
9933
+ return pipe(text, Option.flatMap(decodeManifest$5), Option.flatMap(({ imports }) => Option.liftPredicate(imports, Predicate.isObject)), Option.map((imports) => Record.toEntries(imports)), Option.getOrElse(() => Array.empty()), Array.filter(intoSource), Array.map(([key]) => problemAt$6(manifest, ALIAS_RULE, `"${key}" ${ALIAS_MESSAGE}`)));
9934
+ });
9935
+ /** @internal */
9936
+ const checkSourceAliases = Effect.fn("checkSourceAliases")(function* checkSourceAliases(root) {
9937
+ const workspaces = yield* memberWorkspaces(root);
9938
+ const aliases = yield* Effect.forEach(workspaces, (workspace) => aliasProblems(root, workspace), { concurrency: 1 });
9939
+ return Array.flatten(aliases);
9516
9940
  });
9517
9941
  // src/features/check-placement/model/placement-checks.ts
9518
9942
  /** @internal */
@@ -9521,6 +9945,7 @@ const checkPlacement = Effect.fn("checkPlacement")(function* checkPlacement(root
9521
9945
  checkDocPlacement(root),
9522
9946
  checkColocatedTests(root),
9523
9947
  checkLayeredSource(root),
9948
+ checkRustModules(root),
9524
9949
  checkSourceAliases(root),
9525
9950
  checkSourceNames(root),
9526
9951
  checkColocatedGitPatterns(root),
@@ -9539,7 +9964,7 @@ const WORKFLOW_DIRECTORY$1 = ".github/";
9539
9964
  const SEPARATOR$13 = "/";
9540
9965
  const CURRENT = "./";
9541
9966
  const READ_CONCURRENCY$17 = 8;
9542
- const FIRST$10 = 1;
9967
+ const FIRST$11 = 1;
9543
9968
  const RUN_FILE = /(?:^|[\s;&|(])(?:node|vpx|tsx|bun|deno)\s+(?:-\S+\s+)*(?<file>[^\s;&|)]+\.[cm]?[jt]s)\b/gu;
9544
9969
  const COMMAND = /^bin\/[^/]+\.[cm]?ts$/u;
9545
9970
  const NOT_COMMAND = /\.(?:test|d|test\.support)\.[cm]?ts$/u;
@@ -9615,8 +10040,8 @@ const problemsIn$12 = Effect.fn("problemsIn")(function* problemsIn(root, directo
9615
10040
  const isRun = (path) => Array.contains(runPaths, path) || Array.contains(entries.bins, path) || String$1.includes(workspacePath(directory, path))(workflows);
9616
10041
  const unrun = pipe(commands, Array.filter((path) => !isRun(path)), Array.map((path) => ({
9617
10042
  file: files.join(root, directory, path),
9618
- line: FIRST$10,
9619
- column: FIRST$10,
10043
+ line: FIRST$11,
10044
+ column: FIRST$11,
9620
10045
  rule: UNRUN,
9621
10046
  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.`
9622
10047
  })));
@@ -9628,8 +10053,8 @@ const scriptsProblem = Effect.fn("scriptsProblem")(function* scriptsProblem(root
9628
10053
  const isDirectory = yield* files.isDirectory(file);
9629
10054
  return pipe(isDirectory, Option.filter(Boolean), Option.map(() => ({
9630
10055
  file,
9631
- line: FIRST$10,
9632
- column: FIRST$10,
10056
+ line: FIRST$11,
10057
+ column: FIRST$11,
9633
10058
  rule: SCRIPTS,
9634
10059
  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.`
9635
10060
  })));
@@ -9643,11 +10068,11 @@ const checkCommandEntries = Effect.fn("checkCommandEntries")(function* checkComm
9643
10068
  return [...Array.flatten(found), ...Array.getSomes(scripts)];
9644
10069
  });
9645
10070
  // src/features/check-repository-layout/model/crates.ts
9646
- const RULE$28 = "unverified-crate";
10071
+ const RULE$29 = "unverified-crate";
9647
10072
  const CARGO_FILE = "Cargo.toml";
9648
- const CONFIG_FILE$4 = "vite.config.ts";
10073
+ const CONFIG_FILE$5 = "vite.config.ts";
9649
10074
  const SEPARATOR$12 = "/";
9650
- const FIRST$9 = 1;
10075
+ const FIRST$10 = 1;
9651
10076
  const READ_CONCURRENCY$16 = 8;
9652
10077
  const CrateEntry = Schema.Struct({
9653
10078
  name: Schema.String,
@@ -9679,17 +10104,17 @@ const owningWorkspace = (directories) => (directory) => {
9679
10104
  };
9680
10105
  const problemFor$2 = (crate, message) => ({
9681
10106
  file: crate.manifest,
9682
- line: FIRST$9,
9683
- column: FIRST$9,
9684
- rule: RULE$28,
10107
+ line: FIRST$10,
10108
+ column: FIRST$10,
10109
+ rule: RULE$29,
9685
10110
  message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
9686
10111
  });
9687
10112
  const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
9688
10113
  const files = yield* RepositoryFiles;
9689
10114
  const workspace = owningWorkspace(directories)(files.relative(root, files.dirname(crate.manifest)));
9690
10115
  if (Option.isNone(workspace)) return Option.some(problemFor$2(crate, "is outside every workspace package"));
9691
- if (yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE$4))) return Option.none();
9692
- return Option.some(problemFor$2(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$4} has no verify task`));
10116
+ if (yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE$5))) return Option.none();
10117
+ return Option.some(problemFor$2(crate, `is in ${workspace.value}, whose ${CONFIG_FILE$5} has no verify task`));
9693
10118
  });
9694
10119
  /** @internal */
9695
10120
  const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
@@ -9701,7 +10126,7 @@ const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
9701
10126
  return Array.getSomes(found);
9702
10127
  });
9703
10128
  // src/features/check-repository-layout/model/deploy-entry-patterns.ts
9704
- const RULE$27 = "deploy-entry-pattern";
10129
+ const RULE$28 = "deploy-entry-pattern";
9705
10130
  const FALLOW_KEYS = [
9706
10131
  "entry",
9707
10132
  "entryPoints",
@@ -9772,7 +10197,7 @@ const problemsIn$11 = Effect.fn("problemsIn")(function* problemsIn(request) {
9772
10197
  return pipe(Array.getSomes(flagged), Array.map(({ text: pattern, start }) => ({
9773
10198
  file: path,
9774
10199
  ...positionOf(text.value)(start - kind.offset),
9775
- rule: RULE$27,
10200
+ rule: RULE$28,
9776
10201
  message: `${pattern} ${MESSAGE$8}`
9777
10202
  })));
9778
10203
  });
@@ -9805,7 +10230,7 @@ const checkDeployEntryPatterns = Effect.fn("checkDeployEntryPatterns")(function*
9805
10230
  return Array.flatten(found);
9806
10231
  });
9807
10232
  // src/features/check-repository-layout/model/fallow-entries.ts
9808
- const RULE$26 = "listed-entry";
10233
+ const RULE$27 = "listed-entry";
9809
10234
  const ENTRY_KEYS = [
9810
10235
  "entry",
9811
10236
  "entryPoints",
@@ -9835,7 +10260,7 @@ const problemsIn$10 = Effect.fn("problemsIn")(function* problemsIn(root, file, d
9835
10260
  return pipe(entryPatternsIn(parsed.program), Array.filter(namesOneFile(directories)), Array.map(({ text: pattern, start }) => ({
9836
10261
  file: path,
9837
10262
  ...positionOf(text.value)(start),
9838
- rule: RULE$26,
10263
+ rule: RULE$27,
9839
10264
  message: `${pattern} names files one by one. Let fallow find the file through what declares it: package.json bin and exports, a tool's config file, or the main of the Alchemy resource that deploys it.`
9840
10265
  })));
9841
10266
  });
@@ -9847,9 +10272,9 @@ const checkFallowEntries = Effect.fn("checkFallowEntries")(function* checkFallow
9847
10272
  return Array.flatten(found);
9848
10273
  });
9849
10274
  // src/features/check-repository-layout/model/hidden-verify.ts
9850
- const RULE$25 = "hidden-verify";
9851
- const CONFIG_FILE$3 = "vite.config.ts";
9852
- const FIRST$8 = 1;
10275
+ const RULE$26 = "hidden-verify";
10276
+ const CONFIG_FILE$4 = "vite.config.ts";
10277
+ const FIRST$9 = 1;
9853
10278
  const READ_CONCURRENCY$13 = 8;
9854
10279
  const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directory) {
9855
10280
  const config = yield* workspaceConfigOf(root, directory);
@@ -9859,10 +10284,10 @@ const problemIn$1 = Effect.fn("problemIn")(function* problemIn(root, directory)
9859
10284
  const verified = yield* hasVerifyTask(file);
9860
10285
  return Option.some({
9861
10286
  file,
9862
- line: FIRST$8,
9863
- column: FIRST$8,
9864
- rule: RULE$25,
9865
- message: `${directory} gets its verify task from code outside ${CONFIG_FILE$3}. The root verify reads ${CONFIG_FILE$3} without running it, so it never runs this verify. Write run.tasks.verify in ${directory}/${CONFIG_FILE$3}.`
10287
+ line: FIRST$9,
10288
+ column: FIRST$9,
10289
+ rule: RULE$26,
10290
+ message: `${directory} gets its verify task from code outside ${CONFIG_FILE$4}. The root verify reads ${CONFIG_FILE$4} without running it, so it never runs this verify. Write run.tasks.verify in ${directory}/${CONFIG_FILE$4}.`
9866
10291
  }).pipe(Option.filter(() => verified));
9867
10292
  });
9868
10293
  /** @internal */
@@ -9872,11 +10297,11 @@ const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVe
9872
10297
  return Array.getSomes(found);
9873
10298
  });
9874
10299
  // src/features/check-repository-layout/model/root-workspace-paths.ts
9875
- const RULE$24 = "root-workspace-path";
9876
- const CONFIG_FILE$2 = "vite.config.ts";
10300
+ const RULE$25 = "root-workspace-path";
10301
+ const CONFIG_FILE$3 = "vite.config.ts";
9877
10302
  const PATH_CHARACTER = /[\w.@/-]/u;
9878
10303
  const NAME_CHARACTER = /[\w.@-]/u;
9879
- const FIRST$7 = 0;
10304
+ const FIRST$8 = 0;
9880
10305
  const NEXT$2 = 1;
9881
10306
  const isBoundary = (character, allowed) => character === "" || !allowed.test(character);
9882
10307
  const mentions$1 = (directory) => (text) => {
@@ -9884,20 +10309,20 @@ const mentions$1 = (directory) => (text) => {
9884
10309
  return pipe(Array.drop(parts, NEXT$2), Array.some((after, index) => {
9885
10310
  const before = parts[index] ?? "";
9886
10311
  const previous = String$1.slice(before.length - NEXT$2)(before);
9887
- const following = String$1.slice(FIRST$7, NEXT$2)(after);
10312
+ const following = String$1.slice(FIRST$8, NEXT$2)(after);
9888
10313
  return isBoundary(previous, PATH_CHARACTER) && (following === "/" || isBoundary(following, NAME_CHARACTER));
9889
10314
  }));
9890
10315
  };
9891
10316
  const problemsIn$9 = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions$1(directory)(found.text)), Array.map((directory) => ({
9892
10317
  file,
9893
10318
  ...positionOf(source)(found.start),
9894
- rule: RULE$24,
9895
- message: `${directory} is a workspace. The root ${CONFIG_FILE$2} holds what applies to every workspace, so move what only ${directory} needs into ${directory}/${CONFIG_FILE$2}: msch.lint, msch.devDependencies or its verify task.`
10319
+ rule: RULE$25,
10320
+ message: `${directory} is a workspace. The root ${CONFIG_FILE$3} holds what applies to every workspace, so move what only ${directory} needs into ${directory}/${CONFIG_FILE$3}: msch.lint, msch.devDependencies or its verify task.`
9896
10321
  })));
9897
10322
  /** @internal */
9898
10323
  const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* checkRootWorkspacePaths(root) {
9899
10324
  const files = yield* RepositoryFiles;
9900
- const file = files.join(root, CONFIG_FILE$2);
10325
+ const file = files.join(root, CONFIG_FILE$3);
9901
10326
  const source = yield* files.readFile(file);
9902
10327
  if (Option.isNone(source)) return [];
9903
10328
  const directories = yield* workspaceDirectories(root);
@@ -9905,7 +10330,7 @@ const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* c
9905
10330
  return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$9(file, source.value, directories)));
9906
10331
  });
9907
10332
  // src/features/check-repository-layout/model/shared-uncached-tasks.ts
9908
- const RULE$23 = "shared-uncached-task";
10333
+ const RULE$24 = "shared-uncached-task";
9909
10334
  const READ_CONCURRENCY$12 = 8;
9910
10335
  const SHARED = 2;
9911
10336
  const OWN_PROGRAM = /^(?:node|vpx|bun|deno|tsx)$|\//u;
@@ -9948,7 +10373,7 @@ const problemsOf$2 = (definitions) => {
9948
10373
  return pipe(definitions, Array.map(({ file, position, name, command }) => ({
9949
10374
  file,
9950
10375
  ...position,
9951
- rule: RULE$23,
10376
+ rule: RULE$24,
9952
10377
  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.`
9953
10378
  })));
9954
10379
  };
@@ -10094,13 +10519,13 @@ const outputPathsOf = (step) => pipe(stringOf(pathInputOf(step)), Option.toArray
10094
10519
  /** @internal */
10095
10520
  const producedPaths = (source) => pipe(jobsOf(source), Array.flatMap(([, job]) => itemsOf(childOf("steps")(job))), Array.flatMap(outputPathsOf));
10096
10521
  // src/features/check-repository-layout/model/workflow-paths.ts
10097
- const RULE$22 = "workflow-path";
10522
+ const RULE$23 = "workflow-path";
10098
10523
  const WORKFLOW_DIRECTORY = ".github/workflows/";
10099
10524
  const WORKFLOW_EXTENSIONS = [".yml", ".yaml"];
10100
10525
  const READ_CONCURRENCY$11 = 8;
10101
10526
  const WILDCARD$2 = /[*?[]/u;
10102
10527
  const SEPARATOR$9 = "/";
10103
- const FIRST$6 = 0;
10528
+ const FIRST$7 = 0;
10104
10529
  const EXPECTED = {
10105
10530
  action: "a directory with action.yml",
10106
10531
  directory: "a directory",
@@ -10141,7 +10566,7 @@ const RESOLVERS = {
10141
10566
  };
10142
10567
  const staticPrefix = (path) => {
10143
10568
  const prefix = Array.headNonEmpty(String$1.split(path, WILDCARD$2));
10144
- if (String$1.endsWith(SEPARATOR$9)(prefix)) return String$1.slice(FIRST$6, -1)(prefix);
10569
+ if (String$1.endsWith(SEPARATOR$9)(prefix)) return String$1.slice(FIRST$7, -1)(prefix);
10145
10570
  return prefix;
10146
10571
  };
10147
10572
  const isIgnored$1 = Effect.fn("isIgnored")(function* isIgnored(root, path) {
@@ -10157,10 +10582,10 @@ const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, fou
10157
10582
  if (yield* RESOLVERS[found.kind](root, found.path)) return false;
10158
10583
  return !(yield* isIgnored$1(root, found.path));
10159
10584
  });
10160
- const problemOf$7 = (file, source) => (found) => ({
10585
+ const problemOf$8 = (file, source) => (found) => ({
10161
10586
  file,
10162
10587
  ...positionOf(source)(found.offset),
10163
- rule: RULE$22,
10588
+ rule: RULE$23,
10164
10589
  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.`
10165
10590
  });
10166
10591
  const problemsIn$8 = Effect.fn("problemsIn")(function* problemsIn(root, workflow) {
@@ -10170,7 +10595,7 @@ const problemsIn$8 = Effect.fn("problemsIn")(function* problemsIn(root, workflow
10170
10595
  if (Option.isNone(source)) return [];
10171
10596
  const produced = producedPaths(source.value);
10172
10597
  const missing = yield* Effect.filter(workflowReferences(source.value), (found) => isMissing(root, produced, found));
10173
- return pipe(missing, Array.map(problemOf$7(file, source.value)));
10598
+ return pipe(missing, Array.map(problemOf$8(file, source.value)));
10174
10599
  });
10175
10600
  /** @internal */
10176
10601
  const checkWorkflowPaths = Effect.fn("checkWorkflowPaths")(function* checkWorkflowPaths(root) {
@@ -10288,12 +10713,12 @@ const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(r
10288
10713
  return Array.flatten(found);
10289
10714
  });
10290
10715
  // src/features/check-typescript-generation/model/typescript-generation.ts
10291
- const RULE$21 = "legacy-typescript";
10716
+ const RULE$22 = "legacy-typescript";
10292
10717
  const LOCKFILE = "pnpm-lock.yaml";
10293
10718
  const COMPILER = "typescript";
10294
10719
  const CURRENT_MAJOR = 7;
10295
10720
  const LEGACY_COMPILER_PACKAGE = /^@typescript\/typescript\d+$/u;
10296
- const FIRST$5 = 1;
10721
+ const FIRST$6 = 1;
10297
10722
  const legacyOf = (id) => {
10298
10723
  const { name, version } = parse$1(id);
10299
10724
  const isOldCompiler = name === COMPILER && pipe(Option.fromNullishOr(version), Option.flatMap((found) => Option.fromNullishOr(semver.coerce(found))), Option.exists((found) => found.major < CURRENT_MAJOR));
@@ -10304,8 +10729,8 @@ const legacyOf = (id) => {
10304
10729
  };
10305
10730
  const dependentsOf = (nodes) => (id) => pipe(nodes, Array.filter(({ dependencies }) => Array.contains(dependencies, id)), Array.map((node) => `\`${node.id}\``));
10306
10731
  const lineOf$2 = (source) => (id) => pipe(String$1.split(source, "\n"), Array.findFirstIndex((line) => String$1.replaceAll("'", "")(String$1.trim(line)) === `${id}:`), Option.match({
10307
- onNone: () => FIRST$5,
10308
- onSome: (index) => index + FIRST$5
10732
+ onNone: () => FIRST$6,
10733
+ onSome: (index) => index + FIRST$6
10309
10734
  }));
10310
10735
  const messageOf$2 = (legacy, dependents) => `\`${legacy.id}\` is installed, pulled in by ${Array.join(dependents, ", ")}. Only TypeScript ${String(CURRENT_MAJOR)} or newer is used: remove the dependency that needs the old compiler, move it to the TypeScript ${String(CURRENT_MAJOR)} API, or bundle or port it. Do not install an old compiler beside TypeScript ${String(CURRENT_MAJOR)}.`;
10311
10736
  /** @internal */
@@ -10318,8 +10743,8 @@ const checkTypescriptGeneration = Effect.fn("checkTypescriptGeneration")(functio
10318
10743
  return pipe(Option.getOrElse(nodes, () => []), Array.flatMap(({ id }) => Option.toArray(legacyOf(id))), Array.map((legacy) => ({
10319
10744
  file,
10320
10745
  line: lineOf$2(source)(legacy.id),
10321
- column: FIRST$5,
10322
- rule: RULE$21,
10746
+ column: FIRST$6,
10747
+ rule: RULE$22,
10323
10748
  message: messageOf$2(legacy, dependentsOf(Option.getOrElse(nodes, () => []))(legacy.id))
10324
10749
  })));
10325
10750
  });
@@ -11610,7 +12035,7 @@ const duplicateProblems = (relative) => (sites) => {
11610
12035
  }))));
11611
12036
  };
11612
12037
  // src/features/check-value-owners/model/name-lists.ts
11613
- const RULE$20 = "hand-written-names";
12038
+ const RULE$21 = "hand-written-names";
11614
12039
  const TEST_FILE = /\.test(?:\.[\w-]+)?\.[cm]?tsx?$/u;
11615
12040
  const nameListOf = (site) => {
11616
12041
  if (TEST_FILE.test(site.file) || site.values.length < 2) return Option.none();
@@ -11621,11 +12046,11 @@ const nameListOf = (site) => {
11621
12046
  }, (list) => list.names.length === site.values.length);
11622
12047
  };
11623
12048
  const mostNamesOf = (list) => Math.max(2, list.names.length - 1);
11624
- const problemOf$6 = ({ list, reason }) => ({
12049
+ const problemOf$7 = ({ list, reason }) => ({
11625
12050
  file: list.site.file,
11626
12051
  line: list.site.line,
11627
12052
  column: list.site.column,
11628
- rule: RULE$20,
12053
+ rule: RULE$21,
11629
12054
  message: `The names ${formatValues(list.names)} are listed by hand, but ${reason}`
11630
12055
  });
11631
12056
  // src/features/check-value-owners/model/declared-names.ts
@@ -11656,7 +12081,7 @@ const declaredNameProblem = ({ literals, relative }) => {
11656
12081
  if (defined.length < mostNamesOf(list) || files.length < 2) return Option.none();
11657
12082
  const names = pipe(defined, Array.map(([name]) => name));
11658
12083
  const shown = pipe(files, Array.take(SHOWN_FILES), Array.map(relative), Array.join(", "));
11659
- return Option.some(problemOf$6({
12084
+ return Option.some(problemOf$7({
11660
12085
  list,
11661
12086
  reason: `${formatValues(names)} are each written in another module (${shown}). Type those values with this list, or build this list from them, so that adding one does not mean editing two places.`
11662
12087
  }));
@@ -11689,11 +12114,11 @@ const listedPathProblem = (repository) => (list) => {
11689
12114
  const paths = pipe(list.names, Array.map(namedPath(repository, list.site.file)), Array.getSomes);
11690
12115
  const packages = pipe(list.names, Array.filter((name) => HashSet.has(repository.packages, name)));
11691
12116
  const directory = enumeratedDirectory(repository)(paths);
11692
- if (Option.isSome(directory)) return Option.some(problemOf$6({
12117
+ if (Option.isSome(directory)) return Option.some(problemOf$7({
11693
12118
  list,
11694
12119
  reason: `they enumerate the entries of ${directoryLabel(directory.value)}. Find them with a glob or derive them from the declaration that names them.`
11695
12120
  }));
11696
- if (packages.length >= 2) return Option.some(problemOf$6({
12121
+ if (packages.length >= 2) return Option.some(problemOf$7({
11697
12122
  list,
11698
12123
  reason: `${formatValues(packages)} are workspace packages. Derive them from the workspace manifests or from a property that each package declares.`
11699
12124
  }));
@@ -11708,7 +12133,7 @@ const connected = (index) => (left, right) => left === right || imports(index)(l
11708
12133
  const isPartOf = (index, list) => (other) => other !== list && canImport(list.site.scope, other.site.scope) && connected(index)(list.site.file, other.site.file) && isSubsetOf(list.names, other.names) && list.names.length * SUBSET_SHARE >= other.names.length && !sameValues(list.names, other.names);
11709
12134
  const subsetListProblem = ({ lists, literals, relative }) => {
11710
12135
  const index = importIndexOf(literals);
11711
- return (list) => pipe(lists, Array.findFirst(isPartOf(index, list)), Option.map((other) => problemOf$6({
12136
+ return (list) => pipe(lists, Array.findFirst(isPartOf(index, list)), Option.map((other) => problemOf$7({
11712
12137
  list,
11713
12138
  reason: `they are a part of ${formatValues(other.names)} at ${relative(other.site.file)}:${String(other.site.line)}. Name that list once and select from it with Extract or Exclude.`
11714
12139
  })));
@@ -11852,7 +12277,7 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
11852
12277
  return sortProblems([...ownerScan.problems, ...repositoryProblems(repository)(analyses)]);
11853
12278
  }, Effect.scoped);
11854
12279
  // src/features/source-code/find-namespace-destructuring/model/namespace-destructuring.ts
11855
- const RULE$19 = "namespace-destructuring";
12280
+ const RULE$20 = "namespace-destructuring";
11856
12281
  const LOCAL = /^[.#/]/u;
11857
12282
  const messageOf$1 = (name) => `Destructuring ${name}, which comes from a package, makes the bundler keep everything ${name} exports. Write ${name}.<member> where it is used.`;
11858
12283
  const isPackage = (specifier) => isStringLiteral(specifier) && !LOCAL.test(specifier.text);
@@ -11867,16 +12292,16 @@ const destructuredName = (declaration) => {
11867
12292
  if (declaration.name.kind !== SyntaxKind.ObjectBindingPattern) return Option.none();
11868
12293
  return pipe(Option.fromUndefinedOr(declaration.initializer), Option.filter(isIdentifier), Option.map((initializer) => initializer.text));
11869
12294
  };
11870
- const problemOf$5 = (names) => (declaration) => pipe(destructuredName(declaration), Option.filter((name) => names.includes(name)), Option.map((name) => problemAt$9({
11871
- rule: RULE$19,
12295
+ const problemOf$6 = (names) => (declaration) => pipe(destructuredName(declaration), Option.filter((name) => names.includes(name)), Option.map((name) => problemAt$9({
12296
+ rule: RULE$20,
11872
12297
  message: messageOf$1(name)
11873
12298
  })), Option.map((report) => report(declaration)));
11874
12299
  const namespaceDestructuringIn = () => (sourceFile) => {
11875
12300
  const names = importedNames(sourceFile);
11876
- return pipe(descendantsOf(sourceFile), Array.filter(isVariableDeclaration), Array.map(problemOf$5(names)), Array.getSomes);
12301
+ return pipe(descendantsOf(sourceFile), Array.filter(isVariableDeclaration), Array.map(problemOf$6(names)), Array.getSomes);
11877
12302
  };
11878
12303
  // src/features/source-code/find-pass-through-wrappers/model/pass-through-wrappers.ts
11879
- const RULE$18 = "pass-through-wrapper";
12304
+ const RULE$19 = "pass-through-wrapper";
11880
12305
  const SINGLE_STATEMENT = 1;
11881
12306
  const SINGLE_DECLARATION = 1;
11882
12307
  const THIS_PARAMETER = "this";
@@ -11970,19 +12395,19 @@ const isPassThrough = (checker) => (candidate) => (forward) => {
11970
12395
  const restForwarded = pipe(wrapper.parameters, Array.some(isRest));
11971
12396
  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);
11972
12397
  };
11973
- const problemOf$4 = (checker) => (candidate) => {
12398
+ const problemOf$5 = (checker) => (candidate) => {
11974
12399
  if (changesTheCall(candidate.wrapper)) return Option.none();
11975
12400
  return pipe(returnedExpression(candidate.wrapper), Option.flatMap(forwardOf), Option.filter(isPassThrough(checker)(candidate)), Option.map((forward) => problemAt$9({
11976
- rule: RULE$18,
12401
+ rule: RULE$19,
11977
12402
  message: messageOf(forward.callee.getText())
11978
12403
  })(candidate.name)));
11979
12404
  };
11980
- const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$4(checker)), Array.getSomes);
12405
+ const passThroughWrappersIn = (checker) => (sourceFile) => pipe(descendantsOf(sourceFile), Array.map(candidateOf), Array.getSomes, Array.map(problemOf$5(checker)), Array.getSomes);
11981
12406
  // src/app/source-checks.ts
11982
12407
  /** @internal */
11983
12408
  const checkSources = (root) => checkRepository(root, [passThroughWrappersIn, namespaceDestructuringIn]);
11984
12409
  // src/features/check-agent-settings/model/missing-hooks.ts
11985
- const RULE$17 = "missing-hook";
12410
+ const RULE$18 = "missing-hook";
11986
12411
  const SETTINGS_FILE$1 = /^\.claude\/settings\.json$/u;
11987
12412
  const PLUGIN_HOOKS_FILE = /(?:^|\/)hooks\/hooks\.json$/u;
11988
12413
  const PROJECT_PATH = /(?<optional>--env-file-if-exists=)?\$\{?CLAUDE_PROJECT_DIR\}?(?:\\")?\/(?<path>[\w.@/-]+)/gu;
@@ -12007,7 +12432,7 @@ const problemsIn$7 = Effect.fn("problemsIn")(function* problemsIn({ root, file,
12007
12432
  return pipe(missing, Array.map(({ path, index }) => ({
12008
12433
  file,
12009
12434
  ...positionOf(source)(index),
12010
- rule: RULE$17,
12435
+ rule: RULE$18,
12011
12436
  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.`
12012
12437
  })));
12013
12438
  });
@@ -12034,6 +12459,47 @@ const checkMissingHooks = Effect.fn("checkMissingHooks")(function* checkMissingH
12034
12459
  const found = yield* Effect.forEach(hookFiles, problemsIn$7, { concurrency: READ_CONCURRENCY$9 });
12035
12460
  return Array.flatten(found);
12036
12461
  });
12462
+ // src/features/check-markdown/model/markdown.ts
12463
+ const taggedError$4 = Schema.TaggedError;
12464
+ var MarkdownConfigUnreadable = class extends taggedError$4()("MarkdownConfigUnreadable", { file: Schema.String }) {};
12465
+ const CONFIG_FILE$2 = "vite.config.ts";
12466
+ const RULE$17 = "markdown";
12467
+ const FIRST$5 = 1;
12468
+ const sectionAt = Effect.fn("markdownSection")(function* sectionAt(file) {
12469
+ if (!(yield* (yield* RepositoryFiles).exists(file))) return Option.none();
12470
+ const config = yield* Effect.tryPromise({
12471
+ try: () => resolveConfigFromFile(file),
12472
+ catch: () => MarkdownConfigUnreadable.make({ file })
12473
+ }).pipe(Effect.option);
12474
+ return pipe(config, Option.map(y8Section));
12475
+ });
12476
+ const problemOf$4 = (root, join) => (diagnostic) => ({
12477
+ file: join(root, diagnostic.path),
12478
+ line: diagnostic.line,
12479
+ column: diagnostic.column ?? FIRST$5,
12480
+ rule: RULE$17,
12481
+ message: `${diagnostic.rule} ${diagnostic.message}${diagnosticDetail(diagnostic)}`
12482
+ });
12483
+ const failureAt = (file, message) => [{
12484
+ file,
12485
+ line: FIRST$5,
12486
+ column: FIRST$5,
12487
+ rule: RULE$17,
12488
+ message
12489
+ }];
12490
+ const checkMarkdown = Effect.fn("checkMarkdown")(function* checkMarkdown(root) {
12491
+ const files = yield* RepositoryFiles;
12492
+ const configFile = files.join(root, CONFIG_FILE$2);
12493
+ const section = yield* sectionAt(configFile);
12494
+ if (Option.isNone(section)) return [];
12495
+ const config = section.value;
12496
+ const listed = yield* files.matchingFiles(root, markdownPathspecs({ config }));
12497
+ return yield* lint({
12498
+ root,
12499
+ files: listed,
12500
+ config
12501
+ }).pipe(Effect.map((diagnostics) => pipe(diagnostics, Array.filter(({ severity }) => severity === "error"), Array.map(problemOf$4(root, files.join)))), Effect.catchTag("Y8Error", (failure) => Effect.succeed(failureAt(configFile, failure.message))));
12502
+ });
12037
12503
  // src/features/check-scripts/model/shell-scripts.ts
12038
12504
  const SHELL_FILE = /\.(?:sh|bash|zsh|ksh|fish|command)$/u;
12039
12505
  const SHELL_SHEBANG = /^#!\S*(?:\/|\s)(?:env\s+)?(?:-\S+\s+)*(?:ba|z|k|da)?sh\b|^#!\S*fish\b/u;
@@ -12512,7 +12978,8 @@ const checkToolUse = Effect.fn("checkToolUse")(function* checkToolUse(root) {
12512
12978
  checkWorkflowCommits(root),
12513
12979
  checkFullHistoryCheckout(root),
12514
12980
  checkReleasePrAutoMerge(root),
12515
- checkRestrictedRules(root)
12981
+ checkRestrictedRules(root),
12982
+ checkMarkdown(root)
12516
12983
  ], { concurrency: "unbounded" });
12517
12984
  return Array.flatten(found);
12518
12985
  });
@@ -12609,34 +13076,24 @@ const COMMENT_NODES = [
12609
13076
  const START$7 = 0;
12610
13077
  const NEXT = 1;
12611
13078
  const NONE$1 = [];
12612
- const grammarFile = (grammar) => fileURLToPath(import.meta.resolve(`@vscode/tree-sitter-wasm/wasm/tree-sitter-${grammar}.wasm`));
12613
- const loadGrammar = (grammar) => Effect.tryPromise({
12614
- try: () => treeSitter.Language.load(grammarFile(grammar)),
12615
- catch: unreadable(grammar)
12616
- }).pipe(Effect.map((language) => [grammar, language]));
13079
+ const loadGrammar = (grammar) => loadLanguage(grammar).pipe(Effect.mapBoth({
13080
+ onFailure: ({ message }) => unreadable(grammar)(message),
13081
+ onSuccess: (language) => [grammar, language]
13082
+ }));
12617
13083
  const loadGrammars = Effect.fn("loadGrammars")(function* loadGrammars() {
12618
- yield* Effect.tryPromise({
12619
- try: () => treeSitter.Parser.init(),
12620
- catch: unreadable("javascript")
12621
- });
12622
13084
  const loaded = yield* Effect.forEach(GRAMMARS, (grammar) => loadGrammar(grammar), { concurrency: 1 });
12623
13085
  const languages = Record.fromEntries(loaded);
12624
13086
  const grammars = (grammar) => Record.get(languages, grammar);
12625
13087
  return grammars;
12626
13088
  });
12627
- const commentNodesIn = (language, source) => {
12628
- const parser = new treeSitter.Parser();
12629
- parser.setLanguage(language);
12630
- const tree = parser.parse(source);
12631
- parser.delete();
12632
- if (tree === null) return NONE$1;
12633
- const found = pipe(tree.rootNode.descendantsOfType(COMMENT_NODES), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.map((node) => trimmed({
13089
+ const commentNodesIn = (language, source) => pipe(readTree({
13090
+ language,
13091
+ source,
13092
+ read: (root) => pipe(root.descendantsOfType(COMMENT_NODES), Array.flatMap((node) => Option.toArray(Option.fromNullishOr(node))), Array.map((node) => trimmed({
12634
13093
  index: node.startIndex,
12635
13094
  text: node.text
12636
- })));
12637
- tree.delete();
12638
- return found;
12639
- };
13095
+ })))
13096
+ }), Option.getOrElse(() => NONE$1));
12640
13097
  const syntaxComments = (grammars, grammar) => (source) => Option.match(grammars(grammar), {
12641
13098
  onNone: () => Effect.fail(unreadable(grammar)("the grammar is not loaded")),
12642
13099
  onSome: (language) => Effect.try({
@@ -13874,7 +14331,8 @@ const checkTrackedText = Effect.fn("checkTrackedText")(function* checkTrackedTex
13874
14331
  checkGitSubpath(root),
13875
14332
  checkDowngrades(root),
13876
14333
  checkRenovateSettings(root),
13877
- checkCatalogEntries(root)
14334
+ checkCatalogEntries(root),
14335
+ checkPackageRegistry(root)
13878
14336
  ], { concurrency: "unbounded" });
13879
14337
  return Array.flatten(found);
13880
14338
  });