@asrunjs/asrun 0.0.0-stage → 0.5.2

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 (305) hide show
  1. package/.claude/commands/explore-case.md +18 -0
  2. package/.claude/commands/gen-spec.md +16 -0
  3. package/.claude/commands/heal-spec.md +26 -0
  4. package/.claude/commands/make-case.md +11 -0
  5. package/.claude/settings.json +5 -0
  6. package/.claude/skills/exploring-cases/SKILL.md +146 -0
  7. package/.claude/skills/exploring-cases/references/assertion-targets.md +103 -0
  8. package/.claude/skills/exploring-cases/references/handoff-card.js +128 -0
  9. package/.claude/skills/exploring-cases/references/open-questions.md +116 -0
  10. package/.claude/skills/exploring-cases/references/readiness.md +146 -0
  11. package/.claude/skills/exploring-cases/references/user-handoff.md +157 -0
  12. package/.claude/skills/generating-specs/SKILL.md +219 -0
  13. package/.claude/skills/generating-specs/references/conventions.md +148 -0
  14. package/.claude/skills/making-cases/SKILL.md +72 -0
  15. package/.claude/skills/making-cases/references/gaps.md +36 -0
  16. package/.claude/skills/making-cases/references/normalizing.md +39 -0
  17. package/.claude/skills/making-cases/references/splitting.md +28 -0
  18. package/.claude/skills/making-cases/references/writes-and-email.md +37 -0
  19. package/AGENTS.md +159 -0
  20. package/CLAUDE.md +2 -0
  21. package/LICENSE +21 -0
  22. package/README.md +511 -2
  23. package/bin/asrun.mjs +49 -0
  24. package/dist/lib/account-lock.d.ts +6 -0
  25. package/dist/lib/account-lock.js +52 -0
  26. package/dist/lib/assertions.d.ts +14 -0
  27. package/dist/lib/assertions.js +39 -0
  28. package/dist/lib/baselines.d.ts +43 -0
  29. package/dist/lib/baselines.js +108 -0
  30. package/dist/lib/build-artifacts.d.ts +8 -0
  31. package/dist/lib/build-artifacts.js +10 -0
  32. package/dist/lib/case-doc.d.ts +311 -0
  33. package/dist/lib/case-doc.js +1117 -0
  34. package/dist/lib/case-id.d.ts +11 -0
  35. package/dist/lib/case-id.js +17 -0
  36. package/dist/lib/case-ops.d.ts +26 -0
  37. package/dist/lib/case-ops.js +110 -0
  38. package/dist/lib/cases.d.ts +16 -0
  39. package/dist/lib/cases.js +51 -0
  40. package/dist/lib/cli.d.ts +10 -0
  41. package/dist/lib/cli.js +18 -0
  42. package/dist/lib/command.d.ts +24 -0
  43. package/dist/lib/command.js +90 -0
  44. package/dist/lib/downloads.d.ts +42 -0
  45. package/dist/lib/downloads.js +84 -0
  46. package/dist/lib/email.d.ts +10 -0
  47. package/dist/lib/email.js +19 -0
  48. package/dist/lib/ffmpeg.d.ts +8 -0
  49. package/dist/lib/ffmpeg.js +50 -0
  50. package/dist/lib/fixtures.d.ts +40 -0
  51. package/dist/lib/fixtures.js +149 -0
  52. package/dist/lib/login-card.d.ts +22 -0
  53. package/dist/lib/login-card.js +183 -0
  54. package/dist/lib/node-cli.d.ts +15 -0
  55. package/dist/lib/node-cli.js +36 -0
  56. package/dist/lib/paths.d.ts +25 -0
  57. package/dist/lib/paths.js +88 -0
  58. package/dist/lib/pdf.d.ts +71 -0
  59. package/dist/lib/pdf.js +140 -0
  60. package/dist/lib/profiles.d.ts +62 -0
  61. package/dist/lib/profiles.js +174 -0
  62. package/dist/lib/ready.d.ts +36 -0
  63. package/dist/lib/ready.js +53 -0
  64. package/dist/lib/records.d.ts +33 -0
  65. package/dist/lib/records.js +61 -0
  66. package/dist/lib/run-filters.d.ts +19 -0
  67. package/dist/lib/run-filters.js +38 -0
  68. package/dist/lib/run-summary.d.ts +90 -0
  69. package/dist/lib/run-summary.js +35 -0
  70. package/dist/lib/session.d.ts +30 -0
  71. package/dist/lib/session.js +111 -0
  72. package/dist/lib/summary-reporter.d.ts +16 -0
  73. package/dist/lib/summary-reporter.js +146 -0
  74. package/dist/lib/targets.d.ts +19 -0
  75. package/dist/lib/targets.js +26 -0
  76. package/dist/lib/ui-build.d.ts +10 -0
  77. package/dist/lib/ui-build.js +30 -0
  78. package/dist/lib/values.d.ts +29 -0
  79. package/dist/lib/values.js +85 -0
  80. package/dist/lib/write-gate.d.ts +41 -0
  81. package/dist/lib/write-gate.js +129 -0
  82. package/dist/playwright.config.d.ts +2 -0
  83. package/dist/playwright.config.js +92 -0
  84. package/dist/scripts/build.d.ts +1 -0
  85. package/dist/scripts/build.js +21 -0
  86. package/dist/scripts/check-cases.d.ts +1 -0
  87. package/dist/scripts/check-cases.js +149 -0
  88. package/dist/scripts/cleanup.d.ts +1 -0
  89. package/dist/scripts/cleanup.js +25 -0
  90. package/dist/scripts/cli.d.ts +1 -0
  91. package/dist/scripts/cli.js +28 -0
  92. package/dist/scripts/doctor.d.ts +1 -0
  93. package/dist/scripts/doctor.js +296 -0
  94. package/dist/scripts/explore.d.ts +1 -0
  95. package/dist/scripts/explore.js +75 -0
  96. package/dist/scripts/go.mjs +188 -0
  97. package/dist/scripts/heal-evidence.mjs +143 -0
  98. package/dist/scripts/init.d.ts +22 -0
  99. package/dist/scripts/init.js +332 -0
  100. package/dist/scripts/lint-specs.d.ts +1 -0
  101. package/dist/scripts/lint-specs.js +141 -0
  102. package/dist/scripts/login.d.ts +1 -0
  103. package/dist/scripts/login.js +75 -0
  104. package/dist/scripts/new-case.d.ts +1 -0
  105. package/dist/scripts/new-case.js +19 -0
  106. package/dist/scripts/render-pdf.d.ts +1 -0
  107. package/dist/scripts/render-pdf.js +44 -0
  108. package/dist/scripts/report.d.ts +1 -0
  109. package/dist/scripts/report.js +14 -0
  110. package/dist/scripts/review-baselines.d.ts +1 -0
  111. package/dist/scripts/review-baselines.js +30 -0
  112. package/dist/scripts/run.d.ts +1 -0
  113. package/dist/scripts/run.js +423 -0
  114. package/dist/scripts/status.d.ts +1 -0
  115. package/dist/scripts/status.js +31 -0
  116. package/dist/scripts/ui-build.d.ts +1 -0
  117. package/dist/scripts/ui-build.js +7 -0
  118. package/dist/scripts/ui-dev.d.ts +1 -0
  119. package/dist/scripts/ui-dev.js +3 -0
  120. package/dist/scripts/ui.d.ts +1 -0
  121. package/dist/scripts/ui.js +13 -0
  122. package/dist/ui/dev.d.ts +1 -0
  123. package/dist/ui/dev.js +36 -0
  124. package/dist/ui/server/actions.d.ts +95 -0
  125. package/dist/ui/server/actions.js +365 -0
  126. package/dist/ui/server/ai-models.d.ts +3 -0
  127. package/dist/ui/server/ai-models.js +347 -0
  128. package/dist/ui/server/ai-stream.d.ts +66 -0
  129. package/dist/ui/server/ai-stream.js +408 -0
  130. package/dist/ui/server/app.d.ts +4 -0
  131. package/dist/ui/server/app.js +395 -0
  132. package/dist/ui/server/cases.d.ts +23 -0
  133. package/dist/ui/server/cases.js +170 -0
  134. package/dist/ui/server/files.d.ts +5 -0
  135. package/dist/ui/server/files.js +67 -0
  136. package/dist/ui/server/index.d.ts +1 -0
  137. package/dist/ui/server/index.js +33 -0
  138. package/dist/ui/server/jobs.d.ts +80 -0
  139. package/dist/ui/server/jobs.js +317 -0
  140. package/dist/ui/server/profiles.d.ts +35 -0
  141. package/dist/ui/server/profiles.js +371 -0
  142. package/dist/ui/server/watch-files.d.ts +4 -0
  143. package/dist/ui/server/watch-files.js +36 -0
  144. package/dist/ui/shared/ai-commands.d.ts +88 -0
  145. package/dist/ui/shared/ai-commands.js +177 -0
  146. package/dist/ui/shared/case-id.d.ts +1 -0
  147. package/dist/ui/shared/case-id.js +1 -0
  148. package/dist/ui/shared/jobs.d.ts +6 -0
  149. package/dist/ui/shared/jobs.js +7 -0
  150. package/dist/ui/shared/product.d.ts +3 -0
  151. package/dist/ui/shared/product.js +3 -0
  152. package/dist/ui/shared/run-filters.d.ts +1 -0
  153. package/dist/ui/shared/run-filters.js +1 -0
  154. package/dist/ui/shared/site-address.d.ts +6 -0
  155. package/dist/ui/shared/site-address.js +11 -0
  156. package/dist/ui/shared/types.d.ts +371 -0
  157. package/dist/ui/shared/types.js +1 -0
  158. package/docs/agents/framework-dev.md +79 -0
  159. package/docs/theme-guide.html +922 -0
  160. package/package.json +109 -3
  161. package/templates/.claude/commands/explore-case.md +22 -0
  162. package/templates/.claude/commands/gen-spec.md +21 -0
  163. package/templates/.claude/commands/heal-spec.md +31 -0
  164. package/templates/.claude/commands/make-case.md +13 -0
  165. package/templates/.claude/settings.json +5 -0
  166. package/templates/.mcp.json +8 -0
  167. package/templates/AGENTS.md +64 -0
  168. package/templates/CLAUDE.md +1 -0
  169. package/templates/cases/_template.md +57 -0
  170. package/templates/gitignore +13 -0
  171. package/templates/opencode.jsonc +16 -0
  172. package/templates/package.json +31 -0
  173. package/templates/playwright.config.ts +3 -0
  174. package/templates/pnpm-workspace.yaml +5 -0
  175. package/templates/profiles.yaml +42 -0
  176. package/templates/seed.spec.ts +9 -0
  177. package/templates/tsconfig.json +14 -0
  178. package/ui/dist/apple-touch-icon.png +0 -0
  179. package/ui/dist/assets/apl-gfMMiTNf.js +1 -0
  180. package/ui/dist/assets/asciiarmor-C_eisQCp.js +1 -0
  181. package/ui/dist/assets/asn1-DCl_8MCW.js +1 -0
  182. package/ui/dist/assets/asterisk-BEn0Cwpx.js +1 -0
  183. package/ui/dist/assets/brainfuck-D5EjA2JK.js +1 -0
  184. package/ui/dist/assets/clike-xvONpD0Z.js +1 -0
  185. package/ui/dist/assets/clojure-BflJGmDX.js +1 -0
  186. package/ui/dist/assets/cmake-84nbDH0I.js +1 -0
  187. package/ui/dist/assets/cobol-DHLQUbN7.js +1 -0
  188. package/ui/dist/assets/coffeescript-De_zI4J0.js +1 -0
  189. package/ui/dist/assets/commonlisp-DgAKBe0r.js +1 -0
  190. package/ui/dist/assets/crystal-Bl6YKCG_.js +1 -0
  191. package/ui/dist/assets/css-CnaYoQib.js +1 -0
  192. package/ui/dist/assets/cypher-p9eYesGn.js +1 -0
  193. package/ui/dist/assets/d-DWkQyNnU.js +1 -0
  194. package/ui/dist/assets/diff-ChtP43wD.js +1 -0
  195. package/ui/dist/assets/dist-BGbe0-Aa.js +1 -0
  196. package/ui/dist/assets/dist-Ba-HC662.js +2 -0
  197. package/ui/dist/assets/dist-BtMLMthJ.js +1 -0
  198. package/ui/dist/assets/dist-Bw5-uxs9.js +1 -0
  199. package/ui/dist/assets/dist-BzulKuec.js +1 -0
  200. package/ui/dist/assets/dist-C-Oyo1ZT.js +1 -0
  201. package/ui/dist/assets/dist-C8MdhqgG.js +1 -0
  202. package/ui/dist/assets/dist-CG1pHn5m.js +1 -0
  203. package/ui/dist/assets/dist-CgIQYY1o.js +1 -0
  204. package/ui/dist/assets/dist-CmpteMYY.js +9 -0
  205. package/ui/dist/assets/dist-DDJNvivM.js +1 -0
  206. package/ui/dist/assets/dist-DF3F_I8N.js +1 -0
  207. package/ui/dist/assets/dist-DSy3dVf4.js +11 -0
  208. package/ui/dist/assets/dist-Dlorc3Sx.js +1 -0
  209. package/ui/dist/assets/dist-Dq6sW5Ur.js +1 -0
  210. package/ui/dist/assets/dist-Dr9crbBz.js +13 -0
  211. package/ui/dist/assets/dist-jjxQutEm.js +1 -0
  212. package/ui/dist/assets/dockerfile-DJkHQgkl.js +1 -0
  213. package/ui/dist/assets/dtd-DTF72YNO.js +1 -0
  214. package/ui/dist/assets/dylan-S7ucR4pR.js +1 -0
  215. package/ui/dist/assets/ebnf-D4c0_ac3.js +1 -0
  216. package/ui/dist/assets/ecl-BVIeWmwY.js +1 -0
  217. package/ui/dist/assets/eiffel-BEjRio4Q.js +1 -0
  218. package/ui/dist/assets/elm-Cshzl8qu.js +1 -0
  219. package/ui/dist/assets/erlang-BV0c4Hdn.js +1 -0
  220. package/ui/dist/assets/factor-LKH5gN8L.js +1 -0
  221. package/ui/dist/assets/fcl-ClOhbFR7.js +1 -0
  222. package/ui/dist/assets/forth-D6RzAl64.js +1 -0
  223. package/ui/dist/assets/fortran-Bt6PBEDR.js +1 -0
  224. package/ui/dist/assets/gas-BHEdbvp9.js +1 -0
  225. package/ui/dist/assets/gherkin-oBAE_ms0.js +1 -0
  226. package/ui/dist/assets/groovy-CUrWKPia.js +1 -0
  227. package/ui/dist/assets/haskell-BRsoo5mP.js +1 -0
  228. package/ui/dist/assets/haxe-DjVOVvNP.js +1 -0
  229. package/ui/dist/assets/http-CLVgA2GD.js +1 -0
  230. package/ui/dist/assets/idl-BUZw3wgd.js +1 -0
  231. package/ui/dist/assets/index-CTmnF0Wp.css +2 -0
  232. package/ui/dist/assets/index-P_Yo0ZZn.js +338 -0
  233. package/ui/dist/assets/javascript-lS2r2ifg.js +1 -0
  234. package/ui/dist/assets/julia-CQfgDRfP.js +1 -0
  235. package/ui/dist/assets/livescript-BXxG0Yva.js +1 -0
  236. package/ui/dist/assets/lua-DPCEkfD_.js +1 -0
  237. package/ui/dist/assets/mathematica-u8YMmbU0.js +1 -0
  238. package/ui/dist/assets/mbox-BEMVcqjs.js +1 -0
  239. package/ui/dist/assets/mirc-C9zpzAZU.js +1 -0
  240. package/ui/dist/assets/mllike-B45xgp2S.js +1 -0
  241. package/ui/dist/assets/modelica-CqHI_q-D.js +1 -0
  242. package/ui/dist/assets/mscgen-qgSLujhx.js +1 -0
  243. package/ui/dist/assets/mumps-BSzj6Xyz.js +1 -0
  244. package/ui/dist/assets/nginx-C-ORUuei.js +1 -0
  245. package/ui/dist/assets/nsis-viPvXFiq.js +1 -0
  246. package/ui/dist/assets/ntriples-CzMBulkp.js +1 -0
  247. package/ui/dist/assets/octave-D2Q8cUp1.js +1 -0
  248. package/ui/dist/assets/oz-BwTct_5T.js +1 -0
  249. package/ui/dist/assets/pascal-Dp_KdFgX.js +1 -0
  250. package/ui/dist/assets/perl-BkSkiI9m.js +1 -0
  251. package/ui/dist/assets/pig-AF4Hwhju.js +1 -0
  252. package/ui/dist/assets/powershell-D8WpQPaX.js +1 -0
  253. package/ui/dist/assets/properties-C357ku5U.js +1 -0
  254. package/ui/dist/assets/protobuf-D1ij_kNL.js +1 -0
  255. package/ui/dist/assets/pug-BqCHZ5xT.js +1 -0
  256. package/ui/dist/assets/puppet-BZyAS7I4.js +1 -0
  257. package/ui/dist/assets/python-B_1Jd8HM.js +1 -0
  258. package/ui/dist/assets/q-B9NhS7L_.js +1 -0
  259. package/ui/dist/assets/r-CxDmU1I4.js +1 -0
  260. package/ui/dist/assets/rpm-gpDK5sbt.js +1 -0
  261. package/ui/dist/assets/ruby-ChfNwlCY.js +1 -0
  262. package/ui/dist/assets/sas-C2OyD2Y6.js +1 -0
  263. package/ui/dist/assets/scheme-D9qYN0V5.js +1 -0
  264. package/ui/dist/assets/shell-DwuoZtxw.js +1 -0
  265. package/ui/dist/assets/sieve-tLWDfEkZ.js +1 -0
  266. package/ui/dist/assets/simple-mode-DXiLM1-G.js +1 -0
  267. package/ui/dist/assets/smalltalk-BLp5-jwC.js +1 -0
  268. package/ui/dist/assets/solr-B78wSQJQ.js +1 -0
  269. package/ui/dist/assets/sparql-Dz-mlCAC.js +1 -0
  270. package/ui/dist/assets/spreadsheet-CTIncYxj.js +1 -0
  271. package/ui/dist/assets/sql-DuQMFDvy.js +1 -0
  272. package/ui/dist/assets/stex-DNzd62Q_.js +1 -0
  273. package/ui/dist/assets/stylus-BOVgKnng.js +1 -0
  274. package/ui/dist/assets/swift-DKB6_1j6.js +1 -0
  275. package/ui/dist/assets/tcl-BGfruO1u.js +1 -0
  276. package/ui/dist/assets/textile-C4jVoHG1.js +1 -0
  277. package/ui/dist/assets/tiddlywiki-VlUiK86J.js +1 -0
  278. package/ui/dist/assets/tiki-CvUEFusT.js +1 -0
  279. package/ui/dist/assets/toml-BPTmHmyx.js +1 -0
  280. package/ui/dist/assets/troff-C2dAgh7P.js +1 -0
  281. package/ui/dist/assets/ttcn-PPSTk1ow.js +1 -0
  282. package/ui/dist/assets/ttcn-cfg-2b4Gb5sE.js +1 -0
  283. package/ui/dist/assets/turtle-Cx3rYX2g.js +1 -0
  284. package/ui/dist/assets/vb-BthdM_4N.js +1 -0
  285. package/ui/dist/assets/vbscript-D9f6rSsU.js +1 -0
  286. package/ui/dist/assets/velocity-CqftRsjg.js +1 -0
  287. package/ui/dist/assets/verilog-CjI9Y6RI.js +1 -0
  288. package/ui/dist/assets/vhdl-kS471soi.js +1 -0
  289. package/ui/dist/assets/webidl-D5jiJvOU.js +1 -0
  290. package/ui/dist/assets/xquery-BKJx4mf9.js +1 -0
  291. package/ui/dist/assets/yacas-CXXgtw0p.js +1 -0
  292. package/ui/dist/assets/z80-Co3PbHdE.js +1 -0
  293. package/ui/dist/favicon.ico +0 -0
  294. package/ui/dist/favicon.svg +11 -0
  295. package/ui/dist/help/ai-tools.png +0 -0
  296. package/ui/dist/help/case-explore.png +0 -0
  297. package/ui/dist/help/case-generate.png +0 -0
  298. package/ui/dist/help/cases-memo.png +0 -0
  299. package/ui/dist/help/profile-form.png +0 -0
  300. package/ui/dist/help/profiles-login.png +0 -0
  301. package/ui/dist/help/reports.png +0 -0
  302. package/ui/dist/help/run-tests.png +0 -0
  303. package/ui/dist/index.html +23 -0
  304. package/ui/dist/logos/claude.svg +1 -0
  305. package/ui/dist/logos/opencode.svg +1 -0
