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.
Files changed (65) hide show
  1. package/README.md +176 -122
  2. package/dist/action/requests.js +130 -0
  3. package/dist/{server.js → action/server.js} +17 -3
  4. package/dist/changes.js +7 -1
  5. package/dist/{args.js → check/args.js} +31 -3
  6. package/dist/check/cache.js +89 -0
  7. package/dist/{check.js → check/check.js} +86 -40
  8. package/dist/{doctor.js → check/doctor.js} +55 -19
  9. package/dist/check/help.js +139 -0
  10. package/dist/{list.js → check/list.js} +27 -15
  11. package/dist/{pipeline.js → check/pipeline.js} +106 -68
  12. package/dist/{render.js → check/render.js} +22 -15
  13. package/dist/check/run.js +277 -0
  14. package/dist/check/targetfilter.js +10 -0
  15. package/dist/check/textcheck.js +162 -0
  16. package/dist/env.js +6 -0
  17. package/dist/fix/agent.js +21 -0
  18. package/dist/fix/claude.js +30 -0
  19. package/dist/fix/codex.js +71 -0
  20. package/dist/fix/fixsetup.js +76 -0
  21. package/dist/fix/fixtarget.js +48 -0
  22. package/dist/fix/models.js +67 -0
  23. package/dist/github.js +62 -14
  24. package/dist/integrations/claude-stop.js +104 -0
  25. package/dist/integrations/cli.js +63 -0
  26. package/dist/integrations/mcp.js +130 -0
  27. package/dist/kane/creditmeter.js +104 -0
  28. package/dist/kane/kane.js +131 -0
  29. package/dist/kane/kaneauth.js +84 -0
  30. package/dist/kane/kaneversion.js +13 -0
  31. package/dist/paths.js +32 -0
  32. package/dist/process.js +65 -0
  33. package/dist/proofed.js +34 -16
  34. package/dist/{live.js → report/live.js} +1 -1
  35. package/dist/{livefile.js → report/livefile.js} +1 -1
  36. package/dist/{report.js → report/report.js} +105 -125
  37. package/dist/report/reportdata.js +120 -0
  38. package/dist/{result.js → report/result.js} +12 -7
  39. package/dist/{runfile.js → report/runfile.js} +2 -2
  40. package/dist/report/runresult.js +5 -0
  41. package/dist/scenarios.js +41 -19
  42. package/dist/secrets.js +74 -0
  43. package/dist/{cdp.js → targets/cdp.js} +20 -6
  44. package/dist/targets/chrome.js +98 -0
  45. package/dist/{clip.js → targets/clip.js} +21 -11
  46. package/dist/{precheck.js → targets/precheck.js} +53 -20
  47. package/dist/targets/preparetarget.js +350 -0
  48. package/dist/{recorder.js → targets/recorder.js} +154 -19
  49. package/dist/{serve.js → targets/serve.js} +9 -13
  50. package/dist/{target.js → targets/target.js} +42 -7
  51. package/dist/targets/targetchecks.js +139 -0
  52. package/dist/timing.js +25 -0
  53. package/dist/types.js +1 -0
  54. package/dist/which.js +26 -13
  55. package/docs/cli.md +370 -0
  56. package/package.json +10 -5
  57. package/dist/cache.js +0 -48
  58. package/dist/chrome.js +0 -77
  59. package/dist/help.js +0 -133
  60. package/dist/kane.js +0 -75
  61. package/dist/kaneauth.js +0 -48
  62. package/dist/models.js +0 -44
  63. package/dist/requests.js +0 -58
  64. package/dist/run.js +0 -173
  65. /package/dist/{deps.js → targets/deps.js} +0 -0
