e2e-pilot 0.0.69

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 (152) hide show
  1. package/bin.js +3 -0
  2. package/dist/aria-snapshot.d.ts +95 -0
  3. package/dist/aria-snapshot.d.ts.map +1 -0
  4. package/dist/aria-snapshot.js +490 -0
  5. package/dist/aria-snapshot.js.map +1 -0
  6. package/dist/bippy.js +971 -0
  7. package/dist/cdp-relay.d.ts +16 -0
  8. package/dist/cdp-relay.d.ts.map +1 -0
  9. package/dist/cdp-relay.js +715 -0
  10. package/dist/cdp-relay.js.map +1 -0
  11. package/dist/cdp-session.d.ts +42 -0
  12. package/dist/cdp-session.d.ts.map +1 -0
  13. package/dist/cdp-session.js +154 -0
  14. package/dist/cdp-session.js.map +1 -0
  15. package/dist/cdp-types.d.ts +63 -0
  16. package/dist/cdp-types.d.ts.map +1 -0
  17. package/dist/cdp-types.js +91 -0
  18. package/dist/cdp-types.js.map +1 -0
  19. package/dist/cli.d.ts +3 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +213 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/create-logger.d.ts +9 -0
  24. package/dist/create-logger.d.ts.map +1 -0
  25. package/dist/create-logger.js +25 -0
  26. package/dist/create-logger.js.map +1 -0
  27. package/dist/debugger-api.md +458 -0
  28. package/dist/debugger-examples-types.d.ts +24 -0
  29. package/dist/debugger-examples-types.d.ts.map +1 -0
  30. package/dist/debugger-examples-types.js +2 -0
  31. package/dist/debugger-examples-types.js.map +1 -0
  32. package/dist/debugger-examples.d.ts +6 -0
  33. package/dist/debugger-examples.d.ts.map +1 -0
  34. package/dist/debugger-examples.js +53 -0
  35. package/dist/debugger-examples.js.map +1 -0
  36. package/dist/debugger.d.ts +381 -0
  37. package/dist/debugger.d.ts.map +1 -0
  38. package/dist/debugger.js +633 -0
  39. package/dist/debugger.js.map +1 -0
  40. package/dist/editor-api.md +364 -0
  41. package/dist/editor-examples.d.ts +11 -0
  42. package/dist/editor-examples.d.ts.map +1 -0
  43. package/dist/editor-examples.js +124 -0
  44. package/dist/editor-examples.js.map +1 -0
  45. package/dist/editor.d.ts +203 -0
  46. package/dist/editor.d.ts.map +1 -0
  47. package/dist/editor.js +336 -0
  48. package/dist/editor.js.map +1 -0
  49. package/dist/execute.d.ts +50 -0
  50. package/dist/execute.d.ts.map +1 -0
  51. package/dist/execute.js +576 -0
  52. package/dist/execute.js.map +1 -0
  53. package/dist/index.d.ts +11 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +7 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/mcp-client.d.ts +20 -0
  58. package/dist/mcp-client.d.ts.map +1 -0
  59. package/dist/mcp-client.js +56 -0
  60. package/dist/mcp-client.js.map +1 -0
  61. package/dist/mcp.d.ts +5 -0
  62. package/dist/mcp.d.ts.map +1 -0
  63. package/dist/mcp.js +720 -0
  64. package/dist/mcp.js.map +1 -0
  65. package/dist/mcp.test.d.ts +10 -0
  66. package/dist/mcp.test.d.ts.map +1 -0
  67. package/dist/mcp.test.js +2999 -0
  68. package/dist/mcp.test.js.map +1 -0
  69. package/dist/network-capture.d.ts +23 -0
  70. package/dist/network-capture.d.ts.map +1 -0
  71. package/dist/network-capture.js +98 -0
  72. package/dist/network-capture.js.map +1 -0
  73. package/dist/protocol.d.ts +54 -0
  74. package/dist/protocol.d.ts.map +1 -0
  75. package/dist/protocol.js +2 -0
  76. package/dist/protocol.js.map +1 -0
  77. package/dist/react-source.d.ts +13 -0
  78. package/dist/react-source.d.ts.map +1 -0
  79. package/dist/react-source.js +68 -0
  80. package/dist/react-source.js.map +1 -0
  81. package/dist/scoped-fs.d.ts +94 -0
  82. package/dist/scoped-fs.d.ts.map +1 -0
  83. package/dist/scoped-fs.js +356 -0
  84. package/dist/scoped-fs.js.map +1 -0
  85. package/dist/selector-generator.js +8126 -0
  86. package/dist/start-relay-server.d.ts +6 -0
  87. package/dist/start-relay-server.d.ts.map +1 -0
  88. package/dist/start-relay-server.js +33 -0
  89. package/dist/start-relay-server.js.map +1 -0
  90. package/dist/styles-api.md +117 -0
  91. package/dist/styles-examples.d.ts +8 -0
  92. package/dist/styles-examples.d.ts.map +1 -0
  93. package/dist/styles-examples.js +64 -0
  94. package/dist/styles-examples.js.map +1 -0
  95. package/dist/styles.d.ts +27 -0
  96. package/dist/styles.d.ts.map +1 -0
  97. package/dist/styles.js +234 -0
  98. package/dist/styles.js.map +1 -0
  99. package/dist/trace-utils.d.ts +14 -0
  100. package/dist/trace-utils.d.ts.map +1 -0
  101. package/dist/trace-utils.js +21 -0
  102. package/dist/trace-utils.js.map +1 -0
  103. package/dist/utils.d.ts +20 -0
  104. package/dist/utils.d.ts.map +1 -0
  105. package/dist/utils.js +75 -0
  106. package/dist/utils.js.map +1 -0
  107. package/dist/wait-for-page-load.d.ts +16 -0
  108. package/dist/wait-for-page-load.d.ts.map +1 -0
  109. package/dist/wait-for-page-load.js +127 -0
  110. package/dist/wait-for-page-load.js.map +1 -0
  111. package/package.json +67 -0
  112. package/src/aria-snapshot.ts +610 -0
  113. package/src/assets/aria-labels-github-snapshot.txt +605 -0
  114. package/src/assets/aria-labels-github.png +0 -0
  115. package/src/assets/aria-labels-google-snapshot.txt +49 -0
  116. package/src/assets/aria-labels-google.png +0 -0
  117. package/src/assets/aria-labels-hacker-news-snapshot.txt +1023 -0
  118. package/src/assets/aria-labels-hacker-news.png +0 -0
  119. package/src/cdp-relay.ts +925 -0
  120. package/src/cdp-session.ts +203 -0
  121. package/src/cdp-timing.md +128 -0
  122. package/src/cdp-types.ts +155 -0
  123. package/src/cli.ts +250 -0
  124. package/src/create-logger.ts +36 -0
  125. package/src/debugger-examples-types.ts +13 -0
  126. package/src/debugger-examples.ts +66 -0
  127. package/src/debugger.md +453 -0
  128. package/src/debugger.ts +713 -0
  129. package/src/editor-examples.ts +148 -0
  130. package/src/editor.ts +390 -0
  131. package/src/execute.ts +763 -0
  132. package/src/index.ts +10 -0
  133. package/src/mcp-client.ts +78 -0
  134. package/src/mcp.test.ts +3596 -0
  135. package/src/mcp.ts +876 -0
  136. package/src/network-capture.ts +140 -0
  137. package/src/prompt.bak.md +323 -0
  138. package/src/prompt.md +7 -0
  139. package/src/protocol.ts +63 -0
  140. package/src/react-source.ts +94 -0
  141. package/src/resource.md +436 -0
  142. package/src/scoped-fs.ts +411 -0
  143. package/src/snapshots/hacker-news-focused-accessibility.md +202 -0
  144. package/src/snapshots/hacker-news-initial-accessibility.md +11 -0
  145. package/src/snapshots/hacker-news-tabbed-accessibility.md +202 -0
  146. package/src/snapshots/shadcn-ui-accessibility.md +11 -0
  147. package/src/start-relay-server.ts +43 -0
  148. package/src/styles-examples.ts +77 -0
  149. package/src/styles.ts +345 -0
  150. package/src/trace-utils.ts +43 -0
  151. package/src/utils.ts +91 -0
  152. package/src/wait-for-page-load.ts +174 -0
