@r_masseater/msch 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.mjs","names":["Arr","Arr","Fn","SCOPE_PREFIX","SCOPED_SEGMENTS","packageOf","Str","Arr","Arr","Str","ownerOf","Arr","Arr","Arr","Arr","childrenOf","Arr","Arr","Arr","Rec","Num","Str","Arr","Str","Arr","mentions","mentions","Arr","SCOPE","SEPARATOR","Str","Arr","Rec","decodeManifest","keysOf","Rec","Arr","childrenOf","Num","Str","START","FIRST_COLUMN","Str","Arr","START","Arr","Str","Num","Rec","keysOf","Arr","Arr","Rec","Str","LOCKFILE","taggedError","textOf","Str","Arr","RULE","FIRST","READ_CONCURRENCY","problemFor","Arr","Str","problemIn","RULE","CONFIG_FILE","SEPARATOR","FIRST","READ_CONCURRENCY","README","RootConfig","taggedError","Str","problemFor","problemIn","Arr","RULE","SEPARATOR","READ_CONCURRENCY","START","Arr","Str","problemsIn","Arr","taggedError","Str","NEXT","Arr","Rec","YamlParser","Str","parseSql","Num","START","NEXT","NONE","Rec","Arr","Str","parseDocument","RULE","CONFIG_FILE","READ_CONCURRENCY","START","FIRST_LINE","FIRST_COLUMN","taggedError","Str","Arr","problemOf","READ_CONCURRENCY","RULE","Str","problemsIn","Arr","READ_CONCURRENCY","Str","Arr","Arr","RULE","CONFIG_FILE","FIRST","READ_CONCURRENCY","Arr","Str","problemIn","RULE","CONFIG_FILE","FIRST","Arr","childrenOf","Arr","Str","Arr","Arr","Arr"],"sources":["../src/slots.ts","../src/values.ts","../src/flows.ts","../src/owners.ts","../src/library.ts","../src/derivation.ts","../src/shapes.ts","../src/sites.ts","../src/value-checks.ts","../src/analysis.ts","../src/duplicates.ts","../src/telemetry.ts","../src/project.ts","../src/check.ts","../src/import-graph.ts","../src/installed-closure.ts","../src/text-position.ts","../src/install-size.ts","../src/override-findings.ts","../src/override-resolution.ts","../src/overrides.ts","../src/colocated-tests.ts","../src/nested-docs.ts","../src/root-readme.ts","../src/placement-checks.ts","../src/found-comment.ts","../src/config-comments.ts","../src/comment-readers.ts","../src/comments.ts","../src/hidden-unicode.ts","../src/python.ts","../src/tracked-text.ts","../src/crates.ts","../src/hidden-verify.ts","../src/root-workspace-paths.ts","../src/workspace-checks.ts","../src/all-checks.ts","../src/output.ts","../src/runtime.ts","../src/cli.ts"],"sourcesContent":["import { Array as Arr, Option } from \"effect\";\n\nimport {\n isCallExpression,\n isNewExpression,\n isObjectLiteralExpression,\n isPropertyAssignment,\n isSignatureDeclaration,\n isVariableDeclaration,\n SyntaxKind,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Expression,\n ParameterDeclaration,\n PropertyDeclaration,\n PropertySignatureDeclaration,\n TypeSymbol,\n TypeNode,\n VariableDeclaration,\n} from \"./compiler.ts\";\nimport { declarationsOf, referencedSymbols } from \"./syntax.ts\";\n\ntype AnnotatedDeclaration =\n | ParameterDeclaration\n | VariableDeclaration\n | PropertySignatureDeclaration\n | PropertyDeclaration;\n\nconst ANNOTATED_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.Parameter,\n SyntaxKind.VariableDeclaration,\n SyntaxKind.PropertySignature,\n SyntaxKind.PropertyDeclaration,\n]);\n\nconst isAnnotated = (declaration: Declaration): declaration is AnnotatedDeclaration =>\n ANNOTATED_KINDS.has(declaration.kind);\n\nconst annotationOf = (declaration: Declaration): Option.Option<TypeNode> =>\n Option.liftPredicate(declaration, isAnnotated).pipe(\n Option.flatMap((annotated) => Option.fromUndefinedOr(annotated.type)),\n );\n\nconst argumentSlot =\n (checker: Checker) =>\n (expression: Expression): Option.Option<Declaration> => {\n const call = expression.parent;\n if (!isCallExpression(call) && !isNewExpression(call)) {\n return Option.none();\n }\n const { arguments: listed } = call;\n const callArguments: readonly Expression[] = listed ?? [];\n const index = callArguments.indexOf(expression);\n return Option.fromUndefinedOr(checker.getResolvedSignature(call).declaration).pipe(\n Option.flatMap((handle) => Option.fromUndefinedOr(handle.resolve())),\n Option.filter(isSignatureDeclaration),\n Option.flatMap((declaration) => Arr.get(declaration.parameters, index)),\n );\n };\n\nconst propertySlot =\n (checker: Checker) =>\n (expression: Expression): Option.Option<Declaration> => {\n const assignment = expression.parent;\n if (!isPropertyAssignment(assignment) || !isObjectLiteralExpression(assignment.parent)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(checker.getContextualType(assignment.parent)).pipe(\n Option.flatMap((objectType) =>\n Option.fromUndefinedOr(objectType.getProperty(assignment.name.getText())),\n ),\n Option.flatMap((property) => Arr.head(declarationsOf(property))),\n );\n };\n\nconst variableSlot = (expression: Expression): Option.Option<Declaration> => {\n const declaration = expression.parent;\n if (!isVariableDeclaration(declaration) || declaration.initializer !== expression) {\n return Option.none();\n }\n return Option.some(declaration);\n};\n\nconst slotOf =\n (checker: Checker) =>\n (expression: Expression): Option.Option<Declaration> =>\n argumentSlot(checker)(expression).pipe(\n Option.orElse(() => propertySlot(checker)(expression)),\n Option.orElse(() => variableSlot(expression)),\n );\n\nconst contextSymbolsOf =\n (checker: Checker) =>\n (expression: Expression): readonly TypeSymbol[] => {\n const alias = Option.fromUndefinedOr(checker.getContextualType(expression)).pipe(\n Option.flatMap((contextual) => Option.fromUndefinedOr(contextual.getAliasSymbol())),\n );\n if (Option.isSome(alias)) {\n return [alias.value];\n }\n return slotOf(checker)(expression).pipe(\n Option.flatMap(annotationOf),\n Option.map((annotation) => referencedSymbols(checker)(annotation)),\n Option.getOrElse(() => []),\n );\n };\n\nexport { annotationOf, contextSymbolsOf, slotOf };\n","import { Array as Arr, Function as Fn, Option, pipe } from \"effect\";\n\nimport { IndexKind } from \"./compiler.ts\";\nimport type { Checker, Type } from \"./compiler.ts\";\n\ntype Value = string | number;\n\ninterface Vocabulary {\n readonly values: readonly Value[];\n readonly admitsUnnamedValues: boolean;\n}\n\nconst SCHEMA_TYPE_PROPERTIES = [\"Type\", \"_output\"] as const;\n\nconst MINIMUM_SET_SIZE = 2;\n\nconst DATA_FIRST_ARITY = 2;\n\nconst valueKey = (value: Value): string => `${typeof value}:${String(value)}`;\n\nconst literalValueOf = (type: Type): Option.Option<Value> => {\n if (type.isStringLiteralType() || type.isNumberLiteralType()) {\n return Option.some(type.value);\n }\n return Option.none();\n};\n\nconst literalValuesOf = (types: readonly Type[]): Option.Option<readonly Value[]> => {\n const values = pipe(\n types,\n Arr.map((member) => literalValueOf(member)),\n Arr.getSomes,\n Arr.dedupeWith((left, right) => valueKey(left) === valueKey(right)),\n );\n if (values.length !== types.length || values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some(values);\n};\n\nconst literalUnionOf = (type: Type): Option.Option<readonly Value[]> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n return literalValuesOf(type.getTypes());\n};\n\nconst elementTypeOf = (checker: Checker, type: Type): Option.Option<Type> => {\n if (!checker.isArrayLikeType(type)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(checker.getIndexTypeOfType(type, IndexKind.Number));\n};\n\nconst schemaTypeOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Type> =>\n Arr.findFirst(SCHEMA_TYPE_PROPERTIES, (name) =>\n Option.fromUndefinedOr(checker.getPropertyOfType(type, name)),\n ).pipe(Option.map((property) => checker.getTypeOfSymbol(property)));\n\nconst finiteValuesOf =\n (checker: Checker) =>\n (type: Type): Option.Option<readonly Value[]> =>\n literalUnionOf(type).pipe(\n Option.orElse(() => elementTypeOf(checker, type).pipe(Option.flatMap(literalUnionOf))),\n Option.orElse(() => schemaTypeOf(checker)(type).pipe(Option.flatMap(literalUnionOf))),\n );\n\nconst vocabularyOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Vocabulary> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n const optionalIds = new Set([checker.getUndefinedType().id, checker.getNullType().id]);\n const members = pipe(\n type.getTypes(),\n Arr.filter((member) => !optionalIds.has(member.id)),\n );\n const values = Arr.getSomes(\n pipe(\n members,\n Arr.map((member) => literalValueOf(member)),\n ),\n );\n if (values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some({ values, admitsUnnamedValues: values.length !== members.length });\n };\n\nconst isSubsetOf: {\n (superset: readonly Value[]): (subset: readonly Value[]) => boolean;\n (subset: readonly Value[], superset: readonly Value[]): boolean;\n} = Fn.dual(DATA_FIRST_ARITY, (subset: readonly Value[], superset: readonly Value[]): boolean => {\n const held = new Set(\n pipe(\n superset,\n Arr.map((value) => valueKey(value)),\n ),\n );\n return pipe(\n subset,\n Arr.every((value) => held.has(valueKey(value))),\n );\n});\n\nconst sameValues: {\n (right: readonly Value[]): (left: readonly Value[]) => boolean;\n (left: readonly Value[], right: readonly Value[]): boolean;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (left: readonly Value[], right: readonly Value[]): boolean =>\n left.length === right.length && isSubsetOf(left, right),\n);\n\nconst valueText = (value: Value): string => {\n if (typeof value === \"string\") {\n return `\"${value}\"`;\n }\n return String(value);\n};\n\nconst formatValues = (values: readonly Value[]): string =>\n pipe(values, Arr.map(valueText), Arr.join(\" | \"));\n\nexport {\n finiteValuesOf,\n formatValues,\n isSubsetOf,\n literalUnionOf,\n literalValuesOf,\n sameValues,\n schemaTypeOf,\n valueKey,\n vocabularyOf,\n};\nexport type { Value, Vocabulary };\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n getNameOfDeclaration,\n isClassDeclaration,\n isElementAccessExpression,\n isIdentifier,\n isInterfaceDeclaration,\n isPropertyAccessExpression,\n isSignatureDeclaration,\n isTypeAliasDeclaration,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n ClassDeclaration,\n Declaration,\n Expression,\n InterfaceDeclaration,\n Node,\n Program,\n SignatureDeclaration,\n SourceFile,\n TypeSymbol,\n Type,\n} from \"./compiler.ts\";\nimport type { ValueSite } from \"./sites.ts\";\nimport { annotationOf, slotOf } from \"./slots.ts\";\nimport {\n contains,\n declarationsOf,\n descendantsOf,\n isExternalDeclaration,\n NODE_MODULES_SEGMENT,\n symbolAt,\n} from \"./syntax.ts\";\nimport { isSubsetOf, vocabularyOf } from \"./values.ts\";\n\ninterface Flow {\n readonly site: ValueSite;\n readonly target: string;\n}\n\ninterface FlowContext {\n readonly checker: Checker;\n readonly program: Program;\n readonly sites: readonly ValueSite[];\n}\n\nconst SCOPE_PREFIX = \"@\";\nconst SCOPED_SEGMENTS = 2;\nconst UNSCOPED_SEGMENTS = 1;\nconst MODULE_PREFIX = /^\".*?\"\\./u;\n\nconst packageOf = (fileName: string): string => {\n const afterModules = pipe(\n fileName,\n Str.lastIndexOf(NODE_MODULES_SEGMENT),\n Option.match({\n onNone: () => fileName,\n onSome: (index) => Str.slice(index + NODE_MODULES_SEGMENT.length)(fileName),\n }),\n );\n const segments = Str.split(\"/\")(afterModules);\n if (Str.startsWith(SCOPE_PREFIX)(afterModules)) {\n return pipe(Arr.take(segments, SCOPED_SEGMENTS), Arr.join(\"/\"));\n }\n return pipe(Arr.take(segments, UNSCOPED_SEGMENTS), Arr.join(\"/\"));\n};\n\nconst externalDeclarationOf =\n (context: FlowContext) =>\n (symbol: TypeSymbol): Option.Option<Declaration> =>\n Arr.findFirst(declarationsOf(symbol), (declaration) =>\n isExternalDeclaration(context.program)(declaration),\n );\n\nconst aliasTarget =\n (context: FlowContext) =>\n (type: Type): Option.Option<string> =>\n Option.fromUndefinedOr(type.getAliasSymbol()).pipe(\n Option.flatMap((alias) =>\n externalDeclarationOf(context)(alias).pipe(\n Option.map(\n (declaration) =>\n `${Str.replace(MODULE_PREFIX, \"\")(context.checker.getFullyQualifiedName(alias))} from ${packageOf(declaration.getSourceFile().fileName)}`,\n ),\n ),\n ),\n );\n\nconst isNamedContainer = (\n node: Node,\n): node is SignatureDeclaration | InterfaceDeclaration | ClassDeclaration =>\n isSignatureDeclaration(node) || isInterfaceDeclaration(node) || isClassDeclaration(node);\n\nconst slotTarget =\n (context: FlowContext) =>\n (expression: Expression): Option.Option<string> =>\n slotOf(context.checker)(expression).pipe(\n Option.filter((slot) => isExternalDeclaration(context.program)(slot)),\n Option.filter((slot) =>\n Option.isSome(vocabularyOf(context.checker)(context.checker.getTypeAtLocation(slot))),\n ),\n Option.map((slot) => {\n const owner = Option.liftPredicate(slot.parent, isNamedContainer).pipe(\n Option.flatMap((container) => Option.fromUndefinedOr(getNameOfDeclaration(container))),\n Option.map((name) => ` of ${name.getText()}`),\n Option.getOrElse(() => \"\"),\n );\n const name = Option.fromUndefinedOr(getNameOfDeclaration(slot)).pipe(\n Option.map((found) => found.getText()),\n Option.getOrElse(() => \"value\"),\n );\n return `${name}${owner} from ${packageOf(slot.getSourceFile().fileName)}`;\n }),\n );\n\nconst libraryTargetOf =\n (context: FlowContext) =>\n (expression: Expression, contextual: Type): Option.Option<string> =>\n aliasTarget(context)(contextual).pipe(Option.orElse(() => slotTarget(context)(expression)));\n\nconst siteWithin =\n (context: FlowContext) =>\n (node: Node): Option.Option<ValueSite> =>\n Arr.findFirst(context.sites, (site) => contains(node)(site.node));\n\nconst aliasSite =\n (context: FlowContext) =>\n (type: Type): Option.Option<ValueSite> =>\n Option.fromUndefinedOr(type.getAliasSymbol()).pipe(\n Option.flatMap((alias) => Arr.findFirst(declarationsOf(alias), isTypeAliasDeclaration)),\n Option.flatMap(siteWithin(context)),\n );\n\nconst annotationSite =\n (context: FlowContext) =>\n (expression: Expression): Option.Option<ValueSite> =>\n symbolAt(context.checker)(expression).pipe(\n Option.flatMap((symbol) => Option.fromUndefinedOr(symbol.valueDeclaration)),\n Option.flatMap((handle) => Option.fromUndefinedOr(handle.resolve())),\n Option.flatMap(annotationOf),\n Option.flatMap((annotation) =>\n siteWithin(context)(annotation).pipe(\n Option.orElse(() => aliasSite(context)(context.checker.getTypeFromTypeNode(annotation))),\n ),\n ),\n );\n\nconst siteBehind =\n (context: FlowContext) =>\n (expression: Expression): Option.Option<ValueSite> =>\n aliasSite(context)(context.checker.getTypeAtLocation(expression)).pipe(\n Option.orElse(() => annotationSite(context)(expression)),\n );\n\nconst isFlowSource = (node: Node): node is Expression =>\n isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node);\n\nconst flowOf =\n (context: FlowContext) =>\n (expression: Expression): Option.Option<Flow> =>\n Option.fromUndefinedOr(context.checker.getContextualType(expression)).pipe(\n Option.flatMap((contextual) =>\n Option.all([\n vocabularyOf(context.checker)(contextual),\n libraryTargetOf(context)(expression, contextual),\n ]),\n ),\n Option.flatMap(([vocabulary, target]) =>\n siteBehind(context)(expression).pipe(\n Option.filter((site) => isSubsetOf(site.values, vocabulary.values)),\n Option.map((site) => ({ site, target })),\n ),\n ),\n );\n\nconst flowsIn =\n (context: FlowContext) =>\n (sourceFile: SourceFile): readonly Flow[] =>\n Arr.getSomes(\n pipe(\n descendantsOf(sourceFile),\n Arr.filter((node) => isFlowSource(node)),\n Arr.map((node) => flowOf(context)(node)),\n ),\n );\n\nexport { flowsIn };\nexport type { Flow, FlowContext };\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n getJSDocTags,\n getTextOfJSDocComment,\n isIdentifier,\n isSourceFile,\n isVariableDeclaration,\n isVariableDeclarationList,\n isVariableStatement,\n SyntaxKind,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Node,\n SourceFile,\n Type,\n VariableDeclaration,\n VariableDeclarationList,\n} from \"./compiler.ts\";\nimport { problemAt } from \"./problem.ts\";\nimport type { Problem } from \"./problem.ts\";\nimport type { Project } from \"./project.ts\";\nimport { columnOf, descendantsOf, lineOf } from \"./syntax.ts\";\nimport { finiteValuesOf, formatValues, literalValuesOf, sameValues } from \"./values.ts\";\nimport type { Value } from \"./values.ts\";\n\ninterface Owner {\n readonly conceptId: string;\n readonly key: string;\n readonly name: string;\n readonly file: string;\n readonly line: number;\n readonly column: number;\n readonly packageName: Option.Option<string>;\n readonly values: readonly Value[];\n}\n\ninterface OwnerScan {\n readonly owners: readonly Owner[];\n readonly problems: readonly Problem[];\n}\n\ninterface Annotated {\n readonly node: Node;\n readonly conceptId: string;\n}\n\nconst OWNER_TAG = \"msch\";\nconst FIRST_OWNER_COUNT = 1;\n\nconst ownerKeyOf = (declaration: Declaration): Option.Option<string> => {\n if (!isVariableDeclaration(declaration) || !isIdentifier(declaration.name)) {\n return Option.none();\n }\n return Option.some(`${declaration.getSourceFile().fileName}#${declaration.name.text}`);\n};\n\nconst annotationsOf = (node: Node): readonly Annotated[] =>\n pipe(\n getJSDocTags(node),\n Arr.filter((tag) => tag.tagName.text === OWNER_TAG),\n Arr.map((tag) => ({ node, conceptId: Str.trim(getTextOfJSDocComment(tag.comment) ?? \"\") })),\n );\n\nconst ANNOTATABLE_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.VariableDeclaration,\n SyntaxKind.FunctionDeclaration,\n SyntaxKind.ClassDeclaration,\n SyntaxKind.InterfaceDeclaration,\n SyntaxKind.TypeAliasDeclaration,\n SyntaxKind.EnumDeclaration,\n SyntaxKind.PropertySignature,\n SyntaxKind.PropertyAssignment,\n SyntaxKind.PropertyDeclaration,\n]);\n\nconst isAnnotatable = (node: Node): boolean => ANNOTATABLE_KINDS.has(node.kind);\n\nconst isConstList = (list: VariableDeclarationList): boolean =>\n Option.fromUndefinedOr(list.getFirstToken()).pipe(\n Option.exists((token) => token.kind === SyntaxKind.ConstKeyword),\n );\n\nconst isModuleStatementList = (list: VariableDeclarationList): boolean =>\n isVariableStatement(list.parent) && isSourceFile(list.parent.parent);\n\nconst isModuleConstList = (node: Node): node is VariableDeclarationList =>\n isVariableDeclarationList(node) && isModuleStatementList(node) && isConstList(node);\n\nconst isModuleConst = (node: Node): node is VariableDeclaration =>\n isVariableDeclaration(node) && isIdentifier(node.name) && isModuleConstList(node.parent);\n\nconst objectValuesOf =\n (checker: Checker) =>\n (type: Type): Option.Option<readonly Value[]> =>\n literalValuesOf(\n pipe(\n checker.getPropertiesOfType(type),\n Arr.map((property) => checker.getTypeOfSymbol(property)),\n ),\n );\n\nconst ownerValuesOf =\n (checker: Checker) =>\n (declaration: VariableDeclaration): Option.Option<readonly Value[]> => {\n const type = checker.getTypeAtLocation(declaration.name);\n return finiteValuesOf(checker)(type).pipe(Option.orElse(() => objectValuesOf(checker)(type)));\n };\n\nconst annotationProblem = (message: string): ((node: Node) => Problem) =>\n problemAt({ rule: \"owner-annotation\", message });\n\nconst scanned = (owners: readonly Owner[], problems: readonly Problem[]): OwnerScan => ({\n owners,\n problems,\n});\n\nconst ownerOf =\n (project: Project) =>\n (annotated: Annotated): OwnerScan => {\n const { node, conceptId } = annotated;\n if (!isModuleConst(node)) {\n return scanned(\n [],\n [annotationProblem(`@${OWNER_TAG} registers an owner only on a module-scope const.`)(node)],\n );\n }\n if (conceptId === \"\") {\n return scanned([], [annotationProblem(`@${OWNER_TAG} needs a concept id.`)(node)]);\n }\n const values = ownerValuesOf(project.checker)(node);\n return Option.match(Option.all([values, ownerKeyOf(node)]), {\n onNone: () =>\n scanned(\n [],\n [annotationProblem(`The owner of ${conceptId} holds no finite value set.`)(node)],\n ),\n onSome: ([ownedValues, key]) =>\n scanned(\n [\n {\n conceptId,\n key,\n name: node.name.getText(),\n file: node.getSourceFile().fileName,\n line: lineOf(node),\n column: columnOf(node),\n packageName: project.packageName,\n values: ownedValues,\n },\n ],\n [],\n ),\n });\n };\n\nconst annotatedIn = (sourceFile: SourceFile): readonly Annotated[] =>\n pipe(\n descendantsOf(sourceFile),\n Arr.filter((node) => isAnnotatable(node)),\n Arr.flatMap((node) => annotationsOf(node)),\n );\n\nconst ownerProblem =\n (message: string) =>\n (owner: Owner): Problem => ({\n file: owner.file,\n line: owner.line,\n column: owner.column,\n rule: \"owner-annotation\",\n message,\n });\n\nconst conflictProblems = (owners: readonly Owner[]): readonly Problem[] =>\n pipe(\n owners,\n Arr.flatMap((owner, index) => {\n const earlier = Arr.take(owners, index);\n const sameConcept = pipe(\n earlier,\n Arr.filter((other) => other.conceptId === owner.conceptId),\n );\n const sameSet = pipe(\n earlier,\n Arr.filter(\n (other) => other.conceptId !== owner.conceptId && sameValues(other.values, owner.values),\n ),\n );\n return [\n ...pipe(\n Arr.take(sameConcept, FIRST_OWNER_COUNT),\n Arr.map(() =>\n ownerProblem(`The concept ${owner.conceptId} already has an owner.`)(owner),\n ),\n ),\n ...pipe(\n Arr.take(sameSet, FIRST_OWNER_COUNT),\n Arr.map((other) =>\n ownerProblem(\n `The values ${formatValues(owner.values)} are already owned by ${other.conceptId}.`,\n )(owner),\n ),\n ),\n ];\n }),\n );\n\nconst ownersIn = (project: Project): OwnerScan => {\n const results = pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) =>\n pipe(\n annotatedIn(sourceFile),\n Arr.map((annotated) => ownerOf(project)(annotated)),\n ),\n ),\n );\n return scanned(\n pipe(\n results,\n Arr.flatMap((result) => result.owners),\n ),\n pipe(\n results,\n Arr.flatMap((result) => result.problems),\n ),\n );\n};\n\nconst combineOwnerScans = (scans: readonly OwnerScan[]): OwnerScan => {\n const owners = Arr.dedupeWith(\n pipe(\n scans,\n Arr.flatMap((scan) => scan.owners),\n ),\n (left, right) => left.key === right.key,\n );\n const problems = [\n ...pipe(\n scans,\n Arr.flatMap((scan) => scan.problems),\n ),\n ...conflictProblems(owners),\n ];\n return { owners, problems };\n};\n\nexport { OWNER_TAG, combineOwnerScans, ownerKeyOf, ownersIn };\nexport type { Owner, OwnerScan };\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport { InternalSymbolName, isModuleDeclaration, isVariableDeclaration } from \"./compiler.ts\";\nimport type { Checker, Declaration, Node, SyntaxKind, TypeSymbol, Type } from \"./compiler.ts\";\nimport type { DependencyEntry } from \"./dependencies.ts\";\nimport {\n declarationsOf,\n isGenericDeclaration,\n isTypeDeclaration,\n propertyNamesOf,\n resolvedSymbol,\n} from \"./syntax.ts\";\nimport { schemaTypeOf, vocabularyOf } from \"./values.ts\";\nimport type { Vocabulary } from \"./values.ts\";\n\ninterface LibraryType {\n readonly specifier: string;\n readonly typeName: string;\n}\n\ninterface LibraryVocabulary extends LibraryType {\n readonly vocabulary: Vocabulary;\n}\n\ninterface DeclarationLocation {\n readonly file: string;\n readonly pos: number;\n readonly kind: SyntaxKind;\n}\n\ninterface LibraryShape extends LibraryType {\n readonly form: \"declared\" | \"schema\";\n readonly declaration: DeclarationLocation;\n readonly propertyNames: readonly string[];\n}\n\ninterface LibraryIndex {\n readonly vocabularies: readonly LibraryVocabulary[];\n readonly shapes: readonly LibraryShape[];\n}\n\ninterface Walk {\n readonly checker: Checker;\n readonly entry: DependencyEntry;\n}\n\ninterface Visit {\n readonly exported: TypeSymbol;\n readonly qualifier: string;\n readonly ancestors: readonly TypeSymbol[];\n}\n\ninterface Exported {\n readonly symbol: TypeSymbol;\n readonly typeName: string;\n}\n\nconst NAMESPACE_DEPTH_LIMIT = 8;\nconst EMPTY_INDEX: LibraryIndex = { vocabularies: [], shapes: [] };\n\nconst isObjectType =\n (checker: Checker) =>\n (type: Type): boolean =>\n !type.isUnionType() &&\n !type.isLiteralType() &&\n checker.getApparentType(type).id === type.id &&\n Arr.isReadonlyArrayNonEmpty(checker.getPropertiesOfType(type));\n\nconst describeLibraryType = (type: LibraryType): string =>\n `${type.typeName} from ${type.specifier}`;\n\nconst locationOf = (declaration: Node): DeclarationLocation => ({\n file: declaration.getSourceFile().fileName,\n pos: declaration.pos,\n kind: declaration.kind,\n});\n\nconst declarationKey = (location: DeclarationLocation): string =>\n `${location.file}#${String(location.pos)}#${String(location.kind)}`;\n\ntype ShapeSource = LibraryType & Pick<LibraryShape, \"form\">;\n\nconst shapeOf =\n (checker: Checker) =>\n (source: ShapeSource, declaration: Declaration, type: Type): readonly LibraryShape[] =>\n Arr.filter(\n [\n {\n ...source,\n declaration: locationOf(declaration),\n propertyNames: propertyNamesOf(checker)(type),\n },\n ],\n () => isObjectType(checker)(type),\n );\n\nconst declaredTypeIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isTypeDeclaration);\n if (Option.isNone(declaration) || isGenericDeclaration(declaration.value)) {\n return EMPTY_INDEX;\n }\n const located = { specifier: walk.entry.specifier, typeName: exported.typeName };\n const type = walk.checker.getDeclaredTypeOfSymbol(exported.symbol);\n const vocabularies = vocabularyOf(walk.checker)(type).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n );\n const shapes = shapeOf(walk.checker)({ ...located, form: \"declared\" }, declaration.value, type);\n return { vocabularies, shapes };\n};\n\nconst schemaTypeIndex =\n (walk: Walk, located: LibraryType) =>\n (declaration: Declaration, schemaType: Type): LibraryIndex => ({\n vocabularies: vocabularyOf(walk.checker)(schemaType).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n ),\n shapes: shapeOf(walk.checker)({ ...located, form: \"schema\" }, declaration, schemaType),\n });\n\nconst schemaValueIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isVariableDeclaration);\n if (Option.isNone(declaration)) {\n return EMPTY_INDEX;\n }\n const valueType = walk.checker.getTypeOfSymbolAtLocation(exported.symbol, declaration.value);\n const located = {\n specifier: walk.entry.specifier,\n typeName: `(typeof ${exported.typeName})[\"Type\"]`,\n };\n return Option.match(schemaTypeOf(walk.checker)(valueType), {\n onNone: () => EMPTY_INDEX,\n onSome: (schemaType) => schemaTypeIndex(walk, located)(declaration.value, schemaType),\n });\n};\n\nconst mergeIndexes = (indexes: readonly LibraryIndex[]): LibraryIndex => ({\n vocabularies: pipe(\n indexes,\n Arr.flatMap((index) => index.vocabularies),\n ),\n shapes: pipe(\n indexes,\n Arr.flatMap((index) => index.shapes),\n ),\n});\n\nconst isNamespace = (symbol: TypeSymbol): boolean =>\n pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isModuleDeclaration(declaration)),\n );\n\nconst indexUnder = (walk: Walk, visit: Visit): LibraryIndex => {\n const symbol = resolvedSymbol(walk.checker)(visit.exported);\n const named = { symbol, typeName: `${visit.qualifier}${visit.exported.name}` };\n const own = mergeIndexes([declaredTypeIndex(walk, named), schemaValueIndex(walk, named)]);\n if (\n !isNamespace(symbol) ||\n visit.ancestors.length >= NAMESPACE_DEPTH_LIMIT ||\n visit.ancestors.includes(symbol)\n ) {\n return own;\n }\n const nested = pipe(\n walk.checker.getExportsOfModule(symbol),\n Arr.map((member) =>\n indexUnder(walk, {\n exported: member,\n qualifier: `${named.typeName}.`,\n ancestors: [...visit.ancestors, symbol],\n }),\n ),\n );\n return mergeIndexes([own, ...nested]);\n};\n\nconst exportAssignmentOf = (moduleSymbol: TypeSymbol): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(moduleSymbol.getExports().get(InternalSymbolName.ExportEquals));\n\nconst indexOfEntry =\n (checker: Checker) =>\n (entry: DependencyEntry): LibraryIndex => {\n const moduleSymbol = Option.fromUndefinedOr(\n checker.getSymbolOfSourceFile(entry.declarationsPath),\n );\n if (Option.isNone(moduleSymbol)) {\n return EMPTY_INDEX;\n }\n const walk: Walk = { checker, entry };\n const roots = Option.match(exportAssignmentOf(moduleSymbol.value), {\n onNone: () => checker.getExportsOfModule(moduleSymbol.value),\n onSome: (assigned) => [resolvedSymbol(checker)(assigned)],\n });\n return mergeIndexes(\n pipe(\n roots,\n Arr.map((exported) => indexUnder(walk, { exported, qualifier: \"\", ancestors: [] })),\n ),\n );\n };\n\ninterface CachedIndex {\n readonly index: LibraryIndex;\n readonly cached: boolean;\n}\n\ninterface LibraryCache {\n readonly indexOf: (entry: DependencyEntry, compute: () => LibraryIndex) => CachedIndex;\n}\n\nconst libraryCache = (): LibraryCache => {\n const indexes = new Map<string, LibraryIndex>();\n return {\n indexOf: (entry, compute) =>\n Option.match(Option.fromUndefinedOr(indexes.get(entry.declarationsPath)), {\n onSome: (index) => ({ index, cached: true }),\n onNone: () => {\n const index = compute();\n indexes.set(entry.declarationsPath, index);\n return { index, cached: false };\n },\n }),\n };\n};\n\nconst indexEntry =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entry: DependencyEntry): Effect.Effect<LibraryIndex> =>\n Effect.sync(() => cache.indexOf(entry, () => indexOfEntry(checker)(entry))).pipe(\n Effect.tap(({ index, cached }) =>\n Effect.annotateCurrentSpan({\n \"msch.library.cached\": cached,\n \"msch.library.vocabularies\": index.vocabularies.length,\n \"msch.library.shapes\": index.shapes.length,\n }),\n ),\n Effect.map(({ index }) => index),\n Effect.withSpan(\"indexLibraryEntry\", {\n attributes: { \"msch.library.specifier\": entry.specifier },\n }),\n );\n\nconst libraryIndex =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entries: readonly DependencyEntry[]): Effect.Effect<LibraryIndex> =>\n pipe(\n entries,\n Effect.forEach(indexEntry(cache)(checker)),\n Effect.map(mergeIndexes),\n Effect.withSpan(\"libraryIndex\"),\n );\n\nexport {\n declarationKey,\n describeLibraryType,\n isObjectType,\n libraryCache,\n libraryIndex,\n locationOf,\n};\nexport type {\n CachedIndex,\n DeclarationLocation,\n LibraryCache,\n LibraryIndex,\n LibraryShape,\n LibraryType,\n LibraryVocabulary,\n};\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport { isSatisfiesExpression, isVariableDeclaration } from \"./compiler.ts\";\nimport type { Checker, Node } from \"./compiler.ts\";\nimport { declarationKey, locationOf } from \"./library.ts\";\nimport { declarationsOf, referencedSymbols } from \"./syntax.ts\";\n\nconst contractOf = (node: Node): readonly Node[] => {\n const { parent } = node;\n if (isSatisfiesExpression(parent) && parent.expression === node) {\n return [parent.type];\n }\n if (isVariableDeclaration(parent) && parent.initializer === node) {\n return Option.toArray(Option.fromUndefinedOr(parent.type));\n }\n return [];\n};\n\nconst derivedDeclarationsOf =\n (checker: Checker) =>\n (node: Node): ReadonlySet<string> => {\n const scopes = Arr.prepend(contractOf(node), node);\n return new Set(\n pipe(\n scopes,\n Arr.flatMap((scope) => referencedSymbols(checker)(scope)),\n Arr.flatMap((symbol) => declarationsOf(symbol)),\n Arr.map((declaration) => declarationKey(locationOf(declaration))),\n ),\n );\n };\n\nexport { derivedDeclarationsOf };\n","import { Array as Arr, Option, Order, pipe } from \"effect\";\n\nimport {\n isCallExpression,\n isInterfaceDeclaration,\n isModuleBlock,\n isModuleDeclaration,\n isObjectLiteralExpression,\n isStringLiteral,\n isTypeAliasDeclaration,\n isTypeLiteralNode,\n isVariableDeclaration,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n EnumDeclaration,\n InterfaceDeclaration,\n Node,\n Program,\n SourceFile,\n TypeSymbol,\n Type,\n TypeAliasDeclaration,\n VariableDeclaration,\n} from \"./compiler.ts\";\nimport { derivedDeclarationsOf } from \"./derivation.ts\";\nimport { declarationKey, describeLibraryType, isObjectType } from \"./library.ts\";\nimport type { DeclarationLocation, LibraryShape } from \"./library.ts\";\nimport { CANDIDATE_LIMIT, problemAt } from \"./problem.ts\";\nimport type { Problem } from \"./problem.ts\";\nimport { descendantsOf, isGenericDeclaration, isTypeDeclaration } from \"./syntax.ts\";\nimport { schemaTypeOf } from \"./values.ts\";\n\ninterface ShapeContext {\n readonly checker: Checker;\n readonly program: Program;\n readonly shapes: readonly LibraryShape[];\n}\n\ninterface ShapeSite {\n readonly node: Node;\n readonly type: Type;\n}\n\ninterface ShapeMatch {\n readonly shape: LibraryShape;\n readonly extra: number;\n}\n\nconst MINIMUM_SHAPE_PROPERTIES = 3;\nconst EXACT = 0;\n\nconst augmentsAModule = (node: Node): boolean => {\n const block = node.parent;\n return (\n isModuleBlock(block) && isModuleDeclaration(block.parent) && isStringLiteral(block.parent.name)\n );\n};\n\nconst isPlainInterface = (node: Node): node is InterfaceDeclaration =>\n isInterfaceDeclaration(node) && !isGenericDeclaration(node) && !augmentsAModule(node);\n\nconst isPlainTypeLiteral = (node: Node): node is TypeAliasDeclaration =>\n isTypeAliasDeclaration(node) && !isGenericDeclaration(node) && isTypeLiteralNode(node.type);\n\nconst isDeclaredShape = (node: Node): node is InterfaceDeclaration | TypeAliasDeclaration =>\n isPlainInterface(node) || isPlainTypeLiteral(node);\n\nconst declaredShapeOf =\n (checker: Checker) =>\n (node: Node): Option.Option<Type> =>\n Option.liftPredicate(node, isDeclaredShape).pipe(\n Option.map((declaration) => checker.getTypeAtLocation(declaration.name)),\n );\n\nconst schemaShapeOf =\n (checker: Checker) =>\n (node: Node): Option.Option<Type> => {\n if (!isCallExpression(node)) {\n return Option.none();\n }\n const { arguments: callArguments } = node;\n if (\n !pipe(\n callArguments,\n Arr.some((argument) => isObjectLiteralExpression(argument)),\n )\n ) {\n return Option.none();\n }\n return schemaTypeOf(checker)(checker.getTypeAtLocation(node)).pipe(\n Option.filter((type) => isObjectType(checker)(type)),\n );\n };\n\nconst shapeSitesIn =\n (checker: Checker) =>\n (sourceFile: SourceFile): readonly ShapeSite[] =>\n Arr.getSomes(\n pipe(\n descendantsOf(sourceFile),\n Arr.map((node) =>\n declaredShapeOf(checker)(node).pipe(\n Option.orElse(() => schemaShapeOf(checker)(node)),\n Option.map((type) => ({ node, type })),\n ),\n ),\n ),\n );\n\ninterface LocalProperty {\n readonly name: string;\n readonly type: Type;\n}\n\ninterface OpenTypeIds {\n readonly any: number;\n readonly unknown: number;\n}\n\nconst openTypeIdsOf = (checker: Checker): OpenTypeIds => ({\n any: checker.getAnyType().id,\n unknown: checker.getUnknownType().id,\n});\n\ntype IndexedDeclaration =\n | TypeAliasDeclaration\n | InterfaceDeclaration\n | EnumDeclaration\n | VariableDeclaration;\n\nconst isIndexedDeclaration = (node: Node): node is IndexedDeclaration =>\n isTypeDeclaration(node) || isVariableDeclaration(node);\n\nconst declarationAt =\n (program: Program) =>\n (location: DeclarationLocation): Option.Option<IndexedDeclaration> =>\n Option.fromUndefinedOr(program.getSourceFile(location.file)).pipe(\n Option.flatMap((sourceFile) =>\n Arr.findFirst(\n descendantsOf(sourceFile),\n (node): node is IndexedDeclaration =>\n node.pos === location.pos && node.kind === location.kind && isIndexedDeclaration(node),\n ),\n ),\n );\n\nconst symbolOfDeclaration =\n (checker: Checker) =>\n (declaration: IndexedDeclaration): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(checker.getSymbolAtLocation(declaration.name));\n\nconst shapeTypeOf =\n (context: ShapeContext) =>\n (shape: LibraryShape): Option.Option<Type> => {\n const { checker } = context;\n return declarationAt(context.program)(shape.declaration).pipe(\n Option.flatMap((declaration) =>\n symbolOfDeclaration(checker)(declaration).pipe(\n Option.flatMap((symbol) => {\n if (shape.form === \"declared\") {\n return Option.some(checker.getDeclaredTypeOfSymbol(symbol));\n }\n return schemaTypeOf(checker)(checker.getTypeOfSymbolAtLocation(symbol, declaration));\n }),\n ),\n ),\n );\n };\n\nconst hasEveryName =\n (locals: readonly LocalProperty[]) =>\n (shape: LibraryShape): boolean => {\n const names: ReadonlySet<string> = new Set(shape.propertyNames);\n return pipe(\n locals,\n Arr.every((local) => names.has(local.name)),\n );\n };\n\nconst sameProperty =\n (checker: Checker, open: OpenTypeIds) =>\n (localType: Type, library: TypeSymbol): boolean => {\n const libraryType = checker.getTypeOfSymbol(library);\n return (\n libraryType.id !== open.any &&\n libraryType.id !== open.unknown &&\n checker.isTypeAssignableTo(localType, libraryType) &&\n checker.isTypeAssignableTo(libraryType, localType)\n );\n };\n\nconst matchOf =\n (context: ShapeContext, open: OpenTypeIds) =>\n (locals: readonly LocalProperty[], shape: LibraryShape): Option.Option<ShapeMatch> => {\n const { checker } = context;\n const matches = shapeTypeOf(context)(shape).pipe(\n Option.exists((shapeType) =>\n pipe(\n locals,\n Arr.every((local) =>\n Option.fromUndefinedOr(checker.getPropertyOfType(shapeType, local.name)).pipe(\n Option.exists((library) => sameProperty(checker, open)(local.type, library)),\n ),\n ),\n ),\n ),\n );\n if (!matches) {\n return Option.none();\n }\n return Option.some({ shape, extra: shape.propertyNames.length - locals.length });\n };\n\nconst localPropertiesOf =\n (checker: Checker) =>\n (symbols: readonly TypeSymbol[]): readonly LocalProperty[] =>\n pipe(\n Arr.zip(symbols, checker.getTypeOfSymbol(symbols)),\n Arr.map(([symbol, type]) => ({ name: symbol.name, type })),\n );\n\nconst matchOrder = Order.mapInput(Order.Number, (match: ShapeMatch) => match.extra);\n\nconst shapeProblem = (site: ShapeSite, matches: readonly ShapeMatch[]): Problem => {\n const shown = pipe(\n Arr.take(matches, CANDIDATE_LIMIT),\n Arr.map((match) => describeLibraryType(match.shape)),\n Arr.join(\", \"),\n );\n const advice = Option.match(\n Arr.findFirst(matches, (match) => match.extra === EXACT),\n {\n onNone: () =>\n \"Derive it from the library type, for example with Pick, instead of copying its properties.\",\n onSome: () => \"Use the library type instead of copying it.\",\n },\n );\n return problemAt({ rule: \"library-shape\", message: `This shape copies ${shown}. ${advice}` })(\n site.node,\n );\n};\n\nconst candidatesOf =\n (context: ShapeContext, open: OpenTypeIds) =>\n (site: ShapeSite, locals: readonly LocalProperty[]): readonly ShapeMatch[] => {\n const derived = derivedDeclarationsOf(context.checker)(site.node);\n const named = pipe(context.shapes, Arr.filter(hasEveryName(locals)));\n if (\n pipe(\n named,\n Arr.some((shape) => derived.has(declarationKey(shape.declaration))),\n )\n ) {\n return [];\n }\n const candidates = pipe(\n named,\n Arr.map((shape) => matchOf(context, open)(locals, shape)),\n Arr.getSomes,\n );\n return Arr.sort(candidates, matchOrder);\n };\n\nconst shapeProblemOf =\n (context: ShapeContext, open: OpenTypeIds) =>\n (site: ShapeSite): Option.Option<Problem> => {\n const symbols = context.checker.getPropertiesOfType(site.type);\n if (symbols.length < MINIMUM_SHAPE_PROPERTIES) {\n return Option.none();\n }\n const locals = localPropertiesOf(context.checker)(symbols);\n return Option.liftPredicate(\n candidatesOf(context, open)(site, locals),\n Arr.isReadonlyArrayNonEmpty,\n ).pipe(Option.map((found) => shapeProblem(site, found)));\n };\n\nconst shapeProblemsIn =\n (context: ShapeContext) =>\n (sourceFile: SourceFile): readonly Problem[] => {\n const sites = shapeSitesIn(context.checker)(sourceFile);\n if (!Arr.isReadonlyArrayNonEmpty(sites)) {\n return [];\n }\n const open = openTypeIdsOf(context.checker);\n return Arr.getSomes(\n pipe(\n sites,\n Arr.map((site) => shapeProblemOf(context, open)(site)),\n ),\n );\n };\n\nexport { shapeProblemsIn };\nexport type { ShapeContext };\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport {\n isArrayLiteralExpression,\n isCallExpression,\n isElementAccessExpression,\n isEnumDeclaration,\n isIdentifier,\n isPropertyAccessExpression,\n isSpreadElement,\n isTypeReferenceNode,\n isUnionTypeNode,\n} from \"./compiler.ts\";\nimport type {\n ArrayLiteralExpression,\n CallExpression,\n Checker,\n Expression,\n Node,\n TypeSymbol,\n TypeNode,\n UnionTypeNode,\n} from \"./compiler.ts\";\nimport {\n childrenOf,\n declarationsOf,\n isTypeDeclaration,\n propertyNamesOf,\n referencedSymbols,\n} from \"./syntax.ts\";\nimport { finiteValuesOf, isSubsetOf, literalUnionOf, schemaTypeOf } from \"./values.ts\";\nimport type { Value } from \"./values.ts\";\n\ninterface ValueSite {\n readonly node: Node;\n readonly values: readonly Value[];\n readonly sources: readonly TypeSymbol[];\n}\n\nconst namedValuesOf =\n (checker: Checker) =>\n (symbol: TypeSymbol): Option.Option<readonly Value[]> => {\n if (\n pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isTypeDeclaration(declaration)),\n )\n ) {\n return finiteValuesOf(checker)(checker.getDeclaredTypeOfSymbol(symbol));\n }\n return finiteValuesOf(checker)(checker.getTypeOfSymbol(symbol));\n };\n\nconst hasFiniteContext =\n (checker: Checker) =>\n (node: Expression): boolean =>\n Option.fromUndefinedOr(checker.getContextualType(node)).pipe(\n Option.flatMap(finiteValuesOf(checker)),\n Option.isSome,\n );\n\nconst isNamedValue = (element: Expression): boolean => {\n if (isSpreadElement(element)) {\n return isNamedValue(element.expression);\n }\n return (\n isIdentifier(element) ||\n isPropertyAccessExpression(element) ||\n isElementAccessExpression(element)\n );\n};\n\nconst namesEveryElement = (array: ArrayLiteralExpression): boolean =>\n pipe(\n array.elements,\n Arr.every((element) => isNamedValue(element)),\n );\n\nconst expressionValuesOf =\n (checker: Checker) =>\n (node: Expression): Option.Option<readonly Value[]> => {\n if (hasFiniteContext(checker)(node)) {\n return Option.none();\n }\n const type = checker.getTypeAtLocation(node);\n if (isArrayLiteralExpression(node)) {\n return Option.liftPredicate(node, (array) => !namesEveryElement(array)).pipe(\n Option.flatMap(() => finiteValuesOf(checker)(type)),\n );\n }\n return schemaTypeOf(checker)(type).pipe(Option.flatMap(literalUnionOf));\n };\n\nconst selectsKeys =\n (checker: Checker) =>\n (node: UnionTypeNode, values: readonly Value[]): boolean => {\n const { parent } = node;\n if (!isTypeReferenceNode(parent)) {\n return false;\n }\n const typeArguments: readonly TypeNode[] = parent.typeArguments ?? [];\n return pipe(\n typeArguments,\n Arr.filter((argument) => argument !== node),\n Arr.some((argument) =>\n isSubsetOf(values, propertyNamesOf(checker)(checker.getTypeFromTypeNode(argument))),\n ),\n );\n };\n\nconst unionValuesOf =\n (checker: Checker) =>\n (node: UnionTypeNode): Option.Option<readonly Value[]> =>\n literalUnionOf(checker.getTypeFromTypeNode(node)).pipe(\n Option.filter((values) => !selectsKeys(checker)(node, values)),\n );\n\nconst isExpressionSite = (node: Node): node is ArrayLiteralExpression | CallExpression =>\n isArrayLiteralExpression(node) || isCallExpression(node);\n\nconst expressionSiteValuesOf =\n (checker: Checker) =>\n (node: Node): Option.Option<readonly Value[]> =>\n Option.liftPredicate(node, isExpressionSite).pipe(Option.flatMap(expressionValuesOf(checker)));\n\nconst siteValuesOf =\n (checker: Checker) =>\n (node: Node): Option.Option<readonly Value[]> => {\n if (isUnionTypeNode(node)) {\n return unionValuesOf(checker)(node);\n }\n if (isEnumDeclaration(node)) {\n return literalUnionOf(checker.getTypeAtLocation(node.name));\n }\n return expressionSiteValuesOf(checker)(node);\n };\n\nconst derivationScopeOf = (node: Node): Node => {\n if (isTypeReferenceNode(node.parent)) {\n return node.parent;\n }\n return node;\n};\n\nconst sourcesOf =\n (checker: Checker) =>\n (node: Node): readonly TypeSymbol[] =>\n pipe(\n referencedSymbols(checker)(derivationScopeOf(node)),\n Arr.filter((symbol) => Option.isSome(namedValuesOf(checker)(symbol))),\n );\n\nconst sitesUnder =\n (checker: Checker) =>\n (node: Node): readonly ValueSite[] => {\n const nested = pipe(\n childrenOf(node),\n Arr.flatMap((child) => sitesUnder(checker)(child)),\n );\n if (Arr.isReadonlyArrayNonEmpty(nested)) {\n return nested;\n }\n return siteValuesOf(checker)(node).pipe(\n Option.map((values) => ({ node, values, sources: sourcesOf(checker)(node) })),\n Option.toArray,\n );\n };\n\nexport { sitesUnder };\nexport type { ValueSite };\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport {\n isBinaryExpression,\n isCallExpression,\n isNewExpression,\n isNumericLiteral,\n isPropertyAssignment,\n isStringLiteral,\n isTypeAliasDeclaration,\n isVariableDeclaration,\n SyntaxKind,\n} from \"./compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Node,\n NumericLiteral,\n SourceFile,\n StringLiteral,\n TypeSymbol,\n} from \"./compiler.ts\";\nimport type { Flow } from \"./flows.ts\";\nimport { describeLibraryType } from \"./library.ts\";\nimport type { LibraryVocabulary } from \"./library.ts\";\nimport { ownerKeyOf } from \"./owners.ts\";\nimport type { Owner } from \"./owners.ts\";\nimport { CANDIDATE_LIMIT, problemAt } from \"./problem.ts\";\nimport type { Problem } from \"./problem.ts\";\nimport type { ValueSite } from \"./sites.ts\";\nimport { contextSymbolsOf } from \"./slots.ts\";\nimport {\n contains,\n declarationsOf,\n descendantsOf,\n importedModulesOf,\n referencedSymbols,\n uniqueByReference,\n} from \"./syntax.ts\";\nimport { formatValues, isSubsetOf, vocabularyOf } from \"./values.ts\";\n\ninterface ValueContext {\n readonly checker: Checker;\n readonly owners: readonly Owner[];\n readonly vocabularies: readonly LibraryVocabulary[];\n readonly flows: readonly Flow[];\n}\n\ninterface SiteVerdict {\n readonly problems: readonly Problem[];\n readonly unowned: readonly ValueSite[];\n}\n\nconst OWNER_SEARCH_DEPTH = 4;\nconst NOTHING_HIDDEN = 0;\n\nconst directOwners =\n (context: ValueContext) =>\n (symbol: TypeSymbol): readonly Owner[] => {\n const keys = Arr.getSomes(\n pipe(\n declarationsOf(symbol),\n Arr.map((declaration) => ownerKeyOf(declaration)),\n ),\n );\n return pipe(\n context.owners,\n Arr.filter((owner) => keys.includes(owner.key)),\n );\n };\n\nconst isFollowable = (declaration: Declaration): boolean =>\n !declaration.getSourceFile().isDeclarationFile &&\n (isTypeAliasDeclaration(declaration) || isVariableDeclaration(declaration));\n\nconst ownersBehind =\n (context: ValueContext) =>\n (symbol: TypeSymbol, ancestors: readonly TypeSymbol[]): readonly Owner[] => {\n const direct = directOwners(context)(symbol);\n if (Arr.isReadonlyArrayNonEmpty(direct) || ancestors.length >= OWNER_SEARCH_DEPTH) {\n return direct;\n }\n const visited = [...ancestors, symbol];\n return uniqueByReference(\n pipe(\n declarationsOf(symbol),\n Arr.filter((declaration) => isFollowable(declaration)),\n Arr.flatMap((declaration) => referencedSymbols(context.checker)(declaration)),\n Arr.filter((referenced) => !visited.includes(referenced)),\n Arr.flatMap((referenced) => ownersBehind(context)(referenced, visited)),\n ),\n );\n };\n\nconst describeOwners = (owners: readonly Owner[]): string =>\n pipe(\n owners,\n Arr.map((owner) => `${owner.conceptId} (${owner.name})`),\n Arr.join(\", \"),\n );\n\nconst verdict = (problems: readonly Problem[], unowned: readonly ValueSite[]): SiteVerdict => ({\n problems,\n unowned,\n});\n\nconst derivedVerdict =\n (context: ValueContext) =>\n (site: ValueSite): SiteVerdict => {\n const owners = uniqueByReference(\n pipe(\n site.sources,\n Arr.flatMap((source) => ownersBehind(context)(source, [])),\n ),\n );\n const held = pipe(\n owners,\n Arr.flatMap((owner) => owner.values),\n );\n const added = pipe(\n site.values,\n Arr.filter((value) => !isSubsetOf([value], held)),\n );\n if (!Arr.isReadonlyArrayNonEmpty(owners) || !Arr.isReadonlyArrayNonEmpty(added)) {\n return verdict([], []);\n }\n 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.`;\n return verdict([problemAt({ rule: \"owner-extension\", message })(site.node)], []);\n };\n\nconst libraryCandidates =\n (context: ValueContext) =>\n (site: ValueSite): readonly string[] => {\n const flowing = Arr.dedupe(\n pipe(\n context.flows,\n Arr.filter((flow) => flow.site.node === site.node),\n Arr.map((flow) => flow.target),\n ),\n );\n if (Arr.isReadonlyArrayNonEmpty(flowing)) {\n return flowing;\n }\n if (\n !pipe(\n site.values,\n Arr.some((value) => typeof value === \"string\"),\n )\n ) {\n return [];\n }\n const imported = importedModulesOf(site.node.getSourceFile());\n return Arr.dedupe(\n pipe(\n context.vocabularies,\n Arr.filter((library) => imported.includes(library.specifier)),\n Arr.filter((library) => isSubsetOf(site.values, library.vocabulary.values)),\n Arr.map((library) => describeLibraryType(library)),\n ),\n );\n };\n\nconst listCandidates = (candidates: readonly string[]): string => {\n const shown = pipe(Arr.take(candidates, CANDIDATE_LIMIT), Arr.join(\", \"));\n const hidden = candidates.length - CANDIDATE_LIMIT;\n if (hidden > NOTHING_HIDDEN) {\n return `${shown} and ${String(hidden)} more`;\n }\n return shown;\n};\n\nconst originalVerdict =\n (context: ValueContext) =>\n (site: ValueSite): SiteVerdict => {\n const owners = pipe(\n context.owners,\n Arr.filter((owner) => isSubsetOf(site.values, owner.values)),\n );\n if (Arr.isReadonlyArrayNonEmpty(owners)) {\n const message = `The values ${formatValues(site.values)} are owned by ${describeOwners(owners)}. Derive this set from the owner instead of restating it.`;\n return verdict([problemAt({ rule: \"owner-value-set\", message })(site.node)], []);\n }\n const candidates = libraryCandidates(context)(site);\n if (Arr.isReadonlyArrayNonEmpty(candidates)) {\n const message = `The values ${formatValues(site.values)} restate a dependency type: ${listCandidates(candidates)}. Derive this set from the library type.`;\n return verdict([problemAt({ rule: \"library-value-set\", message })(site.node)], []);\n }\n return verdict([], [site]);\n };\n\nconst siteVerdict =\n (context: ValueContext) =>\n (site: ValueSite): SiteVerdict => {\n if (Arr.isReadonlyArrayNonEmpty(site.sources)) {\n return derivedVerdict(context)(site);\n }\n return originalVerdict(context)(site);\n };\n\nconst VALUE_PARENT_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.ReturnStatement,\n SyntaxKind.ArrayLiteralExpression,\n SyntaxKind.ConditionalExpression,\n SyntaxKind.ParenthesizedExpression,\n SyntaxKind.ArrowFunction,\n SyntaxKind.JsxExpression,\n]);\n\nconst isCallArgument = (node: Node, parent: Node): boolean =>\n (isCallExpression(parent) || isNewExpression(parent)) && parent.expression !== node;\n\nconst isInitializer = (node: Node, parent: Node): boolean =>\n (isPropertyAssignment(parent) || isVariableDeclaration(parent)) && parent.initializer === node;\n\nconst isRightOperand = (node: Node, parent: Node): boolean =>\n isBinaryExpression(parent) && parent.right === node;\n\nconst VALUE_SLOTS = [isCallArgument, isInitializer, isRightOperand];\n\nconst isValuePosition = (node: Node): boolean => {\n const { parent } = node;\n return (\n VALUE_PARENT_KINDS.has(parent.kind) ||\n pipe(\n VALUE_SLOTS,\n Arr.some((isSlot) => isSlot(node, parent)),\n )\n );\n};\n\nconst ownedLiteralProblem =\n (context: ValueContext) =>\n (literal: StringLiteral | NumericLiteral): Option.Option<Problem> =>\n Option.fromUndefinedOr(context.checker.getContextualType(literal)).pipe(\n Option.filter((contextual) =>\n vocabularyOf(context.checker)(contextual).pipe(\n Option.exists((vocabulary) => !vocabulary.admitsUnnamedValues),\n ),\n ),\n Option.map(() =>\n pipe(\n contextSymbolsOf(context.checker)(literal),\n Arr.flatMap((symbol) => ownersBehind(context)(symbol, [])),\n uniqueByReference,\n Arr.filter((owner) => isSubsetOf([literal.text], pipe(owner.values, Arr.map(String)))),\n ),\n ),\n Option.filter((owners) => Arr.isReadonlyArrayNonEmpty(owners)),\n Option.map((owners) =>\n problemAt({\n rule: \"owned-literal\",\n message: `${literal.getText()} is a value of ${describeOwners(owners)}. Write it through the owner's binding instead of as a literal.`,\n })(literal),\n ),\n );\n\nconst ownedLiteralProblems =\n (context: ValueContext) =>\n (sourceFile: SourceFile, excluded: readonly Node[]): readonly Problem[] =>\n Arr.getSomes(\n pipe(\n descendantsOf(sourceFile),\n Arr.filter((node) => isStringLiteral(node) || isNumericLiteral(node)),\n Arr.filter((node) => isValuePosition(node)),\n Arr.filter(\n (node) =>\n !pipe(\n excluded,\n Arr.some((outer) => contains(outer)(node)),\n ),\n ),\n Arr.map((node) => ownedLiteralProblem(context)(node)),\n ),\n );\n\nexport { ownedLiteralProblems, siteVerdict };\nexport type { SiteVerdict, ValueContext };\n","import { Option, Array as Arr, pipe } from \"effect\";\n\nimport { isVariableDeclaration } from \"./compiler.ts\";\nimport type { Checker, Node, VariableDeclaration } from \"./compiler.ts\";\nimport { flowsIn } from \"./flows.ts\";\nimport { ownerKeyOf } from \"./owners.ts\";\nimport type { Owner } from \"./owners.ts\";\nimport type { Problem } from \"./problem.ts\";\nimport type { Project } from \"./project.ts\";\nimport { shapeProblemsIn } from \"./shapes.ts\";\nimport { sitesUnder } from \"./sites.ts\";\nimport type { ValueSite } from \"./sites.ts\";\nimport { contains, descendantsOf } from \"./syntax.ts\";\nimport { ownedLiteralProblems, siteVerdict } from \"./value-checks.ts\";\n\ninterface ProjectAnalysis {\n readonly problems: readonly Problem[];\n readonly unowned: readonly ValueSite[];\n}\n\nconst isVisibleTo =\n (project: Project) =>\n (owner: Owner): boolean =>\n pipe(\n project.sourceFiles,\n Arr.some((sourceFile) => sourceFile.fileName === owner.file),\n ) ||\n Option.exists(\n owner.packageName,\n (name) =>\n Option.contains(project.packageName, name) || project.workspaceDependencies.includes(name),\n );\n\nconst ownerDeclarationsIn = (\n project: Project,\n owners: readonly Owner[],\n): readonly VariableDeclaration[] => {\n const keys = new Set(\n pipe(\n owners,\n Arr.map((owner) => owner.key),\n ),\n );\n return pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) =>\n pipe(\n descendantsOf(sourceFile),\n Arr.filter((node) => isVariableDeclaration(node)),\n Arr.filter((declaration) => Option.exists(ownerKeyOf(declaration), (key) => keys.has(key))),\n ),\n ),\n );\n};\n\nconst isInside =\n (outers: readonly Node[]) =>\n (node: Node): boolean =>\n pipe(\n outers,\n Arr.some((outer) => contains(outer)(node)),\n );\n\nconst sitesOutside =\n (checker: Checker) =>\n (project: Project, outers: readonly Node[]): readonly ValueSite[] =>\n pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) => sitesUnder(checker)(sourceFile)),\n Arr.filter((site) => !isInside(outers)(site.node)),\n );\n\nconst nodesOf = (sites: readonly ValueSite[]): readonly Node[] =>\n pipe(\n sites,\n Arr.map((site) => site.node),\n );\n\nconst analyzeProject =\n (owners: readonly Owner[]) =>\n (project: Project): ProjectAnalysis => {\n const { checker } = project;\n const ownerDeclarations = ownerDeclarationsIn(project, owners);\n const sites = sitesOutside(checker)(project, ownerDeclarations);\n const flowContext = { checker, program: project.program, sites };\n const context = {\n checker,\n owners: pipe(\n owners,\n Arr.filter((owner) => isVisibleTo(project)(owner)),\n ),\n vocabularies: project.library.vocabularies,\n flows: pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) => flowsIn(flowContext)(sourceFile)),\n ),\n };\n const verdicts = pipe(\n sites,\n Arr.map((site) => siteVerdict(context)(site)),\n );\n const excluded = [...ownerDeclarations, ...nodesOf(sites)];\n const shapeContext = { checker, program: project.program, shapes: project.library.shapes };\n return {\n problems: [\n ...pipe(\n verdicts,\n Arr.flatMap((found) => found.problems),\n ),\n ...pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) => [\n ...ownedLiteralProblems(context)(sourceFile, excluded),\n ...shapeProblemsIn(shapeContext)(sourceFile),\n ]),\n ),\n ],\n unowned: pipe(\n verdicts,\n Arr.flatMap((found) => found.unowned),\n ),\n };\n };\n\nexport { analyzeProject };\nexport type { ProjectAnalysis };\n","import { Array as Arr, Order, Record as Rec, pipe } from \"effect\";\n\nimport { OWNER_TAG } from \"./owners.ts\";\nimport type { Problem } from \"./problem.ts\";\nimport type { ValueSite } from \"./sites.ts\";\nimport { columnOf, lineOf } from \"./syntax.ts\";\nimport { formatValues, valueKey } from \"./values.ts\";\nimport type { Value } from \"./values.ts\";\n\ninterface PackageScope {\n readonly name: string;\n readonly dependencies: readonly string[];\n}\n\ninterface UnownedSite {\n readonly scope: PackageScope;\n readonly file: string;\n readonly start: number;\n readonly line: number;\n readonly column: number;\n readonly values: readonly Value[];\n}\n\nconst DUPLICATE_THRESHOLD = 1;\n\nconst unownedSiteOf =\n (scope: PackageScope) =>\n (site: ValueSite): UnownedSite => ({\n scope,\n file: site.node.getSourceFile().fileName,\n start: site.node.getStart(),\n line: lineOf(site.node),\n column: columnOf(site.node),\n values: site.values,\n });\n\nconst canDerive = (left: UnownedSite, right: UnownedSite): boolean =>\n left.scope.name === right.scope.name ||\n left.scope.dependencies.includes(right.scope.name) ||\n right.scope.dependencies.includes(left.scope.name);\n\nconst siteKey = (site: UnownedSite): string => `${site.file}#${String(site.start)}`;\n\nconst valueSetKey = (site: UnownedSite): string => {\n const keys = pipe(\n site.values,\n Arr.map((value) => valueKey(value)),\n );\n return pipe(Arr.sort(keys, Order.String), Arr.join(\"\\0\"));\n};\n\nconst duplicateProblems =\n (relative: (file: string) => string) =>\n (sites: readonly UnownedSite[]): readonly Problem[] => {\n const unique = Arr.dedupeWith(sites, (left, right) => siteKey(left) === siteKey(right));\n const groups = Rec.values(Arr.groupBy(unique, (site) => valueSetKey(site)));\n return pipe(\n groups,\n Arr.filter((group) => group.length > DUPLICATE_THRESHOLD),\n Arr.flatMap((group) =>\n pipe(\n group,\n Arr.flatMap((site): readonly Problem[] => {\n const related = pipe(\n group,\n Arr.filter((other) => other !== site && canDerive(site, other)),\n );\n if (!Arr.isReadonlyArrayNonEmpty(related)) {\n return [];\n }\n const others = pipe(\n related,\n Arr.map((other) => `${relative(other.file)}:${String(other.line)}`),\n Arr.join(\", \"),\n );\n return [\n {\n file: site.file,\n line: site.line,\n column: site.column,\n rule: \"duplicate-value-set\",\n message: `The values ${formatValues(site.values)} are also declared at ${others}. Register one owner with /** @${OWNER_TAG} <concept> */ and derive the others from it.`,\n },\n ];\n }),\n ),\n ),\n );\n };\n\nexport { duplicateProblems, unownedSiteOf };\nexport type { PackageScope, UnownedSite };\n","import { Array as Arr, Effect, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nimport type { API } from \"./compiler.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst RSS_LINE = /^VmRSS:\\s+(?<kib>\\d+) kB$/mu;\nconst BYTES_PER_KIB = 1024;\nconst UNKNOWN_RSS = 0;\n\nconst kibibytesIn = (status: string): Option.Option<string> =>\n Option.fromNullishOr(RSS_LINE.exec(status)).pipe(\n Option.flatMap((match) => Option.fromUndefinedOr(match.groups)),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[\"kib\"])),\n );\n\nconst residentBytesOf = (pid: string): Effect.Effect<number, never, RepositoryFiles> =>\n Effect.gen(function* residentBytes() {\n const files = yield* RepositoryFiles;\n const status = yield* files.readFile(`/proc/${pid}/status`);\n return pipe(\n status,\n Option.flatMap(kibibytesIn),\n Option.flatMap(Num.parse),\n Option.map((kib) => kib * BYTES_PER_KIB),\n Option.getOrElse(() => UNKNOWN_RSS),\n );\n });\n\nconst childPids = Effect.gen(function* childPids() {\n const files = yield* RepositoryFiles;\n const pid = String(process.pid);\n const children = yield* files.readFile(`/proc/${pid}/task/${pid}/children`);\n return pipe(\n children,\n Option.map((text) => pipe(Str.trim(text), Str.split(\" \"), Arr.filter(Str.isNonEmpty))),\n Option.getOrElse((): readonly string[] => []),\n );\n});\n\nconst annotateMemory = Effect.gen(function* annotateMemory() {\n const own = yield* residentBytesOf(String(process.pid));\n const pids = yield* childPids;\n const children = yield* pipe(\n pids,\n Effect.forEach((pid) => residentBytesOf(pid)),\n );\n const { heapUsed } = process.memoryUsage();\n yield* Effect.annotateCurrentSpan({\n \"process.memory.rss\": own,\n \"process.memory.heap_used\": heapUsed,\n \"msch.compiler.memory.rss\": Num.sumAll(children),\n });\n});\n\nconst annotateResources = (api: API): Effect.Effect<void, never, RepositoryFiles> =>\n Effect.gen(function* annotateCompiler() {\n yield* annotateMemory;\n const { totals } = api.getTimingInfo();\n yield* Effect.annotateCurrentSpan({\n \"msch.compiler.requests\": totals.requestCount,\n \"msch.compiler.round_trip_ms\": totals.roundTripMs,\n \"msch.compiler.server_ms\": totals.serverTimeMs,\n });\n });\n\nexport { annotateResources };\n","import { Array as Arr, Effect, Option, Order, String as Str, pipe } from \"effect\";\n\nimport { API, getLeadingCommentRanges } from \"./compiler.ts\";\nimport type { Checker, ParsedCommandLine, Program, SourceFile } from \"./compiler.ts\";\nimport {\n MANIFEST_FILE,\n NODE_MODULES,\n dependencyEntries,\n readManifest,\n workspaceDependencies,\n} from \"./dependencies.ts\";\nimport { libraryCache, libraryIndex } from \"./library.ts\";\nimport type { LibraryCache, LibraryIndex } from \"./library.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { annotateResources } from \"./telemetry.ts\";\n\ninterface Project {\n readonly packageName: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n readonly program: Program;\n readonly checker: Checker;\n readonly sourceFiles: readonly SourceFile[];\n readonly library: LibraryIndex;\n}\n\ninterface PackageInfo {\n readonly directory: string;\n readonly name: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n}\n\nconst CONFIG_FILE = \"tsconfig.json\";\nconst CONFIG_PATHSPEC = `:(glob)**/${CONFIG_FILE}`;\nconst HIDDEN_PREFIX = \".\";\nconst SKIPPED_DIRECTORIES: ReadonlySet<string> = new Set([NODE_MODULES, \"dist\", \"coverage\"]);\n\nconst isVisible = (file: string): boolean =>\n pipe(\n Str.split(file, \"/\"),\n Arr.every(\n (segment) => !Str.startsWith(HIDDEN_PREFIX)(segment) && !SKIPPED_DIRECTORIES.has(segment),\n ),\n );\n\nconst listConfigFiles = (root: string): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* configFilesUnder() {\n const files = yield* RepositoryFiles;\n const listed = yield* files.matchingFiles(root, [CONFIG_PATHSPEC]);\n const visible = pipe(\n listed,\n Arr.filter(isVisible),\n Arr.map((file) => files.join(root, file)),\n );\n return Arr.sort(visible, Order.String);\n });\n\nconst parseConfig =\n (api: API) =>\n (configPath: string): Option.Option<ParsedCommandLine> =>\n Option.some(api.parseConfigFile(configPath)).pipe(\n Option.filter((parsed) => Arr.isReadonlyArrayNonEmpty(parsed.fileNames)),\n );\n\nconst nearestPackageDirectory = (\n directory: string,\n root: string,\n): Effect.Effect<string, never, RepositoryFiles> =>\n Effect.gen(function* nearestPackage() {\n const files = yield* RepositoryFiles;\n const hasManifest = yield* files.exists(files.join(directory, MANIFEST_FILE));\n const parent = files.dirname(directory);\n if (hasManifest || directory === root || parent === directory) {\n return directory;\n }\n return yield* nearestPackageDirectory(parent, root);\n });\n\nconst packageInfoOf = Effect.fn(\"packageInfoOf\")(function* packageInfoOf(\n configPath: string,\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const directory = yield* nearestPackageDirectory(files.dirname(configPath), root);\n const manifest = yield* readManifest(directory);\n return {\n directory,\n name: manifest.pipe(Option.flatMap((found) => Option.fromUndefinedOr(found.name))),\n workspaceDependencies: manifest.pipe(\n Option.map(workspaceDependencies),\n Option.getOrElse(() => []),\n ),\n } satisfies PackageInfo;\n});\n\nconst NO_CHECK_PRAGMA = /^\\/\\/\\s*@ts-nocheck/u;\nconst FILE_START = 0;\n\nconst skipsTypeChecking = (sourceFile: SourceFile): boolean =>\n pipe(\n getLeadingCommentRanges(sourceFile.text, FILE_START) ?? [],\n Arr.some((range) => NO_CHECK_PRAGMA.test(Str.slice(range.pos, range.end)(sourceFile.text))),\n );\n\nconst buildProject = Effect.fn(\"buildProject\")(function* buildProject(\n { compiler: { api, libraries }, generated }: Workspace,\n parsed: ParsedCommandLine,\n info: PackageInfo,\n) {\n const entries = yield* dependencyEntries(info.directory);\n const program = yield* Effect.sync(() =>\n api.createProgram(\n [\n ...parsed.fileNames,\n ...pipe(\n entries,\n Arr.map((entry) => entry.declarationsPath),\n ),\n ],\n { ...parsed.options, noEmit: true },\n ),\n ).pipe(Effect.withSpan(\"createProgram\"));\n const { checker } = program.getProject();\n const library = yield* libraryIndex(libraries)(checker)(entries);\n const projectFiles: ReadonlySet<string> = new Set(\n pipe(\n parsed.fileNames,\n Arr.filter((fileName) => !generated.includes(fileName)),\n ),\n );\n return {\n packageName: info.name,\n workspaceDependencies: info.workspaceDependencies,\n program,\n checker,\n sourceFiles: pipe(\n program.getSourceFileNames(),\n Arr.filter((fileName) => projectFiles.has(fileName)),\n Arr.flatMap((fileName) =>\n Option.toArray(Option.fromUndefinedOr(program.getSourceFile(fileName))),\n ),\n Arr.filter((sourceFile) => !sourceFile.isDeclarationFile && !skipsTypeChecking(sourceFile)),\n ),\n library,\n } satisfies Project;\n});\n\ninterface Compiler {\n readonly api: API;\n readonly libraries: LibraryCache;\n}\n\ninterface Workspace {\n readonly compiler: Compiler;\n readonly root: string;\n readonly generated: readonly string[];\n}\n\nconst typeScriptCompiler = Effect.acquireRelease(\n Effect.sync((): Compiler => ({\n api: new API({ collectTiming: true }),\n libraries: libraryCache(),\n })),\n ({ api }) =>\n Effect.sync(() => {\n api.close();\n }),\n);\n\nconst loadProject = Effect.fn(\"loadProject\")(function* loadProject(\n workspace: Workspace,\n configPath: string,\n) {\n const { compiler, root } = workspace;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none<Project>();\n }\n const info = yield* packageInfoOf(configPath, root);\n const project = yield* buildProject(workspace, parsed.value, info);\n yield* Effect.annotateCurrentSpan({\n \"msch.project.config\": configPath,\n \"msch.project.program_files\": project.program.getSourceFileNames().length,\n \"msch.project.source_files\": project.sourceFiles.length,\n });\n yield* annotateResources(compiler.api);\n return Option.some(project);\n});\n\nconst releaseProject = (project: Project): Effect.Effect<void> =>\n Effect.sync(() => {\n project.program.dispose();\n });\n\nconst withProject =\n (workspace: Workspace) =>\n (configPath: string) =>\n <Value, Failure, Requirements>(\n work: (project: Project) => Effect.Effect<Value, Failure, Requirements>,\n ): Effect.Effect<Option.Option<Value>, Failure, Requirements | RepositoryFiles> =>\n Effect.acquireUseRelease(\n loadProject(workspace, configPath),\n (loaded) =>\n Option.match(loaded, {\n onNone: () => Effect.succeedNone,\n onSome: (project) => work(project).pipe(Effect.asSome),\n }),\n (loaded) => Option.match(loaded, { onNone: () => Effect.void, onSome: releaseProject }),\n );\n\nconst mentions =\n (needle: string) =>\n ({ api }: Compiler) =>\n (configPath: string): Effect.Effect<boolean, never, RepositoryFiles> =>\n Effect.gen(function* mentionsNeedle() {\n const files = yield* RepositoryFiles;\n const fileNames = Option.match(parseConfig(api)(configPath), {\n onNone: (): readonly string[] => [],\n onSome: (parsed): readonly string[] => parsed.fileNames,\n });\n const texts = yield* pipe(\n fileNames,\n Effect.forEach((fileName) => files.readFile(fileName)),\n );\n const includesNeedle = Str.includes(needle);\n return pipe(\n texts,\n Arr.some((text) => Option.exists(text, includesNeedle)),\n );\n });\n\nexport { listConfigFiles, mentions, typeScriptCompiler, withProject };\nexport type { Compiler, Project, Workspace };\n","import { Effect, Option, Array as Arr, pipe } from \"effect\";\n\nimport { analyzeProject } from \"./analysis.ts\";\nimport { duplicateProblems, unownedSiteOf } from \"./duplicates.ts\";\nimport type { PackageScope, UnownedSite } from \"./duplicates.ts\";\nimport { OWNER_TAG, combineOwnerScans, ownersIn } from \"./owners.ts\";\nimport type { Owner, OwnerScan } from \"./owners.ts\";\nimport { sortProblems } from \"./problem.ts\";\nimport type { Problem } from \"./problem.ts\";\nimport { listConfigFiles, mentions, typeScriptCompiler, withProject } from \"./project.ts\";\nimport type { Project, Workspace } from \"./project.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst scanOwners = Effect.fn(\"scanOwners\")(function* scanOwners(\n workspace: Workspace,\n configPaths: readonly string[],\n) {\n const ownerConfigs = yield* pipe(\n configPaths,\n Effect.filter(mentions(`@${OWNER_TAG}`)(workspace.compiler)),\n );\n const scans = yield* pipe(\n ownerConfigs,\n Effect.forEach((configPath) =>\n withProject(workspace)(configPath)((project) => Effect.sync(() => ownersIn(project))),\n ),\n );\n return combineOwnerScans(Arr.getSomes(scans));\n});\n\nconst scopeOf = (project: Project, configPath: string): PackageScope => ({\n name: Option.getOrElse(project.packageName, () => configPath),\n dependencies: project.workspaceDependencies,\n});\n\ninterface Analysis {\n readonly problems: readonly Problem[];\n readonly unowned: readonly UnownedSite[];\n}\n\nconst analyzeProjects =\n (workspace: Workspace, owners: readonly Owner[]) =>\n (configPaths: readonly string[]): Effect.Effect<readonly Analysis[], never, RepositoryFiles> =>\n pipe(\n configPaths,\n Effect.forEach((configPath) =>\n withProject(workspace)(configPath)((project) =>\n Effect.sync(() => {\n const analysis = analyzeProject(owners)(project);\n const scope = scopeOf(project, configPath);\n return {\n problems: analysis.problems,\n unowned: pipe(analysis.unowned, Arr.map(unownedSiteOf(scope))),\n };\n }).pipe(Effect.withSpan(\"analyzeProject\")),\n ),\n ),\n Effect.map(Arr.getSomes),\n );\n\nconst checkRepository = Effect.fn(\"checkRepository\")(function* checkRepository(root: string) {\n const files = yield* RepositoryFiles;\n const compiler = yield* typeScriptCompiler;\n const generated = yield* files.generatedFiles(root);\n const workspace: Workspace = { compiler, root, generated };\n const configPaths = yield* listConfigFiles(root);\n const ownerScan: OwnerScan = yield* scanOwners(workspace, configPaths);\n const analyses = yield* analyzeProjects(workspace, ownerScan.owners)(configPaths);\n const relative = (file: string): string => files.relative(root, file);\n const unowned = pipe(\n analyses,\n Arr.flatMap((analysis) => analysis.unowned),\n );\n return sortProblems([\n ...ownerScan.problems,\n ...pipe(\n analyses,\n Arr.flatMap((analysis) => analysis.problems),\n ),\n ...duplicateProblems(relative)(unowned),\n ]);\n}, Effect.scoped);\n\nexport { checkRepository };\n","import {\n Array as Arr,\n Effect,\n HashSet,\n Option,\n Record as Rec,\n Result,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport {\n SyntaxKind,\n isExportDeclaration,\n isImportDeclaration,\n isStringLiteral,\n} from \"./compiler.ts\";\nimport type { API, Node } from \"./compiler.ts\";\nimport { MANIFEST_FILE } from \"./dependencies.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst RELATIVE = /^\\.\\.?(?:\\/|$)/u;\nconst SUBPATH_IMPORT = \"#\";\nconst WILDCARD = \"*\";\nconst SCOPE = \"@\";\nconst SEPARATOR = \"/\";\nconst SOURCE_SUFFIXES = [\"\", \".ts\", \".tsx\", \"/index.ts\"] as const;\nconst SCOPED_SEGMENTS = 2;\nconst PLAIN_SEGMENTS = 1;\n\nconst ImportsField = Schema.Struct({\n imports: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n});\n\nconst decodeImports = Schema.decodeOption(Schema.fromJsonString(ImportsField));\n\ninterface Graph {\n readonly api: API;\n readonly directory: string;\n readonly imports: Readonly<Record<string, string>>;\n}\n\ninterface Walk {\n readonly pending: readonly string[];\n readonly visited: HashSet.HashSet<string>;\n readonly packages: HashSet.HashSet<string>;\n}\n\ntype Reference = Result.Result<string, string>;\n\nconst packageNameOf = (specifier: string): string => {\n const segments = Str.split(specifier, SEPARATOR);\n if (Str.startsWith(SCOPE)(specifier)) {\n return pipe(segments, Arr.take(SCOPED_SEGMENTS), Arr.join(SEPARATOR));\n }\n return pipe(segments, Arr.take(PLAIN_SEGMENTS), Arr.join(SEPARATOR));\n};\n\nconst literalText = (specifier: Node): Option.Option<string> =>\n pipe(\n Option.liftPredicate(specifier, isStringLiteral),\n Option.map((literal) => literal.text),\n );\n\nconst runtimeSpecifierOf = (statement: Node): Option.Option<string> => {\n if (isImportDeclaration(statement)) {\n const typeOnly = pipe(\n Option.fromUndefinedOr(statement.importClause),\n Option.exists((clause) => clause.phaseModifier === SyntaxKind.TypeKeyword),\n );\n return Option.filter(literalText(statement.moduleSpecifier), () => !typeOnly);\n }\n if (isExportDeclaration(statement) && !statement.isTypeOnly) {\n return Option.flatMap(Option.fromUndefinedOr(statement.moduleSpecifier), literalText);\n }\n return Option.none();\n};\n\nconst specifiersIn = (api: API, file: string, text: string): readonly string[] => {\n const retained = api.createSourceFile(file, text);\n const found = pipe(retained.sourceFile.statements, Arr.fromIterable, Arr.map(runtimeSpecifierOf));\n retained.dispose();\n return Arr.getSomes(found);\n};\n\nconst subpathTarget = (\n imports: Readonly<Record<string, string>>,\n specifier: string,\n): Option.Option<string> =>\n pipe(\n Rec.toEntries(imports),\n Arr.findFirst(([pattern, target]) => {\n if (!Str.endsWith(WILDCARD)(pattern)) {\n return Option.liftPredicate(target, () => pattern === specifier);\n }\n const prefix = Str.replace(WILDCARD, \"\")(pattern);\n return Option.liftPredicate(\n Str.replace(WILDCARD, Str.replace(prefix, \"\")(specifier))(target),\n () => Str.startsWith(prefix)(specifier),\n );\n }),\n );\n\nconst existingSource = Effect.fn(\"existingSource\")(function* existingSource(base: string) {\n const files = yield* RepositoryFiles;\n const found = yield* pipe(\n SOURCE_SUFFIXES,\n Effect.forEach((suffix) => {\n const candidate = `${base}${suffix}`;\n return files\n .isDirectory(candidate)\n .pipe(\n Effect.map((directory) =>\n Option.liftPredicate(candidate, () =>\n Option.exists(directory, (isDirectory) => !isDirectory),\n ),\n ),\n );\n }),\n );\n return Arr.head(Arr.getSomes(found));\n});\n\nconst localFile = Effect.fn(\"localFile\")(function* localFile(\n { directory, imports }: Graph,\n from: string,\n specifier: string,\n) {\n const files = yield* RepositoryFiles;\n if (RELATIVE.test(specifier)) {\n return yield* existingSource(files.resolve(files.dirname(from), specifier));\n }\n const target = subpathTarget(imports, specifier);\n if (Option.isNone(target)) {\n return Option.none<string>();\n }\n return yield* existingSource(files.resolve(directory, target.value));\n});\n\nconst referenceOf = (\n graph: Graph,\n from: string,\n specifier: string,\n): Effect.Effect<Option.Option<Reference>, never, RepositoryFiles> => {\n if (RELATIVE.test(specifier) || Str.startsWith(SUBPATH_IMPORT)(specifier)) {\n return localFile(graph, from, specifier).pipe(Effect.map(Option.map(Result.succeed)));\n }\n const name = packageNameOf(specifier);\n return Effect.succeedSome(Result.fail(name));\n};\n\nconst referencesIn = Effect.fn(\"referencesIn\")(function* referencesIn(graph: Graph, file: string) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(file);\n const specifiers = Option.match(text, {\n onNone: (): readonly string[] => [],\n onSome: (source) => specifiersIn(graph.api, file, source),\n });\n const references = yield* pipe(\n specifiers,\n Effect.forEach((specifier) => referenceOf(graph, file, specifier)),\n );\n const found = Arr.getSomes(references);\n return { packages: Arr.getFailures(found), sources: Arr.getSuccesses(found) };\n});\n\nconst packagesFrom = (\n graph: Graph,\n walk: Walk,\n): Effect.Effect<HashSet.HashSet<string>, never, RepositoryFiles> =>\n Arr.match(walk.pending, {\n onEmpty: () => Effect.succeed(walk.packages),\n onNonEmpty: ([next, ...rest]) => {\n if (HashSet.has(walk.visited, next)) {\n return packagesFrom(graph, { ...walk, pending: rest });\n }\n return referencesIn(graph, next).pipe(\n Effect.flatMap(({ packages, sources }) =>\n packagesFrom(graph, {\n pending: [...rest, ...sources],\n visited: HashSet.add(walk.visited, next),\n packages: HashSet.union(walk.packages, HashSet.fromIterable(packages)),\n }),\n ),\n );\n },\n });\n\n/** @internal */\nconst packagesByEntry = Effect.fn(\"packagesByEntry\")(function* packagesByEntry(\n api: API,\n directory: string,\n entries: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const manifest = yield* files.readFile(files.join(directory, MANIFEST_FILE));\n const imports = pipe(\n manifest,\n Option.flatMap(decodeImports),\n Option.flatMap((field) => Option.fromUndefinedOr(field.imports)),\n Option.getOrElse((): Readonly<Record<string, string>> => ({})),\n );\n const graph: Graph = { api, directory, imports };\n return yield* pipe(\n entries,\n Effect.forEach((entry) =>\n packagesFrom(graph, {\n pending: [entry],\n visited: HashSet.empty(),\n packages: HashSet.empty(),\n }).pipe(Effect.map((packages) => [entry, packages] as const)),\n ),\n );\n});\n\nexport { packagesByEntry };\n","import {\n Array as Arr,\n Effect,\n HashSet,\n Number as Num,\n Option,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { MANIFEST_FILE, NODE_MODULES } from \"./dependencies.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst EMPTY = 0;\n\nconst DependencyMap = Schema.optional(Schema.Record(Schema.String, Schema.String));\nconst PeerMetaEntry = Schema.Struct({ optional: Schema.optional(Schema.Boolean) });\nconst PeerMeta = Schema.optional(Schema.Record(Schema.String, PeerMetaEntry));\nconst InstalledManifest = Schema.Struct({\n dependencies: DependencyMap,\n optionalDependencies: DependencyMap,\n peerDependencies: DependencyMap,\n peerDependenciesMeta: PeerMeta,\n});\ntype Installed = typeof InstalledManifest.Type;\n\ntype Pending = readonly (readonly [string, string])[];\n\ninterface Collect {\n readonly pending: Pending;\n readonly seen: HashSet.HashSet<string>;\n}\n\nconst decodeManifest = Schema.decodeOption(Schema.fromJsonString(InstalledManifest));\n\nconst keysOf = (map: Readonly<Record<string, string>> | undefined): readonly string[] =>\n pipe(\n Option.fromUndefinedOr(map),\n Option.map(Rec.keys),\n Option.getOrElse((): readonly string[] => []),\n );\n\nconst isOptionalPeer = (manifest: Installed, name: string): boolean =>\n pipe(\n Option.fromUndefinedOr(manifest.peerDependenciesMeta),\n Option.flatMap(Rec.get(name)),\n Option.exists((meta) => meta.optional === true),\n );\n\nconst installedNames = (manifest: Installed): readonly string[] => [\n ...keysOf(manifest.dependencies),\n ...keysOf(manifest.optionalDependencies),\n ...pipe(\n keysOf(manifest.peerDependencies),\n Arr.filter((name) => !isOptionalPeer(manifest, name)),\n ),\n];\n\nconst childrenOf = Effect.fn(\"childrenOf\")(function* childrenOf(directory: string) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));\n return pipe(\n text,\n Option.flatMap(decodeManifest),\n Option.map(installedNames),\n Option.getOrElse((): readonly string[] => []),\n Arr.map((child) => [directory, child] as const),\n );\n});\n\nconst resolveFrom = (\n from: string,\n name: string,\n): Effect.Effect<Option.Option<string>, never, RepositoryFiles> =>\n Effect.gen(function* resolvePackage() {\n const files = yield* RepositoryFiles;\n const candidate = files.join(from, NODE_MODULES, name);\n const found = yield* files.exists(files.join(candidate, MANIFEST_FILE));\n if (found) {\n const real = yield* files.realPath(candidate);\n return Option.some(real);\n }\n const parent = files.dirname(from);\n if (parent === from) {\n return Option.none<string>();\n }\n return yield* resolveFrom(parent, name);\n });\n\nconst unseen = (\n from: string,\n name: string,\n seen: HashSet.HashSet<string>,\n): Effect.Effect<Option.Option<string>, never, RepositoryFiles> =>\n resolveFrom(from, name).pipe(\n Effect.map(Option.filter((directory) => !HashSet.has(seen, directory))),\n );\n\nconst closureOf = (\n provided: HashSet.HashSet<string>,\n collect: Collect,\n): Effect.Effect<HashSet.HashSet<string>, never, RepositoryFiles> =>\n Arr.match(collect.pending, {\n onEmpty: () => Effect.succeed(collect.seen),\n onNonEmpty: ([[from, name], ...rest]) => {\n if (HashSet.has(provided, name)) {\n return closureOf(provided, { ...collect, pending: rest });\n }\n return unseen(from, name, collect.seen).pipe(\n Effect.flatMap((resolved) => {\n if (Option.isNone(resolved)) {\n return closureOf(provided, { ...collect, pending: rest });\n }\n return childrenOf(resolved.value).pipe(\n Effect.flatMap((children) =>\n closureOf(provided, {\n pending: [...rest, ...children],\n seen: HashSet.add(collect.seen, resolved.value),\n }),\n ),\n );\n }),\n );\n },\n });\n\nconst directorySize = (directory: string): Effect.Effect<number, never, RepositoryFiles> =>\n Effect.gen(function* sizeOfDirectory() {\n const files = yield* RepositoryFiles;\n const names = yield* files.readDirectory(directory);\n const entries = pipe(\n names,\n Arr.filter((name) => name !== NODE_MODULES),\n Arr.map((name) => files.join(directory, name)),\n );\n const sizes = yield* pipe(\n entries,\n Effect.forEach((entry) =>\n files.isDirectory(entry).pipe(\n Effect.flatMap((kind) => {\n if (Option.isNone(kind)) {\n return Effect.succeed(EMPTY);\n }\n if (kind.value) {\n return directorySize(entry);\n }\n return files.fileSize(entry);\n }),\n ),\n ),\n );\n return Num.sumAll(sizes);\n });\n\ninterface ClosureRoot {\n readonly provided: HashSet.HashSet<string>;\n readonly from: string;\n readonly name: string;\n}\n\nconst installedClosure = ({\n provided,\n from,\n name,\n}: ClosureRoot): Effect.Effect<HashSet.HashSet<string>, never, RepositoryFiles> =>\n closureOf(provided, { pending: [[from, name]], seen: HashSet.empty() });\n\nconst installedSize = (directory: string): Effect.Effect<number, never, RepositoryFiles> => {\n if (Str.includes(`/${NODE_MODULES}/`)(directory)) {\n return directorySize(directory);\n }\n return Effect.succeed(EMPTY);\n};\n\nexport { installedClosure, installedSize, keysOf };\nexport type { ClosureRoot };\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport type { Problem } from \"./problem.ts\";\n\nconst START = 0;\nconst FIRST_COLUMN = 1;\n\nconst positionOf =\n (source: string) =>\n (index: number): Pick<Problem, \"line\" | \"column\"> => {\n const before = pipe(source, Str.slice(START, index), Str.split(\"\\n\"));\n return {\n line: before.length,\n column: pipe(\n Arr.last(before),\n Option.match({ onNone: () => FIRST_COLUMN, onSome: (last) => last.length + FIRST_COLUMN }),\n ),\n };\n };\n\nexport { positionOf };\n","import {\n Array as Arr,\n Effect,\n HashMap,\n HashSet,\n Number as Num,\n Option,\n Order,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { MANIFEST_FILE } from \"./dependencies.ts\";\nimport { packagesByEntry } from \"./import-graph.ts\";\nimport { installedClosure, installedSize, keysOf } from \"./installed-closure.ts\";\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { typeScriptCompiler } from \"./project.ts\";\nimport { publicEntriesOf } from \"./public-entries.ts\";\nimport type { PublicEntry } from \"./public-entries.ts\";\nimport { publishedWorkspaces } from \"./published.ts\";\nimport type { PublishedWorkspace } from \"./published.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { positionOf } from \"./text-position.ts\";\n\nconst INSTALL_SIZE: RuleName = \"install-size\";\nconst STACK_DEPENDENCY: RuleName = \"stack-dependency\";\nconst STACK_CATALOG = \"catalog:stack\";\nconst BUDGET_KEY = \"installSize\";\nconst DEPENDENCIES_KEY = '\"dependencies\"';\nconst LISTED_LARGEST = 5;\nconst SIZE_CONCURRENCY = 32;\nconst MEGABYTE = 1_000_000;\nconst MEGABYTE_DIGITS = 1;\nconst START = 0;\nconst SINGLE_ENTRY = 1;\n\ninterface DependencySize {\n readonly name: string;\n readonly size: number;\n readonly entries: readonly string[];\n}\n\ninterface Published {\n readonly workspace: PublishedWorkspace;\n readonly entries: readonly PublicEntry[];\n readonly provided: HashSet.HashSet<string>;\n}\n\ninterface Measured {\n readonly closures: readonly (readonly [string, HashSet.HashSet<string>])[];\n readonly sizeOf: (packages: HashSet.HashSet<string>) => number;\n readonly total: number;\n}\n\ninterface Overrun {\n readonly workspace: PublishedWorkspace;\n readonly total: number;\n readonly largest: readonly DependencySize[];\n readonly entryCount: number;\n}\n\nconst megabytes = (bytes: number): string => `${(bytes / MEGABYTE).toFixed(MEGABYTE_DIGITS)} MB`;\n\nconst usageHint = (dependency: DependencySize, entryCount: number): string => {\n const partial =\n entryCount > SINGLE_ENTRY &&\n dependency.entries.length > START &&\n dependency.entries.length < entryCount;\n if (!partial) {\n return \"\";\n }\n return ` (imported only from ${Arr.join(dependency.entries, \", \")})`;\n};\n\nconst listed = ({ largest, entryCount }: Overrun): string =>\n pipe(\n largest,\n Arr.map(\n (dependency) =>\n `${dependency.name} ${megabytes(dependency.size)}${usageHint(dependency, entryCount)}`,\n ),\n Arr.join(\", \"),\n );\n\nconst budgetProblem = Effect.fn(\"budgetProblem\")(function* budgetProblem(overrun: Overrun) {\n const files = yield* RepositoryFiles;\n const { workspace, total } = overrun;\n const config = yield* files.readFile(workspace.configFile);\n const source = Option.getOrElse(config, () => \"\");\n const index = Option.getOrElse(Str.indexOf(BUDGET_KEY)(source), () => START);\n return {\n file: workspace.configFile,\n ...positionOf(source)(index),\n rule: INSTALL_SIZE,\n message: `installing this package adds ${megabytes(total)} of dependencies besides its peers, over the ${workspace.installSize} in msch.publish.installSize. Largest: ${listed(overrun)}. Make a dependency imported only from some entries an optional peer, move one that the installing project already has to peerDependencies, or replace a heavy one. Raise installSize only when none of these applies.`,\n } satisfies Problem;\n});\n\nconst measure = Effect.fn(\"measure\")(function* measure(\n { workspace, provided }: Published,\n direct: readonly string[],\n) {\n const closures = yield* pipe(\n direct,\n Effect.forEach((name) =>\n installedClosure({ provided, from: workspace.directory, name }).pipe(\n Effect.map((packages) => [name, packages] as const),\n ),\n ),\n );\n const everything = pipe(\n closures,\n Arr.flatMap(([, packages]) => Arr.fromIterable(packages)),\n HashSet.fromIterable,\n );\n const measured = yield* Effect.forEach(\n everything,\n (found) => installedSize(found).pipe(Effect.map((size) => [found, size] as const)),\n { concurrency: SIZE_CONCURRENCY },\n );\n const sizes = HashMap.fromIterable(measured);\n const sizeOf = (packages: HashSet.HashSet<string>): number =>\n Num.sumAll(\n pipe(\n Arr.fromIterable(packages),\n Arr.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START)),\n ),\n );\n return { closures, sizeOf, total: sizeOf(everything) } satisfies Measured;\n});\n\nconst importersOf = Effect.fn(\"importersOf\")(function* importersOf({\n workspace,\n entries,\n}: Published) {\n const compiler = yield* typeScriptCompiler;\n const sources = pipe(\n entries,\n Arr.map((entry) => entry.source),\n Arr.dedupe,\n );\n const byEntry = yield* packagesByEntry(compiler.api, workspace.directory, sources);\n const reached = HashMap.fromIterable(byEntry);\n return (name: string): readonly string[] =>\n pipe(\n entries,\n Arr.filter((entry) =>\n pipe(HashMap.get(reached, entry.source), Option.exists(HashSet.has(name))),\n ),\n Arr.map((entry) => entry.label),\n Arr.dedupe,\n );\n}, Effect.scoped);\n\nconst bySizeDescending = Order.mapInput(\n Order.flip(Order.Number),\n (dependency: DependencySize) => dependency.size,\n);\n\nconst sizeProblems = Effect.fn(\"sizeProblems\")(function* sizeProblems(\n published: Published,\n direct: readonly string[],\n) {\n const { closures, sizeOf, total } = yield* measure(published, direct);\n if (total <= published.workspace.installBudget) {\n return [];\n }\n const importers = yield* importersOf(published);\n const largest = pipe(\n closures,\n Arr.map(([name, packages]): DependencySize => ({\n name,\n size: sizeOf(packages),\n entries: importers(name),\n })),\n Arr.sortBy(bySizeDescending),\n Arr.take(LISTED_LARGEST),\n );\n const entryCount = pipe(\n published.entries,\n Arr.map((entry) => entry.label),\n Arr.dedupe,\n ).length;\n const problem = yield* budgetProblem({\n workspace: published.workspace,\n total,\n largest,\n entryCount,\n });\n return [problem];\n});\n\nconst stackProblems = (\n file: string,\n source: string,\n dependencies: Readonly<Record<string, string>>,\n): readonly Problem[] => {\n const section = Option.getOrElse(Str.indexOf(DEPENDENCIES_KEY)(source), () => START);\n const rest = Str.slice(section)(source);\n return pipe(\n Rec.toEntries(dependencies),\n Arr.filter(([, specifier]) => specifier === STACK_CATALOG),\n Arr.map(([name]): Problem => ({\n file,\n ...positionOf(source)(\n section + Option.getOrElse(Str.indexOf(`\"${name}\"`)(rest), () => START),\n ),\n rule: STACK_DEPENDENCY,\n message: `${name} comes from the stack catalog, so every project that installs this package already has it. Move it to peerDependencies and keep it in devDependencies, so the installing project shares one copy.`,\n })),\n );\n};\n\nconst PublishedManifest = Schema.Struct({\n name: Schema.optional(Schema.String),\n dependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n peerDependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n exports: Schema.optional(Schema.Unknown),\n bin: Schema.optional(Schema.Unknown),\n});\n\nconst problemsOf = Effect.fn(\"problemsOf\")(function* problemsOf(\n workspace: PublishedWorkspace,\n file: string,\n source: string,\n) {\n const files = yield* RepositoryFiles;\n const manifest = Schema.decodeOption(Schema.fromJsonString(PublishedManifest))(source);\n if (Option.isNone(manifest)) {\n return [];\n }\n const dependencies = Option.getOrElse(\n Option.fromUndefinedOr(manifest.value.dependencies),\n () => ({}),\n );\n const entries = publicEntriesOf({\n manifest: manifest.value,\n join: (target) => files.join(workspace.directory, target),\n packEntries: workspace.packEntries,\n });\n const provided = HashSet.fromIterable(keysOf(manifest.value.peerDependencies));\n const sized = yield* sizeProblems({ workspace, entries, provided }, Rec.keys(dependencies));\n return [...stackProblems(file, source, dependencies), ...sized];\n});\n\nconst workspaceProblems = Effect.fn(\"workspaceProblems\")(function* workspaceProblems(\n workspace: PublishedWorkspace,\n) {\n const files = yield* RepositoryFiles;\n const file = files.join(workspace.directory, MANIFEST_FILE);\n const source = yield* files.readFile(file);\n return yield* Option.match(source, {\n onNone: () => Effect.succeed<readonly Problem[]>([]),\n onSome: (text) => problemsOf(workspace, file, text),\n });\n});\n\n/** @internal */\nconst checkPublishedPackages = Effect.fn(\"checkPublishedPackages\")(function* checkPublishedPackages(\n root: string,\n) {\n const workspaces = yield* publishedWorkspaces(root);\n const found = yield* pipe(workspaces, Effect.forEach(workspaceProblems));\n return Arr.flatten(found);\n});\n\nexport { checkPublishedPackages };\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport type { OverrideKey, OverrideReport } from \"./override-resolution.ts\";\nimport type { Problem } from \"./problem.ts\";\n\nconst describeVersions = (versions: readonly string[]): string =>\n Option.getOrElse(\n Option.liftPredicate(Arr.join(versions, \",\"), (joined) => joined !== \"\"),\n () => \"-\",\n );\n\nconst describeChanges = (report: OverrideReport): string => {\n const versions = pipe(\n report.changes,\n Arr.map(\n (change) =>\n `${change.name} ${describeVersions(change.before)} -> ${describeVersions(change.after)}`,\n ),\n );\n const contexts = Arr.filter([\"the peer contexts\"], () => report.peerContextsChanged);\n return Arr.join([...versions, ...contexts], \"; \");\n};\n\ninterface LocatedOverride extends OverrideKey {\n readonly file: string;\n}\n\nconst overrideProblem =\n (located: LocatedOverride) =>\n (report: OverrideReport): Option.Option<Problem> => {\n const at = { file: located.file, line: located.line, column: located.column };\n if (report.verdict === \"unused\") {\n return Option.some({\n ...at,\n rule: \"unused-override\",\n message: `Every package resolves the same way without the override ${report.key}. Remove it.`,\n });\n }\n if (report.verdict === \"verify\") {\n return Option.some({\n ...at,\n rule: \"removable-override\",\n message: `Removing the override ${report.key} changes ${describeChanges(report)} without new peer issues or advisories. Remove it and run verify.`,\n });\n }\n return Option.none();\n };\n\nexport { overrideProblem };\nexport type { LocatedOverride };\n","import { Array as Arr, Option, Order, Record as Rec, Schema, String as Str, pipe } from \"effect\";\nimport { LineCounter, isMap, isScalar, parseAllDocuments, parseDocument } from \"yaml\";\n\nconst VerdictSchema = Schema.Literals([\"unused\", \"keep\", \"verify\"]);\n\nconst PackageChangeSchema = Schema.Struct({\n name: Schema.String,\n before: Schema.Array(Schema.String),\n after: Schema.Array(Schema.String),\n});\n\nconst OverrideReportSchema = Schema.Struct({\n key: Schema.String,\n verdict: VerdictSchema,\n changes: Schema.Array(PackageChangeSchema),\n peerContextsChanged: Schema.Boolean,\n peerIssues: Schema.Array(Schema.String),\n advisories: Schema.Array(Schema.String),\n});\n\ntype OverrideReport = typeof OverrideReportSchema.Type;\ntype PackageChange = typeof PackageChangeSchema.Type;\n\nconst PeerParentSchema = Schema.Struct({ name: Schema.String, version: Schema.String });\n\nconst PeerIssueSchema = Schema.Struct({\n parents: Schema.Array(PeerParentSchema),\n wantedRange: Schema.String,\n foundVersion: Schema.optionalKey(Schema.String),\n});\n\ntype PeerIssue = typeof PeerIssueSchema.Type;\n\nconst ProjectPeerIssuesSchema = Schema.Struct({\n bad: Schema.Record(Schema.String, Schema.Array(PeerIssueSchema)),\n missing: Schema.Record(Schema.String, Schema.Array(PeerIssueSchema)),\n conflicts: Schema.Array(Schema.String),\n});\n\ntype ProjectPeerIssues = typeof ProjectPeerIssuesSchema.Type;\n\nconst PeerIssuesLog = Schema.fromJsonString(\n Schema.Struct({\n name: Schema.Literal(\"pnpm:peer-dependency-issues\"),\n issuesByProjects: Schema.Record(Schema.String, ProjectPeerIssuesSchema),\n }),\n);\n\ninterface Findings {\n readonly peerIssues: readonly string[];\n readonly advisories: readonly string[];\n}\n\ninterface Resolution extends Findings {\n readonly versions: Readonly<Record<string, readonly string[]>>;\n readonly snapshots: readonly string[];\n}\n\nconst AdvisorySchema = Schema.Struct({\n module_name: Schema.String,\n github_advisory_id: Schema.String,\n});\n\nconst AuditReport = Schema.fromJsonString(\n Schema.Struct({ advisories: Schema.Record(Schema.String, AdvisorySchema) }),\n);\n\nconst SCOPE_PREFIX = \"@\";\nconst NAME_START = 0;\nconst SEPARATOR_LENGTH = 1;\nconst PEER_CONTEXT_START = \"(\";\n\nconst sorted = (values: readonly string[]): readonly string[] =>\n Arr.sort(Arr.dedupe(values), Order.String);\n\nconst describeIssue =\n (project: string, kind: string) =>\n ([peer, issues]: readonly [string, readonly PeerIssue[]]): readonly string[] =>\n pipe(\n issues,\n Arr.map((issue) => {\n const dependent = Option.match(Arr.last(issue.parents), {\n onNone: () => project,\n onSome: (parent) => `${parent.name}@${parent.version}`,\n });\n const found = Option.getOrElse(Option.fromUndefinedOr(issue.foundVersion), () => \"none\");\n return `${project}: ${kind} peer ${peer}@${issue.wantedRange} of ${dependent}, found ${found}`;\n }),\n );\n\nconst issuesOfProject = ([project, issues]: readonly [\n string,\n ProjectPeerIssues,\n]): readonly string[] => [\n ...pipe(Rec.toEntries(issues.bad), Arr.flatMap(describeIssue(project, \"unmet\"))),\n ...pipe(Rec.toEntries(issues.missing), Arr.flatMap(describeIssue(project, \"missing\"))),\n ...pipe(\n issues.conflicts,\n Arr.map((peer) => `${project}: conflicting peer ${peer}`),\n ),\n];\n\nconst peerIssuesIn = (output: string): readonly string[] =>\n sorted(\n pipe(\n Str.split(output, \"\\n\"),\n Arr.map((line) => Schema.decodeOption(PeerIssuesLog)(line)),\n Arr.getSomes,\n Arr.flatMap((log) => pipe(Rec.toEntries(log.issuesByProjects), Arr.flatMap(issuesOfProject))),\n ),\n );\n\nconst advisoriesIn = (output: string): readonly string[] =>\n Option.match(Schema.decodeOption(AuditReport)(output), {\n onNone: () => [],\n onSome: (report) =>\n sorted(\n pipe(\n Rec.values(report.advisories),\n Arr.map((advisory) => `${advisory.module_name} ${advisory.github_advisory_id}`),\n ),\n ),\n });\n\nconst separatorOf = (key: string): Option.Option<number> => {\n if (!Str.startsWith(SCOPE_PREFIX)(key)) {\n return Str.indexOf(SCOPE_PREFIX)(key);\n }\n return pipe(\n Str.slice(SEPARATOR_LENGTH)(key),\n Str.indexOf(SCOPE_PREFIX),\n Option.map((index) => index + SEPARATOR_LENGTH),\n );\n};\n\nconst withoutPeerContext = (version: string): string =>\n Option.match(Str.indexOf(PEER_CONTEXT_START)(version), {\n onNone: () => version,\n onSome: (start) => Str.slice(NAME_START, start)(version),\n });\n\nconst packageOf = (key: string): Option.Option<readonly [string, string]> =>\n Option.map(separatorOf(key), (separator) => [\n Str.slice(NAME_START, separator)(key),\n withoutPeerContext(Str.slice(separator + SEPARATOR_LENGTH)(key)),\n ]);\n\nconst keysOf = (node: unknown): readonly string[] => {\n if (!isMap(node)) {\n return [];\n }\n return pipe(\n node.items,\n Arr.flatMap((pair): readonly string[] => {\n if (isScalar(pair.key)) {\n return [String(pair.key.value)];\n }\n return [];\n }),\n );\n};\n\nconst lockfileKeysOf = (lockfile: string, section: string): readonly string[] =>\n pipe(\n parseAllDocuments(lockfile),\n Arr.flatMap((document) => keysOf(document.get(section))),\n );\n\nconst resolutionOf =\n (findings: Findings) =>\n (lockfile: string): Resolution => {\n const snapshots = lockfileKeysOf(lockfile, \"snapshots\");\n const packages = Arr.getSomes(\n pipe(\n [...lockfileKeysOf(lockfile, \"packages\"), ...snapshots],\n Arr.map((key) => packageOf(key)),\n ),\n );\n const versions = Rec.map(\n Arr.groupBy(packages, ([name]) => name),\n (entries) =>\n sorted(\n pipe(\n entries,\n Arr.map(([, version]) => version),\n ),\n ),\n );\n return { ...findings, versions, snapshots: sorted(snapshots) };\n };\n\nconst changesBetween = (baseline: Resolution, candidate: Resolution): readonly PackageChange[] =>\n pipe(\n sorted([...Rec.keys(baseline.versions), ...Rec.keys(candidate.versions)]),\n Arr.map((name) => ({\n name,\n before: baseline.versions[name] ?? [],\n after: candidate.versions[name] ?? [],\n })),\n Arr.filter((change) => Arr.join(change.before, \" \") !== Arr.join(change.after, \" \")),\n );\n\nconst growsThePackageSet = (change: PackageChange): boolean =>\n change.after.length > change.before.length;\n\nconst needsTheOverride = (\n found: Pick<OverrideReport, \"changes\" | \"peerIssues\" | \"advisories\">,\n): boolean =>\n pipe(\n found.changes,\n Arr.some((change) => growsThePackageSet(change)),\n ) ||\n Arr.isReadonlyArrayNonEmpty(found.peerIssues) ||\n Arr.isReadonlyArrayNonEmpty(found.advisories);\n\nconst judge =\n (baseline: Resolution) =>\n (key: string, candidate: Resolution): OverrideReport => {\n const changes = changesBetween(baseline, candidate);\n const peerIssues = Arr.difference(candidate.peerIssues, baseline.peerIssues);\n const advisories = Arr.difference(candidate.advisories, baseline.advisories);\n const peerContextsChanged =\n Arr.join(baseline.snapshots, \" \") !== Arr.join(candidate.snapshots, \" \");\n const found = { key, changes, peerContextsChanged, peerIssues, advisories };\n if (!Arr.isReadonlyArrayNonEmpty(changes) && !peerContextsChanged) {\n return { ...found, verdict: \"unused\" };\n }\n if (needsTheOverride(found)) {\n return { ...found, verdict: \"keep\" };\n }\n return { ...found, verdict: \"verify\" };\n };\n\nconst OVERRIDES = \"overrides\";\nconst BASELINE_PROBE = \"msch-baseline-probe\";\nconst REMOVED_DEPENDENCY = \"-\";\n\ninterface OverrideKey {\n readonly key: string;\n readonly line: number;\n readonly column: number;\n}\n\nconst overrideKeysOf = (manifest: string): readonly OverrideKey[] => {\n const lineCounter = new LineCounter();\n const overrides = parseDocument(manifest, { lineCounter }).get(OVERRIDES);\n if (!isMap(overrides)) {\n return [];\n }\n return pipe(\n overrides.items,\n Arr.flatMap((pair): readonly OverrideKey[] => {\n const { key } = pair;\n if (!isScalar(key)) {\n return [];\n }\n return pipe(\n Option.fromNullishOr(key.range),\n Option.map(([start]) => {\n const { line, col } = lineCounter.linePos(start);\n return { key: String(key.value), line, column: col };\n }),\n Option.toArray,\n );\n }),\n );\n};\n\nconst withoutOverride =\n (key: string) =>\n (manifest: string): string => {\n const document = parseDocument(manifest);\n document.deleteIn([OVERRIDES, key]);\n return document.toString();\n };\n\nconst withBaselineProbe = (manifest: string): string => {\n const document = parseDocument(manifest);\n document.setIn([OVERRIDES, BASELINE_PROBE], REMOVED_DEPENDENCY);\n return document.toString();\n};\n\nexport {\n BASELINE_PROBE,\n advisoriesIn,\n judge,\n overrideKeysOf,\n peerIssuesIn,\n resolutionOf,\n withBaselineProbe,\n withoutOverride,\n};\nexport type { Findings, OverrideKey, OverrideReport, Resolution };\n","import {\n Array as Arr,\n Effect,\n FileSystem,\n Option,\n Path,\n Schema,\n Stream,\n String as Str,\n pipe,\n} from \"effect\";\nimport type { PlatformError } from \"effect\";\nimport { ChildProcess } from \"effect/process\";\nimport type { ChildProcessSpawner } from \"effect/process\";\n\nimport { overrideProblem } from \"./override-findings.ts\";\nimport {\n BASELINE_PROBE,\n advisoriesIn,\n judge,\n overrideKeysOf,\n peerIssuesIn,\n resolutionOf,\n withBaselineProbe,\n withoutOverride,\n} from \"./override-resolution.ts\";\nimport type { OverrideKey } from \"./override-resolution.ts\";\nimport type { Problem } from \"./problem.ts\";\n\nconst WORKSPACE_FILE = \"pnpm-workspace.yaml\";\nconst LOCKFILE = \"pnpm-lock.yaml\";\nconst RESOLUTION_FILES = [\"*package.json\", WORKSPACE_FILE, LOCKFILE, \".npmrc\", \"patches/*\"];\nconst RESOLUTION_CONCURRENCY = 4;\nconst SUCCEEDED = 0;\n\nconst taggedError = Schema.TaggedError;\n\nclass OverrideResolutionFailed extends taggedError<\n OverrideResolutionFailed,\n { readonly brand: unique symbol }\n>()(\"OverrideResolutionFailed\", { override: Schema.String, output: Schema.String }) {}\n\ntype CandidateFailure = OverrideResolutionFailed | PlatformError.PlatformError;\ntype CandidateServices =\n | FileSystem.FileSystem\n | Path.Path\n | ChildProcessSpawner.ChildProcessSpawner;\n\ninterface Workspace {\n readonly root: string;\n readonly files: readonly string[];\n readonly manifest: string;\n}\n\nconst textOf = <Failure>(\n stream: Stream.Stream<Uint8Array, Failure>,\n): Effect.Effect<string, Failure> => stream.pipe(Stream.decodeText(), Stream.mkString);\n\nconst resolveIn = Effect.fn(\"resolveIn\")(function* resolveIn(directory: string, override: string) {\n const handle = yield* ChildProcess.make(\n \"vp\",\n [\"install\", \"--lockfile-only\", \"--ignore-scripts\", \"--\", \"--reporter=ndjson\"],\n { cwd: directory, env: { CI: \"true\" }, extendEnv: true, stdin: \"ignore\" },\n );\n const [output, status] = yield* Effect.all([textOf(handle.all), handle.exitCode], {\n concurrency: \"unbounded\",\n });\n if (Number(status) !== SUCCEEDED) {\n return yield* OverrideResolutionFailed.make({ override, output });\n }\n return output;\n});\n\nconst auditIn = Effect.fn(\"auditIn\")(function* auditIn(directory: string) {\n const handle = yield* ChildProcess.make(\"vp\", [\"pm\", \"audit\", \"--json\"], {\n cwd: directory,\n extendEnv: true,\n stdin: \"ignore\",\n });\n const [report] = yield* Effect.all([textOf(handle.stdout), handle.exitCode], {\n concurrency: \"unbounded\",\n });\n return advisoriesIn(report);\n}, Effect.scoped);\n\nconst trackedResolutionFiles = Effect.fn(\"trackedResolutionFiles\")(function* trackedFiles(\n root: string,\n) {\n const handle = yield* ChildProcess.make(\"git\", [\"ls-files\", \"-z\", \"--\", ...RESOLUTION_FILES], {\n cwd: root,\n });\n const listed = yield* textOf(handle.stdout);\n return pipe(Str.split(listed, \"\\0\"), Arr.filter(Str.isNonEmpty));\n}, Effect.scoped);\n\nconst copyFiles = Effect.fn(\"copyFiles\")(function* copyFiles(\n workspace: Workspace,\n directory: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const copyOne = (file: string): Effect.Effect<void, PlatformError.PlatformError> => {\n const target = path.join(directory, file);\n const copy = fs.copyFile(path.join(workspace.root, file), target);\n return fs.makeDirectory(path.dirname(target), { recursive: true }).pipe(Effect.andThen(copy));\n };\n yield* Effect.forEach(workspace.files, copyOne, { discard: true });\n});\n\nconst resolutionWith = Effect.fn(\"resolutionWith\")(function* resolutionWith(\n workspace: Workspace,\n override: string,\n manifest: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directory = yield* fs.makeTempDirectoryScoped({ prefix: \"msch-overrides-\" });\n yield* copyFiles(workspace, directory);\n yield* fs.writeFileString(path.join(directory, WORKSPACE_FILE), manifest);\n const output = yield* resolveIn(directory, override);\n const lockfile = yield* fs.readFileString(path.join(directory, LOCKFILE));\n yield* Effect.annotateCurrentSpan({ \"msch.override\": override });\n const advisories = yield* auditIn(directory);\n return resolutionOf({ peerIssues: peerIssuesIn(output), advisories })(lockfile);\n}, Effect.scoped);\n\nconst problemsFor = Effect.fn(\"problemsFor\")(function* problemsFor(\n root: string,\n manifest: string,\n keys: readonly OverrideKey[],\n) {\n const path = yield* Path.Path;\n const files = yield* trackedResolutionFiles(root);\n const workspace: Workspace = { root, files, manifest };\n const baseline = yield* resolutionWith(workspace, BASELINE_PROBE, withBaselineProbe(manifest));\n const judgeAgainstBaseline = judge(baseline);\n const file = path.join(root, WORKSPACE_FILE);\n const problemOf = (\n located: OverrideKey,\n ): Effect.Effect<Option.Option<Problem>, CandidateFailure, CandidateServices> =>\n resolutionWith(workspace, located.key, withoutOverride(located.key)(manifest)).pipe(\n Effect.map((candidate) =>\n overrideProblem({ ...located, file })(judgeAgainstBaseline(located.key, candidate)),\n ),\n );\n const problems = yield* Effect.forEach(keys, problemOf, {\n concurrency: RESOLUTION_CONCURRENCY,\n });\n return Arr.getSomes(problems);\n});\n\n/** @internal */\nconst checkOverrides = Effect.fn(\"checkOverrides\")(function* checkOverrides(root: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const manifest = yield* fs.readFileString(path.join(root, WORKSPACE_FILE)).pipe(Effect.option);\n const keys = Option.match(manifest, { onNone: () => [], onSome: overrideKeysOf });\n if (Option.isNone(manifest) || !Arr.isReadonlyArrayNonEmpty(keys)) {\n return [];\n }\n return yield* problemsFor(root, manifest.value, keys);\n});\n\nexport { checkOverrides };\n","import { Array as Arr, Effect, Option, Order, Schema, String as Str, pipe } from \"effect\";\n\nimport { MANIFEST_FILE } from \"./dependencies.ts\";\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { publicEntriesOf } from \"./public-entries.ts\";\nimport type { EntryManifest } from \"./public-entries.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst RULE: RuleName = \"colocated-test\";\nconst FIRST = 1;\nconst READ_CONCURRENCY = 64;\nconst ROOT_SUBPATH = \".\";\nconst NAME_GROUP = \"name\";\nconst SPECIFIER_GROUP = \"specifier\";\nconst SCRIPT = /\\.[cm]?[jt]sx?$/u;\nconst TEST_FILE = /\\.test\\.[cm]?[jt]sx?$/u;\nconst MANIFEST_NAME = /package\\.json$/u;\nconst SEPARATE_TEST_DIRECTORY = /(?:^|\\/)(?:__tests__|__mocks__|tests?|specs?)\\//u;\nconst RELATIVE_REFERENCE = /[\"'`]\\.\\/(?<name>[^/\"'`]+)/gu;\nconst DIRNAME_REFERENCE = /import\\.meta\\.dirname\\s*,\\s*[\"'](?<name>[^/\"']+)[\"']/gu;\nconst MODULE_SPECIFIER =\n /(?:\\bfrom\\s+|\\bimport\\s*\\(\\s*|\\bimport\\s+|\\bvi\\.mock\\(\\s*)[\"'](?<specifier>[^\"'.#][^\"']*)[\"']/gu;\nconst EXCLUDED: readonly string[] = [\n \":(exclude,attr:linguist-vendored)\",\n \":(exclude,attr:linguist-generated)\",\n];\n\nconst DIRECTORY_MESSAGE =\n \"sits in a separate test directory. Put each test next to the module it tests, and test-only helpers next to the tests as <name>.test.support.ts.\";\nconst SIBLING_MESSAGE =\n \"refers to nothing in its own directory. Move the test next to the module it tests and import that module, or a helper beside it, with ./<name>.\";\n\nconst Manifest = Schema.Struct({\n name: Schema.optional(Schema.String),\n exports: Schema.optional(Schema.Unknown),\n});\nconst decodeManifest = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest));\n\ninterface TestFile {\n readonly name: string;\n readonly base: string;\n readonly file: string;\n readonly directory: string;\n}\n\ninterface Context {\n readonly root: string;\n readonly packages: readonly string[];\n}\n\ninterface Beside {\n readonly join: (target: string) => string;\n readonly dirname: (file: string) => string;\n readonly directory: string;\n}\n\nconst byLength = Order.mapInput(Order.Number, (directory: string) => directory.length);\n\nconst problemFor = (test: TestFile, message: string): Problem => ({\n file: test.file,\n line: FIRST,\n column: FIRST,\n rule: RULE,\n message: `${test.base} ${message}`,\n});\n\nconst groupsOf = (source: string, pattern: RegExp, group: string): readonly string[] =>\n pipe(\n Arr.fromIterable(Str.matchAll(pattern)(source)),\n Arr.map((match) =>\n pipe(\n Option.fromUndefinedOr(match.groups),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[group])),\n ),\n ),\n Arr.getSomes,\n );\n\nconst namesSibling = (source: string): boolean =>\n pipe(\n [\n ...groupsOf(source, RELATIVE_REFERENCE, NAME_GROUP),\n ...groupsOf(source, DIRNAME_REFERENCE, NAME_GROUP),\n ],\n Arr.some((name) => !TEST_FILE.test(name)),\n );\n\nconst ownerOf = (packages: readonly string[], name: string): Option.Option<string> => {\n const owners = pipe(\n packages,\n Arr.filter((directory) => Str.startsWith(directory)(name)),\n );\n return Arr.last(Arr.sort(owners, byLength));\n};\n\nconst specifiersBeside =\n ({ join, dirname, directory }: Beside) =>\n (manifest: EntryManifest): readonly string[] =>\n pipe(\n Option.fromUndefinedOr(manifest.name),\n Option.map((name) =>\n pipe(\n publicEntriesOf({ manifest, join, packEntries: [] }),\n Arr.filter(({ source }) => dirname(source) === directory),\n Arr.map(({ label }) => Str.replace(ROOT_SUBPATH, name)(label)),\n ),\n ),\n Option.getOrElse((): readonly string[] => []),\n );\n\nconst ownSpecifiers = Effect.fn(\"ownSpecifiers\")(function* ownSpecifiers(\n context: Context,\n test: TestFile,\n) {\n const files = yield* RepositoryFiles;\n const owner = ownerOf(context.packages, test.name);\n if (Option.isNone(owner)) {\n return [];\n }\n const text = yield* files.readFile(files.join(context.root, owner.value, MANIFEST_FILE));\n const join = (target: string): string => files.join(context.root, owner.value, target);\n return pipe(\n text,\n Option.flatMap(decodeManifest),\n Option.map(specifiersBeside({ join, dirname: files.dirname, directory: test.directory })),\n Option.getOrElse((): readonly string[] => []),\n );\n});\n\nconst refersToOwnDirectory = Effect.fn(\"refersToOwnDirectory\")(function* refersToOwnDirectory(\n context: Context,\n test: TestFile,\n source: string,\n) {\n if (namesSibling(source)) {\n return true;\n }\n const specifiers = groupsOf(source, MODULE_SPECIFIER, SPECIFIER_GROUP);\n if (Arr.isReadonlyArrayEmpty(specifiers)) {\n return false;\n }\n const own = yield* ownSpecifiers(context, test);\n return pipe(\n specifiers,\n Arr.some((specifier) => pipe(own, Arr.contains(specifier))),\n );\n});\n\nconst refersIn = Effect.fn(\"refersIn\")(function* refersIn(context: Context, test: TestFile) {\n const files = yield* RepositoryFiles;\n const source = yield* files.readFile(test.file);\n if (Option.isNone(source)) {\n return true;\n }\n return yield* refersToOwnDirectory(context, test, source.value);\n});\n\nconst problemIn = Effect.fn(\"problemIn\")(function* problemIn(context: Context, test: TestFile) {\n if (SEPARATE_TEST_DIRECTORY.test(test.name)) {\n return Option.some(problemFor(test, DIRECTORY_MESSAGE));\n }\n if (!TEST_FILE.test(test.name)) {\n return Option.none<Problem>();\n }\n const refers = yield* refersIn(context, test);\n if (refers) {\n return Option.none<Problem>();\n }\n return Option.some(problemFor(test, SIBLING_MESSAGE));\n});\n\n/** @internal */\nconst checkColocatedTests = Effect.fn(\"checkColocatedTests\")(function* checkColocatedTests(\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.matchingFiles(root, EXCLUDED);\n const names = pipe(listed, Arr.filter(Str.isNonEmpty));\n const context: Context = {\n root,\n packages: pipe(\n names,\n Arr.filter((name) => files.basename(name) === MANIFEST_FILE),\n Arr.map(Str.replace(MANIFEST_NAME, \"\")),\n ),\n };\n const tests = pipe(\n names,\n Arr.filter((name) => SCRIPT.test(name)),\n Arr.map((name): TestFile => {\n const file = files.join(root, name);\n return { name, base: files.basename(name), file, directory: files.dirname(file) };\n }),\n );\n const found = yield* Effect.forEach(tests, (test) => problemIn(context, test), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(found);\n});\n\nexport { checkColocatedTests };\n","import { Array as Arr, Effect, HashSet, Option, Schema, String as Str, pipe } from \"effect\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport { MANIFEST_FILE } from \"./dependencies.ts\";\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst RULE: RuleName = \"nested-docs\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst SEPARATOR = \"/\";\nconst FIRST = 1;\nconst READ_CONCURRENCY = 64;\nconst AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\\.[^/]+)?\\.md$/iu;\nconst WORKSPACE_AGENT_DOC = \"AGENTS.md\";\nconst README = /^README(?:\\.[^/]+)?$/iu;\n\nconst RootConfig = Schema.Struct({\n msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }),\n});\n\nconst taggedError = Schema.TaggedError;\n\nclass RootConfigUnreadable extends taggedError<\n RootConfigUnreadable,\n { readonly brand: unique symbol }\n>()(\"RootConfigUnreadable\", { file: Schema.String }) {}\n\nconst isNested = (name: string): boolean => Str.includes(SEPARATOR)(name);\n\nconst problemFor = (file: string, message: string): Problem => ({\n file,\n line: FIRST,\n column: FIRST,\n rule: RULE,\n message,\n});\n\nconst AGENT_DOCS_MESSAGE =\n \"belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.\";\nconst WORKSPACE_AGENT_DOCS_MESSAGE =\n \"belongs only at the repository root or as AGENTS.md directly in a workspace, the directory that holds its package.json. Move what agents need there and delete this file.\";\nconst README_MESSAGE =\n \"is allowed below the root only in a workspace, the directory that holds its package.json. Move it into the workspace it describes.\";\n\ninterface Allowed {\n readonly workspaces: HashSet.HashSet<string>;\n readonly workspaceAgentDocs: boolean;\n}\n\ninterface NestedDoc {\n readonly file: string;\n readonly base: string;\n readonly directory: string;\n}\n\nconst agentDocProblem = (\n { file, base, directory }: NestedDoc,\n allowed: Allowed,\n): Option.Option<Problem> => {\n if (!allowed.workspaceAgentDocs) {\n return Option.some(problemFor(file, `${base} ${AGENT_DOCS_MESSAGE}`));\n }\n if (base === WORKSPACE_AGENT_DOC && HashSet.has(allowed.workspaces, directory)) {\n return Option.none<Problem>();\n }\n return Option.some(problemFor(file, `${base} ${WORKSPACE_AGENT_DOCS_MESSAGE}`));\n};\n\nconst readmeProblem = (\n { file, base, directory }: NestedDoc,\n allowed: Allowed,\n): Option.Option<Problem> => {\n if (!README.test(base) || HashSet.has(allowed.workspaces, directory)) {\n return Option.none<Problem>();\n }\n return Option.some(problemFor(file, `${base} ${README_MESSAGE}`));\n};\n\nconst problemIn = Effect.fn(\"problemIn\")(function* problemIn(\n root: string,\n allowed: Allowed,\n name: string,\n) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, name);\n const doc: NestedDoc = { file, base: files.basename(name), directory: files.dirname(file) };\n if (AGENT_DOCS.test(doc.base)) {\n return agentDocProblem(doc, allowed);\n }\n return readmeProblem(doc, allowed);\n});\n\nconst allowsWorkspaceAgentDocs = Effect.fn(\"allowsWorkspaceAgentDocs\")(\n function* allowsWorkspaceAgentDocs(root: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, CONFIG_FILE);\n const exists = yield* files.exists(file);\n if (!exists) {\n return false;\n }\n const config = yield* Effect.tryPromise({\n try: () => resolveConfigFromFile(file),\n catch: () => RootConfigUnreadable.make({ file }),\n }).pipe(Effect.option);\n return pipe(config, Option.flatMap(Schema.decodeUnknownOption(RootConfig)), Option.isSome);\n },\n);\n\n/** @internal */\nconst checkNestedDocs = Effect.fn(\"checkNestedDocs\")(function* checkNestedDocs(root: string) {\n const files = yield* RepositoryFiles;\n const names = yield* files.listedFiles(root);\n const nested = pipe(names, Arr.filter(isNested));\n const workspaceAgentDocs = yield* allowsWorkspaceAgentDocs(root);\n const allowed: Allowed = {\n workspaces: pipe(\n nested,\n Arr.filter((name) => files.basename(name) === MANIFEST_FILE),\n Arr.map((name) => files.dirname(files.join(root, name))),\n HashSet.fromIterable,\n ),\n workspaceAgentDocs,\n };\n const found = yield* Effect.forEach(nested, (name) => problemIn(root, allowed, name), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(found);\n});\n\nexport { checkNestedDocs };\n","import { Array as Arr, Effect, Option, Schema, String as Str, pipe } from \"effect\";\n\nimport { MANIFEST_FILE } from \"./dependencies.ts\";\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { positionOf } from \"./text-position.ts\";\n\nconst RULE: RuleName = \"root-readme\";\nconst SEPARATOR = \"/\";\nconst ALTERNATIVE = \"|\";\nconst SCOPE = /^@[^/]+\\//u;\nconst README = /^README(?:\\.[^/]+)?$/iu;\nconst SPECIAL = /[$()*+.?[\\\\\\]^{|}]/gu;\nconst READ_CONCURRENCY = 16;\nconst START = 0;\nconst NamedManifest = Schema.fromJsonString(\n Schema.Struct({ name: Schema.optional(Schema.String) }),\n);\n\ninterface Workspace {\n readonly directory: string;\n readonly pattern: RegExp;\n}\n\nconst patternOf = (names: readonly string[]): RegExp => {\n const alternatives = pipe(names, Arr.map(Str.replaceAll(SPECIAL, String.raw`\\$&`)));\n return new RegExp(\n `(?<![\\\\p{L}\\\\p{N}_-])(?:${Arr.join(alternatives, ALTERNATIVE)})(?![\\\\p{L}\\\\p{N}_-])`,\n \"gu\",\n );\n};\n\nconst packageNameIn = (text: Option.Option<string>): Option.Option<string> =>\n pipe(\n text,\n Option.flatMap(Schema.decodeOption(NamedManifest)),\n Option.flatMap((manifest) => Option.fromUndefinedOr(manifest.name)),\n );\n\nconst workspaceIn = Effect.fn(\"workspaceIn\")(function* workspaceIn(root: string, name: string) {\n const files = yield* RepositoryFiles;\n const directory = files.dirname(name);\n const text = yield* files.readFile(files.join(root, name));\n const packageName = packageNameIn(text);\n const unscoped = pipe(packageName, Option.map(Str.replace(SCOPE, \"\")));\n const names = pipe(\n [Option.some(directory), Option.some(files.basename(directory)), packageName, unscoped],\n Arr.getSomes,\n Arr.dedupe,\n );\n return { directory, pattern: patternOf(names) };\n});\n\nconst messageFor = (directory: string): string =>\n `names the workspace ${directory}. The root README describes the repository as a whole. Write what belongs to the workspace in ${directory}/README.md.`;\n\nconst problemsIn =\n (file: string, source: string) =>\n ({ directory, pattern }: Workspace): readonly Problem[] => {\n const message = messageFor(directory);\n const at = positionOf(source);\n return pipe(\n Arr.fromIterable(Str.matchAll(pattern)(source)),\n Arr.map((found) => ({ file, ...at(found.index ?? START), rule: RULE, message })),\n );\n };\n\nconst problemsInReadme = Effect.fn(\"problemsInReadme\")(function* problemsInReadme(\n file: string,\n workspaces: readonly Workspace[],\n) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(file);\n return pipe(\n text,\n Option.match({\n onNone: (): readonly Problem[] => [],\n onSome: (source) => pipe(workspaces, Arr.flatMap(problemsIn(file, source))),\n }),\n );\n});\n\n/** @internal */\nconst checkRootReadme = Effect.fn(\"checkRootReadme\")(function* checkRootReadme(root: string) {\n const files = yield* RepositoryFiles;\n const names = yield* files.listedFiles(root);\n const readmes = pipe(\n names,\n Arr.filter((name) => README.test(name)),\n );\n const manifests = pipe(\n names,\n Arr.filter((name) => Str.includes(SEPARATOR)(name) && files.basename(name) === MANIFEST_FILE),\n );\n const workspaces = yield* Effect.forEach(manifests, (name) => workspaceIn(root, name), {\n concurrency: READ_CONCURRENCY,\n });\n const found = yield* Effect.forEach(\n readmes,\n (name) => problemsInReadme(files.join(root, name), workspaces),\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.flatten(found);\n});\n\nexport { checkRootReadme };\n","import { Array as Arr, Effect } from \"effect\";\n\nimport { checkColocatedTests } from \"./colocated-tests.ts\";\nimport { checkNestedDocs } from \"./nested-docs.ts\";\nimport { checkRootReadme } from \"./root-readme.ts\";\n\n/** @internal */\nconst checkPlacement = Effect.fn(\"checkPlacement\")(function* checkPlacement(root: string) {\n const found = yield* Effect.all(\n [checkNestedDocs(root), checkRootReadme(root), checkColocatedTests(root)],\n { concurrency: \"unbounded\" },\n );\n return Arr.flatten(found);\n});\n\nexport { checkPlacement };\n","import { Schema, String as Str } from \"effect\";\nimport type { Effect } from \"effect\";\n\ninterface FoundComment {\n readonly index: number;\n readonly text: string;\n}\n\ntype Found = Effect.Effect<readonly FoundComment[], CommentsUnreadable>;\n\nconst taggedError = Schema.TaggedError;\n\nclass CommentsUnreadable extends taggedError<\n CommentsUnreadable,\n { readonly brand: unique symbol }\n>()(\"CommentsUnreadable\", { reader: Schema.String, message: Schema.String }) {}\n\nconst unreadable =\n (reader: string) =>\n (cause: unknown): CommentsUnreadable =>\n CommentsUnreadable.make({ reader, message: String(cause) });\n\nconst trimmed = ({ index, text }: FoundComment): FoundComment => ({\n index,\n text: Str.trimEnd(text),\n});\n\nexport { CommentsUnreadable, trimmed, unreadable };\nexport type { Found, FoundComment };\n","import { DockerfileParser } from \"dockerfile-ast\";\nimport { Array as Arr, Effect, Number as Num, Record as Rec, String as Str, pipe } from \"effect\";\nimport { parse as parseSql } from \"sql-parser-cst\";\nimport { parseTOML } from \"toml-eslint-parser\";\nimport { Parser as YamlParser } from \"yaml\";\n\nimport { trimmed, unreadable } from \"./found-comment.ts\";\nimport type { Found } from \"./found-comment.ts\";\n\nconst NEXT = 1;\n\nconst isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>\n typeof value === \"object\" && value !== null;\n\nconst childrenOf = (value: unknown): readonly unknown[] => {\n if (Arr.isArray(value)) {\n return value;\n }\n if (isRecord(value)) {\n return Rec.values(value);\n }\n return [];\n};\n\nconst collect =\n <Item>(isItem: (value: unknown) => value is Item) =>\n (value: unknown): readonly Item[] => {\n if (isItem(value)) {\n return [value];\n }\n return pipe(childrenOf(value), Arr.flatMap(collect(isItem)));\n };\n\ninterface YamlSourceToken {\n readonly offset: number;\n readonly source: string;\n}\n\nconst isYamlComment = (value: unknown): value is YamlSourceToken =>\n isRecord(value) &&\n value[\"type\"] === \"comment\" &&\n typeof value[\"offset\"] === \"number\" &&\n typeof value[\"source\"] === \"string\";\n\nconst yamlComments = (source: string): Found =>\n Effect.try({\n try: () =>\n pipe(\n Arr.fromIterable(new YamlParser().parse(source)),\n Arr.flatMap(collect(isYamlComment)),\n Arr.map((token) => trimmed({ index: token.offset, text: token.source })),\n ),\n catch: unreadable(\"yaml\"),\n });\n\nconst tomlComments = (source: string): Found =>\n Effect.try({\n try: () =>\n pipe(\n parseTOML(source).comments,\n Arr.map(({ range: [start, end] }) =>\n trimmed({ index: start, text: Str.slice(start, end)(source) }),\n ),\n ),\n catch: unreadable(\"toml\"),\n });\n\ninterface SqlComment {\n readonly text: string;\n readonly range: readonly [number, number];\n}\n\nconst isSqlComment = (value: unknown): value is SqlComment =>\n isRecord(value) &&\n (value[\"type\"] === \"line_comment\" || value[\"type\"] === \"block_comment\") &&\n typeof value[\"text\"] === \"string\" &&\n Arr.isArray(value[\"range\"]);\n\nconst sqlComments = (source: string): Found =>\n Effect.try({\n try: () => {\n const program = parseSql(source, {\n dialect: \"sqlite\",\n includeComments: true,\n includeRange: true,\n paramTypes: [],\n });\n return pipe(\n collect(isSqlComment)(program),\n Arr.map(({ range: [start], text }) => trimmed({ index: start, text })),\n );\n },\n catch: unreadable(\"sql\"),\n });\n\nconst offsetAt =\n (lines: readonly string[]) =>\n ({ line, character }: Readonly<{ line: number; character: number }>): number =>\n character +\n pipe(\n lines,\n Arr.take(line),\n Arr.map((text) => text.length + NEXT),\n Num.sumAll,\n );\n\nconst dockerfileComments = (source: string): Found =>\n Effect.try({\n try: () => {\n const lines = Str.split(source, \"\\n\");\n return pipe(\n DockerfileParser.parse(source).getComments(),\n Arr.map((comment) =>\n trimmed({\n index: offsetAt(lines)(comment.getRange().start),\n text: comment.toString(),\n }),\n ),\n );\n },\n catch: unreadable(\"dockerfile\"),\n });\n\nexport { dockerfileComments, sqlComments, tomlComments, yamlComments };\n","import { fileURLToPath } from \"node:url\";\n\nimport treeSitter from \"@vscode/tree-sitter-wasm\";\nimport { isComment, isTag, isText } from \"domhandler\";\nimport type { AnyNode, Text } from \"domhandler\";\nimport { Array as Arr, Effect, Option, Record as Rec, String as Str, pipe } from \"effect\";\nimport { DomUtils, parseDocument } from \"htmlparser2\";\n\nimport { dockerfileComments, sqlComments, tomlComments, yamlComments } from \"./config-comments.ts\";\nimport { trimmed, unreadable } from \"./found-comment.ts\";\nimport type { CommentsUnreadable, Found, FoundComment } from \"./found-comment.ts\";\n\nconst GRAMMARS = [\n \"bash\",\n \"c-sharp\",\n \"cpp\",\n \"css\",\n \"go\",\n \"java\",\n \"javascript\",\n \"php\",\n \"powershell\",\n \"ruby\",\n \"rust\",\n \"tsx\",\n \"typescript\",\n] as const;\n\ntype Grammar = (typeof GRAMMARS)[number];\n\ntype Markup = \"html\" | \"xml\";\n\ntype Reader = Grammar | Markup | \"yaml\" | \"toml\" | \"sql\" | \"dockerfile\";\n\ntype Grammars = (grammar: Grammar) => Option.Option<treeSitter.Language>;\n\nconst COMMENT_NODES = [\"comment\", \"line_comment\", \"block_comment\", \"multiline_comment\"];\nconst START = 0;\nconst NEXT = 1;\nconst NONE: readonly FoundComment[] = [];\n\nconst grammarFile = (grammar: Grammar): string =>\n fileURLToPath(import.meta.resolve(`@vscode/tree-sitter-wasm/wasm/tree-sitter-${grammar}.wasm`));\n\nconst loadGrammar = (\n grammar: Grammar,\n): Effect.Effect<readonly [Grammar, treeSitter.Language], CommentsUnreadable> =>\n Effect.tryPromise({\n try: () => treeSitter.Language.load(grammarFile(grammar)),\n catch: unreadable(grammar),\n }).pipe(Effect.map((language) => [grammar, language] as const));\n\nconst loadGrammars = Effect.fn(\"loadGrammars\")(function* loadGrammars() {\n yield* Effect.tryPromise({\n try: () => treeSitter.Parser.init(),\n catch: unreadable(\"javascript\"),\n });\n const loaded = yield* pipe(\n GRAMMARS,\n Effect.forEach((grammar) => loadGrammar(grammar)),\n );\n const languages = Rec.fromEntries(loaded);\n const grammars: Grammars = (grammar) => Rec.get(languages, grammar);\n return grammars;\n});\n\nconst commentNodesIn = (language: treeSitter.Language, source: string): readonly FoundComment[] => {\n const parser = new treeSitter.Parser();\n parser.setLanguage(language);\n const tree = parser.parse(source);\n parser.delete();\n if (tree === null) {\n return NONE;\n }\n const found = pipe(\n tree.rootNode.descendantsOfType(COMMENT_NODES),\n Arr.flatMap((node) => Option.toArray(Option.fromNullishOr(node))),\n Arr.map((node) => trimmed({ index: node.startIndex, text: node.text })),\n );\n tree.delete();\n return found;\n};\n\nconst syntaxComments =\n (grammars: Grammars, grammar: Grammar) =>\n (source: string): Found =>\n Option.match(grammars(grammar), {\n onNone: () => Effect.fail(unreadable(grammar)(\"the grammar is not loaded\")),\n onSome: (language) =>\n Effect.try({ try: () => commentNodesIn(language, source), catch: unreadable(grammar) }),\n });\n\nconst SCRIPT_TYPE = /^(?:|module|text\\/javascript|application\\/javascript)$/iu;\nconst SHADER_TYPE = /shader|glsl/iu;\n\ninterface EmbeddingTag {\n readonly name: string;\n readonly attribs: Readonly<Record<string, string>>;\n}\n\nconst scriptGrammar = (attribs: EmbeddingTag[\"attribs\"]): Option.Option<Grammar> => {\n const type = Str.trim(Option.getOrElse(Rec.get(attribs, \"type\"), () => \"\"));\n if (Rec.get(attribs, \"lang\").pipe(Option.contains(\"ts\"))) {\n return Option.some<Grammar>(\"typescript\");\n }\n if (SHADER_TYPE.test(type)) {\n return Option.some<Grammar>(\"cpp\");\n }\n return Option.liftPredicate<Grammar>(\"javascript\", () => SCRIPT_TYPE.test(type));\n};\n\nconst embeddedGrammar = ({ name, attribs }: EmbeddingTag): Option.Option<Grammar> => {\n if (name === \"style\") {\n return Option.some<Grammar>(\"css\");\n }\n if (name === \"script\") {\n return scriptGrammar(attribs);\n }\n return Option.none();\n};\n\nconst shifted =\n (offset: number) =>\n ({ index, text }: FoundComment): FoundComment => ({ index: index + offset, text });\n\nconst markupComment =\n (source: string) =>\n (node: AnyNode): readonly FoundComment[] => {\n if (!isComment(node) || node.startIndex === null || node.endIndex === null) {\n return NONE;\n }\n return [\n { index: node.startIndex, text: Str.slice(node.startIndex, node.endIndex + NEXT)(source) },\n ];\n };\n\nconst textComments =\n (grammars: Grammars, grammar: Grammar) =>\n (text: Text): Found => {\n const shift = shifted(text.startIndex ?? START);\n return syntaxComments(grammars, grammar)(text.data).pipe(Effect.map(Arr.map(shift)));\n };\n\nconst embeddedComments =\n (grammars: Grammars) =>\n (node: AnyNode): Found => {\n if (!isTag(node)) {\n return Effect.succeed(NONE);\n }\n const texts = pipe(node.children, Arr.filter(isText));\n return Option.match(embeddedGrammar(node), {\n onNone: () => Effect.succeed(NONE),\n onSome: (grammar) =>\n pipe(texts, Effect.forEach(textComments(grammars, grammar)), Effect.map(Arr.flatten)),\n });\n };\n\nconst markupComments =\n (grammars: Grammars, markup: Markup) =>\n (source: string): Found =>\n Effect.gen(function* readMarkup() {\n const document = parseDocument(source, {\n xmlMode: markup === \"xml\",\n withStartIndices: true,\n withEndIndices: true,\n });\n const nodes = DomUtils.filter(() => true, document.children, true);\n const own = pipe(nodes, Arr.flatMap(markupComment(source)));\n if (markup === \"xml\") {\n return own;\n }\n const embedded = yield* pipe(nodes, Effect.forEach(embeddedComments(grammars)));\n return [...own, ...Arr.flatten(embedded)];\n });\n\nconst isGrammar = (reader: Reader): reader is Grammar => pipe(GRAMMARS, Arr.contains(reader));\n\nconst commentsWith =\n (grammars: Grammars) =>\n (reader: Reader, source: string): Found => {\n if (isGrammar(reader)) {\n return syntaxComments(grammars, reader)(source);\n }\n const readers = {\n html: markupComments(grammars, \"html\"),\n xml: markupComments(grammars, \"xml\"),\n yaml: yamlComments,\n toml: tomlComments,\n sql: sqlComments,\n dockerfile: dockerfileComments,\n } satisfies Record<Exclude<Reader, Grammar>, (text: string) => Found>;\n return readers[reader](source);\n };\n\nexport { commentsWith, loadGrammars };\nexport type { Grammar, Grammars, Markup, Reader };\n","import path from \"node:path\";\n\nimport {\n Array as Arr,\n Effect,\n HashSet,\n Option,\n Predicate,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport { commentsWith, loadGrammars } from \"./comment-readers.ts\";\nimport type { Reader } from \"./comment-readers.ts\";\nimport type { FoundComment } from \"./found-comment.ts\";\nimport { COMMENT_DIRECTIVES } from \"./lint/comment-directives.ts\";\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { positionOf } from \"./text-position.ts\";\n\nconst RULE: RuleName = \"comment\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst VENDORED_PATHSPEC = \":(attr:linguist-vendored)\";\nconst READ_CONCURRENCY = 64;\nconst START = 0;\nconst FIRST_LINE = 1;\nconst FIRST_COLUMN = 1;\n\nconst READERS: readonly (readonly [RegExp, Reader])[] = [\n [/\\.(?:[cm]?jsx?)$/u, \"javascript\"],\n [/\\.(?:[cm]?ts)$/u, \"typescript\"],\n [/\\.tsx$/u, \"tsx\"],\n [/\\.rs$/u, \"rust\"],\n [/\\.(?:cs|csx)$/u, \"c-sharp\"],\n [/\\.(?:sh|bash|zsh|ksh)$/u, \"bash\"],\n [/(?:^|\\/)\\.(?:vite-hooks|husky|githooks)\\/[^./][^/]*$/u, \"bash\"],\n [/\\.(?:ps1|psm1|psd1)$/u, \"powershell\"],\n [/\\.go$/u, \"go\"],\n [/\\.(?:java|kt|kts)$/u, \"java\"],\n [/\\.(?:rb|rake)$/u, \"ruby\"],\n [/\\.php$/u, \"php\"],\n [/\\.(?:c|h|cc|cpp|cxx|hpp|hh|m|mm|glsl|frag|vert|comp|wgsl|hlsl|metal)$/u, \"cpp\"],\n [/\\.(?:css|pcss)$/u, \"css\"],\n [/\\.(?:html?|vue|svelte|astro)$/u, \"html\"],\n [/\\.(?:xml|xaml|plist|resx|props|targets|[a-z]+proj|manifest|nuspec)$/u, \"xml\"],\n [/\\.ya?ml$/u, \"yaml\"],\n [/\\.toml$/u, \"toml\"],\n [/\\.sql$/u, \"sql\"],\n [/(?:^|\\/)(?:Dockerfile|Containerfile)(?:\\.[^/]+)?$|\\.dockerfile$/u, \"dockerfile\"],\n];\n\nconst SHEBANG_READERS: readonly (readonly [RegExp, Reader])[] = [\n [/^#!.*\\b(?:ba|z|k|da)?sh\\b/u, \"bash\"],\n [/^#!.*\\b(?:node|bun|deno|tsx)\\b/u, \"javascript\"],\n [/^#!.*\\bpwsh\\b/u, \"powershell\"],\n];\n\nconst SHEBANG = \"#!\";\nconst PIN = /@(?:[0-9a-f]{40}|sha256:[0-9a-f]{64})\\s*$/u;\nconst VERSION = /^\\s?v?\\d[\\w.+-]*$/u;\nconst DELIMITERS = /^(?:\\/\\/|\\/\\*|<!--|<#|#|--)|(?:\\*\\/|-->|#>)$/gu;\nconst MESSAGE =\n \"Comments are not written in this repository. Say it with names and types in the code, put the reason in the commit message, and delete the comment.\";\n\nconst Patterns = Schema.Array(Schema.String);\nconst CommentSettings = Schema.Struct({ allow: Patterns });\nconst MschSettings = Schema.Struct({ comments: Schema.optional(CommentSettings) });\nconst LintSettings = Schema.Struct({ ignorePatterns: Schema.optional(Patterns) });\n\nconst RootConfig = Schema.Struct({\n msch: Schema.optional(MschSettings),\n lint: Schema.optional(LintSettings),\n});\n\ntype RootConfigType = typeof RootConfig.Type;\n\ninterface RootSettings {\n readonly allow: readonly string[];\n readonly ignorePatterns: readonly string[];\n}\n\ninterface Listed {\n readonly name: string;\n readonly file: string;\n}\n\nconst NO_SETTINGS: RootSettings = { allow: [], ignorePatterns: [] };\nconst NONE: readonly Problem[] = [];\n\nconst taggedError = Schema.TaggedError;\n\nclass CommentConfigUnreadable extends taggedError<\n CommentConfigUnreadable,\n { readonly brand: unique symbol }\n>()(\"CommentConfigUnreadable\", { file: Schema.String }) {}\n\nconst shebangReader = (source: string): Option.Option<readonly [RegExp, Reader]> => {\n if (!Str.startsWith(SHEBANG)(source)) {\n return Option.none();\n }\n return pipe(\n SHEBANG_READERS,\n Arr.findFirst(([pattern]) => pattern.test(source)),\n );\n};\n\nconst readerOf = (name: string, source: string): Option.Option<Reader> =>\n pipe(\n READERS,\n Arr.findFirst(([pattern]) => pattern.test(name)),\n Option.orElse(() => shebangReader(source)),\n Option.map(([, reader]) => reader),\n );\n\nconst valueOf = (text: string): string => Str.replaceAll(DELIMITERS, \"\")(text);\n\nconst lineBefore = (source: string, index: number): string => {\n const lines = pipe(source, Str.slice(START, index), Str.split(\"\\n\"));\n return Option.getOrElse(Arr.last(lines), () => \"\");\n};\n\nconst isPinVersion = (source: string, { index, text }: FoundComment): boolean =>\n PIN.test(lineBefore(source, index)) && VERSION.test(valueOf(text));\n\nconst isShebang = ({ index, text }: FoundComment): boolean =>\n index === START && Str.startsWith(SHEBANG)(text);\n\nconst isAllowed =\n (source: string, directives: RegExp) =>\n (comment: FoundComment): boolean =>\n isShebang(comment) || directives.test(valueOf(comment.text)) || isPinVersion(source, comment);\n\nconst problemOf =\n (file: string, source: string) =>\n ({ index }: FoundComment): Problem => ({\n file,\n ...positionOf(source)(index),\n rule: RULE,\n message: MESSAGE,\n });\n\nconst unreadableProblem = (file: string, message: string): Problem => ({\n file,\n line: FIRST_LINE,\n column: FIRST_COLUMN,\n rule: RULE,\n message: `msch could not read the comments in this file: ${message}`,\n});\n\nconst settingsOf = ({ msch, lint }: RootConfigType): RootSettings => ({\n allow: pipe(\n Option.fromUndefinedOr(msch),\n Option.flatMap(({ comments }) => Option.fromUndefinedOr(comments)),\n Option.match({ onNone: () => NO_SETTINGS.allow, onSome: ({ allow }) => allow }),\n ),\n ignorePatterns: pipe(\n Option.fromUndefinedOr(lint),\n Option.flatMap(({ ignorePatterns }) => Option.fromUndefinedOr(ignorePatterns)),\n Option.getOrElse(() => NO_SETTINGS.ignorePatterns),\n ),\n});\n\nconst rootSettings = Effect.fn(\"rootSettings\")(function* rootSettings(root: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, CONFIG_FILE);\n const exists = yield* files.exists(file);\n if (!exists) {\n return NO_SETTINGS;\n }\n const config = yield* Effect.tryPromise({\n try: () => resolveConfigFromFile(file),\n catch: () => CommentConfigUnreadable.make({ file }),\n }).pipe(Effect.option);\n return pipe(\n config,\n Option.flatMap(Schema.decodeUnknownOption(RootConfig)),\n Option.match({ onNone: () => NO_SETTINGS, onSome: settingsOf }),\n );\n});\n\nconst directivePattern = (directives: readonly string[]): RegExp =>\n new RegExp(String.raw`^\\s?(?:${Arr.join(directives, \"|\")})`, \"u\");\n\nconst isIgnored =\n (patterns: readonly string[]) =>\n (name: string): boolean =>\n pipe(\n patterns,\n Arr.some((pattern) => path.matchesGlob(name, pattern)),\n );\n\nconst scannedFiles = Effect.fn(\"scannedFiles\")(function* scannedFiles(\n root: string,\n settings: RootSettings,\n) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.listedFiles(root);\n const generated = yield* files.generatedFiles(root);\n const vendored = yield* files.matchingFiles(root, [VENDORED_PATHSPEC]);\n const skipped = HashSet.fromIterable([\n ...generated,\n ...pipe(\n vendored,\n Arr.map((name) => files.join(root, name)),\n ),\n ]);\n return pipe(\n listed,\n Arr.filter((name) => !isIgnored(settings.ignorePatterns)(name)),\n Arr.map((name): Listed => ({ name, file: files.join(root, name) })),\n Arr.filter(({ file }) => !HashSet.has(skipped, file)),\n );\n});\n\n/** @internal */\nconst checkComments = Effect.fn(\"checkComments\")(function* checkComments(root: string) {\n const files = yield* RepositoryFiles;\n const settings = yield* rootSettings(root);\n const scanned = yield* scannedFiles(root, settings);\n const directives = directivePattern([...COMMENT_DIRECTIVES, ...settings.allow]);\n const grammars = yield* loadGrammars();\n const comments = commentsWith(grammars);\n const problemsIn = (\n { name, file }: Listed,\n source: string,\n ): Effect.Effect<readonly Problem[]> => {\n const kept = Predicate.not(isAllowed(source, directives));\n const toProblem = problemOf(file, source);\n return Option.match(readerOf(name, source), {\n onNone: () => Effect.succeed(NONE),\n onSome: (reader) =>\n comments(reader, source).pipe(\n Effect.map(Arr.filter(kept)),\n Effect.map(Arr.map(toProblem)),\n Effect.catchTag(\"CommentsUnreadable\", ({ message }) =>\n Effect.succeed([unreadableProblem(file, message)]),\n ),\n ),\n });\n };\n const found = yield* Effect.forEach(\n scanned,\n (entry) =>\n files.readFile(entry.file).pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.succeed(NONE),\n onSome: (source) => problemsIn(entry, source),\n }),\n ),\n ),\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.flatten(found);\n});\n\nexport { checkComments };\n","import { Array as Arr, Effect, Option, String as Str, pipe } from \"effect\";\n\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { positionOf } from \"./text-position.ts\";\n\nconst HIDDEN =\n /[\\u00AD\\u180E\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\u2066-\\u2069\\uFEFF]|[\\u{E0000}-\\u{E007F}]/gu;\n\nconst NUL = \"\\0\";\nconst START = 0;\nconst HEX = 16;\nconst CODE_POINT_WIDTH = 4;\nconst READ_CONCURRENCY = 64;\nconst RULE: RuleName = \"hidden-unicode\";\n\nconst hexOf = (character: string): string =>\n pipe(\n Str.codePointAt(START)(character),\n Option.getOrElse(() => START),\n (code) => code.toString(HEX),\n Str.toUpperCase,\n Str.padStart(CODE_POINT_WIDTH, \"0\"),\n );\n\nconst problemOf =\n (file: string, source: string) =>\n (found: RegExpMatchArray): Problem => {\n const hex = hexOf(found[START]);\n return {\n file,\n ...positionOf(source)(found.index ?? START),\n rule: RULE,\n 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}.`,\n };\n };\n\nconst problemsIn = (file: string, source: string): readonly Problem[] => {\n if (Str.includes(NUL)(source)) {\n return [];\n }\n return pipe(Arr.fromIterable(Str.matchAll(HIDDEN)(source)), Arr.map(problemOf(file, source)));\n};\n\n/** @internal */\nconst checkHiddenUnicode = Effect.fn(\"checkHiddenUnicode\")(function* checkHiddenUnicode(\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const names = yield* files.listedFiles(root);\n const found = yield* Effect.forEach(\n names,\n (name) => {\n const file = files.join(root, name);\n return files.readFile(file).pipe(\n Effect.map(\n Option.match({\n onNone: (): readonly Problem[] => [],\n onSome: (source) => problemsIn(file, source),\n }),\n ),\n );\n },\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.flatten(found);\n});\n\nexport { checkHiddenUnicode };\n","import { Array as Arr, Effect, Option, String as Str, pipe } from \"effect\";\n\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { positionOf } from \"./text-position.ts\";\n\nconst PYTHON_FILE =\n /(?:\\.(?:py|pyi|pyw|pyx|ipynb)|(?:^|\\/)(?:pyproject\\.toml|uv\\.lock|uv\\.toml|poetry\\.lock|Pipfile|Pipfile\\.lock|setup\\.cfg|tox\\.ini|pytest\\.ini|\\.python-version|requirements[^/]*\\.txt))$/u;\n\nconst SCANNED_FILE =\n /(?:\\.(?:[cm]?[jt]sx?|jsonc?|toml|ya?ml|sh|bash|zsh|fish|rs|cs|go|mk)|(?:^|\\/)(?:Dockerfile[^/]*|Makefile|justfile|\\.tool-versions|[^./][^./]*))$/u;\n\nconst LOCKFILE = /(?:^|\\/)(?:[^/]*\\.lock|[^/]*-lock\\.(?:json|ya?ml))$/u;\n\nconst TOOL_VERSIONS = /(?:^|\\/)(?:\\.?mise(?:\\.[^/]+)?\\.toml|\\.tool-versions)$/u;\n\nconst COMMAND_PATTERNS: readonly RegExp[] = [\n /(?<![\\w./@-])python[\\d.]*[ \\t]+(?:[-\"'$./]|\\S+\\.py\\b)/gu,\n /(?<![\\w./@-])pip3?[ \\t]+(?:install|uninstall|download|freeze|wheel|compile|sync)\\b/gu,\n /(?<![\\w./@-])pipx[ \\t]+(?:run|install|inject|upgrade)\\b/gu,\n /(?<![\\w./@-])uvx[ \\t]+[^\\s=:,;)|&]/gu,\n /(?<![\\w./@-])uv[ \\t]+(?:run|sync|lock|pip|tool|venv|add|remove|python|export|build|publish|init|tree|cache|self)\\b/gu,\n /(?<![\\w./@-])poetry[ \\t]+(?:run|install|add|lock|build|publish|shell|export)\\b/gu,\n /(?:\\bcommand[\"']?\\s*[:=]\\s*|(?:\\bspawn\\w*|\\bexec\\w*|\\bexeca|Command::new|ChildProcess\\.make|\\$)\\(\\s*)[\"'`](?:python[\\d.]*|pip3?|pipx|uvx?|poetry)[\"'`]/gu,\n /\\buses:\\s*[\"']?(?:actions\\/setup-python|astral-sh\\/setup-uv|astral-sh\\/ruff-action|pypa\\/[\\w.-]+|snok\\/install-poetry|abatilo\\/actions-poetry|conda-incubator\\/setup-miniconda|mamba-org\\/setup-micromamba|pdm-project\\/setup-pdm)\\b/gu,\n];\n\nconst TOOL_PATTERNS: readonly RegExp[] = [\n /^[ \\t]*[\"']?(?:python|uv|pipx|poetry|ruff|pdm|hatch|pipx:[^\"'\\s=]+)[\"']?[ \\t]*(?:=|[ \\t]+\\S)/gmu,\n];\n\nconst READ_CONCURRENCY = 64;\nconst FIRST_LINE = 1;\nconst FIRST_COLUMN = 1;\nconst WHOLE_MATCH = 0;\nconst FILE_RULE: RuleName = \"python-file\";\nconst COMMAND_RULE: RuleName = \"python-command\";\n\ninterface Listed {\n readonly name: string;\n readonly file: string;\n}\n\nconst fileProblem = ({ file }: Listed): Problem => ({\n file,\n line: FIRST_LINE,\n column: FIRST_COLUMN,\n rule: FILE_RULE,\n message: \"Python is not used in this repository. Replace this file with TypeScript or Rust.\",\n});\n\nconst patternsFor = (name: string): readonly RegExp[] => {\n if (TOOL_VERSIONS.test(name)) {\n return [...COMMAND_PATTERNS, ...TOOL_PATTERNS];\n }\n return COMMAND_PATTERNS;\n};\n\nconst commandProblem =\n ({ file }: Listed, source: string) =>\n (found: RegExpMatchArray): Problem => ({\n file,\n ...positionOf(source)(found.index ?? WHOLE_MATCH),\n rule: COMMAND_RULE,\n message: `Python is not used in this repository. Remove \\`${Str.trim(found[WHOLE_MATCH])}\\` and do the work in TypeScript or Rust.`,\n });\n\nconst commandProblems = (entry: Listed, source: string): readonly Problem[] =>\n pipe(\n patternsFor(entry.name),\n Arr.flatMap((pattern) => Arr.fromIterable(Str.matchAll(pattern)(source))),\n Arr.map(commandProblem(entry, source)),\n );\n\nconst isPython = ({ name }: Listed): boolean => PYTHON_FILE.test(name);\n\nconst isScanned = (entry: Listed): boolean =>\n !isPython(entry) && SCANNED_FILE.test(entry.name) && !LOCKFILE.test(entry.name);\n\n/** @internal */\nconst checkPython = Effect.fn(\"checkPython\")(function* checkPython(root: string) {\n const files = yield* RepositoryFiles;\n const names = yield* files.listedFiles(root);\n const listed = pipe(\n names,\n Arr.map((name): Listed => ({ name, file: files.join(root, name) })),\n );\n const problemsIn = (entry: Listed): Effect.Effect<readonly Problem[]> =>\n files.readFile(entry.file).pipe(\n Effect.map(\n Option.match({\n onNone: (): readonly Problem[] => [],\n onSome: (source) => commandProblems(entry, source),\n }),\n ),\n );\n const scanned = yield* Effect.forEach(pipe(listed, Arr.filter(isScanned)), problemsIn, {\n concurrency: READ_CONCURRENCY,\n });\n const present = yield* Effect.filter(pipe(listed, Arr.filter(isPython)), ({ file }) =>\n files.exists(file),\n );\n return [...pipe(present, Arr.map(fileProblem)), ...Arr.flatten(scanned)];\n});\n\nexport { checkPython };\n","import { Array as Arr, Effect } from \"effect\";\n\nimport { checkComments } from \"./comments.ts\";\nimport { checkHiddenUnicode } from \"./hidden-unicode.ts\";\nimport { checkPython } from \"./python.ts\";\n\n/** @internal */\nconst checkTrackedText = Effect.fn(\"checkTrackedText\")(function* checkTrackedText(root: string) {\n const found = yield* Effect.all(\n [checkHiddenUnicode(root), checkPython(root), checkComments(root)],\n { concurrency: \"unbounded\" },\n );\n return Arr.flatten(found);\n});\n\nexport { checkTrackedText };\n","import { Array as Arr, Effect, Option, Schema, Stream, String as Str, pipe } from \"effect\";\nimport { ChildProcess } from \"effect/process\";\n\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { workspaceDirectories } from \"./workspace-directories.ts\";\nimport { hasVerifyTask } from \"./workspace-tasks.ts\";\n\nconst RULE: RuleName = \"unverified-crate\";\nconst CARGO_FILE = \"Cargo.toml\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst SEPARATOR = \"/\";\nconst FIRST = 1;\nconst READ_CONCURRENCY = 8;\n\nconst CrateEntry = Schema.Struct({ name: Schema.String, manifest_path: Schema.String });\nconst CrateList = Schema.fromJsonString(Schema.Struct({ packages: Schema.Array(CrateEntry) }));\nconst decodeCrateList = Schema.decodeUnknownEffect(CrateList);\n\ninterface Crate {\n readonly name: string;\n readonly manifest: string;\n}\n\nconst cratesIn = Effect.fn(\"cratesIn\")(function* cratesIn(root: string) {\n const handle = yield* ChildProcess.make(\n \"cargo\",\n [\"metadata\", \"--no-deps\", \"--format-version\", \"1\", \"--offline\"],\n { cwd: root, extendEnv: true, stdin: \"ignore\" },\n );\n const output = yield* handle.stdout.pipe(Stream.decodeText(), Stream.mkString);\n const list = yield* decodeCrateList(output);\n return pipe(\n list.packages,\n Arr.map((crate): Crate => ({ name: crate.name, manifest: crate.manifest_path })),\n );\n}, Effect.scoped);\n\nconst owningWorkspace =\n (directories: readonly string[]) =>\n (directory: string): Option.Option<string> => {\n const owners = pipe(\n directories,\n Arr.filter(\n (workspace) =>\n directory === workspace || Str.startsWith(`${workspace}${SEPARATOR}`)(directory),\n ),\n );\n return Arr.last(Arr.sort(owners, Str.Order));\n };\n\nconst problemFor = (crate: Crate, message: string): Problem => ({\n file: crate.manifest,\n line: FIRST,\n column: FIRST,\n rule: RULE,\n message: `crate ${crate.name} ${message}, so vp run verify never checks it.`,\n});\n\nconst problemIn = Effect.fn(\"problemIn\")(function* problemIn(\n root: string,\n directories: readonly string[],\n crate: Crate,\n) {\n const files = yield* RepositoryFiles;\n const workspace = owningWorkspace(directories)(\n files.relative(root, files.dirname(crate.manifest)),\n );\n if (Option.isNone(workspace)) {\n return Option.some(problemFor(crate, \"is outside every workspace package\"));\n }\n const verified = yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE));\n if (verified) {\n return Option.none<Problem>();\n }\n return Option.some(\n problemFor(crate, `is in ${workspace.value}, whose ${CONFIG_FILE} has no verify task`),\n );\n});\n\n/** @internal */\nconst checkCrates = Effect.fn(\"checkCrates\")(function* checkCrates(root: string) {\n const files = yield* RepositoryFiles;\n const cargo = yield* files.exists(files.join(root, CARGO_FILE));\n if (!cargo) {\n return [];\n }\n const directories = yield* workspaceDirectories(root);\n const crates = yield* cratesIn(root);\n const found = yield* Effect.forEach(crates, (crate) => problemIn(root, directories, crate), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(found);\n});\n\nexport { checkCrates };\n","import { Array as Arr, Effect, Option } from \"effect\";\n\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { programOf } from \"./workspace-config-source.ts\";\nimport { workspaceDirectories } from \"./workspace-directories.ts\";\nimport { VERIFY_TASK, definesTask, hasVerifyTask } from \"./workspace-tasks.ts\";\n\nconst RULE: RuleName = \"hidden-verify\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst FIRST = 1;\nconst READ_CONCURRENCY = 8;\n\nconst problemIn = Effect.fn(\"problemIn\")(function* problemIn(root: string, directory: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, directory, CONFIG_FILE);\n const text = yield* files.readFile(file);\n if (Option.isNone(text)) {\n return Option.none<Problem>();\n }\n const program = yield* programOf(file, text.value);\n if (definesTask(VERIFY_TASK)(program)) {\n return Option.none<Problem>();\n }\n const verified = yield* hasVerifyTask(file);\n return Option.some<Problem>({\n file,\n line: FIRST,\n column: FIRST,\n rule: RULE,\n message: `${directory} gets its verify task from code outside ${CONFIG_FILE}. The root verify reads ${CONFIG_FILE} without running it, so it never runs this verify. Write run.tasks.verify in ${directory}/${CONFIG_FILE}.`,\n }).pipe(Option.filter(() => verified));\n});\n\n/** @internal */\nconst checkHiddenVerify = Effect.fn(\"checkHiddenVerify\")(function* checkHiddenVerify(root: string) {\n const directories = yield* workspaceDirectories(root);\n const found = yield* Effect.forEach(directories, (directory) => problemIn(root, directory), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(found);\n});\n\nexport { checkHiddenVerify };\n","import { Array as Arr, Effect, Option, Schema, String as Str, pipe } from \"effect\";\nimport { parse } from \"vite-plus\";\nimport type { ESTree } from \"vite-plus/lint/plugins\";\n\nimport { childrenOf } from \"./config-literal.ts\";\nimport type { Problem, RuleName } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { positionOf } from \"./text-position.ts\";\nimport { workspaceDirectories } from \"./workspace-directories.ts\";\n\nconst RULE: RuleName = \"root-workspace-path\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst PATH_CHARACTER = /[\\w.@/-]/u;\nconst NAME_CHARACTER = /[\\w.@-]/u;\nconst FIRST = 0;\nconst NEXT = 1;\n\nconst StringNode = Schema.Union([\n Schema.Struct({\n type: Schema.Literal<ESTree.StringLiteral[\"type\"]>(\"Literal\"),\n value: Schema.String,\n start: Schema.Finite,\n }),\n Schema.Struct({\n type: Schema.Literal<ESTree.TemplateElement[\"type\"]>(\"TemplateElement\"),\n value: Schema.Struct({ cooked: Schema.String }),\n start: Schema.Finite,\n }),\n]);\nconst decodeStringNode = Schema.decodeUnknownOption(StringNode);\n\ninterface FoundString {\n readonly text: string;\n readonly start: number;\n}\n\nconst textOf = (node: typeof StringNode.Type): string => {\n if (node.type === \"Literal\") {\n return node.value;\n }\n return node.value.cooked;\n};\n\nconst stringsIn = (node: unknown): readonly FoundString[] => {\n const own = pipe(\n decodeStringNode(node),\n Option.map((found) => ({ text: textOf(found), start: found.start })),\n Option.toArray,\n );\n return [...own, ...pipe(childrenOf(node), Arr.flatMap(stringsIn))];\n};\n\nconst isBoundary = (character: string, allowed: RegExp): boolean =>\n character === \"\" || !allowed.test(character);\n\nconst mentions =\n (directory: string) =>\n (text: string): boolean => {\n const parts = Str.split(text, directory);\n return pipe(\n Arr.drop(parts, NEXT),\n Arr.some((after, index) => {\n const before = parts[index] ?? \"\";\n const previous = Str.slice(before.length - NEXT)(before);\n const following = Str.slice(FIRST, NEXT)(after);\n return (\n isBoundary(previous, PATH_CHARACTER) &&\n (following === \"/\" || isBoundary(following, NAME_CHARACTER))\n );\n }),\n );\n };\n\nconst problemsIn =\n (file: string, source: string, directories: readonly string[]) =>\n (found: FoundString): readonly Problem[] =>\n pipe(\n directories,\n Arr.filter((directory) => mentions(directory)(found.text)),\n Arr.map((directory): Problem => ({\n file,\n ...positionOf(source)(found.start),\n rule: RULE,\n message: `${directory} is a workspace. The root ${CONFIG_FILE} holds what applies to every workspace, so move what only ${directory} needs into ${directory}/${CONFIG_FILE}: msch.lint, msch.devDependencies or its verify task.`,\n })),\n );\n\n/** @internal */\nconst checkRootWorkspacePaths = Effect.fn(\"checkRootWorkspacePaths\")(\n function* checkRootWorkspacePaths(root: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, CONFIG_FILE);\n const source = yield* files.readFile(file);\n if (Option.isNone(source)) {\n return [];\n }\n const directories = yield* workspaceDirectories(root);\n const parsed = yield* Effect.promise(() => parse(file, source.value, { lang: \"ts\" }));\n return pipe(\n stringsIn(parsed.program),\n Arr.flatMap(problemsIn(file, source.value, directories)),\n );\n },\n);\n\nexport { checkRootWorkspacePaths };\n","import { Array as Arr, Effect } from \"effect\";\n\nimport { checkCrates } from \"./crates.ts\";\nimport { checkHiddenVerify } from \"./hidden-verify.ts\";\nimport { checkRootWorkspacePaths } from \"./root-workspace-paths.ts\";\n\n/** @internal */\nconst checkWorkspaces = Effect.fn(\"checkWorkspaces\")(function* checkWorkspaces(root: string) {\n const found = yield* Effect.all(\n [checkCrates(root), checkHiddenVerify(root), checkRootWorkspacePaths(root)],\n {\n concurrency: \"unbounded\",\n },\n );\n return Arr.flatten(found);\n});\n\nexport { checkWorkspaces };\n","import { Array as Arr, Effect } from \"effect\";\n\nimport { checkRepository } from \"./check.ts\";\nimport { checkPublishedPackages } from \"./install-size.ts\";\nimport { checkOverrides } from \"./overrides.ts\";\nimport { checkPlacement } from \"./placement-checks.ts\";\nimport type { Problem } from \"./problem.ts\";\nimport { checkTrackedText } from \"./tracked-text.ts\";\nimport { checkWorkspaces } from \"./workspace-checks.ts\";\n\n/** @internal */\nconst checkAll: (\n root: string,\n) => Effect.Effect<\n readonly Problem[],\n Effect.Error<\n | ReturnType<typeof checkRepository>\n | ReturnType<typeof checkOverrides>\n | ReturnType<typeof checkTrackedText>\n | ReturnType<typeof checkWorkspaces>\n >,\n Effect.Services<\n | ReturnType<typeof checkRepository>\n | ReturnType<typeof checkOverrides>\n | ReturnType<typeof checkTrackedText>\n >\n> = Effect.fn(\"checkAll\")(function* checkAll(root: string) {\n const found = yield* Effect.all(\n [\n checkRepository(root),\n checkOverrides(root),\n checkTrackedText(root),\n checkPlacement(root),\n checkPublishedPackages(root),\n checkWorkspaces(root),\n ],\n { concurrency: \"unbounded\" },\n );\n return Arr.flatten(found);\n});\n\nexport { checkAll };\n","import { Effect, Schema, Stdio, Stream } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nclass ProblemsFound extends taggedError<ProblemsFound, { readonly brand: unique symbol }>()(\n \"ProblemsFound\",\n {\n count: Schema.Finite,\n },\n) {}\n\n/** @internal */\nconst writeStdout = Effect.fn(\"writeStdout\")(function* writeStdout(text: string) {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n});\n\nexport { ProblemsFound, writeStdout };\n","import { runMain } from \"@effect/platform-node-shared/NodeRuntime\";\nimport { Cause, Effect, Layer, Option, Schema, Stdio, Stream } from \"effect\";\nimport type { FileSystem, Path } from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { Otlp, OtlpSerialization } from \"effect/observability\";\nimport type { ChildProcessSpawner } from \"effect/process\";\n\nimport { nodeServicesLayer } from \"./node-services.ts\";\nimport { ProblemsFound } from \"./output.ts\";\nimport { nodeRepositoryFiles } from \"./repository-files.ts\";\nimport type { RepositoryFiles } from \"./repository-files.ts\";\n\nconst reportFailure = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* report() {\n const stdio = yield* Stdio.Stdio;\n const failed = Cause.findErrorOption(cause).pipe(Option.exists(Schema.is(ProblemsFound)));\n if (failed) {\n return;\n }\n yield* Stream.make(`${Cause.pretty(cause)}\\n`).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\nconst tracing = Otlp.layerFromConfig({ resource: { serviceName: \"msch\" } }).pipe(\n Layer.provide(OtlpSerialization.layerJson),\n Layer.provide(FetchHttpClient.layer),\n);\n\nconst runCli = <Value, Failure>(\n program: Effect.Effect<\n Value,\n Failure,\n | RepositoryFiles\n | Stdio.Stdio\n | FileSystem.FileSystem\n | Path.Path\n | ChildProcessSpawner.ChildProcessSpawner\n >,\n): void => {\n const services = Layer.mergeAll(nodeRepositoryFiles, tracing).pipe(\n Layer.provideMerge(nodeServicesLayer),\n );\n const main = Layer.build(services).pipe(\n Effect.flatMap((context) =>\n Effect.provideContext(program.pipe(Effect.tapCause(reportFailure)), context),\n ),\n Effect.scoped,\n );\n runMain(main, { disableErrorReporting: true });\n};\n\n/** @internal */\nexport { runCli };\n","#!/usr/bin/env node\nimport { Effect, Schema, Stdio, Array as Arr, pipe } from \"effect\";\n\nimport { checkAll } from \"./all-checks.ts\";\nimport { JSON_FLAG } from \"./cli-contract.ts\";\nimport { ProblemsFound, writeStdout } from \"./output.ts\";\nimport { ProblemList, formatProblem, sortProblems } from \"./problem.ts\";\nimport type { Problem } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\nimport { runCli } from \"./runtime.ts\";\n\nconst NO_PROBLEMS = 0;\n\nconst reportText = (\n root: string,\n problems: readonly Problem[],\n): Effect.Effect<void, ProblemsFound, RepositoryFiles | Stdio.Stdio> =>\n Effect.gen(function* report() {\n const files = yield* RepositoryFiles;\n const format = formatProblem((file) => files.relative(root, file));\n yield* writeStdout(\n pipe(\n problems,\n Arr.map((problem) => `${format(problem)}\\n`),\n Arr.join(\"\"),\n ),\n );\n if (problems.length > NO_PROBLEMS) {\n return yield* ProblemsFound.make({ count: problems.length });\n }\n return yield* Effect.void;\n });\n\nconst msch = Effect.gen(function* msch() {\n const stdio = yield* Stdio.Stdio;\n const files = yield* RepositoryFiles;\n const args = yield* stdio.args;\n const root = files.resolve(\".\");\n const found = yield* checkAll(root);\n const problems = sortProblems(found);\n if (args.includes(JSON_FLAG)) {\n const text = yield* Schema.encodeEffect(Schema.fromJsonString(ProblemList))(problems);\n return yield* writeStdout(text);\n }\n return yield* reportText(root, problems);\n});\n\nrunCli(msch);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,kCAA2C,IAAI,IAAI;CACvD,WAAW;CACX,WAAW;CACX,WAAW;CACX,WAAW;AACb,CAAC;AAED,MAAM,eAAe,gBACnB,gBAAgB,IAAI,YAAY,IAAI;AAEtC,MAAM,gBAAgB,gBACpB,OAAO,cAAc,aAAa,WAAW,CAAC,CAAC,KAC7C,OAAO,SAAS,cAAc,OAAO,gBAAgB,UAAU,IAAI,CAAC,CACtE;AAEF,MAAM,gBACH,aACA,eAAuD;CACtD,MAAM,OAAO,WAAW;CACxB,IAAI,CAAC,iBAAiB,IAAI,KAAK,CAAC,gBAAgB,IAAI,GAClD,OAAO,OAAO,KAAK;CAErB,MAAM,EAAE,WAAW,WAAW;CAE9B,MAAM,SADuC,UAAU,CAAC,EAAA,CAC5B,QAAQ,UAAU;CAC9C,OAAO,OAAO,gBAAgB,QAAQ,qBAAqB,IAAI,CAAC,CAAC,WAAW,CAAC,CAAC,KAC5E,OAAO,SAAS,WAAW,OAAO,gBAAgB,OAAO,QAAQ,CAAC,CAAC,GACnE,OAAO,OAAO,sBAAsB,GAC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arr","mentions","START","FIRST_COLUMN","Str","Arr","SCOPE","SEPARATOR","SCOPED_SEGMENTS","Str","Arr","Rec","decodeManifest","keysOf","Rec","Arr","childrenOf","Num","Str","START","Arr","Str","Num","Rec","problemsOf","keysOf","Arr","SCOPE_PREFIX","Arr","Rec","Str","packageOf","WORKSPACE_FILE","LOCKFILE","taggedError","textOf","Str","Arr","RULE","FIRST","READ_CONCURRENCY","problemFor","Arr","Str","ownerOf","problemIn","RULE","CONFIG_FILE","SEPARATOR","FIRST","READ_CONCURRENCY","README","RootConfig","taggedError","Str","problemFor","problemIn","Arr","RULE","SEPARATOR","READ_CONCURRENCY","START","Arr","Str","problemsIn","Arr","RULE","CONFIG_FILE","SEPARATOR","FIRST","READ_CONCURRENCY","Arr","Str","problemIn","RULE","CONFIG_FILE","FIRST","READ_CONCURRENCY","Arr","RULE","CONFIG_FILE","NEXT","childrenOf","Arr","Str","problemsIn","RULE","READ_CONCURRENCY","Arr","Str","Rec","Arr","Arr","Str","Arr","Arr","Str","Arr","Arr","Arr","childrenOf","Arr","Arr","Arr","Rec","mentions","Arr","taggedError","Str","NEXT","Arr","Rec","YamlParser","Str","parseSql","Num","START","NONE","Rec","Arr","Str","parseDocument","RULE","READ_CONCURRENCY","START","FIRST_LINE","FIRST_COLUMN","taggedError","Str","Arr","problemOf","START","READ_CONCURRENCY","Str","Arr","Arr","TOOL_PATTERNS","FIRST_LINE","FIRST_COLUMN","WHOLE_MATCH","FILE_RULE","Str","Arr","parse","Str","Arr","Arr","Arr","Arr"],"sources":["../src/shared/lib/values.ts","../src/entities/project/model/library.ts","../src/entities/project/model/telemetry.ts","../src/entities/project/model/project.ts","../src/shared/lib/text-position.ts","../src/features/install-size/model/import-graph.ts","../src/features/install-size/model/installed-closure.ts","../src/features/install-size/model/install-size.ts","../src/features/overrides/model/override-findings.ts","../src/features/overrides/model/override-resolution.ts","../src/features/overrides/model/overrides.ts","../src/features/placement/model/colocated-tests.ts","../src/features/placement/model/nested-docs.ts","../src/features/placement/model/root-readme.ts","../src/features/placement/model/placement-checks.ts","../src/features/repository-layout/model/crates.ts","../src/features/repository-layout/model/hidden-verify.ts","../src/features/repository-layout/model/root-workspace-paths.ts","../src/features/repository-layout/model/shared-uncached-tasks.ts","../src/features/repository-layout/model/workspace-checks.ts","../src/features/value-owners/model/slots.ts","../src/features/value-owners/model/flows.ts","../src/features/value-owners/model/owners.ts","../src/features/value-owners/model/derivation.ts","../src/features/value-owners/model/shapes.ts","../src/features/value-owners/model/sites.ts","../src/features/value-owners/model/value-checks.ts","../src/features/value-owners/model/analysis.ts","../src/features/value-owners/model/duplicates.ts","../src/features/value-owners/model/check.ts","../src/features/comments/model/found-comment.ts","../src/features/comments/model/config-comments.ts","../src/features/comments/model/comment-readers.ts","../src/features/comments/model/comments.ts","../src/features/invisible-characters/model/hidden-unicode.ts","../src/shared/lib/scanned-files.ts","../src/features/python/model/python.ts","../src/features/unneeded-files/model/unneeded-files.ts","../src/app/tracked-text.ts","../src/app/all-checks.ts","../src/app/output.ts","../src/app/runtime.ts","../src/app/cli.ts"],"sourcesContent":["import { Array as Arr, Function as Fn, Option, pipe } from \"effect\";\n\nimport { IndexKind } from \"./compiler.ts\";\nimport type { Checker, Type } from \"./compiler.ts\";\n\nexport type Value = string | number;\n\nexport interface Vocabulary {\n readonly values: readonly Value[];\n readonly admitsUnnamedValues: boolean;\n}\n\nconst SCHEMA_TYPE_PROPERTIES = [\"Type\", \"_output\"] as const;\n\nconst MINIMUM_SET_SIZE = 2;\n\nconst DATA_FIRST_ARITY = 2;\n\nexport const valueKey = (value: Value): string => `${typeof value}:${String(value)}`;\n\nconst literalValueOf = (type: Type): Option.Option<Value> => {\n if (type.isStringLiteralType() || type.isNumberLiteralType()) {\n return Option.some(type.value);\n }\n return Option.none();\n};\n\nexport const literalValuesOf = (types: readonly Type[]): Option.Option<readonly Value[]> => {\n const values = pipe(\n types,\n Arr.map((member) => literalValueOf(member)),\n Arr.getSomes,\n Arr.dedupeWith((left, right) => valueKey(left) === valueKey(right)),\n );\n if (values.length !== types.length || values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some(values);\n};\n\nexport const literalUnionOf = (type: Type): Option.Option<readonly Value[]> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n return literalValuesOf(type.getTypes());\n};\n\nconst elementTypeOf = (checker: Checker, type: Type): Option.Option<Type> => {\n if (!checker.isArrayLikeType(type)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(checker.getIndexTypeOfType(type, IndexKind.Number));\n};\n\nexport const schemaTypeOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Type> =>\n Arr.findFirst(SCHEMA_TYPE_PROPERTIES, (name) =>\n Option.fromUndefinedOr(checker.getPropertyOfType(type, name)),\n ).pipe(Option.map((property) => checker.getTypeOfSymbol(property)));\n\nexport const finiteValuesOf =\n (checker: Checker) =>\n (type: Type): Option.Option<readonly Value[]> =>\n literalUnionOf(type).pipe(\n Option.orElse(() => elementTypeOf(checker, type).pipe(Option.flatMap(literalUnionOf))),\n Option.orElse(() => schemaTypeOf(checker)(type).pipe(Option.flatMap(literalUnionOf))),\n );\n\nexport const vocabularyOf =\n (checker: Checker) =>\n (type: Type): Option.Option<Vocabulary> => {\n if (!type.isUnionType()) {\n return Option.none();\n }\n const optionalIds = new Set([checker.getUndefinedType().id, checker.getNullType().id]);\n const members = pipe(\n type.getTypes(),\n Arr.filter((member) => !optionalIds.has(member.id)),\n );\n const values = Arr.getSomes(\n pipe(\n members,\n Arr.map((member) => literalValueOf(member)),\n ),\n );\n if (values.length < MINIMUM_SET_SIZE) {\n return Option.none();\n }\n return Option.some({ values, admitsUnnamedValues: values.length !== members.length });\n };\n\nexport const isSubsetOf: {\n (superset: readonly Value[]): (subset: readonly Value[]) => boolean;\n (subset: readonly Value[], superset: readonly Value[]): boolean;\n} = Fn.dual(DATA_FIRST_ARITY, (subset: readonly Value[], superset: readonly Value[]): boolean => {\n const held = new Set(\n pipe(\n superset,\n Arr.map((value) => valueKey(value)),\n ),\n );\n return pipe(\n subset,\n Arr.every((value) => held.has(valueKey(value))),\n );\n});\n\nexport const sameValues: {\n (right: readonly Value[]): (left: readonly Value[]) => boolean;\n (left: readonly Value[], right: readonly Value[]): boolean;\n} = Fn.dual(\n DATA_FIRST_ARITY,\n (left: readonly Value[], right: readonly Value[]): boolean =>\n left.length === right.length && isSubsetOf(left, right),\n);\n\nconst valueText = (value: Value): string => {\n if (typeof value === \"string\") {\n return `\"${value}\"`;\n }\n return String(value);\n};\n\nexport const formatValues = (values: readonly Value[]): string =>\n pipe(values, Arr.map(valueText), Arr.join(\" | \"));\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport type { DependencyEntry } from \"#/entities/package/@x/project.ts\";\nimport {\n InternalSymbolName,\n isModuleDeclaration,\n isVariableDeclaration,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Node,\n SyntaxKind,\n TypeSymbol,\n Type,\n} from \"#/shared/lib/compiler.ts\";\nimport {\n declarationsOf,\n isGenericDeclaration,\n isTypeDeclaration,\n propertyNamesOf,\n resolvedSymbol,\n} from \"#/shared/lib/syntax.ts\";\nimport { schemaTypeOf, vocabularyOf } from \"#/shared/lib/values.ts\";\nimport type { Vocabulary } from \"#/shared/lib/values.ts\";\n\nexport interface LibraryType {\n readonly specifier: string;\n readonly typeName: string;\n}\n\nexport interface LibraryVocabulary extends LibraryType {\n readonly vocabulary: Vocabulary;\n}\n\nexport interface DeclarationLocation {\n readonly file: string;\n readonly pos: number;\n readonly kind: SyntaxKind;\n}\n\nexport interface LibraryShape extends LibraryType {\n readonly form: \"declared\" | \"schema\";\n readonly declaration: DeclarationLocation;\n readonly propertyNames: readonly string[];\n}\n\nexport interface LibraryIndex {\n readonly vocabularies: readonly LibraryVocabulary[];\n readonly shapes: readonly LibraryShape[];\n}\n\ninterface Walk {\n readonly checker: Checker;\n readonly entry: DependencyEntry;\n}\n\ninterface Visit {\n readonly exported: TypeSymbol;\n readonly qualifier: string;\n readonly ancestors: readonly TypeSymbol[];\n}\n\ninterface Exported {\n readonly symbol: TypeSymbol;\n readonly typeName: string;\n}\n\nconst NAMESPACE_DEPTH_LIMIT = 8;\nconst EMPTY_INDEX: LibraryIndex = { vocabularies: [], shapes: [] };\n\nexport const isObjectType =\n (checker: Checker) =>\n (type: Type): boolean =>\n !type.isUnionType() &&\n !type.isLiteralType() &&\n checker.getApparentType(type).id === type.id &&\n Arr.isReadonlyArrayNonEmpty(checker.getPropertiesOfType(type));\n\nexport const describeLibraryType = (type: LibraryType): string =>\n `${type.typeName} from ${type.specifier}`;\n\nexport const locationOf = (declaration: Node): DeclarationLocation => ({\n file: declaration.getSourceFile().fileName,\n pos: declaration.pos,\n kind: declaration.kind,\n});\n\nexport const declarationKey = (location: DeclarationLocation): string =>\n `${location.file}#${String(location.pos)}#${String(location.kind)}`;\n\ntype ShapeSource = LibraryType & Pick<LibraryShape, \"form\">;\n\nconst shapeOf =\n (checker: Checker) =>\n (source: ShapeSource, declaration: Declaration, type: Type): readonly LibraryShape[] =>\n Arr.filter(\n [\n {\n ...source,\n declaration: locationOf(declaration),\n propertyNames: propertyNamesOf(checker)(type),\n },\n ],\n () => isObjectType(checker)(type),\n );\n\nconst declaredTypeIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isTypeDeclaration);\n if (Option.isNone(declaration) || isGenericDeclaration(declaration.value)) {\n return EMPTY_INDEX;\n }\n const located = { specifier: walk.entry.specifier, typeName: exported.typeName };\n const type = walk.checker.getDeclaredTypeOfSymbol(exported.symbol);\n const vocabularies = vocabularyOf(walk.checker)(type).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n );\n const shapes = shapeOf(walk.checker)({ ...located, form: \"declared\" }, declaration.value, type);\n return { vocabularies, shapes };\n};\n\nconst schemaTypeIndex =\n (walk: Walk, located: LibraryType) =>\n (declaration: Declaration, schemaType: Type): LibraryIndex => ({\n vocabularies: vocabularyOf(walk.checker)(schemaType).pipe(\n Option.map((vocabulary) => ({ ...located, vocabulary })),\n Option.toArray,\n ),\n shapes: shapeOf(walk.checker)({ ...located, form: \"schema\" }, declaration, schemaType),\n });\n\nconst schemaValueIndex = (walk: Walk, exported: Exported): LibraryIndex => {\n const declaration = Arr.findFirst(declarationsOf(exported.symbol), isVariableDeclaration);\n if (Option.isNone(declaration)) {\n return EMPTY_INDEX;\n }\n const valueType = walk.checker.getTypeOfSymbolAtLocation(exported.symbol, declaration.value);\n const located = {\n specifier: walk.entry.specifier,\n typeName: `(typeof ${exported.typeName})[\"Type\"]`,\n };\n return Option.match(schemaTypeOf(walk.checker)(valueType), {\n onNone: () => EMPTY_INDEX,\n onSome: (schemaType) => schemaTypeIndex(walk, located)(declaration.value, schemaType),\n });\n};\n\nconst mergeIndexes = (indexes: readonly LibraryIndex[]): LibraryIndex => ({\n vocabularies: pipe(\n indexes,\n Arr.flatMap((index) => index.vocabularies),\n ),\n shapes: pipe(\n indexes,\n Arr.flatMap((index) => index.shapes),\n ),\n});\n\nconst isNamespace = (symbol: TypeSymbol): boolean =>\n pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isModuleDeclaration(declaration)),\n );\n\nconst indexUnder = (walk: Walk, visit: Visit): LibraryIndex => {\n const symbol = resolvedSymbol(walk.checker)(visit.exported);\n const named = { symbol, typeName: `${visit.qualifier}${visit.exported.name}` };\n const own = mergeIndexes([declaredTypeIndex(walk, named), schemaValueIndex(walk, named)]);\n if (\n !isNamespace(symbol) ||\n visit.ancestors.length >= NAMESPACE_DEPTH_LIMIT ||\n visit.ancestors.includes(symbol)\n ) {\n return own;\n }\n const nested = pipe(\n walk.checker.getExportsOfModule(symbol),\n Arr.map((member) =>\n indexUnder(walk, {\n exported: member,\n qualifier: `${named.typeName}.`,\n ancestors: [...visit.ancestors, symbol],\n }),\n ),\n );\n return mergeIndexes([own, ...nested]);\n};\n\nconst exportAssignmentOf = (moduleSymbol: TypeSymbol): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(moduleSymbol.getExports().get(InternalSymbolName.ExportEquals));\n\nconst indexOfEntry =\n (checker: Checker) =>\n (entry: DependencyEntry): LibraryIndex => {\n const moduleSymbol = Option.fromUndefinedOr(\n checker.getSymbolOfSourceFile(entry.declarationsPath),\n );\n if (Option.isNone(moduleSymbol)) {\n return EMPTY_INDEX;\n }\n const walk: Walk = { checker, entry };\n const roots = Option.match(exportAssignmentOf(moduleSymbol.value), {\n onNone: () => checker.getExportsOfModule(moduleSymbol.value),\n onSome: (assigned) => [resolvedSymbol(checker)(assigned)],\n });\n return mergeIndexes(\n pipe(\n roots,\n Arr.map((exported) => indexUnder(walk, { exported, qualifier: \"\", ancestors: [] })),\n ),\n );\n };\n\nexport interface CachedIndex {\n readonly index: LibraryIndex;\n readonly cached: boolean;\n}\n\nexport interface LibraryCache {\n readonly indexOf: (entry: DependencyEntry, compute: () => LibraryIndex) => CachedIndex;\n}\n\nexport const libraryCache = (): LibraryCache => {\n const indexes = new Map<string, LibraryIndex>();\n return {\n indexOf: (entry, compute) =>\n Option.match(Option.fromUndefinedOr(indexes.get(entry.declarationsPath)), {\n onSome: (index) => ({ index, cached: true }),\n onNone: () => {\n const index = compute();\n indexes.set(entry.declarationsPath, index);\n return { index, cached: false };\n },\n }),\n };\n};\n\nconst indexEntry =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entry: DependencyEntry): Effect.Effect<LibraryIndex> =>\n Effect.sync(() => cache.indexOf(entry, () => indexOfEntry(checker)(entry))).pipe(\n Effect.tap(({ index, cached }) =>\n Effect.annotateCurrentSpan({\n \"msch.library.cached\": cached,\n \"msch.library.vocabularies\": index.vocabularies.length,\n \"msch.library.shapes\": index.shapes.length,\n }),\n ),\n Effect.map(({ index }) => index),\n Effect.withSpan(\"indexLibraryEntry\", {\n attributes: { \"msch.library.specifier\": entry.specifier },\n }),\n );\n\nexport const libraryIndex =\n (cache: LibraryCache) =>\n (checker: Checker) =>\n (entries: readonly DependencyEntry[]): Effect.Effect<LibraryIndex> =>\n pipe(\n entries,\n Effect.forEach(indexEntry(cache)(checker)),\n Effect.map(mergeIndexes),\n Effect.withSpan(\"libraryIndex\"),\n );\n","import { Array as Arr, Effect, Number as Num, Option, String as Str, pipe } from \"effect\";\n\nimport type { API } from \"#/shared/lib/compiler.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RSS_LINE = /^VmRSS:\\s+(?<kib>\\d+) kB$/mu;\nconst BYTES_PER_KIB = 1024;\nconst UNKNOWN_RSS = 0;\n\nconst kibibytesIn = (status: string): Option.Option<string> =>\n Option.fromNullishOr(RSS_LINE.exec(status)).pipe(\n Option.flatMap((match) => Option.fromUndefinedOr(match.groups)),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[\"kib\"])),\n );\n\nconst residentBytesOf = (pid: string): Effect.Effect<number, never, RepositoryFiles> =>\n Effect.gen(function* residentBytes() {\n const files = yield* RepositoryFiles;\n const status = yield* files.readFile(`/proc/${pid}/status`);\n return pipe(\n status,\n Option.flatMap(kibibytesIn),\n Option.flatMap(Num.parse),\n Option.map((kib) => kib * BYTES_PER_KIB),\n Option.getOrElse(() => UNKNOWN_RSS),\n );\n });\n\nconst childPids = Effect.gen(function* childPids() {\n const files = yield* RepositoryFiles;\n const pid = String(process.pid);\n const children = yield* files.readFile(`/proc/${pid}/task/${pid}/children`);\n return pipe(\n children,\n Option.map((text) => pipe(Str.trim(text), Str.split(\" \"), Arr.filter(Str.isNonEmpty))),\n Option.getOrElse((): readonly string[] => []),\n );\n});\n\nconst annotateMemory = Effect.gen(function* annotateMemory() {\n const own = yield* residentBytesOf(String(process.pid));\n const pids = yield* childPids;\n const children = yield* pipe(\n pids,\n Effect.forEach((pid) => residentBytesOf(pid)),\n );\n const { heapUsed } = process.memoryUsage();\n yield* Effect.annotateCurrentSpan({\n \"process.memory.rss\": own,\n \"process.memory.heap_used\": heapUsed,\n \"msch.compiler.memory.rss\": Num.sumAll(children),\n });\n});\n\nexport const annotateResources = (api: API): Effect.Effect<void, never, RepositoryFiles> =>\n Effect.gen(function* annotateCompiler() {\n yield* annotateMemory;\n const { totals } = api.getTimingInfo();\n yield* Effect.annotateCurrentSpan({\n \"msch.compiler.requests\": totals.requestCount,\n \"msch.compiler.round_trip_ms\": totals.roundTripMs,\n \"msch.compiler.server_ms\": totals.serverTimeMs,\n });\n });\n","import { Array as Arr, Effect, Option, Order, String as Str, pipe } from \"effect\";\n\nimport {\n MANIFEST_FILE,\n dependencyEntries,\n readManifest,\n workspaceDependencies,\n} from \"#/entities/package/@x/project.ts\";\nimport { API, getLeadingCommentRanges } from \"#/shared/lib/compiler.ts\";\nimport type { Checker, ParsedCommandLine, Program, SourceFile } from \"#/shared/lib/compiler.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { libraryCache, libraryIndex } from \"./library.ts\";\nimport type { LibraryCache, LibraryIndex } from \"./library.ts\";\nimport { annotateResources } from \"./telemetry.ts\";\n\nexport interface Project {\n readonly packageName: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n readonly program: Program;\n readonly checker: Checker;\n readonly sourceFiles: readonly SourceFile[];\n readonly library: LibraryIndex;\n}\n\ninterface PackageInfo {\n readonly directory: string;\n readonly name: Option.Option<string>;\n readonly workspaceDependencies: readonly string[];\n}\n\nconst CONFIG_FILE = \"tsconfig.json\";\nconst CONFIG_PATHSPEC = `:(glob)**/${CONFIG_FILE}`;\nconst HIDDEN_PREFIX = \".\";\nconst SKIPPED_DIRECTORIES: ReadonlySet<string> = new Set([NODE_MODULES, \"dist\", \"coverage\"]);\n\nconst isVisible = (file: string): boolean =>\n pipe(\n Str.split(file, \"/\"),\n Arr.every(\n (segment) => !Str.startsWith(HIDDEN_PREFIX)(segment) && !SKIPPED_DIRECTORIES.has(segment),\n ),\n );\n\nexport const listConfigFiles = (\n root: string,\n): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* configFilesUnder() {\n const files = yield* RepositoryFiles;\n const listed = yield* files.matchingFiles(root, [CONFIG_PATHSPEC]);\n const visible = pipe(\n listed,\n Arr.filter(isVisible),\n Arr.map((file) => files.join(root, file)),\n );\n return Arr.sort(visible, Order.String);\n });\n\nconst parseConfig =\n (api: API) =>\n (configPath: string): Option.Option<ParsedCommandLine> =>\n Option.some(api.parseConfigFile(configPath)).pipe(\n Option.filter((parsed) => Arr.isReadonlyArrayNonEmpty(parsed.fileNames)),\n );\n\nconst nearestPackageDirectory = (\n directory: string,\n root: string,\n): Effect.Effect<string, never, RepositoryFiles> =>\n Effect.gen(function* nearestPackage() {\n const files = yield* RepositoryFiles;\n const hasManifest = yield* files.exists(files.join(directory, MANIFEST_FILE));\n const parent = files.dirname(directory);\n if (hasManifest || directory === root || parent === directory) {\n return directory;\n }\n return yield* nearestPackageDirectory(parent, root);\n });\n\nconst packageInfoOf = Effect.fn(\"packageInfoOf\")(function* packageInfoOf(\n configPath: string,\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const directory = yield* nearestPackageDirectory(files.dirname(configPath), root);\n const manifest = yield* readManifest(directory);\n return {\n directory,\n name: manifest.pipe(Option.flatMap((found) => Option.fromUndefinedOr(found.name))),\n workspaceDependencies: manifest.pipe(\n Option.map(workspaceDependencies),\n Option.getOrElse(() => []),\n ),\n } satisfies PackageInfo;\n});\n\nconst NO_CHECK_PRAGMA = /^\\/\\/\\s*@ts-nocheck/u;\nconst FILE_START = 0;\n\nconst skipsTypeChecking = (sourceFile: SourceFile): boolean =>\n pipe(\n getLeadingCommentRanges(sourceFile.text, FILE_START) ?? [],\n Arr.some((range) => NO_CHECK_PRAGMA.test(Str.slice(range.pos, range.end)(sourceFile.text))),\n );\n\nconst buildProject = Effect.fn(\"buildProject\")(function* buildProject(\n { compiler: { api, libraries }, generated }: Workspace,\n parsed: ParsedCommandLine,\n info: PackageInfo,\n) {\n const entries = yield* dependencyEntries(info.directory);\n const program = yield* Effect.sync(() =>\n api.createProgram(\n [\n ...parsed.fileNames,\n ...pipe(\n entries,\n Arr.map((entry) => entry.declarationsPath),\n ),\n ],\n { ...parsed.options, noEmit: true },\n ),\n ).pipe(Effect.withSpan(\"createProgram\"));\n const { checker } = program.getProject();\n const library = yield* libraryIndex(libraries)(checker)(entries);\n const projectFiles: ReadonlySet<string> = new Set(\n pipe(\n parsed.fileNames,\n Arr.filter((fileName) => !generated.includes(fileName)),\n ),\n );\n return {\n packageName: info.name,\n workspaceDependencies: info.workspaceDependencies,\n program,\n checker,\n sourceFiles: pipe(\n program.getSourceFileNames(),\n Arr.filter((fileName) => projectFiles.has(fileName)),\n Arr.flatMap((fileName) =>\n Option.toArray(Option.fromUndefinedOr(program.getSourceFile(fileName))),\n ),\n Arr.filter((sourceFile) => !sourceFile.isDeclarationFile && !skipsTypeChecking(sourceFile)),\n ),\n library,\n } satisfies Project;\n});\n\nexport interface Compiler {\n readonly api: API;\n readonly libraries: LibraryCache;\n}\n\nexport interface Workspace {\n readonly compiler: Compiler;\n readonly root: string;\n readonly generated: readonly string[];\n}\n\nexport const typeScriptCompiler = Effect.acquireRelease(\n Effect.sync((): Compiler => ({\n api: new API({ collectTiming: true }),\n libraries: libraryCache(),\n })),\n ({ api }) =>\n Effect.sync(() => {\n api.close();\n }),\n);\n\nconst loadProject = Effect.fn(\"loadProject\")(function* loadProject(\n workspace: Workspace,\n configPath: string,\n) {\n const { compiler, root } = workspace;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none<Project>();\n }\n const info = yield* packageInfoOf(configPath, root);\n const project = yield* buildProject(workspace, parsed.value, info);\n yield* Effect.annotateCurrentSpan({\n \"msch.project.config\": configPath,\n \"msch.project.program_files\": project.program.getSourceFileNames().length,\n \"msch.project.source_files\": project.sourceFiles.length,\n });\n yield* annotateResources(compiler.api);\n return Option.some(project);\n});\n\nconst releaseProject = (project: Project): Effect.Effect<void> =>\n Effect.sync(() => {\n project.program.dispose();\n });\n\nexport const withProject =\n (workspace: Workspace) =>\n (configPath: string) =>\n <Value, Failure, Requirements>(\n work: (project: Project) => Effect.Effect<Value, Failure, Requirements>,\n ): Effect.Effect<Option.Option<Value>, Failure, Requirements | RepositoryFiles> =>\n Effect.acquireUseRelease(\n loadProject(workspace, configPath),\n (loaded) =>\n Option.match(loaded, {\n onNone: () => Effect.succeedNone,\n onSome: (project) => work(project).pipe(Effect.asSome),\n }),\n (loaded) => Option.match(loaded, { onNone: () => Effect.void, onSome: releaseProject }),\n );\n\nexport const mentions =\n (needle: string) =>\n ({ api }: Compiler) =>\n (configPath: string): Effect.Effect<boolean, never, RepositoryFiles> =>\n Effect.gen(function* mentionsNeedle() {\n const files = yield* RepositoryFiles;\n const fileNames = Option.match(parseConfig(api)(configPath), {\n onNone: (): readonly string[] => [],\n onSome: (parsed): readonly string[] => parsed.fileNames,\n });\n const texts = yield* pipe(\n fileNames,\n Effect.forEach((fileName) => files.readFile(fileName)),\n );\n const includesNeedle = Str.includes(needle);\n return pipe(\n texts,\n Arr.some((text) => Option.exists(text, includesNeedle)),\n );\n });\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport type { Problem } from \"./problem.ts\";\n\nconst START = 0;\nconst FIRST_COLUMN = 1;\n\nexport const positionOf =\n (source: string) =>\n (index: number): Pick<Problem, \"line\" | \"column\"> => {\n const before = pipe(source, Str.slice(START, index), Str.split(\"\\n\"));\n return {\n line: before.length,\n column: pipe(\n Arr.last(before),\n Option.match({ onNone: () => FIRST_COLUMN, onSome: (last) => last.length + FIRST_COLUMN }),\n ),\n };\n };\n","import {\n Array as Arr,\n Effect,\n HashSet,\n Option,\n Record as Rec,\n Result,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { MANIFEST_FILE } from \"#/entities/package/index.ts\";\nimport {\n SyntaxKind,\n isExportDeclaration,\n isImportDeclaration,\n isStringLiteral,\n} from \"#/shared/lib/compiler.ts\";\nimport type { API, Node } from \"#/shared/lib/compiler.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RELATIVE = /^\\.\\.?(?:\\/|$)/u;\nconst SUBPATH_IMPORT = \"#\";\nconst WILDCARD = \"*\";\nconst SCOPE = \"@\";\nconst SEPARATOR = \"/\";\nconst SOURCE_SUFFIXES = [\"\", \".ts\", \".tsx\", \"/index.ts\"] as const;\nconst SCOPED_SEGMENTS = 2;\nconst PLAIN_SEGMENTS = 1;\n\nconst ImportsField = Schema.Struct({\n imports: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n});\n\nconst decodeImports = Schema.decodeOption(Schema.fromJsonString(ImportsField));\n\ninterface Graph {\n readonly api: API;\n readonly directory: string;\n readonly imports: Readonly<Record<string, string>>;\n}\n\ninterface Walk {\n readonly pending: readonly string[];\n readonly visited: HashSet.HashSet<string>;\n readonly packages: HashSet.HashSet<string>;\n}\n\ntype Reference = Result.Result<string, string>;\n\nconst packageNameOf = (specifier: string): string => {\n const segments = Str.split(specifier, SEPARATOR);\n if (Str.startsWith(SCOPE)(specifier)) {\n return pipe(segments, Arr.take(SCOPED_SEGMENTS), Arr.join(SEPARATOR));\n }\n return pipe(segments, Arr.take(PLAIN_SEGMENTS), Arr.join(SEPARATOR));\n};\n\nconst literalText = (specifier: Node): Option.Option<string> =>\n pipe(\n Option.liftPredicate(specifier, isStringLiteral),\n Option.map((literal) => literal.text),\n );\n\nconst runtimeSpecifierOf = (statement: Node): Option.Option<string> => {\n if (isImportDeclaration(statement)) {\n const typeOnly = pipe(\n Option.fromUndefinedOr(statement.importClause),\n Option.exists((clause) => clause.phaseModifier === SyntaxKind.TypeKeyword),\n );\n return Option.filter(literalText(statement.moduleSpecifier), () => !typeOnly);\n }\n if (isExportDeclaration(statement) && !statement.isTypeOnly) {\n return Option.flatMap(Option.fromUndefinedOr(statement.moduleSpecifier), literalText);\n }\n return Option.none();\n};\n\nconst specifiersIn = (api: API, file: string, text: string): readonly string[] => {\n const retained = api.createSourceFile(file, text);\n const found = pipe(retained.sourceFile.statements, Arr.fromIterable, Arr.map(runtimeSpecifierOf));\n retained.dispose();\n return Arr.getSomes(found);\n};\n\nconst subpathTarget = (\n imports: Readonly<Record<string, string>>,\n specifier: string,\n): Option.Option<string> =>\n pipe(\n Rec.toEntries(imports),\n Arr.findFirst(([pattern, target]) => {\n if (!Str.endsWith(WILDCARD)(pattern)) {\n return Option.liftPredicate(target, () => pattern === specifier);\n }\n const prefix = Str.replace(WILDCARD, \"\")(pattern);\n return Option.liftPredicate(\n Str.replace(WILDCARD, Str.replace(prefix, \"\")(specifier))(target),\n () => Str.startsWith(prefix)(specifier),\n );\n }),\n );\n\nconst existingSource = Effect.fn(\"existingSource\")(function* existingSource(base: string) {\n const files = yield* RepositoryFiles;\n const found = yield* pipe(\n SOURCE_SUFFIXES,\n Effect.forEach((suffix) => {\n const candidate = `${base}${suffix}`;\n return files\n .isDirectory(candidate)\n .pipe(\n Effect.map((directory) =>\n Option.liftPredicate(candidate, () =>\n Option.exists(directory, (isDirectory) => !isDirectory),\n ),\n ),\n );\n }),\n );\n return Arr.head(Arr.getSomes(found));\n});\n\nconst localFile = Effect.fn(\"localFile\")(function* localFile(\n { directory, imports }: Graph,\n from: string,\n specifier: string,\n) {\n const files = yield* RepositoryFiles;\n if (RELATIVE.test(specifier)) {\n return yield* existingSource(files.resolve(files.dirname(from), specifier));\n }\n const target = subpathTarget(imports, specifier);\n if (Option.isNone(target)) {\n return Option.none<string>();\n }\n return yield* existingSource(files.resolve(directory, target.value));\n});\n\nconst referenceOf = (\n graph: Graph,\n from: string,\n specifier: string,\n): Effect.Effect<Option.Option<Reference>, never, RepositoryFiles> => {\n if (RELATIVE.test(specifier) || Str.startsWith(SUBPATH_IMPORT)(specifier)) {\n return localFile(graph, from, specifier).pipe(Effect.map(Option.map(Result.succeed)));\n }\n const name = packageNameOf(specifier);\n return Effect.succeedSome(Result.fail(name));\n};\n\nconst referencesIn = Effect.fn(\"referencesIn\")(function* referencesIn(graph: Graph, file: string) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(file);\n const specifiers = Option.match(text, {\n onNone: (): readonly string[] => [],\n onSome: (source) => specifiersIn(graph.api, file, source),\n });\n const references = yield* pipe(\n specifiers,\n Effect.forEach((specifier) => referenceOf(graph, file, specifier)),\n );\n const found = Arr.getSomes(references);\n return { packages: Arr.getFailures(found), sources: Arr.getSuccesses(found) };\n});\n\nconst packagesFrom = (\n graph: Graph,\n walk: Walk,\n): Effect.Effect<HashSet.HashSet<string>, never, RepositoryFiles> =>\n Arr.match(walk.pending, {\n onEmpty: () => Effect.succeed(walk.packages),\n onNonEmpty: ([next, ...rest]) => {\n if (HashSet.has(walk.visited, next)) {\n return packagesFrom(graph, { ...walk, pending: rest });\n }\n return referencesIn(graph, next).pipe(\n Effect.flatMap(({ packages, sources }) =>\n packagesFrom(graph, {\n pending: [...rest, ...sources],\n visited: HashSet.add(walk.visited, next),\n packages: HashSet.union(walk.packages, HashSet.fromIterable(packages)),\n }),\n ),\n );\n },\n });\n\n/** @internal */\nexport const packagesByEntry = Effect.fn(\"packagesByEntry\")(function* packagesByEntry(\n api: API,\n directory: string,\n entries: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const manifest = yield* files.readFile(files.join(directory, MANIFEST_FILE));\n const imports = pipe(\n manifest,\n Option.flatMap(decodeImports),\n Option.flatMap((field) => Option.fromUndefinedOr(field.imports)),\n Option.getOrElse((): Readonly<Record<string, string>> => ({})),\n );\n const graph: Graph = { api, directory, imports };\n return yield* pipe(\n entries,\n Effect.forEach((entry) =>\n packagesFrom(graph, {\n pending: [entry],\n visited: HashSet.empty(),\n packages: HashSet.empty(),\n }).pipe(Effect.map((packages) => [entry, packages] as const)),\n ),\n );\n});\n","import {\n Array as Arr,\n Effect,\n HashSet,\n Number as Num,\n Option,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { MANIFEST_FILE } from \"#/entities/package/index.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst EMPTY = 0;\n\nconst DependencyMap = Schema.optional(Schema.Record(Schema.String, Schema.String));\nconst PeerMetaEntry = Schema.Struct({ optional: Schema.optional(Schema.Boolean) });\nconst PeerMeta = Schema.optional(Schema.Record(Schema.String, PeerMetaEntry));\nconst InstalledManifest = Schema.Struct({\n dependencies: DependencyMap,\n optionalDependencies: DependencyMap,\n peerDependencies: DependencyMap,\n peerDependenciesMeta: PeerMeta,\n});\ntype Installed = typeof InstalledManifest.Type;\n\ntype Pending = readonly (readonly [string, string])[];\n\ninterface Collect {\n readonly pending: Pending;\n readonly seen: HashSet.HashSet<string>;\n}\n\nconst decodeManifest = Schema.decodeOption(Schema.fromJsonString(InstalledManifest));\n\nexport const keysOf = (map: Readonly<Record<string, string>> | undefined): readonly string[] =>\n pipe(\n Option.fromUndefinedOr(map),\n Option.map(Rec.keys),\n Option.getOrElse((): readonly string[] => []),\n );\n\nconst isOptionalPeer = (manifest: Installed, name: string): boolean =>\n pipe(\n Option.fromUndefinedOr(manifest.peerDependenciesMeta),\n Option.flatMap(Rec.get(name)),\n Option.exists((meta) => meta.optional === true),\n );\n\nconst installedNames = (manifest: Installed): readonly string[] => [\n ...keysOf(manifest.dependencies),\n ...keysOf(manifest.optionalDependencies),\n ...pipe(\n keysOf(manifest.peerDependencies),\n Arr.filter((name) => !isOptionalPeer(manifest, name)),\n ),\n];\n\nconst childrenOf = Effect.fn(\"childrenOf\")(function* childrenOf(directory: string) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(files.join(directory, MANIFEST_FILE));\n return pipe(\n text,\n Option.flatMap(decodeManifest),\n Option.map(installedNames),\n Option.getOrElse((): readonly string[] => []),\n Arr.map((child) => [directory, child] as const),\n );\n});\n\nconst resolveFrom = (\n from: string,\n name: string,\n): Effect.Effect<Option.Option<string>, never, RepositoryFiles> =>\n Effect.gen(function* resolvePackage() {\n const files = yield* RepositoryFiles;\n const candidate = files.join(from, NODE_MODULES, name);\n const found = yield* files.exists(files.join(candidate, MANIFEST_FILE));\n if (found) {\n const real = yield* files.realPath(candidate);\n return Option.some(real);\n }\n const parent = files.dirname(from);\n if (parent === from) {\n return Option.none<string>();\n }\n return yield* resolveFrom(parent, name);\n });\n\nconst unseen = (\n from: string,\n name: string,\n seen: HashSet.HashSet<string>,\n): Effect.Effect<Option.Option<string>, never, RepositoryFiles> =>\n resolveFrom(from, name).pipe(\n Effect.map(Option.filter((directory) => !HashSet.has(seen, directory))),\n );\n\nconst closureOf = (\n provided: HashSet.HashSet<string>,\n collect: Collect,\n): Effect.Effect<HashSet.HashSet<string>, never, RepositoryFiles> =>\n Arr.match(collect.pending, {\n onEmpty: () => Effect.succeed(collect.seen),\n onNonEmpty: ([[from, name], ...rest]) => {\n if (HashSet.has(provided, name)) {\n return closureOf(provided, { ...collect, pending: rest });\n }\n return unseen(from, name, collect.seen).pipe(\n Effect.flatMap((resolved) => {\n if (Option.isNone(resolved)) {\n return closureOf(provided, { ...collect, pending: rest });\n }\n return childrenOf(resolved.value).pipe(\n Effect.flatMap((children) =>\n closureOf(provided, {\n pending: [...rest, ...children],\n seen: HashSet.add(collect.seen, resolved.value),\n }),\n ),\n );\n }),\n );\n },\n });\n\nconst directorySize = (directory: string): Effect.Effect<number, never, RepositoryFiles> =>\n Effect.gen(function* sizeOfDirectory() {\n const files = yield* RepositoryFiles;\n const names = yield* files.readDirectory(directory);\n const entries = pipe(\n names,\n Arr.filter((name) => name !== NODE_MODULES),\n Arr.map((name) => files.join(directory, name)),\n );\n const sizes = yield* pipe(\n entries,\n Effect.forEach((entry) =>\n files.isDirectory(entry).pipe(\n Effect.flatMap((kind) => {\n if (Option.isNone(kind)) {\n return Effect.succeed(EMPTY);\n }\n if (kind.value) {\n return directorySize(entry);\n }\n return files.fileSize(entry);\n }),\n ),\n ),\n );\n return Num.sumAll(sizes);\n });\n\nexport interface ClosureRoot {\n readonly provided: HashSet.HashSet<string>;\n readonly from: string;\n readonly name: string;\n}\n\nexport const installedClosure = ({\n provided,\n from,\n name,\n}: ClosureRoot): Effect.Effect<HashSet.HashSet<string>, never, RepositoryFiles> =>\n closureOf(provided, { pending: [[from, name]], seen: HashSet.empty() });\n\nexport const installedSize = (directory: string): Effect.Effect<number, never, RepositoryFiles> => {\n if (Str.includes(`/${NODE_MODULES}/`)(directory)) {\n return directorySize(directory);\n }\n return Effect.succeed(EMPTY);\n};\n","import {\n Array as Arr,\n Effect,\n HashMap,\n HashSet,\n Number as Num,\n Option,\n Order,\n Record as Rec,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\n\nimport { MANIFEST_FILE, publicEntriesOf, publishedWorkspaces } from \"#/entities/package/index.ts\";\nimport type { PublicEntry, PublishedWorkspace } from \"#/entities/package/index.ts\";\nimport { typeScriptCompiler } from \"#/entities/project/index.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nimport { packagesByEntry } from \"./import-graph.ts\";\nimport { installedClosure, installedSize, keysOf } from \"./installed-closure.ts\";\n\nconst INSTALL_SIZE: RuleName = \"install-size\";\nconst STACK_DEPENDENCY: RuleName = \"stack-dependency\";\nconst STACK_CATALOG = \"catalog:stack\";\nconst BUDGET_KEY = \"installSize\";\nconst DEPENDENCIES_KEY = '\"dependencies\"';\nconst LISTED_LARGEST = 5;\nconst SIZE_CONCURRENCY = 32;\nconst MEGABYTE = 1_000_000;\nconst MEGABYTE_DIGITS = 1;\nconst START = 0;\nconst SINGLE_ENTRY = 1;\n\ninterface DependencySize {\n readonly name: string;\n readonly size: number;\n readonly entries: readonly string[];\n}\n\ninterface Published {\n readonly workspace: PublishedWorkspace;\n readonly entries: readonly PublicEntry[];\n readonly provided: HashSet.HashSet<string>;\n}\n\ninterface Measured {\n readonly closures: readonly (readonly [string, HashSet.HashSet<string>])[];\n readonly sizeOf: (packages: HashSet.HashSet<string>) => number;\n readonly total: number;\n}\n\ninterface Overrun {\n readonly workspace: PublishedWorkspace;\n readonly total: number;\n readonly largest: readonly DependencySize[];\n readonly entryCount: number;\n}\n\nconst megabytes = (bytes: number): string => `${(bytes / MEGABYTE).toFixed(MEGABYTE_DIGITS)} MB`;\n\nconst usageHint = (dependency: DependencySize, entryCount: number): string => {\n const partial =\n entryCount > SINGLE_ENTRY &&\n dependency.entries.length > START &&\n dependency.entries.length < entryCount;\n if (!partial) {\n return \"\";\n }\n return ` (imported only from ${Arr.join(dependency.entries, \", \")})`;\n};\n\nconst listed = ({ largest, entryCount }: Overrun): string =>\n pipe(\n largest,\n Arr.map(\n (dependency) =>\n `${dependency.name} ${megabytes(dependency.size)}${usageHint(dependency, entryCount)}`,\n ),\n Arr.join(\", \"),\n );\n\nconst budgetProblem = Effect.fn(\"budgetProblem\")(function* budgetProblem(overrun: Overrun) {\n const files = yield* RepositoryFiles;\n const { workspace, total } = overrun;\n const config = yield* files.readFile(workspace.configFile);\n const source = Option.getOrElse(config, () => \"\");\n const index = Option.getOrElse(Str.indexOf(BUDGET_KEY)(source), () => START);\n return {\n file: workspace.configFile,\n ...positionOf(source)(index),\n rule: INSTALL_SIZE,\n message: `installing this package adds ${megabytes(total)} of dependencies besides its peers, over the ${workspace.installSize} in msch.publish.installSize. Largest: ${listed(overrun)}. Make a dependency imported only from some entries an optional peer, move one that the installing project already has to peerDependencies, or replace a heavy one. Raise installSize only when none of these applies.`,\n } satisfies Problem;\n});\n\nconst measure = Effect.fn(\"measure\")(function* measure(\n { workspace, provided }: Published,\n direct: readonly string[],\n) {\n const closures = yield* pipe(\n direct,\n Effect.forEach((name) =>\n installedClosure({ provided, from: workspace.directory, name }).pipe(\n Effect.map((packages) => [name, packages] as const),\n ),\n ),\n );\n const everything = pipe(\n closures,\n Arr.flatMap(([, packages]) => Arr.fromIterable(packages)),\n HashSet.fromIterable,\n );\n const measured = yield* Effect.forEach(\n everything,\n (found) => installedSize(found).pipe(Effect.map((size) => [found, size] as const)),\n { concurrency: SIZE_CONCURRENCY },\n );\n const sizes = HashMap.fromIterable(measured);\n const sizeOf = (packages: HashSet.HashSet<string>): number =>\n Num.sumAll(\n pipe(\n Arr.fromIterable(packages),\n Arr.map((found) => Option.getOrElse(HashMap.get(sizes, found), () => START)),\n ),\n );\n return { closures, sizeOf, total: sizeOf(everything) } satisfies Measured;\n});\n\nconst importersOf = Effect.fn(\"importersOf\")(function* importersOf({\n workspace,\n entries,\n}: Published) {\n const compiler = yield* typeScriptCompiler;\n const sources = pipe(\n entries,\n Arr.map((entry) => entry.source),\n Arr.dedupe,\n );\n const byEntry = yield* packagesByEntry(compiler.api, workspace.directory, sources);\n const reached = HashMap.fromIterable(byEntry);\n return (name: string): readonly string[] =>\n pipe(\n entries,\n Arr.filter((entry) =>\n pipe(HashMap.get(reached, entry.source), Option.exists(HashSet.has(name))),\n ),\n Arr.map((entry) => entry.label),\n Arr.dedupe,\n );\n}, Effect.scoped);\n\nconst bySizeDescending = Order.mapInput(\n Order.flip(Order.Number),\n (dependency: DependencySize) => dependency.size,\n);\n\nconst sizeProblems = Effect.fn(\"sizeProblems\")(function* sizeProblems(\n published: Published,\n direct: readonly string[],\n) {\n const { closures, sizeOf, total } = yield* measure(published, direct);\n if (total <= published.workspace.installBudget) {\n return [];\n }\n const importers = yield* importersOf(published);\n const largest = pipe(\n closures,\n Arr.map(([name, packages]): DependencySize => ({\n name,\n size: sizeOf(packages),\n entries: importers(name),\n })),\n Arr.sortBy(bySizeDescending),\n Arr.take(LISTED_LARGEST),\n );\n const entryCount = pipe(\n published.entries,\n Arr.map((entry) => entry.label),\n Arr.dedupe,\n ).length;\n const problem = yield* budgetProblem({\n workspace: published.workspace,\n total,\n largest,\n entryCount,\n });\n return [problem];\n});\n\nconst stackProblems = (\n file: string,\n source: string,\n dependencies: Readonly<Record<string, string>>,\n): readonly Problem[] => {\n const section = Option.getOrElse(Str.indexOf(DEPENDENCIES_KEY)(source), () => START);\n const rest = Str.slice(section)(source);\n return pipe(\n Rec.toEntries(dependencies),\n Arr.filter(([, specifier]) => specifier === STACK_CATALOG),\n Arr.map(([name]): Problem => ({\n file,\n ...positionOf(source)(\n section + Option.getOrElse(Str.indexOf(`\"${name}\"`)(rest), () => START),\n ),\n rule: STACK_DEPENDENCY,\n message: `${name} comes from the stack catalog, so every project that installs this package already has it. Move it to peerDependencies and keep it in devDependencies, so the installing project shares one copy.`,\n })),\n );\n};\n\nconst PublishedManifest = Schema.Struct({\n name: Schema.optional(Schema.String),\n dependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n peerDependencies: Schema.optional(Schema.Record(Schema.String, Schema.String)),\n exports: Schema.optional(Schema.Unknown),\n bin: Schema.optional(Schema.Unknown),\n});\n\nconst problemsOf = Effect.fn(\"problemsOf\")(function* problemsOf(\n workspace: PublishedWorkspace,\n file: string,\n source: string,\n) {\n const files = yield* RepositoryFiles;\n const manifest = Schema.decodeOption(Schema.fromJsonString(PublishedManifest))(source);\n if (Option.isNone(manifest)) {\n return [];\n }\n const dependencies = Option.getOrElse(\n Option.fromUndefinedOr(manifest.value.dependencies),\n () => ({}),\n );\n const entries = publicEntriesOf({\n manifest: manifest.value,\n join: (target) => files.join(workspace.directory, target),\n packEntries: workspace.packEntries,\n });\n const provided = HashSet.fromIterable(keysOf(manifest.value.peerDependencies));\n const sized = yield* sizeProblems({ workspace, entries, provided }, Rec.keys(dependencies));\n return [...stackProblems(file, source, dependencies), ...sized];\n});\n\nconst workspaceProblems = Effect.fn(\"workspaceProblems\")(function* workspaceProblems(\n workspace: PublishedWorkspace,\n) {\n const files = yield* RepositoryFiles;\n const file = files.join(workspace.directory, MANIFEST_FILE);\n const source = yield* files.readFile(file);\n return yield* Option.match(source, {\n onNone: () => Effect.succeed<readonly Problem[]>([]),\n onSome: (text) => problemsOf(workspace, file, text),\n });\n});\n\n/** @internal */\nexport const checkPublishedPackages = Effect.fn(\"checkPublishedPackages\")(\n function* checkPublishedPackages(root: string) {\n const workspaces = yield* publishedWorkspaces(root);\n const found = yield* pipe(workspaces, Effect.forEach(workspaceProblems));\n return Arr.flatten(found);\n },\n);\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport type { Problem } from \"#/shared/lib/problem.ts\";\n\nimport type { OverrideKey, OverrideReport } from \"./override-resolution.ts\";\n\nconst describeVersions = (versions: readonly string[]): string =>\n Option.getOrElse(\n Option.liftPredicate(Arr.join(versions, \",\"), (joined) => joined !== \"\"),\n () => \"-\",\n );\n\nconst describeChanges = (report: OverrideReport): string => {\n const versions = pipe(\n report.changes,\n Arr.map(\n (change) =>\n `${change.name} ${describeVersions(change.before)} -> ${describeVersions(change.after)}`,\n ),\n );\n const contexts = Arr.filter([\"the peer contexts\"], () => report.peerContextsChanged);\n return Arr.join([...versions, ...contexts], \"; \");\n};\n\nexport interface LocatedOverride extends OverrideKey {\n readonly file: string;\n}\n\nexport const overrideProblem =\n (located: LocatedOverride) =>\n (report: OverrideReport): Option.Option<Problem> => {\n const at = { file: located.file, line: located.line, column: located.column };\n if (report.verdict === \"unused\") {\n return Option.some({\n ...at,\n rule: \"unused-override\",\n message: `Every package resolves the same way without the override ${report.key}. Remove it.`,\n });\n }\n if (report.verdict === \"verify\") {\n return Option.some({\n ...at,\n rule: \"removable-override\",\n message: `Removing the override ${report.key} changes ${describeChanges(report)} without new peer issues or advisories. Remove it and run verify.`,\n });\n }\n return Option.none();\n };\n","import { Array as Arr, Option, Order, Record as Rec, Schema, String as Str, pipe } from \"effect\";\nimport { LineCounter, isMap, isScalar, parseAllDocuments, parseDocument } from \"yaml\";\n\nconst VerdictSchema = Schema.Literals([\"unused\", \"keep\", \"verify\"]);\n\nconst PackageChangeSchema = Schema.Struct({\n name: Schema.String,\n before: Schema.Array(Schema.String),\n after: Schema.Array(Schema.String),\n});\n\nconst OverrideReportSchema = Schema.Struct({\n key: Schema.String,\n verdict: VerdictSchema,\n changes: Schema.Array(PackageChangeSchema),\n peerContextsChanged: Schema.Boolean,\n peerIssues: Schema.Array(Schema.String),\n advisories: Schema.Array(Schema.String),\n});\n\nexport type OverrideReport = typeof OverrideReportSchema.Type;\ntype PackageChange = typeof PackageChangeSchema.Type;\n\nconst PeerParentSchema = Schema.Struct({ name: Schema.String, version: Schema.String });\n\nconst PeerIssueSchema = Schema.Struct({\n parents: Schema.Array(PeerParentSchema),\n wantedRange: Schema.String,\n foundVersion: Schema.optionalKey(Schema.String),\n});\n\ntype PeerIssue = typeof PeerIssueSchema.Type;\n\nconst ProjectPeerIssuesSchema = Schema.Struct({\n bad: Schema.Record(Schema.String, Schema.Array(PeerIssueSchema)),\n missing: Schema.Record(Schema.String, Schema.Array(PeerIssueSchema)),\n conflicts: Schema.Array(Schema.String),\n});\n\ntype ProjectPeerIssues = typeof ProjectPeerIssuesSchema.Type;\n\nconst PeerIssuesLog = Schema.fromJsonString(\n Schema.Struct({\n name: Schema.Literal(\"pnpm:peer-dependency-issues\"),\n issuesByProjects: Schema.Record(Schema.String, ProjectPeerIssuesSchema),\n }),\n);\n\nexport interface Findings {\n readonly peerIssues: readonly string[];\n readonly advisories: readonly string[];\n}\n\nexport interface Resolution extends Findings {\n readonly versions: Readonly<Record<string, readonly string[]>>;\n readonly snapshots: readonly string[];\n}\n\nconst AdvisorySchema = Schema.Struct({\n module_name: Schema.String,\n github_advisory_id: Schema.String,\n});\n\nconst AuditReport = Schema.fromJsonString(\n Schema.Struct({ advisories: Schema.Record(Schema.String, AdvisorySchema) }),\n);\n\nconst SCOPE_PREFIX = \"@\";\nconst NAME_START = 0;\nconst SEPARATOR_LENGTH = 1;\nconst PEER_CONTEXT_START = \"(\";\n\nconst sorted = (values: readonly string[]): readonly string[] =>\n Arr.sort(Arr.dedupe(values), Order.String);\n\nconst describeIssue =\n (project: string, kind: string) =>\n ([peer, issues]: readonly [string, readonly PeerIssue[]]): readonly string[] =>\n pipe(\n issues,\n Arr.map((issue) => {\n const dependent = Option.match(Arr.last(issue.parents), {\n onNone: () => project,\n onSome: (parent) => `${parent.name}@${parent.version}`,\n });\n const found = Option.getOrElse(Option.fromUndefinedOr(issue.foundVersion), () => \"none\");\n return `${project}: ${kind} peer ${peer}@${issue.wantedRange} of ${dependent}, found ${found}`;\n }),\n );\n\nconst issuesOfProject = ([project, issues]: readonly [\n string,\n ProjectPeerIssues,\n]): readonly string[] => [\n ...pipe(Rec.toEntries(issues.bad), Arr.flatMap(describeIssue(project, \"unmet\"))),\n ...pipe(Rec.toEntries(issues.missing), Arr.flatMap(describeIssue(project, \"missing\"))),\n ...pipe(\n issues.conflicts,\n Arr.map((peer) => `${project}: conflicting peer ${peer}`),\n ),\n];\n\nexport const peerIssuesIn = (output: string): readonly string[] =>\n sorted(\n pipe(\n Str.split(output, \"\\n\"),\n Arr.map((line) => Schema.decodeOption(PeerIssuesLog)(line)),\n Arr.getSomes,\n Arr.flatMap((log) => pipe(Rec.toEntries(log.issuesByProjects), Arr.flatMap(issuesOfProject))),\n ),\n );\n\nexport const advisoriesIn = (output: string): readonly string[] =>\n Option.match(Schema.decodeOption(AuditReport)(output), {\n onNone: () => [],\n onSome: (report) =>\n sorted(\n pipe(\n Rec.values(report.advisories),\n Arr.map((advisory) => `${advisory.module_name} ${advisory.github_advisory_id}`),\n ),\n ),\n });\n\nconst separatorOf = (key: string): Option.Option<number> => {\n if (!Str.startsWith(SCOPE_PREFIX)(key)) {\n return Str.indexOf(SCOPE_PREFIX)(key);\n }\n return pipe(\n Str.slice(SEPARATOR_LENGTH)(key),\n Str.indexOf(SCOPE_PREFIX),\n Option.map((index) => index + SEPARATOR_LENGTH),\n );\n};\n\nconst withoutPeerContext = (version: string): string =>\n Option.match(Str.indexOf(PEER_CONTEXT_START)(version), {\n onNone: () => version,\n onSome: (start) => Str.slice(NAME_START, start)(version),\n });\n\nconst packageOf = (key: string): Option.Option<readonly [string, string]> =>\n Option.map(separatorOf(key), (separator) => [\n Str.slice(NAME_START, separator)(key),\n withoutPeerContext(Str.slice(separator + SEPARATOR_LENGTH)(key)),\n ]);\n\nconst keysOf = (node: unknown): readonly string[] => {\n if (!isMap(node)) {\n return [];\n }\n return pipe(\n node.items,\n Arr.flatMap((pair): readonly string[] => {\n if (isScalar(pair.key)) {\n return [String(pair.key.value)];\n }\n return [];\n }),\n );\n};\n\nconst lockfileKeysOf = (lockfile: string, section: string): readonly string[] =>\n pipe(\n parseAllDocuments(lockfile),\n Arr.flatMap((document) => keysOf(document.get(section))),\n );\n\nexport const resolutionOf =\n (findings: Findings) =>\n (lockfile: string): Resolution => {\n const snapshots = lockfileKeysOf(lockfile, \"snapshots\");\n const packages = Arr.getSomes(\n pipe(\n [...lockfileKeysOf(lockfile, \"packages\"), ...snapshots],\n Arr.map((key) => packageOf(key)),\n ),\n );\n const versions = Rec.map(\n Arr.groupBy(packages, ([name]) => name),\n (entries) =>\n sorted(\n pipe(\n entries,\n Arr.map(([, version]) => version),\n ),\n ),\n );\n return { ...findings, versions, snapshots: sorted(snapshots) };\n };\n\nconst changesBetween = (baseline: Resolution, candidate: Resolution): readonly PackageChange[] =>\n pipe(\n sorted([...Rec.keys(baseline.versions), ...Rec.keys(candidate.versions)]),\n Arr.map((name) => ({\n name,\n before: baseline.versions[name] ?? [],\n after: candidate.versions[name] ?? [],\n })),\n Arr.filter((change) => Arr.join(change.before, \" \") !== Arr.join(change.after, \" \")),\n );\n\nconst growsThePackageSet = (change: PackageChange): boolean =>\n change.after.length > change.before.length;\n\nconst needsTheOverride = (\n found: Pick<OverrideReport, \"changes\" | \"peerIssues\" | \"advisories\">,\n): boolean =>\n pipe(\n found.changes,\n Arr.some((change) => growsThePackageSet(change)),\n ) ||\n Arr.isReadonlyArrayNonEmpty(found.peerIssues) ||\n Arr.isReadonlyArrayNonEmpty(found.advisories);\n\nexport const judge =\n (baseline: Resolution) =>\n (key: string, candidate: Resolution): OverrideReport => {\n const changes = changesBetween(baseline, candidate);\n const peerIssues = Arr.difference(candidate.peerIssues, baseline.peerIssues);\n const advisories = Arr.difference(candidate.advisories, baseline.advisories);\n const peerContextsChanged =\n Arr.join(baseline.snapshots, \" \") !== Arr.join(candidate.snapshots, \" \");\n const found = { key, changes, peerContextsChanged, peerIssues, advisories };\n if (!Arr.isReadonlyArrayNonEmpty(changes) && !peerContextsChanged) {\n return { ...found, verdict: \"unused\" };\n }\n if (needsTheOverride(found)) {\n return { ...found, verdict: \"keep\" };\n }\n return { ...found, verdict: \"verify\" };\n };\n\nconst OVERRIDES = \"overrides\";\nexport const BASELINE_PROBE = \"msch-baseline-probe\";\nconst REMOVED_DEPENDENCY = \"-\";\n\nexport interface OverrideKey {\n readonly key: string;\n readonly line: number;\n readonly column: number;\n}\n\nexport const overrideKeysOf = (manifest: string): readonly OverrideKey[] => {\n const lineCounter = new LineCounter();\n const overrides = parseDocument(manifest, { lineCounter }).get(OVERRIDES);\n if (!isMap(overrides)) {\n return [];\n }\n return pipe(\n overrides.items,\n Arr.flatMap((pair): readonly OverrideKey[] => {\n const { key } = pair;\n if (!isScalar(key)) {\n return [];\n }\n return pipe(\n Option.fromNullishOr(key.range),\n Option.map(([start]) => {\n const { line, col } = lineCounter.linePos(start);\n return { key: String(key.value), line, column: col };\n }),\n Option.toArray,\n );\n }),\n );\n};\n\nexport const withoutOverride =\n (key: string) =>\n (manifest: string): string => {\n const document = parseDocument(manifest);\n document.deleteIn([OVERRIDES, key]);\n return document.toString();\n };\n\nexport const withBaselineProbe = (manifest: string): string => {\n const document = parseDocument(manifest);\n document.setIn([OVERRIDES, BASELINE_PROBE], REMOVED_DEPENDENCY);\n return document.toString();\n};\n","import {\n Array as Arr,\n Effect,\n FileSystem,\n Option,\n Path,\n Schema,\n Stream,\n String as Str,\n pipe,\n} from \"effect\";\nimport type { PlatformError } from \"effect\";\nimport { ChildProcess } from \"effect/process\";\nimport type { ChildProcessSpawner } from \"effect/process\";\n\nimport type { Problem } from \"#/shared/lib/problem.ts\";\n\nimport { overrideProblem } from \"./override-findings.ts\";\nimport {\n BASELINE_PROBE,\n advisoriesIn,\n judge,\n overrideKeysOf,\n peerIssuesIn,\n resolutionOf,\n withBaselineProbe,\n withoutOverride,\n} from \"./override-resolution.ts\";\nimport type { OverrideKey } from \"./override-resolution.ts\";\n\nconst WORKSPACE_FILE = \"pnpm-workspace.yaml\";\nconst LOCKFILE = \"pnpm-lock.yaml\";\nconst RESOLUTION_FILES = [\"*package.json\", WORKSPACE_FILE, LOCKFILE, \".npmrc\", \"patches/*\"];\nconst RESOLUTION_CONCURRENCY = 4;\nconst SUCCEEDED = 0;\n\nconst taggedError = Schema.TaggedError;\n\nclass OverrideResolutionFailed extends taggedError<\n OverrideResolutionFailed,\n { readonly brand: unique symbol }\n>()(\"OverrideResolutionFailed\", { override: Schema.String, output: Schema.String }) {}\n\ntype CandidateFailure = OverrideResolutionFailed | PlatformError.PlatformError;\ntype CandidateServices =\n | FileSystem.FileSystem\n | Path.Path\n | ChildProcessSpawner.ChildProcessSpawner;\n\ninterface Workspace {\n readonly root: string;\n readonly files: readonly string[];\n readonly manifest: string;\n}\n\nconst textOf = <Failure>(\n stream: Stream.Stream<Uint8Array, Failure>,\n): Effect.Effect<string, Failure> => stream.pipe(Stream.decodeText(), Stream.mkString);\n\nconst resolveIn = Effect.fn(\"resolveIn\")(function* resolveIn(directory: string, override: string) {\n const handle = yield* ChildProcess.make(\n \"vp\",\n [\"install\", \"--lockfile-only\", \"--ignore-scripts\", \"--\", \"--reporter=ndjson\"],\n { cwd: directory, env: { CI: \"true\" }, extendEnv: true, stdin: \"ignore\" },\n );\n const [output, status] = yield* Effect.all([textOf(handle.all), handle.exitCode], {\n concurrency: \"unbounded\",\n });\n if (Number(status) !== SUCCEEDED) {\n return yield* OverrideResolutionFailed.make({ override, output });\n }\n return output;\n});\n\nconst auditIn = Effect.fn(\"auditIn\")(function* auditIn(directory: string) {\n const handle = yield* ChildProcess.make(\"vp\", [\"pm\", \"audit\", \"--json\"], {\n cwd: directory,\n extendEnv: true,\n stdin: \"ignore\",\n });\n const [report] = yield* Effect.all([textOf(handle.stdout), handle.exitCode], {\n concurrency: \"unbounded\",\n });\n return advisoriesIn(report);\n}, Effect.scoped);\n\nconst trackedResolutionFiles = Effect.fn(\"trackedResolutionFiles\")(function* trackedFiles(\n root: string,\n) {\n const handle = yield* ChildProcess.make(\"git\", [\"ls-files\", \"-z\", \"--\", ...RESOLUTION_FILES], {\n cwd: root,\n });\n const listed = yield* textOf(handle.stdout);\n return pipe(Str.split(listed, \"\\0\"), Arr.filter(Str.isNonEmpty));\n}, Effect.scoped);\n\nconst copyFiles = Effect.fn(\"copyFiles\")(function* copyFiles(\n workspace: Workspace,\n directory: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const copyOne = (file: string): Effect.Effect<void, PlatformError.PlatformError> => {\n const target = path.join(directory, file);\n const copy = fs.copyFile(path.join(workspace.root, file), target);\n return fs.makeDirectory(path.dirname(target), { recursive: true }).pipe(Effect.andThen(copy));\n };\n yield* Effect.forEach(workspace.files, copyOne, { discard: true });\n});\n\nconst resolutionWith = Effect.fn(\"resolutionWith\")(function* resolutionWith(\n workspace: Workspace,\n override: string,\n manifest: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const directory = yield* fs.makeTempDirectoryScoped({ prefix: \"msch-overrides-\" });\n yield* copyFiles(workspace, directory);\n yield* fs.writeFileString(path.join(directory, WORKSPACE_FILE), manifest);\n const output = yield* resolveIn(directory, override);\n const lockfile = yield* fs.readFileString(path.join(directory, LOCKFILE));\n yield* Effect.annotateCurrentSpan({ \"msch.override\": override });\n const advisories = yield* auditIn(directory);\n return resolutionOf({ peerIssues: peerIssuesIn(output), advisories })(lockfile);\n}, Effect.scoped);\n\nconst problemsFor = Effect.fn(\"problemsFor\")(function* problemsFor(\n root: string,\n manifest: string,\n keys: readonly OverrideKey[],\n) {\n const path = yield* Path.Path;\n const files = yield* trackedResolutionFiles(root);\n const workspace: Workspace = { root, files, manifest };\n const baseline = yield* resolutionWith(workspace, BASELINE_PROBE, withBaselineProbe(manifest));\n const judgeAgainstBaseline = judge(baseline);\n const file = path.join(root, WORKSPACE_FILE);\n const problemOf = (\n located: OverrideKey,\n ): Effect.Effect<Option.Option<Problem>, CandidateFailure, CandidateServices> =>\n resolutionWith(workspace, located.key, withoutOverride(located.key)(manifest)).pipe(\n Effect.map((candidate) =>\n overrideProblem({ ...located, file })(judgeAgainstBaseline(located.key, candidate)),\n ),\n );\n const problems = yield* Effect.forEach(keys, problemOf, {\n concurrency: RESOLUTION_CONCURRENCY,\n });\n return Arr.getSomes(problems);\n});\n\n/** @internal */\nexport const checkOverrides = Effect.fn(\"checkOverrides\")(function* checkOverrides(root: string) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const manifest = yield* fs.readFileString(path.join(root, WORKSPACE_FILE)).pipe(Effect.option);\n const keys = Option.match(manifest, { onNone: () => [], onSome: overrideKeysOf });\n if (Option.isNone(manifest) || !Arr.isReadonlyArrayNonEmpty(keys)) {\n return [];\n }\n return yield* problemsFor(root, manifest.value, keys);\n});\n","import { Array as Arr, Effect, Option, Order, Schema, String as Str, pipe } from \"effect\";\n\nimport { MANIFEST_FILE, publicEntriesOf } from \"#/entities/package/index.ts\";\nimport type { EntryManifest } from \"#/entities/package/index.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RULE: RuleName = \"colocated-test\";\nconst FIRST = 1;\nconst READ_CONCURRENCY = 64;\nconst ROOT_SUBPATH = \".\";\nconst NAME_GROUP = \"name\";\nconst SPECIFIER_GROUP = \"specifier\";\nconst SCRIPT = /\\.[cm]?[jt]sx?$/u;\nconst TEST_FILE = /\\.test\\.[cm]?[jt]sx?$/u;\nconst MANIFEST_NAME = /package\\.json$/u;\nconst SEPARATE_TEST_DIRECTORY = /(?:^|\\/)(?:__tests__|__mocks__|tests?|specs?)\\//u;\nconst RELATIVE_REFERENCE = /[\"'`]\\.\\/(?<name>[^/\"'`]+)/gu;\nconst DIRNAME_REFERENCE = /import\\.meta\\.dirname\\s*,\\s*[\"'](?<name>[^/\"']+)[\"']/gu;\nconst MODULE_SPECIFIER =\n /(?:\\bfrom\\s+|\\bimport\\s*\\(\\s*|\\bimport\\s+|\\bvi\\.mock\\(\\s*)[\"'](?<specifier>[^\"'.#][^\"']*)[\"']/gu;\nconst EXCLUDED: readonly string[] = [\n \":(exclude,attr:linguist-vendored)\",\n \":(exclude,attr:linguist-generated)\",\n];\n\nconst DIRECTORY_MESSAGE =\n \"sits in a separate test directory. Put each test next to the module it tests, and test-only helpers next to the tests as <name>.test.support.ts.\";\nconst SIBLING_MESSAGE =\n \"refers to nothing in its own directory. Move the test next to the module it tests and import that module, or a helper beside it, with ./<name>.\";\n\nconst Manifest = Schema.Struct({\n name: Schema.optional(Schema.String),\n exports: Schema.optional(Schema.Unknown),\n});\nconst decodeManifest = Schema.decodeUnknownOption(Schema.fromJsonString(Manifest));\n\ninterface TestFile {\n readonly name: string;\n readonly base: string;\n readonly file: string;\n readonly directory: string;\n}\n\ninterface Context {\n readonly root: string;\n readonly packages: readonly string[];\n}\n\ninterface Beside {\n readonly join: (target: string) => string;\n readonly dirname: (file: string) => string;\n readonly directory: string;\n}\n\nconst byLength = Order.mapInput(Order.Number, (directory: string) => directory.length);\n\nconst problemFor = (test: TestFile, message: string): Problem => ({\n file: test.file,\n line: FIRST,\n column: FIRST,\n rule: RULE,\n message: `${test.base} ${message}`,\n});\n\nconst groupsOf = (source: string, pattern: RegExp, group: string): readonly string[] =>\n pipe(\n Arr.fromIterable(Str.matchAll(pattern)(source)),\n Arr.map((match) =>\n pipe(\n Option.fromUndefinedOr(match.groups),\n Option.flatMap((groups) => Option.fromUndefinedOr(groups[group])),\n ),\n ),\n Arr.getSomes,\n );\n\nconst namesSibling = (source: string): boolean =>\n pipe(\n [\n ...groupsOf(source, RELATIVE_REFERENCE, NAME_GROUP),\n ...groupsOf(source, DIRNAME_REFERENCE, NAME_GROUP),\n ],\n Arr.some((name) => !TEST_FILE.test(name)),\n );\n\nconst ownerOf = (packages: readonly string[], name: string): Option.Option<string> => {\n const owners = pipe(\n packages,\n Arr.filter((directory) => Str.startsWith(directory)(name)),\n );\n return Arr.last(Arr.sort(owners, byLength));\n};\n\nconst specifiersBeside =\n ({ join, dirname, directory }: Beside) =>\n (manifest: EntryManifest): readonly string[] =>\n pipe(\n Option.fromUndefinedOr(manifest.name),\n Option.map((name) =>\n pipe(\n publicEntriesOf({ manifest, join, packEntries: [] }),\n Arr.filter(({ source }) => dirname(source) === directory),\n Arr.map(({ label }) => Str.replace(ROOT_SUBPATH, name)(label)),\n ),\n ),\n Option.getOrElse((): readonly string[] => []),\n );\n\nconst ownSpecifiers = Effect.fn(\"ownSpecifiers\")(function* ownSpecifiers(\n context: Context,\n test: TestFile,\n) {\n const files = yield* RepositoryFiles;\n const owner = ownerOf(context.packages, test.name);\n if (Option.isNone(owner)) {\n return [];\n }\n const text = yield* files.readFile(files.join(context.root, owner.value, MANIFEST_FILE));\n const join = (target: string): string => files.join(context.root, owner.value, target);\n return pipe(\n text,\n Option.flatMap(decodeManifest),\n Option.map(specifiersBeside({ join, dirname: files.dirname, directory: test.directory })),\n Option.getOrElse((): readonly string[] => []),\n );\n});\n\nconst refersToOwnDirectory = Effect.fn(\"refersToOwnDirectory\")(function* refersToOwnDirectory(\n context: Context,\n test: TestFile,\n source: string,\n) {\n if (namesSibling(source)) {\n return true;\n }\n const specifiers = groupsOf(source, MODULE_SPECIFIER, SPECIFIER_GROUP);\n if (Arr.isReadonlyArrayEmpty(specifiers)) {\n return false;\n }\n const own = yield* ownSpecifiers(context, test);\n return pipe(\n specifiers,\n Arr.some((specifier) => pipe(own, Arr.contains(specifier))),\n );\n});\n\nconst refersIn = Effect.fn(\"refersIn\")(function* refersIn(context: Context, test: TestFile) {\n const files = yield* RepositoryFiles;\n const source = yield* files.readFile(test.file);\n if (Option.isNone(source)) {\n return true;\n }\n return yield* refersToOwnDirectory(context, test, source.value);\n});\n\nconst problemIn = Effect.fn(\"problemIn\")(function* problemIn(context: Context, test: TestFile) {\n if (SEPARATE_TEST_DIRECTORY.test(test.name)) {\n return Option.some(problemFor(test, DIRECTORY_MESSAGE));\n }\n if (!TEST_FILE.test(test.name)) {\n return Option.none<Problem>();\n }\n const refers = yield* refersIn(context, test);\n if (refers) {\n return Option.none<Problem>();\n }\n return Option.some(problemFor(test, SIBLING_MESSAGE));\n});\n\n/** @internal */\nexport const checkColocatedTests = Effect.fn(\"checkColocatedTests\")(function* checkColocatedTests(\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.matchingFiles(root, EXCLUDED);\n const names = pipe(listed, Arr.filter(Str.isNonEmpty));\n const context: Context = {\n root,\n packages: pipe(\n names,\n Arr.filter((name) => files.basename(name) === MANIFEST_FILE),\n Arr.map(Str.replace(MANIFEST_NAME, \"\")),\n ),\n };\n const tests = pipe(\n names,\n Arr.filter((name) => SCRIPT.test(name)),\n Arr.map((name): TestFile => {\n const file = files.join(root, name);\n return { name, base: files.basename(name), file, directory: files.dirname(file) };\n }),\n );\n const found = yield* Effect.forEach(tests, (test) => problemIn(context, test), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(found);\n});\n","import { Array as Arr, Effect, HashSet, Option, Schema, String as Str, pipe } from \"effect\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport { MANIFEST_FILE } from \"#/entities/package/index.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RULE: RuleName = \"nested-docs\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst SEPARATOR = \"/\";\nconst FIRST = 1;\nconst READ_CONCURRENCY = 64;\nconst AGENT_DOCS = /^(?:AGENTS|CLAUDE)(?:\\.[^/]+)?\\.md$/iu;\nconst WORKSPACE_AGENT_DOC = \"AGENTS.md\";\nconst README = /^README(?:\\.[^/]+)?$/iu;\n\nconst RootConfig = Schema.Struct({\n msch: Schema.Struct({ workspaceAgentsMd: Schema.Literal(true) }),\n});\n\nconst taggedError = Schema.TaggedError;\n\nclass RootConfigUnreadable extends taggedError<\n RootConfigUnreadable,\n { readonly brand: unique symbol }\n>()(\"RootConfigUnreadable\", { file: Schema.String }) {}\n\nconst isNested = (name: string): boolean => Str.includes(SEPARATOR)(name);\n\nconst problemFor = (file: string, message: string): Problem => ({\n file,\n line: FIRST,\n column: FIRST,\n rule: RULE,\n message,\n});\n\nconst AGENT_DOCS_MESSAGE =\n \"belongs only at the repository root. Move what agents need into the root AGENTS.md and delete this file.\";\nconst WORKSPACE_AGENT_DOCS_MESSAGE =\n \"belongs only at the repository root or as AGENTS.md directly in a workspace, the directory that holds its package.json. Move what agents need there and delete this file.\";\nconst README_MESSAGE =\n \"is allowed below the root only in a workspace, the directory that holds its package.json. Move it into the workspace it describes.\";\n\ninterface Allowed {\n readonly workspaces: HashSet.HashSet<string>;\n readonly workspaceAgentDocs: boolean;\n}\n\ninterface NestedDoc {\n readonly file: string;\n readonly base: string;\n readonly directory: string;\n}\n\nconst agentDocProblem = (\n { file, base, directory }: NestedDoc,\n allowed: Allowed,\n): Option.Option<Problem> => {\n if (!allowed.workspaceAgentDocs) {\n return Option.some(problemFor(file, `${base} ${AGENT_DOCS_MESSAGE}`));\n }\n if (base === WORKSPACE_AGENT_DOC && HashSet.has(allowed.workspaces, directory)) {\n return Option.none<Problem>();\n }\n return Option.some(problemFor(file, `${base} ${WORKSPACE_AGENT_DOCS_MESSAGE}`));\n};\n\nconst readmeProblem = (\n { file, base, directory }: NestedDoc,\n allowed: Allowed,\n): Option.Option<Problem> => {\n if (!README.test(base) || HashSet.has(allowed.workspaces, directory)) {\n return Option.none<Problem>();\n }\n return Option.some(problemFor(file, `${base} ${README_MESSAGE}`));\n};\n\nconst problemIn = Effect.fn(\"problemIn\")(function* problemIn(\n root: string,\n allowed: Allowed,\n name: string,\n) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, name);\n const doc: NestedDoc = { file, base: files.basename(name), directory: files.dirname(file) };\n if (AGENT_DOCS.test(doc.base)) {\n return agentDocProblem(doc, allowed);\n }\n return readmeProblem(doc, allowed);\n});\n\nconst allowsWorkspaceAgentDocs = Effect.fn(\"allowsWorkspaceAgentDocs\")(\n function* allowsWorkspaceAgentDocs(root: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, CONFIG_FILE);\n const exists = yield* files.exists(file);\n if (!exists) {\n return false;\n }\n const config = yield* Effect.tryPromise({\n try: () => resolveConfigFromFile(file),\n catch: () => RootConfigUnreadable.make({ file }),\n }).pipe(Effect.option);\n return pipe(config, Option.flatMap(Schema.decodeUnknownOption(RootConfig)), Option.isSome);\n },\n);\n\n/** @internal */\nexport const checkNestedDocs = Effect.fn(\"checkNestedDocs\")(function* checkNestedDocs(\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const names = yield* files.listedFiles(root);\n const nested = pipe(names, Arr.filter(isNested));\n const workspaceAgentDocs = yield* allowsWorkspaceAgentDocs(root);\n const allowed: Allowed = {\n workspaces: pipe(\n nested,\n Arr.filter((name) => files.basename(name) === MANIFEST_FILE),\n Arr.map((name) => files.dirname(files.join(root, name))),\n HashSet.fromIterable,\n ),\n workspaceAgentDocs,\n };\n const found = yield* Effect.forEach(nested, (name) => problemIn(root, allowed, name), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(found);\n});\n","import { Array as Arr, Effect, Option, Schema, String as Str, pipe } from \"effect\";\n\nimport { MANIFEST_FILE } from \"#/entities/package/index.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nconst RULE: RuleName = \"root-readme\";\nconst SEPARATOR = \"/\";\nconst ALTERNATIVE = \"|\";\nconst SCOPE = /^@[^/]+\\//u;\nconst README = /^README(?:\\.[^/]+)?$/iu;\nconst SPECIAL = /[$()*+.?[\\\\\\]^{|}]/gu;\nconst READ_CONCURRENCY = 16;\nconst START = 0;\nconst NamedManifest = Schema.fromJsonString(\n Schema.Struct({ name: Schema.optional(Schema.String) }),\n);\n\ninterface Workspace {\n readonly directory: string;\n readonly pattern: RegExp;\n}\n\nconst patternOf = (names: readonly string[]): RegExp => {\n const alternatives = pipe(names, Arr.map(Str.replaceAll(SPECIAL, String.raw`\\$&`)));\n return new RegExp(\n `(?<![\\\\p{L}\\\\p{N}_-])(?:${Arr.join(alternatives, ALTERNATIVE)})(?![\\\\p{L}\\\\p{N}_-])`,\n \"gu\",\n );\n};\n\nconst packageNameIn = (text: Option.Option<string>): Option.Option<string> =>\n pipe(\n text,\n Option.flatMap(Schema.decodeOption(NamedManifest)),\n Option.flatMap((manifest) => Option.fromUndefinedOr(manifest.name)),\n );\n\nconst workspaceIn = Effect.fn(\"workspaceIn\")(function* workspaceIn(root: string, name: string) {\n const files = yield* RepositoryFiles;\n const directory = files.dirname(name);\n const text = yield* files.readFile(files.join(root, name));\n const packageName = packageNameIn(text);\n const unscoped = pipe(packageName, Option.map(Str.replace(SCOPE, \"\")));\n const names = pipe(\n [Option.some(directory), Option.some(files.basename(directory)), packageName, unscoped],\n Arr.getSomes,\n Arr.dedupe,\n );\n return { directory, pattern: patternOf(names) };\n});\n\nconst messageFor = (directory: string): string =>\n `names the workspace ${directory}. The root README describes the repository as a whole. Write what belongs to the workspace in ${directory}/README.md.`;\n\nconst problemsIn =\n (file: string, source: string) =>\n ({ directory, pattern }: Workspace): readonly Problem[] => {\n const message = messageFor(directory);\n const at = positionOf(source);\n return pipe(\n Arr.fromIterable(Str.matchAll(pattern)(source)),\n Arr.map((found) => ({ file, ...at(found.index ?? START), rule: RULE, message })),\n );\n };\n\nconst problemsInReadme = Effect.fn(\"problemsInReadme\")(function* problemsInReadme(\n file: string,\n workspaces: readonly Workspace[],\n) {\n const files = yield* RepositoryFiles;\n const text = yield* files.readFile(file);\n return pipe(\n text,\n Option.match({\n onNone: (): readonly Problem[] => [],\n onSome: (source) => pipe(workspaces, Arr.flatMap(problemsIn(file, source))),\n }),\n );\n});\n\n/** @internal */\nexport const checkRootReadme = Effect.fn(\"checkRootReadme\")(function* checkRootReadme(\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const names = yield* files.listedFiles(root);\n const readmes = pipe(\n names,\n Arr.filter((name) => README.test(name)),\n );\n const manifests = pipe(\n names,\n Arr.filter((name) => Str.includes(SEPARATOR)(name) && files.basename(name) === MANIFEST_FILE),\n );\n const workspaces = yield* Effect.forEach(manifests, (name) => workspaceIn(root, name), {\n concurrency: READ_CONCURRENCY,\n });\n const found = yield* Effect.forEach(\n readmes,\n (name) => problemsInReadme(files.join(root, name), workspaces),\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.flatten(found);\n});\n","import { Array as Arr, Effect } from \"effect\";\n\nimport { checkColocatedTests } from \"./colocated-tests.ts\";\nimport { checkNestedDocs } from \"./nested-docs.ts\";\nimport { checkRootReadme } from \"./root-readme.ts\";\n\n/** @internal */\nexport const checkPlacement = Effect.fn(\"checkPlacement\")(function* checkPlacement(root: string) {\n const found = yield* Effect.all(\n [checkNestedDocs(root), checkRootReadme(root), checkColocatedTests(root)],\n { concurrency: \"unbounded\" },\n );\n return Arr.flatten(found);\n});\n","import { Array as Arr, Effect, Option, Schema, Stream, String as Str, pipe } from \"effect\";\nimport { ChildProcess } from \"effect/process\";\n\nimport { workspaceDirectories, hasVerifyTask } from \"#/entities/workspace/index.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RULE: RuleName = \"unverified-crate\";\nconst CARGO_FILE = \"Cargo.toml\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst SEPARATOR = \"/\";\nconst FIRST = 1;\nconst READ_CONCURRENCY = 8;\n\nconst CrateEntry = Schema.Struct({ name: Schema.String, manifest_path: Schema.String });\nconst CrateList = Schema.fromJsonString(Schema.Struct({ packages: Schema.Array(CrateEntry) }));\nconst decodeCrateList = Schema.decodeUnknownEffect(CrateList);\n\ninterface Crate {\n readonly name: string;\n readonly manifest: string;\n}\n\nconst cratesIn = Effect.fn(\"cratesIn\")(function* cratesIn(root: string) {\n const handle = yield* ChildProcess.make(\n \"cargo\",\n [\"metadata\", \"--no-deps\", \"--format-version\", \"1\", \"--offline\"],\n { cwd: root, extendEnv: true, stdin: \"ignore\" },\n );\n const output = yield* handle.stdout.pipe(Stream.decodeText(), Stream.mkString);\n const list = yield* decodeCrateList(output);\n return pipe(\n list.packages,\n Arr.map((crate): Crate => ({ name: crate.name, manifest: crate.manifest_path })),\n );\n}, Effect.scoped);\n\nconst owningWorkspace =\n (directories: readonly string[]) =>\n (directory: string): Option.Option<string> => {\n const owners = pipe(\n directories,\n Arr.filter(\n (workspace) =>\n directory === workspace || Str.startsWith(`${workspace}${SEPARATOR}`)(directory),\n ),\n );\n return Arr.last(Arr.sort(owners, Str.Order));\n };\n\nconst problemFor = (crate: Crate, message: string): Problem => ({\n file: crate.manifest,\n line: FIRST,\n column: FIRST,\n rule: RULE,\n message: `crate ${crate.name} ${message}, so vp run verify never checks it.`,\n});\n\nconst problemIn = Effect.fn(\"problemIn\")(function* problemIn(\n root: string,\n directories: readonly string[],\n crate: Crate,\n) {\n const files = yield* RepositoryFiles;\n const workspace = owningWorkspace(directories)(\n files.relative(root, files.dirname(crate.manifest)),\n );\n if (Option.isNone(workspace)) {\n return Option.some(problemFor(crate, \"is outside every workspace package\"));\n }\n const verified = yield* hasVerifyTask(files.join(root, workspace.value, CONFIG_FILE));\n if (verified) {\n return Option.none<Problem>();\n }\n return Option.some(\n problemFor(crate, `is in ${workspace.value}, whose ${CONFIG_FILE} has no verify task`),\n );\n});\n\n/** @internal */\nexport const checkCrates = Effect.fn(\"checkCrates\")(function* checkCrates(root: string) {\n const files = yield* RepositoryFiles;\n const cargo = yield* files.exists(files.join(root, CARGO_FILE));\n if (!cargo) {\n return [];\n }\n const directories = yield* workspaceDirectories(root);\n const crates = yield* cratesIn(root);\n const found = yield* Effect.forEach(crates, (crate) => problemIn(root, directories, crate), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(found);\n});\n","import { Array as Arr, Effect, Option } from \"effect\";\n\nimport {\n workspaceConfigOf,\n workspaceDirectories,\n VERIFY_TASK,\n definesTask,\n hasVerifyTask,\n} from \"#/entities/workspace/index.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\n\nconst RULE: RuleName = \"hidden-verify\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst FIRST = 1;\nconst READ_CONCURRENCY = 8;\n\nconst problemIn = Effect.fn(\"problemIn\")(function* problemIn(root: string, directory: string) {\n const config = yield* workspaceConfigOf(root, directory);\n if (Option.isNone(config)) {\n return Option.none<Problem>();\n }\n const { file, program } = config.value;\n if (definesTask(VERIFY_TASK)(program)) {\n return Option.none<Problem>();\n }\n const verified = yield* hasVerifyTask(file);\n return Option.some<Problem>({\n file,\n line: FIRST,\n column: FIRST,\n rule: RULE,\n message: `${directory} gets its verify task from code outside ${CONFIG_FILE}. The root verify reads ${CONFIG_FILE} without running it, so it never runs this verify. Write run.tasks.verify in ${directory}/${CONFIG_FILE}.`,\n }).pipe(Option.filter(() => verified));\n});\n\n/** @internal */\nexport const checkHiddenVerify = Effect.fn(\"checkHiddenVerify\")(function* checkHiddenVerify(\n root: string,\n) {\n const directories = yield* workspaceDirectories(root);\n const found = yield* Effect.forEach(directories, (directory) => problemIn(root, directory), {\n concurrency: READ_CONCURRENCY,\n });\n return Arr.getSomes(found);\n});\n","import { Array as Arr, Effect, Option, Schema, String as Str, pipe } from \"effect\";\nimport { parse } from \"vite-plus\";\nimport type { ESTree } from \"vite-plus/lint/plugins\";\n\nimport { childrenOf, workspaceDirectories } from \"#/entities/workspace/index.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nconst RULE: RuleName = \"root-workspace-path\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst PATH_CHARACTER = /[\\w.@/-]/u;\nconst NAME_CHARACTER = /[\\w.@-]/u;\nconst FIRST = 0;\nconst NEXT = 1;\n\nconst StringNode = Schema.Union([\n Schema.Struct({\n type: Schema.Literal<ESTree.StringLiteral[\"type\"]>(\"Literal\"),\n value: Schema.String,\n start: Schema.Finite,\n }),\n Schema.Struct({\n type: Schema.Literal<ESTree.TemplateElement[\"type\"]>(\"TemplateElement\"),\n value: Schema.Struct({ cooked: Schema.String }),\n start: Schema.Finite,\n }),\n]);\nconst decodeStringNode = Schema.decodeUnknownOption(StringNode);\n\ninterface FoundString {\n readonly text: string;\n readonly start: number;\n}\n\nconst textOf = (node: typeof StringNode.Type): string => {\n if (node.type === \"Literal\") {\n return node.value;\n }\n return node.value.cooked;\n};\n\nconst stringsIn = (node: unknown): readonly FoundString[] => {\n const own = pipe(\n decodeStringNode(node),\n Option.map((found) => ({ text: textOf(found), start: found.start })),\n Option.toArray,\n );\n return [...own, ...pipe(childrenOf(node), Arr.flatMap(stringsIn))];\n};\n\nconst isBoundary = (character: string, allowed: RegExp): boolean =>\n character === \"\" || !allowed.test(character);\n\nconst mentions =\n (directory: string) =>\n (text: string): boolean => {\n const parts = Str.split(text, directory);\n return pipe(\n Arr.drop(parts, NEXT),\n Arr.some((after, index) => {\n const before = parts[index] ?? \"\";\n const previous = Str.slice(before.length - NEXT)(before);\n const following = Str.slice(FIRST, NEXT)(after);\n return (\n isBoundary(previous, PATH_CHARACTER) &&\n (following === \"/\" || isBoundary(following, NAME_CHARACTER))\n );\n }),\n );\n };\n\nconst problemsIn =\n (file: string, source: string, directories: readonly string[]) =>\n (found: FoundString): readonly Problem[] =>\n pipe(\n directories,\n Arr.filter((directory) => mentions(directory)(found.text)),\n Arr.map((directory): Problem => ({\n file,\n ...positionOf(source)(found.start),\n rule: RULE,\n message: `${directory} is a workspace. The root ${CONFIG_FILE} holds what applies to every workspace, so move what only ${directory} needs into ${directory}/${CONFIG_FILE}: msch.lint, msch.devDependencies or its verify task.`,\n })),\n );\n\n/** @internal */\nexport const checkRootWorkspacePaths = Effect.fn(\"checkRootWorkspacePaths\")(\n function* checkRootWorkspacePaths(root: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, CONFIG_FILE);\n const source = yield* files.readFile(file);\n if (Option.isNone(source)) {\n return [];\n }\n const directories = yield* workspaceDirectories(root);\n const parsed = yield* Effect.promise(() => parse(file, source.value, { lang: \"ts\" }));\n return pipe(\n stringsIn(parsed.program),\n Arr.flatMap(problemsIn(file, source.value, directories)),\n );\n },\n);\n","import { Array as Arr, Effect, Option, Record as Rec, Schema, String as Str, pipe } from \"effect\";\n\nimport {\n KeySchema,\n keyName,\n literalOf,\n nestedValues,\n workspaceConfigOf,\n workspaceDirectories,\n} from \"#/entities/workspace/index.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nconst RULE: RuleName = \"shared-uncached-task\";\nconst TASKS_PATH = [\"run\", \"tasks\"] as const;\nconst READ_CONCURRENCY = 8;\nconst SHARED = 2;\nconst OWN_PROGRAM = /^(?:node|vpx|bun|deno|tsx)$|\\//u;\n\nconst TaskProperty = Schema.Struct({\n type: Schema.Literal(\"Property\"),\n computed: Schema.Literal(false),\n key: KeySchema,\n value: Schema.Unknown,\n start: Schema.Finite,\n});\nconst TaskObject = Schema.Struct({\n type: Schema.Literal(\"ObjectExpression\"),\n properties: Schema.Array(Schema.Unknown),\n});\nconst UncachedTask = Schema.Struct({\n cache: Schema.Literal(false),\n command: Schema.Union([Schema.String, Schema.NonEmptyArray(Schema.String)]),\n});\n\nconst decodeTaskProperty = Schema.decodeUnknownOption(TaskProperty);\nconst decodeTaskObject = Schema.decodeUnknownOption(TaskObject);\nconst decodeUncachedTask = Schema.decodeUnknownOption(UncachedTask);\nconst encodeDefinition = Schema.encodeOption(Schema.fromJsonString(Schema.Unknown));\n\ninterface UncachedDefinition {\n readonly directory: string;\n readonly file: string;\n readonly position: Pick<Problem, \"line\" | \"column\">;\n readonly name: string;\n readonly command: string;\n readonly definition: string;\n}\n\nconst commandText = (command: typeof UncachedTask.Type.command): string =>\n Arr.join(Arr.ensure(command), \" && \");\n\nconst runsOwnProgram = (command: string): boolean =>\n pipe(\n Str.trim(command),\n Str.split(/\\s+/u),\n Arr.head,\n Option.exists((program) => OWN_PROGRAM.test(program)),\n );\n\ninterface ConfigFile {\n readonly directory: string;\n readonly file: string;\n readonly source: string;\n}\n\nconst definitionOf =\n ({ directory, file, source }: ConfigFile) =>\n (task: typeof TaskProperty.Type): Option.Option<UncachedDefinition> =>\n Option.gen(function* uncachedDefinition() {\n const literal = yield* literalOf(task.value);\n const { command } = yield* decodeUncachedTask(literal);\n const text = commandText(command);\n if (runsOwnProgram(text)) {\n return yield* Option.none();\n }\n const definition = yield* encodeDefinition(literal);\n return {\n directory,\n file,\n position: positionOf(source)(task.start),\n name: keyName(task.key),\n command: text,\n definition,\n };\n });\n\nconst definitionsIn = Effect.fn(\"definitionsIn\")(function* definitionsIn(\n root: string,\n directory: string,\n) {\n const config = yield* workspaceConfigOf(root, directory);\n if (Option.isNone(config)) {\n return [];\n }\n const { file, source, program } = config.value;\n return pipe(\n nestedValues(TASKS_PATH)(program),\n Arr.flatMap((tasks) =>\n pipe(\n decodeTaskObject(tasks),\n Option.map(({ properties }) => properties),\n Option.getOrElse((): readonly unknown[] => []),\n ),\n ),\n Arr.flatMap((property) =>\n pipe(\n decodeTaskProperty(property),\n Option.flatMap(definitionOf({ directory, file, source })),\n Option.toArray,\n ),\n ),\n );\n});\n\nconst problemsOf = (definitions: readonly UncachedDefinition[]): readonly Problem[] => {\n const directories = pipe(\n definitions,\n Arr.map(({ directory }) => directory),\n Arr.dedupe,\n );\n if (directories.length < SHARED) {\n return [];\n }\n return pipe(\n definitions,\n Arr.map(({ file, position, name, command }): Problem => ({\n file,\n ...position,\n rule: RULE,\n message: `The uncached task ${name} (${command}) is written the same way in ${Arr.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.`,\n })),\n );\n};\n\n/** @internal */\nexport const checkSharedUncachedTasks = Effect.fn(\"checkSharedUncachedTasks\")(\n function* checkSharedUncachedTasks(root: string) {\n const directories = yield* workspaceDirectories(root);\n const found = yield* Effect.forEach(\n directories,\n (directory) => definitionsIn(root, directory),\n { concurrency: READ_CONCURRENCY },\n );\n return pipe(\n Arr.flatten(found),\n Arr.groupBy(({ name, definition }) => `${name}\\u0000${definition}`),\n Rec.values,\n Arr.flatMap(problemsOf),\n );\n },\n);\n","import { Array as Arr, Effect } from \"effect\";\n\nimport { checkCrates } from \"./crates.ts\";\nimport { checkHiddenVerify } from \"./hidden-verify.ts\";\nimport { checkRootWorkspacePaths } from \"./root-workspace-paths.ts\";\nimport { checkSharedUncachedTasks } from \"./shared-uncached-tasks.ts\";\n\n/** @internal */\nexport const checkWorkspaces = Effect.fn(\"checkWorkspaces\")(function* checkWorkspaces(\n root: string,\n) {\n const found = yield* Effect.all(\n [\n checkCrates(root),\n checkHiddenVerify(root),\n checkRootWorkspacePaths(root),\n checkSharedUncachedTasks(root),\n ],\n {\n concurrency: \"unbounded\",\n },\n );\n return Arr.flatten(found);\n});\n","import { Array as Arr, Option } from \"effect\";\n\nimport {\n isCallExpression,\n isNewExpression,\n isObjectLiteralExpression,\n isPropertyAssignment,\n isSignatureDeclaration,\n isVariableDeclaration,\n SyntaxKind,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Expression,\n ParameterDeclaration,\n PropertyDeclaration,\n PropertySignatureDeclaration,\n TypeSymbol,\n TypeNode,\n VariableDeclaration,\n} from \"#/shared/lib/compiler.ts\";\nimport { declarationsOf, referencedSymbols } from \"#/shared/lib/syntax.ts\";\n\ntype AnnotatedDeclaration =\n | ParameterDeclaration\n | VariableDeclaration\n | PropertySignatureDeclaration\n | PropertyDeclaration;\n\nconst ANNOTATED_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.Parameter,\n SyntaxKind.VariableDeclaration,\n SyntaxKind.PropertySignature,\n SyntaxKind.PropertyDeclaration,\n]);\n\nconst isAnnotated = (declaration: Declaration): declaration is AnnotatedDeclaration =>\n ANNOTATED_KINDS.has(declaration.kind);\n\nexport const annotationOf = (declaration: Declaration): Option.Option<TypeNode> =>\n Option.liftPredicate(declaration, isAnnotated).pipe(\n Option.flatMap((annotated) => Option.fromUndefinedOr(annotated.type)),\n );\n\nconst argumentSlot =\n (checker: Checker) =>\n (expression: Expression): Option.Option<Declaration> => {\n const call = expression.parent;\n if (!isCallExpression(call) && !isNewExpression(call)) {\n return Option.none();\n }\n const { arguments: listed } = call;\n const callArguments: readonly Expression[] = listed ?? [];\n const index = callArguments.indexOf(expression);\n return Option.fromUndefinedOr(checker.getResolvedSignature(call).declaration).pipe(\n Option.flatMap((handle) => Option.fromUndefinedOr(handle.resolve())),\n Option.filter(isSignatureDeclaration),\n Option.flatMap((declaration) => Arr.get(declaration.parameters, index)),\n );\n };\n\nconst propertySlot =\n (checker: Checker) =>\n (expression: Expression): Option.Option<Declaration> => {\n const assignment = expression.parent;\n if (!isPropertyAssignment(assignment) || !isObjectLiteralExpression(assignment.parent)) {\n return Option.none();\n }\n return Option.fromUndefinedOr(checker.getContextualType(assignment.parent)).pipe(\n Option.flatMap((objectType) =>\n Option.fromUndefinedOr(objectType.getProperty(assignment.name.getText())),\n ),\n Option.flatMap((property) => Arr.head(declarationsOf(property))),\n );\n };\n\nconst variableSlot = (expression: Expression): Option.Option<Declaration> => {\n const declaration = expression.parent;\n if (!isVariableDeclaration(declaration) || declaration.initializer !== expression) {\n return Option.none();\n }\n return Option.some(declaration);\n};\n\nexport const slotOf =\n (checker: Checker) =>\n (expression: Expression): Option.Option<Declaration> =>\n argumentSlot(checker)(expression).pipe(\n Option.orElse(() => propertySlot(checker)(expression)),\n Option.orElse(() => variableSlot(expression)),\n );\n\nexport const contextSymbolsOf =\n (checker: Checker) =>\n (expression: Expression): readonly TypeSymbol[] => {\n const alias = Option.fromUndefinedOr(checker.getContextualType(expression)).pipe(\n Option.flatMap((contextual) => Option.fromUndefinedOr(contextual.getAliasSymbol())),\n );\n if (Option.isSome(alias)) {\n return [alias.value];\n }\n return slotOf(checker)(expression).pipe(\n Option.flatMap(annotationOf),\n Option.map((annotation) => referencedSymbols(checker)(annotation)),\n Option.getOrElse(() => []),\n );\n };\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport {\n getNameOfDeclaration,\n isClassDeclaration,\n isElementAccessExpression,\n isIdentifier,\n isInterfaceDeclaration,\n isPropertyAccessExpression,\n isSignatureDeclaration,\n isTypeAliasDeclaration,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n Checker,\n ClassDeclaration,\n Declaration,\n Expression,\n InterfaceDeclaration,\n Node,\n Program,\n SignatureDeclaration,\n SourceFile,\n TypeSymbol,\n Type,\n} from \"#/shared/lib/compiler.ts\";\nimport {\n contains,\n declarationsOf,\n descendantsOf,\n isExternalDeclaration,\n NODE_MODULES_SEGMENT,\n symbolAt,\n} from \"#/shared/lib/syntax.ts\";\nimport { isSubsetOf, vocabularyOf } from \"#/shared/lib/values.ts\";\n\nimport type { ValueSite } from \"./sites.ts\";\nimport { annotationOf, slotOf } from \"./slots.ts\";\n\nexport interface Flow {\n readonly site: ValueSite;\n readonly target: string;\n}\n\nexport interface FlowContext {\n readonly checker: Checker;\n readonly program: Program;\n readonly sites: readonly ValueSite[];\n}\n\nconst SCOPE_PREFIX = \"@\";\nconst SCOPED_SEGMENTS = 2;\nconst UNSCOPED_SEGMENTS = 1;\nconst MODULE_PREFIX = /^\".*?\"\\./u;\n\nconst packageOf = (fileName: string): string => {\n const afterModules = pipe(\n fileName,\n Str.lastIndexOf(NODE_MODULES_SEGMENT),\n Option.match({\n onNone: () => fileName,\n onSome: (index) => Str.slice(index + NODE_MODULES_SEGMENT.length)(fileName),\n }),\n );\n const segments = Str.split(\"/\")(afterModules);\n if (Str.startsWith(SCOPE_PREFIX)(afterModules)) {\n return pipe(Arr.take(segments, SCOPED_SEGMENTS), Arr.join(\"/\"));\n }\n return pipe(Arr.take(segments, UNSCOPED_SEGMENTS), Arr.join(\"/\"));\n};\n\nconst externalDeclarationOf =\n (context: FlowContext) =>\n (symbol: TypeSymbol): Option.Option<Declaration> =>\n Arr.findFirst(declarationsOf(symbol), (declaration) =>\n isExternalDeclaration(context.program)(declaration),\n );\n\nconst aliasTarget =\n (context: FlowContext) =>\n (type: Type): Option.Option<string> =>\n Option.fromUndefinedOr(type.getAliasSymbol()).pipe(\n Option.flatMap((alias) =>\n externalDeclarationOf(context)(alias).pipe(\n Option.map(\n (declaration) =>\n `${Str.replace(MODULE_PREFIX, \"\")(context.checker.getFullyQualifiedName(alias))} from ${packageOf(declaration.getSourceFile().fileName)}`,\n ),\n ),\n ),\n );\n\nconst isNamedContainer = (\n node: Node,\n): node is SignatureDeclaration | InterfaceDeclaration | ClassDeclaration =>\n isSignatureDeclaration(node) || isInterfaceDeclaration(node) || isClassDeclaration(node);\n\nconst slotTarget =\n (context: FlowContext) =>\n (expression: Expression): Option.Option<string> =>\n slotOf(context.checker)(expression).pipe(\n Option.filter((slot) => isExternalDeclaration(context.program)(slot)),\n Option.filter((slot) =>\n Option.isSome(vocabularyOf(context.checker)(context.checker.getTypeAtLocation(slot))),\n ),\n Option.map((slot) => {\n const owner = Option.liftPredicate(slot.parent, isNamedContainer).pipe(\n Option.flatMap((container) => Option.fromUndefinedOr(getNameOfDeclaration(container))),\n Option.map((name) => ` of ${name.getText()}`),\n Option.getOrElse(() => \"\"),\n );\n const name = Option.fromUndefinedOr(getNameOfDeclaration(slot)).pipe(\n Option.map((found) => found.getText()),\n Option.getOrElse(() => \"value\"),\n );\n return `${name}${owner} from ${packageOf(slot.getSourceFile().fileName)}`;\n }),\n );\n\nconst libraryTargetOf =\n (context: FlowContext) =>\n (expression: Expression, contextual: Type): Option.Option<string> =>\n aliasTarget(context)(contextual).pipe(Option.orElse(() => slotTarget(context)(expression)));\n\nconst siteWithin =\n (context: FlowContext) =>\n (node: Node): Option.Option<ValueSite> =>\n Arr.findFirst(context.sites, (site) => contains(node)(site.node));\n\nconst aliasSite =\n (context: FlowContext) =>\n (type: Type): Option.Option<ValueSite> =>\n Option.fromUndefinedOr(type.getAliasSymbol()).pipe(\n Option.flatMap((alias) => Arr.findFirst(declarationsOf(alias), isTypeAliasDeclaration)),\n Option.flatMap(siteWithin(context)),\n );\n\nconst annotationSite =\n (context: FlowContext) =>\n (expression: Expression): Option.Option<ValueSite> =>\n symbolAt(context.checker)(expression).pipe(\n Option.flatMap((symbol) => Option.fromUndefinedOr(symbol.valueDeclaration)),\n Option.flatMap((handle) => Option.fromUndefinedOr(handle.resolve())),\n Option.flatMap(annotationOf),\n Option.flatMap((annotation) =>\n siteWithin(context)(annotation).pipe(\n Option.orElse(() => aliasSite(context)(context.checker.getTypeFromTypeNode(annotation))),\n ),\n ),\n );\n\nconst siteBehind =\n (context: FlowContext) =>\n (expression: Expression): Option.Option<ValueSite> =>\n aliasSite(context)(context.checker.getTypeAtLocation(expression)).pipe(\n Option.orElse(() => annotationSite(context)(expression)),\n );\n\nconst isFlowSource = (node: Node): node is Expression =>\n isIdentifier(node) || isPropertyAccessExpression(node) || isElementAccessExpression(node);\n\nconst flowOf =\n (context: FlowContext) =>\n (expression: Expression): Option.Option<Flow> =>\n Option.fromUndefinedOr(context.checker.getContextualType(expression)).pipe(\n Option.flatMap((contextual) =>\n Option.all([\n vocabularyOf(context.checker)(contextual),\n libraryTargetOf(context)(expression, contextual),\n ]),\n ),\n Option.flatMap(([vocabulary, target]) =>\n siteBehind(context)(expression).pipe(\n Option.filter((site) => isSubsetOf(site.values, vocabulary.values)),\n Option.map((site) => ({ site, target })),\n ),\n ),\n );\n\nexport const flowsIn =\n (context: FlowContext) =>\n (sourceFile: SourceFile): readonly Flow[] =>\n Arr.getSomes(\n pipe(\n descendantsOf(sourceFile),\n Arr.filter((node) => isFlowSource(node)),\n Arr.map((node) => flowOf(context)(node)),\n ),\n );\n","import { Array as Arr, Option, String as Str, pipe } from \"effect\";\n\nimport type { Project } from \"#/entities/project/index.ts\";\nimport {\n getJSDocTags,\n getTextOfJSDocComment,\n isIdentifier,\n isSourceFile,\n isVariableDeclaration,\n isVariableDeclarationList,\n isVariableStatement,\n SyntaxKind,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Node,\n SourceFile,\n Type,\n VariableDeclaration,\n VariableDeclarationList,\n} from \"#/shared/lib/compiler.ts\";\nimport { problemAt } from \"#/shared/lib/problem.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { columnOf, descendantsOf, lineOf } from \"#/shared/lib/syntax.ts\";\nimport { finiteValuesOf, formatValues, literalValuesOf, sameValues } from \"#/shared/lib/values.ts\";\nimport type { Value } from \"#/shared/lib/values.ts\";\n\nexport interface Owner {\n readonly conceptId: string;\n readonly key: string;\n readonly name: string;\n readonly file: string;\n readonly line: number;\n readonly column: number;\n readonly packageName: Option.Option<string>;\n readonly values: readonly Value[];\n}\n\nexport interface OwnerScan {\n readonly owners: readonly Owner[];\n readonly problems: readonly Problem[];\n}\n\ninterface Annotated {\n readonly node: Node;\n readonly conceptId: string;\n}\n\nexport const OWNER_TAG = \"msch\";\nconst FIRST_OWNER_COUNT = 1;\n\nexport const ownerKeyOf = (declaration: Declaration): Option.Option<string> => {\n if (!isVariableDeclaration(declaration) || !isIdentifier(declaration.name)) {\n return Option.none();\n }\n return Option.some(`${declaration.getSourceFile().fileName}#${declaration.name.text}`);\n};\n\nconst annotationsOf = (node: Node): readonly Annotated[] =>\n pipe(\n getJSDocTags(node),\n Arr.filter((tag) => tag.tagName.text === OWNER_TAG),\n Arr.map((tag) => ({ node, conceptId: Str.trim(getTextOfJSDocComment(tag.comment) ?? \"\") })),\n );\n\nconst ANNOTATABLE_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.VariableDeclaration,\n SyntaxKind.FunctionDeclaration,\n SyntaxKind.ClassDeclaration,\n SyntaxKind.InterfaceDeclaration,\n SyntaxKind.TypeAliasDeclaration,\n SyntaxKind.EnumDeclaration,\n SyntaxKind.PropertySignature,\n SyntaxKind.PropertyAssignment,\n SyntaxKind.PropertyDeclaration,\n]);\n\nconst isAnnotatable = (node: Node): boolean => ANNOTATABLE_KINDS.has(node.kind);\n\nconst isConstList = (list: VariableDeclarationList): boolean =>\n Option.fromUndefinedOr(list.getFirstToken()).pipe(\n Option.exists((token) => token.kind === SyntaxKind.ConstKeyword),\n );\n\nconst isModuleStatementList = (list: VariableDeclarationList): boolean =>\n isVariableStatement(list.parent) && isSourceFile(list.parent.parent);\n\nconst isModuleConstList = (node: Node): node is VariableDeclarationList =>\n isVariableDeclarationList(node) && isModuleStatementList(node) && isConstList(node);\n\nconst isModuleConst = (node: Node): node is VariableDeclaration =>\n isVariableDeclaration(node) && isIdentifier(node.name) && isModuleConstList(node.parent);\n\nconst objectValuesOf =\n (checker: Checker) =>\n (type: Type): Option.Option<readonly Value[]> =>\n literalValuesOf(\n pipe(\n checker.getPropertiesOfType(type),\n Arr.map((property) => checker.getTypeOfSymbol(property)),\n ),\n );\n\nconst ownerValuesOf =\n (checker: Checker) =>\n (declaration: VariableDeclaration): Option.Option<readonly Value[]> => {\n const type = checker.getTypeAtLocation(declaration.name);\n return finiteValuesOf(checker)(type).pipe(Option.orElse(() => objectValuesOf(checker)(type)));\n };\n\nconst annotationProblem = (message: string): ((node: Node) => Problem) =>\n problemAt({ rule: \"owner-annotation\", message });\n\nconst scanned = (owners: readonly Owner[], problems: readonly Problem[]): OwnerScan => ({\n owners,\n problems,\n});\n\nconst ownerOf =\n (project: Project) =>\n (annotated: Annotated): OwnerScan => {\n const { node, conceptId } = annotated;\n if (!isModuleConst(node)) {\n return scanned(\n [],\n [annotationProblem(`@${OWNER_TAG} registers an owner only on a module-scope const.`)(node)],\n );\n }\n if (conceptId === \"\") {\n return scanned([], [annotationProblem(`@${OWNER_TAG} needs a concept id.`)(node)]);\n }\n const values = ownerValuesOf(project.checker)(node);\n return Option.match(Option.all([values, ownerKeyOf(node)]), {\n onNone: () =>\n scanned(\n [],\n [annotationProblem(`The owner of ${conceptId} holds no finite value set.`)(node)],\n ),\n onSome: ([ownedValues, key]) =>\n scanned(\n [\n {\n conceptId,\n key,\n name: node.name.getText(),\n file: node.getSourceFile().fileName,\n line: lineOf(node),\n column: columnOf(node),\n packageName: project.packageName,\n values: ownedValues,\n },\n ],\n [],\n ),\n });\n };\n\nconst annotatedIn = (sourceFile: SourceFile): readonly Annotated[] =>\n pipe(\n descendantsOf(sourceFile),\n Arr.filter((node) => isAnnotatable(node)),\n Arr.flatMap((node) => annotationsOf(node)),\n );\n\nconst ownerProblem =\n (message: string) =>\n (owner: Owner): Problem => ({\n file: owner.file,\n line: owner.line,\n column: owner.column,\n rule: \"owner-annotation\",\n message,\n });\n\nconst conflictProblems = (owners: readonly Owner[]): readonly Problem[] =>\n pipe(\n owners,\n Arr.flatMap((owner, index) => {\n const earlier = Arr.take(owners, index);\n const sameConcept = pipe(\n earlier,\n Arr.filter((other) => other.conceptId === owner.conceptId),\n );\n const sameSet = pipe(\n earlier,\n Arr.filter(\n (other) => other.conceptId !== owner.conceptId && sameValues(other.values, owner.values),\n ),\n );\n return [\n ...pipe(\n Arr.take(sameConcept, FIRST_OWNER_COUNT),\n Arr.map(() =>\n ownerProblem(`The concept ${owner.conceptId} already has an owner.`)(owner),\n ),\n ),\n ...pipe(\n Arr.take(sameSet, FIRST_OWNER_COUNT),\n Arr.map((other) =>\n ownerProblem(\n `The values ${formatValues(owner.values)} are already owned by ${other.conceptId}.`,\n )(owner),\n ),\n ),\n ];\n }),\n );\n\nexport const ownersIn = (project: Project): OwnerScan => {\n const results = pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) =>\n pipe(\n annotatedIn(sourceFile),\n Arr.map((annotated) => ownerOf(project)(annotated)),\n ),\n ),\n );\n return scanned(\n pipe(\n results,\n Arr.flatMap((result) => result.owners),\n ),\n pipe(\n results,\n Arr.flatMap((result) => result.problems),\n ),\n );\n};\n\nexport const combineOwnerScans = (scans: readonly OwnerScan[]): OwnerScan => {\n const owners = Arr.dedupeWith(\n pipe(\n scans,\n Arr.flatMap((scan) => scan.owners),\n ),\n (left, right) => left.key === right.key,\n );\n const problems = [\n ...pipe(\n scans,\n Arr.flatMap((scan) => scan.problems),\n ),\n ...conflictProblems(owners),\n ];\n return { owners, problems };\n};\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport { declarationKey, locationOf } from \"#/entities/project/index.ts\";\nimport { isSatisfiesExpression, isVariableDeclaration } from \"#/shared/lib/compiler.ts\";\nimport type { Checker, Node } from \"#/shared/lib/compiler.ts\";\nimport { declarationsOf, referencedSymbols } from \"#/shared/lib/syntax.ts\";\n\nconst contractOf = (node: Node): readonly Node[] => {\n const { parent } = node;\n if (isSatisfiesExpression(parent) && parent.expression === node) {\n return [parent.type];\n }\n if (isVariableDeclaration(parent) && parent.initializer === node) {\n return Option.toArray(Option.fromUndefinedOr(parent.type));\n }\n return [];\n};\n\nexport const derivedDeclarationsOf =\n (checker: Checker) =>\n (node: Node): ReadonlySet<string> => {\n const scopes = Arr.prepend(contractOf(node), node);\n return new Set(\n pipe(\n scopes,\n Arr.flatMap((scope) => referencedSymbols(checker)(scope)),\n Arr.flatMap((symbol) => declarationsOf(symbol)),\n Arr.map((declaration) => declarationKey(locationOf(declaration))),\n ),\n );\n };\n","import { Array as Arr, Option, Order, pipe } from \"effect\";\n\nimport { declarationKey, describeLibraryType, isObjectType } from \"#/entities/project/index.ts\";\nimport type { DeclarationLocation, LibraryShape } from \"#/entities/project/index.ts\";\nimport {\n isCallExpression,\n isInterfaceDeclaration,\n isModuleBlock,\n isModuleDeclaration,\n isObjectLiteralExpression,\n isStringLiteral,\n isTypeAliasDeclaration,\n isTypeLiteralNode,\n isVariableDeclaration,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n Checker,\n EnumDeclaration,\n InterfaceDeclaration,\n Node,\n Program,\n SourceFile,\n TypeSymbol,\n Type,\n TypeAliasDeclaration,\n VariableDeclaration,\n} from \"#/shared/lib/compiler.ts\";\nimport { CANDIDATE_LIMIT, problemAt } from \"#/shared/lib/problem.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { descendantsOf, isGenericDeclaration, isTypeDeclaration } from \"#/shared/lib/syntax.ts\";\nimport { schemaTypeOf } from \"#/shared/lib/values.ts\";\n\nimport { derivedDeclarationsOf } from \"./derivation.ts\";\n\nexport interface ShapeContext {\n readonly checker: Checker;\n readonly program: Program;\n readonly shapes: readonly LibraryShape[];\n}\n\ninterface ShapeSite {\n readonly node: Node;\n readonly type: Type;\n}\n\ninterface ShapeMatch {\n readonly shape: LibraryShape;\n readonly extra: number;\n}\n\nconst MINIMUM_SHAPE_PROPERTIES = 3;\nconst EXACT = 0;\n\nconst augmentsAModule = (node: Node): boolean => {\n const block = node.parent;\n return (\n isModuleBlock(block) && isModuleDeclaration(block.parent) && isStringLiteral(block.parent.name)\n );\n};\n\nconst isPlainInterface = (node: Node): node is InterfaceDeclaration =>\n isInterfaceDeclaration(node) && !isGenericDeclaration(node) && !augmentsAModule(node);\n\nconst isPlainTypeLiteral = (node: Node): node is TypeAliasDeclaration =>\n isTypeAliasDeclaration(node) && !isGenericDeclaration(node) && isTypeLiteralNode(node.type);\n\nconst isDeclaredShape = (node: Node): node is InterfaceDeclaration | TypeAliasDeclaration =>\n isPlainInterface(node) || isPlainTypeLiteral(node);\n\nconst declaredShapeOf =\n (checker: Checker) =>\n (node: Node): Option.Option<Type> =>\n Option.liftPredicate(node, isDeclaredShape).pipe(\n Option.map((declaration) => checker.getTypeAtLocation(declaration.name)),\n );\n\nconst schemaShapeOf =\n (checker: Checker) =>\n (node: Node): Option.Option<Type> => {\n if (!isCallExpression(node)) {\n return Option.none();\n }\n const { arguments: callArguments } = node;\n if (\n !pipe(\n callArguments,\n Arr.some((argument) => isObjectLiteralExpression(argument)),\n )\n ) {\n return Option.none();\n }\n return schemaTypeOf(checker)(checker.getTypeAtLocation(node)).pipe(\n Option.filter((type) => isObjectType(checker)(type)),\n );\n };\n\nconst shapeSitesIn =\n (checker: Checker) =>\n (sourceFile: SourceFile): readonly ShapeSite[] =>\n Arr.getSomes(\n pipe(\n descendantsOf(sourceFile),\n Arr.map((node) =>\n declaredShapeOf(checker)(node).pipe(\n Option.orElse(() => schemaShapeOf(checker)(node)),\n Option.map((type) => ({ node, type })),\n ),\n ),\n ),\n );\n\ninterface LocalProperty {\n readonly name: string;\n readonly type: Type;\n}\n\ninterface OpenTypeIds {\n readonly any: number;\n readonly unknown: number;\n}\n\nconst openTypeIdsOf = (checker: Checker): OpenTypeIds => ({\n any: checker.getAnyType().id,\n unknown: checker.getUnknownType().id,\n});\n\ntype IndexedDeclaration =\n | TypeAliasDeclaration\n | InterfaceDeclaration\n | EnumDeclaration\n | VariableDeclaration;\n\nconst isIndexedDeclaration = (node: Node): node is IndexedDeclaration =>\n isTypeDeclaration(node) || isVariableDeclaration(node);\n\nconst declarationAt =\n (program: Program) =>\n (location: DeclarationLocation): Option.Option<IndexedDeclaration> =>\n Option.fromUndefinedOr(program.getSourceFile(location.file)).pipe(\n Option.flatMap((sourceFile) =>\n Arr.findFirst(\n descendantsOf(sourceFile),\n (node): node is IndexedDeclaration =>\n node.pos === location.pos && node.kind === location.kind && isIndexedDeclaration(node),\n ),\n ),\n );\n\nconst symbolOfDeclaration =\n (checker: Checker) =>\n (declaration: IndexedDeclaration): Option.Option<TypeSymbol> =>\n Option.fromUndefinedOr(checker.getSymbolAtLocation(declaration.name));\n\nconst shapeTypeOf =\n (context: ShapeContext) =>\n (shape: LibraryShape): Option.Option<Type> => {\n const { checker } = context;\n return declarationAt(context.program)(shape.declaration).pipe(\n Option.flatMap((declaration) =>\n symbolOfDeclaration(checker)(declaration).pipe(\n Option.flatMap((symbol) => {\n if (shape.form === \"declared\") {\n return Option.some(checker.getDeclaredTypeOfSymbol(symbol));\n }\n return schemaTypeOf(checker)(checker.getTypeOfSymbolAtLocation(symbol, declaration));\n }),\n ),\n ),\n );\n };\n\nconst hasEveryName =\n (locals: readonly LocalProperty[]) =>\n (shape: LibraryShape): boolean => {\n const names: ReadonlySet<string> = new Set(shape.propertyNames);\n return pipe(\n locals,\n Arr.every((local) => names.has(local.name)),\n );\n };\n\nconst sameProperty =\n (checker: Checker, open: OpenTypeIds) =>\n (localType: Type, library: TypeSymbol): boolean => {\n const libraryType = checker.getTypeOfSymbol(library);\n return (\n libraryType.id !== open.any &&\n libraryType.id !== open.unknown &&\n checker.isTypeAssignableTo(localType, libraryType) &&\n checker.isTypeAssignableTo(libraryType, localType)\n );\n };\n\nconst matchOf =\n (context: ShapeContext, open: OpenTypeIds) =>\n (locals: readonly LocalProperty[], shape: LibraryShape): Option.Option<ShapeMatch> => {\n const { checker } = context;\n const matches = shapeTypeOf(context)(shape).pipe(\n Option.exists((shapeType) =>\n pipe(\n locals,\n Arr.every((local) =>\n Option.fromUndefinedOr(checker.getPropertyOfType(shapeType, local.name)).pipe(\n Option.exists((library) => sameProperty(checker, open)(local.type, library)),\n ),\n ),\n ),\n ),\n );\n if (!matches) {\n return Option.none();\n }\n return Option.some({ shape, extra: shape.propertyNames.length - locals.length });\n };\n\nconst localPropertiesOf =\n (checker: Checker) =>\n (symbols: readonly TypeSymbol[]): readonly LocalProperty[] =>\n pipe(\n Arr.zip(symbols, checker.getTypeOfSymbol(symbols)),\n Arr.map(([symbol, type]) => ({ name: symbol.name, type })),\n );\n\nconst matchOrder = Order.mapInput(Order.Number, (match: ShapeMatch) => match.extra);\n\nconst shapeProblem = (site: ShapeSite, matches: readonly ShapeMatch[]): Problem => {\n const shown = pipe(\n Arr.take(matches, CANDIDATE_LIMIT),\n Arr.map((match) => describeLibraryType(match.shape)),\n Arr.join(\", \"),\n );\n const advice = Option.match(\n Arr.findFirst(matches, (match) => match.extra === EXACT),\n {\n onNone: () =>\n \"Derive it from the library type, for example with Pick, instead of copying its properties.\",\n onSome: () => \"Use the library type instead of copying it.\",\n },\n );\n return problemAt({ rule: \"library-shape\", message: `This shape copies ${shown}. ${advice}` })(\n site.node,\n );\n};\n\nconst candidatesOf =\n (context: ShapeContext, open: OpenTypeIds) =>\n (site: ShapeSite, locals: readonly LocalProperty[]): readonly ShapeMatch[] => {\n const derived = derivedDeclarationsOf(context.checker)(site.node);\n const named = pipe(context.shapes, Arr.filter(hasEveryName(locals)));\n if (\n pipe(\n named,\n Arr.some((shape) => derived.has(declarationKey(shape.declaration))),\n )\n ) {\n return [];\n }\n const candidates = pipe(\n named,\n Arr.map((shape) => matchOf(context, open)(locals, shape)),\n Arr.getSomes,\n );\n return Arr.sort(candidates, matchOrder);\n };\n\nconst shapeProblemOf =\n (context: ShapeContext, open: OpenTypeIds) =>\n (site: ShapeSite): Option.Option<Problem> => {\n const symbols = context.checker.getPropertiesOfType(site.type);\n if (symbols.length < MINIMUM_SHAPE_PROPERTIES) {\n return Option.none();\n }\n const locals = localPropertiesOf(context.checker)(symbols);\n return Option.liftPredicate(\n candidatesOf(context, open)(site, locals),\n Arr.isReadonlyArrayNonEmpty,\n ).pipe(Option.map((found) => shapeProblem(site, found)));\n };\n\nexport const shapeProblemsIn =\n (context: ShapeContext) =>\n (sourceFile: SourceFile): readonly Problem[] => {\n const sites = shapeSitesIn(context.checker)(sourceFile);\n if (!Arr.isReadonlyArrayNonEmpty(sites)) {\n return [];\n }\n const open = openTypeIdsOf(context.checker);\n return Arr.getSomes(\n pipe(\n sites,\n Arr.map((site) => shapeProblemOf(context, open)(site)),\n ),\n );\n };\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport {\n isArrayLiteralExpression,\n isCallExpression,\n isElementAccessExpression,\n isEnumDeclaration,\n isIdentifier,\n isPropertyAccessExpression,\n isSpreadElement,\n isTypeReferenceNode,\n isUnionTypeNode,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n ArrayLiteralExpression,\n CallExpression,\n Checker,\n Expression,\n Node,\n TypeSymbol,\n TypeNode,\n UnionTypeNode,\n} from \"#/shared/lib/compiler.ts\";\nimport {\n childrenOf,\n declarationsOf,\n isTypeDeclaration,\n propertyNamesOf,\n referencedSymbols,\n} from \"#/shared/lib/syntax.ts\";\nimport { finiteValuesOf, isSubsetOf, literalUnionOf, schemaTypeOf } from \"#/shared/lib/values.ts\";\nimport type { Value } from \"#/shared/lib/values.ts\";\n\nexport interface ValueSite {\n readonly node: Node;\n readonly values: readonly Value[];\n readonly sources: readonly TypeSymbol[];\n}\n\nconst namedValuesOf =\n (checker: Checker) =>\n (symbol: TypeSymbol): Option.Option<readonly Value[]> => {\n if (\n pipe(\n declarationsOf(symbol),\n Arr.some((declaration) => isTypeDeclaration(declaration)),\n )\n ) {\n return finiteValuesOf(checker)(checker.getDeclaredTypeOfSymbol(symbol));\n }\n return finiteValuesOf(checker)(checker.getTypeOfSymbol(symbol));\n };\n\nconst hasFiniteContext =\n (checker: Checker) =>\n (node: Expression): boolean =>\n Option.fromUndefinedOr(checker.getContextualType(node)).pipe(\n Option.flatMap(finiteValuesOf(checker)),\n Option.isSome,\n );\n\nconst isNamedValue = (element: Expression): boolean => {\n if (isSpreadElement(element)) {\n return isNamedValue(element.expression);\n }\n return (\n isIdentifier(element) ||\n isPropertyAccessExpression(element) ||\n isElementAccessExpression(element)\n );\n};\n\nconst namesEveryElement = (array: ArrayLiteralExpression): boolean =>\n pipe(\n array.elements,\n Arr.every((element) => isNamedValue(element)),\n );\n\nconst expressionValuesOf =\n (checker: Checker) =>\n (node: Expression): Option.Option<readonly Value[]> => {\n if (hasFiniteContext(checker)(node)) {\n return Option.none();\n }\n const type = checker.getTypeAtLocation(node);\n if (isArrayLiteralExpression(node)) {\n return Option.liftPredicate(node, (array) => !namesEveryElement(array)).pipe(\n Option.flatMap(() => finiteValuesOf(checker)(type)),\n );\n }\n return schemaTypeOf(checker)(type).pipe(Option.flatMap(literalUnionOf));\n };\n\nconst selectsKeys =\n (checker: Checker) =>\n (node: UnionTypeNode, values: readonly Value[]): boolean => {\n const { parent } = node;\n if (!isTypeReferenceNode(parent)) {\n return false;\n }\n const typeArguments: readonly TypeNode[] = parent.typeArguments ?? [];\n return pipe(\n typeArguments,\n Arr.filter((argument) => argument !== node),\n Arr.some((argument) =>\n isSubsetOf(values, propertyNamesOf(checker)(checker.getTypeFromTypeNode(argument))),\n ),\n );\n };\n\nconst unionValuesOf =\n (checker: Checker) =>\n (node: UnionTypeNode): Option.Option<readonly Value[]> =>\n literalUnionOf(checker.getTypeFromTypeNode(node)).pipe(\n Option.filter((values) => !selectsKeys(checker)(node, values)),\n );\n\nconst isExpressionSite = (node: Node): node is ArrayLiteralExpression | CallExpression =>\n isArrayLiteralExpression(node) || isCallExpression(node);\n\nconst expressionSiteValuesOf =\n (checker: Checker) =>\n (node: Node): Option.Option<readonly Value[]> =>\n Option.liftPredicate(node, isExpressionSite).pipe(Option.flatMap(expressionValuesOf(checker)));\n\nconst siteValuesOf =\n (checker: Checker) =>\n (node: Node): Option.Option<readonly Value[]> => {\n if (isUnionTypeNode(node)) {\n return unionValuesOf(checker)(node);\n }\n if (isEnumDeclaration(node)) {\n return literalUnionOf(checker.getTypeAtLocation(node.name));\n }\n return expressionSiteValuesOf(checker)(node);\n };\n\nconst derivationScopeOf = (node: Node): Node => {\n if (isTypeReferenceNode(node.parent)) {\n return node.parent;\n }\n return node;\n};\n\nconst sourcesOf =\n (checker: Checker) =>\n (node: Node): readonly TypeSymbol[] =>\n pipe(\n referencedSymbols(checker)(derivationScopeOf(node)),\n Arr.filter((symbol) => Option.isSome(namedValuesOf(checker)(symbol))),\n );\n\nexport const sitesUnder =\n (checker: Checker) =>\n (node: Node): readonly ValueSite[] => {\n const nested = pipe(\n childrenOf(node),\n Arr.flatMap((child) => sitesUnder(checker)(child)),\n );\n if (Arr.isReadonlyArrayNonEmpty(nested)) {\n return nested;\n }\n return siteValuesOf(checker)(node).pipe(\n Option.map((values) => ({ node, values, sources: sourcesOf(checker)(node) })),\n Option.toArray,\n );\n };\n","import { Array as Arr, Option, pipe } from \"effect\";\n\nimport { describeLibraryType } from \"#/entities/project/index.ts\";\nimport type { LibraryVocabulary } from \"#/entities/project/index.ts\";\nimport {\n isBinaryExpression,\n isCallExpression,\n isNewExpression,\n isNumericLiteral,\n isPropertyAssignment,\n isStringLiteral,\n isTypeAliasDeclaration,\n isVariableDeclaration,\n SyntaxKind,\n} from \"#/shared/lib/compiler.ts\";\nimport type {\n Checker,\n Declaration,\n Node,\n NumericLiteral,\n SourceFile,\n StringLiteral,\n TypeSymbol,\n} from \"#/shared/lib/compiler.ts\";\nimport { CANDIDATE_LIMIT, problemAt } from \"#/shared/lib/problem.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport {\n contains,\n declarationsOf,\n descendantsOf,\n importedModulesOf,\n referencedSymbols,\n uniqueByReference,\n} from \"#/shared/lib/syntax.ts\";\nimport { formatValues, isSubsetOf, vocabularyOf } from \"#/shared/lib/values.ts\";\n\nimport type { Flow } from \"./flows.ts\";\nimport { ownerKeyOf } from \"./owners.ts\";\nimport type { Owner } from \"./owners.ts\";\nimport type { ValueSite } from \"./sites.ts\";\nimport { contextSymbolsOf } from \"./slots.ts\";\n\nexport interface ValueContext {\n readonly checker: Checker;\n readonly owners: readonly Owner[];\n readonly vocabularies: readonly LibraryVocabulary[];\n readonly flows: readonly Flow[];\n}\n\nexport interface SiteVerdict {\n readonly problems: readonly Problem[];\n readonly unowned: readonly ValueSite[];\n}\n\nconst OWNER_SEARCH_DEPTH = 4;\nconst NOTHING_HIDDEN = 0;\n\nconst directOwners =\n (context: ValueContext) =>\n (symbol: TypeSymbol): readonly Owner[] => {\n const keys = Arr.getSomes(\n pipe(\n declarationsOf(symbol),\n Arr.map((declaration) => ownerKeyOf(declaration)),\n ),\n );\n return pipe(\n context.owners,\n Arr.filter((owner) => keys.includes(owner.key)),\n );\n };\n\nconst isFollowable = (declaration: Declaration): boolean =>\n !declaration.getSourceFile().isDeclarationFile &&\n (isTypeAliasDeclaration(declaration) || isVariableDeclaration(declaration));\n\nconst ownersBehind =\n (context: ValueContext) =>\n (symbol: TypeSymbol, ancestors: readonly TypeSymbol[]): readonly Owner[] => {\n const direct = directOwners(context)(symbol);\n if (Arr.isReadonlyArrayNonEmpty(direct) || ancestors.length >= OWNER_SEARCH_DEPTH) {\n return direct;\n }\n const visited = [...ancestors, symbol];\n return uniqueByReference(\n pipe(\n declarationsOf(symbol),\n Arr.filter((declaration) => isFollowable(declaration)),\n Arr.flatMap((declaration) => referencedSymbols(context.checker)(declaration)),\n Arr.filter((referenced) => !visited.includes(referenced)),\n Arr.flatMap((referenced) => ownersBehind(context)(referenced, visited)),\n ),\n );\n };\n\nconst describeOwners = (owners: readonly Owner[]): string =>\n pipe(\n owners,\n Arr.map((owner) => `${owner.conceptId} (${owner.name})`),\n Arr.join(\", \"),\n );\n\nconst verdict = (problems: readonly Problem[], unowned: readonly ValueSite[]): SiteVerdict => ({\n problems,\n unowned,\n});\n\nconst derivedVerdict =\n (context: ValueContext) =>\n (site: ValueSite): SiteVerdict => {\n const owners = uniqueByReference(\n pipe(\n site.sources,\n Arr.flatMap((source) => ownersBehind(context)(source, [])),\n ),\n );\n const held = pipe(\n owners,\n Arr.flatMap((owner) => owner.values),\n );\n const added = pipe(\n site.values,\n Arr.filter((value) => !isSubsetOf([value], held)),\n );\n if (!Arr.isReadonlyArrayNonEmpty(owners) || !Arr.isReadonlyArrayNonEmpty(added)) {\n return verdict([], []);\n }\n 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.`;\n return verdict([problemAt({ rule: \"owner-extension\", message })(site.node)], []);\n };\n\nconst libraryCandidates =\n (context: ValueContext) =>\n (site: ValueSite): readonly string[] => {\n const flowing = Arr.dedupe(\n pipe(\n context.flows,\n Arr.filter((flow) => flow.site.node === site.node),\n Arr.map((flow) => flow.target),\n ),\n );\n if (Arr.isReadonlyArrayNonEmpty(flowing)) {\n return flowing;\n }\n if (\n !pipe(\n site.values,\n Arr.some((value) => typeof value === \"string\"),\n )\n ) {\n return [];\n }\n const imported = importedModulesOf(site.node.getSourceFile());\n return Arr.dedupe(\n pipe(\n context.vocabularies,\n Arr.filter((library) => imported.includes(library.specifier)),\n Arr.filter((library) => isSubsetOf(site.values, library.vocabulary.values)),\n Arr.map((library) => describeLibraryType(library)),\n ),\n );\n };\n\nconst listCandidates = (candidates: readonly string[]): string => {\n const shown = pipe(Arr.take(candidates, CANDIDATE_LIMIT), Arr.join(\", \"));\n const hidden = candidates.length - CANDIDATE_LIMIT;\n if (hidden > NOTHING_HIDDEN) {\n return `${shown} and ${String(hidden)} more`;\n }\n return shown;\n};\n\nconst originalVerdict =\n (context: ValueContext) =>\n (site: ValueSite): SiteVerdict => {\n const owners = pipe(\n context.owners,\n Arr.filter((owner) => isSubsetOf(site.values, owner.values)),\n );\n if (Arr.isReadonlyArrayNonEmpty(owners)) {\n const message = `The values ${formatValues(site.values)} are owned by ${describeOwners(owners)}. Derive this set from the owner instead of restating it.`;\n return verdict([problemAt({ rule: \"owner-value-set\", message })(site.node)], []);\n }\n const candidates = libraryCandidates(context)(site);\n if (Arr.isReadonlyArrayNonEmpty(candidates)) {\n const message = `The values ${formatValues(site.values)} restate a dependency type: ${listCandidates(candidates)}. Derive this set from the library type.`;\n return verdict([problemAt({ rule: \"library-value-set\", message })(site.node)], []);\n }\n return verdict([], [site]);\n };\n\nexport const siteVerdict =\n (context: ValueContext) =>\n (site: ValueSite): SiteVerdict => {\n if (Arr.isReadonlyArrayNonEmpty(site.sources)) {\n return derivedVerdict(context)(site);\n }\n return originalVerdict(context)(site);\n };\n\nconst VALUE_PARENT_KINDS: ReadonlySet<SyntaxKind> = new Set([\n SyntaxKind.ReturnStatement,\n SyntaxKind.ArrayLiteralExpression,\n SyntaxKind.ConditionalExpression,\n SyntaxKind.ParenthesizedExpression,\n SyntaxKind.ArrowFunction,\n SyntaxKind.JsxExpression,\n]);\n\nconst isCallArgument = (node: Node, parent: Node): boolean =>\n (isCallExpression(parent) || isNewExpression(parent)) && parent.expression !== node;\n\nconst isInitializer = (node: Node, parent: Node): boolean =>\n (isPropertyAssignment(parent) || isVariableDeclaration(parent)) && parent.initializer === node;\n\nconst isRightOperand = (node: Node, parent: Node): boolean =>\n isBinaryExpression(parent) && parent.right === node;\n\nconst VALUE_SLOTS = [isCallArgument, isInitializer, isRightOperand];\n\nconst isValuePosition = (node: Node): boolean => {\n const { parent } = node;\n return (\n VALUE_PARENT_KINDS.has(parent.kind) ||\n pipe(\n VALUE_SLOTS,\n Arr.some((isSlot) => isSlot(node, parent)),\n )\n );\n};\n\nconst ownedLiteralProblem =\n (context: ValueContext) =>\n (literal: StringLiteral | NumericLiteral): Option.Option<Problem> =>\n Option.fromUndefinedOr(context.checker.getContextualType(literal)).pipe(\n Option.filter((contextual) =>\n vocabularyOf(context.checker)(contextual).pipe(\n Option.exists((vocabulary) => !vocabulary.admitsUnnamedValues),\n ),\n ),\n Option.map(() =>\n pipe(\n contextSymbolsOf(context.checker)(literal),\n Arr.flatMap((symbol) => ownersBehind(context)(symbol, [])),\n uniqueByReference,\n Arr.filter((owner) => isSubsetOf([literal.text], pipe(owner.values, Arr.map(String)))),\n ),\n ),\n Option.filter((owners) => Arr.isReadonlyArrayNonEmpty(owners)),\n Option.map((owners) =>\n problemAt({\n rule: \"owned-literal\",\n message: `${literal.getText()} is a value of ${describeOwners(owners)}. Write it through the owner's binding instead of as a literal.`,\n })(literal),\n ),\n );\n\nexport const ownedLiteralProblems =\n (context: ValueContext) =>\n (sourceFile: SourceFile, excluded: readonly Node[]): readonly Problem[] =>\n Arr.getSomes(\n pipe(\n descendantsOf(sourceFile),\n Arr.filter((node) => isStringLiteral(node) || isNumericLiteral(node)),\n Arr.filter((node) => isValuePosition(node)),\n Arr.filter(\n (node) =>\n !pipe(\n excluded,\n Arr.some((outer) => contains(outer)(node)),\n ),\n ),\n Arr.map((node) => ownedLiteralProblem(context)(node)),\n ),\n );\n","import { Option, Array as Arr, pipe } from \"effect\";\n\nimport type { Project } from \"#/entities/project/index.ts\";\nimport { isVariableDeclaration } from \"#/shared/lib/compiler.ts\";\nimport type { Checker, Node, VariableDeclaration } from \"#/shared/lib/compiler.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { contains, descendantsOf } from \"#/shared/lib/syntax.ts\";\n\nimport { flowsIn } from \"./flows.ts\";\nimport { ownerKeyOf } from \"./owners.ts\";\nimport type { Owner } from \"./owners.ts\";\nimport { shapeProblemsIn } from \"./shapes.ts\";\nimport { sitesUnder } from \"./sites.ts\";\nimport type { ValueSite } from \"./sites.ts\";\nimport { ownedLiteralProblems, siteVerdict } from \"./value-checks.ts\";\n\nexport interface ProjectAnalysis {\n readonly problems: readonly Problem[];\n readonly unowned: readonly ValueSite[];\n}\n\nconst isVisibleTo =\n (project: Project) =>\n (owner: Owner): boolean =>\n pipe(\n project.sourceFiles,\n Arr.some((sourceFile) => sourceFile.fileName === owner.file),\n ) ||\n Option.exists(\n owner.packageName,\n (name) =>\n Option.contains(project.packageName, name) || project.workspaceDependencies.includes(name),\n );\n\nconst ownerDeclarationsIn = (\n project: Project,\n owners: readonly Owner[],\n): readonly VariableDeclaration[] => {\n const keys = new Set(\n pipe(\n owners,\n Arr.map((owner) => owner.key),\n ),\n );\n return pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) =>\n pipe(\n descendantsOf(sourceFile),\n Arr.filter((node) => isVariableDeclaration(node)),\n Arr.filter((declaration) => Option.exists(ownerKeyOf(declaration), (key) => keys.has(key))),\n ),\n ),\n );\n};\n\nconst isInside =\n (outers: readonly Node[]) =>\n (node: Node): boolean =>\n pipe(\n outers,\n Arr.some((outer) => contains(outer)(node)),\n );\n\nconst sitesOutside =\n (checker: Checker) =>\n (project: Project, outers: readonly Node[]): readonly ValueSite[] =>\n pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) => sitesUnder(checker)(sourceFile)),\n Arr.filter((site) => !isInside(outers)(site.node)),\n );\n\nconst nodesOf = (sites: readonly ValueSite[]): readonly Node[] =>\n pipe(\n sites,\n Arr.map((site) => site.node),\n );\n\nexport const analyzeProject =\n (owners: readonly Owner[]) =>\n (project: Project): ProjectAnalysis => {\n const { checker } = project;\n const ownerDeclarations = ownerDeclarationsIn(project, owners);\n const sites = sitesOutside(checker)(project, ownerDeclarations);\n const flowContext = { checker, program: project.program, sites };\n const context = {\n checker,\n owners: pipe(\n owners,\n Arr.filter((owner) => isVisibleTo(project)(owner)),\n ),\n vocabularies: project.library.vocabularies,\n flows: pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) => flowsIn(flowContext)(sourceFile)),\n ),\n };\n const verdicts = pipe(\n sites,\n Arr.map((site) => siteVerdict(context)(site)),\n );\n const excluded = [...ownerDeclarations, ...nodesOf(sites)];\n const shapeContext = { checker, program: project.program, shapes: project.library.shapes };\n return {\n problems: [\n ...pipe(\n verdicts,\n Arr.flatMap((found) => found.problems),\n ),\n ...pipe(\n project.sourceFiles,\n Arr.flatMap((sourceFile) => [\n ...ownedLiteralProblems(context)(sourceFile, excluded),\n ...shapeProblemsIn(shapeContext)(sourceFile),\n ]),\n ),\n ],\n unowned: pipe(\n verdicts,\n Arr.flatMap((found) => found.unowned),\n ),\n };\n };\n","import { Array as Arr, Order, Record as Rec, pipe } from \"effect\";\n\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { columnOf, lineOf } from \"#/shared/lib/syntax.ts\";\nimport { formatValues, valueKey } from \"#/shared/lib/values.ts\";\nimport type { Value } from \"#/shared/lib/values.ts\";\n\nimport { OWNER_TAG } from \"./owners.ts\";\nimport type { ValueSite } from \"./sites.ts\";\n\nexport interface PackageScope {\n readonly name: string;\n readonly dependencies: readonly string[];\n}\n\nexport interface UnownedSite {\n readonly scope: PackageScope;\n readonly file: string;\n readonly start: number;\n readonly line: number;\n readonly column: number;\n readonly values: readonly Value[];\n}\n\nconst DUPLICATE_THRESHOLD = 1;\n\nexport const unownedSiteOf =\n (scope: PackageScope) =>\n (site: ValueSite): UnownedSite => ({\n scope,\n file: site.node.getSourceFile().fileName,\n start: site.node.getStart(),\n line: lineOf(site.node),\n column: columnOf(site.node),\n values: site.values,\n });\n\nconst canDerive = (left: UnownedSite, right: UnownedSite): boolean =>\n left.scope.name === right.scope.name ||\n left.scope.dependencies.includes(right.scope.name) ||\n right.scope.dependencies.includes(left.scope.name);\n\nconst siteKey = (site: UnownedSite): string => `${site.file}#${String(site.start)}`;\n\nconst valueSetKey = (site: UnownedSite): string => {\n const keys = pipe(\n site.values,\n Arr.map((value) => valueKey(value)),\n );\n return pipe(Arr.sort(keys, Order.String), Arr.join(\"\\0\"));\n};\n\nexport const duplicateProblems =\n (relative: (file: string) => string) =>\n (sites: readonly UnownedSite[]): readonly Problem[] => {\n const unique = Arr.dedupeWith(sites, (left, right) => siteKey(left) === siteKey(right));\n const groups = Rec.values(Arr.groupBy(unique, (site) => valueSetKey(site)));\n return pipe(\n groups,\n Arr.filter((group) => group.length > DUPLICATE_THRESHOLD),\n Arr.flatMap((group) =>\n pipe(\n group,\n Arr.flatMap((site): readonly Problem[] => {\n const related = pipe(\n group,\n Arr.filter((other) => other !== site && canDerive(site, other)),\n );\n if (!Arr.isReadonlyArrayNonEmpty(related)) {\n return [];\n }\n const others = pipe(\n related,\n Arr.map((other) => `${relative(other.file)}:${String(other.line)}`),\n Arr.join(\", \"),\n );\n return [\n {\n file: site.file,\n line: site.line,\n column: site.column,\n rule: \"duplicate-value-set\",\n message: `The values ${formatValues(site.values)} are also declared at ${others}. Register one owner with /** @${OWNER_TAG} <concept> */ and derive the others from it.`,\n },\n ];\n }),\n ),\n ),\n );\n };\n","import { Effect, Option, Array as Arr, pipe } from \"effect\";\n\nimport {\n listConfigFiles,\n mentions,\n typeScriptCompiler,\n withProject,\n} from \"#/entities/project/index.ts\";\nimport type { Project, Workspace } from \"#/entities/project/index.ts\";\nimport { sortProblems } from \"#/shared/lib/problem.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { analyzeProject } from \"./analysis.ts\";\nimport { duplicateProblems, unownedSiteOf } from \"./duplicates.ts\";\nimport type { PackageScope, UnownedSite } from \"./duplicates.ts\";\nimport { OWNER_TAG, combineOwnerScans, ownersIn } from \"./owners.ts\";\nimport type { Owner, OwnerScan } from \"./owners.ts\";\n\nconst scanOwners = Effect.fn(\"scanOwners\")(function* scanOwners(\n workspace: Workspace,\n configPaths: readonly string[],\n) {\n const ownerConfigs = yield* pipe(\n configPaths,\n Effect.filter(mentions(`@${OWNER_TAG}`)(workspace.compiler)),\n );\n const scans = yield* pipe(\n ownerConfigs,\n Effect.forEach((configPath) =>\n withProject(workspace)(configPath)((project) => Effect.sync(() => ownersIn(project))),\n ),\n );\n return combineOwnerScans(Arr.getSomes(scans));\n});\n\nconst scopeOf = (project: Project, configPath: string): PackageScope => ({\n name: Option.getOrElse(project.packageName, () => configPath),\n dependencies: project.workspaceDependencies,\n});\n\ninterface Analysis {\n readonly problems: readonly Problem[];\n readonly unowned: readonly UnownedSite[];\n}\n\nconst analyzeProjects =\n (workspace: Workspace, owners: readonly Owner[]) =>\n (configPaths: readonly string[]): Effect.Effect<readonly Analysis[], never, RepositoryFiles> =>\n pipe(\n configPaths,\n Effect.forEach((configPath) =>\n withProject(workspace)(configPath)((project) =>\n Effect.sync(() => {\n const analysis = analyzeProject(owners)(project);\n const scope = scopeOf(project, configPath);\n return {\n problems: analysis.problems,\n unowned: pipe(analysis.unowned, Arr.map(unownedSiteOf(scope))),\n };\n }).pipe(Effect.withSpan(\"analyzeProject\")),\n ),\n ),\n Effect.map(Arr.getSomes),\n );\n\nexport const checkRepository = Effect.fn(\"checkRepository\")(function* checkRepository(\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const compiler = yield* typeScriptCompiler;\n const generated = yield* files.generatedFiles(root);\n const workspace: Workspace = { compiler, root, generated };\n const configPaths = yield* listConfigFiles(root);\n const ownerScan: OwnerScan = yield* scanOwners(workspace, configPaths);\n const analyses = yield* analyzeProjects(workspace, ownerScan.owners)(configPaths);\n const relative = (file: string): string => files.relative(root, file);\n const unowned = pipe(\n analyses,\n Arr.flatMap((analysis) => analysis.unowned),\n );\n return sortProblems([\n ...ownerScan.problems,\n ...pipe(\n analyses,\n Arr.flatMap((analysis) => analysis.problems),\n ),\n ...duplicateProblems(relative)(unowned),\n ]);\n}, Effect.scoped);\n","import { Schema, String as Str } from \"effect\";\nimport type { Effect } from \"effect\";\n\nexport interface FoundComment {\n readonly index: number;\n readonly text: string;\n}\n\nexport type Found = Effect.Effect<readonly FoundComment[], CommentsUnreadable>;\n\nconst taggedError = Schema.TaggedError;\n\nexport class CommentsUnreadable extends taggedError<\n CommentsUnreadable,\n { readonly brand: unique symbol }\n>()(\"CommentsUnreadable\", { reader: Schema.String, message: Schema.String }) {}\n\nexport const unreadable =\n (reader: string) =>\n (cause: unknown): CommentsUnreadable =>\n CommentsUnreadable.make({ reader, message: String(cause) });\n\nexport const trimmed = ({ index, text }: FoundComment): FoundComment => ({\n index,\n text: Str.trimEnd(text),\n});\n","import { DockerfileParser } from \"dockerfile-ast\";\nimport { Array as Arr, Effect, Number as Num, Record as Rec, String as Str, pipe } from \"effect\";\nimport { parse as parseSql } from \"sql-parser-cst\";\nimport { parseTOML } from \"toml-eslint-parser\";\nimport { Parser as YamlParser } from \"yaml\";\n\nimport { trimmed, unreadable } from \"./found-comment.ts\";\nimport type { Found } from \"./found-comment.ts\";\n\nconst NEXT = 1;\n\nconst isRecord = (value: unknown): value is Readonly<Record<string, unknown>> =>\n typeof value === \"object\" && value !== null;\n\nconst childrenOf = (value: unknown): readonly unknown[] => {\n if (Arr.isArray(value)) {\n return value;\n }\n if (isRecord(value)) {\n return Rec.values(value);\n }\n return [];\n};\n\nconst collect =\n <Item>(isItem: (value: unknown) => value is Item) =>\n (value: unknown): readonly Item[] => {\n if (isItem(value)) {\n return [value];\n }\n return pipe(childrenOf(value), Arr.flatMap(collect(isItem)));\n };\n\ninterface YamlSourceToken {\n readonly offset: number;\n readonly source: string;\n}\n\nconst isYamlComment = (value: unknown): value is YamlSourceToken =>\n isRecord(value) &&\n value[\"type\"] === \"comment\" &&\n typeof value[\"offset\"] === \"number\" &&\n typeof value[\"source\"] === \"string\";\n\nexport const yamlComments = (source: string): Found =>\n Effect.try({\n try: () =>\n pipe(\n Arr.fromIterable(new YamlParser().parse(source)),\n Arr.flatMap(collect(isYamlComment)),\n Arr.map((token) => trimmed({ index: token.offset, text: token.source })),\n ),\n catch: unreadable(\"yaml\"),\n });\n\nexport const tomlComments = (source: string): Found =>\n Effect.try({\n try: () =>\n pipe(\n parseTOML(source).comments,\n Arr.map(({ range: [start, end] }) =>\n trimmed({ index: start, text: Str.slice(start, end)(source) }),\n ),\n ),\n catch: unreadable(\"toml\"),\n });\n\ninterface SqlComment {\n readonly text: string;\n readonly range: readonly [number, number];\n}\n\nconst isSqlComment = (value: unknown): value is SqlComment =>\n isRecord(value) &&\n (value[\"type\"] === \"line_comment\" || value[\"type\"] === \"block_comment\") &&\n typeof value[\"text\"] === \"string\" &&\n Arr.isArray(value[\"range\"]);\n\nexport const sqlComments = (source: string): Found =>\n Effect.try({\n try: () => {\n const program = parseSql(source, {\n dialect: \"sqlite\",\n includeComments: true,\n includeRange: true,\n paramTypes: [],\n });\n return pipe(\n collect(isSqlComment)(program),\n Arr.map(({ range: [start], text }) => trimmed({ index: start, text })),\n );\n },\n catch: unreadable(\"sql\"),\n });\n\nconst offsetAt =\n (lines: readonly string[]) =>\n ({ line, character }: Readonly<{ line: number; character: number }>): number =>\n character +\n pipe(\n lines,\n Arr.take(line),\n Arr.map((text) => text.length + NEXT),\n Num.sumAll,\n );\n\nexport const dockerfileComments = (source: string): Found =>\n Effect.try({\n try: () => {\n const lines = Str.split(source, \"\\n\");\n return pipe(\n DockerfileParser.parse(source).getComments(),\n Arr.map((comment) =>\n trimmed({\n index: offsetAt(lines)(comment.getRange().start),\n text: comment.toString(),\n }),\n ),\n );\n },\n catch: unreadable(\"dockerfile\"),\n });\n","import { fileURLToPath } from \"node:url\";\n\nimport treeSitter from \"@vscode/tree-sitter-wasm\";\nimport { isComment, isTag, isText } from \"domhandler\";\nimport type { AnyNode, Text } from \"domhandler\";\nimport { Array as Arr, Effect, Option, Record as Rec, String as Str, pipe } from \"effect\";\nimport { DomUtils, parseDocument } from \"htmlparser2\";\n\nimport { dockerfileComments, sqlComments, tomlComments, yamlComments } from \"./config-comments.ts\";\nimport { trimmed, unreadable } from \"./found-comment.ts\";\nimport type { CommentsUnreadable, Found, FoundComment } from \"./found-comment.ts\";\n\nconst GRAMMARS = [\n \"bash\",\n \"c-sharp\",\n \"cpp\",\n \"css\",\n \"go\",\n \"java\",\n \"javascript\",\n \"php\",\n \"powershell\",\n \"ruby\",\n \"rust\",\n \"tsx\",\n \"typescript\",\n] as const;\n\nexport type Grammar = (typeof GRAMMARS)[number];\n\nexport type Markup = \"html\" | \"xml\";\n\nexport type Reader = Grammar | Markup | \"yaml\" | \"toml\" | \"sql\" | \"dockerfile\";\n\nexport type Grammars = (grammar: Grammar) => Option.Option<treeSitter.Language>;\n\nconst COMMENT_NODES = [\"comment\", \"line_comment\", \"block_comment\", \"multiline_comment\"];\nconst START = 0;\nconst NEXT = 1;\nconst NONE: readonly FoundComment[] = [];\n\nconst grammarFile = (grammar: Grammar): string =>\n fileURLToPath(import.meta.resolve(`@vscode/tree-sitter-wasm/wasm/tree-sitter-${grammar}.wasm`));\n\nconst loadGrammar = (\n grammar: Grammar,\n): Effect.Effect<readonly [Grammar, treeSitter.Language], CommentsUnreadable> =>\n Effect.tryPromise({\n try: () => treeSitter.Language.load(grammarFile(grammar)),\n catch: unreadable(grammar),\n }).pipe(Effect.map((language) => [grammar, language] as const));\n\nexport const loadGrammars = Effect.fn(\"loadGrammars\")(function* loadGrammars() {\n yield* Effect.tryPromise({\n try: () => treeSitter.Parser.init(),\n catch: unreadable(\"javascript\"),\n });\n const loaded = yield* pipe(\n GRAMMARS,\n Effect.forEach((grammar) => loadGrammar(grammar)),\n );\n const languages = Rec.fromEntries(loaded);\n const grammars: Grammars = (grammar) => Rec.get(languages, grammar);\n return grammars;\n});\n\nconst commentNodesIn = (language: treeSitter.Language, source: string): readonly FoundComment[] => {\n const parser = new treeSitter.Parser();\n parser.setLanguage(language);\n const tree = parser.parse(source);\n parser.delete();\n if (tree === null) {\n return NONE;\n }\n const found = pipe(\n tree.rootNode.descendantsOfType(COMMENT_NODES),\n Arr.flatMap((node) => Option.toArray(Option.fromNullishOr(node))),\n Arr.map((node) => trimmed({ index: node.startIndex, text: node.text })),\n );\n tree.delete();\n return found;\n};\n\nconst syntaxComments =\n (grammars: Grammars, grammar: Grammar) =>\n (source: string): Found =>\n Option.match(grammars(grammar), {\n onNone: () => Effect.fail(unreadable(grammar)(\"the grammar is not loaded\")),\n onSome: (language) =>\n Effect.try({ try: () => commentNodesIn(language, source), catch: unreadable(grammar) }),\n });\n\nconst SCRIPT_TYPE = /^(?:|module|text\\/javascript|application\\/javascript)$/iu;\nconst SHADER_TYPE = /shader|glsl/iu;\n\ninterface EmbeddingTag {\n readonly name: string;\n readonly attribs: Readonly<Record<string, string>>;\n}\n\nconst scriptGrammar = (attribs: EmbeddingTag[\"attribs\"]): Option.Option<Grammar> => {\n const type = Str.trim(Option.getOrElse(Rec.get(attribs, \"type\"), () => \"\"));\n if (Rec.get(attribs, \"lang\").pipe(Option.contains(\"ts\"))) {\n return Option.some<Grammar>(\"typescript\");\n }\n if (SHADER_TYPE.test(type)) {\n return Option.some<Grammar>(\"cpp\");\n }\n return Option.liftPredicate<Grammar>(\"javascript\", () => SCRIPT_TYPE.test(type));\n};\n\nconst embeddedGrammar = ({ name, attribs }: EmbeddingTag): Option.Option<Grammar> => {\n if (name === \"style\") {\n return Option.some<Grammar>(\"css\");\n }\n if (name === \"script\") {\n return scriptGrammar(attribs);\n }\n return Option.none();\n};\n\nconst shifted =\n (offset: number) =>\n ({ index, text }: FoundComment): FoundComment => ({ index: index + offset, text });\n\nconst markupComment =\n (source: string) =>\n (node: AnyNode): readonly FoundComment[] => {\n if (!isComment(node) || node.startIndex === null || node.endIndex === null) {\n return NONE;\n }\n return [\n { index: node.startIndex, text: Str.slice(node.startIndex, node.endIndex + NEXT)(source) },\n ];\n };\n\nconst textComments =\n (grammars: Grammars, grammar: Grammar) =>\n (text: Text): Found => {\n const shift = shifted(text.startIndex ?? START);\n return syntaxComments(grammars, grammar)(text.data).pipe(Effect.map(Arr.map(shift)));\n };\n\nconst embeddedComments =\n (grammars: Grammars) =>\n (node: AnyNode): Found => {\n if (!isTag(node)) {\n return Effect.succeed(NONE);\n }\n const texts = pipe(node.children, Arr.filter(isText));\n return Option.match(embeddedGrammar(node), {\n onNone: () => Effect.succeed(NONE),\n onSome: (grammar) =>\n pipe(texts, Effect.forEach(textComments(grammars, grammar)), Effect.map(Arr.flatten)),\n });\n };\n\nconst markupComments =\n (grammars: Grammars, markup: Markup) =>\n (source: string): Found =>\n Effect.gen(function* readMarkup() {\n const document = parseDocument(source, {\n xmlMode: markup === \"xml\",\n withStartIndices: true,\n withEndIndices: true,\n });\n const nodes = DomUtils.filter(() => true, document.children, true);\n const own = pipe(nodes, Arr.flatMap(markupComment(source)));\n if (markup === \"xml\") {\n return own;\n }\n const embedded = yield* pipe(nodes, Effect.forEach(embeddedComments(grammars)));\n return [...own, ...Arr.flatten(embedded)];\n });\n\nconst isGrammar = (reader: Reader): reader is Grammar => pipe(GRAMMARS, Arr.contains(reader));\n\nexport const commentsWith =\n (grammars: Grammars) =>\n (reader: Reader, source: string): Found => {\n if (isGrammar(reader)) {\n return syntaxComments(grammars, reader)(source);\n }\n const readers = {\n html: markupComments(grammars, \"html\"),\n xml: markupComments(grammars, \"xml\"),\n yaml: yamlComments,\n toml: tomlComments,\n sql: sqlComments,\n dockerfile: dockerfileComments,\n } satisfies Record<Exclude<Reader, Grammar>, (text: string) => Found>;\n return readers[reader](source);\n };\n","import path from \"node:path\";\n\nimport {\n Array as Arr,\n Effect,\n HashSet,\n Option,\n Predicate,\n Schema,\n String as Str,\n pipe,\n} from \"effect\";\nimport { resolveConfigFromFile } from \"vite-plus\";\n\nimport { COMMENT_DIRECTIVES } from \"#/shared/lib/comment-directives.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nimport { commentsWith, loadGrammars } from \"./comment-readers.ts\";\nimport type { Reader } from \"./comment-readers.ts\";\nimport type { FoundComment } from \"./found-comment.ts\";\n\nconst RULE: RuleName = \"comment\";\nconst CONFIG_FILE = \"vite.config.ts\";\nconst VENDORED_PATHSPEC = \":(attr:linguist-vendored)\";\nconst READ_CONCURRENCY = 64;\nconst START = 0;\nconst FIRST_LINE = 1;\nconst FIRST_COLUMN = 1;\n\nconst READERS: readonly (readonly [RegExp, Reader])[] = [\n [/\\.(?:[cm]?jsx?)$/u, \"javascript\"],\n [/\\.(?:[cm]?ts)$/u, \"typescript\"],\n [/\\.tsx$/u, \"tsx\"],\n [/\\.rs$/u, \"rust\"],\n [/\\.(?:cs|csx)$/u, \"c-sharp\"],\n [/\\.(?:sh|bash|zsh|ksh)$/u, \"bash\"],\n [/(?:^|\\/)\\.(?:vite-hooks|husky|githooks)\\/[^./][^/]*$/u, \"bash\"],\n [/\\.(?:ps1|psm1|psd1)$/u, \"powershell\"],\n [/\\.go$/u, \"go\"],\n [/\\.(?:java|kt|kts)$/u, \"java\"],\n [/\\.(?:rb|rake)$/u, \"ruby\"],\n [/\\.php$/u, \"php\"],\n [/\\.(?:c|h|cc|cpp|cxx|hpp|hh|m|mm|glsl|frag|vert|comp|wgsl|hlsl|metal)$/u, \"cpp\"],\n [/\\.(?:css|pcss)$/u, \"css\"],\n [/\\.(?:html?|vue|svelte|astro)$/u, \"html\"],\n [/\\.(?:xml|xaml|plist|resx|props|targets|[a-z]+proj|manifest|nuspec)$/u, \"xml\"],\n [/\\.ya?ml$/u, \"yaml\"],\n [/\\.toml$/u, \"toml\"],\n [/\\.sql$/u, \"sql\"],\n [/(?:^|\\/)(?:Dockerfile|Containerfile)(?:\\.[^/]+)?$|\\.dockerfile$/u, \"dockerfile\"],\n];\n\nconst SHEBANG_READERS: readonly (readonly [RegExp, Reader])[] = [\n [/^#!.*\\b(?:ba|z|k|da)?sh\\b/u, \"bash\"],\n [/^#!.*\\b(?:node|bun|deno|tsx)\\b/u, \"javascript\"],\n [/^#!.*\\bpwsh\\b/u, \"powershell\"],\n];\n\nconst SHEBANG = \"#!\";\nconst PIN = /@(?:[0-9a-f]{40}|sha256:[0-9a-f]{64})\\s*$/u;\nconst VERSION = /^\\s?v?\\d[\\w.+-]*$/u;\nconst DELIMITERS = /^(?:\\/\\/|\\/\\*|<!--|<#|#|--)|(?:\\*\\/|-->|#>)$/gu;\nconst MESSAGE =\n \"Comments are not written in this repository. Say it with names and types in the code, put the reason in the commit message, and delete the comment.\";\n\nconst Patterns = Schema.Array(Schema.String);\nconst CommentSettings = Schema.Struct({ allow: Patterns });\nconst MschSettings = Schema.Struct({ comments: Schema.optional(CommentSettings) });\nconst LintSettings = Schema.Struct({ ignorePatterns: Schema.optional(Patterns) });\n\nconst RootConfig = Schema.Struct({\n msch: Schema.optional(MschSettings),\n lint: Schema.optional(LintSettings),\n});\n\ntype RootConfigType = typeof RootConfig.Type;\n\ninterface RootSettings {\n readonly allow: readonly string[];\n readonly ignorePatterns: readonly string[];\n}\n\ninterface Listed {\n readonly name: string;\n readonly file: string;\n}\n\nconst NO_SETTINGS: RootSettings = { allow: [], ignorePatterns: [] };\nconst NONE: readonly Problem[] = [];\n\nconst taggedError = Schema.TaggedError;\n\nclass CommentConfigUnreadable extends taggedError<\n CommentConfigUnreadable,\n { readonly brand: unique symbol }\n>()(\"CommentConfigUnreadable\", { file: Schema.String }) {}\n\nconst shebangReader = (source: string): Option.Option<readonly [RegExp, Reader]> => {\n if (!Str.startsWith(SHEBANG)(source)) {\n return Option.none();\n }\n return pipe(\n SHEBANG_READERS,\n Arr.findFirst(([pattern]) => pattern.test(source)),\n );\n};\n\nconst readerOf = (name: string, source: string): Option.Option<Reader> =>\n pipe(\n READERS,\n Arr.findFirst(([pattern]) => pattern.test(name)),\n Option.orElse(() => shebangReader(source)),\n Option.map(([, reader]) => reader),\n );\n\nconst valueOf = (text: string): string => Str.replaceAll(DELIMITERS, \"\")(text);\n\nconst lineBefore = (source: string, index: number): string => {\n const lines = pipe(source, Str.slice(START, index), Str.split(\"\\n\"));\n return Option.getOrElse(Arr.last(lines), () => \"\");\n};\n\nconst isPinVersion = (source: string, { index, text }: FoundComment): boolean =>\n PIN.test(lineBefore(source, index)) && VERSION.test(valueOf(text));\n\nconst isShebang = ({ index, text }: FoundComment): boolean =>\n index === START && Str.startsWith(SHEBANG)(text);\n\nconst isAllowed =\n (source: string, directives: RegExp) =>\n (comment: FoundComment): boolean =>\n isShebang(comment) || directives.test(valueOf(comment.text)) || isPinVersion(source, comment);\n\nconst problemOf =\n (file: string, source: string) =>\n ({ index }: FoundComment): Problem => ({\n file,\n ...positionOf(source)(index),\n rule: RULE,\n message: MESSAGE,\n });\n\nconst unreadableProblem = (file: string, message: string): Problem => ({\n file,\n line: FIRST_LINE,\n column: FIRST_COLUMN,\n rule: RULE,\n message: `msch could not read the comments in this file: ${message}`,\n});\n\nconst settingsOf = ({ msch, lint }: RootConfigType): RootSettings => ({\n allow: pipe(\n Option.fromUndefinedOr(msch),\n Option.flatMap(({ comments }) => Option.fromUndefinedOr(comments)),\n Option.match({ onNone: () => NO_SETTINGS.allow, onSome: ({ allow }) => allow }),\n ),\n ignorePatterns: pipe(\n Option.fromUndefinedOr(lint),\n Option.flatMap(({ ignorePatterns }) => Option.fromUndefinedOr(ignorePatterns)),\n Option.getOrElse(() => NO_SETTINGS.ignorePatterns),\n ),\n});\n\nconst rootSettings = Effect.fn(\"rootSettings\")(function* rootSettings(root: string) {\n const files = yield* RepositoryFiles;\n const file = files.join(root, CONFIG_FILE);\n const exists = yield* files.exists(file);\n if (!exists) {\n return NO_SETTINGS;\n }\n const config = yield* Effect.tryPromise({\n try: () => resolveConfigFromFile(file),\n catch: () => CommentConfigUnreadable.make({ file }),\n }).pipe(Effect.option);\n return pipe(\n config,\n Option.flatMap(Schema.decodeUnknownOption(RootConfig)),\n Option.match({ onNone: () => NO_SETTINGS, onSome: settingsOf }),\n );\n});\n\nconst directivePattern = (directives: readonly string[]): RegExp =>\n new RegExp(String.raw`^\\s?(?:${Arr.join(directives, \"|\")})`, \"u\");\n\nconst isIgnored =\n (patterns: readonly string[]) =>\n (name: string): boolean =>\n pipe(\n patterns,\n Arr.some((pattern) => path.matchesGlob(name, pattern)),\n );\n\nconst scannedFiles = Effect.fn(\"scannedFiles\")(function* scannedFiles(\n root: string,\n settings: RootSettings,\n) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.listedFiles(root);\n const generated = yield* files.generatedFiles(root);\n const vendored = yield* files.matchingFiles(root, [VENDORED_PATHSPEC]);\n const skipped = HashSet.fromIterable([\n ...generated,\n ...pipe(\n vendored,\n Arr.map((name) => files.join(root, name)),\n ),\n ]);\n return pipe(\n listed,\n Arr.filter((name) => !isIgnored(settings.ignorePatterns)(name)),\n Arr.map((name): Listed => ({ name, file: files.join(root, name) })),\n Arr.filter(({ file }) => !HashSet.has(skipped, file)),\n );\n});\n\n/** @internal */\nexport const checkComments = Effect.fn(\"checkComments\")(function* checkComments(root: string) {\n const files = yield* RepositoryFiles;\n const settings = yield* rootSettings(root);\n const scanned = yield* scannedFiles(root, settings);\n const directives = directivePattern([...COMMENT_DIRECTIVES, ...settings.allow]);\n const grammars = yield* loadGrammars();\n const comments = commentsWith(grammars);\n const problemsIn = (\n { name, file }: Listed,\n source: string,\n ): Effect.Effect<readonly Problem[]> => {\n const kept = Predicate.not(isAllowed(source, directives));\n const toProblem = problemOf(file, source);\n return Option.match(readerOf(name, source), {\n onNone: () => Effect.succeed(NONE),\n onSome: (reader) =>\n comments(reader, source).pipe(\n Effect.map(Arr.filter(kept)),\n Effect.map(Arr.map(toProblem)),\n Effect.catchTag(\"CommentsUnreadable\", ({ message }) =>\n Effect.succeed([unreadableProblem(file, message)]),\n ),\n ),\n });\n };\n const found = yield* Effect.forEach(\n scanned,\n (entry) =>\n files.readFile(entry.file).pipe(\n Effect.flatMap(\n Option.match({\n onNone: () => Effect.succeed(NONE),\n onSome: (source) => problemsIn(entry, source),\n }),\n ),\n ),\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.flatten(found);\n});\n","import { Array as Arr, Effect, Option, String as Str, pipe } from \"effect\";\n\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nconst HIDDEN =\n /[\\u00AD\\u180E\\u200B-\\u200F\\u202A-\\u202E\\u2060-\\u2064\\u2066-\\u2069\\uFEFF]|[\\u{E0000}-\\u{E007F}]/gu;\n\nconst NUL = \"\\0\";\nconst START = 0;\nconst HEX = 16;\nconst CODE_POINT_WIDTH = 4;\nconst READ_CONCURRENCY = 64;\nconst RULE: RuleName = \"hidden-unicode\";\n\nconst hexOf = (character: string): string =>\n pipe(\n Str.codePointAt(START)(character),\n Option.getOrElse(() => START),\n (code) => code.toString(HEX),\n Str.toUpperCase,\n Str.padStart(CODE_POINT_WIDTH, \"0\"),\n );\n\nconst problemOf =\n (file: string, source: string) =>\n (found: RegExpMatchArray): Problem => {\n const hex = hexOf(found[START]);\n return {\n file,\n ...positionOf(source)(found.index ?? START),\n rule: RULE,\n 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}.`,\n };\n };\n\nconst problemsIn = (file: string, source: string): readonly Problem[] => {\n if (Str.includes(NUL)(source)) {\n return [];\n }\n return pipe(Arr.fromIterable(Str.matchAll(HIDDEN)(source)), Arr.map(problemOf(file, source)));\n};\n\n/** @internal */\nexport const checkHiddenUnicode = Effect.fn(\"checkHiddenUnicode\")(function* checkHiddenUnicode(\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const names = yield* files.listedFiles(root);\n const found = yield* Effect.forEach(\n names,\n (name) => {\n const file = files.join(root, name);\n return files.readFile(file).pipe(\n Effect.map(\n Option.match({\n onNone: (): readonly Problem[] => [],\n onSome: (source) => problemsIn(file, source),\n }),\n ),\n );\n },\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.flatten(found);\n});\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport type { Problem } from \"./problem.ts\";\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst SCANNED_FILE =\n /(?:\\.(?:[cm]?[jt]sx?|jsonc?|toml|ya?ml|sh|bash|zsh|fish|rs|cs|go|mk)|(?:^|\\/)(?:Dockerfile[^/]*|Makefile|justfile|\\.tool-versions|[^./][^./]*))$/u;\n\nconst LOCKFILE = /(?:^|\\/)(?:[^/]*\\.lock|[^/]*-lock\\.(?:json|ya?ml))$/u;\n\nconst TOOL_VERSIONS = /(?:^|\\/)(?:\\.?mise(?:\\.[^/]+)?\\.toml|\\.tool-versions)$/u;\n\nconst READ_CONCURRENCY = 64;\n\nexport interface Listed {\n readonly name: string;\n readonly file: string;\n}\n\nexport const isScannedText = ({ name }: Listed): boolean =>\n SCANNED_FILE.test(name) && !LOCKFILE.test(name);\n\nexport const isToolVersions = ({ name }: Listed): boolean => TOOL_VERSIONS.test(name);\n\n/** @internal */\nexport const listedFiles = Effect.fn(\"listedFiles\")(function* listedFiles(root: string) {\n const files = yield* RepositoryFiles;\n const names = yield* files.listedFiles(root);\n return pipe(\n names,\n Arr.map((name): Listed => ({ name, file: files.join(root, name) })),\n );\n});\n\n/** @internal */\nexport const presentFiles = Effect.fn(\"presentFiles\")(function* presentFiles(\n listed: readonly Listed[],\n) {\n const files = yield* RepositoryFiles;\n return yield* pipe(\n listed,\n Effect.filter(({ file }) => files.exists(file)),\n );\n});\n\n/** @internal */\nexport const scanText = Effect.fn(\"scanText\")(function* scanText(\n listed: readonly Listed[],\n problemsIn: (entry: Listed, source: string) => readonly Problem[],\n) {\n const files = yield* RepositoryFiles;\n const found = yield* Effect.forEach(\n listed,\n (entry) =>\n files.readFile(entry.file).pipe(\n Effect.map(\n Option.match({\n onNone: (): readonly Problem[] => [],\n onSome: (source) => problemsIn(entry, source),\n }),\n ),\n ),\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.flatten(found);\n});\n","import { Array as Arr, Effect, String as Str, pipe } from \"effect\";\n\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport {\n isScannedText,\n isToolVersions,\n listedFiles,\n presentFiles,\n scanText,\n} from \"#/shared/lib/scanned-files.ts\";\nimport type { Listed } from \"#/shared/lib/scanned-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nconst PYTHON_FILE =\n /(?:\\.(?:py|pyi|pyw|pyx|ipynb)|(?:^|\\/)(?:pyproject\\.toml|uv\\.lock|uv\\.toml|poetry\\.lock|Pipfile|Pipfile\\.lock|setup\\.cfg|tox\\.ini|pytest\\.ini|\\.python-version|requirements[^/]*\\.txt))$/u;\n\nconst COMMAND_PATTERNS: readonly RegExp[] = [\n /(?<![\\w./@-])python[\\d.]*[ \\t]+(?:[-\"'$./]|\\S+\\.py\\b)/gu,\n /(?<![\\w./@-])pip3?[ \\t]+(?:install|uninstall|download|freeze|wheel|compile|sync)\\b/gu,\n /(?<![\\w./@-])pipx[ \\t]+(?:run|install|inject|upgrade)\\b/gu,\n /(?<![\\w./@-])uvx[ \\t]+[^\\s=:,;)|&]/gu,\n /(?<![\\w./@-])uv[ \\t]+(?:run|sync|lock|pip|tool|venv|add|remove|python|export|build|publish|init|tree|cache|self)\\b/gu,\n /(?<![\\w./@-])poetry[ \\t]+(?:run|install|add|lock|build|publish|shell|export)\\b/gu,\n /(?:\\bcommand[\"']?\\s*[:=]\\s*|(?:\\bspawn\\w*|\\bexec\\w*|\\bexeca|Command::new|ChildProcess\\.make|\\$)\\(\\s*)[\"'`](?:python[\\d.]*|pip3?|pipx|uvx?|poetry)[\"'`]/gu,\n /\\buses:\\s*[\"']?(?:actions\\/setup-python|astral-sh\\/setup-uv|astral-sh\\/ruff-action|pypa\\/[\\w.-]+|snok\\/install-poetry|abatilo\\/actions-poetry|conda-incubator\\/setup-miniconda|mamba-org\\/setup-micromamba|pdm-project\\/setup-pdm)\\b/gu,\n];\n\nconst TOOL_PATTERNS: readonly RegExp[] = [\n /^[ \\t]*[\"']?(?:python|uv|pipx|poetry|ruff|pdm|hatch|pipx:[^\"'\\s=]+)[\"']?[ \\t]*(?:=|[ \\t]+\\S)/gmu,\n];\n\nconst FIRST_LINE = 1;\nconst FIRST_COLUMN = 1;\nconst WHOLE_MATCH = 0;\nconst FILE_RULE: RuleName = \"python-file\";\nconst COMMAND_RULE: RuleName = \"python-command\";\n\nconst fileProblem = ({ file }: Listed): Problem => ({\n file,\n line: FIRST_LINE,\n column: FIRST_COLUMN,\n rule: FILE_RULE,\n message: \"Python is not used in this repository. Replace this file with TypeScript or Rust.\",\n});\n\nconst patternsFor = (entry: Listed): readonly RegExp[] => {\n if (isToolVersions(entry)) {\n return [...COMMAND_PATTERNS, ...TOOL_PATTERNS];\n }\n return COMMAND_PATTERNS;\n};\n\nconst commandProblem =\n ({ file }: Listed, source: string) =>\n (found: RegExpMatchArray): Problem => ({\n file,\n ...positionOf(source)(found.index ?? WHOLE_MATCH),\n rule: COMMAND_RULE,\n message: `Python is not used in this repository. Remove \\`${Str.trim(found[WHOLE_MATCH])}\\` and do the work in TypeScript or Rust.`,\n });\n\nconst commandProblems = (entry: Listed, source: string): readonly Problem[] =>\n pipe(\n patternsFor(entry),\n Arr.flatMap((pattern) => Arr.fromIterable(Str.matchAll(pattern)(source))),\n Arr.map(commandProblem(entry, source)),\n );\n\nconst isPython = ({ name }: Listed): boolean => PYTHON_FILE.test(name);\n\nconst isScanned = (entry: Listed): boolean => !isPython(entry) && isScannedText(entry);\n\n/** @internal */\nexport const checkPython = Effect.fn(\"checkPython\")(function* checkPython(root: string) {\n const listed = yield* listedFiles(root);\n const scanned = yield* scanText(pipe(listed, Arr.filter(isScanned)), commandProblems);\n const present = yield* presentFiles(pipe(listed, Arr.filter(isPython)));\n return [...pipe(present, Arr.map(fileProblem)), ...scanned];\n});\n","import { Array as Arr, Effect, Option, Order, Schema, String as Str, pipe } from \"effect\";\nimport { parse } from \"yaml\";\n\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport {\n isScannedText,\n isToolVersions,\n listedFiles,\n presentFiles,\n scanText,\n} from \"#/shared/lib/scanned-files.ts\";\nimport type { Listed } from \"#/shared/lib/scanned-files.ts\";\nimport { positionOf } from \"#/shared/lib/text-position.ts\";\n\nconst WORKSPACE_FILE = \"pnpm-workspace.yaml\";\nconst PNPM_DIRECTORY = \".pnpm/\";\nconst SEPARATOR = \"/\";\n\nconst FOREIGN_LOCKFILE =\n /(?:^|\\/)(?:package-lock\\.json|npm-shrinkwrap\\.json|yarn\\.lock|bun\\.lockb?)$/u;\nconst CARGO_MANIFEST_FILE = /(?:^|\\/)Cargo\\.toml$/u;\nconst CARGO_LOCK_FILE = /(?:^|\\/)Cargo\\.lock$/u;\nconst PNPM_OUTPUT = /(?:^|\\/)\\.pnpm\\//u;\nconst CARGO_WORKSPACE = /^\\[workspace\\]/mu;\nconst LEGACY_CARGO_CONFIG = /(?:^|\\/)\\.cargo\\/config$/u;\nconst CARGO_CONFIG_FILE = /(?:^|\\/)\\.cargo\\/config\\.toml$/u;\nconst PNPM_CARGO_START = /# >>> pnpm-managed cargo sources >>>/u;\nconst PNPM_CARGO_BLOCK =\n /# >>> pnpm-managed cargo sources >>>[\\s\\S]*?# <<< pnpm-managed cargo sources <<<\\n?/gu;\n\nconst SETUP_PATTERNS: readonly RegExp[] = [\n /(?<![\\w./@-])rustup[ \\t]+(?:toolchain[ \\t]+install|install|update|default|override[ \\t]+set|target[ \\t]+add|component[ \\t]+add)\\b/gu,\n /(?<![\\w./@-])cargo[ \\t]+(?:vendor|fetch)\\b/gu,\n /\\buses:\\s*[\"']?(?:dtolnay\\/rust-toolchain|actions-rust-lang\\/setup-rust-toolchain|actions-rs\\/toolchain|moonrepo\\/setup-rust)\\b/gu,\n];\n\nconst TOOL_PATTERNS: readonly RegExp[] = [\n /^[ \\t]*[\"']?(?:rust|rustup)[\"']?[ \\t]*(?:=|[ \\t]+\\S)/gmu,\n];\n\nconst START = 0;\nconst LAST_SEGMENT = 1;\nconst FIRST_LINE = 1;\nconst FIRST_COLUMN = 1;\nconst WHOLE_MATCH = 0;\nconst FILE_RULE: RuleName = \"unneeded-file\";\nconst SETUP_RULE: RuleName = \"unneeded-setup\";\nconst CARGO_RULE: RuleName = \"cargo-outside-pnpm\";\n\nconst CargoSettings = Schema.Struct({ enabled: Schema.optionalKey(Schema.Boolean) });\nconst WorkspaceFile = Schema.Struct({ cargo: Schema.optionalKey(CargoSettings) });\nconst decodeWorkspaceFile = Schema.decodeUnknownOption(WorkspaceFile);\n\nconst cargoEnabled = (text: string): boolean =>\n pipe(\n decodeWorkspaceFile(parse(text)),\n Option.flatMap(({ cargo }) => Option.fromUndefinedOr(cargo)),\n Option.flatMap(({ enabled }) => Option.fromUndefinedOr(enabled)),\n Option.getOrElse(() => false),\n );\n\nconst problemAtStart =\n (rule: RuleName, message: string) =>\n ({ file }: Listed): Problem => ({\n file,\n line: FIRST_LINE,\n column: FIRST_COLUMN,\n rule,\n message,\n });\n\nconst foreignLockfile = problemAtStart(\n FILE_RULE,\n \"pnpm-lock.yaml is this repository's lockfile, and pnpm never reads this one. Delete it.\",\n);\n\nconst nestedCargoLock = problemAtStart(\n FILE_RULE,\n \"Cargo reads only the Cargo.lock beside the workspace's Cargo.toml, and pnpm install writes that one. Delete this one.\",\n);\n\nconst legacyCargoConfig = problemAtStart(\n FILE_RULE,\n \"pnpm install writes .cargo/config.toml, and Cargo warns when .cargo/config sits beside it. Move its settings into .cargo/config.toml and delete it.\",\n);\n\nconst pnpmOutput = problemAtStart(\n FILE_RULE,\n \"pnpm install writes .pnpm/ from Cargo.lock and rust-toolchain.toml. Add this .pnpm directory to .gitignore and keep it out of the repository.\",\n);\n\nconst pnpmCargoConfig = problemAtStart(\n FILE_RULE,\n \"pnpm install writes this .cargo/config.toml, and it holds nothing else. Add /.cargo/config.toml to .gitignore and keep it out of the repository.\",\n);\n\nconst generatedCargoConfig = (entry: Listed, source: string): readonly Problem[] => {\n if (!CARGO_CONFIG_FILE.test(entry.name) || !PNPM_CARGO_START.test(source)) {\n return [];\n }\n if (Str.isNonEmpty(Str.trim(Str.replaceAll(PNPM_CARGO_BLOCK, \"\")(source)))) {\n return [];\n }\n return [pnpmCargoConfig(entry)];\n};\n\nconst cargoOutsidePnpm = problemAtStart(\n CARGO_RULE,\n `pnpm does not manage these crates. Set \\`cargo: { enabled: true }\\` in ${WORKSPACE_FILE} so pnpm install fetches the crates and the Rust toolchain.`,\n);\n\nconst setupProblem =\n ({ file }: Listed, source: string) =>\n (found: RegExpMatchArray): Problem => ({\n file,\n ...positionOf(source)(found.index ?? WHOLE_MATCH),\n rule: SETUP_RULE,\n message: `pnpm install already installs the toolchain in rust-toolchain.toml and vendors the crates in Cargo.lock. Remove \\`${Str.trim(found[WHOLE_MATCH])}\\`.`,\n });\n\nconst setupPatternsFor = (entry: Listed): readonly RegExp[] => {\n if (isToolVersions(entry)) {\n return [...SETUP_PATTERNS, ...TOOL_PATTERNS];\n }\n return SETUP_PATTERNS;\n};\n\nconst setupProblems = (entry: Listed, source: string): readonly Problem[] =>\n pipe(\n setupPatternsFor(entry),\n Arr.flatMap((pattern) => Arr.fromIterable(Str.matchAll(pattern)(source))),\n Arr.map(setupProblem(entry, source)),\n Arr.appendAll(generatedCargoConfig(entry, source)),\n );\n\nconst matches =\n (pattern: RegExp) =>\n ({ name }: Listed): boolean =>\n pattern.test(name);\n\nconst isCargoManifest = matches(CARGO_MANIFEST_FILE);\nconst isForeignLockfile = matches(FOREIGN_LOCKFILE);\nconst isLegacyCargoConfig = matches(LEGACY_CARGO_CONFIG);\nconst isPnpmOutput = matches(PNPM_OUTPUT);\n\nconst directoryOf = (name: string): string =>\n pipe(Str.split(name, SEPARATOR), Arr.dropRight(LAST_SEGMENT), Arr.join(SEPARATOR));\n\nconst ancestorsOf = (directory: string): readonly string[] => {\n const parts = Str.split(directory, SEPARATOR);\n return pipe(\n Arr.makeBy(parts.length, (depth) => Arr.join(Arr.take(parts, depth), SEPARATOR)),\n Arr.filter((ancestor) => ancestor !== directory),\n );\n};\n\nconst readsCargoLock =\n (manifests: readonly string[], workspaces: readonly string[]) =>\n ({ name }: Listed): boolean => {\n const directory = directoryOf(name);\n const insideWorkspace = pipe(\n ancestorsOf(directory),\n Arr.some((ancestor) => Arr.contains(workspaces, ancestor)),\n );\n return Arr.contains(manifests, directory) && !insideWorkspace;\n };\n\nconst isWorkspaceManifest = (source: Option.Option<string>): boolean =>\n Option.exists(source, (text) => CARGO_WORKSPACE.test(text));\n\nconst directoriesOf = (entries: readonly Listed[]): readonly string[] =>\n pipe(\n entries,\n Arr.map(({ name }) => directoryOf(name)),\n );\n\nconst cargoWorkspaces = Effect.fn(\"cargoWorkspaces\")(function* cargoWorkspaces(\n manifests: readonly Listed[],\n) {\n const files = yield* RepositoryFiles;\n const roots = yield* pipe(\n manifests,\n Effect.filter(({ file }) => files.readFile(file).pipe(Effect.map(isWorkspaceManifest))),\n );\n return directoriesOf(roots);\n});\n\nconst pnpmDirectoryOf = ({ name }: Listed): string =>\n pipe(\n name,\n Str.indexOf(PNPM_DIRECTORY),\n Option.getOrElse(() => START),\n (end) => Str.slice(START, end)(name),\n );\n\nconst pnpmOutputs = (present: readonly Listed[]): readonly Problem[] =>\n pipe(\n present,\n Arr.filter(isPnpmOutput),\n Arr.dedupeWith((left, right) => pnpmDirectoryOf(left) === pnpmDirectoryOf(right)),\n Arr.map(pnpmOutput),\n );\n\nconst byDepth: Order.Order<Listed> = Order.mapInput(\n Order.Number,\n ({ name }: Listed) => Str.split(name, \"/\").length,\n);\n\nconst cargoProblems = (\n present: readonly Listed[],\n enabled: boolean,\n): Effect.Effect<readonly Problem[], never, RepositoryFiles> => {\n if (!enabled) {\n return Effect.succeed(\n pipe(\n present,\n Arr.filter(isCargoManifest),\n Arr.match({\n onEmpty: (): readonly Problem[] => [],\n onNonEmpty: (manifests) => [cargoOutsidePnpm(Arr.min(manifests, byDepth))],\n }),\n ),\n );\n }\n return Effect.gen(function* enabledCargoProblems() {\n const manifests = pipe(present, Arr.filter(isCargoManifest));\n const workspaces = yield* cargoWorkspaces(manifests);\n const reads = readsCargoLock(directoriesOf(manifests), workspaces);\n const setup = yield* scanText(pipe(present, Arr.filter(isScannedText)), setupProblems);\n return [\n ...pipe(\n present,\n Arr.filter((entry) => CARGO_LOCK_FILE.test(entry.name) && !reads(entry)),\n Arr.map(nestedCargoLock),\n ),\n ...pipe(present, Arr.filter(isLegacyCargoConfig), Arr.map(legacyCargoConfig)),\n ...pnpmOutputs(present),\n ...setup,\n ];\n });\n};\n\nconst unneededIn = Effect.fn(\"unneededIn\")(function* unneededIn(root: string, workspace: string) {\n const listed = yield* listedFiles(root);\n const present = yield* presentFiles(listed);\n const lockfiles = pipe(present, Arr.filter(isForeignLockfile), Arr.map(foreignLockfile));\n if (!pipe(present, Arr.some(isCargoManifest))) {\n return lockfiles;\n }\n const cargo = yield* cargoProblems(present, cargoEnabled(workspace));\n return [...lockfiles, ...cargo];\n});\n\n/** @internal */\nexport const checkUnneededFiles = Effect.fn(\"checkUnneededFiles\")(function* checkUnneededFiles(\n root: string,\n) {\n const files = yield* RepositoryFiles;\n const workspace = yield* files.readFile(files.join(root, WORKSPACE_FILE));\n if (Option.isNone(workspace)) {\n return [];\n }\n return yield* unneededIn(root, workspace.value);\n});\n","import { Array as Arr, Effect } from \"effect\";\n\nimport { checkComments } from \"#/features/comments/index.ts\";\nimport { checkHiddenUnicode } from \"#/features/invisible-characters/index.ts\";\nimport { checkPython } from \"#/features/python/index.ts\";\nimport { checkUnneededFiles } from \"#/features/unneeded-files/index.ts\";\n\n/** @internal */\nexport const checkTrackedText = Effect.fn(\"checkTrackedText\")(function* checkTrackedText(\n root: string,\n) {\n const found = yield* Effect.all(\n [checkHiddenUnicode(root), checkPython(root), checkUnneededFiles(root), checkComments(root)],\n { concurrency: \"unbounded\" },\n );\n return Arr.flatten(found);\n});\n","import { Array as Arr, Effect } from \"effect\";\n\nimport { checkPublishedPackages } from \"#/features/install-size/index.ts\";\nimport { checkOverrides } from \"#/features/overrides/index.ts\";\nimport { checkPlacement } from \"#/features/placement/index.ts\";\nimport { checkWorkspaces } from \"#/features/repository-layout/index.ts\";\nimport { checkRepository } from \"#/features/value-owners/index.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\n\nimport { checkTrackedText } from \"./tracked-text.ts\";\n\n/** @internal */\nexport const checkAll: (\n root: string,\n) => Effect.Effect<\n readonly Problem[],\n Effect.Error<\n | ReturnType<typeof checkRepository>\n | ReturnType<typeof checkOverrides>\n | ReturnType<typeof checkTrackedText>\n | ReturnType<typeof checkWorkspaces>\n >,\n Effect.Services<\n | ReturnType<typeof checkRepository>\n | ReturnType<typeof checkOverrides>\n | ReturnType<typeof checkTrackedText>\n >\n> = Effect.fn(\"checkAll\")(function* checkAll(root: string) {\n const found = yield* Effect.all(\n [\n checkRepository(root),\n checkOverrides(root),\n checkTrackedText(root),\n checkPlacement(root),\n checkPublishedPackages(root),\n checkWorkspaces(root),\n ],\n { concurrency: \"unbounded\" },\n );\n return Arr.flatten(found);\n});\n","import { Effect, Schema, Stdio, Stream } from \"effect\";\n\nconst taggedError = Schema.TaggedError;\n\nexport class ProblemsFound extends taggedError<ProblemsFound, { readonly brand: unique symbol }>()(\n \"ProblemsFound\",\n {\n count: Schema.Finite,\n },\n) {}\n\n/** @internal */\nexport const writeStdout = Effect.fn(\"writeStdout\")(function* writeStdout(text: string) {\n const stdio = yield* Stdio.Stdio;\n yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);\n});\n","import { runMain } from \"@effect/platform-node-shared/NodeRuntime\";\nimport { Cause, Effect, Layer, Option, Schema, Stdio, Stream } from \"effect\";\nimport type { FileSystem, Path } from \"effect\";\nimport { FetchHttpClient } from \"effect/http\";\nimport { Otlp, OtlpSerialization } from \"effect/observability\";\nimport type { ChildProcessSpawner } from \"effect/process\";\n\nimport { nodeServicesLayer } from \"#/shared/lib/node-services.ts\";\nimport { nodeRepositoryFiles } from \"#/shared/lib/repository-files.ts\";\nimport type { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { ProblemsFound } from \"./output.ts\";\n\nconst reportFailure = <Failure>(\n cause: Cause.Cause<Failure>,\n): Effect.Effect<void, never, Stdio.Stdio> =>\n Effect.gen(function* report() {\n const stdio = yield* Stdio.Stdio;\n const failed = Cause.findErrorOption(cause).pipe(Option.exists(Schema.is(ProblemsFound)));\n if (failed) {\n return;\n }\n yield* Stream.make(`${Cause.pretty(cause)}\\n`).pipe(Stream.run(stdio.stderr()), Effect.orDie);\n });\n\nconst tracing = Otlp.layerFromConfig({ resource: { serviceName: \"msch\" } }).pipe(\n Layer.provide(OtlpSerialization.layerJson),\n Layer.provide(FetchHttpClient.layer),\n);\n\n/** @internal */\nexport const runCli = <Value, Failure>(\n program: Effect.Effect<\n Value,\n Failure,\n | RepositoryFiles\n | Stdio.Stdio\n | FileSystem.FileSystem\n | Path.Path\n | ChildProcessSpawner.ChildProcessSpawner\n >,\n): void => {\n const services = Layer.mergeAll(nodeRepositoryFiles, tracing).pipe(\n Layer.provideMerge(nodeServicesLayer),\n );\n const main = Layer.build(services).pipe(\n Effect.flatMap((context) =>\n Effect.provideContext(program.pipe(Effect.tapCause(reportFailure)), context),\n ),\n Effect.scoped,\n );\n runMain(main, { disableErrorReporting: true });\n};\n","#!/usr/bin/env node\nimport { Effect, Schema, Stdio, Array as Arr, pipe } from \"effect\";\n\nimport { JSON_FLAG } from \"#/shared/lib/cli-contract.ts\";\nimport { ProblemList, formatProblem, sortProblems } from \"#/shared/lib/problem.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { checkAll } from \"./all-checks.ts\";\nimport { ProblemsFound, writeStdout } from \"./output.ts\";\nimport { runCli } from \"./runtime.ts\";\n\nconst NO_PROBLEMS = 0;\n\nconst reportText = (\n root: string,\n problems: readonly Problem[],\n): Effect.Effect<void, ProblemsFound, RepositoryFiles | Stdio.Stdio> =>\n Effect.gen(function* report() {\n const files = yield* RepositoryFiles;\n const format = formatProblem((file) => files.relative(root, file));\n yield* writeStdout(\n pipe(\n problems,\n Arr.map((problem) => `${format(problem)}\\n`),\n Arr.join(\"\"),\n ),\n );\n if (problems.length > NO_PROBLEMS) {\n return yield* ProblemsFound.make({ count: problems.length });\n }\n return yield* Effect.void;\n });\n\nconst msch = Effect.gen(function* msch() {\n const stdio = yield* Stdio.Stdio;\n const files = yield* RepositoryFiles;\n const args = yield* stdio.args;\n const root = files.resolve(\".\");\n const found = yield* checkAll(root);\n const problems = sortProblems(found);\n if (args.includes(JSON_FLAG)) {\n const text = yield* Schema.encodeEffect(Schema.fromJsonString(ProblemList))(problems);\n return yield* writeStdout(text);\n }\n return yield* reportText(root, problems);\n});\n\nrunCli(msch);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,yBAAyB,CAAC,QAAQ,SAAS;AAEjD,MAAM,mBAAmB;AAEzB,MAAM,mBAAmB;AAEzB,MAAa,YAAY,UAAyB,GAAG,OAAO,MAAM,GAAG,OAAO,KAAK;AAEjF,MAAM,kBAAkB,SAAqC;CAC3D,IAAI,KAAK,oBAAoB,KAAK,KAAK,oBAAoB,GACzD,OAAO,OAAO,KAAK,KAAK,KAAK;CAE/B,OAAO,OAAO,KAAK;AACrB;AAEA,MAAa,mBAAmB,UAA4D;CAC1F,MAAM,SAAS,KACb,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