@williamthorsen/nmr 0.19.0 → 0.21.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 (44) hide show
  1. package/AGENTS.md +5 -96
  2. package/README.md +303 -99
  3. package/bin/nmr-fmt.js +11 -0
  4. package/dist/esm/cli-ensure-prepublish-hooks.js +1 -1
  5. package/dist/esm/cli-fmt.js +3 -0
  6. package/dist/esm/cli-report-overrides.js +1 -1
  7. package/dist/esm/cli-sync-agent-files.js +1 -1
  8. package/dist/esm/commands/clean.js +4 -3
  9. package/dist/esm/commands/ensure-prepublish-hooks.js +1 -1
  10. package/dist/esm/commands/fmt.d.ts +23 -0
  11. package/dist/esm/commands/fmt.js +172 -0
  12. package/dist/esm/context.d.ts +0 -2
  13. package/dist/esm/context.js +7 -60
  14. package/dist/esm/default-scripts.d.ts +1 -3
  15. package/dist/esm/default-scripts.js +17 -21
  16. package/dist/esm/help.js +3 -2
  17. package/dist/esm/helpers/workspace-patterns.d.ts +1 -0
  18. package/dist/esm/helpers/workspace-patterns.js +29 -0
  19. package/dist/esm/index.d.ts +0 -1
  20. package/dist/esm/resolve-scripts.d.ts +1 -1
  21. package/dist/esm/resolve-scripts.js +3 -6
  22. package/dist/esm/resolver.d.ts +1 -2
  23. package/dist/esm/resolver.js +3 -6
  24. package/dist/esm/runCli.js +17 -19
  25. package/dist/esm/vitest.d.ts +15 -0
  26. package/dist/esm/vitest.js +62 -0
  27. package/dist/esm/workspace.d.ts +2 -0
  28. package/dist/esm/workspace.js +38 -0
  29. package/package.json +27 -12
  30. package/bin/nmr-sync-pnpm-version.js +0 -11
  31. package/dist/esm/cli-sync-pnpm-version.js +0 -11
  32. package/dist/esm/commands/sync-pnpm-version.d.ts +0 -3
  33. package/dist/esm/commands/sync-pnpm-version.js +0 -40
  34. package/dist/esm/helpers/code-quality-pnpm-action.d.ts +0 -13
  35. package/dist/esm/helpers/code-quality-pnpm-action.js +0 -22
  36. package/dist/esm/tests/consistency.d.ts +0 -7
  37. package/dist/esm/tests/consistency.js +0 -57
  38. package/dist/esm/tests/helpers/get-runtime-version-from-asdf.d.ts +0 -1
  39. package/dist/esm/tests/helpers/get-runtime-version-from-asdf.js +0 -12
  40. package/dist/esm/tests/helpers/get-string-from-yaml-file.d.ts +0 -1
  41. package/dist/esm/tests/helpers/get-string-from-yaml-file.js +0 -12
  42. package/dist/esm/tests/helpers/get-value-at-path.d.ts +0 -1
  43. package/dist/esm/tests/helpers/get-value-at-path.js +0 -34
  44. /package/dist/esm/{cli-sync-pnpm-version.d.ts → cli-fmt.d.ts} +0 -0
package/AGENTS.md CHANGED
@@ -2,100 +2,9 @@
2
2
  source: '@williamthorsen/nmr@0.0.0-source'
3
3
  ---
4
4
 
5
- # nmr: agent guidance
5
+ # nmr: agent guidance (generated; do not edit)
6
6
 
