@r_masseater/msch 0.77.1 → 0.78.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 (39) hide show
  1. package/README.md +1 -0
  2. package/dist/changed.mjs +2 -2
  3. package/dist/cli.mjs +230 -320
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/exits.mjs +2 -2
  6. package/dist/{lookup-report-Dp36RBaW.mjs → lookup-report-BdUByHMt.mjs} +2 -2
  7. package/dist/{lookup-report-Dp36RBaW.mjs.map → lookup-report-BdUByHMt.mjs.map} +1 -1
  8. package/dist/manifest-texts-C6Qjv0xy.mjs +29 -0
  9. package/dist/manifest-texts-C6Qjv0xy.mjs.map +1 -0
  10. package/dist/output-BUCq_3DP.mjs +28 -0
  11. package/dist/output-BUCq_3DP.mjs.map +1 -0
  12. package/dist/oxlint.mjs +1 -1
  13. package/dist/package-versions-G9Unih6I.mjs +91 -0
  14. package/dist/package-versions-G9Unih6I.mjs.map +1 -0
  15. package/dist/{pass-records-D5HYFQWz.mjs → pass-records-6XLhXZL3.mjs} +2 -2
  16. package/dist/{pass-records-D5HYFQWz.mjs.map → pass-records-6XLhXZL3.mjs.map} +1 -1
  17. package/dist/{syntax-CbxAKkqt.mjs → problem-OJg859cN.mjs} +54 -8
  18. package/dist/problem-OJg859cN.mjs.map +1 -0
  19. package/dist/publish.mjs +17 -6
  20. package/dist/publish.mjs.map +1 -1
  21. package/dist/published.mjs +3 -2
  22. package/dist/published.mjs.map +1 -1
  23. package/dist/refs.mjs +1 -1
  24. package/dist/{manifest-texts-CfnH7ifu.mjs → specifiers-D9L0OV3r.mjs} +3 -28
  25. package/dist/specifiers-D9L0OV3r.mjs.map +1 -0
  26. package/dist/unbumped.d.mts +1 -0
  27. package/dist/unbumped.mjs +19 -0
  28. package/dist/unbumped.mjs.map +1 -0
  29. package/dist/{upstream-exits-CiX81Owg.mjs → upstream-exits-CJehIR2f.mjs} +2 -2
  30. package/dist/{upstream-exits-CiX81Owg.mjs.map → upstream-exits-CJehIR2f.mjs.map} +1 -1
  31. package/package.json +4 -3
  32. package/skills/msch-checks/SKILL.md +2 -1
  33. package/skills/msch-publishing/SKILL.md +1 -1
  34. package/dist/manifest-texts-CfnH7ifu.mjs.map +0 -1
  35. package/dist/output-DrM4OsOJ.mjs +0 -14
  36. package/dist/output-DrM4OsOJ.mjs.map +0 -1
  37. package/dist/problem-aeeiOlaz.mjs +0 -51
  38. package/dist/problem-aeeiOlaz.mjs.map +0 -1
  39. package/dist/syntax-CbxAKkqt.mjs.map +0 -1
package/dist/exits.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { t as lookupReport } from "./lookup-report-Dp36RBaW.mjs";
2
+ import { t as lookupReport } from "./lookup-report-BdUByHMt.mjs";
3
3
  import { t as runCli } from "./runtime-CFZ41rB0.mjs";
4
- import { n as upstreamExitsMet } from "./upstream-exits-CiX81Owg.mjs";
4
+ import { n as upstreamExitsMet } from "./upstream-exits-CJehIR2f.mjs";
5
5
  import { n as RepositoryFiles } from "./repository-files-C2gVviac.mjs";
6
6
  import { Array, Effect, Schema, pipe } from "effect";
7
7
  // bin/msch-exits.ts
@@ -1,6 +1,6 @@
1
1
  import { t as JSON_FLAG } from "./cli-contract-D7btWrEu.mjs";
2
2
  import { n as RepositoryFiles } from "./repository-files-C2gVviac.mjs";
3
- import { n as writeStdout, t as ProblemsFound } from "./output-DrM4OsOJ.mjs";
3
+ import { i as writeStdout, t as ProblemsFound } from "./output-BUCq_3DP.mjs";
4
4
  import { Array, Effect, Order, Schema, Stdio, pipe } from "effect";
5
5
  // src/app/lookup-report.ts
6
6
  const NONE_FOUND = 0;
@@ -26,4 +26,4 @@ const lookupReport = ({ row, rows, describe }) => Effect.gen(function* report()
26
26
  });
27
27
  export { lookupReport as t };
28
28
 
