explorbot 0.2.3 → 0.2.5

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 (174) hide show
  1. package/README.md +1 -1
  2. package/bin/explorbot-cli.ts +26 -8
  3. package/boat/api-tester/src/cli.ts +17 -0
  4. package/boat/api-tester/src/config.ts +4 -2
  5. package/boat/doc-collector/bin/doc-collector-cli.ts +2 -0
  6. package/boat/doc-collector/src/ai/documentarian.ts +61 -31
  7. package/boat/doc-collector/src/cli.ts +14 -1
  8. package/boat/doc-collector/src/config.ts +4 -2
  9. package/boat/prima/bin/prima-cli.ts +0 -0
  10. package/boat/prima/src/activity-line.ts +33 -0
  11. package/boat/prima/src/cli.ts +127 -86
  12. package/boat/prima/src/envelope.ts +102 -52
  13. package/boat/prima/src/prima.ts +567 -128
  14. package/boat/prima/src/pw-parser.ts +11 -1
  15. package/boat/prima/src/pw-registry.ts +4 -5
  16. package/boat/prima/src/session-log.ts +126 -0
  17. package/dist/bin/explorbot-cli.js +26 -8
  18. package/dist/boat/api-tester/bin/apibot-cli.js +2 -0
  19. package/dist/boat/api-tester/src/cli.js +17 -0
  20. package/dist/boat/api-tester/src/config.js +4 -2
  21. package/dist/boat/doc-collector/bin/doc-collector-cli.js +2 -0
  22. package/dist/boat/doc-collector/src/ai/documentarian.js +44 -19
  23. package/dist/boat/doc-collector/src/cli.js +14 -1
  24. package/dist/boat/doc-collector/src/config.js +4 -2
  25. package/dist/boat/prima/src/activity-line.js +30 -0
  26. package/dist/boat/prima/src/cli.js +109 -77
  27. package/dist/boat/prima/src/envelope.js +94 -44
  28. package/dist/boat/prima/src/prima.js +533 -119
  29. package/dist/boat/prima/src/pw-parser.js +13 -1
  30. package/dist/boat/prima/src/pw-registry.js +4 -5
  31. package/dist/boat/prima/src/session-log.js +108 -0
  32. package/dist/package.json +3 -2
  33. package/dist/rules/navigator/verification-actions.md +20 -0
  34. package/dist/src/action-result.d.ts +7 -0
  35. package/dist/src/action-result.js +4 -0
  36. package/dist/src/action.d.ts +2 -0
  37. package/dist/src/action.js +41 -2
  38. package/dist/src/ai/captain/web-mode.js +6 -3
  39. package/dist/src/ai/captain.js +2 -0
  40. package/dist/src/ai/navigator.d.ts +34 -0
  41. package/dist/src/ai/navigator.js +237 -181
  42. package/dist/src/ai/pilot.d.ts +7 -0
  43. package/dist/src/ai/pilot.js +90 -2
  44. package/dist/src/ai/provider.d.ts +2 -2
  45. package/dist/src/ai/provider.js +14 -23
  46. package/dist/src/ai/rerunner.js +2 -1
  47. package/dist/src/ai/researcher/cache.d.ts +2 -0
  48. package/dist/src/ai/researcher/cache.js +10 -2
  49. package/dist/src/ai/researcher.js +3 -2
  50. package/dist/src/ai/rules.js +17 -10
  51. package/dist/src/ai/session-analyst.js +2 -0
  52. package/dist/src/ai/task-agent.js +4 -1
  53. package/dist/src/ai/tester.d.ts +6 -3
  54. package/dist/src/ai/tester.js +50 -46
  55. package/dist/src/ai/tools.d.ts +14 -0
  56. package/dist/src/ai/tools.js +117 -37
  57. package/dist/src/commands/config-command.d.ts +51 -0
  58. package/dist/src/commands/config-command.js +117 -0
  59. package/dist/src/commands/index.js +2 -0
  60. package/dist/src/config.d.ts +9 -1
  61. package/dist/src/config.js +53 -4
  62. package/dist/src/execution-controller.d.ts +2 -0
  63. package/dist/src/execution-controller.js +6 -0
  64. package/dist/src/explorbot.d.ts +2 -1
  65. package/dist/src/explorbot.js +7 -2
  66. package/dist/src/explorer.js +2 -3
  67. package/dist/src/playwright-recorder.js +30 -0
  68. package/dist/src/remote.d.ts +55 -0
  69. package/dist/src/remote.js +235 -0
  70. package/dist/src/reporter.d.ts +1 -0
  71. package/dist/src/reporter.js +7 -1
  72. package/dist/src/state-manager.d.ts +2 -1
  73. package/dist/src/state-manager.js +3 -1
  74. package/dist/src/stats.d.ts +1 -0
  75. package/dist/src/stats.js +1 -0
  76. package/dist/src/test-plan.d.ts +3 -0
  77. package/dist/src/test-plan.js +26 -0
  78. package/dist/src/utils/aria.d.ts +2 -8
  79. package/dist/src/utils/aria.js +69 -40
  80. package/dist/src/utils/html.js +1 -0
  81. package/dist/src/utils/logger.d.ts +7 -1
  82. package/dist/src/utils/logger.js +32 -0
  83. package/dist/src/utils/page-readiness.js +18 -1
  84. package/dist/src/utils/url-matcher.js +3 -0
  85. package/dist/src/utils/web-element.d.ts +2 -0
  86. package/dist/src/utils/web-element.js +8 -0
  87. package/dist/src/utils/web-sandbox.d.ts +1 -1
  88. package/dist/src/utils/web-sandbox.js +2 -3
  89. package/docs/api-testing/basics.md +90 -0
  90. package/docs/api-testing/planning.md +57 -0
  91. package/docs/api-testing/running-tests.md +55 -0
  92. package/docs/assets/cloud-report.png +0 -0
  93. package/docs/assets/html-report.png +0 -0
  94. package/docs/assets/langfuse-trace.png +0 -0
  95. package/docs/assets/successful-explore-run.png +0 -0
  96. package/docs/basics/getting-started.md +140 -0
  97. package/docs/basics/prerequisites.md +63 -0
  98. package/docs/basics/providers.md +362 -0
  99. package/docs/basics/running.md +78 -0
  100. package/docs/contributing/ai-integration-tests.md +57 -0
  101. package/docs/contributing/contributing.md +90 -0
  102. package/docs/contributing/demo-videos.md +36 -0
  103. package/docs/contributing/npm-package.md +138 -0
  104. package/docs/contributing/observability.md +227 -0
  105. package/docs/contributing/regression-tests.md +103 -0
  106. package/docs/contributing/testing.md +95 -0
  107. package/docs/doc-collection/basics.md +128 -0
  108. package/docs/doc-collection/crawling.md +67 -0
  109. package/docs/doc-collection/interactive-mode.md +99 -0
  110. package/docs/index.json +87 -0
  111. package/docs/reference/commands.md +997 -0
  112. package/docs/reference/configuration.md +569 -0
  113. package/docs/reference/scripting.md +303 -0
  114. package/docs/reference/websocket.md +50 -0
  115. package/docs/superpowers/plans/2026-08-01-actor-boat.md +925 -0
  116. package/docs/superpowers/plans/2026-08-01-prima-boat.md +1120 -0
  117. package/docs/superpowers/reviews/2026-08-06-prima-vs-playwright-cli.md +268 -0
  118. package/docs/superpowers/specs/2026-08-01-actor-boat-design.md +204 -0
  119. package/docs/superpowers/specs/2026-08-01-prima-boat-design.md +242 -0
  120. package/docs/superpowers/specs/2026-08-03-global-config-design.md +138 -0
  121. package/docs/superpowers/specs/2026-08-07-prima-fixes-design.md +394 -0
  122. package/docs/superpowers/specs/2026-08-18-prima-false-verdicts.md +159 -0
  123. package/docs/web-testing/agents.md +158 -0
  124. package/docs/web-testing/automated-tests.md +134 -0
  125. package/docs/web-testing/basics.md +91 -0
  126. package/docs/web-testing/customization.md +131 -0
  127. package/docs/web-testing/hooks.md +238 -0
  128. package/docs/web-testing/page-interaction.md +84 -0
  129. package/docs/web-testing/planner.md +122 -0
  130. package/docs/web-testing/rerun.md +164 -0
  131. package/docs/web-testing/researcher.md +380 -0
  132. package/docs/workflow/agentic-usage.md +233 -0
  133. package/docs/workflow/application-spec.md +73 -0
  134. package/docs/workflow/ci.md +202 -0
  135. package/docs/workflow/knowledge.md +310 -0
  136. package/docs/workflow/planning-styles.md +67 -0
  137. package/docs/workflow/reporting.md +133 -0
  138. package/docs/workflow/test-plans.md +90 -0
  139. package/package.json +3 -2
  140. package/rules/navigator/verification-actions.md +20 -0
  141. package/src/action-result.ts +11 -0
  142. package/src/action.ts +43 -3
  143. package/src/ai/captain/web-mode.ts +6 -3
  144. package/src/ai/captain.ts +3 -0
  145. package/src/ai/navigator.ts +255 -186
  146. package/src/ai/pilot.ts +104 -2
  147. package/src/ai/provider.ts +14 -24
  148. package/src/ai/rerunner.ts +2 -1
  149. package/src/ai/researcher/cache.ts +12 -2
  150. package/src/ai/researcher.ts +3 -2
  151. package/src/ai/rules.ts +17 -10
  152. package/src/ai/session-analyst.ts +2 -0
  153. package/src/ai/task-agent.ts +3 -1
  154. package/src/ai/tester.ts +52 -45
  155. package/src/ai/tools.ts +136 -37
  156. package/src/commands/config-command.ts +146 -0
  157. package/src/commands/index.ts +2 -0
  158. package/src/config.ts +60 -5
  159. package/src/execution-controller.ts +8 -0
  160. package/src/explorbot.ts +7 -3
  161. package/src/explorer.ts +2 -2
  162. package/src/playwright-recorder.ts +23 -0
  163. package/src/remote.ts +244 -0
  164. package/src/reporter.ts +7 -1
  165. package/src/state-manager.ts +6 -2
  166. package/src/stats.ts +1 -0
  167. package/src/test-plan.ts +29 -0
  168. package/src/utils/aria.ts +65 -45
  169. package/src/utils/html.ts +1 -0
  170. package/src/utils/logger.ts +33 -2
  171. package/src/utils/page-readiness.ts +24 -1
  172. package/src/utils/url-matcher.ts +3 -0
  173. package/src/utils/web-element.ts +9 -0
  174. package/src/utils/web-sandbox.ts +3 -4
