proofed-cli 0.1.0 → 0.1.1

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 CHANGED
@@ -123,7 +123,7 @@ In the app's repo:
123
123
 
124
124
  The change is everything since the merge base with the default branch (`origin/HEAD`, else `origin/main`, or `--base`), uncommitted and untracked files included. The URL and the commands that build and serve the app come from `--url`, `--build` and `--serve`, then `PROOFED_URL`, `PROOFED_BUILD` and `PROOFED_SERVE`, then `.proofed/config.json`, then the Proofed step of the repo's workflow. In a repo that already runs Proofed on its PRs, `proofed check` needs no flags. If the app isn't running, Proofed builds and starts it, and stops it at the end. 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.
125
125
 
126
- A passed scenario isn't run again until its file, the URL, the base commit or a changed file in its `paths` changes. `--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. From a real run on the demo store with the free shipping threshold changed to €60. Shown with the current CLI wording and first-run estimate; paths are relative:
126
+ A passed scenario isn't run again until its file, the URL, the base commit or a changed file in its `paths` changes. `--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. From a real run on the demo store with the free shipping threshold changed to €60. Kane blamed the scenario, so the check ran twice, and the credits are for both runs. Paths are relative, and the credits in the "failed" line (56.8 in that run) are rounded as the CLI rounds them now:
127
127
 
128
128
  ```
129
129
  Proofed: checking 1 of 3 scenario(s), --only, at http://localhost:4173.
@@ -133,22 +133,27 @@ Building the app: pnpm build
133
133
  Starting the app: pnpm preview --port 4173
134
134
  Started the app in 1 s (build from --build, serve from --serve); its output is in .proofed-out/serve.log
135
135
  [0:01] started free-shipping: Free shipping from €50
136
- [0:26] still running: free-shipping 0:25 at "click: Clicking Add House Espresso to bag"
137
- [0:51] still running: free-shipping 0:50 at "Step 7"
138
- [1:16] still running: free-shipping 1:15 at "Step 11"
139
- [1:41] still running: free-shipping 1:41 at "assert: shipping is now Free and the total is €51.00."
140
- [2:01] failed free-shipping: Free shipping from €50 (2:00, 27.4 credits)
141
-
142
- ✗ Free shipping from €50 failed after 2:00
136
+ [0:26] still running: free-shipping 0:25 at "Step 3"
137
+ [0:51] still running: free-shipping 0:50 at "Step 9"
138
+ [1:16] still running: free-shipping 1:15 at "assert: shipping is now Free and the total is €51.00."
139
+ [1:41] still running: free-shipping 1:40 at "assert: shipping is now Free and the total is €51.00."
140
+ [1:45] retrying free-shipping: the check failed, but Kane blames the scenario; running it once more to be sure
141
+ [2:11] still running: free-shipping 2:10 at "Step 3"
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
143
148
  Kane saw Final verification failed: "shipping is now Free and the total is €51.00."
144
- Why The scenario's check did not hold on the page. Kane believes the scenario is out of date.
145
- Kane thinks The test used the wrong free-shipping threshold. The cart subtotal after adding one more Paper Filters was €51.00, which is still below the €60.00 threshold shown by the store.
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.
146
151
  Next If the change in the app was intended, update the scenario; otherwise fix the app.
147
152
  Failed step assert: shipping is now Free and the total is €51.00.
148
153
  Clip .proofed-out/free-shipping/clip.mp4
149
154
  Scenario .proofed/scenarios/free-shipping.md
150
155
 
151
- ✗ 1 failed · 27.4 credits · 2m 2s
156
+ ✗ 1 failed · 56.9 credits · 3m 52s
152
157
  Credits are Kane's report; balance may drop slightly more.
153
158
  1 of 1 broke: Free shipping from €50
154
159
  Re-run what broke: proofed check --only free-shipping --url http://localhost:4173 --serve 'pnpm preview --port 4173' --build 'pnpm build'
@@ -158,7 +163,7 @@ A first run is estimated at 30 Kane credits per scenario. Later estimates use th
158
163
 
159
164
  `--json` prints one JSON document on stdout and the progress on stderr. Every run also writes it to `.proofed-out/result.json`, next to the clips; the folder has its own `.gitignore`. The exit code is 0 when everything checked passed, 1 when a scenario failed, 2 when nothing failed but something wasn't checked, 3 when the check couldn't start (the message says why and how to fix it) and 130 on Ctrl-C or a closed terminal, which stops Kane, Chrome and the app first.
160
165
 
161
- `failedCheck: "scenario_doubted"` means a scenario's check failed, but Kane believes it 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. This stays a failure (exit 1). `notChecked: "scenario_doubted"` is used when Kane doubted the scenario without a failed check (exit 2).
166
+ `failedCheck: "scenario_doubted"` means a scenario's check failed, but Kane believes it 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. Such a failure is run a second time before it is reported, at the scenario's cost again, and the second run is the result: Kane gives the same verdict when it misreads a page that is fine, and a misreading rarely repeats. A check that fails both times is a failure (exit 1). `notChecked: "scenario_doubted"` is used when Kane doubted the scenario without a failed check (exit 2).
162
167
 
163
168
  For an agent, add this to the app's `AGENTS.md` or `CLAUDE.md`:
164
169
 
@@ -227,7 +232,7 @@ jobs:
227
232
 
228
233
  ## Limits
229
234
 
230
- - **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:` stays a failure even when Kane blames the scenario.
235
+ - **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.
231
236
  - **Fixes need Claude's usage limit to have room.** 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.
