@_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.
Files changed (51) hide show
  1. package/README.md +331 -227
  2. package/dist/cli.js +1068 -911
  3. package/dist/cli.js.map +1 -1
  4. package/dist/cli.mjs +1277 -1033
  5. package/dist/cli.mjs.map +1 -1
  6. package/dist/dsl-BIjVN1M0.d.mts +204 -0
  7. package/dist/dsl-BIjVN1M0.d.ts +204 -0
  8. package/dist/index.d.mts +131 -178
  9. package/dist/index.d.ts +131 -178
  10. package/dist/index.js +1506 -8
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +1479 -3
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/plugins/a11y-tree/index.d.mts +11 -0
  15. package/dist/plugins/a11y-tree/index.d.ts +11 -0
  16. package/dist/plugins/a11y-tree/index.js +190 -0
  17. package/dist/plugins/a11y-tree/index.js.map +1 -0
  18. package/dist/plugins/a11y-tree/index.mjs +155 -0
  19. package/dist/plugins/a11y-tree/index.mjs.map +1 -0
  20. package/dist/plugins/desktop-webview2/index.d.mts +14 -0
  21. package/dist/plugins/desktop-webview2/index.d.ts +14 -0
  22. package/dist/plugins/desktop-webview2/index.js +258 -0
  23. package/dist/plugins/desktop-webview2/index.js.map +1 -0
  24. package/dist/plugins/desktop-webview2/index.mjs +221 -0
  25. package/dist/plugins/desktop-webview2/index.mjs.map +1 -0
  26. package/dist/plugins/live-controller/index.d.mts +35 -0
  27. package/dist/plugins/live-controller/index.d.ts +35 -0
  28. package/dist/plugins/live-controller/index.js +303 -0
  29. package/dist/plugins/live-controller/index.js.map +1 -0
  30. package/dist/plugins/live-controller/index.mjs +261 -0
  31. package/dist/plugins/live-controller/index.mjs.map +1 -0
  32. package/dist/plugins/mock-ipc/index.d.mts +30 -0
  33. package/dist/plugins/mock-ipc/index.d.ts +30 -0
  34. package/dist/plugins/mock-ipc/index.js +210 -0
  35. package/dist/plugins/mock-ipc/index.js.map +1 -0
  36. package/dist/plugins/mock-ipc/index.mjs +181 -0
  37. package/dist/plugins/mock-ipc/index.mjs.map +1 -0
  38. package/dist/plugins/visual-diff/index.d.mts +30 -0
  39. package/dist/plugins/visual-diff/index.d.ts +30 -0
  40. package/dist/plugins/visual-diff/index.js +163 -0
  41. package/dist/plugins/visual-diff/index.js.map +1 -0
  42. package/dist/plugins/visual-diff/index.mjs +127 -0
  43. package/dist/plugins/visual-diff/index.mjs.map +1 -0
  44. package/docs/plugins.md +415 -0
  45. package/package.json +40 -2
  46. package/skills/agent-lens/SKILL.md +130 -43
  47. package/skills/agent-lens/examples/07-live-controller-interactive-loop.md +108 -0
  48. package/skills/agent-lens/examples/08-accessibility-semantic-inspection.md +80 -0
  49. package/skills/agent-lens/examples/09-visual-regression-and-pixel-diffing.md +66 -0
  50. package/skills/agent-lens/examples/10-authoring-custom-agent-plugins.md +85 -0
  51. package/skills/agent-lens/references/plugin-development.md +165 -0