@@ -0,0 +1,146 @@
1
+ # Readiness: look at the result only after the content is there
2
+
3
+ Shared by `exploring-cases`, `generating-specs` and healing. It is binding in all three.
4
+
5
+ A page that has just reacted is not ready. Dialogs, composers, previews, lists and PDFs show a frame first and fill
6
+ in later. Reading it too early gives a false "missing", "empty" or "wrong", and exploration then writes the false fact
7
+ into the case, the spec encodes it, and healing believes it.
8
+
9
+ **The rule: after every action that loads something, wait for its key requests to finish and for the content itself
10
+ to be visible, before reading, asserting or recording anything.**
11
+
12
+ ## What "ready" is
13
+ All of these, in this order:
14
+ 1. **The key requests finished** with a success status. The key requests are the data calls the action starts
15
+ (the composer's content, the list query, the PDF render), not images, fonts or analytics.
16
+ 2. **Nothing says it is still loading**: no spinner, progress bar, skeleton, `aria-busy="true"`, "Loading..." text.
17
+ 3. **The content itself is visible**: a positive signal that only exists when the data is there (a field with its value, the
18
+ first row, an image whose `naturalWidth` is above 0), never "the frame is open".
19
+ 4. **Stable**: for exploration, two snapshots one second apart say the same.
20
+
21
+ A check for something **missing, empty or hidden** is only valid after a positive ready signal. "The list has no X"
22
+ means: the list finished loading and has rows, and none is X.
23
+
24
+ ## Exploring
25
+ - Know the key requests: after the action, call `browser_network_requests`, pick the data calls (XHR/fetch to the
26
+ app's API, the ones that return the content). Wait until they are finished; use `browser_network_clear` before the
27
+ action so the list only holds what the action started.
28
+ - Then wait for the content signal (`browser_wait_for` with text, or `browser_find` that the content is there), and
29
+ take the snapshot only then. A snapshot taken right after a click is a frame, not a fact.
30
+ - Observations record the ready signal: `(observed after <signal>, ...)`. A fact with no signal is not recorded.
31
+ - When the first read shows less than expected (empty, a missing field, a logo not there), do not record it yet and do
32
+ not raise a question yet. Wait for readiness, read again, and only then decide. Mention in the report that the first
33
+ read was too early, with what was missing.
34
+ - Do it for every profile: loading time differs between profiles and environments.
35
+
36
+ ## In the case
37
+ Steps and targets state their ready signal: `Ready when: <signal>` under the step, or the target card's `Ready when`.
38
+ Example: `Ready when: the composer's "To" field is visible and the logo image has loaded.` It is what `/gen-spec` turns into
39
+ `ready` and `responses`.
40
+
41
+ **A ready signal is when to look, `## Expected` is what must hold.** Write the shortest positive signal that proves the
42
+ content arrived (one element, one image, one first row): no counts, no negatives, no "and everything else is right". The
43
+ requirement itself lives in `## Expected`, and a check may repeat the same element the signal names — one is the wait,
44
+ the other the assertion. A ready signal is never the only place where a required behaviour is written down.
45
+
46
+ A step that loads something and has no `Ready when` is read too early by whoever replays it: `/gen-spec` then waits for
47
+ the step's text alone, and a check on what only appears later fails or records a false "empty". Add one to every step
48
+ whose action opens a page, a dialog, a tab, a list or a preview.
49
+
50
+ ## Generating (spec code)
51
+ Use `actAndWait` and `expectNotBusy` from `@asrunjs/asrun/ready`, and `verifyDownload` from `@asrunjs/asrun/downloads`:
52
+
53
+ ```ts
54
+ // ready: the composer shows its recipient field and the logo image has loaded
55
+ const composer = page.getByRole('dialog', {name: 'Email PDF'});
56
+ await actAndWait(page, () => option.click(), {
57
+ responses: [/\/api\/documents\/[^/]+\/email-preview/],
58
+ ready: [composer.getByRole('textbox', {name: 'To'}), logo],
59
+ });
60
+ await expectImageLoaded(logo);
61
+ ```
62
+
63
+ - Register the response wait **before** the action (`actAndWait` does).
64
+ - Every action that opens a dialog, a tab, a menu with data, a list or a preview waits for its key requests and its content
65
+ signal. The request URL patterns come from `browser_network_requests` during exploration, not from guesses; if none was
66
+ seen (the action was not run), say "not verified on the page" in the report.
67
+ - Never `waitForTimeout`, never `networkidle`. They wait for time or for silence, not for the content. `pnpm spec:lint` fails both.
68
+ - Never `if (await x.isVisible()) ...` to decide something that may not have loaded yet. Wait for a ready signal, then branch.
69
+ Where an element is genuinely optional, say what proves the page finished (`// ready: ...`) before looking for it.
70
+ - `locator.isVisible()` and `isHidden()` answer for this instant only. Their `timeout` option is deprecated and ignored:
71
+ `isVisible({timeout: 3_000})` does not wait 3 seconds. Never write it, and never use `.catch(() => false)` to make it
72
+ look like a wait. `pnpm spec:lint` fails both.
73
+ - An optional confirmation (see below) is handled with `clickOptionalUntilHidden`, not with `isVisible`.
74
+
75
+ ### Optional confirmations (a dialog that may or may not show up)
76
+ Closing a composer, leaving an editor or deleting something can raise "Discard draft?", "Are you sure?" or nothing at all,
77
+ and the dialog can show up a second or two after the click. A check made right after the click sees "no dialog" and skips
78
+ it, then the next check (the composer is closed) races a dialog that appears later and fails.
79
+
80
+ The click on the confirmation and the check that the action finished go into **one retry loop**:
81
+
82
+ ```ts
83
+ await composer.getByRole('button', {name: 'close', exact: true}).click();
84
+ await clickOptionalUntilHidden(page.getByRole('button', {name: 'Discard', exact: true}), composer, {
85
+ message: 'The email composer did not close',
86
+ });
87
+ ```
88
+
89
+ - Each round: click the confirmation if it is visible now, then check that the target is hidden. A late dialog is clicked
90
+ in a later round; no dialog passes in the first round.
91
+ - Never decide "there is no dialog" from one look, and never wait a fixed time for it.
92
+ - The same holds for any other optional modal (for example "Add to Business Tracker" after publishing): when the case says
93
+ it opens, assert it with a waiting `expect(...).toBeVisible({timeout})`; when it may or may not open, use a loop that
94
+ also checks the next page state, or wait for the signal that proves the action finished (URL, heading), then look.
95
+ - A check for absence needs a positive ready signal in front of it (`// ready: <signal>`).
96
+ - A new tab: wait for the page event first (`context.waitForEvent('page')`), then for its URL, then for its content signal.
97
+ - A download is verified with `verifyDownload` (below), never with a bare `waitForEvent('download')`.
98
+
99
+ ## Downloads
100
+ Any download (PDF, image, CSV, ZIP), in exploration and in the spec, is verified in five parts, and the verification
101
+ step fails as a whole when any part fails or times out:
102
+ 1. wait for the download to start after the click;
103
+ 2. wait for the download to finish;
104
+ 3. check that the file exists and has content;
105
+ 4. check that the file is valid for its kind (an image has the right signature; a ZIP/CSV likewise; a PDF starts with `%PDF-`,
106
+ ends with `%%EOF` and **opens with at least one page**), and run the case's own validation if there is one;
107
+ 5. any failure or timeout of 1 to 4 fails the verification with a message that names the stage.
108
+
109
+ `verifyDownload(page, trigger, {kind, fileName?, minBytes?, validate?})` does exactly this. Name the file type in the
110
+ case (`kind`), and describe in a target card what the file must contain.
111
+
112
+ ### PDF content: read it like a person (rendered images and extracted text)
113
+ A PDF check never stops at "it is a PDF". `verifyDownload(..., {kind: 'pdf'})` returns `file.pdf`, and
114
+ `expectPdf(file.pdf!, {...})` from `@asrunjs/asrun/pdf` then:
115
+ - **renders the pages to images** (scale 2, white background) and, for every region check, fails when the region is blank
116
+ and compares it with the profile's baseline image (2% tolerance; the first run with `--update-snapshots` creates the
117
+ baseline and a person looks at it, like any other baseline);
118
+ - **extracts the text** of every page and checks `textContains` / `textNotContains` (the names of the other profiles, for
119
+ example).
120
+ Regions are fractions of the page from the top-left corner; `corner('top-left')` is the usual logo corner.
121
+
122
+ **Which pages are checked is the case's decision, case by case:**
123
+ - The case says ONLY certain pages in strong words (a requirement: "only", "exactly", "must be on the first page", "the
124
+ logo is on the first and last page and nowhere else"): check just those (`pages: 'first' | 'last' | [1, 3]`), and put
125
+ `// pages: <the case's words>` above the check so a reviewer can see where the limit comes from.
126
+ - The case names pages softly ("should", "always", "usually", "typically", "normally", "e.g.") or names no page: check
127
+ **every page** (`pages: 'all'`, the default). The named page is then only the place where the check was first seen.
128
+ - A page limit that comes from the agent's own reading of the case is not allowed. When it is unclear whether a wording is
129
+ a strong requirement, check all pages and put the doubt in a `[non-blocking]` TODO.
130
+
131
+ **While exploring, the agent looks at the PDF too:** save the downloaded file under `.explore/` (`download.saveAs(...)`
132
+ in the same `browser_run_code_unsafe` call that waits for the download), run
133
+ `pnpm pdf:render <file> --out .explore/targets/<case-id>/<name> --pages all --corner top-left`, then **open the page
134
+ images** and say in the card where the logo really is on each page, which pages have it and which do not, and what the
135
+ text shows. The rendered pages are the card's `Reference`. If the logo is not where the case says, that is a question.
136
+
137
+ While exploring, do the same by hand: click, wait for the download event, see the file finish, read its size and its first
138
+ bytes. Record "(observed: <file name>, <size>, valid <kind>)".
139
+
140
+ ## Healing
141
+ A failure of the kind "missing", "empty", "not visible", "wrong count", "timeout waiting for X" is first a suspected
142
+ readiness problem, then a suspected product problem:
143
+ 1. Read the failure screenshot and video: was the page still loading (a spinner, a skeleton, an empty frame)?
144
+ 2. Run the failing step by hand with the readiness protocol above and compare.
145
+ 3. Only when the content is complete and still not what the case says is it a test-expectation or product matter.
146
+ 4. A readiness fix goes into the spec as `actAndWait` / a ready signal, never as a longer timeout alone and never as a sleep.
@@ -0,0 +1,157 @@
1
+ # User handoff: a person works in the browser, the agent waits
2
+
3
+ Used by `exploring-cases` (and by `making-cases` never: it does not open a browser). `generating-specs` never hands
4
+ off; it replays the step recipes that an exploration recorded.
5
+
6
+ ## The rule
7
+ **An agent never writes data.** Not in staging, not in production. Every step that creates, edits, publishes, shares,
8
+ deletes or otherwise changes data, and every step that needs a human's choice (an existing document, items, a contact
9
+ name), is done by the user in the browser window that Playwright opened. Writing is rare (only while preparing a
10
+ case) and a person succeeds where an agent guesses. The agent drives only what is read-only: open, look, read,
11
+ hover, switch tabs, open and close dialogs and menus.
12
+
13
+ The runtime permission is a different thing and stays as it is: `writes: [<env>, ...]` in the case front matter says
14
+ where the finished spec may write, and a human confirms a run in any environment except staging.
15
+
16
+ ## When a handoff happens
17
+ Only in an attended run (`--attended`, a person is at the machine, the browser window is visible). A step is a
18
+ handoff when it is marked `[input]` or `[writes]` in the case, or when the agent finds out while exploring that the
19
+ next action would write data or needs a choice.
20
+
21
+ Without `--attended` the agent does not wait. It writes a `TODO [blocking]` under that step ("a person has to
22
+ perform this step; run /explore-case with --attended") and goes on with the rest. Never wait for a person in a run
23
+ that nobody watches.
24
+
25
+ ## Before the handoff
26
+ 1. Say what the user has to do and when it is finished, in one or two sentences ("Fill in the form, pick two
27
+ items, then press Done"). Name the finish condition first (below).
28
+ 2. Put every text the user has to type into `copy` (the `[asrun] ...` name of a document, a title), so it can be
29
+ copied with one click.
30
+ 3. Never ask the user to send email (production: never; other environments: only when `email` is `true` for the
31
+ profile). Never ask for login or 2FA. Name everything the user creates `[asrun] <something>`.
32
+ 4. Start recording with `browser_start_recording` (see "Recording").
33
+
34
+ ## The wait loop
35
+ Run it with one `browser_run_code_unsafe` call. A single call may wait for minutes (verified: 150 s without a
36
+ timeout), so no polling from outside is needed. The loop:
37
+
38
+ - **Shows a small floating card, not a bar.** It sits in the bottom-left corner and only the card takes clicks, so
39
+ nothing of the page is covered or blocked. The user can **drag** it by its title bar and **minimize** it to a small
40
+ pill that still has a Done button. Position and minimized state survive a page reload (kept in `sessionStorage`).
41
+ - **Click to copy.** Every text in `copy` (for example the `[asrun] ...` name the user has to type) is shown on its
42
+ own line with a copy icon; one click puts it on the clipboard and the icon shows "Copied". Pass only text that the
43
+ case says to type; leave `copy` empty when there is none.
44
+ - **Resets the flag first**: `window.__handoff = null` on every page it paints. A flag left over from an earlier
45
+ handoff ends the wait at once.
46
+ - **Paints the card on every open tab** and repaints after navigation (a new page has no card). The document
47
+ editor opens in a new tab, so the loop looks at `context.pages()`, not only at the first page.
48
+ - **Stops** when one of these happens, whichever is first: the user presses Done or "Cannot do this" on the card
49
+ (`window.__handoff` is `'done'` or `'skip'`), or the finish condition holds, or the time is up (default 10 minutes).
50
+ - **Ends visibly**: the card turns green and says control is back for two seconds, then it is removed, and the tab
51
+ titles are restored.
52
+ - The card lives in a Shadow DOM (the site's CSS cannot change it), does not take keyboard focus (the user can keep
53
+ typing in the page) and works even when the page locks all clicks behind a modal. The icons are inline SVG because
54
+ the card is injected into the page under test; the web UI's react-feather rule does not apply to it.
55
+
56
+ **Never write this code yourself and never shorten it.** It lives in `references/handoff-card.js` (next to this
57
+ file) and a rewritten, simplified card has already gone wrong once: it had no drag handle, no minimize button and
58
+ no copy icon. Load that file in two calls:
59
+
60
+ **Two calls, every time.** Set the options with their own call and only then run the card, for every handoff,
61
+ including a second one later in the same run. Never reuse the options of an earlier handoff and never change them
62
+ inside the call that runs the card: OpenCode reports a tool call only when it ends, so the options call is the only
63
+ way the web UI can see that a person is needed while the card waits. With the card alone there is no "Your turn"
64
+ badge, no count in the tab title and no notification (a HINT in the job log says so).
65
+
66
+ 1. Set the options on the browser context (this call only sets data):
67
+ ```js
68
+ async (page) => {
69
+ page.context().__handoffCfg = {
70
+ message: '<what the user does, one sentence>',
71
+ copy: [], // texts to type, e.g. ['[asrun] published document']
72
+ doneText: null, // text that appears when finished, or null
73
+ maxMs: 600000,
74
+ };
75
+ return 'cfg set';
76
+ }
77
+ ```
78
+ 2. Run the card and wait: `browser_run_code_unsafe` with `filename` set to the absolute path of
79
+ `<framework>/.claude/skills/exploring-cases/references/handoff-card.js` (use the absolute path of the repository, a
80
+ relative one is resolved against the workspace root, which may be the parent folder). It returns `{outcome: 'done' | 'skip' | 'condition' | 'timeout', waitedMs}`.
81
+
82
+ Check once, after the card shows, that it looks right: take a screenshot and see a title bar with a move icon, a
83
+ chevron button at its right and, when `copy` is not empty, a line per text with a copy icon. If not, stop and report
84
+ it; do not hand off with a broken card.
85
+
86
+ Tell the user in the chat (the terminal or the UI job log) as well: "Your turn in the browser window: <task>. Press
87
+ Done on the card (bottom-left; drag it if it is in the way) when you finish." When the run was started from the web
88
+ UI, the UI notices the handoff by itself (it sees the `__handoffCfg` call and the `handoff-card.js` call, whether the
89
+ browser tool is called directly or through the CLI's code mode, as OpenCode's `execute` tool does) and shows the
90
+ "Your turn" badge, a count in the tab title and, if the person switched notifications on, a browser notification;
91
+ this is why the message in `__handoffCfg` must be a plain string literal. A macOS notification is a bonus and may
92
+ fail in a sandbox: `osascript -e 'display notification "<task>" with title "AsRun" sound name "Glass"'`. If it
93
+ fails, go on.
94
+
95
+ ## Finish condition
96
+ Pick one that the page can show, before the handoff, and write it into the message of the card:
97
+ - a text that appears (a "Saved" toast, the title of the next step) or one that goes away;
98
+ - a URL that the page reaches;
99
+ - an element that appears or disappears (an editor that closes).
100
+
101
+ The Done button is always there (also on the minimized card) as the fallback, and "Cannot do this" lets the user give up a step.
102
+
103
+ ## After the handoff
104
+ - The card turns green and says control is back ("Done: control is back with Playwright. Do not touch the page.")
105
+ for two seconds before it is removed, so the user knows when they may let go.
106
+ - `outcome: 'timeout'` or `'skip'`: do not guess. Write a `TODO [blocking]` under the step and go on with what does
107
+ not depend on it.
108
+ - Take a snapshot and write down what the user did (see "Recording"), then continue read-only.
109
+ - At the end of the exploration hand off once more when the user created data: "Delete the [asrun] items you
110
+ created, then press Done". The case must clean up after itself, and so must the exploration.
111
+
112
+ ## Recording
113
+ Between the start and the end of a handoff the agent records what the user does (`browser_start_recording`,
114
+ `browser_stop_recording`). The recorded Playwright code is **raw material, never saved as it is**. It is turned into
115
+ a general recipe and written under the step as `- Recipe (phase): ...` lines (format below). The recipe holds what the
116
+ user did in words, plus the **labels and roles of the controls** they used ("the textbox 'Title'", "the button
117
+ 'Next'"), because `/gen-spec` cannot write data and so cannot see those controls itself. It never holds selectors,
118
+ ids or the names of data that can change.
119
+
120
+ Make the recipe as general as possible, because lists and data change:
121
+ - **A choice from a list that can change** (items, search results, a contact list): record the position, never the
122
+ name or id. "Select items #1 to #3 from the list."
123
+ - **Random is allowed only when the user asks for it** ("pick any 3"). The default is the position, because it can be
124
+ repeated. A random pick must be written into the test's annotations when the spec runs.
125
+ - **Text the case creates**: `[asrun] <something>`.
126
+ - **A value that has to exist** (an existing name, a search term): write what it must be like ("a name that
127
+ returns a result") and the observed value as `(observed "<value>", 🔍 to be confirmed by QA)` plus a
128
+ `[non-blocking]` TODO block. Do not put a brittle literal in as the only truth.
129
+ - **Nothing that depends on the pick** may become an assertion (a total changes with the items). Say so in a
130
+ TODO when a check would.
131
+ - Settings that the user changed on purpose (a toggle, a template) are recorded as they were set, by label.
132
+
133
+ If the recording tool fails or returns nothing, describe what the user did from before/after snapshots instead.
134
+
135
+ ## Recipe lines under a step
136
+ One or more `- Recipe (phase): ...` lines directly under the `[input]` or `[writes]` step they belong to, indented by
137
+ four spaces. The phase is optional (`start`, `items`, `finish`, ...). The step is the key; there is no step number to
138
+ keep in sync.
139
+
140
+ ```
141
+ 3. Select an existing document and pick 3 items. [input]
142
+ - Recipe (start): search for an existing document and pick result #1 (observed search term "...", 🔍 to be confirmed by QA).
143
+ - ❓ TODO [non-blocking]: Is any result that opens fine as the starting point? (seen on example-staging)
144
+ - ✍️ Answer:
145
+ - Recipe (items): select 3 items by position (#1 to #3) from the list.
146
+ - Recipe (finish): press "Next" until the "Publish" button shows, then publish.
147
+ ```
148
+
149
+ A step that is marked `[input]` or `[writes]` and has no `- Recipe:` line has never been explored. `generating-specs`
150
+ stops on it, and `pnpm case:check` warns about it.
151
+
152
+ ## Hard rules
153
+ - Never write data yourself, never press a button that writes. In production the same, with no exception.
154
+ - Never wait in an unattended run.
155
+ - Never ask a person to log in, pass 2FA or send email through the handoff.
156
+ - Never save selectors, ids or the names of changing data into a case. Control labels and roles are fine.
157
+ - Never read or print anything under `.auth/`.
@@ -0,0 +1,219 @@
1
+ ---
2
+ name: generating-specs
3
+ description: Turns a human-written test case (cases/<id>.md, the id may include a group folder such as documents/landing-page) into a Playwright spec (tests/<id>.spec.ts) for the multi-profile test suite, explores the real pages to learn the locators and values, and completes the case's own "## Values" block. It only generates: it never runs the tests. Use when asked to generate, update, fix or heal a spec, or for /gen-spec.
4
+ ---
5
+
6
+ # Generating specs from case documents
7
+
8
+ Read `references/conventions.md` first. It defines the spec shape, fixtures, assertion layers and
9
+ the read-only rules. Read the workspace `AGENTS.md` for the hard rules and the project rules. Read `../exploring-cases/references/open-questions.md`: it
10
+ defines how open questions are written into the case file, resolved and reported. Also read
11
+ `../exploring-cases/references/assertion-targets.md` (the exact thing each check looks at) and
12
+ `../exploring-cases/references/readiness.md` (wait for the content, verify downloads in five parts). All three are binding here.
13
+
14
+ This skill never stops to ask the user in the chat, because it may run without anybody present (a one-shot
15
+ `claude -p` / `opencode run`). Questions go into the case file; the final line is `RESULT: ready` or
16
+ `RESULT: needs-input`.
17
+
18
+ This skill trusts the case. What the pages show, what a person has to enter, and what the open questions are is
19
+ settled by `/explore-case` and recorded in the case (`(observed, ...)` marks, the step recipes). Generating
20
+ only finds locators and writes code: it replays the case and does not judge the case again.
21
+
22
+ Generating a spec and running it are separate processes. This skill only writes files: it does not run
23
+ `pnpm asrun`, does not create screenshot baselines and does not judge whether the spec passes. The user runs the
24
+ spec afterwards (see the report). Healing a failing spec (below) is the exception: it reads the last report first and runs only the profiles that are logged in, and only when the report is not enough.
25
+
26
+ ## Before you start
27
+ Read the workspace `AGENTS.md`: its §2 holds the project rules, and it points at the framework baseline. If
28
+ `.claude/skills/generating-specs.md` exists in the workspace, read it and apply it after this skill. Then apply
29
+ `AGENTS.md` §2, which wins over both (the baseline, "Precedence"). F1–F6 always win. This is not a stop condition:
30
+ continue with the procedure below.
31
+
32
+ ## Inputs
33
+ - The case id and the environment to explore in (`staging` or `production`). There is no default. If the
34
+ environment is missing, stop before exploring and report `RESULT: needs-input` ("pass the environment").
35
+ - Optionally `--force`: regenerate the spec from scratch and overwrite the existing one. See "An existing spec".
36
+
37
+ A case id is its path below `cases/` without `.md`: `hub-landing`, or `documents/landing-page` when the case is in a
38
+ folder (one level only). The spec is at the same path below `tests/` (`tests/documents/landing-page.spec.ts`); both import
39
+ the framework through the `@asrunjs/asrun/*` alias, so the folder depth does not change the imports.
40
+
41
+ - `cases/<id>.md` (front matter: `id`, `login: required|none` (`none` = public page; the login page itself is not a valid case), `suites: [<name>, ...]` (the old `priority: <level>` means one suite), `writes: [<env>, ...]` (omitted = read-only; the environments the spec may write in, e.g. `[staging]`) + `writes-note`, optional `envs: [...]`; sections Steps (with a step's `- Recipe:` lines) / Expected / Values / Visual checks / Targets; an old `## Inputs` section may still hold recipes). `## Values` holds one fenced yaml block keyed by `default` and by profile id, with the exact literals the spec asserts. The case document is the only place where expected values live.
42
+ - `profiles.yaml` (profiles: id, name, env, baseURL, account, tags, email). It holds no expected values.
43
+
44
+ ## An existing spec
45
+ Decide this first, before exploring anything. The spec path is `tests/<id>.spec.ts`.
46
+ - **No spec yet:** generate it (the procedure below).
47
+ - **A spec exists and `--force` was not given:** do not touch it. Do not edit the spec, the case values or any baseline.
48
+ Report that the spec already exists, say that `--force` regenerates and overwrites it, and give the id and
49
+ environment to run it again with. End with `RESULT: ready` (the spec that exists is not in question). Nothing else
50
+ is written, not even the case file.
51
+ - **A spec exists and `--force` was given:** the user chose to overwrite it. Regenerate it from the case with the
52
+ procedure below, and write the new file over the old one (do not merge with it: the case file is the source of
53
+ truth). Do not read the old spec as a starting point and do not keep it just because the result looks the same:
54
+ write the file from the case and the exploration. If it ends up identical, say so in the report. Keep the `## Values`
55
+ of other cases untouched; only this case's `## Values` is yours. Leave the
56
+ baseline images in `tests/<id>.spec.ts-snapshots/` alone: a changed visual check needs a person to update them,
57
+ so list in the report which baselines may now be out of date. Say in the report that an existing spec was
58
+ overwritten.
59
+
60
+ ## Procedure
61
+ 1. **Make sure the case uses the artifact language.** `AGENTS.md` §2 sets it (English by default), and spec step
62
+ titles copy the case's step text. If `cases/<id>.md` is written in another language, translate it into that
63
+ language and rewrite the file BEFORE anything else: keep the front matter keys and values, the section headings,
64
+ the `## Values` entries and the step numbering as they are, and keep quoted UI text exactly as it appears
65
+ on the page (do not translate strings the page shows). Do not add, drop or reinterpret any step or
66
+ expectation; if a sentence is unclear, translate it literally and raise it as a question in the next step.
67
+ Tell the user in the report that the case file was translated. Skip this when the case already uses that language.
68
+ 2. **Validate the case.** Collect everything that is ambiguous, every check without an expected value and every
69
+ missing per-profile value, including the `TODO` items already in the case. Resolve them in the order of
70
+ `open-questions.md`; do not stop here:
71
+ - **Steps that write or need a choice (`[input]`, `[writes]`) need a recipe.** Each must have at least one
72
+ `- Recipe (phase): ...` line under it in the case (written by `/explore-case`). An old case may still hold the
73
+ same recipe in `## Inputs`: use that line until it is moved under the step. If one has none, the case was
74
+ never explored with a person: stop before opening a browser, do not write the spec, and report `RESULT:
75
+ needs-input` with exactly this: "step <n> has no recorded input; run `/explore-case <id> <env> --attended`
76
+ first". Nothing else is written.
77
+ - Facts the page can answer and that the case does not hold yet are read in step 4 and written into the case as
78
+ `(observed, 🔍 to be confirmed by QA)`. A spec is generated from observed values.
79
+ - Safe defaults are applied: the suggestion is the sentence above the TODO block, and the block stays in the case
80
+ as `❓ TODO [non-blocking]` with an empty `✍️ Answer:`. A sentence with no TODO block under it is confirmed text.
81
+ - A non-empty `Answer:` is the user's answer: it wins over the sentence above it. Fold it into the case.
82
+ - Only what is always-blocking in `open-questions.md` blocks. Generate everything else; for a blocked check
83
+ (a `[blocking]` block), write `test.fixme(true, '<the question>')` inside its step (or skip that profile), never
84
+ an invented value and never a check built from the sentence above a `[blocking]` block.
85
+ - **Every check on a logo, image, icon, file, PDF, screenshot or repeated text needs a target card** (`## Targets`,
86
+ referenced as `[T<n>]`) that was observed (`Reference <profile-id>:` is a screenshot, not `none`) and has no open
87
+ `[blocking]` block. A check that has no card, or whose card is not observed, is not guessed here. Do not pick
88
+ an element yourself: report `RESULT: needs-input` with "check <text> has no observed target; run `/explore-case
89
+ <id> <env>` first" (or, when the card has a `[blocking]` TODO, write `test.fixme(true, '<the question>')` for that check as
90
+ the rule above says and go on with the rest).
91
+ - **Evidence gate:** a hard assertion (one that decides pass or fail) on something nobody has seen on a page is not
92
+ written. "Not verified on the page" is allowed for a locator of a page that only exists after a write step, but
93
+ never for what the check asserts about it: that goes to `test.fixme` with the reason, or `needs-input`.
94
+ - Do not invent expected values. If the case's `## Values` and the spec disagree, the case wins: fix the spec and
95
+ mention the change in the report.
96
+ 3. **Check sessions** if `login: required`: run `pnpm status --env <env>`. If a profile needs login, tell the
97
+ user to run `pnpm signin <profile-id>` and continue with the profiles that are ready. If `pnpm status`
98
+ cannot run (a sandbox error such as `listen EPERM` or a Chromium start failure), judge by the page instead: a page
99
+ that lands on the login page means the profile is not logged in.
100
+ 4. **Replay the case on the real page** with the `playwright-test` MCP. If its tools are not registered in this
101
+ session (no `browser_*` / `generator_*` tool) or it reports that it failed to start, do not fall back to ad-hoc
102
+ Playwright scripts: stop, tell the user which MCP server is missing and to run `pnpm asrun doctor`, write no spec,
103
+ and end with `RESULT: needs-input`.
104
+ Call `generator_setup_page` with
105
+ `project=<profile-id>` (for example `example-staging`) and `seedFile=tests/seed.spec.ts`, then perform the
106
+ steps in the environment you were given (never ask for it; there is no default) to learn the locators.
107
+ Do the read-only steps as written. **Never perform a step that writes or needs a choice**: the agent does not write
108
+ data, in staging or in production, and it does not hand off to a person here or wait for one. Write those steps
109
+ of the spec from the `- Recipe:` lines under the step (positions, `[asrun]` names, control labels and roles that
110
+ `/explore-case` recorded). Pages that only exist after such a step cannot be seen from here: write their locators
111
+ from what the recipe and the exploration notes say, mark them in the report as "not verified on the page", and
112
+ leave the first run of the spec (or `/heal-spec`) to confirm them. Do this for at least one profile
113
+ per domain (example.com and exampleshop.com differ in markup). Profiles that are not logged in are skipped and
114
+ named in the report. Use this exploration to answer the open points of step 2, and look at every profile that has
115
+ an entry in `## Values` to read its value.
116
+ Keep every browser call short (one action, about 60 s at most, a snapshot between steps, `{timeout: 5000}` when
117
+ something may not appear, no third retry): see "Keep every browser call short" in `../exploring-cases/SKILL.md`.
118
+ **Ready before you read, here too** (`readiness.md`): `browser_network_clear`, act, wait for the key requests
119
+ (`browser_network_requests`) and the content signal, then snapshot. The request URL patterns for `actAndWait` and the
120
+ `Ready when` signals of the case are taken from what you see here.
121
+ **Check every target on the page:** for each target card, find its `Identified by` locator, confirm that it matches
122
+ exactly one element and that this element is what `What` says (highlight it and read the screenshot). A locator that
123
+ matches several elements or the wrong one is fixed or becomes a question, never `.first()`.
124
+ Prefer `getByTestId` (the project uses `data-tn`), then role/label locators. No CSS chains or XPath.
125
+ Update the case file with what you learned: fold observations into the right section marked
126
+ `(observed, 🔍 to be confirmed by QA)`, remove the TODO blocks they answer (rewrite the sentence above the block),
127
+ and narrow the ones that remain. Keep the shape of `open-questions.md` for every block. Edit the case
128
+ with targeted edits; never touch its `## Source` table.
129
+ 5. **Complete the case's `## Values`**: for every profile the spec runs for, add the entry with the literals the spec
130
+ asserts (the same keys as `default`, only what differs). Do not move values into `profiles.yaml`; it holds connection
131
+ settings only. Mention every value you added or corrected in the report.
132
+ 6. **Write `tests/<id>.spec.ts`** (inside the group folder if the id has one, creating it if needed) following the conventions. One `test()` per outcome, and every
133
+ case step wrapped in `test.step()` with the case's step text as the title, and the top-level
134
+ `test.describe` tagged with `caseTags('<id>')`. The spec must
135
+ contain no profile-specific literals: everything profile-specific comes from `requireValues('<id>', profile)`
136
+ (`@asrunjs/asrun/values`), which merges `default` with the running profile's entry.
137
+ Every action that loads something goes through `actAndWait` (`@asrunjs/asrun/ready`) with the key requests and the ready
138
+ signal; every download goes through `verifyDownload` (`@asrunjs/asrun/downloads`); every check on a target has
139
+ `// target: T<n>` on the line before it; every absence check has a `// ready: <signal>` before it. Never
140
+ `waitForTimeout`, `networkidle` or `.first()` to pick an image. A confirmation or modal that may or may not appear is
141
+ never decided by one `isVisible()` look (its `timeout` option is ignored): use `clickOptionalUntilHidden`
142
+ (`@asrunjs/asrun/ready`) or a waiting `expect(...).toBeVisible({timeout})`; see `readiness.md`, "Optional confirmations".
143
+ 7. **Check the files**: run `pnpm typecheck`, `pnpm spec:lint <id>` and `pnpm case:check` (or `node --import tsx <framework>/scripts/check-cases.ts` if
144
+ it fails with a sandbox error such as `listen EPERM`). Fix every error, including every `FAIL` of the spec lint (a lint failure is never silenced: fix the spec or turn the check
145
+ into a question). Every lint `WARN` is handled too: fix it, or name it in the report with the reason it is acceptable.
146
+ Then do the **self-review**: for each assertion answer in writing "if the product were broken, would this fail?"
147
+ and "if the product is right, could this fail by timing?" (a check that cannot fail, or that races the page, is rewritten).
148
+ For every branch that depends on something possibly not there yet (`if`, `.count()`, `.catch(() => false)`), ask "what
149
+ if it shows up a second later?"; the answer must be a retry loop or a waiting assertion, never a single look.
150
+ Do NOT run `pnpm asrun`, do not use
151
+ `--update-snapshots` and do not create baselines: the first run of the spec does that, and a person reviews them.
152
+ 8. **Report** in the user's language: spec path, **an assertion table** (step, what is asserted, target card, ready signal, and
153
+ `observed on the page` or `not verified`; no row may be missing), profiles explored, profiles skipped (and why), whether the case file was
154
+ translated, what was added to the case file as observed, checks generated from observations (QA must confirm
155
+ them), visual checks that need a baseline on the first run, and the remaining TODO blocks (`[blocking]` ones with
156
+ the sentence that deleting the block would confirm). State that the spec was not run and give the command to run it:
157
+ `pnpm asrun --env <env> --profile <ids> --grep <id>` (with `--update-snapshots` once if the spec has visual
158
+ checks, then run `pnpm baselines:review <id> --new` and open every new image: it must show what its target card says). The last line is `RESULT: ready` (no `[blocking]` question left, spec
159
+ written and the checks above pass) or `RESULT: needs-input`, as defined in `open-questions.md`.
160
+
161
+ ## Cases that write data
162
+ Only when the case front matter lists environments under `writes` (for example `writes: [staging]`). Never add
163
+ `--allow-writes` or set `ASRUN_ALLOW_WRITES`. Use the `records` fixture, `configureCase` and `emailStepAllowed` as
164
+ described in `references/conventions.md`. The agent does not perform write steps while generating (see step 4); the
165
+ spec does, when a person runs it in an environment that `writes` lists. Elsewhere the runner skips the case with a
166
+ notice. Never send email in production; in other environments only if `profile.email` is true, otherwise skip that step and say so
167
+ in the report.
168
+
169
+ ## Healing a failing spec
170
+ Inputs: the case id and the environment (both required, there is no default: without an environment stop and say so),
171
+ optionally `--profiles a,b`, `--report <run-id>` and `--hints <file>` (or free text after the arguments). Healing is
172
+ the one case where this skill runs specs, and only in the environment given.
173
+
174
+ Heal from evidence, not from a habit of rerunning. A report that already exists says what failed.
175
+
176
+ 1. **Read the user's clues first** (the `--hints` file, or the free text). They say what to look at and may hold
177
+ evidence the report lacks. They guide the diagnosis and nothing else: they never lower the bar for a product
178
+ finding and never allow an expectation to be changed just to make a test pass. Quote the clue you used, or say that
179
+ it did not hold up, in the report.
180
+ 2. **Read the existing report**: run `pnpm heal:evidence --case <case-id> --env <env>` (add `--profile a,b` when `--profiles`
181
+ was given). It reads `reports/*/summary.json` and prints, per profile, the status, the failed step, the error, the call
182
+ log, the screenshots and videos, and ends with `EVIDENCE: fresh | stale | no-failure | none`. With `--report <run-id>`,
183
+ read `reports/<run-id>/summary.json` instead. Look at the screenshot when the error alone does not explain it. A profile
184
+ that failed only because it was not logged in is no evidence about the spec.
185
+ 3. **Decide whether to rerun the case**. Do not rerun when the report is `fresh`, names the failing step and the error,
186
+ and that is enough to tell whether the product changed or the test is wrong. Rerun when:
187
+ - there is no report (`none`), or it is `stale` (the spec, the case or `profiles.yaml` changed after it);
188
+ - the report does not explain the failure (a bare timeout with no locator, a failure before any step, a truncated log);
189
+ - a clue from the user has to be checked against the real page;
190
+ - a profile that must be healed has no result in the report (for example it was not logged in then).
191
+ Rerun with one plain command, as few profiles as possible, and say why in the report:
192
+ `pnpm asrun --env <env> --logged-in --profile <ids> --grep <case-id>` (optionally piped to `tail`; do not chain it
193
+ with other commands, or it runs inside Claude's sandbox and fails with `listen EPERM`). Always add `--logged-in`: it
194
+ leaves out the profiles that are not logged in instead of failing them. A profile that is not logged in is never healed:
195
+ name it in the report with `pnpm signin <profile-id>`.
196
+ 4. **Audit the assertion before you blame anyone.** Read the `assertion-targets.md` and `readiness.md` sections on healing.
197
+ - Is the locator still what the target card says (`What`, `Identified by`)? Open the failure screenshot and the
198
+ baseline (`pnpm baselines:review <case-id>`) and look at each: a baseline that shows something other than the card
199
+ (a content image instead of a logo) is a wrong test, and passing runs on it prove nothing. Delete it and report it; a
200
+ person creates the new baseline after the spec is fixed. Note: other profiles that pass on the same wrong target are also suspect.
201
+ - Is the failure a "missing / empty / not visible / timeout" kind? Then it is first a readiness suspect: was the page
202
+ still loading in the screenshot or video? Fix with `actAndWait` and a ready signal, never with a longer timeout alone or a sleep.
203
+ - Is the spec weak in the ways the lint knows? Run `pnpm spec:lint <case-id>` and fix every `FAIL` while you are there.
204
+ - A download that fails says which stage failed (start, finish, exists, valid): fix the stage, do not loosen the check.
205
+ - Doubt about which element is meant: write the question into the case (a `[blocking]` TODO naming the exact image,
206
+ text, place or UI) instead of choosing; do not rewrite the card quietly.
207
+ 5. **Decide whether the PRODUCT changed or the TEST is wrong.**
208
+ - Locator/timing problem: fix the spec.
209
+ - A real product difference (wrong logo, wrong name): do NOT change the expectation to make it
210
+ pass. Report it as a finding with the trace/screenshot path.
211
+ 6. **After editing the spec, run it once to confirm** (same command as in step 3, for the profiles you healed). That rerun
212
+ is the only one that is always allowed. Run `pnpm typecheck` too.
213
+ 7. **Report** in the user's language: which report was read (or that there was none) and whether it was fresh or stale,
214
+ whether the case was run again and why (or why not), what was changed, what is a product finding (with paths),
215
+ which assertions were wrong or raced the page, which baselines are wrong and were deleted, what the user's clues contributed, which profiles were left out because they are not logged in, and the result of the
216
+ confirming run.
217
+
218
+ A case that writes data in `production` needs a person's confirmation at run time, so the rerun is refused there:
219
+ use the report, or heal in staging, and never add `--allow-writes`.