@r_masseater/msch 0.134.1 → 0.141.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 (55) hide show
  1. package/dist/addon-tasks.mjs +1 -1
  2. package/dist/build-workspace-settings-C2EOC9GX.mjs +627 -0
  3. package/dist/build-workspace-settings-C2EOC9GX.mjs.map +1 -0
  4. package/dist/cargo-inputs.mjs +1 -1
  5. package/dist/cli.mjs +708 -750
  6. package/dist/cli.mjs.map +1 -1
  7. package/dist/config.d.mts +13 -37
  8. package/dist/config.mjs +335 -23
  9. package/dist/config.mjs.map +1 -1
  10. package/dist/decision-rules-CqgOVodl.mjs +43 -0
  11. package/dist/decision-rules-CqgOVodl.mjs.map +1 -0
  12. package/dist/decision-rules.d.mts +2 -1
  13. package/dist/decision-rules.mjs +1 -1
  14. package/dist/{dependencies-Bjn3xWkq.mjs → dependencies-DgltkhvK.mjs} +2 -2
  15. package/dist/{dependencies-Bjn3xWkq.mjs.map → dependencies-DgltkhvK.mjs.map} +1 -1
  16. package/dist/{derive-cargo-inputs-BLMqkRS3.mjs → derive-cargo-inputs-DbMOBcGP.mjs} +3 -3
  17. package/dist/{derive-cargo-inputs-BLMqkRS3.mjs.map → derive-cargo-inputs-DbMOBcGP.mjs.map} +1 -1
  18. package/dist/{ignored-directories-CaTFIbjo.mjs → ignored-directories-BGiOSvNx.mjs} +2 -2
  19. package/dist/{ignored-directories-CaTFIbjo.mjs.map → ignored-directories-BGiOSvNx.mjs.map} +1 -1
  20. package/dist/index-DOkaGaUe.d.mts +25 -0
  21. package/dist/library.mjs +2 -2
  22. package/dist/lint.d.mts +38 -2
  23. package/dist/lint.mjs +20 -1
  24. package/dist/lint.mjs.map +1 -0
  25. package/dist/oxlint.mjs +2 -2
  26. package/dist/{problem-Dk1svgmC.mjs → problem-CkDaLJxX.mjs} +2 -2
  27. package/dist/{problem-Dk1svgmC.mjs.map → problem-CkDaLJxX.mjs.map} +1 -1
  28. package/dist/{published-Cgl1qeYH.mjs → published-BrX24558.mjs} +269 -8
  29. package/dist/published-BrX24558.mjs.map +1 -0
  30. package/dist/{repository-files-C_GzAnYp.mjs → repository-files-CX48nfE5.mjs} +4 -5
  31. package/dist/repository-files-CX48nfE5.mjs.map +1 -0
  32. package/dist/{define-lint-preset-_bDnJMcY.mjs → repository-text-CpD8Z1kp.mjs} +355 -380
  33. package/dist/repository-text-CpD8Z1kp.mjs.map +1 -0
  34. package/dist/traced-rules.config-CnYNZrOa.mjs +8 -0
  35. package/dist/traced-rules.config-CnYNZrOa.mjs.map +1 -0
  36. package/dist/workspace-settings.mjs +2 -434
  37. package/dist/zenn-markdown.config-uksui7Go.mjs +77 -0
  38. package/dist/zenn-markdown.config-uksui7Go.mjs.map +1 -0
  39. package/package.json +13 -13
  40. package/skills/msch-checks/SKILL.md +5 -5
  41. package/skills/msch-publishing/SKILL.md +1 -1
  42. package/skills/msch-repository-config/SKILL.md +19 -18
  43. package/skills/msch-workspace-settings/SKILL.md +15 -9
  44. package/src/app/vite.d.ts +5 -8
  45. package/dist/define-lint-preset-_bDnJMcY.mjs.map +0 -1
  46. package/dist/index-_y7Igwy0.d.mts +0 -321
  47. package/dist/published-Cgl1qeYH.mjs.map +0 -1
  48. package/dist/repository-files-C_GzAnYp.mjs.map +0 -1
  49. package/dist/repository-text-BPhi-pct.mjs +0 -331
  50. package/dist/repository-text-BPhi-pct.mjs.map +0 -1
  51. package/dist/required-stack-BLSiAmpx.mjs +0 -188
  52. package/dist/required-stack-BLSiAmpx.mjs.map +0 -1
  53. package/dist/workspace-projects-Zg078aA1.mjs +0 -269
  54. package/dist/workspace-projects-Zg078aA1.mjs.map +0 -1
  55. package/dist/workspace-settings.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { Effect } from "effect";
2
- import { n as DERIVATION_READS, t as cargoInputs } from "./derive-cargo-inputs-BLMqkRS3.mjs";
2
+ import { n as DERIVATION_READS, t as cargoInputs } from "./derive-cargo-inputs-DbMOBcGP.mjs";
3
3
  import { t as LOCKED } from "./locked-inputs-CP2lVRLR.mjs";
