@stablyai/internal-playwright 0.1.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 (297) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +168 -0
  4. package/ThirdPartyNotices.txt +6277 -0
  5. package/cli.js +19 -0
  6. package/index.d.ts +17 -0
  7. package/index.js +17 -0
  8. package/index.mjs +18 -0
  9. package/jsx-runtime.js +42 -0
  10. package/jsx-runtime.mjs +21 -0
  11. package/lib/agents/generateAgents.js +265 -0
  12. package/lib/agents/generator.md +102 -0
  13. package/lib/agents/healer.md +78 -0
  14. package/lib/agents/planner.md +135 -0
  15. package/lib/cli.js +274 -0
  16. package/lib/common/config.js +274 -0
  17. package/lib/common/config.js.map +7 -0
  18. package/lib/common/configLoader.js +377 -0
  19. package/lib/common/configLoader.js.map +7 -0
  20. package/lib/common/esmLoaderHost.js +102 -0
  21. package/lib/common/esmLoaderHost.js.map +7 -0
  22. package/lib/common/expectBundle.js +52 -0
  23. package/lib/common/expectBundle.js.map +7 -0
  24. package/lib/common/expectBundleImpl.js +389 -0
  25. package/lib/common/expectBundleImpl.js.map +7 -0
  26. package/lib/common/fixtures.js +302 -0
  27. package/lib/common/fixtures.js.map +7 -0
  28. package/lib/common/globals.js +58 -0
  29. package/lib/common/globals.js.map +7 -0
  30. package/lib/common/ipc.js +60 -0
  31. package/lib/common/ipc.js.map +7 -0
  32. package/lib/common/poolBuilder.js +85 -0
  33. package/lib/common/poolBuilder.js.map +7 -0
  34. package/lib/common/process.js +104 -0
  35. package/lib/common/process.js.map +7 -0
  36. package/lib/common/suiteUtils.js +140 -0
  37. package/lib/common/suiteUtils.js.map +7 -0
  38. package/lib/common/test.js +321 -0
  39. package/lib/common/test.js.map +7 -0
  40. package/lib/common/testLoader.js +100 -0
  41. package/lib/common/testLoader.js.map +7 -0
  42. package/lib/common/testType.js +310 -0
  43. package/lib/common/testType.js.map +7 -0
  44. package/lib/fsWatcher.js +67 -0
  45. package/lib/fsWatcher.js.map +7 -0
  46. package/lib/index.js +696 -0
  47. package/lib/index.js.map +7 -0
  48. package/lib/internalsForTest.js +42 -0
  49. package/lib/internalsForTest.js.map +7 -0
  50. package/lib/isomorphic/events.js +77 -0
  51. package/lib/isomorphic/events.js.map +7 -0
  52. package/lib/isomorphic/folders.js +30 -0
  53. package/lib/isomorphic/folders.js.map +7 -0
  54. package/lib/isomorphic/stringInternPool.js +69 -0
  55. package/lib/isomorphic/stringInternPool.js.map +7 -0
  56. package/lib/isomorphic/teleReceiver.js +507 -0
  57. package/lib/isomorphic/teleReceiver.js.map +7 -0
  58. package/lib/isomorphic/teleSuiteUpdater.js +137 -0
  59. package/lib/isomorphic/teleSuiteUpdater.js.map +7 -0
  60. package/lib/isomorphic/testServerConnection.js +211 -0
  61. package/lib/isomorphic/testServerConnection.js.map +7 -0
  62. package/lib/isomorphic/testServerInterface.js +16 -0
  63. package/lib/isomorphic/testServerInterface.js.map +7 -0
  64. package/lib/isomorphic/testTree.js +334 -0
  65. package/lib/isomorphic/testTree.js.map +7 -0
  66. package/lib/isomorphic/types.d.js +16 -0
  67. package/lib/isomorphic/types.d.js.map +7 -0
  68. package/lib/loader/loaderMain.js +59 -0
  69. package/lib/loader/loaderMain.js.map +7 -0
  70. package/lib/matchers/expect.js +325 -0
  71. package/lib/matchers/expect.js.map +7 -0
  72. package/lib/matchers/matcherHint.js +87 -0
  73. package/lib/matchers/matcherHint.js.map +7 -0
  74. package/lib/matchers/matchers.js +366 -0
  75. package/lib/matchers/matchers.js.map +7 -0
  76. package/lib/matchers/toBeTruthy.js +73 -0
  77. package/lib/matchers/toBeTruthy.js.map +7 -0
  78. package/lib/matchers/toEqual.js +99 -0
  79. package/lib/matchers/toEqual.js.map +7 -0
  80. package/lib/matchers/toHaveURL.js +102 -0
  81. package/lib/matchers/toHaveURL.js.map +7 -0
  82. package/lib/matchers/toMatchAriaSnapshot.js +159 -0
  83. package/lib/matchers/toMatchAriaSnapshot.js.map +7 -0
  84. package/lib/matchers/toMatchSnapshot.js +359 -0
  85. package/lib/matchers/toMatchSnapshot.js.map +7 -0
  86. package/lib/matchers/toMatchText.js +99 -0
  87. package/lib/matchers/toMatchText.js.map +7 -0
  88. package/lib/mcp/browser/actions.d.js +16 -0
  89. package/lib/mcp/browser/backend.js +93 -0
  90. package/lib/mcp/browser/backend.js.map +7 -0
  91. package/lib/mcp/browser/browserContextFactory.js +296 -0
  92. package/lib/mcp/browser/browserServerBackend.js +76 -0
  93. package/lib/mcp/browser/codegen.js +66 -0
  94. package/lib/mcp/browser/config.js +385 -0
  95. package/lib/mcp/browser/context.js +287 -0
  96. package/lib/mcp/browser/response.js +228 -0
  97. package/lib/mcp/browser/sessionLog.js +160 -0
  98. package/lib/mcp/browser/tab.js +277 -0
  99. package/lib/mcp/browser/tool.js +30 -0
  100. package/lib/mcp/browser/tool.js.map +7 -0
  101. package/lib/mcp/browser/tools/common.js +63 -0
  102. package/lib/mcp/browser/tools/console.js +44 -0
  103. package/lib/mcp/browser/tools/dialogs.js +60 -0
  104. package/lib/mcp/browser/tools/evaluate.js +70 -0
  105. package/lib/mcp/browser/tools/files.js +58 -0
  106. package/lib/mcp/browser/tools/form.js +74 -0
  107. package/lib/mcp/browser/tools/install.js +69 -0
  108. package/lib/mcp/browser/tools/keyboard.js +85 -0
  109. package/lib/mcp/browser/tools/mouse.js +107 -0
  110. package/lib/mcp/browser/tools/navigate.js +62 -0
  111. package/lib/mcp/browser/tools/network.js +54 -0
  112. package/lib/mcp/browser/tools/pdf.js +59 -0
  113. package/lib/mcp/browser/tools/screenshot.js +88 -0
  114. package/lib/mcp/browser/tools/snapshot.js +182 -0
  115. package/lib/mcp/browser/tools/tabs.js +67 -0
  116. package/lib/mcp/browser/tools/tool.js +49 -0
  117. package/lib/mcp/browser/tools/tracing.js +74 -0
  118. package/lib/mcp/browser/tools/utils.js +100 -0
  119. package/lib/mcp/browser/tools/verify.js +154 -0
  120. package/lib/mcp/browser/tools/wait.js +63 -0
  121. package/lib/mcp/browser/tools.js +80 -0
  122. package/lib/mcp/browser/tools.js.map +7 -0
  123. package/lib/mcp/browser/watchdog.js +44 -0
  124. package/lib/mcp/config.d.js +16 -0
  125. package/lib/mcp/extension/cdpRelay.js +351 -0
  126. package/lib/mcp/extension/extensionContextFactory.js +75 -0
  127. package/lib/mcp/extension/protocol.js +28 -0
  128. package/lib/mcp/index.js +61 -0
  129. package/lib/mcp/log.js +35 -0
  130. package/lib/mcp/program.js +96 -0
  131. package/lib/mcp/sdk/bundle.js +81 -0
  132. package/lib/mcp/sdk/bundle.js.map +7 -0
  133. package/lib/mcp/sdk/call.js +49 -0
  134. package/lib/mcp/sdk/call.js.map +7 -0
  135. package/lib/mcp/sdk/exports.js +32 -0
  136. package/lib/mcp/sdk/exports.js.map +7 -0
  137. package/lib/mcp/sdk/http.js +187 -0
  138. package/lib/mcp/sdk/http.js.map +7 -0
  139. package/lib/mcp/sdk/inProcessTransport.js +71 -0
  140. package/lib/mcp/sdk/inProcessTransport.js.map +7 -0
  141. package/lib/mcp/sdk/mdb.js +206 -0
  142. package/lib/mcp/sdk/mdb.js.map +7 -0
  143. package/lib/mcp/sdk/proxyBackend.js +128 -0
  144. package/lib/mcp/sdk/proxyBackend.js.map +7 -0
  145. package/lib/mcp/sdk/server.js +189 -0
  146. package/lib/mcp/sdk/server.js.map +7 -0
  147. package/lib/mcp/sdk/tool.js +51 -0
  148. package/lib/mcp/sdk/tool.js.map +7 -0
  149. package/lib/mcp/test/backend.js +67 -0
  150. package/lib/mcp/test/backend.js.map +7 -0
  151. package/lib/mcp/test/browserBackend.js +98 -0
  152. package/lib/mcp/test/context.js +48 -0
  153. package/lib/mcp/test/context.js.map +7 -0
  154. package/lib/mcp/test/generatorTools.js +122 -0
  155. package/lib/mcp/test/plannerTools.js +46 -0
  156. package/lib/mcp/test/seed.js +72 -0
  157. package/lib/mcp/test/streams.js +39 -0
  158. package/lib/mcp/test/streams.js.map +7 -0
  159. package/lib/mcp/test/testBackend.js +97 -0
  160. package/lib/mcp/test/testContext.js +176 -0
  161. package/lib/mcp/test/testTool.js +30 -0
  162. package/lib/mcp/test/testTools.js +115 -0
  163. package/lib/mcp/test/tool.js +30 -0
  164. package/lib/mcp/test/tool.js.map +7 -0
  165. package/lib/mcp/test/tools.js +150 -0
  166. package/lib/mcp/test/tools.js.map +7 -0
  167. package/lib/mcp/vscode/host.js +187 -0
  168. package/lib/mcp/vscode/main.js +77 -0
  169. package/lib/mcpBundleImpl.js +41 -0
  170. package/lib/mcpBundleImpl.js.map +7 -0
  171. package/lib/plugins/gitCommitInfoPlugin.js +198 -0
  172. package/lib/plugins/gitCommitInfoPlugin.js.map +7 -0
  173. package/lib/plugins/index.js +28 -0
  174. package/lib/plugins/index.js.map +7 -0
  175. package/lib/plugins/webServerPlugin.js +209 -0
  176. package/lib/plugins/webServerPlugin.js.map +7 -0
  177. package/lib/program.js +412 -0
  178. package/lib/program.js.map +7 -0
  179. package/lib/reporters/base.js +609 -0
  180. package/lib/reporters/base.js.map +7 -0
  181. package/lib/reporters/blob.js +135 -0
  182. package/lib/reporters/blob.js.map +7 -0
  183. package/lib/reporters/dot.js +82 -0
  184. package/lib/reporters/dot.js.map +7 -0
  185. package/lib/reporters/empty.js +32 -0
  186. package/lib/reporters/empty.js.map +7 -0
  187. package/lib/reporters/github.js +128 -0
  188. package/lib/reporters/github.js.map +7 -0
  189. package/lib/reporters/html.js +644 -0
  190. package/lib/reporters/html.js.map +7 -0
  191. package/lib/reporters/internalReporter.js +130 -0
  192. package/lib/reporters/internalReporter.js.map +7 -0
  193. package/lib/reporters/json.js +254 -0
  194. package/lib/reporters/json.js.map +7 -0
  195. package/lib/reporters/junit.js +230 -0
  196. package/lib/reporters/junit.js.map +7 -0
  197. package/lib/reporters/line.js +113 -0
  198. package/lib/reporters/line.js.map +7 -0
  199. package/lib/reporters/list.js +235 -0
  200. package/lib/reporters/list.js.map +7 -0
  201. package/lib/reporters/listModeReporter.js +69 -0
  202. package/lib/reporters/listModeReporter.js.map +7 -0
  203. package/lib/reporters/markdown.js +144 -0
  204. package/lib/reporters/markdown.js.map +7 -0
  205. package/lib/reporters/merge.js +535 -0
  206. package/lib/reporters/merge.js.map +7 -0
  207. package/lib/reporters/multiplexer.js +104 -0
  208. package/lib/reporters/multiplexer.js.map +7 -0
  209. package/lib/reporters/reporterV2.js +102 -0
  210. package/lib/reporters/reporterV2.js.map +7 -0
  211. package/lib/reporters/teleEmitter.js +297 -0
  212. package/lib/reporters/teleEmitter.js.map +7 -0
  213. package/lib/reporters/versions/blobV1.js +16 -0
  214. package/lib/reporters/versions/blobV1.js.map +7 -0
  215. package/lib/runner/dispatcher.js +491 -0
  216. package/lib/runner/dispatcher.js.map +7 -0
  217. package/lib/runner/failureTracker.js +72 -0
  218. package/lib/runner/failureTracker.js.map +7 -0
  219. package/lib/runner/lastRun.js +77 -0
  220. package/lib/runner/lastRun.js.map +7 -0
  221. package/lib/runner/loadUtils.js +333 -0
  222. package/lib/runner/loadUtils.js.map +7 -0
  223. package/lib/runner/loaderHost.js +89 -0
  224. package/lib/runner/loaderHost.js.map +7 -0
  225. package/lib/runner/processHost.js +161 -0
  226. package/lib/runner/processHost.js.map +7 -0
  227. package/lib/runner/projectUtils.js +241 -0
  228. package/lib/runner/projectUtils.js.map +7 -0
  229. package/lib/runner/rebase.js +189 -0
  230. package/lib/runner/rebase.js.map +7 -0
  231. package/lib/runner/reporters.js +137 -0
  232. package/lib/runner/reporters.js.map +7 -0
  233. package/lib/runner/runner.js +173 -0
  234. package/lib/runner/sigIntWatcher.js +96 -0
  235. package/lib/runner/sigIntWatcher.js.map +7 -0
  236. package/lib/runner/taskRunner.js +127 -0
  237. package/lib/runner/taskRunner.js.map +7 -0
  238. package/lib/runner/tasks.js +410 -0
  239. package/lib/runner/tasks.js.map +7 -0
  240. package/lib/runner/testGroups.js +117 -0
  241. package/lib/runner/testGroups.js.map +7 -0
  242. package/lib/runner/testRunner.js +390 -0
  243. package/lib/runner/testRunner.js.map +7 -0
  244. package/lib/runner/testServer.js +264 -0
  245. package/lib/runner/testServer.js.map +7 -0
  246. package/lib/runner/uiMode.js +271 -0
  247. package/lib/runner/uiModeReporter.js +30 -0
  248. package/lib/runner/uiModeReporter.js.map +7 -0
  249. package/lib/runner/vcs.js +72 -0
  250. package/lib/runner/vcs.js.map +7 -0
  251. package/lib/runner/watchMode.js +395 -0
  252. package/lib/runner/watchMode.js.map +7 -0
  253. package/lib/runner/workerHost.js +95 -0
  254. package/lib/runner/workerHost.js.map +7 -0
  255. package/lib/store.js +98 -0
  256. package/lib/third_party/pirates.js +62 -0
  257. package/lib/third_party/pirates.js.map +7 -0
  258. package/lib/third_party/tsconfig-loader.js +103 -0
  259. package/lib/third_party/tsconfig-loader.js.map +7 -0
  260. package/lib/transform/babelBundle.js +43 -0
  261. package/lib/transform/babelBundle.js.map +7 -0
  262. package/lib/transform/babelBundleImpl.js +461 -0
  263. package/lib/transform/babelBundleImpl.js.map +7 -0
  264. package/lib/transform/compilationCache.js +272 -0
  265. package/lib/transform/compilationCache.js.map +7 -0
  266. package/lib/transform/esmLoader.js +104 -0
  267. package/lib/transform/esmLoader.js.map +7 -0
  268. package/lib/transform/esmUtils.js +32 -0
  269. package/lib/transform/portTransport.js +67 -0
  270. package/lib/transform/portTransport.js.map +7 -0
  271. package/lib/transform/transform.js +293 -0
  272. package/lib/transform/transform.js.map +7 -0
  273. package/lib/util.js +403 -0
  274. package/lib/util.js.map +7 -0
  275. package/lib/utilsBundle.js +43 -0
  276. package/lib/utilsBundle.js.map +7 -0
  277. package/lib/utilsBundleImpl.js +100 -0
  278. package/lib/utilsBundleImpl.js.map +7 -0
  279. package/lib/worker/fixtureRunner.js +258 -0
  280. package/lib/worker/fixtureRunner.js.map +7 -0
  281. package/lib/worker/stepContext.js +34 -0
  282. package/lib/worker/testInfo.js +508 -0
  283. package/lib/worker/testInfo.js.map +7 -0
  284. package/lib/worker/testTracing.js +344 -0
  285. package/lib/worker/testTracing.js.map +7 -0
  286. package/lib/worker/timeoutManager.js +174 -0
  287. package/lib/worker/timeoutManager.js.map +7 -0
  288. package/lib/worker/util.js +31 -0
  289. package/lib/worker/util.js.map +7 -0
  290. package/lib/worker/workerMain.js +520 -0
  291. package/lib/worker/workerMain.js.map +7 -0
  292. package/package.json +74 -0
  293. package/test.d.ts +18 -0
  294. package/test.js +24 -0
  295. package/test.mjs +33 -0
  296. package/types/test.d.ts +10217 -0
  297. package/types/testReporter.d.ts +816 -0
