@_deep4wee/agent-lens 1.1.0 โ 1.2.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/README.md +331 -227
- package/dist/cli.js +1068 -911
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1277 -1033
- package/dist/cli.mjs.map +1 -1
- package/dist/dsl-BIjVN1M0.d.mts +204 -0
- package/dist/dsl-BIjVN1M0.d.ts +204 -0
- package/dist/index.d.mts +131 -178
- package/dist/index.d.ts +131 -178
- package/dist/index.js +1506 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1479 -3
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/a11y-tree/index.d.mts +11 -0
- package/dist/plugins/a11y-tree/index.d.ts +11 -0
- package/dist/plugins/a11y-tree/index.js +190 -0
- package/dist/plugins/a11y-tree/index.js.map +1 -0
- package/dist/plugins/a11y-tree/index.mjs +155 -0
- package/dist/plugins/a11y-tree/index.mjs.map +1 -0
- package/dist/plugins/desktop-webview2/index.d.mts +14 -0
- package/dist/plugins/desktop-webview2/index.d.ts +14 -0
- package/dist/plugins/desktop-webview2/index.js +258 -0
- package/dist/plugins/desktop-webview2/index.js.map +1 -0
- package/dist/plugins/desktop-webview2/index.mjs +221 -0
- package/dist/plugins/desktop-webview2/index.mjs.map +1 -0
- package/dist/plugins/live-controller/index.d.mts +35 -0
- package/dist/plugins/live-controller/index.d.ts +35 -0
- package/dist/plugins/live-controller/index.js +303 -0
- package/dist/plugins/live-controller/index.js.map +1 -0
- package/dist/plugins/live-controller/index.mjs +261 -0
- package/dist/plugins/live-controller/index.mjs.map +1 -0
- package/dist/plugins/mock-ipc/index.d.mts +30 -0
- package/dist/plugins/mock-ipc/index.d.ts +30 -0
- package/dist/plugins/mock-ipc/index.js +210 -0
- package/dist/plugins/mock-ipc/index.js.map +1 -0
- package/dist/plugins/mock-ipc/index.mjs +181 -0
- package/dist/plugins/mock-ipc/index.mjs.map +1 -0
- package/dist/plugins/visual-diff/index.d.mts +30 -0
- package/dist/plugins/visual-diff/index.d.ts +30 -0
- package/dist/plugins/visual-diff/index.js +163 -0
- package/dist/plugins/visual-diff/index.js.map +1 -0
- package/dist/plugins/visual-diff/index.mjs +127 -0
- package/dist/plugins/visual-diff/index.mjs.map +1 -0
- package/docs/plugins.md +415 -0
- package/package.json +40 -2
- package/skills/agent-lens/SKILL.md +130 -43
- package/skills/agent-lens/examples/07-live-controller-interactive-loop.md +108 -0
- package/skills/agent-lens/examples/08-accessibility-semantic-inspection.md +80 -0
- package/skills/agent-lens/examples/09-visual-regression-and-pixel-diffing.md +66 -0
- package/skills/agent-lens/examples/10-authoring-custom-agent-plugins.md +85 -0
- package/skills/agent-lens/references/plugin-development.md +165 -0
package/README.md
CHANGED
|
@@ -1,227 +1,331 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<h1>๐๏ธ AgentLens</h1>
|
|
3
|
-
<p><b>Give your AI coding agent eyes.</b></p>
|
|
4
|
-
<p>
|
|
5
|
-
|
|
6
|
-
[](https://www.npmjs.com/package/@_deep4wee/agent-lens)
|
|
7
|
-
[](https://www.npmjs.com/package/@_deep4wee/agent-lens)
|
|
8
|
-
[](https://github.com/deep4wee/agent-lens/blob/main/LICENSE)
|
|
9
|
-
[](https://www.typescriptlang.org/)
|
|
10
|
-
[](https://playwright.dev/)
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## ๐ค The Problem
|
|
16
|
-
|
|
17
|
-
AI coding agents (
|
|
18
|
-
|
|
19
|
-
When an agent builds a
|
|
20
|
-
- The CSS layout shifted or
|
|
21
|
-
- The modal opened off-screen or clips behind another layer.
|
|
22
|
-
- An unhandled JavaScript error or
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
{
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>๐๏ธ AgentLens</h1>
|
|
3
|
+
<p><b>Give your AI coding agent eyes and hands.</b></p>
|
|
4
|
+
<p>A Microkernel Agentic UI Platform for visual self-checks, responsive layout verification, interactive live control, accessibility inspection, and pixel regression testing before reporting back to humans.</p>
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/@_deep4wee/agent-lens)
|
|
7
|
+
[](https://www.npmjs.com/package/@_deep4wee/agent-lens)
|
|
8
|
+
[](https://github.com/deep4wee/agent-lens/blob/main/LICENSE)
|
|
9
|
+
[](https://www.typescriptlang.org/)
|
|
10
|
+
[](https://playwright.dev/)
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## ๐ค The Problem
|
|
16
|
+
|
|
17
|
+
AI coding agents (such as Cursor, Claude Code, Gemini CLI, or Roo) are remarkably capable at writing code, but they are **blind**.
|
|
18
|
+
|
|
19
|
+
When an agent builds or refactors a user interface, it reports *"Done!"*, yet it cannot know if:
|
|
20
|
+
- The CSS layout shifted or broke on mobile viewports.
|
|
21
|
+
- The modal opened off-screen or clips behind another layer.
|
|
22
|
+
- An unhandled JavaScript runtime error or undefined prop crashed the React tree.
|
|
23
|
+
- Text-only reasoning models have no structured way to understand the interactive DOM hierarchy.
|
|
24
|
+
|
|
25
|
+
Humans are forced to manually launch browsers, take screenshots, and tell the agent what to fix.
|
|
26
|
+
|
|
27
|
+
## ๐ก The Solution
|
|
28
|
+
|
|
29
|
+
**AgentLens** is a visual testing platform built specifically for AI coding agents. It provides a modular **Microkernel architecture** that enables agents to:
|
|
30
|
+
1. Write frontend or desktop code.
|
|
31
|
+
2. **"See" the result immediately** using one-shot `snap` commands or scripted scenarios.
|
|
32
|
+
3. **Interact in real-time** via the persistent `live` controller loop with coordinate clicks and input typing.
|
|
33
|
+
4. **"Read" semantic UI hierarchies** using the built-in accessibility tree plugin (essential for text-only LLMs).
|
|
34
|
+
5. **Detect pixel-level visual regressions** using automated `pixelmatch` diffing.
|
|
35
|
+
6. Intercept silent console crashes, network failures, and runtime exceptions.
|
|
36
|
+
7. Author **1-file plugins on-the-fly** to solve project-specific constraints.
|
|
37
|
+
8. Self-correct mistakes *before* presenting the final result to the user!
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## ๐๏ธ Architecture: The Microkernel Platform
|
|
42
|
+
|
|
43
|
+
AgentLens separates the core execution engine from drivers, state bridges, and developer tools:
|
|
44
|
+
|
|
45
|
+
```mermaid
|
|
46
|
+
flowchart TD
|
|
47
|
+
CLI["AgentLens CLI (snap / live / test)"] --> Core["AgentLens Core Microkernel Engine"]
|
|
48
|
+
Core --> Runner["Scenario Runner & Lifecycle Orchestrator"]
|
|
49
|
+
Core --> PM["PluginManager (JITI / Zero-Compile TS)"]
|
|
50
|
+
|
|
51
|
+
PM --> P1["๐ฆ desktop-webview2 (Native .exe & CDP)"]
|
|
52
|
+
PM --> P2["๐ฆ mock-ipc (Hybrid Desktop Bridge)"]
|
|
53
|
+
PM --> P3["๐ live-controller (Interactive CDP CLI & --full)"]
|
|
54
|
+
PM --> P4["โฟ a11y-tree (Semantic Markdown for Text LLMs)"]
|
|
55
|
+
PM --> P5["๐จ visual-diff (Pixelmatch Regression Diffing)"]
|
|
56
|
+
PM --> P6["๐ ๏ธ Custom Workspace Plugins (.agent-lens/plugins/*.ts)"]
|
|
57
|
+
|
|
58
|
+
Runner --> Report["VisualReporter (artifacts/latest/report.md)"]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## โจ Features & Official Plugins
|
|
64
|
+
|
|
65
|
+
- โก **Instant One-Shot Verification (`snap`)**: Verify any live URL across desktop and mobile in seconds without writing test files.
|
|
66
|
+
- ๐ **Full-Page Screen Captures (`--full`)**: Capture entire scrollable page heights beyond the default viewport.
|
|
67
|
+
- ๐ **Interactive Live Controller (`live`)**: Persistent background browser session with sub-50ms command execution (`click <x> <y>`, `type <sel> <text>`, `snap --full`, `stop`).
|
|
68
|
+
- โฟ **Semantic Accessibility Inspector (`a11y-tree`)**: Extracts clean Markdown accessibility trees (roles, names, states, focus) so text-only LLMs can "read" the UI layout.
|
|
69
|
+
- ๐จ **Visual Regression Diffing (`visual-diff`)**: Automated pixel-by-pixel comparisons with baseline images using `pixelmatch` + `pngjs`, generating difference masks (`*_diff.png`) and changed pixel percentages.
|
|
70
|
+
- ๐ฅ๏ธ **Native Desktop Testing (`desktop-webview2`)**: Test compiled Windows `.exe` binaries (WebView2 / Electron / Photino) over CDP with process tree management (`treeKill`).
|
|
71
|
+
- ๐ฆ **Hybrid IPC Mock Bridge (`mock-ipc`)**: Intercept desktop IPC calls (`window.__mockIpc` and `window.external.sendMessage`) for error boundaries and offline states.
|
|
72
|
+
- ๐ **Network API Route Mocking**: Intercept REST/GraphQL calls (`mockRoutes` / `ctx.setMockRoute`) without backend dependencies.
|
|
73
|
+
- ๐ด **Console Crash Tracker**: Intercepts `console.error`, `console.warn`, and unhandled exceptions (`pageerror`) with stack traces.
|
|
74
|
+
- ๐งน **Guaranteed Clean Teardown**: Built-in `setup()`, `teardown()`, and `--clean` flags that execute in a `finally` block even if the test fails.
|
|
75
|
+
- ๐ค **Agent-First Markdown Reports**: Produces a standardized `artifacts/latest/report.md` formatted for LLM file-reading tools.
|
|
76
|
+
- ๐ **Extensible Plugin System**: Agents can author custom 1-file plugins in `.agent-lens/plugins/` using modern TypeScript without compiling.
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## ๐ Quickstart
|
|
81
|
+
|
|
82
|
+
### 1. Instant One-Shot Check (`snap`)
|
|
83
|
+
|
|
84
|
+
The fastest way to verify changes without writing any test files:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Run directly via npx:
|
|
88
|
+
npx @_deep4wee/agent-lens snap --url=http://localhost:5173
|
|
89
|
+
|
|
90
|
+
# Capture full scrollable page:
|
|
91
|
+
npx @_deep4wee/agent-lens snap --url=http://localhost:5173 --full
|
|
92
|
+
|
|
93
|
+
# Auto-start dev server, wait until ready, snap, and auto-terminate:
|
|
94
|
+
npx @_deep4wee/agent-lens snap --start="npm run dev" --url=http://localhost:5173
|
|
95
|
+
|
|
96
|
+
# Focus on a specific component:
|
|
97
|
+
npx @_deep4wee/agent-lens snap --url=http://localhost:5173/settings --selector=".pricing-card"
|
|
98
|
+
|
|
99
|
+
# Extract semantic accessibility tree during snap:
|
|
100
|
+
npx @_deep4wee/agent-lens snap --url=http://localhost:5173 --plugin=a11y-tree
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### 2. Interactive Live Controller Loop (`live`)
|
|
106
|
+
|
|
107
|
+
Keep a browser running in the background and send commands step-by-step with sub-50ms latency:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# 1. Start background live session:
|
|
111
|
+
npx agent-lens live start --url=http://localhost:5173
|
|
112
|
+
|
|
113
|
+
# 2. Click coordinates (for Vision AI models) or CSS selectors:
|
|
114
|
+
npx agent-lens live click 450 180
|
|
115
|
+
npx agent-lens live click "button.open-modal"
|
|
116
|
+
|
|
117
|
+
# 3. Fill in form fields:
|
|
118
|
+
npx agent-lens live type "input[name='email']" "agent@example.com"
|
|
119
|
+
|
|
120
|
+
# 4. Take live snapshots (updates artifacts/live/current.png):
|
|
121
|
+
npx agent-lens live snap step_02 --full
|
|
122
|
+
|
|
123
|
+
# 5. Stop session when done:
|
|
124
|
+
npx agent-lens live stop
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### 3. Scripted Scenarios
|
|
130
|
+
|
|
131
|
+
Install as a development dependency:
|
|
132
|
+
```bash
|
|
133
|
+
npm install -D @_deep4wee/agent-lens
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Initialize starter scenario and mocks:
|
|
137
|
+
```bash
|
|
138
|
+
npx agent-lens init
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Run a scenario:
|
|
142
|
+
```bash
|
|
143
|
+
npx agent-lens --scenario=smoke --url=http://localhost:5173
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## ๐ ๏ธ API Reference (Scenario DSL)
|
|
149
|
+
|
|
150
|
+
Write scenarios in `scenarios/<name>.scenario.ts`:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { defineVisualTest, VIEWPORT_PRESETS, type TestContext } from 'agent-lens';
|
|
154
|
+
|
|
155
|
+
export default defineVisualTest({
|
|
156
|
+
id: 'checkout-flow',
|
|
157
|
+
title: 'Checkout Flow Verification',
|
|
158
|
+
route: '/checkout',
|
|
159
|
+
viewports: [VIEWPORT_PRESETS.DEFAULT, VIEWPORT_PRESETS.MIN_SUPPORTED],
|
|
160
|
+
|
|
161
|
+
// Enable official or custom plugins:
|
|
162
|
+
plugins: ['a11y-tree', 'visual-diff'],
|
|
163
|
+
|
|
164
|
+
// 1. Setup: Prepare clean test environment
|
|
165
|
+
setup: async () => {
|
|
166
|
+
// fs.mkdirSync('./tmp_test_data', { recursive: true });
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
// 2. Main Test Execution
|
|
170
|
+
run: async (ctx: TestContext) => {
|
|
171
|
+
// --- Navigation & Viewport ---
|
|
172
|
+
await ctx.setPreset(VIEWPORT_PRESETS.DEFAULT);
|
|
173
|
+
await ctx.capture('01_checkout_initial');
|
|
174
|
+
|
|
175
|
+
// --- Mock Network API ---
|
|
176
|
+
await ctx.setMockRoute('**/api/checkout/summary', { subtotal: 80, discount: 20, total: 60 });
|
|
177
|
+
|
|
178
|
+
// --- Interaction ---
|
|
179
|
+
await ctx.type('input[name="coupon"]', 'DISCOUNT2026');
|
|
180
|
+
await ctx.click('button.apply-coupon');
|
|
181
|
+
await ctx.wait(500);
|
|
182
|
+
|
|
183
|
+
// --- Component Isolation ---
|
|
184
|
+
await ctx.resizeToFit('.cart-summary', 15);
|
|
185
|
+
await ctx.capture('02_cart_summary_fitted');
|
|
186
|
+
|
|
187
|
+
// --- Semantic Accessibility Inspection (a11y-tree plugin) ---
|
|
188
|
+
const a11y = await (ctx as any).dumpAccessibilityTree({ compact: true });
|
|
189
|
+
ctx.log('Accessibility hierarchy captured.');
|
|
190
|
+
|
|
191
|
+
// --- Visual Regression Check (visual-diff plugin) ---
|
|
192
|
+
// await (ctx as any).captureAndCompare('03_checkout_final', 'baselines/checkout.png');
|
|
193
|
+
|
|
194
|
+
// --- Assertions & DOM Inspection ---
|
|
195
|
+
const totalText = await ctx.readText('.total-amount');
|
|
196
|
+
ctx.log(`Verified total amount: ${totalText}`);
|
|
197
|
+
|
|
198
|
+
// --- Check Console Errors ---
|
|
199
|
+
const errors = ctx.getConsoleErrors();
|
|
200
|
+
if (errors.length > 0) {
|
|
201
|
+
ctx.log(`๐จ UI errors detected: ${errors.length}`);
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
// 3. Teardown: Guaranteed to execute even if run() crashes!
|
|
206
|
+
teardown: async () => {
|
|
207
|
+
// fs.rmSync('./tmp_test_data', { recursive: true, force: true });
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## ๐ป CLI Flags Reference
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
npx agent-lens [command] [options]
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
| Command / Flag | Description | Default |
|
|
221
|
+
| :--- | :--- | :--- |
|
|
222
|
+
| `snap` | Subcommand: Instant one-shot verification of a URL | โ |
|
|
223
|
+
| `live <action>` | Subcommand: Interactive controller (`start`, `click`, `type`, `snap`, `stop`) | โ |
|
|
224
|
+
| `init` | Subcommand: Scaffold starter `template.scenario.ts` and `mocks.ts` | โ |
|
|
225
|
+
| `--url=<url>` | Target URL to test (live dev server or preview) | *Auto-detected* |
|
|
226
|
+
| `--start="<cmd>"` | Command to launch dev server/backend before test | โ |
|
|
227
|
+
| `--start-cwd=<path>` | Directory to run `--start` in (e.g. `--start-cwd=./Frontend`) | *Auto-detected* |
|
|
228
|
+
| `--clean-artifacts` | Purge previous test runs in `artifacts/` | `false` |
|
|
229
|
+
| `--full` | Capture full scrollable page height instead of viewport | `false` |
|
|
230
|
+
| `--selector=<css>` | Component selector to focus on / resize-to-fit | โ |
|
|
231
|
+
| `--viewports=<list>`| Viewport presets (`desktop,mobile,tablet` or `1200x800`) | `desktop,mobile` |
|
|
232
|
+
| `--wait=<ms>` | Milliseconds to wait after page load before capture | `1000` |
|
|
233
|
+
| `--plugin=<list>` | Comma-separated plugins to load (`--plugin=a11y-tree,visual-diff`) | โ |
|
|
234
|
+
| `--scenario=<id>` | Name or prefix of scenario file to run | โ |
|
|
235
|
+
| `--all` | Run all discovered scenarios | `false` |
|
|
236
|
+
| `--mode=<mode>` | Engine mode: `preview` (Web/Live) or `desktop` (native .exe) | `preview` |
|
|
237
|
+
| `--exe=<path>` | Path to compiled desktop executable for desktop mode | โ |
|
|
238
|
+
| `--port=<port>` | CDP remote debugging port for desktop mode | `9222` |
|
|
239
|
+
| `--build[=<cmd>]` | Build command to run before testing | `npm run build` |
|
|
240
|
+
| `--clean=<paths>` | Comma-separated paths to purge upon test completion | โ |
|
|
241
|
+
| `--folder=<path>` | Folder to store artifacts and reports (also `--outDir`) | `artifacts` |
|
|
242
|
+
| `--headed` | Show Chromium browser window (for human debugging) | `false` |
|
|
243
|
+
| `--detach` | Do not close browser or app after tests finish | `false` |
|
|
244
|
+
|
|
245
|
+
> ๐ก **Tip for AI Agents:** AgentLens always maintains a persistent copy of the most recent report at `artifacts/latest/report.md`. You can inspect this file directly without needing to compute or match timestamped directory names.
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
## ๐ Developing Custom Plugins
|
|
250
|
+
|
|
251
|
+
AgentLens makes it effortless to author custom plugins. When an AI agent or developer faces unique project constraints (e.g., custom OAuth token injection, IndexedDB pre-population, or Canvas drawing assertions), they can create a 1-file plugin in `.agent-lens/plugins/<name>.ts`.
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
// .agent-lens/plugins/mock-auth.ts
|
|
255
|
+
import { definePlugin } from 'agent-lens';
|
|
256
|
+
|
|
257
|
+
export default definePlugin({
|
|
258
|
+
name: 'mock-auth',
|
|
259
|
+
onContextCreated: async (context) => {
|
|
260
|
+
await context.addInitScript(() => {
|
|
261
|
+
window.localStorage.setItem('auth_token', 'mock-agent-jwt');
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Execute immediately with zero build steps:
|
|
268
|
+
```bash
|
|
269
|
+
npx agent-lens snap --plugin=mock-auth --url=http://localhost:5173
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
๐ **Read the full [Plugin Development Guide](docs/plugins.md)** for interface specifications, lifecycle hooks, and complete recipes.
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## โ๏ธ Configuration (`agent-lens.json`)
|
|
277
|
+
|
|
278
|
+
You can define options globally in an `agent-lens.json` file in your repository root:
|
|
279
|
+
|
|
280
|
+
```json
|
|
281
|
+
{
|
|
282
|
+
"url": "http://localhost:5173",
|
|
283
|
+
"startCommand": "npm run dev",
|
|
284
|
+
"scenarios": "scenarios",
|
|
285
|
+
"outDir": "visual-reports",
|
|
286
|
+
"clean": ["./cache", "./tmp_test_data"],
|
|
287
|
+
"plugins": ["a11y-tree"],
|
|
288
|
+
"autoBuild": false
|
|
289
|
+
}
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
Or under the `"agentLens"` property in your `package.json`:
|
|
293
|
+
|
|
294
|
+
```json
|
|
295
|
+
{
|
|
296
|
+
"agentLens": {
|
|
297
|
+
"url": "http://localhost:3000",
|
|
298
|
+
"scenarios": "tests/visual",
|
|
299
|
+
"plugins": ["a11y-tree", "visual-diff"]
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## ๐ง Equipping AI Agents (`SKILL.md`)
|
|
307
|
+
|
|
308
|
+
When installed via NPM, AgentLens automatically copies the agent skill into your project's `.agents/skills/agent-lens/` folder. This equips agents (like Cursor, Gemini, Claude, and Roo) with the exact system instructions and example workflows needed to use AgentLens autonomously.
|
|
309
|
+
|
|
310
|
+
Check the `skills/agent-lens/examples/` directory for detailed walkthroughs:
|
|
311
|
+
- **[01-instant-verification-snap.md](skills/agent-lens/examples/01-instant-verification-snap.md)**: Zero-config quick checks.
|
|
312
|
+
- **[02-dev-server-live-testing.md](skills/agent-lens/examples/02-dev-server-live-testing.md)**: Live dev server workflows.
|
|
313
|
+
- **[03-component-isolation-and-animations.md](skills/agent-lens/examples/03-component-isolation-and-animations.md)**: Deep component and animation testing.
|
|
314
|
+
- **[04-desktop-native-testing.md](skills/agent-lens/examples/04-desktop-native-testing.md)**: Native `.exe` and WebView2 testing.
|
|
315
|
+
- **[05-clean-teardown-and-sandboxing.md](skills/agent-lens/examples/05-clean-teardown-and-sandboxing.md)**: Preventing leftover test data.
|
|
316
|
+
- **[06-state-testing-with-mock-ipc.md](skills/agent-lens/examples/06-state-testing-with-mock-ipc.md)**: Empty states and error handling.
|
|
317
|
+
- **[07-live-controller-interactive-loop.md](skills/agent-lens/examples/07-live-controller-interactive-loop.md)**: Low-latency real-time control via CLI commands.
|
|
318
|
+
- **[08-accessibility-semantic-inspection.md](skills/agent-lens/examples/08-accessibility-semantic-inspection.md)**: Extracting UI hierarchies for text LLMs.
|
|
319
|
+
- **[09-visual-regression-and-pixel-diffing.md](skills/agent-lens/examples/09-visual-regression-and-pixel-diffing.md)**: Automated pixelmatch difference masks.
|
|
320
|
+
- **[10-authoring-custom-agent-plugins.md](skills/agent-lens/examples/10-authoring-custom-agent-plugins.md)**: Writing 1-file plugins on-the-fly.
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## ๐ License & Disclaimer
|
|
325
|
+
|
|
326
|
+
Released under the [MIT License](https://github.com/deep4wee/agent-lens/blob/main/LICENSE). Free for open-source and commercial use.
|
|
327
|
+
|
|
328
|
+
> [!NOTE]
|
|
329
|
+
> **Autonomous Agent Usage Disclaimer**: AgentLens is designed to execute commands, launch local dev servers, and interact with web browsers or desktop binaries as instructed by scripts or AI agents. The author and contributors assume no liability for any unintentional file modifications, port conflicts, process terminations, or data loss caused by autonomous agent actions or third-party code tested with this tool. Run agents and test scripts in appropriate development environments or containers.
|
|
330
|
+
|
|
331
|
+
Copyright ยฉ 2026 [deep4wee](https://github.com/deep4wee).
|