7
- This file is managed by `@williamthorsen/nmr`. Do not edit; run `nmr sync-agent-files` to refresh it after an nmr upgrade that changes this guidance.
8
-
9
- ## Discover scripts by running nmr
10
-
11
- Run `nmr` with no command (from the monorepo root or any workspace package) to list every available script, including composite expansions and resolved shell commands. Check this before guessing a script name from another repo: The registry is authoritative.
12
-
13
- ## Invocation rules
14
-
15
- - Use `nmr <command>` for anything nmr provides. Do not use `pnpm run <command>`.
16
- - You can invoke nmr from the monorepo root or any workspace package.
17
-
18
- ### How to make `nmr` resolvable
19
-
20
- `nmr` ships as a workspace bin. The bare `nmr` command works only when your shell can find `<root>/node_modules/.bin/nmr`. Choose one:
21
-
22
- - **direnv** (recommended for contributors). With [direnv](https://direnv.net/) installed, the repo's `.envrc` adds `node_modules/.bin` to your `PATH` automatically. From any subdirectory, bare `nmr` works.
23
- - **`pnpm exec nmr <command>`**: Works without setup. pnpm resolves the bin from the workspace root.
24
-
25
- Avoid `npx nmr`. Inside git worktrees, `npx` can resolve a different nmr binary from outside the working tree.
26
-
27
- ## Root vs. workspace context
28
-
29
- nmr walks up to find `pnpm-workspace.yaml`, then decides which registry to use based on whether your cwd is inside a workspace package. The same command name (e.g. `build`, `test`, `check:strict`) often exists in both registries with different behavior; the root version typically delegates across all workspaces. Use `-w` to force the root registry from inside a package dir, and `-F <pkg>` to run a single package's script from anywhere.
30
-
31
- ## Composite scripts
32
-
33
- A script value shown in `nmr` output as `[a, b, c]` is a composite: it runs `nmr a && nmr b && nmr c`, stopping at the first failure. Composites can reference other composites.
34
-
35
- ## `root:*` siblings
36
-
37
- Some root scripts (e.g. `lint`, `typecheck`, `test`) expand to `nmr root:X && pnpm --recursive exec nmr X`. The `root:X` variant runs only against root-level files; the plain name runs everywhere. Use `root:X` directly when you want to isolate a failure to the root code.
38
-
39
- ## Managed build
40
-
41
- The default `compile` script runs `nmr-compile`, a standalone bin that uses the TypeScript compiler API to emit a package's `src` to `dist/esm` as `.js` and `.d.ts` in one pass, rewriting relative `.ts`→`.js` specifiers and tsconfig `paths` aliases in both outputs, and skipping work when inputs are unchanged. `typescript` is a peer dependency (`>=5.7.0 <7`; TypeScript 7 ships no compiler API). There is no repo-local build script to maintain, and no separate typings step; `nmr build` runs `compile` alone. To find or debug the build, look to `nmr-compile`, not a `config/build.ts` in the consuming repo.
42
-
43
- ## Dependency upgrades
44
-
45
- `nmr upgrade` reports available dependency upgrades, honoring the version ceilings the repo declares in its root `taze.config.ts`. Scope follows context: from the root it covers the root `package.json` and every workspace in one pass; from inside a package, or under `nmr -F <package> upgrade`, it covers that package. `nmr root:upgrade` covers the root `package.json` alone. Run the root-context commands from the monorepo root.
46
-
47
- There are no `outdated` or `update` commands; `upgrade` replaced them. Reach for `pnpm outdated` or `pnpm update` directly if you need a report that ignores the ceilings.
48
-
49
- Arguments pass through to the underlying tool, including the range mode: `nmr upgrade major` proposes major upgrades, still inside the ceilings. Every form above is report-only until you add `--write`.
50
-
51
- **`-w` is not the same on both sides of the command.** `nmr upgrade -w` passes `--write` through and rewrites `package.json`; `nmr -w upgrade` is nmr's own `--workspace-root` and writes nothing. Use the long forms.
52
-
53
- To change what a repo holds back, edit its `taze.config.ts`. It imports `defineConfig` from `@williamthorsen/nmr/taze`, which supplies the shared upgrade policy — so that file should carry only the ceilings specific to that repo, and the repo needs no dependency on the upgrade tool itself.
54
-
55
- ## Override behaviors
56
-
57
- In `.config/nmr.config.ts` or a package's `package.json`, override values have special semantics:
58
-
59
- - `""` (empty string): Skip the script with a "Skipping" message; exit 0.
60
- - `":"`: No-op; exit 0. Prefer this over `""` if your repo enforces non-empty script values.
61
- - Any other string: Runs in place of the default.
62
-
63
- ## Pre and post hooks
64
-
65
- Every `nmr X` invocation auto-wraps as the equivalent of `nmr X:pre && nmr X && nmr X:post`. Hooks are first-class scripts that resolve through the same 3-tier registry (built-in defaults → `.config/nmr.config.ts` → per-package `package.json`). Wrapping is uniform; nested invocations from composite expansion get their own hook treatment. Hook failure short-circuits the chain via shell `&&` semantics, propagating the failing exit code.
66
-
67
- Behaviors worth knowing:
68
-
69
- - **Silent when absent**: Missing hooks produce no error and no output.
70
- - **Skip overrides apply to hooks**: A hook value of `""` or `":"` is treated the same as not defining the hook. No console message.
71
- - **Skipping the main command skips its hooks**: When `X` is overridden to `""` or `":"`, neither `X:pre` nor `X:post` fires.
72
- - **Recursion guard**: Direct invocation of a hook (e.g., `nmr build:pre`) is treated as a leaf operation. It does NOT itself attempt to resolve `build:pre:pre` or `build:pre:post`.
73
- - **Passthrough args attach only to the main command**: `nmr X --flag value` runs hooks without `--flag value`.
74
-
75
- Worked examples:
76
-
77
- ```ts
78
- // .config/nmr.config.ts — extend `nmr build` with a pre-build compile step
79
- import { defineConfig } from '@williamthorsen/nmr';
80
-
81
- export default defineConfig({
82
- workspaceScripts: {
83
- 'build:pre': 'npx rdy compile',
84
- },
85
- });
86
- ```
87
-
88
- ```jsonc
89
- // packages/nmr/package.json — re-stamp .agents/nmr/AGENTS.md after every build
90
- {
91
- "scripts": {
92
- "build:post": "nmr-sync-agent-files",
93
- },
94
- }
95
- ```
96
-
97
- The second example calls the bin directly to sidestep the workspace-vs-root registry distinction.
98
-
99
- ## Agent-file sync
100
-
101
- The presence and version stamp of `.agents/nmr/AGENTS.md` is verified by `check:agent-files`, which is part of the default root `check:strict` composite. If it fails, run `nmr sync-agent-files`.
7
+ - Use `nmr <command>`, not `pnpm run <command>`, for anything nmr provides. Run bare `nmr` to list every command and the shell command it resolves to; a wrong guess reports only `Unknown command`, with no list.
8
+ - Scope follows cwd, and bare `nmr` lists both registries: from the repo root a command covers root files and every workspace; from inside a package, that package alone. `nmr -F <pkg> <command>` targets one package from anywhere; `nmr root:<command>` targets root files alone, which isolates a failure to root code.
9
+ - Never `npx nmr`: inside a git worktree it can resolve a different nmr from outside the tree. Fall back to `pnpm exec nmr`.
10
+ - 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`), and the `nmr-compile` build (there is no repo-local build script).