@empiricalrun/test-gen 0.73.1 → 0.74.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 (313) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/dist/actions/utils/index.d.ts.map +1 -1
  3. package/dist/actions/utils/index.js +1 -2
  4. package/dist/agent/browsing/index.d.ts.map +1 -1
  5. package/dist/agent/browsing/index.js +9 -7
  6. package/dist/agent/browsing/utils.d.ts.map +1 -1
  7. package/dist/agent/browsing/utils.js +3 -4
  8. package/dist/agent/chat/agent-loop.d.ts +7 -8
  9. package/dist/agent/chat/agent-loop.d.ts.map +1 -1
  10. package/dist/agent/chat/agent-loop.js +13 -17
  11. package/dist/agent/chat/exports.d.ts +5 -4
  12. package/dist/agent/chat/exports.d.ts.map +1 -1
  13. package/dist/agent/chat/exports.js +9 -4
  14. package/dist/agent/chat/filesystem-cache.d.ts +12 -0
  15. package/dist/agent/chat/filesystem-cache.d.ts.map +1 -0
  16. package/dist/agent/chat/filesystem-cache.js +101 -0
  17. package/dist/agent/chat/index.d.ts +4 -1
  18. package/dist/agent/chat/index.d.ts.map +1 -1
  19. package/dist/agent/chat/index.js +44 -22
  20. package/dist/agent/chat/models.d.ts +2 -1
  21. package/dist/agent/chat/models.d.ts.map +1 -1
  22. package/dist/agent/chat/models.js +25 -3
  23. package/dist/agent/chat/prompt/index.d.ts +3 -1
  24. package/dist/agent/chat/prompt/index.d.ts.map +1 -1
  25. package/dist/agent/chat/prompt/index.js +77 -2
  26. package/dist/agent/chat/prompt/repo.d.ts.map +1 -1
  27. package/dist/agent/chat/prompt/repo.js +1 -0
  28. package/dist/agent/chat/state.d.ts +6 -5
  29. package/dist/agent/chat/state.d.ts.map +1 -1
  30. package/dist/agent/chat/state.js +35 -5
  31. package/dist/agent/chat/utils.d.ts +1 -0
  32. package/dist/agent/chat/utils.d.ts.map +1 -1
  33. package/dist/agent/chat/utils.js +16 -3
  34. package/dist/agent/cua/index.js +1 -1
  35. package/dist/agent/cua/model.js +1 -1
  36. package/dist/agent/cua/pw-codegen/pw-pause/index.d.ts.map +1 -1
  37. package/dist/agent/cua/pw-codegen/pw-pause/index.js +0 -1
  38. package/dist/agent/master/browser-tests/fixtures.d.ts.map +1 -1
  39. package/dist/agent/master/browser-tests/fixtures.js +0 -1
  40. package/dist/agent/master/element-annotation.d.ts.map +1 -1
  41. package/dist/agent/master/element-annotation.js +1 -2
  42. package/dist/agent/master/execute-browser-action.d.ts.map +1 -1
  43. package/dist/agent/master/execute-browser-action.js +8 -6
  44. package/dist/agent/master/icon-descriptor/index.js +2 -2
  45. package/dist/agent/master/next-action.js +1 -1
  46. package/dist/agent/master/planner.js +1 -1
  47. package/dist/agent/master/scroller.js +2 -2
  48. package/dist/agent/master/with-hints.d.ts.map +1 -1
  49. package/dist/agent/master/with-hints.js +6 -5
  50. package/dist/agent/planner/run-time-planner.js +1 -1
  51. package/dist/agent/planner/run.d.ts.map +1 -1
  52. package/dist/agent/planner/run.js +4 -2
  53. package/dist/auth/cli-auth.js +1 -1
  54. package/dist/auth/token-store.d.ts.map +1 -1
  55. package/dist/auth/token-store.js +4 -6
  56. package/dist/bin/index.js +30 -163
  57. package/dist/bin/utils/context.js +1 -1
  58. package/dist/bin/utils/index.d.ts +0 -12
  59. package/dist/bin/utils/index.d.ts.map +1 -1
  60. package/dist/bin/utils/index.js +0 -70
  61. package/dist/bin/utils/platform/web/index.d.ts +2 -2
  62. package/dist/bin/utils/platform/web/index.d.ts.map +1 -1
  63. package/dist/bin/utils/platform/web/index.js +7 -5
  64. package/dist/bin/utils/scenarios/index.d.ts +11 -3
  65. package/dist/bin/utils/scenarios/index.d.ts.map +1 -1
  66. package/dist/browser-injected-scripts/annotate-elements.spec.js +0 -5
  67. package/dist/browser-injected-scripts/annotate-elements.spec.ts +0 -5
  68. package/dist/dashboard/client.d.ts +2 -2
  69. package/dist/dashboard/client.d.ts.map +1 -1
  70. package/dist/dashboard/client.js +4 -1
  71. package/dist/file-info/adapters/file-system/index.d.ts +9 -0
  72. package/dist/file-info/adapters/file-system/index.d.ts.map +1 -0
  73. package/dist/file-info/adapters/file-system/index.js +25 -0
  74. package/dist/file-info/adapters/file-system/reader.d.ts +6 -0
  75. package/dist/file-info/adapters/file-system/reader.d.ts.map +1 -0
  76. package/dist/file-info/{file-system.js → adapters/file-system/reader.js} +16 -0
  77. package/dist/file-info/adapters/github/index.d.ts +11 -0
  78. package/dist/file-info/adapters/github/index.d.ts.map +1 -0
  79. package/dist/file-info/adapters/github/index.js +29 -0
  80. package/dist/file-info/adapters/github/reader.d.ts +16 -0
  81. package/dist/file-info/adapters/github/reader.d.ts.map +1 -0
  82. package/dist/file-info/adapters/github/reader.js +185 -0
  83. package/dist/file-info/index.d.ts +4 -0
  84. package/dist/file-info/index.d.ts.map +1 -0
  85. package/dist/file-info/index.js +10 -0
  86. package/dist/index.d.ts +2 -0
  87. package/dist/index.d.ts.map +1 -1
  88. package/dist/index.js +6 -1
  89. package/dist/recorder/index.d.ts +7 -3
  90. package/dist/recorder/index.d.ts.map +1 -1
  91. package/dist/recorder/index.js +181 -64
  92. package/dist/recorder/temp-files.d.ts +1 -1
  93. package/dist/recorder/temp-files.d.ts.map +1 -1
  94. package/dist/recorder/temp-files.js +2 -2
  95. package/dist/recorder/upload.d.ts +1 -1
  96. package/dist/recorder/upload.d.ts.map +1 -1
  97. package/dist/recorder/upload.js +3 -3
  98. package/dist/tools/{commit-and-create-pr.d.ts → commit-and-create-pr/index.d.ts} +1 -1
  99. package/dist/tools/commit-and-create-pr/index.d.ts.map +1 -0
  100. package/dist/tools/{commit-and-create-pr.js → commit-and-create-pr/index.js} +8 -28
  101. package/dist/tools/definitions/commit-and-create-pr.d.ts +3 -0
  102. package/dist/tools/definitions/commit-and-create-pr.d.ts.map +1 -0
  103. package/dist/tools/definitions/commit-and-create-pr.js +31 -0
  104. package/dist/tools/definitions/delete-file.d.ts +3 -0
  105. package/dist/tools/definitions/delete-file.d.ts.map +1 -0
  106. package/dist/tools/definitions/delete-file.js +20 -0
  107. package/dist/tools/{download-build.d.ts → definitions/download-build.d.ts} +2 -2
  108. package/dist/tools/definitions/download-build.d.ts.map +1 -0
  109. package/dist/tools/definitions/download-build.js +18 -0
  110. package/dist/tools/definitions/fetch-video-analysis.d.ts +11 -0
  111. package/dist/tools/definitions/fetch-video-analysis.d.ts.map +1 -0
  112. package/dist/tools/definitions/fetch-video-analysis.js +26 -0
  113. package/dist/tools/definitions/grep.d.ts +3 -0
  114. package/dist/tools/definitions/grep.d.ts.map +1 -0
  115. package/dist/tools/definitions/grep.js +29 -0
  116. package/dist/tools/definitions/merge-conflicts.d.ts +3 -0
  117. package/dist/tools/definitions/merge-conflicts.d.ts.map +1 -0
  118. package/dist/tools/definitions/merge-conflicts.js +24 -0
  119. package/dist/tools/definitions/run-test.d.ts +2 -2
  120. package/dist/tools/definitions/run-test.d.ts.map +1 -1
  121. package/dist/tools/definitions/run-test.js +4 -7
  122. package/dist/tools/definitions/str_replace_editor.d.ts.map +1 -1
  123. package/dist/tools/definitions/str_replace_editor.js +9 -5
  124. package/dist/tools/definitions/test-gen-browser.d.ts +5 -5
  125. package/dist/tools/definitions/test-gen-browser.d.ts.map +1 -1
  126. package/dist/tools/definitions/test-gen-browser.js +4 -7
  127. package/dist/tools/definitions/upgrade-packages.d.ts +36 -0
  128. package/dist/tools/definitions/upgrade-packages.d.ts.map +1 -0
  129. package/dist/tools/definitions/upgrade-packages.js +21 -0
  130. package/dist/tools/definitions/utils.d.ts +15 -0
  131. package/dist/tools/definitions/utils.d.ts.map +1 -0
  132. package/dist/tools/definitions/utils.js +16 -0
  133. package/dist/tools/{delete-file.d.ts → delete-file/index.d.ts} +1 -1
  134. package/dist/tools/delete-file/index.d.ts.map +1 -0
  135. package/dist/tools/{delete-file.js → delete-file/index.js} +4 -16
  136. package/dist/tools/diagnosis-fetcher.d.ts.map +1 -1
  137. package/dist/tools/diagnosis-fetcher.js +13 -11
  138. package/dist/tools/download-build/index.d.ts +3 -0
  139. package/dist/tools/download-build/index.d.ts.map +1 -0
  140. package/dist/tools/{download-build.js → download-build/index.js} +4 -14
  141. package/dist/tools/executor/index.d.ts.map +1 -1
  142. package/dist/tools/executor/index.js +19 -4
  143. package/dist/tools/executor/utils/git.js +1 -1
  144. package/dist/tools/executor/utils/pr-description.d.ts +1 -1
  145. package/dist/tools/executor/utils/pr-description.d.ts.map +1 -1
  146. package/dist/tools/fetch-image/index.d.ts +10 -1
  147. package/dist/tools/fetch-image/index.d.ts.map +1 -1
  148. package/dist/tools/fetch-image/index.js +1 -0
  149. package/dist/tools/fetch-last-successful-test-run/index.d.ts +3 -0
  150. package/dist/tools/fetch-last-successful-test-run/index.d.ts.map +1 -0
  151. package/dist/tools/fetch-last-successful-test-run/index.js +60 -0
  152. package/dist/tools/fetch-video-analysis/index.d.ts +5 -0
  153. package/dist/tools/fetch-video-analysis/index.d.ts.map +1 -0
  154. package/dist/tools/fetch-video-analysis/index.js +89 -0
  155. package/dist/tools/fetch-video-analysis/local-ffmpeg-client.d.ts +24 -0
  156. package/dist/tools/fetch-video-analysis/local-ffmpeg-client.d.ts.map +1 -0
  157. package/dist/tools/fetch-video-analysis/local-ffmpeg-client.js +209 -0
  158. package/dist/tools/fetch-video-analysis/utils.d.ts +10 -0
  159. package/dist/tools/fetch-video-analysis/utils.d.ts.map +1 -0
  160. package/dist/tools/fetch-video-analysis/utils.js +72 -0
  161. package/dist/tools/fetch-video-analysis/video-analysis.d.ts +7 -0
  162. package/dist/tools/fetch-video-analysis/video-analysis.d.ts.map +1 -0
  163. package/dist/tools/fetch-video-analysis/video-analysis.js +54 -0
  164. package/dist/tools/file-operations/create.d.ts +11 -0
  165. package/dist/tools/file-operations/create.d.ts.map +1 -0
  166. package/dist/tools/file-operations/create.js +60 -0
  167. package/dist/tools/file-operations/index.d.ts +15 -0
  168. package/dist/tools/file-operations/index.d.ts.map +1 -0
  169. package/dist/tools/file-operations/index.js +143 -0
  170. package/dist/tools/file-operations/insert.d.ts +11 -0
  171. package/dist/tools/file-operations/insert.d.ts.map +1 -0
  172. package/dist/tools/file-operations/insert.js +61 -0
  173. package/dist/tools/file-operations/replace.d.ts +11 -0
  174. package/dist/tools/file-operations/replace.d.ts.map +1 -0
  175. package/dist/tools/file-operations/replace.js +80 -0
  176. package/dist/tools/file-operations/shared/git-helper.d.ts +4 -0
  177. package/dist/tools/file-operations/shared/git-helper.d.ts.map +1 -0
  178. package/dist/tools/file-operations/shared/git-helper.js +29 -0
  179. package/dist/tools/file-operations/shared/helpers.d.ts +19 -0
  180. package/dist/tools/file-operations/shared/helpers.d.ts.map +1 -0
  181. package/dist/tools/file-operations/shared/helpers.js +133 -0
  182. package/dist/tools/file-operations/view/index.d.ts +14 -0
  183. package/dist/tools/file-operations/view/index.d.ts.map +1 -0
  184. package/dist/tools/file-operations/view/index.js +56 -0
  185. package/dist/tools/grep/index.d.ts.map +1 -1
  186. package/dist/tools/grep/index.js +2 -9
  187. package/dist/tools/grep/ripgrep/index.d.ts +2 -2
  188. package/dist/tools/grep/ripgrep/index.d.ts.map +1 -1
  189. package/dist/tools/grep/ripgrep/index.js +3 -3
  190. package/dist/tools/grep/types.d.ts.map +1 -0
  191. package/dist/tools/index.d.ts +7 -2
  192. package/dist/tools/index.d.ts.map +1 -1
  193. package/dist/tools/index.js +66 -22
  194. package/dist/tools/issues/create-issue.d.ts +3 -0
  195. package/dist/tools/issues/create-issue.d.ts.map +1 -0
  196. package/dist/tools/issues/create-issue.js +76 -0
  197. package/dist/tools/issues/index.d.ts +4 -0
  198. package/dist/tools/issues/index.d.ts.map +1 -0
  199. package/dist/tools/issues/index.js +9 -0
  200. package/dist/tools/issues/list-issues.d.ts +3 -0
  201. package/dist/tools/issues/list-issues.d.ts.map +1 -0
  202. package/dist/tools/issues/list-issues.js +32 -0
  203. package/dist/tools/issues/metadata-schema.d.ts +24 -0
  204. package/dist/tools/issues/metadata-schema.d.ts.map +1 -0
  205. package/dist/tools/issues/metadata-schema.js +22 -0
  206. package/dist/tools/issues/update-issue.d.ts +3 -0
  207. package/dist/tools/issues/update-issue.d.ts.map +1 -0
  208. package/dist/tools/issues/update-issue.js +75 -0
  209. package/dist/tools/issues/utils.d.ts +5 -0
  210. package/dist/tools/issues/utils.d.ts.map +1 -0
  211. package/dist/tools/issues/utils.js +26 -0
  212. package/dist/tools/list-environments.d.ts.map +1 -1
  213. package/dist/tools/list-environments.js +4 -0
  214. package/dist/tools/{merge-conflicts.d.ts → merge-conflicts/index.d.ts} +1 -1
  215. package/dist/tools/merge-conflicts/index.d.ts.map +1 -0
  216. package/dist/tools/{merge-conflicts.js → merge-conflicts/index.js} +3 -19
  217. package/dist/tools/test-gen-browser.js +4 -4
  218. package/dist/tools/test-run-fetcher/index.d.ts.map +1 -1
  219. package/dist/tools/test-run-fetcher/index.js +4 -0
  220. package/dist/tools/trace-dot-zip/index.d.ts +3 -0
  221. package/dist/tools/trace-dot-zip/index.d.ts.map +1 -0
  222. package/dist/tools/trace-dot-zip/index.js +48 -0
  223. package/dist/tools/trace-dot-zip/types.d.ts +86 -0
  224. package/dist/tools/trace-dot-zip/types.d.ts.map +1 -0
  225. package/dist/tools/trace-dot-zip/types.js +2 -0
  226. package/dist/tools/trace-dot-zip/utils/console-trace.d.ts +7 -0
  227. package/dist/tools/trace-dot-zip/utils/console-trace.d.ts.map +1 -0
  228. package/dist/tools/trace-dot-zip/utils/console-trace.js +34 -0
  229. package/dist/tools/trace-dot-zip/utils/extract-zip.d.ts +21 -0
  230. package/dist/tools/trace-dot-zip/utils/extract-zip.d.ts.map +1 -0
  231. package/dist/tools/trace-dot-zip/utils/extract-zip.js +174 -0
  232. package/dist/tools/trace-dot-zip/utils/network-trace.d.ts +21 -0
  233. package/dist/tools/trace-dot-zip/utils/network-trace.d.ts.map +1 -0
  234. package/dist/tools/trace-dot-zip/utils/network-trace.js +189 -0
  235. package/dist/tools/triage-summary/index.d.ts +3 -0
  236. package/dist/tools/triage-summary/index.d.ts.map +1 -0
  237. package/dist/tools/triage-summary/index.js +51 -0
  238. package/dist/tools/triage-summary/types.d.ts +5 -0
  239. package/dist/tools/triage-summary/types.d.ts.map +1 -0
  240. package/dist/tools/triage-summary/types.js +2 -0
  241. package/dist/tools/triage-summary/utils.d.ts +4 -0
  242. package/dist/tools/triage-summary/utils.d.ts.map +1 -0
  243. package/dist/tools/triage-summary/utils.js +16 -0
  244. package/dist/tools/upgrade-packages/index.d.ts.map +1 -1
  245. package/dist/tools/upgrade-packages/index.js +5 -15
  246. package/dist/tools/view-failed-test-run-report/index.d.ts +12 -0
  247. package/dist/tools/view-failed-test-run-report/index.d.ts.map +1 -0
  248. package/dist/tools/view-failed-test-run-report/index.js +163 -0
  249. package/dist/trace-utils/index.d.ts +4 -0
  250. package/dist/trace-utils/index.d.ts.map +1 -0
  251. package/dist/trace-utils/index.js +10 -0
  252. package/dist/utils/dedup-image-fs.d.ts +27 -0
  253. package/dist/utils/dedup-image-fs.d.ts.map +1 -0
  254. package/dist/utils/dedup-image-fs.js +88 -0
  255. package/dist/utils/dedup-image.d.ts +25 -0
  256. package/dist/utils/dedup-image.d.ts.map +1 -0
  257. package/dist/utils/dedup-image.js +80 -0
  258. package/dist/utils/env.d.ts.map +1 -1
  259. package/dist/utils/env.js +0 -1
  260. package/dist/utils/json.js +1 -1
  261. package/dist/utils/model.d.ts +3 -0
  262. package/dist/utils/model.d.ts.map +1 -0
  263. package/dist/utils/model.js +18 -0
  264. package/dist/utils/playwright-report-parser.d.ts +13 -0
  265. package/dist/utils/playwright-report-parser.d.ts.map +1 -0
  266. package/dist/utils/playwright-report-parser.js +138 -0
  267. package/dist/utils/slug.d.ts +1 -0
  268. package/dist/utils/slug.d.ts.map +1 -1
  269. package/dist/utils/slug.js +9 -1
  270. package/dist/utils/stripAnsi.d.ts.map +1 -1
  271. package/dist/utils/stripAnsi.js +1 -3
  272. package/eslint.config.mjs +43 -0
  273. package/package.json +22 -6
  274. package/tsconfig.tsbuildinfo +1 -1
  275. package/dist/agent/codegen/generate-code-apply-changes.d.ts +0 -13
  276. package/dist/agent/codegen/generate-code-apply-changes.d.ts.map +0 -1
  277. package/dist/agent/codegen/generate-code-apply-changes.js +0 -379
  278. package/dist/agent/codegen/repo-edit.d.ts +0 -23
  279. package/dist/agent/codegen/repo-edit.d.ts.map +0 -1
  280. package/dist/agent/codegen/repo-edit.js +0 -81
  281. package/dist/agent/codegen/run.d.ts +0 -20
  282. package/dist/agent/codegen/run.d.ts.map +0 -1
  283. package/dist/agent/codegen/run.js +0 -116
  284. package/dist/agent/enrich-prompt/index.d.ts +0 -12
  285. package/dist/agent/enrich-prompt/index.d.ts.map +0 -1
  286. package/dist/agent/enrich-prompt/index.js +0 -80
  287. package/dist/agent/enrich-prompt/utils.d.ts +0 -6
  288. package/dist/agent/enrich-prompt/utils.d.ts.map +0 -1
  289. package/dist/agent/enrich-prompt/utils.js +0 -11
  290. package/dist/agent/infer-agent/index.d.ts +0 -10
  291. package/dist/agent/infer-agent/index.d.ts.map +0 -1
  292. package/dist/agent/infer-agent/index.js +0 -60
  293. package/dist/evals/add-scenario-agent.evals.d.ts +0 -4
  294. package/dist/evals/add-scenario-agent.evals.d.ts.map +0 -1
  295. package/dist/evals/add-scenario-agent.evals.js +0 -44
  296. package/dist/evals/infer-master-or-code-agent.evals.d.ts +0 -4
  297. package/dist/evals/infer-master-or-code-agent.evals.d.ts.map +0 -1
  298. package/dist/evals/infer-master-or-code-agent.evals.js +0 -22
  299. package/dist/file-info/file-system.d.ts +0 -3
  300. package/dist/file-info/file-system.d.ts.map +0 -1
  301. package/dist/file-info/github.d.ts +0 -3
  302. package/dist/file-info/github.d.ts.map +0 -1
  303. package/dist/file-info/github.js +0 -107
  304. package/dist/tools/commit-and-create-pr.d.ts.map +0 -1
  305. package/dist/tools/delete-file.d.ts.map +0 -1
  306. package/dist/tools/download-build.d.ts.map +0 -1
  307. package/dist/tools/grep/ripgrep/types.d.ts.map +0 -1
  308. package/dist/tools/merge-conflicts.d.ts.map +0 -1
  309. package/dist/tools/str_replace_editor.d.ts +0 -22
  310. package/dist/tools/str_replace_editor.d.ts.map +0 -1
  311. package/dist/tools/str_replace_editor.js +0 -429
  312. /package/dist/tools/grep/{ripgrep/types.d.ts → types.d.ts} +0 -0
  313. /package/dist/tools/grep/{ripgrep/types.js → types.js} +0 -0