package/docs/cli.md ADDED
@@ -0,0 +1,370 @@
1
+ # proofed check
2
+
3
+ The reference for `proofed check`. Installation is in the [README](../README.md#locally-and-from-an-ai-agent).
4
+
5
+ ## What it checks
6
+
7
+ The change is everything since the merge base with the default branch (`origin/HEAD`, else `origin/main`, `origin/master`, `main`, `master`, or `--base`), uncommitted and untracked files included.
8
+
9
+ ## Where it finds the app
10
+
11
+ The URL and the commands that install, build and serve the app are taken from the first of these that sets them:
12
+
13
+ 1. `--url`, `--install`, `--build`, `--serve`
14
+ 2. `PROOFED_URL`, `PROOFED_INSTALL`, `PROOFED_BUILD`, `PROOFED_SERVE`
15
+ 3. `.proofed/config.json`
16
+ 4. the Proofed step of the repo's workflow, so a repo that already runs Proofed on its PRs needs no flags
17
+
18
+ The CLI inherits only these workflow inputs: `url`, `install`, `build`, `serve`, `working-directory`,
19
+ `target`, `execution`, `app`, `device`, `os-version`, `launch` and `cdp-endpoint`.
20
+ Use literal, single-line values. The CLI ignores `${{ }}` expressions, block scalars and the `scenarios` input.
21
+
22
+ A build or install set in config or the workflow belongs to its serve command. Overriding
23
+ `serve` also drops that layer's build/install; pass them explicitly when needed.
24
+
25
+ Before anything is built, `kane-cli balance` (free) checks that TestMu accepts the login or the `LT_USERNAME` and `LT_ACCESS_KEY`. If it doesn't, the check stops with exit 3: `kane_not_signed_in` (fix: `kane-cli login`) or `kane_keys_rejected` (the keys are wrong or expired).
26
+
27
+ If the app isn't running, Proofed starts it and stops it at the end. It installs the dependencies only when `node_modules` is missing or older than `package.json` or the lockfile (with the install command found as above, else the app's package manager), then builds, then serves. If something already answers at the URL and a build is configured, the check stops rather than test what may be an old build; `--reuse` tests it anyway.
28
+
29
+ ## Caching and output
30
+
31
+ A passed scenario isn't run again until its file, the URL, the web build/install commands, the resolved target, Kane version, the base commit or a changed file in its `paths` changes. Native and desktop checks with a build command always rebuild and run again; an old artifact's pass cannot skip the build. `--dry-run` shows what would run and the credit estimate, for free. In a terminal the scenarios update in place; in a pipe each event is one line, with a "still running" line at least every 30 seconds.
32
+
33
+ ## For an agent
34
+
35
+ Run the one command the task needs: `proofed check` checks its own setup first and exits 3
36
+ with `error.fix` when something is missing. For setup questions, `proofed doctor --json` lists
37
+ problems and their fixes. To ask which scenarios a change touches without planning a check,
38
+ `proofed list --json` gives each scenario's `selected`, `cached` and `estimatedCredits`, plus the total
39
+ `estimatedCredits`. A selected scenario is touched by the change, or all scenarios when
40
+ there is no Git base. A clean diff selects nothing. Untouched scenarios and cached passes cost zero. Estimates use the
41
+ last reported cost, or 30 credits for a first web run; mobile and desktop estimates are `null` without history. Invalid scenarios are in `errors`; fix
42
+ those before checking. These commands do not spend credits.
43
+
44
+ Use `proofed check --only <id> --dry-run --json` to plan one scenario, or
45
+ `proofed check "<what to check>" --dry-run --json` to plan a check of a behavior no scenario
46
+ covers. Text that is a scenario's id or name is refused with exit 3 and the `--only` command. Remove
47
+ `--dry-run` to run it. Allow at least 10 minutes. Read `reason`, `diagnosis` and `rerun`
48
+ when a scenario fails. `not_checked` is not a pass. On exit 3, follow `error.fix`.
49
+
50
+ ## MCP and the Claude Code Stop hook
51
+
52
+ `proofed mcp` serves tools over stdio. Start the client in the repository root so Proofed finds the project's scenarios and app settings.
53
+
54
+ For Claude Code, add this to the project's `.mcp.json`.
55
+
56
+ ```json
57
+ {"mcpServers":{"proofed":{"command":"npx","args":["-y","proofed-cli","mcp"]}}}
58
+ ```
59
+
60
+ For Codex, add this to `config.toml`.
61
+
62
+ ```toml
63
+ [mcp_servers.proofed]
64
+ command = "npx"
65
+ args = ["-y", "proofed-cli", "mcp"]
66
+ tool_timeout_sec = 900
67
+ ```
68
+
69
+ | Tool | Inputs and cost |
70
+ |---|---|
71
+ | `proofed_list` | Free. Shows selection, cached passes and estimated credits. Set `base` to compare against another Git ref or `all` to estimate every scenario. |
72
+ | `proofed_doctor` | Free. Shows setup problems and their fixes. |
73
+ | `proofed_check` | Runs affected scenarios by default. Use `only` with an array of ids, `all` for every scenario, or `behavior` for a single plain-English check. Also accepts `base`, `noCache`, `url`, `serve`, `build` and `target`. A run spends Kane credits and takes about 1 to 4 minutes per scenario. `dryRun` and cached passes are free. |
74
+
75
+ Allow at least 10 minutes for the MCP client to wait on a check. The tool returns scenarios that failed or come back as `not_checked` in the result. Treat `not_checked` as unverified. Only change the scenario if the change in the app was intended.
76
+
77
+ To run checks at the end of a Claude Code turn, add this to `.claude/settings.json`. Hook timeouts are in seconds.
78
+
79
+ ```json
80
+ {
81
+ "hooks": {
82
+ "Stop": [
83
+ {"hooks": [{"type": "command", "command": "npx -y proofed-cli hook claude-stop", "timeout": 900}]}
84
+ ]
85
+ }
86
+ }
87
+ ```
88
+
89
+ The hook lists affected scenarios first and runs a check only when there is something to verify. A failed, unchecked or errored scenario sends Claude the outcome, Kane's observations, a clip path when available and a rerun command. Setup problems allow Claude to stop and leave the fix on stderr. The hook records which scenarios it reported under `.proofed-out/` and allows Claude to stop if the same scenarios are still broken during a continuation or the session has already blocked three times. [Claude Code Stop hook reference](https://code.claude.com/docs/en/hooks#stop)
90
+
91
+ ## A sample run
92
+
93
+ A real run on the demo store with the free shipping threshold changed to €60. Kane blamed the scenario, so it ran twice, and the credits are for both runs:
94
+
95
+ ```
96
+ Proofed: checking 1 of 3 scenario(s), --only, at http://localhost:4173.
97
+ Estimate: about 30 Kane credits.
98
+ Time: about 1 to 4 minutes per scenario, 3 at a time, so 1 to 4 minutes in all. Do not interrupt: let it finish.
99
+ Building the app: pnpm build
100
+ Starting the app: pnpm preview --port 4173
101
+ Started the app in 1 s (build from --build, serve from --serve); its output is in .proofed-out/serve.log
102
+ [0:01] started free-shipping: Free shipping from €50
103
+ [0:26] still running: free-shipping 0:25 at "Step 3"
104
+ [0:51] still running: free-shipping 0:50 at "Step 9"
105
+ [1:16] still running: free-shipping 1:15 at "assert: shipping is now Free and the total is €51.00."
106
+ [1:41] still running: free-shipping 1:40 at "assert: shipping is now Free and the total is €51.00."
107
+ [1:45] retrying free-shipping: the check failed, but Kane blames the scenario; running it once more to be sure
108
+ [2:11] still running: free-shipping 2:10 at "Step 3"
109
+ [2:36] still running: free-shipping 2:35 at "Step 8"
110
+ [3:01] still running: free-shipping 3:00 at "Step 10"
111
+ [3:26] still running: free-shipping 3:25 at "assert: shipping is now Free and the total is €51.00."
112
+ [3:51] failed free-shipping: Free shipping from €50 (3:50, 56.9 credits)
113
+
114
+ ✗ Free shipping from €50 failed after 3:50
115
+ Kane saw Final verification failed: "shipping is now Free and the total is €51.00."
116
+ 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.
117
+ 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.
118
+ Next If the change in the app was intended, update the scenario; otherwise fix the app.
119
+ Failed step assert: shipping is now Free and the total is €51.00.
120
+ Clip .proofed-out/free-shipping/clip.mp4
121
+ Scenario .proofed/scenarios/free-shipping.md
122
+
123
+ ✗ 1 failed · 56.9 credits · 3m 52s
124
+ Credits are Kane's report; balance may drop slightly more.
125
+ 1 of 1 broke: Free shipping from €50
126
+ Re-run what broke: proofed check --only free-shipping --url http://localhost:4173 --serve 'pnpm preview --port 4173' --build 'pnpm build'
127
+ ```
128
+
129
+ ## Credits
130
+
131
+ `--no-retry` limits each selected scenario to one Kane attempt, including infrastructure errors
132
+ and checks Kane blames on the scenario. The first verdict is returned, with its usual exit code
133
+ and diagnostics. Without the flag, infrastructure errors get one retry unless Kane rejected the login. A doubted failure gets a second run, which can also retry an infrastructure error: up to four Kane attempts in total.
134
+
135
+ A first web run is estimated at 30 Kane credits per scenario. Mobile and desktop estimates are `null` without history. Later estimates use the last reported cost. Credits are Kane estimates for the runs, retries included (`creditsSource: "kane_estimate"`); the account balance can drop slightly more. An interrupted run can spend credits before Kane reports them.
136
+
137
+ When available, scenario JSON includes `accountBalance: {before, after, debit}`. This is
138
+ the whole account's balance change, with unknown attribution to the scenario. Proofed
139
+ omits it when it detects overlapping Proofed runs on the same machine; it cannot
140
+ detect other activity on the account.
141
+
142
+ ## JSON and exit codes
143
+
144
+ `--json` prints one compact JSON document on stdout and the progress on stderr. Every check also writes the same fields, with indentation, to `.proofed-out/result.json`, next to the clips; the folder has its own `.gitignore`.
145
+
146
+ | Exit | Meaning |
147
+ |---|---|
148
+ | 0 | Everything checked passed, nothing needed to run, or a dry run succeeded |
149
+ | 1 | A scenario failed |
150
+ | 2 | Nothing failed, but something wasn't checked or a run errored |
151
+ | 3 | The check couldn't start. The message says why and how to fix it; running it again unchanged won't help |
152
+ | 130 | Ctrl-C or a closed terminal. Kane, Chrome and the app are stopped first |
153
+
154
+ `failedCheck: "scenario_doubted"` means a scenario's check failed, but Kane believes the scenario is out of date. `diagnosis` is Kane's opinion; `suggestion` and `next` say to update the scenario if the app change was intended, otherwise fix the app. Unless `--no-retry` is set, such a failure is run a second time, at the scenario's cost again. A check that fails both times is a failure (exit 1). A failure followed by a pass stays unconfirmed and is reported as `notChecked: "runs_disagreed"` (exit 2). `notChecked: "scenario_doubted"` means Kane doubted the scenario without a failed check (exit 2).
155
+
156
+ In GitHub Actions, the check generated from a PR description is best effort. If Kane doubts it, Proofed adds a note to the PR report and leaves the check out of the commit status and autofix.
157
+
158
+ ## Mobile and Electron targets
159
+
160
+ A scenario can select `target: web|ios|android|desktop` and `execution: local|cloud`.
161
+ Cloud execution is only for iOS and Android.
162
+ Existing scenarios default to local web checks. Each selected scenario reports its resolved
163
+ `target` and field sources in JSON. `list` also prints the target in its table.
164
+
165
+ ```markdown
166
+ ---
167
+ name: Counter increments
168
+ target: ios
169
+ execution: local
170
+ app: build/Counter.app
171
+ device: iPhone 17
172
+ os_version: '26.4'
173
+ ---
174
+ Tap Add once. Assert that the counter reads 1.
175
+ ```
176
+
177
+ Kane gets 5 minutes per scenario. A long native flow can ask for more with
178
+ `timeout_minutes: 10` (1 to 30) in its frontmatter.
179
+
180
+ Use `--target`, `--execution`, `--app`, `--device`, `--os-version`, `--launch`,
181
+ and `--cdp-endpoint` with `check`, `doctor`, or `list`. Their environment equivalents
182
+ are `PROOFED_TARGET`, `PROOFED_EXECUTION`, `PROOFED_APP`, `PROOFED_DEVICE`,
183
+ `PROOFED_OS_VERSION`, `PROOFED_LAUNCH`, and `PROOFED_CDP_ENDPOINT`.
184
+ Config and frontmatter use underscores (`os_version`, `cdp_endpoint`); action inputs
185
+ use hyphens. Each field resolves in this order: flag, environment, scenario,
186
+ `.proofed/config.json`, action inputs read from the workflow, default.
187
+ Relative app paths resolve from the app working directory.
188
+ `--target` filters scenario files; it sets the target for an ad hoc objective.
189
+ `--only` with ids from another target is an error.
190
+
191
+ - Local iOS needs an Apple Silicon Mac (macOS arm64), full Xcode, an installed simulator runtime, Kane's managed simulator
192
+ dependencies, and exactly one matching booted device. Supply a simulator `.app` or
193
+ `.zip`, or a Kane `APP…` ID. Proofed temporarily zips `.app` bundles for Kane.
194
+ A device `.ipa` cannot run in Simulator.
195
+ - Local Android needs an Apple Silicon Mac (macOS arm64), Kane's managed emulator dependencies, `adb` on PATH, and exactly
196
+ one matching online emulator. Supply an `.apk` or `APP…` ID. A local `.aab` is rejected.
197
+ Device names and OS versions must identify the same device in Kane and adb.
198
+ - Cloud iOS uses `.ipa` or `APP…`; cloud Android uses `.apk`, `.aab`, or `APP…`.
199
+ Kane provisions real devices; the TestMu plan must include real-device automation. Evidence is screenshot-only in Kane's session directory;
200
+ Proofed reports a recording note and does not promise a cloud MP4.
201
+ - Desktop is experimental and limited to a single Electron Chromium page renderer.
202
+ Set `launch` to the executable and its remote debugging arguments, and set
203
+ `cdp_endpoint` to its browser CDP endpoint. Proofed waits for `/json/version` and
204
+ rejects multiple page renderers. An already running app requires `--reuse` with no
205
+ `launch`; Proofed never terminates that app. Owned launch processes run in their own
206
+ process group. Alternatively, set `app` to the desktop executable or macOS `.app` bundle;
207
+ Proofed adds the debugging port from `cdp_endpoint`. Clip rendering uses a separate Proofed Chrome.
208
+
209
+ ```markdown
210
+ ---
211
+ name: Desktop counter
212
+ target: desktop
213
+ launch: ./dist/Counter --remote-debugging-port=9223
214
+ cdp_endpoint: http://127.0.0.1:9223
215
+ ---
216
+ Click Add once. Assert that the counter reads 1.
217
+ ```
218
+
219
+ `doctor` discovers tools and devices without installing, downloading, launching, or
220
+ booting anything. Every target check includes a fix line in JSON. Missing build output
221
+ is reported as `artifact_pending_build` when a build command is configured. `check`
222
+ builds before validating the artifact. `--dry-run` resolves scenarios and reads cache
223
+ metadata; it never starts a device or Kane scenario. Both commands can call Kane's
224
+ free `--version` command. Local mobile checks refuse to run with missing managed deps,
225
+ since Kane can otherwise download them automatically.
226
+
227
+ After installing the SDK and managed dependencies explicitly, choose a device from the
228
+ local inventory, boot it yourself, and run:
229
+
230
+ ```sh
231
+ kane-cli doctor --target simulator --install
232
+ xcrun simctl list devices available
233
+ xcrun simctl boot '<simulator-udid>'
234
+ xcrun simctl bootstatus '<simulator-udid>' -b
235
+ proofed doctor --target ios --app build/Counter.app --device 'iPhone 17' --os-version 26.4
236
+ proofed check --target ios --all --app build/Counter.app --device 'iPhone 17' --os-version 26.4
237
+
238
+ kane-cli doctor --target emulator --install
239
+ emulator -list-avds
240
+ emulator -avd '<avd-name>'
241
+ adb devices
242
+ proofed doctor --target android --app app/build/outputs/apk/debug/app-debug.apk --device '<device-name>' --os-version '<version>'
243
+ proofed check --target android --all --app app/build/outputs/apk/debug/app-debug.apk --device '<device-name>' --os-version '<version>'
244
+ ```
245
+
246
+ Run the emulator command in a separate terminal. Supply names and versions from your
247
+ actual inventory; the examples do not install a runtime or choose a device for you.
248
+
249
+ Native recording uses `simctl recordVideo` or `adb shell screenrecord`. Android segments
250
+ are limited to 175 seconds and concatenated after pulling them. ffmpeg produces MP4,
251
+ final JPG and GIF without changing portrait orientation or adding a cursor or zoom.
252
+ Segment boundaries may have a gap. A recording failure is reported separately and
253
+ preserves Kane's verdict. Cloud recordings are not available through this adapter.
254
+ Only Proofed's remote recording files are removed, after a successful pull.
255
+
256
+ No target supports direct Safari automation. Tauri and WKWebView are unsupported.
257
+ Electron coverage excludes native desktop menus, OS file dialogs and tray UI.
258
+ Kane may upload app artifacts to the TestMu account even for a local run. Mobile
259
+ cost remains unknown until the first run reports `credits_consumed`; JSON uses `null`
260
+ for mobile and desktop targets without history. Web scenarios fall back to 30 credits. History is separate by app digest, device, OS and Kane version.
261
+ Doubted failures use the same retry rules as web checks; `--no-retry` permits one attempt.
262
+
263
+ Fixing uses the same checkbox, `/proofed fix` command and **Fix automatically** setting
264
+ on every target. Set `build` to produce the artifact named by `app`, or the desktop
265
+ app started by `launch`. Every attempt rebuilds, then Kane re-checks through the normal
266
+ target preparation. Local mobile installs the rebuilt artifact; cloud mobile uploads
267
+ changed artifact bytes and starts a fresh device session; desktop launches a new process.
268
+ Kane keys its upload cache by the artifact SHA-256, platform, account and environment,
269
+ so an identical rebuild may reuse that upload; a changed artifact gets a new upload.
270
+ The final check reuses this job's last attempt results when the tree is unchanged,
271
+ including native results. It rebuilds and runs only missing scenarios; a changed tree
272
+ requires checking the full selection again. If every result is already known, it skips
273
+ the build and Kane. Verification finishes before committing and pushing. These checks
274
+ never use a pass from the CLI cache. Only web scenarios start the HTTP server,
275
+ so native and desktop jobs need no `url` or `serve`.
276
+
277
+ A pre-uploaded `APP…` ID cannot receive a rebuild. A desktop `cdp_endpoint` without
278
+ `launch` or `app` cannot be restarted. These cases, and a non-web target without a
279
+ build command, get a “Fix didn't run” note instead of an offered fix. Ordinary checks
280
+ of uploaded IDs and explicitly reused desktop sessions still work.
281
+
282
+ ### GitHub Actions examples
283
+
284
+ Use the PR/comment triggers, permissions and concurrency from the [README workflow](../README.md#setup).
285
+ Pass `vars: ${{ toJSON(vars) }}` to carry the dashboard's **Fix automatically** setting.
286
+ Set the matching `target` in the scenario frontmatter; the action's `target` input
287
+ filters scenario files. Prepare SDKs and devices before the action; Proofed installs
288
+ none of them.
289
+
290
+ Android cloud on Ubuntu builds an APK locally and gives Kane its path for each check. This
291
+ needs a TestMu plan with real-device automation; an Ubuntu emulator is not a supported
292
+ Kane local target.
293
+
294
+ ```yaml
295
+ runs-on: ubuntu-latest
296
+ steps:
297
+ - uses: actions/checkout@v4
298
+ - uses: actions/setup-java@v4
299
+ with: { distribution: temurin, java-version: '17' }
300
+ - uses: android-actions/setup-android@v3
301
+ - uses: t1dem/proofed@main
302
+ with:
303
+ target: android
304
+ execution: cloud
305
+ build: ./gradlew :app:assembleDebug
306
+ app: app/build/outputs/apk/debug/app-debug.apk
307
+ device: Pixel 8
308
+ os-version: '14'
309
+ lt-username: ${{ secrets.LT_USERNAME }}
310
+ lt-access-key: ${{ secrets.LT_ACCESS_KEY }}
311
+ codex-api-key: ${{ secrets.CODEX_API_KEY }}
312
+ vars: ${{ toJSON(vars) }}
313
+ ```
314
+
315
+ Local Android can use a self-hosted Apple Silicon Mac with Java 17, Android SDK,
316
+ Kane's managed dependencies and a matching emulator already booted. Replace the device
317
+ name and version with that runner's inventory. Local iOS uses the same runner class
318
+ with Xcode and a booted simulator.
319
+
320
+ ```yaml
321
+ runs-on: [self-hosted, macOS, ARM64]
322
+ steps:
323
+ - uses: t1dem/proofed@main
324
+ with:
325
+ target: android
326
+ execution: local
327
+ build: ./gradlew :app:assembleDebug
328
+ app: app/build/outputs/apk/debug/app-debug.apk
329
+ device: Pixel 8 API 35
330
+ os-version: '15'
331
+ lt-username: ${{ secrets.LT_USERNAME }}
332
+ lt-access-key: ${{ secrets.LT_ACCESS_KEY }}
333
+ codex-api-key: ${{ secrets.CODEX_API_KEY }}
334
+ vars: ${{ toJSON(vars) }}
335
+ ```
336
+
337
+ Electron on macOS: Proofed launches and stops the app for each check. The build must
338
+ produce the code loaded by `main.js`.
339
+
340
+ ```yaml
341
+ runs-on: macos-latest
342
+ steps:
343
+ - uses: t1dem/proofed@main
344
+ with:
345
+ target: desktop
346
+ install: npm ci
347
+ build: npm run build
348
+ launch: "./node_modules/.bin/electron main.js --remote-debugging-port=9223"
349
+ cdp-endpoint: http://127.0.0.1:9223
350
+ lt-username: ${{ secrets.LT_USERNAME }}
351
+ lt-access-key: ${{ secrets.LT_ACCESS_KEY }}
352
+ codex-api-key: ${{ secrets.CODEX_API_KEY }}
353
+ vars: ${{ toJSON(vars) }}
354
+ ```
355
+
356
+ ### Platform support
357
+
358
+ Fake Kane tests check the build, install/upload arguments, process cleanup, cache and
359
+ fix ordering. They do not prove device automation, cloud uploads or runner setup.
360
+
361
+ 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.
362
+
363
+ | Target / host | Verified with real Kane runs |
364
+ |---|---|
365
+ | Web, GitHub-hosted Linux/macOS/Windows | Linux/macOS: verified; Windows: not yet verified |
366
+ | Desktop Electron, macOS runner | Verified on GitHub-hosted macOS |
367
+ | Android local, Apple Silicon Mac / self-hosted runner | Verified on a self-hosted Apple Silicon runner with an Android 14 emulator |
368
+ | Android/iOS cloud real devices, needs a TestMu plan with real devices | Not yet verified |
369
+ | iOS local simulator, Apple Silicon Mac | Not yet verified |
370
+ | Windows host | Not yet verified; local mobile requires an Apple Silicon Mac |
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "proofed-cli",
3
- "version": "0.1.3",
4
- "description": "Check web app scenarios in Chrome with Kane CLI before you call a change done.",
3
+ "version": "0.2.0",
4
+ "description": "Check web, Android and Electron app scenarios with Kane CLI before you call a change done.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/t1dem/proofed.git"
@@ -28,7 +28,7 @@
28
28
  "scripts": {
29
29
  "build": "node --input-type=module -e 'import { rmSync } from \"node:fs\"; rmSync(\"dist\", { recursive: true, force: true });' && tsc -p tsconfig.build.json",
30
30
  "typecheck": "tsc --noEmit",
31
- "test": "node --test src/*.test.ts",
31
+ "test": "node --test \"src/**/*.test.ts\"",
32
32
  "check:package": "node scripts/check-package.ts",
33
33
  "prepack": "npm run build",
34
34
  "prepublishOnly": "npm run typecheck && npm test && npm run check:package"
@@ -40,7 +40,12 @@
40
40
  "packageManager": "pnpm@10.20.0",
41
41
  "files": [
42
42
  "bin/*.cjs",
43
- "dist/*.js",
43
+ "dist/**/*.js",
44
+ "docs/cli.md",
44
45
  "README.md"
45
- ]
46
+ ],
47
+ "dependencies": {
48
+ "@modelcontextprotocol/sdk": "1.32.2",
49
+ "zod": "4.1.13"
50
+ }
46
51
  }
