@empiricalrun/playwright-utils 0.23.0 → 0.23.1

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 (273) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/package.json +2 -2
  3. package/bundled/test-gen/actions/assert.d.ts +0 -4
  4. package/bundled/test-gen/actions/assert.d.ts.map +0 -1
  5. package/bundled/test-gen/actions/assert.js +0 -50
  6. package/bundled/test-gen/actions/click.d.ts +0 -4
  7. package/bundled/test-gen/actions/click.d.ts.map +0 -1
  8. package/bundled/test-gen/actions/click.js +0 -51
  9. package/bundled/test-gen/actions/constants/index.d.ts +0 -2
  10. package/bundled/test-gen/actions/constants/index.d.ts.map +0 -1
  11. package/bundled/test-gen/actions/constants/index.js +0 -4
  12. package/bundled/test-gen/actions/done.d.ts +0 -4
  13. package/bundled/test-gen/actions/done.d.ts.map +0 -1
  14. package/bundled/test-gen/actions/done.js +0 -30
  15. package/bundled/test-gen/actions/fill.d.ts +0 -4
  16. package/bundled/test-gen/actions/fill.d.ts.map +0 -1
  17. package/bundled/test-gen/actions/fill.js +0 -82
  18. package/bundled/test-gen/actions/goto.d.ts +0 -4
  19. package/bundled/test-gen/actions/goto.d.ts.map +0 -1
  20. package/bundled/test-gen/actions/goto.js +0 -47
  21. package/bundled/test-gen/actions/hover.d.ts +0 -4
  22. package/bundled/test-gen/actions/hover.d.ts.map +0 -1
  23. package/bundled/test-gen/actions/hover.js +0 -51
  24. package/bundled/test-gen/actions/index.d.ts +0 -30
  25. package/bundled/test-gen/actions/index.d.ts.map +0 -1
  26. package/bundled/test-gen/actions/index.js +0 -159
  27. package/bundled/test-gen/actions/next-task.d.ts +0 -53
  28. package/bundled/test-gen/actions/next-task.d.ts.map +0 -1
  29. package/bundled/test-gen/actions/next-task.js +0 -58
  30. package/bundled/test-gen/actions/press.d.ts +0 -4
  31. package/bundled/test-gen/actions/press.d.ts.map +0 -1
  32. package/bundled/test-gen/actions/press.js +0 -56
  33. package/bundled/test-gen/actions/skill.d.ts +0 -21
  34. package/bundled/test-gen/actions/skill.d.ts.map +0 -1
  35. package/bundled/test-gen/actions/skill.js +0 -127
  36. package/bundled/test-gen/actions/text-content.d.ts +0 -4
  37. package/bundled/test-gen/actions/text-content.d.ts.map +0 -1
  38. package/bundled/test-gen/actions/text-content.js +0 -58
  39. package/bundled/test-gen/actions/utils/index.d.ts +0 -10
  40. package/bundled/test-gen/actions/utils/index.d.ts.map +0 -1
  41. package/bundled/test-gen/actions/utils/index.js +0 -109
  42. package/bundled/test-gen/agent/browsing/index.d.ts +0 -15
  43. package/bundled/test-gen/agent/browsing/index.d.ts.map +0 -1
  44. package/bundled/test-gen/agent/browsing/index.js +0 -68
  45. package/bundled/test-gen/agent/browsing/run.d.ts +0 -19
  46. package/bundled/test-gen/agent/browsing/run.d.ts.map +0 -1
  47. package/bundled/test-gen/agent/browsing/run.js +0 -88
  48. package/bundled/test-gen/agent/browsing/utils.d.ts +0 -41
  49. package/bundled/test-gen/agent/browsing/utils.d.ts.map +0 -1
  50. package/bundled/test-gen/agent/browsing/utils.js +0 -406
  51. package/bundled/test-gen/agent/codegen/create-test-block.d.ts +0 -9
  52. package/bundled/test-gen/agent/codegen/create-test-block.d.ts.map +0 -1
  53. package/bundled/test-gen/agent/codegen/create-test-block.js +0 -63
  54. package/bundled/test-gen/agent/codegen/fix-ts-errors.d.ts +0 -13
  55. package/bundled/test-gen/agent/codegen/fix-ts-errors.d.ts.map +0 -1
  56. package/bundled/test-gen/agent/codegen/fix-ts-errors.js +0 -80
  57. package/bundled/test-gen/agent/codegen/generate-code-apply-changes.d.ts +0 -13
  58. package/bundled/test-gen/agent/codegen/generate-code-apply-changes.d.ts.map +0 -1
  59. package/bundled/test-gen/agent/codegen/generate-code-apply-changes.js +0 -381
  60. package/bundled/test-gen/agent/codegen/lexical-scoped-vars.d.ts +0 -9
  61. package/bundled/test-gen/agent/codegen/lexical-scoped-vars.d.ts.map +0 -1
  62. package/bundled/test-gen/agent/codegen/lexical-scoped-vars.js +0 -56
  63. package/bundled/test-gen/agent/codegen/repo-edit.d.ts +0 -23
  64. package/bundled/test-gen/agent/codegen/repo-edit.d.ts.map +0 -1
  65. package/bundled/test-gen/agent/codegen/repo-edit.js +0 -86
  66. package/bundled/test-gen/agent/codegen/run.d.ts +0 -16
  67. package/bundled/test-gen/agent/codegen/run.d.ts.map +0 -1
  68. package/bundled/test-gen/agent/codegen/run.js +0 -119
  69. package/bundled/test-gen/agent/codegen/skills-retriever.d.ts +0 -26
  70. package/bundled/test-gen/agent/codegen/skills-retriever.d.ts.map +0 -1
  71. package/bundled/test-gen/agent/codegen/skills-retriever.js +0 -93
  72. package/bundled/test-gen/agent/codegen/test-update-feedback.d.ts +0 -12
  73. package/bundled/test-gen/agent/codegen/test-update-feedback.d.ts.map +0 -1
  74. package/bundled/test-gen/agent/codegen/test-update-feedback.js +0 -50
  75. package/bundled/test-gen/agent/codegen/types.d.ts +0 -25
  76. package/bundled/test-gen/agent/codegen/types.d.ts.map +0 -1
  77. package/bundled/test-gen/agent/codegen/types.js +0 -8
  78. package/bundled/test-gen/agent/codegen/update-flow.d.ts +0 -34
  79. package/bundled/test-gen/agent/codegen/update-flow.d.ts.map +0 -1
  80. package/bundled/test-gen/agent/codegen/update-flow.js +0 -300
  81. package/bundled/test-gen/agent/codegen/use-skill.d.ts +0 -11
  82. package/bundled/test-gen/agent/codegen/use-skill.d.ts.map +0 -1
  83. package/bundled/test-gen/agent/codegen/use-skill.js +0 -54
  84. package/bundled/test-gen/agent/codegen/utils.d.ts +0 -126
  85. package/bundled/test-gen/agent/codegen/utils.d.ts.map +0 -1
  86. package/bundled/test-gen/agent/codegen/utils.js +0 -416
  87. package/bundled/test-gen/agent/diagnosis-agent/index.d.ts +0 -18
  88. package/bundled/test-gen/agent/diagnosis-agent/index.d.ts.map +0 -1
  89. package/bundled/test-gen/agent/diagnosis-agent/index.js +0 -105
  90. package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.d.ts +0 -9
  91. package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.d.ts.map +0 -1
  92. package/bundled/test-gen/agent/diagnosis-agent/strict-mode-violation.js +0 -31
  93. package/bundled/test-gen/agent/enrich-prompt/index.d.ts +0 -12
  94. package/bundled/test-gen/agent/enrich-prompt/index.d.ts.map +0 -1
  95. package/bundled/test-gen/agent/enrich-prompt/index.js +0 -81
  96. package/bundled/test-gen/agent/enrich-prompt/utils.d.ts +0 -6
  97. package/bundled/test-gen/agent/enrich-prompt/utils.d.ts.map +0 -1
  98. package/bundled/test-gen/agent/enrich-prompt/utils.js +0 -12
  99. package/bundled/test-gen/agent/infer-agent/index.d.ts +0 -10
  100. package/bundled/test-gen/agent/infer-agent/index.d.ts.map +0 -1
  101. package/bundled/test-gen/agent/infer-agent/index.js +0 -70
  102. package/bundled/test-gen/agent/master/action-tool-calls.d.ts +0 -42
  103. package/bundled/test-gen/agent/master/action-tool-calls.d.ts.map +0 -1
  104. package/bundled/test-gen/agent/master/action-tool-calls.js +0 -87
  105. package/bundled/test-gen/agent/master/browser-tests/fixtures.d.ts +0 -9
  106. package/bundled/test-gen/agent/master/browser-tests/fixtures.d.ts.map +0 -1
  107. package/bundled/test-gen/agent/master/browser-tests/fixtures.js +0 -33
  108. package/bundled/test-gen/agent/master/browser-tests/index.spec.d.ts +0 -2
  109. package/bundled/test-gen/agent/master/browser-tests/index.spec.d.ts.map +0 -1
  110. package/bundled/test-gen/agent/master/browser-tests/index.spec.js +0 -113
  111. package/bundled/test-gen/agent/master/browser-tests/skills.spec.d.ts +0 -2
  112. package/bundled/test-gen/agent/master/browser-tests/skills.spec.d.ts.map +0 -1
  113. package/bundled/test-gen/agent/master/browser-tests/skills.spec.js +0 -109
  114. package/bundled/test-gen/agent/master/element-annotation.d.ts +0 -30
  115. package/bundled/test-gen/agent/master/element-annotation.d.ts.map +0 -1
  116. package/bundled/test-gen/agent/master/element-annotation.js +0 -195
  117. package/bundled/test-gen/agent/master/execute-browser-action.d.ts +0 -24
  118. package/bundled/test-gen/agent/master/execute-browser-action.d.ts.map +0 -1
  119. package/bundled/test-gen/agent/master/execute-browser-action.js +0 -124
  120. package/bundled/test-gen/agent/master/execute-skill-action.d.ts +0 -11
  121. package/bundled/test-gen/agent/master/execute-skill-action.d.ts.map +0 -1
  122. package/bundled/test-gen/agent/master/execute-skill-action.js +0 -25
  123. package/bundled/test-gen/agent/master/icon-descriptor/index.d.ts +0 -22
  124. package/bundled/test-gen/agent/master/icon-descriptor/index.d.ts.map +0 -1
  125. package/bundled/test-gen/agent/master/icon-descriptor/index.js +0 -250
  126. package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.d.ts +0 -2
  127. package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.d.ts.map +0 -1
  128. package/bundled/test-gen/agent/master/icon-descriptor/normalize-svg.js +0 -248
  129. package/bundled/test-gen/agent/master/next-action.d.ts +0 -22
  130. package/bundled/test-gen/agent/master/next-action.d.ts.map +0 -1
  131. package/bundled/test-gen/agent/master/next-action.js +0 -104
  132. package/bundled/test-gen/agent/master/planner.d.ts +0 -15
  133. package/bundled/test-gen/agent/master/planner.d.ts.map +0 -1
  134. package/bundled/test-gen/agent/master/planner.js +0 -144
  135. package/bundled/test-gen/agent/master/run.d.ts +0 -15
  136. package/bundled/test-gen/agent/master/run.d.ts.map +0 -1
  137. package/bundled/test-gen/agent/master/run.js +0 -274
  138. package/bundled/test-gen/agent/master/scroller.d.ts +0 -15
  139. package/bundled/test-gen/agent/master/scroller.d.ts.map +0 -1
  140. package/bundled/test-gen/agent/master/scroller.js +0 -375
  141. package/bundled/test-gen/agent/master/with-hints.d.ts +0 -17
  142. package/bundled/test-gen/agent/master/with-hints.d.ts.map +0 -1
  143. package/bundled/test-gen/agent/master/with-hints.js +0 -102
  144. package/bundled/test-gen/agent/planner/run-time-planner.d.ts +0 -15
  145. package/bundled/test-gen/agent/planner/run-time-planner.d.ts.map +0 -1
  146. package/bundled/test-gen/agent/planner/run-time-planner.js +0 -100
  147. package/bundled/test-gen/agent/planner/run.d.ts +0 -7
  148. package/bundled/test-gen/agent/planner/run.d.ts.map +0 -1
  149. package/bundled/test-gen/agent/planner/run.js +0 -127
  150. package/bundled/test-gen/agent/utils.d.ts +0 -2
  151. package/bundled/test-gen/agent/utils.d.ts.map +0 -1
  152. package/bundled/test-gen/agent/utils.js +0 -12
  153. package/bundled/test-gen/bin/index.d.ts +0 -3
  154. package/bundled/test-gen/bin/index.d.ts.map +0 -1
  155. package/bundled/test-gen/bin/index.js +0 -212
  156. package/bundled/test-gen/bin/logger/index.d.ts +0 -14
  157. package/bundled/test-gen/bin/logger/index.d.ts.map +0 -1
  158. package/bundled/test-gen/bin/logger/index.js +0 -57
  159. package/bundled/test-gen/bin/utils/context.d.ts +0 -13
  160. package/bundled/test-gen/bin/utils/context.d.ts.map +0 -1
  161. package/bundled/test-gen/bin/utils/context.js +0 -67
  162. package/bundled/test-gen/bin/utils/fs/index.d.ts +0 -6
  163. package/bundled/test-gen/bin/utils/fs/index.d.ts.map +0 -1
  164. package/bundled/test-gen/bin/utils/fs/index.js +0 -63
  165. package/bundled/test-gen/bin/utils/index.d.ts +0 -9
  166. package/bundled/test-gen/bin/utils/index.d.ts.map +0 -1
  167. package/bundled/test-gen/bin/utils/index.js +0 -64
  168. package/bundled/test-gen/bin/utils/platform/web/index.d.ts +0 -78
  169. package/bundled/test-gen/bin/utils/platform/web/index.d.ts.map +0 -1
  170. package/bundled/test-gen/bin/utils/platform/web/index.js +0 -544
  171. package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts +0 -2
  172. package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.d.ts.map +0 -1
  173. package/bundled/test-gen/bin/utils/platform/web/test-files/ts-path-import-validate.js +0 -7
  174. package/bundled/test-gen/bin/utils/scenarios/index.d.ts +0 -6
  175. package/bundled/test-gen/bin/utils/scenarios/index.d.ts.map +0 -1
  176. package/bundled/test-gen/bin/utils/scenarios/index.js +0 -57
  177. package/bundled/test-gen/browser-injected-scripts/annotate-elements.js +0 -615
  178. package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.d.ts +0 -2
  179. package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.d.ts.map +0 -1
  180. package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.js +0 -207
  181. package/bundled/test-gen/browser-injected-scripts/annotate-elements.spec.ts +0 -332
  182. package/bundled/test-gen/constants/index.d.ts +0 -7
  183. package/bundled/test-gen/constants/index.d.ts.map +0 -1
  184. package/bundled/test-gen/constants/index.js +0 -18
  185. package/bundled/test-gen/errors/index.d.ts +0 -5
  186. package/bundled/test-gen/errors/index.d.ts.map +0 -1
  187. package/bundled/test-gen/errors/index.js +0 -9
  188. package/bundled/test-gen/evals/add-scenario-agent.evals.d.ts +0 -4
  189. package/bundled/test-gen/evals/add-scenario-agent.evals.d.ts.map +0 -1
  190. package/bundled/test-gen/evals/add-scenario-agent.evals.js +0 -44
  191. package/bundled/test-gen/evals/append-create-test-agent.evals.d.ts +0 -4
  192. package/bundled/test-gen/evals/append-create-test-agent.evals.d.ts.map +0 -1
  193. package/bundled/test-gen/evals/append-create-test-agent.evals.js +0 -117
  194. package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.d.ts +0 -4
  195. package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.d.ts.map +0 -1
  196. package/bundled/test-gen/evals/fetch-pom-skills-agent.evals.js +0 -36
  197. package/bundled/test-gen/evals/infer-master-or-code-agent.evals.d.ts +0 -4
  198. package/bundled/test-gen/evals/infer-master-or-code-agent.evals.d.ts.map +0 -1
  199. package/bundled/test-gen/evals/infer-master-or-code-agent.evals.js +0 -22
  200. package/bundled/test-gen/evals/master-agent.evals.d.ts +0 -4
  201. package/bundled/test-gen/evals/master-agent.evals.d.ts.map +0 -1
  202. package/bundled/test-gen/evals/master-agent.evals.js +0 -35
  203. package/bundled/test-gen/evals/type.d.ts +0 -12
  204. package/bundled/test-gen/evals/type.d.ts.map +0 -1
  205. package/bundled/test-gen/evals/type.js +0 -2
  206. package/bundled/test-gen/evals/update-scenario-agent.evals.d.ts +0 -4
  207. package/bundled/test-gen/evals/update-scenario-agent.evals.d.ts.map +0 -1
  208. package/bundled/test-gen/evals/update-scenario-agent.evals.js +0 -47
  209. package/bundled/test-gen/file/client.d.ts +0 -14
  210. package/bundled/test-gen/file/client.d.ts.map +0 -1
  211. package/bundled/test-gen/file/client.js +0 -48
  212. package/bundled/test-gen/file/server.d.ts +0 -13
  213. package/bundled/test-gen/file/server.d.ts.map +0 -1
  214. package/bundled/test-gen/file/server.js +0 -52
  215. package/bundled/test-gen/human-in-the-loop/cli.d.ts +0 -2
  216. package/bundled/test-gen/human-in-the-loop/cli.d.ts.map +0 -1
  217. package/bundled/test-gen/human-in-the-loop/cli.js +0 -24
  218. package/bundled/test-gen/human-in-the-loop/index.d.ts +0 -12
  219. package/bundled/test-gen/human-in-the-loop/index.d.ts.map +0 -1
  220. package/bundled/test-gen/human-in-the-loop/index.js +0 -30
  221. package/bundled/test-gen/human-in-the-loop/ipc.d.ts +0 -4
  222. package/bundled/test-gen/human-in-the-loop/ipc.d.ts.map +0 -1
  223. package/bundled/test-gen/human-in-the-loop/ipc.js +0 -47
  224. package/bundled/test-gen/index.d.ts +0 -4
  225. package/bundled/test-gen/index.d.ts.map +0 -1
  226. package/bundled/test-gen/index.js +0 -55
  227. package/bundled/test-gen/package.json +0 -106
  228. package/bundled/test-gen/page/index.d.ts +0 -11
  229. package/bundled/test-gen/page/index.d.ts.map +0 -1
  230. package/bundled/test-gen/page/index.js +0 -16
  231. package/bundled/test-gen/prompts/lib/ts-transformer.d.ts +0 -4
  232. package/bundled/test-gen/prompts/lib/ts-transformer.d.ts.map +0 -1
  233. package/bundled/test-gen/prompts/lib/ts-transformer.js +0 -92
  234. package/bundled/test-gen/reporter/index.d.ts +0 -33
  235. package/bundled/test-gen/reporter/index.d.ts.map +0 -1
  236. package/bundled/test-gen/reporter/index.js +0 -161
  237. package/bundled/test-gen/session/index.d.ts +0 -20
  238. package/bundled/test-gen/session/index.d.ts.map +0 -1
  239. package/bundled/test-gen/session/index.js +0 -105
  240. package/bundled/test-gen/test-build/index.d.ts +0 -10
  241. package/bundled/test-gen/test-build/index.d.ts.map +0 -1
  242. package/bundled/test-gen/test-build/index.js +0 -30
  243. package/bundled/test-gen/types/index.d.ts +0 -69
  244. package/bundled/test-gen/types/index.d.ts.map +0 -1
  245. package/bundled/test-gen/types/index.js +0 -2
  246. package/bundled/test-gen/uploader/index.d.ts +0 -26
  247. package/bundled/test-gen/uploader/index.d.ts.map +0 -1
  248. package/bundled/test-gen/uploader/index.js +0 -102
  249. package/bundled/test-gen/utils/env.d.ts +0 -2
  250. package/bundled/test-gen/utils/env.d.ts.map +0 -1
  251. package/bundled/test-gen/utils/env.js +0 -9
  252. package/bundled/test-gen/utils/exec.d.ts +0 -4
  253. package/bundled/test-gen/utils/exec.d.ts.map +0 -1
  254. package/bundled/test-gen/utils/exec.js +0 -45
  255. package/bundled/test-gen/utils/file.d.ts +0 -2
  256. package/bundled/test-gen/utils/file.d.ts.map +0 -1
  257. package/bundled/test-gen/utils/file.js +0 -25
  258. package/bundled/test-gen/utils/html.d.ts +0 -4
  259. package/bundled/test-gen/utils/html.d.ts.map +0 -1
  260. package/bundled/test-gen/utils/html.js +0 -46
  261. package/bundled/test-gen/utils/index.d.ts +0 -2
  262. package/bundled/test-gen/utils/index.d.ts.map +0 -1
  263. package/bundled/test-gen/utils/index.js +0 -5
  264. package/bundled/test-gen/utils/pw-test.d.ts +0 -3
  265. package/bundled/test-gen/utils/pw-test.d.ts.map +0 -1
  266. package/bundled/test-gen/utils/pw-test.js +0 -26
  267. package/bundled/test-gen/utils/slug.d.ts +0 -2
  268. package/bundled/test-gen/utils/slug.d.ts.map +0 -1
  269. package/bundled/test-gen/utils/slug.js +0 -18
  270. package/bundled/test-gen/utils/string.d.ts +0 -2
  271. package/bundled/test-gen/utils/string.d.ts.map +0 -1
  272. package/bundled/test-gen/utils/string.js +0 -9
  273. package/scripts/prepare-publish.js +0 -42
