@axn-dev/cmd-flow 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/dist/adapter-dispose.test.d.ts +2 -0
- package/dist/adapter-dispose.test.d.ts.map +1 -0
- package/dist/adapter-dispose.test.js +105 -0
- package/dist/adapter-dispose.test.js.map +1 -0
- package/dist/adapter-routing.test.d.ts +2 -0
- package/dist/adapter-routing.test.d.ts.map +1 -0
- package/dist/adapter-routing.test.js +97 -0
- package/dist/adapter-routing.test.js.map +1 -0
- package/dist/adapter-video.test.d.ts +2 -0
- package/dist/adapter-video.test.d.ts.map +1 -0
- package/dist/adapter-video.test.js +80 -0
- package/dist/adapter-video.test.js.map +1 -0
- package/dist/adapters/adapterRegistry.d.ts +14 -0
- package/dist/adapters/adapterRegistry.d.ts.map +1 -0
- package/dist/adapters/adapterRegistry.js +25 -0
- package/dist/adapters/adapterRegistry.js.map +1 -0
- package/dist/adapters/http.d.ts +19 -0
- package/dist/adapters/http.d.ts.map +1 -0
- package/dist/adapters/http.js +47 -0
- package/dist/adapters/http.js.map +1 -0
- package/dist/completion.test.d.ts +2 -0
- package/dist/completion.test.d.ts.map +1 -0
- package/dist/completion.test.js +60 -0
- package/dist/completion.test.js.map +1 -0
- package/dist/env-expand.d.ts +17 -0
- package/dist/env-expand.d.ts.map +1 -0
- package/dist/env-expand.js +56 -0
- package/dist/env-expand.js.map +1 -0
- package/dist/env-expand.test.d.ts +2 -0
- package/dist/env-expand.test.d.ts.map +1 -0
- package/dist/env-expand.test.js +38 -0
- package/dist/env-expand.test.js.map +1 -0
- package/dist/flow.d.ts +157 -0
- package/dist/flow.d.ts.map +1 -0
- package/dist/flow.js +2466 -0
- package/dist/flow.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive-host.d.ts +17 -0
- package/dist/interactive-host.d.ts.map +1 -0
- package/dist/interactive-host.js +64 -0
- package/dist/interactive-host.js.map +1 -0
- package/dist/interactive-ui.test.d.ts +2 -0
- package/dist/interactive-ui.test.d.ts.map +1 -0
- package/dist/interactive-ui.test.js +228 -0
- package/dist/interactive-ui.test.js.map +1 -0
- package/dist/interactive.d.ts +53 -0
- package/dist/interactive.d.ts.map +1 -0
- package/dist/interactive.js +78 -0
- package/dist/interactive.js.map +1 -0
- package/dist/interactive.test.d.ts +2 -0
- package/dist/interactive.test.d.ts.map +1 -0
- package/dist/interactive.test.js +161 -0
- package/dist/interactive.test.js.map +1 -0
- package/dist/live-session.d.ts +32 -0
- package/dist/live-session.d.ts.map +1 -0
- package/dist/live-session.js +115 -0
- package/dist/live-session.js.map +1 -0
- package/dist/llm-judge.d.ts +7 -0
- package/dist/llm-judge.d.ts.map +1 -0
- package/dist/llm-judge.js +190 -0
- package/dist/llm-judge.js.map +1 -0
- package/dist/orchestrator-host.d.ts +2 -0
- package/dist/orchestrator-host.d.ts.map +1 -0
- package/dist/orchestrator-host.js +190 -0
- package/dist/orchestrator-host.js.map +1 -0
- package/dist/orchestrator-host.test.d.ts +2 -0
- package/dist/orchestrator-host.test.d.ts.map +1 -0
- package/dist/orchestrator-host.test.js +201 -0
- package/dist/orchestrator-host.test.js.map +1 -0
- package/dist/pw/pw-runner.d.ts +11 -0
- package/dist/pw/pw-runner.d.ts.map +1 -0
- package/dist/pw/pw-runner.js +150 -0
- package/dist/pw/pw-runner.js.map +1 -0
- package/dist/pw/pw-spec.d.ts +2 -0
- package/dist/pw/pw-spec.d.ts.map +1 -0
- package/dist/pw/pw-spec.js +379 -0
- package/dist/pw/pw-spec.js.map +1 -0
- package/dist/repeat-llm.test.d.ts +2 -0
- package/dist/repeat-llm.test.d.ts.map +1 -0
- package/dist/repeat-llm.test.js +137 -0
- package/dist/repeat-llm.test.js.map +1 -0
- package/dist/screenshot.d.ts +83 -0
- package/dist/screenshot.d.ts.map +1 -0
- package/dist/screenshot.js +197 -0
- package/dist/screenshot.js.map +1 -0
- package/dist/screenshot.test.d.ts +2 -0
- package/dist/screenshot.test.d.ts.map +1 -0
- package/dist/screenshot.test.js +276 -0
- package/dist/screenshot.test.js.map +1 -0
- package/package.json +100 -3
- package/skills/axn-dev-flow/SKILL.md +464 -0
- package/README.md +0 -3
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: axn-dev-flow
|
|
3
|
+
description: Run XML- or Gherkin (.feature)-defined flow tests against scenarios, deployed devices, or any deployment URL with `axn-dev flow`. Supports the built-in tsAdapter (TypeScript/Playwright scripts), pluggable adapters (http, keycloak, custom tags), readiness checks, orchestrators, and JSON report output.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# axn-dev flow Skill
|
|
7
|
+
|
|
8
|
+
`axn-dev flow` runs tests defined in XML or Gherkin (`.feature`) against Docker Compose scenarios, deployed devices (`-i`), or any already-running deployment (`--base-url` / `url=` on `<scenario>`). A flow describes which scenario to start, which model/adapter to use, the steps to execute, and assertions to verify.
|
|
9
|
+
|
|
10
|
+
## When to use this skill
|
|
11
|
+
|
|
12
|
+
- Regression-testing API behavior end-to-end (e.g. an agent or chat endpoint).
|
|
13
|
+
- Verifying that a specific user message still triggers the right response.
|
|
14
|
+
- Running TypeScript/Playwright E2E scripts against a scenario (`tsAdapter`).
|
|
15
|
+
- Testing against a deployed device (`-i <device>` with tsAdapter).
|
|
16
|
+
- Running the same prompt against multiple models (e.g. `ollama/llama3.1` and `openai/gpt-4o`).
|
|
17
|
+
- Collecting structured pass/fail reports over time.
|
|
18
|
+
|
|
19
|
+
## Repo layout
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
<integration-repo>/ # e.g. app-integration
|
|
23
|
+
├── flows/
|
|
24
|
+
│ ├── example.xml # one or more <flow> definitions
|
|
25
|
+
│ ├── example.feature # or Gherkin + YAML frontmatter (one or more Scenarios)
|
|
26
|
+
│ └── .reports/ # generated JSON reports (gitignored)
|
|
27
|
+
└── scenarios/
|
|
28
|
+
└── app-dev/
|
|
29
|
+
└── compose.yaml
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## XML format
|
|
33
|
+
|
|
34
|
+
```xml
|
|
35
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
36
|
+
<flows>
|
|
37
|
+
<flow name="example - how late is it">
|
|
38
|
+
<description>
|
|
39
|
+
Example flow - about asking about current time
|
|
40
|
+
</description>
|
|
41
|
+
<scenarios>
|
|
42
|
+
<scenario name="app-dev" service="app-server" adapter="http">
|
|
43
|
+
<readiness path="/health" expected="ok"/>
|
|
44
|
+
</scenario>
|
|
45
|
+
</scenarios>
|
|
46
|
+
<setup>
|
|
47
|
+
<models>
|
|
48
|
+
<model provider="ollama" name="llama3.1:latest"/>
|
|
49
|
+
</models>
|
|
50
|
+
<env>
|
|
51
|
+
<var name="MY_VAR" value="value"/>
|
|
52
|
+
</env>
|
|
53
|
+
</setup>
|
|
54
|
+
<steps>
|
|
55
|
+
<usermessage>What time is it?</usermessage>
|
|
56
|
+
<assertions>
|
|
57
|
+
<assert that="num_responses" value="1"/>
|
|
58
|
+
<assert that="contains" value="time"/>
|
|
59
|
+
</assertions>
|
|
60
|
+
</steps>
|
|
61
|
+
</flow>
|
|
62
|
+
</flows>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Gherkin (.feature) format
|
|
66
|
+
|
|
67
|
+
A `.feature` file is an alternative notation: YAML frontmatter carries the
|
|
68
|
+
file-level config (scenarios, env, models, orchestrator, runner, adapter,
|
|
69
|
+
`base-url`, tags, `include` dirs), each `Scenario` becomes a flow.
|
|
70
|
+
Semantics are custom — deterministic patterns, no step-definition matching
|
|
71
|
+
— but the file stays parseable as ordinary Gherkin.
|
|
72
|
+
|
|
73
|
+
```gherkin
|
|
74
|
+
---
|
|
75
|
+
scenarios:
|
|
76
|
+
- name: app-dev
|
|
77
|
+
service: app-server
|
|
78
|
+
adapter: http
|
|
79
|
+
env:
|
|
80
|
+
MY_VAR: value
|
|
81
|
+
models:
|
|
82
|
+
- { provider: ollama, name: llama3.1:latest }
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
Feature: example - how late is it
|
|
86
|
+
|
|
87
|
+
Scenario: asking about the time
|
|
88
|
+
Given step "db-cleanup" # step-file ref (steps/*.xml)
|
|
89
|
+
When script "steps/invite.ts"
|
|
90
|
+
When the user says "What time is it?"
|
|
91
|
+
Then the output contains "time"
|
|
92
|
+
And there is 1 response
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
- **Producing steps**: `step "name"` / `step file "p.xml"` / `script "x.ts"`
|
|
96
|
+
/ `the user says "…"` (+ `"""` docstring) / `picture` / `extract` / bare
|
|
97
|
+
ident → custom adapter tag. `k=v` tokens → args; `adapter=`/`desc=` → fields.
|
|
98
|
+
`| k | v |` tables under a step → args.
|
|
99
|
+
- **Assertions** (`Then`/`And`): `the output contains "x"`, `the new output
|
|
100
|
+
contains "x"` (fresh), `there is|are N responses`, `the exit code is N`,
|
|
101
|
+
`it took less than|between … ms`, `the page matches "ref.png"`,
|
|
102
|
+
`"sel" matches "ref.png"`, `an llm judges "rubric" [using "judge"]`,
|
|
103
|
+
`script "x.ts" passes`, plus generic `assert <that> [value] [k=v] [flags]`.
|
|
104
|
+
- **Blocks** (custom, `*`-prefixed): `* video "x":` / `* repeat N times at
|
|
105
|
+
80%:` / `* stopwatch "id":` — children are the deeper-indented lines.
|
|
106
|
+
- A `Then` indented deeper than a step binds to that step (nested assert).
|
|
107
|
+
- `Background:` steps prepend to every scenario; `@tags` → flow tags;
|
|
108
|
+
`Scenario Outline` + `Examples` fan out into flows (row merges into env,
|
|
109
|
+
`<col>` substitutes).
|
|
110
|
+
- Frontmatter is file-level: all scenarios share config — divergent flows
|
|
111
|
+
go in separate files. Step files stay `.xml`.
|
|
112
|
+
|
|
113
|
+
### Elements
|
|
114
|
+
|
|
115
|
+
`<flow name="..." orchestrator="..." adapter="..." base-url="...">`:: A single test flow. `orchestrator` points to a TypeScript orchestrator script (see below). `adapter` is the *default step adapter* — `<step>`/`<script>` units without their own `adapter=` use it, also inside `<repeat>`, `<metric>` and `<video>` — e.g. `<flow adapter="axn-term">` lets a flow of adapter steps omit `adapter=` on every step; it does **not** affect `<usermessage>` or custom tags. In an adapter flow, a step no adapter can run fails the flow, naming the step; it is never skipped. `base-url` is the *default deployment URL* — a scenario-less flow pointing at an already-running deployment (k8s, staging…); `url=` on a `<scenario>` and `--base-url` take precedence.
|
|
116
|
+
|
|
117
|
+
`<scenarios>`:: One or more `<scenario>` elements to start and test against.
|
|
118
|
+
|
|
119
|
+
`<scenario name="..." service="..." adapter="..."/>`:: Attributes:
|
|
120
|
+
- `name` — scenario name (its meaning is adapter-defined: usually a compose scenario)
|
|
121
|
+
- `service` — target service inside the compose file
|
|
122
|
+
- `adapter` — a registered adapter name (`http`, `tsAdapter`, `keycloak`, a plugin adapter, or a file path)
|
|
123
|
+
- `orchestrator` — (tsAdapter) path to a TypeScript orchestrator script, relative to the flow file
|
|
124
|
+
- `url` — base URL of an already-running deployment (k8s, VM, staging…); no scenario is started and `name` becomes a label only. `${VAR}` expands against process + flow env; `--base-url` overrides it.
|
|
125
|
+
- Plugin adapters may define additional attributes (e.g. `project`, `workingDirectory`, `branch`).
|
|
126
|
+
|
|
127
|
+
`<readiness path="..." port="..." expected="..."/>`:: Optional child of `<scenario>`: poll an HTTP endpoint on the scenario's published port until it responds with the expected body substring (default: the service's published port).
|
|
128
|
+
|
|
129
|
+
`<setup>`:: Optional `<models>`, `<env>` (`<var name="..." value="..."/>`), plus adapter-specific children.
|
|
130
|
+
|
|
131
|
+
`<steps>`:: `<usermessage>` (served by any adapter claiming that tag), one or more `<step>`/`<script>` elements (tsAdapter or `adapter="..."`), custom plugin tags, plus `<assertions>`.
|
|
132
|
+
|
|
133
|
+
`<step src="path/to/script.ts"/>` / `<script src="..."/>`:: (tsAdapter) a TypeScript/Playwright script, either via `src` (relative to the flow file) or inline text. Multiple steps require an `orchestrator` on the `<flow>` or `<scenario>`. The tag body can be used as a description when `src` is set, e.g. `<step src="steps/login.ts" myArgs="xyz">Login of user</step>`.
|
|
134
|
+
|
|
135
|
+
**`<step>` vs `<script>`** — pure aliases (both parse to the same `script` unit; no adapter can tell them apart). Recommended convention by readability: `<step adapter="x" action="…"/>` for adapter/command calls — it reads like a pipeline step — and `<script>` only when the content literally is code (`<script src="…"/>` or an inline body).
|
|
136
|
+
|
|
137
|
+
`<step adapter="keycloak" action="createUser" .../>`:: (keycloak plugin adapter) creates a Keycloak user and sets the password. Supported actions: `createUser`, `deleteUser`, `resetPassword`.
|
|
138
|
+
|
|
139
|
+
`<usermessage value="...">`:: The user message, dispatched to whichever adapter claims the `usermessage` tag — selected by the scenario's `adapter` attribute. The tag body can be used as a description when a `value` attribute provides the message.
|
|
140
|
+
|
|
141
|
+
`<assertions>`:: One or more `<assert that="..." value="..."/>` checks. The tag body (before the child `<assert>` elements) can be used as a description.
|
|
142
|
+
|
|
143
|
+
`<picture name="after-login" [selector=".data-grid"] [fullPage="true"]/>`:: (tsAdapter + orchestrator) captures a screenshot at that exact point in the step order — viewport by default, a single element with `selector`, or the whole scrollable page with `fullPage`. Saved as a PNG in the run's evidence dir.
|
|
144
|
+
|
|
145
|
+
`<video name="segment">...</video>`:: (tsAdapter + orchestrator) records a video while the enclosed steps run. Steps inside `<video>` execute normally; the orchestrator's `videoStart(name, dir)`/`videoStop(name)` hooks drive the recording (see "Orchestrator contract" below). Saved as `.webm` in the evidence dir.
|
|
146
|
+
|
|
147
|
+
### Reusable step files
|
|
148
|
+
|
|
149
|
+
A step can live in its own `.xml` file (exactly one step element — `<step>`/`<script>`, `<usermessage>`, `<assertions>` or a custom adapter tag — as root or inside a single-child `<steps>`) and be bound by name or path:
|
|
150
|
+
|
|
151
|
+
```xml
|
|
152
|
+
<!-- flows/steps/login.xml -->
|
|
153
|
+
<step src="ft-login.ts"/>
|
|
154
|
+
|
|
155
|
+
<!-- in the flow -->
|
|
156
|
+
<steps include="../shared/step-lib">
|
|
157
|
+
<step action="login" user="mom"/> <!-- binds login.xml by name -->
|
|
158
|
+
<step file="steps/logout.xml"/> <!-- explicit path, relative to flow -->
|
|
159
|
+
</steps>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
- Lookup dirs: the flow dir, `steps/` next to it, plus `include="a,b"` dirs on `<flows>`, `<flow>` or `<steps>` (relative to the flow file).
|
|
163
|
+
- `src`/`script` inside the step file resolves relative to the step file's dir; `script` is an alias for `src`.
|
|
164
|
+
- Duplicate names across step dirs are an error — disambiguate with `file=`.
|
|
165
|
+
- `action=` on a plain `<step>` is a step-file ref; combined with `adapter=` it stays an adapter argument. `file=` cannot be combined with `src`/`adapter`.
|
|
166
|
+
- Extra attributes on the referencing step merge into the bound step's args (caller wins); `desc`/tag text override the description.
|
|
167
|
+
- Step files may chain (`<step action="other"/>` inside); cycles are an error.
|
|
168
|
+
- `file=` and `action=` cannot be combined on one `<step>`.
|
|
169
|
+
|
|
170
|
+
### Reserved names
|
|
171
|
+
|
|
172
|
+
Self-declared names must not reuse the engine's vocabulary — custom `<steps>` tags, `<step action="name">` refs and step-file basenames. Reserved: the step elements (`usermessage`, `step`, `script`, `assert`, `assertions`, `picture`, `video`, `repeat`, `extract`), structural elements (`flows`, `flow`, `steps`, `scenarios`, `scenario`, `setup`, `models`, `model`, `env`, `var`, `readiness`, `tags`, `tag`, `description`, `tool-mode`, `use-docker`) and the step-ref keywords (`file`, `action`, `include`, `src`). `<file .../>` in `<steps>` or `<step action="file">` fails at load time. Plugin adapters cannot claim these tags either (dropped with a warning; `usermessage` exempt).
|
|
173
|
+
|
|
174
|
+
Flow files are validated at load: required attributes, known `that` assertion types (`contains`, `num_responses`, `exitCode`, `screenshot`, `llm`, `duration`, `metric`, `script`) plus their per-type requirements, evidence `name`s, non-empty steps, unique flow names per file.
|
|
175
|
+
|
|
176
|
+
### Evidence capture
|
|
177
|
+
|
|
178
|
+
`<picture>` and `<video>` are inline step units — like `<assertions>` they can sit anywhere between steps. Artifacts are written to `flows/.reports/evidence/<flow>-<timestamp>/` (alongside the JSON reports in the gitignored `.reports/` dir) and listed in the JSON report under `flows[].evidence` (`{kind, name, path}`). The `axn-dev serve` report view renders screenshots inline and plays videos.
|
|
179
|
+
|
|
180
|
+
```xml
|
|
181
|
+
<steps>
|
|
182
|
+
<step src="steps/login.ts">Log in</step>
|
|
183
|
+
<picture name="after-login" />
|
|
184
|
+
<picture name="grid" selector=".data-grid" />
|
|
185
|
+
<video name="booking">
|
|
186
|
+
<step src="steps/open-booking.ts" />
|
|
187
|
+
<step src="steps/confirm.ts" />
|
|
188
|
+
</video>
|
|
189
|
+
<assertions><assert that="exitCode" value="0"/></assertions>
|
|
190
|
+
</steps>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Evidence requires an orchestrator-driven `tsAdapter` flow (a browser must exist); on other adapters the run fails with an error.
|
|
194
|
+
|
|
195
|
+
In **interactive runs** (`--interactive`, adapter flows only for now) the engine executes each top-level step only after a key: Enter runs it, `s` skips, `q` aborts; a failed step stops for retry (Enter/`r`) or skip, and a retry is judged on its own output. `interactive="auto"` on a step runs it without stopping. The report records `flows[].interactive` (outcome and failed attempts per gated step). Needs a TTY, unless `--interactive-ui [port]` serves a driver page — open `http://127.0.0.1:<port>/` (→ `/interactive/<runId>/driver`): step rail, Next/Skip/Retry, live output, while the product runs in its own visible or attached browser window (`/interactive/<runId>` frames it instead only when `AXN_DEV_BROWSER_HEADED=false`); keys →/PageDown/Space, S, R. Port: flag, else `AXN_DEV_INTERACTIVE_PORT`, else `interactive.port` config, else free. **Browser** for pw flows, screenshot assertions and browser-driving adapters: `AXN_DEV_BROWSER` (chromium|firefox|webkit), `AXN_DEV_BROWSER_CHANNEL` (chrome, msedge…), `AXN_DEV_BROWSER_HEADED` (auto = window when interactive), `AXN_DEV_BROWSER_ATTACH` (CDP URL of an open Chrome) — shell or flow `<env>`.
|
|
196
|
+
|
|
197
|
+
In **manual runs** (`--manual` or the serve manual view) evidence is supplied by the human: every step card has an "Attach evidence" file input (web) or an "Attach evidence file" prompt (CLI). Uploaded/copied files land in the same evidence dir layout and are recorded with their `stepIndex`, so a screenshot of a failure shows up in the report next to the failed step.
|
|
198
|
+
|
|
199
|
+
### Orchestrator contract
|
|
200
|
+
|
|
201
|
+
An orchestrator is a TypeScript module (run via `tsx`) whose default export has `start(baseUrl, env)`, `run(steps)` and `stop()`. Steps are script paths (or `{path, args}` objects); each script's default export is called with whatever the orchestrator passes — the Playwright convention is `(page, baseUrl)`.
|
|
202
|
+
|
|
203
|
+
For `<video>` support the orchestrator additionally implements:
|
|
204
|
+
|
|
205
|
+
- `videoStart(name: string, dir?: string)` — begin recording. Prefer `page.screencast.start({ path })`, which records the live page in place; swapping in a `recordVideo` context reloads the page, so state (an open dialog) is lost across `</video>` and a `<picture>` right after it captures a loading page.
|
|
206
|
+
- `videoStop(name: string)` — stop recording, finalize the artifact in `dir`, and return its absolute path (or `void`).
|
|
207
|
+
|
|
208
|
+
The host splits each `run()` batch at video boundaries and calls the hooks between segments, so `run()` itself never sees markers. If a step inside a video fails, still-open recordings are finalized best-effort before the error propagates. Orchestrators without the hooks fail with a clear error when a `<video>` step runs.
|
|
209
|
+
|
|
210
|
+
### Adapters
|
|
211
|
+
|
|
212
|
+
Adapters are pluggable — declared in a plugin's `package.json` under `axn-dev.flowAdapters` with `{name, entry, tags, extends, wantsScenario}`. An adapter claims XML tags; `axn-dev flow list-adapters` shows the registry.
|
|
213
|
+
|
|
214
|
+
`tsAdapter` (built-in):: Executes TypeScript/Playwright scripts via `tsx` against the scenario (or a device with `-i`). Requires `tsx` to be installed. Script output goes to stdout and is evaluated by the assertions.
|
|
215
|
+
|
|
216
|
+
`http` (bundled):: POSTs `<usermessage>` as `{message, provider, model}` to the scenario service — path defaults to `/chat`, overridable per step via the `path` attribute; `field` picks the JSON response field to use as output. Base URL is discovered from the scenario's published port, overridable via `BASE_URL`.
|
|
217
|
+
|
|
218
|
+
`keycloak` (`@axn-dev/adapter-keycloak`):: Creates, deletes or resets Keycloak users through the Admin API. Claims the `<keycloak>` tag; attributes on the `<step>` are passed to the adapter.
|
|
219
|
+
|
|
220
|
+
`<custom>`:: Any unregistered `adapter` attribute resolves to a script file run by `tsx`, receiving the step as `process.env.AXN_STEP` JSON plus the merged flow env. Resolved in order: `--adapter <name=path>`, `adapters:` in `.axn-dev/config.yaml`, the step's `src` attribute, then `adapters/<adapter>.ts`/`.js` next to the flow file. Use this for product-specific logic.
|
|
221
|
+
|
|
222
|
+
Plugin adapters:: Any installed plugin can contribute adapters — including custom XML tags (e.g. `<keycloak>`) and adapters that `extend` an existing one. See `docs/plugins.adoc`.
|
|
223
|
+
|
|
224
|
+
### Assertions
|
|
225
|
+
|
|
226
|
+
Assertions judge **captured stdout** — step output, adapter responses, `<extract>` reads — accumulating in one buffer per flow. Placement decides *which slice* of that buffer an assert sees:
|
|
227
|
+
|
|
228
|
+
- **Nested in a producing step** (`<step>`, `<usermessage>`, `<extract>`, custom tags) — the assert judges *that step's own output only* (and `that="duration"` measures its wall-clock ms). The subject under test is explicit — the preferred shape.
|
|
229
|
+
- **Bare `<assert/>` or `<assertions>` between steps** — sees **all output accumulated since the flow started** (or since the current `<repeat>` iteration started). Cumulative — *not* just the last step.
|
|
230
|
+
- **`fresh="true"`** (on `<assert>` or the whole `<assertions>` group) — sees only output produced **since the previous assertions unit**. A `fresh` first assert behaves like a normal one (there is no previous unit yet).
|
|
231
|
+
|
|
232
|
+
The window mechanic: after *every* assertions unit — a bare `<assert/>` counts as a one-element block — an internal cursor moves to the end of output at that moment. `fresh` asserts evaluate the slice since that cursor; non-fresh asserts ignore it entirely. Inside one `<assertions>` group, all asserts share the same window (the cursor moves only after the group completes).
|
|
233
|
+
|
|
234
|
+
```text
|
|
235
|
+
<step/> 1 <step/> 2 <step/> 3
|
|
236
|
+
<assert/> → sees 1,2,3
|
|
237
|
+
<step> 4 <assert/></step> → sees 4 only (nested = step-scoped)
|
|
238
|
+
<assert/> → sees 1,2,3,4 (cumulative)
|
|
239
|
+
<step/> 5
|
|
240
|
+
<assert fresh="true"/> → sees 5 only (since previous assertions unit)
|
|
241
|
+
<step/> 6 <step/> 7
|
|
242
|
+
<assertions>
|
|
243
|
+
<assert/> → sees 1..7 — NOT just 6,7
|
|
244
|
+
</assertions>
|
|
245
|
+
<assertions fresh="true">
|
|
246
|
+
<assert/> → sees 6,7 — windowed by the flag
|
|
247
|
+
</assertions>
|
|
248
|
+
<assert/> → sees 1..7
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Rules of thumb: want "check what just happened" → `fresh="true"` or nest the assert in the step; want "did this ever appear in the run" → bare assert. Inside `<repeat>`, each iteration gets its own buffer start, so plain asserts there see only that iteration's output.
|
|
252
|
+
|
|
253
|
+
**When to use `<assertions>`** — only two reasons, both optional:
|
|
254
|
+
|
|
255
|
+
1. **`desc="…"`** — a named report group: the label shows on its asserts in reports and the serve view. Without it, each assert is a standalone line item.
|
|
256
|
+
2. **`fresh="true"`** — apply the windowed scope to several asserts at once instead of repeating the flag on each.
|
|
257
|
+
|
|
258
|
+
An `<assertions>` group with neither is just bare asserts with extra indentation — it does **not** create a sub-scope or narrow the window.
|
|
259
|
+
|
|
260
|
+
```xml
|
|
261
|
+
<usermessage value="What time is it?">
|
|
262
|
+
<assert that="llm" judge="ollama/qwen2.5:14b">The reply states a concrete time</assert>
|
|
263
|
+
<assert that="duration" max="3000"/>
|
|
264
|
+
</usermessage>
|
|
265
|
+
<step src="steps/book.ts"><assert that="contains" value="confirmed"/></step>
|
|
266
|
+
<extract selector=".chat .bubble:last-child"><assert that="contains" value="Berlin"/></extract>
|
|
267
|
+
<assertions fresh="true" desc="latest output only">
|
|
268
|
+
<assert that="contains" value="done"/>
|
|
269
|
+
</assertions>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
`num_responses`:: Number of responses received (`1` for a single REST call, non-empty output for scripts).
|
|
273
|
+
`contains`:: A string that must appear (case-insensitive) in the response/stdout.
|
|
274
|
+
`exitCode`:: (tsAdapter) the process exit code must equal `value`.
|
|
275
|
+
`duration`:: Step wall-clock time in ms — `min`/`max` bounds, or numeric `value` as shorthand max. Needs a producing-step context (nested asserts).
|
|
276
|
+
`metric`:: Bound a recorded metric — `name=` required plus `min`/`max` bounds (numeric `value` = shorthand max). Checks the latest metric of that name recorded in this flow: emitted (`AXN_METRIC` line / `ctx.emitMetric`) or collected (`<metric>` block).
|
|
277
|
+
`script`:: A ts/js assertion script (`src` or `value`), run via tsx: gets the output under test as `$AXN_OUTPUT`, the assert JSON as `$AXN_ASSERT`; exit 0 = pass, stdout becomes the report detail.
|
|
278
|
+
`screenshot`:: Visual regression: captures `url` (default `BASE_URL`) with headless Chromium and compares it against the reference PNG at `value` (relative to the flow file). Antialiasing is tolerated; layout/shape changes fail. Attributes: `selector` (element capture — cropped to the element, so position changes are invisible; select a *container* element or omit it for a whole-page capture to catch moves), `fullPage`, `maxDiff` (fraction of differing pixels, default 0.01), `threshold` (per-pixel color, default 0.1), `viewport` ("WxH", default 1280x800), `wait` (ms or CSS selector). Diffs land in `flows/.reports/screenshots/`; `AXN_FLOW_UPDATE_SCREENSHOTS=1` rewrites the reference. Requires `playwright-core` and a Chromium browser (`npx playwright install chromium`).
|
|
279
|
+
|
|
280
|
+
```xml
|
|
281
|
+
<assert that="screenshot" value="refs/button.png" selector="#buy"
|
|
282
|
+
url="${BASE_URL}/shop" maxDiff="0.02"/>
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
`llm`:: Judges the captured output with an LLM, a local agent CLI, a binary judge service, or a plugin-registered judge. Rubric comes from `prompt` (or `value`); `judge` selects the evaluator: `ollama/<model>` (`OLLAMA_BASE_URL`), `openai/<model>` (`OPENAI_API_KEY`, `OPENAI_BASE_URL`), a local agent CLI in one-shot mode (`claude[/model]` → `claude -p`, `gemini[/model]` → `gemini -p`, `codex[/model]` → `codex exec`, `devin[/model]` → `devin -p`), an `http(s)://` endpoint POSTed `{prompt, response}` returning a binary verdict (`{"pass":true|false}` or `PASS`/`FAIL` text), or a plugin judge declared via `axn-dev.judges` (`judge="<name>"` or `"<name>/<arg>"`). Falls back to `$AXN_JUDGE`; `AXN_JUDGE_TIMEOUT_MS` overrides the 60s timeout.
|
|
286
|
+
|
|
287
|
+
```xml
|
|
288
|
+
<assert that="llm" prompt="The response states a concrete time" judge="ollama/llama3.1"/>
|
|
289
|
+
<assert that="llm" value="mentions Berlin" judge="https://jev.example/eval"/>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### DOM extraction: `<extract>`
|
|
293
|
+
|
|
294
|
+
`<extract selector=".chat .msg:last-child" [attr="text|value|html|<attr-name>"] [url="…"/>` reads a DOM element's content into the output stream, so `contains`/`llm` assertions — and `<repeat>` blocks — can judge e.g. the last message of an interactive HTML chat. On orchestrator flows it reads the **live page** (state after prior steps); under `runner="pw"` the worker page. Requires `selector`; `attr` defaults to `text`. Without a browser context (sequential/custom/message flows) it fails with a clear error — pair it with an orchestrator or `runner="pw"`.
|
|
295
|
+
|
|
296
|
+
```xml
|
|
297
|
+
<extract selector=".chat-history .bubble:last-child"/>
|
|
298
|
+
<assertions><assert that="llm" prompt="the reply mentions Berlin" judge="ollama/qwen2.5:14b"/></assertions>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
### Flakiness: `<repeat>`
|
|
302
|
+
|
|
303
|
+
`<repeat num="N" success="R">` wraps any steps: the children run N times and the block passes when ≥R of the iterations pass — a rate (`"0.8"`) or percent (`"80%"`, `"80"`); `success` defaults to 1. An iteration fails on a failed inner assertion or a step error; failed iterations do not stop the block, and assertions inside a repeat see only that iteration's output. The loop exits early once the threshold is unreachable. Works in every engine (axn orchestrator, sequential, custom-adapter and message flows, and the `pw` runner); nested repeats are allowed. In message-adapter flows children must be `<usermessage>`/`<assertions>` only. The block reports as a `repeat` assertion with `repeat: {runs, succeeded, needed, failures[]}` detail in the JSON report.
|
|
304
|
+
|
|
305
|
+
```xml
|
|
306
|
+
<repeat num="10" success="0.8">
|
|
307
|
+
<usermessage>What time is it?</usermessage>
|
|
308
|
+
<assertions>
|
|
309
|
+
<assert that="llm" prompt="states a concrete time" judge="ollama/llama3.1"/>
|
|
310
|
+
</assertions>
|
|
311
|
+
</repeat>
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
### Metrics: collected and emitted
|
|
315
|
+
|
|
316
|
+
Two ways land measurements in the report's `flows[].metrics[]`:
|
|
317
|
+
|
|
318
|
+
- **`<metric id="n" collect="duration,...">` / `<stopwatch id="n">`** — engine-side bracket collectors (`duration` built in; plugins add more via `axn-dev.flowMetrics`). Pure measurement, no verdict.
|
|
319
|
+
- **Emitted** — a step reports its own measurements: any output line `AXN_METRIC {"name":"x","value":1,"unit":"ms","samples":[...],"better":"lower"}` is parsed out of the output (asserts never see it) and recorded. Plugin adapters use `ctx.emitMetric({name, value, ...})` instead. Everything emitted is recorded; bound it with `<assert that="metric" name="x" max="…"/>`.
|
|
320
|
+
|
|
321
|
+
Reports are the metrics store: `--label <name>` tags a run (`report.label` + `flow-report-<label>-<ts>.json`), then:
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
axn-dev flow compare -f flows/perf.xml before after # latest report per label, per-metric deltas + improved/regressed
|
|
325
|
+
axn-dev flow history -f flows/perf.xml --metric app.prompt_ms # every recorded value over time
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### Locating flows/scenarios (`paths:`)
|
|
329
|
+
|
|
330
|
+
By default flows live in `<root>/flows/` and scenarios in `<root>/scenarios/`. Override per repo or globally — precedence: **env > repo `.axn-dev/config.yaml` > `~/.axn-dev/config.yaml`**:
|
|
331
|
+
|
|
332
|
+
```yaml
|
|
333
|
+
paths:
|
|
334
|
+
flows: qa/flows # or [qa/flows, e2e/flows]
|
|
335
|
+
scenarios: qa/scenarios # relative to each scanned root…
|
|
336
|
+
# …or absolute paths, scanned as standalone locations
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
AXN_FLOW_DIRS=qa/flows,e2e/flows AXN_SCENARIO_DIRS=/data/scenarios axn-dev list
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
## Core commands
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
# Run a flow file
|
|
347
|
+
axn-dev flow -f flows/example.xml
|
|
348
|
+
|
|
349
|
+
# Run only one model from the configured list
|
|
350
|
+
axn-dev flow -f flows/example.xml -m llama3.1:latest
|
|
351
|
+
|
|
352
|
+
# Run only flows whose name matches a string
|
|
353
|
+
axn-dev flow -f flows/example.xml -t "how late"
|
|
354
|
+
|
|
355
|
+
# Keep the scenario running after the test
|
|
356
|
+
axn-dev flow -f flows/example.xml --no-stop
|
|
357
|
+
|
|
358
|
+
# Wipe scenario data and start fresh (non-interactive)
|
|
359
|
+
axn-dev flow -f flows/app-dev-e2e.xml --clean-start --yes
|
|
360
|
+
|
|
361
|
+
# Keep the scenario running after a clean start
|
|
362
|
+
axn-dev flow -f flows/app-dev-e2e.xml --clean-start --yes --no-stop
|
|
363
|
+
|
|
364
|
+
# Run a tsAdapter flow against a deployed device
|
|
365
|
+
axn-dev flow -f flows/device-check.xml -i my-device
|
|
366
|
+
|
|
367
|
+
# Run against any already-running deployment — no scenario is started
|
|
368
|
+
axn-dev flow -f flows/e2e.xml --base-url https://staging.example.com
|
|
369
|
+
|
|
370
|
+
# CI: quiet output + JUnit report artifact (exit code gates the pipeline)
|
|
371
|
+
axn-dev flow -f flows/e2e.xml --quiet --report junit.xml --report-format junit
|
|
372
|
+
|
|
373
|
+
# List registered adapters and their claimed tags
|
|
374
|
+
axn-dev flow list-adapters
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
## How it works
|
|
378
|
+
|
|
379
|
+
1. `axn-dev flow` reads the flow file (`.xml` or `.feature`).
|
|
380
|
+
2. It starts the requested scenario if it is not already running (for adapters that declare `wantsScenario`, and without `-i`).
|
|
381
|
+
3. Waits for the scenario's readiness probe (or the service's published port).
|
|
382
|
+
4. For each flow and each configured model, it dispatches steps to the selected adapter, or runs `<step>`/`<script>` scripts (through an `orchestrator` if configured).
|
|
383
|
+
5. It evaluates all `<assert>` elements against the response/stdout.
|
|
384
|
+
6. It writes a JSON report to `flows/.reports/` next to the flow file.
|
|
385
|
+
7. It stops the started scenario and any scenario-scoped orchestrators unless `--no-stop` is used.
|
|
386
|
+
|
|
387
|
+
## Report output
|
|
388
|
+
|
|
389
|
+
Reports are written to `flows/.reports/flow-report-<timestamp>.json` next to the flow file:
|
|
390
|
+
|
|
391
|
+
```json
|
|
392
|
+
{
|
|
393
|
+
"timestamp": "2026-08-18T07-54-13-540Z",
|
|
394
|
+
"flows": [
|
|
395
|
+
{
|
|
396
|
+
"flow": "example - how late is it",
|
|
397
|
+
"model": { "provider": "ollama", "name": "llama3.1:latest" },
|
|
398
|
+
"passed": true,
|
|
399
|
+
"assertions": [
|
|
400
|
+
{ "that": "num_responses", "value": "1", "passed": true, "actual": "1" },
|
|
401
|
+
{ "that": "contains", "value": "time", "passed": true }
|
|
402
|
+
],
|
|
403
|
+
"durationMs": 11999,
|
|
404
|
+
"evidence": [
|
|
405
|
+
{ "kind": "picture", "name": "after-login", "path": ".../flow-reports/evidence/example-2026-08-18T07-54-13-540Z/000-after-login.png" },
|
|
406
|
+
{ "kind": "video", "name": "booking", "path": ".../flow-reports/evidence/example-2026-08-18T07-54-13-540Z/booking.webm" }
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
]
|
|
410
|
+
}
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
## Common tasks (cookbook)
|
|
414
|
+
|
|
415
|
+
**"Run all flows in the example file":**
|
|
416
|
+
```bash
|
|
417
|
+
axn-dev flow -f flows/example.xml
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
**"Run only the Ollama model":**
|
|
421
|
+
```bash
|
|
422
|
+
axn-dev flow -f flows/example.xml -m llama3.1:latest
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**"Run a flow without stopping the scenario afterwards":**
|
|
426
|
+
```bash
|
|
427
|
+
axn-dev flow -f flows/example.xml --no-stop
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
**"Run a Playwright check against a real device":**
|
|
431
|
+
```bash
|
|
432
|
+
axn-dev flow -f flows/device.xml -i my-device
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**"Run a flow against a Kubernetes/staging deployment (no local scenario)":**
|
|
436
|
+
```bash
|
|
437
|
+
axn-dev flow -f flows/e2e.xml --base-url https://staging.example.com
|
|
438
|
+
# or pin it in XML: <scenario name="staging" adapter="tsAdapter" url="https://staging.example.com"/>
|
|
439
|
+
```
|
|
440
|
+
`--base-url` overrides `url=` and applies to all scenarios in the run; env gets `BASE_URL` (+`SCENARIO_PORT` when the URL has an explicit port). Declared `<readiness>` probes address the base URL. Not combinable with `-i`, `--clean-start`, `--port`, `--auto-port`.
|
|
441
|
+
|
|
442
|
+
**"Run a flow while inspecting the report":**
|
|
443
|
+
```bash
|
|
444
|
+
axn-dev flow -f flows/example.xml
|
|
445
|
+
ls flows/.reports/
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
## Gotchas
|
|
449
|
+
|
|
450
|
+
- `-i/--infra` is currently only supported with `tsAdapter` flows.
|
|
451
|
+
- `tsAdapter` requires `tsx` to be installed.
|
|
452
|
+
- Multiple `<step>`/`<script>` elements require an `orchestrator` on the `<flow>` or `<scenario>`; orchestrators are long-lived processes that are reused across flows for the same scenario.
|
|
453
|
+
- `<picture>`/`<video>` evidence requires an orchestrator-driven tsAdapter flow; `<video>` additionally needs the orchestrator's `videoStart`/`videoStop` hooks.
|
|
454
|
+
- The `flows/.reports/` directory is created automatically (with a `.gitignore`), but individual JSON reports and evidence files should not be committed.
|
|
455
|
+
- A non-zero exit code from a tsAdapter script is reported via the `exitCode` assertion and fails the flow.
|
|
456
|
+
|
|
457
|
+
## Source files
|
|
458
|
+
|
|
459
|
+
- `packages/cmd-flow/src/flow.ts` — main `flow` command implementation
|
|
460
|
+
- `packages/cmd-flow/src/adapters/http.ts` — bundled generic HTTP adapter
|
|
461
|
+
- `packages/flow-format/src/flow-util.ts` — XML parser and flow types
|
|
462
|
+
- `packages/flow-format/src/flow-gherkin.ts` — .feature parser (grammar spec in the header comment)
|
|
463
|
+
- `packages/core/src/flow-adapter.ts` — adapter registry (lazy load, tag routing, `extends`)
|
|
464
|
+
- `<integration-repo>/flows/*.xml` — flow files
|
package/README.md
DELETED