@@ -1,379 +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.systemPromptBuilderForRepoEdit = systemPromptBuilderForRepoEdit;
7
- exports.generateCodeAndApplyChanges = generateCodeAndApplyChanges;
8
- const llm_1 = require("@empiricalrun/llm");
9
- const fs_1 = __importDefault(require("fs"));
10
- const path_1 = require("path");
11
- const constants_1 = require("../../constants");
12
- const types_1 = require("./types");
13
- const utils_1 = require("./utils");
14
- function getCodeEditorToolCalls() {
15
- const strReplace = {
16
- name: "code-block-replace",
17
- description: "replace the code block with the provided code",
18
- schema: {
19
- type: "function",
20
- function: {
21
- name: types_1.CodeEditorToolCall.STR_REPLACE,
22
- description: "replace the code block with the provided code",
23
- parameters: {
24
- type: "object",
25
- properties: {
26
- reason: {
27
- type: "string",
28
- description: "reason for why the current block is selected for replacement and why is it needed.",
29
- },
30
- filePath: {
31
- type: "string",
32
- description: "path of the file where the code block is present",
33
- },
34
- oldCode: {
35
- type: "string",
36
- description: "old code block to be replaced",
37
- },
38
- newCode: {
39
- type: "string",
40
- description: "new code block to replace the old code block",
41
- },
42
- },
43
- required: ["reason", "filePath", "oldCode", "newCode"],
44
- additionalProperties: false,
45
- },
46
- },
47
- },
48
- };
49
- const createFile = {
50
- name: "create_file",
51
- description: "create a new file with the provided code if the file doesn't exist",
52
- schema: {
53
- type: "function",
54
- function: {
55
- name: types_1.CodeEditorToolCall.CREATE_FILE,
56
- description: "create a new file with the provided code if the file doesn't exist",
57
- parameters: {
58
- type: "object",
59
- properties: {
60
- reason: {
61
- type: "string",
62
- description: "reason for why the file is needed and what is the purpose of the file.",
63
- },
64
- filePath: {
65
- type: "string",
66
- description: "path of the file that needs to be created",
67
- },
68
- code: {
69
- type: "string",
70
- description: "code to be written to the file",
71
- },
72
- },
73
- required: ["reason", "filePath", "code"],
74
- additionalProperties: false,
75
- },
76
- },
77
- },
78
- };
79
- return [strReplace, createFile].map((tool) => tool.schema);
80
- }
81
- function getPlannerToolCalls() {
82
- const planner = {
83
- name: "change_plan",
84
- description: "Provides the plan for the changes to be made",
85
- schema: {
86
- type: "function",
87
- function: {
88
- name: "change_plan",
89
- description: "Provides the plan for the changes to be made",
90
- parameters: {
91
- type: "object",
92
- properties: {
93
- reason: {
94
- type: "string",
95
- description: "Reason for providing the plan. Why a certain file needed the change ? Are you sure that all the changes required are present in the plan ?",
96
- },
97
- plan: {
98
- type: "string",
99
- description: "Plan given to code agent to execute. The plan should be readable and easy to understand.",
100
- },
101
- },
102
- additionalProperties: false,
103
- required: ["reason", "plan"],
104
- },
105
- },
106
- },
107
- };
108
- const exit = {
109
- name: "exit",
110
- description: "Called when there are no more changes to be made. All the changes are done.",
111
- schema: {
112
- type: "function",
113
- function: {
114
- name: "exit",
115
- description: "Called when there are no more changes to be made. All the changes are done",
116
- parameters: {
117
- type: "object",
118
- properties: {
119
- reason: {
120
- type: "string",
121
- description: "Reason for marking the task as done.",
122
- },
123
- },
124
- additionalProperties: false,
125
- },
126
- },
127
- },
128
- };
129
- return [planner, exit].map((tool) => tool.schema);
130
- }
131
- async function getPlanForCodeEditorAgent({ prompt, trace, }) {
132
- const promptSpan = trace?.span({
133
- name: "repo-edit-planner-agent",
134
- input: {
135
- prompt,
136
- },
137
- });
138
- const llm = new llm_1.LLM({
139
- trace: promptSpan,
140
- provider: "openai",
141
- defaultModel: "o3-mini-2025-01-31",
142
- providerApiKey: constants_1.MODEL_API_KEYS["openai"],
143
- });
144
- const completion = await llm.createChatCompletion({
145
- messages: prompt,
146
- modelParameters: {
147
- max_completion_tokens: constants_1.DEFAULT_O1_MODEL_PARAMETERS.max_completion_tokens,
148
- reasoning_effort: "high",
149
- tool_choice: "required",
150
- },
151
- trace: promptSpan,
152
- tools: getPlannerToolCalls(),
153
- });
154
- promptSpan?.end({ output: { completion } });
155
- if (!completion?.tool_calls || completion?.tool_calls?.length === 0) {
156
- return;
157
- }
158
- if (completion.tool_calls[0].function.name === "exit") {
159
- return;
160
- }
161
- if (completion.tool_calls[0].function.name === "change_plan") {
162
- const args = completion.tool_calls[0].function.arguments;
163
- const plan = JSON.parse(args).plan;
164
- return plan;
165
- }
166
- }
167
- function systemPromptBuilderForRepoEdit(files) {
168
- const prompt = `
169
- You are an expert QA automation engineer well versed in Playwright and Typescript and is given an objective to update tests in the repository on the basis of task provided.
170
-
171
- Directory structure for the repository:
172
- └── /
173
- ├── tests/
174
- ├────test-data/
175
- │ └── index.ts
176
- ├── pages/
177
- ├── playwright.config.ts
178
- ├── app_knowledge.md
179
- ├── .eslintrc.js
180
- ├── package.json
181
- └── tsconfig.json
182
-
183
- Explanation of repository structure:
184
- - tests: this is a directory where all tests and fixtures are kept. All spec files here end with ".spec.ts" as naming convention. There is an exception for Playwright fixtures file. Fixtures file is named as "fixtures.ts"
185
- - test-data: this is a directory where all the test data are kept.
186
- - pages: this is a directory where all reusable page object model methods are kept. Page object model methods are written in a pure functional convention. These methods are reusable methods created to be used across tests. This is also a directory where all the utility methods are kept which can be executed independent of the Playwright tests.
187
-
188
- Coding principles and guidelines:
189
-
190
- ## Code Style and Structure
191
- - Write concise, maintainable, and technically accurate TypeScript code with relevant examples.
192
- - Use functional and declarative programming patterns; avoid classes.
193
- - Use types to describe the shape of data and the behavior of functions.
194
- - Favour iteration and modularisation to adhere to DRY principles and avoid code duplication.
195
- - Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
196
- - Organise files systematically: each file should contain only related content, such as exported components, subcomponents, helpers, static content, and types.
197
- - Page object models are pure functions and are stateless.
198
-
199
- ## Naming Conventions
200
- - Use lowercase with dashes for directories (e.g., tests/auth-wizard).
201
- - Favour named exports for functions.
202
-
203
- ## TypeScript Usage
204
- - Use TypeScript for all code; prefer interfaces over types for their extendability and ability to merge.
205
- - Avoid enums; use maps instead for better type safety and flexibility.
206
- - Use functional components with TypeScript interfaces.
207
-
208
- ## Syntax and Formatting
209
- - Use the "function" keyword for pure functions to benefit from hoisting and clarity.
210
-
211
- You will also be provided with current test files, fixtures and page object models for you to use and update code as per the task provided to you.
212
-
213
- Here is the list of the files in the repository:
214
- ${files}
215
- `;
216
- return prompt;
217
- }
218
- function userPromptBuilderForStrReplace(plan) {
219
- const prompt = `
220
- You need to work to achieve the plan provided to you.
221
-
222
- Plan:
223
- ${plan}
224
-
225
- In order to execute the plan, FOLLOW BELOW STEPS:
226
- - First go through the files in the repository and understand the code and the dependencies.
227
- - Read the plan and figure out what are the changes that needs to be made.
228
- - List down the changes required to execute the plan.
229
- - Pick each change and identify the file path which needs the change, the reason for change and the code change they need.
230
- - Use 'create_file' tool to create a new file if the file doesn't exist.
231
- - Use separate 'str_replace' tool to make the changes for each update, even if the changes are in the same file.
232
- - You can provide multiple 'str_replace' tool calls in the response.
233
- - After making the changes check if the changes are made to all the files if not apply the changes to the remaining files.
234
- - Also ensure that no extra changes are made to the code.
235
-
236
- Notes for using the 'str_replace' command:
237
- * The 'oldCode' parameter should match EXACTLY one or more consecutive lines from the original file. Be mindful of whitespaces!
238
- * If the 'oldCode' parameter is not unique in the file, the replacement will not be performed. Make sure to include enough context in 'oldCode' to make it unique
239
- * The 'newCode' parameter should contain the edited lines that should replace the 'oldCode'
240
-
241
- Notes for using the 'create_file' command:
242
- * The 'create_file' command cannot be used if the specified 'filePath' already exists as a file.
243
- `;
244
- return prompt;
245
- }
246
- function userPromptBuilderForPlanner(task) {
247
- return `
248
- You need to work towards completing the task provided to you.
249
-
250
- Task:
251
- ${task}
252
-
253
- In order to execute the task, FOLLOW BELOW STEPS:
254
- - First go through the files in the repository and understand the code and the dependencies.
255
- - Read the task and figure out what are the changes that needs to be made.
256
- - List down the changes required for the given task.
257
- - If there are no changes to be made, respond with "exit" tool call to exit the conversation.
258
- - Craft a prompt for the agent to make the changes to the code.
259
- - The plan should be readable and easy to understand.
260
- - The plan should contain the details of the changes to be made such as file path, test name etc.
261
- - If there are multiple changes in the same file, mention those separately in the plan.
262
- `;
263
- }
264
- function deDupUpdatedFiles(updatedFiles) {
265
- return updatedFiles.filter((change, index, self) => index ===
266
- self.findIndex((existing) => existing.filePath === change.filePath));
267
- }
268
- async function generateCodeAndApplyChanges({ task, trace, logger, getRelevantFiles, }) {
269
- // Reducing this from 5 to 3, if the required changes are getting missed will change it back.
270
- let planRetries = 3;
271
- let updatedFiles = [];
272
- while (planRetries--) {
273
- const generateCodeAndApplyChangesSpan = trace?.span({
274
- name: "generate-code-apply-changes",
275
- input: {
276
- task,
277
- },
278
- });
279
- const { prompt: files } = await getRelevantFiles();
280
- if (!files) {
281
- return deDupUpdatedFiles(updatedFiles);
282
- }
283
- let strReplacePlan = await getPlanForCodeEditorAgent({
284
- prompt: [
285
- {
286
- role: "system",
287
- content: systemPromptBuilderForRepoEdit(files),
288
- },
289
- {
290
- role: "user",
291
- content: userPromptBuilderForPlanner(task),
292
- },
293
- ],
294
- trace: generateCodeAndApplyChangesSpan,
295
- logger,
296
- });
297
- if (!strReplacePlan) {
298
- await (0, llm_1.flushAllTraces)();
299
- return deDupUpdatedFiles(updatedFiles);
300
- }
301
- const promptForStrReplace = [
302
- {
303
- role: "system",
304
- content: systemPromptBuilderForRepoEdit(files),
305
- },
306
- {
307
- role: "user",
308
- content: userPromptBuilderForStrReplace(strReplacePlan),
309
- },
310
- ];
311
- const codeEditorSpan = generateCodeAndApplyChangesSpan?.span({
312
- name: "code-editor-agent",
313
- input: {
314
- prompt: promptForStrReplace,
315
- },
316
- });
317
- const llm = new llm_1.LLM({
318
- trace: codeEditorSpan,
319
- provider: "anthropic",
320
- defaultModel: "claude-3-5-sonnet-20240620",
321
- providerApiKey: constants_1.MODEL_API_KEYS["anthropic"],
322
- });
323
- const completion = await llm.createChatCompletion({
324
- messages: promptForStrReplace,
325
- modelParameters: {
326
- ...constants_1.DEFAULT_MODEL_PARAMETERS,
327
- temperature: 0.1,
328
- tool_choice: "required",
329
- },
330
- trace: codeEditorSpan,
331
- tools: getCodeEditorToolCalls(),
332
- });
333
- codeEditorSpan?.end({ output: { completion } });
334
- if (!completion?.tool_calls || completion?.tool_calls?.length === 0) {
335
- continue;
336
- }
337
- // Filter out the tool calls which are for creating new files
338
- const createFileToolCalls = completion.tool_calls.filter((tc) => tc.function.name === types_1.CodeEditorToolCall.CREATE_FILE);
339
- if (createFileToolCalls.length > 0) {
340
- console.log(`create_file tool calls: `, createFileToolCalls);
341
- }
342
- await Promise.all(createFileToolCalls.map((tc) => {
343
- return (async () => {
344
- const args = JSON.parse(tc.function.arguments);
345
- updatedFiles.push({
346
- filePath: args.filePath,
347
- oldCode: "",
348
- newCode: args.code,
349
- reason: args.reason,
350
- });
351
- fs_1.default.mkdirSync((0, path_1.dirname)(args.filePath), { recursive: true });
352
- fs_1.default.writeFileSync(args.filePath, args.code, "utf-8");
353
- console.log(`Created file: ${args.filePath}`);
354
- })();
355
- }));
356
- const strReplaceToolCalls = completion.tool_calls.filter((tc) => tc.function.name === types_1.CodeEditorToolCall.STR_REPLACE);
357
- if (strReplaceToolCalls.length > 0) {
358
- console.log(`str_replace tool calls: `, strReplaceToolCalls);
359
- }
360
- // Filter out the tool calls which are for replacing code in existing files
361
- const fileChanges = strReplaceToolCalls
362
- .map((toolCall) => JSON.parse(toolCall.function.arguments))
363
- .filter((f) => f.filePath && fs_1.default.existsSync(f.filePath));
364
- // We add all the suggested changes to the updatedFiles array
365
- // This is used to validate and format files later
366
- updatedFiles.push(...fileChanges);
367
- // applyChangesResponse contains the errors occurred while applying the changes
368
- const updates = await (0, utils_1.applyFileChangesUsingStrReplace)({
369
- trace: codeEditorSpan,
370
- fileChanges,
371
- logger,
372
- });
373
- const failedCodeUpdates = updates.filter((f) => f?.error);
374
- if (failedCodeUpdates.length > 0) {
375
- logger?.log(`Failed to apply changes, retrying...`, failedCodeUpdates);
376
- }
377
- }
378
- return deDupUpdatedFiles(updatedFiles);
379
- }
@@ -1,23 +0,0 @@
1
- import { TraceClient } from "@empiricalrun/llm";
2
- import { ChatCompletionMessageParam } from "openai/resources/index.mjs";
3
- import { CustomLogger } from "../../bin/logger";
4
- import { CodeUpdate } from "./types";
5
- export declare function generateCodeUsingRepoAgent({ task, trace, repoFiles, logger, }: {
6
- trace?: TraceClient;
7
- task: string;
8
- repoFiles: string;
9
- logger?: CustomLogger;
10
- }): Promise<{
11
- prompt: ChatCompletionMessageParam[];
12
- agentResponse: string;
13
- fileChanges: CodeUpdate[];
14
- }>;
15
- export declare function repoEditAgent({ trace, task, logger, }: {
16
- trace?: TraceClient;
17
- task: string;
18
- logger?: CustomLogger;
19
- }): Promise<{
20
- prompt: ChatCompletionMessageParam[];
21
- fileChanges: CodeUpdate[];
22
- }>;
23
- //# sourceMappingURL=repo-edit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"repo-edit.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/repo-edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAExE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,wBAAsB,0BAA0B,CAAC,EAC/C,IAAI,EACJ,KAAK,EACL,SAAS,EAET,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC,CA6CD;AAED,wBAAsB,aAAa,CAAC,EAClC,KAAK,EACL,IAAI,EACJ,MAAM,GACP,EAAE;IACD,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,0BAA0B,EAAE,CAAC;IACrC,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B,CAAC,CA8BD"}
@@ -1,81 +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.generateCodeUsingRepoAgent = generateCodeUsingRepoAgent;
7
- exports.repoEditAgent = repoEditAgent;
8
- const fs_1 = __importDefault(require("fs"));
9
- const context_1 = require("../../bin/utils/context");
10
- const web_1 = require("../../bin/utils/platform/web");
11
- const generate_code_apply_changes_1 = require("./generate-code-apply-changes");
12
- const utils_1 = require("./utils");
13
- async function generateCodeUsingRepoAgent({ task, trace, repoFiles, logger, }) {
14
- const repoEditSpan = trace?.span({
15
- name: "repo-edit",
16
- input: { task },
17
- });
18
- const prompt = [
19
- {
20
- role: "system",
21
- content: (0, generate_code_apply_changes_1.systemPromptBuilderForRepoEdit)(repoFiles),
22
- },
23
- {
24
- role: "user",
25
- content: `
26
- You need to work towards completing the task provided to you.
27
-
28
- Task:
29
- ${task}
30
-
31
- In order to execute the task, FOLLOW BELOW STEPS:
32
- - First go through the files in the repository and understand the code and the dependencies.
33
- - Read the task and figure out what are the changes that needs to be made.
34
- - List down the changes required for the given task.
35
- - Create a clear, detailed plan which will be used as a prompt for the code change agent. Include specifics like file paths and test names. If there are multiple changes in one file, list them separately.
36
- - The plan should be readable and easy to understand.
37
-
38
- If all the changes are done, respond with "exit" tool call otherwise respond with "change-plan" tool call.
39
- `,
40
- },
41
- ];
42
- const fileChanges = await (0, generate_code_apply_changes_1.generateCodeAndApplyChanges)({
43
- task,
44
- trace: repoEditSpan,
45
- getRelevantFiles: async () => await (0, context_1.generateTxtForRepository)(),
46
- logger,
47
- });
48
- repoEditSpan?.end({
49
- output: { fileChanges },
50
- });
51
- return {
52
- prompt,
53
- fileChanges,
54
- agentResponse: "",
55
- };
56
- }
57
- async function repoEditAgent({ trace, task, logger, }) {
58
- logger?.log(`Starting repo agent: [trace](${trace?.getTraceUrl()})`);
59
- const { prompt: repoFiles } = await (0, context_1.generateTxtForRepository)();
60
- const repoAgentOutput = await generateCodeUsingRepoAgent({
61
- task,
62
- trace,
63
- repoFiles: repoFiles,
64
- logger,
65
- });
66
- const updates = repoAgentOutput.fileChanges;
67
- await (0, utils_1.validateTypesAndFormatCode)({
68
- validateTypes: true,
69
- trace,
70
- testCase: {},
71
- filePaths: updates.map((f) => f.filePath),
72
- });
73
- await Promise.all(updates.map((f) => {
74
- return (async () => {
75
- if (fs_1.default.existsSync(f.filePath)) {
76
- await (0, web_1.lintErrors)(f.filePath);
77
- }
78
- })();
79
- }));
80
- return repoAgentOutput;
81
- }
@@ -1,20 +0,0 @@
1
- import { TraceClient } from "@empiricalrun/llm";
2
- import type { TestCase } from "@empiricalrun/shared-types";
3
- import OpenAI from "openai";
4
- import { CreateTestCodeUpdate } from "./types";
5
- export declare function createTestWithCodeAgent({ testCase, file, repoFiles, trace, }: {
6
- testCase: TestCase;
7
- file: string;
8
- repoFiles: string | undefined;
9
- trace?: TraceClient;
10
- }): Promise<{
11
- prompt: OpenAI.Chat.Completions.ChatCompletionMessageParam[];
12
- agentResponse: string;
13
- fileChanges: CreateTestCodeUpdate[];
14
- }>;
15
- export declare function generateTestWithCodegen({ testCase, file, trace, }: {
16
- testCase: TestCase;
17
- file: string;
18
- trace?: TraceClient;
19
- }): Promise<TestCase[] | void>;
20
- //# sourceMappingURL=run.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/agent/codegen/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,MAAM,MAAM,QAAQ,CAAC;AAa5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAQ/C,wBAAsB,uBAAuB,CAAC,EAC5C,QAAQ,EACR,IAAI,EACJ,SAAS,EACT,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,0BAA0B,EAAE,CAAC;IAC7D,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,oBAAoB,EAAE,CAAC;CACrC,CAAC,CAyDD;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,QAAQ,EACR,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,GAAG,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CA2D7B"}
@@ -1,116 +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.createTestWithCodeAgent = createTestWithCodeAgent;
7
- exports.generateTestWithCodegen = generateTestWithCodegen;
8
- const llm_1 = require("@empiricalrun/llm");
9
- const fs_1 = __importDefault(require("fs"));
10
- const logger_1 = require("../../bin/logger");
11
- const context_1 = require("../../bin/utils/context");
12
- const web_1 = require("../../bin/utils/platform/web");
13
- const constants_1 = require("../../constants");
14
- const promptTemplate_0 = "{{#section \"system\"}}\nYou are a software test engineer who is given a task to write test cases in a Playwright test repository.\nYou will be provided with current test files, fixtures and page object models for you to use and update code as per the\ntask provided to you.\nYou need to respond with file path, the new test code block to be updated in the file and the reason for the change.\n\nHere is the list of files:\n\n{{repoFiles}}\n{{/section}}\n\n{{#section \"user\"}}\nTask: {{task}}\n\n## Follow these instructions before responding with output:\n- Scan the file '{{testFilePath}}' and check whether test case with name '{{testCaseName}}' exists in the file\n- If it exists do not update the file\n- else respond with <file_path></file_path>, <code_block></code_block> and <change></change> as xml tags\n- Only respond with single code_block in the response containing only the test code block to be updated\n{{/section}}";
15
- const update_flow_1 = require("./update-flow");
16
- const utils_1 = require("./utils");
17
- async function createTestWithCodeAgent({ testCase, file, repoFiles, trace, }) {
18
- const task = `
19
- Create a new test case with name '${testCase.name}' at file path '${file}'
20
- ${testCase.suites.length
21
- ? `
22
- Put this test case inside describe blocks named: ${testCase.suites.join(" > ")}`
23
- : ""}
24
-
25
- In the above test, write code that performs these actions and ONLY these actions:
26
- ${testCase.steps.join("\n")}`;
27
- const prompt = (0, llm_1.compilePrompt)(promptTemplate_0, {
28
- task,
29
- repoFiles,
30
- testCaseName: testCase.name,
31
- testFilePath: file,
32
- });
33
- const createTestSpan = trace?.span({
34
- name: "create-test",
35
- input: {
36
- testCase,
37
- repoFiles,
38
- testFilePath: file,
39
- task,
40
- },
41
- });
42
- const llm = new llm_1.LLM({
43
- trace,
44
- provider: "anthropic",
45
- defaultModel: "claude-3-5-sonnet-20240620",
46
- providerApiKey: constants_1.MODEL_API_KEYS["anthropic"],
47
- });
48
- const updatedUsageExampleMessage = await llm.createChatCompletion({
49
- messages: prompt,
50
- trace,
51
- traceName: "create-test-llm",
52
- modelParameters: {
53
- ...constants_1.DEFAULT_MODEL_PARAMETERS,
54
- },
55
- });
56
- const updates = (0, utils_1.extractCreateTestUpdates)(updatedUsageExampleMessage?.content);
57
- createTestSpan?.end({
58
- output: { updates },
59
- });
60
- console.log("Updates: ", updates);
61
- return {
62
- prompt,
63
- agentResponse: updatedUsageExampleMessage?.content,
64
- fileChanges: updates,
65
- };
66
- }
67
- async function generateTestWithCodegen({ testCase, file, trace, }) {
68
- const logger = new logger_1.CustomLogger();
69
- if (!fs_1.default.existsSync(file)) {
70
- logger.log(`Creating a new spec file: ${file}`);
71
- fs_1.default.writeFileSync(file, "");
72
- }
73
- const context = await (0, context_1.contextForGeneration)(file);
74
- const { testFileContent } = context;
75
- const { testBlock } = (0, web_1.getTypescriptTestBlock)({
76
- scenarioName: testCase?.name,
77
- content: testFileContent,
78
- suites: testCase?.suites,
79
- });
80
- // Update the test if it already exists
81
- const isUpdate = !!testBlock;
82
- if (isUpdate) {
83
- logger.log(`Updating the test '${testCase.name}': [View trace](${trace?.getTraceUrl()})`);
84
- return await (0, update_flow_1.updateTest)({
85
- testCase,
86
- file,
87
- trace,
88
- });
89
- }
90
- logger?.log(`Creating a new test case '${testCase.name}': [trace](${trace?.getTraceUrl()})`);
91
- // Create the test if it doesn't exist
92
- const { prompt: repoFiles } = await (0, context_1.generateTxtForRepository)();
93
- const updates = await createTestWithCodeAgent({
94
- testCase,
95
- file,
96
- repoFiles,
97
- trace,
98
- });
99
- await (0, utils_1.applyFileChangesForCreateTest)({
100
- trace,
101
- fileChanges: updates.fileChanges,
102
- });
103
- await (0, utils_1.validateTypesAndFormatCode)({
104
- validateTypes: true,
105
- trace,
106
- testCase: {},
107
- filePaths: updates.fileChanges.map((f) => f.filePath),
108
- });
109
- await Promise.all(updates.fileChanges.map((f) => {
110
- return (async () => {
111
- if (fs_1.default.existsSync(f.filePath)) {
112
- await (0, web_1.lintErrors)(f.filePath);
113
- }
114
- })();
115
- }));
116
- }
@@ -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;
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,GAAU,uDAK/C;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB,KAAG,OAAO,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,OAAO,CAAC;IAClC,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAwDA,CAAC"}