package/cli.js ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Copyright (c) Microsoft Corporation.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ const { program } = require('./lib/program');
19
+ program.parse(process.argv);
package/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ export * from 'playwright-core';
package/index.js ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ module.exports = require('playwright-core');
package/index.mjs ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export * from 'playwright-core';
17
+ import playwright from 'playwright-core';
18
+ export default playwright;
package/jsx-runtime.js ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ function jsx(type, props, key) {
18
+ return {
19
+ __pw_type: 'jsx',
20
+ type,
21
+ props,
22
+ key,
23
+ };
24
+ }
25
+
26
+ function jsxs(type, props, key) {
27
+ return {
28
+ __pw_type: 'jsx',
29
+ type,
30
+ props,
31
+ key,
32
+ };
33
+ }
34
+
35
+ // this is used in <></> notation
36
+ const Fragment = { __pw_jsx_fragment: true };
37
+
38
+ module.exports = {
39
+ Fragment,
40
+ jsx,
41
+ jsxs,
42
+ };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) Microsoft Corporation.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import jsxRuntime from './jsx-runtime.js';
18
+
19
+ export const jsx = jsxRuntime.jsx;
20
+ export const jsxs = jsxRuntime.jsxs;
21
+ export const Fragment = jsxRuntime.Fragment;
@@ -0,0 +1,265 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var generateAgents_exports = {};
30
+ __export(generateAgents_exports, {
31
+ initClaudeCodeRepo: () => initClaudeCodeRepo,
32
+ initOpencodeRepo: () => initOpencodeRepo,
33
+ initVSCodeRepo: () => initVSCodeRepo
34
+ });
35
+ module.exports = __toCommonJS(generateAgents_exports);
36
+ var import_fs = __toESM(require("fs"));
37
+ var import_path = __toESM(require("path"));
38
+ var import_utilsBundle = require("playwright-core/lib/utilsBundle");
39
+ class AgentParser {
40
+ static async parseFile(filePath) {
41
+ const rawMarkdown = await import_fs.default.promises.readFile(filePath, "utf-8");
42
+ const { header, content } = this.extractYamlAndContent(rawMarkdown);
43
+ const { instructions, examples } = this.extractInstructionsAndExamples(content);
44
+ return { header, instructions, examples };
45
+ }
46
+ static extractYamlAndContent(markdown) {
47
+ const lines = markdown.split("\n");
48
+ if (lines[0] !== "---")
49
+ throw new Error("Markdown file must start with YAML front matter (---)");
50
+ let yamlEndIndex = -1;
51
+ for (let i = 1; i < lines.length; i++) {
52
+ if (lines[i] === "---") {
53
+ yamlEndIndex = i;
54
+ break;
55
+ }
56
+ }
57
+ if (yamlEndIndex === -1)
58
+ throw new Error("YAML front matter must be closed with ---");
59
+ const yamlLines = lines.slice(1, yamlEndIndex);
60
+ const yamlRaw = yamlLines.join("\n");
61
+ const contentLines = lines.slice(yamlEndIndex + 1);
62
+ const content = contentLines.join("\n");
63
+ let header;
64
+ try {
65
+ header = import_utilsBundle.yaml.parse(yamlRaw);
66
+ } catch (error) {
67
+ throw new Error(`Failed to parse YAML header: ${error.message}`);
68
+ }
69
+ if (!header.name)
70
+ throw new Error('YAML header must contain a "name" field');
71
+ if (!header.description)
72
+ throw new Error('YAML header must contain a "description" field');
73
+ return { header, content };
74
+ }
75
+ static extractInstructionsAndExamples(content) {
76
+ const examples = [];
77
+ const instructions = content.split("<example>")[0].trim();
78
+ const exampleRegex = /<example>([\s\S]*?)<\/example>/g;
79
+ let match;
80
+ while ((match = exampleRegex.exec(content)) !== null) {
81
+ const example = match[1].trim();
82
+ examples.push(example.replace(/[\n]/g, " ").replace(/ +/g, " "));
83
+ }
84
+ return { instructions, examples };
85
+ }
86
+ }
87
+ const claudeToolMap = /* @__PURE__ */ new Map([
88
+ ["ls", ["Glob"]],
89
+ ["grep", ["Grep"]],
90
+ ["read", ["Read"]],
91
+ ["edit", ["Edit", "MultiEdit"]],
92
+ ["write", ["Write"]]
93
+ ]);
94
+ const commonMcpServers = {
95
+ playwrightTest: {
96
+ type: "local",
97
+ command: "npx",
98
+ args: ["playwright", "run-test-mcp-server"]
99
+ }
100
+ };
101
+ function saveAsClaudeCode(agent) {
102
+ function asClaudeTool(tool) {
103
+ const [first, second] = tool.split("/");
104
+ if (!second)
105
+ return (claudeToolMap.get(first) || [first]).join(", ");
106
+ return `mcp__${first}__${second}`;
107
+ }
108
+ const lines = [];
109
+ lines.push(`---`);
110
+ lines.push(`name: playwright-test-${agent.header.name}`);
111
+ lines.push(`description: ${agent.header.description}. Examples: ${agent.examples.map((example) => `<example>${example}</example>`).join("")}`);
112
+ lines.push(`tools: ${agent.header.tools.map((tool) => asClaudeTool(tool)).join(", ")}`);
113
+ lines.push(`model: ${agent.header.model}`);
114
+ lines.push(`color: ${agent.header.color}`);
115
+ lines.push(`---`);
116
+ lines.push("");
117
+ lines.push(agent.instructions);
118
+ return lines.join("\n");
119
+ }
120
+ const opencodeToolMap = /* @__PURE__ */ new Map([
121
+ ["ls", ["ls", "glob"]],
122
+ ["grep", ["grep"]],
123
+ ["read", ["read"]],
124
+ ["edit", ["edit"]],
125
+ ["write", ["write"]]
126
+ ]);
127
+ function saveAsOpencodeJson(agents) {
128
+ function asOpencodeTool(tools, tool) {
129
+ const [first, second] = tool.split("/");
130
+ if (!second) {
131
+ for (const tool2 of opencodeToolMap.get(first) || [first])
132
+ tools[tool2] = true;
133
+ } else {
134
+ tools[`${first}*${second}`] = true;
135
+ }
136
+ }
137
+ const result = {};
138
+ result["$schema"] = "https://opencode.ai/config.json";
139
+ result["mcp"] = {};
140
+ result["tools"] = {
141
+ "playwright*": false
142
+ };
143
+ result["agent"] = {};
144
+ for (const agent of agents) {
145
+ const tools = {};
146
+ result["agent"]["playwright-test-" + agent.header.name] = {
147
+ description: agent.header.description,
148
+ mode: "subagent",
149
+ prompt: `{file:.opencode/prompts/playwright-test-${agent.header.name}.md}`,
150
+ tools
151
+ };
152
+ for (const tool of agent.header.tools)
153
+ asOpencodeTool(tools, tool);
154
+ }
155
+ const server = commonMcpServers.playwrightTest;
156
+ result["mcp"]["playwright-test"] = {
157
+ type: server.type,
158
+ command: [server.command, ...server.args],
159
+ enabled: true
160
+ };
161
+ return JSON.stringify(result, null, 2);
162
+ }
163
+ async function loadAgents() {
164
+ const files = await import_fs.default.promises.readdir(__dirname);
165
+ return Promise.all(files.filter((file) => file.endsWith(".md")).map((file) => AgentParser.parseFile(import_path.default.join(__dirname, file))));
166
+ }
167
+ async function writeFile(filePath, content) {
168
+ console.log(`Writing file: ${filePath}`);
169
+ await import_fs.default.promises.writeFile(filePath, content, "utf-8");
170
+ }
171
+ async function initClaudeCodeRepo() {
172
+ const agents = await loadAgents();
173
+ await import_fs.default.promises.mkdir(".claude/agents", { recursive: true });
174
+ for (const agent of agents)
175
+ await writeFile(`.claude/agents/playwright-test-${agent.header.name}.md`, saveAsClaudeCode(agent));
176
+ await writeFile(".mcp.json", JSON.stringify({
177
+ mcpServers: {
178
+ "playwright-test": {
179
+ command: commonMcpServers.playwrightTest.command,
180
+ args: commonMcpServers.playwrightTest.args
181
+ }
182
+ }
183
+ }, null, 2));
184
+ }
185
+ const vscodeToolMap = /* @__PURE__ */ new Map([
186
+ ["ls", ["search/listDirectory", "search/fileSearch"]],
187
+ ["grep", ["search/textSearch"]],
188
+ ["read", ["search/readFile"]],
189
+ ["edit", ["edit/editFiles"]],
190
+ ["write", ["edit/createFile", "edit/createDirectory"]]
191
+ ]);
192
+ const vscodeToolsOrder = ["edit/createFile", "edit/createDirectory", "edit/editFiles", "search/fileSearch", "search/textSearch", "search/listDirectory", "search/readFile"];
193
+ const vscodeMcpName = "playwright-test";
194
+ function saveAsVSCodeChatmode(agent) {
195
+ function asVscodeTool(tool) {
196
+ const [first, second] = tool.split("/");
197
+ if (second)
198
+ return `${vscodeMcpName}/${second}`;
199
+ return vscodeToolMap.get(first) || first;
200
+ }
201
+ const tools = agent.header.tools.map(asVscodeTool).flat().sort((a, b) => {
202
+ const indexA = vscodeToolsOrder.indexOf(a);
203
+ const indexB = vscodeToolsOrder.indexOf(b);
204
+ if (indexA === -1 && indexB === -1)
205
+ return a.localeCompare(b);
206
+ if (indexA === -1)
207
+ return 1;
208
+ if (indexB === -1)
209
+ return -1;
210
+ return indexA - indexB;
211
+ }).map((tool) => `'${tool}'`).join(", ");
212
+ const lines = [];
213
+ lines.push(`---`);
214
+ lines.push(`description: ${agent.header.description}.`);
215
+ lines.push(`tools: [${tools}]`);
216
+ lines.push(`---`);
217
+ lines.push("");
218
+ lines.push(agent.instructions);
219
+ for (const example of agent.examples)
220
+ lines.push(`<example>${example}</example>`);
221
+ return lines.join("\n");
222
+ }
223
+ async function initVSCodeRepo() {
224
+ const agents = await loadAgents();
225
+ await import_fs.default.promises.mkdir(".github/chatmodes", { recursive: true });
226
+ for (const agent of agents)
227
+ await writeFile(`.github/chatmodes/${agent.header.name === "planner" ? " " : ""}\u{1F3AD} ${agent.header.name}.chatmode.md`, saveAsVSCodeChatmode(agent));
228
+ await import_fs.default.promises.mkdir(".vscode", { recursive: true });
229
+ const mcpJsonPath = ".vscode/mcp.json";
230
+ let mcpJson = {
231
+ servers: {},
232
+ inputs: []
233
+ };
234
+ try {
235
+ mcpJson = JSON.parse(import_fs.default.readFileSync(mcpJsonPath, "utf8"));
236
+ } catch {
237
+ }
238
+ if (!mcpJson.servers)
239
+ mcpJson.servers = {};
240
+ mcpJson.servers["playwright-test"] = {
241
+ type: "stdio",
242
+ command: commonMcpServers.playwrightTest.command,
243
+ args: commonMcpServers.playwrightTest.args,
244
+ cwd: "${workspaceFolder}"
245
+ };
246
+ await writeFile(mcpJsonPath, JSON.stringify(mcpJson, null, 2));
247
+ console.log(import_utilsBundle.colors.yellow(`${import_utilsBundle.colors.bold("Note:")} Playwright Test Agents require VSCode version 1.105+ or VSCode Insiders`));
248
+ }
249
+ async function initOpencodeRepo() {
250
+ const agents = await loadAgents();
251
+ await import_fs.default.promises.mkdir(".opencode/prompts", { recursive: true });
252
+ for (const agent of agents) {
253
+ const prompt = [agent.instructions];
254
+ prompt.push("");
255
+ prompt.push(...agent.examples.map((example) => `<example>${example}</example>`));
256
+ await writeFile(`.opencode/prompts/playwright-test-${agent.header.name}.md`, prompt.join("\n"));
257
+ }
258
+ await writeFile("opencode.json", saveAsOpencodeJson(agents));
259
+ }
260
+ // Annotate the CommonJS export names for ESM import in node:
261
+ 0 && (module.exports = {
262
+ initClaudeCodeRepo,
263
+ initOpencodeRepo,
264
+ initVSCodeRepo
265
+ });
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: generator
3
+ description: Use this agent when you need to create automated browser tests using Playwright
4
+ model: sonnet
5
+ color: blue
6
+ tools:
7
+ - ls
8
+ - grep
9
+ - read
10
+ - playwright-test/browser_click
11
+ - playwright-test/browser_drag
12
+ - playwright-test/browser_evaluate
13
+ - playwright-test/browser_file_upload
14
+ - playwright-test/browser_handle_dialog
15
+ - playwright-test/browser_hover
16
+ - playwright-test/browser_navigate
17
+ - playwright-test/browser_press_key
18
+ - playwright-test/browser_select_option
19
+ - playwright-test/browser_snapshot
20
+ - playwright-test/browser_type
21
+ - playwright-test/browser_verify_element_visible
22
+ - playwright-test/browser_verify_list_visible
23
+ - playwright-test/browser_verify_text_visible
24
+ - playwright-test/browser_verify_value
25
+ - playwright-test/browser_wait_for
26
+ - playwright-test/generator_read_log
27
+ - playwright-test/generator_setup_page
28
+ - playwright-test/generator_write_test
29
+ ---
30
+
31
+ You are a Playwright Test Generator, an expert in browser automation and end-to-end testing.
32
+ Your specialty is creating robust, reliable Playwright tests that accurately simulate user interactions and validate
33
+ application behavior.
34
+
35
+ # For each test you generate
36
+ - Obtain the test plan with all the steps and verification specification
37
+ - Run the `generator_setup_page` tool to set up page for the scenario
38
+ - For each step and verification in the scenario, do the following:
39
+ - Use Playwright tool to manually execute it in real-time.
40
+ - Use the step description as the intent for each Playwright tool call.
41
+ - Retrieve generator log via `generator_read_log`
42
+ - Immediately after reading the test log, invoke `generator_write_test` with the generated source code
43
+ - File should contain single test
44
+ - File name must be fs-friendly scenario name
45
+ - Test must be placed in a describe matching the top-level test plan item
46
+ - Test title must match the scenario name
47
+ - Includes a comment with the step text before each step execution. Do not duplicate comments if step requires
48
+ multiple actions.
49
+ - Always use best practices from the log when generating tests.
50
+
51
+ <example-generation>
52
+ For following plan:
53
+
54
+ ```markdown file=specs/plan.md
55
+ ### 1. Adding New Todos
56
+ **Seed:** `tests/seed.spec.ts`
57
+
58
+ #### 1.1 Add Valid Todo
59
+ **Steps:**
60
+ 1. Click in the "What needs to be done?" input field
61
+
62
+ #### 1.2 Add Multiple Todos
63
+ ...
64
+ ```
65
+
66
+ Following file is generated:
67
+
68
+ ```ts file=add-valid-todo.spec.ts
69
+ // spec: specs/plan.md
70
+ // seed: tests/seed.spec.ts
71
+
72
+ test.describe('Adding New Todos', () => {
73
+ test('Add Valid Todo', async { page } => {
74
+ // 1. Click in the "What needs to be done?" input field
75
+ await page.click(...);
76
+
77
+ ...
78
+ });
79
+ });
80
+ ```
81
+ </example-generation>
82
+
83
+ <example>
84
+ Context: User wants to test a login flow on their web application.
85
+ user: 'I need a test that logs into my app at localhost:3000 with username admin@test.com and password 123456, then
86
+ verifies the dashboard page loads'
87
+ assistant: 'I'll use the generator agent to create and validate this login test for you'
88
+ <commentary>
89
+ The user needs a specific browser automation test created, which is exactly what the generator agent
90
+ is designed for.
91
+ </commentary>
92
+ </example>
93
+ <example>
94
+ Context: User has built a new checkout flow and wants to ensure it works correctly.
95
+ user: 'Can you create a test that adds items to cart, proceeds to checkout, fills in payment details, and confirms the
96
+ order?'
97
+ assistant: 'I'll use the generator agent to build a comprehensive checkout flow test'
98
+ <commentary>
99
+ This is a complex user journey that needs to be automated and tested, perfect for the generator
100
+ agent.
101
+ </commentary>
102
+ </example>
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: healer
3
+ description: Use this agent when you need to debug and fix failing Playwright tests
4
+ color: red
5
+ model: sonnet
6
+ tools:
7
+ - ls
8
+ - grep
9
+ - read
10
+ - write
11
+ - edit
12
+ - playwright-test/browser_console_messages
13
+ - playwright-test/browser_evaluate
14
+ - playwright-test/browser_generate_locator
15
+ - playwright-test/browser_network_requests
16
+ - playwright-test/browser_snapshot
17
+ - playwright-test/test_debug
18
+ - playwright-test/test_list
19
+ - playwright-test/test_run
20
+ ---
21
+
22
+ You are the Playwright Test Healer, an expert test automation engineer specializing in debugging and
23
+ resolving Playwright test failures. Your mission is to systematically identify, diagnose, and fix
24
+ broken Playwright tests using a methodical approach.
25
+
26
+ Your workflow:
27
+ 1. **Initial Execution**: Run all tests using playwright_test_run_test tool to identify failing tests
28
+ 2. **Debug failed tests**: For each failing test run playwright_test_debug_test.
29
+ 3. **Error Investigation**: When the test pauses on errors, use available Playwright MCP tools to:
30
+ - Examine the error details
31
+ - Capture page snapshot to understand the context
32
+ - Analyze selectors, timing issues, or assertion failures
33
+ 4. **Root Cause Analysis**: Determine the underlying cause of the failure by examining:
34
+ - Element selectors that may have changed
35
+ - Timing and synchronization issues
36
+ - Data dependencies or test environment problems
37
+ - Application changes that broke test assumptions
38
+ 5. **Code Remediation**: Edit the test code to address identified issues, focusing on:
39
+ - Updating selectors to match current application state
40
+ - Fixing assertions and expected values
41
+ - Improving test reliability and maintainability
42
+ - For inherently dynamic data, utilize regular expressions to produce resilient locators
43
+ 6. **Verification**: Restart the test after each fix to validate the changes
44
+ 7. **Iteration**: Repeat the investigation and fixing process until the test passes cleanly
45
+
46
+ Key principles:
47
+ - Be systematic and thorough in your debugging approach
48
+ - Document your findings and reasoning for each fix
49
+ - Prefer robust, maintainable solutions over quick hacks
50
+ - Use Playwright best practices for reliable test automation
51
+ - If multiple errors exist, fix them one at a time and retest
52
+ - Provide clear explanations of what was broken and how you fixed it
53
+ - You will continue this process until the test runs successfully without any failures or errors.
54
+ - If the error persists and you have high level of confidence that the test is correct, mark this test as test.fixme()
55
+ so that it is skipped during the execution. Add a comment before the failing step explaining what is happening instead
56
+ of the expected behavior.
57
+ - Do not ask user questions, you are not interactive tool, do the most reasonable thing possible to pass the test.
58
+ - Never wait for networkidle or use other discouraged or deprecated apis
59
+
60
+ <example>
61
+ Context: A developer has a failing Playwright test that needs to be debugged and fixed.
62
+ user: 'The login test is failing, can you fix it?'
63
+ assistant: 'I'll use the healer agent to debug and fix the failing login test.'
64
+ <commentary>
65
+ The user has identified a specific failing test that needs debugging and fixing, which is exactly what the
66
+ healer agent is designed for.
67
+ </commentary>
68
+ </example>
69
+
70
+ <example>
71
+ Context: After running a test suite, several tests are reported as failing.
72
+ user: 'Test user-registration.spec.ts is broken after the recent changes'
73
+ assistant: 'Let me use the healer agent to investigate and fix the user-registration test.'
74
+ <commentary>
75
+ A specific test file is failing and needs debugging, which requires the systematic approach of the
76
+ playwright-test-healer agent.
77
+ </commentary>
78
+ </example>