@plune-ai/cairn 0.3.5 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/README.md +60 -10
  2. package/dist/agent/graph.d.ts +17 -530
  3. package/dist/agent/graph.d.ts.map +1 -1
  4. package/dist/agent/graph.js +144 -215
  5. package/dist/agent/graph.js.map +1 -1
  6. package/dist/agent/index.d.ts +4 -2
  7. package/dist/agent/index.d.ts.map +1 -1
  8. package/dist/agent/index.js +222 -205
  9. package/dist/agent/index.js.map +1 -1
  10. package/dist/agent/repair-loop.d.ts +8 -0
  11. package/dist/agent/repair-loop.d.ts.map +1 -1
  12. package/dist/agent/repair-loop.js +17 -5
  13. package/dist/agent/repair-loop.js.map +1 -1
  14. package/dist/agent/summary.d.ts +7 -0
  15. package/dist/agent/summary.d.ts.map +1 -1
  16. package/dist/agent/summary.js +11 -2
  17. package/dist/agent/summary.js.map +1 -1
  18. package/dist/artifacts/report.d.ts.map +1 -1
  19. package/dist/artifacts/report.js +7 -2
  20. package/dist/artifacts/report.js.map +1 -1
  21. package/dist/cli/index.d.ts.map +1 -1
  22. package/dist/cli/index.js +12 -7
  23. package/dist/cli/index.js.map +1 -1
  24. package/dist/codegen/lint.d.ts +11 -0
  25. package/dist/codegen/lint.d.ts.map +1 -0
  26. package/dist/codegen/lint.js +37 -0
  27. package/dist/codegen/lint.js.map +1 -0
  28. package/dist/config/index.d.ts.map +1 -1
  29. package/dist/config/index.js +7 -0
  30. package/dist/config/index.js.map +1 -1
  31. package/dist/config/schema.d.ts +2 -0
  32. package/dist/config/schema.d.ts.map +1 -1
  33. package/dist/core/modalities/explore.d.ts.map +1 -1
  34. package/dist/core/modalities/explore.js +7 -4
  35. package/dist/core/modalities/explore.js.map +1 -1
  36. package/dist/design/dedup.d.ts +14 -0
  37. package/dist/design/dedup.d.ts.map +1 -0
  38. package/dist/design/dedup.js +64 -0
  39. package/dist/design/dedup.js.map +1 -0
  40. package/dist/design/index.d.ts.map +1 -1
  41. package/dist/design/index.js +3 -1
  42. package/dist/design/index.js.map +1 -1
  43. package/dist/eval/collect.d.ts +15 -0
  44. package/dist/eval/collect.d.ts.map +1 -1
  45. package/dist/eval/collect.js +14 -0
  46. package/dist/eval/collect.js.map +1 -1
  47. package/dist/eval/legend.d.ts +19 -0
  48. package/dist/eval/legend.d.ts.map +1 -0
  49. package/dist/eval/legend.js +27 -0
  50. package/dist/eval/legend.js.map +1 -0
  51. package/dist/eval/scorers.d.ts.map +1 -1
  52. package/dist/eval/scorers.js +33 -0
  53. package/dist/eval/scorers.js.map +1 -1
  54. package/dist/index.d.ts +4 -2
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +2 -1
  57. package/dist/index.js.map +1 -1
  58. package/dist/llm/routing.d.ts +5 -1
  59. package/dist/llm/routing.d.ts.map +1 -1
  60. package/dist/llm/routing.js +7 -2
  61. package/dist/llm/routing.js.map +1 -1
  62. package/dist/llm/structured.d.ts +1 -1
  63. package/dist/llm/structured.d.ts.map +1 -1
  64. package/dist/llm/structured.js +2 -2
  65. package/dist/llm/structured.js.map +1 -1
  66. package/dist/prompts/local/qa-playwright-ts-writer.d.ts +1 -1
  67. package/dist/prompts/local/qa-playwright-ts-writer.d.ts.map +1 -1
  68. package/dist/prompts/local/qa-playwright-ts-writer.js +1 -0
  69. package/dist/prompts/local/qa-playwright-ts-writer.js.map +1 -1
  70. package/dist/prompts/local/qa-testcase-from-ui.d.ts +1 -1
  71. package/dist/prompts/local/qa-testcase-from-ui.d.ts.map +1 -1
  72. package/dist/prompts/local/qa-testcase-from-ui.js +2 -1
  73. package/dist/prompts/local/qa-testcase-from-ui.js.map +1 -1
  74. package/dist/telemetry/index.d.ts +6 -0
  75. package/dist/telemetry/index.d.ts.map +1 -1
  76. package/dist/telemetry/index.js +15 -2
  77. package/dist/telemetry/index.js.map +1 -1
  78. package/dist/tui/hooks/use-runner.d.ts.map +1 -1
  79. package/dist/tui/hooks/use-runner.js +6 -2
  80. package/dist/tui/hooks/use-runner.js.map +1 -1
  81. package/dist/tui/index.d.ts.map +1 -1
  82. package/dist/tui/index.js +18 -3
  83. package/dist/tui/index.js.map +1 -1
  84. package/dist/tui/screens/form-screen.d.ts.map +1 -1
  85. package/dist/tui/screens/form-screen.js +51 -4
  86. package/dist/tui/screens/form-screen.js.map +1 -1
  87. package/dist/tui/types.d.ts +5 -0
  88. package/dist/tui/types.d.ts.map +1 -1
  89. package/dist/validate/index.d.ts +4 -0
  90. package/dist/validate/index.d.ts.map +1 -1
  91. package/dist/validate/index.js +7 -2
  92. package/dist/validate/index.js.map +1 -1
  93. package/dist/validate/runner.d.ts +5 -1
  94. package/dist/validate/runner.d.ts.map +1 -1
  95. package/dist/validate/runner.js +7 -4
  96. package/dist/validate/runner.js.map +1 -1
  97. package/package.json +7 -8
