@williamthorsen/nmr 0.33.0 → 0.35.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 (59) hide show
  1. package/.readyup/kits/default.js +121 -25
  2. package/.readyup/manifest.json +11 -8
  3. package/README.md +155 -18
  4. package/agents/guidance/rulebooks/nmr.md +1 -1
  5. package/dist/esm/UserError.d.ts +6 -0
  6. package/dist/esm/check-cache.d.ts +145 -0
  7. package/dist/esm/commands/build-output.d.ts +64 -0
  8. package/dist/esm/commands/build.d.ts +29 -1
  9. package/dist/esm/commands/build.js +25 -5
  10. package/dist/esm/commands/clean.d.ts +15 -0
  11. package/dist/esm/commands/ensure-prepublish-hooks.d.ts +11 -0
  12. package/dist/esm/commands/fmt.d.ts +32 -0
  13. package/dist/esm/commands/report-catalog.d.ts +10 -0
  14. package/dist/esm/commands/report-overrides.d.ts +6 -0
  15. package/dist/esm/commands/taze.d.ts +18 -0
  16. package/dist/esm/commands/taze.js +17 -1
  17. package/dist/esm/config.d.ts +25 -0
  18. package/dist/esm/context.d.ts +11 -0
  19. package/dist/esm/default-scripts.d.ts +15 -0
  20. package/dist/esm/defineConfig.d.ts +9 -0
  21. package/dist/esm/help.d.ts +13 -0
  22. package/dist/esm/helpers/clampToBytes.d.ts +12 -0
  23. package/dist/esm/helpers/createBoundedBuffer.d.ts +7 -0
  24. package/dist/esm/helpers/deriveExcerpt.d.ts +10 -0
  25. package/dist/esm/helpers/duration.d.ts +15 -0
  26. package/dist/esm/helpers/hook-name.d.ts +8 -0
  27. package/dist/esm/helpers/package-json.d.ts +25 -0
  28. package/dist/esm/helpers/readStringValues.d.ts +7 -0
  29. package/dist/esm/helpers/reportClosing.d.ts +15 -0
  30. package/dist/esm/helpers/transcript.d.ts +25 -0
  31. package/dist/esm/helpers/type-guards.d.ts +1 -0
  32. package/dist/esm/helpers/workspace-patterns.d.ts +7 -0
  33. package/dist/esm/prettier.d.ts +8 -0
  34. package/dist/esm/recording.d.ts +39 -1
  35. package/dist/esm/replay-assembly.d.ts +18 -2
  36. package/dist/esm/report-format.d.ts +33 -0
  37. package/dist/esm/reportCliFailure.d.ts +8 -0
  38. package/dist/esm/resolve-scripts.d.ts +10 -1
  39. package/dist/esm/resolver.d.ts +67 -2
  40. package/dist/esm/resolver.js +1 -1
  41. package/dist/esm/runCli.d.ts +17 -0
  42. package/dist/esm/runCli.js +1 -1
  43. package/dist/esm/runner.d.ts +52 -0
  44. package/dist/esm/scripts.d.ts +1 -0
  45. package/dist/esm/steps.d.ts +71 -0
  46. package/dist/esm/taze.d.ts +16 -0
  47. package/dist/esm/tests.d.ts +40 -0
  48. package/dist/esm/tests.js +25 -0
  49. package/dist/esm/tiers.d.ts +56 -1
  50. package/dist/esm/tiers.js +22 -9
  51. package/dist/esm/types.d.ts +27 -0
  52. package/dist/esm/verbosity.d.ts +37 -0
  53. package/dist/esm/verdict.d.ts +45 -0
  54. package/dist/esm/vitest-git-isolation.d.ts +1 -0
  55. package/dist/esm/vitest-git-isolation.js +4 -0
  56. package/dist/esm/vitest.d.ts +74 -2
  57. package/dist/esm/vitest.js +33 -2
  58. package/dist/esm/workspace.d.ts +18 -0
  59. package/package.json +21 -11
package/README.md CHANGED
@@ -3,15 +3,33 @@
3
3
  Context-aware script runner for pnpm monorepos. Ships an `nmr` (node-monorepo run) binary that provides centralized, consistent script execution across workspace packages and the monorepo root.
4
4
 
5
5
  <!-- section:release-notes -->
6
- ## Release notes — v0.33.0 (2026-08-20)
6
+ ## Release notes — v0.35.0 (2026-09-01)
7
7
 
8
8
  ### 🎉 Features
9
9
 