package/dist/cache.js DELETED
@@ -1,48 +0,0 @@
1
- // Passes Proofed doesn't pay for twice. A coding agent runs the check again after each fix, and a
2
- // scenario it didn't touch would cost another 20 to 30 credits to come out the same. A pass stays
3
- // good while its scenario file, its start URL, the commit the change is measured from and the
4
- // changed files in its `paths` (every changed file, when it has none) stay as they were. Only
5
- // passes are kept; everything else runs again.
6
- import { createHash } from "node:crypto";
7
- import { readFileSync, writeFileSync } from "node:fs";
8
- import { matchesGlob } from "node:path";
9
- export const CACHE_FILE = "cache.json";
10
- // The demo-store runs reported 27 to 30 credits without accounting for the balance change.
11
- export const DEFAULT_CREDITS = 30;
12
- export function readCache(file) {
13
- try {
14
- const data = JSON.parse(readFileSync(file, "utf8"));
15
- if (data.version === 1)
16
- return { version: 1, passes: data.passes ?? {}, last: data.last ?? {} };
17
- }
18
- catch {
19
- // Missing or unreadable: start over, the worst case is paying for a run again.
20
- }
21
- return { version: 1, passes: {}, last: {} };
22
- }
23
- export const writeCache = (file, cache) => writeFileSync(file, `${JSON.stringify(cache, null, 2)}\n`);
24
- export const estimate = (cache, id) => cache.last[id]?.credits ?? DEFAULT_CREDITS;
25
- // The changed files a scenario depends on.
26
- export const relevantChanges = (s, changed) => s.paths.length ? changed.filter((f) => s.paths.some((glob) => matchesGlob(f, glob))) : changed;
27
- const readOrUndefined = (file) => {
28
- try {
29
- return readFileSync(file);
30
- }
31
- catch {
32
- return undefined; // Deleted in the change.
33
- }
34
- };
35
- // `base`: the commit the change is measured from (mergeBaseOf).
36
- export function cacheKey(s, startUrl, changed, read = readOrUndefined, base = "") {
37
- const hash = createHash("sha256");
38
- // Length-prefixed, so no two different lists of parts hash the same.
39
- const add = (part) => hash.update(`${typeof part === "string" ? Buffer.byteLength(part) : part.length}:`).update(part);
40
- add(read(s.file) ?? s.objective);
41
- add(startUrl);
42
- add(base);
43
- for (const file of relevantChanges(s, changed).toSorted()) {
44
- add(file);
45
- add(read(file) ?? "\0deleted");
46
- }
47
- return hash.digest("hex");
48
- }
package/dist/chrome.js DELETED
@@ -1,77 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import { adopt, stopping } from "./children.js";
6
- import { log } from "./log.js";
7
- const candidates = [
8
- process.env.CHROME_PATH,
9
- "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
10
- "/usr/bin/google-chrome",
11
- "/usr/bin/google-chrome-stable",
12
- "/usr/bin/chromium",
13
- ];
14
- export const findChrome = () => candidates.find((p) => !!p && existsSync(p));
15
- const chromePath = () => {
16
- const found = findChrome();
17
- if (!found)
18
- throw new Error("Chrome not found; set CHROME_PATH");
19
- return found;
20
- };
21
- // We start Chrome ourselves (instead of letting Kane do it) so the recorder can attach to the same browser.
22
- // Chrome picks a free debugging port and writes it to DevToolsActivePort in its profile folder.
23
- // A cold runner can take a while to start the first Chrome, so it gets 30 s and one more try.
24
- export async function launchChrome({ headless = true } = {}) {
25
- for (let attempt = 1;; attempt++) {
26
- try {
27
- return await startChrome(headless);
28
- }
29
- catch (e) {
30
- if (attempt >= 2 || stopping())
31
- throw e;
32
- log(`${e instanceof Error ? e.message : e}; starting Chrome again`);
33
- }
34
- }
35
- }
36
- async function startChrome(headless) {
37
- const profile = mkdtempSync(join(tmpdir(), "proofed-chrome-"));
38
- const proc = spawn(chromePath(), [
39
- "--remote-debugging-port=0",
40
- `--user-data-dir=${profile}`,
41
- "--window-size=1280,800",
42
- "--no-first-run",
43
- "--no-default-browser-check",
44
- "--mute-audio",
45
- ...(headless ? ["--headless=new"] : []),
46
- ...(process.env.CI ? ["--no-sandbox"] : []),
47
- "about:blank",
48
- ], { stdio: "ignore" });
49
- let exited;
50
- const release = adopt({ kill: (signal) => proc.kill(signal), exited: new Promise((r) => proc.once("exit", r)) });
51
- proc.on("exit", (code) => {
52
- exited = code;
53
- release();
54
- // A profile is a few megabytes, one per Chrome; a laptop keeps its temp folder.
55
- try {
56
- rmSync(profile, { recursive: true, force: true, maxRetries: 2 });
57
- }
58
- catch {
59
- // A helper still writing into it; the OS cleans the temp folder eventually.
60
- }
61
- });
62
- const deadline = Date.now() + 30_000;
63
- while (Date.now() < deadline && exited === undefined) {
64
- const port = existsSync(join(profile, "DevToolsActivePort"))
65
- ? readFileSync(join(profile, "DevToolsActivePort"), "utf8").split("\n")[0]?.trim()
66
- : undefined;
67
- if (port) {
68
- const endpoint = `http://127.0.0.1:${port}`;
69
- const ok = await fetch(`${endpoint}/json/version`).then((r) => r.ok, () => false);
70
- if (ok)
71
- return { endpoint, close: () => proc.kill() };
72
- }
73
- await new Promise((r) => setTimeout(r, 200));
74
- }
75
- proc.kill();
76
- throw new Error(exited !== undefined ? `Chrome exited with code ${exited} on start` : "Chrome did not open its debugging port");
77
- }
package/dist/help.js DELETED
@@ -1,133 +0,0 @@
1
- const MAIN = `proofed: check a web app in real Chrome with Kane CLI before you call a change done.
2
- It runs the plain-English scenarios in .proofed/scenarios/ that your local change touches.
3
-
4
- Usage
5
- proofed check [text] [flags] Run the scenarios the local change touches, or check just [text]
6
- proofed list [flags] Every scenario: does the change touch it, is a pass cached
7
- proofed doctor [flags] Is Kane CLI (and its login), Chrome, ffmpeg and the app ready
8
- proofed <command> --help The flags of one command
9
- proofed --version
10
-
11
- Install (macOS and Linux; Node 22.18+ is required, including with bun)
12
- npm install -g proofed-cli pnpm add -g proofed-cli bun add -g proofed-cli
13
- Run without installing: npx proofed-cli | pnpm dlx proofed-cli | bunx proofed-cli
14
- Update: npm install -g proofed-cli@latest | pnpm add -g proofed-cli@latest | bun add -g proofed-cli@latest
15
- Uninstall: npm uninstall -g proofed-cli | pnpm remove -g proofed-cli | bun remove -g proofed-cli
16
- Pick one manager. The command runs on Node, with bun too.
17
-
18
- Usual runs, in the app's repo
19
- proofed check url and serve come from the Proofed workflow, if the repo has one
20
- proofed check --url http://localhost:5173 --serve "npm run dev"
21
- proofed check "the promo code welcome10 takes 10% off"
22
- proofed check --only free-shipping
23
-
24
- Time and credits
25
- A scenario takes 1 to 4 minutes; 3 run at a time. A first run is estimated at 30 Kane credits.
26
- Credits are what Kane reported, not the account balance change, which can be slightly higher.
27
- An interrupted run can spend credits before Kane reports them.
28
- A passed scenario isn't run again (0 credits, shown as "cached") until its file, the URL, or a
29
- changed file in its paths changes. --dry-run shows what would run and the estimate, for free.
30
- --no-cache runs them anyway.
31
-
32
- Outcomes
33
- passed Kane checked what the scenario says, and it held
34
- failed A scenario's check did not hold on the page. Review the failure and fix it.
35
- When Kane blames the scenario for it, the scenario is run a second time, at
36
- its cost again, and the second run is the result.
37
- not_checked Kane asserted nothing, or thinks the scenario text is wrong. Not a pass.
38
- error Kane couldn't finish, even on one automatic retry (browser or service trouble).
39
- Says nothing about the app.
40
-
41
- Exit codes
42
- 0 everything that ran passed, or nothing needed to run
43
- 1 at least one scenario failed
44
- 2 nothing failed, but at least one was not_checked or error
45
- 3 Proofed couldn't run: usage, setup (such as no Kane login), app not reachable
46
- 130 interrupted
47
-
48
- For AI agents
49
- After changing UI code, run: proofed check --json
50
- Give the command a timeout of at least 10 minutes, and don't interrupt it.
51
- stdout is one JSON document (progress goes to stderr); see proofed check --help.
52
- On "failed", read reason and diagnosis, then run "rerun" after fixing the cause.
53
- failedCheck: "scenario_doubted" means the check failed but Kane believes it is out of date.
54
- Diagnosis is Kane's opinion. If the app change was intended, update the scenario; otherwise fix the app.
55
- Never treat "not_checked" as a pass: fix the scenario or tell the user why Kane doubts it.
56
- On "error", run the "rerun" command once more. On exit 3, do what error.fix says; running the
57
- same command again without that won't help. kane_not_signed_in needs the user: kane-cli login;
58
- kane_keys_rejected needs working LT_USERNAME and LT_ACCESS_KEY from the user.`;
59
- const CHECK = `proofed check [text] [flags]
60
-
61
- Runs the scenarios the local change touches, in Chrome, with Kane, and says what broke.
62
- The local change: files that differ from the merge base with --base, committed or not, plus new
63
- files git doesn't ignore. Nothing changed: nothing runs (exit 0). Not a git repo: every scenario runs.
64
- With [text], Kane checks just that, e.g. proofed check "the cart total updates when I press +".
65
-
66
- Which scenarios
67
- --base <rev> Compare against this (default: origin/HEAD, origin/main, origin/master, main, master)
68
- --only <id,id> Exactly these (ids from proofed list)
69
- --all Every scenario
70
- --scenarios <dir> Where they are (default .proofed/scenarios, env PROOFED_SCENARIOS)
71
-
72
- Where the app is (flag, then env, then .proofed/config.json, then the Proofed workflow step)
73
- --url <url> Where it runs (env PROOFED_URL), e.g. http://localhost:5173
74
- --serve <cmd> Starts it when the URL doesn't answer; stopped at the end (env PROOFED_SERVE)
75
- --build <cmd> Runs before --serve (env PROOFED_BUILD)
76
- --install <cmd> Installs the app's dependencies before the build, when node_modules is
77
- missing or older than package.json or the lockfile (env PROOFED_INSTALL;
78
- default: the workflow's install, else the app's package manager)
79
- --reuse With a build set, a URL that already answers stops the check (exit 3): it
80
- may be an old build. --reuse tests what is running; its passes aren't cached
81
- --serve-timeout <s> How long the URL gets to answer after --serve (default 60)
82
-
83
- Running
84
- --dry-run Show what would run and the credit estimate; spends nothing
85
- --no-cache Run scenarios whose pass is cached, too
86
- --concurrency <n> Scenarios at a time (default 3)
87
- --headed Show Chrome
88
- --out <dir> Clips, logs, cache and result.json (default .proofed-out, env PROOFED_OUT)
89
- --verbose Also print Kane's steps and Chrome's log (always in <out>/run.log)
90
- --json stdout gets one JSON document and nothing else
91
-
92
- JSON (also written to <out>/result.json)
93
- ok, exitCode, summary, counts {passed, failed, not_checked, error, skipped}, base, url,
94
- app ("started" | "reused"), credits, estimatedCredits, seconds, next, rerun (re-runs
95
- everything that didn't pass),
96
- skipped [{id, name, why}], scenarios [{id, name, file, outcome, cached, cachedAt, objective,
97
- reason, notChecked ("nothing_asserted" | "scenario_doubted"), failedCheck ("scenario_doubted"),
98
- diagnosis (Kane's opinion), suggestion,
99
- failedStep, steps [{remark, failed}], pageError, clip {mp4, jpg}, credits, seconds, rerun}]
100
- failedCheck is only set on failed checks Kane blames on the scenario. suggestion gives the
101
- conditional next step: if the app change was intended, update the scenario; otherwise fix the app.
102
- credits is the sum Kane reported, not the balance change; the balance can drop slightly more.
103
- First-run estimate: 30 credits. An interrupted run can spend credits before reporting them.
104
- Proofed couldn't run: {ok: false, exitCode: 3, error: {code, message, fix}}
105
- Interrupted: the same shape with exitCode 130 and scenarios [...] for what had finished
106
-
107
- Before anything is built, the Kane login is checked with TestMu (kane-cli balance, free): without
108
- one the check stops with exit 3 and error.code "kane_not_signed_in"; with LT_USERNAME and
109
- LT_ACCESS_KEY that TestMu rejects, error.code "kane_keys_rejected".
110
-
111
- Exit codes: 0 passed, 1 failed, 2 not_checked or error, 3 couldn't run, 130 interrupted.`;
112
- const LIST = `proofed list [flags]
113
-
114
- Every scenario with its id, name, start URL and paths, whether the local change touches it, and
115
- whether a pass of it is cached. A file that doesn't parse is shown with its error (exit 3).
116
- Spends nothing.
117
-
118
- --base <rev> Compare against this (default: the remote's default branch)
119
- --url <url> The app's URL, for the cache (default: as proofed check finds it)
120
- --scenarios <dir> Default .proofed/scenarios
121
- --out <dir> Where the cache is (default .proofed-out)
122
- --json One JSON document: {ok, exitCode, base, url, scenarios [...], errors [{file, message}]}`;
123
- const DOCTOR = `proofed doctor [flags]
124
-
125
- Checks Node, git, the scenarios, Kane CLI (installed, signed in, credits left), Chrome, ffmpeg
126
- (optional: without it there are no clips, the verdicts still work) and where the app is. Every
127
- problem comes with the command or step that fixes it. Uses only Kane's free commands.
128
- Exit 0 when proofed check can run, else 3.
129
-
130
- --url, --serve, --build, --install As for proofed check
131
- --scenarios <dir> Default .proofed/scenarios
132
- --json {ok, exitCode, checks [{name, status: ok | warn | fail, detail, fix}]}`;
133
- export const helpText = (command) => (command === "check" ? CHECK : command === "list" ? LIST : command === "doctor" ? DOCTOR : MAIN);