package/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <p align="center">
2
+ <img src="docs/assets/hero.png" alt="Cairn — an AI that walks your system and leaves a trail of tests. Autonomous QA agent for UI, API, unit & docs testing. Node.js · TypeScript · Playwright." width="100%" />
3
+ </p>
4
+
1
5
  # Cairn
2
6
 
3
7
  > **Cairn — an AI that walks your system and leaves a trail of tests: UI, API, unit, docs.**
@@ -109,6 +113,11 @@ cairn explore --url https://app.example.com/page --session myapp --checklist pla
109
113
  The `--checklist` file steers **what** the bot tests (and is scored as coverage). Copy
110
114
  [`examples/plan.md`](examples/plan.md) — a ready-to-run checklist for `https://plune.ai/cairn` — as a starting point.
111
115
 
116
+ Add `--fresh` (on `design` and `explore`) to **ignore prior runs of the same URL**. By default a 2nd+
117
+ run on a URL reuses its *previously stable* cases as context and generates only the **delta** (new
118
+ cases), so re-runs get smaller. `--fresh` skips that and generates a **full set** every time — useful
119
+ for clean A/B comparisons. In the TUI it's the "Ignore prior-run experience for this URL?" toggle (default **no**).
120
+
112
121
  New here? Read the **[Getting started guide](docs/getting-started.md)** — it walks the whole cycle with explanations.
113
122
 
114
123
  ## Authenticated targets
@@ -134,21 +143,30 @@ cairn explore --url https://your-app.example.com/dashboard --session myapp
134
143
 
135
144
  > 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`.
136
145
 
137
- ## Interactive TUI
146
+ ## Interactive TUI (optional)
138
147
 
139
- Run `cairn` with **no arguments** in a terminal to open the interactive TUI (built with Ink):
148
+ Run `cairn` with **no arguments** in a terminal to open the interactive TUI (built with Ink / React-for-CLI).
149
+ Ink and React are **optional dependencies** — a default install omits them to keep the footprint small.
150
+ Install them once to enable the TUI:
140
151
 
141
152
  ```bash