10
- - Drop the coverage step from the `check:strict` gate (#727)
10
+ - Expose tsconfigPaths as a first-class Vitest config flag (#751)
11
11
 
12
- Drops the coverage step from `check:strict` in both the workspace and root registries: The gate now runs `test` rather than `test:coverage`.
12
+ Adds a `tsconfigPaths` option to `defineVitestConfig` and `defineRootVitestConfig` in `@williamthorsen/nmr/vitest`. It emits Vite's `resolve.tsconfigPaths`, so a test resolves an aliased specifier through the `paths` its own `tsconfig.json` declares, the way `tsc` does.
13
13
 
14
- Coverage is still available as `nmr test:coverage`, run as a separate step.
14
+ The option defaults to `false` and requires Vite 8, which `@williamthorsen/nmr` now declares as an optional peer dependency at `>=8.0.0 <9`.
15
+
16
+ - Publish a test-file conventions check consuming repos can gate in CI (#753)
17
+
18
+ Adds `checkTestFileConventions` at `@williamthorsen/nmr/tests`, which a consuming repo calls from a test of its own. It fails the run on any test file that names no isolation tier or sits outside `__tests__`. Both passed silently before.
19
+
20
+ Adds `testCollectionExclude` to `defineVitestConfig` and `defineRootVitestConfig`. The same array of directory names goes to the check's `exclude`, so one declaration scopes both the sweep and what Vitest collects.
21
+
22
+ - Keep doc comments in published declaration files (#762)
23
+
24
+ Changes the behavior of `nmr-compile` so that it preserves doc comments in `.d.ts` files.
25
+
26
+ TypeScript's `removeComments` governs a whole emit, so a TS configuration that kept comments out of JavaScript also kept them out of declaration files. `nmr-compile` now emits from two programs: The first produces the `.js` under the package's own `removeComments`, and the second produces the declarations with comments.
27
+
28
+ - Report workspaces whose Vitest config bypasses the projects model (#763)
29
+
30
+ Adds a check to nmr's ReadyUp kit to report every workspace that holds a Vite config without a Vitest config beside it, and widens the existing content check from the repo root to every workspace, so a Vitest config that does not build on `defineVitestConfig` is reported. The purpose of these checks is to ensure that tier-selecting test commands are supported.
31
+
32
+ Also fixes an issue where the `no package re-exports the ancestor Vitest config` check incorrectly advised a consumer to delete a config.
15
33
  <!-- /section:release-notes -->
16
34
 
17
35
  ## Installation
@@ -39,7 +57,7 @@ From a package directory:
39
57
 
40
58
  ```bash
41
59
  nmr test # Run tests for the current package
42
- nmr build # Compile to .js and .d.ts in one pass
60
+ nmr build # Compile to .js and .d.ts
43
61
  nmr check # Typecheck, format check, lint check, and tests
44
62
  ```
45
63
 
@@ -556,7 +574,7 @@ export default defineConfig({
556
574
 
557
575
  `defineConfig` supplies nmr's shared upgrade policy — a seven-day quarantine on brand-new releases, and the pair of settings that report a dependency pinned to an exact version: locked dependencies are included, and the range searched is `minor` — so your config carries only what is specific to your repo. Any setting you declare wins over nmr's default. Passing `undefined` clears a default rather than falling back to it, which is how you hand the quarantine policy back to `pnpm-workspace.yaml`'s `minimumReleaseAge`. `mode` is the exception: the upgrade tool carries a default of its own for it, and clearing nmr's leaves no valid range to search, so name a mode instead.
558
576
 
559
- Everything the [taze configuration](https://github.com/antfu-collective/taze#config-file) accepts is accepted here.
577
+ Everything the [taze configuration](https://github.com/antfu-collective/taze#config-file) accepts is accepted here, with five exceptions that reach the upgrade tool from no config file at all: `concurrency`, `githubActions`, `ignoreOtherWorkspaces`, `nodeVersion`, and `requestTimeout`. The tool's CLI writes a default for each of them over whatever the config declares ([taze#317](https://github.com/antfu-collective/taze/issues/317)), so the command line is the only place they can be set. nmr's ReadyUp kit warns when your config declares one, and [request timeout](#request-timeout) below shows how to set it instead.
560
578
 
561
579
  > **Note:** This file is what activates nmr's upgrade policy at all. A repo without one gets neither the release quarantine nor the settings that report a dependency pinned to an exact version, and `nmr upgrade` reports nothing in a repo using pnpm's `savePrefix: ''`. nmr's ReadyUp kit warns when the file is missing.
562
580
 
@@ -565,6 +583,32 @@ Two consequences of the `minor` range mode the policy declares:
565
583
  - A `packageMode` entry is honored only by the pass whose mode matches it, or by a `default` pass; every other pass drops that dependency rather than narrowing it. Under the policy's `minor` mode, a `patch` ceiling hides its dependency until you run `nmr upgrade patch`, and a `minor` ceiling hides it from `nmr upgrade major`.
566
584
  - A `~` range is searched as `^`, so minor upgrades are proposed for it and `--write` applies them under the original `~`. To hold one dependency to patches, give it a `packageMode` entry of `patch` and read it from `nmr upgrade patch`; to hold the whole repo there, declare `mode: 'patch'`.
567
585
 
586
+ ### Request timeout
587
+
588
+ Every `upgrade` script reaches the upgrade tool with a 30-second request timeout, in place of the tool's own 5 seconds.
589
+
590
+ Five seconds is too tight for a registry that proxies npm. The tool fetches a full packument whenever the resolved registry is not `registry.npmjs.org`, and a large one runs to tens of megabytes; the budget covers the whole retry chain rather than a single attempt, so one slow response ends the run with `Timeout requesting "<package>"`. The symptom is an upgrade pass that succeeds or fails according to how warm the tool's cache happens to be.
591
+
592
+ Pass a different value for one run:
593
+
594
+ ```bash
595
+ nmr upgrade --request-timeout 90000
596
+ ```
597
+
598
+ To change it for every run, override the `upgrade` script in `.config/nmr.config.ts`, keeping the rest of the default. This is nmr's own config, not the `taze.config.ts` above; taze ignores a `rootScripts` key, and nothing reports it:
599
+
600
+ ```ts
601
+ import { defineConfig } from '@williamthorsen/nmr/config';
602
+
603
+ export default defineConfig({
604
+ rootScripts: {
605
+ upgrade: 'nmr-report-overrides && nmr-taze --recursive --request-timeout 90000',
606
+ },
607
+ });
608
+ ```
609
+
610
+ The override is one command string rather than a list of steps, because a composite element names an nmr command and both halves here are binaries.
611
+
568
612
  ## Default script registries
569
613
 
570
614
  These scripts are available out of the box. Repo-wide config (tier 2) and per-package overrides (tier 3) can add to or replace any of them.
@@ -765,7 +809,7 @@ Position determines ownership: flags before the command name are nmr's own, and
765
809
  ```bash
766
810
  # From a package directory
767
811
  nmr test # Run workspace test script
768
- nmr build # Compile to .js and .d.ts in one pass
812
+ nmr build # Compile to .js and .d.ts
769
813
 
770
814
  # From the monorepo root
771
815
  nmr test # Root tests + recursive workspace tests
@@ -842,7 +886,7 @@ nmr-clean
842
886
 
843
887
  ### `nmr-compile`
844
888
 
845
- Compile a single package's `src` tree to `dist/esm` with the TypeScript compiler API, emitting `.js` and `.d.ts` in one pass. Because the compiler parses each source file, every relative import form — static, re-export, dynamic `import()`, and bare side-effect — is rewritten from `.ts` to `.js` in both outputs, and `.ts` occurrences inside strings and comments are left intact. tsconfig `paths` aliases are resolved to runnable relative `.js` specifiers in both outputs, sourced from the package's tsconfig. An aliased import whose target resolves outside the package's `src/` and is not resolvable without the alias mapping fails the build with a diagnostic, rather than being emitted verbatim to produce output that fails at runtime. The build is skipped when no input has changed and the previous output is still on disk (the key is cached under `node_modules/.cache/nmr-compile/`, outside the published output). Deleting the output by any means — `nmr clean`, `rm -rf dist`, `git clean` — therefore forces a rebuild rather than a skip. This is the default `compile` script — run it from a package directory.
889
+ Compile a single package's `src` tree to `dist/esm` with the TypeScript compiler API, emitting `.js` from one program and `.d.ts` from a second that reuses it. The package's own `removeComments` governs the `.js` emit; the declarations emit forces it off, so `.d.ts` files carry their doc comments either way. Because the compiler parses each source file, every relative import form — static, re-export, dynamic `import()`, and bare side-effect — is rewritten from `.ts` to `.js` in both outputs, and `.ts` occurrences inside strings and comments are left intact. tsconfig `paths` aliases are resolved to runnable relative `.js` specifiers in both outputs, sourced from the package's tsconfig. An aliased import whose target resolves outside the package's `src/` and is not resolvable without the alias mapping fails the build with a diagnostic, rather than being emitted verbatim to produce output that fails at runtime. The build is skipped when no input has changed and the previous output is still on disk (the key is cached under `node_modules/.cache/nmr-compile/`, outside the published output). Deleting the output by any means — `nmr clean`, `rm -rf dist`, `git clean` — therefore forces a rebuild rather than a skip. This is the default `compile` script — run it from a package directory.
846
890
 
847
891
  **What it compiles.** Entry points are `src/**/*.ts` less the directories that hold test scaffolding rather than shipped code: `__fixtures__/`, `__mocks__/`, `__tests__/`, and `test-utils/`. Add to that list per package with [`build.extraIgnorePatterns`](#package-level-configuration). Ignoring a directory drops it as an _entry point_, not from the emit: the compiler still emits whatever the surviving entry points import, so a helper that production code uses is still compiled and its importer never emits a dangling specifier. This list is deliberately not the Vitest [coverage exclusions](#what-the-config-excludes) — helpers live in `test-utils/` precisely so they stay covered.
848
892
 
@@ -877,7 +921,7 @@ nmr-fmt --write packages/nmr
877
921
 
878
922
  ### `nmr-taze`
879
923
 
880
- Run the [taze](https://github.com/antfu-collective/taze) dependency-upgrade tool, forwarding every argument to it untouched. This is what every `upgrade` chain ends with, `root:upgrade` included — see [dependency upgrades](#dependency-upgrades) for the workflow.
924
+ Run the [taze](https://github.com/antfu-collective/taze) dependency-upgrade tool, forwarding every argument to it untouched and adding one of its own: a 30-second request timeout, unless the invocation already carries one. This is what every `upgrade` chain ends with, `root:upgrade` included — see [dependency upgrades](#dependency-upgrades) for the workflow, and [request timeout](#request-timeout) for why the timeout is set here.
881
925
 
882
926
  Under pnpm's isolated `node_modules`, a transitive package's binary is absent from the consuming repo's `node_modules/.bin`, so a repo that depends on nmr cannot run `taze` directly. `nmr-taze` can, because nmr is a direct dependency, and it resolves the tool from the tree nmr controls.
883
927
 
@@ -901,7 +945,7 @@ ensure-prepublish-hooks
901
945
 
902
946
  ## Conformance checks
903
947
 
904
- nmr publishes a `readyup` kit that checks a consuming repo against the current release: the shared Vitest and Prettier configs, the workspace layout, the root script registry, the [test-tier convention](#test-tiers), and that no `package.json` in the tree declares a `pnpm` field, which pnpm 11 reads no key from. Those settings belong in `pnpm-workspace.yaml`, and `pnpx codemod run pnpm-v10-to-v11` moves them. The kit ships inside the package, so it checks against the nmr version installed rather than whatever a repository ref happens to point at, and a tier added or renamed in nmr reaches the repo on upgrade.
948
+ nmr publishes a `readyup` kit that checks a consuming repo against the current release: the shared Vitest and Prettier configs, the workspace layout, the root script registry, the [test-tier convention](#test-tiers), and that no `package.json` in the tree declares a `pnpm` field, which pnpm 11 reads no key from. Those settings belong in `pnpm-workspace.yaml`, and `pnpx codemod run pnpm-v10-to-v11` moves them. The kit ships inside the package, so it checks against the nmr version installed rather than whatever a repository ref happens to point at, and a tier added or renamed in nmr reaches the repo on upgrade. A repo that wants the tier convention in its own gate rather than in a command run by hand declares the [conventions check](#gating-the-test-file-conventions) instead, which also covers the half the kit does not.
905
949
 
906
950
  Add `readyup` as a devDependency, then name nmr in its config:
907
951
 
@@ -1023,7 +1067,7 @@ import { defineVitestConfig } from '@williamthorsen/nmr/vitest';
1023
1067
  export default defineVitestConfig();
1024
1068
  ```
1025
1069
 
1026
- `vitest` is a peer dependency (`>=4.0.0 <5`), declared optional — the consuming repo provides it, and repos that never import this subpath are unaffected.
1070
+ `vitest` is a peer dependency (`>=4.0.0 <5`), declared optional — the consuming repo provides it, and repos that never import this subpath are unaffected. `vite` is an optional peer as well (`>=8.0.0 <9`), required only by the [`tsconfigPaths` setting](#resolving-through-tsconfig-paths); a repo that declares a `vite` of its own below that range sees an unmet-peer warning whether or not it sets the flag.
1027
1071
 
1028
1072
  ### Test tiers
1029
1073
 
@@ -1050,7 +1094,7 @@ vitest # every project
1050
1094
 
1051
1095
  **Every test file names its tier**, in the form `<subject>[.<aspect>].<tier>.test.ts`. Only the segment immediately before `.test.` selects a project, so an earlier one is free for documentation: `resolveConfig.packaged.unit.test.ts` reads as a companion to `resolveConfig.unit.test.ts` and still names `unit`.
1052
1096
 
1053
- `unit` is defined by subtracting the tiers rather than by an allow-list of infixes, so a file such as `parser.smoke.test.ts` runs under `unit` instead of being silently dropped. That is a safety net, not a licence to omit the tier: a file whose tier segment is missing or misspelt runs under `unit` and reports success, so no test run distinguishes it from a conformant one. [nmr's readyup kit](#conformance-checks) reports those files, which is the only thing that does.
1097
+ `unit` is defined by subtracting the tiers rather than by an allow-list of infixes, so a file such as `parser.smoke.test.ts` runs under `unit` instead of being silently dropped. That is a safety net, not a licence to omit the tier: a file whose tier segment is missing or misspelt runs under `unit` and reports success, so no test run distinguishes it from a conformant one until the repo declares the [conventions check](#gating-the-test-file-conventions). In a repo that has not, [nmr's readyup kit](#conformance-checks) is what reports those files.
1054
1098
 
1055
1099
  `localhost` and `remote` have no test script of their own. They are declared anyway, so that a `*.remote.test.ts` file cannot fall into `unit` and run in the default gate unnoticed.
1056
1100
 
@@ -1058,6 +1102,73 @@ Every tier above `unit` carries a 30-second `testTimeout` and `hookTimeout`, whe
1058
1102
 
1059
1103
  To raise a budget for one tier and no other, use the `tiers` seam below. The `project` seam merges over both budgets as well, but like every option passed through it the value reaches all four projects at once -- raising a tier's budget raises `unit`'s with it. To lift the ceiling for a single file rather than a whole tier, pass a timeout to the individual test or hook, which stays the narrower tool.
1060
1104
 
1105
+ ### Gating the test-file conventions
1106
+
1107
+ Both halves of the convention are silent on their own: an untiered file runs under the residual `unit` and passes, and a file outside `__tests__` is collected by nothing at all. `@williamthorsen/nmr/tests` exports a check that reports both, which a repo declares from a one-line test of its own:
1108
+
1109
+ ```ts
1110
+ // __tests__/test-file-conventions.unit.test.ts
1111
+ import { checkTestFileConventions } from '@williamthorsen/nmr/tests';
1112
+
1113
+ checkTestFileConventions();
1114
+ ```
1115
+
1116
+ It declares one suite with an assertion per half, each carrying the remedy that fixes it: the four tier names and the rename form, or the `__tests__` directory the file belongs in. The guard names its own tier like any other test file, so a misnamed guard reports itself.
1117
+
1118
+ A repo linting with `vitest/require-hook` needs a disable directive on that call, which the rule reads as setup work where it declares the suite:
1119
+
1120
+ ```ts
1121
+ // eslint-disable-next-line vitest/require-hook -- the call declares the suite, where the rule reads it as setup work.
1122
+ checkTestFileConventions();
1123
+ ```
1124
+
1125
+ The sweep starts at the monorepo root rather than at the directory Vitest supplies, so one call covers the whole repo from whichever package the run began in. `rootDir` overrides that, for a check pointed at a tree other than the repo's own.
1126
+
1127
+ An exported check rather than a step nmr runs for you, because nothing nmr runs reaches the whole tree: `nmr test` fans out per package, and a direct `vitest` invocation runs no nmr script at all. A test the repo owns also lets the repo scope what the sweep covers.
1128
+
1129
+ `exclude` names directory basenames the sweep prunes at any depth, additive to the ones nmr always prunes:
1130
+
1131
+ ```ts
1132
+ checkTestFileConventions({ exclude: ['cypress', 'generated'] });
1133
+ ```
1134
+
1135
+ **Pass the same array to [`testCollectionExclude`](#what-the-config-excludes).** The two describe one scope, and naming a directory in only one is a defect in either direction. Pruned from the sweep alone, the directory's test files still run and still report nothing, which is the silence this check exists to end. Excluded from collection alone, the sweep reports files a consumer has no reason to act on.
1136
+
1137
+ Expect the first run to fail in a repo that has never gated this. Vitest 4 excludes only `node_modules` and `.git` by default, so a `__tests__` tree under a generated or vendored directory is collected and runs today; naming that directory in both lists is the fix, rather than widening what nmr prunes for everyone.
1138
+
1139
+ ### What the config supplies
1140
+
1141
+ Two settings a workspace test runner needs almost universally are part of what the factory produces, so a config file declares neither:
1142
+
1143
+ - **Workspace packages resolve from source.** `source` leads the emitted `resolve.conditions` and `ssr.resolve.conditions`, so a cross-package import reaches the dependency's `.ts` rather than its `dist/` and a suite runs without a prior build. A package declaring no such condition is unaffected.
1144
+ - **Git subprocesses are isolated.** Every project loads a setup file that points `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM` at the null device and sets `GIT_CONFIG_NOSYSTEM`, so a test that spawns `git` reads neither the developer's identity nor a signing config that can block on a passphrase. It leads each project's `setupFiles`, ahead of every entry the layers add, because a shared setup establishes the environment the rest run in.
1145
+
1146
+ Both defaults exist because omitting either is silent rather than loud: the tiers still exist and the suite still runs green, testing `dist/` and the developer's git identity instead. Turn either off through its own option, which folds across layers like any other, the last layer to declare it winning:
1147
+
1148
+ ```ts
1149
+ export default defineVitestConfig({ isolateGit: false, resolveFromSource: false });
1150
+ ```
1151
+
1152
+ `resolveFromSource: false` is for a repo that resolves a `source` condition it does not want in tests; `isolateGit: false` is for a suite meant to read the developer's own git configuration.
1153
+
1154
+ **Vite replaces its condition defaults rather than extending them.** A config writing `conditions: ['source']` by hand therefore drops `module`, so a dependency exposing a `module` entry falls through to whatever its `exports` lists next. A replaced list still resolves `node` and `development` under Vitest, which is why nothing in a test run reports the loss. The factory emits `source` alongside Vite's defaults for each environment, so a config declaring no conditions of its own starts from a complete list.
1155
+
1156
+ **A package declaring a `source` condition must ship its sources.** Every nmr consumer now resolves that condition, so a published package whose `files` carries `dist` alone resolves to a path that is not in the tarball. A package that publishes only its build output takes a bespoke condition name instead, the way `@williamthorsen/nmr-core` uses `nmr-source` for the build's own bootstrap.
1157
+
1158
+ ### Resolving through tsconfig paths
1159
+
1160
+ A third resolution setting sits alongside those two, and this one is off. `tsconfigPaths: true` emits Vite's `resolve.tsconfigPaths`, so a test reaches an aliased specifier through the `paths` its `tsconfig.json` declares, the way `tsc` does:
1161
+
1162
+ ```ts
1163
+ export default defineVitestConfig({ tsconfigPaths: true });
1164
+ ```
1165
+
1166
+ It folds across layers like the other two, the last layer to declare it winning. It needs no `ssr` counterpart the way a condition does: Vite holds this setting outside its per-environment resolve options, so the single key reaches the environment a test's own imports resolve through.
1167
+
1168
+ **It is an opt-in because its silent direction is the reverse of the two defaults'.** Leaving it off fails loudly, with an unresolved import naming the specifier. Turning it on is the silent direction, for a repo that declares `paths` for `tsc` alone: a specifier that resolved through a package's `exports` starts resolving through the alias instead, and nothing in the run reports the switch. A repo declaring no `paths` is unaffected either way.
1169
+
1170
+ **It requires Vite 8**, where `resolve.tsconfigPaths` arrived. nmr declares `vite` as an optional peer at `>=8.0.0 <9`, so a repo holding a stale `vite` of its own hears about it at install time. That check does not reach a repo whose only Vite comes in through Vitest's own dependency, and Vitest 4 accepts Vite 6 and 7: on those, the emitted key does nothing and the aliased import fails exactly as it would with the flag off.
1171
+
1061
1172
  ### Customizing by scope
1062
1173
 
1063
1174
  Vitest applies some options at the root of a `projects` config and others per project, and placing one at the wrong level is silent rather than loud. The factory therefore takes separate override surfaces instead of one merged config:
@@ -1065,7 +1176,7 @@ Vitest applies some options at the root of a `projects` config and others per pr
1065
1176
  ```ts
1066
1177
  export default defineVitestConfig({
1067
1178
  // Vite-level options, plus the test options Vitest honours only at the root.
1068
- root: { resolve: { conditions: ['development'] } },
1179
+ root: { ssr: { resolve: { conditions: ['my-condition'] } } },
1069
1180
  // Applied to every project.
1070
1181
  project: { setupFiles: ['./vitest.setup.ts'] },
1071
1182
  // Applied to one tier, after the `project` block above.
@@ -1079,7 +1190,9 @@ export default defineVitestConfig({
1079
1190
 
1080
1191
  Arrays concatenate rather than replace. `exclude` and `setupFiles` therefore add to what the config already declares, and no surface can narrow `include` or drop a default exclusion. Adding an `include` pattern through `project` widens all four projects at once, so a file matching it is collected by each and runs four times.
1081
1192
 
1082
- `resolve.conditions` concatenates too, but layer order carries no meaning there: Vite consumes conditions as a set, and which one wins is decided by the key order of the consumed package's own `exports`. A later layer can add a condition and can never remove or outrank one an earlier layer contributed. `resolve.alias` is the one key that merges override-first, so a later alias takes precedence over an earlier one.
1193
+ `resolve.conditions` concatenates too, onto the `source` condition and the Vite defaults the factory already emits, but layer order carries no meaning there: Vite consumes conditions as a set, and which one wins is decided by the key order of the consumed package's own `exports`. A later layer can add a condition and can never remove or outrank one an earlier layer contributed; removing `source` is what `resolveFromSource: false` is for. `resolve.alias` is the one key that merges override-first, so a later alias takes precedence over an earlier one.
1194
+
1195
+ **A condition for the tests' own resolution goes under `ssr`.** `resolve` is per-environment, and Vitest resolves a test's imports through the server environment, so `root: { ssr: { resolve: { conditions: ['my-condition'] } } }` is the seam that reaches them. A top-level `root: { resolve: { conditions: [...] } }` entry reaches the client environment, which only browser-mode tests resolve through; it composes into that array and never reports that a node test did not see it. `resolve.alias` is not per-environment, so a top-level alias reaches both.
1083
1196
 
1084
1197
  ### Sharing options across config files
1085
1198
 
@@ -1092,7 +1205,7 @@ import { fileURLToPath } from 'node:url';
1092
1205
  import type { VitestConfigOptions } from '@williamthorsen/nmr/vitest';
1093
1206
 
1094
1207
  export const shared: VitestConfigOptions = {
1095
- root: { resolve: { conditions: ['source'] } },
1208
+ root: { resolve: { alias: { '~': fileURLToPath(new URL('.', import.meta.url)) } } },
1096
1209
  project: { setupFiles: [fileURLToPath(new URL('./vitest.setup.ts', import.meta.url))] },
1097
1210
  };
1098
1211
  ```
@@ -1110,15 +1223,25 @@ Both factories fold any number of layers left to right: a later layer wins on a
1110
1223
 
1111
1224
  Order is the point where `setupFiles` is concerned, since a shared setup file establishes the environment the package's own then runs in. A later layer's `project` block likewise wins over an earlier layer's `tiers` target: the nearer config is the more deliberate.
1112
1225
 
1226
+ **A package's own `vite.config.ts` fills that one slot too.** Vitest searches for a config by ascending from the run root and stopping at the first directory holding any of `vitest.config.*` or `vite.config.*`, so a package carrying only a Vite config ends the search there and never reaches the root config. Within a directory `vitest.config.*` is tried first, which makes the fix a Vitest config beside the Vite one, calling `defineVitestConfig()` as any other package config does. Without it the package declares no projects and every tier-selecting command fails with `No projects matched the filter`, `nmr ci` among them. [nmr's readyup kit](#conformance-checks) reports a package in that state.
1227
+
1113
1228
  **A path in a shared layer must be absolute.** Vitest resolves `setupFiles` against each project's own root, not against the module that declared the path, so a bare `'./vitest.setup.ts'` in a shared module names a different file in every package that consumes it -- and a package that happens to own a file by that name loads the wrong one instead of failing. The co-located form stays correct in a config file that declares the path directly.
1114
1229
 
1115
1230
  **Do not merge two returned configs.** `mergeConfig(defineVitestConfig(), defineVitestConfig(mine))` looks like the idiomatic recovery and fails at startup: both sides declare the same four project names, which Vitest rejects with `Project name "unit" ... is not unique`. Layers merge the factory's inputs instead, which is why they yield four projects however many fold.
1116
1231
 
1117
- A config file that omits the shared layer still loses those settings, silently -- Vitest's own resolution contract, not something the factory can intercept. Guard it with a test that fails when a package's suite goes missing, which also catches a shared `exclude` pattern swallowing one package's tests.
1232
+ A config file that omits the shared layer still loses those settings, silently -- Vitest's own resolution contract, not something the factory can intercept. Guard it with a test that fails when a package's suite goes missing, which also catches a shared `exclude` pattern swallowing one package's tests. Source resolution and git isolation need no such guard: the factory supplies both, so a config file cannot omit them by forgetting a layer.
1118
1233
 
1119
1234
  ### What the config excludes
1120
1235
 
1121
- Collection skips `**/node_modules/**`, `**/.git/**`, and `**/dist/**`. Coverage skips `**/__{fixtures,mocks,tests}__/**`, `**/index.ts`, and `**/*.d.ts`.
1236
+ Collection skips `**/node_modules/**`, `**/.git/**`, `**/coverage/**`, and `**/dist/**`. Coverage skips `**/__{fixtures,mocks,tests}__/**`, `**/index.ts`, and `**/*.d.ts`.
1237
+
1238
+ `testCollectionExclude` adds to the collection list. It takes directory basenames rather than globs, matched at any depth, so the same array serves the [conventions check](#gating-the-test-file-conventions):
1239
+
1240
+ ```ts
1241
+ export default defineVitestConfig({ testCollectionExclude: ['cypress', 'generated'] });
1242
+ ```
1243
+
1244
+ Every layer's entries are concatenated, and a name the shared config already prunes is emitted once. A repo needing a glob rather than a directory name has the `project` seam's own `exclude`.
1122
1245
 
1123
1246
  Because both seams concatenate, a consumer can add an exclusion but never remove one. A pattern therefore earns its place in these lists only by preventing a _silent_ failure, one a consumer cannot self-diagnose. A visible failure, such as a stray file sitting at 0% in the coverage report, is left to the consumer's own `project` seam.
1124
1247
 
@@ -1155,7 +1278,7 @@ The projects were once named `unit`, `integration`, and `app`, for what a test _
1155
1278
  2. Rename every `*.app.test.ts` onto the convention. `app` was never a tier, so keep it as the aspect segment and add the tier after it: `scaffold.app.test.ts` becomes `scaffold.app.unit.test.ts`.
1156
1279
  3. Replace `nmr test:integration` with `nmr test:tool`, and `nmr root:test:integration` with `nmr root:test:tool`, wherever a script or workflow names them.
1157
1280
 
1158
- **A file left without a tier is a silent failure.** The residual `unit` claims it and it runs in the default gate -- green, with nothing reporting that the separation was lost. [nmr's readyup kit](#conformance-checks) reports every such file; a passing test run does not. Run it before treating the migration as done.
1281
+ **A file left without a tier is a silent failure.** The residual `unit` claims it and it runs in the default gate -- green, with nothing reporting that the separation was lost. Declare the [conventions check](#gating-the-test-file-conventions), which turns that state into a failing test run, or run [nmr's readyup kit](#conformance-checks), which reports every such file. Do one of the two before treating the migration as done.
1159
1282
 
1160
1283
  `nmr test` also runs the `tool` tier, which the old `test` excluded. Those tests previously ran in no default selection at all: `check`, `check:strict`, and `ci` all inherited the exclusion, so a green pipeline said nothing about them. Expect `nmr test` to take longer and to surface failures that were never gated.
1161
1284
 
@@ -1171,3 +1294,17 @@ nmr once selected a package's test scripts by looking for a `vitest.integration.
1171
1294
  Until step 1 is done, every test command that names a tier fails against a config declaring no projects, with `Error: No projects matched the filter "unit", "tool".` at startup. `test:all` is the exception: it names no project, so it runs everything the config collects.
1172
1295
 
1173
1296
  That is a change for the better. While `test` selected by negation, an unmigrated config produced a _green_ run, because `--project '!integration'` had nothing to exclude, so the separation was lost with no error anywhere. Positive selection turns the same state into a startup failure that names the missing projects.
1297
+
1298
+ ### Migrating a repo that layered source resolution or git isolation by hand
1299
+
1300
+ The factory supplies both, so the layer a repo wrote for them, and any guard test that checked every config file imported it, can go.
1301
+
1302
+ 1. Delete the shared module's `resolve.conditions` entry for `source` and its `ssr.resolve` twin. Keep the module for whatever else it carries; delete it outright once it carries nothing.
1303
+ 2. Delete the git-isolation setup file and its `setupFiles` entry. nmr's runs in its place, ahead of every entry a layer adds.
1304
+ 3. Delete the test that asserted each config file imports the shared module, where the module is gone.
1305
+
1306
+ Two behaviors change on upgrade even in a repo that layered neither.
1307
+
1308
+ A suite whose tests run `git commit` while relying on the developer's global identity now fails with git's own `Please tell me who you are`. Set the identity locally in the fixture repo the test builds -- `git -C <repo> config user.email`, `user.name`, and `commit.gpgsign false` -- which is what makes the test report the same result on every machine.
1309
+
1310
+ A workspace package declaring a `source` condition is now resolved from source in tests that previously read its `dist`. That is the point of the default, and it means a suite stops exercising build output it may have been exercising by accident.
@@ -13,5 +13,5 @@ delivery: ambient
13
13
  - A check that already passed on the current working tree skips, printing `⏭️ <scope>: <command>: passed …` and, where the recalled run left one, `— replayed: <excerpt>` of what that run concluded. Any edit, addition, or deletion re-runs it, so read the replayed excerpt rather than paying for the answer again: never pass `--no-cache` to get a "real" run, which costs the command's full runtime to reach the same answer. Its one use is a file rather than an exit status -- a skipped command writes none, so a fresh `coverage/` needs `nmr --no-cache test:coverage`. A composite replays its constituents' excerpts, each attributed as `<scope>: <command>: <excerpt>` and cut at the line's ceiling where there are too many to fit. A skip carrying no excerpt is one whose run wrote to a terminal, or one whose constituents recorded none.
14
14
  - `nmr --log <command>` prints the whole run behind that excerpt -- up to 256 KiB, led by when it was recorded, how long it ran, and the command string that produced it -- so output you need in full is a recording to read rather than a run to pay for again. It runs nothing, and it is held to the tree rather than to the terminal: a recording a piped run made prints for a reader at one. A composite prints its constituents' excerpts, so the transcript of one of them is `nmr -F <pkg> --log <command>` or that constituent's own name. Nothing to show is said on one line and exits non-zero, naming which it is.
15
15
  - Every command nmr runs reports one line -- `✅ <scope>: <command>: passed in 12.4s`, `❌ … failed in 1.2s (exit 1)`, `⏭️ … passed 4m ago on this tree`, or `⛔ … skipped, the override is empty` -- and a composite reports alongside every command it expands into. The lines print in every verbosity, so `-q` is the low-noise way to run rather than a silent one: it withholds the output of the commands nmr runs and keeps nmr's own verdicts, which is how a pass, a cached skip, and a `""`/`":"` override stay distinguishable. Expect a run to be quiet already without the flag: nmr recognizes a known agent harness in the environment and takes quiet from that, as it does from `NMR_COMMAND_VERBOSITY` or the repo's `output.commandVerbosity`. A command whose output you need in full is one to run with `NMR_COMMAND_VERBOSITY=full`, which outranks both.
16
- - Every test file lives under a `__tests__` directory and names its isolation tier last: `<subject>[.<aspect>].<tier>.test.ts`, where any earlier segment is free-form documentation. A tier is the furthest thing the test reaches -- `tool` (a program the environment supplies), `localhost` (a service on this machine), `remote` (a machine that isn't this one), or `unit`, the residual claiming everything else. Neither a file outside `__tests__` nor one whose tier segment is missing or misspelt fails anything: the first is collected by nothing and the second runs under `unit`, and no test run distinguishes either from a conformant file. `rdy run --packages` reports the misspelt tier, and nothing reports the misplaced file.
16
+ - Every test file lives under a `__tests__` directory and names its isolation tier last: `<subject>[.<aspect>].<tier>.test.ts`, where any earlier segment is free-form documentation. A tier is the furthest thing the test reaches -- `tool` (a program the environment supplies), `localhost` (a service on this machine), `remote` (a machine that isn't this one), or `unit`, the residual claiming everything else. A file outside `__tests__`, or one whose tier segment is missing or misspelt, fails the test run in a repo that declares nmr's exported conventions check, which reports both. In a repo that has not, neither fails anything -- the first is collected by nothing and the second runs under `unit` -- and `rdy run --packages` reports the misspelt tier alone.
17
17
  - The rest is in `node_modules/@williamthorsen/nmr/README.md`: pre/post hooks (every `nmr X` auto-wraps as `nmr X:pre && nmr X && nmr X:post`), script overrides and their `""`/`":"` skip values, `nmr upgrade` ceilings (report-only until `nmr upgrade --write`), the `nmr-compile` build (there is no repo-local build script), the test tiers' timeout budgets and the `tiers` seam that raises one, which script reaches which tier, and the check-result cache's key, the retention key a replayed excerpt is additionally held to, the retention ceiling `--log` prints within, its `checkCache` config, and every condition that disables it.
@@ -1,3 +1,9 @@
1
+ /**
2
+ * A failure in what the user declared -- a config file, a `package.json` -- rather than a fault in nmr.
3
+ *
4
+ * The CLI boundary prints one of these as its message alone. A stack trace records where nmr noticed the
5
+ * problem, which says nothing about the file the reader has to edit.
6
+ */
1
7
  export declare class UserError extends Error {
2
8
  constructor(message: string);
3
9
  }
@@ -1,7 +1,9 @@
1
1
  import type { Writable } from 'node:stream';
2
2
  import type { OutputChannels } from './runner.js';
3
3
  import type { CheckCacheConfig, NmrConfig } from './types.js';
4
+ /** A recorded pass: what ran, on which tree, and what it cost. */
4
5
  export interface CheckCacheEntry {
6
+ /** The full cache key the pass was recorded under; a hit is this matching the key computed now. */
5
7
  key: string;
6
8
  treeHash: string;
7
9
  headSha: string;
@@ -9,44 +11,94 @@ export interface CheckCacheEntry {
9
11
  nmrVersion: string;
10
12
  nodeVersion: string;
11
13
  durationMs: number;
14
+ /** ISO-8601 instant the pass completed. */
12
15
  recordedAt: string;
16
+ /**
17
+ * The build digest each covered package's output carried when the pass was recorded. Build output is
18
+ * git-ignored, so the tree hash cannot describe it; comparing these is what separates output built from this
19
+ * tree from output another tree left behind.
20
+ */
13
21
  buildDigests: Record<string, string>;
22
+ /** What a skip replays in place of the run it recalls, absent on a pass that retained nothing. */
14
23
  retention?: Retention;
15
24
  }
25
+ /** What locates one command's recorded pass at one scope, and the transcript beside it. */
16
26
  export interface EntryRef {
17
27
  anchorDir: string;
18
28
  command: string;
19
29
  monorepoRoot: string;
20
30
  }
31
+ /** One command's excerpt, attributed to the scope and the command that produced it. */
21
32
  export interface ReplayLine {
22
33
  command: string;
23
34
  excerpt: string;
24
35
  scope: string;
25
36
  }
37
+ /**
38
+ * What a recalled pass replays, the key certifying the excerpts describe this environment's output, and the
39
+ * run that last vouched for them.
40
+ *
41
+ * A list rather than one excerpt: a composite's entry carries its constituents' lines, and a nested one's are
42
+ * spliced into its parent's, where the attribution cannot be re-derived from the entry that holds them.
43
+ *
44
+ * The witness is what admits a constituent's line into the assembly its parent records: a run writes it when
45
+ * it records an excerpt, and restamps it when it recalls one and replays it.
46
+ */
26
47
  export interface Retention {
27
48
  key: string;
28
49
  replay: ReplayLine[];
29
50
  runId: string;
30
51
  }
52
+ /** What nmr's own build has left on disk across the workspace. */
31
53
  export interface BuildOutputState {
54
+ /** Covered packages whose output is absent. */
32
55
  missing: string[];
56
+ /** The digest of the inputs each covered package's output was built from, keyed by package name. */
33
57
  digests: Record<string, string>;
34
58
  }
59
+ /** The parts of the running interpreter that can change what a check concludes. */
35
60
  export interface RuntimeIdentity {
36
61
  arch: string;
37
62
  nodeVersion: string;
38
63
  platform: string;
39
64
  }
65
+ /** One working tree, observed once per top-level invocation and shared with every process below it. */
40
66
  export interface TreeSnapshot {
41
67
  hash: string;
42
68
  headSha: string;
43
69
  }
70
+ /** The interpreter this process is running on, folded into every key and recorded alongside every pass. */
44
71
  export declare const CURRENT_RUNTIME: RuntimeIdentity;
72
+ /** Set to `1` to hear why the gate did not skip, or why it is disabled. */
45
73
  export declare const DEBUG_ENV_VAR = "NMR_DEBUG";
74
+ /**
75
+ * The commands cacheable without configuration: those whose whole contribution is an exit status, and that
76
+ * reach nothing beyond a checkout and an install.
77
+ *
78
+ * Excluded on purpose. `audit` and `prepush` consult a vulnerability database that changes without the tree
79
+ * (`prepush`'s `ci` constituent still skips while its `audit` always runs). `build` and `compile` carry a cache
80
+ * of their own. `fix`, `fmt`, `lint`, and `upgrade` mutate the tree they are asked about. `test:all` reaches
81
+ * whatever the environment supplies. Anything a repo adds here promises exit-status-only semantics through its
82
+ * whole chain, hooks included.
83
+ */
46
84
  export declare const DEFAULT_CACHEABLE_COMMANDS: string[];
85
+ /** Set to `1` for the standing equivalent of `--no-cache`: skip the lookup, still record on success. */
47
86
  export declare const NO_CACHE_ENV_VAR = "NMR_NO_CACHE";
87
+ /** Carries one run's identity down the spawned chain, so an entry can name the run that vouched for it. */
48
88
  export declare const RUN_ID_ENV_VAR = "NMR_RUN_ID";
89
+ /** Carries the top-level tree snapshot down the spawned chain, so one invocation hashes the tree once. */
49
90
  export declare const TREE_SNAPSHOT_ENV_VAR = "NMR_TREE_SNAPSHOT";
91
+ /**
92
+ * Restamps a recalled entry's retention with the run that is replaying it, so an excerpt this run certified
93
+ * can join the assembly a composite above it records.
94
+ *
95
+ * A recall certifies as surely as a recording does: the pass key matched, so the excerpt describes this tree,
96
+ * and the caller reaches this only where the retention key matched too, so it describes this presentation
97
+ * environment. Everything else the entry records stands -- the instant and the duration belong to the run that
98
+ * earned the pass, and a recall must not make it read as later or longer than it was.
99
+ *
100
+ * A cache that cannot be written is not worth failing a green run over, so that failure goes to the debug note.
101
+ */
50
102
  export declare function certifyRetention(options: {
51
103
  anchorDir: string;
52
104
  command: string;
@@ -56,6 +108,14 @@ export declare function certifyRetention(options: {
56
108
  runId: string;
57
109
  stderr: Writable;
58
110
  }): Promise<void>;
111
+ /**
112
+ * Folds everything that can change what a command concludes into one key: the tree's content, the command
113
+ * string that would run, the scope it would run in, nmr's own version, the interpreter, what is installed, and
114
+ * the environment variables a check can read. A hit is this key matching a recorded one, so an ingredient left
115
+ * out here is an ingredient that could change while the cache still claims a pass.
116
+ *
117
+ * Reports a reason instead of a key when the install fingerprint cannot be read, which disables the gate.
118
+ */
59
119
  export declare function computeCacheKey(options: {
60
120
  anchorDir: string;
61
121
  command: string;
@@ -72,26 +132,105 @@ export declare function computeCacheKey(options: {
72
132
  ok: false;
73
133
  reason: string;
74
134
  };
135
+ /**
136
+ * Folds what changes a transcript without changing a conclusion onto the pass key: the channel each of the
137
+ * command's output streams ran on, and the environment variables a tool presents itself through.
138
+ *
139
+ * Taking the pass key as an ingredient rather than recomputing its parts is what keeps the two from drifting
140
+ * apart. The channel kind is what keeps a run at a terminal from replaying a piped recording; folding in raw
141
+ * TTY-ness instead would be wrong under quiet mode, where the child sees pipes at a terminal and the
142
+ * transcript is reproducible.
143
+ */
75
144
  export declare function computeRetentionKey(options: {
76
145
  channels: OutputChannels;
77
146
  env: NodeJS.ProcessEnv;
78
147
  passKey: string;
79
148
  }): string;
149
+ /** Renders a snapshot for the environment of every process below this one. */
80
150
  export declare function encodeTreeSnapshot(snapshot: TreeSnapshot): string;
151
+ /**
152
+ * Names a covered package whose output differs between two observations of it, or `undefined` when every
153
+ * package agrees. A package that has appeared or disappeared between them counts as a disagreement, because
154
+ * the output the earlier observation describes is not the output the later one found.
155
+ */
81
156
  export declare function findStaleBuildOutput(earlier: Record<string, string>, later: Record<string, string>): string | undefined;
157
+ /**
158
+ * Renders the warning for a `--no-cache` that landed after the command name, where it is an argument to the
159
+ * command rather than a flag to nmr. Passing it on unchanged is the honest thing to do with an argument, so
160
+ * the warning is all that separates this from a silently un-bypassed run.
161
+ */
82
162
  export declare function formatMisplacedNoCacheWarning(command: string): string;
163
+ /**
164
+ * Reports whether a command's passes are recorded at all, which is what separates a command with no recording
165
+ * from one that could never have had one.
166
+ *
167
+ * A hook is excluded here rather than at one caller: it is not a command anyone asks for, so nothing records
168
+ * it, and a repo naming one in `extraCommands` must not make the gate and a reader of its entries disagree.
169
+ */
83
170
  export declare function isCacheableCommand(checkCache: CheckCacheConfig | undefined, command: string): boolean;
171
+ /**
172
+ * Reads the state of the build output nmr's own build covers. Build output is git-ignored, so the tree hash
173
+ * says nothing about it: a `ci` whose `build` constituent is cached would otherwise skip on a tree whose `dist`
174
+ * had been deleted, or whose `dist` was compiled from a different tree, and hand back a green exit over a
175
+ * repository that cannot run.
176
+ *
177
+ * A package whose `build` or `compile` is overridden emits somewhere this does not know about, so it is left
178
+ * out rather than made a permanent miss.
179
+ */
84
180
  export declare function readBuildOutputState(monorepoRoot: string, config: NmrConfig): Promise<BuildOutputState>;
181
+ /**
182
+ * Reads the entry recorded for one command at one scope, or `undefined` when there is none to trust.
183
+ *
184
+ * Retention is vouched for separately from the pass it rides on: an excerpt of a shape this cannot read is
185
+ * dropped, leaving a pass that skips cleanly and reports its verdict alone. Voiding the pass instead would
186
+ * cost a full run to avoid a line nobody would have printed.
187
+ */
85
188
  export declare function readCheckCacheEntry(options: {
86
189
  anchorDir: string;
87
190
  command: string;
88
191
  monorepoRoot: string;
89
192
  }): Promise<CheckCacheEntry | undefined>;
193
+ /**
194
+ * Reads the whole output one recorded pass retained, or `undefined` where it retained none.
195
+ *
196
+ * Held to nothing on its own: the entry beside it is what says which tree the bytes describe, and a caller
197
+ * that has not matched the entry's key is reading a transcript of some other tree.
198
+ */
90
199
  export declare function readTranscript(ref: EntryRef): Promise<string | undefined>;
200
+ /**
201
+ * Makes the transcript beside one entry be exactly what this pass retained, removing what an earlier pass
202
+ * left when this one retained nothing.
203
+ *
204
+ * A composite retains nothing of its own, so without the removal a leaf's transcript would stand beside an
205
+ * entry that never produced it, and `--log` would date another run's bytes by this one's instant.
206
+ */
91
207
  export declare function recordTranscript(ref: EntryRef, transcript: string | undefined): Promise<void>;
208
+ /** Removes every recorded pass for a monorepo, or for a standalone package outside one. */
92
209
  export declare function removeCheckCache(scopeDir: string): Promise<void>;
210
+ /**
211
+ * Merges a repo's `checkCache` configuration into the default set. Extending rather than replacing means
212
+ * declaring one command cannot silently drop the defaults; excluding is how a repo retires a name whose chain
213
+ * turned out to do more than report an exit status.
214
+ */
93
215
  export declare function resolveCacheableCommands(checkCache: CheckCacheConfig | undefined): Set<string>;
216
+ /**
217
+ * Resolves the identity of the run this invocation belongs to: the one an ancestor nmr process passed down,
218
+ * and otherwise a fresh one, this invocation being where the run starts.
219
+ *
220
+ * Unbounded where the tree snapshot is bounded by a HEAD comparison: a process that outlives its run hands a
221
+ * stale identity to the invocations it later makes, and what keeps that harmless is the tree hash every
222
+ * constituent entry is held to before its excerpt joins an assembly.
223
+ */
94
224
  export declare function resolveRunId(env: NodeJS.ProcessEnv): string;
225
+ /**
226
+ * Resolves the tree snapshot this invocation gates on: the one a parent nmr process already took, when there
227
+ * is one, and otherwise a fresh hash of the working tree. Reports a reason instead when no snapshot can be
228
+ * had, which disables the gate.
229
+ *
230
+ * The monorepo root must be the git toplevel. A repository holding the monorepo inside a subdirectory has
231
+ * content outside it that the checks may still read, and a hash covering more than the monorepo would move
232
+ * for edits that cannot affect it.
233
+ */
95
234
  export declare function resolveTreeSnapshot(options: {
96
235
  monorepoRoot: string;
97
236
  env: NodeJS.ProcessEnv;
@@ -102,10 +241,16 @@ export declare function resolveTreeSnapshot(options: {
102
241
  ok: false;
103
242
  reason: string;
104
243
  };
244
+ /** Records a pass, replacing whatever this command last recorded at this scope. */
105
245
  export declare function writeCheckCacheEntry(options: {
106
246
  anchorDir: string;
107
247
  command: string;
108
248
  entry: CheckCacheEntry;
109
249
  monorepoRoot: string;
110
250
  }): Promise<void>;
251
+ /**
252
+ * Writes a note explaining a gate decision, but only when `NMR_DEBUG=1`. The gate is silent by default: a
253
+ * reason to run is not news, and a line per invocation explaining why nothing was skipped would bury the
254
+ * output of the command that did run.
255
+ */
111
256
  export declare function writeDebugNote(message: string, env: NodeJS.ProcessEnv, stderr: Writable): void;