explorbot 0.2.3 → 0.2.4

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 (156) hide show
  1. package/README.md +1 -1
  2. package/bin/explorbot-cli.ts +7 -1
  3. package/boat/api-tester/src/config.ts +4 -2
  4. package/boat/doc-collector/bin/doc-collector-cli.ts +2 -0
  5. package/boat/doc-collector/src/ai/documentarian.ts +61 -31
  6. package/boat/doc-collector/src/config.ts +4 -2
  7. package/boat/prima/bin/prima-cli.ts +0 -0
  8. package/boat/prima/src/activity-line.ts +33 -0
  9. package/boat/prima/src/cli.ts +115 -86
  10. package/boat/prima/src/envelope.ts +80 -52
  11. package/boat/prima/src/prima.ts +547 -128
  12. package/boat/prima/src/pw-parser.ts +11 -1
  13. package/boat/prima/src/pw-registry.ts +4 -5
  14. package/boat/prima/src/session-log.ts +126 -0
  15. package/dist/bin/explorbot-cli.js +7 -1
  16. package/dist/boat/api-tester/bin/apibot-cli.js +2 -0
  17. package/dist/boat/api-tester/src/config.js +4 -2
  18. package/dist/boat/doc-collector/bin/doc-collector-cli.js +2 -0
  19. package/dist/boat/doc-collector/src/ai/documentarian.js +44 -19
  20. package/dist/boat/doc-collector/src/config.js +4 -2
  21. package/dist/boat/prima/src/activity-line.js +30 -0
  22. package/dist/boat/prima/src/cli.js +97 -77
  23. package/dist/boat/prima/src/envelope.js +70 -44
  24. package/dist/boat/prima/src/prima.js +515 -119
  25. package/dist/boat/prima/src/pw-parser.js +13 -1
  26. package/dist/boat/prima/src/pw-registry.js +4 -5
  27. package/dist/boat/prima/src/session-log.js +108 -0
  28. package/dist/package.json +3 -2
  29. package/dist/rules/navigator/verification-actions.md +20 -0
  30. package/dist/src/action-result.d.ts +7 -0
  31. package/dist/src/action-result.js +4 -0
  32. package/dist/src/action.d.ts +2 -0
  33. package/dist/src/action.js +36 -1
  34. package/dist/src/ai/captain/web-mode.js +6 -3
  35. package/dist/src/ai/captain.js +2 -0
  36. package/dist/src/ai/navigator.d.ts +7 -0
  37. package/dist/src/ai/navigator.js +10 -6
  38. package/dist/src/ai/pilot.d.ts +4 -0
  39. package/dist/src/ai/pilot.js +48 -2
  40. package/dist/src/ai/provider.js +2 -2
  41. package/dist/src/ai/rerunner.js +2 -1
  42. package/dist/src/ai/researcher.js +1 -1
  43. package/dist/src/ai/rules.js +17 -10
  44. package/dist/src/ai/task-agent.js +4 -1
  45. package/dist/src/ai/tester.d.ts +1 -1
  46. package/dist/src/ai/tester.js +33 -33
  47. package/dist/src/ai/tools.d.ts +14 -0
  48. package/dist/src/ai/tools.js +113 -36
  49. package/dist/src/config.d.ts +1 -0
  50. package/dist/src/config.js +13 -4
  51. package/dist/src/execution-controller.d.ts +2 -0
  52. package/dist/src/execution-controller.js +6 -0
  53. package/dist/src/explorbot.d.ts +2 -1
  54. package/dist/src/explorbot.js +3 -1
  55. package/dist/src/explorer.js +2 -3
  56. package/dist/src/playwright-recorder.js +30 -0
  57. package/dist/src/remote.d.ts +54 -0
  58. package/dist/src/remote.js +229 -0
  59. package/dist/src/reporter.d.ts +1 -0
  60. package/dist/src/reporter.js +7 -1
  61. package/dist/src/state-manager.d.ts +2 -1
  62. package/dist/src/stats.d.ts +1 -0
  63. package/dist/src/stats.js +1 -0
  64. package/dist/src/test-plan.d.ts +2 -0
  65. package/dist/src/test-plan.js +7 -0
  66. package/dist/src/utils/aria.d.ts +2 -8
  67. package/dist/src/utils/aria.js +69 -40
  68. package/dist/src/utils/html.js +1 -0
  69. package/dist/src/utils/logger.d.ts +6 -0
  70. package/dist/src/utils/logger.js +24 -0
  71. package/dist/src/utils/page-readiness.js +18 -1
  72. package/dist/src/utils/url-matcher.js +3 -0
  73. package/dist/src/utils/web-element.d.ts +2 -0
  74. package/dist/src/utils/web-element.js +8 -0
  75. package/dist/src/utils/web-sandbox.d.ts +1 -1
  76. package/dist/src/utils/web-sandbox.js +2 -3
  77. package/docs/api-testing/basics.md +90 -0
  78. package/docs/api-testing/planning.md +57 -0
  79. package/docs/api-testing/running-tests.md +55 -0
  80. package/docs/assets/cloud-report.png +0 -0
  81. package/docs/assets/html-report.png +0 -0
  82. package/docs/assets/langfuse-trace.png +0 -0
  83. package/docs/assets/successful-explore-run.png +0 -0
  84. package/docs/basics/getting-started.md +140 -0
  85. package/docs/basics/prerequisites.md +63 -0
  86. package/docs/basics/providers.md +362 -0
  87. package/docs/basics/running.md +78 -0
  88. package/docs/contributing/ai-integration-tests.md +57 -0
  89. package/docs/contributing/contributing.md +90 -0
  90. package/docs/contributing/demo-videos.md +36 -0
  91. package/docs/contributing/npm-package.md +138 -0
  92. package/docs/contributing/observability.md +227 -0
  93. package/docs/contributing/regression-tests.md +103 -0
  94. package/docs/contributing/testing.md +95 -0
  95. package/docs/doc-collection/basics.md +128 -0
  96. package/docs/doc-collection/crawling.md +67 -0
  97. package/docs/doc-collection/interactive-mode.md +99 -0
  98. package/docs/index.json +86 -0
  99. package/docs/reference/commands.md +994 -0
  100. package/docs/reference/configuration.md +569 -0
  101. package/docs/reference/scripting.md +303 -0
  102. package/docs/superpowers/plans/2026-08-01-actor-boat.md +925 -0
  103. package/docs/superpowers/plans/2026-08-01-prima-boat.md +1120 -0
  104. package/docs/superpowers/reviews/2026-08-06-prima-vs-playwright-cli.md +268 -0
  105. package/docs/superpowers/specs/2026-08-01-actor-boat-design.md +204 -0
  106. package/docs/superpowers/specs/2026-08-01-prima-boat-design.md +242 -0
  107. package/docs/superpowers/specs/2026-08-03-global-config-design.md +138 -0
  108. package/docs/superpowers/specs/2026-08-07-prima-fixes-design.md +394 -0
  109. package/docs/web-testing/agents.md +158 -0
  110. package/docs/web-testing/automated-tests.md +134 -0
  111. package/docs/web-testing/basics.md +91 -0
  112. package/docs/web-testing/customization.md +131 -0
  113. package/docs/web-testing/hooks.md +238 -0
  114. package/docs/web-testing/page-interaction.md +84 -0
  115. package/docs/web-testing/planner.md +122 -0
  116. package/docs/web-testing/rerun.md +164 -0
  117. package/docs/web-testing/researcher.md +380 -0
  118. package/docs/workflow/agentic-usage.md +233 -0
  119. package/docs/workflow/application-spec.md +73 -0
  120. package/docs/workflow/ci.md +202 -0
  121. package/docs/workflow/knowledge.md +310 -0
  122. package/docs/workflow/planning-styles.md +67 -0
  123. package/docs/workflow/reporting.md +133 -0
  124. package/docs/workflow/test-plans.md +90 -0
  125. package/package.json +3 -2
  126. package/rules/navigator/verification-actions.md +20 -0
  127. package/src/action-result.ts +11 -0
  128. package/src/action.ts +38 -2
  129. package/src/ai/captain/web-mode.ts +6 -3
  130. package/src/ai/captain.ts +3 -0
  131. package/src/ai/navigator.ts +14 -8
  132. package/src/ai/pilot.ts +53 -2
  133. package/src/ai/provider.ts +2 -4
  134. package/src/ai/rerunner.ts +2 -1
  135. package/src/ai/researcher.ts +1 -1
  136. package/src/ai/rules.ts +17 -10
  137. package/src/ai/task-agent.ts +3 -1
  138. package/src/ai/tester.ts +32 -33
  139. package/src/ai/tools.ts +132 -36
  140. package/src/config.ts +15 -4
  141. package/src/execution-controller.ts +8 -0
  142. package/src/explorbot.ts +4 -2
  143. package/src/explorer.ts +2 -2
  144. package/src/playwright-recorder.ts +23 -0
  145. package/src/remote.ts +238 -0
  146. package/src/reporter.ts +7 -1
  147. package/src/state-manager.ts +2 -1
  148. package/src/stats.ts +1 -0
  149. package/src/test-plan.ts +9 -0
  150. package/src/utils/aria.ts +65 -45
  151. package/src/utils/html.ts +1 -0
  152. package/src/utils/logger.ts +24 -1
  153. package/src/utils/page-readiness.ts +24 -1
  154. package/src/utils/url-matcher.ts +3 -0
  155. package/src/utils/web-element.ts +9 -0
  156. package/src/utils/web-sandbox.ts +3 -4