142
- cairn # launches the terminal UI
153
+ npm install ink react ink-select-input ink-spinner ink-text-input
143
154
  ```
144
155
 
145
- Pick a command (explore / design / automate), fill parameters (URL, session, checklist, style) via a
146
- guided form, watch a **live dashboard** of the graph nodes as the run progresses, read the result summary
156
+ Then:
157
+
158
+ ```bash
159
+ cairn # launches the terminal UI (requires the Ink packages above)
160
+ ```
161
+
162
+ Pick a command (explore / design / automate), fill parameters (URL, session, checklist, style, fresh) via a
163
+ guided form, watch a **live dashboard** of the pipeline stages as the run progresses, read the result summary
147
164
  (scores, green %, Pilot verdict, test cases), and **browse past runs** in `./runs` — opening any run to
148
165
  read its test cases, report and logs.
149
166
 
150
167
  The commands below stay available for scripting/CI; in a non-interactive (piped/CI) shell, `cairn` with
151
- no arguments prints help instead of starting the UI.
168
+ no arguments prints help instead of starting the UI. If the Ink packages are not installed, `cairn` with
169
+ no arguments also falls back to printing help.
152
170
 
153
171
  ## Commands
154
172
 
@@ -156,10 +174,10 @@ no arguments prints help instead of starting the UI.
156
174
  |---|---|
157
175
  | `cairn session capture --url <loginUrl> --name <s>` | Capture a login session once → `.auth/` (`cairn login` is a shorthand; `session ls` / `session rm`) |
158
176
  | `cairn observe --url <u> [--session <s>]` | ARIA snapshot + interactive elements + screenshot |
159
- | `cairn design --url <u> --session <s> [--checklist <f>] [--style <s>]` | Test cases only (ATC/MTC `.md` + selectors), no code |
177
+ | `cairn design --url <u> --session <s> [--checklist <f>] [--style <s>] [--fresh]` | Test cases only (ATC/MTC `.md` + selectors), no code |
160
178
  | `cairn automate --run <dir> [--validate --session <s>]` | `@playwright/test` from `ATC-*` cases |
161
179
  | `cairn promote --run <dir> --cases <ids> [--session <s>]` | Promote manual MTC case(s) to ATC (.md only; then `automate`) |
162
- | `cairn explore --url <u> --session <s> [--checklist <f>]` | Full pipeline (cases → code → validate → repair → Pilot) |
180
+ | `cairn explore --url <u> --session <s> [--checklist <f>] [--fresh]` | Full pipeline (cases → code → validate → repair → Pilot) |
163
181
  | `cairn experiment --dataset <d> --candidate name=file` | Compare prompt versions on a dataset |
164
182
 
165
183
  > `lex-bot <command>` still runs every command above (deprecated alias — prints a notice, then runs `cairn`).
@@ -187,6 +205,38 @@ no arguments prints help instead of starting the UI.
187
205
  - **Domain knowledge:** put `*.md` files in `./knowledge/` with a `url:` front-matter to inject credentials/validation rules into design.
188
206
  - **Prompt overrides:** drop `./prompts/<name>.md` to override any built-in prompt without rebuilding.
189
207
 
208
+ ## Metrics
209
+
210
+ Every run scores itself. The numbers appear in the console (`=== Metrics ===`), in each run's
211
+ `report.md` (with a one-line meaning per metric), and in Langfuse when configured. **↑ = higher is
212
+ better, ↓ = lower is better.** `case_redundancy` and `flaky_ratio` are the **only** "lower is better"
213
+ metrics — every other metric is higher-is-better.
214
+
215
+ <!-- KEEP IN SYNC with src/eval/legend.ts (METRIC_LEGEND) — same metric names, directions, and blurbs. -->
216
+
217
+ **Deterministic** (computed from run data, no LLM):
218
+
219
+ | metric | direction | meaning |
220
+ |---|---|---|
221
+ | `runs_green` | ↑ higher is better | Share of generated tests that pass on validation. |
222
+ | `flaky_ratio` | ↓ lower is better | Share of tests classified flaky (inconsistent pass/fail). |
223
+ | `verified_ratio` | ↑ higher is better | Share of identified elements that resolve to exactly one element (unique locator). |
224
+ | `grounding` | ↑ higher is better | Share of cases whose element refs all point to real on-page elements (no hallucinated refs). |
225
+ | `locator_quality` | ↑ higher is better | Share of user-facing locators (getByRole/Label/Text…) vs fragile (.locator/getByTestId). |
226
+ | `locator_robustness` | ↑ higher is better | Weighted selector strength: role 1.0 > label/text 0.8 > test-id 0.5 > css 0. |
227
+ | `technique_coverage` | ↑ higher is better | Distinct test techniques used out of the 6 (ISO/IEC/IEEE 29119-4). |
228
+ | `case_redundancy` | ↓ lower is better | Share of cases that are near-duplicates of another (0 = all distinct). |
229
+
230
+ **Judge** (LLM-scored):
231
+
232
+ | metric | direction | meaning |
233
+ |---|---|---|
234
+ | `test_case_quality` | ↑ higher is better | Holistic quality of the cases (clarity, correctness, usefulness). |
235
+ | `methodology_adherence` | ↑ higher is better | How well the cases follow the testing methodology. |
236
+ | `checklist_coverage` | ↑ higher is better | Semantic coverage of the provided checklist by the cases. |
237
+
238
+ (The holistic **Pilot** verdict is separate — a pass / needs-work / fail judgment on the whole run, not a 0–1 score.)
239
+
190
240
  ## Cost benchmark
191
241
 
192
242
  What does a run cost on each [routing preset](#role-routing)? The table below is generated by
@@ -283,8 +333,8 @@ npm run lint
283
333
  ## Documentation
284
334
 
285
335
  - **[Getting started](docs/getting-started.md)** — step-by-step onboarding (session → design → review → promote → automate → validate), written for people new to the tool.
286
- - **[Architecture overview](docs/architecture/overview.md)** — how the agent works inside (the LangGraph state machine, locator grounding, self-improvement).
287
- - **[Architecture Decision Records](docs/adr/)** — why it's built this way (0001–0012, incl. the interactive TUI, the `@playwright/test` output format, the Lex-Bot → Cairn rename, and the Apache-2.0 relicense).
336
+ - **[Architecture overview](docs/architecture/overview.md)** — how the agent works inside (the plain async pipeline, locator grounding, self-improvement).
337
+ - **[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).
288
338
 
289
339
  ## License
290
340