supercov 0.0.42 → 0.0.44

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 (47) hide show
  1. package/README.md +23 -3
  2. package/analyzers/typescript/README.md +59 -0
  3. package/analyzers/typescript/bin/compiler-identity.mjs +78 -0
  4. package/analyzers/typescript/bin/identity.mjs +71 -0
  5. package/analyzers/typescript/bin/query.mjs +29 -0
  6. package/analyzers/typescript/dist/analyze.js +5273 -0
  7. package/analyzers/typescript/dist/archive.js +337 -0
  8. package/analyzers/typescript/dist/awaited-observations.js +376 -0
  9. package/analyzers/typescript/dist/build-identity.json +1 -0
  10. package/analyzers/typescript/dist/compiler.js +32 -0
  11. package/analyzers/typescript/dist/frontend.js +75 -0
  12. package/analyzers/typescript/dist/mock-counts.js +2517 -0
  13. package/analyzers/typescript/dist/native-frontend.js +271 -0
  14. package/analyzers/typescript/dist/pragmas.js +186 -0
  15. package/analyzers/typescript/dist/types.js +1 -0
  16. package/analyzers/typescript/package.json +27 -0
  17. package/analyzers/typescript/src/analyze.ts +6180 -0
  18. package/analyzers/typescript/src/archive.ts +471 -0
  19. package/analyzers/typescript/src/awaited-observations.ts +561 -0
  20. package/analyzers/typescript/src/compiler.ts +49 -0
  21. package/analyzers/typescript/src/frontend.ts +136 -0
  22. package/analyzers/typescript/src/mock-counts.ts +3219 -0
  23. package/analyzers/typescript/src/native-frontend.ts +315 -0
  24. package/analyzers/typescript/src/pragmas.ts +284 -0
  25. package/analyzers/typescript/src/types.ts +45 -0
  26. package/analyzers/typescript/tsconfig.json +12 -0
  27. package/docs/agent-loop.md +129 -31
  28. package/docs/assertion-evidence.md +694 -0
  29. package/docs/cli.md +25 -15
  30. package/docs/code-verification.md +4 -0
  31. package/docs/coverage-model.md +6 -6
  32. package/docs/evidence.md +6 -6
  33. package/docs/getting-started.md +60 -72
  34. package/docs/performance.md +4 -4
  35. package/docs/supported-suites.md +40 -9
  36. package/docs/troubleshooting.md +8 -8
  37. package/docs/verification.md +14 -2
  38. package/docs/workspace-isolation.md +1 -1
  39. package/package.json +35 -15
  40. package/runtime/javascript/jest.cjs +134 -0
  41. package/runtime/javascript/jest.config.mjs +39 -0
  42. package/runtime/javascript/jestReporter.mjs +77 -0
  43. package/runtime/javascript/nodeAssertAdapter.mjs +32 -8
  44. package/runtime/javascript/nodeTest.mjs +13 -5
  45. package/runtime/javascript/register.mjs +22 -4
  46. package/runtime/javascript/runnerEvidence.mjs +33 -11
  47. package/runtime/javascript/runtime.mjs +73 -16
@@ -1,41 +1,33 @@
1
1
  # Agent workflow
2
2
 
3
- Supercov works best as a small, repeatable loop: run the suite, choose one useful
4
- gap, write one test, rerun, and prove what improved.
3
+ Use Supercov with your coding agent and the test suite you already have.
4
+ Supercov reports coverage and gaps. Your agent writes a test, reruns the suite,
5
+ and checks what improved.
5
6
 
6
- ```text
7
- run the suite → choose a gap → write one test → rerun → compare
8
- ↑ |
9
- └────────────────────────────────────────────────────────────┘
10
- ```
11
-
12
- Supercov supplies the coverage signal and evidence. Your coding agent writes
13
- the tests.
14
-
15
- ## Choose the job
7
+ ## Start with one test
16
8
 
17
- For one careful first pass, ask:
9
+ Open your own repository in your coding agent and paste this prompt. You don't
10
+ need to install Supercov first; the agent can handle that.
18
11
 
19
- ```text
20
- Measure code coverage with `npx supercov` and write the first useful test based
21
- on coverage. Only edit tests. Rerun the complete suite and report what improved.
12
+ ```text supercov-prompt
13
+ Measure code coverage with npx supercov and write one missing test.
14
+ Only change tests. Rerun the full test suite and show me the test you
15
+ added and the before-and-after coverage.
22
16
  ```
23
17
 
24
- For an overnight run or leftover token budget, ask:
18
+ If the project has several test commands, tell the agent which full suite to
19
+ use. Let it run the commands and edit the tests, approving those actions if
20
+ your agent asks.
25
21
 
26
- ```text
27
- Use `npx supercov` to improve coverage. Only write tests. Keep going while
28
- useful gaps remain. Never weaken assertions or change application code to make
29
- coverage easier. Stop at a measurement limit, unreachable behavior, or the end
30
- of the available time budget. Report the run ids compared and what improved.
31
- ```
32
-
33
- The second prompt is intentionally open-ended, but 100% is a direction rather
34
- than permission to write meaningless tests or reshape application code.
22
+ The result is a normal test-file change and a coverage comparison in the
23
+ conversation. Ask separately if you want a commit or pull request.
35
24
 
36
25
  ## One safe pass
37
26
 
38
- ```sh
27
+ The agent should run the suite, inspect a gap, write a test, then rerun the
28
+ same suite and compare. These are the commands it can use:
29
+
30
+ ```sh supercov-example
39
31
  # 1. Establish a baseline.
40
32
  npx supercov -- npm test
41
33
 
@@ -52,16 +44,122 @@ npx supercov -- npm test
52
44
  npx supercov diff <previous-run-id> latest
53
45
  ```
