@r_masseater/msch 0.54.0 → 0.57.1

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.
Files changed (77) hide show
  1. package/README.md +18 -18
  2. package/dist/app-B22Gq0no.mjs +2120 -0
  3. package/dist/app-B22Gq0no.mjs.map +1 -0
  4. package/dist/cargo-inputs.d.mts +1 -1
  5. package/dist/cargo-inputs.mjs +5 -11
  6. package/dist/cargo-inputs.mjs.map +1 -1
  7. package/dist/changed.mjs +90 -19
  8. package/dist/changed.mjs.map +1 -1
  9. package/dist/cli.mjs +1361 -707
  10. package/dist/cli.mjs.map +1 -1
  11. package/dist/config.d.mts +1 -1
  12. package/dist/config.mjs +3 -2
  13. package/dist/config.mjs.map +1 -1
  14. package/dist/credential-broker-9FMyTp1H.mjs +44 -0
  15. package/dist/credential-broker-9FMyTp1H.mjs.map +1 -0
  16. package/dist/decision-rules.d.mts +1 -1
  17. package/dist/decision-rules.mjs +1 -1
  18. package/dist/{define-lint-preset-CWEkZVIC.mjs → define-lint-preset-DeLIlDuA.mjs} +7 -634
  19. package/dist/define-lint-preset-DeLIlDuA.mjs.map +1 -0
  20. package/dist/dependencies-B6p7x90y.mjs +215 -0
  21. package/dist/dependencies-B6p7x90y.mjs.map +1 -0
  22. package/dist/exits.mjs +4 -5
  23. package/dist/exits.mjs.map +1 -1
  24. package/dist/{ignored-directories-BTMTNuAx.mjs → ignored-directories-BgUqwuc4.mjs} +12 -3
  25. package/dist/ignored-directories-BgUqwuc4.mjs.map +1 -0
  26. package/dist/{index-BeH2yfX6.d.mts → index-Cwnhs7VE.d.mts} +4 -51
  27. package/dist/library.d.mts +18 -0
  28. package/dist/library.mjs +28 -0
  29. package/dist/library.mjs.map +1 -0
  30. package/dist/lint-rules.mjs +243 -40
  31. package/dist/lint-rules.mjs.map +1 -1
  32. package/dist/lint.d.mts +2 -2
  33. package/dist/lint.mjs +1 -1
  34. package/dist/locked-inputs-DMSoGCa-.mjs +20 -0
  35. package/dist/locked-inputs-DMSoGCa-.mjs.map +1 -0
  36. package/dist/locked-inputs.d.mts +2 -3
  37. package/dist/locked-inputs.mjs +1 -20
  38. package/dist/oxlint.mjs +28 -14
  39. package/dist/oxlint.mjs.map +1 -1
  40. package/dist/{project-C4uzq7_4.mjs → pass-records-BCT1Ls9c.mjs} +38 -66
  41. package/dist/pass-records-BCT1Ls9c.mjs.map +1 -0
  42. package/dist/{problem-CzOlOb5f.mjs → problem-BoHYLMQT.mjs} +10 -6
  43. package/dist/problem-BoHYLMQT.mjs.map +1 -0
  44. package/dist/publish.mjs +634 -303
  45. package/dist/publish.mjs.map +1 -1
  46. package/dist/published-BNJdq0h1.mjs +510 -0
  47. package/dist/published-BNJdq0h1.mjs.map +1 -0
  48. package/dist/runtime-LT40e_l3.mjs +28 -0
  49. package/dist/runtime-LT40e_l3.mjs.map +1 -0
  50. package/dist/{syntax-3AJkpCcs.mjs → syntax-CTiXR0EJ.mjs} +13 -4
  51. package/dist/syntax-CTiXR0EJ.mjs.map +1 -0
  52. package/dist/{check-upstream-exits-DYxWDyHC.mjs → upstream-exits-DitN-yYH.mjs} +10 -92
  53. package/dist/upstream-exits-DitN-yYH.mjs.map +1 -0
  54. package/dist/wake.d.mts +1 -0
  55. package/dist/wake.mjs +25 -0
  56. package/dist/wake.mjs.map +1 -0
  57. package/dist/workspace-settings.mjs +69 -7
  58. package/dist/workspace-settings.mjs.map +1 -1
  59. package/package.json +31 -22
  60. package/skills/{publishing → msch-publishing}/SKILL.md +8 -2
  61. package/skills/{repository-config → msch-repository-config}/SKILL.md +5 -2
  62. package/skills/{workspace-settings → msch-workspace-settings}/SKILL.md +4 -3
  63. package/dist/check-upstream-exits-DYxWDyHC.mjs.map +0 -1
  64. package/dist/define-lint-preset-CWEkZVIC.mjs.map +0 -1
  65. package/dist/dependencies-DCJv7YcW.mjs +0 -684
  66. package/dist/dependencies-DCJv7YcW.mjs.map +0 -1
  67. package/dist/ignored-directories-BTMTNuAx.mjs.map +0 -1
  68. package/dist/locked-inputs.mjs.map +0 -1
  69. package/dist/package-LeBO9czg.mjs +0 -144
  70. package/dist/package-LeBO9czg.mjs.map +0 -1
  71. package/dist/problem-CzOlOb5f.mjs.map +0 -1
  72. package/dist/project-C4uzq7_4.mjs.map +0 -1
  73. package/dist/reachable-Cc-255L3.mjs +0 -13
  74. package/dist/reachable-Cc-255L3.mjs.map +0 -1
  75. package/dist/runtime-DFsdNYI0.mjs +0 -29
  76. package/dist/runtime-DFsdNYI0.mjs.map +0 -1
  77. package/dist/syntax-3AJkpCcs.mjs.map +0 -1