29
- //# sourceMappingURL=lookup-report-Dp36RBaW.mjs.map
29
+ //# sourceMappingURL=lookup-report-BdUByHMt.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lookup-report-Dp36RBaW.mjs","names":["Arr"],"sources":["../src/app/lookup-report.ts"],"sourcesContent":["import { Array as Arr, Effect, Order, Schema, Stdio, pipe } from \"effect\";\n\nimport { JSON_FLAG } from \"#/shared/lib/cli-contract.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { ProblemsFound, writeStdout } from \"./output.ts\";\n\nconst NONE_FOUND = 0;\nconst LINE_BREAK = \"\\n\";\n\nconst byPlace = Order.Struct({ file: Order.String, line: Order.Number });\n\n/** @internal */\nexport interface Place {\n readonly file: string;\n readonly line: number;\n}\n\n/** @internal */\nexport interface LookupReport<Row extends Place, Failure, Requirements> {\n readonly row: Schema.Codec<Row>;\n readonly rows: (root: string) => Effect.Effect<readonly Row[], Failure, Requirements>;\n readonly describe: (row: Row) => string;\n}\n\nconst textOf =\n <Row extends Place>(row: Schema.Codec<Row>, describe: (row: Row) => string) =>\n (json: boolean, rows: readonly Row[]): Effect.Effect<string, Schema.SchemaError> => {\n if (json) {\n return Schema.encodeEffect(row.pipe(Schema.Array, Schema.fromJsonString))(rows);\n }\n return Effect.succeed(\n pipe(\n rows,\n Arr.map((found) => `${describe(found)}${LINE_BREAK}`),\n Arr.join(\"\"),\n ),\n );\n };\n\n/** @internal */\nexport const lookupReport = <Row extends Place, Failure, Requirements>({\n row,\n rows,\n describe,\n}: LookupReport<Row, Failure, Requirements>): Effect.Effect<\n number,\n Failure | Schema.SchemaError | ProblemsFound,\n Requirements | RepositoryFiles | Stdio.Stdio\n> =>\n Effect.gen(function* report() {\n const stdio = yield* Stdio.Stdio;\n const files = yield* RepositoryFiles;\n const args = yield* stdio.args;\n const found = yield* rows(files.resolve(\".\"));\n const text = yield* textOf(row, describe)(\n Arr.contains(args, JSON_FLAG),\n Arr.sort(found, byPlace),\n );\n yield* writeStdout(text);\n if (found.length > NONE_FOUND) {\n return yield* ProblemsFound.make({ count: found.length });\n }\n return NONE_FOUND;\n });\n"],"mappings":";;;;;AAOA,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,MAAM,UAAU,MAAM,OAAO;CAAE,MAAM,MAAM;CAAQ,MAAM,MAAM;AAAO,CAAC;AAevE,MAAM,UACgB,KAAwB,cAC3C,MAAe,SAAoE;CAClF,IAAI,MACF,OAAO,OAAO,aAAa,IAAI,KAAK,OAAO,OAAO,OAAO,cAAc,CAAC,CAAC,CAAC,IAAI;CAEhF,OAAO,OAAO,QACZ,KACE,MACAA,MAAI,KAAK,UAAU,GAAG,SAAS,KAAK,IAAI,YAAY,GACpDA,MAAI,KAAK,EAAE,CACb,CACF;AACF;;AAGF,MAAa,gBAA0D,EACrE,KACA,MACA,eAMA,OAAO,IAAI,UAAU,SAAS;CAC5B,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,MAAM;CAC1B,MAAM,QAAQ,OAAO,KAAK,MAAM,QAAQ,GAAG,CAAC;CAC5C,MAAM,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CACvCA,MAAI,SAAS,MAAM,SAAS,GAC5BA,MAAI,KAAK,OAAO,OAAO,CACzB;CACA,OAAO,YAAY,IAAI;CACvB,IAAI,MAAM,SAAS,YACjB,OAAO,OAAO,cAAc,KAAK,EAAE,OAAO,MAAM,OAAO,CAAC;CAE1D,OAAO;AACT,CAAC"}
1
+ {"version":3,"file":"lookup-report-BdUByHMt.mjs","names":["Arr"],"sources":["../src/app/lookup-report.ts"],"sourcesContent":["import { Array as Arr, Effect, Order, Schema, Stdio, pipe } from \"effect\";\n\nimport { JSON_FLAG } from \"#/shared/lib/cli-contract.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { ProblemsFound, writeStdout } from \"./output.ts\";\n\nconst NONE_FOUND = 0;\nconst LINE_BREAK = \"\\n\";\n\nconst byPlace = Order.Struct({ file: Order.String, line: Order.Number });\n\n/** @internal */\nexport interface Place {\n readonly file: string;\n readonly line: number;\n}\n\n/** @internal */\nexport interface LookupReport<Row extends Place, Failure, Requirements> {\n readonly row: Schema.Codec<Row>;\n readonly rows: (root: string) => Effect.Effect<readonly Row[], Failure, Requirements>;\n readonly describe: (row: Row) => string;\n}\n\nconst textOf =\n <Row extends Place>(row: Schema.Codec<Row>, describe: (row: Row) => string) =>\n (json: boolean, rows: readonly Row[]): Effect.Effect<string, Schema.SchemaError> => {\n if (json) {\n return Schema.encodeEffect(row.pipe(Schema.Array, Schema.fromJsonString))(rows);\n }\n return Effect.succeed(\n pipe(\n rows,\n Arr.map((found) => `${describe(found)}${LINE_BREAK}`),\n Arr.join(\"\"),\n ),\n );\n };\n\n/** @internal */\nexport const lookupReport = <Row extends Place, Failure, Requirements>({\n row,\n rows,\n describe,\n}: LookupReport<Row, Failure, Requirements>): Effect.Effect<\n number,\n Failure | Schema.SchemaError | ProblemsFound,\n Requirements | RepositoryFiles | Stdio.Stdio\n> =>\n Effect.gen(function* report() {\n const stdio = yield* Stdio.Stdio;\n const files = yield* RepositoryFiles;\n const args = yield* stdio.args;\n const found = yield* rows(files.resolve(\".\"));\n const text = yield* textOf(row, describe)(\n Arr.contains(args, JSON_FLAG),\n Arr.sort(found, byPlace),\n );\n yield* writeStdout(text);\n if (found.length > NONE_FOUND) {\n return yield* ProblemsFound.make({ count: found.length });\n }\n return NONE_FOUND;\n });\n"],"mappings":";;;;;AAOA,MAAM,aAAa;AACnB,MAAM,aAAa;AAEnB,MAAM,UAAU,MAAM,OAAO;CAAE,MAAM,MAAM;CAAQ,MAAM,MAAM;AAAO,CAAC;AAevE,MAAM,UACgB,KAAwB,cAC3C,MAAe,SAAoE;CAClF,IAAI,MACF,OAAO,OAAO,aAAa,IAAI,KAAK,OAAO,OAAO,OAAO,cAAc,CAAC,CAAC,CAAC,IAAI;CAEhF,OAAO,OAAO,QACZ,KACE,MACAA,MAAI,KAAK,UAAU,GAAG,SAAS,KAAK,IAAI,YAAY,GACpDA,MAAI,KAAK,EAAE,CACb,CACF;AACF;;AAGF,MAAa,gBAA0D,EACrE,KACA,MACA,eAMA,OAAO,IAAI,UAAU,SAAS;CAC5B,MAAM,QAAQ,OAAO,MAAM;CAC3B,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO,MAAM;CAC1B,MAAM,QAAQ,OAAO,KAAK,MAAM,QAAQ,GAAG,CAAC;CAC5C,MAAM,OAAO,OAAO,OAAO,KAAK,QAAQ,CAAC,CACvCA,MAAI,SAAS,MAAM,SAAS,GAC5BA,MAAI,KAAK,OAAO,OAAO,CACzB;CACA,OAAO,YAAY,IAAI;CACvB,IAAI,MAAM,SAAS,YACjB,OAAO,OAAO,cAAc,KAAK,EAAE,OAAO,MAAM,OAAO,CAAC;CAE1D,OAAO;AACT,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { n as RepositoryFiles } from "./repository-files-C2gVviac.mjs";
2
+ import { Array, Config, Effect, Option, pipe } from "effect";
3
+ // src/shared/lib/base-revision.ts
4
+ const DEFAULT_BASE = "origin/main";
5
+ /** @internal */
6
+ const baseName = Config.option(Config.String("VPA_BASE")).pipe(Effect.orDie, Effect.map(Option.getOrElse(() => DEFAULT_BASE)));
7
+ /** @internal */
8
+ const baseRevision = Effect.fn("baseRevision")(function* baseRevision(root) {
9
+ const files = yield* RepositoryFiles;
10
+ const base = yield* baseName;
11
+ return yield* files.mergeBase(root, base);
12
+ });
13
+ // src/shared/lib/manifest-texts.ts
14
+ const MANIFEST = /(?:^|\/)package\.json$/u;
15
+ const READ_CONCURRENCY = 16;
16
+ /** @internal */
17
+ const manifestTexts = Effect.fn("manifestTexts")(function* manifestTexts(root) {
18
+ const files = yield* RepositoryFiles;
19
+ const listed = yield* files.listedFiles(root);
20
+ const names = pipe(listed, Array.filter((name) => MANIFEST.test(name)));
21
+ const read = yield* Effect.forEach(names, (file) => Effect.map(files.readFile(files.join(root, file)), Option.map((text) => ({
22
+ file,
23
+ text
24
+ }))), { concurrency: READ_CONCURRENCY });
25
+ return Array.getSomes(read);
26
+ });
27
+ export { baseName as n, baseRevision as r, manifestTexts as t };
28
+
29
+ //# sourceMappingURL=manifest-texts-C6Qjv0xy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-texts-C6Qjv0xy.mjs","names":["Arr"],"sources":["../src/shared/lib/base-revision.ts","../src/shared/lib/manifest-texts.ts"],"sourcesContent":["import { Config, Effect, Option } from \"effect\";\n\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst DEFAULT_BASE = \"origin/main\";\n\n/** @internal */\nexport const baseName = Config.option(Config.String(\"VPA_BASE\")).pipe(\n Effect.orDie,\n Effect.map(Option.getOrElse(() => DEFAULT_BASE)),\n);\n\n/** @internal */\nexport const baseRevision = Effect.fn(\"baseRevision\")(function* baseRevision(root: string) {\n const files = yield* RepositoryFiles;\n const base = yield* baseName;\n return yield* files.mergeBase(root, base);\n});\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst MANIFEST = /(?:^|\\/)package\\.json$/u;\nconst READ_CONCURRENCY = 16;\n\n/** @internal */\nexport interface ManifestText {\n readonly file: string;\n readonly text: string;\n}\n\n/** @internal */\nexport const manifestTexts = Effect.fn(\"manifestTexts\")(function* manifestTexts(root: string) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.listedFiles(root);\n const names = pipe(\n listed,\n Arr.filter((name) => MANIFEST.test(name)),\n );\n const read = yield* Effect.forEach(\n names,\n (file) =>\n Effect.map(\n files.readFile(files.join(root, file)),\n Option.map((text): ManifestText => ({ file, text })),\n ),\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.getSomes(read);\n});\n"],"mappings":";;;AAIA,MAAM,eAAe;;AAGrB,MAAa,WAAW,OAAO,OAAO,OAAO,OAAO,UAAU,CAAC,CAAC,CAAC,KAC/D,OAAO,OACP,OAAO,IAAI,OAAO,gBAAgB,YAAY,CAAC,CACjD;;AAGA,MAAa,eAAe,OAAO,GAAG,cAAc,CAAC,CAAC,UAAU,aAAa,MAAc;CACzF,MAAM,QAAQ,OAAO;CACrB,MAAM,OAAO,OAAO;CACpB,OAAO,OAAO,MAAM,UAAU,MAAM,IAAI;AAC1C,CAAC;;ACbD,MAAM,WAAW;AACjB,MAAM,mBAAmB;;AASzB,MAAa,gBAAgB,OAAO,GAAG,eAAe,CAAC,CAAC,UAAU,cAAc,MAAc;CAC5F,MAAM,QAAQ,OAAO;CACrB,MAAM,SAAS,OAAO,MAAM,YAAY,IAAI;CAC5C,MAAM,QAAQ,KACZ,QACAA,MAAI,QAAQ,SAAS,SAAS,KAAK,IAAI,CAAC,CAC1C;CACA,MAAM,OAAO,OAAO,OAAO,QACzB,QACC,SACC,OAAO,IACL,MAAM,SAAS,MAAM,KAAK,MAAM,IAAI,CAAC,GACrC,OAAO,KAAK,UAAwB;EAAE;EAAM;CAAK,EAAE,CACrD,GACF,EAAE,aAAa,iBAAiB,CAClC;CACA,OAAOA,MAAI,SAAS,IAAI;AAC1B,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { r as formatProblem } from "./problem-OJg859cN.mjs";
2
+ import { n as RepositoryFiles } from "./repository-files-C2gVviac.mjs";
3
+ import { Array, Effect, Runtime, Schema, Stdio, Stream, pipe } from "effect";
4
+ // src/app/output.ts
5
+ const taggedError = Schema.TaggedError;
6
+ const NO_PROBLEMS = 0;
7
+ var ProblemsFound = class extends taggedError()("ProblemsFound", { count: Schema.Finite }) {
8
+ [Runtime.errorReported] = false;
9
+ };
10
+ /** @internal */
11
+ const writeStdout = Effect.fn("writeStdout")(function* writeStdout(text) {
12
+ const stdio = yield* Stdio.Stdio;
13
+ yield* Stream.make(text).pipe(Stream.run(stdio.stdout()), Effect.orDie);
14
+ });
15
+ /** @internal */
16
+ const writeProblems = (root) => (problems) => Effect.gen(function* report() {
17
+ const files = yield* RepositoryFiles;
18
+ const format = formatProblem((file) => files.relative(root, file));
19
+ yield* writeStdout(pipe(problems, Array.map((problem) => `${format(problem)}\n`), Array.join("")));
20
+ });
21
+ /** @internal */
22
+ const failWhenAny = (count) => {
23
+ if (count > NO_PROBLEMS) return Effect.fail(ProblemsFound.make({ count }));
24
+ return Effect.void;
25
+ };
26
+ export { writeStdout as i, failWhenAny as n, writeProblems as r, ProblemsFound as t };
27
+
28
+ //# sourceMappingURL=output-BUCq_3DP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-BUCq_3DP.mjs","names":["Arr"],"sources":["../src/app/output.ts"],"sourcesContent":["import { Array as Arr, Effect, Runtime, Schema, Stdio, Stream, pipe } from \"effect\";\n\nimport { formatProblem } from \"#/shared/lib/problem.ts\";\nimport type { Problem } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst taggedError = Schema.TaggedError;\nconst NO_PROBLEMS = 0;\n\nexport class ProblemsFound extends taggedError<ProblemsFound, { readonly brand: unique symbol }>()(\n \"ProblemsFound\",\n {\n count: Schema.Finite,\n },\n) {\n public override readonly [Runtime.errorReported] = false;\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\n/** @internal */\nexport const writeProblems =\n (root: string) =>\n (problems: readonly Problem[]): Effect.Effect<void, never, 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 });\n\n/** @internal */\nexport const failWhenAny = (count: number): Effect.Effect<void, ProblemsFound> => {\n if (count > NO_PROBLEMS) {\n return Effect.fail(ProblemsFound.make({ count }));\n }\n return Effect.void;\n};\n"],"mappings":";;;;AAMA,MAAM,cAAc,OAAO;AAC3B,MAAM,cAAc;AAEpB,IAAa,gBAAb,cAAmC,YAA8D,CAAC,CAChG,iBACA,EACE,OAAO,OAAO,OAChB,CACF,CAAC,CAAC;CACA,CAA0B,QAAQ,iBAAiB;AACrD;;AAGA,MAAa,cAAc,OAAO,GAAG,aAAa,CAAC,CAAC,UAAU,YAAY,MAAc;CACtF,MAAM,QAAQ,OAAO,MAAM;CAC3B,OAAO,OAAO,KAAK,IAAI,CAAC,CAAC,KAAK,OAAO,IAAI,MAAM,OAAO,CAAC,GAAG,OAAO,KAAK;AACxE,CAAC;;AAGD,MAAa,iBACV,UACA,aACC,OAAO,IAAI,UAAU,SAAS;CAC5B,MAAM,QAAQ,OAAO;CACrB,MAAM,SAAS,eAAe,SAAS,MAAM,SAAS,MAAM,IAAI,CAAC;CACjE,OAAO,YACL,KACE,UACAA,MAAI,KAAK,YAAY,GAAG,OAAO,OAAO,EAAE,GAAG,GAC3CA,MAAI,KAAK,EAAE,CACb,CACF;AACF,CAAC;;AAGL,MAAa,eAAe,UAAsD;CAChF,IAAI,QAAQ,aACV,OAAO,OAAO,KAAK,cAAc,KAAK,EAAE,MAAM,CAAC,CAAC;CAElD,OAAO,OAAO;AAChB"}
package/dist/oxlint.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as describeFinding, t as ProblemList } from "./problem-aeeiOlaz.mjs";
1
+ import { n as describeFinding, t as ProblemList } from "./problem-OJg859cN.mjs";
2
2
  import { t as JSON_FLAG } from "./cli-contract-D7btWrEu.mjs";
