@plune-ai/cairn 0.4.2 → 0.6.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 (262) hide show
  1. package/README.md +55 -261
  2. package/dist/agent/graph.d.ts +41 -0
  3. package/dist/agent/graph.d.ts.map +1 -1
  4. package/dist/agent/graph.js +110 -8
  5. package/dist/agent/graph.js.map +1 -1
  6. package/dist/agent/index.d.ts +34 -0
  7. package/dist/agent/index.d.ts.map +1 -1
  8. package/dist/agent/index.js +238 -54
  9. package/dist/agent/index.js.map +1 -1
  10. package/dist/agent/summary.d.ts +11 -0
  11. package/dist/agent/summary.d.ts.map +1 -1
  12. package/dist/agent/summary.js +10 -0
  13. package/dist/agent/summary.js.map +1 -1
  14. package/dist/analyze/index.d.ts +2 -0
  15. package/dist/analyze/index.d.ts.map +1 -1
  16. package/dist/analyze/index.js +1 -0
  17. package/dist/analyze/index.js.map +1 -1
  18. package/dist/api/adversarial.d.ts +38 -0
  19. package/dist/api/adversarial.d.ts.map +1 -0
  20. package/dist/api/adversarial.js +175 -0
  21. package/dist/api/adversarial.js.map +1 -0
  22. package/dist/api/cases.d.ts +105 -0
  23. package/dist/api/cases.d.ts.map +1 -0
  24. package/dist/api/cases.js +256 -0
  25. package/dist/api/cases.js.map +1 -0
  26. package/dist/api/coverage.d.ts +51 -0
  27. package/dist/api/coverage.d.ts.map +1 -0
  28. package/dist/api/coverage.js +80 -0
  29. package/dist/api/coverage.js.map +1 -0
  30. package/dist/api/openapi.d.ts +84 -0
  31. package/dist/api/openapi.d.ts.map +1 -0
  32. package/dist/api/openapi.js +119 -0
  33. package/dist/api/openapi.js.map +1 -0
  34. package/dist/api/runner.d.ts +58 -0
  35. package/dist/api/runner.d.ts.map +1 -0
  36. package/dist/api/runner.js +285 -0
  37. package/dist/api/runner.js.map +1 -0
  38. package/dist/api/scenario-runner.d.ts +22 -0
  39. package/dist/api/scenario-runner.d.ts.map +1 -0
  40. package/dist/api/scenario-runner.js +132 -0
  41. package/dist/api/scenario-runner.js.map +1 -0
  42. package/dist/api/scenarios.d.ts +31 -0
  43. package/dist/api/scenarios.d.ts.map +1 -0
  44. package/dist/api/scenarios.js +71 -0
  45. package/dist/api/scenarios.js.map +1 -0
  46. package/dist/api/testcase-docs.d.ts +12 -0
  47. package/dist/api/testcase-docs.d.ts.map +1 -0
  48. package/dist/api/testcase-docs.js +22 -0
  49. package/dist/api/testcase-docs.js.map +1 -0
  50. package/dist/artifacts/index.d.ts +23 -0
  51. package/dist/artifacts/index.d.ts.map +1 -1
  52. package/dist/artifacts/index.js +61 -1
  53. package/dist/artifacts/index.js.map +1 -1
  54. package/dist/artifacts/report.d.ts +29 -0
  55. package/dist/artifacts/report.d.ts.map +1 -1
  56. package/dist/artifacts/report.js +96 -0
  57. package/dist/artifacts/report.js.map +1 -1
  58. package/dist/artifacts/testcase-md.d.ts +27 -0
  59. package/dist/artifacts/testcase-md.d.ts.map +1 -1
  60. package/dist/artifacts/testcase-md.js +61 -0
  61. package/dist/artifacts/testcase-md.js.map +1 -1
  62. package/dist/browser/backends/playwright-lib.d.ts +12 -0
  63. package/dist/browser/backends/playwright-lib.d.ts.map +1 -1
  64. package/dist/browser/backends/playwright-lib.js +48 -3
  65. package/dist/browser/backends/playwright-lib.js.map +1 -1
  66. package/dist/browser/recovery.d.ts +42 -0
  67. package/dist/browser/recovery.d.ts.map +1 -0
  68. package/dist/browser/recovery.js +62 -0
  69. package/dist/browser/recovery.js.map +1 -0
  70. package/dist/browser/types.d.ts +7 -0
  71. package/dist/browser/types.d.ts.map +1 -1
  72. package/dist/checklist/index.d.ts +7 -0
  73. package/dist/checklist/index.d.ts.map +1 -1
  74. package/dist/checklist/index.js +14 -0
  75. package/dist/checklist/index.js.map +1 -1
  76. package/dist/ci/github.d.ts +83 -0
  77. package/dist/ci/github.d.ts.map +1 -0
  78. package/dist/ci/github.js +104 -0
  79. package/dist/ci/github.js.map +1 -0
  80. package/dist/ci/index.d.ts +14 -0
  81. package/dist/ci/index.d.ts.map +1 -0
  82. package/dist/ci/index.js +35 -0
  83. package/dist/ci/index.js.map +1 -0
  84. package/dist/ci/inputs.d.ts +93 -0
  85. package/dist/ci/inputs.d.ts.map +1 -0
  86. package/dist/ci/inputs.js +100 -0
  87. package/dist/ci/inputs.js.map +1 -0
  88. package/dist/ci/run.d.ts +51 -0
  89. package/dist/ci/run.d.ts.map +1 -0
  90. package/dist/ci/run.js +207 -0
  91. package/dist/ci/run.js.map +1 -0
  92. package/dist/ci/summary.d.ts +42 -0
  93. package/dist/ci/summary.d.ts.map +1 -0
  94. package/dist/ci/summary.js +45 -0
  95. package/dist/ci/summary.js.map +1 -0
  96. package/dist/cli/index.d.ts.map +1 -1
  97. package/dist/cli/index.js +65 -4
  98. package/dist/cli/index.js.map +1 -1
  99. package/dist/codegen/index.d.ts +13 -1
  100. package/dist/codegen/index.d.ts.map +1 -1
  101. package/dist/codegen/index.js +75 -0
  102. package/dist/codegen/index.js.map +1 -1
  103. package/dist/codegen/journey-setup.d.ts +14 -0
  104. package/dist/codegen/journey-setup.d.ts.map +1 -0
  105. package/dist/codegen/journey-setup.js +69 -0
  106. package/dist/codegen/journey-setup.js.map +1 -0
  107. package/dist/config/index.d.ts.map +1 -1
  108. package/dist/config/index.js +9 -0
  109. package/dist/config/index.js.map +1 -1
  110. package/dist/config/profiles.d.ts +6 -0
  111. package/dist/config/profiles.d.ts.map +1 -1
  112. package/dist/config/profiles.js +13 -0
  113. package/dist/config/profiles.js.map +1 -1
  114. package/dist/config/schema.d.ts +6 -0
  115. package/dist/config/schema.d.ts.map +1 -1
  116. package/dist/core/modalities/api.d.ts +27 -0
  117. package/dist/core/modalities/api.d.ts.map +1 -0
  118. package/dist/core/modalities/api.js +321 -0
  119. package/dist/core/modalities/api.js.map +1 -0
  120. package/dist/core/modalities/explore.d.ts.map +1 -1
  121. package/dist/core/modalities/explore.js +19 -1
  122. package/dist/core/modalities/explore.js.map +1 -1
  123. package/dist/core/registry.d.ts.map +1 -1
  124. package/dist/core/registry.js +4 -1
  125. package/dist/core/registry.js.map +1 -1
  126. package/dist/design/critique.d.ts +86 -0
  127. package/dist/design/critique.d.ts.map +1 -0
  128. package/dist/design/critique.js +62 -0
  129. package/dist/design/critique.js.map +1 -0
  130. package/dist/design/index.d.ts +2 -0
  131. package/dist/design/index.d.ts.map +1 -1
  132. package/dist/design/index.js +1 -0
  133. package/dist/design/index.js.map +1 -1
  134. package/dist/design/schema.d.ts +74 -0
  135. package/dist/design/schema.d.ts.map +1 -1
  136. package/dist/design/schema.js +22 -0
  137. package/dist/design/schema.js.map +1 -1
  138. package/dist/design/style.d.ts +18 -0
  139. package/dist/design/style.d.ts.map +1 -0
  140. package/dist/design/style.js +34 -0
  141. package/dist/design/style.js.map +1 -0
  142. package/dist/documentarian/index.d.ts +53 -0
  143. package/dist/documentarian/index.d.ts.map +1 -0
  144. package/dist/documentarian/index.js +135 -0
  145. package/dist/documentarian/index.js.map +1 -0
  146. package/dist/eval/coverage.d.ts +49 -0
  147. package/dist/eval/coverage.d.ts.map +1 -0
  148. package/dist/eval/coverage.js +60 -0
  149. package/dist/eval/coverage.js.map +1 -0
  150. package/dist/eval/gap-cases.d.ts +21 -0
  151. package/dist/eval/gap-cases.d.ts.map +1 -0
  152. package/dist/eval/gap-cases.js +27 -0
  153. package/dist/eval/gap-cases.js.map +1 -0
  154. package/dist/eval/legend.d.ts +3 -3
  155. package/dist/eval/legend.js +3 -3
  156. package/dist/eval/pilot.d.ts +4 -1
  157. package/dist/eval/pilot.d.ts.map +1 -1
  158. package/dist/eval/pilot.js +9 -2
  159. package/dist/eval/pilot.js.map +1 -1
  160. package/dist/flow/crawl.d.ts +66 -0
  161. package/dist/flow/crawl.d.ts.map +1 -0
  162. package/dist/flow/crawl.js +0 -0
  163. package/dist/flow/crawl.js.map +1 -0
  164. package/dist/flow/journey.d.ts +25 -0
  165. package/dist/flow/journey.d.ts.map +1 -0
  166. package/dist/flow/journey.js +51 -0
  167. package/dist/flow/journey.js.map +1 -0
  168. package/dist/flow/setup.d.ts +85 -0
  169. package/dist/flow/setup.d.ts.map +1 -0
  170. package/dist/flow/setup.js +65 -0
  171. package/dist/flow/setup.js.map +1 -0
  172. package/dist/index.d.ts +2 -1
  173. package/dist/index.d.ts.map +1 -1
  174. package/dist/knowledge/index.d.ts +30 -4
  175. package/dist/knowledge/index.d.ts.map +1 -1
  176. package/dist/knowledge/index.js +80 -22
  177. package/dist/knowledge/index.js.map +1 -1
  178. package/dist/llm/index.d.ts +2 -2
  179. package/dist/llm/index.d.ts.map +1 -1
  180. package/dist/llm/index.js +1 -1
  181. package/dist/llm/index.js.map +1 -1
  182. package/dist/llm/routing.d.ts.map +1 -1
  183. package/dist/llm/routing.js +8 -2
  184. package/dist/llm/routing.js.map +1 -1
  185. package/dist/llm/schema-lint.d.ts +9 -0
  186. package/dist/llm/schema-lint.d.ts.map +1 -0
  187. package/dist/llm/schema-lint.js +42 -0
  188. package/dist/llm/schema-lint.js.map +1 -0
  189. package/dist/llm/structured.d.ts +22 -0
  190. package/dist/llm/structured.d.ts.map +1 -1
  191. package/dist/llm/structured.js +42 -0
  192. package/dist/llm/structured.js.map +1 -1
  193. package/dist/mcp/server.d.ts +9 -0
  194. package/dist/mcp/server.d.ts.map +1 -0
  195. package/dist/mcp/server.js +49 -0
  196. package/dist/mcp/server.js.map +1 -0
  197. package/dist/mcp/tools.d.ts +149 -0
  198. package/dist/mcp/tools.d.ts.map +1 -0
  199. package/dist/mcp/tools.js +138 -0
  200. package/dist/mcp/tools.js.map +1 -0
  201. package/dist/observe/parse-aria.d.ts.map +1 -1
  202. package/dist/observe/parse-aria.js +11 -2
  203. package/dist/observe/parse-aria.js.map +1 -1
  204. package/dist/project/index.d.ts +70 -0
  205. package/dist/project/index.d.ts.map +1 -0
  206. package/dist/project/index.js +173 -0
  207. package/dist/project/index.js.map +1 -0
  208. package/dist/prompts/local/identify-elements.d.ts +1 -1
  209. package/dist/prompts/local/identify-elements.d.ts.map +1 -1
  210. package/dist/prompts/local/identify-elements.js +5 -2
  211. package/dist/prompts/local/identify-elements.js.map +1 -1
  212. package/dist/prompts/local/index.d.ts.map +1 -1
  213. package/dist/prompts/local/index.js +8 -0
  214. package/dist/prompts/local/index.js.map +1 -1
  215. package/dist/prompts/local/pilot-review.d.ts +1 -1
  216. package/dist/prompts/local/pilot-review.d.ts.map +1 -1
  217. package/dist/prompts/local/pilot-review.js +2 -1
  218. package/dist/prompts/local/pilot-review.js.map +1 -1
  219. package/dist/prompts/local/qa-case-critique.d.ts +8 -0
  220. package/dist/prompts/local/qa-case-critique.d.ts.map +1 -0
  221. package/dist/prompts/local/qa-case-critique.js +34 -0
  222. package/dist/prompts/local/qa-case-critique.js.map +1 -0
  223. package/dist/prompts/local/qa-gap-cases.d.ts +7 -0
  224. package/dist/prompts/local/qa-gap-cases.d.ts.map +1 -0
  225. package/dist/prompts/local/qa-gap-cases.js +22 -0
  226. package/dist/prompts/local/qa-gap-cases.js.map +1 -0
  227. package/dist/prompts/local/qa-journey-from-flow.d.ts +7 -0
  228. package/dist/prompts/local/qa-journey-from-flow.d.ts.map +1 -0
  229. package/dist/prompts/local/qa-journey-from-flow.js +29 -0
  230. package/dist/prompts/local/qa-journey-from-flow.js.map +1 -0
  231. package/dist/prompts/local/qa-setup-planner.d.ts +6 -0
  232. package/dist/prompts/local/qa-setup-planner.d.ts.map +1 -0
  233. package/dist/prompts/local/qa-setup-planner.js +28 -0
  234. package/dist/prompts/local/qa-setup-planner.js.map +1 -0
  235. package/dist/prompts/local/qa-testcase-from-ui.d.ts +1 -1
  236. package/dist/prompts/local/qa-testcase-from-ui.d.ts.map +1 -1
  237. package/dist/prompts/local/qa-testcase-from-ui.js +2 -0
  238. package/dist/prompts/local/qa-testcase-from-ui.js.map +1 -1
  239. package/dist/safety/guardrails.d.ts +36 -0
  240. package/dist/safety/guardrails.d.ts.map +1 -0
  241. package/dist/safety/guardrails.js +60 -0
  242. package/dist/safety/guardrails.js.map +1 -0
  243. package/dist/tui/hooks/use-runs.d.ts.map +1 -1
  244. package/dist/tui/hooks/use-runs.js +4 -1
  245. package/dist/tui/hooks/use-runs.js.map +1 -1
  246. package/dist/tui/screens/runs-list-screen.d.ts.map +1 -1
  247. package/dist/tui/screens/runs-list-screen.js +3 -1
  248. package/dist/tui/screens/runs-list-screen.js.map +1 -1
  249. package/dist/tui/screens/summary-screen.d.ts.map +1 -1
  250. package/dist/tui/screens/summary-screen.js +1 -1
  251. package/dist/tui/screens/summary-screen.js.map +1 -1
  252. package/dist/tui/types.d.ts +7 -1
  253. package/dist/tui/types.d.ts.map +1 -1
  254. package/dist/validate/index.d.ts +7 -3
  255. package/dist/validate/index.d.ts.map +1 -1
  256. package/dist/validate/index.js +22 -3
  257. package/dist/validate/index.js.map +1 -1
  258. package/dist/validate/runner.d.ts +61 -1
  259. package/dist/validate/runner.d.ts.map +1 -1
  260. package/dist/validate/runner.js +67 -4
  261. package/dist/validate/runner.js.map +1 -1
  262. package/package.json +5 -1
