@shivaedev/quality 0.48.2 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/README.md +18 -10
  3. package/biome/plugins/ambient-runtime.grit +67 -1
  4. package/biome/plugins/type-re-exports.grit +33 -4
  5. package/dist/adapters/biome/run.js +4 -4
  6. package/dist/adapters/biome/run.js.map +1 -1
  7. package/dist/adapters/knip/configuration.d.ts +5 -2
  8. package/dist/adapters/knip/configuration.d.ts.map +1 -1
  9. package/dist/adapters/knip/configuration.js +12 -5
  10. package/dist/adapters/knip/configuration.js.map +1 -1
  11. package/dist/adapters/knip/run.d.ts +2 -3
  12. package/dist/adapters/knip/run.d.ts.map +1 -1
  13. package/dist/adapters/knip/run.js +25 -7
  14. package/dist/adapters/knip/run.js.map +1 -1
  15. package/dist/adapters/knip/sourceConfig.d.ts.map +1 -1
  16. package/dist/adapters/knip/sourceConfig.js +3 -0
  17. package/dist/adapters/knip/sourceConfig.js.map +1 -1
  18. package/dist/baseline/looseStagedEntries.d.ts +4 -0
  19. package/dist/baseline/looseStagedEntries.d.ts.map +1 -0
  20. package/dist/baseline/looseStagedEntries.js +31 -0
  21. package/dist/baseline/looseStagedEntries.js.map +1 -0
  22. package/dist/baseline/update.d.ts +1 -1
  23. package/dist/baseline/update.d.ts.map +1 -1
  24. package/dist/baseline/update.js +3 -3
  25. package/dist/baseline/update.js.map +1 -1
  26. package/dist/cli/args.d.ts +2 -1
  27. package/dist/cli/args.d.ts.map +1 -1
  28. package/dist/cli/args.js +9 -35
  29. package/dist/cli/args.js.map +1 -1
  30. package/dist/cli/baseline.d.ts +1 -1
  31. package/dist/cli/baseline.d.ts.map +1 -1
  32. package/dist/cli/baseline.js +25 -2
  33. package/dist/cli/baseline.js.map +1 -1
  34. package/dist/cli/lint.d.ts +1 -1
  35. package/dist/cli/lint.d.ts.map +1 -1
  36. package/dist/cli/lint.js +11 -2
  37. package/dist/cli/lint.js.map +1 -1
  38. package/dist/cli/messages.d.ts +1 -1
  39. package/dist/cli/messages.d.ts.map +1 -1
  40. package/dist/cli/messages.js +4 -3
  41. package/dist/cli/messages.js.map +1 -1
  42. package/dist/cli/options.d.ts +45 -0
  43. package/dist/cli/options.d.ts.map +1 -0
  44. package/dist/cli/options.js +35 -0
  45. package/dist/cli/options.js.map +1 -0
  46. package/dist/cli/program.d.ts.map +1 -1
  47. package/dist/cli/program.js +3 -2
  48. package/dist/cli/program.js.map +1 -1
  49. package/dist/hooks/preCommit.js +1 -1
  50. package/dist/hooks/preCommit.js.map +1 -1
  51. package/dist/imports/classifyRuntime.d.ts.map +1 -1
  52. package/dist/imports/classifyRuntime.js +4 -1
  53. package/dist/imports/classifyRuntime.js.map +1 -1
  54. package/dist/imports/runtime.d.ts +6 -3
  55. package/dist/imports/runtime.d.ts.map +1 -1
  56. package/dist/imports/runtime.js +15 -21
  57. package/dist/imports/runtime.js.map +1 -1
  58. package/dist/inventory/collect.js +3 -3
  59. package/dist/inventory/collect.js.map +1 -1
  60. package/dist/inventory/shadcnFiles.d.ts +4 -0
  61. package/dist/inventory/shadcnFiles.d.ts.map +1 -0
  62. package/dist/inventory/shadcnFiles.js +83 -0
  63. package/dist/inventory/shadcnFiles.js.map +1 -0
  64. package/dist/naming/migrationFile.d.ts.map +1 -1
  65. package/dist/naming/migrationFile.js +3 -1
  66. package/dist/naming/migrationFile.js.map +1 -1
  67. package/dist/naming/moduleRoot.d.ts +2 -0
  68. package/dist/naming/moduleRoot.d.ts.map +1 -0
  69. package/dist/naming/moduleRoot.js +13 -0
  70. package/dist/naming/moduleRoot.js.map +1 -0
  71. package/dist/report/render.d.ts.map +1 -1
  72. package/dist/report/render.js +3 -10
  73. package/dist/report/render.js.map +1 -1
  74. package/dist/report/staleSections.js +1 -1
  75. package/dist/report/staleSections.js.map +1 -1
  76. package/dist/rules/builtIn.d.ts +2 -2
  77. package/dist/rules/effect/boundary.d.ts.map +1 -1
  78. package/dist/rules/effect/boundary.js +30 -6
  79. package/dist/rules/effect/boundary.js.map +1 -1
  80. package/dist/rules/effect/boundaryCalls.d.ts +3 -0
  81. package/dist/rules/effect/boundaryCalls.d.ts.map +1 -0
  82. package/dist/rules/effect/boundaryCalls.js +121 -0
  83. package/dist/rules/effect/boundaryCalls.js.map +1 -0
  84. package/dist/rules/effect/boundaryReference.d.ts +4 -0
  85. package/dist/rules/effect/boundaryReference.d.ts.map +1 -0
  86. package/dist/rules/effect/boundaryReference.js +80 -0
  87. package/dist/rules/effect/boundaryReference.js.map +1 -0
  88. package/dist/rules/effect/program.d.ts +1 -1
  89. package/dist/rules/effect/program.d.ts.map +1 -1
  90. package/dist/rules/effect/program.js +4 -1
  91. package/dist/rules/effect/program.js.map +1 -1
  92. package/dist/rules/effect/promiseParameter.d.ts +3 -0
  93. package/dist/rules/effect/promiseParameter.d.ts.map +1 -0
  94. package/dist/rules/effect/promiseParameter.js +24 -0
  95. package/dist/rules/effect/promiseParameter.js.map +1 -0
  96. package/dist/rules/importOrigins.d.ts +4 -0
  97. package/dist/rules/importOrigins.d.ts.map +1 -0
  98. package/dist/rules/importOrigins.js +36 -0
  99. package/dist/rules/importOrigins.js.map +1 -0
  100. package/dist/rules/imports/runtime.d.ts +1 -1
  101. package/dist/rules/imports/runtime.d.ts.map +1 -1
  102. package/dist/rules/noBarrel.d.ts.map +1 -1
  103. package/dist/rules/noBarrel.js +19 -7
  104. package/dist/rules/noBarrel.js.map +1 -1
  105. package/dist/rules/secondNames.d.ts +7 -0
  106. package/dist/rules/secondNames.d.ts.map +1 -0
  107. package/dist/rules/secondNames.js +98 -0
  108. package/dist/rules/secondNames.js.map +1 -0
  109. package/dist/rules/stories/groupedOutcomes.js +1 -1
  110. package/dist/rules/stories/groupedOutcomes.js.map +1 -1
  111. package/dist/rules/stories/importBindings.d.ts.map +1 -1
  112. package/dist/rules/stories/importBindings.js +3 -0
  113. package/dist/rules/stories/importBindings.js.map +1 -1
  114. package/dist/rules/unusedCode.d.ts +1 -1
  115. package/dist/rules/unusedCode.d.ts.map +1 -1
  116. package/docs/debt-and-hooks.md +7 -5
  117. package/package.json +3 -3
  118. package/src/adapters/biome/run.ts +4 -4
  119. package/src/adapters/knip/configuration.ts +12 -5
  120. package/src/adapters/knip/run.ts +27 -7
  121. package/src/adapters/knip/sourceConfig.ts +3 -0
  122. package/src/baseline/looseStagedEntries.ts +32 -0
  123. package/src/baseline/update.ts +5 -2
  124. package/src/cli/args.ts +16 -45
  125. package/src/cli/baseline.ts +26 -1
  126. package/src/cli/lint.ts +11 -1
  127. package/src/cli/messages.ts +4 -3
  128. package/src/cli/options.ts +43 -0
  129. package/src/cli/program.ts +3 -2
  130. package/src/hooks/preCommit.ts +1 -1
  131. package/src/imports/classifyRuntime.ts +4 -1
  132. package/src/imports/runtime.ts +19 -21
  133. package/src/inventory/collect.ts +3 -3
  134. package/src/inventory/shadcnFiles.ts +87 -0
  135. package/src/naming/migrationFile.ts +3 -1
  136. package/src/naming/moduleRoot.ts +13 -0
  137. package/src/report/render.ts +3 -10
  138. package/src/report/staleSections.ts +1 -1
  139. package/src/rules/effect/boundary.ts +48 -24
  140. package/src/rules/effect/boundaryCalls.ts +130 -0
  141. package/src/rules/effect/boundaryReference.ts +85 -0
  142. package/src/rules/effect/program.ts +4 -1
  143. package/src/rules/effect/promiseParameter.ts +26 -0
  144. package/src/rules/importOrigins.ts +38 -0
  145. package/src/rules/noBarrel.ts +21 -8
  146. package/src/rules/secondNames.ts +121 -0
  147. package/src/rules/stories/groupedOutcomes.ts +1 -1
  148. package/src/rules/stories/importBindings.ts +3 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.50.0 - 2026-10-31