232
237
  - **Only flows with a scenario are checked.** A scenario whose `paths` miss a file isn't picked when that file changes.
233
238
  - **Slow next to unit tests.** One to four minutes of Kane per scenario, plus a build and a re-check per fix attempt.
@@ -242,6 +247,7 @@ Each fix is a few lines, found by a run that went wrong.
242
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` |
243
248
  | A run was still going after 361 seconds | A 360-second wall-clock limit over Kane's own `--timeout 300` | `src/kane.ts` |
244
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; the second run is the result | `src/run.ts` |
245
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` |
246
252
 
247
253
  ## Code
@@ -251,16 +257,16 @@ Node 24+ runs the checkout's TypeScript directly. The GitHub Action needs no bui
251
257
  `pnpm typecheck` and `pnpm test` check the source. `pnpm check:package` builds a tarball, checks its
252
258
  contents, installs it into a temporary prefix and runs its version and help. It removes its temp files.
253
259
 
254
- To release, confirm the version in `package.json` (currently `0.1.0`); published versions cannot be reused. From a clean checkout with Node 24+:
260
+ To release, confirm the version in `package.json` (currently `0.1.1`); published versions cannot be reused. From a clean checkout with Node 24+:
255
261
 
256
262
  ```sh
257
263
  pnpm install --frozen-lockfile
258
264
  npm login --registry=https://registry.npmjs.org/
259
265
  npm whoami --registry=https://registry.npmjs.org/
260
266
  npm publish --access public --registry=https://registry.npmjs.org/
261
- npm view proofed-cli@0.1.0 version bin engines dist.tarball --registry=https://registry.npmjs.org/
262
- npx --yes proofed-cli@0.1.0 --version
263
- npx --yes proofed-cli@0.1.0 --help
267
+ npm view proofed-cli@0.1.1 version bin engines dist.tarball --registry=https://registry.npmjs.org/
268
+ npx --yes proofed-cli@0.1.1 --version
269
+ npx --yes proofed-cli@0.1.1 --help
264
270
  ```
265
271
 
266
272
  Use the chosen version in the last three commands. `npm publish` runs typecheck, tests and the package
package/dist/check.js CHANGED
@@ -13,6 +13,7 @@ import { runAll } from "./pipeline.js";
13
13
  import { colorOn, LiveView, PlainView } from "./render.js";
14
14
  import { askedScenario } from "./requests.js";
15
15
  import { buildDoc, errorDoc, quote, sameCommand, scenarioDoc } from "./result.js";
16
+ import { creditsOf } from "./run.js";
16
17
  import { affectedBy, readScenarios } from "./scenarios.js";
17
18
  import { answers, startApp } from "./serve.js";
18
19
  import { SetupError } from "./setuperror.js";
@@ -208,8 +209,6 @@ export async function check(flags, text, io, view = makeView(flags, io)) {
208
209
  }
209
210
  const baseId = base?.rev ? mergeBaseOf(io.cwd, base.rev) : "";
210
211
  let appState;