@@ -1,4 +1,8 @@
1
- import { Array, Boolean, Option, Predicate, Record, Schema, String, pipe } from "effect";
1
+ import { n as baseName } from "./app-B22Gq0no.mjs";
2
+ import { Array, Boolean, Match, Option, Predicate, Record, Schema, String as String$1, pipe } from "effect";
3
+ import { isTypeNode } from "typescript/ast/is";
4
+ import { SymbolFlags } from "typescript/sync";
5
+ import { withTypeInformation } from "@r_masseater/oxlint-typed-rules";
2
6
  // src/features/define-lint-rules/model/get-or-insert-ast.ts
3
7
  const START$3 = 0;
4
8
  const END$3 = 1;
@@ -42,7 +46,7 @@ const decodeReturn = Schema.decodeUnknownOption(Schema.Struct({
42
46
  argument: RangedSchema$1
43
47
  }));
44
48
  const decodeTyped = Schema.decodeUnknownOption(Schema.Struct({ type: Schema.String }));
45
- const textOf$1 = (scope) => (node) => String.slice(node.range[START$3], node.range[END$3])(scope.text);
49
+ const textOf$1 = (scope) => (node) => String$1.slice(node.range[START$3], node.range[END$3])(scope.text);
46
50
  const textOfNode = (scope) => (node) => pipe(decodeRanged(node), Option.map(textOf$1(scope)));