4
+
5
+ ### Added
6
+
7
+ - `quality baseline write --first-adoption --rule <id>` records existing debt when a shared rule that refuses config exceptions gains new checks. It may include unchanged files; ordinary baseline writes still require changed `--file` selections. Review the resulting counts and state why retained debt needs a separate migration.
8
+ - `test-story` exports `lessThan`, `atMost`, `greaterThan` and `atLeast` from `server/adapters/outcomeMatchers.ts` for numeric bounds, including in nested expected values. Failure diffs show the bound and received value.
9
+
10
+ ### Changed
11
+
12
+ - The shared story-testing skill teaches ordered lazy outcomes, nested partial expectations and numeric bounds. Quality’s grouped-outcomes diagnostic recommends the ordered callback form.
13
+
14
+ ### Fixed
15
+
16
+ - Minimal generated apps carry the same existing foundation-registration boundary debt as the full template, so their first commit passes the stricter Quality gate after baseline pruning.
17
+ - Recognize client, server and test-support folders in modules grouped one level below `src/modules`, and accept their numbered server migrations like ungrouped modules.
18
+
19
+ ### Breaking
20
+
21
+ - `effect/boundary` reports synchronous Node filesystem and child-process calls, core `Effect.run*` runners, Promise parameters and callbacks, throwing APIs inside `Effect.sync`, and each call to a helper that throws. Move IO to Effect services, yield computations in the current runtime, and use `Effect.try` with tagged failures for throwing work. Outside-library bridges belong in `adapters/`. Record retained first-adoption debt with `quality baseline write --rule effect/boundary --first-adoption`, then lower it with `quality baseline tighten` as repairs land. Runners remain accepted at entry points, in tool configs and in tests.
22
+ - Consumers calling `runtimeOf` or `runtimeDeclarationProblems` from `@shivaedev/quality/imports/runtime.ts` must provide Effect's `FileSystem.FileSystem` service, for example with `NodeFileSystem.layer`. Directory probes now use that service and report filesystem failures as `FilesystemFailure`; only missing directories are treated as absent.
23
+ - Consumers constructing `Command` records from `@shivaedev/quality/cli/args.ts` with `_tag: "BaselineWrite"` must set `firstAdoption: false` for ordinary scoped writes, or `true` for an explicit shared-policy upgrade.
24
+ - `test-story` outcomes now takes an ordered list of `[label, () => readout(), expected]` rows. Migrate each `label: [readout(), expected]` object entry to a tuple and wrap its readout in a callback. Keep labels natural and put rows in their intended run order. Readouts are built only when their row starts. Expected objects match partially at every depth with native `toMatchObject` semantics; arrays retain length and order. Use a plain `expect(...).toEqual(...)` when exact object equality is required.
25
+
26
+ ## 0.49.0 - 2026-10-31
27
+
28
+ ### Changed
29
+
30
+ - Generated starters import schedule definitions and the default queue client factory from their defining modules.
31
+
32
+ ### Fixed
33
+
34
+ - Report ambient runtime workarounds in core code: runners over Clock, Config and Random, unsafe clock reads, cryptographic randomness, performance time, process state and scheduling. Entry points, tool configs, adapters and test-support retain their boundary role for these checks.
35
+ - Surface knip's error output and exit code when analysis produces no valid report, and reject exits inconsistent with the report.
36
+ - Resolve analysis and tool configuration within the checked checkout, including git worktrees nested in another checkout.
37
+ - Count migration-folder modules, shadcn UI imports, CSS imports and custom Vitest configurations as entry points so plain apps retain their used dependencies and test support.
38
+ - Generated apps prune their copied baseline after formatting and before the initial commit, so repaired debt cannot block the strict commit gate.
39
+ - Generated app guidance shows file-scoped baseline writes and stages new files before recording their debt.
40
+ - Failing reports point moved files to baseline pruning instead of suggesting repo-wide debt recording.
41
+ - Report exported type aliases of imports, value aliases with `typeof` annotations or local const chains, object facades and unchanged forwarding functions, with repairs naming their defining modules. Keep wrappers that transform inputs, add steps, supply defaults or declare overloads.
42
+ - Limit shadcn exclusions to canonical registry filenames inside the configured UI folder, so hand-written neighbors receive source rules and Biome lint, formatting and fixes. Keep skipped components in the unused-code import graph so dependencies they import count as used.
43
+
44
+ ### Breaking
45
+
46
+ - Repositories upgrading Quality must repair the newly reported ambient access or record existing adoption debt with `quality baseline write --rule biome/plugin`, then lower it as repairs land.
47
+ - `createApp` reads secret bytes from Effect's Crypto service. Applications embedding this Effect must provide `Crypto.Crypto`, for example with `NodeServices.layer` or `NodeCrypto.layer` from `@effect/platform-node`. The create-app command already provides it.
48
+ - The pg-boss testing-expiration bridge moved from `@shivaedev/jobs/server/internal/testingExpirations.ts` to `@shivaedev/jobs/server/adapters/testingExpirations.ts`. Consumers importing that internal path must import the adapter path instead.
49
+ - Recording an existing baseline now requires `--rule <id> --file <path>`, and every selected file must be changed since `HEAD`. Replace repo-wide rule writes with explicit changed paths, repeating `--file` as needed; stage new files first. Direct callers pass selected paths as `writeBaseline`'s fourth argument. Initial adoption without a baseline still records existing debt once. For renames, use `quality baseline prune --against <base>` to carry existing counts.
50
+ - Pre-commit rejects staged baseline counts that allow more findings than remain in their files. Run `quality baseline tighten --staged` and stage the resulting baseline changes before committing a repair.
51
+ - Quality: the gate now rejects imported second names even when they use type aliases, value annotations, object facades or forwarding functions. Import from the defining module and remove the second name; existing facade debt can be recorded at adoption. Import `USAGE` from `cli/messages.ts` instead of `cli/args.ts`.
52
+ - Jobs: import `defaultClientFactory` from `@shivaedev/jobs/server/defaultClientFactory.ts` instead of `server/client.ts`. Import `defineSchedule` from `@shivaedev/jobs/server/defineSchedule.ts` instead of `server/definition.ts`. The removed `server/internal/nativeClient.ts` and `server/internal/scheduleDefinition.ts` exports migrate to those same modules as `defaultClientFactory` and `defineSchedule`. The default factory now exposes its native pg-boss return type; type custom factory mocks against `PgBossClient` or `PgBossClientFactory` from `server/client.ts`.
53
+ - React: import `resumeSignal`, `ResumeOptions`, `ResumeSource` and `ResumeWindow` from `@shivaedev/contract/resume.ts`; `@shivaedev/react/resumeSignal.ts` is removed.
54
+ - Work Board: import `Identity` from `path/Identity.ts`, view state helpers from `browser/views/state.ts`, `isMarkdown` from `path/isMarkdown.ts`, and `processes` from `server/processOwnership.ts`. The forwarding `server/views/state.ts` and `server/integration/processes.ts` modules are removed. Replace the removed `attention` facade with imports of `managedRequestReceipt` from `server/attention/managedRequestReceipt.ts`, `attentionProjection` from `server/attention/projection.ts`, and `RequestReceipt` from `attention/RequestReceipt.ts`. Replace the removed `publication` facade with direct imports from `server/responses/publicationDirectory.ts`. Import `Changes` from `server/files/changes.ts`, `MarkdownFile` from `server/files/list.ts`, `Snapshot` from `server/search/snapshot.ts`, metadata document/model/diagnostic/parsed types from `integration/metadata.ts`, `InboxProjection` from `browser/views/schema.ts` instead of `AttentionProjection`, `SourceFailure` from `diagnostics/source.ts`, and `WorkspaceOptions` from `server/workspace.ts` instead of the integration facades. Metadata types are also removed from `server/metadata/model.ts` and `server/metadata/parse.ts`; import them from `integration/metadata.ts`.
55
+ - Work Fleet: import `WAIT_EXIT`, `WaitState`, `WaitOutcome` and `settled` from `host/waitOutcome.ts` instead of `host/wait.ts`; import `fleetRecords` from `fleetRecords.ts` instead of `operations.ts`.
56
+
3
57
  ## 0.48.2 - 2026-10-31