3
3
  import { i as nodeServicesLayer } from "./repository-files-C2gVviac.mjs";
4
4
  import { Array, Effect, Layer, Schema, Stream, pipe } from "effect";
@@ -0,0 +1,91 @@
1
+ import { n as baseName, r as baseRevision, t as manifestTexts } from "./manifest-texts-C6Qjv0xy.mjs";
2
+ import { n as RepositoryFiles } from "./repository-files-C2gVviac.mjs";
3
+ import { Array, Effect, Option, String, pipe } from "effect";
4
+ import { DEPENDENCY_SECTIONS, namesIn } from "@r_masseater/kestrion";
5
+ import { decodePackageJson, decodeVersionedPackageJson } from "@r_masseater/kestrion/npm";
6
+ import semver from "semver";
7
+ // src/features/check-version-downgrades/model/package-versions.ts
8
+ const RULE = "unbumped-package";
9
+ const UNSHIPPED = /(?:\.test\.[\w.]+$|(?:^|\/)(?:fixtures|__tests__|tests?)\/|(?:^|\/)(?:AGENTS|CLAUDE|CHANGELOG)\.md$)/u;
10
+ const UNVERSIONED = "0.0.0";
11
+ const FIRST_LINE = 1;
12
+ const FIRST_COLUMN = 1;
13
+ const READ_CONCURRENCY = 16;
14
+ const LAST_SEGMENT = /[^/]*$/u;
15
+ const directoryOf = (file) => String.replace(LAST_SEGMENT, "")(file);
16
+ const packageAt = (file, text) => pipe(decodeVersionedPackageJson(text), Option.filter(({ private: hidden, version }) => hidden !== true && version !== UNVERSIONED), Option.map((manifest) => ({
17
+ file,
18
+ directory: directoryOf(file),
19
+ name: manifest.name,
20
+ version: manifest.version,
21
+ text,
22
+ depends: namesIn(manifest, DEPENDENCY_SECTIONS)
23
+ })));
24
+ const hiddenAt = (file, text) => pipe(decodePackageJson(text), Option.filter((manifest) => manifest.private === true), Option.flatMap((manifest) => Option.map(Option.fromUndefinedOr(manifest.name), (name) => [name, {
25
+ directory: directoryOf(file),
26
+ depends: namesIn(manifest, DEPENDENCY_SECTIONS)
27
+ }])));
28
+ const visit = (hidden, seen, name) => {
29
+ if (seen.has(name)) return seen;
30
+ return Option.match(Option.fromUndefinedOr(hidden.get(name)), {
31
+ onNone: () => seen,
32
+ onSome: (found) => {
33
+ const added = /* @__PURE__ */ new Set([...seen, name]);
34
+ return Array.reduce(found.depends, added, (next, dependency) => visit(hidden, next, dependency));
35
+ }
36
+ });
37
+ };
38
+ const bundledBy = (hidden, depends) => [...Array.reduce(depends, /* @__PURE__ */ new Set(), (seen, name) => visit(hidden, seen, name))];
39
+ const hiddenPackagesIn = (manifests) => new Map(pipe(manifests, Array.flatMap(({ file, text }) => Option.toArray(hiddenAt(file, text)))));
40
+ const versionAt = (name, text) => pipe(text, Option.flatMap(decodeVersionedPackageJson), Option.filter((manifest) => manifest.name === name), Option.map(({ version }) => version), Option.filter((version) => semver.valid(version) !== null));
41
+ const versionLine = (text) => pipe(String.split(text, "\n"), Array.findFirstIndex((line) => String.includes("\"version\"")(line)), Option.match({
42
+ onNone: () => FIRST_LINE,
43
+ onSome: (index) => index + FIRST_LINE
44
+ }));
45
+ const shippedChange = (directory, changed) => pipe(changed, Array.some((name) => String.startsWith(directory)(name) && !UNSHIPPED.test(name)));
46
+ const higher = (left, right) => {
47
+ if (semver.gt(right, left)) return right;
48
+ return left;
49
+ };
50
+ const floorOf = (versions) => {
51
+ let floor = Option.none();
52
+ for (const version of Array.getSomes(versions)) floor = Option.match(floor, {
53
+ onNone: () => Option.some(version),
54
+ onSome: (lowest) => Option.some(higher(version, lowest))
55
+ });
56
+ return floor;
57
+ };
58
+ const changedPart = (hidden, changed, pack) => {
59
+ if (shippedChange(pack.directory, changed)) return Option.some(pack.name);
60
+ return pipe(bundledBy(hidden, pack.depends), Array.findFirst((name) => Option.exists(Option.fromUndefinedOr(hidden.get(name)), ({ directory }) => shippedChange(directory, changed))), Option.map((name) => `${name}, which ${pack.name} bundles,`));
61
+ };
62
+ const message = ({ name, version }, part, floor) => `${part} changed, but the version of ${name}, ${version}, is not above ${floor}, the version of the base or of main. Another change may already publish ${floor}. Bump the version above ${floor}.`;
63
+ /** @internal */
64
+ const checkPackageVersions = Effect.fn("checkPackageVersions")(function* checkPackageVersions(root) {
65
+ const files = yield* RepositoryFiles;
66
+ const base = yield* baseRevision(root);
67
+ if (Option.isNone(base)) return [];
68
+ const tip = yield* baseName;
69
+ const changed = yield* files.changedFiles(root, base.value);
70
+ const manifests = yield* manifestTexts(root);
71
+ const hidden = hiddenPackagesIn(manifests);
72
+ const found = yield* Effect.forEach(pipe(manifests, Array.flatMap(({ file, text }) => Option.toArray(packageAt(file, text))), Array.flatMap((pack) => pipe(changedPart(hidden, changed, pack), Option.map((part) => ({
73
+ pack,
74
+ part
75
+ })), Option.toArray))), ({ pack, part }) => Effect.gen(function* compare() {
76
+ const before = yield* files.readAtRevision(root, base.value, pack.file);
77
+ const claimed = yield* files.readAtRevision(root, tip, pack.file);
78
+ const floor = floorOf([versionAt(pack.name, before), versionAt(pack.name, claimed)]);
79
+ return pipe(floor, Option.filter((lowest) => !semver.gt(pack.version, lowest)), Option.map((lowest) => ({
80
+ file: files.join(root, pack.file),
81
+ line: versionLine(pack.text),
82
+ column: FIRST_COLUMN,
83
+ rule: RULE,
84
+ message: message(pack, part, lowest)
85
+ })), Option.toArray);
86
+ }), { concurrency: READ_CONCURRENCY });
87
+ return Array.flatten(found);
88
+ });
89
+ export { checkPackageVersions as t };
90
+
91
+ //# sourceMappingURL=package-versions-G9Unih6I.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-versions-G9Unih6I.mjs","names":["Str","Arr"],"sources":["../src/features/check-version-downgrades/model/package-versions.ts"],"sourcesContent":["import { DEPENDENCY_SECTIONS, namesIn } from \"@r_masseater/kestrion\";\nimport { decodePackageJson, decodeVersionedPackageJson } from \"@r_masseater/kestrion/npm\";\nimport { Array as Arr, Effect, Option, String as Str, pipe } from \"effect\";\nimport semver from \"semver\";\n\nimport { baseName, baseRevision } from \"#/shared/lib/base-revision.ts\";\nimport { manifestTexts } from \"#/shared/lib/manifest-texts.ts\";\nimport type { ManifestText } from \"#/shared/lib/manifest-texts.ts\";\nimport type { Problem, RuleName } from \"#/shared/lib/problem.ts\";\nimport { RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nconst RULE: RuleName = \"unbumped-package\";\nconst UNSHIPPED =\n /(?:\\.test\\.[\\w.]+$|(?:^|\\/)(?:fixtures|__tests__|tests?)\\/|(?:^|\\/)(?:AGENTS|CLAUDE|CHANGELOG)\\.md$)/u;\nconst UNVERSIONED = \"0.0.0\";\nconst FIRST_LINE = 1;\nconst FIRST_COLUMN = 1;\nconst READ_CONCURRENCY = 16;\n\ninterface Package {\n readonly file: string;\n readonly directory: string;\n readonly name: string;\n readonly version: string;\n readonly text: string;\n readonly depends: readonly string[];\n}\n\ninterface Hidden {\n readonly directory: string;\n readonly depends: readonly string[];\n}\n\ntype HiddenPackages = ReadonlyMap<string, Hidden>;\n\nconst LAST_SEGMENT = /[^/]*$/u;\n\nconst directoryOf = (file: string): string => Str.replace(LAST_SEGMENT, \"\")(file);\n\nconst packageAt = (file: string, text: string): Option.Option<Package> =>\n pipe(\n decodeVersionedPackageJson(text),\n Option.filter(({ private: hidden, version }) => hidden !== true && version !== UNVERSIONED),\n Option.map((manifest): Package => ({\n file,\n directory: directoryOf(file),\n name: manifest.name,\n version: manifest.version,\n text,\n depends: namesIn(manifest, DEPENDENCY_SECTIONS),\n })),\n );\n\nconst hiddenAt = (file: string, text: string): Option.Option<readonly [string, Hidden]> =>\n pipe(\n decodePackageJson(text),\n Option.filter((manifest) => manifest.private === true),\n Option.flatMap((manifest) =>\n Option.map(Option.fromUndefinedOr(manifest.name), (name): readonly [string, Hidden] => [\n name,\n { directory: directoryOf(file), depends: namesIn(manifest, DEPENDENCY_SECTIONS) },\n ]),\n ),\n );\n\nconst visit = (\n hidden: HiddenPackages,\n seen: ReadonlySet<string>,\n name: string,\n): ReadonlySet<string> => {\n if (seen.has(name)) {\n return seen;\n }\n return Option.match(Option.fromUndefinedOr(hidden.get(name)), {\n onNone: () => seen,\n onSome: (found) => {\n const added: ReadonlySet<string> = new Set([...seen, name]);\n return Arr.reduce(found.depends, added, (next, dependency) =>\n visit(hidden, next, dependency),\n );\n },\n });\n};\n\nconst bundledBy = (hidden: HiddenPackages, depends: readonly string[]): readonly string[] => [\n ...Arr.reduce(depends, new Set<string>() as ReadonlySet<string>, (seen, name) =>\n visit(hidden, seen, name),\n ),\n];\n\nconst hiddenPackagesIn = (manifests: readonly ManifestText[]): HiddenPackages =>\n new Map(\n pipe(\n manifests,\n Arr.flatMap(({ file, text }) => Option.toArray(hiddenAt(file, text))),\n ),\n );\n\nconst versionAt = (name: string, text: Option.Option<string>): Option.Option<string> =>\n pipe(\n text,\n Option.flatMap(decodeVersionedPackageJson),\n Option.filter((manifest) => manifest.name === name),\n Option.map(({ version }) => version),\n Option.filter((version) => semver.valid(version) !== null),\n );\n\nconst versionLine = (text: string): number =>\n pipe(\n Str.split(text, \"\\n\"),\n Arr.findFirstIndex((line) => Str.includes('\"version\"')(line)),\n Option.match({ onNone: () => FIRST_LINE, onSome: (index) => index + FIRST_LINE }),\n );\n\nconst shippedChange = (directory: string, changed: readonly string[]): boolean =>\n pipe(\n changed,\n Arr.some((name) => Str.startsWith(directory)(name) && !UNSHIPPED.test(name)),\n );\n\nconst higher = (left: string, right: string): string => {\n if (semver.gt(right, left)) {\n return right;\n }\n return left;\n};\n\nconst floorOf = (versions: readonly Option.Option<string>[]): Option.Option<string> => {\n let floor = Option.none<string>();\n for (const version of Arr.getSomes(versions)) {\n floor = Option.match(floor, {\n onNone: () => Option.some(version),\n onSome: (lowest) => Option.some(higher(version, lowest)),\n });\n }\n return floor;\n};\n\nconst changedPart = (\n hidden: HiddenPackages,\n changed: readonly string[],\n pack: Package,\n): Option.Option<string> => {\n if (shippedChange(pack.directory, changed)) {\n return Option.some(pack.name);\n }\n return pipe(\n bundledBy(hidden, pack.depends),\n Arr.findFirst((name) =>\n Option.exists(Option.fromUndefinedOr(hidden.get(name)), ({ directory }) =>\n shippedChange(directory, changed),\n ),\n ),\n Option.map((name) => `${name}, which ${pack.name} bundles,`),\n );\n};\n\nconst message = ({ name, version }: Package, part: string, floor: string): string =>\n `${part} changed, but the version of ${name}, ${version}, is not above ${floor}, the version of the base or of main. Another change may already publish ${floor}. Bump the version above ${floor}.`;\n\n/** @internal */\nexport const checkPackageVersions = Effect.fn(\"checkPackageVersions\")(\n function* checkPackageVersions(root: string) {\n const files = yield* RepositoryFiles;\n const base = yield* baseRevision(root);\n if (Option.isNone(base)) {\n return [];\n }\n const tip = yield* baseName;\n const changed = yield* files.changedFiles(root, base.value);\n const manifests = yield* manifestTexts(root);\n const hidden = hiddenPackagesIn(manifests);\n const found = yield* Effect.forEach(\n pipe(\n manifests,\n Arr.flatMap(({ file, text }) => Option.toArray(packageAt(file, text))),\n Arr.flatMap((pack) =>\n pipe(\n changedPart(hidden, changed, pack),\n Option.map((part) => ({ pack, part })),\n Option.toArray,\n ),\n ),\n ),\n ({ pack, part }) =>\n Effect.gen(function* compare() {\n const before = yield* files.readAtRevision(root, base.value, pack.file);\n const claimed = yield* files.readAtRevision(root, tip, pack.file);\n const floor = floorOf([versionAt(pack.name, before), versionAt(pack.name, claimed)]);\n return pipe(\n floor,\n Option.filter((lowest) => !semver.gt(pack.version, lowest)),\n Option.map((lowest): Problem => ({\n file: files.join(root, pack.file),\n line: versionLine(pack.text),\n column: FIRST_COLUMN,\n rule: RULE,\n message: message(pack, part, lowest),\n })),\n Option.toArray,\n );\n }),\n { concurrency: READ_CONCURRENCY },\n );\n return Arr.flatten(found);\n },\n);\n"],"mappings":";;;;;;;AAWA,MAAM,OAAiB;AACvB,MAAM,YACJ;AACF,MAAM,cAAc;AACpB,MAAM,aAAa;AACnB,MAAM,eAAe;AACrB,MAAM,mBAAmB;AAkBzB,MAAM,eAAe;AAErB,MAAM,eAAe,SAAyBA,OAAI,QAAQ,cAAc,EAAE,CAAC,CAAC,IAAI;AAEhF,MAAM,aAAa,MAAc,SAC/B,KACE,2BAA2B,IAAI,GAC/B,OAAO,QAAQ,EAAE,SAAS,QAAQ,cAAc,WAAW,QAAQ,YAAY,WAAW,GAC1F,OAAO,KAAK,cAAuB;CACjC;CACA,WAAW,YAAY,IAAI;CAC3B,MAAM,SAAS;CACf,SAAS,SAAS;CAClB;CACA,SAAS,QAAQ,UAAU,mBAAmB;AAChD,EAAE,CACJ;AAEF,MAAM,YAAY,MAAc,SAC9B,KACE,kBAAkB,IAAI,GACtB,OAAO,QAAQ,aAAa,SAAS,YAAY,IAAI,GACrD,OAAO,SAAS,aACd,OAAO,IAAI,OAAO,gBAAgB,SAAS,IAAI,IAAI,SAAoC,CACrF,MACA;CAAE,WAAW,Y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OAAO,QAAQ,UAAU,MAAM,IAAI,CAAC,CAAC,GACrEA,MAAI,SAAS,SACX,KACE,YAAY,QAAQ,SAAS,IAAI,GACjC,OAAO,KAAK,UAAU;EAAE;EAAM;CAAK,EAAE,GACrC,OAAO,OACT,CACF,CACF,IACC,EAAE,MAAM,WACP,OAAO,IAAI,UAAU,UAAU;EAC7B,MAAM,SAAS,OAAO,MAAM,eAAe,MAAM,KAAK,OAAO,KAAK,IAAI;EACtE,MAAM,UAAU,OAAO,MAAM,eAAe,MAAM,KAAK,KAAK,IAAI;EAChE,MAAM,QAAQ,QAAQ,CAAC,UAAU,KAAK,MAAM,MAAM,GAAG,UAAU,KAAK,MAAM,OAAO,CAAC,CAAC;EACnF,OAAO,KACL,OACA,OAAO,QAAQ,WAAW,CAAC,OAAO,GAAG,KAAK,SAAS,MAAM,CAAC,GAC1D,OAAO,KAAK,YAAqB;GAC/B,MAAM,MAAM,KAAK,MAAM,KAAK,IAAI;GAChC,MAAM,YAAY,KAAK,IAAI;GAC3B,QAAQ;GACR,MAAM;GACN,SAAS,QAAQ,MAAM,MAAM,MAAM;EACrC,EAAE,GACF,OAAO,OACT;CACF,CAAC,GACH,EAAE,aAAa,iBAAiB,CAClC;CACA,OAAOA,MAAI,QAAQ,KAAK;AAC1B,CACF"}
@@ -1,6 +1,6 @@
1
1
  import { n as RepositoryFiles, t as NODE_MODULES } from "./repository-files-C2gVviac.mjs";