54
46
 
55
- For Rust, use `cargo test` or `cargo nextest run` in both runs. Keep the baseline
56
- and verification commands identical.
47
+ Everything after `--` is your project's test command. Use your actual command
48
+ and file paths in place of the examples. For example,
49
+ Rust projects can use `cargo test`, Python projects `pytest`, and Ruby projects
50
+ `bundle exec rspec`. Keep the baseline and verification commands identical.
57
51
 
58
52
  The `line` query is useful before writing a test because it shows which tests
59
53
  already reach that line. Extending a nearby test is often better than adding a
60
54
  duplicate.
61
55
 
62
- ## A complete prompt for longer runs
56
+ For supported JS/TS projects, inspect assertion evidence before adding tests:
57
+
58
+ ```sh
59
+ npx supercov runs latest assertions --file app/checkout/session.ts --limit 5 --json
60
+ npx supercov runs latest assertions --pragmas --json
61
+ ```
62
+
63
+ This post-run query needs the matching source and a compatible
64
+ project TypeScript API. An `evident` candidate is not a proof of safety; keep
65
+ test gaps separate from analysis limits. Follow the returned evidence pointers
66
+ and `pagination.nextOffset`, pinning `--analysis` and the run id while paging.
67
+ See [assertion evidence](assertion-evidence.md) for requirements and examples.
68
+
69
+ ## Example
70
+
71
+ Here's a recorded Codex run in a JavaScript project, using the first prompt.
72
+ The files are from our checkout example; you don't need to add them to your
73
+ project.
74
+
75
+ [`src/session.js`](https://github.com/supercorp-ai/supercov/blob/main/examples/checkout-verification/starter/src/session.js)
76
+ allows checkout only when the customer is signed in and their session has
77
+ not expired:
78
+
79
+ ```js
80
+ export function canCheckout(signedIn, expired) {
81
+ if (signedIn && !expired) return true;
82
+ return false;
83
+ }
84
+ ```
85
+
86
+ The two tests in
87
+ [`tests/session.test.js`](https://github.com/supercorp-ai/supercov/blob/main/examples/checkout-verification/starter/tests/session.test.js)
88
+ check a valid session and a signed-out visitor:
89
+
90
+ ```js
91
+ assert.equal(canCheckout(true, false), true);
92
+ assert.equal(canCheckout(false, false), false);
93
+ ```
94
+
95
+ The agent ran `npx supercov -- npm test`. Both tests passed, and the summary
96
+ from `npx supercov runs latest` showed:
63
97
 
64
98
  ```text
99
+ Coverage
100
+ Lines 100.00% (3/3)
101
+ Branches 100.00% (2/2)
102
+ MC/DC 50.00% (1/2)
103
+ ```
104
+
105
+ It listed the gaps and inspected the file. You can open those views with:
106
+
107
+ ```sh
108
+ npx supercov runs latest gaps
109
+ npx supercov runs latest file src/session.js
110
+ ```
111
+
112
+ The file query explained the gap:
113
+
114
+ ```text
115
+ LINE STATUS SOURCE
116
+ 2 PARTIAL signedIn && !expired
117
+ Unobserved: no witness pair shows `!expired` independently changing the decision result
118
+ ```
119
+
120
+ Both return paths had run, but neither test checked an expired session. MC/DC
121
+ checks whether each condition has been shown to affect the decision
122
+ independently. Here, `signedIn` had; `!expired` had not.
123
+
124
+ The agent added one test to `tests/session.test.js`, leaving the application
125
+ code and existing tests unchanged:
126
+
127
+ ```js
128
+ test('a signed-in visitor with an expired session cannot check out', () => {
129
+ assert.equal(canCheckout(true, true), false);
130
+ });
131
+ ```
132
+
133
+ It reran the same full suite. All three tests passed, and MC/DC reached 100%.
134
+ The comparison from `npx supercov diff <before-run-id> latest` showed:
135
+
136
+ ```text
137
+ lines +0pp, branches +0pp, MC/DC +50pp
138
+ gained: 0 lines, 0 branches, 1 MC/DC conditions
139
+ lost: 0 lines, 0 branches, 0 MC/DC conditions
140
+ + MC/DC src/session.js:2 C2 !expired
141
+ ```
142
+
143
+ The new assertion checks that checkout is denied when a signed-in customer's
144
+ session has expired. Removing the expiry check makes this test fail; the
145
+ original two tests still pass.
146
+
147
+ In your project, look for the same evidence: the test checks the behavior the
148
+ agent identified, and the full suite passes. One useful test won't necessarily
149
+ take coverage to 100%.
150
+
151
+ To try these exact files, [download the starter](https://supercov.com/downloads/supercov-tutorial.zip),
152
+ extract it, open the `supercov-tutorial` folder in your agent, and run `npm ci`.
153
+ Then use the JavaScript prompt above. The completed test is not included in the
154
+ download. The [recorded run](https://github.com/supercorp-ai/supercov/tree/main/examples/checkout-verification/agent-run)
155
+ includes the commands, full output, and completed test.
156
+
157
+ ## A complete prompt for longer runs
158
+
159
+ Once you've reviewed the first test, use this prompt to continue through
160
+ useful gaps—for example, during an overnight run:
161
+
162
+ ```text supercov-prompt
65
163
  Use `npx supercov` to improve coverage. Only write tests. Keep going while
66
164
  useful gaps remain.
67
165
 
@@ -97,7 +195,7 @@ reason to manufacture a test.
97
195
 
98
196
  If the repository separates test levels, narrow the view:
99
197
 
100
- ```sh
198
+ ```sh supercov
101
199
  npx supercov runs latest gaps --kind e2e --limit 10
102
200
  ```
103
201