47
51
  const accessOf = (scope) => (method) => (node) => pipe(decodeMemberCall(node), Option.filter((call) => call.callee.property.name === method), Option.flatMap((call) => pipe(Array.get(call.arguments, KEY), Option.map((key) => ({
48
52
  map: textOf$1(scope)(call.callee.object),
@@ -73,7 +77,7 @@ const childrenOf$1 = (keys, node) => pipe(Option.liftPredicate(node, Predicate.i
73
77
  const descendants = (keys) => (node) => [node, ...pipe(childrenOf$1(keys, node), Array.flatMap(descendants(keys)))];
74
78
  const accessesIn = (scope) => (method) => (node) => pipe(descendants(scope.keys)(node), Array.map(accessOf(scope)(method)), Array.getSomes);
75
79
  // src/features/define-lint-rules/model/array-from-async.ts
76
- const MESSAGE$3 = "Collect an async iterable with Array.fromAsync, passing the mapping as its second argument. Do not push each item from a for await loop.";
80
+ const MESSAGE$4 = "Collect an async iterable with Array.fromAsync, passing the mapping as its second argument. Do not push each item from a for await loop.";
77
81
  const ONE$1 = 1;
78
82
  const DeclarationSchema = Schema.Struct({
79
83
  type: Schema.Literal("VariableDeclaration"),
@@ -107,7 +111,7 @@ const arrayFromAsync = {
107
111
  create: (context) => ({ ForOfStatement: (node) => {
108
112
  if (collectsByHand(node)) context.report({
109
113
  node,
110
- message: MESSAGE$3
114
+ message: MESSAGE$4
111
115
  });
112
116
  } })
113
117
  };
@@ -166,8 +170,6 @@ const PARSER_CALLS = {
166
170
  typescript: Option.none(),
167
171
  yaml: Option.none()
168
172
  };
169
- const SEPARATOR$1 = "/";
170
- const baseNameOf = (text) => pipe(String.split(text, SEPARATOR$1), Array.last, Option.getOrElse(() => text));
171
173
  const importedModules = (statements) => pipe(statements, Array.filter((statement) => statement.type === "ImportDeclaration"), Array.map((declaration) => declaration.source.value));
172
174
  const parserIn = (context) => (format) => {
173
175
  const imported = importedModules(context.sourceCode.ast.body);
@@ -176,7 +178,7 @@ const parserIn = (context) => (format) => {
176
178
  return pipe(Record.get(PARSER_CALLS, format), Option.flatten, Option.flatMap((pattern) => Option.fromNullishOr(pattern.exec(context.sourceCode.text))), Option.map(([call]) => call));
177
179
  };
178
180
  const messageFor = (context) => (text) => {
179
- const name = baseNameOf(text);
181
+ const name = baseName(text);
180
182
  return pipe(ECOSYSTEM_FILES, Array.findFirst((entry) => entry.name.test(name)), Option.flatMap(({ format, reader }) => pipe(parserIn(context)(format), Option.map((parser) => `${name} has an official reader: ${reader}. Read it with that instead of parsing it with ${parser}, so that the file means what its own tool says it means.`))));
181
183
  };
182
184
  const ecosystemReaders = {
@@ -199,7 +201,7 @@ const ecosystemReaders = {
199
201
  })
200
202
  };
201
203
  // src/features/define-lint-rules/model/get-or-insert.ts
202
- const MESSAGE$2 = "Use getOrInsert or getOrInsertComputed on the Map or WeakMap, so that reading a key and storing its first value is one call. Do not read the key and then set it by hand.";
204
+ const MESSAGE$3 = "Use getOrInsert or getOrInsertComputed on the Map or WeakMap, so that reading a key and storing its first value is one call. Do not read the key and then set it by hand.";
203
205
  const ONE = 1;
204
206
  const TWO = 2;
205
207
  const OPTION_FROM = /^(?:Option\.)?from(?:NullishOr|UndefinedOr|Nullable)$/u;
@@ -308,17 +310,17 @@ const getOrInsert = {
308
310
  IfStatement: (node) => {
309
311
  if (isHasGuard(scope, node)) context.report({
310
312
  node,
311
- message: MESSAGE$2
313
+ message: MESSAGE$3
312
314
  });
313
315
  },
314
316
  BlockStatement: (node) => {
315
317
  for (const index of fallbackIndices(scope, node.body)) for (const statement of Option.toArray(Array.get(node.body, index))) context.report({
316
318
  node: statement,
317
- message: MESSAGE$2
319
+ message: MESSAGE$3
318
320
  });
319
321
  if (isMemoized(scope, node)) context.report({
320
322
  node,
321
- message: MESSAGE$2
323
+ message: MESSAGE$3
322
324
  });
323
325
  }
324
326
  };
@@ -373,15 +375,15 @@ const START$2 = 0;
373
375
  const END$2 = 1;
374
376
  const NEXT = 1;
375
377
  const NEWLINE$1 = "\n";
376
- const textOf = (source) => (range) => pipe(source.text, String.slice(range[START$2], range[END$2]));
377
- const lineStartOf = (source, offset) => pipe(source.text, String.slice(START$2, offset), String.lastIndexOf(NEWLINE$1), Option.match({
378
+ const textOf = (source) => (range) => pipe(source.text, String$1.slice(range[START$2], range[END$2]));
379
+ const lineStartOf = (source, offset) => pipe(source.text, String$1.slice(START$2, offset), String$1.lastIndexOf(NEWLINE$1), Option.match({
378
380
  onNone: () => START$2,
379
381
  onSome: (index) => index + NEXT
380
382
  }));
381
383
  const indentOf = (source) => (offset) => textOf(source)([lineStartOf(source, offset), offset]);
382
384
  const lineRangeOf = (source) => (range) => {
383
- const indented = String.isEmpty(String.trim(indentOf(source)(range[START$2])));
384
- const endsLine = pipe(source.text, String.charAt(range[END$2]), Option.contains(NEWLINE$1));
385
+ const indented = String$1.isEmpty(String$1.trim(indentOf(source)(range[START$2])));
386
+ const endsLine = pipe(source.text, String$1.charAt(range[END$2]), Option.contains(NEWLINE$1));
385
387
  return [Boolean.match(indented, {
386
388
  onFalse: () => range[START$2],
387
389
  onTrue: () => lineStartOf(source, range[START$2])
@@ -390,7 +392,7 @@ const lineRangeOf = (source) => (range) => {
390
392
  onTrue: () => range[END$2] + NEXT
391
393
  })];
392
394
  };
393
- const commentsBefore = (source) => (start) => pipe(source.comments, Array.findLast((comment) => comment[END$2] <= start), Option.filter((comment) => String.isEmpty(String.trim(textOf(source)([comment[END$2], start])))), Option.match({
395
+ const commentsBefore = (source) => (start) => pipe(source.comments, Array.findLast((comment) => comment[END$2] <= start), Option.filter((comment) => String$1.isEmpty(String$1.trim(textOf(source)([comment[END$2], start])))), Option.match({
394
396
  onNone: () => [],
395
397
  onSome: (comment) => [...commentsBefore(source)(comment[START$2]), comment]
396
398
  }));
@@ -460,11 +462,11 @@ const replacementOf = (source, list, resolved) => {
460
462
  const removedOf = (source, reexports) => pipe(statementsOf(reexports), Array.filter((statement) => pipe(statement.bindings, Array.every((binding) => pipe(reexports, Array.some((entry) => entry.statement === statement && entry.binding === binding)) && !pipe(source.usedOutside, Array.contains(binding.local))))));
461
463
  const prefixOf = (source, comments) => (statement) => {
462
464
  const start = statement.range[START$1];
463
- if (String.isEmpty(comments) || pipe(leadingTextOf(source)(start), String.includes(comments))) return EXPORT;
465
+ if (String$1.isEmpty(comments) || pipe(leadingTextOf(source)(start), String$1.includes(comments))) return EXPORT;
464
466
  return `${comments}${NEWLINE}${indentOf(source)(start)}${EXPORT}`;
465
467
  };
466
468
  const listEditOf = (source, list, text) => {
467
- if (!String.isEmpty(text)) return {
469
+ if (!String$1.isEmpty(text)) return {
468
470
  range: list.range,
469
471
  text
470
472
  };
@@ -650,28 +652,28 @@ const exportListOf = (node) => pipe(decodeList(node), Option.filter((list) => Ar
650
652
  body: pipe(list.parent.body, Array.map(statementOf), Array.getSomes)
651
653
  })));
652
654
  // src/features/define-lint-rules/model/inline-exports.ts
653
- const MESSAGE$1 = "export は宣言に付ける(export const・export function など)。ファイルの末尾で export { … } にまとめない。";
655
+ const MESSAGE$2 = "export は宣言に付ける(export const・export function など)。ファイルの末尾で export { … } にまとめない。";
654
656
  const START = 0;
655
657
  const END = 1;
656
658
  const outside = (list) => (range) => range[START] < list[START] || range[END] > list[END];
657
659
  const usedOutside = (context, list) => pipe(context.sourceCode.scopeManager.scopes, Array.flatMap((scope) => scope.variables), Array.filter((variable) => pipe(variable.references, Array.some((reference) => outside(list.range)(reference.identifier.range)))), Array.map((variable) => variable.name));
658
- const sourceOf = (context, list) => ({
660
+ const sourceOf$1 = (context, list) => ({
659
661
  text: context.sourceCode.text,
660
662
  comments: pipe(context.sourceCode.getAllComments(), Array.map((comment) => comment.range)),
661
663
  usedOutside: usedOutside(context, list)
662
664
  });
663
665
  const reportList = (context, node, list) => {
664
- pipe(editsOf(sourceOf(context, list))(list), Option.match({
666
+ pipe(editsOf(sourceOf$1(context, list))(list), Option.match({
665
667
  onNone: () => {
666
668
  context.report({
667
669
  node,
668
- message: MESSAGE$1
670
+ message: MESSAGE$2
669
671
  });
670
672
  },
671
673
  onSome: (edits) => {
672
674
  context.report({
673
675
  node,
674
- message: MESSAGE$1,
676
+ message: MESSAGE$2,
675
677
  fix: (fixer) => pipe(edits, Array.map((edit) => fixer.replaceTextRange([edit.range[START], edit.range[END]], edit.text)))
676
678
  });
677
679
  }
@@ -842,15 +844,218 @@ const INTENTS = {
842
844
  };
843
845
  // src/features/define-lint-rules/model/mcp-tool-layer.ts
844
846
  const SOURCE = "/src/";
845
- const SEPARATOR = "/";
847
+ const SEPARATOR$1 = "/";
846
848
  const WINDOWS_SEPARATOR = "\\";
847
849
  const TOOL_LAYERS = ["features", "shared"];
848
850
  const TEST_FILE = /\.test(?:\.support)?\.[cm]?[jt]sx?$/u;
849
851
  const METHOD = "registerTool";
850
- const MESSAGE = "Register an MCP tool in the features slice of the operation it performs. A tool is one operation, so app/ only composes the slices' register functions and entities/ only holds the data they share.";
851
- const layerIn = (path) => pipe(String.lastIndexOf(SOURCE)(path), Option.flatMap((index) => pipe(String.slice(index + 5)(path), String.split(SEPARATOR), Array.head)));
852
- const layerOf = (filename) => layerIn(String.replaceAll(WINDOWS_SEPARATOR, SEPARATOR)(filename));
852
+ const MESSAGE$1 = "Register an MCP tool in the features slice of the operation it performs. A tool is one operation, so app/ only composes the slices' register functions and entities/ only holds the data they share.";
853
+ const layerIn = (path) => pipe(String$1.lastIndexOf(SOURCE)(path), Option.flatMap((index) => pipe(String$1.slice(index + 5)(path), String$1.split(SEPARATOR$1), Array.head)));
854
+ const layerOf = (filename) => layerIn(String$1.replaceAll(WINDOWS_SEPARATOR, SEPARATOR$1)(filename));
853
855
  const outsideToolLayers = (filename) => !TEST_FILE.test(filename) && Option.exists(layerOf(filename), (layer) => !Array.contains(TOOL_LAYERS, layer));
856
+ const mcpToolLayer = {
857
+ meta: { type: "problem" },
858
+ create: (context) => {
859
+ if (!outsideToolLayers(context.filename)) return {};
860
+ return { CallExpression: (node) => {
861
+ const { callee } = node;
862
+ if (callee.type === "MemberExpression" && callee.property.type === "Identifier" && callee.property.name === METHOD) context.report({
863
+ node: callee.property,
864
+ message: MESSAGE$1
865
+ });
866
+ } };
867
+ }
868
+ };
869
+ // src/features/define-lint-rules/model/declared-outside.ts
870
+ const origins = /* @__PURE__ */ new WeakMap();
871
+ const readonlyForms = /* @__PURE__ */ new WeakMap();
872
+ const fileOrigin = (project, handle) => pipe(Option.fromNullishOr(project.program.getSourceFileMetadataByPath(handle.path)), Option.flatMap(({ isDefaultLibrary, isFromExternalLibrary }) => {
873
+ if (isDefaultLibrary) return Option.some("builtin");
874
+ if (isFromExternalLibrary) return Option.some("package");
875
+ return Option.none();
876
+ }));
877
+ const declarationOrigin = (project) => (handle) => pipe(fileOrigin(project, handle), Option.orElse(() => pipe(Option.fromNullishOr(handle.resolve(project)), Option.filter((node) => node.getSourceFile().isDeclarationFile), Option.as("package"))), Option.getOrElse(() => "own"));
878
+ const originOf = (project) => (symbol) => origins.getOrInsertComputed(symbol, () => {
879
+ const found = pipe(symbol.declarations, Array.map(declarationOrigin(project)));
880
+ if (Array.contains(found, "builtin")) return "builtin";
881
+ if (Array.contains(found, "package")) return "package";
882
+ return "own";
883
+ });
884
+ const builtinNamed = (project) => (name) => pipe(Option.fromNullishOr(project.checker.resolveName(name, SymbolFlags.Type)), Option.filter((symbol) => originOf(project)(symbol) === "builtin"), Option.as(name));
885
+ const readonlyFormOf = (project) => (name) => readonlyForms.getOrInsertComputed(project, () => /* @__PURE__ */ new Map()).getOrInsertComputed(name, () => pipe([`Readonly${name}`, `${name}ReadOnly`], Array.findFirst(builtinNamed(project))));
886
+ const MUTABLE_ARRAY = "Array";
887
+ const PRIVATE_NAME = "__#";
888
+ const SYMBOL_NAME = "__@";
889
+ const here = (mutability) => Option.some({
890
+ path: [],
891
+ mutability
892
+ });
893
+ const under = (segment) => (part) => ({
894
+ ...part,
895
+ path: [segment, ...part.path]
896
+ });
897
+ const firstPart = (search, types) => pipe(types, Array.findFirst(search.partOf));
898
+ const formOf = (project) => (name) => pipe(readonlyFormOf(project)(name), Option.flatMap((readonlyName) => here({
899
+ kind: "form",
900
+ name,
901
+ readonlyName
902
+ })));
903
+ const isOpaqueAlias = (project, type) => pipe(Option.fromNullishOr(type.getAliasSymbol()), Option.exists((alias) => {
904
+ const origin = originOf(project)(alias);
905
+ return origin === "package" || origin === "builtin" && Array.isReadonlyArrayEmpty(type.getAliasTypeArguments());
906
+ }));
907
+ const isNamed = (type) => type.isClassOrInterface() || type.isTypeReference() && type.getTarget().isClassOrInterface();
908
+ const declaredOutside = (project, type) => pipe(Option.fromNullishOr(type.getSymbol()), Option.flatMap((symbol) => {
909
+ const origin = originOf(project)(symbol);
910
+ if (origin === "package") return Option.some(Option.none());
911
+ if (origin === "own" || !isNamed(type)) return Option.none();
912
+ return Option.some(formOf(project)(symbol.name));
913
+ }));
914
+ const isOutside = (project, type) => isOpaqueAlias(project, type) || type.isObjectType() && Option.exists(declaredOutside(project, type), Option.isNone);
915
+ const sourceOf = (type) => {
916
+ if (!type.isMappedType()) return Option.none();
917
+ const template = type.getTemplateType();
918
+ if (!template.isIndexedAccessType()) return Option.none();
919
+ return Option.some(template.getObjectType());
920
+ };
921
+ const takenFromOutside = (project) => (type) => {
922
+ if (isOutside(project, type)) return pipe(type.getProperties(), Array.map((property) => property.name));
923
+ if (type.isUnionType() || type.isIntersectionType()) return pipe(type.getTypes(), Array.flatMap(takenFromOutside(project)));
924
+ return pipe(sourceOf(type), Option.map(takenFromOutside(project)), Option.getOrElse(() => []));
925
+ };
926
+ const elementsPart = (search, type) => {
927
+ if (!type.isTypeReference()) return Option.none();
928
+ return pipe(firstPart(search, search.project.checker.getTypeArguments(type)), Option.map(under("[]")));
929
+ };
930
+ const arrayPart = (search, type) => {
931
+ if (pipe(Option.fromNullishOr(type.getSymbol()), Option.exists((symbol) => symbol.name === MUTABLE_ARRAY))) return here({ kind: "array" });
932
+ return elementsPart(search, type);
933
+ };
934
+ const tuplePart = (search, type) => {
935
+ if (type.isTupleType() && !type.getTarget().readonly) return here({ kind: "tuple" });
936
+ return elementsPart(search, type);
937
+ };
938
+ const named = (prefix) => (property) => pipe(String(property.escapedName), String$1.startsWith(prefix));
939
+ const isWritable = (checker) => (property) => !checker.isReadonlySymbol(property) && !named(PRIVATE_NAME)(property);
940
+ const isStringNamed = (property) => !named(PRIVATE_NAME)(property) && !named(SYMBOL_NAME)(property);
941
+ const declaredIn = (project, origin) => (property) => originOf(project)(property) === origin;
942
+ const inheritedForm = (project) => (property) => pipe(Option.fromNullishOr(property.getParent()), Option.flatMap((owner) => formOf(project)(owner.name)));
943
+ const propertyTypesPart = (search, properties) => {
944
+ const judged = pipe(properties, Array.filter(isStringNamed));
945
+ return pipe(Array.zip(judged, search.project.checker.getTypeOfSymbol(judged)), Array.findFirst(([property, type]) => pipe(search.partOf(type), Option.map(under(property.name)))));
946
+ };
947
+ const indexPart = (search, type) => pipe(type.getIndexInfos(), Array.findFirst((info) => {
948
+ if (!info.isReadonly) return here({ kind: "index" });
949
+ return pipe(search.partOf(info.valueType), Option.map(under("[]")));
950
+ }));
951
+ const membersPart = (search, type) => {
952
+ const { project } = search;
953
+ const properties = type.getProperties();
954
+ const taken = pipe(sourceOf(type), Option.map(takenFromOutside(project)), Option.getOrElse(() => []));
955
+ const own = pipe(properties, Array.filter((property) => declaredIn(project, "own")(property) && !Array.contains(taken, property.name)));
956
+ return pipe(own, Array.findFirst(isWritable(project.checker)), Option.map((property) => ({
957
+ path: [property.name],
958
+ mutability: { kind: "property" }
959
+ })), Option.orElse(() => pipe(properties, Array.filter(declaredIn(project, "builtin")), Array.findFirst(inheritedForm(project)))), Option.orElse(() => propertyTypesPart(search, own)), Option.orElse(() => indexPart(search, type)));
960
+ };
961
+ const isFunction = (type) => Array.isReadonlyArrayNonEmpty(type.getCallSignatures()) && Array.isReadonlyArrayEmpty(type.getProperties());
962
+ const objectPart = (search, type) => {
963
+ if (isFunction(type)) return Option.none();
964
+ if (search.project.checker.isArrayType(type)) return arrayPart(search, type);
965
+ if (type.isTupleType()) return tuplePart(search, type);
966
+ return pipe(declaredOutside(search.project, type), Option.getOrElse(() => membersPart(search, type)));
967
+ };
968
+ const typePart = (search, type) => {
969
+ if (isOpaqueAlias(search.project, type)) return Option.none();
970
+ if (type.isUnionType() || type.isIntersectionType()) return firstPart(search, type.getTypes());
971
+ if (type.isConditionalType()) return firstPart(search, [type.getTrueType(), type.getFalseType()]);
972
+ if (!type.isObjectType()) return Option.none();
973
+ return objectPart(search, type);
974
+ };
975
+ const writablePartOf = (project) => (type) => {
976
+ const seen = /* @__PURE__ */ new Set();
977
+ const partOf = (inner) => {
978
+ if (seen.has(inner)) return Option.none();
979
+ seen.add(inner);
980
+ return typePart({
981
+ project,
982
+ partOf
983
+ }, inner);
984
+ };
985
+ return partOf(type);
986
+ };
987
+ // src/features/define-lint-rules/model/readonly-parameters.ts
988
+ const MESSAGE = "A function must not be able to change its arguments, but {{part}}. Declare the parameter with a read-only type. Types declared by a package or by the language are exempt unless the language has a read-only form of them.";
989
+ const MESSAGE_ID = "shouldBeReadonly";
990
+ const WHOLE = "the type";
991
+ const SEPARATOR = ".";
992
+ const TAGGABLE = [
993
+ "string",
994
+ "number",
995
+ "bigint"
996
+ ];
997
+ const isBrandObject = (type) => type.isObjectType() && Array.isReadonlyArrayEmpty(type.getCallSignatures()) && Array.isReadonlyArrayEmpty(type.getConstructSignatures());
998
+ const isTaggable = (type) => type.isLiteralType() || type.isTemplateLiteralType() || type.isIntrinsicType() && Array.contains(TAGGABLE, type.intrinsicName);
999
+ const isBrandedLiteral = (type) => {
1000
+ if (!type.isIntersectionType()) return false;
1001
+ const parts = type.getTypes();
1002
+ const objects = pipe(parts, Array.filter(isBrandObject));
1003
+ const primitives = pipe(parts, Array.filter(isTaggable));
1004
+ return Array.isReadonlyArrayNonEmpty(objects) && Array.isReadonlyArrayNonEmpty(primitives) && objects.length + primitives.length === parts.length;
1005
+ };
1006
+ const isBrandedLiteralLike = (type) => {
1007
+ if (type.isUnionType()) return pipe(type.getTypes(), Array.every(isBrandedLiteral));
1008
+ return isBrandedLiteral(type);
1009
+ };
1010
+ const outermost = (node) => pipe(Option.fromNullishOr(node.parent), Option.filter((parent) => parent.getStart() === node.getStart() && parent.end === node.end), Option.match({
1011
+ onNone: () => node,
1012
+ onSome: outermost
1013
+ }));
1014
+ const unwrapped = (parameter) => {
1015
+ if (parameter.type === "TSParameterProperty") return parameter.parameter;
1016
+ return parameter;
1017
+ };
1018
+ const annotationOf = (parameter) => {
1019
+ if (parameter.type === "AssignmentPattern") return Option.fromNullishOr(parameter.left.typeAnnotation);
1020
+ return Option.fromNullishOr(parameter.typeAnnotation);
1021
+ };
1022
+ const annotatedType = (services, parameter) => pipe(annotationOf(parameter), Option.map((annotation) => outermost(services.esTreeNodeToTSNodeMap.get(annotation.typeAnnotation))), Option.filter(isTypeNode), Option.map((node) => services.program.native.checker.getTypeFromTypeNode(node)));
1023
+ const subjectOf = (path) => {
1024
+ if (Array.isReadonlyArrayEmpty(path)) return WHOLE;
1025
+ return `\`${pipe(Array.join(path, SEPARATOR), String$1.replaceAll(`${SEPARATOR}[]`, "[]"))}\``;
1026
+ };
1027
+ const predicateOf = Match.type().pipe(Match.discriminatorsExhaustive("kind")({
1028
+ array: () => "is a mutable array",
1029
+ tuple: () => "is a mutable tuple",
1030
+ property: () => "is writable",
1031
+ index: () => "has a writable index signature",
1032
+ form: ({ name, readonlyName }) => `is a \`${name}\`, which has the read-only form \`${readonlyName}\``
1033
+ }));
1034
+ const describe = ({ path, mutability }) => `${subjectOf(path)} ${predicateOf(mutability)}`;
1035
+ const visitorOf = (context, services) => {
1036
+ const partOf = writablePartOf(services.program.native);
1037
+ const check = ({ params }) => {
1038
+ for (const parameter of pipe(params, Array.map(unwrapped))) {
1039
+ const part = pipe(annotatedType(services, parameter), Option.filter((type) => !isBrandedLiteralLike(type)), Option.flatMap(partOf));
1040
+ if (Option.isSome(part)) context.report({
1041
+ node: parameter,
1042
+ messageId: MESSAGE_ID,
1043
+ data: { part: describe(part.value) }
1044
+ });
1045
+ }
1046
+ };
1047
+ return {
1048
+ ArrowFunctionExpression: check,
1049
+ FunctionDeclaration: check,
1050
+ FunctionExpression: check,
1051
+ TSCallSignatureDeclaration: check,
1052
+ TSConstructSignatureDeclaration: check,
1053
+ TSDeclareFunction: check,
1054
+ TSEmptyBodyFunctionExpression: check,
1055
+ TSFunctionType: check,
1056
+ TSMethodSignature: check
1057
+ };
1058
+ };
854
1059
  // src/features/define-lint-rules/model/plugin.ts
855
1060
  const mschLintPlugin = {
856
1061
  meta: { name: "msch-lint" },
@@ -859,19 +1064,17 @@ const mschLintPlugin = {
859
1064
  "ecosystem-readers": ecosystemReaders,
860
1065
  "get-or-insert": getOrInsert,
861
1066
  "inline-exports": inlineExports,
862
- "mcp-tool-layer": {
863
- meta: { type: "problem" },
864
- create: (context) => {
865
- if (!outsideToolLayers(context.filename)) return {};
866
- return { CallExpression: (node) => {
867
- const { callee } = node;
868
- if (callee.type === "MemberExpression" && callee.property.type === "Identifier" && callee.property.name === METHOD) context.report({
869
- node: callee.property,
870
- message: MESSAGE
871
- });
872
- } };
873
- }
874
- },
1067
+ "mcp-tool-layer": mcpToolLayer,
1068
+ "readonly-parameters": withTypeInformation({
1069
+ meta: {
1070
+ type: "suggestion",
1071
+ messages: { [MESSAGE_ID]: MESSAGE }
1072
+ },
1073
+ create: (context) => pipe(Option.fromNullishOr(context.sourceCode.parserServices), Option.match({
1074
+ onNone: () => ({}),
1075
+ onSome: (services) => visitorOf(context, services)
1076
+ }))
1077
+ }),
875
1078
  ...pipe(INTENTS, Record.map(ruleOf))
876
1079
  }
877
1080
  };