@@ -0,0 +1,203 @@
1
+ import type { ICDPSession } from './cdp-session.js';
2
+ export interface ReadResult {
3
+ content: string;
4
+ totalLines: number;
5
+ startLine: number;
6
+ endLine: number;
7
+ }
8
+ export interface SearchMatch {
9
+ url: string;
10
+ lineNumber: number;
11
+ lineContent: string;
12
+ }
13
+ export interface EditResult {
14
+ success: boolean;
15
+ stackChanged?: boolean;
16
+ }
17
+ /**
18
+ * A class for viewing and editing web page scripts via Chrome DevTools Protocol.
19
+ * Provides a Claude Code-like interface: list, read, edit, grep.
20
+ *
21
+ * Edits are in-memory only and persist until page reload. They modify the running
22
+ * V8 instance but are not saved to disk or server.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const cdp = await getCDPSession({ page })
27
+ * const editor = new Editor({ cdp })
28
+ * await editor.enable()
29
+ *
30
+ * // List available scripts
31
+ * const scripts = editor.list({ search: 'app' })
32
+ *
33
+ * // Read a script
34
+ * const { content } = await editor.read({ url: 'https://example.com/app.js' })
35
+ *
36
+ * // Edit a script
37
+ * await editor.edit({
38
+ * url: 'https://example.com/app.js',
39
+ * oldString: 'console.log("old")',
40
+ * newString: 'console.log("new")'
41
+ * })
42
+ * ```
43
+ */
44
+ export declare class Editor {
45
+ private cdp;
46
+ private enabled;
47
+ private scripts;
48
+ private stylesheets;
49
+ private sourceCache;
50
+ constructor({ cdp }: {
51
+ cdp: ICDPSession;
52
+ });
53
+ private setupEventListeners;
54
+ /**
55
+ * Enables the editor. Must be called before other methods.
56
+ * Scripts are collected from Debugger.scriptParsed events.
57
+ * Reload the page after enabling to capture all scripts.
58
+ */
59
+ enable(): Promise<void>;
60
+ private getIdByUrl;
61
+ /**
62
+ * Lists available script and stylesheet URLs. Use pattern to filter by regex.
63
+ * Automatically enables the editor if not already enabled.
64
+ *
65
+ * @param options - Options
66
+ * @param options.pattern - Optional regex to filter URLs
67
+ * @returns Array of URLs
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * // List all scripts and stylesheets
72
+ * const urls = await editor.list()
73
+ *
74
+ * // List only JS files
75
+ * const jsFiles = await editor.list({ pattern: /\.js/ })
76
+ *
77
+ * // List only CSS files
78
+ * const cssFiles = await editor.list({ pattern: /\.css/ })
79
+ *
80
+ * // Search for specific scripts
81
+ * const appScripts = await editor.list({ pattern: /app/ })
82
+ * ```
83
+ */
84
+ list({ pattern }?: {
85
+ pattern?: RegExp;
86
+ }): Promise<string[]>;
87
+ /**
88
+ * Reads a script or stylesheet's source code by URL.
89
+ * Returns line-numbered content like Claude Code's Read tool.
90
+ * For inline scripts, use the `inline://` URL from list() or grep().
91
+ *
92
+ * @param options - Options
93
+ * @param options.url - Script or stylesheet URL (inline scripts have `inline://{id}` URLs)
94
+ * @param options.offset - Line number to start from (0-based, default 0)
95
+ * @param options.limit - Number of lines to return (default 2000)
96
+ * @returns Content with line numbers, total lines, and range info
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * // Read by URL
101
+ * const { content, totalLines } = await editor.read({
102
+ * url: 'https://example.com/app.js'
103
+ * })
104
+ *
105
+ * // Read a CSS file
106
+ * const { content } = await editor.read({ url: 'https://example.com/styles.css' })
107
+ *
108
+ * // Read lines 100-200
109
+ * const { content } = await editor.read({
110
+ * url: 'https://example.com/app.js',
111
+ * offset: 100,
112
+ * limit: 100
113
+ * })
114
+ * ```
115
+ */
116
+ read({ url, offset, limit }: {
117
+ url: string;
118
+ offset?: number;
119
+ limit?: number;
120
+ }): Promise<ReadResult>;
121
+ private getSource;
122
+ /**
123
+ * Edits a script or stylesheet by replacing oldString with newString.
124
+ * Like Claude Code's Edit tool - performs exact string replacement.
125
+ *
126
+ * @param options - Options
127
+ * @param options.url - Script or stylesheet URL (inline scripts have `inline://{id}` URLs)
128
+ * @param options.oldString - Exact string to find and replace
129
+ * @param options.newString - Replacement string
130
+ * @param options.dryRun - If true, validate without applying (default false)
131
+ * @returns Result with success status
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * // Replace a string in JS
136
+ * await editor.edit({
137
+ * url: 'https://example.com/app.js',
138
+ * oldString: 'const DEBUG = false',
139
+ * newString: 'const DEBUG = true'
140
+ * })
141
+ *
142
+ * // Edit CSS
143
+ * await editor.edit({
144
+ * url: 'https://example.com/styles.css',
145
+ * oldString: 'color: red',
146
+ * newString: 'color: blue'
147
+ * })
148
+ * ```
149
+ */
150
+ edit({ url, oldString, newString, dryRun, }: {
151
+ url: string;
152
+ oldString: string;
153
+ newString: string;
154
+ dryRun?: boolean;
155
+ }): Promise<EditResult>;
156
+ private setSource;
157
+ /**
158
+ * Searches for a regex across all scripts and stylesheets.
159
+ * Like Claude Code's Grep tool - returns matching lines with context.
160
+ *
161
+ * @param options - Options
162
+ * @param options.regex - Regular expression to search for in file contents
163
+ * @param options.pattern - Optional regex to filter which URLs to search
164
+ * @returns Array of matches with url, line number, and line content
165
+ *
166
+ * @example
167
+ * ```ts
168
+ * // Search all scripts and stylesheets for "color"
169
+ * const matches = await editor.grep({ regex: /color/ })
170
+ *
171
+ * // Search only CSS files
172
+ * const matches = await editor.grep({
173
+ * regex: /background-color/,
174
+ * pattern: /\.css/
175
+ * })
176
+ *
177
+ * // Regex search for console methods in JS
178
+ * const matches = await editor.grep({
179
+ * regex: /console\.(log|error|warn)/,
180
+ * pattern: /\.js/
181
+ * })
182
+ * ```
183
+ */
184
+ grep({ regex, pattern }: {
185
+ regex: RegExp;
186
+ pattern?: RegExp;
187
+ }): Promise<SearchMatch[]>;
188
+ /**
189
+ * Writes entire content to a script or stylesheet, replacing all existing code.
190
+ * Use with caution - prefer edit() for targeted changes.
191
+ *
192
+ * @param options - Options
193
+ * @param options.url - Script or stylesheet URL (inline scripts have `inline://{id}` URLs)
194
+ * @param options.content - New content
195
+ * @param options.dryRun - If true, validate without applying (default false, only works for JS)
196
+ */
197
+ write({ url, content, dryRun }: {
198
+ url: string;
199
+ content: string;
200
+ dryRun?: boolean;
201
+ }): Promise<EditResult>;
202
+ }
203
+ //# sourceMappingURL=editor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.d.ts","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,kBAAkB,CAAA;AAE/D,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAA;IAChB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,GAAG,CAAY;IACvB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,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,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,UAAU,CAAC;CAKvH"}
package/dist/editor.js ADDED
@@ -0,0 +1,336 @@
1
+ /**
2
+ * A class for viewing and editing web page scripts via Chrome DevTools Protocol.
3
+ * Provides a Claude Code-like interface: list, read, edit, grep.
4
+ *
5
+ * Edits are in-memory only and persist until page reload. They modify the running
6
+ * V8 instance but are not saved to disk or server.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const cdp = await getCDPSession({ page })
11
+ * const editor = new Editor({ cdp })
12
+ * await editor.enable()
13
+ *
14
+ * // List available scripts
15
+ * const scripts = editor.list({ search: 'app' })
16
+ *
17
+ * // Read a script
18
+ * const { content } = await editor.read({ url: 'https://example.com/app.js' })
19
+ *
20
+ * // Edit a script
21
+ * await editor.edit({
22
+ * url: 'https://example.com/app.js',
23
+ * oldString: 'console.log("old")',
24
+ * newString: 'console.log("new")'
25
+ * })
26
+ * ```
27
+ */
28
+ export class Editor {
29
+ cdp;
30
+ enabled = false;
31
+ scripts = new Map();
32
+ stylesheets = new Map();
33
+ sourceCache = new Map();
34
+ constructor({ cdp }) {
35
+ // Cast to CDPSession for internal type safety - at runtime both are compatible
36
+ this.cdp = cdp;
37
+ this.setupEventListeners();
38
+ }
39
+ setupEventListeners() {
40
+ this.cdp.on('Debugger.scriptParsed', (params) => {
41
+ if (!params.url.startsWith('chrome') && !params.url.startsWith('devtools')) {
42
+ const url = params.url || `inline://${params.scriptId}`;
43
+ this.scripts.set(url, params.scriptId);
44
+ this.sourceCache.delete(params.scriptId);
45
+ }
46
+ });
47
+ this.cdp.on('CSS.styleSheetAdded', (params) => {
48
+ const header = params.header;
49
+ if (header.sourceURL?.startsWith('chrome') || header.sourceURL?.startsWith('devtools')) {
50
+ return;
51
+ }
52
+ const url = header.sourceURL || `inline-css://${header.styleSheetId}`;
53
+ this.stylesheets.set(url, header.styleSheetId);
54
+ this.sourceCache.delete(header.styleSheetId);
55
+ });
56
+ }
57
+ /**
58
+ * Enables the editor. Must be called before other methods.
59
+ * Scripts are collected from Debugger.scriptParsed events.
60
+ * Reload the page after enabling to capture all scripts.
61
+ */
62
+ async enable() {
63
+ if (this.enabled) {
64
+ return;
65
+ }
66
+ await this.cdp.send('Debugger.disable');
67
+ await this.cdp.send('CSS.disable');
68
+ this.scripts.clear();
69
+ this.stylesheets.clear();
70
+ this.sourceCache.clear();
71
+ const resourcesReady = new Promise((resolve) => {
72
+ let timeout;
73
+ const listener = () => {
74
+ clearTimeout(timeout);
75
+ timeout = setTimeout(() => {
76
+ this.cdp.off('Debugger.scriptParsed', listener);
77
+ this.cdp.off('CSS.styleSheetAdded', listener);
78
+ resolve();
79
+ }, 100);
80
+ };
81
+ this.cdp.on('Debugger.scriptParsed', listener);
82
+ this.cdp.on('CSS.styleSheetAdded', listener);
83
+ timeout = setTimeout(() => {
84
+ this.cdp.off('Debugger.scriptParsed', listener);
85
+ this.cdp.off('CSS.styleSheetAdded', listener);
86
+ resolve();
87
+ }, 100);
88
+ });
89
+ await this.cdp.send('Debugger.enable');
90
+ await this.cdp.send('DOM.enable');
91
+ await this.cdp.send('CSS.enable');
92
+ await resourcesReady;
93
+ this.enabled = true;
94
+ }
95
+ getIdByUrl(url) {
96
+ const scriptId = this.scripts.get(url);
97
+ if (scriptId) {
98
+ return { scriptId };
99
+ }
100
+ const styleSheetId = this.stylesheets.get(url);
101
+ if (styleSheetId) {
102
+ return { styleSheetId };
103
+ }
104
+ const allUrls = [...Array.from(this.scripts.keys()), ...Array.from(this.stylesheets.keys())];
105
+ const available = allUrls.slice(0, 5);
106
+ throw new Error(`Resource not found: ${url}\nAvailable: ${available.join(', ')}${allUrls.length > 5 ? '...' : ''}`);
107
+ }
108
+ /**
109
+ * Lists available script and stylesheet URLs. Use pattern to filter by regex.
110
+ * Automatically enables the editor if not already enabled.
111
+ *
112
+ * @param options - Options
113
+ * @param options.pattern - Optional regex to filter URLs
114
+ * @returns Array of URLs
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * // List all scripts and stylesheets
119
+ * const urls = await editor.list()
120
+ *
121
+ * // List only JS files
122
+ * const jsFiles = await editor.list({ pattern: /\.js/ })
123
+ *
124
+ * // List only CSS files
125
+ * const cssFiles = await editor.list({ pattern: /\.css/ })
126
+ *
127
+ * // Search for specific scripts
128
+ * const appScripts = await editor.list({ pattern: /app/ })
129
+ * ```
130
+ */
131
+ async list({ pattern } = {}) {
132
+ await this.enable();
133
+ const urls = [...Array.from(this.scripts.keys()), ...Array.from(this.stylesheets.keys())];
134
+ if (!pattern) {
135
+ return urls;
136
+ }
137
+ return urls.filter((url) => {
138
+ const matches = pattern.test(url);
139
+ pattern.lastIndex = 0;
140
+ return matches;
141
+ });
142
+ }
143
+ /**
144
+ * Reads a script or stylesheet's source code by URL.
145
+ * Returns line-numbered content like Claude Code's Read tool.
146
+ * For inline scripts, use the `inline://` URL from list() or grep().
147
+ *
148
+ * @param options - Options
149
+ * @param options.url - Script or stylesheet URL (inline scripts have `inline://{id}` URLs)
150
+ * @param options.offset - Line number to start from (0-based, default 0)
151
+ * @param options.limit - Number of lines to return (default 2000)
152
+ * @returns Content with line numbers, total lines, and range info
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * // Read by URL
157
+ * const { content, totalLines } = await editor.read({
158
+ * url: 'https://example.com/app.js'
159
+ * })
160
+ *
161
+ * // Read a CSS file
162
+ * const { content } = await editor.read({ url: 'https://example.com/styles.css' })
163
+ *
164
+ * // Read lines 100-200
165
+ * const { content } = await editor.read({
166
+ * url: 'https://example.com/app.js',
167
+ * offset: 100,
168
+ * limit: 100
169
+ * })
170
+ * ```
171
+ */
172
+ async read({ url, offset = 0, limit = 2000 }) {
173
+ await this.enable();
174
+ const id = this.getIdByUrl(url);
175
+ const source = await this.getSource(id);
176
+ const lines = source.split('\n');
177
+ const totalLines = lines.length;
178
+ const startLine = Math.min(offset, totalLines);
179
+ const endLine = Math.min(offset + limit, totalLines);
180
+ const selectedLines = lines.slice(startLine, endLine);
181
+ const content = selectedLines.map((line, i) => `${String(startLine + i + 1).padStart(5)}| ${line}`).join('\n');
182
+ return {
183
+ content,
184
+ totalLines,
185
+ startLine: startLine + 1,
186
+ endLine,
187
+ };
188
+ }
189
+ async getSource(id) {
190
+ if ('styleSheetId' in id) {
191
+ const cached = this.sourceCache.get(id.styleSheetId);
192
+ if (cached) {
193
+ return cached;
194
+ }
195
+ const response = await this.cdp.send('CSS.getStyleSheetText', { styleSheetId: id.styleSheetId });
196
+ this.sourceCache.set(id.styleSheetId, response.text);
197
+ return response.text;
198
+ }
199
+ const cached = this.sourceCache.get(id.scriptId);
200
+ if (cached) {
201
+ return cached;
202
+ }
203
+ const response = await this.cdp.send('Debugger.getScriptSource', { scriptId: id.scriptId });
204
+ this.sourceCache.set(id.scriptId, response.scriptSource);
205
+ return response.scriptSource;
206
+ }
207
+ /**
208
+ * Edits a script or stylesheet by replacing oldString with newString.
209
+ * Like Claude Code's Edit tool - performs exact string replacement.
210
+ *
211
+ * @param options - Options
212
+ * @param options.url - Script or stylesheet URL (inline scripts have `inline://{id}` URLs)
213
+ * @param options.oldString - Exact string to find and replace
214
+ * @param options.newString - Replacement string
215
+ * @param options.dryRun - If true, validate without applying (default false)
216
+ * @returns Result with success status
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * // Replace a string in JS
221
+ * await editor.edit({
222
+ * url: 'https://example.com/app.js',
223
+ * oldString: 'const DEBUG = false',
224
+ * newString: 'const DEBUG = true'
225
+ * })
226
+ *
227
+ * // Edit CSS
228
+ * await editor.edit({
229
+ * url: 'https://example.com/styles.css',
230
+ * oldString: 'color: red',
231
+ * newString: 'color: blue'
232
+ * })
233
+ * ```
234
+ */
235
+ async edit({ url, oldString, newString, dryRun = false, }) {
236
+ await this.enable();
237
+ const id = this.getIdByUrl(url);
238
+ const source = await this.getSource(id);
239
+ const matchCount = source.split(oldString).length - 1;
240
+ if (matchCount === 0) {
241
+ throw new Error(`oldString not found in ${url}`);
242
+ }
243
+ if (matchCount > 1) {
244
+ throw new Error(`oldString found ${matchCount} times in ${url}. Provide more context to make it unique.`);
245
+ }
246
+ const newSource = source.replace(oldString, newString);
247
+ return this.setSource(id, newSource, dryRun);
248
+ }
249
+ async setSource(id, content, dryRun = false) {
250
+ if ('styleSheetId' in id) {
251
+ await this.cdp.send('CSS.setStyleSheetText', { styleSheetId: id.styleSheetId, text: content });
252
+ if (!dryRun) {
253
+ this.sourceCache.set(id.styleSheetId, content);
254
+ }
255
+ return { success: true };
256
+ }
257
+ const response = await this.cdp.send('Debugger.setScriptSource', {
258
+ scriptId: id.scriptId,
259
+ scriptSource: content,
260
+ dryRun,
261
+ });
262
+ if (!dryRun) {
263
+ this.sourceCache.set(id.scriptId, content);
264
+ }
265
+ return { success: true, stackChanged: response.stackChanged };
266
+ }
267
+ /**
268
+ * Searches for a regex across all scripts and stylesheets.
269
+ * Like Claude Code's Grep tool - returns matching lines with context.
270
+ *
271
+ * @param options - Options
272
+ * @param options.regex - Regular expression to search for in file contents
273
+ * @param options.pattern - Optional regex to filter which URLs to search
274
+ * @returns Array of matches with url, line number, and line content
275
+ *
276
+ * @example
277
+ * ```ts
278
+ * // Search all scripts and stylesheets for "color"
279
+ * const matches = await editor.grep({ regex: /color/ })
280
+ *
281
+ * // Search only CSS files
282
+ * const matches = await editor.grep({
283
+ * regex: /background-color/,
284
+ * pattern: /\.css/
285
+ * })
286
+ *
287
+ * // Regex search for console methods in JS
288
+ * const matches = await editor.grep({
289
+ * regex: /console\.(log|error|warn)/,
290
+ * pattern: /\.js/
291
+ * })
292
+ * ```
293
+ */
294
+ async grep({ regex, pattern }) {
295
+ await this.enable();
296
+ const matches = [];
297
+ const urls = await this.list({ pattern });
298
+ for (const url of urls) {
299
+ let source;
300
+ try {
301
+ const id = this.getIdByUrl(url);
302
+ source = await this.getSource(id);
303
+ }
304
+ catch {
305
+ continue;
306
+ }
307
+ const lines = source.split('\n');
308
+ for (let i = 0; i < lines.length; i++) {
309
+ if (regex.test(lines[i])) {
310
+ matches.push({
311
+ url,
312
+ lineNumber: i + 1,
313
+ lineContent: lines[i].trim().slice(0, 200),
314
+ });
315
+ regex.lastIndex = 0;
316
+ }
317
+ }
318
+ }
319
+ return matches;
320
+ }
321
+ /**
322
+ * Writes entire content to a script or stylesheet, replacing all existing code.
323
+ * Use with caution - prefer edit() for targeted changes.
324
+ *
325
+ * @param options - Options
326
+ * @param options.url - Script or stylesheet URL (inline scripts have `inline://{id}` URLs)
327
+ * @param options.content - New content
328
+ * @param options.dryRun - If true, validate without applying (default false, only works for JS)
329
+ */
330
+ async write({ url, content, dryRun = false }) {
331
+ await this.enable();
332
+ const id = this.getIdByUrl(url);
333
+ return this.setSource(id, content, dryRun);
334
+ }
335
+ }
336
+ //# sourceMappingURL=editor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor.js","sourceRoot":"","sources":["../src/editor.ts"],"names":[],"mappings":"AAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,MAAM;IACT,GAAG,CAAY;IACf,OAAO,GAAG,KAAK,CAAA;IACf,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAA;IACnC,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAA;IACvC,WAAW,GAAG,IAAI,GAAG,EAAkB,CAAA;IAE/C,YAAY,EAAE,GAAG,EAAwB;QACvC,+EAA+E;QAC/E,IAAI,CAAC,GAAG,GAAG,GAAiB,CAAA;QAC5B,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IAEO,mBAAmB;QACzB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,uBAAuB,EAAE,CAAC,MAAM,EAAE,EAAE;YAC9C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;gBAC3E,MAA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,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,EAAsD;QAC9F,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;QACnB,MAAM,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAC5C,CAAC;CACF"}
@@ -0,0 +1,50 @@
1
+ import { Page, BrowserContext } from 'playwright-core';
2
+ import { CDPSession } from './cdp-session.js';
3
+ interface Snapshots {
4
+ fullPath: string;
5
+ incrementalPath: string;
6
+ full: string | null;
7
+ incremental: string | null;
8
+ }
9
+ export declare function savePageSnapshots({ page, lastSnapshots, timeout, }: {
10
+ page: Page;
11
+ lastSnapshots: WeakMap<Page, string>;
12
+ timeout: number;
13
+ }): Promise<Snapshots | null>;
14
+ export interface ExecuteCodeDependencies {
15
+ page: Page;
16
+ context: BrowserContext;
17
+ userState: Record<string, any>;
18
+ browserLogs: Map<string, string[]>;
19
+ lastSnapshots: WeakMap<Page, string>;
20
+ cdpSessionCache: WeakMap<Page, CDPSession>;
21
+ getPageTargetId: (page: Page) => Promise<string>;
22
+ getCdpUrl: () => string;
23
+ resetConnection: () => Promise<{
24
+ page: Page;
25
+ context: BrowserContext;
26
+ }>;
27
+ logger: (...args: any[]) => void;
28
+ sendLogToRelayServer: (level: string, ...args: any[]) => void;
29
+ intend?: string;
30
+ activeRecordingPath?: string;
31
+ }
32
+ export interface ExecuteCodeResult {
33
+ [x: string]: unknown;
34
+ content: Array<{
35
+ type: 'text';
36
+ text: string;
37
+ } | {
38
+ type: 'image';
39
+ data: string;
40
+ mimeType: string;
41
+ }>;
42
+ isError?: boolean;
43
+ }
44
+ export declare function executeCode({ code, timeout, deps, }: {
45
+ code: string;
46
+ timeout: number;
47
+ deps: ExecuteCodeDependencies;
48
+ }): Promise<ExecuteCodeResult>;
49
+ export {};
50
+ //# sourceMappingURL=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