package/README.md CHANGED
@@ -11,311 +11,103 @@
11
11
  [![node](https://img.shields.io/badge/node-%3E%3D20-brightgreen)](package.json)
12
12
  [![license](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
13
13
 
14
- <!-- Inline player badge (optional): `asciinema upload docs/demo/cairn.cast`, then replace the line below
15
- with [![Cairn demo](https://asciinema.org/a/<id>.svg)](https://asciinema.org/a/<id>) — see docs/demo/. -->
16
14
  ▶ **Demo:** [`docs/demo/cairn.cast`](docs/demo/cairn.cast) — play with `asciinema play docs/demo/cairn.cast`
17
15
 
18
- > Autonomous QA agent (Node.js / TypeScript) that logs into a web app with a saved session, explores
19
- > pages (ARIA snapshot + screenshot), designs methodology-based UI test cases (ISO/IEC/IEEE 29119-4),
20
- > generates runnable `@playwright/test` code, self-validates and self-repairs, and **self-improves**
21
- > via Langfuse. A portable utility (CLI + library) for embedding into other TypeScript projects.
16
+ Autonomous QA agent (Node.js / TypeScript) that logs into a web app with a saved session, explores
17
+ pages (ARIA snapshot + screenshot), designs methodology-based UI test cases (ISO/IEC/IEEE 29119-4),
18
+ generates runnable `@playwright/test` code, self-validates, self-repairs, and **self-improves** via
19
+ Langfuse. A portable CLI + library for embedding into other TypeScript projects.
22
20
 
23
- **Cairn is the generation layer** — it produces tests across surfaces (UI today; API / unit / docs planned),
24
- each arriving by demand, one at a time. A separate **Plune** layer owns record / management / eval.
21
+ **Cairn is the generation layer** — it produces tests across surfaces (UI + API shipped; unit / docs
22
+ planned), each arriving by demand. A separate **Plune** layer owns record / management / eval.
25
23
 
26
- > **Renamed from Lex-Bot → Cairn.** The old `lex-bot` command and the `@plune-ai/lex-bot` package still
27
- > work — the CLI prints a one-line deprecation notice — but switch to `cairn` / `@plune-ai/cairn`; the old
28
- > names will be removed in 1–2 releases. Legacy `LEX_`/`LEXBOT_` env vars still work too; prefer `CAIRN_`.
24
+ > **Renamed Lex-Bot → Cairn.** The old `lex-bot` command and `@plune-ai/lex-bot` package still work
25
+ > (the CLI prints a one-line deprecation notice) — prefer `cairn` / `@plune-ai/cairn`. Legacy
26
+ > `LEX_`/`LEXBOT_` env vars still work too; prefer `CAIRN_`.
29
27
 
30
28
  ## What it does
31
29
 
32
- Point it at a URL (behind login, with a saved Playwright `storageState`) and it will:
30
+ Point it at a URL (behind login, with a saved Playwright `storageState`) and it will **observe** (ARIA
31
+ + screenshot + interactive elements), **ground** (verify every locator, explore tabs/views, probe safe
32
+ state transitions — so it tests what is *actually* there, not hallucinations), **design** 29119-4 cases
33
+ (EP / BVA / decision-table / state-transition / error-guessing), **generate & validate** POM-style
34
+ `@playwright/test` specs with **self-repair** (keep-best: a repair never makes the suite worse), and
35
+ **judge & learn** (deterministic scorers + an LLM judge + a holistic **Pilot** verdict, traced to Langfuse).
33
36
 
34
- 1. **Observe** — navigate, wait for SPA hydration, capture an ARIA snapshot + screenshot, extract interactive elements.
35
- 2. **Ground** — verify every locator (`getByRole().count()`), explore tabs/views (multi-state), probe safe state transitions — so it tests what is *actually* there, not hallucinations.
36
- 3. **Design** — write methodology-based test cases (29119-4: EP / BVA / decision-table / state-transition / error-guessing), steered by an optional checklist and domain knowledge files.
37
- 4. **Generate & validate** — emit POM-style `@playwright/test` specs (role-based locators, `test.step`), run them, classify pass/fail/flaky, and **self-repair** failures (with keep-best: a repair never makes the suite worse).
38
- 5. **Judge & learn** — deterministic scorers + an LLM judge + a holistic **Pilot** verdict + semantic checklist coverage, all traced to Langfuse; accumulate the best cases across runs.
37
+ It writes two kinds of case: **ATC** (*Automatable* — code is generated) and **MTC** (*Manual* — full
38
+ submits, security/XSS, visual/UX, irreversible actions — left for a human).
39
39
 
40
40
  ## Two decoupled modes
41
41
 
42
- - **`design`** — explore + write test cases as Markdown files (`ATC-*` automatable / `MTC-*` manual) with recorded selectors. **No code.** Review them as a human, automate later.
43
- - **`automate`** — generate `@playwright/test` code from approved `ATC-*` cases (skips `MTC-*` manual ones).
42
+ - **`design`** — explore + write cases as Markdown (`ATC-*` / `MTC-*`) with recorded selectors. **No code.**
43
+ - **`automate`** — generate `@playwright/test` code from approved `ATC-*` cases (skips `MTC-*`).
44
44
  - **`explore`** — the full pipeline at once (cases → code → validation → repair → Pilot verdict).
45
45
 
46
- ## How it works — the full cycle
47
-
48
- New to this? The bot writes two kinds of test case:
49
- - **ATC** (*Automatable Test Case*) — the bot is confident it can drive reliably (read-only checks, verified locators) → it generates Playwright code for these.
50
- - **MTC** (*Manual Test Case*) — needs a human (full form submits, security/XSS, visual/UX, irreversible actions) → left for you to run by hand.
51
-
52
- The typical flow:
53
-
54
- 1. **Capture a session** (once) — log in so the bot can reach pages behind auth.
55
- 2. **Design** — the bot studies the page and writes test cases (`ATC-*` / `MTC-*` `.md` files with recorded selectors). No code yet.
56
- 3. **Review** — you read the cases (in the TUI: *Browse past runs* → open a run → *Cases*).
57
- 4. **Promote** *(optional)* — reviewed an `MTC` and decided it's actually automatable? `cairn promote …` (or `a` in the TUI) converts it to an `ATC` in place. It's then picked up by automate.
58
- 5. **Automate** — generate `@playwright/test` code from the `ATC` cases.
59
- 6. **Validate** — run the generated tests, classify pass/fail/flaky, and self-repair failures.
60
-
61
- `explore` runs steps 2–6 in one go; `design` + `automate` split them so you can review (and promote) in between. Full walkthrough: **[docs/getting-started.md](docs/getting-started.md)**.
46
+ Full walkthrough: **[Getting started](docs/getting-started.md)**.
62
47
 
63
48
  ## Install
64
49
 
65
50
  ```bash
66
51
  npm install -g @plune-ai/cairn # global CLI → run `cairn …`
67
- # …or local / library install:
68
- npm install @plune-ai/cairn # → run via `npx cairn …`
52
+ # …or local / library: npm install @plune-ai/cairn → run via `npx cairn …`
69
53
 
70
- # one-time: download the Chromium build Cairn drives (NOT shipped inside the npm package)
71
- cairn install-browsers # uses Cairn's OWN Playwright → always the right Chromium revision
72
- # …or skip the download entirely and drive your installed Google Chrome: pass --channel chrome
54
+ cairn install-browsers # one-time: the Chromium Cairn drives (its OWN Playwright revision)
73
55
  ```
74
56
 
75
- Requires Node.js 20+. Copy `.env.example` → `.env` and fill in your keys.
76
-
77
- > **Two ways to invoke.** A **global** install (`-g`) puts `cairn` on your PATH, so `cairn design …` works
78
- > anywhere. A **local** install does *not* — run it as **`npx cairn design …`** from the folder where you
79
- > installed it. The examples below use the bare `cairn`; prefix them with `npx` if you installed locally.
80
- >
81
- > **Browsers are a separate download.** `npm install` pulls the Playwright *library* but not its *browser
82
- > binaries*. Run **`cairn install-browsers`** once — it uses Cairn's own Playwright, so the Chromium
83
- > revision always matches what Cairn launches. Prefer your existing Chrome? Skip the download and pass
84
- > **`--channel chrome`** (this is also how Cairn coexists with a project that already ships its *own*
85
- > Playwright). Otherwise `explore` / `automate --validate` stop early with a clear *"Playwright browsers
86
- > are not installed"* message that prints both fixes — run **`cairn doctor`** any time to see the state.
57
+ Requires Node.js 20+. Copy `.env.example` → `.env` and add your keys. Browsers are a **separate
58
+ download** — run `cairn install-browsers` once, or pass `--channel chrome` to drive your installed
59
+ Chrome with **zero download** (also the simplest path for OAuth and for projects that already ship
60
+ Playwright). `cairn doctor` diagnoses the setup. See **[Authenticated targets](docs/sessions.md)** and
61
+ **[Configuration](docs/configuration.md)**.
87
62
 
88
63
  ## Quickstart
89
64
 
90
- > Installed locally (without `-g`)? Prefix every `cairn …` below with `npx` (e.g. `npx cairn design …`).
65
+ > Installed locally (without `-g`)? Prefix every `cairn …` below with `npx`.
91
66
 
92
67
  ```bash
93
- # 0. One-time: download the browser Cairn drives (skip if you already ran it during install,
94
- # or skip entirely and add --channel chrome to drive your installed Google Chrome)
95
- cairn install-browsers
96
-
97
- # 1. Capture a session (opens a browser to log in)
68
+ # 1. Capture a login session once (a browser opens — log in, then press Enter)
98
69
  cairn session capture --url https://app.example.com/login --name myapp
99
70
 
100
71
  # 2. Design test cases (no code) — review the .md files it writes
101
72
  cairn design --url https://app.example.com/page --session myapp --checklist plan.md
102
73
 
103
- # 3. (optional) Promote a manual case you decided is automatable: MTC → ATC
104
- cairn promote --run runs/<id> --cases MTC-LOGIN-001
105
-
106
- # 4. Automate the approved (ATC) cases → @playwright/test code, and run them
74
+ # 3. Automate the approved (ATC) cases → @playwright/test code, and run them
107
75
  cairn automate --run runs/<id> --validate --session myapp
108
76
 
109
77
  # …or do everything at once:
110
78
  cairn explore --url https://app.example.com/page --session myapp --checklist plan.md
111
79
  ```
112
80
 
113
- The `--checklist` file steers **what** the bot tests (and is scored as coverage). Copy
114
- [`examples/plan.md`](examples/plan.md) — a ready-to-run checklist for `https://plune.ai/cairn` — as a starting point.
115
-
116
- > **Run id / Windows tip:** `--run` (and `--from-run`) accept just the run id — `--run <id>` — in addition to
117
- > `runs/<id>` or an absolute path. In **Git Bash (MINGW64)** quote the path or use forward slashes
118
- > (`--run 'runs/<id>'`), because an unquoted `\` is eaten by the shell *before* Cairn sees it (so `runs\<id>`
119
- > would otherwise arrive as `runs<id>`). The bare-id form sidesteps the issue entirely.
120
-
121
- Add `--fresh` (on `design` and `explore`) to **ignore prior runs of the same URL**. By default a 2nd+
122
- run on a URL reuses its *previously stable* cases as context and generates only the **delta** (new
123
- cases), so re-runs get smaller. `--fresh` skips that and generates a **full set** every time — useful
124
- for clean A/B comparisons. In the TUI it's the "Ignore prior-run experience for this URL?" toggle (default **no**).
125
-
126
- New here? Read the **[Getting started guide](docs/getting-started.md)** — it walks the whole cycle with explanations.
127
-
128
- ## Authenticated targets
129
-
130
- Cairn explores your app **as a logged-in user**. You capture the login **once** into a Playwright
131
- `storageState` (cookies + localStorage); every later run reuses it — no credentials in code, no
132
- re-login per run.
133
-
134
- ```bash
135
- # 1. Capture once — a real browser opens; log in by hand, then press Enter.
136
- cairn session capture --url https://your-app.example.com/login --name myapp
137
-
138
- # 2. Point Cairn at any page behind that login, reusing the session.
139
- cairn explore --url https://your-app.example.com/dashboard --session myapp
140
- ```
141
-
142
- - **Pointing Cairn at your OWN gated app?** That's the intended flow — capture against your login page, then `explore` / `design` any authenticated page with `--session <name>`.
143
- - **OAuth / Google login** (blocks automated browsers): add `--channel chrome` to drive your real Google Chrome. `--channel` works on `session capture`, `observe`, `design`, `explore`, and `automate --validate` — and needs **no bundled-Chromium download**, so it's also the simplest way to run inside a project that already has its own Playwright. (Without a channel, Cairn uses the bundled Chromium from `cairn install-browsers`.)
144
- - **Manage sessions:** `cairn session ls` lists saved sessions; `cairn session rm <name>` deletes one. (`cairn login` is a shorthand for `cairn session capture`.)
145
- - **Already have a `storageState.json`?** Skip capture and pass it directly: `--session-file ./path/to/state.json`.
146
- - **Expired session?** If the first page Cairn sees looks like a login screen, it stops with a clear *re-capture* message instead of exploring the sign-in page.
147
- - **Secrets hygiene:** sessions live in `.auth/` (matching `*.storageState.json`), which is **gitignored** — never committed. Treat the files like passwords.
148
-
149
- > Working inside the repo? `npm run session:save -- --url <u> --name <s>` still works — it's a thin wrapper over the same capture logic that ships as `cairn session capture`.
150
-
151
- ## Interactive TUI (optional)
152
-
153
- Run `cairn` with **no arguments** in a terminal to open the interactive TUI (built with Ink / React-for-CLI).
154
- Ink and React are **optional dependencies** — a default install omits them to keep the footprint small.
155
- Install them once to enable the TUI:
156
-
157
- ```bash
158
- npm install ink react ink-select-input ink-spinner ink-text-input
159
- ```
160
-
161
- Then:
81
+ `--checklist` steers **what** the bot tests (and is scored as coverage) — copy
82
+ [`examples/plan.md`](examples/plan.md) as a starting point. Add `--fresh` to ignore prior runs of a URL,
83
+ `--style <pack>` to restyle cases ([Prompts & styles](docs/prompts-and-styles.md)), or `--critique` to
84
+ prune weak cases and top up technique gaps. (Git Bash: quote `--run 'runs/<id>'` or use the bare id.)
162
85
 
163
- ```bash
164
- cairn # launches the terminal UI (requires the Ink packages above)
165
- ```
86
+ Add `--screencast` (to `explore`, or `automate --validate`) to record a **`.webm` per scenario** during
87
+ validation into `runs/<id>/screencasts/`, with a `screencasts.json` sidecar mapping each scenario's step
88
+ chapters (step → timecode). It's a review-gate affordance — watch what the agent did before approving a
89
+ case. Off by default; the recorded `.webm` paths are linked from the run summary and the TUI result screen.
166
90
 
167
- Pick a command (explore / design / automate), fill parameters (URL, session, checklist, style, fresh) via a
168
- guided form, watch a **live dashboard** of the pipeline stages as the run progresses, read the result summary
169
- (scores, green %, Pilot verdict, test cases), and **browse past runs** in `./runs` — opening any run to
170
- read its test cases, report and logs.
91
+ ## Interactive TUI
171
92
 
172
- The commands below stay available for scripting/CI; in a non-interactive (piped/CI) shell, `cairn` with
173
- no arguments prints help instead of starting the UI. If the Ink packages are not installed, `cairn` with
174
- no arguments also falls back to printing help.
93
+ Run `cairn` with **no arguments** in a terminal for a guided UI (launcher → form → live dashboard →
94
+ result summary → past-run browser). Ink/React are optional deps — see **[docs/tui.md](docs/tui.md)**.
175
95
 
176
96
  ## Commands
177
97
 
178
98
  | Command | Purpose |
179
99
  |---|---|
180
- | `cairn session capture --url <loginUrl> --name <s>` | Capture a login session once → `.auth/` (`cairn login` is a shorthand; `session ls` / `session rm`) |
100
+ | `cairn session capture --url <loginUrl> --name <s>` | Capture a login session → `.auth/` (`cairn login` is a shorthand; `session ls` / `rm`) |
181
101
  | `cairn observe --url <u> [--session <s>]` | ARIA snapshot + interactive elements + screenshot |
182
- | `cairn design --url <u> --session <s> [--checklist <f>] [--style <s>] [--fresh]` | Test cases only (ATC/MTC `.md` + selectors), no code |
183
- | `cairn automate --run <dir> [--validate --session <s>]` | `@playwright/test` from `ATC-*` cases |
102
+ | `cairn design --url <u> --session <s> [--checklist <f>] [--style <s>] [--fresh] [--critique]` | Test cases only (ATC/MTC `.md` + selectors), no code |
103
+ | `cairn automate --run <dir> [--validate --session <s>] [--screencast]` | `@playwright/test` from `ATC-*` cases |
184
104
  | `cairn promote --run <dir> --cases <ids> [--session <s>]` | Promote manual MTC case(s) to ATC (.md only; then `automate`) |
185
- | `cairn explore --url <u> --session <s> [--checklist <f>] [--fresh]` | Full pipeline (cases → code → validate → repair → Pilot) |
105
+ | `cairn explore --url <u> --session <s> [--checklist <f>] [--fresh] [--critique] [--screencast]` | Full pipeline (cases → code → validate → repair → Pilot) |
106
+ | `cairn api --spec <path\|url> [--base-url <u>] [--negative] [--scenarios] [--adversarial [styles]]` | Generate (and, with `--base-url`, run + assert status/contract) happy-path, negative-schema, multi-endpoint-scenario, and adversarial (`normal`/`curious`/`psycho`/`hacker`) cases from an OpenAPI 3.x spec |
186
107
  | `cairn experiment --dataset <d> --candidate name=file` | Compare prompt versions on a dataset |
187
108
 
188
109
  > `lex-bot <command>` still runs every command above (deprecated alias — prints a notice, then runs `cairn`).
189
110
 
190
- ## Configuration (env)
191
-
192
- | Var | Purpose |
193
- |---|---|
194
- | `LLM_PROFILE` | `anthropic` \| `openrouter` \| `mixed` (per-tier default models) |
195
- | `LLM_ROUTING` | per-role preset: `fast` (Groq worker) \| `volume` (OpenRouter worker) — see [Role routing](#role-routing) |
196
- | `ANTHROPIC_API_KEY` / `OPENROUTER_API_KEY` / `GROQ_API_KEY` | provider keys (per profile / routing) |
197
- | `QA_TESTCASE_LANG` | test-case language (default `English`; e.g. `Ukrainian`, `uk`) |
198
- | `LANGFUSE_BASE_URL` / `LANGFUSE_PUBLIC_KEY` / `LANGFUSE_SECRET_KEY` | Langfuse — **cloud or self-hosted** (optional; see [below](#optional-langfuse)) |
199
- | `BROWSER_BACKEND` | `lib` (in-process Playwright) \| `cli` |
200
- | `BROWSER_CHANNEL` | `chrome`/`msedge` → drive a system browser (helps with OAuth; **no bundled-Chromium download**, and coexists with a host project's own Playwright). Per-command flag: `--channel`. |
201
- | `MAX_REPAIR` | repair attempts (default 2) |
202
-
203
- - **Env var prefix:** every variable above is read as-is **or** with a `CAIRN_` prefix (e.g. `CAIRN_LLM_PROFILE`, `CAIRN_MAX_REPAIR`). Legacy `LEX_`/`LEXBOT_` prefixes still work but print a one-time deprecation warning — prefer `CAIRN_`.
204
- - <a id="role-routing"></a>**Role routing (`LLM_ROUTING`, optional):** layer a cheap **worker** over any profile while keeping the strong **reasoner**. One flag picks where the mechanical steps (identify-elements, generate-code/repair) run:
205
- - `fast` → worker on **Groq** `llama-3.3-70b-versatile` — lowest latency/cost, OpenAI-compatible tool-calling.
206
- - `volume` → worker on **OpenRouter** `deepseek/deepseek-chat` — model breadth.
207
- - default (unset) → the profile's own per-tier models.
208
-
209
- In **every** preset the reasoner (design test cases + Pilot verdict) stays on **Anthropic** `claude-opus-4-8` for judgment quality, and the cheap `judge` scorer keeps the profile tier (routing never touches it). Override any role with `CAIRN_ROLE_WORKER` / `CAIRN_ROLE_REASONER=provider:model`; pass `--routing <preset>` on `explore`/`design`/`automate` to set it per run. Per-run **per-role cost** (tokens + $) is printed in the run summary.
210
- - **Domain knowledge:** put `*.md` files in `./knowledge/` with a `url:` front-matter to inject credentials/validation rules into design.
211
- - **Prompt overrides:** drop `./prompts/<name>.md` to override any built-in prompt without rebuilding.
212
-
213
- ## Metrics
214
-
215
- Every run scores itself. The numbers appear in the console (`=== Metrics ===`), in each run's
216
- `report.md` (with a one-line meaning per metric), and in Langfuse when configured. **↑ = higher is
217
- better, ↓ = lower is better.** `case_redundancy` and `flaky_ratio` are the **only** "lower is better"
218
- metrics — every other metric is higher-is-better.
219
-
220
- <!-- KEEP IN SYNC with src/eval/legend.ts (METRIC_LEGEND) — same metric names, directions, and blurbs. -->
221
-
222
- **Deterministic** (computed from run data, no LLM):
223
-
224
- | metric | direction | meaning |
225
- |---|---|---|
226
- | `runs_green` | ↑ higher is better | Share of generated tests that pass on validation. |
227
- | `flaky_ratio` | ↓ lower is better | Share of tests classified flaky (inconsistent pass/fail). |
228
- | `verified_ratio` | ↑ higher is better | Share of identified elements that resolve to exactly one element (unique locator). |
229
- | `grounding` | ↑ higher is better | Share of cases whose element refs all point to real on-page elements (no hallucinated refs). |
230
- | `locator_quality` | ↑ higher is better | Share of user-facing locators (getByRole/Label/Text…) vs fragile (.locator/getByTestId). |
231
- | `locator_robustness` | ↑ higher is better | Weighted selector strength: role 1.0 > label/text 0.8 > test-id 0.5 > css 0. |
232
- | `technique_coverage` | ↑ higher is better | Distinct test techniques used out of the 6 (ISO/IEC/IEEE 29119-4). |
233
- | `case_redundancy` | ↓ lower is better | Share of cases that are near-duplicates of another (0 = all distinct). |
234
-
235
- **Judge** (LLM-scored):
236
-
237
- | metric | direction | meaning |
238
- |---|---|---|
239
- | `test_case_quality` | ↑ higher is better | Holistic quality of the cases (clarity, correctness, usefulness). |
240
- | `methodology_adherence` | ↑ higher is better | How well the cases follow the testing methodology. |
241
- | `checklist_coverage` | ↑ higher is better | Semantic coverage of the provided checklist by the cases. |
242
-
243
- (The holistic **Pilot** verdict is separate — a pass / needs-work / fail judgment on the whole run, not a 0–1 score.)
244
-
245
- ## Cost benchmark
246
-
247
- What does a run cost on each [routing preset](#role-routing)? The table below is generated by
248
- `npm run bench`: it runs `cairn explore` against a fixed target once per preset and reads the per-run
249
- cost ledger (tokens + $) already written into each run's `report.json` (L1-01) — it re-prices nothing.
250
- Treat the numbers as an **approximate, single-run snapshot** (LLM token counts vary run-to-run).
251
-
252
- <!-- BENCHMARK:START -->
253
- <!-- Generated by `npm run bench` — do not edit between the BENCHMARK markers by hand. -->
254
-
255
- _Snapshot: 2026-06-13 · commit `a2906cf` · profile `anthropic` · MAX_REPAIR=0 · target: `https://demoqa.com/text-box` (no session) · approximate, single-run._
256
-
257
- | Preset | Worker | Reasoner | Tokens/run | $/run | Wall-clock/run | $/hour† |
258
- |---|---|---|---|---|---|---|
259
- | `default` | claude-haiku-4-5+claude-sonnet-4-6 | claude-opus-4-8 | 27,191 | $0.2854 | 390.6s | $2.63 |
260
- | `volume` | deepseek/deepseek-chat | claude-opus-4-8 | 13,923 | $0.1209 | 58.2s | $7.48 |
261
- | `fast` | llama-3.3-70b-versatile | claude-opus-4-8 | n/a — run failed: 400 Failed to call a function. Please adjust your prompt. See 'fail… | — | — | — |
262
-
263
- † **$/hour is an extrapolation**, not a steady-state rate: `$/run × (3600 / seconds-per-run)` — the cost if runs fired back-to-back for an hour. Real throughput varies with target complexity, retries, and provider latency.
264
-
265
- Reproduce: `npm run bench -- --url https://demoqa.com/text-box --session <name>`
266
-
267
- > Token counts vary run-to-run (LLM nondeterminism). OpenRouter/Groq prices are approximate and movable ([ADR-0002](docs/adr/0002-llm-anthropic-tiering.md)); Anthropic prices follow the published rates. `$/run` is `—` when a model has no configured price (tokens are still counted).
268
- <!-- BENCHMARK:END -->
269
-
270
- Regenerate it yourself — you need the provider keys for the presets you want measured and, ideally, a
271
- [captured session](#authenticated-targets) so the target is a real page rather than `example.com`:
272
-
273
- ```bash
274
- npm run bench -- --url https://your-app.example.com/dashboard --session myapp --write
275
- ```
276
-
277
- For reproducibility the benchmark **pins `LLM_PROFILE=anthropic` and `MAX_REPAIR=0`** (both shown in the
278
- snapshot line) instead of inheriting your `.env` — so `default` always means the same baseline and the
279
- [reasoner stays on Opus in every preset](#role-routing); only the worker changes. Override with
280
- `--profile <p>` / `--max-repair <n>`. A preset whose provider key is unset is **skipped** and shown as
281
- `n/a`, so a partial run (e.g. only `ANTHROPIC_API_KEY` available) still produces a useful table.
282
-
283
- ## Optional: Langfuse
284
-
285
- Langfuse is **entirely optional** — leave the `LANGFUSE_*` variables unset and the bot runs fully offline.
286
- Everything core still works: `observe` / `design` / `automate` / `explore`, locator grounding, the LLM judge,
287
- deterministic scorers, self-repair, and results-level learning (best cases are read from local
288
- `runs/<id>/report.json`). Prompts fall back to the built-in defaults — override any of them with `./prompts/<name>.md`.
289
-
290
- Set the three `LANGFUSE_*` variables to **additionally** get: traces in the Langfuse UI, scores/datasets
291
- recorded centrally, and versioned prompts (with production labels & A/B prompt experiments via `cairn experiment`).
292
-
293
- Tracing ships as an **optional add-on** (0.3.3): the `@langfuse/*` / `@opentelemetry/*` packages are no
294
- longer part of the default install — that keeps the footprint small and `npm audit` clean. Install them
295
- once to enable it:
296
-
297
- ```bash
298
- npm install @langfuse/client @langfuse/langchain @langfuse/otel @langfuse/tracing @opentelemetry/api @opentelemetry/sdk-node
299
- ```
300
-
301
- If the `LANGFUSE_*` variables are set but the packages aren't installed, Cairn prints a one-line hint and
302
- keeps running **without** tracing — it never crashes a run over telemetry.
303
-
304
- **Cloud or self-hosted — same setup.** Langfuse Cloud and a self-hosted instance are configured identically:
305
- you only pass the host URL and the API keys, nothing else changes.
306
-
307
- ```bash
308
- # Pick ONE base URL:
309
- LANGFUSE_BASE_URL=https://cloud.langfuse.com # Langfuse Cloud (EU)
310
- # LANGFUSE_BASE_URL=https://us.cloud.langfuse.com # Langfuse Cloud (US)
311
- # LANGFUSE_BASE_URL=https://langfuse.your-host.tld # self-hosted
312
- LANGFUSE_PUBLIC_KEY=pk-lf-...
313
- LANGFUSE_SECRET_KEY=sk-lf-...
314
- ```
315
-
316
- > Enablement is all-or-nothing: Langfuse turns on only when **all three** variables are set; otherwise
317
- > telemetry is a no-op and the bot behaves exactly as offline.
318
-
319
111
  ## Library API
320
112
 
321
113
  ```ts
@@ -326,6 +118,14 @@ const result = await runDesign({ url, config, sessionName: "myapp", checklistTex
326
118
  // result.testCases, result.testCaseFiles, result.scores
327
119
  ```
328
120
 
121
+ ## Documentation
122
+
123
+ - **[Getting started](docs/getting-started.md)** — step-by-step onboarding (session → design → review → promote → automate → validate).
124
+ - **[Authenticated targets](docs/sessions.md)** · **[Configuration & role routing](docs/configuration.md)** · **[Prompts & styles](docs/prompts-and-styles.md)** · **[Interactive TUI](docs/tui.md)** · **[MCP server](docs/mcp.md)**
125
+ - **[Metrics](docs/metrics.md)** · **[Cost benchmark](docs/cost.md)** · **[Langfuse](docs/langfuse.md)**
126
+ - **[Architecture overview](docs/architecture/overview.md)** — the plain async pipeline, locator grounding, self-improvement.
127
+ - **[Architecture Decision Records](docs/adr/)** — why it's built this way (0001–0013).
128
+
329
129
  ## Development
330
130
 
331
131
  ```bash
@@ -335,12 +135,6 @@ npm run test:coverage
335
135
  npm run lint
336
136
  ```
337
137
 
338
- ## Documentation
339
-
340
- - **[Getting started](docs/getting-started.md)** — step-by-step onboarding (session → design → review → promote → automate → validate), written for people new to the tool.
341
- - **[Architecture overview](docs/architecture/overview.md)** — how the agent works inside (the plain async pipeline, locator grounding, self-improvement).
342
- - **[Architecture Decision Records](docs/adr/)** — why it's built this way (0001–0013, incl. the interactive TUI, the `@playwright/test` output format, the Lex-Bot → Cairn rename, the Apache-2.0 relicense, and the drop of LangGraph in 0.4.0).
343
-
344
138
  ## License
345
139
 
346
- Apache-2.0 (relicensed from GPL-3.0 in 0.3.0 — see [`docs/adr/0012`](docs/adr/0012-relicense-to-apache-2.0.md)). Methodology prompts ported from `AZANIR/qa-skills` (see `docs/adr/0008`).
140
+ Apache-2.0 (relicensed from GPL-3.0 in 0.3.0 — see [`docs/adr/0012`](docs/adr/0012-relicense-to-apache-2.0.md)). Methodology prompts ported from `AZANIR/qa-skills` (see [`docs/adr/0008`](docs/adr/0008-methodology-port-from-qa-skills.md)).
@@ -1,8 +1,13 @@
1
1
  import { type PageStudy } from "../observe/index.js";
2
2
  import { type PageAnalysis } from "../analyze/index.js";
3
3
  import { type TestCase } from "../design/index.js";
4
+ import { type CritiqueDelta } from "../design/critique.js";
5
+ import { type FlowGraph } from "../flow/crawl.js";
6
+ import { type SetupPlan } from "../flow/setup.js";
7
+ import type { JourneyCase } from "../design/schema.js";
4
8
  import { type GeneratedSuite } from "../codegen/index.js";
5
9
  import { type Transition } from "../probe/index.js";
10
+ import { type InteractionMap } from "../documentarian/index.js";
6
11
  import type { ValidationReport } from "../validate/index.js";
7
12
  import type { RunWriter } from "../artifacts/index.js";
8
13
  import type { BrowserGateway, VerifiedElement } from "../browser/index.js";
@@ -15,7 +20,21 @@ export interface ExploreDeps {
15
20
  analyzeInvoke: StructuredInvoke;
16
21
  designInvoke: StructuredInvoke;
17
22
  codegenInvoke: StructuredInvoke;
23
+ /** #82: worker-tier invoker for the design-time self-critique pass. Absent → pass is skipped. */
24
+ critiqueInvoke?: StructuredInvoke;
25
+ /** #82: run the self-critique pass (prune + technique top-up). Conservative default: off. */
26
+ critique?: boolean;
27
+ /** #59: follow in-app navigation, build a page/flow graph, design multi-page journey cases. Opt-in. */
28
+ flow?: boolean;
29
+ /** #59: max pages to crawl when `flow` is on (page cap — cost guardrail). Default 1 (single page). */
30
+ maxPages?: number;
31
+ /** #60: plan + emit starting-state setup (fixtures / API seed) for journeys. Opt-in. */
32
+ setup?: boolean;
33
+ /** #60: worker-tier invoker for setup planning (precondition extraction). Absent → no setup. */
34
+ setupInvoke?: StructuredInvoke;
18
35
  useVision: boolean;
36
+ /** #63: pre-formatted goal directive ({@link formatGoal}) — biases observe (element pick) + design. "" → no bias. */
37
+ goalText?: string;
19
38
  checklistText?: string;
20
39
  knowledgeText?: string;
21
40
  experienceText?: string;
@@ -40,6 +59,20 @@ export interface ExploreDeps {
40
59
  * suite label the final write uses, so the early and final writes produce identical files.
41
60
  */
42
61
  onTestCases?: (testCases: TestCase[], verified: VerifiedElement[], studyUrl: string) => void | Promise<void>;
62
+ /**
63
+ * #93: cross-run cache dir for the page-understanding artifact. When set, a run on a page whose
64
+ * fingerprint matches a cached map REUSES it and skips the ground (analyzePage) LLM call. Undefined
65
+ * → caching off (behavior unchanged). The dir is keyed internally by url + page fingerprint.
66
+ */
67
+ understandingCacheDir?: string;
68
+ /** #93: ignore a cached understanding for this run (forces a fresh ground call). Mirrors `--fresh`. */
69
+ fresh?: boolean;
70
+ /**
71
+ * #93: called with the freshly built interaction map (mirrors onStudy/onTestCases) so the caller can
72
+ * persist it as the run's first-class artifact (page-understanding.json). Best-effort: a throw here
73
+ * must not break the run.
74
+ */
75
+ onUnderstanding?: (map: InteractionMap) => void | Promise<void>;
43
76
  /** Codeless mode: stop after designTestCases (cases only, no codegen/validate). */
44
77
  codeless?: boolean;
45
78
  /**
@@ -63,6 +96,14 @@ export interface ExploreOutcome {
63
96
  stoppedEarly: boolean;
64
97
  /** Repair attempts actually run (0 = green on the first try, or maxRepair=0 or codeless). */
65
98
  attempts: number;
99
+ /** #82: before/after delta of the self-critique pass (undefined when the pass didn't run). */
100
+ critique?: CritiqueDelta;
101
+ /** #59: the page/flow graph crawled when `flow` is on (undefined for single-page runs). */
102
+ flowGraph?: FlowGraph;
103
+ /** #59: multi-page journey cases designed from the graph (undefined for single-page runs). */
104
+ journeys?: JourneyCase[];
105
+ /** #60: per-journey structured setup plans (undefined unless `setup` ran). */
106
+ setupPlans?: SetupPlan[];
66
107
  }
67
108
  /** Sprint 3: observe → identify → design → generateCode → validate ⇄ repair (bounded by maxRepair). */
68
109
  export declare function runExploreGraph(deps: ExploreDeps, init: {
@@ -1 +1 @@
1
- {"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/agent/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE9D,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAmB,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAoB,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAItE,OAAO,KAAK,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