4
58
 
5
59
  ### Fixed
package/README.md CHANGED
@@ -21,7 +21,7 @@ Adopt Quality's policy as a whole. Quality owns the shared rules, their defaults
21
21
  A **rule** checks a repository and returns **findings**, each naming a file and what to change. Built-in and local rules always run at `error`. A finding normally counts once; a limit rule counts how far the file exceeds its limit. Use the defaults and keep checks strict. The config rejects warning levels, disabled rules, raised thresholds and inventory exclusions.
22
22
 
23
23
  Two records explain findings the repository deliberately keeps:
24
- - The **baseline** records existing debt by rule and file, as a maximum count. It makes strict checks usable before every file is cleaned up. `tighten` and `prune` lower the counts as debt disappears; explicitly writing a named rule again can raise them, and that diff needs review.
24
+ - The **baseline** records existing debt by rule and file, as a maximum count. It makes strict checks usable before every file is cleaned up. `tighten` and `prune` lower the counts as debt disappears; explicitly writing a named rule for a changed file can raise its count, and that diff needs review.
25
25
  - The config's **exceptions** list records permanent exceptions once, each with files, rules, a reason and optionally a Quality finding's `subject`. One declaration covers both Quality and Biome rules. A rule may refuse exceptions. An entry that no longer applies fails the gate instead of silently excusing future code.
26
26
 
27
27
  Exceptions apply first, then the baseline. With the default rule settings, remaining findings fail in one report grouped by rule. A baseline entry with fewer findings left is a note, so removing debt passes immediately. An entry for an unknown or disabled rule fails; debt records must still name a check that runs.
@@ -38,11 +38,19 @@ Interrupting a run stops its Biome and knip processes and removes their scoped t
38
38
 
39
39
  `effect/boundary` checks every TypeScript or JavaScript source in Quality's inventory, including shipped code, tooling and specs. It reports async functions, methods and arrows, await (including `for await`), `new Promise(...)`, `.then(...)`, try statements and throw statements. Model the work with Effect, fail with a tagged error, and use `Effect.die` for defects. Effect's resource and finalizer primitives model cleanup.
40
40
 
41
+ It also reports synchronous calls imported from `node:fs` and `node:child_process` (including aliases, namespace imports and string member keys), parameters typed as Promise or callbacks returning Promise, and each call to a helper whose body throws. A guard called 31 times contributes 31 call findings, in addition to its throw statement. `Effect.sync` reports a throwing body: explicit throws, throwing helpers, synchronous Node IO, `JSON.parse`, URI encoding/decoding, `BigInt` and synchronous Schema decoders/encoders. Use `FileSystem` and `ChildProcessSpawner` for IO, and `Effect.try` with a tagged error for fallible synchronous work.
42
+
43
+ `Effect.run*` references in core are reported even without Clock, Config or Random. Yield the computation so it uses the caller's runtime. Runners are accepted in `cli.ts`, `main.ts`, `*-cli.ts`, tool configs and tests, modules that call `runMain`, and modules with the `fileURLToPath(import.meta.url) === process.argv[1]` entry guard. These entry-point conventions accept runners only; the other boundary checks still apply.
44
+
41
45
  Only folders named `adapters/` or `test-support/`, at any depth, are exempt from this boundary rule. An `adapters/` folder bridges an outside library and hands the rest of the application Effect values. The name is fixed by convention, with no config or copied Biome plugin globs. Code that cannot be Effect belongs in that bridge or calls for a better Effect primitive. Adapter code still follows `effect/service-parameters` and the ambient time, randomness, console and environment bans.