2
2
  import { n as readManifest, r as workspaceDependencies, t as dependencyEntries } from "./dependencies-BAjtDvY4.mjs";
3
- import { C as IndexKind, J as isModuleDeclaration, S as API, a as declarationsOf, dt as isVariableDeclaration, g as propertyNamesOf, k as getLeadingCommentRanges, o as declaresAType, p as isTypeDeclaration, t as carriesTag, u as isGenericDeclaration, v as resolvedSymbol, w as InternalSymbolName } from "./syntax-CbxAKkqt.mjs";
3
+ import { A as IndexKind, C as propertyNamesOf, I as getLeadingCommentRanges, T as resolvedSymbol, _ as isGenericDeclaration, b as isTypeDeclaration, c as carriesTag, f as declarationsOf, j as InternalSymbolName, k as API, p as declaresAType, tt as isModuleDeclaration, vt as isVariableDeclaration } from "./problem-OJg859cN.mjs";
4
4
  import { Array, Effect, Function, Number, Option, Order, Schema, String as String$1, pipe } from "effect";
5
5
  import { PACKAGE_JSON_FILE } from "@r_masseater/kestrion";
6
6
  // src/shared/lib/values.ts
@@ -434,4 +434,4 @@ const keepOnly = Effect.fn("keepOnly")(function* keepOnly(records, keys) {
434
434
  });