4
4
  // src/app/addon-tasks.ts
5
5
  const NATIVE_OUTPUT = "native/*.node";
@@ -0,0 +1,627 @@
1
+ import { Array, Effect, Option, Order, Predicate, Record, Schema, String, pipe } from "effect";
2
+ import { r as readManifest } from "./dependencies-DgltkhvK.mjs";
3
+ import { C as workspaceProjects, F as literalSettings, G as literalOf, I as merged, K as nestedValues, L as programOf, N as tasksOf, P as testsItself, R as settingsInvalid, S as workspaceDirectories, T as NO_TASKS, _ as shadcnUiIn, c as publicEntriesOf, f as splitFrontmatter, g as deployEntries, l as modDirectories, n as entriesOf, p as linkedPaths, t as PackEntry, u as INDEX_SKILL, y as prefixed, z as usedFrom } from "./published-BrX24558.mjs";
4
+ import { i as nodeRepositoryFiles, r as RepositoryFiles } from "./repository-files-CX48nfE5.mjs";
5
+ import { n as FINGERPRINT_FILE, r as LOCK_FILE, t as CLOSURE_FILE } from "./locked-closure-paths-_N_97Dbp.mjs";
6
+ import { depPathsOf, readWantedLockfile } from "@r_masseater/masseater-utils/kestrion/pnpm";
7
+ import { i as reachable, t as collectIgnoredDirectories } from "./ignored-directories-BGiOSvNx.mjs";
8
+ import { PACKAGE_JSON_FILE } from "@r_masseater/masseater-utils/kestrion";
9
+ import { decodePackageJson } from "@r_masseater/masseater-utils/kestrion/npm";
10
+ // src/entities/workspace/model/structure-members.ts
11
+ const ROOT_WORKSPACE = ".";
12
+ const PLUGIN_MANIFEST = ".claude-plugin/plugin.json";
13
+ const READ_CONCURRENCY$3 = 16;
14
+ const isPlugin = Effect.fn("isPlugin")(function* isPlugin(root, directory) {
15
+ const files = yield* RepositoryFiles;
16
+ return yield* files.exists(files.join(root, directory, PLUGIN_MANIFEST));
17
+ });
18
+ const pluginWorkspaces = Effect.fn("pluginWorkspaces")(function* pluginWorkspaces(root, directories) {
19
+ return yield* Effect.filter(directories, (directory) => isPlugin(root, directory), { concurrency: READ_CONCURRENCY$3 });
20
+ });
21
+ const sourcePlugins = Effect.fn("sourcePlugins")(function* sourcePlugins(root, directories) {
22
+ const plugins = yield* pluginWorkspaces(root, directories);
23
+ const projects = yield* workspaceProjects(root);
24
+ const published = pipe(projects, Array.filter((project) => project.published), Array.map(({ directory }) => directory));
25
+ return pipe(plugins, Array.filter((directory) => !Array.contains(published, directory)));
26
+ });
27
+ const structureMembers = Effect.fn("structureMembers")(function* structureMembers(root, directories) {
28
+ const plugins = yield* pluginWorkspaces(root, directories);
29
+ return pipe(directories, Array.filter((directory) => directory !== ROOT_WORKSPACE && !Array.contains(plugins, directory)));
30
+ });
31
+ // src/entities/workspace/model/site-entries.ts
32
+ const READ_CONCURRENCY$2 = 16;
33
+ const SCRIPT = /\.[cm]?tsx?$/u;
34
+ const SKIPPED = /\.test\.|\.d\.[cm]?ts$/u;
35
+ const SERVER_ENTRY_IMPORT = /from\s+["']@effect\/ui\/html\/HtmlServerHttp["']/u;
36
+ const siteEntries = Effect.fn("siteEntries")(function* siteEntries(root) {
37
+ const files = yield* RepositoryFiles;
38
+ const listed = yield* files.listedFiles(root);
39
+ const candidates = pipe(listed, Array.filter((file) => SCRIPT.test(file) && !SKIPPED.test(file)));
40
+ const texts = yield* Effect.forEach(candidates, (file) => files.readFile(files.join(root, file)), { concurrency: READ_CONCURRENCY$2 });
41
+ return pipe(Array.zip(candidates, texts), Array.filter(([, text]) => Option.exists(text, (value) => SERVER_ENTRY_IMPORT.test(value))), Array.map(([file]) => file));
42
+ });
43
+ // src/entities/workspace/model/locked-closures.ts
44
+ const IMPORTER = "importer:";
45
+ const ROOT_IMPORTER = ".";
46
+ const usedSections = ({ dependencies, optionalDependencies }) => [dependencies, optionalDependencies];
47
+ const packageEdges = (packages) => pipe(Record.toEntries(packages), Array.map(([id, snapshot]) => [id, pipe(usedSections(snapshot), Array.flatMap(depPathsOf))]));
48
+ const closureOf = (edges) => ({ own }) => {
49
+ const packages = pipe(reachable(edges, own), Array.filter((id) => !String.startsWith(IMPORTER)(id)));
50
+ return Array.sort(packages, String.Order);
51
+ };
52
+ /** @internal */
53
+ const lockedClosures = Effect.fn("lockedClosures")(function* lockedClosures(root) {
54
+ const files = yield* RepositoryFiles;
55
+ const lockfile = yield* readWantedLockfile(root);
56
+ const nodesOf = (id, sections) => [...pipe(sections, Array.flatMap(depPathsOf)), ...pipe(linkedPaths(sections), Array.map((path) => files.relative(root, files.join(root, id, path))), Array.map((linked) => `${IMPORTER}${Option.getOrElse(Option.liftPredicate(linked, String.isNonEmpty), () => ROOT_IMPORTER)}`))];
57
+ return pipe(lockfile, Option.map(({ importers, packages }) => {
58
+ const found = pipe(Record.toEntries(importers), Array.map(([id, project]) => {
59
+ const used = usedSections(project);
60
+ return {
61
+ id,
62
+ own: nodesOf(id, [...used, project.devDependencies]),
63
+ used: nodesOf(id, used)
64
+ };
65
+ }));
66
+ const edges = Record.fromEntries([...pipe(found, Array.map(({ id, used }) => [`${IMPORTER}${id}`, used])), ...packageEdges(packages ?? {})]);
67
+ return Record.fromEntries(pipe(found, Array.map((importer) => [importer.id, closureOf(edges)(importer)])));
68
+ }));
69
+ });
70
+ // src/entities/workspace/model/locked-closure-files.ts
71
+ const LINE = "\n";
72
+ const FILE_CONCURRENCY = 16;
73
+ const writeChanged = Effect.fn("writeChanged")(function* writeChanged(file, text) {
74
+ const files = yield* RepositoryFiles;
75
+ const written = yield* files.readFile(file);
76
+ if (!Option.exists(written, (found) => found === text)) yield* files.writeFile(file, text);
77
+ });
78
+ const isWritten = Effect.fn("isWritten")(function* isWritten(root, fingerprint) {
79
+ const files = yield* RepositoryFiles;
80
+ const [hash, ...importers] = (yield* files.readFile(files.join(root, FINGERPRINT_FILE))).pipe(Option.getOrElse(() => ""), String.split(LINE));
81
+ if (hash !== fingerprint) return false;
82
+ const present = yield* Effect.forEach(importers, (importer) => files.exists(files.join(root, importer, CLOSURE_FILE)), { concurrency: FILE_CONCURRENCY });
83
+ return pipe(present, Array.every(Boolean));
84
+ });
85
+ const writeAll = Effect.fn("writeAll")(function* writeAll(root, fingerprint) {
86
+ const files = yield* RepositoryFiles;
87
+ const entries = (yield* lockedClosures(root)).pipe(Option.getOrElse(() => ({})), Record.toEntries);
88
+ yield* Effect.forEach(entries, ([importer, closure]) => writeChanged(files.join(root, importer, CLOSURE_FILE), Array.join(closure, LINE)), {
89
+ concurrency: FILE_CONCURRENCY,
90
+ discard: true
91
+ });
92
+ const importers = pipe(entries, Array.map(([importer]) => importer));
93
+ yield* files.writeFile(files.join(root, FINGERPRINT_FILE), Array.join([fingerprint, ...importers], LINE));
94
+ });
95
+ /** @internal */
96
+ const writeLockedClosures = Effect.fn("writeLockedClosures")(function* writeLockedClosures(root) {
97
+ const files = yield* RepositoryFiles;
98
+ const fingerprint = yield* files.hashFile(files.join(root, LOCK_FILE));
99
+ if (Option.isNone(fingerprint)) return;
100
+ if (!(yield* isWritten(root, fingerprint.value))) yield* writeAll(root, fingerprint.value);
101
+ });
102
+ // src/entities/workspace/model/index-skill.ts
103
+ const SKILL_DIRECTORIES = [
104
+ ".agents/skills",
105
+ ".claude/skills",
106
+ "skills"
107
+ ];
108
+ const PLUGINS = "plugins";
109
+ const SKILLS = "skills";
110
+ const SKILL_FILE = "SKILL.md";
111
+ const READ_CONCURRENCY$1 = 16;
112
+ const nameOf = ({ fields }) => Option.filter(Option.fromNullishOr(fields["name"]), Predicate.isString);
113
+ const skillDirectories = Effect.fn("skillDirectories")(function* skillDirectories(root) {
114
+ const files = yield* RepositoryFiles;
115
+ const plugins = yield* files.readDirectory(files.join(root, PLUGINS));
116
+ return [...SKILL_DIRECTORIES, ...pipe(plugins, Array.map((plugin) => files.join(PLUGINS, plugin, SKILLS)))];
117
+ });
118
+ const skillFiles = Effect.fn("skillFiles")(function* skillFiles(root) {
119
+ const files = yield* RepositoryFiles;
120
+ const directories = yield* skillDirectories(root);
121
+ const found = yield* Effect.forEach(directories, (directory) => files.readDirectory(files.join(root, directory)).pipe(Effect.map(Array.map((name) => files.join(directory, name, SKILL_FILE)))), { concurrency: READ_CONCURRENCY$1 });
122
+ return pipe(Array.flatten(found), Array.sortBy(Order.String));
123
+ });
124
+ const indexNameAt = Effect.fn("indexNameAt")(function* indexNameAt(root, file) {
125
+ const files = yield* RepositoryFiles;
126
+ const source = yield* files.readFile(files.join(root, file));
127
+ return pipe(source, Option.filter(() => INDEX_SKILL.test(file)), Option.flatMap(splitFrontmatter), Option.flatMap(nameOf));
128
+ });
129
+ const indexSkillIn = Effect.fn("indexSkillIn")(function* indexSkillIn(root) {
130
+ const found = yield* skillFiles(root);
131
+ const names = yield* Effect.forEach(found, (file) => indexNameAt(root, file), { concurrency: READ_CONCURRENCY$1 });
132
+ return Array.head(Array.getSomes(names));
133
+ });
134
+ // src/entities/workspace/model/workspace-fallow.ts
135
+ const MSCH_FALLOW = ["msch", "fallow"];
136
+ const FALLOW_PATHS = [
137
+ "entry",
138
+ "dynamicallyLoaded",
139
+ "ignorePatterns"
140
+ ];
141
+ const Names$2 = Schema.String.pipe(Schema.Array, Schema.optional);
142
+ const IgnoredExports = Schema.Struct({
143
+ file: Schema.String,
144
+ exports: Schema.Array(Schema.String)
145
+ });
146
+ const WorkspaceFallowSettings = Schema.Struct({
147
+ entry: Names$2,
148
+ dynamicallyLoaded: Names$2,
149
+ ignorePatterns: Names$2,
150
+ ignoreDependencies: Names$2,
151
+ ignoreExports: IgnoredExports.pipe(Schema.Array, Schema.optional),
152
+ allowImports: Names$2
153
+ });
154
+ const fallowPathsOf = (directory, settings) => pipe(FALLOW_PATHS, Array.flatMap((key) => pipe(Option.fromUndefinedOr(settings[key]), Option.map((patterns) => [key, pipe(patterns, Array.map(prefixed(directory)))]), Option.toArray)), Record.fromEntries);
155
+ const fallowExportsOf = (directory, settings) => pipe(Option.fromUndefinedOr(settings.ignoreExports), Option.match({
156
+ onNone: () => ({}),
157
+ onSome: (ignored) => ({ ignoreExports: pipe(ignored, Array.map(({ file, exports }) => ({
158
+ file: prefixed(directory)(file),
159
+ exports
160
+ }))) })
161
+ }));
162
+ const fallowDependenciesOf = (directory, settings) => pipe(Option.fromUndefinedOr(settings.ignoreDependencies), Option.match({
163
+ onNone: () => ({}),
164
+ onSome: (ignoreDependencies) => ({ workspaces: { settings: { [directory]: { ignoreDependencies } } } })
165
+ }));
166
+ const fallowBoundariesOf = (directory, settings) => pipe(Option.fromUndefinedOr(settings.allowImports), Option.match({
167
+ onNone: () => ({}),
168
+ onSome: (allow) => ({ boundaries: { rules: [{
169
+ from: directory,
170
+ allow
171
+ }] } })
172
+ }));
173
+ const fallowOf = Effect.fn("fallowOf")(function* fallowOf(source) {
174
+ const settings = yield* literalSettings({
175
+ source,
176
+ path: MSCH_FALLOW,
177
+ decode: Schema.decodeUnknownEffect(WorkspaceFallowSettings, { onExcessProperty: "error" })
178
+ });
179
+ return pipe(settings, Option.map((found) => ({
180
+ ...fallowPathsOf(source.directory, found),
181
+ ...fallowExportsOf(source.directory, found),
182
+ ...fallowDependenciesOf(source.directory, found),
183
+ ...fallowBoundariesOf(source.directory, found)
184
+ })), Option.toArray);
185
+ });
186
+ // src/shared/config/required-stack.ts
187
+ const UI_STATE = "UI 状態は effect-atom だけで扱う";
188
+ const INSTRUMENTATION = "計装は Effect のトレーシングだけで扱う";
189
+ const INFRASTRUCTURE = "インフラは Alchemy の IaC と Cloudflare だけで扱い、wrangler は使わない";
190
+ const requiredStack = {
191
+ [UI_STATE]: [
192
+ "zustand",
193
+ "jotai",
194
+ "valtio",
195
+ "recoil",
196
+ "mobx",
197
+ "mobx-*",
198
+ "redux",
199
+ "@reduxjs/*",
200
+ "react-redux",
201
+ "xstate",
202
+ "@xstate/*",
203
+ "nanostores",
204
+ "@nanostores/*",
205
+ "@preact/signals*"
206
+ ],
207
+ "サーバー状態は TanStack Query と Eden だけで扱う": [
208
+ "swr",
209
+ "react-query",
210
+ "@apollo/*",
211
+ "urql",
212
+ "@urql/*",
213
+ "axios",
214
+ "ky",
215
+ "ofetch",
216
+ "got",
217
+ "node-fetch",
218
+ "graphql-request",
219
+ "@trpc/*"
220
+ ],
221
+ "ルーティングとサーバーは TanStack Start と Elysia だけで扱う": [
222
+ "react-router",
223
+ "react-router-dom",
224
+ "next",
225
+ "@remix-run/*",
226
+ "wouter",
227
+ "express",
228
+ "hono",
229
+ "fastify",
230
+ "koa",
231
+ "@nestjs/*"
232
+ ],
233
+ "データベースは Drizzle だけで扱い、スキーマはマイグレーションで生成する": [
234
+ "prisma",
235
+ "@prisma/*",
236
+ "typeorm",
237
+ "sequelize",
238
+ "kysely",
239
+ "knex",
240
+ "@mikro-orm/*",
241
+ "better-sqlite3",
242
+ "pg",
243
+ "mysql2"
244
+ ],
245
+ "認証は better-auth だけで扱う": [
246
+ "next-auth",
247
+ "@auth/*",
248
+ "lucia",
249
+ "passport",
250
+ "passport-*",
251
+ "@clerk/*",
252
+ "firebase/auth",
253
+ "@supabase/*"
254
+ ],
255
+ "UI は shadcn/ui と Tailwind CSS だけで組む": [
256
+ "@mui/*",
257
+ "antd",
258
+ "@chakra-ui/*",
259
+ "@mantine/*",
260
+ "styled-components",
261
+ "@emotion/*",
262
+ "bootstrap",
263
+ "react-bootstrap"
264
+ ],
265
+ "検証、日時、ログ、関数型ユーティリティは Effect だけで扱う": [
266
+ "zod",
267
+ "yup",
268
+ "joi",
269
+ "valibot",
270
+ "arktype",
271
+ "io-ts",
272
+ "superstruct",
273
+ "moment",
274
+ "dayjs",
275
+ "date-fns",
276
+ "luxon",
277
+ "winston",
278
+ "pino",
279
+ "bunyan",
280
+ "loglevel",
281
+ "lodash",
282
+ "lodash-es",
283
+ "ramda",
284
+ "rxjs",
285
+ "fp-ts",
286
+ "neverthrow",
287
+ "ts-results",
288
+ "purify-ts"
289
+ ],
290
+ "CSV は effect/encoding の Csv だけで読み書きする": [
291
+ "papaparse",
292
+ "csv-parse",
293
+ "csv-parser",
294
+ "csv-stringify",
295
+ "fast-csv",
296
+ "@fast-csv/*",
297
+ "d3-dsv"
298
+ ],
299
+ "tar は effect/encoding の Tar だけで読み書きする": [
300
+ "modern-tar",
301
+ "nanotar",
302
+ "tar",
303
+ "tar-stream",
304
+ "tar-fs",
305
+ "tar-js",
306
+ "tarts",
307
+ "it-tar"
308
+ ],
309
+ "エージェントスキルは vite.config.ts の skills に書き、msch --prepare で入れる": ["skills"],
310
+ "フィーチャーフラグは OpenFeature だけで扱う": [
311
+ "launchdarkly-*",
312
+ "@launchdarkly/*",
313
+ "@growthbook/*",
314
+ "unleash-client",
315
+ "flagsmith",
316
+ "@vercel/flags"
317
+ ],
318
+ "テストは Vitest と Playwright だけで扱う": [
319
+ "jest",
320
+ "jest-*",
321
+ "@jest/*",
322
+ "ts-jest",
323
+ "mocha",
324
+ "jasmine",
325
+ "jasmine-core",
326
+ "ava",
327
+ "cypress",
328
+ "tap",
329
+ "uvu"
330
+ ],
331
+ "決済は Stripe だけで扱う": [
332
+ "@paypal/*",
333
+ "paypal-rest-sdk",
334
+ "braintree",
335
+ "@paddle/*",
336
+ "@lemonsqueezy/*",
337
+ "square"
338
+ ],
339
+ "整形は Vite+ の vp fmt だけで扱う": [
340
+ "prettier",
341
+ "prettier-plugin-*",
342
+ "@prettier/*",
343
+ "@biomejs/*",
344
+ "dprint"
345
+ ],
346
+ "lint は Vite+ の vp lint だけで扱い、ESLint のプラグインは oxlint の JS プラグインとして読む": [
347
+ "eslint",
348
+ "@eslint/*",
349
+ "eslint-config-*",
350
+ "tslint",
351
+ "standard",
352
+ "xo"
353
+ ],
354
+ [INSTRUMENTATION]: [
355
+ "@opentelemetry/*",
356
+ "dd-trace",
357
+ "newrelic"
358
+ ],
359
+ [INFRASTRUCTURE]: [
360
+ "wrangler",
361
+ "miniflare",
362
+ "@cloudflare/vite-plugin",
363
+ "@vercel/*",
364
+ "@netlify/*",
365
+ "aws-cdk",
366
+ "aws-cdk-lib",
367
+ "@pulumi/*",
368
+ "cdktf"
369
+ ]
370
+ };
371
+ // src/shared/lib/added-rules.ts
372
+ const Enabled = Schema.Literals(["error", "deny"]);
373
+ const EnabledWithOptions = Schema.mutable(Schema.TupleWithRest(Schema.Tuple([Enabled]), [Schema.Unknown]));
374
+ const AddedRule = Schema.Union([Enabled, EnabledWithOptions]);
375
+ const AddedRules = Schema.Record(Schema.String, AddedRule);
376
+ // src/features/build-workspace-settings/model/dependency-allowances.ts
377
+ const DEPENDENCY_SETS = { instrumentation: requiredStack["計装は Effect のトレーシングだけで扱う"] ?? [] };
378
+ const MSCH_DEV_DEPENDENCIES = ["msch", "devDependencies"];
379
+ const MSCH_DEPENDENCIES = ["msch", "dependencies"];
380
+ const Names$1 = Schema.String.pipe(Schema.Array, Schema.optional);
381
+ const DependencySettings = Schema.Struct({
382
+ use: Names$1,
383
+ dependencies: Names$1
384
+ });
385
+ const WorkspaceDependencyAllowances = Schema.Record(Schema.String, DependencySettings);
386
+ const allowanceOf = Effect.fn("allowanceOf")(function* allowanceOf(source, [reason, allowance]) {
387
+ const sets = yield* usedFrom(source.file, DEPENDENCY_SETS, allowance.use ?? []);
388
+ const dependencies = [...Array.flatten(sets), ...allowance.dependencies ?? []];
389
+ return [`${source.directory}: ${reason}`, {
390
+ workspaces: [source.directory],
391
+ dependencies
392
+ }];
393
+ });
394
+ const allowancesOf = Effect.fn("allowancesOf")(function* allowancesOf(source, path) {
395
+ const allowed = (yield* literalSettings({
396
+ source,
397
+ path,
398
+ decode: Schema.decodeUnknownEffect(WorkspaceDependencyAllowances)
399
+ })).pipe(Option.getOrElse(() => ({})), Record.toEntries);
400
+ const entries = yield* Effect.forEach(allowed, (entry) => allowanceOf(source, entry), { concurrency: 1 });
401
+ return Record.fromEntries(entries);
402
+ });
403
+ // src/features/build-workspace-settings/model/test-project.ts
404
+ const TEST_ISOLATION = ["test", "isolate"];
405
+ const DEFAULT_EXCLUDE = ["**/node_modules/**", "**/.git/**"];
406
+ const excludeOf = (mods) => pipe(mods, Option.liftPredicate(Array.isReadonlyArrayNonEmpty), Option.match({
407
+ onNone: () => ({}),
408
+ onSome: (directories) => ({ exclude: [...DEFAULT_EXCLUDE, ...pipe(directories, Array.map((directory) => `${directory}**/*.test.{ts,tsx}`))] })
409
+ }));
410
+ const sharedTestProject = (manifest) => ({ directory, config, mods }) => ({
411
+ extends: config,
412
+ root: directory,
413
+ test: {
414
+ name: pipe(manifest, Option.flatMap(({ name }) => Option.fromUndefinedOr(name)), Option.getOrElse(() => directory)),
415
+ isolate: false,
416
+ ...excludeOf(mods)
417
+ }
418
+ });
419
+ const testProjectOf = Effect.fn("testProjectOf")(function* testProjectOf(source, config, manifest) {
420
+ const isolated = yield* literalSettings({
421
+ source,
422
+ path: TEST_ISOLATION,
423
+ decode: Schema.decodeUnknownEffect(Schema.Boolean)
424
+ });
425
+ if (Option.getOrElse(isolated, () => false)) return source.directory;
426
+ const files = yield* RepositoryFiles;
427
+ const mods = yield* modDirectories(files.dirname(source.file));
428
+ return sharedTestProject(manifest)({
429
+ directory: source.directory,
430
+ config,
431
+ mods
432
+ });
433
+ });
434
+ const excludeCopy = (exclude) => pipe(Option.fromUndefinedOr(exclude), Option.match({
435
+ onNone: () => ({}),
436
+ onSome: (patterns) => ({ exclude: [...patterns] })
437
+ }));
438
+ /** @internal */
439
+ const vitestProjectOf = (project) => {
440
+ if (Predicate.isString(project)) return project;
441
+ const { name, isolate, exclude } = project.test;
442
+ return {
443
+ extends: project.extends,
444
+ root: project.root,
445
+ test: {
446
+ name,
447
+ isolate,
448
+ ...excludeCopy(exclude)
449
+ }
450
+ };
451
+ };
452
+ // src/features/build-workspace-settings/model/workspace-public-entries.ts
453
+ const PACK_ENTRY = ["pack", "entry"];
454
+ const decodePackEntry = Schema.decodeUnknownOption(PackEntry);
455
+ const packEntriesIn = (program) => pipe(nestedValues(PACK_ENTRY)(program), Array.flatMap((node) => pipe(literalOf(node), Option.flatMap(decodePackEntry), Option.toArray, Array.flatMap(entriesOf))));
456
+ const entryFilesOf = ({ join, packEntries }) => (manifest) => {
457
+ const joined = pipe(packEntries, Array.map((entry) => ({
458
+ name: entry.name,
459
+ source: join(entry.source)
460
+ })));
461
+ return pipe(publicEntriesOf({
462
+ manifest,
463
+ join,
464
+ packEntries: joined
465
+ }), Array.map(({ source }) => source), Array.dedupe);
466
+ };
467
+ const publicEntryFiles = Effect.fn("publicEntryFiles")(function* publicEntryFiles(root, directory, config) {
468
+ const files = yield* RepositoryFiles;
469
+ const text = yield* files.readFile(files.join(root, directory, PACKAGE_JSON_FILE));
470
+ const packEntries = pipe(config, Option.map(packEntriesIn), Option.getOrElse(() => []));
471
+ const join = (target) => files.join(directory, target);
472
+ return pipe(text, Option.flatMap(decodePackageJson), Option.map(entryFilesOf({
473
+ join,
474
+ packEntries
475
+ })), Option.getOrElse(() => []));
476
+ });
477
+ // src/features/build-workspace-settings/model/workspace-settings.ts
478
+ const CONFIG_FILE = "vite.config.ts";
479
+ const READ_CONCURRENCY = 16;
480
+ const MSCH_LINT = ["msch", "lint"];
481
+ const MSCH_TEXT = ["msch", "text"];
482
+ const ZENN_FILES = ["articles/**/*.md", "books/**/*.md"];
483
+ const decodeRules = Schema.decodeUnknownEffect(AddedRules);
484
+ const Names = Schema.String.pipe(Schema.Array, Schema.optional);
485
+ const WorkspaceOverride = Schema.Struct({
486
+ files: Schema.Array(Schema.String),
487
+ excludeFiles: Names,
488
+ rules: Schema.Record(Schema.String, Schema.Unknown)
489
+ });
490
+ const WorkspaceLintSettings = Schema.Struct({ overrides: WorkspaceOverride.pipe(Schema.Array, Schema.optional) });
491
+ const WorkspaceTextSettings = Schema.Struct({ use: Schema.Array(Schema.Literal("zenn")) });
492
+ const overrideOf = Effect.fn("overrideOf")(function* overrideOf(source, override) {
493
+ const { file, directory } = source;
494
+ const rules = yield* decodeRules(override.rules).pipe(Effect.mapError((error) => settingsInvalid(file)(error.message)));
495
+ const files = pipe(override.files, Array.map(prefixed(directory)));
496
+ return pipe(Option.fromUndefinedOr(override.excludeFiles), Option.match({
497
+ onNone: () => ({
498
+ files,
499
+ rules
500
+ }),
501
+ onSome: (excluded) => ({
502
+ files,
503
+ excludeFiles: pipe(excluded, Array.map(prefixed(directory))),
504
+ rules
505
+ })
506
+ }));
507
+ });
508
+ const lintOf = Effect.fn("lintOf")(function* lintOf(source) {
509
+ const settings = yield* literalSettings({
510
+ source,
511
+ path: MSCH_LINT,
512
+ decode: Schema.decodeUnknownEffect(WorkspaceLintSettings, { onExcessProperty: "error" })
513
+ });
514
+ const lint = Option.getOrElse(settings, () => ({}));
515
+ return { overrides: yield* Effect.forEach(lint.overrides ?? [], (override) => overrideOf(source, override), { concurrency: 1 }) };
516
+ });
517
+ const articlesOf = Effect.fn("articlesOf")(function* articlesOf(source) {
518
+ const settings = yield* literalSettings({
519
+ source,
520
+ path: MSCH_TEXT,
521
+ decode: Schema.decodeUnknownEffect(WorkspaceTextSettings, { onExcessProperty: "error" })
522
+ });
523
+ return pipe(settings, Option.filter(({ use }) => Array.contains(use, "zenn")), Option.map(() => pipe(ZENN_FILES, Array.map(prefixed(source.directory)))), Option.getOrElse(() => []));
524
+ });
525
+ const settingsOf = Effect.fn("settingsOf")(function* settingsOf(source) {
526
+ const lint = yield* lintOf(source);
527
+ const articles = yield* articlesOf(source);
528
+ const devDependencies = yield* allowancesOf(source, MSCH_DEV_DEPENDENCIES);
529
+ const dependencies = yield* allowancesOf(source, MSCH_DEPENDENCIES);
530
+ const ownTests = testsItself(source.program);
531
+ const files = yield* RepositoryFiles;
532
+ const manifest = yield* readManifest(files.dirname(source.file));
533
+ const tasks = tasksOf(manifest)(source.program);
534
+ const testProject = yield* testProjectOf(source, `${source.directory}/${CONFIG_FILE}`, manifest);
535
+ return {
536
+ directory: source.directory,
537
+ ...lint,
538
+ articles,
539
+ devDependencies,
540
+ dependencies,
541
+ ownTests,
542
+ testProject,
543
+ tasks
544
+ };
545
+ });
546
+ const unconfiguredWorkspace = Effect.fn("unconfiguredWorkspace")(function* unconfiguredWorkspace(root, directory) {
547
+ const files = yield* RepositoryFiles;
548
+ const publicEntries = yield* publicEntryFiles(root, directory, Option.none());
549
+ const manifest = yield* readManifest(files.join(root, directory));
550
+ const mods = yield* modDirectories(files.join(root, directory));
551
+ return {
552
+ directory,
553
+ overrides: [],
554
+ articles: [],
555
+ fallow: [],
556
+ devDependencies: {},
557
+ dependencies: {},
558
+ ownTests: false,
559
+ testProject: sharedTestProject(manifest)({
560
+ directory,
561
+ config: false,
562
+ mods
563
+ }),
564
+ tasks: NO_TASKS,
565
+ publicEntries
566
+ };
567
+ });
568
+ const workspaceIn = Effect.fn("workspaceIn")(function* workspaceIn(options, directory) {
569
+ const files = yield* RepositoryFiles;
570
+ const file = files.join(options.root, directory, CONFIG_FILE);
571
+ const text = yield* files.readFile(file);
572
+ if (Option.isNone(text)) return yield* unconfiguredWorkspace(options.root, directory);
573
+ const program = yield* programOf(file, text.value);
574
+ const settings = yield* settingsOf({
575
+ file,
576
+ directory,
577
+ program
578
+ });
579
+ const publicEntries = yield* publicEntryFiles(options.root, directory, Option.some(program));
580
+ const fallow = yield* fallowOf({
581
+ file,
582
+ directory,
583
+ program
584
+ });
585
+ return {
586
+ ...settings,
587
+ publicEntries,
588
+ fallow
589
+ };
590
+ });
591
+ const mergedTasks = (found) => ({
592
+ verify: pipe(found, Array.flatMap(({ tasks }) => tasks.verify)),
593
+ test: pipe(found, Array.flatMap(({ tasks }) => tasks.test)),
594
+ native: pipe(found, Array.flatMap(({ tasks }) => tasks.native))
595
+ });
596
+ const mergedAllowances = (found) => ({
597
+ devDependencies: merged(pipe(found, Array.map(({ devDependencies }) => devDependencies))),
598
+ dependencies: merged(pipe(found, Array.map(({ dependencies }) => dependencies)))
599
+ });
600
+ const collectWorkspaceSettings = Effect.fn("collectWorkspaceSettings")(function* collectWorkspaceSettings(options) {
601
+ yield* Effect.ignore(writeLockedClosures(options.root));
602
+ const directories = yield* workspaceDirectories(options.root);
603
+ const found = yield* Effect.forEach(directories, (directory) => workspaceIn(options, directory), { concurrency: READ_CONCURRENCY });
604
+ const shadcnUi = yield* Effect.forEach(directories, (directory) => shadcnUiIn(options.root, directory), { concurrency: READ_CONCURRENCY });
605
+ return {
606
+ members: yield* structureMembers(options.root, directories),
607
+ plugins: yield* sourcePlugins(options.root, directories),
608
+ ignoredDirectories: yield* collectIgnoredDirectories(options.root),
609
+ lint: {
610
+ overrides: pipe(found, Array.flatMap(({ overrides }) => overrides)),
611
+ shadcnUi: Array.getSomes(shadcnUi),
612
+ publicEntries: pipe(found, Array.flatMap(({ publicEntries }) => publicEntries)),
613
+ deployEntries: yield* deployEntries(options.root),
614
+ siteEntries: yield* siteEntries(options.root)
615
+ },
616
+ testProjects: pipe(found, Array.filter(({ ownTests }) => !ownTests), Array.map(({ testProject }) => vitestProjectOf(testProject))),
617
+ tasks: mergedTasks(found),
618
+ ...mergedAllowances(found),
619
+ indexSkill: yield* indexSkillIn(options.root),
620
+ articles: pipe(found, Array.flatMap(({ articles }) => articles)),
621
+ fallow: pipe(found, Array.flatMap(({ fallow }) => fallow))
622
+ };
623
+ });
624
+ const workspaceSettings = (options) => Effect.runPromise(collectWorkspaceSettings(options).pipe(Effect.provide(nodeRepositoryFiles)));
625
+ export { requiredStack as n, workspaceSettings as t };
626
+
627
+ //# sourceMappingURL=build-workspace-settings-C2EOC9GX.mjs.map