@plune-ai/cairn 0.2.1 → 0.3.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.
- package/LICENSE +201 -674
- package/README.md +275 -181
- package/dist/agent/finalize.d.ts +20 -0
- package/dist/agent/finalize.d.ts.map +1 -0
- package/dist/agent/finalize.js +42 -0
- package/dist/agent/finalize.js.map +1 -0
- package/dist/agent/graph.d.ts +40 -0
- package/dist/agent/graph.d.ts.map +1 -1
- package/dist/agent/graph.js +0 -0
- package/dist/agent/graph.js.map +1 -1
- package/dist/agent/index.d.ts +18 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +166 -64
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/observe-guard.d.ts +14 -0
- package/dist/agent/observe-guard.d.ts.map +1 -0
- package/dist/agent/observe-guard.js +46 -0
- package/dist/agent/observe-guard.js.map +1 -0
- package/dist/agent/progress.d.ts +22 -0
- package/dist/agent/progress.d.ts.map +1 -0
- package/dist/agent/progress.js +25 -0
- package/dist/agent/progress.js.map +1 -0
- package/dist/agent/repair-loop.d.ts +26 -0
- package/dist/agent/repair-loop.d.ts.map +1 -0
- package/dist/agent/repair-loop.js +42 -0
- package/dist/agent/repair-loop.js.map +1 -0
- package/dist/agent/summary.d.ts +53 -0
- package/dist/agent/summary.d.ts.map +1 -0
- package/dist/agent/summary.js +103 -0
- package/dist/agent/summary.js.map +1 -0
- package/dist/agent/testcase-docs.d.ts +20 -0
- package/dist/agent/testcase-docs.d.ts.map +1 -0
- package/dist/agent/testcase-docs.js +30 -0
- package/dist/agent/testcase-docs.js.map +1 -0
- package/dist/artifacts/report.d.ts +10 -0
- package/dist/artifacts/report.d.ts.map +1 -1
- package/dist/artifacts/report.js +16 -0
- package/dist/artifacts/report.js.map +1 -1
- package/dist/browser/backends/playwright-lib.d.ts.map +1 -1
- package/dist/browser/backends/playwright-lib.js +17 -6
- package/dist/browser/backends/playwright-lib.js.map +1 -1
- package/dist/browser/preflight.d.ts +46 -0
- package/dist/browser/preflight.d.ts.map +1 -0
- package/dist/browser/preflight.js +73 -0
- package/dist/browser/preflight.js.map +1 -0
- package/dist/cli/index.d.ts +10 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +327 -266
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/is-main.d.ts +10 -0
- package/dist/cli/is-main.d.ts.map +1 -0
- package/dist/cli/is-main.js +21 -0
- package/dist/cli/is-main.js.map +1 -0
- package/dist/codegen/index.d.ts +3 -1
- package/dist/codegen/index.d.ts.map +1 -1
- package/dist/codegen/index.js +7 -2
- package/dist/codegen/index.js.map +1 -1
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +80 -2
- package/dist/config/index.js.map +1 -1
- package/dist/config/profiles.d.ts +14 -1
- package/dist/config/profiles.d.ts.map +1 -1
- package/dist/config/profiles.js +30 -0
- package/dist/config/profiles.js.map +1 -1
- package/dist/config/schema.d.ts +23 -1
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +7 -2
- package/dist/config/schema.js.map +1 -1
- package/dist/core/config.d.ts +18 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +23 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/index.d.ts +15 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/modalities/explore.d.ts +3 -0
- package/dist/core/modalities/explore.d.ts.map +1 -0
- package/dist/core/modalities/explore.js +82 -0
- package/dist/core/modalities/explore.js.map +1 -0
- package/dist/core/modality.d.ts +49 -0
- package/dist/core/modality.d.ts.map +1 -0
- package/dist/core/modality.js +24 -0
- package/dist/core/modality.js.map +1 -0
- package/dist/core/registry.d.ts +11 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/registry.js +43 -0
- package/dist/core/registry.js.map +1 -0
- package/dist/core/reporting.d.ts +11 -0
- package/dist/core/reporting.d.ts.map +1 -0
- package/dist/core/reporting.js +13 -0
- package/dist/core/reporting.js.map +1 -0
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/llm/cost.d.ts +53 -0
- package/dist/llm/cost.d.ts.map +1 -0
- package/dist/llm/cost.js +99 -0
- package/dist/llm/cost.js.map +1 -0
- package/dist/llm/factory.d.ts +18 -0
- package/dist/llm/factory.d.ts.map +1 -1
- package/dist/llm/factory.js +24 -0
- package/dist/llm/factory.js.map +1 -1
- package/dist/llm/index.d.ts +6 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +5 -1
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/routing.d.ts +40 -0
- package/dist/llm/routing.d.ts.map +1 -0
- package/dist/llm/routing.js +52 -0
- package/dist/llm/routing.js.map +1 -0
- package/dist/llm/structured.d.ts +28 -5
- package/dist/llm/structured.d.ts.map +1 -1
- package/dist/llm/structured.js +42 -9
- package/dist/llm/structured.js.map +1 -1
- package/dist/prompts/local/identify-elements.js +15 -15
- package/dist/prompts/local/judge-checklist-coverage.js +8 -8
- package/dist/prompts/local/judge-test-cases.js +8 -8
- package/dist/prompts/local/pilot-review.js +10 -10
- package/dist/prompts/local/qa-manual-test-designer.d.ts +1 -1
- package/dist/prompts/local/qa-manual-test-designer.js +7 -7
- package/dist/prompts/local/qa-playwright-ts-writer.d.ts +1 -1
- package/dist/prompts/local/qa-playwright-ts-writer.js +35 -35
- package/dist/prompts/local/qa-testcase-from-ui.d.ts +1 -1
- package/dist/prompts/local/qa-testcase-from-ui.js +47 -47
- package/dist/session/capture.d.ts +31 -0
- package/dist/session/capture.d.ts.map +1 -0
- package/dist/session/capture.js +84 -0
- package/dist/session/capture.js.map +1 -0
- package/dist/session/index.d.ts +16 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +52 -2
- package/dist/session/index.js.map +1 -1
- package/dist/tui/screens/summary-screen.d.ts.map +1 -1
- package/dist/tui/screens/summary-screen.js +13 -1
- package/dist/tui/screens/summary-screen.js.map +1 -1
- package/dist/validate/runner.d.ts +6 -0
- package/dist/validate/runner.d.ts.map +1 -1
- package/dist/validate/runner.js +28 -9
- package/dist/validate/runner.js.map +1 -1
- package/package.json +98 -97
package/README.md
CHANGED
|
@@ -1,181 +1,275 @@
|
|
|
1
|
-
# Cairn
|
|
2
|
-
|
|
3
|
-
> **Cairn — an AI that walks your system and leaves a trail of tests: UI, API, unit, docs.**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
[](https://github.com/plune-ai/cairn/actions/workflows/ci.yml)
|
|
6
|
+
[](https://www.npmjs.com/package/@plune-ai/cairn)
|
|
7
|
+
[](package.json)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
<!-- Inline player badge (optional): `asciinema upload docs/demo/cairn.cast`, then replace the line below
|
|
11
|
+
with [](https://asciinema.org/a/<id>) — see docs/demo/. -->
|
|
12
|
+
▶ **Demo:** [`docs/demo/cairn.cast`](docs/demo/cairn.cast) — play with `asciinema play docs/demo/cairn.cast`
|
|
13
|
+
|
|
14
|
+
> Autonomous QA agent (Node.js / TypeScript) that logs into a web app with a saved session, explores
|
|
15
|
+
> pages (ARIA snapshot + screenshot), designs methodology-based UI test cases (ISO/IEC/IEEE 29119-4),
|
|
16
|
+
> generates runnable `@playwright/test` code, self-validates and self-repairs, and **self-improves**
|
|
17
|
+
> via Langfuse. A portable utility (CLI + library) for embedding into other TypeScript projects.
|
|
18
|
+
|
|
19
|
+
**Cairn is the generation layer** — it produces tests across surfaces (UI today; API / unit / docs planned),
|
|
20
|
+
each arriving by demand, one at a time. A separate **Plune** layer owns record / management / eval.
|
|
21
|
+
|
|
22
|
+
> **Renamed from Lex-Bot → Cairn.** The old `lex-bot` command and the `@plune-ai/lex-bot` package still
|
|
23
|
+
> work — the CLI prints a one-line deprecation notice — but switch to `cairn` / `@plune-ai/cairn`; the old
|
|
24
|
+
> names will be removed in 1–2 releases. Legacy `LEX_`/`LEXBOT_` env vars still work too; prefer `CAIRN_`.
|
|
25
|
+
|
|
26
|
+
## What it does
|
|
27
|
+
|
|
28
|
+
Point it at a URL (behind login, with a saved Playwright `storageState`) and it will:
|
|
29
|
+
|
|
30
|
+
1. **Observe** — navigate, wait for SPA hydration, capture an ARIA snapshot + screenshot, extract interactive elements.
|
|
31
|
+
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.
|
|
32
|
+
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.
|
|
33
|
+
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).
|
|
34
|
+
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.
|
|
35
|
+
|
|
36
|
+
## Two decoupled modes
|
|
37
|
+
|
|
38
|
+
- **`design`** — explore + write test cases as Markdown files (`ATC-*` automatable / `MTC-*` manual) with recorded selectors. **No code.** Review them as a human, automate later.
|
|
39
|
+
- **`automate`** — generate `@playwright/test` code from approved `ATC-*` cases (skips `MTC-*` manual ones).
|
|
40
|
+
- **`explore`** — the full pipeline at once (cases → code → validation → repair → Pilot verdict).
|
|
41
|
+
|
|
42
|
+
## How it works — the full cycle
|
|
43
|
+
|
|
44
|
+
New to this? The bot writes two kinds of test case:
|
|
45
|
+
- **ATC** (*Automatable Test Case*) — the bot is confident it can drive reliably (read-only checks, verified locators) → it generates Playwright code for these.
|
|
46
|
+
- **MTC** (*Manual Test Case*) — needs a human (full form submits, security/XSS, visual/UX, irreversible actions) → left for you to run by hand.
|
|
47
|
+
|
|
48
|
+
The typical flow:
|
|
49
|
+
|
|
50
|
+
1. **Capture a session** (once) — log in so the bot can reach pages behind auth.
|
|
51
|
+
2. **Design** — the bot studies the page and writes test cases (`ATC-*` / `MTC-*` `.md` files with recorded selectors). No code yet.
|
|
52
|
+
3. **Review** — you read the cases (in the TUI: *Browse past runs* → open a run → *Cases*).
|
|
53
|
+
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.
|
|
54
|
+
5. **Automate** — generate `@playwright/test` code from the `ATC` cases.
|
|
55
|
+
6. **Validate** — run the generated tests, classify pass/fail/flaky, and self-repair failures.
|
|
56
|
+
|
|
57
|
+
`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)**.
|
|
58
|
+
|
|
59
|
+
## Install
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm install -g @plune-ai/cairn # global CLI → run `cairn …`
|
|
63
|
+
# …or local / library install:
|
|
64
|
+
npm install @plune-ai/cairn # → run via `npx cairn …`
|
|
65
|
+
|
|
66
|
+
# one-time: download the Chromium build Cairn drives (NOT shipped inside the npm package)
|
|
67
|
+
npx playwright install chromium
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Requires Node.js 20+. Copy `.env.example` → `.env` and fill in your keys.
|
|
71
|
+
|
|
72
|
+
> **Two ways to invoke.** A **global** install (`-g`) puts `cairn` on your PATH, so `cairn design …` works
|
|
73
|
+
> anywhere. A **local** install does *not* — run it as **`npx cairn design …`** from the folder where you
|
|
74
|
+
> installed it. The examples below use the bare `cairn`; prefix them with `npx` if you installed locally.
|
|
75
|
+
>
|
|
76
|
+
> **Browsers are a separate download.** `npm install` pulls the Playwright *library* but not its *browser
|
|
77
|
+
> binaries*. Run **`npx playwright install chromium`** once — otherwise `explore` / `automate --validate`
|
|
78
|
+
> stop early with a clear *"Playwright browsers are not installed"* message (not a wall of failed tests).
|
|
79
|
+
|
|
80
|
+
## Quickstart
|
|
81
|
+
|
|
82
|
+
> Installed locally (without `-g`)? Prefix every `cairn …` below with `npx` (e.g. `npx cairn design …`).
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# 0. One-time: download the browser Cairn drives (skip if you already ran it during install)
|
|
86
|
+
npx playwright install chromium
|
|
87
|
+
|
|
88
|
+
# 1. Capture a session (opens a browser to log in)
|
|
89
|
+
cairn session capture --url https://app.example.com/login --name myapp
|
|
90
|
+
|
|
91
|
+
# 2. Design test cases (no code) — review the .md files it writes
|
|
92
|
+
cairn design --url https://app.example.com/page --session myapp --checklist plan.md
|
|
93
|
+
|
|
94
|
+
# 3. (optional) Promote a manual case you decided is automatable: MTC → ATC
|
|
95
|
+
cairn promote --run runs/<id> --cases MTC-LOGIN-001
|
|
96
|
+
|
|
97
|
+
# 4. Automate the approved (ATC) cases → @playwright/test code, and run them
|
|
98
|
+
cairn automate --run runs/<id> --validate --session myapp
|
|
99
|
+
|
|
100
|
+
# …or do everything at once:
|
|
101
|
+
cairn explore --url https://app.example.com/page --session myapp --checklist plan.md
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The `--checklist` file steers **what** the bot tests (and is scored as coverage). Copy
|
|
105
|
+
[`examples/plan.md`](examples/plan.md) — a ready-to-run checklist for `https://plune.ai/cairn` — as a starting point.
|
|
106
|
+
|
|
107
|
+
New here? Read the **[Getting started guide](docs/getting-started.md)** — it walks the whole cycle with explanations.
|
|
108
|
+
|
|
109
|
+
## Authenticated targets
|
|
110
|
+
|
|
111
|
+
Cairn explores your app **as a logged-in user**. You capture the login **once** into a Playwright
|
|
112
|
+
`storageState` (cookies + localStorage); every later run reuses it — no credentials in code, no
|
|
113
|
+
re-login per run.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# 1. Capture once — a real browser opens; log in by hand, then press Enter.
|
|
117
|
+
cairn session capture --url https://your-app.example.com/login --name myapp
|
|
118
|
+
|
|
119
|
+
# 2. Point Cairn at any page behind that login, reusing the session.
|
|
120
|
+
cairn explore --url https://your-app.example.com/dashboard --session myapp
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- **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>`.
|
|
124
|
+
- **OAuth / Google login** (blocks automated browsers): add `--channel chrome` to capture in real Chrome. Cairn falls back to the bundled browser if Chrome isn't installed.
|
|
125
|
+
- **Manage sessions:** `cairn session ls` lists saved sessions; `cairn session rm <name>` deletes one. (`cairn login` is a shorthand for `cairn session capture`.)
|
|
126
|
+
- **Already have a `storageState.json`?** Skip capture and pass it directly: `--session-file ./path/to/state.json`.
|
|
127
|
+
- **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.
|
|
128
|
+
- **Secrets hygiene:** sessions live in `.auth/` (matching `*.storageState.json`), which is **gitignored** — never committed. Treat the files like passwords.
|
|
129
|
+
|
|
130
|
+
> 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`.
|
|
131
|
+
|
|
132
|
+
## Interactive TUI
|
|
133
|
+
|
|
134
|
+
Run `cairn` with **no arguments** in a terminal to open the interactive TUI (built with Ink):
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
cairn # launches the terminal UI
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Pick a command (explore / design / automate), fill parameters (URL, session, checklist, style) via a
|
|
141
|
+
guided form, watch a **live dashboard** of the graph nodes as the run progresses, read the result summary
|
|
142
|
+
(scores, green %, Pilot verdict, test cases), and **browse past runs** in `./runs` — opening any run to
|
|
143
|
+
read its test cases, report and logs.
|
|
144
|
+
|
|
145
|
+
The commands below stay available for scripting/CI; in a non-interactive (piped/CI) shell, `cairn` with
|
|
146
|
+
no arguments prints help instead of starting the UI.
|
|
147
|
+
|
|
148
|
+
## Commands
|
|
149
|
+
|
|
150
|
+
| Command | Purpose |
|
|
151
|
+
|---|---|
|
|
152
|
+
| `cairn session capture --url <loginUrl> --name <s>` | Capture a login session once → `.auth/` (`cairn login` is a shorthand; `session ls` / `session rm`) |
|
|
153
|
+
| `cairn observe --url <u> [--session <s>]` | ARIA snapshot + interactive elements + screenshot |
|
|
154
|
+
| `cairn design --url <u> --session <s> [--checklist <f>] [--style <s>]` | Test cases only (ATC/MTC `.md` + selectors), no code |
|
|
155
|
+
| `cairn automate --run <dir> [--validate --session <s>]` | `@playwright/test` from `ATC-*` cases |
|
|
156
|
+
| `cairn promote --run <dir> --cases <ids> [--session <s>]` | Promote manual MTC case(s) to ATC (.md only; then `automate`) |
|
|
157
|
+
| `cairn explore --url <u> --session <s> [--checklist <f>]` | Full pipeline (cases → code → validate → repair → Pilot) |
|
|
158
|
+
| `cairn experiment --dataset <d> --candidate name=file` | Compare prompt versions on a dataset |
|
|
159
|
+
|
|
160
|
+
> `lex-bot <command>` still runs every command above (deprecated alias — prints a notice, then runs `cairn`).
|
|
161
|
+
|
|
162
|
+
## Configuration (env)
|
|
163
|
+
|
|
164
|
+
| Var | Purpose |
|
|
165
|
+
|---|---|
|
|
166
|
+
| `LLM_PROFILE` | `anthropic` \| `openrouter` \| `mixed` (per-tier default models) |
|
|
167
|
+
| `LLM_ROUTING` | per-role preset: `fast` (Groq worker) \| `volume` (OpenRouter worker) — see [Role routing](#role-routing) |
|
|
168
|
+
| `ANTHROPIC_API_KEY` / `OPENROUTER_API_KEY` / `GROQ_API_KEY` | provider keys (per profile / routing) |
|
|
169
|
+
| `QA_TESTCASE_LANG` | test-case language (default `English`; e.g. `Ukrainian`, `uk`) |
|
|
170
|
+
| `LANGFUSE_BASE_URL` / `LANGFUSE_PUBLIC_KEY` / `LANGFUSE_SECRET_KEY` | Langfuse — **cloud or self-hosted** (optional; see [below](#optional-langfuse)) |
|
|
171
|
+
| `BROWSER_BACKEND` | `lib` (in-process Playwright) \| `cli` |
|
|
172
|
+
| `BROWSER_CHANNEL` | `chrome` to use real Chrome (helps with OAuth) |
|
|
173
|
+
| `MAX_REPAIR` | repair attempts (default 2) |
|
|
174
|
+
|
|
175
|
+
- **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_`.
|
|
176
|
+
- <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:
|
|
177
|
+
- `fast` → worker on **Groq** `llama-3.3-70b-versatile` — lowest latency/cost, OpenAI-compatible tool-calling.
|
|
178
|
+
- `volume` → worker on **OpenRouter** `deepseek/deepseek-chat` — model breadth.
|
|
179
|
+
- default (unset) → the profile's own per-tier models.
|
|
180
|
+
|
|
181
|
+
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.
|
|
182
|
+
- **Domain knowledge:** put `*.md` files in `./knowledge/` with a `url:` front-matter to inject credentials/validation rules into design.
|
|
183
|
+
- **Prompt overrides:** drop `./prompts/<name>.md` to override any built-in prompt without rebuilding.
|
|
184
|
+
|
|
185
|
+
## Cost benchmark
|
|
186
|
+
|
|
187
|
+
What does a run cost on each [routing preset](#role-routing)? The table below is generated by
|
|
188
|
+
`npm run bench`: it runs `cairn explore` against a fixed target once per preset and reads the per-run
|
|
189
|
+
cost ledger (tokens + $) already written into each run's `report.json` (L1-01) — it re-prices nothing.
|
|
190
|
+
Treat the numbers as an **approximate, single-run snapshot** (LLM token counts vary run-to-run).
|
|
191
|
+
|
|
192
|
+
<!-- BENCHMARK:START -->
|
|
193
|
+
<!-- Generated by `npm run bench` — do not edit between the BENCHMARK markers by hand. -->
|
|
194
|
+
|
|
195
|
+
_Snapshot: 2026-06-13 · commit `a2906cf` · profile `anthropic` · MAX_REPAIR=0 · target: `https://demoqa.com/text-box` (no session) · approximate, single-run._
|
|
196
|
+
|
|
197
|
+
| Preset | Worker | Reasoner | Tokens/run | $/run | Wall-clock/run | $/hour† |
|
|
198
|
+
|---|---|---|---|---|---|---|
|
|
199
|
+
| `default` | claude-haiku-4-5+claude-sonnet-4-6 | claude-opus-4-8 | 27,191 | $0.2854 | 390.6s | $2.63 |
|
|
200
|
+
| `volume` | deepseek/deepseek-chat | claude-opus-4-8 | 13,923 | $0.1209 | 58.2s | $7.48 |
|
|
201
|
+
| `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… | — | — | — |
|
|
202
|
+
|
|
203
|
+
† **$/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.
|
|
204
|
+
|
|
205
|
+
Reproduce: `npm run bench -- --url https://demoqa.com/text-box --session <name>`
|
|
206
|
+
|
|
207
|
+
> 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).
|
|
208
|
+
<!-- BENCHMARK:END -->
|
|
209
|
+
|
|
210
|
+
Regenerate it yourself — you need the provider keys for the presets you want measured and, ideally, a
|
|
211
|
+
[captured session](#authenticated-targets) so the target is a real page rather than `example.com`:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
npm run bench -- --url https://your-app.example.com/dashboard --session myapp --write
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
For reproducibility the benchmark **pins `LLM_PROFILE=anthropic` and `MAX_REPAIR=0`** (both shown in the
|
|
218
|
+
snapshot line) instead of inheriting your `.env` — so `default` always means the same baseline and the
|
|
219
|
+
[reasoner stays on Opus in every preset](#role-routing); only the worker changes. Override with
|
|
220
|
+
`--profile <p>` / `--max-repair <n>`. A preset whose provider key is unset is **skipped** and shown as
|
|
221
|
+
`n/a`, so a partial run (e.g. only `ANTHROPIC_API_KEY` available) still produces a useful table.
|
|
222
|
+
|
|
223
|
+
## Optional: Langfuse
|
|
224
|
+
|
|
225
|
+
Langfuse is **entirely optional** — leave the `LANGFUSE_*` variables unset and the bot runs fully offline.
|
|
226
|
+
Everything core still works: `observe` / `design` / `automate` / `explore`, locator grounding, the LLM judge,
|
|
227
|
+
deterministic scorers, self-repair, and results-level learning (best cases are read from local
|
|
228
|
+
`runs/<id>/report.json`). Prompts fall back to the built-in defaults — override any of them with `./prompts/<name>.md`.
|
|
229
|
+
|
|
230
|
+
Set the three `LANGFUSE_*` variables to **additionally** get: traces in the Langfuse UI, scores/datasets
|
|
231
|
+
recorded centrally, and versioned prompts (with production labels & A/B prompt experiments via `cairn experiment`).
|
|
232
|
+
|
|
233
|
+
**Cloud or self-hosted — same setup.** Langfuse Cloud and a self-hosted instance are configured identically:
|
|
234
|
+
you only pass the host URL and the API keys, nothing else changes.
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
# Pick ONE base URL:
|
|
238
|
+
LANGFUSE_BASE_URL=https://cloud.langfuse.com # Langfuse Cloud (EU)
|
|
239
|
+
# LANGFUSE_BASE_URL=https://us.cloud.langfuse.com # Langfuse Cloud (US)
|
|
240
|
+
# LANGFUSE_BASE_URL=https://langfuse.your-host.tld # self-hosted
|
|
241
|
+
LANGFUSE_PUBLIC_KEY=pk-lf-...
|
|
242
|
+
LANGFUSE_SECRET_KEY=sk-lf-...
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
> Enablement is all-or-nothing: Langfuse turns on only when **all three** variables are set; otherwise
|
|
246
|
+
> telemetry is a no-op and the bot behaves exactly as offline.
|
|
247
|
+
|
|
248
|
+
## Library API
|
|
249
|
+
|
|
250
|
+
```ts
|
|
251
|
+
import { runDesign, runAutomate, runExploration, loadConfig } from "@plune-ai/cairn";
|
|
252
|
+
|
|
253
|
+
const config = loadConfig(process.env);
|
|
254
|
+
const result = await runDesign({ url, config, sessionName: "myapp", checklistText });
|
|
255
|
+
// result.testCases, result.testCaseFiles, result.scores
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Development
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
npm run build # tsc
|
|
262
|
+
npm test # vitest (unit + integration; LLM/browser are mocked in unit)
|
|
263
|
+
npm run test:coverage
|
|
264
|
+
npm run lint
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Documentation
|
|
268
|
+
|
|
269
|
+
- **[Getting started](docs/getting-started.md)** — step-by-step onboarding (session → design → review → promote → automate → validate), written for people new to the tool.
|
|
270
|
+
- **[Architecture overview](docs/architecture/overview.md)** — how the agent works inside (the LangGraph state machine, locator grounding, self-improvement).
|
|
271
|
+
- **[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).
|
|
272
|
+
|
|
273
|
+
## License
|
|
274
|
+
|
|
275
|
+
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`).
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RunWriter } from "../artifacts/index.js";
|
|
2
|
+
import type { CostReport } from "../llm/cost.js";
|
|
3
|
+
import { type BudgetReport } from "./summary.js";
|
|
4
|
+
export interface FailureContext {
|
|
5
|
+
runId: string;
|
|
6
|
+
url: string;
|
|
7
|
+
error: unknown;
|
|
8
|
+
cost?: CostReport;
|
|
9
|
+
budget?: BudgetReport;
|
|
10
|
+
sessionName?: string;
|
|
11
|
+
onProgress?: (event: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The single failure path for `runExploration` (L1-04, Box 1/3/4): classify the error into a
|
|
15
|
+
* readable, actionable message, write partial artifacts (report.json/report.md/run.log), and return
|
|
16
|
+
* the friendly Error to throw. The user always gets a summary + a partial report on disk — never a
|
|
17
|
+
* raw traceback, and never a silent halt.
|
|
18
|
+
*/
|
|
19
|
+
export declare function finalizeFailure(runWriter: RunWriter, ctx: FailureContext): Promise<Error>;
|
|
20
|
+
//# sourceMappingURL=finalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize.d.ts","sourceRoot":"","sources":["../../src/agent/finalize.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAA4D,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAE3G,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAWD;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC,CAmC/F"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { classifyRunError, renderRunSummary, partialReportPayload } from "./summary.js";
|
|
2
|
+
/** Run a best-effort artifact write — an artifact write must never mask the original failure. */
|
|
3
|
+
async function safe(fn) {
|
|
4
|
+
try {
|
|
5
|
+
await fn();
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
// swallow — the run already failed; we just want to leave whatever trail we can.
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The single failure path for `runExploration` (L1-04, Box 1/3/4): classify the error into a
|
|
13
|
+
* readable, actionable message, write partial artifacts (report.json/report.md/run.log), and return
|
|
14
|
+
* the friendly Error to throw. The user always gets a summary + a partial report on disk — never a
|
|
15
|
+
* raw traceback, and never a silent halt.
|
|
16
|
+
*/
|
|
17
|
+
export async function finalizeFailure(runWriter, ctx) {
|
|
18
|
+
const info = classifyRunError(ctx.error, { sessionName: ctx.sessionName, runDir: runWriter.dir });
|
|
19
|
+
ctx.onProgress?.(info.line);
|
|
20
|
+
const summary = renderRunSummary({
|
|
21
|
+
runDir: runWriter.dir,
|
|
22
|
+
cost: ctx.cost,
|
|
23
|
+
budget: ctx.budget,
|
|
24
|
+
partial: true,
|
|
25
|
+
note: info.hint,
|
|
26
|
+
});
|
|
27
|
+
await safe(() => runWriter.writeReport(partialReportPayload({ runId: ctx.runId, url: ctx.url, error: info.line, cost: ctx.cost, budget: ctx.budget })));
|
|
28
|
+
await safe(() => runWriter.writeReportMd([
|
|
29
|
+
"# QA Explorer — run report (partial)",
|
|
30
|
+
"",
|
|
31
|
+
`- **URL:** ${ctx.url}`,
|
|
32
|
+
`- **Run ID:** ${ctx.runId}`,
|
|
33
|
+
"",
|
|
34
|
+
`> ⚠ ${info.line}`,
|
|
35
|
+
`> ${info.hint}`,
|
|
36
|
+
"",
|
|
37
|
+
...summary,
|
|
38
|
+
].join("\n")));
|
|
39
|
+
await safe(() => runWriter.writeLog([info.line, "", ...summary].join("\n")));
|
|
40
|
+
return new Error([info.line, "", ...summary, "", info.hint].join("\n"));
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=finalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize.js","sourceRoot":"","sources":["../../src/agent/finalize.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,oBAAoB,EAAqB,MAAM,cAAc,CAAC;AAY3G,iGAAiG;AACjG,KAAK,UAAU,IAAI,CAAC,EAA0B;IAC5C,IAAI,CAAC;QACH,MAAM,EAAE,EAAE,CAAC;IACb,CAAC;IAAC,MAAM,CAAC;QACP,iFAAiF;IACnF,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAoB,EAAE,GAAmB;IAC7E,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,GAAG,EAAE,CAAC,CAAC;IAClG,GAAG,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE5B,MAAM,OAAO,GAAG,gBAAgB,CAAC;QAC/B,MAAM,EAAE,SAAS,CAAC,GAAG;QACrB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,IAAI,CAAC,IAAI;KAChB,CAAC,CAAC;IAEH,MAAM,IAAI,CAAC,GAAG,EAAE,CACd,SAAS,CAAC,WAAW,CACnB,oBAAoB,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAC/G,CACF,CAAC;IACF,MAAM,IAAI,CAAC,GAAG,EAAE,CACd,SAAS,CAAC,aAAa,CACrB;QACE,sCAAsC;QACtC,EAAE;QACF,cAAc,GAAG,CAAC,GAAG,EAAE;QACvB,iBAAiB,GAAG,CAAC,KAAK,EAAE;QAC5B,EAAE;QACF,OAAO,IAAI,CAAC,IAAI,EAAE;QAClB,KAAK,IAAI,CAAC,IAAI,EAAE;QAChB,EAAE;QACF,GAAG,OAAO;KACX,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CACF,CAAC;IACF,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE7E,OAAO,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1E,CAAC"}
|