@@ -0,0 +1,238 @@
1
+ # Agent Hooks
2
+
3
+ Hooks run custom code before or after a specific agent. Use them to prepare and clean up the page per agent.
4
+
5
+ > [!NOTE]
6
+ > For simple page automation such as waiting or clicking cookie banners, use [Knowledge Files](../workflow/knowledge.md) with the `wait`, `waitForElement`, or `code` fields. Reach for hooks when you need different behavior for different agents.
7
+
8
+ ## When to Use Hooks vs Knowledge
9
+
10
+ | Use Case | Solution |
11
+ |----------|----------|
12
+ | Wait for element on all page visits | Knowledge: `waitForElement` |
13
+ | Dismiss cookie banner on page load | Knowledge: `code` |
14
+ | Wait for network idle only during research | Hook: `researcher.beforeHook` |
15
+ | Clean up test data after each test | Hook: `tester.afterHook` |
16
+ | Different waits for navigation vs testing | Hooks for each agent |
17
+
18
+ ## Configuration
19
+
20
+ Hooks are configured per-agent in `explorbot.config.js`:
21
+
22
+ ```javascript
23
+ export default {
24
+ ai: {
25
+ model: myProvider('gpt-4o'),
26
+ agents: {
27
+ navigator: {
28
+ beforeHook: {
29
+ type: 'playwright',
30
+ hook: async ({ page, url }) => {
31
+ await page.waitForLoadState('networkidle');
32
+ }
33
+ }
34
+ },
35
+ tester: {
36
+ afterHook: {
37
+ type: 'codeceptjs',
38
+ hook: async ({ I, url }) => {
39
+ await I.executeScript(() => localStorage.clear());
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## Hook Types
49
+
50
+ ### Playwright Hooks
51
+
52
+ Get direct access to the Playwright page object:
53
+
54
+ ```javascript
55
+ beforeHook: {
56
+ type: 'playwright',
57
+ hook: async ({ page, url }) => {
58
+ await page.waitForLoadState('networkidle');
59
+ await page.locator('.loading').waitFor({ state: 'hidden' });
60
+ }
61
+ }
62
+ ```
63
+
64
+ ### CodeceptJS Hooks
65
+
66
+ Use the CodeceptJS `I` actor:
67
+
68
+ ```javascript
69
+ beforeHook: {
70
+ type: 'codeceptjs',
71
+ hook: async ({ I, url }) => {
72
+ await I.waitForElement('.page-ready');
73
+ await I.wait(1);
74
+ }
75
+ }
76
+ ```
77
+
78
+ ## URL Pattern Matching
79
+
80
+ Run different hooks for different URL patterns:
81
+
82
+ ```javascript
83
+ researcher: {
84
+ beforeHook: {
85
+ '/login': {
86
+ type: 'codeceptjs',
87
+ hook: async ({ I }) => await I.waitForElement('#login-form')
88
+ },
89
+ '/admin/*': {
90
+ type: 'playwright',
91
+ hook: async ({ page }) => await page.waitForLoadState('networkidle')
92
+ },
93
+ '/api/*': {
94
+ type: 'codeceptjs',
95
+ hook: async ({ I }) => await I.wait(2)
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ ### Pattern Syntax
102
+
103
+ | Pattern | Matches |
104
+ |---------|---------|
105
+ | `/login` | Exact path `/login` |
106
+ | `/admin/*` | `/admin` and any path starting with `/admin/` |
107
+ | `*` | All URLs (fallback) |
108
+ | `^/users/\d+$` | Regex: `/users/` followed by digits |
109
+ | `**/*.html` | Glob: any `.html` file |
110
+
111
+ ## Supported Agents
112
+
113
+ | Agent | beforeHook | afterHook | Description |
114
+ |-------|------------|-----------|-------------|
115
+ | `navigator` | After navigation | After page capture | Browser navigation |
116
+ | `researcher` | After navigation | After research complete | Page analysis |
117
+ | `tester` | Before test loop | After test loop | Test execution |
118
+ | `driller` | Before drilling starts | After drilling completes | Component drilling |
119
+ | `captain` | Before handling command | After command complete | User commands |
120
+
121
+ > [!WARNING]
122
+ > The `planner` agent does not support hooks as it doesn't interact with the browser.
123
+
124
+ ## Examples
125
+
126
+ ### Wait for SPA to Load
127
+
128
+ ```javascript
129
+ navigator: {
130
+ beforeHook: {
131
+ type: 'playwright',
132
+ hook: async ({ page }) => {
133
+ await page.waitForFunction(() => {
134
+ return window.__APP_READY__ === true;
135
+ });
136
+ }
137
+ }
138
+ }
139
+ ```
140
+
141
+ ### Dismiss Modals Before Research
142
+
143
+ ```javascript
144
+ researcher: {
145
+ beforeHook: {
146
+ type: 'codeceptjs',
147
+ hook: async ({ I }) => {
148
+ const modalVisible = await I.grabNumberOfVisibleElements('.modal-overlay');
149
+ if (modalVisible > 0) {
150
+ await I.click('.modal-close');
151
+ await I.wait(0.5);
152
+ }
153
+ }
154
+ }
155
+ }
156
+ ```
157
+
158
+ ### Clean Up After Tests
159
+
160
+ ```javascript
161
+ tester: {
162
+ afterHook: {
163
+ type: 'playwright',
164
+ hook: async ({ page }) => {
165
+ await page.evaluate(() => {
166
+ localStorage.clear();
167
+ sessionStorage.clear();
168
+ });
169
+ }
170
+ }
171
+ }
172
+ ```
173
+
174
+ ### Different Behavior per URL
175
+
176
+ ```javascript
177
+ tester: {
178
+ beforeHook: {
179
+ '/checkout': {
180
+ type: 'codeceptjs',
181
+ hook: async ({ I }) => {
182
+ // Ensure cart has items before checkout tests
183
+ await I.executeScript(() => {
184
+ if (!localStorage.getItem('cart')) {
185
+ localStorage.setItem('cart', JSON.stringify([{ id: 1, qty: 1 }]));
186
+ }
187
+ });
188
+ }
189
+ },
190
+ '/admin/*': {
191
+ type: 'codeceptjs',
192
+ hook: async ({ I }) => {
193
+ // Ensure admin session
194
+ await I.waitForElement('.admin-header', 5);
195
+ }
196
+ }
197
+ }
198
+ }
199
+ ```
200
+
201
+ ## Error Handling
202
+
203
+ A hook error is logged but does not stop the agent:
204
+
205
+ ```javascript
206
+ beforeHook: {
207
+ type: 'codeceptjs',
208
+ hook: async ({ I }) => {
209
+ try {
210
+ await I.waitForElement('.optional-banner', 2);
211
+ await I.click('.dismiss');
212
+ } catch {
213
+ // Banner not present, continue
214
+ }
215
+ }
216
+ }
217
+ ```
218
+
219
+ ## Execution Flow
220
+
221
+ ```
222
+ ┌─────────────────────────────────────────────────────────┐
223
+ │ Agent Execution │
224
+ ├─────────────────────────────────────────────────────────┤
225
+ │ 1. Agent starts │
226
+ │ 2. Navigate to URL (if applicable) │
227
+ │ 3. ▶ beforeHook executes │
228
+ │ 4. Agent performs main work │
229
+ │ 5. ▶ afterHook executes │
230
+ │ 6. Agent completes │
231
+ └─────────────────────────────────────────────────────────┘
232
+ ```
233
+
234
+ ## See Also
235
+
236
+ - [Knowledge Files](../workflow/knowledge.md) — page-level automation with `wait`, `waitForElement`, `code`
237
+ - [Configuration](../reference/configuration.md) — full configuration reference
238
+ - [Agents](./agents.md) — agent descriptions and workflows
@@ -0,0 +1,84 @@
1
+ # Page Interaction
2
+
3
+ This page explains how Explorbot agents read a web page and act on it — and the two things you can change to help them: filtering noisy HTML and marking custom components.
4
+
5
+ ## How agents see a page
6
+
7
+ Agents read each page three ways at once:
8
+
9
+ | Source | What it gives | Used for |
10
+ |--------|---------------|----------|
11
+ | **ARIA snapshot** | Roles, labels, states, hierarchy | Understanding structure, building locators |
12
+ | **HTML** | Classes, IDs, data attributes, form fields | Precise locators, reading field values |
13
+ | **Screenshot** | Layout, colors, icons, coordinates | Visual checks, click fallbacks |
14
+
15
+ The accessibility tree is the primary source. HTML adds detail. The screenshot is a fallback when the first two aren't enough.
16
+
17
+ ## Filter noisy HTML
18
+
19
+ Agents work from the `combined` HTML snapshot. Cookie banners, chat widgets, ads, and analytics tags add noise and burn tokens. Exclude them in your config:
20
+
21
+ ```javascript
22
+ // explorbot.config.js
23
+ html: {
24
+ combined: {
25
+ include: ['*'],
26
+ exclude: ['script', 'style', 'svg', '.cookie-banner', '.analytics-tracker'],
27
+ },
28
+ }
29
+ ```
30
+
31
+ Three snapshots exist, each configurable:
32
+
33
+ | Snapshot | Purpose | Config key |
34
+ |----------|---------|------------|
35
+ | `combined` | Main HTML for agents | `html.combined` |
36
+ | `minimal` | Interactive elements only | `html.minimal` |
37
+ | `text` | Text content only | `html.text` |
38
+
39
+ ## Mark custom components
40
+
41
+ Some components are interactive but have no ARIA role or semantic HTML, so agents miss them. Mark them with a `data-explorbot-*` attribute:
42
+
43
+ ```html
44
+ <div data-explorbot-role="button" data-explorbot-label="Save Draft">
45
+ <svg>...</svg>
46
+ Save
47
+ </div>
48
+ ```
49
+
50
+ A marked element is always kept in snapshots, treated as interactive, and shown to agents. During processing, `data-explorbot-role="button"` becomes `role="button"`, so you add a hint without changing how your component behaves.
51
+
52
+ Use this when standard locators fail to find an element, or when a custom control isn't detected as interactive.
53
+
54
+ ## Locator priority
55
+
56
+ When an agent picks a locator, it prefers the most stable option first:
57
+
58
+ ```mermaid
59
+ flowchart LR
60
+ A[ARIA, semantic text, and role] --> B[Scope with a container]
61
+ B --> C[HTML attributes, CSS, or XPath]
62
+ C --> D[Screenshot and visual coordinates]
63
+ ```
64
+
65
+ The agent starts with short semantic locators from ARIA or visible text. When a match is ambiguous, it scopes that locator to a container before moving to HTML-based selectors and, finally, visual coordinates.
66
+
67
+ 1. Short ARIA or text — `I.click({ role: 'button', text: 'Save' })` or `I.click('Save')` when it is unique
68
+ 2. Text with a container — `I.click('Save', '.modal')` — simplest and preferred when a container is known
69
+ 3. ARIA with a container — `I.click({ role: 'button', text: 'Save' }, '.modal')` — for semantic disambiguation
70
+ 4. CSS or XPath — `I.click('#save-btn')`
71
+ 5. Coordinates — `I.clickXY(400, 300)` (last resort)
72
+
73
+ When a locator fails, the agent tries the next strategy, then a visual click. Locators that worked are saved to experience and preferred on the next run.
74
+
75
+ ## What happens after each action
76
+
77
+ After every action, Explorbot captures the new page state and compares it with the previous one. The resulting diff tells the agent what changed — the URL, the accessibility tree, or the HTML — so it can confirm the action worked and decide what to do next. The Researcher turns a page into a structured UI map of sections and elements; see [Researcher](./researcher.md).
78
+
79
+ ## See also
80
+
81
+ - [Knowledge files](../workflow/knowledge.md) — teach Explorbot about your app
82
+ - [Agent hooks](./hooks.md) — run code before or after an agent
83
+ - [Configuration](../reference/configuration.md) — full configuration reference
84
+ - [Researcher](./researcher.md) — how pages become UI maps
@@ -0,0 +1,122 @@
1
+ # Planner Agent
2
+
3
+ The Planner agent turns Researcher findings into test scenarios. Each scenario has steps, expected outcomes, and a priority, ready for the Tester to run.
4
+
5
+ ## Overview
6
+
7
+ When you run `/plan` or `/explore`, the Planner:
8
+
9
+ 1. Receives the Researcher's UI map of the current page.
10
+ 2. Applies a planning style.
11
+ 3. Generates 3 to 12 scenarios with steps and expected outcomes.
12
+ 4. Assigns priorities based on business importance.
13
+
14
+ Run it again and the Planner adds new scenarios in a different style. It skips scenarios that already exist.
15
+
16
+ ## Write a useful focus
17
+
18
+ Focus works best when it names one feature boundary, the user goal, and the behavior that matters. Treat it as a testing brief, not a keyword.
19
+
20
+ ```bash
21
+ npx explorbot plan /checkout --focus "Guest checkout: complete an order with card payment; cover validation, declined payment, retry, and confirmation without testing account registration"
22
+ ```
23
+
24
+ The same focus works in the TUI:
25
+
26
+ ```
27
+ /plan --focus "Guest checkout: complete an order with card payment; cover validation, declined payment, retry, and confirmation without testing account registration"
28
+ ```
29
+
30
+ `checkout` alone leaves the scope ambiguous. The fuller focus tells Planner where the flow starts and ends, which outcomes deserve scenarios, and what to leave out. Keep the focus observable from the current page; put durable product facts or credentials in [Knowledge](../workflow/knowledge.md), not in the focus.
31
+
32
+ ## Configuration
33
+
34
+ ```javascript
35
+ ai: {
36
+ agents: {
37
+ planner: {
38
+ model: groq('gpt-oss-20b'),
39
+ styles: ['normal', 'curious', 'psycho'],
40
+ rules: [
41
+ { '/checkout/*': 'payment-focus' },
42
+ ],
43
+ },
44
+ },
45
+ }
46
+ ```
47
+
48
+ ### Options Reference
49
+
50
+ | Option | Type | Default | Description |
51
+ |--------|------|---------|-------------|
52
+ | `model` | `LanguageModel` | default model | Override model for Planner |
53
+ | `styles` | `string[]` | `['normal', 'curious', 'psycho']` | Style names and cycling order |
54
+ | `rules` | `RuleEntry[]` | `[]` | URL-aware rule files from `rules/planner/` |
55
+ | `systemPrompt` | `string` | - | Inline instructions appended to the prompt |
56
+
57
+ ## Planning Styles
58
+
59
+ A style is a testing approach that shapes which tests the Planner creates. Styles cycle on each planning iteration, so repeated runs produce different kinds of tests. See [Planning Styles](../workflow/planning-styles.md) for how cycling works, custom style files, and `extract-rules`.
60
+
61
+ ### Built-in Styles
62
+
63
+ All three built-in styles rank scenarios by outcome strength, from strongest to weakest:
64
+
65
+ 1. **Data change** — a record is created, edited, deleted; a setting is persisted; a message is sent; a job is triggered.
66
+ 2. **State change** — a route change, a filter or sort applied to real data, a mode or auth change the app remembers.
67
+ 3. **UI-only change** — something opens, closes, is cancelled, is hovered, or is toggled for display. The application registers nothing new.
68
+
69
+ The Planner prefers scenarios that end in category 1 or 2. It proposes category 3 only when the UI-only behaviour has a verifiable side effect, such as a warning prompt, a persisted draft, or a badge appearing.
70
+
71
+ | Style | Focus | What it generates |
72
+ |-------|-------|-------------------|
73
+ | **normal** | Complete user workflows | CRUD operations, full commit flows, filter+verify flows, distributed across feature areas. UI-only tests (tab switching, pagination, view toggles) come last. |
74
+ | **curious** | Coverage gaps | Cross-references previous test results with page research to find untested controls. Variation scenarios and dismissal scenarios are kept separate — the planner will not merge them by appending a cancel at the end. |
75
+ | **psycho** | Invalid and extreme inputs | Attacks **every reachable control in the same scenario** with a different strange value — empty, 10000 chars, unicode, SQL, script tags, invalid formats, conflicting toggles, out-of-range dates — then commits. Scenarios that enter bad data and cancel are rejected: the application never received the payload. |
76
+
77
+ ### Style Cycling
78
+
79
+ The default cycle is: normal, curious, psycho, then back to normal. The 1st `/plan` uses normal, the 2nd curious, the 3rd psycho. Each iteration proposes only scenarios that aren't already in the plan. When all feature areas are covered, the Planner returns an empty list.
80
+
81
+ Force a specific style:
82
+
83
+ ```
84
+ /plan --style psycho
85
+ ```
86
+
87
+ Set `styles` in the config to control the rotation. To customize or add style files, see [Planning Styles](../workflow/planning-styles.md).
88
+
89
+ ## Page-Specific Rules
90
+
91
+ Use [rules](../reference/configuration.md#rules) to give the Planner extra instructions for specific pages:
92
+
93
+ ```javascript
94
+ planner: {
95
+ rules: [
96
+ 'no-delete-tests', // rules/planner/no-delete-tests.md — all pages
97
+ { '/checkout/*': 'payment-rules' }, // rules/planner/payment-rules.md — checkout only
98
+ { '/admin/*': 'admin-scenarios' }, // rules/planner/admin-scenarios.md — admin pages
99
+ ],
100
+ }
101
+ ```
102
+
103
+ Rules are additive. The Planner concatenates all matching rules and appends them to its prompt alongside the active style.
104
+
105
+ ## Test Priorities
106
+
107
+ The Planner assigns priorities by business importance:
108
+
109
+ | Priority | Meaning | Examples |
110
+ |----------|---------|---------|
111
+ | **critical** | Core business functionality | Login, checkout, primary CRUD |
112
+ | **important** | Key user flows | Profile edit, search, main filters |
113
+ | **high** | Secondary features | Edge cases for critical flows |
114
+ | **normal** | Supporting actions | Settings, configuration |
115
+ | **low** | Minor interactions | Cosmetic checks, boundary tests |
116
+
117
+ ## See Also
118
+
119
+ - [Planning Styles](../workflow/planning-styles.md) — cycling, custom styles, `extract-rules`
120
+ - [Configuration: Rules](../reference/configuration.md#rules) — URL-aware rule files
121
+ - [Agents](./agents.md) — all agent descriptions
122
+ - [Commands](../reference/commands.md) — CLI and TUI commands
@@ -0,0 +1,164 @@
1
+ # Rerunning Tests
2
+
3
+ Explorbot generates CodeceptJS test files in `output/tests/` after an exploration session. Use the `runs` and `rerun` commands to list, inspect, and re-execute these tests with AI healing.
4
+
5
+ ## Workflow
6
+
7
+ ```
8
+ npx explorbot explore /dashboard # generates output/tests/dashboard.js
9
+ npx explorbot runs # list all generated tests with indices
10
+ npx explorbot runs output/tests/dashboard.js # preview steps (dry-run)
11
+ npx explorbot rerun output/tests/dashboard.js --session # run with healing
12
+ npx explorbot rerun output/tests/dashboard.js 3 --session # run test #3 only
13
+ ```
14
+
15
+ ## Listing tests
16
+
17
+ ```bash
18
+ npx explorbot runs
19
+ ```
20
+
21
+ Lists all generated test files with numbered scenarios:
22
+
23
+ ```
24
+ Dashboard Testing
25
+ output/tests/dashboard_testing.js
26
+ 1. ❯ Create a new item
27
+ 2. ─ Delete an item (skipped)
28
+ 3. ❯ Edit item title
29
+ ```
30
+
31
+ Active tests show `❯`, skipped tests show `─`.
32
+
33
+ ### Dry-run a file
34
+
35
+ ```bash
36
+ npx explorbot runs output/tests/dashboard_testing.js
37
+ ```
38
+
39
+ Prints the CodeceptJS steps each test runs, including `Before` hooks, without launching a browser. Use it to check what a test does before running it.
40
+
41
+ ## Re-running tests
42
+
43
+ ```bash
44
+ npx explorbot rerun <file> [index] [--session]
45
+ ```
46
+
47
+ Runs tests through CodeceptJS. The Rerunner agent heals steps that fail.
48
+
49
+ ### Index selection
50
+
51
+ | Syntax | Meaning |
52
+ |--------|---------|
53
+ | _(no index)_ | Run all tests in the file |
54
+ | `3` | Run test #3 only |
55
+ | `1-5` | Run tests 1 through 5 |
56
+ | `1,3,7` | Run specific tests |
57
+
58
+ Indices match the numbers shown by `npx explorbot runs`.
59
+
60
+ ### What gets skipped
61
+
62
+ - **Scenario.skip / Scenario.todo** — already marked as skipped in the test file.
63
+ - **Tests without assertions** — tests with no `I.see`, `I.seeElement`, `I.dontSee`, or similar are skipped, because their results can't be verified.
64
+
65
+ ## AI healing
66
+
67
+ When a step fails, the Rerunner agent diagnoses the problem and tries to fix it. It uses the same tools as the Tester agent: click, form, pressKey, xpathCheck, see, research, and bash.
68
+
69
+ ### How it works
70
+
71
+ 1. A step like `I.click("Save", ".modal")` fails.
72
+ 2. The healer receives the current page state (URL, ARIA tree) and trace data.
73
+ 3. It diagnoses the cause: wrong page, loading, broken locator, or missing data.
74
+ 4. It runs a replacement action, for example waiting for the page to load and then clicking with a corrected locator.
75
+ 5. On success, the test continues. On failure, it moves to the next test.
76
+
77
+ ### Healing boundaries
78
+
79
+ AI healing repairs how an existing step reaches the same intended outcome. It is deliberately not a second exploratory test run.
80
+
81
+ | Healing can | Healing does not |
82
+ |-------------|------------------|
83
+ | Replace a stale or ambiguous locator | Change the scenario's business intent |
84
+ | Wait for loading or dismiss a blocking transient UI | Turn a failed assertion into a pass |
85
+ | Restore expected navigation or repeat an equivalent interaction | Invent missing credentials, permissions, or test data |
86
+ | Adapt to a small UI structure change | Work around a real product defect or unavailable service |
87
+
88
+ The healer only has `healLimit` attempts per test and `healMaxIterations` AI iterations per failed step. It should stop when the expected element or state no longer exists, required data is missing, access is denied, or the application behavior contradicts the assertion. In those cases the test remains failed and the trace preserves the evidence for review.
89
+
90
+ Successful healing updates the generated test file with the replacement step. Review that diff before committing it: healing shows that an equivalent interaction worked now, not that every UI change is safe or intentional.
91
+
92
+ ### Healing output
93
+
94
+ During healing, the agent's actions show as substeps:
95
+
96
+ ```
97
+ ❯ Create a new test
98
+ I.amOnPage("/projects/testcaselabs/")
99
+ I.click("Test", ".sticky-header .first")
100
+ → Healing: I.click("Test", ".sticky-header .first")
101
+ > ✔ Detected loading spinner, waiting
102
+ > ✔ Click Test button in toolbar
103
+ ✔ Healed: I.click({"role":"button","text":"Test"})
104
+ ```
105
+
106
+ ### Healing configuration
107
+
108
+ Configure the Rerunner agent in `explorbot.config.js`:
109
+
110
+ ```javascript
111
+ export default {
112
+ ai: {
113
+ agents: {
114
+ rerunner: {
115
+ healLimit: 3, // max heals per test (default: 3)
116
+ healMaxIterations: 3, // max AI loop iterations per heal (default: 3)
117
+ recipes: {
118
+ // Custom healing recipes (CodeceptJS heal API)
119
+ waitForLoader: {
120
+ steps: ['amOnPage'],
121
+ fn: async () => {
122
+ return async ({ I }) => {
123
+ await I.waitForInvisible('.loader', 20);
124
+ };
125
+ },
126
+ },
127
+ },
128
+ },
129
+ },
130
+ },
131
+ };
132
+ ```
133
+
134
+ ### Custom rules
135
+
136
+ Healing prompt rules live in `rules/rerunner/` as markdown files:
137
+
138
+ | File | Purpose |
139
+ |------|---------|
140
+ | `healing-approach.md` | Step-by-step diagnosis strategy |
141
+
142
+ To override a rule, place a file with the same name in your project's `rules/rerunner/` directory.
143
+
144
+ ## Trace output
145
+
146
+ Each rerun creates a trace directory under `output/states/rerun_<timestamp>/` with per-test artifacts:
147
+
148
+ - `trace.md` — execution timeline with links to all artifacts
149
+ - `*_aria.txt` — ARIA snapshot per step
150
+ - `*_page.html` — full HTML per step
151
+ - `*_screenshot.png` — screenshot per step
152
+ - `*_console.json` — browser console logs per step
153
+
154
+ The healer reads these files to diagnose failures.
155
+
156
+ ## After exploration
157
+
158
+ After `/explore` or `npx explorbot explore`, Explorbot shows the generated test files with rerun suggestions:
159
+
160
+ ```
161
+ Generated: test_management.js
162
+ List tests: npx explorbot runs
163
+ Re-run with healing: npx explorbot rerun <filename> [index]
164
+ ```