@@ -1,416 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.applyFileChanges = exports.searchAndReplaceCode = exports.applyFileChangesForCreateTest = exports.searchAndReplaceCodeUsingStrReplace = exports.applyFileChangesUsingStrReplace = exports.validateTypesAndFormatCode = exports.extractTestStepsSuggestions = exports.extractAppendTestUpdates = exports.extractCreateTestUpdates = exports.extractTestUpdates = void 0;
7
- const llm_1 = require("@empiricalrun/llm");
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const ts_morph_1 = require("ts-morph");
10
- const web_1 = require("../../bin/utils/platform/web");
11
- const fix_ts_errors_1 = require("./fix-ts-errors");
12
- /**
13
- *
14
- * method to extract file path and code updates for the LLM response of update flow
15
- * @export
16
- * @param {string} input
17
- * @return {*} {({
18
- * filePath: string | undefined;
19
- * oldCode: string | undefined;
20
- * newCode: string | undefined;
21
- * reason: string | undefined;
22
- * }[])}
23
- */
24
- function extractTestUpdates(input) {
25
- const result = [];
26
- // TODO: use better structure for this. Do not kill me for this please.
27
- const regex = /<file_path>(.*?)<\/file_path>[\s\S]*?<old_code_block>([\s\S]*?)<\/old_code_block>[\s\S]*?<new_code_block>([\s\S]*?)<\/new_code_block>[\s\S]*?<change>([\s\S]*?)<\/change>/g;
28
- let match;
29
- while ((match = regex.exec(input)) !== null) {
30
- const [, filePath, oldCode, newCode, reason] = match;
31
- result.push({
32
- filePath: filePath?.trim(),
33
- oldCode: oldCode?.trim(),
34
- newCode: newCode?.trim(),
35
- reason: reason?.trim(),
36
- });
37
- }
38
- return result;
39
- }
40
- exports.extractTestUpdates = extractTestUpdates;
41
- /**
42
- *
43
- * method to extract file path and code updates for the LLM response of create flow
44
- * @export
45
- * @param {string} input
46
- * @return {*} {({
47
- * filePath: string | undefined;
48
- * code: string | undefined;
49
- * reason: string | undefined;
50
- * }[])}
51
- */
52
- function extractCreateTestUpdates(input) {
53
- const result = [];
54
- // TODO: use better structure for this. Do not kill me for this please.
55
- const regex = /<file_path>(.*?)<\/file_path>[\s\S]*?<code_block>([\s\S]*?)<\/code_block>[\s\S]*?<change>([\s\S]*?)<\/change>/g;
56
- let match;
57
- while ((match = regex.exec(input)) !== null) {
58
- const [, filePath, code, reason] = match;
59
- result.push({
60
- filePath: filePath?.trim(),
61
- code: code?.trim(),
62
- reason: reason?.trim(),
63
- });
64
- }
65
- return result;
66
- }
67
- exports.extractCreateTestUpdates = extractCreateTestUpdates;
68
- /**
69
- *
70
- * method to extract append create test updates
71
- * @export
72
- * @param {string} input
73
- * @return {*} {({
74
- * intent: string | undefined,
75
- * updateLocation: string | undefined,
76
- * filePath: string | undefined;
77
- * oldCode: string | undefined;
78
- * newCode: string | undefined;
79
- * reason: string | undefined;
80
- * }[])}
81
- */
82
- function extractAppendTestUpdates(input) {
83
- const result = [];
84
- // TODO: use better structure for this. Do not kill me for this please.
85
- const regex = /<reason_for_intent>(.*?)<\/reason_for_intent>[\s\S]*?<intent>(.*?)<\/intent>[\s\S]*?<location_of_update>([\s\S]*?)<\/location_of_update>[\s\S]*?<file_path>([\s\S]*?)<\/file_path>[\s\S]*?<old_code_block>([\s\S]*?)<\/old_code_block>[\s\S]*?<new_code_block>([\s\S]*?)<\/new_code_block>[\s\S]*?<change>([\s\S]*?)<\/change>/g;
86
- let match;
87
- while ((match = regex.exec(input)) !== null) {
88
- const [, reasonForIntent, intent, updateLocation, filePath, oldCode, newCode, reason,] = match;
89
- result.push({
90
- reasonForIntent: reasonForIntent?.trim(),
91
- intent: intent?.trim(),
92
- updateLocation: updateLocation?.trim(),
93
- filePath: filePath?.trim(),
94
- oldCode: oldCode?.trim(),
95
- newCode: newCode?.trim(),
96
- reason: reason?.trim(),
97
- });
98
- }
99
- return result;
100
- }
101
- exports.extractAppendTestUpdates = extractAppendTestUpdates;
102
- function extractTestStepsSuggestions(input) {
103
- const result = [];
104
- // Extract all sections with their subtask tags first
105
- const subtaskRegex = /<subtask>([\s\S]*?)<\/subtask>([\s\S]*?)(?=<subtask>|$)/g;
106
- let subtaskMatch;
107
- while ((subtaskMatch = subtaskRegex.exec(input)) !== null) {
108
- const [, testStepText = "", content = ""] = subtaskMatch;
109
- // Extract individual tag content regardless of order
110
- const reasonMatch = /<reason>([\s\S]*?)<\/reason>/i.exec(content);
111
- const filePathMatch = /<file_import_path>([\s\S]*?)<\/file_import_path>/i.exec(content);
112
- const usageExampleMatch = /<usage_example>([\s\S]*?)<\/usage_example>/i.exec(content);
113
- const methodNameMatch = /<method_name>([\s\S]*?)<\/method_name>/i.exec(content);
114
- // Extract values or use empty strings if not found
115
- const reasonText = reasonMatch?.[1] || "";
116
- const filePathText = filePathMatch?.[1] || "";
117
- const usageExampleText = usageExampleMatch?.[1] || "";
118
- const methodNameText = methodNameMatch?.[1] || "";
119
- result.push({
120
- testStep: testStepText.trim(),
121
- filePath: filePathText.trim(),
122
- usageExample: usageExampleText.trim(),
123
- reason: reasonText.trim(),
124
- methodName: methodNameText.trim(),
125
- });
126
- }
127
- return result.filter((r) => !!r.filePath && !!r.usageExample);
128
- }
129
- exports.extractTestStepsSuggestions = extractTestStepsSuggestions;
130
- async function validateTypesAndFormatCode({ validateTypes = true, trace, testCase, filePaths, logger, testGenOptions, pomPrompt, nonSpecFilePrompt, }) {
131
- for (let filePath of filePaths) {
132
- if (!filePath) {
133
- continue;
134
- }
135
- try {
136
- if (validateTypes) {
137
- await (0, fix_ts_errors_1.validateAndFixTypescriptErrors)({
138
- trace,
139
- logger,
140
- file: filePath,
141
- pomCode: pomPrompt ?? "",
142
- nonSpecFileCode: nonSpecFilePrompt ?? "",
143
- testCase: testCase,
144
- options: testGenOptions,
145
- });
146
- }
147
- trace?.event({ name: "format-file" });
148
- await (0, web_1.formatCode)(filePath, trace);
149
- logger?.success(`${filePath} file formatted successfully!`);
150
- }
151
- catch (e) {
152
- console.error(`Error while formatting the file ${filePath}`, e);
153
- }
154
- }
155
- await (0, llm_1.flushAllTraces)();
156
- }
157
- exports.validateTypesAndFormatCode = validateTypesAndFormatCode;
158
- async function applyFileChangesUsingStrReplace({ trace, fileChanges, logger, }) {
159
- const repoEditFileChangesSpan = trace?.span({
160
- name: "repo-edit-file-changes",
161
- });
162
- const results = [];
163
- for (const fileChange of fileChanges) {
164
- if (!fileChange.filePath) {
165
- continue;
166
- }
167
- try {
168
- const readWriteFileSpan = repoEditFileChangesSpan?.span({
169
- name: "write-to-file",
170
- input: {
171
- fileChange,
172
- },
173
- });
174
- const { result, updatedContent } = await searchAndReplaceCode({
175
- logger,
176
- fileChange,
177
- });
178
- if (result.error) {
179
- logger?.error(`Unable to find the code to update in ${result.filePath}, full error:`, result);
180
- }
181
- else {
182
- await fs_extra_1.default.writeFile(fileChange.filePath, updatedContent, "utf-8");
183
- readWriteFileSpan?.end({ output: { updatedContent } });
184
- }
185
- results.push(result);
186
- }
187
- catch (e) {
188
- trace?.event({
189
- name: "repo-edit-file-changes-error",
190
- output: {
191
- filePath: fileChange.filePath,
192
- error: e,
193
- },
194
- });
195
- console.error(`Error while applying changes to file ${fileChange.filePath}`, e);
196
- }
197
- }
198
- return results;
199
- }
200
- exports.applyFileChangesUsingStrReplace = applyFileChangesUsingStrReplace;
201
- async function searchAndReplaceCodeUsingStrReplace({ logger, fileChange, }) {
202
- let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
203
- if (contents.includes(fileChange.oldCode)) {
204
- // Check for multiple instances of old code block
205
- // If there are multiple instances, then we cannot safely determine which instance to replace
206
- const firstIndex = contents.indexOf(fileChange.oldCode);
207
- const lastIndex = contents.lastIndexOf(fileChange.oldCode);
208
- if (firstIndex !== lastIndex) {
209
- return {
210
- result: {
211
- error: true,
212
- errorMessage: `Multiple instances of the code block found in file "${fileChange.filePath}". Cannot safely determine which instance to replace.`,
213
- filePath: fileChange.filePath,
214
- },
215
- updatedContent: contents,
216
- };
217
- }
218
- const updatedContent = contents.replace(fileChange.oldCode, `\n\n${fileChange.newCode}`);
219
- return {
220
- result: {
221
- error: false,
222
- errorMessage: "",
223
- filePath: fileChange.filePath,
224
- },
225
- updatedContent,
226
- };
227
- }
228
- logger?.error(`Unable to find the code to update in ${fileChange.filePath}`);
229
- return {
230
- result: {
231
- error: true,
232
- errorMessage: `The content of "old_code_block" corresponding to file path "${fileChange.filePath}" did not match the current content of the file "${fileChange.filePath}"`,
233
- filePath: fileChange.filePath,
234
- },
235
- updatedContent: contents,
236
- };
237
- }
238
- exports.searchAndReplaceCodeUsingStrReplace = searchAndReplaceCodeUsingStrReplace;
239
- async function applyFileChangesForCreateTest({ trace, fileChanges, testgenUpdatesReporter, }) {
240
- const repoEditFileChangesSpan = trace?.span({
241
- name: "create-test-file-changes",
242
- });
243
- for (const fileChange of fileChanges) {
244
- if (!fileChange.filePath) {
245
- continue;
246
- }
247
- try {
248
- const readWriteFileSpan = repoEditFileChangesSpan?.span({
249
- name: "write-to-file",
250
- input: {
251
- fileChange,
252
- },
253
- });
254
- if (fileChange.code) {
255
- const currentContent = fs_extra_1.default.existsSync(fileChange.filePath)
256
- ? await fs_extra_1.default.readFile(fileChange.filePath, "utf-8")
257
- : "";
258
- await fs_extra_1.default.writeFile(fileChange.filePath, currentContent
259
- ? `${currentContent}\n\n${fileChange.code}`
260
- : fileChange.code, "utf-8");
261
- const updatedFileContent = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
262
- readWriteFileSpan?.end({
263
- output: { fileChange, updatedFile: updatedFileContent },
264
- });
265
- }
266
- }
267
- catch (e) {
268
- trace?.event({
269
- name: "create-test-file-changes-error",
270
- output: {
271
- filePath: fileChange.filePath,
272
- error: e,
273
- },
274
- });
275
- void testgenUpdatesReporter?.sendMessage(`Error while applying changes to file ${fileChange.filePath}, error: ${e}`);
276
- console.error(`Error while applying changes to file ${fileChange.filePath}`, e);
277
- }
278
- }
279
- }
280
- exports.applyFileChangesForCreateTest = applyFileChangesForCreateTest;
281
- async function searchAndReplaceCode({ logger, fileChange, }) {
282
- let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
283
- // since we dont know what is getting updated,
284
- // we believe that the patch is correct and contains few before and after lines
285
- // to make the change unique for search & replace
286
- if (contents.includes(fileChange.oldCode)) {
287
- const updatedContent = contents.replace(fileChange.oldCode, `\n\n${fileChange.newCode}`);
288
- return {
289
- result: {
290
- error: false,
291
- errorMessage: "",
292
- filePath: fileChange.filePath,
293
- },
294
- updatedContent,
295
- };
296
- }
297
- logger?.error(`Unable to find the code to update in ${fileChange.filePath}`);
298
- return {
299
- result: {
300
- error: true,
301
- errorMessage: `The content of "old_code_block" corresponding to file path "${fileChange.filePath}" did not match the current content of the file "${fileChange.filePath}"`,
302
- filePath: fileChange.filePath,
303
- },
304
- updatedContent: contents,
305
- };
306
- }
307
- exports.searchAndReplaceCode = searchAndReplaceCode;
308
- async function applyFileChanges({ trace, testCase, fileChanges, logger, }) {
309
- const results = [];
310
- for (const fileChange of fileChanges) {
311
- if (!fileChange.filePath) {
312
- continue;
313
- }
314
- try {
315
- const hasTestCaseAsUpdateContext = !!testCase?.name;
316
- let testBlockUpdate = undefined;
317
- if (hasTestCaseAsUpdateContext) {
318
- const applyFileChangesSpan = trace?.span({
319
- name: "apply-file-changes",
320
- });
321
- const block = (0, web_1.getTypescriptTestBlock)({
322
- scenarioName: testCase?.name,
323
- content: fileChange.newCode || "",
324
- suites: [], // // suites should be empty here since we ask LLM to send immediate parent AST node for the code update. so there won't be any nesting here, just the test block
325
- });
326
- testBlockUpdate = block.testBlock;
327
- applyFileChangesSpan?.end({ output: { testBlock: testBlockUpdate } });
328
- }
329
- if (testBlockUpdate) {
330
- // assuming the test case getting updated
331
- // maintaining the previous accuracy of the test case update
332
- const readWriteFileSpan = trace?.span({ name: "write-to-file" });
333
- let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
334
- const [prependContent, strippedContent] = await (0, web_1.stripAndPrependImports)(fileChange.newCode, testCase?.name);
335
- let updatedContent = prependContent + contents + `\n\n${strippedContent}`;
336
- const { testBlock } = (0, web_1.getTypescriptTestBlock)({
337
- scenarioName: testCase?.name,
338
- content: contents,
339
- suites: testCase?.suites,
340
- });
341
- contents = contents.replace(testBlock, `\n\n${strippedContent}`);
342
- updatedContent = prependContent + contents;
343
- await fs_extra_1.default.writeFile(fileChange.filePath, updatedContent, "utf-8");
344
- readWriteFileSpan?.end({ output: { updatedContent } });
345
- }
346
- else {
347
- const readWriteFileSpan = trace?.span({ name: "write-to-file" });
348
- let contents = await fs_extra_1.default.readFile(fileChange.filePath, "utf-8");
349
- const project = new ts_morph_1.Project();
350
- const sourceFile = project.createSourceFile("updated-code.ts", fileChange.newCode);
351
- const functions = sourceFile.getFunctions();
352
- const checkForMethodSrc = project.createSourceFile("check-method.ts", `class A {
353
- ${fileChange.newCode}
354
- }`);
355
- const methods = checkForMethodSrc.getDescendantsOfKind(ts_morph_1.SyntaxKind.MethodDeclaration);
356
- const originalSource = project.createSourceFile("current-code.ts", contents);
357
- // if there is a single function update in the file
358
- if (functions.length === 1 &&
359
- functions[0]?.getText() === fileChange.newCode) {
360
- const updatedCodeFuncNames = functions.map((f) => f.getName());
361
- const funcName = updatedCodeFuncNames[0];
362
- const matchingNodes = originalSource
363
- .getDescendantsOfKind(ts_morph_1.SyntaxKind.FunctionDeclaration)
364
- .filter((node) => node.getName() === funcName);
365
- matchingNodes[0]?.replaceWithText(functions[0]?.getText());
366
- contents = originalSource.getFullText();
367
- }
368
- else if (
369
- // if there is a update in method of a class in the file
370
- methods.length === 1 &&
371
- methods[0]?.getText() === fileChange.newCode) {
372
- const method = methods[0];
373
- const funcName = method?.getName();
374
- const matchingNodes = originalSource
375
- .getDescendantsOfKind(ts_morph_1.SyntaxKind.MethodDeclaration)
376
- .filter((node) => node.getName() === funcName);
377
- matchingNodes[0]?.replaceWithText(method?.getText());
378
- contents = originalSource.getFullText();
379
- }
380
- else {
381
- const { result, updatedContent } = await searchAndReplaceCode({
382
- logger,
383
- fileChange,
384
- });
385
- if (result.error) {
386
- logger?.error(`Unable to find the code to update in ${fileChange.filePath}`);
387
- results.push(result);
388
- continue;
389
- }
390
- else {
391
- contents = updatedContent;
392
- }
393
- }
394
- await fs_extra_1.default.writeFile(fileChange.filePath, contents, "utf-8");
395
- readWriteFileSpan?.end({ output: { contents } });
396
- results.push({
397
- filePath: fileChange.filePath,
398
- error: false,
399
- errorMessage: "",
400
- });
401
- }
402
- }
403
- catch (e) {
404
- trace?.event({
405
- name: "apply-file-changes-error",
406
- output: {
407
- filePath: fileChange.filePath,
408
- error: e,
409
- },
410
- });
411
- console.error(`Error while applying changes to file ${fileChange.filePath}`, e);
412
- }
413
- }
414
- return results;
415
- }
416
- exports.applyFileChanges = applyFileChanges;
@@ -1,18 +0,0 @@
1
- import { TraceClient } from "@empiricalrun/llm";
2
- import { TestErrorDiagnosisDetails, TestGenConfigOptions } from "@empiricalrun/shared-types";
3
- import { CustomLogger } from "../../bin/logger";
4
- /**
5
- *
6
- * inputs
7
- * - task
8
- * - diagnosis
9
- */
10
- export declare function createTaskUsingFailureDiagnosis({ options, trace, diagnosis, logger, }: {
11
- options?: TestGenConfigOptions;
12
- trace?: TraceClient;
13
- diagnosis: TestErrorDiagnosisDetails;
14
- logger?: CustomLogger;
15
- }): Promise<{
16
- task: string;
17
- }>;
18
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/diagnosis-agent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAuChD;;;;;GAKG;AACH,wBAAsB,+BAA+B,CAAC,EACpD,OAAO,EACP,KAAK,EACL,SAAS,EACT,MAAM,GACP,EAAE;IACD,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,yBAAyB,CAAC;IACrC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CA8E5B"}
@@ -1,105 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTaskUsingFailureDiagnosis = void 0;
4
- const llm_1 = require("@empiricalrun/llm");
5
- const session_1 = require("../../session");
6
- const strict_mode_violation_1 = require("./strict-mode-violation");
7
- const session = (0, session_1.getSessionDetails)();
8
- const responseFormat = {
9
- type: "json_schema",
10
- json_schema: {
11
- name: "test-case-auto-fix-summary",
12
- strict: true,
13
- schema: {
14
- type: "object",
15
- properties: {
16
- observation: {
17
- type: "array",
18
- items: {
19
- type: "string",
20
- },
21
- description: "Detailed observation of what changed between successful and failed test screenshots",
22
- },
23
- action: {
24
- type: "string",
25
- description: "Direct action to fix the test in natural language without code snippets or options",
26
- },
27
- },
28
- required: ["observation", "action"],
29
- additionalProperties: false,
30
- },
31
- },
32
- };
33
- /**
34
- *
35
- * inputs
36
- * - task
37
- * - diagnosis
38
- */
39
- async function createTaskUsingFailureDiagnosis({ options, trace, diagnosis, logger, }) {
40
- trace =
41
- trace ||
42
- llm_1.langfuseInstance?.trace({
43
- name: "infer-agent-task",
44
- id: crypto.randomUUID(),
45
- release: session.version,
46
- });
47
- const failureDiagnosisSpan = trace?.span({
48
- name: "auto-fix",
49
- input: {
50
- diagnosisId: diagnosis.diagnosisId,
51
- prjRepoName: options?.metadata.projectRepoName,
52
- },
53
- });
54
- logger?.log("Trying to fix the test using failure diagnosis. Fetching key moments of the diagnosis");
55
- const resp = await fetch(diagnosis.keyMomentsUrl);
56
- // TODO: check for response to be not ok
57
- if (resp.ok) {
58
- logger?.success("Successfully fetched key moments of the diagnosis");
59
- }
60
- else {
61
- logger?.warn("Failed to fetch key moments of the diagnosis");
62
- }
63
- const screenshotsData = await resp.json();
64
- const llm = new llm_1.LLM({
65
- provider: "openai",
66
- defaultModel: "o1",
67
- trace: failureDiagnosisSpan,
68
- });
69
- // TODO: make this dynamic in nature. the prompts should be made receipe
70
- // which will help to get rid of if else logic
71
- // receipe to have:
72
- // 1. selection criteria
73
- // 2. job to be done - in this case generate a prompt
74
- let prompt;
75
- if (diagnosis.failed_run_metadata.stack.includes("strict mode violation")) {
76
- prompt = (0, strict_mode_violation_1.fixStrictModeViolationPrompt)({
77
- screenshotsData,
78
- diagnosis,
79
- });
80
- }
81
- if (prompt) {
82
- const llmResponse = await llm.createChatCompletion({
83
- messages: prompt,
84
- modelParameters: {
85
- max_completion_tokens: 40000,
86
- },
87
- responseFormat,
88
- });
89
- const { observation, action } = JSON.parse(llmResponse?.content);
90
- failureDiagnosisSpan?.update({
91
- output: {
92
- observation,
93
- action,
94
- },
95
- });
96
- return {
97
- task: action,
98
- };
99
- }
100
- // TODO: handle default prompt
101
- return {
102
- task: "",
103
- };
104
- }
105
- exports.createTaskUsingFailureDiagnosis = createTaskUsingFailureDiagnosis;
@@ -1,9 +0,0 @@
1
- import { TestErrorDiagnosisDetails } from "@empiricalrun/shared-types";
2
- export declare function fixStrictModeViolationPrompt({ screenshotsData, diagnosis, }: {
3
- screenshotsData: {
4
- success: string[];
5
- failure: string[];
6
- };
7
- diagnosis: TestErrorDiagnosisDetails;
8
- }): import("openai/resources/index.mjs").ChatCompletionMessageParam[];
9
- //# sourceMappingURL=strict-mode-violation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strict-mode-violation.d.ts","sourceRoot":"","sources":["../../../src/agent/diagnosis-agent/strict-mode-violation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAoBvE,wBAAgB,4BAA4B,CAAC,EAC3C,eAAe,EACf,SAAS,GACV,EAAE;IACD,eAAe,EAAE;QAAE,OAAO,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAC1D,SAAS,EAAE,yBAAyB,CAAC;CACtC,qEAiBA"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fixStrictModeViolationPrompt = void 0;
4
- const llm_1 = require("@empiricalrun/llm");
5
- const promptTemplate_0 = "{{#section \"system\"}}\nAs a software engineer, your task is to identify a fix for a failing Playwright test by analyzing screenshots of both the failed and successful test steps.\n\nKey issues for test failures include:\n- Duplicate elements for the same Playwright selector.\n\nInstructions:\n1. Examine the provided successful and failed test screenshots.\n2. Identify the correct element for action based on these observations on the successful test run screenshots.\n3. Sometimes the exact same locator is not available on failed test run screenshot, you need to identify the intent from successful test screenshots and apply that intent in failed test run screenshot to identify the right locator to interact with\n4. Evaluate the playwright selector options provided to you to execute the action. Pick the selector which best matches the intent of the test.\n5. Propose a precise action that addresses the issue.\n\nExample:\n- observation: \n - Current step failure: await page.getByText(\"Audience\").click()\n - Two similar buttons named \"Audience\" exist in the failed run screenshots\n - The successful test run clicked on \"Untracked Audience\"\n - The failed test run should click on \"Untracked Audience\"\n - Available locators: await page.getByText(\"Untracked Audience\").click() contain the selector for Untracked Audience\n- action: Replace failing line with await page.getByText(\"Untracked Audience\").click()\n\nYour action should:\n- Be directly actionable and free of ambiguity, as it will guide another LLM to generate code.\n- Be in natural language and not just code snippet.\n- Be verified as feasible on the failure screen before responding.\n- Choose from the provided possible actions that can be executed on the failure screen.\n- Action should adhere to the format mentioned in the example, i.e. it should start with \"Replace the failing line\" and the updated code with replaced selector following it.\n\nEnsure the action is executable based on the failure screen context before providing it.\n{{/section}}\n\n{{#section \"user\"}}\nSuccessful test screenshots\n\n{{images successScreenshots}}\n\nFailed test screenshots\n\n{{images failedScreenshots}}\n\nStep where test failed:\n{{failingLine}}\n\nOptions for Playwright selectors to perform actions on a failed test screen:\n{{selectorOptions}}\n\n{{/section}}\n\n";
6
- function extractLocatorOptions(errorStack) {
7
- // This regex matches a chain of locator API calls following the pattern:
8
- // functionName(arguments) optionally chained with .functionName(arguments)
9
- const regex = /aka\s+((?:[A-Za-z0-9_]+\([^)]*\)(?:\.[A-Za-z0-9_]+\([^)]*\))*))/g;
10
- const options = [];
11
- let match;
12
- while ((match = regex.exec(errorStack)) !== null) {
13
- if (match[1]) {
14
- options.push(match[1]);
15
- }
16
- }
17
- return options;
18
- }
19
- function fixStrictModeViolationPrompt({ screenshotsData, diagnosis, }) {
20
- const compiledPrompt = (0, llm_1.compilePrompt)(promptTemplate_0, {
21
- failingLine: diagnosis.failingLine,
22
- successScreenshots: screenshotsData.success,
23
- failedScreenshots: screenshotsData.failure,
24
- selectorOptions: extractLocatorOptions(diagnosis.failed_run_metadata.stack).join("\n"),
25
- }, {
26
- imageDetail: "high",
27
- modelProvider: "openai",
28
- });
29
- return compiledPrompt;
30
- }
31
- exports.fixStrictModeViolationPrompt = fixStrictModeViolationPrompt;
@@ -1,12 +0,0 @@
1
- import { TraceClient } from "@empiricalrun/llm";
2
- export declare const enrichPromptWithFailingLine: ({ trace, testBlock, testFilePath, suggestionForFix, }: {
3
- testBlock: string;
4
- testFilePath: string;
5
- suggestionForFix: string;
6
- trace?: TraceClient | undefined;
7
- }) => Promise<{
8
- output: string;
9
- is_user_message_enriched: boolean;
10
- reason_for_output: string;
11
- }>;
12
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent/enrich-prompt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmCpE,eAAO,MAAM,2BAA2B;eAM3B,MAAM;kBACH,MAAM;sBACF,MAAM;;;YAGhB,MAAM;8BACY,OAAO;uBACd,MAAM;EA0D1B,CAAC"}