@cosyte/vitest-config 0.0.3 → 0.1.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 (3) hide show
  1. package/CHANGELOG.md +42 -3
  2. package/README.md +113 -16
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,20 +2,59 @@
2
2
 
3
3
  All notable changes to `@cosyte/vitest-config` are documented here, following
4
4
  [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). Versions are managed with Changesets;
5
- this file is hand-maintained. The package stays on the **`0.0.x`-until-first-alpha** ladder.
5
+ this file is hand-maintained (Changesets' own changelog generation is disabled). The package is on the
6
+ **`0.1.x`** line: its surface is settled, and bump types follow ordinary semver rather than a
7
+ pre-alpha rule. See
8
+ [ADR 0002](../../documentation/decisions/0002-the-0-1-0-version-line.md).
9
+
10
+ > Because the generator is disabled, **`[Unreleased]` is promoted to a version heading BY HAND**, in
11
+ > the pull request that adds the changeset. Nothing does it automatically. Until 2026-08-04 nothing
12
+ > did it at all, so shipped content stayed under `[Unreleased]` and every release republished it.
6
13
 
7
14
  ## [Unreleased]
8
15
 
16
+ ## [0.1.0] - Unreleased
17
+
18
+ ### Changed
19
+
20
+ - **The package leaves the pre-alpha version ladder for the `0.1.x` line.** No config or behaviour
21
+ change: `cosyteVitest(opts)`, its coverage thresholds, its peer ranges and the `./snippets`
22
+ doc-agreement harness are byte-identical to `0.0.4`. What moves is the version policy this package
23
+ states about itself, and the reasoning is in
24
+ [ADR 0002](../../documentation/decisions/0002-the-0-1-0-version-line.md). A consumer pinned at
25
+ `^0.0.4` does not resolve this release and has to widen its range once.
26
+ - The `README.md` in the tarball now opens its `## Status` section on the settled-line sentence
27
+ instead of the pre-alpha ladder one, so the policy text a consumer reads agrees with the version
28
+ printed beside it. `scripts/readme-check.mjs` grades that sentence against the release line the
29
+ pending changesets resolve to. Its "still moving" note is rewritten to match: the parts that are
30
+ settled are now described as settled, and a change to one is recorded with the bump type it
31
+ deserves.
32
+ - The `0.0.4` section below was relabelled: its content had shipped and was still sitting under
33
+ `[Unreleased]`, which is the same defect the note above describes, recurring one release after it
34
+ was written down. That relabelling changes only the `CHANGELOG.md` inside the published tarball.
35
+
36
+ ## [0.0.4] - 2026-08-04
37
+
38
+ ### Changed
39
+
40
+ - The sections below were relabelled: content that had already shipped was still sitting under
41
+ `[Unreleased]`, so each release republished it. Every section now carries the version it shipped
42
+ in. No config or behaviour change; the `CHANGELOG.md` inside the published tarball is the only
43
+ thing that differs.
44
+
45
+ ## [0.0.3] - 2026-07-31
46
+
9
47
  ### Changed
10
48
 
11
49
  - Documentation and source comments no longer use em dashes, in line with the cosyte brand
12
50
  voice. No config or behaviour change.
13
51
 
52
+ ## [0.0.2] - 2026-07-15
53
+
14
54
  ### Added
15
55
 
16
56
  - Declared `vite` (`^6 || ^7 || ^8`) as a peer dependency. Vitest 4 requires vite >= 6, and the
17
- resolver otherwise keeps an incompatible vite 5 (missing the `./module-runner` export). _(Added after
18
- `0.0.1` published; ships in the next release.)_
57
+ resolver otherwise keeps an incompatible vite 5 (missing the `./module-runner` export).
19
58
  - **Doc/code-agreement harness** on a new `@cosyte/vitest-config/snippets` subpath: `docSnippetSuite()`
20
59
  plus the factored primitives (`extractRunnableSnippets`, `rewriteAssertions`, `remapImports`,
21
60
  `runSnippet`). It extracts every fenced ` ```ts runnable ` block from a package's `docs-content/`,
package/README.md CHANGED
@@ -1,8 +1,40 @@
1
+ <a href="https://cosyte.com">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://cosyte.com/tile/cosyte-lockup-tile-on-dark-1200x300.png">
4
+ <img alt="The Cosyte logo on its own white ground: the icon beside the word Cosyte." src="https://cosyte.com/tile/cosyte-lockup-tile-on-light-1200x300.png">
5
+ </picture>
6
+ </a>
7
+
1
8
  # @cosyte/vitest-config
2
9
 
3
- Shared [Vitest](https://vitest.dev) config for the `@cosyte/*` packages: v8 coverage with
4
- `text` / `html` / `lcov` reporters, the standard excludes (barrels, fixtures, generated code,
5
- declarations), and **enabled, gating** per-directory thresholds at **>= 90**.
10
+ > Gating coverage thresholds by default, plus a suite that runs the examples in your docs.
11
+
12
+ [![npm version](https://img.shields.io/npm/v/@cosyte/vitest-config.svg)](https://www.npmjs.com/package/@cosyte/vitest-config)
13
+ [![CI](https://img.shields.io/github/actions/workflow/status/cosyte/config/ci.yml?branch=main&label=CI)](https://github.com/cosyte/config/actions/workflows/ci.yml)
14
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/cosyte/config/blob/main/LICENSE)
15
+ [![Node](https://img.shields.io/badge/node-%3E%3D22.14-brightgreen.svg)](https://nodejs.org)
16
+
17
+ Shared Vitest config (v8 coverage, per-directory >=90 gates) for @cosyte/\* packages.
18
+
19
+ ## Why this exists
20
+
21
+ Coverage that is reported but not gated is a number nobody acts on, and a repo-wide threshold hides
22
+ the one directory that has none: a package can sit at 92% overall while its serializer is at 40%.
23
+ The cosyte baseline gates per directory, and it ships enabled rather than as a setting each repo
24
+ remembers to switch on.
25
+
26
+ The nearest alternative is a hand-written `vitest.config.ts` per repository with `coverage.thresholds`
27
+ copied in. That is the drift this removes, and it is also where the second half of this package comes
28
+ from: nothing in that alternative proves the examples in your documentation still work.
29
+
30
+ ## Status
31
+
32
+ `@cosyte/vitest-config` is on the cosyte 0.1.x line: the public API is settled and bump types follow ordinary semver.
33
+
34
+ Still moving: the coverage exclude list and the snippet-suite options (`runnableTag`, `resolve`,
35
+ `requireSnippet`), which have changed shape as the first consumers adopted them. The 90 threshold and
36
+ the `cosyteVitest(options)` signature are the settled parts, and a change to either is recorded with
37
+ the bump type it deserves rather than absorbed into a patch.
6
38
 
7
39
  ## Install
8
40
 
@@ -10,26 +42,81 @@ declarations), and **enabled, gating** per-directory thresholds at **>= 90**.
10
42
  pnpm add -D @cosyte/vitest-config vitest @vitest/coverage-v8 vite
11
43
  ```
12
44
 
13
- `vitest`, `@vitest/coverage-v8`, and `vite` are peer dependencies (Vitest 4 needs `vite` >= 6: install
14
- it explicitly so the resolver doesn't keep an incompatible vite 5).
45
+ `vitest`, `@vitest/coverage-v8`, and `vite` are peer dependencies. Install `vite` explicitly:
46
+ Vitest 4 requires major version 6 or later, and without a direct declaration the resolver will
47
+ happily keep an incompatible vite 5. Node `>=22.14`. ESM only.
15
48
 
16
- ## Use
49
+ ## Usage
17
50
 
18
- `vitest.config.ts`:
51
+ `vitest.config.ts` exports what the factory returns:
19
52
 
20
- ```ts
53
+ ```ts runnable
21
54
  import { cosyteVitest } from "@cosyte/vitest-config";
22
55
 
23
- export default cosyteVitest({
24
- coverageDirs: ["parser", "model", "serialize", "helpers"],
25
- });
56
+ const { thresholds } = cosyteVitest({ coverageDirs: ["parser", "model"] }).test.coverage;
57
+ thresholds.lines; // => 90
58
+ thresholds["src/parser/**"].lines; // => 90
26
59
  ```
27
60
 
28
61
  Each entry in `coverageDirs` adds a per-directory `src/<dir>/**` gate at >= 90 on top of the global
29
- gate. Use `coverageThresholds` to add or override specific keys, and `test` for any other Vitest
30
- options.
62
+ gate, which is what stops a well-covered helper directory paying for an untested parser.
63
+
64
+ ## Entry points
31
65
 
32
- ## Doc/code agreement: `@cosyte/vitest-config/snippets`
66
+ | entry point | what it is |
67
+ | -------------------------------- | ------------------------------------------------------------------- |
68
+ | `@cosyte/vitest-config` | the `cosyteVitest(opts?)` factory, returning a Vitest config object |
69
+ | `@cosyte/vitest-config/snippets` | the doc/code-agreement harness described under the API below |
70
+
71
+ They are separate subpaths because they are separately adoptable, and importing the config never
72
+ loads the harness. `extractRunnableSnippets` is the primitive that decides what runs, and it reports
73
+ each block's 1-based first code line so a failure points at the snippet rather than at the fence:
74
+
75
+ ```ts runnable
76
+ import { extractRunnableSnippets } from "@cosyte/vitest-config/snippets";
77
+
78
+ const fence = "`".repeat(3);
79
+ const doc = ["# Title", "", fence + "ts runnable", "const dose = 5;", fence].join("\n");
80
+ extractRunnableSnippets(doc).length; // => 1
81
+ extractRunnableSnippets(doc)[0].line; // => 4
82
+ ```
83
+
84
+ ## Overrides
85
+
86
+ Both entry points are configured entirely through their arguments, and neither enforces anything a
87
+ consumer cannot reach:
88
+
89
+ - `cosyteVitest` takes `coverageThresholds` to add or override specific coverage keys, and `test`
90
+ for any other Vitest option. Both are merged last, so a repo that genuinely cannot hold >= 90 in
91
+ one directory lowers that one key rather than abandoning the config.
92
+ - `docSnippetSuite` takes `docsDir` or `files`, `include` (default `.md` and `.mdx`), `resolve`,
93
+ `runnableTag` (default `"runnable"`), `name`, `requireSnippet` and `tmpDir`.
94
+
95
+ A package with no runnable snippets yields an empty, passing suite unless `requireSnippet` is set:
96
+ absence degrades quietly, a _wrong_ snippet fails loudly. Lowering a coverage threshold is the
97
+ override worth arguing about in review, because unlike the others it changes what CI will let
98
+ through.
99
+
100
+ ## PHI and safety
101
+
102
+ This package is test configuration. It processes no patient data: it configures a test runner and,
103
+ through `/snippets`, compiles and executes the code blocks you point it at.
104
+
105
+ Two consequences worth stating plainly, because `/snippets` does run code. It executes the snippets
106
+ in your own documentation, in your own process, so a documentation example must never contain real
107
+ patient data: it would then be executed, and it is already committed. And the transient module
108
+ `runSnippet` writes is written under your project root, so a snippet's inputs land on disk exactly as
109
+ a test fixture's would. Use synthetic data in documentation, as in tests.
110
+
111
+ ## API
112
+
113
+ ### `cosyteVitest(options)`
114
+
115
+ The baseline config: v8 coverage with `text` / `html` / `lcov` reporters, the standard excludes
116
+ (barrels, fixtures, generated code, declarations), and **enabled, gating** per-directory thresholds
117
+ at **>= 90**.
118
+
119
+ ### Doc/code agreement: `@cosyte/vitest-config/snippets`
33
120
 
34
121
  The `/snippets` subpath is the **documentation analog of the conformance runners**: it proves the
35
122
  examples in a package's `docs-content/` still do what the prose claims. A copy-pasteable snippet that
@@ -76,5 +163,15 @@ are exported too, for bespoke wiring.
76
163
  > project root) and imports it so Vitest transforms the TypeScript: add `.cosyte-doc-snippets*/` to
77
164
  > `.gitignore`. It must stay inside the project root; files under `node_modules` are not transformed.
78
165
 
79
- Part of [cosyte/config](https://github.com/cosyte/config), one enforced toolchain for the `@cosyte/*`
80
- suite.
166
+ ## Contributing
167
+
168
+ Questions, bug reports and proposals go to
169
+ [the issue tracker](https://github.com/cosyte/config/issues). Pull requests are welcome, in
170
+ [cosyte/config](https://github.com/cosyte/config), where this package lives.
171
+
172
+ A change has to clear the required `verify` job, and a change to the thresholds or the excludes needs
173
+ a changeset saying what moved: it can red a consumer that was passing.
174
+
175
+ ## License
176
+
177
+ MIT, copyright Cosyte. See [LICENSE](https://github.com/cosyte/config/blob/main/LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosyte/vitest-config",
3
- "version": "0.0.3",
3
+ "version": "0.1.0",
4
4
  "description": "Shared Vitest config (v8 coverage, per-directory >=90 gates) for @cosyte/* packages.",
5
5
  "keywords": [
6
6
  "vitest",