42
46
 
47
+ The `ambient-runtime` Biome plugin also reports `Effect.run*` calls whose computation contains `Clock`, `Config` or `Random`, `currentTimeMillisUnsafe`, crypto UUIDs and bytes, `performance.now`, process arguments, working directory and exit state, `globalThis.process.env`, timeouts and microtasks. Yield service computations in the caller's Effect so its environment controls them. These additional checks apply to core TypeScript code. They accept `cli.ts`, `main.ts`, `*-cli.ts`, modules that call `runMain`, use `NodeRuntime.runMain` or guard execution with `fileURLToPath(import.meta.url) === process.argv[1]`, tool configs, tests, `adapters/` and `test-support/`. The existing `Date.now()`, `new Date()`, `Math.random()`, console and direct `process.env` bans still apply there.
48
+
43
49
  `effect/service-parameters` reports parameters carrying a service in exported functions and public methods, including returned factories. It follows service classes and tags, non-empty Contexts and service implementation shapes through aliases, interfaces, generic constraints, inferred parameters and destructuring. Read services from Effect's environment instead. An Effect or Stream requiring a service is a computation and is accepted. Methods implementing a service and functions constructing Layers may take services as parameters. Only `test-support/` folders are exempt from this rule; `adapters/` folders are checked.
44
50
 
45
- Both rules refuse config exceptions and inline suppressions. Record existing debt with `quality baseline write --rule effect/boundary` and `quality baseline write --rule effect/service-parameters`; the normal report and baseline burn-down apply.
51
+ Both rules refuse config exceptions and inline suppressions. Record existing debt with `quality baseline write --rule effect/boundary --file src/legacy.ts` and `quality baseline write --rule effect/service-parameters --file src/legacy.ts`; the normal report and baseline burn-down apply.
52
+
53
+ When an upgrade expands these checks, inspect the new findings, repair the small ones and record retained debt with `quality baseline write --first-adoption --rule effect/boundary` (or `--rule effect/service-parameters`). This explicit first-adoption mode requires named rules that refuse config exceptions and may record unchanged files. Review each raised count and explain its reason in the pull request. Ordinary writes still require changed `--file` selections. Run `quality baseline tighten` after repairs to lower the touched files' counts.
46
54
 
47
55
  ### 1. Once per repository: connect the shared policy
48
56
 
@@ -85,9 +93,9 @@ quality hooks install
85
93
 
86
94
  For an application setup script, use `quality setup`. It installs the same hook when the current folder has its own `.git` entry, including a linked worktree. An unversioned app or an app inside another repository leaves hooks alone.
87
95
 
88
- Installing the package does not install a hook. `hooks install` writes the repository's pre-commit hook. A hook Quality did not write is kept unless `--force` replaces it. For an existing repository, `quality baseline write` records error-level findings when there is no baseline; it refuses to regenerate an existing baseline without `--rule <id>`.
96
+ Installing the package does not install a hook. `hooks install` writes the repository's pre-commit hook. A hook Quality did not write is kept unless `--force` replaces it. For an existing repository, `quality baseline write` records error-level findings when there is no baseline; ordinary later writes require `--rule <id>` and `--file <path>`. Each selected path must be changed since `HEAD`; stage new files first. Initial adoption without a baseline may record the repository once.
89
97
 
90
- When upgrading Quality, the starter and apps generated by create-app provide `pnpm baseline write --rule <id>`. Record each new rule’s existing findings, review the baseline diff, and land the upgrade before burning down that debt. Checks remain strict for findings above the recorded counts. After repairs, run `pnpm baseline tighten` to lower the touched files’ debt.
98
+ When upgrading Quality, the starter and apps generated by create-app provide `pnpm baseline write --rule <id> --file <path>`. Record each new rule’s findings in the changed files, review the baseline diff, and land the upgrade before burning down that debt. Checks remain strict for findings above the recorded counts. After repairs, run `pnpm baseline tighten` to lower the touched files’ debt.
91
99
 
92
100
  Use `pnpm format --rule react/jsx-conditionals` (or `quality fix --rule react/jsx-conditionals`) for mechanical repairs. It extracts a conditional child into a variable before its return when the enclosing intrinsic elements or fragments have no attributes or other children. It preserves the conditional expression, including falsy values such as `0`, and leaves mapped children, component elements and evaluation-sensitive cases for manual repair. Remaining findings are printed and exit 1 even when the baseline covers them. The rule-specific command does not run Biome’s unsafe fixes.
93
101
 
@@ -103,7 +111,7 @@ export default defineConfig({ sources: ["src"] });
103
111
 
104
112
  When a config exists, its folder is the root for paths and hook scripts. Without one, the current directory is the root. `sources` chooses the files the source rules read; a missing source stops the run. Directory discovery skips untracked files ignored by git through `.gitignore`, `info/exclude` or `core.excludesFile`, and the `.git`, `.worktrees` and `node_modules` directories. Tracked files remain checked even when an ignore pattern matches them; a folder named `generated/` does not exempt authored code. Some repository rules, such as manifest sorting, inspect the whole repository even when `sources` names only `src`.
105
113
 
106
- Quality discovers each app’s `components.json` and resolves `aliases.ui` through its TypeScript paths or package imports. That folder belongs to the shadcn CLI: source rules and Biome lint, formatting and fixes skip it by default. Neighbouring authored folders stay checked. This leaves TypeScript’s inputs unchanged, so type checking still covers the stock components.
114
+ Quality discovers each app’s `components.json` and resolves `aliases.ui` through its TypeScript paths or package imports. Inside that folder, source rules and Biome lint, formatting and fixes skip only canonical shadcn registry filenames such as `button.tsx` and `dialog.tsx`, including their `.ts`, `.js` and `.jsx` variants. Hand-written components with other names stay checked, as do matching names outside the configured UI folder. Knip still follows imports from skipped components, so their dependencies count as used. Ownership follows filenames: a hand-written file that reuses a registry name inside the UI folder is also skipped.
107
115
 
108
116
  Module folders under `src/modules/<name>` use the same `client/` and `server/` import boundaries as the foundation, and their shared declarations remain independent of both runtimes.
109
117
 
@@ -221,10 +229,10 @@ quality baseline tighten
221
229
  When a Quality upgrade adds a check, or a reviewed change needs to record one rule's findings again:
222
230
 
223
231
  ```sh
224
- quality baseline write --rule tests/story-setup
232
+ quality baseline write --rule tests/story-setup --file src/orders.spec.ts
225
233
  ```
