@_deep4wee/agent-lens 1.0.1 → 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 +141 -31
- package/dist/cli.d.mts +2 -1
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +1169 -957
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1268 -974
- 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 -155
- package/dist/index.d.ts +131 -155
- 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 +142 -37
- package/skills/agent-lens/examples/06-state-testing-with-mock-ipc.md +13 -12
- 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,7 +1,7 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h1>👁️ AgentLens</h1>
|
|
3
|
-
<p><b>Give your AI coding agent eyes.</b></p>
|
|
4
|
-
<p>
|
|
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
5
|
|
|
6
6
|
[](https://www.npmjs.com/package/@_deep4wee/agent-lens)
|
|
7
7
|
[](https://www.npmjs.com/package/@_deep4wee/agent-lens)
|
|
@@ -14,37 +14,66 @@
|
|
|
14
14
|
|
|
15
15
|
## 🤔 The Problem
|
|
16
16
|
|
|
17
|
-
AI coding agents (
|
|
17
|
+
AI coding agents (such as Cursor, Claude Code, Gemini CLI, or Roo) are remarkably capable at writing code, but they are **blind**.
|
|
18
18
|
|
|
19
|
-
When an agent builds a
|
|
19
|
+
When an agent builds or refactors a user interface, it reports *"Done!"*, yet it cannot know if:
|
|
20
20
|
- The CSS layout shifted or broke on mobile viewports.
|
|
21
21
|
- The modal opened off-screen or clips behind another layer.
|
|
22
|
-
- An unhandled JavaScript error or
|
|
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.
|
|
23
24
|
|
|
24
|
-
Humans are forced to manually
|
|
25
|
+
Humans are forced to manually launch browsers, take screenshots, and tell the agent what to fix.
|
|
25
26
|
|
|
26
27
|
## 💡 The Solution
|
|
27
28
|
|
|
28
|
-
**AgentLens** is a visual testing
|
|
29
|
-
1. Write
|
|
30
|
-
2. **"See" the result immediately** using
|
|
31
|
-
3.
|
|
32
|
-
4.
|
|
33
|
-
5.
|
|
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!
|
|
34
38
|
|
|
35
39
|
---
|
|
36
40
|
|
|
37
|
-
##
|
|
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
|
|
38
64
|
|
|
39
65
|
- ⚡ **Instant One-Shot Verification (`snap`)**: Verify any live URL across desktop and mobile in seconds without writing test files.
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
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.
|
|
46
74
|
- 🧹 **Guaranteed Clean Teardown**: Built-in `setup()`, `teardown()`, and `--clean` flags that execute in a `finally` block even if the test fails.
|
|
47
|
-
- 🤖 **Agent-First Markdown Reports**:
|
|
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.
|
|
48
77
|
|
|
49
78
|
---
|
|
50
79
|
|
|
@@ -58,21 +87,53 @@ The fastest way to verify changes without writing any test files:
|
|
|
58
87
|
# Run directly via npx:
|
|
59
88
|
npx @_deep4wee/agent-lens snap --url=http://localhost:5173
|
|
60
89
|
|
|
90
|
+
# Capture full scrollable page:
|
|
91
|
+
npx @_deep4wee/agent-lens snap --url=http://localhost:5173 --full
|
|
92
|
+
|
|
61
93
|
# Auto-start dev server, wait until ready, snap, and auto-terminate:
|
|
62
94
|
npx @_deep4wee/agent-lens snap --start="npm run dev" --url=http://localhost:5173
|
|
63
95
|
|
|
64
96
|
# Focus on a specific component:
|
|
65
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
|
|
66
125
|
```
|
|
67
126
|
|
|
68
|
-
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### 3. Scripted Scenarios
|
|
69
130
|
|
|
70
131
|
Install as a development dependency:
|
|
71
132
|
```bash
|
|
72
133
|
npm install -D @_deep4wee/agent-lens
|
|
73
134
|
```
|
|
74
135
|
|
|
75
|
-
Initialize starter scenario:
|
|
136
|
+
Initialize starter scenario and mocks:
|
|
76
137
|
```bash
|
|
77
138
|
npx agent-lens init
|
|
78
139
|
```
|
|
@@ -97,6 +158,9 @@ export default defineVisualTest({
|
|
|
97
158
|
route: '/checkout',
|
|
98
159
|
viewports: [VIEWPORT_PRESETS.DEFAULT, VIEWPORT_PRESETS.MIN_SUPPORTED],
|
|
99
160
|
|
|
161
|
+
// Enable official or custom plugins:
|
|
162
|
+
plugins: ['a11y-tree', 'visual-diff'],
|
|
163
|
+
|
|
100
164
|
// 1. Setup: Prepare clean test environment
|
|
101
165
|
setup: async () => {
|
|
102
166
|
// fs.mkdirSync('./tmp_test_data', { recursive: true });
|
|
@@ -108,6 +172,9 @@ export default defineVisualTest({
|
|
|
108
172
|
await ctx.setPreset(VIEWPORT_PRESETS.DEFAULT);
|
|
109
173
|
await ctx.capture('01_checkout_initial');
|
|
110
174
|
|
|
175
|
+
// --- Mock Network API ---
|
|
176
|
+
await ctx.setMockRoute('**/api/checkout/summary', { subtotal: 80, discount: 20, total: 60 });
|
|
177
|
+
|
|
111
178
|
// --- Interaction ---
|
|
112
179
|
await ctx.type('input[name="coupon"]', 'DISCOUNT2026');
|
|
113
180
|
await ctx.click('button.apply-coupon');
|
|
@@ -117,6 +184,13 @@ export default defineVisualTest({
|
|
|
117
184
|
await ctx.resizeToFit('.cart-summary', 15);
|
|
118
185
|
await ctx.capture('02_cart_summary_fitted');
|
|
119
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
|
+
|
|
120
194
|
// --- Assertions & DOM Inspection ---
|
|
121
195
|
const totalText = await ctx.readText('.total-amount');
|
|
122
196
|
ctx.log(`Verified total amount: ${totalText}`);
|
|
@@ -143,17 +217,20 @@ export default defineVisualTest({
|
|
|
143
217
|
npx agent-lens [command] [options]
|
|
144
218
|
```
|
|
145
219
|
|
|
146
|
-
| Flag | Description | Default |
|
|
220
|
+
| Command / Flag | Description | Default |
|
|
147
221
|
| :--- | :--- | :--- |
|
|
148
222
|
| `snap` | Subcommand: Instant one-shot verification of a URL | — |
|
|
149
|
-
| `
|
|
223
|
+
| `live <action>` | Subcommand: Interactive controller (`start`, `click`, `type`, `snap`, `stop`) | — |
|
|
224
|
+
| `init` | Subcommand: Scaffold starter `template.scenario.ts` and `mocks.ts` | — |
|
|
150
225
|
| `--url=<url>` | Target URL to test (live dev server or preview) | *Auto-detected* |
|
|
151
226
|
| `--start="<cmd>"` | Command to launch dev server/backend before test | — |
|
|
152
227
|
| `--start-cwd=<path>` | Directory to run `--start` in (e.g. `--start-cwd=./Frontend`) | *Auto-detected* |
|
|
153
228
|
| `--clean-artifacts` | Purge previous test runs in `artifacts/` | `false` |
|
|
229
|
+
| `--full` | Capture full scrollable page height instead of viewport | `false` |
|
|
154
230
|
| `--selector=<css>` | Component selector to focus on / resize-to-fit | — |
|
|
155
231
|
| `--viewports=<list>`| Viewport presets (`desktop,mobile,tablet` or `1200x800`) | `desktop,mobile` |
|
|
156
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`) | — |
|
|
157
234
|
| `--scenario=<id>` | Name or prefix of scenario file to run | — |
|
|
158
235
|
| `--all` | Run all discovered scenarios | `false` |
|
|
159
236
|
| `--mode=<mode>` | Engine mode: `preview` (Web/Live) or `desktop` (native .exe) | `preview` |
|
|
@@ -169,6 +246,33 @@ npx agent-lens [command] [options]
|
|
|
169
246
|
|
|
170
247
|
---
|
|
171
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
|
+
|
|
172
276
|
## ⚙️ Configuration (`agent-lens.json`)
|
|
173
277
|
|
|
174
278
|
You can define options globally in an `agent-lens.json` file in your repository root:
|
|
@@ -180,6 +284,7 @@ You can define options globally in an `agent-lens.json` file in your repository
|
|
|
180
284
|
"scenarios": "scenarios",
|
|
181
285
|
"outDir": "visual-reports",
|
|
182
286
|
"clean": ["./cache", "./tmp_test_data"],
|
|
287
|
+
"plugins": ["a11y-tree"],
|
|
183
288
|
"autoBuild": false
|
|
184
289
|
}
|
|
185
290
|
```
|
|
@@ -190,7 +295,8 @@ Or under the `"agentLens"` property in your `package.json`:
|
|
|
190
295
|
{
|
|
191
296
|
"agentLens": {
|
|
192
297
|
"url": "http://localhost:3000",
|
|
193
|
-
"scenarios": "tests/visual"
|
|
298
|
+
"scenarios": "tests/visual",
|
|
299
|
+
"plugins": ["a11y-tree", "visual-diff"]
|
|
194
300
|
}
|
|
195
301
|
}
|
|
196
302
|
```
|
|
@@ -208,14 +314,18 @@ Check the `skills/agent-lens/examples/` directory for detailed walkthroughs:
|
|
|
208
314
|
- **[04-desktop-native-testing.md](skills/agent-lens/examples/04-desktop-native-testing.md)**: Native `.exe` and WebView2 testing.
|
|
209
315
|
- **[05-clean-teardown-and-sandboxing.md](skills/agent-lens/examples/05-clean-teardown-and-sandboxing.md)**: Preventing leftover test data.
|
|
210
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.
|
|
211
321
|
|
|
212
322
|
---
|
|
213
323
|
|
|
214
324
|
## 📄 License & Disclaimer
|
|
215
325
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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).
|
package/dist/cli.d.mts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
export { }
|
package/dist/cli.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
export { }
|