@@ -0,0 +1,303 @@
1
+ # Building Custom Scripts
2
+
3
+ Use Explorbot programmatically to build testing pipelines. This guide shows how to write scripts that run without the TUI.
4
+
5
+ Explorbot runs on **Bun**. Importing `explorbot` resolves to the TypeScript source under Bun and to the compiled `dist/` build under Node.js, and the package ships type declarations either way — so run your scripts with `bun run`. The package exposes a single entry point:
6
+
7
+ ```typescript
8
+ import { ExplorBot, Plan, Test } from 'explorbot';
9
+ ```
10
+
11
+ Available exports: `ExplorBot`, `Plan`, `Test`, `TestResult`, `TestStatus`, plus the types `ExplorBotOptions`, `WebPageState`, and `ExplorbotConfig`.
12
+
13
+ ## Basic Setup
14
+
15
+ ```typescript
16
+ import { ExplorBot } from 'explorbot';
17
+
18
+ const bot = new ExplorBot({
19
+ path: '.', // Path to explorbot.config.js
20
+ from: '/dashboard', // Starting URL
21
+ verbose: true, // Enable debug logging
22
+ show: true, // Show browser window (false for headless)
23
+ incognito: true, // Don't save/load experience files
24
+ });
25
+
26
+ await bot.start();
27
+ // ... do stuff ...
28
+ await bot.stop();
29
+ ```
30
+
31
+ ### Options
32
+
33
+ | Option | Type | Description |
34
+ |--------|------|-------------|
35
+ | `path` | string | Path to directory containing `explorbot.config.js` |
36
+ | `from` | string | Starting URL path (e.g., `/login`, `/dashboard`) |
37
+ | `verbose` | boolean | Enable debug logging |
38
+ | `show` | boolean | Show browser window (default: false) |
39
+ | `headless` | boolean | Run in headless mode |
40
+ | `incognito` | boolean | Don't persist experience files |
41
+
42
+ ## Navigation
43
+
44
+ ```typescript
45
+ // Visit a page
46
+ await bot.visit('/settings');
47
+
48
+ // Get current page state
49
+ const state = bot.getCurrentState();
50
+ console.log(state.url);
51
+ console.log(state.title);
52
+ ```
53
+
54
+ ## Research
55
+
56
+ Analyze a page to read its UI:
57
+
58
+ ```typescript
59
+ const state = bot.getCurrentState();
60
+ const research = await bot.agentResearcher().research(state);
61
+
62
+ console.log(research);
63
+ // Contains: interactive elements, forms, navigation, etc.
64
+ ```
65
+
66
+ Research with options:
67
+
68
+ ```typescript
69
+ await bot.agentResearcher().research(state, {
70
+ screenshot: true, // Capture screenshot for vision analysis
71
+ force: true, // Re-research even if cached
72
+ data: true, // Extract structured data (tables, lists)
73
+ });
74
+ ```
75
+
76
+ ## Planning
77
+
78
+ Generate test scenarios automatically. `bot.plan()` researches the current page, generates a plan, tracks it as the current plan, and saves it to `output/plans/`:
79
+
80
+ ```typescript
81
+ // Plan tests for current page
82
+ const plan = await bot.plan();
83
+
84
+ console.log(plan.title);
85
+ console.log(plan.tests.map(t => t.scenario));
86
+ // ["Verify login with valid credentials", "Test password validation", ...]
87
+ ```
88
+
89
+ Plan with focus:
90
+
91
+ ```typescript
92
+ // Focus on specific feature
93
+ const plan = await bot.plan('checkout flow');
94
+ // Or from CLI: explorbot plan /checkout --focus "checkout flow"
95
+ ```
96
+
97
+ ## Creating Tests Manually
98
+
99
+ Define your own test scenarios:
100
+
101
+ ```typescript
102
+ import { Plan, Test } from 'explorbot';
103
+
104
+ const plan = new Plan('User Authentication');
105
+ plan.url = '/login';
106
+
107
+ const test = new Test(
108
+ 'Verify login with valid credentials', // Scenario name
109
+ 'high', // Priority: critical, important, high, normal, low
110
+ [ // Expected outcomes
111
+ 'Username field accepts input',
112
+ 'Password field accepts input',
113
+ 'Login button submits form',
114
+ 'User is redirected to dashboard',
115
+ ],
116
+ '/login' // Starting URL
117
+ );
118
+
119
+ plan.addTest(test);
120
+ ```
121
+
122
+ ## Running Tests
123
+
124
+ Execute tests using the Tester agent:
125
+
126
+ ```typescript
127
+ const tester = bot.agentTester();
128
+
129
+ // Run a single test
130
+ await tester.test(test);
131
+
132
+ // Check results
133
+ console.log(test.isSuccessful); // true/false
134
+ console.log(test.hasFailed); // true/false
135
+ console.log(test.getPrintableNotes());
136
+ ```
137
+
138
+ Run all tests in a plan:
139
+
140
+ ```typescript
141
+ for (const test of plan.tests) {
142
+ await tester.test(test);
143
+
144
+ console.log(`${test.scenario}: ${test.isSuccessful ? 'PASSED' : 'FAILED'}`);
145
+ test.getPrintableNotes().forEach(note => console.log(` ${note}`));
146
+ }
147
+ ```
148
+
149
+ ## Full Exploration Cycle
150
+
151
+ Combine research, planning, and testing. `bot.plan()` already researches the current page, so a full cycle is a plan followed by a test run:
152
+
153
+ ```typescript
154
+ await bot.visit('/dashboard');
155
+
156
+ // Research the page and generate a plan
157
+ const plan = await bot.plan('user settings');
158
+
159
+ // Run every generated test
160
+ const tester = bot.agentTester();
161
+ for (const test of plan.tests) {
162
+ await tester.test(test);
163
+ }
164
+ ```
165
+
166
+ For turnkey autonomous exploration — invent scenarios and run them in a loop, unattended — use the CLI:
167
+
168
+ ```bash
169
+ explorbot explore /dashboard --focus "user settings"
170
+ ```
171
+
172
+ ## Accessing Results
173
+
174
+ ```typescript
175
+ // Get the current plan
176
+ const plan = bot.getCurrentPlan();
177
+
178
+ // Check completion
179
+ console.log(plan.isComplete); // All tests finished
180
+ console.log(plan.allSuccessful); // All tests passed
181
+ console.log(plan.allFailed); // All tests failed
182
+
183
+ // Get pending tests
184
+ const pending = plan.getPendingTests();
185
+
186
+ // Iterate results
187
+ for (const test of plan.tests) {
188
+ console.log({
189
+ scenario: test.scenario,
190
+ priority: test.priority,
191
+ status: test.status, // pending, in_progress, done
192
+ result: test.result, // passed, failed, null
193
+ summary: test.summary,
194
+ generatedCode: test.generatedCode, // CodeceptJS code
195
+ });
196
+ }
197
+ ```
198
+
199
+ ## Saving Plans
200
+
201
+ ```typescript
202
+ // Save current plan to markdown
203
+ const path = bot.savePlan();
204
+ // Saved to: output/plans/user-authentication.md
205
+
206
+ // Save with custom filename
207
+ bot.savePlan('my-custom-plan.md');
208
+
209
+ // Load a saved plan
210
+ const loaded = bot.loadPlan('my-custom-plan.md');
211
+ ```
212
+
213
+ ## Complete Example
214
+
215
+ ```typescript
216
+ #!/usr/bin/env bun
217
+
218
+ import { ExplorBot, Plan, Test } from 'explorbot';
219
+
220
+ async function runTests() {
221
+ const bot = new ExplorBot({
222
+ path: '.',
223
+ from: '/login',
224
+ show: process.env.SHOW === 'true',
225
+ });
226
+
227
+ await bot.start();
228
+
229
+ // Navigate and research
230
+ const state = bot.getCurrentState();
231
+ await bot.agentResearcher().research(state);
232
+
233
+ // Create a test plan
234
+ const plan = new Plan('Login Flow');
235
+ plan.url = '/login';
236
+
237
+ plan.addTest(new Test(
238
+ 'Login with valid credentials',
239
+ 'high',
240
+ ['User sees dashboard after login'],
241
+ '/login'
242
+ ));
243
+
244
+ plan.addTest(new Test(
245
+ 'Login with invalid password',
246
+ 'normal',
247
+ ['Error message is displayed'],
248
+ '/login'
249
+ ));
250
+
251
+ // Run tests
252
+ const tester = bot.agentTester();
253
+
254
+ for (const test of plan.tests) {
255
+ await tester.test(test);
256
+ }
257
+
258
+ // Report results
259
+ const passed = plan.tests.filter(t => t.isSuccessful).length;
260
+ const failed = plan.tests.filter(t => t.hasFailed).length;
261
+
262
+ console.log(`\nResults: ${passed} passed, ${failed} failed`);
263
+
264
+ for (const test of plan.tests) {
265
+ const icon = test.isSuccessful ? '✓' : '✗';
266
+ console.log(`${icon} ${test.scenario}`);
267
+ }
268
+
269
+ await bot.stop();
270
+
271
+ // Exit with error code if any test failed
272
+ process.exit(failed > 0 ? 1 : 0);
273
+ }
274
+
275
+ runTests();
276
+ ```
277
+
278
+ ## Running in CI
279
+
280
+ ```bash
281
+ # Run script
282
+ bun run ./scripts/my-tests.ts
283
+
284
+ # Show browser for debugging
285
+ SHOW=true bun run ./scripts/my-tests.ts
286
+ ```
287
+
288
+ Example GitHub Actions workflow:
289
+
290
+ ```yaml
291
+ - name: Run Explorbot tests
292
+ env:
293
+ GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
294
+ run: bun run ./scripts/smoke-tests.ts
295
+ ```
296
+
297
+ ## Tips
298
+
299
+ 1. Set `incognito: true` in CI for a clean state.
300
+ 2. Set `show: true` during development to watch the browser.
301
+ 3. Start small. Test one scenario before you build full suites.
302
+ 4. Save plans. Load them later to re-run the same tests.
303
+ 5. Check `generatedCode`. Tests produce reusable CodeceptJS code.