226
234
 
227
- Keep the default error level. The command replaces that rule's entries and leaves other rules' entries alone. Call out any new or raised count in the review and the pull request description. The [debt and hook guide](https://github.com/ShivaeDev/platform/blob/main/packages/quality/docs/debt-and-hooks.md) covers the baseline format, exception subjects, limit changes, renames and commit checks.
235
+ Keep the default error level. The command replaces that rule's entries only for the selected changed files. Repeat `--file` for additional paths; every other entry stays unchanged. Call out any new or raised count in the review and the pull request description. The [debt and hook guide](https://github.com/ShivaeDev/platform/blob/main/packages/quality/docs/debt-and-hooks.md) covers the baseline format, exception subjects, limit changes, renames and commit checks.
228
236
 
229
237
  ### Baseline merges
230
238
 
@@ -245,12 +253,12 @@ Git calls `quality baseline merge <ancestor> <current> <other>`. Entries are key
245
253
 
246
254
  Package `exports` are public API, including wildcard targets and source conditions. Package `bin` and scripts, test and story globs, tool configs and `src/test-support` provide the other entry points. Imports reachable from those entries count as used. Source-conditioned package import aliases resolve to their sources before a build. Compiler mappings from `tsconfig.json` and `tsconfig.build.json` keep imports on their source files when build output exists. An internal module can be used while one of its exports remains unused. An application’s declared dependency entry points satisfy provided imports under the same policy as `imports/manifest`.
247
255
 
248
- For adoption, run `quality baseline write --rule code/unused` and review the recorded debt. Burn it down by deleting unused code, removing unused dependency declarations, declaring missing dependencies, or connecting code to a real entry point. Run `quality baseline tighten` after repairs, or `quality baseline prune` across the repository. Do not add an entry point just to hide dead code.
256
+ For adoption, run `quality baseline write --rule code/unused --file src/legacy.ts` and review the recorded debt. Burn it down by deleting unused code, removing unused dependency declarations, declaring missing dependencies, or connecting code to a real entry point. Run `quality baseline tighten` after repairs, or `quality baseline prune` across the repository. Do not add an entry point just to hide dead code.
249
257
 
250
258
  ### What the rules check
251
259
 
252
260
  `quality lint` prints each failing rule's guidance with its findings, so the finding is the reference for what to change. The built-in rules fall into these groups:
253
- - **Structure:** `structure/max-lines` allows 150 lines in a source file and 300 in test code, `nesting/max-depth` rejects lines indented eight tabs deep, and `structure/no-barrel` rejects `index` modules. The preset rejects every re-export, types included; when `noExportedImports` suggests `export … from`, import the name where it is used instead. A module does one job.
261
+ - **Structure:** `structure/max-lines` allows 150 lines in a source file and 300 in test code, `nesting/max-depth` rejects lines indented eight tabs deep, and `structure/no-barrel` rejects `index` modules, exported value aliases (including `typeof` annotations and local const chains), facades of imports and functions that only forward their parameters unchanged to an import. Overloaded adapters keep their own meaning. The preset rejects bare type aliases of named or default imports as well as explicit type re-exports; each repair names the defining module. When `noExportedImports` suggests `export … from`, import the name where it is used instead. A module does one job.
254
262
  - **Comments:** the `comments/*` rules reject JSDoc, TODOs, banners, line and pull request references, environment pragmas and more than two comments per file. A comment says why, never what the code already says or what it used to be. A tool pragma such as `@jsxImportSource` counts as a comment until both `comments/no-jsdoc` and `comments/max-per-file` list its tag in their `allow` option.
255
263
  - **Documentation:** `docs/references` checks every Markdown file in the sources except `CHANGELOG.md`, whose released history keeps the links of its release. Relative links, reference definitions and `href`/`src` attributes reach an existing file or folder inside the repository, and a heading anchor matches one GitHub forms from the target's headings. A link to the repository's own GitHub tree, named by the root `package.json` `repository` field, is checked like a relative one unless it is pinned to a commit or a release tag. A published workspace package's README is shown on npm without the repository around it, so its links that leave the package use absolute URLs. Imports in TypeScript and JavaScript code blocks, workspace module paths such as `@scope/lib/repository.ts` written as inline code, `` `name` from `module` `` phrases and a package README's API rows resolve through the owning package's `exports` to an exported module, and every named import exists in that module unless it re-exports another. A linked document such as `CLAUDE.md` beside `AGENTS.md` is checked once, through its target. `docs/unversioned-installs` rejects a version after a package name in install commands, in shell code blocks and inline code; the package's own version ranges decide what installs, and a written version goes stale with the next release. A dist-tag such as `latest` passes.
256
264
  - **Suppressions:** the `suppressions/*` rules reject inline lint and compiler directives, casts through `unknown`, `any` or `never`, Biome settings that weaken a check, recommended Biome rules the preset leaves below `error`, and `ignoreDeprecations`. None of them takes exceptions. A type test (`*.typecheck.test.ts`) may use `@ts-expect-error`; a test that must pass a rejected value at run time calls the API through `Reflect.apply`.
@@ -404,7 +412,7 @@ quality fix [--config <file>]
404
412
  quality exceptions migrate [--config <file>] [--from <registry>]
405
413
  quality baseline merge <ancestor> <current> <other>
406
414
  quality baseline install-driver
407
- quality baseline write [--config <file>] [--rule <id>]...
415
+ quality baseline write [--config <file>] [--rule <id>]... [--file <path>]... [--first-adoption]
408
416
  quality baseline prune [--config <file>] [--against <ref>]
409
417
  quality baseline tighten [--config <file>] [--staged]
410
418
  quality baseline migrate [--config <file>] [--from <file>]
@@ -16,5 +16,71 @@ or {
16
16
  or {
17
17
  JsStaticMemberExpression() as $match where { $match <: `process.env` },
18
18
  JsComputedMemberExpression() as $match where { $match <: `process["env"]` }
19
- } where { register_diagnostic(span=$match, message="process.env is banned. Read configuration through Effect's Config service.") }
19
+ } where { register_diagnostic(span=$match, message="process.env is banned. Read configuration through Effect's Config service.") },
20
+ or {
21
+ or {
22
+ `Clock.$member.pipe($...)` as $match,
23
+ `Config.$member($...).pipe($...)` as $match,
24
+ `Random.$member.pipe($...)` as $match
25
+ } where {
26
+ $match <: contains `Effect.$runner` where { $runner <: r"run.*" },
27
+ $message = "Running Clock, Config or Random outside the current runtime is banned. Yield the computation in the caller's Effect so its services are preserved."
28
+ },
29
+ `Effect.$method($value, $...)` as $match where {
30
+ $method <: r"run.*",
31
+ $value <: contains or {
32
+ `Clock.$member`,
33
+ `Config.$member`,
34
+ `Random.$member`
35
+ },
36
+ $message = "Running Clock, Config or Random outside the current runtime is banned. Yield the computation in the caller's Effect so its services are preserved."
37
+ },
38
+ `$clock.currentTimeMillisUnsafe` as $match where {
39
+ $message = "Unsafe clock reads are banned. Yield Clock.currentTimeMillis in the caller's Effect; bridge a synchronous callback in adapters/."
40
+ },
41
+ or {
42
+ `crypto.randomUUID($...)` as $match,
43
+ `globalThis.crypto.randomUUID($...)` as $match,
44
+ `globalThis.crypto.randomBytes($...)` as $match,
45
+ `randomUUID($...)` as $match,
46
+ `randomBytes($...)` as $match
47
+ } where { $message = "Ambient cryptographic randomness is banned. Read secure values through Effect's Crypto service." },
48
+ `crypto.randomBytes($...)` as $match where {
49
+ $program <: contains or {
50
+ `import * as crypto from "node:crypto"`,
51
+ `import * as crypto from "crypto"`,
52
+ `import crypto from "node:crypto"`,
53
+ `import crypto from "crypto"`
54
+ },
55
+ $message = "Ambient cryptographic randomness is banned. Read secure values through Effect's Crypto service."
56
+ },
57
+ `performance.now()` as $match where { $message = "Ambient performance time is banned. Read time through Effect's Clock service." },
58
+ or {
59
+ `process.$member` as $match,
60
+ `globalThis.process.$member` as $match,
61
+ `process.$member = $value` as $match,
62
+ `globalThis.process.$member = $value` as $match
63
+ } where {
64
+ $member <: r"argv|cwd|exit|exitCode",
65
+ ! $match <: within JsYieldExpression(argument=JsYieldArgument(expression=`process.exitCode`)),
66
+ $message = "Ambient process state is banned. Read arguments and the working directory at the entry point and use the runtime to exit; bridge process APIs in adapters/."
67
+ },
68
+ `globalThis.process.env` as $match where { $message = "Global process.env is banned. Read configuration through Effect's Config service." },
69
+ or {
70
+ `setTimeout($...)` as $match,
71
+ `queueMicrotask($...)` as $match,
72
+ `globalThis.setTimeout($...)` as $match,
73
+ `globalThis.queueMicrotask($...)` as $match
74
+ } where {
75
+ $message = "Ambient scheduling is banned. Use Effect's sleep, scheduling and fibers in the current runtime; bridge callback APIs in adapters/."
76
+ }
77
+ } where {
78
+ ! $filename <: r"(?:^|.*[/\\])(?:adapters|test-support)[/\\].*|(?:^|.*[/\\])(?:cli|main|.*-cli)\.[cm]?[jt]sx?$|.*\.(?:config|test|spec)\.[cm]?[jt]sx?$",
79
+ ! $program <: contains or {
80
+ `NodeRuntime.runMain`,
81
+ `runMain($...)`,
82
+ `fileURLToPath(import.meta.url) === process.argv[1]`
83
+ },
84
+ register_diagnostic(span=$match, message=$message)
85
+ }
20
86
  }
