@r_masseater/msch 0.29.1 → 0.32.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/README.md +18 -48
- package/dist/{cli-contract-kyLbx4PX.mjs → cli-contract-CmaJS4ne.mjs} +2 -2
- package/dist/{cli-contract-kyLbx4PX.mjs.map → cli-contract-CmaJS4ne.mjs.map} +1 -1
- package/dist/cli.mjs +621 -411
- package/dist/cli.mjs.map +1 -1
- package/dist/config.d.mts +28 -0
- package/dist/config.mjs +192 -0
- package/dist/config.mjs.map +1 -0
- package/dist/decision-rules.d.mts +1 -1
- package/dist/decision-rules.mjs +1 -1
- package/dist/{index-B3B75yJ6.d.mts → index-BOXkKig9.d.mts} +4 -2
- package/dist/index-C02uoL59.d.mts +41 -0
- package/dist/{lint-preset-Dz2aZ0Yl.mjs → lint-preset-CtRoIi4F.mjs} +65 -7
- package/dist/lint-preset-CtRoIi4F.mjs.map +1 -0
- package/dist/lint-rules.mjs +88 -0
- package/dist/lint-rules.mjs.map +1 -1
- package/dist/lint.d.mts +2 -2
- package/dist/lint.mjs +1 -1
- package/dist/oxlint.mjs +1 -1
- package/dist/{repository-files-B11FFAIk.mjs → repository-files-D_lFq7Bj.mjs} +11 -1
- package/dist/repository-files-D_lFq7Bj.mjs.map +1 -0
- package/dist/{workspace-DuBjvDMC.mjs → workspace-BNAwy85Z.mjs} +70 -57
- package/dist/workspace-BNAwy85Z.mjs.map +1 -0
- package/dist/workspace-settings.d.mts +2 -38
- package/dist/workspace-settings.mjs +68 -54
- package/dist/workspace-settings.mjs.map +1 -1
- package/package.json +18 -3
- package/skills/msch-checks/SKILL.md +31 -5
- package/skills/repository-config/SKILL.md +88 -0
- package/skills/workspace-settings/SKILL.md +62 -0
- package/dist/lint-preset-Dz2aZ0Yl.mjs.map +0 -1
- package/dist/repository-files-B11FFAIk.mjs.map +0 -1
- package/dist/workspace-DuBjvDMC.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
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, a as problemAt$
|
|
4
|
-
import { a as groupOf$1, i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-
|
|
2
|
+
import { C as childrenOf$2, D as propertyValue, E as nestedValues, F as dependencyEntries, I as readManifest, L as workspaceDependencies, M as EntryManifestJson, N as publicEntriesOf, O as stringsIn, P as MANIFEST_FILE$1, S as KeySchema, T as literalOf, c as workspaceManifest, d as RUN_TASKS, f as VERIFY_TASK, j as publishedWorkspaces, l as runTasksOf, m as hasVerifyTask, n as namedWorkspaces, o as workspaceDirectories, p as definesTask, r as patternOf, s as workspaceProjects, t as deployEntries, w as keyName, x as workspaceConfigOf } from "./workspace-BNAwy85Z.mjs";
|
|
3
|
+
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, a as problemAt$8, 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-CmaJS4ne.mjs";
|
|
4
|
+
import { a as groupOf$1, i as nodeServicesLayer, n as RepositoryFiles, r as nodeRepositoryFiles, t as NODE_MODULES } from "./repository-files-D_lFq7Bj.mjs";
|
|
5
5
|
import { t as COMMENT_DIRECTIVES } from "./comment-directives-WcDqvLwJ.mjs";
|
|
6
6
|
import { VpToolsError, runVpa } from "@r_masseater/vite-plus-adopt";
|
|
7
7
|
import { Array, Cause, Effect, FileSystem, Function, HashMap, HashSet, Layer, Number as Number$1, Option, Order, Path, Predicate, Record, Result, Schema, Stdio, Stream, String as String$1, pipe } from "effect";
|
|
8
8
|
import { ChildProcess } from "effect/process";
|
|
9
9
|
import { parse, resolveConfigFromFile } from "vite-plus";
|
|
10
|
-
import {
|
|
10
|
+
import { readWantedLockfile } from "@pnpm/lockfile.fs";
|
|
11
|
+
import { updateWorkspaceManifest } from "@pnpm/workspace.workspace-manifest-writer";
|
|
12
|
+
import { Parser, isMap, isPair, isScalar, isSeq, parse as parse$1, parseDocument, visit } from "yaml";
|
|
11
13
|
import path from "node:path";
|
|
12
14
|
import { fileURLToPath } from "node:url";
|
|
13
15
|
import treeSitter from "@vscode/tree-sitter-wasm";
|
|
@@ -16,6 +18,7 @@ import { DomUtils, parseDocument as parseDocument$1 } from "htmlparser2";
|
|
|
16
18
|
import { DockerfileParser } from "dockerfile-ast";
|
|
17
19
|
import { parse as parse$2 } from "sql-parser-cst";
|
|
18
20
|
import { parseTOML } from "toml-eslint-parser";
|
|
21
|
+
import { findSkillFiles } from "@tanstack/intent";
|
|
19
22
|
import { runMain } from "@effect/platform-node-shared/NodeRuntime";
|
|
20
23
|
import { FetchHttpClient } from "effect/http";
|
|
21
24
|
import { Otlp, OtlpSerialization } from "effect/observability";
|
|
@@ -185,7 +188,7 @@ const indexEntry = (cache) => (checker) => (entry) => Effect.sync(() => cache.in
|
|
|
185
188
|
"msch.library.vocabularies": index.vocabularies.length,
|
|
186
189
|
"msch.library.shapes": index.shapes.length
|
|
187
190
|
})), Effect.map(({ index }) => index), Effect.withSpan("indexLibraryEntry", { attributes: { "msch.library.specifier": entry.specifier } }));
|
|
188
|
-
const libraryIndex = (cache) => (checker) => (entries) => pipe(entries, Effect.forEach(indexEntry(cache)(checker)), Effect.map(mergeIndexes), Effect.withSpan("libraryIndex"));
|
|
191
|
+
const libraryIndex = (cache) => (checker) => (entries) => pipe(entries, (items) => Effect.forEach(items, indexEntry(cache)(checker), { concurrency: 1 }), Effect.map(mergeIndexes), Effect.withSpan("libraryIndex"));
|
|
189
192
|
// src/entities/project/model/telemetry.ts
|
|
190
193
|
const RSS_LINE = /^VmRSS:\s+(?<kib>\d+) kB$/mu;
|
|
191
194
|
const BYTES_PER_KIB = 1024;
|
|
@@ -204,7 +207,7 @@ const childPids = Effect.gen(function* childPids() {
|
|
|
204
207
|
const annotateMemory = Effect.gen(function* annotateMemory() {
|
|
205
208
|
const own = yield* residentBytesOf(String(process.pid));
|
|
206
209
|
const pids = yield* childPids;
|
|
207
|
-
const children = yield*
|
|
210
|
+
const children = yield* Effect.forEach(pids, (pid) => residentBytesOf(pid), { concurrency: 1 });
|
|
208
211
|
const { heapUsed } = process.memoryUsage();
|
|
209
212
|
yield* Effect.annotateCurrentSpan({
|
|
210
213
|
"process.memory.rss": own,
|
|
@@ -239,7 +242,7 @@ const listConfigFiles = (root) => Effect.gen(function* configFilesUnder() {
|
|
|
239
242
|
const parseConfig = (api) => (configPath) => Option.some(api.parseConfigFile(configPath)).pipe(Option.filter((parsed) => Array.isReadonlyArrayNonEmpty(parsed.fileNames)));
|
|
240
243
|
const nearestPackageDirectory = (directory, root) => Effect.gen(function* nearestPackage() {
|
|
241
244
|
const files = yield* RepositoryFiles;
|
|
242
|
-
const hasManifest = yield* files.exists(files.join(directory, MANIFEST_FILE));
|
|
245
|
+
const hasManifest = yield* files.exists(files.join(directory, MANIFEST_FILE$1));
|
|
243
246
|
const parent = files.dirname(directory);
|
|
244
247
|
if (hasManifest || directory === root || parent === directory) return directory;
|
|
245
248
|
return yield* nearestPackageDirectory(parent, root);
|
|
@@ -312,12 +315,12 @@ const mentions$1 = (needle) => ({ api }) => (configPath) => Effect.gen(function*
|
|
|
312
315
|
onNone: () => [],
|
|
313
316
|
onSome: (parsed) => parsed.fileNames
|
|
314
317
|
});
|
|
315
|
-
const texts = yield*
|
|
318
|
+
const texts = yield* Effect.forEach(fileNames, (fileName) => files.readFile(fileName), { concurrency: 1 });
|
|
316
319
|
const includesNeedle = String$1.includes(needle);
|
|
317
320
|
return pipe(texts, Array.some((text) => Option.exists(text, includesNeedle)));
|
|
318
321
|
});
|
|
319
322
|
// src/entities/project/model/inputs.ts
|
|
320
|
-
const SEPARATOR$
|
|
323
|
+
const SEPARATOR$19 = "/";
|
|
321
324
|
const SCOPE_PREFIX$1 = "@";
|
|
322
325
|
const HIDDEN_PREFIX = ".";
|
|
323
326
|
const encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));
|
|
@@ -338,7 +341,7 @@ const dependenciesOf = Effect.fn("dependenciesOf")(function* dependenciesOf(dire
|
|
|
338
341
|
onNone: () => [],
|
|
339
342
|
onSome: workspaceDependencies
|
|
340
343
|
});
|
|
341
|
-
return yield*
|
|
344
|
+
return yield* Effect.forEach(names, (name) => files.realPath(files.join(directory, NODE_MODULES, name)), { concurrency: 1 });
|
|
342
345
|
});
|
|
343
346
|
const workspaceClosure = Effect.fn("workspaceClosure")(function* workspaceClosure(start) {
|
|
344
347
|
const seen = /* @__PURE__ */ new Set([start]);
|
|
@@ -359,28 +362,28 @@ const closureOf$1 = Effect.fn("closureOf")(function* closureOf(root, configPath)
|
|
|
359
362
|
const directories = yield* workspaceClosure(directory);
|
|
360
363
|
return {
|
|
361
364
|
directories,
|
|
362
|
-
prefixes: pipe(directories, Array.map((found) => `${files.relative(root, found)}${SEPARATOR$
|
|
365
|
+
prefixes: pipe(directories, Array.map((found) => `${files.relative(root, found)}${SEPARATOR$19}`))
|
|
363
366
|
};
|
|
364
367
|
});
|
|
365
368
|
const scopedNames = (modules) => (name) => Effect.gen(function* listScope() {
|
|
366
369
|
const files = yield* RepositoryFiles;
|
|
367
370
|
if (!String$1.startsWith(SCOPE_PREFIX$1)(name)) return [name];
|
|
368
371
|
const scoped = yield* files.readDirectory(files.join(modules, name));
|
|
369
|
-
return pipe(scoped, Array.map((entry) => `${name}${SEPARATOR$
|
|
372
|
+
return pipe(scoped, Array.map((entry) => `${name}${SEPARATOR$19}${entry}`));
|
|
370
373
|
});
|
|
371
374
|
const installedNames$1 = Effect.fn("installedNames")(function* installedNames(modules) {
|
|
372
375
|
const listed = yield* (yield* RepositoryFiles).readDirectory(modules);
|
|
373
|
-
const nested = yield* pipe(listed, Array.filter((name) => !String$1.startsWith(HIDDEN_PREFIX)(name)), Effect.forEach(scopedNames(modules)));
|
|
376
|
+
const nested = yield* pipe(listed, Array.filter((name) => !String$1.startsWith(HIDDEN_PREFIX)(name)), (items) => Effect.forEach(items, scopedNames(modules), { concurrency: 1 }));
|
|
374
377
|
return Array.flatten(nested);
|
|
375
378
|
});
|
|
376
379
|
const installedPackages = Effect.fn("installedPackages")(function* installedPackages(root, directory) {
|
|
377
380
|
const files = yield* RepositoryFiles;
|
|
378
381
|
const modules = files.join(directory, NODE_MODULES);
|
|
379
382
|
const names = yield* installedNames$1(modules);
|
|
380
|
-
return yield*
|
|
383
|
+
return yield* Effect.forEach(names, (name) => files.realPath(files.join(modules, name)).pipe(Effect.map((found) => files.relative(root, found))), { concurrency: 1 });
|
|
381
384
|
});
|
|
382
385
|
const dependencyVersions = Effect.fn("dependencyVersions")(function* dependencyVersions(root, directories) {
|
|
383
|
-
const installed = yield*
|
|
386
|
+
const installed = yield* Effect.forEach(Array.dedupe([root, ...directories]), (directory) => installedPackages(root, directory), { concurrency: 1 });
|
|
384
387
|
return Array.sort(Array.dedupe(Array.flatten(installed)), Order.String);
|
|
385
388
|
});
|
|
386
389
|
const projectInputs = ({ workspace: { compiler, root }, listed }) => (configPath) => Effect.gen(function* collectInputs() {
|
|
@@ -416,7 +419,7 @@ const RELATIVE$1 = /^\.\.?(?:\/|$)/u;
|
|
|
416
419
|
const SUBPATH_IMPORT = "#";
|
|
417
420
|
const WILDCARD$2 = "*";
|
|
418
421
|
const SCOPE$1 = "@";
|
|
419
|
-
const SEPARATOR$
|
|
422
|
+
const SEPARATOR$18 = "/";
|
|
420
423
|
const SOURCE_SUFFIXES = [
|
|
421
424
|
"",
|
|
422
425
|
".ts",
|
|
@@ -428,9 +431,9 @@ const PLAIN_SEGMENTS = 1;
|
|
|
428
431
|
const ImportsField = Schema.Struct({ imports: Schema.optional(Schema.Record(Schema.String, Schema.String)) });
|
|
429
432
|
const decodeImports = Schema.decodeOption(Schema.fromJsonString(ImportsField));
|
|
430
433
|
const packageNameOf = (specifier) => {
|
|
431
|
-
const segments = String$1.split(specifier, SEPARATOR$
|
|
432
|
-
if (String$1.startsWith(SCOPE$1)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS), Array.join(SEPARATOR$
|
|
433
|
-
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$
|
|
434
|
+
const segments = String$1.split(specifier, SEPARATOR$18);
|
|
435
|
+
if (String$1.startsWith(SCOPE$1)(specifier)) return pipe(segments, Array.take(SCOPED_SEGMENTS), Array.join(SEPARATOR$18));
|
|
436
|
+
return pipe(segments, Array.take(PLAIN_SEGMENTS), Array.join(SEPARATOR$18));
|
|
434
437
|
};
|
|
435
438
|
const literalText = (specifier) => pipe(Option.liftPredicate(specifier, isStringLiteral), Option.map((literal) => literal.text));
|
|
436
439
|
const runtimeSpecifierOf = (statement) => {
|
|
@@ -454,10 +457,10 @@ const subpathTarget = (imports, specifier) => pipe(Record.toEntries(imports), Ar
|
|
|
454
457
|
}));
|
|
455
458
|
const existingSource = Effect.fn("existingSource")(function* existingSource(base) {
|
|
456
459
|
const files = yield* RepositoryFiles;
|
|
457
|
-
const found = yield*
|
|
460
|
+
const found = yield* Effect.forEach(SOURCE_SUFFIXES, (suffix) => {
|
|
458
461
|
const candidate = `${base}${suffix}`;
|
|
459
462
|
return files.isDirectory(candidate).pipe(Effect.map((directory) => Option.liftPredicate(candidate, () => Option.exists(directory, (isDirectory) => !isDirectory))));
|
|
460
|
-
})
|
|
463
|
+
}, { concurrency: 1 });
|
|
461
464
|
return Array.head(Array.getSomes(found));
|
|
462
465
|
});
|
|
463
466
|
const localFile = Effect.fn("localFile")(function* localFile({ directory, imports }, from, specifier) {
|
|
@@ -478,7 +481,7 @@ const referencesIn$1 = Effect.fn("referencesIn")(function* referencesIn(graph, f
|
|
|
478
481
|
onNone: () => [],
|
|
479
482
|
onSome: (source) => specifiersIn(graph.api, file, source)
|
|
480
483
|
});
|
|
481
|
-
const references = yield*
|
|
484
|
+
const references = yield* Effect.forEach(specifiers, (specifier) => referenceOf$1(graph, file, specifier), { concurrency: 1 });
|
|
482
485
|
const found = Array.getSomes(references);
|
|
483
486
|
return {
|
|
484
487
|
packages: Array.getFailures(found),
|
|
@@ -502,17 +505,17 @@ const packagesFrom = (graph, walk) => Array.match(walk.pending, {
|
|
|
502
505
|
/** @internal */
|
|
503
506
|
const packagesByEntry = Effect.fn("packagesByEntry")(function* packagesByEntry(api, directory, entries) {
|
|
504
507
|
const files = yield* RepositoryFiles;
|
|
505
|
-
const manifest = yield* files.readFile(files.join(directory, MANIFEST_FILE));
|
|
508
|
+
const manifest = yield* files.readFile(files.join(directory, MANIFEST_FILE$1));
|
|
506
509
|
const graph = {
|
|
507
510
|
api,
|
|
508
511
|
directory,
|
|
509
512
|
imports: pipe(manifest, Option.flatMap(decodeImports), Option.flatMap((field) => Option.fromUndefinedOr(field.imports)), Option.getOrElse(() => ({})))
|
|
510
513
|
};
|
|
511
|
-
return yield*
|
|
514
|
+
return yield* Effect.forEach(entries, (entry) => packagesFrom(graph, {
|
|
512
515
|
pending: [entry],
|
|
513
516
|
visited: HashSet.empty(),
|
|
514
517
|
packages: HashSet.empty()
|
|
515
|
-
}).pipe(Effect.map((packages) => [entry, packages])))
|
|
518
|
+
}).pipe(Effect.map((packages) => [entry, packages])), { concurrency: 1 });
|
|
516
519
|
});
|
|
517
520
|
// src/features/install-size/model/installed-closure.ts
|
|
518
521
|
const EMPTY$1 = 0;
|
|
@@ -526,16 +529,16 @@ const InstalledManifest = Schema.Struct({
|
|
|
526
529
|
peerDependenciesMeta: PeerMeta
|
|
527
530
|
});
|
|
528
531
|
const decodeManifest$5 = Schema.decodeOption(Schema.fromJsonString(InstalledManifest));
|
|
529
|
-
const keysOf$
|
|
532
|
+
const keysOf$1 = (map) => pipe(Option.fromUndefinedOr(map), Option.map(Record.keys), Option.getOrElse(() => []));
|
|
530
533
|
const isOptionalPeer = (manifest, name) => pipe(Option.fromUndefinedOr(manifest.peerDependenciesMeta), Option.flatMap(Record.get(name)), Option.exists((meta) => meta.optional === true));
|
|
531
534
|
const installedNames = (manifest) => [
|
|
532
|
-
...keysOf$
|
|
533
|
-
...keysOf$
|
|
534
|
-
...pipe(keysOf$
|
|
535
|
+
...keysOf$1(manifest.dependencies),
|
|
536
|
+
...keysOf$1(manifest.optionalDependencies),
|
|
537
|
+
...pipe(keysOf$1(manifest.peerDependencies), Array.filter((name) => !isOptionalPeer(manifest, name)))
|
|
535
538
|
];
|
|
536
539
|
const childrenOf$1 = Effect.fn("childrenOf")(function* childrenOf(directory) {
|
|
537
540
|
const files = yield* RepositoryFiles;
|
|
538
|
-
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));
|
|
541
|
+
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE$1));
|
|
539
542
|
return pipe(text, Option.flatMap(decodeManifest$5), Option.map(installedNames), Option.getOrElse(() => []), Array.map((child) => [directory, child]));
|
|
540
543
|
});
|
|
541
544
|
const resolveFrom = (from, name) => Effect.gen(function* resolvePackage() {
|
|
@@ -573,11 +576,11 @@ const directorySize = (directory) => Effect.gen(function* sizeOfDirectory() {
|
|
|
573
576
|
const files = yield* RepositoryFiles;
|
|
574
577
|
const names = yield* files.readDirectory(directory);
|
|
575
578
|
const entries = pipe(names, Array.filter((name) => name !== NODE_MODULES), Array.map((name) => files.join(directory, name)));
|
|
576
|
-
const sizes = yield*
|
|
579
|
+
const sizes = yield* Effect.forEach(entries, (entry) => files.isDirectory(entry).pipe(Effect.flatMap((kind) => {
|
|
577
580
|
if (Option.isNone(kind)) return Effect.succeed(EMPTY$1);
|
|
578
581
|
if (kind.value) return directorySize(entry);
|
|
579
582
|
return files.fileSize(entry);
|
|
580
|
-
})))
|
|
583
|
+
})), { concurrency: 1 });
|
|
581
584
|
return Number$1.sumAll(sizes);
|
|
582
585
|
});
|
|
583
586
|
const installedClosure = ({ provided, from, name }) => closureOf(provided, {
|
|
@@ -620,11 +623,11 @@ const budgetProblem = Effect.fn("budgetProblem")(function* budgetProblem(overrun
|
|
|
620
623
|
};
|
|
621
624
|
});
|
|
622
625
|
const measure = Effect.fn("measure")(function* measure({ workspace, provided }, direct) {
|
|
623
|
-
const closures = yield*
|
|
626
|
+
const closures = yield* Effect.forEach(direct, (name) => installedClosure({
|
|
624
627
|
provided,
|
|
625
628
|
from: workspace.directory,
|
|
626
629
|
name
|
|
627
|
-
}).pipe(Effect.map((packages) => [name, packages])))
|
|
630
|
+
}).pipe(Effect.map((packages) => [name, packages])), { concurrency: 1 });
|
|
628
631
|
const everything = pipe(closures, Array.flatMap(([, packages]) => Array.fromIterable(packages)), HashSet.fromIterable);
|
|
629
632
|
const measured = yield* Effect.forEach(everything, (found) => installedSize(found).pipe(Effect.map((size) => [found, size])), { concurrency: SIZE_CONCURRENCY });
|
|
630
633
|
const sizes = HashMap.fromIterable(measured);
|
|
@@ -687,7 +690,7 @@ const problemsOf$2 = Effect.fn("problemsOf")(function* problemsOf(workspace, fil
|
|
|
687
690
|
join: (target) => files.join(workspace.directory, target),
|
|
688
691
|
packEntries: workspace.packEntries
|
|
689
692
|
});
|
|
690
|
-
const provided = HashSet.fromIterable(keysOf$
|
|
693
|
+
const provided = HashSet.fromIterable(keysOf$1(manifest.value.peerDependencies));
|
|
691
694
|
const sized = yield* sizeProblems({
|
|
692
695
|
workspace,
|
|
693
696
|
entries,
|
|
@@ -697,7 +700,7 @@ const problemsOf$2 = Effect.fn("problemsOf")(function* problemsOf(workspace, fil
|
|
|
697
700
|
});
|
|
698
701
|
const workspaceProblems = Effect.fn("workspaceProblems")(function* workspaceProblems(workspace) {
|
|
699
702
|
const files = yield* RepositoryFiles;
|
|
700
|
-
const file = files.join(workspace.directory, MANIFEST_FILE);
|
|
703
|
+
const file = files.join(workspace.directory, MANIFEST_FILE$1);
|
|
701
704
|
const source = yield* files.readFile(file);
|
|
702
705
|
return yield* Option.match(source, {
|
|
703
706
|
onNone: () => Effect.succeed([]),
|
|
@@ -707,7 +710,7 @@ const workspaceProblems = Effect.fn("workspaceProblems")(function* workspaceProb
|
|
|
707
710
|
/** @internal */
|
|
708
711
|
const checkPublishedPackages = Effect.fn("checkPublishedPackages")(function* checkPublishedPackages(root) {
|
|
709
712
|
const workspaces = yield* publishedWorkspaces(root);
|
|
710
|
-
const found = yield*
|
|
713
|
+
const found = yield* Effect.forEach(workspaces, workspaceProblems, { concurrency: 1 });
|
|
711
714
|
return Array.flatten(found);
|
|
712
715
|
});
|
|
713
716
|
// src/features/overrides/model/override-findings.ts
|
|
@@ -809,22 +812,13 @@ const withoutPeerContext = (version) => Option.match(String$1.indexOf(PEER_CONTE
|
|
|
809
812
|
onSome: (start) => String$1.slice(NAME_START, start)(version)
|
|
810
813
|
});
|
|
811
814
|
const packageOf = (key) => Option.map(separatorOf(key), (separator) => [String$1.slice(NAME_START, separator)(key), withoutPeerContext(String$1.slice(separator + SEPARATOR_LENGTH)(key))]);
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
return pipe(node.items, Array.flatMap((pair) => {
|
|
815
|
-
if (isScalar(pair.key)) return [String(pair.key.value)];
|
|
816
|
-
return [];
|
|
817
|
-
}));
|
|
818
|
-
};
|
|
819
|
-
const lockfileKeysOf = (lockfile, section) => pipe(parseAllDocuments(lockfile), Array.flatMap((document) => keysOf$1(document.get(section))));
|
|
820
|
-
const resolutionOf = (findings) => (lockfile) => {
|
|
821
|
-
const snapshots = lockfileKeysOf(lockfile, "snapshots");
|
|
822
|
-
const packages = Array.getSomes(pipe([...lockfileKeysOf(lockfile, "packages"), ...snapshots], Array.map((key) => packageOf(key))));
|
|
815
|
+
const resolutionOf = (findings) => (depPaths) => {
|
|
816
|
+
const packages = Array.getSomes(pipe(depPaths, Array.map((key) => packageOf(key))));
|
|
823
817
|
const versions = Record.map(Array.groupBy(packages, ([name]) => name), (entries) => sorted(pipe(entries, Array.map(([, version]) => version))));
|
|
824
818
|
return {
|
|
825
819
|
...findings,
|
|
826
820
|
versions,
|
|
827
|
-
snapshots: sorted(
|
|
821
|
+
snapshots: sorted(depPaths)
|
|
828
822
|
};
|
|
829
823
|
};
|
|
830
824
|
const changesBetween = (baseline, candidate) => pipe(sorted([...Record.keys(baseline.versions), ...Record.keys(candidate.versions)]), Array.map((name) => ({
|
|
@@ -859,48 +853,37 @@ const judge = (baseline) => (key, candidate) => {
|
|
|
859
853
|
verdict: "verify"
|
|
860
854
|
};
|
|
861
855
|
};
|
|
862
|
-
const OVERRIDES = "overrides";
|
|
863
856
|
const BASELINE_PROBE = "msch-baseline-probe";
|
|
864
857
|
const REMOVED_DEPENDENCY = "-";
|
|
865
|
-
const
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
return
|
|
870
|
-
const { key } = pair;
|
|
871
|
-
if (!isScalar(key)) return [];
|
|
872
|
-
return pipe(Option.fromNullishOr(key.range), Option.map(([start]) => {
|
|
873
|
-
const { line, col } = lineCounter.linePos(start);
|
|
874
|
-
return {
|
|
875
|
-
key: String(key.value),
|
|
876
|
-
line,
|
|
877
|
-
column: col
|
|
878
|
-
};
|
|
879
|
-
}), Option.toArray);
|
|
880
|
-
}));
|
|
881
|
-
};
|
|
882
|
-
const withoutOverride = (key) => (manifest) => {
|
|
883
|
-
const document = parseDocument(manifest);
|
|
884
|
-
document.deleteIn([OVERRIDES, key]);
|
|
885
|
-
return document.toString();
|
|
858
|
+
const QUOTES = ["\"", "'"];
|
|
859
|
+
const PREVIOUS = 1;
|
|
860
|
+
const keyStart = (source) => (index) => {
|
|
861
|
+
const before = String$1.slice(index - PREVIOUS, index)(source);
|
|
862
|
+
return index - Number(Array.contains(QUOTES, before)) * PREVIOUS;
|
|
886
863
|
};
|
|
887
|
-
const
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
|
|
864
|
+
const overrideKeysOf = (source) => (overrides) => {
|
|
865
|
+
const at = positionOf(source);
|
|
866
|
+
return pipe(Record.keys(overrides), Array.flatMap((key) => pipe(String$1.indexOf(key)(source), Option.map((index) => ({
|
|
867
|
+
key,
|
|
868
|
+
...at(keyStart(source)(index))
|
|
869
|
+
})), Option.toArray)));
|
|
891
870
|
};
|
|
871
|
+
const withoutOverride = (key) => (overrides) => Record.remove(overrides, key);
|
|
872
|
+
const withBaselineProbe = (overrides) => ({
|
|
873
|
+
...overrides,
|
|
874
|
+
[BASELINE_PROBE]: REMOVED_DEPENDENCY
|
|
875
|
+
});
|
|
892
876
|
// src/features/overrides/model/overrides.ts
|
|
893
877
|
const WORKSPACE_FILE$3 = "pnpm-workspace.yaml";
|
|
894
|
-
const LOCKFILE$1 = "pnpm-lock.yaml";
|
|
895
878
|
const RESOLUTION_FILES = [
|
|
896
879
|
"*package.json",
|
|
897
880
|
WORKSPACE_FILE$3,
|
|
898
|
-
|
|
881
|
+
"pnpm-lock.yaml",
|
|
899
882
|
".npmrc",
|
|
900
883
|
"patches/*"
|
|
901
884
|
];
|
|
902
885
|
const RESOLUTION_CONCURRENCY = 4;
|
|
903
|
-
const SUCCEEDED = 0;
|
|
886
|
+
const SUCCEEDED$1 = 0;
|
|
904
887
|
const taggedError$4 = Schema.TaggedError;
|
|
905
888
|
var OverrideResolutionFailed = class extends taggedError$4()("OverrideResolutionFailed", {
|
|
906
889
|
override: Schema.String,
|
|
@@ -921,7 +904,7 @@ const resolveIn = Effect.fn("resolveIn")(function* resolveIn(directory, override
|
|
|
921
904
|
stdin: "ignore"
|
|
922
905
|
});
|
|
923
906
|
const [output, status] = yield* Effect.all([textOf(handle.all), handle.exitCode], { concurrency: "unbounded" });
|
|
924
|
-
if (Number(status) !== SUCCEEDED) return yield* OverrideResolutionFailed.make({
|
|
907
|
+
if (Number(status) !== SUCCEEDED$1) return yield* OverrideResolutionFailed.make({
|
|
925
908
|
override,
|
|
926
909
|
output
|
|
927
910
|
});
|
|
@@ -958,34 +941,48 @@ const copyFiles = Effect.fn("copyFiles")(function* copyFiles(workspace, director
|
|
|
958
941
|
const copy = fs.copyFile(path.join(workspace.root, file), target);
|
|
959
942
|
return fs.makeDirectory(path.dirname(target), { recursive: true }).pipe(Effect.andThen(copy));
|
|
960
943
|
};
|
|
961
|
-
yield* Effect.forEach(workspace.files, copyOne, {
|
|
944
|
+
yield* Effect.forEach(workspace.files, copyOne, {
|
|
945
|
+
concurrency: 1,
|
|
946
|
+
discard: true
|
|
947
|
+
});
|
|
962
948
|
});
|
|
963
|
-
const
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
949
|
+
const depPathsIn = (directory, override) => Effect.tryPromise({
|
|
950
|
+
try: () => readWantedLockfile(directory, { ignoreIncompatible: false }),
|
|
951
|
+
catch: (cause) => OverrideResolutionFailed.make({
|
|
952
|
+
override,
|
|
953
|
+
output: String(cause)
|
|
954
|
+
})
|
|
955
|
+
}).pipe(Effect.map((lockfile) => pipe(Option.fromNullishOr(lockfile), Option.flatMap(({ packages }) => Option.fromUndefinedOr(packages)), Option.map(Record.keys), Option.getOrElse(() => []))));
|
|
956
|
+
const resolutionWith = Effect.fn("resolutionWith")(function* resolutionWith(workspace, override, overrides) {
|
|
957
|
+
const directory = yield* (yield* FileSystem.FileSystem).makeTempDirectoryScoped({ prefix: "msch-overrides-" });
|
|
967
958
|
yield* copyFiles(workspace, directory);
|
|
968
|
-
yield*
|
|
959
|
+
yield* Effect.tryPromise({
|
|
960
|
+
try: () => updateWorkspaceManifest(directory, { updatedFields: { overrides: { ...overrides } } }),
|
|
961
|
+
catch: (cause) => OverrideResolutionFailed.make({
|
|
962
|
+
override,
|
|
963
|
+
output: String(cause)
|
|
964
|
+
})
|
|
965
|
+
});
|
|
969
966
|
const output = yield* resolveIn(directory, override);
|
|
970
|
-
const
|
|
967
|
+
const depPaths = yield* depPathsIn(directory, override);
|
|
971
968
|
yield* Effect.annotateCurrentSpan({ "msch.override": override });
|
|
972
969
|
const advisories = yield* auditIn(directory);
|
|
973
970
|
return resolutionOf({
|
|
974
971
|
peerIssues: peerIssuesIn(output),
|
|
975
972
|
advisories
|
|
976
|
-
})(
|
|
973
|
+
})(depPaths);
|
|
977
974
|
}, Effect.scoped);
|
|
978
|
-
const problemsFor = Effect.fn("problemsFor")(function* problemsFor(root,
|
|
975
|
+
const problemsFor = Effect.fn("problemsFor")(function* problemsFor(root, overrides, keys) {
|
|
979
976
|
const path = yield* Path.Path;
|
|
980
977
|
const workspace = {
|
|
981
978
|
root,
|
|
982
979
|
files: yield* trackedResolutionFiles(root),
|
|
983
|
-
|
|
980
|
+
overrides
|
|
984
981
|
};
|
|
985
|
-
const baseline = yield* resolutionWith(workspace, BASELINE_PROBE, withBaselineProbe(
|
|
982
|
+
const baseline = yield* resolutionWith(workspace, BASELINE_PROBE, withBaselineProbe(overrides));
|
|
986
983
|
const judgeAgainstBaseline = judge(baseline);
|
|
987
984
|
const file = path.join(root, WORKSPACE_FILE$3);
|
|
988
|
-
const problemOf = (located) => resolutionWith(workspace, located.key, withoutOverride(located.key)(
|
|
985
|
+
const problemOf = (located) => resolutionWith(workspace, located.key, withoutOverride(located.key)(overrides)).pipe(Effect.map((candidate) => overrideProblem({
|
|
989
986
|
...located,
|
|
990
987
|
file
|
|
991
988
|
})(judgeAgainstBaseline(located.key, candidate))));
|
|
@@ -996,19 +993,18 @@ const problemsFor = Effect.fn("problemsFor")(function* problemsFor(root, manifes
|
|
|
996
993
|
const checkOverrides = Effect.fn("checkOverrides")(function* checkOverrides(root) {
|
|
997
994
|
const fs = yield* FileSystem.FileSystem;
|
|
998
995
|
const path = yield* Path.Path;
|
|
999
|
-
const
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
return yield* problemsFor(root, manifest.value, keys);
|
|
996
|
+
const source = yield* fs.readFileString(path.join(root, WORKSPACE_FILE$3)).pipe(Effect.option);
|
|
997
|
+
const manifest = yield* workspaceManifest(root);
|
|
998
|
+
const overrides = pipe(manifest, Option.flatMap((found) => Option.fromUndefinedOr(found.overrides)), Option.getOrElse(() => ({})));
|
|
999
|
+
const keys = pipe(source, Option.map((text) => overrideKeysOf(text)(overrides)), Option.getOrElse(() => []));
|
|
1000
|
+
if (!Array.isReadonlyArrayNonEmpty(keys)) return [];
|
|
1001
|
+
return yield* problemsFor(root, overrides, keys);
|
|
1006
1002
|
});
|
|
1007
1003
|
// src/shared/lib/scanned-files.ts
|
|
1008
1004
|
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;
|
|
1009
1005
|
const LOCKFILE = /(?:^|\/)(?:[^/]*\.lock|[^/]*-lock\.(?:json|ya?ml))$/u;
|
|
1010
1006
|
const TOOL_VERSIONS = /(?:^|\/)(?:\.?mise(?:\.[^/]+)?\.toml|\.tool-versions)$/u;
|
|
1011
|
-
const READ_CONCURRENCY$
|
|
1007
|
+
const READ_CONCURRENCY$21 = 64;
|
|
1012
1008
|
const isScannedText = ({ name }) => SCANNED_FILE.test(name) && !LOCKFILE.test(name);
|
|
1013
1009
|
const isToolVersions = ({ name }) => TOOL_VERSIONS.test(name);
|
|
1014
1010
|
/** @internal */
|
|
@@ -1031,77 +1027,161 @@ const scanText = Effect.fn("scanText")(function* scanText(listed, problemsIn) {
|
|
|
1031
1027
|
const found = yield* Effect.forEach(listed, (entry) => files.readFile(entry.file).pipe(Effect.map(Option.match({
|
|
1032
1028
|
onNone: () => [],
|
|
1033
1029
|
onSome: (source) => problemsIn(entry, source)
|
|
1034
|
-
}))), { concurrency: READ_CONCURRENCY$
|
|
1030
|
+
}))), { concurrency: READ_CONCURRENCY$21 });
|
|
1035
1031
|
return Array.flatten(found);
|
|
1036
1032
|
});
|
|
1037
1033
|
// src/features/overrides/model/git-subpath.ts
|
|
1038
1034
|
const DEPENDENCY_FILE = /(?:^|\/)(?:package\.json|pnpm-workspace\.ya?ml)$/u;
|
|
1039
1035
|
const GIT_SUBPATH = /(?<![^\s"':])[^\s"'#]+#(?:[^\s"'&]*&)*path:[^\s"']*/gu;
|
|
1040
|
-
const RULE$
|
|
1036
|
+
const RULE$34 = "git-subpath-dependency";
|
|
1041
1037
|
const WHOLE_MATCH$3 = 0;
|
|
1042
|
-
const problemAt$
|
|
1038
|
+
const problemAt$7 = ({ file }, source) => (found) => ({
|
|
1043
1039
|
file,
|
|
1044
1040
|
...positionOf(source)(found.index ?? WHOLE_MATCH$3),
|
|
1045
|
-
rule: RULE$
|
|
1041
|
+
rule: RULE$34,
|
|
1046
1042
|
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])}\`.`
|
|
1047
1043
|
});
|
|
1048
|
-
const problemsIn$
|
|
1044
|
+
const problemsIn$14 = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(GIT_SUBPATH)(source)), Array.map(problemAt$7(entry, source)));
|
|
1049
1045
|
const isDependencyFile = ({ name }) => DEPENDENCY_FILE.test(name);
|
|
1050
1046
|
/** @internal */
|
|
1051
1047
|
const checkGitSubpath = Effect.fn("checkGitSubpath")(function* checkGitSubpath(root) {
|
|
1052
1048
|
const listed = yield* listedFiles(root);
|
|
1053
|
-
return yield* scanText(pipe(listed, Array.filter(isDependencyFile)), problemsIn$
|
|
1049
|
+
return yield* scanText(pipe(listed, Array.filter(isDependencyFile)), problemsIn$14);
|
|
1054
1050
|
});
|
|
1055
1051
|
// src/features/overrides/model/restricted-rules.ts
|
|
1056
|
-
const RULE$
|
|
1052
|
+
const RULE$33 = "unnamed-restriction";
|
|
1057
1053
|
const WHOLE_MATCH$2 = 0;
|
|
1058
1054
|
const UNNAMED = new RegExp(`(?:[\\w@-]+/)?no-restricted-(?:imports|properties)\\b`, "gu");
|
|
1059
|
-
const problemsIn$
|
|
1055
|
+
const problemsIn$13 = (entry, source) => pipe(Array.fromIterable(String$1.matchAll(UNNAMED)(source)), Array.map((found) => ({
|
|
1060
1056
|
file: entry.file,
|
|
1061
1057
|
...positionOf(source)(found.index ?? WHOLE_MATCH$2),
|
|
1062
|
-
rule: RULE$
|
|
1058
|
+
rule: RULE$33,
|
|
1063
1059
|
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.`
|
|
1064
1060
|
})));
|
|
1065
1061
|
/** @internal */
|
|
1066
1062
|
const checkRestrictedRules = Effect.fn("checkRestrictedRules")(function* checkRestrictedRules(root) {
|
|
1067
1063
|
const listed = yield* listedFiles(root);
|
|
1068
|
-
return yield* scanText(pipe(listed, Array.filter(isScannedText)), problemsIn$
|
|
1064
|
+
return yield* scanText(pipe(listed, Array.filter(isScannedText)), problemsIn$13);
|
|
1069
1065
|
});
|
|
1070
|
-
// src/
|
|
1071
|
-
const
|
|
1072
|
-
const
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
const
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1066
|
+
// src/features/placement/model/colocated-git-patterns.ts
|
|
1067
|
+
const RULE$32 = "colocated-git-patterns";
|
|
1068
|
+
const PATTERN_FILES = [":(glob)**/.gitignore", ":(glob)**/.gitattributes"];
|
|
1069
|
+
const ROOT$2 = ".";
|
|
1070
|
+
const SEPARATOR$17 = "/";
|
|
1071
|
+
const NEGATION$1 = "!";
|
|
1072
|
+
const COMMENT$1 = "#";
|
|
1073
|
+
const ANY_DEPTH = "**";
|
|
1074
|
+
const FLOATING_PREFIX = `${ANY_DEPTH}${SEPARATOR$17}`;
|
|
1075
|
+
const LEADING_SLASHES = /^\/+/u;
|
|
1076
|
+
const TRAILING_SLASHES = /\/+$/u;
|
|
1077
|
+
const SPACES = /\s+/u;
|
|
1078
|
+
const FIRST$18 = 1;
|
|
1079
|
+
const READ_CONCURRENCY$20 = 16;
|
|
1080
|
+
const isInside = (directory) => (inner) => inner !== directory && (directory === ROOT$2 || String$1.startsWith(`${directory}${SEPARATOR$17}`)(inner));
|
|
1081
|
+
const withoutPrefix = (prefix, text) => {
|
|
1082
|
+
if (String$1.startsWith(prefix)(text)) return String$1.slice(prefix.length)(text);
|
|
1083
|
+
return text;
|
|
1084
|
+
};
|
|
1085
|
+
const isAnchored = (pattern) => {
|
|
1086
|
+
const body = withoutPrefix(NEGATION$1, pattern);
|
|
1087
|
+
return pipe(body, String$1.replace(TRAILING_SLASHES, ""), String$1.includes(SEPARATOR$17));
|
|
1088
|
+
};
|
|
1089
|
+
const segmentsOf = ({ directory, pattern }) => {
|
|
1090
|
+
const body = withoutPrefix(NEGATION$1, pattern);
|
|
1091
|
+
const trimmed = pipe(body, String$1.replace(LEADING_SLASHES, ""), String$1.replace(TRAILING_SLASHES, ""));
|
|
1092
|
+
const own = String$1.split(SEPARATOR$17)(trimmed);
|
|
1093
|
+
if (directory === ROOT$2) return own;
|
|
1094
|
+
return [...String$1.split(SEPARATOR$17)(directory), ...own];
|
|
1095
|
+
};
|
|
1096
|
+
const depthOf = (directory) => String$1.split(SEPARATOR$17)(directory).length;
|
|
1097
|
+
const entryOf$1 = (file, kind, directory) => (line, index) => {
|
|
1098
|
+
const [pattern, ...values] = pipe(String$1.trim(line), String$1.split(SPACES));
|
|
1099
|
+
if (String$1.isEmpty(pattern) || String$1.startsWith(COMMENT$1)(pattern)) return Option.none();
|
|
1091
1100
|
return Option.some({
|
|
1092
1101
|
file,
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1102
|
+
kind,
|
|
1103
|
+
directory,
|
|
1104
|
+
line: index + FIRST$18,
|
|
1105
|
+
pattern,
|
|
1106
|
+
values: Array.join(values, " ")
|
|
1097
1107
|
});
|
|
1098
1108
|
};
|
|
1109
|
+
const entriesIn = Effect.fn("entriesIn")(function* entriesIn(root, file) {
|
|
1110
|
+
const files = yield* RepositoryFiles;
|
|
1111
|
+
const absolute = files.join(root, file);
|
|
1112
|
+
const text = yield* files.readFile(absolute);
|
|
1113
|
+
const toEntry = entryOf$1(absolute, files.basename(file), files.dirname(file));
|
|
1114
|
+
return pipe(Option.getOrElse(text, () => ""), String$1.split("\n"), Array.map(toEntry), Array.getSomes);
|
|
1115
|
+
});
|
|
1116
|
+
const problemAt$6 = (entry, message) => ({
|
|
1117
|
+
file: entry.file,
|
|
1118
|
+
line: entry.line,
|
|
1119
|
+
column: FIRST$18,
|
|
1120
|
+
rule: RULE$32,
|
|
1121
|
+
message
|
|
1122
|
+
});
|
|
1123
|
+
const misplacedMessage = (kind, workspaces) => {
|
|
1124
|
+
if (workspaces.length === FIRST$18) {
|
|
1125
|
+
const workspace = Array.join(workspaces, "");
|
|
1126
|
+
return `matches only paths inside the workspace ${workspace}. Move it to ${workspace}/${kind} and write it relative to that directory.`;
|
|
1127
|
+
}
|
|
1128
|
+
return `matches paths inside the workspaces ${Array.join(workspaces, ", ")}. Move it to the ${kind} of each workspace that needs it, or start it with **/ when it belongs to a tool any workspace can use.`;
|
|
1129
|
+
};
|
|
1130
|
+
const matchedAtDepth = Effect.fn("matchedAtDepth")(function* matchedAtDepth(root, segments, depth) {
|
|
1131
|
+
const files = yield* RepositoryFiles;
|
|
1132
|
+
const leading = Array.take(segments, depth);
|
|
1133
|
+
if (Array.contains(leading, ANY_DEPTH)) return [];
|
|
1134
|
+
const manifests = yield* files.matchingFiles(root, [`:(glob)${Array.join(leading, SEPARATOR$17)}${SEPARATOR$17}${MANIFEST_FILE$1}`]);
|
|
1135
|
+
return pipe(manifests, Array.map((manifest) => files.dirname(manifest)));
|
|
1136
|
+
});
|
|
1137
|
+
const deepestOf = (inner) => pipe(inner, Array.filter((workspace) => !pipe(inner, Array.some(isInside(workspace)))));
|
|
1138
|
+
const matchedWorkspaces = Effect.fn("matchedWorkspaces")(function* matchedWorkspaces(root, workspaces, entry) {
|
|
1139
|
+
const segments = segmentsOf(entry);
|
|
1140
|
+
const candidates = pipe(workspaces, Array.filter(isInside(entry.directory)), Array.filter((workspace) => depthOf(workspace) < segments.length));
|
|
1141
|
+
const depths = pipe(candidates, Array.map(depthOf), Array.dedupe);
|
|
1142
|
+
const matched = yield* Effect.forEach(depths, (depth) => matchedAtDepth(root, segments, depth), { concurrency: 1 });
|
|
1143
|
+
const flat = Array.flatten(matched);
|
|
1144
|
+
return pipe(candidates, Array.filter((workspace) => Array.contains(flat, workspace)), deepestOf);
|
|
1145
|
+
});
|
|
1146
|
+
const misplaced = Effect.fn("misplaced")(function* misplaced(root, workspaces, entry) {
|
|
1147
|
+
if (!isAnchored(entry.pattern)) return Option.none();
|
|
1148
|
+
const deepest = yield* matchedWorkspaces(root, workspaces, entry);
|
|
1149
|
+
if (Array.isReadonlyArrayEmpty(deepest)) return Option.none();
|
|
1150
|
+
return Option.some(problemAt$6(entry, misplacedMessage(entry.kind, deepest)));
|
|
1151
|
+
});
|
|
1152
|
+
const isFloating = (pattern) => !String$1.startsWith(NEGATION$1)(pattern) && (!isAnchored(pattern) || String$1.startsWith(FLOATING_PREFIX)(pattern));
|
|
1153
|
+
const ownLevelName = (pattern) => {
|
|
1154
|
+
if (isFloating(pattern)) return Option.some(pattern);
|
|
1155
|
+
const name = withoutPrefix(SEPARATOR$17, pattern);
|
|
1156
|
+
return Option.liftPredicate(name, (own) => isFloating(own) && !isAnchored(own));
|
|
1157
|
+
};
|
|
1158
|
+
const sameName = (outer, name) => {
|
|
1159
|
+
if (outer === name) return true;
|
|
1160
|
+
return String$1.endsWith(SEPARATOR$17)(name) && `${outer}${SEPARATOR$17}` === name;
|
|
1161
|
+
};
|
|
1162
|
+
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);
|
|
1163
|
+
const outerName = ({ directory, kind }) => {
|
|
1164
|
+
if (directory === ROOT$2) return `the root ${kind}`;
|
|
1165
|
+
return `${directory}/${kind}`;
|
|
1166
|
+
};
|
|
1167
|
+
const repeated = (entries) => (entry) => {
|
|
1168
|
+
const outer = pipe(ownLevelName(entry.pattern), Option.flatMap((name) => pipe(entries, Array.findFirst(coveredBy(entry, name)))));
|
|
1169
|
+
return pipe(outer, Option.map((found) => problemAt$6(entry, `repeats ${found.pattern} from ${outerName(found)}, which already applies here. Delete it.`)));
|
|
1170
|
+
};
|
|
1099
1171
|
/** @internal */
|
|
1100
|
-
const
|
|
1172
|
+
const checkColocatedGitPatterns = Effect.fn("checkColocatedGitPatterns")(function* checkColocatedGitPatterns(root) {
|
|
1173
|
+
const patternFiles = yield* (yield* RepositoryFiles).matchingFiles(root, PATTERN_FILES);
|
|
1174
|
+
const read = yield* Effect.forEach(patternFiles, (file) => entriesIn(root, file), { concurrency: READ_CONCURRENCY$20 });
|
|
1175
|
+
const entries = Array.flatten(read);
|
|
1176
|
+
const workspaces = yield* workspaceDirectories(root);
|
|
1177
|
+
const misplacedFound = yield* Effect.forEach(entries, (entry) => misplaced(root, workspaces, entry), { concurrency: READ_CONCURRENCY$20 });
|
|
1178
|
+
const repeatedFound = pipe(entries, Array.map(repeated(entries)));
|
|
1179
|
+
return Array.getSomes([...misplacedFound, ...repeatedFound]);
|
|
1180
|
+
});
|
|
1101
1181
|
// src/features/placement/model/colocated-tests.ts
|
|
1102
|
-
const RULE$
|
|
1103
|
-
const FIRST$
|
|
1104
|
-
const READ_CONCURRENCY$
|
|
1182
|
+
const RULE$31 = "colocated-test";
|
|
1183
|
+
const FIRST$17 = 1;
|
|
1184
|
+
const READ_CONCURRENCY$19 = 64;
|
|
1105
1185
|
const ROOT_SUBPATH = ".";
|
|
1106
1186
|
const NAME_GROUP = "name";
|
|
1107
1187
|
const SPECIFIER_GROUP = "specifier";
|
|
@@ -1123,11 +1203,11 @@ const Manifest$3 = Schema.Struct({
|
|
|
1123
1203
|
});
|
|
1124
1204
|
const decodeManifest$4 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$3));
|
|
1125
1205
|
const byLength$1 = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
1126
|
-
const problemFor$
|
|
1206
|
+
const problemFor$5 = (test, message) => ({
|
|
1127
1207
|
file: test.file,
|
|
1128
|
-
line: FIRST$
|
|
1129
|
-
column: FIRST$
|
|
1130
|
-
rule: RULE$
|
|
1208
|
+
line: FIRST$17,
|
|
1209
|
+
column: FIRST$17,
|
|
1210
|
+
rule: RULE$31,
|
|
1131
1211
|
message: `${test.base} ${message}`
|
|
1132
1212
|
});
|
|
1133
1213
|
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);
|
|
@@ -1145,7 +1225,7 @@ const ownSpecifiers = Effect.fn("ownSpecifiers")(function* ownSpecifiers(context
|
|
|
1145
1225
|
const files = yield* RepositoryFiles;
|
|
1146
1226
|
const owner = ownerOf$3(context.packages, test.name);
|
|
1147
1227
|
if (Option.isNone(owner)) return [];
|
|
1148
|
-
const text = yield* files.readFile(files.join(context.root, owner.value, MANIFEST_FILE));
|
|
1228
|
+
const text = yield* files.readFile(files.join(context.root, owner.value, MANIFEST_FILE$1));
|
|
1149
1229
|
const join = (target) => files.join(context.root, owner.value, target);
|
|
1150
1230
|
return pipe(text, Option.flatMap(decodeManifest$4), Option.map(specifiersBeside({
|
|
1151
1231
|
join,
|
|
@@ -1167,10 +1247,10 @@ const refersIn = Effect.fn("refersIn")(function* refersIn(context, test) {
|
|
|
1167
1247
|
});
|
|
1168
1248
|
const inSeparateTestDirectory = (name) => SEPARATE_TEST_DIRECTORY.test(name) || SPEC_DIRECTORY.test(name) && SPEC_FILE.test(name);
|
|
1169
1249
|
const problemIn$5 = Effect.fn("problemIn")(function* problemIn(context, test) {
|
|
1170
|
-
if (inSeparateTestDirectory(test.name)) return Option.some(problemFor$
|
|
1250
|
+
if (inSeparateTestDirectory(test.name)) return Option.some(problemFor$5(test, DIRECTORY_MESSAGE));
|
|
1171
1251
|
if (!TEST_FILE$1.test(test.name)) return Option.none();
|
|
1172
1252
|
if (yield* refersIn(context, test)) return Option.none();
|
|
1173
|
-
return Option.some(problemFor$
|
|
1253
|
+
return Option.some(problemFor$5(test, SIBLING_MESSAGE));
|
|
1174
1254
|
});
|
|
1175
1255
|
/** @internal */
|
|
1176
1256
|
const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColocatedTests(root) {
|
|
@@ -1179,7 +1259,7 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
|
|
|
1179
1259
|
const names = pipe(listed, Array.filter(String$1.isNonEmpty));
|
|
1180
1260
|
const context = {
|
|
1181
1261
|
root,
|
|
1182
|
-
packages: pipe(names, Array.filter((name) => files.basename(name) === MANIFEST_FILE), Array.map(String$1.replace(MANIFEST_NAME, "")))
|
|
1262
|
+
packages: pipe(names, Array.filter((name) => files.basename(name) === MANIFEST_FILE$1), Array.map(String$1.replace(MANIFEST_NAME, "")))
|
|
1183
1263
|
};
|
|
1184
1264
|
const tests = pipe(names, Array.filter((name) => SCRIPT$2.test(name)), Array.map((name) => {
|
|
1185
1265
|
const file = files.join(root, name);
|
|
@@ -1190,13 +1270,44 @@ const checkColocatedTests = Effect.fn("checkColocatedTests")(function* checkColo
|
|
|
1190
1270
|
directory: files.dirname(file)
|
|
1191
1271
|
};
|
|
1192
1272
|
}));
|
|
1193
|
-
const found = yield* Effect.forEach(tests, (test) => problemIn$5(context, test), { concurrency: READ_CONCURRENCY$
|
|
1273
|
+
const found = yield* Effect.forEach(tests, (test) => problemIn$5(context, test), { concurrency: READ_CONCURRENCY$19 });
|
|
1194
1274
|
return Array.getSomes(found);
|
|
1195
1275
|
});
|
|
1276
|
+
// src/shared/lib/agent-docs.ts
|
|
1277
|
+
const AGENT_DOC = /(?:^|\/)(?:AGENTS|CLAUDE)\.md$/u;
|
|
1278
|
+
const READ_CONCURRENCY$18 = 16;
|
|
1279
|
+
const agentDocProblems = Effect.fn("agentDocProblems")(function* agentDocProblems(root, problemIn) {
|
|
1280
|
+
const files = yield* RepositoryFiles;
|
|
1281
|
+
const listed = yield* files.listedFiles(root);
|
|
1282
|
+
const docs = pipe(listed, Array.filter((name) => AGENT_DOC.test(name)));
|
|
1283
|
+
const found = yield* Effect.forEach(docs, (name) => {
|
|
1284
|
+
const file = files.join(root, name);
|
|
1285
|
+
const problemOf = Option.flatMap(problemIn(file));
|
|
1286
|
+
return files.readFile(file).pipe(Effect.map(problemOf));
|
|
1287
|
+
}, { concurrency: READ_CONCURRENCY$18 });
|
|
1288
|
+
return Array.getSomes(found);
|
|
1289
|
+
});
|
|
1290
|
+
// src/features/placement/model/agent-docs-length.ts
|
|
1291
|
+
const RECOMMENDED_LINES = 200;
|
|
1292
|
+
const FIRST$16 = 1;
|
|
1293
|
+
const RULE$30 = "agent-docs-length";
|
|
1294
|
+
const lineCount = (source) => pipe(String$1.trimEnd(source), String$1.split("\n")).length;
|
|
1295
|
+
const problemFor$4 = (file) => (lines) => {
|
|
1296
|
+
if (lines <= RECOMMENDED_LINES) return Option.none();
|
|
1297
|
+
return Option.some({
|
|
1298
|
+
file,
|
|
1299
|
+
line: 201,
|
|
1300
|
+
column: FIRST$16,
|
|
1301
|
+
rule: RULE$30,
|
|
1302
|
+
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.`
|
|
1303
|
+
});
|
|
1304
|
+
};
|
|
1305
|
+
/** @internal */
|
|
1306
|
+
const checkAgentDocsLength = (root) => agentDocProblems(root, (file) => (source) => problemFor$4(file)(lineCount(source)));
|
|
1196
1307
|
// src/features/placement/model/dangling-links.ts
|
|
1197
|
-
const RULE$
|
|
1308
|
+
const RULE$29 = "dangling-link";
|
|
1198
1309
|
const SEPARATOR$16 = "/";
|
|
1199
|
-
const FIRST$
|
|
1310
|
+
const FIRST$15 = 1;
|
|
1200
1311
|
const READ_CONCURRENCY$17 = 16;
|
|
1201
1312
|
const holds = (target) => (name) => name === target || String$1.startsWith(`${target}${SEPARATOR$16}`)(name);
|
|
1202
1313
|
/** @internal */
|
|
@@ -1208,99 +1319,20 @@ const checkDanglingLinks = Effect.fn("checkDanglingLinks")(function* checkDangli
|
|
|
1208
1319
|
const link = yield* files.readLink(file);
|
|
1209
1320
|
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) => ({
|
|
1210
1321
|
file,
|
|
1211
|
-
line: FIRST$
|
|
1212
|
-
column: FIRST$
|
|
1213
|
-
rule: RULE$
|
|
1322
|
+
line: FIRST$15,
|
|
1323
|
+
column: FIRST$15,
|
|
1324
|
+
rule: RULE$29,
|
|
1214
1325
|
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.`
|
|
1215
1326
|
})));
|
|
1216
1327
|
});
|
|
1217
1328
|
const found = yield* Effect.forEach(links, problemOf, { concurrency: READ_CONCURRENCY$17 });
|
|
1218
1329
|
return Array.getSomes(found);
|
|
1219
1330
|
});
|
|
1220
|
-
// src/features/placement/model/member-sources.ts
|
|
1221
|
-
const ROOT_WORKSPACE$1 = ".";
|
|
1222
|
-
const EXCLUDED$2 = [
|
|
1223
|
-
":(exclude,attr:linguist-vendored)",
|
|
1224
|
-
":(exclude,attr:linguist-generated)",
|
|
1225
|
-
":(exclude,attr:linguist-documentation)"
|
|
1226
|
-
];
|
|
1227
|
-
const memberWorkspaces = Effect.fn("memberWorkspaces")(function* memberWorkspaces(root) {
|
|
1228
|
-
const declared = yield* workspaceDirectories(root);
|
|
1229
|
-
return pipe(declared, Array.filter((workspace) => workspace !== ROOT_WORKSPACE$1));
|
|
1230
|
-
});
|
|
1231
|
-
const memberSources = Effect.fn("memberSources")(function* memberSources(root) {
|
|
1232
|
-
const files = yield* RepositoryFiles;
|
|
1233
|
-
return {
|
|
1234
|
-
workspaces: yield* memberWorkspaces(root),
|
|
1235
|
-
listed: yield* files.matchingFiles(root, EXCLUDED$2)
|
|
1236
|
-
};
|
|
1237
|
-
});
|
|
1238
|
-
// src/features/placement/model/layered-source.ts
|
|
1239
|
-
const LAYERED_RULE = "layered-source";
|
|
1240
|
-
const ENTRY_RULE = "public-entry";
|
|
1241
|
-
const FIRST$12 = 1;
|
|
1242
|
-
const SOURCE_DIRECTORY = "src";
|
|
1243
|
-
const SEPARATOR$15 = "/";
|
|
1244
|
-
const LOOSE_DEPTH = 2;
|
|
1245
|
-
const LAYERS = [
|
|
1246
|
-
"app",
|
|
1247
|
-
"pages",
|
|
1248
|
-
"widgets",
|
|
1249
|
-
"features",
|
|
1250
|
-
"entities",
|
|
1251
|
-
"shared"
|
|
1252
|
-
];
|
|
1253
|
-
const SCRIPT$1 = /\.[cm]?[jt]sx?$/u;
|
|
1254
|
-
const ROOT_ALLOWED = /^(?:[^/]+\.config\.[cm]?[jt]s|alchemy\.[^/]+\.ts|[^/]+\.d\.[cm]?ts|bin\/.+)$/u;
|
|
1255
|
-
const PUBLIC_ENTRY = /^(?:bin\/[^/]+|src\/(?:app\/[^/]+|(?:pages|widgets|features|entities)\/[^/]+\/index(?:\.[a-z]+)*\.tsx?|shared\/[^/]+\/index(?:\.[a-z]+)*\.tsx?|shared\/(?:ui|lib)\/.+))$/u;
|
|
1256
|
-
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.";
|
|
1257
|
-
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.";
|
|
1258
|
-
const LAYER_MESSAGE = `is not an FSD layer. src/ holds only ${Array.join(LAYERS, ", ")}.`;
|
|
1259
|
-
const ENTRY_MESSAGE = "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.";
|
|
1260
|
-
const decodeEntryManifest = Schema.decodeUnknownOption(EntryManifestJson);
|
|
1261
|
-
const byLength = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
1262
|
-
const problemAt$4 = (file, rule, message) => ({
|
|
1263
|
-
file,
|
|
1264
|
-
line: FIRST$12,
|
|
1265
|
-
column: FIRST$12,
|
|
1266
|
-
rule,
|
|
1267
|
-
message
|
|
1268
|
-
});
|
|
1269
|
-
const ownerOf$2 = (workspaces) => (name) => pipe(workspaces, Array.filter((workspace) => String$1.startsWith(`${workspace}${SEPARATOR$15}`)(name)), (owners) => Array.last(Array.sort(owners, byLength)), Option.map((workspace) => ({
|
|
1270
|
-
workspace,
|
|
1271
|
-
inner: String$1.slice(workspace.length + 1)(name)
|
|
1272
|
-
})));
|
|
1273
|
-
const layerProblemOf = (owned) => {
|
|
1274
|
-
const parts = String$1.split(owned.inner, SEPARATOR$15);
|
|
1275
|
-
const [top, layer] = parts;
|
|
1276
|
-
if (top !== SOURCE_DIRECTORY) return Option.liftPredicate([`${owned.workspace}${SEPARATOR$15}${owned.inner}`, OUTSIDE_MESSAGE], () => !ROOT_ALLOWED.test(owned.inner));
|
|
1277
|
-
if (parts.length === LOOSE_DEPTH) return Option.some([`${owned.workspace}${SEPARATOR$15}${owned.inner}`, LOOSE_MESSAGE]);
|
|
1278
|
-
return Option.liftPredicate([`${owned.workspace}${SEPARATOR$15}${SOURCE_DIRECTORY}${SEPARATOR$15}${layer}`, LAYER_MESSAGE], () => !pipe(LAYERS, Array.contains(layer ?? "")));
|
|
1279
|
-
};
|
|
1280
|
-
const entryProblems = Effect.fn("entryProblems")(function* entryProblems(root, workspace) {
|
|
1281
|
-
const files = yield* RepositoryFiles;
|
|
1282
|
-
const directory = files.join(root, workspace);
|
|
1283
|
-
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));
|
|
1284
|
-
const join = (target) => files.join(directory, target);
|
|
1285
|
-
return pipe(text, Option.flatMap(decodeEntryManifest), Option.map((manifest) => publicEntriesOf({
|
|
1286
|
-
manifest,
|
|
1287
|
-
join,
|
|
1288
|
-
packEntries: []
|
|
1289
|
-
})), Option.getOrElse(() => []), Array.filter(({ source }) => !PUBLIC_ENTRY.test(files.relative(directory, source))), Array.map(({ label, source }) => problemAt$4(source, ENTRY_RULE, `${label} ${ENTRY_MESSAGE}`)));
|
|
1290
|
-
});
|
|
1291
|
-
/** @internal */
|
|
1292
|
-
const checkLayeredSource = Effect.fn("checkLayeredSource")(function* checkLayeredSource(root) {
|
|
1293
|
-
const files = yield* RepositoryFiles;
|
|
1294
|
-
const { workspaces, listed } = yield* memberSources(root);
|
|
1295
|
-
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]) => problemAt$4(files.join(root, file), LAYERED_RULE, message)));
|
|
1296
|
-
const entries = yield* pipe(workspaces, Effect.forEach((workspace) => entryProblems(root, workspace)));
|
|
1297
|
-
return [...layered, ...Array.flatten(entries)];
|
|
1298
|
-
});
|
|
1299
1331
|
// src/features/placement/model/nested-docs.ts
|
|
1300
|
-
const RULE$
|
|
1332
|
+
const RULE$28 = "nested-docs";
|
|
1301
1333
|
const CONFIG_FILE$4 = "vite.config.ts";
|
|
1302
|
-
const SEPARATOR$
|
|
1303
|
-
const FIRST$
|
|
1334
|
+
const SEPARATOR$15 = "/";
|
|
1335
|
+
const FIRST$14 = 1;
|
|
1304
1336
|
const READ_CONCURRENCY$16 = 64;
|
|
1305
1337
|
const AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\.[^/]+)?\.md$/iu;
|
|
1306
1338
|
const WORKSPACE_AGENT_DOC = "AGENTS.md";
|
|
@@ -1308,12 +1340,12 @@ const README = /^README(?:\.[^/]+)?$/iu;
|
|
|
1308
1340
|
const RootConfig$1 = Schema.Struct({ msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }) });
|
|
1309
1341
|
const taggedError$3 = Schema.TaggedError;
|
|
1310
1342
|
var RootConfigUnreadable = class extends taggedError$3()("RootConfigUnreadable", { file: Schema.String }) {};
|
|
1311
|
-
const isNested = (name) => String$1.includes(SEPARATOR$
|
|
1343
|
+
const isNested = (name) => String$1.includes(SEPARATOR$15)(name);
|
|
1312
1344
|
const problemFor$3 = (file, message) => ({
|
|
1313
1345
|
file,
|
|
1314
|
-
line: FIRST$
|
|
1315
|
-
column: FIRST$
|
|
1316
|
-
rule: RULE$
|
|
1346
|
+
line: FIRST$14,
|
|
1347
|
+
column: FIRST$14,
|
|
1348
|
+
rule: RULE$28,
|
|
1317
1349
|
message
|
|
1318
1350
|
});
|
|
1319
1351
|
const AGENT_DOCS_MESSAGE = "belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.";
|
|
@@ -1355,42 +1387,43 @@ const checkNestedDocs = Effect.fn("checkNestedDocs")(function* checkNestedDocs(r
|
|
|
1355
1387
|
const names = yield* files.listedFiles(root);
|
|
1356
1388
|
const nested = pipe(names, Array.filter(isNested));
|
|
1357
1389
|
const workspaceAgentDocs = yield* allowsWorkspaceAgentDocs(root);
|
|
1390
|
+
const directories = yield* workspaceDirectories(root);
|
|
1358
1391
|
const allowed = {
|
|
1359
|
-
workspaces: pipe(
|
|
1392
|
+
workspaces: pipe(directories, Array.map((directory) => files.join(root, directory)), HashSet.fromIterable),
|
|
1360
1393
|
workspaceAgentDocs
|
|
1361
1394
|
};
|
|
1362
1395
|
const found = yield* Effect.forEach(nested, (name) => problemIn$4(root, allowed, name), { concurrency: READ_CONCURRENCY$16 });
|
|
1363
1396
|
return Array.getSomes(found);
|
|
1364
1397
|
});
|
|
1365
1398
|
// src/features/placement/model/root-docs.ts
|
|
1366
|
-
const RULE$
|
|
1367
|
-
const SEPARATOR$
|
|
1368
|
-
const FIRST$
|
|
1399
|
+
const RULE$27 = "root-docs";
|
|
1400
|
+
const SEPARATOR$14 = "/";
|
|
1401
|
+
const FIRST$13 = 1;
|
|
1369
1402
|
const MARKDOWN$1 = /\.(?:md|mdx|markdown)$/iu;
|
|
1370
1403
|
const ALLOWED = /^(?:README(?:\.[^/]+)?|AGENTS|CLAUDE|ARCHITECTURE|DESIGN|CHANGELOG|LICENSE|NOTICE)\.(?:md|mdx|markdown)$/iu;
|
|
1371
|
-
const MESSAGE$
|
|
1372
|
-
const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$
|
|
1404
|
+
const MESSAGE$8 = "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.";
|
|
1405
|
+
const isStrayRootDoc = (name) => !String$1.includes(SEPARATOR$14)(name) && MARKDOWN$1.test(name) && !ALLOWED.test(name);
|
|
1373
1406
|
/** @internal */
|
|
1374
1407
|
const checkRootDocs = Effect.fn("checkRootDocs")(function* checkRootDocs(root) {
|
|
1375
1408
|
const files = yield* RepositoryFiles;
|
|
1376
1409
|
const names = yield* files.listedFiles(root);
|
|
1377
1410
|
return pipe(names, Array.filter(isStrayRootDoc), Array.map((name) => ({
|
|
1378
1411
|
file: files.join(root, name),
|
|
1379
|
-
line: FIRST$
|
|
1380
|
-
column: FIRST$
|
|
1381
|
-
rule: RULE$
|
|
1382
|
-
message: `${name} ${MESSAGE$
|
|
1412
|
+
line: FIRST$13,
|
|
1413
|
+
column: FIRST$13,
|
|
1414
|
+
rule: RULE$27,
|
|
1415
|
+
message: `${name} ${MESSAGE$8}`
|
|
1383
1416
|
})));
|
|
1384
1417
|
});
|
|
1385
1418
|
// src/features/placement/model/root-readme.ts
|
|
1386
|
-
const RULE$
|
|
1419
|
+
const RULE$26 = "root-readme";
|
|
1387
1420
|
const ROOT_DOC = /^(?:README(?:\.[^/]+)?|AGENTS\.md|CLAUDE\.md)$/iu;
|
|
1388
1421
|
const READ_CONCURRENCY$15 = 16;
|
|
1389
1422
|
const START$12 = 0;
|
|
1390
1423
|
const CHECK_POLICY = "@r_masseater/msch";
|
|
1391
1424
|
const MARKETPLACE = ".claude-plugin/marketplace.json";
|
|
1392
1425
|
const RELATIVE = /^\.\//u;
|
|
1393
|
-
const SEPARATOR$
|
|
1426
|
+
const SEPARATOR$13 = "/";
|
|
1394
1427
|
const MarketplacePlugin = Schema.Struct({
|
|
1395
1428
|
name: Schema.optional(Schema.String),
|
|
1396
1429
|
source: Schema.Unknown
|
|
@@ -1402,7 +1435,7 @@ const NO_PLUGINS = {
|
|
|
1402
1435
|
};
|
|
1403
1436
|
const isCheckPolicy = ({ packageName }) => Option.contains(packageName, CHECK_POLICY);
|
|
1404
1437
|
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.`;
|
|
1405
|
-
const lastSegment = (directory) => pipe(String$1.split(SEPARATOR$
|
|
1438
|
+
const lastSegment = (directory) => pipe(String$1.split(SEPARATOR$13)(directory), Array.last, Option.getOrElse(() => directory));
|
|
1406
1439
|
const pluginsOf = (plugins) => {
|
|
1407
1440
|
const directories = pipe(plugins, Array.map(({ source }) => source), Array.filter(Predicate.isString), Array.map(String$1.replace(RELATIVE, "")));
|
|
1408
1441
|
const segments = pipe(directories, Array.map(lastSegment));
|
|
@@ -1425,14 +1458,14 @@ const patternFor = (plugins) => ({ directory, names }) => patternOf(Option.match
|
|
|
1425
1458
|
onNone: () => ownNames(plugins, names),
|
|
1426
1459
|
onSome: () => [directory]
|
|
1427
1460
|
}));
|
|
1428
|
-
const problemsIn$
|
|
1461
|
+
const problemsIn$12 = (file, source, plugins) => (workspace) => {
|
|
1429
1462
|
const message = messageFor(workspace.directory);
|
|
1430
1463
|
const at = positionOf(source);
|
|
1431
1464
|
const pattern = patternFor(plugins)(workspace);
|
|
1432
1465
|
return pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.map((found) => ({
|
|
1433
1466
|
file,
|
|
1434
1467
|
...at(found.index ?? START$12),
|
|
1435
|
-
rule: RULE$
|
|
1468
|
+
rule: RULE$26,
|
|
1436
1469
|
message
|
|
1437
1470
|
})));
|
|
1438
1471
|
};
|
|
@@ -1440,7 +1473,7 @@ const problemsInReadme = Effect.fn("problemsInReadme")(function* problemsInReadm
|
|
|
1440
1473
|
const text = yield* (yield* RepositoryFiles).readFile(file);
|
|
1441
1474
|
return pipe(text, Option.match({
|
|
1442
1475
|
onNone: () => [],
|
|
1443
|
-
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$
|
|
1476
|
+
onSome: (source) => pipe(workspaces, Array.flatMap(problemsIn$12(file, source, plugins)))
|
|
1444
1477
|
}));
|
|
1445
1478
|
});
|
|
1446
1479
|
/** @internal */
|
|
@@ -1454,19 +1487,127 @@ const checkRootReadme = Effect.fn("checkRootReadme")(function* checkRootReadme(r
|
|
|
1454
1487
|
const found = yield* Effect.forEach(readmes, (name) => problemsInReadme(files.join(root, name), workspaces, plugins), { concurrency: READ_CONCURRENCY$15 });
|
|
1455
1488
|
return Array.flatten(found);
|
|
1456
1489
|
});
|
|
1490
|
+
// src/features/placement/model/doc-placement.ts
|
|
1491
|
+
/** @internal */
|
|
1492
|
+
const checkDocPlacement = Effect.fn("checkDocPlacement")(function* checkDocPlacement(root) {
|
|
1493
|
+
const found = yield* Effect.all([
|
|
1494
|
+
checkNestedDocs(root),
|
|
1495
|
+
checkRootReadme(root),
|
|
1496
|
+
checkRootDocs(root),
|
|
1497
|
+
checkAgentDocsLength(root),
|
|
1498
|
+
checkDanglingLinks(root)
|
|
1499
|
+
], { concurrency: "unbounded" });
|
|
1500
|
+
return Array.flatten(found);
|
|
1501
|
+
});
|
|
1502
|
+
// src/features/placement/model/ignored-sources.ts
|
|
1503
|
+
const RULE$25 = "ignored-sources";
|
|
1504
|
+
const SOURCES = [":(glob)**/src/**", ":(exclude,glob)**/node_modules/**"];
|
|
1505
|
+
const FIRST$12 = 1;
|
|
1506
|
+
const MESSAGE$7 = "is under src/ but .gitignore ignores it, so verify passes here while the file never reaches the commit. Narrow the pattern in .gitignore.";
|
|
1507
|
+
/** @internal */
|
|
1508
|
+
const checkIgnoredSources = Effect.fn("checkIgnoredSources")(function* checkIgnoredSources(root) {
|
|
1509
|
+
const files = yield* RepositoryFiles;
|
|
1510
|
+
const ignored = yield* files.ignoredFiles(root, SOURCES);
|
|
1511
|
+
return pipe(ignored, Array.map((file) => ({
|
|
1512
|
+
file: files.join(root, file),
|
|
1513
|
+
line: FIRST$12,
|
|
1514
|
+
column: FIRST$12,
|
|
1515
|
+
rule: RULE$25,
|
|
1516
|
+
message: MESSAGE$7
|
|
1517
|
+
})));
|
|
1518
|
+
});
|
|
1519
|
+
// src/features/placement/model/member-sources.ts
|
|
1520
|
+
const ROOT_WORKSPACE$1 = ".";
|
|
1521
|
+
const EXCLUDED$2 = [
|
|
1522
|
+
":(exclude,attr:linguist-vendored)",
|
|
1523
|
+
":(exclude,attr:linguist-generated)",
|
|
1524
|
+
":(exclude,attr:linguist-documentation)"
|
|
1525
|
+
];
|
|
1526
|
+
const memberWorkspaces = Effect.fn("memberWorkspaces")(function* memberWorkspaces(root) {
|
|
1527
|
+
const declared = yield* workspaceDirectories(root);
|
|
1528
|
+
return pipe(declared, Array.filter((workspace) => workspace !== ROOT_WORKSPACE$1));
|
|
1529
|
+
});
|
|
1530
|
+
const memberSources = Effect.fn("memberSources")(function* memberSources(root) {
|
|
1531
|
+
const files = yield* RepositoryFiles;
|
|
1532
|
+
return {
|
|
1533
|
+
workspaces: yield* memberWorkspaces(root),
|
|
1534
|
+
listed: yield* files.matchingFiles(root, EXCLUDED$2)
|
|
1535
|
+
};
|
|
1536
|
+
});
|
|
1537
|
+
// src/features/placement/model/layered-source.ts
|
|
1538
|
+
const LAYERED_RULE = "layered-source";
|
|
1539
|
+
const ENTRY_RULE = "public-entry";
|
|
1540
|
+
const FIRST$11 = 1;
|
|
1541
|
+
const SOURCE_DIRECTORY = "src";
|
|
1542
|
+
const SEPARATOR$12 = "/";
|
|
1543
|
+
const LOOSE_DEPTH = 2;
|
|
1544
|
+
const LAYERS = [
|
|
1545
|
+
"app",
|
|
1546
|
+
"pages",
|
|
1547
|
+
"widgets",
|
|
1548
|
+
"features",
|
|
1549
|
+
"entities",
|
|
1550
|
+
"shared"
|
|
1551
|
+
];
|
|
1552
|
+
const SCRIPT$1 = /\.[cm]?[jt]sx?$/u;
|
|
1553
|
+
const ROOT_ALLOWED = /^(?:[^/]+\.config\.[cm]?[jt]s|alchemy\.[^/]+\.ts|[^/]+\.d\.[cm]?ts|bin\/.+)$/u;
|
|
1554
|
+
const PUBLIC_ENTRY = /^(?:bin\/[^/]+|src\/(?:app\/[^/]+|(?:pages|widgets|features|entities)\/[^/]+\/index(?:\.[a-z]+)*\.tsx?|shared\/[^/]+\/index(?:\.[a-z]+)*\.tsx?|shared\/(?:ui|lib)\/.+))$/u;
|
|
1555
|
+
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.";
|
|
1556
|
+
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.";
|
|
1557
|
+
const LAYER_MESSAGE = `is not an FSD layer. src/ holds only ${Array.join(LAYERS, ", ")}.`;
|
|
1558
|
+
const ENTRY_MESSAGE = "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.";
|
|
1559
|
+
const decodeEntryManifest = Schema.decodeUnknownOption(EntryManifestJson);
|
|
1560
|
+
const byLength = Order.mapInput(Order.Number, (directory) => directory.length);
|
|
1561
|
+
const problemAt$5 = (file, rule, message) => ({
|
|
1562
|
+
file,
|
|
1563
|
+
line: FIRST$11,
|
|
1564
|
+
column: FIRST$11,
|
|
1565
|
+
rule,
|
|
1566
|
+
message
|
|
1567
|
+
});
|
|
1568
|
+
const ownerOf$2 = (workspaces) => (name) => pipe(workspaces, Array.filter((workspace) => String$1.startsWith(`${workspace}${SEPARATOR$12}`)(name)), (owners) => Array.last(Array.sort(owners, byLength)), Option.map((workspace) => ({
|
|
1569
|
+
workspace,
|
|
1570
|
+
inner: String$1.slice(workspace.length + 1)(name)
|
|
1571
|
+
})));
|
|
1572
|
+
const layerProblemOf = (owned) => {
|
|
1573
|
+
const parts = String$1.split(owned.inner, SEPARATOR$12);
|
|
1574
|
+
const [top, layer] = parts;
|
|
1575
|
+
if (top !== SOURCE_DIRECTORY) return Option.liftPredicate([`${owned.workspace}${SEPARATOR$12}${owned.inner}`, OUTSIDE_MESSAGE], () => !ROOT_ALLOWED.test(owned.inner));
|
|
1576
|
+
if (parts.length === LOOSE_DEPTH) return Option.some([`${owned.workspace}${SEPARATOR$12}${owned.inner}`, LOOSE_MESSAGE]);
|
|
1577
|
+
return Option.liftPredicate([`${owned.workspace}${SEPARATOR$12}${SOURCE_DIRECTORY}${SEPARATOR$12}${layer}`, LAYER_MESSAGE], () => !pipe(LAYERS, Array.contains(layer ?? "")));
|
|
1578
|
+
};
|
|
1579
|
+
const entryProblems = Effect.fn("entryProblems")(function* entryProblems(root, workspace) {
|
|
1580
|
+
const files = yield* RepositoryFiles;
|
|
1581
|
+
const directory = files.join(root, workspace);
|
|
1582
|
+
const text = yield* files.readFile(files.join(directory, MANIFEST_FILE$1));
|
|
1583
|
+
const join = (target) => files.join(directory, target);
|
|
1584
|
+
return pipe(text, Option.flatMap(decodeEntryManifest), Option.map((manifest) => publicEntriesOf({
|
|
1585
|
+
manifest,
|
|
1586
|
+
join,
|
|
1587
|
+
packEntries: []
|
|
1588
|
+
})), Option.getOrElse(() => []), Array.filter(({ source }) => !PUBLIC_ENTRY.test(files.relative(directory, source))), Array.map(({ label, source }) => problemAt$5(source, ENTRY_RULE, `${label} ${ENTRY_MESSAGE}`)));
|
|
1589
|
+
});
|
|
1590
|
+
/** @internal */
|
|
1591
|
+
const checkLayeredSource = Effect.fn("checkLayeredSource")(function* checkLayeredSource(root) {
|
|
1592
|
+
const files = yield* RepositoryFiles;
|
|
1593
|
+
const { workspaces, listed } = yield* memberSources(root);
|
|
1594
|
+
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]) => problemAt$5(files.join(root, file), LAYERED_RULE, message)));
|
|
1595
|
+
const entries = yield* Effect.forEach(workspaces, (workspace) => entryProblems(root, workspace), { concurrency: 1 });
|
|
1596
|
+
return [...layered, ...Array.flatten(entries)];
|
|
1597
|
+
});
|
|
1457
1598
|
// src/features/placement/model/source-aliases.ts
|
|
1458
1599
|
const ALIAS_RULE = "source-alias";
|
|
1459
|
-
const FIRST$
|
|
1600
|
+
const FIRST$10 = 1;
|
|
1460
1601
|
const SOURCE_ALIAS = "#/*";
|
|
1461
1602
|
const SOURCE_TARGET = "./src/*";
|
|
1462
1603
|
const SOURCE_PREFIX = /^\.\/src(?:\/|$)/u;
|
|
1463
1604
|
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.`;
|
|
1464
1605
|
const Manifest$2 = Schema.Struct({ imports: Schema.optional(Schema.Unknown) });
|
|
1465
1606
|
const decodeManifest$3 = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest$2));
|
|
1466
|
-
const problemAt$
|
|
1607
|
+
const problemAt$4 = (file, rule, message) => ({
|
|
1467
1608
|
file,
|
|
1468
|
-
line: FIRST$
|
|
1469
|
-
column: FIRST$
|
|
1609
|
+
line: FIRST$10,
|
|
1610
|
+
column: FIRST$10,
|
|
1470
1611
|
rule,
|
|
1471
1612
|
message
|
|
1472
1613
|
});
|
|
@@ -1478,28 +1619,26 @@ const targetsOf = (target) => {
|
|
|
1478
1619
|
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)));
|
|
1479
1620
|
const aliasProblems = Effect.fn("aliasProblems")(function* aliasProblems(root, workspace) {
|
|
1480
1621
|
const files = yield* RepositoryFiles;
|
|
1481
|
-
const manifest = files.join(root, workspace, MANIFEST_FILE);
|
|
1622
|
+
const manifest = files.join(root, workspace, MANIFEST_FILE$1);
|
|
1482
1623
|
const text = yield* files.readFile(manifest);
|
|
1483
|
-
return pipe(text, Option.flatMap(decodeManifest$3), 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$
|
|
1624
|
+
return pipe(text, Option.flatMap(decodeManifest$3), 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$4(manifest, ALIAS_RULE, `"${key}" ${ALIAS_MESSAGE}`)));
|
|
1484
1625
|
});
|
|
1485
1626
|
/** @internal */
|
|
1486
1627
|
const checkSourceAliases = Effect.fn("checkSourceAliases")(function* checkSourceAliases(root) {
|
|
1487
1628
|
const workspaces = yield* memberWorkspaces(root);
|
|
1488
|
-
const aliases = yield*
|
|
1629
|
+
const aliases = yield* Effect.forEach(workspaces, (workspace) => aliasProblems(root, workspace), { concurrency: 1 });
|
|
1489
1630
|
return Array.flatten(aliases);
|
|
1490
1631
|
});
|
|
1491
1632
|
// src/features/placement/model/placement-checks.ts
|
|
1492
1633
|
/** @internal */
|
|
1493
1634
|
const checkPlacement = Effect.fn("checkPlacement")(function* checkPlacement(root) {
|
|
1494
1635
|
const found = yield* Effect.all([
|
|
1495
|
-
|
|
1496
|
-
checkRootReadme(root),
|
|
1497
|
-
checkRootDocs(root),
|
|
1636
|
+
checkDocPlacement(root),
|
|
1498
1637
|
checkColocatedTests(root),
|
|
1499
|
-
checkAgentDocsLength(root),
|
|
1500
1638
|
checkLayeredSource(root),
|
|
1501
|
-
|
|
1502
|
-
|
|
1639
|
+
checkSourceAliases(root),
|
|
1640
|
+
checkColocatedGitPatterns(root),
|
|
1641
|
+
checkIgnoredSources(root)
|
|
1503
1642
|
], { concurrency: "unbounded" });
|
|
1504
1643
|
return Array.flatten(found);
|
|
1505
1644
|
});
|
|
@@ -1513,7 +1652,7 @@ const WORKFLOW_DIRECTORY$1 = ".github/";
|
|
|
1513
1652
|
const SEPARATOR$11 = "/";
|
|
1514
1653
|
const CURRENT = "./";
|
|
1515
1654
|
const READ_CONCURRENCY$14 = 8;
|
|
1516
|
-
const FIRST$
|
|
1655
|
+
const FIRST$9 = 1;
|
|
1517
1656
|
const RUN_FILE = /(?:^|[\s;&|(])(?:node|vpx|tsx|bun|deno)\s+(?:-\S+\s+)*(?<file>[^\s;&|)]+\.[cm]?[jt]s)\b/gu;
|
|
1518
1657
|
const COMMAND = /^bin\/[^/]+\.[cm]?ts$/u;
|
|
1519
1658
|
const NOT_COMMAND = /\.(?:test|d|test\.support)\.[cm]?ts$/u;
|
|
@@ -1549,7 +1688,7 @@ const entriesOf$1 = (manifest) => {
|
|
|
1549
1688
|
};
|
|
1550
1689
|
const declaredEntries = Effect.fn("declaredEntries")(function* declaredEntries(root, directory) {
|
|
1551
1690
|
const files = yield* RepositoryFiles;
|
|
1552
|
-
const text = yield* files.readFile(files.join(root, directory, MANIFEST_FILE));
|
|
1691
|
+
const text = yield* files.readFile(files.join(root, directory, MANIFEST_FILE$1));
|
|
1553
1692
|
return pipe(text, Option.flatMap(decodeManifest$2), Option.map(entriesOf$1), Option.getOrElse(() => NO_ENTRIES));
|
|
1554
1693
|
});
|
|
1555
1694
|
const isCommand$1 = (path) => COMMAND.test(path) && !NOT_COMMAND.test(path);
|
|
@@ -1573,7 +1712,7 @@ const outsideProblems = ({ file, source, runs, entries }) => pipe(runs, Array.fi
|
|
|
1573
1712
|
message: `A task runs ${path}. Put each file that a task runs at ${BIN}/<name>.ts, the one place where every workspace keeps its commands, so that fallow and the other tools find it without a list of files.`
|
|
1574
1713
|
})));
|
|
1575
1714
|
const runsOf = (program) => pipe(nestedValues(RUN_TASKS)(program), Array.flatMap(stringsIn), Array.flatMap(runsIn));
|
|
1576
|
-
const problemsIn$
|
|
1715
|
+
const problemsIn$11 = Effect.fn("problemsIn")(function* problemsIn(root, directory, workflows) {
|
|
1577
1716
|
const files = yield* RepositoryFiles;
|
|
1578
1717
|
const config = yield* workspaceConfigOf(root, directory);
|
|
1579
1718
|
const entries = yield* declaredEntries(root, directory);
|
|
@@ -1589,8 +1728,8 @@ const problemsIn$10 = Effect.fn("problemsIn")(function* problemsIn(root, directo
|
|
|
1589
1728
|
const isRun = (path) => Array.contains(runPaths, path) || Array.contains(entries.bins, path) || String$1.includes(workspacePath(directory, path))(workflows);
|
|
1590
1729
|
const unrun = pipe(commands, Array.filter((path) => !isRun(path)), Array.map((path) => ({
|
|
1591
1730
|
file: files.join(root, directory, path),
|
|
1592
|
-
line: FIRST$
|
|
1593
|
-
column: FIRST$
|
|
1731
|
+
line: FIRST$9,
|
|
1732
|
+
column: FIRST$9,
|
|
1594
1733
|
rule: UNRUN,
|
|
1595
1734
|
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.`
|
|
1596
1735
|
})));
|
|
@@ -1602,8 +1741,8 @@ const scriptsProblem = Effect.fn("scriptsProblem")(function* scriptsProblem(root
|
|
|
1602
1741
|
const isDirectory = yield* files.isDirectory(file);
|
|
1603
1742
|
return pipe(isDirectory, Option.filter(Boolean), Option.map(() => ({
|
|
1604
1743
|
file,
|
|
1605
|
-
line: FIRST$
|
|
1606
|
-
column: FIRST$
|
|
1744
|
+
line: FIRST$9,
|
|
1745
|
+
column: FIRST$9,
|
|
1607
1746
|
rule: SCRIPTS,
|
|
1608
1747
|
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.`
|
|
1609
1748
|
})));
|
|
@@ -1612,16 +1751,16 @@ const scriptsProblem = Effect.fn("scriptsProblem")(function* scriptsProblem(root
|
|
|
1612
1751
|
const checkCommandEntries = Effect.fn("checkCommandEntries")(function* checkCommandEntries(root) {
|
|
1613
1752
|
const all = ["", ...yield* workspaceDirectories(root)];
|
|
1614
1753
|
const workflows = yield* workflowText(root);
|
|
1615
|
-
const found = yield* Effect.forEach(all, (directory) => problemsIn$
|
|
1754
|
+
const found = yield* Effect.forEach(all, (directory) => problemsIn$11(root, directory, workflows), { concurrency: READ_CONCURRENCY$14 });
|
|
1616
1755
|
const scripts = yield* Effect.forEach(all, (directory) => scriptsProblem(root, directory), { concurrency: READ_CONCURRENCY$14 });
|
|
1617
1756
|
return [...Array.flatten(found), ...Array.getSomes(scripts)];
|
|
1618
1757
|
});
|
|
1619
1758
|
// src/features/repository-layout/model/crates.ts
|
|
1620
|
-
const RULE$
|
|
1759
|
+
const RULE$24 = "unverified-crate";
|
|
1621
1760
|
const CARGO_FILE = "Cargo.toml";
|
|
1622
1761
|
const CONFIG_FILE$3 = "vite.config.ts";
|
|
1623
1762
|
const SEPARATOR$10 = "/";
|
|
1624
|
-
const FIRST$
|
|
1763
|
+
const FIRST$8 = 1;
|
|
1625
1764
|
const READ_CONCURRENCY$13 = 8;
|
|
1626
1765
|
const CrateEntry = Schema.Struct({
|
|
1627
1766
|
name: Schema.String,
|
|
@@ -1653,9 +1792,9 @@ const owningWorkspace = (directories) => (directory) => {
|
|
|
1653
1792
|
};
|
|
1654
1793
|
const problemFor$2 = (crate, message) => ({
|
|
1655
1794
|
file: crate.manifest,
|
|
1656
|
-
line: FIRST$
|
|
1657
|
-
column: FIRST$
|
|
1658
|
-
rule: RULE$
|
|
1795
|
+
line: FIRST$8,
|
|
1796
|
+
column: FIRST$8,
|
|
1797
|
+
rule: RULE$24,
|
|
1659
1798
|
message: `crate ${crate.name} ${message}, so vp run verify never checks it.`
|
|
1660
1799
|
});
|
|
1661
1800
|
const problemIn$3 = Effect.fn("problemIn")(function* problemIn(root, directories, crate) {
|
|
@@ -1675,7 +1814,7 @@ const checkCrates = Effect.fn("checkCrates")(function* checkCrates(root) {
|
|
|
1675
1814
|
return Array.getSomes(found);
|
|
1676
1815
|
});
|
|
1677
1816
|
// src/features/repository-layout/model/deploy-entry-patterns.ts
|
|
1678
|
-
const RULE$
|
|
1817
|
+
const RULE$23 = "deploy-entry-pattern";
|
|
1679
1818
|
const FALLOW_KEYS = [
|
|
1680
1819
|
"entry",
|
|
1681
1820
|
"entryPoints",
|
|
@@ -1694,7 +1833,7 @@ const ROOT_WORKSPACE = ".";
|
|
|
1694
1833
|
const WRAP_OFFSET$1 = 1;
|
|
1695
1834
|
const NO_OFFSET = 0;
|
|
1696
1835
|
const READ_CONCURRENCY$12 = 8;
|
|
1697
|
-
const MESSAGE$
|
|
1836
|
+
const MESSAGE$6 = "selects deploy entries by their name or location. A deploy entry is the file that an Alchemy resource names in main, and its name and place change with the code. Use workspaceSettings().lint.deployEntries in lint settings; fallow reads main from the stack by itself.";
|
|
1698
1837
|
const decodeKey$1 = Schema.decodeUnknownOption(KeySchema);
|
|
1699
1838
|
const FALLOW = {
|
|
1700
1839
|
keys: FALLOW_KEYS,
|
|
@@ -1730,7 +1869,7 @@ const patternsOf = Effect.fn("patternsOf")(function* patternsOf(file, text, kind
|
|
|
1730
1869
|
const parsed = yield* Effect.promise(() => parse(`${file}.ts`, kind.sourceOf(text), { lang: "ts" }));
|
|
1731
1870
|
return pipe(patternsIn(kind.keys)(parsed.program), Array.filter(({ text: pattern }) => !String$1.startsWith(NEGATED)(pattern)));
|
|
1732
1871
|
});
|
|
1733
|
-
const problemsIn$
|
|
1872
|
+
const problemsIn$10 = Effect.fn("problemsIn")(function* problemsIn(request) {
|
|
1734
1873
|
const { root, file, kind, workspaces, entries } = request;
|
|
1735
1874
|
const files = yield* RepositoryFiles;
|
|
1736
1875
|
const path = files.join(root, file);
|
|
@@ -1742,12 +1881,12 @@ const problemsIn$9 = Effect.fn("problemsIn")(function* problemsIn(request) {
|
|
|
1742
1881
|
bases: kind.bases(files.dirname(file), workspaces),
|
|
1743
1882
|
entries
|
|
1744
1883
|
};
|
|
1745
|
-
const flagged = yield*
|
|
1884
|
+
const flagged = yield* Effect.forEach(patterns, (pattern) => selectsOnlyDeployEntries(selection, pattern), { concurrency: 1 });
|
|
1746
1885
|
return pipe(Array.getSomes(flagged), Array.map(({ text: pattern, start }) => ({
|
|
1747
1886
|
file: path,
|
|
1748
1887
|
...positionOf(text.value)(start - kind.offset),
|
|
1749
|
-
rule: RULE$
|
|
1750
|
-
message: `${pattern} ${MESSAGE$
|
|
1888
|
+
rule: RULE$23,
|
|
1889
|
+
message: `${pattern} ${MESSAGE$6}`
|
|
1751
1890
|
})));
|
|
1752
1891
|
});
|
|
1753
1892
|
/** @internal */
|
|
@@ -1769,7 +1908,7 @@ const checkDeployEntryPatterns = Effect.fn("checkDeployEntryPatterns")(function*
|
|
|
1769
1908
|
}];
|
|
1770
1909
|
return [];
|
|
1771
1910
|
}));
|
|
1772
|
-
const found = yield* Effect.forEach(configs, ({ file, kind }) => problemsIn$
|
|
1911
|
+
const found = yield* Effect.forEach(configs, ({ file, kind }) => problemsIn$10({
|
|
1773
1912
|
root,
|
|
1774
1913
|
file,
|
|
1775
1914
|
kind,
|
|
@@ -1779,7 +1918,7 @@ const checkDeployEntryPatterns = Effect.fn("checkDeployEntryPatterns")(function*
|
|
|
1779
1918
|
return Array.flatten(found);
|
|
1780
1919
|
});
|
|
1781
1920
|
// src/features/repository-layout/model/fallow-entries.ts
|
|
1782
|
-
const RULE$
|
|
1921
|
+
const RULE$22 = "listed-entry";
|
|
1783
1922
|
const ENTRY_KEYS = [
|
|
1784
1923
|
"entry",
|
|
1785
1924
|
"entryPoints",
|
|
@@ -1800,7 +1939,7 @@ const entryPatternsIn = (node) => {
|
|
|
1800
1939
|
return pipe(childrenOf$2(node), Array.flatMap(entryPatternsIn));
|
|
1801
1940
|
};
|
|
1802
1941
|
const namesOneFile = (directories) => ({ text }) => pipe(directories, Array.some((directory) => String$1.startsWith(`${directory}${SEPARATOR$9}`)(text))) || String$1.includes(SEPARATOR$9)(text) && !WILDCARD$1.test(text);
|
|
1803
|
-
const problemsIn$
|
|
1942
|
+
const problemsIn$9 = Effect.fn("problemsIn")(function* problemsIn(root, file, directories) {
|
|
1804
1943
|
const files = yield* RepositoryFiles;
|
|
1805
1944
|
const path = files.join(root, file);
|
|
1806
1945
|
const text = yield* files.readFile(path);
|
|
@@ -1809,7 +1948,7 @@ const problemsIn$8 = Effect.fn("problemsIn")(function* problemsIn(root, file, di
|
|
|
1809
1948
|
return pipe(entryPatternsIn(parsed.program), Array.filter(namesOneFile(directories)), Array.map(({ text: pattern, start }) => ({
|
|
1810
1949
|
file: path,
|
|
1811
1950
|
...positionOf(text.value)(start),
|
|
1812
|
-
rule: RULE$
|
|
1951
|
+
rule: RULE$22,
|
|
1813
1952
|
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.`
|
|
1814
1953
|
})));
|
|
1815
1954
|
});
|
|
@@ -1817,13 +1956,13 @@ const problemsIn$8 = Effect.fn("problemsIn")(function* problemsIn(root, file, di
|
|
|
1817
1956
|
const checkFallowEntries = Effect.fn("checkFallowEntries")(function* checkFallowEntries(root) {
|
|
1818
1957
|
const listed = yield* (yield* RepositoryFiles).listedFiles(root);
|
|
1819
1958
|
const directories = yield* workspaceDirectories(root);
|
|
1820
|
-
const found = yield* Effect.forEach(pipe(listed, Array.filter((file) => FALLOW_CONFIG.test(file))), (file) => problemsIn$
|
|
1959
|
+
const found = yield* Effect.forEach(pipe(listed, Array.filter((file) => FALLOW_CONFIG.test(file))), (file) => problemsIn$9(root, file, directories), { concurrency: READ_CONCURRENCY$11 });
|
|
1821
1960
|
return Array.flatten(found);
|
|
1822
1961
|
});
|
|
1823
1962
|
// src/features/repository-layout/model/hidden-verify.ts
|
|
1824
|
-
const RULE$
|
|
1963
|
+
const RULE$21 = "hidden-verify";
|
|
1825
1964
|
const CONFIG_FILE$2 = "vite.config.ts";
|
|
1826
|
-
const FIRST$
|
|
1965
|
+
const FIRST$7 = 1;
|
|
1827
1966
|
const READ_CONCURRENCY$10 = 8;
|
|
1828
1967
|
const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, directory) {
|
|
1829
1968
|
const config = yield* workspaceConfigOf(root, directory);
|
|
@@ -1833,9 +1972,9 @@ const problemIn$2 = Effect.fn("problemIn")(function* problemIn(root, directory)
|
|
|
1833
1972
|
const verified = yield* hasVerifyTask(file);
|
|
1834
1973
|
return Option.some({
|
|
1835
1974
|
file,
|
|
1836
|
-
line: FIRST$
|
|
1837
|
-
column: FIRST$
|
|
1838
|
-
rule: RULE$
|
|
1975
|
+
line: FIRST$7,
|
|
1976
|
+
column: FIRST$7,
|
|
1977
|
+
rule: RULE$21,
|
|
1839
1978
|
message: `${directory} gets its verify task from code outside ${CONFIG_FILE$2}. The root verify reads ${CONFIG_FILE$2} without running it, so it never runs this verify. Write run.tasks.verify in ${directory}/${CONFIG_FILE$2}.`
|
|
1840
1979
|
}).pipe(Option.filter(() => verified));
|
|
1841
1980
|
});
|
|
@@ -1846,11 +1985,11 @@ const checkHiddenVerify = Effect.fn("checkHiddenVerify")(function* checkHiddenVe
|
|
|
1846
1985
|
return Array.getSomes(found);
|
|
1847
1986
|
});
|
|
1848
1987
|
// src/features/repository-layout/model/root-workspace-paths.ts
|
|
1849
|
-
const RULE$
|
|
1988
|
+
const RULE$20 = "root-workspace-path";
|
|
1850
1989
|
const CONFIG_FILE$1 = "vite.config.ts";
|
|
1851
1990
|
const PATH_CHARACTER = /[\w.@/-]/u;
|
|
1852
1991
|
const NAME_CHARACTER = /[\w.@-]/u;
|
|
1853
|
-
const FIRST$
|
|
1992
|
+
const FIRST$6 = 0;
|
|
1854
1993
|
const NEXT$2 = 1;
|
|
1855
1994
|
const isBoundary = (character, allowed) => character === "" || !allowed.test(character);
|
|
1856
1995
|
const mentions = (directory) => (text) => {
|
|
@@ -1858,14 +1997,14 @@ const mentions = (directory) => (text) => {
|
|
|
1858
1997
|
return pipe(Array.drop(parts, NEXT$2), Array.some((after, index) => {
|
|
1859
1998
|
const before = parts[index] ?? "";
|
|
1860
1999
|
const previous = String$1.slice(before.length - NEXT$2)(before);
|
|
1861
|
-
const following = String$1.slice(FIRST$
|
|
2000
|
+
const following = String$1.slice(FIRST$6, NEXT$2)(after);
|
|
1862
2001
|
return isBoundary(previous, PATH_CHARACTER) && (following === "/" || isBoundary(following, NAME_CHARACTER));
|
|
1863
2002
|
}));
|
|
1864
2003
|
};
|
|
1865
|
-
const problemsIn$
|
|
2004
|
+
const problemsIn$8 = (file, source, directories) => (found) => pipe(directories, Array.filter((directory) => mentions(directory)(found.text)), Array.map((directory) => ({
|
|
1866
2005
|
file,
|
|
1867
2006
|
...positionOf(source)(found.start),
|
|
1868
|
-
rule: RULE$
|
|
2007
|
+
rule: RULE$20,
|
|
1869
2008
|
message: `${directory} is a workspace. The root ${CONFIG_FILE$1} holds what applies to every workspace, so move what only ${directory} needs into ${directory}/${CONFIG_FILE$1}: msch.lint, msch.devDependencies or its verify task.`
|
|
1870
2009
|
})));
|
|
1871
2010
|
/** @internal */
|
|
@@ -1876,10 +2015,10 @@ const checkRootWorkspacePaths = Effect.fn("checkRootWorkspacePaths")(function* c
|
|
|
1876
2015
|
if (Option.isNone(source)) return [];
|
|
1877
2016
|
const directories = yield* workspaceDirectories(root);
|
|
1878
2017
|
const parsed = yield* Effect.promise(() => parse(file, source.value, { lang: "ts" }));
|
|
1879
|
-
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$
|
|
2018
|
+
return pipe(stringsIn(parsed.program), Array.flatMap(problemsIn$8(file, source.value, directories)));
|
|
1880
2019
|
});
|
|
1881
2020
|
// src/features/repository-layout/model/shared-uncached-tasks.ts
|
|
1882
|
-
const RULE$
|
|
2021
|
+
const RULE$19 = "shared-uncached-task";
|
|
1883
2022
|
const READ_CONCURRENCY$9 = 8;
|
|
1884
2023
|
const SHARED = 2;
|
|
1885
2024
|
const OWN_PROGRAM = /^(?:node|vpx|bun|deno|tsx)$|\//u;
|
|
@@ -1922,7 +2061,7 @@ const problemsOf$1 = (definitions) => {
|
|
|
1922
2061
|
return pipe(definitions, Array.map(({ file, position, name, command }) => ({
|
|
1923
2062
|
file,
|
|
1924
2063
|
...position,
|
|
1925
|
-
rule: RULE$
|
|
2064
|
+
rule: RULE$19,
|
|
1926
2065
|
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.`
|
|
1927
2066
|
})));
|
|
1928
2067
|
};
|
|
@@ -2068,13 +2207,13 @@ const outputPathsOf = (step) => pipe(stringOf(pathInputOf(step)), Option.toArray
|
|
|
2068
2207
|
/** @internal */
|
|
2069
2208
|
const producedPaths = (source) => pipe(jobsOf(source), Array.flatMap(([, job]) => itemsOf(childOf("steps")(job))), Array.flatMap(outputPathsOf));
|
|
2070
2209
|
// src/features/repository-layout/model/workflow-paths.ts
|
|
2071
|
-
const RULE$
|
|
2210
|
+
const RULE$18 = "workflow-path";
|
|
2072
2211
|
const WORKFLOW_DIRECTORY = ".github/workflows/";
|
|
2073
2212
|
const WORKFLOW_EXTENSIONS = [".yml", ".yaml"];
|
|
2074
2213
|
const READ_CONCURRENCY$8 = 8;
|
|
2075
2214
|
const WILDCARD = /[*?[]/u;
|
|
2076
2215
|
const SEPARATOR$7 = "/";
|
|
2077
|
-
const FIRST$
|
|
2216
|
+
const FIRST$5 = 0;
|
|
2078
2217
|
const EXPECTED = {
|
|
2079
2218
|
action: "a directory with action.yml",
|
|
2080
2219
|
directory: "a directory",
|
|
@@ -2098,7 +2237,7 @@ const isDirectoryAt = Effect.fn("isDirectoryAt")(function* isDirectoryAt(root, p
|
|
|
2098
2237
|
return Option.getOrElse(directory, () => false);
|
|
2099
2238
|
});
|
|
2100
2239
|
const hasAction = Effect.fn("hasAction")(function* hasAction(root, path) {
|
|
2101
|
-
const found = yield*
|
|
2240
|
+
const found = yield* Effect.forEach(ACTION_DEFINITIONS, (name) => existsAt(root, `${path}${SEPARATOR$7}${name}`), { concurrency: 1 });
|
|
2102
2241
|
return pipe(found, Array.some(Boolean));
|
|
2103
2242
|
});
|
|
2104
2243
|
const suffixAt = (segments) => (index) => `:(glob)**/${pipe(segments, Array.drop(index), Array.join(SEPARATOR$7))}`;
|
|
@@ -2115,7 +2254,7 @@ const RESOLVERS = {
|
|
|
2115
2254
|
};
|
|
2116
2255
|
const staticPrefix = (path) => {
|
|
2117
2256
|
const prefix = Array.headNonEmpty(String$1.split(path, WILDCARD));
|
|
2118
|
-
if (String$1.endsWith(SEPARATOR$7)(prefix)) return String$1.slice(FIRST$
|
|
2257
|
+
if (String$1.endsWith(SEPARATOR$7)(prefix)) return String$1.slice(FIRST$5, -1)(prefix);
|
|
2119
2258
|
return prefix;
|
|
2120
2259
|
};
|
|
2121
2260
|
const isIgnored$1 = Effect.fn("isIgnored")(function* isIgnored(root, path) {
|
|
@@ -2134,10 +2273,10 @@ const isMissing = Effect.fn("isMissing")(function* isMissing(root, produced, fou
|
|
|
2134
2273
|
const problemOf$6 = (file, source) => (found) => ({
|
|
2135
2274
|
file,
|
|
2136
2275
|
...positionOf(source)(found.offset),
|
|
2137
|
-
rule: RULE$
|
|
2276
|
+
rule: RULE$18,
|
|
2138
2277
|
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.`
|
|
2139
2278
|
});
|
|
2140
|
-
const problemsIn$
|
|
2279
|
+
const problemsIn$7 = Effect.fn("problemsIn")(function* problemsIn(root, workflow) {
|
|
2141
2280
|
const files = yield* RepositoryFiles;
|
|
2142
2281
|
const file = files.join(root, workflow);
|
|
2143
2282
|
const source = yield* files.readFile(file);
|
|
@@ -2149,7 +2288,7 @@ const problemsIn$6 = Effect.fn("problemsIn")(function* problemsIn(root, workflow
|
|
|
2149
2288
|
/** @internal */
|
|
2150
2289
|
const checkWorkflowPaths = Effect.fn("checkWorkflowPaths")(function* checkWorkflowPaths(root) {
|
|
2151
2290
|
const listed = yield* (yield* RepositoryFiles).listedFiles(root);
|
|
2152
|
-
const found = yield* Effect.forEach(pipe(listed, Array.filter(isWorkflow)), (workflow) => problemsIn$
|
|
2291
|
+
const found = yield* Effect.forEach(pipe(listed, Array.filter(isWorkflow)), (workflow) => problemsIn$7(root, workflow), { concurrency: READ_CONCURRENCY$8 });
|
|
2153
2292
|
return Array.flatten(found);
|
|
2154
2293
|
});
|
|
2155
2294
|
// src/features/repository-layout/model/workflow-scale.ts
|
|
@@ -2168,7 +2307,7 @@ const SPACE = " ";
|
|
|
2168
2307
|
const FILTER_MESSAGE = "A workflow that reacts to changes under listed paths needs a new entry for every package and drifts from the packages it is meant to cover. Run the generic pipeline on every push and let it decide from the workspace what changed.";
|
|
2169
2308
|
const packageMessage = (what, directory) => `${what} names the workspace ${directory}. A workflow or job made for one package does not scale: give the package a vp task and let the generic pipeline (verify, deploy, release, daily, task) find it.`;
|
|
2170
2309
|
const keysOf = (node) => pipe(Option.liftPredicate(node, isMap), Option.map((map) => map.items), Option.getOrElse(() => []), Array.filter(isPair), Array.flatMap(({ key }) => Option.toArray(stringOf(key))));
|
|
2171
|
-
const problemAt$
|
|
2310
|
+
const problemAt$3 = ({ file, source }, rule, message) => (offset) => ({
|
|
2172
2311
|
file,
|
|
2173
2312
|
...positionOf(source)(offset),
|
|
2174
2313
|
rule,
|
|
@@ -2178,7 +2317,7 @@ const pathFiltersIn = (file, source) => {
|
|
|
2178
2317
|
const root = parseDocument(source).contents;
|
|
2179
2318
|
const triggers = pipe(entriesOf(childOf("on")(root)), Array.flatMap(([, trigger]) => keysOf(trigger)), Array.filter(({ text }) => Array.contains(FILTER_KEYS, text)));
|
|
2180
2319
|
const actions = pipe(scalarsIn(source), Array.filter(({ text }) => PATHS_FILTER_ACTION.test(text)));
|
|
2181
|
-
return pipe([...triggers, ...actions], Array.map(({ offset }) => problemAt$
|
|
2320
|
+
return pipe([...triggers, ...actions], Array.map(({ offset }) => problemAt$3({
|
|
2182
2321
|
file,
|
|
2183
2322
|
source
|
|
2184
2323
|
}, PATH_FILTER, FILTER_MESSAGE)(offset)));
|
|
@@ -2201,7 +2340,7 @@ const filtersIn = (source) => pipe(scalarsIn(source), Array.flatMap(({ text, off
|
|
|
2201
2340
|
text: value,
|
|
2202
2341
|
offset
|
|
2203
2342
|
})))));
|
|
2204
|
-
const reported = (where, offset, what) => (found) => pipe(found, Option.map((directory) => problemAt$
|
|
2343
|
+
const reported = (where, offset, what) => (found) => pipe(found, Option.map((directory) => problemAt$3(where, PACKAGE, packageMessage(what, directory))(offset)), Option.toArray);
|
|
2205
2344
|
const packagesIn = (workspaces, { file, name, source }) => {
|
|
2206
2345
|
const where = {
|
|
2207
2346
|
file,
|
|
@@ -2262,7 +2401,7 @@ const checkWorkspaces = Effect.fn("checkWorkspaces")(function* checkWorkspaces(r
|
|
|
2262
2401
|
return Array.flatten(found);
|
|
2263
2402
|
});
|
|
2264
2403
|
// src/features/pass-through-wrappers/model/pass-through-wrappers.ts
|
|
2265
|
-
const RULE$
|
|
2404
|
+
const RULE$17 = "pass-through-wrapper";
|
|
2266
2405
|
const SINGLE_STATEMENT = 1;
|
|
2267
2406
|
const SINGLE_DECLARATION = 1;
|
|
2268
2407
|
const THIS_PARAMETER = "this";
|
|
@@ -2358,8 +2497,8 @@ const isPassThrough = (checker) => (candidate) => (forward) => {
|
|
|
2358
2497
|
};
|
|
2359
2498
|
const problemOf$5 = (checker) => (candidate) => {
|
|
2360
2499
|
if (changesTheCall(candidate.wrapper)) return Option.none();
|
|
2361
|
-
return pipe(returnedExpression(candidate.wrapper), Option.flatMap(forwardOf), Option.filter(isPassThrough(checker)(candidate)), Option.map((forward) => problemAt$
|
|
2362
|
-
rule: RULE$
|
|
2500
|
+
return pipe(returnedExpression(candidate.wrapper), Option.flatMap(forwardOf), Option.filter(isPassThrough(checker)(candidate)), Option.map((forward) => problemAt$8({
|
|
2501
|
+
rule: RULE$17,
|
|
2363
2502
|
message: messageOf(forward.callee.getText())
|
|
2364
2503
|
})(candidate.name)));
|
|
2365
2504
|
};
|
|
@@ -2478,7 +2617,7 @@ const ownerValuesOf = (checker) => (declaration) => {
|
|
|
2478
2617
|
const type = checker.getTypeAtLocation(declaration.name);
|
|
2479
2618
|
return finiteValuesOf(checker)(type).pipe(Option.orElse(() => objectValuesOf(checker)(type)));
|
|
2480
2619
|
};
|
|
2481
|
-
const annotationProblem = (message) => problemAt$
|
|
2620
|
+
const annotationProblem = (message) => problemAt$8({
|
|
2482
2621
|
rule: "owner-annotation",
|
|
2483
2622
|
message
|
|
2484
2623
|
});
|
|
@@ -2615,7 +2754,7 @@ const shapeProblem = (site, matches) => {
|
|
|
2615
2754
|
onNone: () => "Derive it from the library type, for example with Pick, instead of copying its properties.",
|
|
2616
2755
|
onSome: () => "Use the library type instead of copying it."
|
|
2617
2756
|
});
|
|
2618
|
-
return problemAt$
|
|
2757
|
+
return problemAt$8({
|
|
2619
2758
|
rule: "library-shape",
|
|
2620
2759
|
message: `This shape copies ${shown}. ${advice}`
|
|
2621
2760
|
})(site.node);
|
|
@@ -2720,7 +2859,7 @@ const derivedVerdict = (context) => (site) => {
|
|
|
2720
2859
|
const added = pipe(site.values, Array.filter((value) => !isSubsetOf([value], held)));
|
|
2721
2860
|
if (!Array.isReadonlyArrayNonEmpty(owners) || !Array.isReadonlyArrayNonEmpty(added)) return verdict([], []);
|
|
2722
2861
|
const message = `This set adds ${formatValues(added)} to ${describeOwners(owners)}. Add the values to the owner, or register the wider set as its own concept.`;
|
|
2723
|
-
return verdict([problemAt$
|
|
2862
|
+
return verdict([problemAt$8({
|
|
2724
2863
|
rule: "owner-extension",
|
|
2725
2864
|
message
|
|
2726
2865
|
})(site.node)], []);
|
|
@@ -2742,7 +2881,7 @@ const originalVerdict = (context) => (site) => {
|
|
|
2742
2881
|
const owners = pipe(context.owners, Array.filter((owner) => isSubsetOf(site.values, owner.values)));
|
|
2743
2882
|
if (Array.isReadonlyArrayNonEmpty(owners)) {
|
|
2744
2883
|
const message = `The values ${formatValues(site.values)} are owned by ${describeOwners(owners)}. Derive this set from the owner instead of restating it.`;
|
|
2745
|
-
return verdict([problemAt$
|
|
2884
|
+
return verdict([problemAt$8({
|
|
2746
2885
|
rule: "owner-value-set",
|
|
2747
2886
|
message
|
|
2748
2887
|
})(site.node)], []);
|
|
@@ -2750,7 +2889,7 @@ const originalVerdict = (context) => (site) => {
|
|
|
2750
2889
|
const candidates = libraryCandidates(context)(site);
|
|
2751
2890
|
if (Array.isReadonlyArrayNonEmpty(candidates)) {
|
|
2752
2891
|
const message = `The values ${formatValues(site.values)} restate a dependency type: ${listCandidates(candidates)}. Derive this set from the library type.`;
|
|
2753
|
-
return verdict([problemAt$
|
|
2892
|
+
return verdict([problemAt$8({
|
|
2754
2893
|
rule: "library-value-set",
|
|
2755
2894
|
message
|
|
2756
2895
|
})(site.node)], []);
|
|
@@ -2781,7 +2920,7 @@ const isValuePosition = (node) => {
|
|
|
2781
2920
|
const { parent } = node;
|
|
2782
2921
|
return VALUE_PARENT_KINDS.has(parent.kind) || pipe(VALUE_SLOTS, Array.some((isSlot) => isSlot(node, parent)));
|
|
2783
2922
|
};
|
|
2784
|
-
const ownedLiteralProblem = (context) => (literal) => Option.fromUndefinedOr(context.checker.getContextualType(literal)).pipe(Option.filter((contextual) => vocabularyOf(context.checker)(contextual).pipe(Option.exists((vocabulary) => !vocabulary.admitsUnnamedValues))), Option.map(() => pipe(contextSymbolsOf(context.checker)(literal), Array.flatMap((symbol) => ownersBehind(context)(symbol, [])), uniqueByReference, Array.filter((owner) => isSubsetOf([literal.text], pipe(owner.values, Array.map(String)))))), Option.filter((owners) => Array.isReadonlyArrayNonEmpty(owners)), Option.map((owners) => problemAt$
|
|
2923
|
+
const ownedLiteralProblem = (context) => (literal) => Option.fromUndefinedOr(context.checker.getContextualType(literal)).pipe(Option.filter((contextual) => vocabularyOf(context.checker)(contextual).pipe(Option.exists((vocabulary) => !vocabulary.admitsUnnamedValues))), Option.map(() => pipe(contextSymbolsOf(context.checker)(literal), Array.flatMap((symbol) => ownersBehind(context)(symbol, [])), uniqueByReference, Array.filter((owner) => isSubsetOf([literal.text], pipe(owner.values, Array.map(String)))))), Option.filter((owners) => Array.isReadonlyArrayNonEmpty(owners)), Option.map((owners) => problemAt$8({
|
|
2785
2924
|
rule: "owned-literal",
|
|
2786
2925
|
message: `${literal.getText()} is a value of ${describeOwners(owners)}. Write it through the owner's binding instead of as a literal.`
|
|
2787
2926
|
})(literal)));
|
|
@@ -2876,13 +3015,13 @@ const fileDigest = (hash) => {
|
|
|
2876
3015
|
})
|
|
2877
3016
|
});
|
|
2878
3017
|
};
|
|
2879
|
-
const digestEntries = (digestFile) => (named) =>
|
|
3018
|
+
const digestEntries = (digestFile) => (named) => Effect.forEach(named, ([name, file]) => digestFile(file).pipe(Effect.map((found) => entryOf(name, found))), { concurrency: 1 });
|
|
2880
3019
|
const fingerprintedFiles = Effect.fn("fingerprintedFiles")(function* fingerprintedFiles(root) {
|
|
2881
3020
|
const files = yield* RepositoryFiles;
|
|
2882
|
-
const nested = yield*
|
|
3021
|
+
const nested = yield* Effect.forEach(FINGERPRINTED, (entry) => {
|
|
2883
3022
|
const base = files.join(root, entry);
|
|
2884
3023
|
return files.walkDirectory(base).pipe(Effect.map(Array.map((file) => files.join(base, file))));
|
|
2885
|
-
})
|
|
3024
|
+
}, { concurrency: 1 });
|
|
2886
3025
|
return Array.sort([files.join(root, MANIFEST_ENTRY), ...Array.flatten(nested)], String$1.Order);
|
|
2887
3026
|
});
|
|
2888
3027
|
const fingerprintOf = Effect.fn("fingerprintOf")(function* fingerprintOf(hash) {
|
|
@@ -2938,7 +3077,7 @@ const pruneAnalyses = (cache) => (kept) => Effect.gen(function* pruneCached() {
|
|
|
2938
3077
|
const files = yield* RepositoryFiles;
|
|
2939
3078
|
const keep = new Set(pipe(kept, Array.map((key) => `${key}${CACHE_SUFFIX}`)));
|
|
2940
3079
|
const present = yield* files.readDirectory(cache.directory);
|
|
2941
|
-
yield* pipe(present, Array.filter((name) => !keep.has(name)), Effect.forEach((name) => files.removeFile(files.join(cache.directory, name))), Effect.asVoid);
|
|
3080
|
+
yield* pipe(present, Array.filter((name) => !keep.has(name)), (items) => Effect.forEach(items, (name) => files.removeFile(files.join(cache.directory, name)), { concurrency: 1 }), Effect.asVoid);
|
|
2942
3081
|
});
|
|
2943
3082
|
// src/features/value-owners/model/duplicates.ts
|
|
2944
3083
|
const DUPLICATE_THRESHOLD = 1;
|
|
@@ -2973,7 +3112,7 @@ const duplicateProblems = (relative) => (sites) => {
|
|
|
2973
3112
|
}))));
|
|
2974
3113
|
};
|
|
2975
3114
|
// src/features/value-owners/model/name-lists.ts
|
|
2976
|
-
const RULE$
|
|
3115
|
+
const RULE$16 = "hand-written-names";
|
|
2977
3116
|
const TEST_FILE = /\.test(?:\.[\w-]+)?\.[cm]?tsx?$/u;
|
|
2978
3117
|
const nameListOf = (site) => {
|
|
2979
3118
|
if (TEST_FILE.test(site.file) || site.values.length < 2) return Option.none();
|
|
@@ -2988,7 +3127,7 @@ const problemOf$4 = ({ list, reason }) => ({
|
|
|
2988
3127
|
file: list.site.file,
|
|
2989
3128
|
line: list.site.line,
|
|
2990
3129
|
column: list.site.column,
|
|
2991
|
-
rule: RULE$
|
|
3130
|
+
rule: RULE$16,
|
|
2992
3131
|
message: `The names ${formatValues(list.names)} are listed by hand, but ${reason}`
|
|
2993
3132
|
});
|
|
2994
3133
|
// src/features/value-owners/model/declared-names.ts
|
|
@@ -3107,7 +3246,7 @@ const nameOf = (text) => pipe(text, Option.flatMap(decodeManifest$1), Option.fla
|
|
|
3107
3246
|
const repositoryNamesOf = Effect.fn("repositoryNamesOf")(function* repositoryNamesOf(root) {
|
|
3108
3247
|
const files = yield* RepositoryFiles;
|
|
3109
3248
|
const listed = yield* files.listedFiles(root);
|
|
3110
|
-
const names = yield* pipe(listed, Array.filter((file) => files.basename(file) === MANIFEST$1), Effect.forEach((manifest) => files.readFile(files.join(root, manifest)).pipe(Effect.map(nameOf))));
|
|
3249
|
+
const names = yield* pipe(listed, Array.filter((file) => files.basename(file) === MANIFEST$1), (items) => Effect.forEach(items, (manifest) => files.readFile(files.join(root, manifest)).pipe(Effect.map(nameOf)), { concurrency: 1 }));
|
|
3111
3250
|
const paths = pipe(listed, Array.flatMap(prefixesOf), Array.dedupe);
|
|
3112
3251
|
return {
|
|
3113
3252
|
root,
|
|
@@ -3123,7 +3262,7 @@ const repositoryNamesOf = Effect.fn("repositoryNamesOf")(function* repositoryNam
|
|
|
3123
3262
|
// src/features/value-owners/model/check.ts
|
|
3124
3263
|
const scanOwners = Effect.fn("scanOwners")(function* scanOwners(workspace, configPaths) {
|
|
3125
3264
|
const ownerConfigs = yield* pipe(configPaths, Effect.filter(mentions$1(`@${OWNER_TAG}`)(workspace.compiler)));
|
|
3126
|
-
const scans = yield*
|
|
3265
|
+
const scans = yield* Effect.forEach(ownerConfigs, (configPath) => withProject(workspace)(configPath)((project) => Effect.sync(() => ownersIn(project))), { concurrency: 1 });
|
|
3127
3266
|
return combineOwnerScans(Array.getSomes(scans));
|
|
3128
3267
|
});
|
|
3129
3268
|
const scopeOf = (project, configPath) => ({
|
|
@@ -3175,13 +3314,13 @@ const analyzeProjects = Effect.fn("analyzeProjects")(function* analyzeProjects(w
|
|
|
3175
3314
|
const files = yield* RepositoryFiles;
|
|
3176
3315
|
const cache = yield* cacheFor(workspace.root, owners);
|
|
3177
3316
|
const listed = yield* files.listedFiles(workspace.root);
|
|
3178
|
-
const keyed = yield*
|
|
3317
|
+
const keyed = yield* Effect.forEach(configPaths, analyzeConfig({
|
|
3179
3318
|
workspace,
|
|
3180
3319
|
owners,
|
|
3181
3320
|
sourceChecks,
|
|
3182
3321
|
cache,
|
|
3183
3322
|
listed
|
|
3184
|
-
}))
|
|
3323
|
+
}), { concurrency: 1 });
|
|
3185
3324
|
const found = Array.getSomes(keyed);
|
|
3186
3325
|
yield* pruneAnalyses(cache)(pipe(found, Array.map(([key]) => key)));
|
|
3187
3326
|
return pipe(found, Array.map(([, analysis]) => analysis));
|
|
@@ -3218,7 +3357,7 @@ const checkRepository = Effect.fn("checkRepository")(function* checkRepository(r
|
|
|
3218
3357
|
/** @internal */
|
|
3219
3358
|
const checkSources = (root) => checkRepository(root, [passThroughWrappersIn]);
|
|
3220
3359
|
// src/features/agent-settings/model/missing-hooks.ts
|
|
3221
|
-
const RULE$
|
|
3360
|
+
const RULE$15 = "missing-hook";
|
|
3222
3361
|
const SETTINGS_FILE$1 = /^\.claude\/settings\.json$/u;
|
|
3223
3362
|
const PLUGIN_HOOKS_FILE = /(?:^|\/)hooks\/hooks\.json$/u;
|
|
3224
3363
|
const PROJECT_PATH = /(?<optional>--env-file-if-exists=)?\$\{?CLAUDE_PROJECT_DIR\}?(?:\\")?\/(?<path>[\w.@/-]+)/gu;
|
|
@@ -3231,7 +3370,7 @@ const referenceOf = (found) => pipe(groupOf$1("path")(found), Option.filter(() =
|
|
|
3231
3370
|
index: found.index ?? START$10
|
|
3232
3371
|
})), Option.toArray);
|
|
3233
3372
|
const referencesIn = (pattern, source) => pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.flatMap(referenceOf));
|
|
3234
|
-
const problemsIn$
|
|
3373
|
+
const problemsIn$6 = Effect.fn("problemsIn")(function* problemsIn({ root, file, base, pattern }) {
|
|
3235
3374
|
const files = yield* RepositoryFiles;
|
|
3236
3375
|
const text = yield* files.readFile(file);
|
|
3237
3376
|
if (Option.isNone(text)) return [];
|
|
@@ -3243,7 +3382,7 @@ const problemsIn$5 = Effect.fn("problemsIn")(function* problemsIn({ root, file,
|
|
|
3243
3382
|
return pipe(missing, Array.map(({ path, index }) => ({
|
|
3244
3383
|
file,
|
|
3245
3384
|
...positionOf(source)(index),
|
|
3246
|
-
rule: RULE$
|
|
3385
|
+
rule: RULE$15,
|
|
3247
3386
|
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.`
|
|
3248
3387
|
})));
|
|
3249
3388
|
});
|
|
@@ -3267,7 +3406,7 @@ const checkMissingHooks = Effect.fn("checkMissingHooks")(function* checkMissingH
|
|
|
3267
3406
|
}];
|
|
3268
3407
|
return [];
|
|
3269
3408
|
}));
|
|
3270
|
-
const found = yield* Effect.forEach(hookFiles, problemsIn$
|
|
3409
|
+
const found = yield* Effect.forEach(hookFiles, problemsIn$6, { concurrency: READ_CONCURRENCY$6 });
|
|
3271
3410
|
return Array.flatten(found);
|
|
3272
3411
|
});
|
|
3273
3412
|
// src/features/scripts/model/shell-scripts.ts
|
|
@@ -3276,9 +3415,9 @@ const SHELL_SHEBANG = /^#!\S*(?:\/|\s)(?:env\s+)?(?:-\S+\s+)*(?:ba|z|k|da)?sh\b|
|
|
|
3276
3415
|
const EXTENSION = /\.[^./]+$/u;
|
|
3277
3416
|
const SETTINGS_FILE = ".claude/settings.json";
|
|
3278
3417
|
const READ_CONCURRENCY$5 = 64;
|
|
3279
|
-
const FIRST$
|
|
3280
|
-
const RULE$
|
|
3281
|
-
const MESSAGE$
|
|
3418
|
+
const FIRST$4 = 1;
|
|
3419
|
+
const RULE$14 = "shell-script";
|
|
3420
|
+
const MESSAGE$5 = "is a shell script. Do the work in TypeScript as a Vite+ task in vite.config.ts, a test, or the tool's own hook, and delete this file. Only the SessionStart hook in .claude/settings.json, which installs the toolchain before TypeScript can run, stays a shell script.";
|
|
3282
3421
|
const HookSchema = Schema.Struct({
|
|
3283
3422
|
command: Schema.optional(Schema.String),
|
|
3284
3423
|
args: Schema.optional(Schema.Array(Schema.String))
|
|
@@ -3298,10 +3437,10 @@ const baseName = (name) => pipe(String$1.split("/")(name), Array.last, Option.ge
|
|
|
3298
3437
|
const hasExtension = (name) => EXTENSION.test(baseName(name));
|
|
3299
3438
|
const problemFor$1 = (file) => ({
|
|
3300
3439
|
file,
|
|
3301
|
-
line: FIRST$
|
|
3302
|
-
column: FIRST$
|
|
3303
|
-
rule: RULE$
|
|
3304
|
-
message: MESSAGE$
|
|
3440
|
+
line: FIRST$4,
|
|
3441
|
+
column: FIRST$4,
|
|
3442
|
+
rule: RULE$14,
|
|
3443
|
+
message: MESSAGE$5
|
|
3305
3444
|
});
|
|
3306
3445
|
/** @internal */
|
|
3307
3446
|
const checkShellScripts = Effect.fn("checkShellScripts")(function* checkShellScripts(root) {
|
|
@@ -3353,28 +3492,28 @@ const runScriptsOf = (source) => {
|
|
|
3353
3492
|
const COMMAND_CHAIN = /&&|\|\||;|\|/u;
|
|
3354
3493
|
const QUOTED$1 = /\$\{\{.*?\}\}|"(?:[^"\\]|\\.)*"|'[^']*'/gu;
|
|
3355
3494
|
const COMMENT = "#";
|
|
3356
|
-
const RULE$
|
|
3495
|
+
const RULE$13 = "workflow-script";
|
|
3357
3496
|
const ONE_COMMAND = 1;
|
|
3358
|
-
const MESSAGE$
|
|
3497
|
+
const MESSAGE$4 = "runs more than one command. Keep a step to one command, `vp run <task>` or `vp exec <bin>`, and put the logic in a Vite+ task in TypeScript.";
|
|
3359
3498
|
const isCommand = (line) => String$1.isNonEmpty(line) && !String$1.startsWith(COMMENT)(line);
|
|
3360
3499
|
const chainsCommands = (line) => COMMAND_CHAIN.test(String$1.replaceAll(QUOTED$1, "")(line));
|
|
3361
3500
|
const runsMoreThanOneCommand = ({ text }) => {
|
|
3362
3501
|
const lines = pipe(String$1.split("\n")(text), Array.map(String$1.trim), Array.filter(isCommand));
|
|
3363
3502
|
return lines.length > ONE_COMMAND || pipe(lines, Array.some(chainsCommands));
|
|
3364
3503
|
};
|
|
3365
|
-
const problemsIn$
|
|
3504
|
+
const problemsIn$5 = (file) => (source) => {
|
|
3366
3505
|
const at = positionOf(source);
|
|
3367
3506
|
return pipe(runScriptsOf(source), Array.filter(runsMoreThanOneCommand), Array.map(({ start }) => ({
|
|
3368
3507
|
file,
|
|
3369
3508
|
...at(start),
|
|
3370
|
-
rule: RULE$
|
|
3371
|
-
message: MESSAGE$
|
|
3509
|
+
rule: RULE$13,
|
|
3510
|
+
message: MESSAGE$4
|
|
3372
3511
|
})));
|
|
3373
3512
|
};
|
|
3374
3513
|
/** @internal */
|
|
3375
3514
|
const checkWorkflows = Effect.fn("checkWorkflows")(function* checkWorkflows(root) {
|
|
3376
3515
|
const workflows = yield* readWorkflows(root);
|
|
3377
|
-
return pipe(workflows, Array.flatMap(({ file, source }) => problemsIn$
|
|
3516
|
+
return pipe(workflows, Array.flatMap(({ file, source }) => problemsIn$5(file)(source)));
|
|
3378
3517
|
});
|
|
3379
3518
|
// src/features/scripts/model/script-checks.ts
|
|
3380
3519
|
/** @internal */
|
|
@@ -3442,7 +3581,7 @@ const ROOT_DIRECTORY = ".";
|
|
|
3442
3581
|
const COMMAND_KEY = "command";
|
|
3443
3582
|
const ARGUMENTS_KEY = "args";
|
|
3444
3583
|
const EXCLUDED$1 = [":(exclude,attr:linguist-vendored)", ":(exclude,attr:linguist-generated)"];
|
|
3445
|
-
const MANIFESTS = [`:(glob)**/${MANIFEST_FILE}`, ...EXCLUDED$1];
|
|
3584
|
+
const MANIFESTS = [`:(glob)**/${MANIFEST_FILE$1}`, ...EXCLUDED$1];
|
|
3446
3585
|
const STEP_FILES = [
|
|
3447
3586
|
":(glob).github/workflows/*.yml",
|
|
3448
3587
|
":(glob).github/workflows/*.yaml",
|
|
@@ -3454,7 +3593,7 @@ const HOOK_FILES = [":(glob).vite-hooks/*"];
|
|
|
3454
3593
|
const AGENT_FILES = [".claude/settings.json", ".mcp.json"];
|
|
3455
3594
|
const READ_CONCURRENCY$3 = 16;
|
|
3456
3595
|
const START$8 = 0;
|
|
3457
|
-
const FIRST$
|
|
3596
|
+
const FIRST$3 = 1;
|
|
3458
3597
|
const LINE = "\n";
|
|
3459
3598
|
const CommandText = Schema.Union([Schema.String, Schema.Array(Schema.String)]);
|
|
3460
3599
|
const decodeCommandText = Schema.decodeUnknownOption(CommandText);
|
|
@@ -3485,8 +3624,8 @@ const hookSources = (file, name) => (source) => pipe(String$1.split(source, LINE
|
|
|
3485
3624
|
kind: "hook",
|
|
3486
3625
|
file,
|
|
3487
3626
|
position: {
|
|
3488
|
-
line: index + FIRST$
|
|
3489
|
-
column: FIRST$
|
|
3627
|
+
line: index + FIRST$3,
|
|
3628
|
+
column: FIRST$3
|
|
3490
3629
|
},
|
|
3491
3630
|
name,
|
|
3492
3631
|
text
|
|
@@ -3557,7 +3696,7 @@ const commandSources = Effect.fn("commandSources")(function* commandSources(root
|
|
|
3557
3696
|
return Array.flatten(found);
|
|
3558
3697
|
});
|
|
3559
3698
|
// src/features/vite-plus/model/package-scripts.ts
|
|
3560
|
-
const RULE$
|
|
3699
|
+
const RULE$12 = "package-script";
|
|
3561
3700
|
const LIFECYCLE = [
|
|
3562
3701
|
"preinstall",
|
|
3563
3702
|
"install",
|
|
@@ -3580,26 +3719,26 @@ const LIFECYCLE = [
|
|
|
3580
3719
|
const problemOf$3 = ({ file, position, name }) => ({
|
|
3581
3720
|
file,
|
|
3582
3721
|
...position,
|
|
3583
|
-
rule: RULE$
|
|
3722
|
+
rule: RULE$12,
|
|
3584
3723
|
message: `The script ${name} is not a lifecycle script. package.json scripts hold only the scripts the package manager runs by itself, such as prepare and prepack. Write ${name} as a task in run.tasks of this package's vite.config.ts, where its shape is type-checked.`
|
|
3585
3724
|
});
|
|
3586
3725
|
const packageScriptProblems = (sources) => pipe(sources, Array.filter(({ kind, name }) => kind === "script" && !Array.contains(LIFECYCLE, name)), Array.map(problemOf$3));
|
|
3587
3726
|
// src/features/vite-plus/model/vite-plus-block.ts
|
|
3588
|
-
const RULE$
|
|
3727
|
+
const RULE$11 = "vite-plus-block";
|
|
3589
3728
|
const MARKER = Array.join([
|
|
3590
3729
|
"<!--",
|
|
3591
3730
|
"VITE PLUS START",
|
|
3592
3731
|
"-->"
|
|
3593
3732
|
], "");
|
|
3594
|
-
const MESSAGE$
|
|
3733
|
+
const MESSAGE$3 = "holds the Vite+ block that `vp create --agent` and `vp migrate --agent` write, and every `vp config` rewrites it. Delete the block with its markers. The vite-plus skill reads the same guidance from node_modules/vite-plus/AGENTS.md.";
|
|
3595
3734
|
const problemIn$1 = (file) => (source) => {
|
|
3596
3735
|
const index = String$1.indexOf(MARKER)(source);
|
|
3597
3736
|
if (Option.isNone(index)) return Option.none();
|
|
3598
3737
|
return Option.some({
|
|
3599
3738
|
file,
|
|
3600
3739
|
...positionOf(source)(index.value),
|
|
3601
|
-
rule: RULE$
|
|
3602
|
-
message: MESSAGE$
|
|
3740
|
+
rule: RULE$11,
|
|
3741
|
+
message: MESSAGE$3
|
|
3603
3742
|
});
|
|
3604
3743
|
};
|
|
3605
3744
|
/** @internal */
|
|
@@ -3614,36 +3753,55 @@ const checkVitePlus = Effect.fn("checkVitePlus")(function* checkVitePlus(root) {
|
|
|
3614
3753
|
...blocks
|
|
3615
3754
|
];
|
|
3616
3755
|
});
|
|
3617
|
-
// src/features/
|
|
3618
|
-
const
|
|
3619
|
-
const QUEUE_KEY = "queue";
|
|
3620
|
-
const RULE$8 = "workflow-queue";
|
|
3621
|
-
const MESSAGE$1 = "queues runs with `queue`. A queued group runs every old push one by one, so a long run holds back the newest commit for hours. Drop `queue`: a job that later pushes redo gets `cancel-in-progress: true`, and a deploy or release job keeps the default, which lets the running one finish and replaces the waiting one with the newest run.";
|
|
3622
|
-
const queueKeyOf = (node) => pipe(Option.liftPredicate(node, isMap), Option.flatMap((map) => Array.findFirst(map.items, (item) => isScalar(item.key) && item.key.value === QUEUE_KEY)), Option.flatMap(({ key }) => Option.liftPredicate(key, isScalar)), Option.flatMap((key) => Option.fromNullishOr(key.range)), Option.map(([start]) => start));
|
|
3623
|
-
const queueOffsetsOf = (source) => {
|
|
3756
|
+
// src/features/workflows/model/workflow-yaml.ts
|
|
3757
|
+
const pairsNamed = (name) => (source) => {
|
|
3624
3758
|
const found = [];
|
|
3625
3759
|
visit(parseDocument(source), { Pair: (_key, pair) => {
|
|
3626
|
-
if (isPair(pair) && isScalar(pair.key) && pair.key.value ===
|
|
3760
|
+
if (isPair(pair) && isScalar(pair.key) && pair.key.value === name) found.push(pair);
|
|
3627
3761
|
} });
|
|
3628
3762
|
return found;
|
|
3629
3763
|
};
|
|
3630
|
-
|
|
3631
|
-
const checkWorkflowQueues = Effect.fn("checkWorkflowQueues")(function* checkWorkflowQueues(root) {
|
|
3764
|
+
const workflowCheck = ({ rule, message, offsetsOf }) => Effect.fn(rule)(function* checkWorkflows(root) {
|
|
3632
3765
|
const workflows = yield* readWorkflows(root);
|
|
3633
3766
|
return pipe(workflows, Array.flatMap(({ file, source }) => {
|
|
3634
3767
|
const at = positionOf(source);
|
|
3635
|
-
return pipe(
|
|
3768
|
+
return pipe(offsetsOf(source), Array.map((offset) => {
|
|
3636
3769
|
const { line, column } = at(offset);
|
|
3637
3770
|
return {
|
|
3638
3771
|
file,
|
|
3639
3772
|
line,
|
|
3640
3773
|
column,
|
|
3641
|
-
rule
|
|
3642
|
-
message
|
|
3774
|
+
rule,
|
|
3775
|
+
message
|
|
3643
3776
|
};
|
|
3644
3777
|
}));
|
|
3645
3778
|
}));
|
|
3646
3779
|
});
|
|
3780
|
+
// src/features/workflows/model/full-history-checkout.ts
|
|
3781
|
+
const DEPTH_KEY = "fetch-depth";
|
|
3782
|
+
const WHOLE_HISTORY = "0";
|
|
3783
|
+
const RULE$10 = "full-history-checkout";
|
|
3784
|
+
const MESSAGE$2 = "fetches the whole history with `fetch-depth: 0`. Fetch only the commits the job reads.";
|
|
3785
|
+
const fullHistoryOffsetsOf = (source) => pipe(pairsNamed(DEPTH_KEY)(source), Array.filter(({ value }) => isScalar(value) && String(value.value) === WHOLE_HISTORY), Array.flatMap(({ key }) => pipe(Option.liftPredicate(key, isScalar), Option.flatMap((scalar) => Option.fromNullishOr(scalar.range)), Option.map(([start]) => start), Option.toArray)));
|
|
3786
|
+
/** @internal */
|
|
3787
|
+
const checkFullHistoryCheckout = workflowCheck({
|
|
3788
|
+
rule: RULE$10,
|
|
3789
|
+
message: MESSAGE$2,
|
|
3790
|
+
offsetsOf: fullHistoryOffsetsOf
|
|
3791
|
+
});
|
|
3792
|
+
// src/features/workflows/model/workflow-queue.ts
|
|
3793
|
+
const CONCURRENCY_KEY = "concurrency";
|
|
3794
|
+
const QUEUE_KEY = "queue";
|
|
3795
|
+
const RULE$9 = "workflow-queue";
|
|
3796
|
+
const MESSAGE$1 = "queues runs with `queue`. A queued group runs every old push one by one, so a long run holds back the newest commit for hours. Drop `queue`: a job that later pushes redo gets `cancel-in-progress: true`, and a deploy or release job keeps the default, which lets the running one finish and replaces the waiting one with the newest run.";
|
|
3797
|
+
const queueKeyOf = (node) => pipe(Option.liftPredicate(node, isMap), Option.flatMap((map) => Array.findFirst(map.items, (item) => isScalar(item.key) && item.key.value === QUEUE_KEY)), Option.flatMap(({ key }) => Option.liftPredicate(key, isScalar)), Option.flatMap((key) => Option.fromNullishOr(key.range)), Option.map(([start]) => start));
|
|
3798
|
+
const queueOffsetsOf = (source) => pipe(pairsNamed(CONCURRENCY_KEY)(source), Array.flatMap((pair) => Option.toArray(queueKeyOf(pair.value))));
|
|
3799
|
+
/** @internal */
|
|
3800
|
+
const checkWorkflowQueues = workflowCheck({
|
|
3801
|
+
rule: RULE$9,
|
|
3802
|
+
message: MESSAGE$1,
|
|
3803
|
+
offsetsOf: queueOffsetsOf
|
|
3804
|
+
});
|
|
3647
3805
|
// src/app/tool-use.ts
|
|
3648
3806
|
/** @internal */
|
|
3649
3807
|
const checkToolUse = Effect.fn("checkToolUse")(function* checkToolUse(root) {
|
|
@@ -3652,6 +3810,7 @@ const checkToolUse = Effect.fn("checkToolUse")(function* checkToolUse(root) {
|
|
|
3652
3810
|
checkMissingHooks(root),
|
|
3653
3811
|
checkScripts(root),
|
|
3654
3812
|
checkWorkflowQueues(root),
|
|
3813
|
+
checkFullHistoryCheckout(root),
|
|
3655
3814
|
checkRestrictedRules(root)
|
|
3656
3815
|
], { concurrency: "unbounded" });
|
|
3657
3816
|
return Array.flatten(found);
|
|
@@ -3835,7 +3994,7 @@ const loadGrammars = Effect.fn("loadGrammars")(function* loadGrammars() {
|
|
|
3835
3994
|
try: () => treeSitter.Parser.init(),
|
|
3836
3995
|
catch: unreadable("javascript")
|
|
3837
3996
|
});
|
|
3838
|
-
const loaded = yield*
|
|
3997
|
+
const loaded = yield* Effect.forEach(GRAMMARS, (grammar) => loadGrammar(grammar), { concurrency: 1 });
|
|
3839
3998
|
const languages = Record.fromEntries(loaded);
|
|
3840
3999
|
const grammars = (grammar) => Record.get(languages, grammar);
|
|
3841
4000
|
return grammars;
|
|
@@ -3893,7 +4052,7 @@ const embeddedComments = (grammars) => (node) => {
|
|
|
3893
4052
|
const texts = pipe(node.children, Array.filter(isText));
|
|
3894
4053
|
return Option.match(embeddedGrammar(node), {
|
|
3895
4054
|
onNone: () => Effect.succeed(NONE$1),
|
|
3896
|
-
onSome: (grammar) => pipe(texts, Effect.forEach(textComments(grammars, grammar)), Effect.map(Array.flatten))
|
|
4055
|
+
onSome: (grammar) => pipe(texts, (items) => Effect.forEach(items, textComments(grammars, grammar), { concurrency: 1 }), Effect.map(Array.flatten))
|
|
3897
4056
|
});
|
|
3898
4057
|
};
|
|
3899
4058
|
const markupComments = (grammars, markup) => (source) => Effect.gen(function* readMarkup() {
|
|
@@ -3905,7 +4064,7 @@ const markupComments = (grammars, markup) => (source) => Effect.gen(function* re
|
|
|
3905
4064
|
const nodes = DomUtils.filter(() => true, document.children, true);
|
|
3906
4065
|
const own = pipe(nodes, Array.flatMap(markupComment(source)));
|
|
3907
4066
|
if (markup === "xml") return own;
|
|
3908
|
-
const embedded = yield*
|
|
4067
|
+
const embedded = yield* Effect.forEach(nodes, embeddedComments(grammars), { concurrency: 1 });
|
|
3909
4068
|
return [...own, ...Array.flatten(embedded)];
|
|
3910
4069
|
});
|
|
3911
4070
|
const isGrammar = (reader) => pipe(GRAMMARS, Array.contains(reader));
|
|
@@ -3921,7 +4080,7 @@ const commentsWith = (grammars) => (reader, source) => {
|
|
|
3921
4080
|
}[reader](source);
|
|
3922
4081
|
};
|
|
3923
4082
|
// src/features/comments/model/comments.ts
|
|
3924
|
-
const RULE$
|
|
4083
|
+
const RULE$8 = "comment";
|
|
3925
4084
|
const CONFIG_FILE = "vite.config.ts";
|
|
3926
4085
|
const VENDORED_PATHSPEC = ":(attr:linguist-vendored)";
|
|
3927
4086
|
const READ_CONCURRENCY$2 = 64;
|
|
@@ -3991,14 +4150,14 @@ const isAllowed = (source, directives) => (comment) => isShebang(comment) || dir
|
|
|
3991
4150
|
const problemOf$2 = (file, source) => ({ index }) => ({
|
|
3992
4151
|
file,
|
|
3993
4152
|
...positionOf(source)(index),
|
|
3994
|
-
rule: RULE$
|
|
4153
|
+
rule: RULE$8,
|
|
3995
4154
|
message: MESSAGE
|
|
3996
4155
|
});
|
|
3997
4156
|
const unreadableProblem = (file, message) => ({
|
|
3998
4157
|
file,
|
|
3999
4158
|
line: FIRST_LINE$1,
|
|
4000
4159
|
column: FIRST_COLUMN$1,
|
|
4001
|
-
rule: RULE$
|
|
4160
|
+
rule: RULE$8,
|
|
4002
4161
|
message: `msch could not read the comments in this file: ${message}`
|
|
4003
4162
|
});
|
|
4004
4163
|
const settingsOf = ({ msch, lint }) => ({
|
|
@@ -4063,18 +4222,18 @@ const START$5 = 0;
|
|
|
4063
4222
|
const HEX = 16;
|
|
4064
4223
|
const CODE_POINT_WIDTH = 4;
|
|
4065
4224
|
const READ_CONCURRENCY$1 = 64;
|
|
4066
|
-
const RULE$
|
|
4225
|
+
const RULE$7 = "hidden-unicode";
|
|
4067
4226
|
const hexOf = (character) => pipe(String$1.codePointAt(START$5)(character), Option.getOrElse(() => START$5), (code) => code.toString(HEX), String$1.toUpperCase, String$1.padStart(CODE_POINT_WIDTH, "0"));
|
|
4068
4227
|
const problemOf$1 = (file, source) => (found) => {
|
|
4069
4228
|
const hex = hexOf(found[START$5]);
|
|
4070
4229
|
return {
|
|
4071
4230
|
file,
|
|
4072
4231
|
...positionOf(source)(found.index ?? START$5),
|
|
4073
|
-
rule: RULE$
|
|
4232
|
+
rule: RULE$7,
|
|
4074
4233
|
message: `U+${hex} is invisible in editors and reviews and can change what the text means. Remove it, or write it as the escape \\u${hex}.`
|
|
4075
4234
|
};
|
|
4076
4235
|
};
|
|
4077
|
-
const problemsIn$
|
|
4236
|
+
const problemsIn$4 = (file, source) => {
|
|
4078
4237
|
if (String$1.includes(NUL)(source)) return [];
|
|
4079
4238
|
return pipe(Array.fromIterable(String$1.matchAll(HIDDEN)(source)), Array.map(problemOf$1(file, source)));
|
|
4080
4239
|
};
|
|
@@ -4086,13 +4245,13 @@ const checkHiddenUnicode = Effect.fn("checkHiddenUnicode")(function* checkHidden
|
|
|
4086
4245
|
const file = files.join(root, name);
|
|
4087
4246
|
return files.readFile(file).pipe(Effect.map(Option.match({
|
|
4088
4247
|
onNone: () => [],
|
|
4089
|
-
onSome: (source) => problemsIn$
|
|
4248
|
+
onSome: (source) => problemsIn$4(file, source)
|
|
4090
4249
|
})));
|
|
4091
4250
|
}, { concurrency: READ_CONCURRENCY$1 });
|
|
4092
4251
|
return Array.flatten(found);
|
|
4093
4252
|
});
|
|
4094
4253
|
// src/features/runtime-version/model/node-version.ts
|
|
4095
|
-
const RULE$
|
|
4254
|
+
const RULE$6 = "node-version";
|
|
4096
4255
|
const MINIMUM = 26;
|
|
4097
4256
|
const SUPPORTED = `Node.js ${String(MINIMUM)} or later is the only supported runtime.`;
|
|
4098
4257
|
const MANIFEST = /(?:^|\/)package\.json$/u;
|
|
@@ -4123,19 +4282,19 @@ const floorIsOld = (alternative) => pipe(floorOf(alternative), Option.match({
|
|
|
4123
4282
|
onSome: isOld
|
|
4124
4283
|
}));
|
|
4125
4284
|
const admitsOld = (range) => pipe(String$1.split(range, ALTERNATIVE), Array.some(floorIsOld));
|
|
4126
|
-
const problemAt$
|
|
4285
|
+
const problemAt$2 = ({ entry, source, index }, message) => ({
|
|
4127
4286
|
file: entry.file,
|
|
4128
4287
|
...positionOf(source)(index),
|
|
4129
|
-
rule: RULE$
|
|
4288
|
+
rule: RULE$6,
|
|
4130
4289
|
message
|
|
4131
4290
|
});
|
|
4132
4291
|
const offsetOf$1 = (source, text) => pipe(String$1.indexOf(text)(source), Option.getOrElse(() => START$4));
|
|
4133
|
-
const unstatedProblem = (entry, source) => problemAt$
|
|
4292
|
+
const unstatedProblem = (entry, source) => problemAt$2({
|
|
4134
4293
|
entry,
|
|
4135
4294
|
source,
|
|
4136
4295
|
index: START$4
|
|
4137
4296
|
}, `${SUPPORTED} This package is published without engines.node, so its users cannot tell. Set engines.node to ">=${String(MINIMUM)}".`);
|
|
4138
|
-
const rangeProblem = (entry, source) => (range) => problemAt$
|
|
4297
|
+
const rangeProblem = (entry, source) => (range) => problemAt$2({
|
|
4139
4298
|
entry,
|
|
4140
4299
|
source,
|
|
4141
4300
|
index: offsetOf$1(source, ENGINES_KEY)
|
|
@@ -4149,17 +4308,17 @@ const manifestProblems = (entry, source) => {
|
|
|
4149
4308
|
if (Option.isNone(range) && isPublished(manifest.value)) return [unstatedProblem(entry, source)];
|
|
4150
4309
|
return pipe(range, Option.filter(admitsOld), Option.map(rangeProblem(entry, source)), Option.toArray);
|
|
4151
4310
|
};
|
|
4152
|
-
const pinnedProblems = (pattern) => (entry, source) => pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.filter((found) => Option.exists(majorOf(found), isOld)), Array.map((found) => problemAt$
|
|
4311
|
+
const pinnedProblems = (pattern) => (entry, source) => pipe(Array.fromIterable(String$1.matchAll(pattern)(source)), Array.filter((found) => Option.exists(majorOf(found), isOld)), Array.map((found) => problemAt$2({
|
|
4153
4312
|
entry,
|
|
4154
4313
|
source,
|
|
4155
4314
|
index: found.index ?? START$4
|
|
4156
4315
|
}, `${SUPPORTED} \`${String$1.trim(found[START$4])}\` pins an older one. Raise it to ${String(MINIMUM)} or later.`)));
|
|
4157
|
-
const versionFileProblems = (entry, source) => pipe(majorOf(PINNED_VERSION.exec(source)), Option.filter(isOld), Option.map((major) => problemAt$
|
|
4316
|
+
const versionFileProblems = (entry, source) => pipe(majorOf(PINNED_VERSION.exec(source)), Option.filter(isOld), Option.map((major) => problemAt$2({
|
|
4158
4317
|
entry,
|
|
4159
4318
|
source,
|
|
4160
4319
|
index: START$4
|
|
4161
4320
|
}, `${SUPPORTED} This file pins ${String(major)}. Raise it to ${String(MINIMUM)} or later.`)), Option.toArray);
|
|
4162
|
-
const problemsIn$
|
|
4321
|
+
const problemsIn$3 = (entry, source) => {
|
|
4163
4322
|
if (MANIFEST.test(entry.name)) return manifestProblems(entry, source);
|
|
4164
4323
|
if (VERSION_FILE.test(entry.name)) return versionFileProblems(entry, source);
|
|
4165
4324
|
if (DOCKERFILE.test(entry.name)) return pinnedProblems(BASE_IMAGE)(entry, source);
|
|
@@ -4171,15 +4330,15 @@ const isVersionSource = (entry) => VERSION_FILE.test(entry.name) || DOCKERFILE.t
|
|
|
4171
4330
|
const checkNodeVersion = Effect.fn("checkNodeVersion")(function* checkNodeVersion(root) {
|
|
4172
4331
|
const files = yield* RepositoryFiles;
|
|
4173
4332
|
const listed = yield* listedFiles(root);
|
|
4174
|
-
const manifests = yield* files.matchingFiles(root, [`:(glob)**/${MANIFEST_FILE}`, ...EXCLUDED]);
|
|
4333
|
+
const manifests = yield* files.matchingFiles(root, [`:(glob)**/${MANIFEST_FILE$1}`, ...EXCLUDED]);
|
|
4175
4334
|
const sources = [...pipe(listed, Array.filter(isVersionSource)), ...pipe(manifests, Array.map((name) => ({
|
|
4176
4335
|
name,
|
|
4177
4336
|
file: files.join(root, name)
|
|
4178
4337
|
})))];
|
|
4179
|
-
return yield* scanText(sources, problemsIn$
|
|
4338
|
+
return yield* scanText(sources, problemsIn$3);
|
|
4180
4339
|
});
|
|
4181
4340
|
// src/features/skills/model/skill-entry.ts
|
|
4182
|
-
const RULE$
|
|
4341
|
+
const RULE$5 = "unlocked-skill";
|
|
4183
4342
|
const LOCK_FILE = "skills-lock.json";
|
|
4184
4343
|
const SOURCE = "masseater/skills";
|
|
4185
4344
|
const ENTRY = "masseater-ecosystem";
|
|
@@ -4193,7 +4352,7 @@ const fixFor = (name) => `Run "vp exec skills add ${SOURCE} -s ${name} -y". The
|
|
|
4193
4352
|
const problemIn = ({ file, source }) => (anchor, message) => ({
|
|
4194
4353
|
file,
|
|
4195
4354
|
...positionOf(source)(pipe(String$1.indexOf(anchor)(source), Option.getOrElse(() => START$3))),
|
|
4196
|
-
rule: RULE$
|
|
4355
|
+
rule: RULE$5,
|
|
4197
4356
|
message
|
|
4198
4357
|
});
|
|
4199
4358
|
const lockedSkills = Effect.fn("lockedSkills")(function* lockedSkills(root) {
|
|
@@ -4217,6 +4376,58 @@ const checkSkillEntry = Effect.fn("checkSkillEntry")(function* checkSkillEntry(r
|
|
|
4217
4376
|
const entry = yield* files.readFile(files.join(root, INSTALLED_ENTRY));
|
|
4218
4377
|
return pipe(entry, Option.map(namedIn), Option.getOrElse(() => []), Array.filter((name) => !Array.contains(names, name)), Array.map((name) => problemAt(`"${ENTRY}"`, `${ENTRY} tells agents to read ${name}, which this file does not install. ${fixFor(name)}`)));
|
|
4219
4378
|
});
|
|
4379
|
+
// src/features/skills/model/published-skills.ts
|
|
4380
|
+
const RULE$4 = "published-skills";
|
|
4381
|
+
const KEYWORD = "tanstack-intent";
|
|
4382
|
+
const SKILLS = "skills";
|
|
4383
|
+
const MANIFEST_FILE = "package.json";
|
|
4384
|
+
const SKILL_FILE$1 = "SKILL.md";
|
|
4385
|
+
const FIRST$2 = 1;
|
|
4386
|
+
const SUCCEEDED = 0;
|
|
4387
|
+
const SYNC = "Run vp exec intent maintainer sync in the repository root.";
|
|
4388
|
+
const INTENT_CLI = fileURLToPath(new URL("./cli.mjs", import.meta.resolve("@tanstack/intent")));
|
|
4389
|
+
const problemAt$1 = (file, message) => ({
|
|
4390
|
+
file,
|
|
4391
|
+
line: FIRST$2,
|
|
4392
|
+
column: FIRST$2,
|
|
4393
|
+
rule: RULE$4,
|
|
4394
|
+
message
|
|
4395
|
+
});
|
|
4396
|
+
const skillDirectoriesIn = (files, directory) => pipe(findSkillFiles(files.join(directory, SKILLS)), Array.filter((file) => files.basename(file) === SKILL_FILE$1), Array.map((file) => files.relative(directory, files.dirname(file))));
|
|
4397
|
+
const isShipped = (listed) => (skill) => Array.contains(listed, SKILLS) || Array.contains(listed, skill);
|
|
4398
|
+
const packagingMessages = ({ keywords, files }, skills) => {
|
|
4399
|
+
const keyword = pipe(Option.liftPredicate(keywords, (own) => !Array.contains(own, KEYWORD)), Option.map(() => `is published with skills but lacks the ${KEYWORD} keyword, so Intent does not find them. ${SYNC}`));
|
|
4400
|
+
const unshipped = pipe(files, Option.map((listed) => pipe(skills, Array.filter((skill) => !isShipped(listed)(skill)))), Option.filter((left) => Array.isReadonlyArrayNonEmpty(left)), Option.map((left) => `leaves ${Array.join(left, ", ")} out of files, so the published package does not ship them. ${SYNC}`));
|
|
4401
|
+
return Array.getSomes([keyword, unshipped]);
|
|
4402
|
+
};
|
|
4403
|
+
const validationOf = Effect.fn("validationOf")(function* validationOf(directory) {
|
|
4404
|
+
const handle = yield* ChildProcess.make("node", [
|
|
4405
|
+
INTENT_CLI,
|
|
4406
|
+
"validate",
|
|
4407
|
+
SKILLS
|
|
4408
|
+
], {
|
|
4409
|
+
cwd: directory,
|
|
4410
|
+
extendEnv: true,
|
|
4411
|
+
stdin: "ignore"
|
|
4412
|
+
});
|
|
4413
|
+
const [output, status] = yield* Effect.all([handle.all.pipe(Stream.decodeText(), Stream.mkString), handle.exitCode], { concurrency: "unbounded" });
|
|
4414
|
+
return Option.liftPredicate(String$1.trim(output), () => Number(status) !== SUCCEEDED);
|
|
4415
|
+
}, Effect.scoped);
|
|
4416
|
+
const problemsIn$2 = Effect.fn("problemsIn")(function* problemsIn(root, project) {
|
|
4417
|
+
const files = yield* RepositoryFiles;
|
|
4418
|
+
const directory = files.join(root, project.directory);
|
|
4419
|
+
const manifest = files.join(directory, MANIFEST_FILE);
|
|
4420
|
+
const skills = skillDirectoriesIn(files, directory);
|
|
4421
|
+
if (!Array.isReadonlyArrayNonEmpty(skills)) return [problemAt$1(manifest, `is published without TanStack Intent skills. Write the tasks an agent needs for this package as ${SKILLS}/<task>/${SKILL_FILE$1} with vp exec intent maintainer add, so agents in the repositories that install it load guidance for the installed version.`)];
|
|
4422
|
+
const validation = yield* validationOf(directory).pipe(Effect.orElseSucceed(() => Option.none()));
|
|
4423
|
+
return [...pipe(packagingMessages(project, skills), Array.map((message) => problemAt$1(manifest, message))), ...pipe(validation, Option.map((output) => problemAt$1(files.join(directory, SKILLS), `fails intent validate:\n${output}`)), Option.toArray)];
|
|
4424
|
+
});
|
|
4425
|
+
/** @internal */
|
|
4426
|
+
const checkPublishedSkills = Effect.fn("checkPublishedSkills")(function* checkPublishedSkills(root) {
|
|
4427
|
+
const projects = yield* workspaceProjects(root);
|
|
4428
|
+
const problems = yield* Effect.forEach(pipe(projects, Array.filter(({ published }) => published)), (project) => problemsIn$2(root, project), { concurrency: 1 });
|
|
4429
|
+
return Array.flatten(problems);
|
|
4430
|
+
});
|
|
4220
4431
|
// src/features/skills/model/skill-files.ts
|
|
4221
4432
|
const RULE$3 = "skill-file";
|
|
4222
4433
|
const SKILL_FILE = /(?:^|\/)SKILL\.md$/u;
|
|
@@ -4343,26 +4554,25 @@ const RULE$2 = "alchemy-patch";
|
|
|
4343
4554
|
const WORKSPACE_FILE$2 = "pnpm-workspace.yaml";
|
|
4344
4555
|
const ALCHEMY$1 = /^(?:alchemy|@alchemy\.run\/[^@]+)(?:@.*)?$/u;
|
|
4345
4556
|
const START$1 = 0;
|
|
4346
|
-
const WorkspaceFile$1 = Schema.Struct({ patchedDependencies: Schema.optionalKey(Schema.Record(Schema.String, Schema.Unknown)) });
|
|
4347
|
-
const decodeWorkspaceFile$1 = Schema.decodeUnknownOption(WorkspaceFile$1);
|
|
4348
|
-
const patchedIn = (source) => pipe(decodeWorkspaceFile$1(parse$1(source)), Option.flatMap(({ patchedDependencies }) => Option.fromUndefinedOr(patchedDependencies)), Option.map(Record.keys), Option.getOrElse(() => []));
|
|
4349
4557
|
const problemOf = (file, position, name) => ({
|
|
4350
4558
|
file,
|
|
4351
4559
|
...position,
|
|
4352
4560
|
rule: RULE$2,
|
|
4353
4561
|
message: `patches ${name}. A patch breaks on every Alchemy release. Define the missing setting as a custom resource in the stack and delete the patch.`
|
|
4354
4562
|
});
|
|
4355
|
-
const problemsIn = (file) => (source) => {
|
|
4563
|
+
const problemsIn = (file, patched) => (source) => {
|
|
4356
4564
|
const at = positionOf(source);
|
|
4357
4565
|
const offsetOf = (name) => pipe(String$1.indexOf(name)(source), Option.getOrElse(() => START$1));
|
|
4358
|
-
return pipe(
|
|
4566
|
+
return pipe(patched, Array.filter((name) => ALCHEMY$1.test(name)), Array.map((name) => problemOf(file, at(offsetOf(name)), name)));
|
|
4359
4567
|
};
|
|
4360
4568
|
/** @internal */
|
|
4361
4569
|
const checkAlchemyPatch = Effect.fn("checkAlchemyPatch")(function* checkAlchemyPatch(root) {
|
|
4362
4570
|
const files = yield* RepositoryFiles;
|
|
4363
4571
|
const file = files.join(root, WORKSPACE_FILE$2);
|
|
4364
4572
|
const text = yield* files.readFile(file);
|
|
4365
|
-
|
|
4573
|
+
const manifest = yield* workspaceManifest(root);
|
|
4574
|
+
const patched = pipe(manifest, Option.flatMap(({ patchedDependencies }) => Option.fromUndefinedOr(patchedDependencies)), Option.map(Record.keys), Option.getOrElse(() => []));
|
|
4575
|
+
return pipe(text, Option.map(problemsIn(file, patched)), Option.getOrElse(() => []));
|
|
4366
4576
|
});
|
|
4367
4577
|
// src/features/unneeded-files/model/applied-packages.ts
|
|
4368
4578
|
const MSCH = "@r_masseater/msch";
|
|
@@ -4388,7 +4598,7 @@ const binsIn = (name, text) => pipe(decodeBinField(text), Option.flatMap(({ bin
|
|
|
4388
4598
|
return Record.keys(bin);
|
|
4389
4599
|
}
|
|
4390
4600
|
}));
|
|
4391
|
-
const manifestOf = Option.liftThrowable((name) => fileURLToPath(import.meta.resolve(`${name}/${MANIFEST_FILE}`)));
|
|
4601
|
+
const manifestOf = Option.liftThrowable((name) => fileURLToPath(import.meta.resolve(`${name}/${MANIFEST_FILE$1}`)));
|
|
4392
4602
|
const installedPackage = Effect.fn("installedPackage")(function* installedPackage(name) {
|
|
4393
4603
|
const files = yield* RepositoryFiles;
|
|
4394
4604
|
const text = yield* pipe(manifestOf(name), Option.match({
|
|
@@ -4407,7 +4617,7 @@ const appliedByMsch = Effect.fn("appliedByMsch")(function* appliedByMsch() {
|
|
|
4407
4617
|
onSome: (file) => readManifest(files.dirname(file))
|
|
4408
4618
|
}));
|
|
4409
4619
|
const names = pipe(manifest, Option.flatMap(({ dependencies }) => Option.fromUndefinedOr(dependencies)), Option.map(Record.keys), Option.getOrElse(() => []), Array.filter(String$1.startsWith(SCOPE)));
|
|
4410
|
-
return yield*
|
|
4620
|
+
return yield* Effect.forEach(names, installedPackage, { concurrency: 1 });
|
|
4411
4621
|
});
|
|
4412
4622
|
const problemAt = (file, source) => (index, name) => ({
|
|
4413
4623
|
file,
|
|
@@ -4429,7 +4639,7 @@ const consumersIn = Effect.fn("consumersIn")(function* consumersIn(root, directo
|
|
|
4429
4639
|
});
|
|
4430
4640
|
const manifestUses = Effect.fn("manifestUses")(function* manifestUses(root, appliedNames, directory) {
|
|
4431
4641
|
const files = yield* RepositoryFiles;
|
|
4432
|
-
const file = files.join(root, directory, MANIFEST_FILE);
|
|
4642
|
+
const file = files.join(root, directory, MANIFEST_FILE$1);
|
|
4433
4643
|
const text = yield* files.readFile(file);
|
|
4434
4644
|
const manifest = yield* readManifest(files.join(root, directory));
|
|
4435
4645
|
return pipe(Option.all({
|
|
@@ -4452,7 +4662,7 @@ const appliedPackageProblems = Effect.fn("appliedPackageProblems")(function* app
|
|
|
4452
4662
|
const directories = ["", ...yield* workspaceDirectories(root)];
|
|
4453
4663
|
const consumers = yield* consumersIn(root, directories);
|
|
4454
4664
|
const appliedNames = pipe(applied, Array.map(({ name }) => name));
|
|
4455
|
-
const manifestProblems = yield*
|
|
4665
|
+
const manifestProblems = yield* Effect.forEach(consumers, (directory) => manifestUses(root, appliedNames, directory), { concurrency: 1 });
|
|
4456
4666
|
const sourceProblems = yield* sourceUses({
|
|
4457
4667
|
root,
|
|
4458
4668
|
applied,
|
|
@@ -4583,7 +4793,7 @@ const CARGO_RULE = "cargo-outside-pnpm";
|
|
|
4583
4793
|
const CargoSettings = Schema.Struct({ enabled: Schema.optionalKey(Schema.Boolean) });
|
|
4584
4794
|
const WorkspaceFile = Schema.Struct({ cargo: Schema.optionalKey(CargoSettings) });
|
|
4585
4795
|
const decodeWorkspaceFile = Schema.decodeUnknownOption(WorkspaceFile);
|
|
4586
|
-
const cargoEnabled = (
|
|
4796
|
+
const cargoEnabled = (manifest) => pipe(decodeWorkspaceFile(manifest), Option.flatMap(({ cargo }) => Option.fromUndefinedOr(cargo)), Option.flatMap(({ enabled }) => Option.fromUndefinedOr(enabled)), Option.getOrElse(() => false));
|
|
4587
4797
|
const problemAtStart = (rule, message) => ({ file }) => ({
|
|
4588
4798
|
file,
|
|
4589
4799
|
line: FIRST_LINE,
|
|
@@ -4663,20 +4873,19 @@ const cargoProblems = (present, enabled) => {
|
|
|
4663
4873
|
];
|
|
4664
4874
|
});
|
|
4665
4875
|
};
|
|
4666
|
-
const unneededIn = Effect.fn("unneededIn")(function* unneededIn(root,
|
|
4876
|
+
const unneededIn = Effect.fn("unneededIn")(function* unneededIn(root, enabled) {
|
|
4667
4877
|
const listed = yield* listedFiles(root);
|
|
4668
4878
|
const present = yield* presentFiles(listed);
|
|
4669
4879
|
const lockfiles = pipe(present, Array.filter(isForeignLockfile), Array.map(foreignLockfile));
|
|
4670
4880
|
if (!pipe(present, Array.some(isCargoManifest))) return lockfiles;
|
|
4671
|
-
const cargo = yield* cargoProblems(present,
|
|
4881
|
+
const cargo = yield* cargoProblems(present, enabled);
|
|
4672
4882
|
return [...lockfiles, ...cargo];
|
|
4673
4883
|
});
|
|
4674
4884
|
/** @internal */
|
|
4675
4885
|
const checkUnneededFiles = Effect.fn("checkUnneededFiles")(function* checkUnneededFiles(root) {
|
|
4676
|
-
const
|
|
4677
|
-
const workspace = yield* files.readFile(files.join(root, WORKSPACE_FILE));
|
|
4886
|
+
const workspace = yield* workspaceManifest(root);
|
|
4678
4887
|
if (Option.isNone(workspace)) return [];
|
|
4679
|
-
return yield* unneededIn(root, workspace.value);
|
|
4888
|
+
return yield* unneededIn(root, cargoEnabled(workspace.value));
|
|
4680
4889
|
});
|
|
4681
4890
|
// src/app/tracked-text.ts
|
|
4682
4891
|
/** @internal */
|
|
@@ -4691,6 +4900,7 @@ const checkTrackedText = Effect.fn("checkTrackedText")(function* checkTrackedTex
|
|
|
4691
4900
|
checkNodeVersion(root),
|
|
4692
4901
|
checkSkillFiles(root),
|
|
4693
4902
|
checkSkillEntry(root),
|
|
4903
|
+
checkPublishedSkills(root),
|
|
4694
4904
|
checkComments(root),
|
|
4695
4905
|
checkAppliedPackages(root),
|
|
4696
4906
|
checkGitSubpath(root)
|