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.
- package/README.md +1 -1
- package/bin/explorbot-cli.ts +7 -1
- package/boat/api-tester/src/config.ts +4 -2
- package/boat/doc-collector/bin/doc-collector-cli.ts +2 -0
- package/boat/doc-collector/src/ai/documentarian.ts +61 -31
- package/boat/doc-collector/src/config.ts +4 -2
- package/boat/prima/bin/prima-cli.ts +0 -0
- package/boat/prima/src/activity-line.ts +33 -0
- package/boat/prima/src/cli.ts +115 -86
- package/boat/prima/src/envelope.ts +80 -52
- package/boat/prima/src/prima.ts +547 -128
- package/boat/prima/src/pw-parser.ts +11 -1
- package/boat/prima/src/pw-registry.ts +4 -5
- package/boat/prima/src/session-log.ts +126 -0
- package/dist/bin/explorbot-cli.js +7 -1
- package/dist/boat/api-tester/bin/apibot-cli.js +2 -0
- package/dist/boat/api-tester/src/config.js +4 -2
- package/dist/boat/doc-collector/bin/doc-collector-cli.js +2 -0
- package/dist/boat/doc-collector/src/ai/documentarian.js +44 -19
- package/dist/boat/doc-collector/src/config.js +4 -2
- package/dist/boat/prima/src/activity-line.js +30 -0
- package/dist/boat/prima/src/cli.js +97 -77
- package/dist/boat/prima/src/envelope.js +70 -44
- package/dist/boat/prima/src/prima.js +515 -119
- package/dist/boat/prima/src/pw-parser.js +13 -1
- package/dist/boat/prima/src/pw-registry.js +4 -5
- package/dist/boat/prima/src/session-log.js +108 -0
- package/dist/package.json +3 -2
- package/dist/rules/navigator/verification-actions.md +20 -0
- package/dist/src/action-result.d.ts +7 -0
- package/dist/src/action-result.js +4 -0
- package/dist/src/action.d.ts +2 -0
- package/dist/src/action.js +36 -1
- package/dist/src/ai/captain/web-mode.js +6 -3
- package/dist/src/ai/captain.js +2 -0
- package/dist/src/ai/navigator.d.ts +7 -0
- package/dist/src/ai/navigator.js +10 -6
- package/dist/src/ai/pilot.d.ts +4 -0
- package/dist/src/ai/pilot.js +48 -2
- package/dist/src/ai/provider.js +2 -2
- package/dist/src/ai/rerunner.js +2 -1
- package/dist/src/ai/researcher.js +1 -1
- package/dist/src/ai/rules.js +17 -10
- package/dist/src/ai/task-agent.js +4 -1
- package/dist/src/ai/tester.d.ts +1 -1
- package/dist/src/ai/tester.js +33 -33
- package/dist/src/ai/tools.d.ts +14 -0
- package/dist/src/ai/tools.js +113 -36
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.js +13 -4
- package/dist/src/execution-controller.d.ts +2 -0
- package/dist/src/execution-controller.js +6 -0
- package/dist/src/explorbot.d.ts +2 -1
- package/dist/src/explorbot.js +3 -1
- package/dist/src/explorer.js +2 -3
- package/dist/src/playwright-recorder.js +30 -0
- package/dist/src/remote.d.ts +54 -0
- package/dist/src/remote.js +229 -0
- package/dist/src/reporter.d.ts +1 -0
- package/dist/src/reporter.js +7 -1
- package/dist/src/state-manager.d.ts +2 -1
- package/dist/src/stats.d.ts +1 -0
- package/dist/src/stats.js +1 -0
- package/dist/src/test-plan.d.ts +2 -0
- package/dist/src/test-plan.js +7 -0
- package/dist/src/utils/aria.d.ts +2 -8
- package/dist/src/utils/aria.js +69 -40
- package/dist/src/utils/html.js +1 -0
- package/dist/src/utils/logger.d.ts +6 -0
- package/dist/src/utils/logger.js +24 -0
- package/dist/src/utils/page-readiness.js +18 -1
- package/dist/src/utils/url-matcher.js +3 -0
- package/dist/src/utils/web-element.d.ts +2 -0
- package/dist/src/utils/web-element.js +8 -0
- package/dist/src/utils/web-sandbox.d.ts +1 -1
- package/dist/src/utils/web-sandbox.js +2 -3
- package/docs/api-testing/basics.md +90 -0
- package/docs/api-testing/planning.md +57 -0
- package/docs/api-testing/running-tests.md +55 -0
- package/docs/assets/cloud-report.png +0 -0
- package/docs/assets/html-report.png +0 -0
- package/docs/assets/langfuse-trace.png +0 -0
- package/docs/assets/successful-explore-run.png +0 -0
- package/docs/basics/getting-started.md +140 -0
- package/docs/basics/prerequisites.md +63 -0
- package/docs/basics/providers.md +362 -0
- package/docs/basics/running.md +78 -0
- package/docs/contributing/ai-integration-tests.md +57 -0
- package/docs/contributing/contributing.md +90 -0
- package/docs/contributing/demo-videos.md +36 -0
- package/docs/contributing/npm-package.md +138 -0
- package/docs/contributing/observability.md +227 -0
- package/docs/contributing/regression-tests.md +103 -0
- package/docs/contributing/testing.md +95 -0
- package/docs/doc-collection/basics.md +128 -0
- package/docs/doc-collection/crawling.md +67 -0
- package/docs/doc-collection/interactive-mode.md +99 -0
- package/docs/index.json +86 -0
- package/docs/reference/commands.md +994 -0
- package/docs/reference/configuration.md +569 -0
- package/docs/reference/scripting.md +303 -0
- package/docs/superpowers/plans/2026-08-01-actor-boat.md +925 -0
- package/docs/superpowers/plans/2026-08-01-prima-boat.md +1120 -0
- package/docs/superpowers/reviews/2026-08-06-prima-vs-playwright-cli.md +268 -0
- package/docs/superpowers/specs/2026-08-01-actor-boat-design.md +204 -0
- package/docs/superpowers/specs/2026-08-01-prima-boat-design.md +242 -0
- package/docs/superpowers/specs/2026-08-03-global-config-design.md +138 -0
- package/docs/superpowers/specs/2026-08-07-prima-fixes-design.md +394 -0
- package/docs/web-testing/agents.md +158 -0
- package/docs/web-testing/automated-tests.md +134 -0
- package/docs/web-testing/basics.md +91 -0
- package/docs/web-testing/customization.md +131 -0
- package/docs/web-testing/hooks.md +238 -0
- package/docs/web-testing/page-interaction.md +84 -0
- package/docs/web-testing/planner.md +122 -0
- package/docs/web-testing/rerun.md +164 -0
- package/docs/web-testing/researcher.md +380 -0
- package/docs/workflow/agentic-usage.md +233 -0
- package/docs/workflow/application-spec.md +73 -0
- package/docs/workflow/ci.md +202 -0
- package/docs/workflow/knowledge.md +310 -0
- package/docs/workflow/planning-styles.md +67 -0
- package/docs/workflow/reporting.md +133 -0
- package/docs/workflow/test-plans.md +90 -0
- package/package.json +3 -2
- package/rules/navigator/verification-actions.md +20 -0
- package/src/action-result.ts +11 -0
- package/src/action.ts +38 -2
- package/src/ai/captain/web-mode.ts +6 -3
- package/src/ai/captain.ts +3 -0
- package/src/ai/navigator.ts +14 -8
- package/src/ai/pilot.ts +53 -2
- package/src/ai/provider.ts +2 -4
- package/src/ai/rerunner.ts +2 -1
- package/src/ai/researcher.ts +1 -1
- package/src/ai/rules.ts +17 -10
- package/src/ai/task-agent.ts +3 -1
- package/src/ai/tester.ts +32 -33
- package/src/ai/tools.ts +132 -36
- package/src/config.ts +15 -4
- package/src/execution-controller.ts +8 -0
- package/src/explorbot.ts +4 -2
- package/src/explorer.ts +2 -2
- package/src/playwright-recorder.ts +23 -0
- package/src/remote.ts +238 -0
- package/src/reporter.ts +7 -1
- package/src/state-manager.ts +2 -1
- package/src/stats.ts +1 -0
- package/src/test-plan.ts +9 -0
- package/src/utils/aria.ts +65 -45
- package/src/utils/html.ts +1 -0
- package/src/utils/logger.ts +24 -1
- package/src/utils/page-readiness.ts +24 -1
- package/src/utils/url-matcher.ts +3 -0
- package/src/utils/web-element.ts +9 -0
- 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.
|