proofed-cli 0.1.3 → 0.2.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.
- package/README.md +176 -122
- package/dist/action/requests.js +130 -0
- package/dist/{server.js → action/server.js} +17 -3
- package/dist/changes.js +7 -1
- package/dist/{args.js → check/args.js} +31 -3
- package/dist/check/cache.js +89 -0
- package/dist/{check.js → check/check.js} +86 -40
- package/dist/{doctor.js → check/doctor.js} +55 -19
- package/dist/check/help.js +139 -0
- package/dist/{list.js → check/list.js} +27 -15
- package/dist/{pipeline.js → check/pipeline.js} +106 -68
- package/dist/{render.js → check/render.js} +22 -15
- package/dist/check/run.js +277 -0
- package/dist/check/targetfilter.js +10 -0
- package/dist/check/textcheck.js +162 -0
- package/dist/env.js +6 -0
- package/dist/fix/agent.js +21 -0
- package/dist/fix/claude.js +30 -0
- package/dist/fix/codex.js +71 -0
- package/dist/fix/fixsetup.js +76 -0
- package/dist/fix/fixtarget.js +48 -0
- package/dist/fix/models.js +67 -0
- package/dist/github.js +62 -14
- package/dist/integrations/claude-stop.js +104 -0
- package/dist/integrations/cli.js +63 -0
- package/dist/integrations/mcp.js +130 -0
- package/dist/kane/creditmeter.js +104 -0
- package/dist/kane/kane.js +131 -0
- package/dist/kane/kaneauth.js +84 -0
- package/dist/kane/kaneversion.js +13 -0
- package/dist/paths.js +32 -0
- package/dist/process.js +65 -0
- package/dist/proofed.js +34 -16
- package/dist/{live.js → report/live.js} +1 -1
- package/dist/{livefile.js → report/livefile.js} +1 -1
- package/dist/{report.js → report/report.js} +105 -125
- package/dist/report/reportdata.js +120 -0
- package/dist/{result.js → report/result.js} +12 -7
- package/dist/{runfile.js → report/runfile.js} +2 -2
- package/dist/report/runresult.js +5 -0
- package/dist/scenarios.js +41 -19
- package/dist/secrets.js +74 -0
- package/dist/{cdp.js → targets/cdp.js} +20 -6
- package/dist/targets/chrome.js +98 -0
- package/dist/{clip.js → targets/clip.js} +21 -11
- package/dist/{precheck.js → targets/precheck.js} +53 -20
- package/dist/targets/preparetarget.js +350 -0
- package/dist/{recorder.js → targets/recorder.js} +154 -19
- package/dist/{serve.js → targets/serve.js} +9 -13
- package/dist/{target.js → targets/target.js} +42 -7
- package/dist/targets/targetchecks.js +139 -0
- package/dist/timing.js +25 -0
- package/dist/types.js +1 -0
- package/dist/which.js +26 -13
- package/docs/cli.md +370 -0
- package/package.json +10 -5
- package/dist/cache.js +0 -48
- package/dist/chrome.js +0 -77
- package/dist/help.js +0 -133
- package/dist/kane.js +0 -75
- package/dist/kaneauth.js +0 -48
- package/dist/models.js +0 -44
- package/dist/requests.js +0 -58
- package/dist/run.js +0 -173
- /package/dist/{deps.js → targets/deps.js} +0 -0
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<img src="site/public/favicon.svg" width="64" alt="">
|
|
3
|
+
<img src="https://raw.githubusercontent.com/t1dem/proofed/main/site/public/favicon.svg" width="64" alt="">
|
|
4
4
|
|
|
5
5
|
# Proofed
|
|
6
6
|
|
|
7
|
-
**
|
|
7
|
+
**Check the user flows a pull request touches before you merge it.**
|
|
8
8
|
|
|
9
|
-
Kane CLI runs the user flows a pull request touches
|
|
10
|
-
When a flow breaks, Claude Code fixes it, and the fix is pushed only after Kane has watched it pass.
|
|
9
|
+
Kane CLI runs the user flows a pull request touches. Proofed posts local recordings or cloud recording notes on the PR.<br>
|
|
10
|
+
When a flow breaks, Claude Code or OpenAI Codex fixes it, and the fix is pushed only after Kane has watched it pass.
|
|
11
11
|
|
|
12
|
-
[**Break it yourself**](https://proofed.neptunescodm.workers.dev/try) · [Dashboard demo](https://proofed.neptunescodm.workers.dev/app?demo) · [
|
|
12
|
+
[Website](https://proofed.neptunescodm.workers.dev) · [**Break it yourself**](https://proofed.neptunescodm.workers.dev/try) · [Dashboard demo](https://proofed.neptunescodm.workers.dev/app?demo) · [Install on GitHub](https://proofed.neptunescodm.workers.dev/install) · [CLI](#locally-and-from-an-ai-agent)
|
|
13
13
|
|
|
14
14
|
<sub>Built for the Kane CLI hackathon, November 2026.</sub>
|
|
15
15
|
|
|
16
16
|
<br>
|
|
17
17
|
|
|
18
|
-
<img src="docs/devices.png" width="880" alt="The Proofed dashboard in a browser and on a phone: pull requests grouped into Needs you, Kane is checking, Claude is fixing and Passed">
|
|
18
|
+
<img src="https://raw.githubusercontent.com/t1dem/proofed/main/docs/devices.png" width="880" alt="The Proofed dashboard in a browser and on a phone: pull requests grouped into Needs you, Kane is checking, Claude is fixing and Passed">
|
|
19
19
|
|
|
20
20
|
</div>
|
|
21
21
|
|
|
@@ -40,13 +40,7 @@ When a flow breaks, Claude Code fixes it, and the fix is pushed only after Kane
|
|
|
40
40
|
|
|
41
41
|
## For judges
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
- **[Dashboard demo](https://proofed.neptunescodm.workers.dev/app?demo)**, no sign-in. `sample-coffee-store` in it is made up and labelled "Sample data"; the rest is copied from GitHub.
|
|
45
|
-
- **Proofed checks itself.** Every pull request here runs five dashboard scenarios through Kane, for example [#25](https://github.com/t1dem/proofed/pull/25#issuecomment-6897255024).
|
|
46
|
-
|
|
47
|
-
<img src="docs/try-run.jpg" alt="A finished run on /try: Kane caught a break, Claude fixed it, Kane confirmed. The fix and a before and after comparison of the page.">
|
|
48
|
-
|
|
49
|
-
If you'd rather read than wait, all four changes have already run:
|
|
43
|
+
Four pull requests on the [demo store](https://github.com/t1dem/proofed-demo-store) each break one flow. All four have already run:
|
|
50
44
|
|
|
51
45
|
| PR | What Kane found | What happened next |
|
|
52
46
|
|---|---|---|
|
|
@@ -55,18 +49,52 @@ If you'd rather read than wait, all four changes have already run:
|
|
|
55
49
|
| [#11](https://github.com/t1dem/proofed-demo-store/pull/11) | The + button in the bag leaves the quantity at 1 | Fixed on the first attempt ([`9999a0d`](https://github.com/t1dem/proofed-demo-store/commit/9999a0d)), 8.5 minutes |
|
|
56
50
|
| [#12](https://github.com/t1dem/proofed-demo-store/pull/12) | A €44.50 bag ships free | Fixed on the first attempt ([`f54f1b5`](https://github.com/t1dem/proofed-demo-store/commit/f54f1b5)), 8.5 minutes |
|
|
57
51
|
|
|
52
|
+
To watch one run live, open [Break it yourself](https://proofed.neptunescodm.workers.dev/try). It needs no account and takes 8 to 14 minutes.
|
|
53
|
+
|
|
54
|
+
<img src="https://raw.githubusercontent.com/t1dem/proofed/main/docs/try-run.jpg" alt="A finished run on /try: Kane caught a break, Claude fixed it, Kane confirmed. The fix and a before and after comparison of the page.">
|
|
55
|
+
|
|
56
|
+
To run Proofed on your machine, with a signed-in [Kane CLI](https://www.npmjs.com/package/@testmuai/kane-cli), Node 22.18+, Chrome, ffmpeg and pnpm (`npm install -g pnpm`):
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
git clone https://github.com/t1dem/proofed-demo-store
|
|
60
|
+
cd proofed-demo-store
|
|
61
|
+
npx proofed-cli check "the promo code welcome10 takes 10% off"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The [dashboard demo](https://proofed.neptunescodm.workers.dev/app?demo) needs no sign-in. In [demo-store #11](https://github.com/t1dem/proofed-demo-store/pull/11#issuecomment-6897672103), Kane caught a broken quantity button, Claude fixed it, and Kane confirmed both affected scenarios passed. Proofed also checks its own pull requests.
|
|
65
|
+
|
|
66
|
+
### Bugs from real projects
|
|
67
|
+
|
|
68
|
+
Nine merged pull requests from open-source projects, each of which shipped a bug that was fixed upstream later. Each one is replayed in a copy of its repository with Proofed added. On every replay Kane caught the bug, Codex GPT-6.2 Sol at medium effort fixed it, and Kane checked the fix before it was pushed to the PR.
|
|
69
|
+
|
|
70
|
+
| Pull request | Target | What broke | Replay with Proofed | Fixed upstream |
|
|
71
|
+
|---|---|---|---|---|
|
|
72
|
+
| [omni-tools #32](https://github.com/iib0011/omni-tools/pull/32) | Web | The numbers 1, 2 and 4 on separate lines add up to 0 instead of 7 | [Caught, fixed on the first attempt](https://github.com/t1dem/omni-tools/pull/1) | [#428](https://github.com/iib0011/omni-tools/pull/428), 567 days later |
|
|
73
|
+
| [frontend-mini-challenges #264](https://github.com/sadanandpai/frontend-mini-challenges/pull/264) | Web | Delete leaves the todo item in the list | [Caught, fixed on the first attempt](https://github.com/t1dem/frontend-mini-challenges/pull/1) | [#338](https://github.com/sadanandpai/frontend-mini-challenges/pull/338), 28 days later |
|
|
74
|
+
| [Excalidraw #11974](https://github.com/excalidraw/excalidraw/pull/11974) | Web | The main menu stays open after a click on the canvas | [Caught, fixed on the first attempt](https://github.com/t1dem/excalidraw/pull/1) | [#12053](https://github.com/excalidraw/excalidraw/pull/12053), 12 days later |
|
|
75
|
+
| [OpenCalc #520](https://github.com/Darkempire78/OpenCalc/pull/520) | Android emulator | A decimal point typed into the first number of 2×0.5 is ignored | [Caught, fixed on the second attempt](https://github.com/t1dem/OpenCalc/pull/1) | [#538](https://github.com/Darkempire78/OpenCalc/pull/538), 81 days later |
|
|
76
|
+
| [Quillpad #396](https://github.com/quillpad/quillpad/pull/396) | Android emulator | Back in a note sends the app to the background instead of the notes list | [Caught, fixed on the first attempt](https://github.com/t1dem/quillpad/pull/1) | [#406](https://github.com/quillpad/quillpad/pull/406), 24 days later |
|
|
77
|
+
| [AnkiDroid #20889](https://github.com/ankidroid/Anki-Android/pull/20889) | Android emulator | A deck picked in the card browser search doesn't change the deck filter | [Caught, fixed on the first attempt](https://github.com/t1dem/Anki-Android/pull/1) | [#23110](https://github.com/ankidroid/Anki-Android/pull/23110), 180 days later |
|
|
78
|
+
| [Zettlr #6001](https://github.com/Zettlr/Zettlr/pull/6001) | Electron | A blank line between paragraphs loses its ¶ mark | [Caught, fixed on the first attempt](https://github.com/t1dem/Zettlr/pull/1) | [#6024](https://github.com/Zettlr/Zettlr/pull/6024), 7 days later |
|
|
79
|
+
| [Zettlr #6031](https://github.com/Zettlr/Zettlr/pull/6031) | Electron | Typing an empty Pandoc span turns off the highlighting in the note | [Caught, fixed on the first attempt](https://github.com/t1dem/zettlr-pandoc/pull/1) | [#6448](https://github.com/Zettlr/Zettlr/pull/6448), 211 days later |
|
|
80
|
+
| [MarkText #5276](https://github.com/marktext/marktext/pull/5276) | Electron | A folded heading unfolds after switching tabs | [Caught, fixed on the first attempt](https://github.com/t1dem/marktext/pull/1) | [#6060](https://github.com/marktext/marktext/pull/6060), 24 days later |
|
|
81
|
+
|
|
82
|
+
The web replays ran on GitHub's Ubuntu runners. The Android and Electron replays ran on a self-hosted Apple Silicon Mac, Android on an Android 14 emulator.
|
|
83
|
+
|
|
58
84
|
## How it works
|
|
59
85
|
|
|
60
86
|
<picture>
|
|
61
|
-
<source media="(prefers-color-scheme: dark)" srcset="docs/flow-dark.svg">
|
|
62
|
-
<img src="docs/flow-light.svg" alt="Pull request, then Kane runs the flows it touches in Chrome, then a report with clips on the PR. If a flow broke, Claude fixes it and Kane re-checks; the fix is pushed on a pass, otherwise Claude tries again, up to 3 times.">
|
|
87
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/t1dem/proofed/main/docs/flow-dark.svg">
|
|
88
|
+
<img src="https://raw.githubusercontent.com/t1dem/proofed/main/docs/flow-light.svg" alt="Pull request, then Kane runs the flows it touches in Chrome, then a report with clips on the PR. If a flow broke, Claude fixes it and Kane re-checks; the fix is pushed on a pass, otherwise Claude tries again, up to 3 times.">
|
|
63
89
|
</picture>
|
|
64
90
|
|
|
65
91
|
- Only the scenarios whose `paths` the diff touches run.
|
|
66
|
-
-
|
|
67
|
-
- Kane doesn't record video, so Proofed records Chrome itself. The clip cuts the waiting, shows where Kane clicked and zooms in on what it checks.
|
|
68
|
-
- When Kane blames the test
|
|
69
|
-
-
|
|
92
|
+
- For web, a start page that crashes on load fails at once, with the browser's error and a screenshot, at no Kane credits.
|
|
93
|
+
- For web, Kane doesn't record video, so Proofed records Chrome itself. The clip cuts the waiting, shows where Kane clicked and zooms in on what it checks.
|
|
94
|
+
- When Kane blames the test without a failed assertion, the scenario shows as "not checked". A failed check that Kane blames on the scenario runs a second time; two failures stay failed.
|
|
95
|
+
- A fix starts when someone ticks **Fix with Claude** or **Fix with Codex**, or on its own with [Fix automatically](#fix-automatically) on.
|
|
96
|
+
- Each attempt rebuilds and re-checks the broken flows and affected neighbors. The final check reuses the last attempt's results on the same tree and rebuilds only when scenarios still need to run, before committing and pushing.
|
|
97
|
+
- The fix commit's `Fixed-by:` line names the model.
|
|
70
98
|
|
|
71
99
|
## Scenarios
|
|
72
100
|
|
|
@@ -83,6 +111,8 @@ Open the bag, type the promo code welcome10 in lowercase and apply it.
|
|
|
83
111
|
Check that the discount is −€9.10, shipping is Free and the total is €81.90.
|
|
84
112
|
```
|
|
85
113
|
|
|
114
|
+
Put the exact text the page should show in quotes in the last check (`Check that the total is "€81.90".`): Proofed then compares it with the page itself ([Text checks](#text-checks-and-uncertain-passes)).
|
|
115
|
+
|
|
86
116
|
## Commands
|
|
87
117
|
|
|
88
118
|
Comment on a PR. Only people with write access can run them.
|
|
@@ -91,27 +121,37 @@ Comment on a PR. Only people with write access can run them.
|
|
|
91
121
|
|---|---|
|
|
92
122
|
| `/proofed` | Check the PR again |
|
|
93
123
|
| `/proofed <what to check>` | Kane checks just that, e.g. `/proofed the kettle goes into the bag at €45.00` |
|
|
94
|
-
| `/proofed fix` |
|
|
95
|
-
| `/proofed fix opus high` | This one fix with
|
|
124
|
+
| `/proofed fix` | Fix with the repository's selected provider and model |
|
|
125
|
+
| `/proofed fix opus high` | This one fix with Claude Opus at high effort |
|
|
126
|
+
| `/proofed fix sol high` | This one fix with Codex GPT-6.2 Sol at high effort |
|
|
127
|
+
| `/proofed fix codex` | This one fix with Codex GPT-6.2 Sol |
|
|
96
128
|
|
|
97
|
-
The repo's model
|
|
129
|
+
The repo's provider, model and effort are set in the [dashboard](https://proofed.neptunescodm.workers.dev/app), under Settings in the repo's model menu. The two icons switch between Claude and Codex. Without a choice, fixes use Claude Haiku 5.5 at xhigh effort. The same choice writes scenarios on the setup PR.
|
|
98
130
|
|
|
99
|
-
##
|
|
131
|
+
## Fix automatically
|
|
132
|
+
|
|
133
|
+
By default a fix waits for someone to tick **Fix with Claude** or **Fix with Codex**. With **Fix automatically** on, it starts as soon as Kane sees a scenario fail. It doesn't start:
|
|
134
|
+
|
|
135
|
+
- on draft pull requests,
|
|
136
|
+
- on pushes by bots, so the fixer's own commit doesn't start another fix,
|
|
137
|
+
- on a run Kane marked "not checked".
|
|
138
|
+
|
|
139
|
+
In the [dashboard](https://proofed.neptunescodm.workers.dev/app), open Settings, click the model menu in the repo's row (it reads like "Haiku 5.5 · xhigh") and turn on **Fix automatically** at the bottom. Or with the GitHub CLI:
|
|
140
|
+
|
|
141
|
+
```sh
|
|
142
|
+
gh variable set PROOFED_AUTOFIX --body true --repo owner/repo # on
|
|
143
|
+
gh variable delete PROOFED_AUTOFIX --repo owner/repo # off
|
|
144
|
+
```
|
|
100
145
|
|
|
101
|
-
|
|
146
|
+
## Locally and from an AI agent
|
|
102
147
|
|
|
103
|
-
|
|
148
|
+
`proofed check` runs the same check on your machine, against the change you haven't pushed yet: the scenarios its files touch, with Kane CLI on their configured targets. A coding agent can run it before it says a UI change is done.
|
|
104
149
|
|
|
105
|
-
|
|
150
|
+
Web checks need Node 22.18 or later, Chrome, [Kane CLI](https://www.npmjs.com/package/@testmuai/kane-cli) signed in (`kane-cli login`) and ffmpeg for the clips.
|
|
106
151
|
|
|
107
|
-
|
|
108
|
-
|---|---|---|---|
|
|
109
|
-
| Install | `npm install -g proofed-cli` | `pnpm add -g proofed-cli` | `bun add -g proofed-cli` |
|
|
110
|
-
| Run without installing | `npx proofed-cli` | `pnpm dlx proofed-cli` | `bunx proofed-cli` |
|
|
111
|
-
| Update | `npm install -g proofed-cli@latest` | `pnpm add -g proofed-cli@latest` | `bun add -g proofed-cli@latest` |
|
|
112
|
-
| Uninstall | `npm uninstall -g proofed-cli` | `pnpm remove -g proofed-cli` | `bun remove -g proofed-cli` |
|
|
152
|
+
Install it with `npm install -g proofed-cli` (or `pnpm add -g`, `bun add -g`), or run it once with `npx proofed-cli`.
|
|
113
153
|
|
|
114
|
-
The command is `proofed
|
|
154
|
+
The command is `proofed`. Run `proofed doctor` to see what's missing. The package ships built JavaScript and has no install scripts. From a clone, `npm link` runs the TypeScript source instead.
|
|
115
155
|
|
|
116
156
|
In the app's repo:
|
|
117
157
|
|
|
@@ -121,80 +161,75 @@ In the app's repo:
|
|
|
121
161
|
| `proofed list` | Every scenario, whether the change touches it and whether its pass is cached |
|
|
122
162
|
| `proofed check` | Runs the scenarios the change touches; `proofed check "the cart total updates"` checks just that |
|
|
123
163
|
|
|
124
|
-
|
|
164
|
+
In a repo that already runs Proofed on its PRs, `proofed check` needs no flags. `--dry-run` shows what would run and the credit estimate, for free. How the check finds the app, the exit codes, the JSON output and a sample run are in [docs/cli.md](https://github.com/t1dem/proofed/blob/main/docs/cli.md).
|
|
125
165
|
|
|
126
|
-
|
|
166
|
+
For an agent, add this to the app's `AGENTS.md` or `CLAUDE.md`:
|
|
127
167
|
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
[2:36] still running: free-shipping 2:35 at "Step 8"
|
|
143
|
-
[3:01] still running: free-shipping 3:00 at "Step 10"
|
|
144
|
-
[3:26] still running: free-shipping 3:25 at "assert: shipping is now Free and the total is €51.00."
|
|
145
|
-
[3:51] failed free-shipping: Free shipping from €50 (3:50, 56.9 credits)
|
|
146
|
-
|
|
147
|
-
✗ Free shipping from €50 failed after 3:50
|
|
148
|
-
Kane saw Final verification failed: "shipping is now Free and the total is €51.00."
|
|
149
|
-
Why The scenario's check did not hold on the page, on two runs in a row. Kane believes the scenario is out of date.
|
|
150
|
-
Kane thinks The test used the wrong free-shipping cutoff. After Paper Filters was increased, the basket subtotal was €51.00, which is still below the displayed €60.00 threshold, so the €4.90 shipping charge was correct.
|
|
151
|
-
Next If the change in the app was intended, update the scenario; otherwise fix the app.
|
|
152
|
-
Failed step assert: shipping is now Free and the total is €51.00.
|
|
153
|
-
Clip .proofed-out/free-shipping/clip.mp4
|
|
154
|
-
Scenario .proofed/scenarios/free-shipping.md
|
|
155
|
-
|
|
156
|
-
✗ 1 failed · 56.9 credits · 3m 52s
|
|
157
|
-
Credits are Kane's report; balance may drop slightly more.
|
|
158
|
-
1 of 1 broke: Free shipping from €50
|
|
159
|
-
Re-run what broke: proofed check --only free-shipping --url http://localhost:4173 --serve 'pnpm preview --port 4173' --build 'pnpm build'
|
|
168
|
+
```md
|
|
169
|
+
## Checking UI changes
|
|
170
|
+
|
|
171
|
+
Run the one command the task needs; `proofed check` checks its own setup first.
|
|
172
|
+
- Check the change: `proofed check --json`. One scenario: `proofed check --only <id> --json`.
|
|
173
|
+
- A behavior no scenario covers: `proofed check "<what>" --json`.
|
|
174
|
+
- To plan without spending credits, add `--dry-run`: it shows what would run and `estimatedCredits`.
|
|
175
|
+
- Only to ask which scenarios a change touches and their cost: `proofed list --json`.
|
|
176
|
+
- Only for setup questions: `proofed doctor --json`.
|
|
177
|
+
Allow at least 10 minutes for a check. stdout is one JSON document; progress is on stderr.
|
|
178
|
+
Exit 0: passed or nothing ran. On `failed`, read `reason` and `diagnosis`, fix and run `rerun`.
|
|
179
|
+
`failedCheck: "scenario_doubted"` is Kane's opinion: review the scenario's expectations.
|
|
180
|
+
`not_checked` is not a pass. On `error`, retry `rerun` once. Exit 3: follow `error.fix`.
|
|
181
|
+
Checks spend Kane credits; planning does not. Use `--no-retry` when another attempt is forbidden.
|
|
160
182
|
```
|
|
161
183
|
|
|
162
|
-
|
|
184
|
+
### MCP and the Claude Code Stop hook
|
|
163
185
|
|
|
164
|
-
|
|
186
|
+
Start your editor or MCP client in the app's repository root. In Claude Code, add this to the project's `.mcp.json`.
|
|
165
187
|
|
|
166
|
-
|
|
188
|
+
```json
|
|
189
|
+
{"mcpServers":{"proofed":{"command":"npx","args":["-y","proofed-cli","mcp"]}}}
|
|
190
|
+
```
|
|
167
191
|
|
|
168
|
-
For
|
|
192
|
+
For Codex, add this to `config.toml`.
|
|
169
193
|
|
|
170
|
-
```
|
|
171
|
-
|
|
194
|
+
```toml
|
|
195
|
+
[mcp_servers.proofed]
|
|
196
|
+
command = "npx"
|
|
197
|
+
args = ["-y", "proofed-cli", "mcp"]
|
|
198
|
+
tool_timeout_sec = 900
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
To run affected checks automatically when Claude Code is about to stop, add this to `.claude/settings.json`.
|
|
172
202
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
To check one thing without a scenario: `proofed check "the cart total updates" --json`.
|
|
203
|
+
```json
|
|
204
|
+
{
|
|
205
|
+
"hooks": {
|
|
206
|
+
"Stop": [
|
|
207
|
+
{"hooks": [{"type": "command", "command": "npx -y proofed-cli hook claude-stop", "timeout": 900}]}
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
}
|
|
182
211
|
```
|
|
183
212
|
|
|
213
|
+
`proofed_list`, `proofed_doctor` and dry runs are free. Checks spend Kane credits unless the pass is cached. The Stop hook asks Claude to continue after a failure, up to three times per session. See [agent setup and behavior](docs/cli.md#mcp-and-the-claude-code-stop-hook).
|
|
214
|
+
|
|
184
215
|
## Setup
|
|
185
216
|
|
|
186
|
-
1. Sign in at [proofed.neptunescodm.workers.dev](https://proofed.neptunescodm.workers.dev/app) and save your TestMu and Claude
|
|
217
|
+
1. Sign in at [proofed.neptunescodm.workers.dev](https://proofed.neptunescodm.workers.dev/app) and save your TestMu keys and a Claude token or OpenAI API key.
|
|
187
218
|
2. Install the GitHub App on a repo. Proofed opens a PR with the workflow and puts the keys into the repo's secrets.
|
|
188
|
-
3. On that PR,
|
|
219
|
+
3. On that PR, the selected provider writes up to five scenarios for the app's main flows. Only the ones Kane saw pass are committed.
|
|
189
220
|
|
|
190
|
-
|
|
221
|
+
One-click setup detects Gradle Android apps and configures checks on real cloud devices. This setup is not yet verified on a real device plan.
|
|
222
|
+
|
|
223
|
+
A web scenario takes 1 to 4 minutes and is estimated at 30 Kane credits the first time. Mobile and desktop costs are unknown without history. A fix attempt re-runs the broken scenarios and affected neighboring scenarios before pushing.
|
|
191
224
|
|
|
192
225
|
<details>
|
|
193
226
|
<summary><b>Setting it up by hand</b></summary>
|
|
194
227
|
|
|
195
228
|
<br>
|
|
196
229
|
|
|
197
|
-
Add `LT_USERNAME` and `LT_ACCESS_KEY` (TestMu: Settings → Keys) and `CLAUDE_CODE_OAUTH_TOKEN` (from `claude setup-token`) to the repo secrets
|
|
230
|
+
Add `LT_USERNAME` and `LT_ACCESS_KEY` (TestMu: Settings → Keys) and either `CLAUDE_CODE_OAUTH_TOKEN` (from `claude setup-token`) or `CODEX_API_KEY` (an OpenAI API key) to the repo secrets. If you use Codex, choose a Codex model in Proofed's repository settings or set the repository Actions variable `PROOFED_PROVIDER` to `codex` before running the workflow.
|
|
231
|
+
|
|
232
|
+
Then add one workflow. The whole file, working, is [proofed-demo-store's](https://github.com/t1dem/proofed-demo-store/blob/main/.github/workflows/proofed.yml); the part that matters:
|
|
198
233
|
|
|
199
234
|
```yaml
|
|
200
235
|
on:
|
|
@@ -208,7 +243,7 @@ jobs:
|
|
|
208
243
|
runs-on: ubuntu-latest
|
|
209
244
|
concurrency:
|
|
210
245
|
group: proofed-${{ github.event.pull_request.number || github.event.issue.number }}
|
|
211
|
-
# A new push cancels a stale check, but not the push of
|
|
246
|
+
# A new push cancels a stale check, but not the push of the fix: that run waits for the fix run.
|
|
212
247
|
cancel-in-progress: ${{ github.event_name == 'pull_request' && github.actor != 'proofed-by-kane[bot]' }}
|
|
213
248
|
steps:
|
|
214
249
|
- uses: t1dem/proofed@main
|
|
@@ -220,66 +255,85 @@ jobs:
|
|
|
220
255
|
lt-username: ${{ secrets.LT_USERNAME }}
|
|
221
256
|
lt-access-key: ${{ secrets.LT_ACCESS_KEY }}
|
|
222
257
|
claude-code-oauth-token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
|
|
258
|
+
codex-api-key: ${{ secrets.CODEX_API_KEY }}
|
|
223
259
|
vars: ${{ toJSON(vars) }}
|
|
224
260
|
```
|
|
225
261
|
|
|
226
262
|
- `vars` hands the action every Actions variable of the repo, so a new setting from the dashboard works without editing the workflow.
|
|
227
|
-
- `id-token: write` lets the fixer push
|
|
263
|
+
- `id-token: write` lets the fixer push the fix commit as the Proofed GitHub App, so your other workflows run on the fix commit without waiting for approval. Without it the fix is pushed with `GITHUB_TOKEN`.
|
|
228
264
|
- Clips go to a `proofed-clips` branch of the same repo, so the GIFs render in the comment with no storage of your own, in private repos too.
|
|
229
|
-
-
|
|
265
|
+
- Claude aliases: `haiku`, `sonnet`, `opus`, `fable`. A version such as `opus 5.1` and full Claude IDs are accepted. Effort: `low`, `medium`, `high`, `xhigh`, `max`.
|
|
266
|
+
- Codex aliases: `sol`, `terra`, `astra`, `luna`. Full IDs: `gpt-6.2-sol`, `gpt-6.1-sol`, `gpt-6.1-terra`, `gpt-6-astra`, `gpt-6-luna`. Effort: `low`, `medium`, `high`, `xhigh`, `max`; Sol, Terra and Astra also accept `ultra`.
|
|
267
|
+
- Actions variables `PROOFED_PROVIDER`, `PROOFED_MODEL`, `PROOFED_EFFORT` and `PROOFED_AUTOFIX` store the menu choice. The provider can be inferred from the model. Existing Claude workflows and their checkbox label keep working. To enable Codex in an installed workflow, add `codex-api-key: ${{ secrets.CODEX_API_KEY }}` and let its edited-comment condition match `- [x] **Fix with Codex**` as well as `- [x] **Fix with Claude**`.
|
|
268
|
+
- Codex CLI is installed only for Codex runs. `codex exec` reads `CODEX_API_KEY`; local runs can also use `codex login`. Its workspace-write sandbox blocks command network access and writes outside the workspace, and Proofed restores changes to scenarios and workflows before checking a fix.
|
|
269
|
+
- The checkout keeps no token in `.git/config` (`persist-credentials: false`); the push hands the token to git itself. Claude and Codex start without the job's tokens. A change that still contains one is discarded before it is built or checked, and the agent's answer is masked before it reaches the PR or the dashboard.
|
|
230
270
|
|
|
231
271
|
</details>
|
|
232
272
|
|
|
273
|
+
## Mobile and desktop apps
|
|
274
|
+
|
|
275
|
+
A scenario can set `target: ios`, `android` or `desktop`; scenarios without it stay web checks.
|
|
276
|
+
|
|
277
|
+
- **Local iOS and Android** need an Apple Silicon Mac (macOS arm64), a built app, Kane's managed dependencies and one device you booted yourself, picked by `device` and `os_version`. GitHub Actions can use a self-hosted `[self-hosted, macOS, ARM64]` runner. `proofed doctor --target ios` (or `android`) lists what is missing and installs nothing.
|
|
278
|
+
- **Cloud iOS and Android** run on real TestMu devices from Linux, macOS or Windows. The plan must include real-device automation. These runs give Kane's screenshots, without a Proofed MP4.
|
|
279
|
+
- **Desktop** is experimental and covers one Electron Chromium window: give `launch` (or `app`) and `cdp_endpoint`. Native menus, OS file dialogs, Safari, Tauri and WKWebView are not supported.
|
|
280
|
+
- **Fixing** uses the same checkbox and auto-fix setting on every target. Set `build` to produce the artifact in `app`, or the desktop code started by `launch`. Each check installs, uploads or launches the rebuild. `url` and `serve` are needed only for web scenarios. Pre-uploaded `APP…` IDs and desktop endpoints without a launch command or app path cannot verify a rebuild, so the report says why fixing didn't run.
|
|
281
|
+
|
|
282
|
+
Commands and Android cloud, self-hosted Android and macOS Electron Actions examples: [docs/cli.md](https://github.com/t1dem/proofed/blob/main/docs/cli.md#github-actions-examples).
|
|
283
|
+
Real-run verification by target and host is listed in [Platform support](https://github.com/t1dem/proofed/blob/main/docs/cli.md#platform-support).
|
|
284
|
+
|
|
233
285
|
## Limits
|
|
234
286
|
|
|
235
287
|
- **Kane's verdict on the same failure varies.** On [#6](https://github.com/t1dem/proofed-demo-store/pull/6) the check that [#9](https://github.com/t1dem/proofed-demo-store/pull/9) reports as a break came back twice as "the test may be wrong". Without a failed check, Proofed shows such a run as not confirmed and starts no fix. A failed `assert:` that Kane blames on the scenario is run a second time, and stays a failure when it fails again.
|
|
236
|
-
- **Fixes need
|
|
288
|
+
- **Fixes need room in the selected provider's usage limit.** On [#7](https://github.com/t1dem/proofed-demo-store/pull/7) and [#8](https://github.com/t1dem/proofed-demo-store/pull/8) it ran out: Kane caught the break, no fix followed, and the report says so.
|
|
237
289
|
- **Only flows with a scenario are checked.** A scenario whose `paths` miss a file isn't picked when that file changes.
|
|
238
290
|
- **Slow next to unit tests.** One to four minutes of Kane per scenario, plus a build and a re-check per fix attempt.
|
|
239
291
|
|
|
240
|
-
## What
|
|
292
|
+
## What we ran into with Kane CLI
|
|
241
293
|
|
|
242
|
-
|
|
294
|
+
What went wrong in real runs, and what Proofed does about it.
|
|
243
295
|
|
|
244
|
-
| What
|
|
296
|
+
| What happened | What Proofed does | Where |
|
|
245
297
|
|---|---|---|
|
|
246
|
-
| Asked something vague, Kane waited and reported a pass | A pass with no `assert` step counts as "not checked" | `src/run.ts` |
|
|
247
|
-
| Kane routed around a broken button and passed | Kane is told to do each step once, with no other way to the goal | `src/run.ts` |
|
|
248
|
-
| A run was still going after 361 seconds | A 360-second wall-clock limit over Kane's own `--timeout 300` | `src/kane.ts` |
|
|
249
|
-
| Kane's children outlived a plain kill and held the output open | Kane runs in its own process group, killed as a whole | `src/kane.ts` |
|
|
250
|
-
| On a page that was fine, Kane reported a heading as not visible and blamed the scenario | A failed check Kane blames on the scenario is run a second time;
|
|
251
|
-
| In 13 of 36 parallel starts, a scenario exited within seconds | One `kane-cli login` before the scenarios, and one retry; the retry always reached a verdict | `action.yml`, `src/run.ts` |
|
|
298
|
+
| Asked something vague, Kane waited and reported a pass | A pass with no `assert` step counts as "not checked" | `src/check/run.ts` |
|
|
299
|
+
| Kane routed around a broken button and passed | Kane is told to do each step once, with no other way to the goal | `src/check/run.ts` |
|
|
300
|
+
| A run was still going after 361 seconds | A 360-second wall-clock limit over Kane's own `--timeout 300`; `timeout_minutes` in a scenario raises both | `src/kane/kane.ts` |
|
|
301
|
+
| Kane's children outlived a plain kill and held the output open | Kane runs in its own process group, killed as a whole | `src/kane/kane.ts` |
|
|
302
|
+
| On a page that was fine, Kane reported a heading as not visible and blamed the scenario | A failed check Kane blames on the scenario is run a second time; two failures stay failed; a failure followed by a pass is not checked | `src/check/run.ts` |
|
|
303
|
+
| In 13 of 36 parallel starts, a scenario exited within seconds | One `kane-cli login` before the scenarios, and one retry; the retry always reached a verdict | `action.yml`, `src/check/run.ts` |
|
|
252
304
|
|
|
253
|
-
|
|
305
|
+
### Text checks and uncertain passes
|
|
254
306
|
|
|
255
|
-
|
|
256
|
-
`pnpm build` emits the CLI and its imports to `dist/` for npm. `npm pack` builds it automatically.
|
|
257
|
-
`pnpm typecheck` and `pnpm test` check the source. `pnpm check:package` builds a tarball, checks its
|
|
258
|
-
contents, installs it into a temporary prefix and runs its version and help. It removes its temp files.
|
|
307
|
+
For web runs, Proofed compares Kane's pass on the scenario's last check with the page text. It costs no Kane credits.
|
|
259
308
|
|
|
260
|
-
|
|
309
|
+
- **What is compared.** Text in quotes anywhere in the last check, such as `Check that the total is "€81.90".` Without quotes, only the shape `Check that A contains B.` (or `shows`, `lists`, `includes`), and only for a side of two or more words that reads like on-screen text: `Check that Vos outils favoris contains Générateur de token.` compares both names, `Check that the favorites section contains Token generator.` compares only `Token generator`.
|
|
310
|
+
- **When.** Proofed reads the page as Kane starts the assert for that check and again as it finishes it. A text counts as missing only when both reads lack it.
|
|
311
|
+
- **What is read.** All visible text in the document, not just the part in view: open shadow roots, same-origin frames, input values and placeholders, the chosen option of a select, image `alt`, `aria-label` and `title`, SVG text and CSS `content`. Case, spaces and quote or dash styles don't matter.
|
|
312
|
+
- **What a contradiction does.** A missing text turns Kane's pass into "not checked", and the reason names the text. Nothing is ever turned into a failure.
|
|
313
|
+
- **What is left to Kane.** Negative checks ("no longer", "not"), other wordings, colours, layout, and whether the text is in the right place. A page with a visible canvas, video, embedded object, cross-origin frame, registered custom element without an open shadow root, or CSS counter can't contradict Kane, since its text may not be readable. Images and icons don't stop the comparison, so a check whose text exists only as pixels in an image can end up "not checked".
|
|
261
314
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
315
|
+
If a failed assert is retried because Kane doubts the scenario, two failures stay failed. A failure followed by a pass is "not checked", and both runs' reasons are kept.
|
|
316
|
+
|
|
317
|
+
### Credit figures
|
|
318
|
+
|
|
319
|
+
`credits` is Kane's own estimate, retries included, and is labelled as an estimate in the terminal, the reports and the dashboard (`creditsSource: "kane_estimate"` in JSON). An interrupted run can spend credits before Kane reports any cost.
|
|
320
|
+
|
|
321
|
+
Proofed can also read the free `kane-cli balance` before and after a scenario and report the account's debit as `accountBalance`. That figure covers the whole account: other activity on the account can contribute to it, so attribution to the scenario is unknown. Proofed drops it when it detects overlapping Proofed runs on the same machine; it cannot detect remote account activity.
|
|
322
|
+
## Code
|
|
323
|
+
|
|
324
|
+
Node 22.18+ runs the checkout's TypeScript directly, so the GitHub Action needs no build or package install. `pnpm build` emits the CLI and its imports to `dist/` for npm; `npm pack` builds it automatically. `pnpm typecheck` and `pnpm test` check the source. `pnpm check:package` builds a tarball, checks its contents, installs it into a temporary prefix and runs its version and help, then removes its temp files.
|
|
325
|
+
|
|
326
|
+
Releasing to npm is manual: [docs/release.md](https://github.com/t1dem/proofed/blob/main/docs/release.md).
|
|
271
327
|
|
|
272
|
-
|
|
273
|
-
check before packing a fresh build. Complete npm's sign-in and two-factor prompts when asked.
|
|
274
|
-
Publishing is manual; no release workflow runs on pushes or pull requests.
|
|
328
|
+
Before deploying the Worker, run `pnpm exec wrangler d1 migrations apply proofed --remote` from `site/`. This applies migration `0008_codex_key.sql` before the Worker needs the `codex_key` column. Then run `pnpm deploy` from `site/`.
|
|
275
329
|
|
|
276
330
|
| File | What it does |
|
|
277
331
|
|---|---|
|
|
278
|
-
| `src/cli.ts` | The PR check |
|
|
279
|
-
| `src/fix.ts` | The fix loop |
|
|
280
|
-
| `src/run.ts` | One scenario:
|
|
281
|
-
| `src/generate.ts` | The setup PR's first scenarios |
|
|
282
|
-
| `src/mode.ts` | Decides what an event asks for |
|
|
332
|
+
| `src/action/cli.ts` | The PR check |
|
|
333
|
+
| `src/fix/fix.ts` | The fix loop |
|
|
334
|
+
| `src/check/run.ts` | One scenario: target preparation, recording, Kane, clip |
|
|
335
|
+
| `src/fix/generate.ts` | The setup PR's first scenarios |
|
|
336
|
+
| `src/action/mode.ts` | Decides what an event asks for |
|
|
283
337
|
| `site/` | The dashboard, `/try` and the Cloudflare Worker behind them |
|
|
284
338
|
|
|
285
339
|
## License
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { baseRev } from "../changes.js";
|
|
2
|
+
import { env } from "../env.js";
|
|
3
|
+
import { effortsFor, isEffort, parseModel } from "../fix/models.js";
|
|
4
|
+
import { scenarioDoubted } from "../report/runresult.js";
|
|
5
|
+
import { loadScenariosOr } from "../scenarios.js";
|
|
6
|
+
import { checkedAt, scenarioTarget } from "../fix/fixtarget.js";
|
|
7
|
+
import { resolveScenarioTarget, TARGET_KEYS } from "../targets/target.js";
|
|
8
|
+
// "/proofed" in a PR comment re-runs the check, which also gives a PR opened before Proofed was
|
|
9
|
+
// added its first run. "/proofed <what to check>" has Kane check just that. A slash command,
|
|
10
|
+
// not "@proofed": that name belongs to someone else on GitHub and would mention them.
|
|
11
|
+
const COMMAND = /(?:^|\s)\/proofed\b([\s\S]*)/i;
|
|
12
|
+
export function parseCommand(comment) {
|
|
13
|
+
const match = COMMAND.exec(comment);
|
|
14
|
+
return match ? match[1].trim() : undefined;
|
|
15
|
+
}
|
|
16
|
+
// "/proofed fix [model] [effort]" has the fixer fix the broken scenarios, with that model this once.
|
|
17
|
+
// Only the first line counts, so a note under the command doesn't become part of the model name.
|
|
18
|
+
export function parseFix(command) {
|
|
19
|
+
const words = (command.split("\n")[0] ?? "").trim().split(/\s+/).filter(Boolean);
|
|
20
|
+
if (words[0]?.toLowerCase() !== "fix")
|
|
21
|
+
return undefined;
|
|
22
|
+
const rest = words.slice(1);
|
|
23
|
+
const last = rest.at(-1)?.toLowerCase() ?? "";
|
|
24
|
+
const effort = isEffort(last) ? last : undefined;
|
|
25
|
+
const modelWords = effort ? rest.slice(0, -1) : rest;
|
|
26
|
+
if (modelWords.length === 0)
|
|
27
|
+
return { effort };
|
|
28
|
+
const choice = parseModel(modelWords);
|
|
29
|
+
if ("error" in choice)
|
|
30
|
+
return choice;
|
|
31
|
+
if (effort && !effortsFor(choice.model).includes(effort))
|
|
32
|
+
return { error: `The model \`${choice.model}\` doesn't support \`${effort}\` effort.` };
|
|
33
|
+
return { model: choice.model, effort };
|
|
34
|
+
}
|
|
35
|
+
// What the PR description asks to have checked. HTML comments (PR templates) are dropped, and a
|
|
36
|
+
// long description is a changelog rather than a request, so it's left alone.
|
|
37
|
+
export function descriptionRequest(body) {
|
|
38
|
+
const text = (body ?? "").replace(/<!--[\s\S]*?-->/g, "").trim();
|
|
39
|
+
return text && text.length <= 1500 ? text : undefined;
|
|
40
|
+
}
|
|
41
|
+
// Any short description becomes a request, and many ask for nothing ("Will be closed, not merged.").
|
|
42
|
+
// Left to itself Kane then improvises: it signs in, ends up on GitHub's OAuth page, and the report
|
|
43
|
+
// says the test may be wrong. A /proofed comment is always a request, so it gets no such way out.
|
|
44
|
+
const MAY_ASK_NOTHING = "If the text above doesn't describe something a user can see or do in this app, stop right away " +
|
|
45
|
+
"without clicking anything: there is nothing to check. Never sign in, and never leave the app's own pages to get there.";
|
|
46
|
+
const descriptionId = /^asked-in-description(?:-\d+)?$/;
|
|
47
|
+
export const isDescriptionScenario = (s) => !s.file && descriptionId.test(s.id);
|
|
48
|
+
export const DESCRIPTION_DOUBTED = "Kane couldn't verify what the PR description asks.";
|
|
49
|
+
export const DESCRIPTION_UNCHECKED = "The PR description didn't name anything Kane could check.";
|
|
50
|
+
// The description is best effort. An unconfirmed result only gets a line under the report.
|
|
51
|
+
export function descriptionCheckNote(r) {
|
|
52
|
+
if (!isDescriptionScenario(r.scenario) || r.requestUnavailable)
|
|
53
|
+
return;
|
|
54
|
+
if (scenarioDoubted(r))
|
|
55
|
+
return DESCRIPTION_DOUBTED;
|
|
56
|
+
if (r.outcome === "unsure")
|
|
57
|
+
return DESCRIPTION_UNCHECKED;
|
|
58
|
+
}
|
|
59
|
+
const NAMES = {
|
|
60
|
+
description: "What the PR description asks",
|
|
61
|
+
comment: "What the /proofed comment asks",
|
|
62
|
+
terminal: "What you asked to check",
|
|
63
|
+
};
|
|
64
|
+
// "terminal": `proofed check "<text>"`, run by a person or a coding agent on their own machine.
|
|
65
|
+
export function askedScenario(where, text, target = resolveScenarioTarget({}, {}, process.env, process.cwd())) {
|
|
66
|
+
const scenario = {
|
|
67
|
+
id: where === "terminal" ? "asked" : `asked-in-${where}`,
|
|
68
|
+
file: "",
|
|
69
|
+
name: NAMES[where],
|
|
70
|
+
paths: [],
|
|
71
|
+
url: "/",
|
|
72
|
+
objective: "",
|
|
73
|
+
};
|
|
74
|
+
const location = target.kind === "web" ? "in the browser" : checkedAt({ ...scenario, resolvedTarget: target });
|
|
75
|
+
scenario.objective =
|
|
76
|
+
(where === "terminal"
|
|
77
|
+
? `The developer of this app asked for this to be checked:\n\n${text}\n\n`
|
|
78
|
+
: `The author of this pull request asked for this to be checked:\n\n${text}\n\n`) +
|
|
79
|
+
`Open the app and check exactly that ${location}, the way a user would. It passes only if what they ` +
|
|
80
|
+
`asked about actually works; the ${target.kind === "web" ? "page" : "app"} loading is not enough.` +
|
|
81
|
+
(where === "description" ? ` ${MAY_ASK_NOTHING}` : "");
|
|
82
|
+
return scenario;
|
|
83
|
+
}
|
|
84
|
+
// File scenarios and requests share the output directory, which may be case-insensitive.
|
|
85
|
+
export function avoidFileId(request, files) {
|
|
86
|
+
if (request.file)
|
|
87
|
+
return request;
|
|
88
|
+
const fileIds = new Set(files.map((s) => s.id.toLowerCase()));
|
|
89
|
+
if (!fileIds.has(request.id))
|
|
90
|
+
return request;
|
|
91
|
+
const stem = request.id.replace(/-\d+$/, "");
|
|
92
|
+
let suffix = 2;
|
|
93
|
+
while (fileIds.has(`${stem}-${suffix}`))
|
|
94
|
+
suffix++;
|
|
95
|
+
return { ...request, id: `${stem}-${suffix}` };
|
|
96
|
+
}
|
|
97
|
+
export function askedScenarioFromFile(where, text, source) {
|
|
98
|
+
const scenario = { ...askedScenario(where, text, scenarioTarget(source)), targetScenarioId: source.id };
|
|
99
|
+
for (const key of TARGET_KEYS)
|
|
100
|
+
if (source[key])
|
|
101
|
+
scenario[key] = source[key];
|
|
102
|
+
return scenario;
|
|
103
|
+
}
|
|
104
|
+
// Reports store the generated objective. Recover the original request only if the check's
|
|
105
|
+
// generator can reproduce that objective with the current target settings.
|
|
106
|
+
export function replayAskedScenario(stored) {
|
|
107
|
+
const where = descriptionId.test(stored.id) ? "description" : /^asked-in-comment(?:-\d+)?$/.test(stored.id) ? "comment" : undefined;
|
|
108
|
+
if (!where || stored.file !== "" || stored.url !== "/" || typeof stored.objective !== "string")
|
|
109
|
+
return;
|
|
110
|
+
let template;
|
|
111
|
+
if (stored.targetScenarioId !== undefined) {
|
|
112
|
+
const { PROOFED_BASE_REF: ref, PROOFED_BASE_SHA: sha } = process.env;
|
|
113
|
+
const rev = ref && sha ? baseRev({ ref, sha }) : sha;
|
|
114
|
+
// Read target settings from the checkout before replaying a request from a report.
|
|
115
|
+
const source = loadScenariosOr(env("PROOFED_SCENARIOS", ".proofed/scenarios"), rev).find((s) => s.id === stored.targetScenarioId);
|
|
116
|
+
if (!source)
|
|
117
|
+
return;
|
|
118
|
+
template = askedScenarioFromFile(where, "", source);
|
|
119
|
+
}
|
|
120
|
+
else
|
|
121
|
+
template = askedScenario(where, "");
|
|
122
|
+
const boundary = template.objective.indexOf("\n\n") + 2;
|
|
123
|
+
const prefix = template.objective.slice(0, boundary);
|
|
124
|
+
const suffix = template.objective.slice(boundary);
|
|
125
|
+
if (!stored.objective.startsWith(prefix) || !stored.objective.endsWith(suffix))
|
|
126
|
+
return;
|
|
127
|
+
const request = stored.objective.slice(prefix.length, -suffix.length);
|
|
128
|
+
if (request.trim())
|
|
129
|
+
return { ...template, id: stored.id, objective: `${prefix}${request}${suffix}` };
|
|
130
|
+
}
|