@@ -2,7 +2,36 @@ engine biome(1.0)
2
2
  language js(typescript, jsx)
3
3
 
4
4
  or {
5
- `export type { $names } from $source` as $match,
6
- `export type * from $source` as $match,
7
- `export type * as $namespace from $source` as $match
8
- } where { register_diagnostic(span=$match, message="A module never re-exports, types included. Import the type from the module that defines it.") }
5
+ or {
6
+ `export type { $names } from $source` as $match,
7
+ `export type * from $source` as $match,
8
+ `export type * as $namespace from $source` as $match
9
+ },
10
+ `export type $alias = $original` as $match where {
11
+ $original <: r"[A-Za-z_$][A-Za-z0-9_$]*",
12
+ $match <: within {
13
+ contains or {
14
+ `import type { $imports } from $source`,
15
+ `import { $imports } from $source`
16
+ } where {
17
+ $imports <: contains or {
18
+ `$original`,
19
+ `$imported as $original`,
20
+ `type $original`,
21
+ `type $imported as $original`
22
+ }
23
+ }
24
+ }
25
+ },
26
+ `export type $alias = $original` as $match where {
27
+ $match <: within {
28
+ contains or {
29
+ `import type $original from $source`,
30
+ `import $original from $source`
31
+ }
32
+ }
33
+ }
34
+ } where {
35
+ register_diagnostic(span=$match, message=`A module never re-exports, types included.
36
+ Help: Import the type from $source, the module that defines it, and remove the second name.`)
37
+ }
@@ -3,14 +3,14 @@ import process from "node:process";
3
3
  import { Effect, Stream } from "effect";
4
4
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
5
5
  import { withExceptionConfig } from "#biome/exceptionConfig.ts";
6
- import { shadcnFolders } from "#inventory/shadcnFolders.ts";
6
+ import { shadcnFiles } from "#inventory/shadcnFiles.ts";
7
7
  const BIN = createRequire(import.meta.url).resolve("@biomejs/biome/bin/biome");