@@ -0,0 +1,204 @@
1
+ import { Page, BrowserContext, Browser } from 'playwright';
2
+
3
+ interface ConsoleEntry {
4
+ level: 'error' | 'warning' | 'info' | 'log' | 'debug';
5
+ text: string;
6
+ url: string;
7
+ timestamp: string;
8
+ stack?: string;
9
+ }
10
+
11
+ type MockIpcResponseType = 'SUCCESS' | 'ERROR';
12
+ interface MockIpcEntry {
13
+ action: string;
14
+ data: any;
15
+ type?: MockIpcResponseType;
16
+ delayMs?: number;
17
+ }
18
+
19
+ interface ReportSection {
20
+ title: string;
21
+ content: string;
22
+ }
23
+ interface ReportData {
24
+ scenario: VisualScenario;
25
+ snapshots: SnapshotMetadata[];
26
+ consoleErrors: ConsoleEntry[];
27
+ consoleWarnings: ConsoleEntry[];
28
+ outputDir: string;
29
+ targetMode: 'desktop' | 'preview' | string;
30
+ durationMs: number;
31
+ customSections?: ReportSection[];
32
+ }
33
+
34
+ interface DriverLaunchResult {
35
+ page: Page;
36
+ context: BrowserContext;
37
+ browser?: Browser;
38
+ stop?: () => Promise<void>;
39
+ }
40
+ interface PluginHookContext {
41
+ scenario?: VisualScenario;
42
+ targetMode: 'desktop' | 'preview' | string;
43
+ artifactsDir: string;
44
+ cliOptions?: Record<string, unknown>;
45
+ state: Map<string, unknown>;
46
+ }
47
+ interface AgentLensPlugin {
48
+ /** Unique plugin identifier (e.g. 'desktop-webview2', 'live-controller', 'mock-ipc') */
49
+ name: string;
50
+ version?: string;
51
+ /** Lifecycle hook: initial setup before drivers and scenarios start */
52
+ setup?: (context: PluginHookContext) => Promise<void> | void;
53
+ /**
54
+ * Microkernel driver hook: allows a plugin to provide a custom browser/page session
55
+ * (e.g., desktop WebView2 CDP connection, custom remote browser).
56
+ */
57
+ launchSession?: (options: {
58
+ currentViewport: {
59
+ width: number;
60
+ height: number;
61
+ };
62
+ headed?: boolean;
63
+ }, hookContext: PluginHookContext) => Promise<DriverLaunchResult | undefined>;
64
+ /** Lifecycle hook: called when browser context is ready */
65
+ onContextCreated?: (context: BrowserContext, hookContext: PluginHookContext) => Promise<void> | void;
66
+ /** Lifecycle hook: called when the test page is created/navigated */
67
+ onPageCreated?: (page: Page, context: BrowserContext, hookContext: PluginHookContext) => Promise<void> | void;
68
+ /**
69
+ * Context extension: inject custom methods or properties directly into TestContext (ctx)
70
+ */
71
+ extendContext?: (ctx: TestContext, page: Page, hookContext: PluginHookContext) => Record<string, any> | Promise<Record<string, any>>;
72
+ /** Lifecycle hook: called after scenario runs and report data is calculated */
73
+ onAfterRun?: (reportData: ReportData, hookContext: PluginHookContext) => Promise<void> | void;
74
+ /** Lifecycle hook: teardown and cleanup guaranteed to run */
75
+ teardown?: (hookContext: PluginHookContext) => Promise<void> | void;
76
+ }
77
+ declare function definePlugin(plugin: AgentLensPlugin): AgentLensPlugin;
78
+
79
+ interface ViewportPreset {
80
+ name: string;
81
+ width: number;
82
+ height: number;
83
+ }
84
+ declare const VIEWPORT_PRESETS: {
85
+ /** Minimum supported window size */
86
+ MIN_SUPPORTED: ViewportPreset;
87
+ /** Standard default window size */
88
+ DEFAULT: ViewportPreset;
89
+ /** Wide screen for checking grids and tables */
90
+ WIDE: ViewportPreset;
91
+ /** Full HD */
92
+ FULL_HD: ViewportPreset;
93
+ };
94
+ interface MockRouteEntry {
95
+ url: string;
96
+ method?: string;
97
+ status?: number;
98
+ body: any;
99
+ delayMs?: number;
100
+ headers?: Record<string, string>;
101
+ }
102
+ interface CaptureOptions {
103
+ selector?: string;
104
+ fullPage?: boolean;
105
+ mask?: string[];
106
+ }
107
+ interface CaptureBurstOptions {
108
+ /** Total duration of burst animation capture in milliseconds */
109
+ durationMs: number;
110
+ /** Interval between frames in milliseconds (default: 80ms) */
111
+ intervalMs?: number;
112
+ /** Restrict capture to a specific element */
113
+ selector?: string;
114
+ }
115
+ interface SnapshotMetadata {
116
+ index: number;
117
+ name: string;
118
+ fileName: string;
119
+ filePath: string;
120
+ relativeUri: string;
121
+ viewport: {
122
+ width: number;
123
+ height: number;
124
+ };
125
+ timestamp: string;
126
+ isBurstFrame?: boolean;
127
+ burstGroup?: string;
128
+ frameIndex?: number;
129
+ selector?: string;
130
+ }
131
+ interface TestContext {
132
+ [key: string]: any;
133
+ page: Page;
134
+ context: BrowserContext;
135
+ targetMode: 'desktop' | 'preview';
136
+ currentViewport: {
137
+ width: number;
138
+ height: number;
139
+ };
140
+ capture: (name: string, options?: CaptureOptions) => Promise<SnapshotMetadata>;
141
+ captureBurst: (name: string, options: CaptureBurstOptions) => Promise<SnapshotMetadata[]>;
142
+ navigate: (route: string) => Promise<void>;
143
+ resize: (width: number, height: number) => Promise<void>;
144
+ setPreset: (preset: ViewportPreset) => Promise<void>;
145
+ resizeToFit: (selector?: string, padding?: number) => Promise<void>;
146
+ wait: (ms: number) => Promise<void>;
147
+ waitForSelector: (selector: string, timeoutMs?: number) => Promise<void>;
148
+ click: (selector: string) => Promise<void>;
149
+ rightClick: (selector: string) => Promise<void>;
150
+ type: (selector: string, text: string) => Promise<void>;
151
+ selectOption: (selector: string, value: string) => Promise<void>;
152
+ hover: (selector: string) => Promise<void>;
153
+ scroll: (selector: string, deltaY: number) => Promise<void>;
154
+ log: (message: string) => void;
155
+ setMockIpc: (action: string, data: any, options?: {
156
+ type?: MockIpcResponseType;
157
+ delayMs?: number;
158
+ }) => Promise<void>;
159
+ setMockRoute: (url: string, body: any, options?: {
160
+ method?: string;
161
+ status?: number;
162
+ delayMs?: number;
163
+ headers?: Record<string, string>;
164
+ }) => Promise<void>;
165
+ getConsoleErrors: () => ConsoleEntry[];
166
+ getConsoleWarnings: () => ConsoleEntry[];
167
+ hasConsoleErrors: () => boolean;
168
+ readText: (selector: string) => Promise<string | null>;
169
+ getPageText: () => Promise<string>;
170
+ isVisible: (selector: string) => Promise<boolean>;
171
+ getElementCount: (selector: string) => Promise<number>;
172
+ }
173
+ interface VisualScenario {
174
+ /** Unique scenario identifier (kebab-case) */
175
+ id: string;
176
+ /** Human-readable title for the report */
177
+ title: string;
178
+ /** Description of what is being tested */
179
+ description?: string;
180
+ /** Initial route to navigate to (e.g., '/instances', '/settings') */
181
+ route?: string;
182
+ /** List of viewport sizes to test */
183
+ viewports?: ViewportPreset[];
184
+ /** Initial IPC mock data for preview mode */
185
+ mockIpc?: Array<{
186
+ action: string;
187
+ data: any;
188
+ type?: MockIpcResponseType;
189
+ delayMs?: number;
190
+ }>;
191
+ /** Initial HTTP REST/GraphQL route mocks for preview mode */
192
+ mockRoutes?: MockRouteEntry[];
193
+ /** Optional plugins required for this scenario */
194
+ plugins?: (string | AgentLensPlugin)[];
195
+ /** Setup hook executed before scenario runs */
196
+ setup?: () => Promise<void> | void;
197
+ /** The main body of the scenario */
198
+ run: (ctx: TestContext) => Promise<void>;
199
+ /** Teardown hook guaranteed to run on completion */
200
+ teardown?: () => Promise<void> | void;
201
+ }
202
+ declare function defineVisualTest(scenario: VisualScenario): VisualScenario;
203
+
204
+ export { type AgentLensPlugin as A, type ConsoleEntry as C, type DriverLaunchResult as D, type MockIpcResponseType as M, type PluginHookContext as P, type ReportData as R, type SnapshotMetadata as S, type TestContext as T, type VisualScenario as V, type MockIpcEntry as a, type CaptureOptions as b, type CaptureBurstOptions as c, type MockRouteEntry as d, type ReportSection as e, VIEWPORT_PRESETS as f, type ViewportPreset as g, definePlugin as h, defineVisualTest as i };
@@ -0,0 +1,204 @@
1
+ import { Page, BrowserContext, Browser } from 'playwright';
2
+
3
+ interface ConsoleEntry {
4
+ level: 'error' | 'warning' | 'info' | 'log' | 'debug';
5
+ text: string;
6
+ url: string;
7
+ timestamp: string;
8
+ stack?: string;
9
+ }
10
+
11
+ type MockIpcResponseType = 'SUCCESS' | 'ERROR';
12
+ interface MockIpcEntry {
13
+ action: string;
14
+ data: any;
15
+ type?: MockIpcResponseType;
16
+ delayMs?: number;
17
+ }
18
+
19
+ interface ReportSection {
20
+ title: string;
21
+ content: string;
22
+ }
23
+ interface ReportData {
24
+ scenario: VisualScenario;
25
+ snapshots: SnapshotMetadata[];
26
+ consoleErrors: ConsoleEntry[];
27
+ consoleWarnings: ConsoleEntry[];
28
+ outputDir: string;
29
+ targetMode: 'desktop' | 'preview' | string;
30
+ durationMs: number;
31
+ customSections?: ReportSection[];
32
+ }
33
+
34
+ interface DriverLaunchResult {
35
+ page: Page;
36
+ context: BrowserContext;
37
+ browser?: Browser;
38
+ stop?: () => Promise<void>;
39
+ }
40
+ interface PluginHookContext {
41
+ scenario?: VisualScenario;
42
+ targetMode: 'desktop' | 'preview' | string;
43
+ artifactsDir: string;
44
+ cliOptions?: Record<string, unknown>;
45
+ state: Map<string, unknown>;
46
+ }
47
+ interface AgentLensPlugin {
48
+ /** Unique plugin identifier (e.g. 'desktop-webview2', 'live-controller', 'mock-ipc') */
49
+ name: string;
50
+ version?: string;
51
+ /** Lifecycle hook: initial setup before drivers and scenarios start */
52
+ setup?: (context: PluginHookContext) => Promise<void> | void;
53
+ /**
54
+ * Microkernel driver hook: allows a plugin to provide a custom browser/page session
55
+ * (e.g., desktop WebView2 CDP connection, custom remote browser).
56
+ */
57
+ launchSession?: (options: {
58
+ currentViewport: {
59
+ width: number;
60
+ height: number;
61
+ };
62
+ headed?: boolean;
63
+ }, hookContext: PluginHookContext) => Promise<DriverLaunchResult | undefined>;
64
+ /** Lifecycle hook: called when browser context is ready */
65
+ onContextCreated?: (context: BrowserContext, hookContext: PluginHookContext) => Promise<void> | void;
66
+ /** Lifecycle hook: called when the test page is created/navigated */
67
+ onPageCreated?: (page: Page, context: BrowserContext, hookContext: PluginHookContext) => Promise<void> | void;
68
+ /**
69
+ * Context extension: inject custom methods or properties directly into TestContext (ctx)
70
+ */
71
+ extendContext?: (ctx: TestContext, page: Page, hookContext: PluginHookContext) => Record<string, any> | Promise<Record<string, any>>;
72
+ /** Lifecycle hook: called after scenario runs and report data is calculated */
73
+ onAfterRun?: (reportData: ReportData, hookContext: PluginHookContext) => Promise<void> | void;
74
+ /** Lifecycle hook: teardown and cleanup guaranteed to run */
75
+ teardown?: (hookContext: PluginHookContext) => Promise<void> | void;
76
+ }
77
+ declare function definePlugin(plugin: AgentLensPlugin): AgentLensPlugin;
78
+
79
+ interface ViewportPreset {
80
+ name: string;
81
+ width: number;
82
+ height: number;
83
+ }
84
+ declare const VIEWPORT_PRESETS: {
85
+ /** Minimum supported window size */
86
+ MIN_SUPPORTED: ViewportPreset;
87
+ /** Standard default window size */
88
+ DEFAULT: ViewportPreset;
89
+ /** Wide screen for checking grids and tables */
90
+ WIDE: ViewportPreset;
91
+ /** Full HD */
92
+ FULL_HD: ViewportPreset;
93
+ };
94
+ interface MockRouteEntry {
95
+ url: string;
96
+ method?: string;
97
+ status?: number;
98
+ body: any;
99
+ delayMs?: number;
100
+ headers?: Record<string, string>;
101
+ }
102
+ interface CaptureOptions {
103
+ selector?: string;
104
+ fullPage?: boolean;
105
+ mask?: string[];
106
+ }
107
+ interface CaptureBurstOptions {
108
+ /** Total duration of burst animation capture in milliseconds */
109
+ durationMs: number;
110
+ /** Interval between frames in milliseconds (default: 80ms) */
111
+ intervalMs?: number;
112
+ /** Restrict capture to a specific element */
113
+ selector?: string;
114
+ }
115
+ interface SnapshotMetadata {
116
+ index: number;
117
+ name: string;
118
+ fileName: string;
119
+ filePath: string;
120
+ relativeUri: string;
121
+ viewport: {
122
+ width: number;
123
+ height: number;
124
+ };
125
+ timestamp: string;
126
+ isBurstFrame?: boolean;
127
+ burstGroup?: string;
128
+ frameIndex?: number;
129
+ selector?: string;
130
+ }
131
+ interface TestContext {
132
+ [key: string]: any;
133
+ page: Page;
134
+ context: BrowserContext;
135
+ targetMode: 'desktop' | 'preview';
136
+ currentViewport: {
137
+ width: number;
138
+ height: number;
139
+ };
140
+ capture: (name: string, options?: CaptureOptions) => Promise<SnapshotMetadata>;
141
+ captureBurst: (name: string, options: CaptureBurstOptions) => Promise<SnapshotMetadata[]>;
142
+ navigate: (route: string) => Promise<void>;
143
+ resize: (width: number, height: number) => Promise<void>;
144
+ setPreset: (preset: ViewportPreset) => Promise<void>;
145
+ resizeToFit: (selector?: string, padding?: number) => Promise<void>;
146
+ wait: (ms: number) => Promise<void>;
147
+ waitForSelector: (selector: string, timeoutMs?: number) => Promise<void>;
148
+ click: (selector: string) => Promise<void>;
149
+ rightClick: (selector: string) => Promise<void>;
150
+ type: (selector: string, text: string) => Promise<void>;
151
+ selectOption: (selector: string, value: string) => Promise<void>;
152
+ hover: (selector: string) => Promise<void>;
153
+ scroll: (selector: string, deltaY: number) => Promise<void>;
154
+ log: (message: string) => void;
155
+ setMockIpc: (action: string, data: any, options?: {
156
+ type?: MockIpcResponseType;
157
+ delayMs?: number;
158
+ }) => Promise<void>;
159
+ setMockRoute: (url: string, body: any, options?: {
160
+ method?: string;
161
+ status?: number;
162
+ delayMs?: number;
163
+ headers?: Record<string, string>;
164
+ }) => Promise<void>;
165
+ getConsoleErrors: () => ConsoleEntry[];
166
+ getConsoleWarnings: () => ConsoleEntry[];
167
+ hasConsoleErrors: () => boolean;
168
+ readText: (selector: string) => Promise<string | null>;
169
+ getPageText: () => Promise<string>;
170
+ isVisible: (selector: string) => Promise<boolean>;
171
+ getElementCount: (selector: string) => Promise<number>;
172
+ }
173
+ interface VisualScenario {
174
+ /** Unique scenario identifier (kebab-case) */
175
+ id: string;
176
+ /** Human-readable title for the report */
177
+ title: string;
178
+ /** Description of what is being tested */
179
+ description?: string;
180
+ /** Initial route to navigate to (e.g., '/instances', '/settings') */
181
+ route?: string;
182
+ /** List of viewport sizes to test */
183
+ viewports?: ViewportPreset[];
184
+ /** Initial IPC mock data for preview mode */
185
+ mockIpc?: Array<{
186
+ action: string;
187
+ data: any;
188
+ type?: MockIpcResponseType;
189
+ delayMs?: number;
190
+ }>;
191
+ /** Initial HTTP REST/GraphQL route mocks for preview mode */
192
+ mockRoutes?: MockRouteEntry[];
193
+ /** Optional plugins required for this scenario */
194
+ plugins?: (string | AgentLensPlugin)[];
195
+ /** Setup hook executed before scenario runs */
196
+ setup?: () => Promise<void> | void;
197
+ /** The main body of the scenario */
198
+ run: (ctx: TestContext) => Promise<void>;
199
+ /** Teardown hook guaranteed to run on completion */
200
+ teardown?: () => Promise<void> | void;
201
+ }
202
+ declare function defineVisualTest(scenario: VisualScenario): VisualScenario;
203
+
204
+ export { type AgentLensPlugin as A, type ConsoleEntry as C, type DriverLaunchResult as D, type MockIpcResponseType as M, type PluginHookContext as P, type ReportData as R, type SnapshotMetadata as S, type TestContext as T, type VisualScenario as V, type MockIpcEntry as a, type CaptureOptions as b, type CaptureBurstOptions as c, type MockRouteEntry as d, type ReportSection as e, VIEWPORT_PRESETS as f, type ViewportPreset as g, definePlugin as h, defineVisualTest as i };