435
435
  export { valueKey as C, schemaTypeOf as S, formatValues as _, nearestManifestDirectory as a, literalValuesOf as b, listConfigFiles as c, withProject as d, declarationKey as f, finiteValuesOf as g, locationOf as h, installedPackages as i, mentions as l, isObjectType as m, keepOnly as n, projectInputs as o, describeLibraryType as p, recordsIn as r, workspaceClosure as s, contentKey as t, typeScriptCompiler as u, isSubsetOf as v, vocabularyOf as w, sameValues as x, literalUnionOf as y };
436
436
 
437
- //# sourceMappingURL=pass-records-D5HYFQWz.mjs.map
437
+ //# sourceMappingURL=pass-records-6XLhXZL3.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pass-records-D5HYFQWz.mjs","names":["Arr","Fn","Arr","Num","Str","Arr","HIDDEN_PREFIX","Str","Arr","Arr","Str","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/entities/project/model/inputs.ts","../src/shared/lib/pass-records.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 carriesTag,\n declaresAType,\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 readonly typeNames: readonly string[];\n readonly tagNames: readonly string[];\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: [], typeNames: [], tagNames: [] };\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 { ...EMPTY_INDEX, vocabularies, shapes };\n};\n\nconst schemaTypeIndex =\n (walk: Walk, located: LibraryType) =>\n (declaration: Declaration, schemaType: Type): LibraryIndex => ({\n ...EMPTY_INDEX,\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 typeNames: pipe(\n indexes,\n Arr.flatMap((index) => index.typeNames),\n ),\n tagNames: pipe(\n indexes,\n Arr.flatMap((index) => index.tagNames),\n ),\n});\n\nconst isNamespace = (symbol: TypeSymbol): boolean =>\n Arr.some(declarationsOf(symbol), isModuleDeclaration);\n\nconst typeNameIndex = (visit: Visit, symbol: TypeSymbol): LibraryIndex => {\n const declarations = declarationsOf(symbol);\n const typeNames = pipe(\n [visit.exported.name],\n Arr.filter(() => declaresAType(declarations)),\n );\n const tagNames = pipe(\n typeNames,\n Arr.filter((name) => carriesTag(name)(declarations)),\n );\n return { ...EMPTY_INDEX, typeNames, tagNames };\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([\n declaredTypeIndex(walk, named),\n schemaValueIndex(walk, named),\n typeNameIndex(visit, symbol),\n ]);\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 (items) => Effect.forEach(items, indexEntry(cache)(checker), { concurrency: 1 }),\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* Effect.forEach(pids, (pid) => residentBytesOf(pid), { concurrency: 1 });\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 { PACKAGE_JSON_FILE } from \"@r_masseater/kestrion\";\nimport { Array as Arr, Effect, Option, Order, String as Str, pipe } from \"effect\";\n\nimport {\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 type { Problem } from \"#/shared/lib/problem.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\nexport type SourceCheck = (checker: Checker) => (sourceFile: SourceFile) => readonly Problem[];\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\nexport const 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, PACKAGE_JSON_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\nexport const packageDirectoryOf =\n (root: string) =>\n (directory: string): Effect.Effect<string, never, RepositoryFiles> =>\n nearestPackageDirectory(directory, root);\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* Effect.forEach(fileNames, (fileName) => files.readFile(fileName), {\n concurrency: 1,\n });\n const includesNeedle = Str.includes(needle);\n return pipe(\n texts,\n Arr.some((text) => Option.exists(text, includesNeedle)),\n );\n });\n","import { PACKAGE_JSON_FILE } from \"@r_masseater/kestrion\";\nimport { Array as Arr, Effect, Option, Order, Schema, String as Str, pipe } from \"effect\";\n\nimport { readManifest, workspaceDependencies } from \"#/entities/package/@x/project.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { packageDirectoryOf, parseConfig } from \"./project.ts\";\nimport type { Workspace } from \"./project.ts\";\n\nexport interface ProjectInputs {\n readonly options: string;\n readonly files: readonly string[];\n readonly dependencies: readonly string[];\n}\n\nconst SEPARATOR = \"/\";\nconst SCOPE_PREFIX = \"@\";\nconst HIDDEN_PREFIX = \".\";\n\nconst encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));\n\nexport const nearestManifestDirectory = Effect.fn(\"nearestManifestDirectory\")(\n function* nearestManifestDirectory(start: string) {\n const files = yield* RepositoryFiles;\n let directory = start;\n let parent = files.dirname(directory);\n while (\n parent !== directory &&\n !(yield* files.exists(files.join(directory, PACKAGE_JSON_FILE)))\n ) {\n directory = parent;\n parent = files.dirname(directory);\n }\n return directory;\n },\n);\n\nconst dependenciesOf = Effect.fn(\"dependenciesOf\")(function* dependenciesOf(directory: string) {\n const files = yield* RepositoryFiles;\n const manifest = yield* readManifest(directory);\n const names = Option.match(manifest, {\n onNone: (): readonly string[] => [],\n onSome: workspaceDependencies,\n });\n return yield* Effect.forEach(\n names,\n (name) => files.realPath(files.join(directory, NODE_MODULES, name)),\n {\n concurrency: 1,\n },\n );\n});\n\nexport const workspaceClosure = Effect.fn(\"workspaceClosure\")(function* workspaceClosure(\n start: string,\n) {\n const seen = new Set([start]);\n const queue = [start];\n for (const directory of queue) {\n const next = yield* dependenciesOf(directory);\n for (const dependency of next) {\n if (!seen.has(dependency)) {\n seen.add(dependency);\n queue.push(dependency);\n }\n }\n }\n return [...seen];\n});\n\nconst isUnder =\n (prefixes: readonly string[]) =>\n (file: string): boolean =>\n pipe(\n prefixes,\n Arr.some((prefix) => Str.startsWith(prefix)(file)),\n );\n\nconst closureOf = Effect.fn(\"closureOf\")(function* closureOf(root: string, configPath: string) {\n const files = yield* RepositoryFiles;\n const directory = yield* packageDirectoryOf(root)(files.dirname(configPath));\n const directories = yield* workspaceClosure(directory);\n const prefixes = pipe(\n directories,\n Arr.map((found) => `${files.relative(root, found)}${SEPARATOR}`),\n );\n return { directories, prefixes };\n});\n\nconst scopedNames =\n (modules: string) =>\n (name: string): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* listScope() {\n const files = yield* RepositoryFiles;\n if (!Str.startsWith(SCOPE_PREFIX)(name)) {\n return [name];\n }\n const scoped = yield* files.readDirectory(files.join(modules, name));\n return pipe(\n scoped,\n Arr.map((entry) => `${name}${SEPARATOR}${entry}`),\n );\n });\n\nconst installedNames = Effect.fn(\"installedNames\")(function* installedNames(modules: string) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.readDirectory(modules);\n const nested = yield* pipe(\n listed,\n Arr.filter((name) => !Str.startsWith(HIDDEN_PREFIX)(name)),\n (items) => Effect.forEach(items, scopedNames(modules), { concurrency: 1 }),\n );\n return Arr.flatten(nested);\n});\n\nexport const installedPackages = Effect.fn(\"installedPackages\")(function* installedPackages(\n root: string,\n directory: string,\n) {\n const files = yield* RepositoryFiles;\n const modules = files.join(directory, NODE_MODULES);\n const names = yield* installedNames(modules);\n return yield* Effect.forEach(\n names,\n (name) =>\n files\n .realPath(files.join(modules, name))\n .pipe(Effect.map((found) => files.relative(root, found))),\n { concurrency: 1 },\n );\n});\n\nconst dependencyVersions = Effect.fn(\"dependencyVersions\")(function* dependencyVersions(\n root: string,\n directories: readonly string[],\n) {\n const installed = yield* Effect.forEach(\n Arr.dedupe([root, ...directories]),\n (directory) => installedPackages(root, directory),\n { concurrency: 1 },\n );\n return Arr.sort(Arr.dedupe(Arr.flatten(installed)), Order.String);\n});\n\nexport interface InputScope {\n readonly workspace: Workspace;\n readonly listed: readonly string[];\n}\n\nexport const projectInputs =\n ({ workspace: { compiler, root }, listed }: InputScope) =>\n (configPath: string): Effect.Effect<Option.Option<ProjectInputs>, never, RepositoryFiles> =>\n Effect.gen(function* collectInputs() {\n const files = yield* RepositoryFiles;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none();\n }\n const closure = yield* closureOf(root, configPath);\n const dependencies = yield* dependencyVersions(root, closure.directories);\n const options = yield* encodeOptions(parsed.value.options).pipe(\n Effect.orElseSucceed(() => \"\"),\n );\n const sources = pipe(\n parsed.value.fileNames,\n Arr.map((fileName) => files.relative(root, fileName)),\n );\n const shared = pipe(listed, Arr.filter(isUnder(closure.prefixes)));\n return Option.some({\n options,\n files: Arr.sort(Arr.dedupe([...sources, ...shared]), Order.String),\n dependencies,\n });\n });\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst PASSED = \"\";\nconst UNREADABLE = \"\";\nconst FIELD_SEPARATOR = \"\\0\";\nconst LINE_SEPARATOR = \"\\n\";\n\nexport interface Records {\n readonly directory: string;\n readonly passed: readonly string[];\n}\n\nexport type NamedFile = readonly [name: string, file: string];\n\nexport const contentKey = Effect.fn(\"contentKey\")(function* contentKey(\n salt: readonly string[],\n named: readonly NamedFile[],\n) {\n const files = yield* RepositoryFiles;\n const entries = yield* Effect.forEach(\n named,\n ([name, file]) =>\n files\n .hashFile(file)\n .pipe(\n Effect.map(\n (found) => `${name}${FIELD_SEPARATOR}${Option.getOrElse(found, () => UNREADABLE)}`,\n ),\n ),\n { concurrency: 1 },\n );\n return yield* files.hash(Arr.join([...salt, ...entries], LINE_SEPARATOR));\n});\n\nexport const recordsIn = Effect.fn(\"recordsIn\")(function* recordsIn(directory: string) {\n const files = yield* RepositoryFiles;\n const present = yield* files.readDirectory(directory);\n return { directory, passed: present } satisfies Records;\n});\n\nexport const keepOnly = Effect.fn(\"keepOnly\")(function* keepOnly(\n records: Records,\n keys: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const stale = pipe(\n records.passed,\n Arr.filter((key) => !Arr.contains(keys, key)),\n );\n yield* Effect.forEach(stale, (key) => files.removeFile(files.join(records.directory, key)), {\n concurrency: 1,\n discard: true,\n });\n yield* Effect.forEach(\n keys,\n (key) => files.writeFile(files.join(records.directory, key), PASSED),\n { concurrency: 1, discard: true },\n );\n});\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,OACAA,MAAI,KAAK,WAAW,eAAe,MAAM,CAAC,GAC1CA,MAAI,UACJA,MAAI,YAAY,MAAM,UAAU,SAAS,IAAI,MAAM,SAAS,KAAK,CAAC,CACpE;CACA,IAAI,OAAO,WAAW,MAAM,UAAU,OAAO,SAAS,kBACpD,OAAO,OAAO,KAAK;CAErB,OAAO,OAAO,KAAK,MAAM;AAC3B;AAEA,MAAa,kBAAkB,SAAgD;CAC7E,IAAI,CAAC,KAAK,YAAY,GACpB,OAAO,OAAO,K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,OAAO,kBAAkB,OAAO,UAAU,aAAa,UAAU,GACjF,CACF,GACJ,EAAE,aAAa,EAAE,CACnB;CACA,OAAO,OAAO,MAAM,KAAKE,MAAI,KAAK,CAAC,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,CAAC;AAC1E,CAAC;AAED,MAAa,YAAY,OAAO,GAAG,WAAW,CAAC,CAAC,UAAU,UAAU,WAAmB;CAGrF,OAAO;EAAE;EAAW,QAAQ,QADL,OADF,gBAAA,CACQ,cAAc,SAAS;CAChB;AACtC,CAAC;AAED,MAAa,WAAW,OAAO,GAAG,UAAU,CAAC,CAAC,UAAU,SACtD,SACA,MACA;CACA,MAAM,QAAQ,OAAO;CACrB,MAAM,QAAQ,KACZ,QAAQ,QACRA,MAAI,QAAQ,QAAQ,CAACA,MAAI,SAAS,MAAM,GAAG,CAAC,CAC9C;CACA,OAAO,OAAO,QAAQ,QAAQ,QAAQ,MAAM,WAAW,MAAM,KAAK,QAAQ,WAAW,GAAG,CAAC,GAAG;EAC1F,aAAa;EACb,SAAS;CACX,CAAC;CACD,OAAO,OAAO,QACZ,OACC,QAAQ,MAAM,UAAU,MAAM,KAAK,QAAQ,WAAW,GAAG,GAAG,MAAM,GACnE;EAAE,aAAa;EAAG,SAAS;CAAK,CAClC;AACF,CAAC"}
1
+ {"version":3,"file":"pass-records-6XLhXZL3.mjs","names":["Arr","Fn","Arr","Num","Str","Arr","HIDDEN_PREFIX","Str","Arr","Arr","Str","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/entities/project/model/inputs.ts","../src/shared/lib/pass-records.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 carriesTag,\n declaresAType,\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 readonly typeNames: readonly string[];\n readonly tagNames: readonly string[];\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: [], typeNames: [], tagNames: [] };\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 { ...EMPTY_INDEX, vocabularies, shapes };\n};\n\nconst schemaTypeIndex =\n (walk: Walk, located: LibraryType) =>\n (declaration: Declaration, schemaType: Type): LibraryIndex => ({\n ...EMPTY_INDEX,\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 typeNames: pipe(\n indexes,\n Arr.flatMap((index) => index.typeNames),\n ),\n tagNames: pipe(\n indexes,\n Arr.flatMap((index) => index.tagNames),\n ),\n});\n\nconst isNamespace = (symbol: TypeSymbol): boolean =>\n Arr.some(declarationsOf(symbol), isModuleDeclaration);\n\nconst typeNameIndex = (visit: Visit, symbol: TypeSymbol): LibraryIndex => {\n const declarations = declarationsOf(symbol);\n const typeNames = pipe(\n [visit.exported.name],\n Arr.filter(() => declaresAType(declarations)),\n );\n const tagNames = pipe(\n typeNames,\n Arr.filter((name) => carriesTag(name)(declarations)),\n );\n return { ...EMPTY_INDEX, typeNames, tagNames };\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([\n declaredTypeIndex(walk, named),\n schemaValueIndex(walk, named),\n typeNameIndex(visit, symbol),\n ]);\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 (items) => Effect.forEach(items, indexEntry(cache)(checker), { concurrency: 1 }),\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* Effect.forEach(pids, (pid) => residentBytesOf(pid), { concurrency: 1 });\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 { PACKAGE_JSON_FILE } from \"@r_masseater/kestrion\";\nimport { Array as Arr, Effect, Option, Order, String as Str, pipe } from \"effect\";\n\nimport {\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 type { Problem } from \"#/shared/lib/problem.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\nexport type SourceCheck = (checker: Checker) => (sourceFile: SourceFile) => readonly Problem[];\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\nexport const 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, PACKAGE_JSON_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\nexport const packageDirectoryOf =\n (root: string) =>\n (directory: string): Effect.Effect<string, never, RepositoryFiles> =>\n nearestPackageDirectory(directory, root);\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* Effect.forEach(fileNames, (fileName) => files.readFile(fileName), {\n concurrency: 1,\n });\n const includesNeedle = Str.includes(needle);\n return pipe(\n texts,\n Arr.some((text) => Option.exists(text, includesNeedle)),\n );\n });\n","import { PACKAGE_JSON_FILE } from \"@r_masseater/kestrion\";\nimport { Array as Arr, Effect, Option, Order, Schema, String as Str, pipe } from \"effect\";\n\nimport { readManifest, workspaceDependencies } from \"#/entities/package/@x/project.ts\";\nimport { NODE_MODULES, RepositoryFiles } from \"#/shared/lib/repository-files.ts\";\n\nimport { packageDirectoryOf, parseConfig } from \"./project.ts\";\nimport type { Workspace } from \"./project.ts\";\n\nexport interface ProjectInputs {\n readonly options: string;\n readonly files: readonly string[];\n readonly dependencies: readonly string[];\n}\n\nconst SEPARATOR = \"/\";\nconst SCOPE_PREFIX = \"@\";\nconst HIDDEN_PREFIX = \".\";\n\nconst encodeOptions = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown));\n\nexport const nearestManifestDirectory = Effect.fn(\"nearestManifestDirectory\")(\n function* nearestManifestDirectory(start: string) {\n const files = yield* RepositoryFiles;\n let directory = start;\n let parent = files.dirname(directory);\n while (\n parent !== directory &&\n !(yield* files.exists(files.join(directory, PACKAGE_JSON_FILE)))\n ) {\n directory = parent;\n parent = files.dirname(directory);\n }\n return directory;\n },\n);\n\nconst dependenciesOf = Effect.fn(\"dependenciesOf\")(function* dependenciesOf(directory: string) {\n const files = yield* RepositoryFiles;\n const manifest = yield* readManifest(directory);\n const names = Option.match(manifest, {\n onNone: (): readonly string[] => [],\n onSome: workspaceDependencies,\n });\n return yield* Effect.forEach(\n names,\n (name) => files.realPath(files.join(directory, NODE_MODULES, name)),\n {\n concurrency: 1,\n },\n );\n});\n\nexport const workspaceClosure = Effect.fn(\"workspaceClosure\")(function* workspaceClosure(\n start: string,\n) {\n const seen = new Set([start]);\n const queue = [start];\n for (const directory of queue) {\n const next = yield* dependenciesOf(directory);\n for (const dependency of next) {\n if (!seen.has(dependency)) {\n seen.add(dependency);\n queue.push(dependency);\n }\n }\n }\n return [...seen];\n});\n\nconst isUnder =\n (prefixes: readonly string[]) =>\n (file: string): boolean =>\n pipe(\n prefixes,\n Arr.some((prefix) => Str.startsWith(prefix)(file)),\n );\n\nconst closureOf = Effect.fn(\"closureOf\")(function* closureOf(root: string, configPath: string) {\n const files = yield* RepositoryFiles;\n const directory = yield* packageDirectoryOf(root)(files.dirname(configPath));\n const directories = yield* workspaceClosure(directory);\n const prefixes = pipe(\n directories,\n Arr.map((found) => `${files.relative(root, found)}${SEPARATOR}`),\n );\n return { directories, prefixes };\n});\n\nconst scopedNames =\n (modules: string) =>\n (name: string): Effect.Effect<readonly string[], never, RepositoryFiles> =>\n Effect.gen(function* listScope() {\n const files = yield* RepositoryFiles;\n if (!Str.startsWith(SCOPE_PREFIX)(name)) {\n return [name];\n }\n const scoped = yield* files.readDirectory(files.join(modules, name));\n return pipe(\n scoped,\n Arr.map((entry) => `${name}${SEPARATOR}${entry}`),\n );\n });\n\nconst installedNames = Effect.fn(\"installedNames\")(function* installedNames(modules: string) {\n const files = yield* RepositoryFiles;\n const listed = yield* files.readDirectory(modules);\n const nested = yield* pipe(\n listed,\n Arr.filter((name) => !Str.startsWith(HIDDEN_PREFIX)(name)),\n (items) => Effect.forEach(items, scopedNames(modules), { concurrency: 1 }),\n );\n return Arr.flatten(nested);\n});\n\nexport const installedPackages = Effect.fn(\"installedPackages\")(function* installedPackages(\n root: string,\n directory: string,\n) {\n const files = yield* RepositoryFiles;\n const modules = files.join(directory, NODE_MODULES);\n const names = yield* installedNames(modules);\n return yield* Effect.forEach(\n names,\n (name) =>\n files\n .realPath(files.join(modules, name))\n .pipe(Effect.map((found) => files.relative(root, found))),\n { concurrency: 1 },\n );\n});\n\nconst dependencyVersions = Effect.fn(\"dependencyVersions\")(function* dependencyVersions(\n root: string,\n directories: readonly string[],\n) {\n const installed = yield* Effect.forEach(\n Arr.dedupe([root, ...directories]),\n (directory) => installedPackages(root, directory),\n { concurrency: 1 },\n );\n return Arr.sort(Arr.dedupe(Arr.flatten(installed)), Order.String);\n});\n\nexport interface InputScope {\n readonly workspace: Workspace;\n readonly listed: readonly string[];\n}\n\nexport const projectInputs =\n ({ workspace: { compiler, root }, listed }: InputScope) =>\n (configPath: string): Effect.Effect<Option.Option<ProjectInputs>, never, RepositoryFiles> =>\n Effect.gen(function* collectInputs() {\n const files = yield* RepositoryFiles;\n const parsed = parseConfig(compiler.api)(configPath);\n if (Option.isNone(parsed)) {\n return Option.none();\n }\n const closure = yield* closureOf(root, configPath);\n const dependencies = yield* dependencyVersions(root, closure.directories);\n const options = yield* encodeOptions(parsed.value.options).pipe(\n Effect.orElseSucceed(() => \"\"),\n );\n const sources = pipe(\n parsed.value.fileNames,\n Arr.map((fileName) => files.relative(root, fileName)),\n );\n const shared = pipe(listed, Arr.filter(isUnder(closure.prefixes)));\n return Option.some({\n options,\n files: Arr.sort(Arr.dedupe([...sources, ...shared]), Order.String),\n dependencies,\n });\n });\n","import { Array as Arr, Effect, Option, pipe } from \"effect\";\n\nimport { RepositoryFiles } from \"./repository-files.ts\";\n\nconst PASSED = \"\";\nconst UNREADABLE = \"\";\nconst FIELD_SEPARATOR = \"\\0\";\nconst LINE_SEPARATOR = \"\\n\";\n\nexport interface Records {\n readonly directory: string;\n readonly passed: readonly string[];\n}\n\nexport type NamedFile = readonly [name: string, file: string];\n\nexport const contentKey = Effect.fn(\"contentKey\")(function* contentKey(\n salt: readonly string[],\n named: readonly NamedFile[],\n) {\n const files = yield* RepositoryFiles;\n const entries = yield* Effect.forEach(\n named,\n ([name, file]) =>\n files\n .hashFile(file)\n .pipe(\n Effect.map(\n (found) => `${name}${FIELD_SEPARATOR}${Option.getOrElse(found, () => UNREADABLE)}`,\n ),\n ),\n { concurrency: 1 },\n );\n return yield* files.hash(Arr.join([...salt, ...entries], LINE_SEPARATOR));\n});\n\nexport const recordsIn = Effect.fn(\"recordsIn\")(function* recordsIn(directory: string) {\n const files = yield* RepositoryFiles;\n const present = yield* files.readDirectory(directory);\n return { directory, passed: present } satisfies Records;\n});\n\nexport const keepOnly = Effect.fn(\"keepOnly\")(function* keepOnly(\n records: Records,\n keys: readonly string[],\n) {\n const files = yield* RepositoryFiles;\n const stale = pipe(\n records.passed,\n Arr.filter((key) => !Arr.contains(keys, key)),\n );\n yield* Effect.forEach(stale, (key) => files.removeFile(files.join(records.directory, key)), {\n concurrency: 1,\n discard: true,\n });\n yield* Effect.forEach(\n keys,\n (key) => files.writeFile(files.join(records.directory, key), PASSED),\n { concurrency: 1, discard: true },\n );\n});\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,OACAA,MAAI,KAAK,WAAW,eAAe,MAAM,CAAC,GAC1CA,MAAI,UACJA,MAAI,YAAY,MAAM,UAAU,SAAS,IAAI,MAAM,SAAS,KAAK,CAAC,CACpE;CACA,IAAI,OAAO,WAAW,MAAM,UAAU,OAAO,SAAS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ACA;CACA,MAAM,QAAQ,OAAO;CACrB,MAAM,UAAU,OAAO,OAAO,QAC5B,QACC,CAAC,MAAM,UACN,MACG,SAAS,IAAI,CAAC,CACd,KACC,OAAO,KACJ,UAAU,GAAG,OAAO,kBAAkB,OAAO,UAAU,aAAa,UAAU,GACjF,CACF,GACJ,EAAE,aAAa,EAAE,CACnB;CACA,OAAO,OAAO,MAAM,KAAKE,MAAI,KAAK,CAAC,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,CAAC;AAC1E,CAAC;AAED,MAAa,YAAY,OAAO,GAAG,WAAW,CAAC,CAAC,UAAU,UAAU,WAAmB;CAGrF,OAAO;EAAE;EAAW,QAAQ,QADL,OADF,gBAAA,CACQ,cAAc,SAAS;CAChB;AACtC,CAAC;AAED,MAAa,WAAW,OAAO,GAAG,UAAU,CAAC,CAAC,UAAU,SACtD,SACA,MACA;CACA,MAAM,QAAQ,OAAO;CACrB,MAAM,QAAQ,KACZ,QAAQ,QACRA,MAAI,QAAQ,QAAQ,CAACA,MAAI,SAAS,MAAM,GAAG,CAAC,CAC9C;CACA,OAAO,OAAO,QAAQ,QAAQ,QAAQ,MAAM,WAAW,MAAM,KAAK,QAAQ,WAAW,GAAG,CAAC,GAAG;EAC1F,aAAa;EACb,SAAS;CACX,CAAC;CACD,OAAO,OAAO,QACZ,OACC,QAAQ,MAAM,UAAU,MAAM,KAAK,QAAQ,WAAW,GAAG,GAAG,MAAM,GACnE;EAAE,aAAa;EAAG,SAAS;CAAK,CAClC;AACF,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { t as NODE_MODULES } from "./repository-files-C2gVviac.mjs";
2
- import { Array, Option, String, pipe } from "effect";
2
+ import { Array, Option, Order, Schema, String as String$1, pipe } from "effect";
3
3
  import { InternalSymbolName, SyntaxKind, getJSDocTags, getLeadingCommentRanges, getNameOfDeclaration, getTextOfJSDocComment } from "tsrs/ast";
4
4
  import { isArrayLiteralExpression, isArrowFunction, isBinaryExpression, isBlock, isCallExpression, isClassDeclaration, isElementAccessExpression, isEnumDeclaration, isExportAssignment, isExportDeclaration, isExpressionStatement, isFunctionDeclaration, isFunctionExpression, isIdentifier, isImportDeclaration, isInterfaceDeclaration, isLiteralTypeNode, isModuleBlock, isModuleDeclaration, isNewExpression, isNumericLiteral, isObjectLiteralExpression, isParenthesizedExpression, isPropertyAccessExpression, isPropertyAssignment, isPropertyDeclaration, isPropertySignatureDeclaration, isReturnStatement, isSatisfiesExpression, isSignatureDeclaration, isSourceFile, isSpreadElement, isStringLiteral, isTypeAliasDeclaration, isTypeLiteralNode, isTypeReferenceNode, isUnionTypeNode, isVariableDeclaration, isVariableDeclarationList, isVariableStatement } from "tsrs/ast/is";
5
5
  import { API, IndexKind, SignatureKind, SymbolFlags as SymbolFlags$1 } from "tsrs/sync";
@@ -17,16 +17,16 @@ const SCOPE_PREFIX = "@";
17
17
  const SCOPED_SEGMENTS = 2;
18
18
  const UNSCOPED_SEGMENTS = 1;
19
19
  const packageOf = (fileName) => {
20
- const afterModules = pipe(fileName, String.lastIndexOf(NODE_MODULES_SEGMENT), Option.match({
20
+ const afterModules = pipe(fileName, String$1.lastIndexOf(NODE_MODULES_SEGMENT), Option.match({
21
21
  onNone: () => fileName,
22
- onSome: (index) => String.slice(index + NODE_MODULES_SEGMENT.length)(fileName)
22
+ onSome: (index) => String$1.slice(index + NODE_MODULES_SEGMENT.length)(fileName)
23
23
  }));
24
- const segments = String.split("/")(afterModules);
25
- if (String.startsWith(SCOPE_PREFIX)(afterModules)) return pipe(Array.take(segments, SCOPED_SEGMENTS), Array.join("/"));
24
+ const segments = String$1.split("/")(afterModules);
25
+ if (String$1.startsWith(SCOPE_PREFIX)(afterModules)) return pipe(Array.take(segments, SCOPED_SEGMENTS), Array.join("/"));
26
26
  return pipe(Array.take(segments, UNSCOPED_SEGMENTS), Array.join("/"));
27
27
  };
28
28
  const descendantsOf = (node) => pipe(childrenOf(node), Array.flatMap((child) => Array.prepend(descendantsOf(child), child)));
29
- const isExternalFile = (program) => (sourceFile) => !program.isSourceFileDefaultLibrary(sourceFile) && (String.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) || program.isSourceFileFromExternalLibrary(sourceFile));
29
+ const isExternalFile = (program) => (sourceFile) => !program.isSourceFileDefaultLibrary(sourceFile) && (String$1.includes(NODE_MODULES_SEGMENT)(sourceFile.fileName) || program.isSourceFileFromExternalLibrary(sourceFile));
30
30
  const isExternalDeclaration = (program) => (declaration) => isExternalFile(program)(declaration.getSourceFile());
31
31
  const isOutsideDeclaration = (program) => (declaration) => program.isSourceFileDefaultLibrary(declaration.getSourceFile()) || isExternalDeclaration(program)(declaration);
32
32
  const ALIAS_KINDS = /* @__PURE__ */ new Set([
@@ -78,6 +78,52 @@ const moduleSpecifierOf = (statement) => {
78
78
  return Option.fromUndefinedOr(statement.moduleSpecifier).pipe(Option.filter((specifier) => isStringLiteral(specifier)), Option.map((specifier) => specifier.text));
79
79
  };
80
80
  const importedModulesOf = (sourceFile) => pipe(sourceFile.statements, Array.map((statement) => moduleSpecifierOf(statement)), Array.getSomes);
81
- export { isPropertyAccessExpression as $, getNameOfDeclaration as A, isExportDeclaration as B, IndexKind as C, SyntaxKind as D, SymbolFlags$1 as E, isBlock as F, isImportDeclaration as G, isFunctionDeclaration as H, isCallExpression as I, isModuleDeclaration as J, isInterfaceDeclaration as K, isClassDeclaration as L, isArrayLiteralExpression as M, isArrowFunction as N, getJSDocTags as O, isBinaryExpression as P, isParenthesizedExpression as Q, isElementAccessExpression as R, API as S, SignatureKind as T, isFunctionExpression as U, isExpressionStatement as V, isIdentifier as W, isNumericLiteral as X, isNewExpression as Y, isObjectLiteralExpression as Z, referencedSymbols as _, declarationsOf as a, isSpreadElement as at, symbolAtLocation as b, importedModulesOf as c, isTypeLiteralNode as ct, isInsideAny as d, isVariableDeclaration as dt, isPropertyAssignment as et, isOutsideDeclaration as f, isVariableDeclarationList as ft, propertyNamesOf as g, packageOf as h, contains as i, isSourceFile as it, getTextOfJSDocComment as j, getLeadingCommentRanges as k, isExternalDeclaration as l, isTypeReferenceNode as lt, lineOf as m, childrenOf as n, isSatisfiesExpression as nt, declaresAType as o, isStringLiteral as ot, isTypeDeclaration as p, isVariableStatement as pt, isModuleBlock as q, columnOf as r, isSignatureDeclaration as rt, descendantsOf as s, isTypeAliasDeclaration as st, carriesTag as t, isReturnStatement as tt, isGenericDeclaration as u, isUnionTypeNode as ut, resolvedSymbol as v, InternalSymbolName as w, uniqueByReference as x, symbolAt as y, isEnumDeclaration as z };
81
+ // src/shared/lib/problem.ts
82
+ const RuleNameSchema = Schema.String.check(Schema.isPattern(/^[a-z]+(?:-[a-z]+)*$/u));
83
+ const ProblemSchema = Schema.Struct({
84
+ file: Schema.String,
85
+ line: Schema.Int,
86
+ column: Schema.Int,
87
+ rule: RuleNameSchema,
88
+ message: Schema.String
89
+ });
90
+ const ProblemList = Schema.Array(ProblemSchema);
91
+ const FIRST = 1;
92
+ const problemAtPosition = (rule) => (file, { line, column }, message) => ({
93
+ file,
94
+ line,
95
+ column,
96
+ rule,
97
+ message
98
+ });
99
+ const problemInFile = (rule) => (file, message) => problemAtPosition(rule)(file, {
100
+ line: FIRST,
101
+ column: FIRST
102
+ }, message);
103
+ const problemAt = ({ rule, message }) => (node) => ({
104
+ file: node.getSourceFile().fileName,
105
+ line: lineOf(node),
106
+ column: columnOf(node),
107
+ rule,
108
+ message
109
+ });
110
+ const problemOrder = Order.combineAll([
111
+ Order.mapInput(Order.String, (problem) => problem.file),
112
+ Order.mapInput(Order.Number, (problem) => problem.line),
113
+ Order.mapInput(Order.Number, (problem) => problem.column),
114
+ Order.mapInput(Order.String, (problem) => problem.rule),
115
+ Order.mapInput(Order.String, (problem) => problem.message)
116
+ ]);
117
+ const problemKey = (problem) => pipe([
118
+ problem.file,
119
+ String(problem.line),
120
+ String(problem.column),
121
+ problem.rule,
122
+ problem.message
123
+ ], Array.join("\0"));
124
+ const sortProblems = (problems) => Array.sort(Array.dedupeWith(problems, (left, right) => problemKey(left) === problemKey(right)), problemOrder);
125
+ const describeFinding = (problem) => `[${problem.rule}] ${problem.message}`;
126
+ const formatProblem = (relative) => (problem) => `${relative(problem.file)}:${String(problem.line)}:${String(problem.column)} ${describeFinding(problem)}`;
127
+ export { isInterfaceDeclaration as $, IndexKind as A, isArrowFunction as B, propertyNamesOf as C, symbolAtLocation as D, symbolAt as E, getJSDocTags as F, isElementAccessExpression as G, isBlock as H, getLeadingCommentRanges as I, isExpressionStatement as J, isEnumDeclaration as K, getNameOfDeclaration as L, SignatureKind as M, SymbolFlags$1 as N, uniqueByReference as O, SyntaxKind as P, isImportDeclaration as Q, getTextOfJSDocComment as R, packageOf as S, resolvedSymbol as T, isCallExpression as U, isBinaryExpression as V, isClassDeclaration as W, isFunctionExpression as X, isFunctionDeclaration as Y, isIdentifier as Z, isGenericDeclaration as _, isUnionTypeNode as _t, problemAtPosition as a, isParenthesizedExpression as at, isTypeDeclaration as b, isVariableStatement as bt, carriesTag as c, isReturnStatement as ct, contains as d, isSourceFile as dt, isModuleBlock as et, declarationsOf as f, isSpreadElement as ft, isExternalDeclaration as g, isTypeReferenceNode as gt, importedModulesOf as h, isTypeLiteralNode as ht, problemAt as i, isObjectLiteralExpression as it, InternalSymbolName as j, API as k, childrenOf as l, isSatisfiesExpression as lt, descendantsOf as m, isTypeAliasDeclaration as mt, describeFinding as n, isNewExpression as nt, problemInFile as o, isPropertyAccessExpression as ot, declaresAType as p, isStringLiteral as pt, isExportDeclaration as q, formatProblem as r, isNumericLiteral as rt, sortProblems as s, isPropertyAssignment as st, ProblemList as t, isModuleDeclaration as tt, columnOf as u, isSignatureDeclaration as ut, isInsideAny as v, isVariableDeclaration as vt, referencedSymbols as w, lineOf as x, isOutsideDeclaration as y, isVariableDeclarationList as yt, isArrayLiteralExpression as z };
82
128
 
83
- //# sourceMappingURL=syntax-CbxAKkqt.mjs.map
129
+ //# sourceMappingURL=problem-OJg859cN.mjs.map