211
- // What the attempts before an automatic retry took, per scenario.
212
- const retried = new Map();
213
212
  const cacheFile = join(out, CACHE_FILE);
214
213
  const cache = readCache(cacheFile);
215
214
  const keys = new Map();
@@ -307,17 +306,14 @@ export async function check(flags, text, io, view = makeView(flags, io)) {
307
306
  const cacheable = !(appState === "reused" && target.build);
308
307
  const onEvent = (e) => {
309
308
  view.event(e);
310
- if (e.type === "retry" && e.credits)
311
- retried.set(e.id, (retried.get(e.id) ?? 0) + e.credits);
312
309
  if (e.type !== "finished")
313
310
  return;
314
311
  finished.set(e.id, e.result);
315
312
  const key = keys.get(e.id);
316
313
  if (!key)
317
314
  return;
318
- const credits = e.result.end?.credits_consumed;
319
- if (credits !== undefined)
320
- cache.last[e.id] = { credits: credits + (retried.get(e.id) ?? 0) };
315
+ if (e.result.end?.credits_consumed !== undefined)
316
+ cache.last[e.id] = { credits: creditsOf(e.result) };
321
317
  if (e.result.outcome === "passed" && cacheable) {
322
318
  const clip = e.result.clip && { ...(e.result.clip.mp4 && { mp4: resolve(e.result.clip.mp4) }), jpg: resolve(e.result.clip.jpg) };
323
319
  cache.passes[e.id] = { key, passedAt: new Date().toISOString(), seconds: e.result.seconds, ...(clip && { clip }) };
@@ -331,7 +327,7 @@ export async function check(flags, text, io, view = makeView(flags, io)) {
331
327
  const byId = new Map(results.map((r) => [r.scenario.id, r]));
332
328
  return docOf(selected.map((s) => {
333
329
  const r = byId.get(s.id);
334
- return r ? { scenario: s, result: r, extraCredits: retried.get(s.id) } : items.get(s.id);
330
+ return r ? { scenario: s, result: r } : items.get(s.id);
335
331
  }));
336
332
  }
337
333
  }
package/dist/help.js CHANGED
@@ -32,6 +32,8 @@ Time and credits
32
32
  Outcomes
33
33
  passed Kane checked what the scenario says, and it held
34
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.
35
37
  not_checked Kane asserted nothing, or thinks the scenario text is wrong. Not a pass.
36
38
  error Kane couldn't finish, even on one automatic retry (browser or service trouble).
37
39
  Says nothing about the app.
package/dist/pipeline.js CHANGED
@@ -8,7 +8,7 @@ import { log } from "./log.js";
8
8
  import { crashResult, findCrashes } from "./precheck.js";
9
9
  import { buildReport, outdated, postsNew } from "./report.js";
10
10
  import { nothingAsked } from "./requests.js";
11
- import { scenarioDoubted, runScenario } from "./run.js";
11
+ import { creditsOf, scenarioDoubted, runScenario } from "./run.js";
12
12
  import { FAILED_CHECK_ACTION, FAILED_CHECK_REASON, RUN_FILE } from "./runfile.js";
13
13
  import { affectedBy, loadScenariosOr } from "./scenarios.js";
14
14
  export const env = (name, fallback) => {
@@ -128,7 +128,7 @@ export function runFile({ sha, results, skipped, runUrl, fix }, clips) {
128
128
  .slice(-30)
129
129
  .map((s) => ({ remark: s.remark.slice(0, 200), ...(s.status === "failed" && { failed: true }), ...(s.at !== undefined && { at: s.at }) })),
130
130
  clip: clips.get(r.scenario.id),
131
- credits: r.end?.credits_consumed,
131
+ credits: r.end?.credits_consumed === undefined ? undefined : creditsOf(r),
132
132
  seconds: r.seconds,
133
133
  })),
134
134
  fix: fix && {
package/dist/render.js CHANGED
@@ -3,6 +3,7 @@
3
3
  // agents and logs: no escape codes and no redraw, one line per event, a heartbeat at least every 30
4
4
  // seconds, then the same details. Colour is drawn by hand; there are no runtime dependencies.
5
5
  import { FAILED_CHECK_REASON } from "./runfile.js";
6
+ import { creditsOf } from "./run.js";
6
7
  import { outcomeOf } from "./result.js";
7
8
  // FORCE_COLOR=0 and NO_COLOR turn colour off, FORCE_COLOR=1 turns it on, even in a pipe.
8
9
  export function colorOn(env, isTTY) {
@@ -149,7 +150,7 @@ export class Board {
149
150
  if (e.type === "retry")
150
151
  Object.assign(row, { retry: e.error, remark: undefined });
151
152
  if (e.type === "finished") {
152
- Object.assign(row, { state: "done", outcome: outcomeOf(e.result), credits: e.result.end?.credits_consumed ?? 0, seconds: e.result.seconds ?? 0 });
153
+ Object.assign(row, { state: "done", outcome: outcomeOf(e.result), credits: Math.round(creditsOf(e.result) * 100) / 100, seconds: e.result.seconds ?? 0 });
153
154
  }
154
155
  }
155
156
  running() {
package/dist/report.js CHANGED
@@ -2,7 +2,7 @@ import { MARKER, OLD_MARKER } from "./github.js";
2
2
  import { BLANK_PAGE, FAILED_CHECK_ACTION, FAILED_CHECK_REASON, runMarker } from "./runfile.js";
3
3
  import { describeFixer } from "./models.js";
4
4
  import { nothingAsked } from "./requests.js";
5
- import { scenarioDoubted, unchecked } from "./run.js";
5
+ import { creditsOf, scenarioDoubted, unchecked } from "./run.js";
6
6
  const DATA_RE = /<!-- proofed:data (.*?) -->/s;
7
7
  export const FIX_BOX = "Fix with Claude";
8
8
  const COMMENT_LIMIT = 65_536;
@@ -202,7 +202,7 @@ function compose({ sha, results: all, skipped, clips, runUrl, fixEnabled, fix, a
202
202
  const errored = results.filter((r) => r.outcome === "error");
203
203
  const unsure = results.filter((r) => r.outcome === "unsure");
204
204
  const passed = results.filter((r) => r.outcome === "passed");
205
- const credits = all.reduce((sum, r) => sum + (r.end?.credits_consumed ?? 0), written?.credits ?? 0);
205
+ const credits = all.reduce((sum, r) => sum + creditsOf(r), written?.credits ?? 0);
206
206
  const repaired = fix?.status === "fixed" && previous
207
207
  ? passed.flatMap((after) => {
208
208
  const before = previous.failures.find((f) => f.id === after.scenario.id);
package/dist/result.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // The result of `proofed check` as one JSON document: what `--json` prints, what <out>/result.json
2
2
  // holds, and what the terminal views draw from. Its names are the CLI's contract with coding agents.
3
3
  import { resolve } from "node:path";
4
- import { scenarioDoubted, unchecked } from "./run.js";
4
+ import { creditsOf, scenarioDoubted, unchecked } from "./run.js";
5
5
  import { FAILED_CHECK_ACTION } from "./runfile.js";
6
6
  export const outcomeOf = (r) => (r.outcome === "unsure" ? "not_checked" : r.outcome);
7
7
  // Shell-safe as typed.
@@ -58,7 +58,7 @@ export function scenarioDoc(item, ctx) {
58
58
  .map((step) => ({ remark: step.remark.slice(0, 200), ...(step.status === "failed" && { failed: true }) })),
59
59
  ...(r.pageError && { pageError: r.pageError }),
60
60
  ...(r.clip && { clip: { ...(r.clip.mp4 && { mp4: resolve(r.clip.mp4) }), jpg: resolve(r.clip.jpg) } }),
61
- credits: round((r.end?.credits_consumed ?? 0) + (item.extraCredits ?? 0)),
61
+ credits: round(creditsOf(r)),
62
62
  ...(r.seconds !== undefined && { seconds: r.seconds }),
63
63
  rerun,
64
64
  };
package/dist/run.js CHANGED
@@ -30,7 +30,7 @@ export { NOTHING_CHECKED };
30
30
  const checked = (steps) => steps.some((s) => s.status === "done" && /^assert:/i.test(s.remark));
31
31
  // Kane read the page and the scenario's own check came out false. When the app is wrong all over
32
32
  // (a changed threshold shown in its banner too), Kane sides with the app and blames the test; the
33
- // scenario is what the app was meant to do, so that is a failure.
33
+ // scenario is what the app was meant to do, so that is a failure. runScenario runs it a second time.
34
34
  const refuted = (steps) => steps.some((s) => s.status === "failed" && /^assert:/i.test(s.remark));
35
35
  export function outcomeOf(end, steps) {
36
36
  if (!end || INFRA.test(end.reason ?? ""))
@@ -43,6 +43,9 @@ export function outcomeOf(end, steps) {
43
43
  // An unsure run where Kane said "passed": nothing was checked, as opposed to Kane doubting the test.
44
44
  export const unchecked = (r) => r.outcome === "unsure" && r.end?.status === "passed";
45
45
  export const scenarioDoubted = (r) => r.outcome === "failed" && r.end?.verdict?.family === "automation_bug";
46
+ // All the credits a scenario took, the runs before the last one included.
47
+ export const creditsOf = (r) => (r.end?.credits_consumed ?? 0) + (r.earlierCredits ?? 0);
48
+ const RECHECK = "the check failed, but Kane blames the scenario; running it once more to be sure";
46
49
  // Kane is good at reaching a goal, so on its own it routes around a broken button (a key press, another
47
50
  // link) and passes. A user who clicks the button and gets the wrong screen has found a bug.
48
51
  const NO_WORKAROUNDS = "Do each step once, the way it is described. If a click or a key press does something other than what " +
@@ -52,13 +55,27 @@ export function kaneObjective(objective) {
52
55
  return `${objective}\n\n${NO_WORKAROUNDS}`;
53
56
  }
54
57
  export async function runScenario(scenario, o) {
55
- let result = await runOnce(scenario, o);
56
- for (let i = 2; i <= (o.attempts ?? 2) && result.outcome === "error" && !stopping(); i++) {
57
- logLine(`[${scenario.id}] ${result.error ?? "infra error"}; retrying`);
58
- o.onEvent?.({ type: "retry", id: scenario.id, error: result.error ?? "infra error", credits: result.end?.credits_consumed });
59
- result = await runOnce(scenario, o);
58
+ let earlier = 0;
59
+ const again = (last, why) => {
60
+ earlier += last.end?.credits_consumed ?? 0;
61
+ logLine(`[${scenario.id}] ${why}`);
62
+ o.onEvent?.({ type: "retry", id: scenario.id, error: why });
63
+ return runOnce(scenario, o);
64
+ };
65
+ const settle = async (result) => {
66
+ for (let i = 2; i <= (o.attempts ?? 2) && result.outcome === "error" && !stopping(); i++) {
67
+ result = await again(result, result.error ?? "infra error");
68
+ }
69
+ return result;
70
+ };
71
+ let result = await settle(await runOnce(scenario, o));
72
+ // Kane gives the same verdict for a wrong value all over the app and for a page it misread (a
73
+ // heading that is there, reported as not visible). A wrong value is wrong again on a second
74
+ // run; a misreading rarely is. So the second run decides, whatever it comes to.
75
+ if (scenarioDoubted(result) && !stopping()) {
76
+ result = await settle(await again(result, RECHECK));
60
77
  }
61
- return result;
78
+ return earlier ? { ...result, earlierCredits: earlier } : result;
62
79
  }
63
80
  async function runOnce(scenario, o) {
64
81
  const log = (line) => logLine(`[${scenario.id}] ${line}`);
package/dist/runfile.js CHANGED
@@ -7,5 +7,5 @@ export const RUN_FILE = "run.json";
7
7
  export const runMarker = (key) => `<!-- proofed:run ${key} -->`;
8
8
  export const readRunKey = (body) => /<!-- proofed:run (pr-\d+\/[\w.-]+) -->/.exec(body)?.[1];
9
9
  // A refuted check stays a failure even when Kane blames the scenario. Consumers share the next step.
10
- export const FAILED_CHECK_REASON = "The scenario's check did not hold on the page. Kane believes the scenario is out of date.";
10
+ export const FAILED_CHECK_REASON = "The scenario's check did not hold on the page, on two runs in a row. Kane believes the scenario is out of date.";
11
11
  export const FAILED_CHECK_ACTION = "If the change in the app was intended, update the scenario; otherwise fix the app.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proofed-cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Check web app scenarios in Chrome with Kane CLI before you call a change done.",
5
5
  "repository": {
6
6
  "type": "git",