8
8
  export const runBiome = Effect.fn("Biome.runBiome")(function* (root, args, exceptions = []) {
9
- const folders = yield* shadcnFolders(root);
9
+ const files = yield* shadcnFiles(root);
10
10
  const toolOwned = [
11
11
  {
12
- files: ["**", "!**/pnpm-lock.yaml", ...folders.map((folder) => `!${folder}`)],
13
- reason: "pnpm writes its lockfiles; components.json assigns UI folders to the shadcn CLI.",
12
+ files: ["**", "!**/pnpm-lock.yaml", ...files.map((file) => `!${file}`)],
13
+ reason: "pnpm writes its lockfiles; canonical shadcn component filenames in the configured UI folder belong to its CLI.",
14
14
  rules: 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UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,EACpH,EAAE,WAAW,EAAE,WAAW,EAAE,CAC5B,CAAC;QACF,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC/C,CAAC,CAAC,CACF,CACD,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { RuleInputs } from "#rule.ts";
2
- export declare function knipConfiguration(inputs: RuleInputs): Promise<{
2
+ export declare function knipConfiguration(inputs: RuleInputs, toolOwned?: readonly string[]): Promise<{
3
3
  exclude: never[];
4
4
  ignore: never[];
5
5
  ignoreBinaries: never[];
@@ -22,7 +22,10 @@ export declare function knipConfiguration(inputs: RuleInputs): Promise<{
22
22
  readonly paths: {
23
23
  [k: string]: string[];
24
24
  };
25
- readonly project: string[];
25
+ readonly project: readonly string[];
26
+ readonly vitest: {
27
+ readonly config: readonly ["vitest*.config.{ts,mts,cts,js,mjs,cjs}", "vitest.{workspace,projects}.{ts,mts,cts,js,mjs,cjs,json}"];
28
+ };
26
29
  };
27
30
  };
28
31
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/configuration.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAe3C,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDzD"}
1
+ {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/configuration.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAe3C,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,GAAE,SAAS,MAAM,EAAO;;;;;;;;;;;;;;;;;;;;;;;;;yBAqC/E,MAAM;;;;GAqBnB"}
@@ -2,7 +2,7 @@ import { posix } from "node:path";
2
2
  import { readPackageManifest } from "#adapters/manifestInventory.ts";
3
3
  import { exportedModule, exportTargets } from "#imports/packageExports.ts";
4
4
  import { packageOf, workspacePackages } from "#imports/workspace.ts";
5
- import { isMigrationFile } from "#naming/migrationFile.ts";
5
+ import { SHADCN_FILE_GLOB } from "#inventory/shadcnFiles.ts";
6
6
  import { KNIP_ISSUES } from "./findings.js";
7
7
  const ENTRIES = ["**/*.{test,spec,stories,story}.{ts,tsx,mts,cts,js,jsx,mjs,cjs}", "src/test-support/**", "*.config.{ts,mts,cts,js,mjs,cjs}"];
8
8
  function importPaths(imports) {
@@ -12,7 +12,7 @@ function importPaths(imports) {
12
12
  return paths.length === 0 ? [] : [[name, paths]];
13
13
  }));
14
14
  }
15
- export async function knipConfiguration(inputs) {
15
+ export async function knipConfiguration(inputs, toolOwned = []) {
16
16
  const packages = await workspacePackages(inputs);
17
17
  const manifests = await Promise.all([".", ...packages.map(({ directory }) => directory)].map(async (directory) => {
18
18
  const manifest = (await readPackageManifest(inputs.readText, posix.join(directory, "package.json"))) ?? {};
@@ -28,13 +28,20 @@ export async function knipConfiguration(inputs) {
28
28
  const binaries = sources.filter((path) => bins.includes(path) || bins.includes(path.replace(/^src\//u, "dist/").replace(/\.(?<mode>[cm]?)tsx?$/u, ".$<mode>js")));
29
29
  const publicFiles = sources.filter((path) => exportedModule(manifest.exports, path));
30
30
  // Migration runners load these files from their directory, so no import reaches them.
31
- const migrations = sources.filter((path) => isMigrationFile(posix.join(directory, path)));
31
+ const migrations = sources.filter((path) => /(?:^|\/)server\/migrations\//u.test(path));
32
+ const ui = toolOwned
33
+ .filter((folder) => (packageOf(packages, `${folder}/component.ts`)?.directory ?? ".") === directory)
34
+ .map((folder) => `${posix.relative(directory, folder)}/**/${SHADCN_FILE_GLOB}`);
35
+ const styles = inputs.files
36
+ .filter((path) => path.endsWith(".css") && (packageOf(packages, path)?.directory ?? ".") === directory)
37
+ .map((path) => posix.relative(directory, path));
32
38
  return [
33
39
  directory,
34
40
  {
35
- entry: [...ENTRIES, ...publicFiles, ...migrations, ...bins, ...binaries, ...scriptEntries],
41
+ entry: [...ENTRIES, ...publicFiles, ...migrations, ...bins, ...binaries, ...scriptEntries, ...ui, ...styles],
36
42
  paths: importPaths(manifest.imports ?? {}),
37
- project: sources,
43
+ project: [...sources, ...ui, ...styles],
44
+ vitest: { config: ["vitest*.config.{ts,mts,cts,js,mjs,cjs}", "vitest.{workspace,projects}.{ts,mts,cts,js,mjs,cjs,json}"] },
38
45
  },
39
46
  ];
40
47
  });
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/adapters/knip/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,OAAO,GAAG,CAAC,gEAAgE,EAAE,qBAAqB,EAAE,kCAAkC,CAAC,CAAC;AAE9I,SAAS,WAAW,CAAC,OAA0C;IAC9D,OAAO,MAAM,CAAC,WAAW,CACxB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE;QAClD,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI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AAC;AACH,CAAC"}
@@ -1,5 +1,4 @@
1
- import { Effect, FileSystem } from "effect";
2
- import { ChildProcessSpawner } from "effect/process";
1
+ import { Effect } from "effect";
3
2
  import type { RuleInputs } from "#rule.ts";
4
- export declare const runKnip: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").Findings, Error | import("effect/PlatformError").PlatformError, ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem>;
3
+ export declare const runKnip: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").Findings, Error | import("effect/PlatformError").PlatformError, import("#rule.ts").RuleServices>;
5
4
  //# sourceMappingURL=run.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/run.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAU,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAgB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAO3C,eAAO,MAAM,OAAO,2LA4ClB,CAAC"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/run.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAsB,MAAM,QAAQ,CAAC;AAIpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAc3C,eAAO,MAAM,OAAO,2JAuDlB,CAAC"}
@@ -1,19 +1,29 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { basename, dirname, join, posix } from "node:path";
3
3
  import process from "node:process";
4
+ import { pathToFileURL } from "node:url";
4
5
  import { Effect, FileSystem, Stream } from "effect";
5
6
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
6
7
  import { readPackageManifest } from "#adapters/manifestInventory.ts";
8
+ import { shadcnFolders } from "#inventory/shadcnFolders.ts";
7
9
  import { knipConfiguration } from "./configuration.js";
8
10
  import { entryPointFindings } from "./entryPointFindings.js";
9
11
  import { KNIP_ISSUES, knipFindings } from "./findings.js";
10
12
  import { sourceConfig } from "./sourceConfig.js";
11
- const BIN = join(dirname(createRequire(import.meta.url).resolve("knip")), "..", "bin", "knip.js");
13
+ const API = createRequire(import.meta.url).resolve("knip");
14
+ const BIN = join(dirname(API), "..", "bin", "knip.js");
15
+ // Initialize the loader in isolation, then evaluate application configs from their checkout.
16
+ const LAUNCH = `
17
+ const [api, entry, root] = process.argv.splice(1, 3);
18
+ import(api).then(() => { process.chdir(root); return import(entry); })
19
+ .catch(error => { console.error(error); process.exitCode = 1; });
20
+ `;
12
21
  export const runKnip = Effect.fn("Knip.runKnip")(function* (inputs) {
13
22
  if ((yield* Effect.promise(() => readPackageManifest(inputs.readText, "package.json"))) === undefined) {
14
23
  return [];
15
24
  }
16
- const configuration = yield* Effect.promise(() => knipConfiguration(inputs));
25
+ const folders = yield* shadcnFolders(inputs.root);
26
+ const configuration = yield* Effect.promise(() => knipConfiguration(inputs, folders));
17
27
  const checked = new Set([...inputs.files, ...Object.keys(configuration.workspaces).map((directory) => posix.join(directory, "package.json"))]);
18
28
  const findings = yield* Effect.scoped(Effect.gen(function* () {
19
29
  const fs = yield* FileSystem.FileSystem;
@@ -21,10 +31,17 @@ export const runKnip = Effect.fn("Knip.runKnip")(function* (inputs) {
21
31
  const config = join(temporary, "knip.json");
22
32
  yield* fs.writeFileString(config, JSON.stringify(configuration));
23
33
  const tsconfig = yield* sourceConfig(inputs, Object.keys(configuration.workspaces), basename(temporary));
34
+ const cwd = join(inputs.root, posix.dirname(tsconfig), "run");
24
35
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
25
36
  const child = yield* spawner.spawn(ChildProcess.make(process.execPath, [
26
37
  "--conditions=source",
27
- BIN,
38
+ "--eval",
39
+ LAUNCH,
40
+ pathToFileURL(API).href,
41
+ pathToFileURL(BIN).href,
42
+ inputs.root,
43
+ "--directory",
44
+ inputs.root,
28
45
  "--config",
29
46
  config,
30
47
  "--tsConfig",
@@ -34,12 +51,13 @@ export const runKnip = Effect.fn("Knip.runKnip")(function* (inputs) {
34
51
  "--include",
35
52
  KNIP_ISSUES.join(","),
36
53
  "--no-progress",
37
- ], { cwd: inputs.root, env: { "JITI_TRY_NATIVE": "true" }, extendEnv: true, stdin: "ignore" }));
54
+ ], { cwd, env: { "JITI_TRY_NATIVE": "true" }, extendEnv: true, stdin: "ignore" }));
38
55
  const [stdout, stderr, code] = yield* Effect.all([Stream.mkString(Stream.decodeText(child.stdout)), Stream.mkString(Stream.decodeText(child.stderr)), child.exitCode], { concurrency: "unbounded" });
39
- if (Number(code) > 1) {
40
- return yield* Effect.fail(new Error(`knip failed: ${stderr || `exit code ${code}`}`));
56
+ const report = yield* Effect.try(() => knipFindings(stdout)).pipe(Effect.mapError(() => new Error(`knip exited ${code} without a valid report:\n${stderr || stdout || "No output."}`)));
57
+ if (Number(code) !== (report.length > 0 ? 1 : 0)) {
58
+ return yield* Effect.fail(new Error(`knip exited ${code} inconsistently with its report:\n${stderr || stdout}`));
41
59
  }
42
- return knipFindings(stdout).filter((finding) => checked.has(finding.file));
60
+ return report.filter((finding) => checked.has(finding.file));
43
61
  }));
44
62
  return yield* Effect.promise(() => entryPointFindings(inputs, findings));
45
63
  });
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/adapters/knip/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC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,OAAO,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC1E,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"sourceConfig.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/sourceConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY,+LAevB,CAAC"}
1
+ {"version":3,"file":"sourceConfig.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/sourceConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY,+LAkBvB,CAAC"}
@@ -10,6 +10,9 @@ export const sourceConfig = Effect.fn("Knip.sourceConfig")(function* (inputs, di
10
10
  const parents = yield* Effect.forEach(["tsconfig.json", "tsconfig.build.json"], (file) => Effect.promise(() => inputs.readText(posix.join(directory, file))).pipe(Effect.map((text) => (text === undefined ? [] : [resolve(inputs.root, directory, file)]))));
11
11
  yield* fs.writeFileString(join(folder, "tsconfig.json"), JSON.stringify({ extends: parents.flat(), files: [] }));
12
12
  }
13
+ // Knip's config loader searches from the parent of cwd, independently of --directory and --tsConfig.
14
+ const cwd = join(inputs.root, posix.dirname(relative), "run");
15
+ yield* fs.makeDirectory(cwd);
13
16
  return relative;
14
17
  });
15
18
  //# sourceMappingURL=sourceConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sourceConfig.js","sourceRoot":"","sources":["../../../src/adapters/knip/sourceConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACj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AY,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5F,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,eAAe,EAAE,qBAAqB,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CACxF,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CACtE,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CACzF,CACD,CAAC;QACF,KAAK,CAAC,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,eAAe,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;IAClH,CAAC;IACD,qGAAqG;IACrG,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;IAC9D,KAAK,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { Effect } from "effect";
2
+ import type { Session } from "#engine/session.ts";
3
+ export declare const looseStagedEntries: (session: Session) => Effect.Effect<readonly import("./compare.ts").StaleBaselineEntry[], import("../failure.ts").SetupFailure, import("effect/process/ChildProcessSpawner").ChildProcessSpawner>;
4
+ //# sourceMappingURL=looseStagedEntries.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"looseStagedEntries.d.ts","sourceRoot":"","sources":["../../src/baseline/looseStagedEntries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AASlD,eAAO,MAAM,kBAAkB,mMAoB7B,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { Effect } from "effect";
2
+ import { validOrFail } from "#decoded.ts";
3
+ import { keyOf } from "#engine/violation.ts";
4
+ import { applyRegistry } from "#exceptions/registry.ts";
5
+ import { gitOrFail, run } from "#git/command.ts";
6
+ import { changesSince } from "#git/history.ts";
7
+ import { applyBaseline } from "./compare.js";
8
+ import { decodeBaseline } from "./format.js";
9
+ import { shardOf } from "./shards.js";
10
+ export const looseStagedEntries = Effect.fn("Baseline.looseStagedEntries")(function* (session) {
11
+ const { root, baseline } = session.config;
12
+ const changed = yield* changesSince(root, ["--cached"]);
13
+ const shards = new Set([...changed.files].map((file) => shardOf(file, baseline)));
14
+ const paths = (yield* gitOrFail(root, ["ls-files", "-z", "--", baseline, "packages/*/quality-baseline.jsonl"]))
15
+ .split("\0")
16
+ .filter((path) => shards.has(path));
17
+ const head = yield* run(root, ["rev-parse", "--verify", "--quiet", "HEAD"]);
18
+ const entries = [];
19
+ for (const path of paths) {
20
+ const raw = yield* gitOrFail(root, ["show", `:./${path}`]);
21
+ const decoded = yield* validOrFail(path, yield* Effect.promise(() => decodeBaseline(raw)));
22
+ const tracked = head.code === 0 ? yield* gitOrFail(root, ["ls-tree", "HEAD", "--", path]) : "";
23
+ const previous = tracked === "" ? undefined : yield* gitOrFail(root, ["show", `HEAD:./${path}`]);
24
+ const before = yield* validOrFail(path, yield* Effect.promise(() => decodeBaseline(previous)));
25
+ const counts = new Map(before.map((entry) => [keyOf(entry.rule, entry.file), entry.count]));
26
+ entries.push(...decoded.filter((entry) => changed.files.has(entry.file) || counts.get(keyOf(entry.rule, entry.file)) !== entry.count));
27
+ }
28
+ const violations = applyRegistry(session.violations, session.registry, session.config).kept;
29
+ return applyBaseline(violations, entries, session.config).loose;
30
+ });
31
+ //# sourceMappingURL=looseStagedEntries.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"looseStagedEntries.js","sourceRoot":"","sources":["../../src/baseline/looseStagedEntries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAsB,cAAc,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,EAAE,CAAC,6BAA6B,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAgB;IACrG,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;IACxD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAA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