@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
@@ -0,0 +1,143 @@
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.textEditorTools = void 0;
7
+ exports.strReplaceEditorExecutor = strReplaceEditorExecutor;
8
+ const path_1 = __importDefault(require("path"));
9
+ const str_replace_editor_1 = require("../definitions/str_replace_editor");
10
+ const create_1 = require("./create");
11
+ const insert_1 = require("./insert");
12
+ const replace_1 = require("./replace");
13
+ const view_1 = require("./view");
14
+ /**
15
+ * Our implementation of Claude's built-in text editor tool
16
+ * https://docs.anthropic.com/en/docs/build-with-claude/tool-use/text-editor-tool
17
+ */
18
+ async function strReplaceEditorExecutor({ input, repoPath, collectArtifacts, apiClient, }) {
19
+ const repoDir = repoPath;
20
+ const { path: filePath } = input;
21
+ const absoluteFilePath = path_1.default.join(repoDir, filePath);
22
+ const repoName = path_1.default.basename(repoPath);
23
+ try {
24
+ switch (input.command) {
25
+ case "view":
26
+ return (0, view_1.fileViewExecutor)({
27
+ input,
28
+ repoName,
29
+ apiClient,
30
+ repoPath,
31
+ });
32
+ case "create":
33
+ return (0, create_1.fileCreateExecutor)({
34
+ input,
35
+ filePath,
36
+ absoluteFilePath,
37
+ repoDir,
38
+ collectArtifacts,
39
+ });
40
+ case "str_replace":
41
+ return (0, replace_1.fileStrReplaceExecutor)({
42
+ input,
43
+ filePath,
44
+ absoluteFilePath,
45
+ repoDir,
46
+ collectArtifacts,
47
+ });
48
+ case "insert":
49
+ return (0, insert_1.fileInsertExecutor)({
50
+ input,
51
+ filePath,
52
+ absoluteFilePath,
53
+ repoDir,
54
+ collectArtifacts,
55
+ });
56
+ case "undo_edit":
57
+ return {
58
+ result: `undo_edit tool is not supported.`,
59
+ isError: true,
60
+ };
61
+ default:
62
+ throw new Error(`Unknown command: ${input.command}`);
63
+ }
64
+ }
65
+ catch (error) {
66
+ return {
67
+ result: error instanceof Error ? error.message : "Unknown error occurred",
68
+ isError: true,
69
+ };
70
+ }
71
+ }
72
+ const fileViewTool = {
73
+ ...str_replace_editor_1.textEditorTools["fileViewTool"],
74
+ execute: async (params) => {
75
+ const { input, apiClient } = params;
76
+ const { repoPath } = params;
77
+ return strReplaceEditorExecutor({
78
+ input: {
79
+ command: "view",
80
+ path: input.path,
81
+ },
82
+ repoPath,
83
+ apiClient,
84
+ });
85
+ },
86
+ };
87
+ const fileCreateTool = {
88
+ ...str_replace_editor_1.textEditorTools["fileCreateTool"],
89
+ execute: async (params) => {
90
+ const { input } = params;
91
+ const { repoPath, collectArtifacts } = params;
92
+ return strReplaceEditorExecutor({
93
+ input: {
94
+ command: "create",
95
+ path: input.path,
96
+ file_text: input.file_text,
97
+ },
98
+ repoPath,
99
+ collectArtifacts,
100
+ });
101
+ },
102
+ };
103
+ const stringReplaceTool = {
104
+ ...str_replace_editor_1.textEditorTools["stringReplaceTool"],
105
+ execute: async (params) => {
106
+ const { input } = params;
107
+ const { repoPath, collectArtifacts } = params;
108
+ return strReplaceEditorExecutor({
109
+ input: {
110
+ command: "str_replace",
111
+ path: input.path,
112
+ old_str: input.old_str,
113
+ new_str: input.new_str,
114
+ },
115
+ repoPath,
116
+ collectArtifacts,
117
+ });
118
+ },
119
+ };
120
+ const stringInsertTool = {
121
+ ...str_replace_editor_1.textEditorTools["stringInsertTool"],
122
+ execute: async (params) => {
123
+ const { input } = params;
124
+ const { repoPath, collectArtifacts } = params;
125
+ return strReplaceEditorExecutor({
126
+ input: {
127
+ command: "insert",
128
+ path: input.path,
129
+ insert_line: input.insert_line,
130
+ new_str: input.new_str,
131
+ },
132
+ repoPath,
133
+ collectArtifacts,
134
+ });
135
+ },
136
+ };
137
+ const textEditorTools = [
138
+ fileViewTool,
139
+ fileCreateTool,
140
+ stringReplaceTool,
141
+ stringInsertTool,
142
+ ];
143
+ exports.textEditorTools = textEditorTools;
@@ -0,0 +1,11 @@
1
+ import { CollectArtifacts, ToolResult } from "@empiricalrun/shared-types";
2
+ import { StrReplaceInputParams } from "./shared/helpers";
3
+ declare function fileInsertExecutor({ input, filePath, absoluteFilePath, repoDir, collectArtifacts, }: {
4
+ input: StrReplaceInputParams;
5
+ filePath: string;
6
+ absoluteFilePath: string;
7
+ repoDir: string;
8
+ collectArtifacts?: CollectArtifacts;
9
+ }): Promise<ToolResult>;
10
+ export { fileInsertExecutor };
11
+ //# sourceMappingURL=insert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../../src/tools/file-operations/insert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAK1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,iBAAe,kBAAkB,CAAC,EAChC,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,gBAAgB,GACjB,EAAE;IACD,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,GAAG,OAAO,CAAC,UAAU,CAAC,CAqDtB;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,61 @@
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.fileInsertExecutor = fileInsertExecutor;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const web_1 = require("../../bin/utils/platform/web");
9
+ const git_helper_1 = require("./shared/git-helper");
10
+ async function fileInsertExecutor({ input, filePath, absoluteFilePath, repoDir, collectArtifacts, }) {
11
+ if (!fs_1.default.existsSync(absoluteFilePath)) {
12
+ return {
13
+ result: `Error: File ${filePath} not found. Please provide relative file path to the repository.`,
14
+ isError: true,
15
+ };
16
+ }
17
+ if (input.insert_line === undefined) {
18
+ return {
19
+ result: "Error: insert_line is required for insert command",
20
+ isError: true,
21
+ };
22
+ }
23
+ let textToInsert = input.insert_text || input.new_str;
24
+ if (!textToInsert) {
25
+ return {
26
+ result: "Error: insert_text or new_str are required for insert command",
27
+ isError: true,
28
+ };
29
+ }
30
+ const content = fs_1.default.readFileSync(absoluteFilePath, "utf8");
31
+ const lines = content.split("\n");
32
+ if (input.insert_line < 0) {
33
+ return {
34
+ result: "Error: insert_line must be greater than or equal to 0.",
35
+ isError: true,
36
+ };
37
+ }
38
+ if (input.insert_line > lines.length) {
39
+ return {
40
+ result: `Error: The file at ${filePath} has only ${lines.length} lines, so insert_line must be less than or equal to ${lines.length}. At the maximum value of ${lines.length}, you can insert at the end of the file.`,
41
+ isError: true,
42
+ };
43
+ }
44
+ lines.splice(input.insert_line, 0, textToInsert);
45
+ fs_1.default.writeFileSync(absoluteFilePath, lines.join("\n"));
46
+ // Collect git patch artifact
47
+ await (0, git_helper_1.collectGitPatchArtifact)(filePath, repoDir, "insert", collectArtifacts);
48
+ let insertTypescriptResult = await (0, web_1.runTypescriptCompiler)(repoDir);
49
+ if (!insertTypescriptResult.success) {
50
+ return {
51
+ result: `Insertion in file ${filePath} was applied. However, type checks are failing with errors:\n${insertTypescriptResult.errors.join("\n")}`,
52
+ isError: true,
53
+ };
54
+ }
55
+ else {
56
+ return {
57
+ result: `Insertion in file ${filePath} was applied. Type checks have also passed.`,
58
+ isError: false,
59
+ };
60
+ }
61
+ }
@@ -0,0 +1,11 @@
1
+ import { CollectArtifacts, ToolResult } from "@empiricalrun/shared-types";
2
+ import type { StrReplaceInputParams } from "./shared/helpers";
3
+ declare function fileStrReplaceExecutor({ input, filePath, absoluteFilePath, repoDir, collectArtifacts, }: {
4
+ input: StrReplaceInputParams;
5
+ filePath: string;
6
+ absoluteFilePath: string;
7
+ repoDir: string;
8
+ collectArtifacts?: CollectArtifacts;
9
+ }): Promise<ToolResult>;
10
+ export { fileStrReplaceExecutor };
11
+ //# sourceMappingURL=replace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace.d.ts","sourceRoot":"","sources":["../../../src/tools/file-operations/replace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAK1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAG9D,iBAAe,sBAAsB,CAAC,EACpC,KAAK,EACL,QAAQ,EACR,gBAAgB,EAChB,OAAO,EACP,gBAAgB,GACjB,EAAE;IACD,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC,GAAG,OAAO,CAAC,UAAU,CAAC,CAiFtB;AAED,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
@@ -0,0 +1,80 @@
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.fileStrReplaceExecutor = fileStrReplaceExecutor;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const web_1 = require("../../bin/utils/platform/web");
9
+ const git_helper_1 = require("./shared/git-helper");
10
+ const helpers_1 = require("./shared/helpers");
11
+ async function fileStrReplaceExecutor({ input, filePath, absoluteFilePath, repoDir, collectArtifacts, }) {
12
+ if (!fs_1.default.existsSync(absoluteFilePath)) {
13
+ return {
14
+ result: `Error: File ${filePath} not found. Please provide relative file path to the repository.`,
15
+ isError: true,
16
+ };
17
+ }
18
+ if (!input.old_str) {
19
+ return {
20
+ result: "Error: old_str is required for str_replace command",
21
+ isError: true,
22
+ };
23
+ }
24
+ if (input.new_str === undefined || input.new_str === null) {
25
+ // "" is valid as new_str, so we check for nullish -- not falsy
26
+ return {
27
+ result: "Error: new_str is required for str_replace command",
28
+ isError: true,
29
+ };
30
+ }
31
+ const content = fs_1.default.readFileSync(absoluteFilePath, "utf8");
32
+ // Normalize newlines in both the content and search string
33
+ const normalizedContent = content.replace(/\r\n/g, "\n");
34
+ const normalizedOldStr = input.old_str
35
+ .replace(/\\n/g, "\n")
36
+ .replace(/\r\n/g, "\n");
37
+ if (!normalizedContent.includes(normalizedOldStr)) {
38
+ return {
39
+ result: `old_str not found in file: ${filePath}`,
40
+ isError: true,
41
+ };
42
+ }
43
+ else {
44
+ const escapedOldStr = (0, helpers_1.escapeRegExp)(normalizedOldStr);
45
+ const occurences = normalizedContent.match(new RegExp(escapedOldStr, "g"));
46
+ if (occurences && occurences.length > 1) {
47
+ const uniqueContexts = (0, helpers_1.getUniqueOccurences)(content, input.old_str);
48
+ if (uniqueContexts.length === 0) {
49
+ return {
50
+ result: `Error: old_str found ${occurences.length} times in file: ${filePath}, but no unique contexts could be identified. Try using a more specific string.`,
51
+ isError: true,
52
+ };
53
+ }
54
+ const uniqueContextsString = uniqueContexts
55
+ .map(({ uniqueContext, lineNumber }, idx) => `${idx + 1}. For occurence at line number ${lineNumber}, unique context is:\n\`\`\`\n${uniqueContext}\n\`\`\`\n`)
56
+ .join("\n");
57
+ return {
58
+ result: `Error: old_str found ${occurences.length} times in file: ${filePath}. Please use one of these unique contexts instead:\n\n${uniqueContextsString}`,
59
+ isError: true,
60
+ };
61
+ }
62
+ const newContent = normalizedContent.replace(normalizedOldStr, input.new_str);
63
+ fs_1.default.writeFileSync(absoluteFilePath, newContent);
64
+ // Collect git patch artifact
65
+ await (0, git_helper_1.collectGitPatchArtifact)(filePath, repoDir, "replace", collectArtifacts);
66
+ let strReplaceTypescriptResult = await (0, web_1.runTypescriptCompiler)(repoDir);
67
+ if (!strReplaceTypescriptResult.success) {
68
+ return {
69
+ result: `Edits to file ${filePath} have been applied. However, type checks are failing with errors:\n\n${strReplaceTypescriptResult.errors.join("\n")}`,
70
+ isError: true,
71
+ };
72
+ }
73
+ else {
74
+ return {
75
+ result: `Edits to file ${filePath} have been applied. Type checks have also passed.`,
76
+ isError: false,
77
+ };
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,4 @@
1
+ import { CollectArtifacts } from "@empiricalrun/shared-types";
2
+ declare function collectGitPatchArtifact(filePath: string, repoDir: string, operation: "create" | "replace" | "insert", collectArtifacts?: CollectArtifacts): Promise<void>;
3
+ export { collectGitPatchArtifact };
4
+ //# sourceMappingURL=git-helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-helper.d.ts","sourceRoot":"","sources":["../../../../src/tools/file-operations/shared/git-helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EACjB,MAAM,4BAA4B,CAAC;AAKpC,iBAAe,uBAAuB,CACpC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,QAAQ,GAAG,SAAS,GAAG,QAAQ,EAC1C,gBAAgB,CAAC,EAAE,gBAAgB,GAClC,OAAO,CAAC,IAAI,CAAC,CAoBf;AAED,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
@@ -0,0 +1,29 @@
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.collectGitPatchArtifact = collectGitPatchArtifact;
7
+ const path_1 = __importDefault(require("path"));
8
+ const git_1 = require("../../executor/utils/git");
9
+ async function collectGitPatchArtifact(filePath, repoDir, operation, collectArtifacts) {
10
+ if (!collectArtifacts)
11
+ return;
12
+ try {
13
+ const gitPatch = operation === "create"
14
+ ? (0, git_1.getGitDiffForNewFile)(filePath, repoDir)
15
+ : (0, git_1.getGitDiff)(filePath, repoDir);
16
+ if (gitPatch.trim()) {
17
+ const patchArtifact = {
18
+ name: `${path_1.default.basename(filePath, path_1.default.extname(filePath))}_${operation}.patch`,
19
+ contentType: "text/plain",
20
+ data: Buffer.from(gitPatch, "utf-8"),
21
+ };
22
+ collectArtifacts([patchArtifact]);
23
+ }
24
+ }
25
+ catch (error) {
26
+ // Ignore git diff errors, don't fail the operation
27
+ console.warn(`Failed to generate git patch for ${filePath}:`, error);
28
+ }
29
+ }
@@ -0,0 +1,19 @@
1
+ export interface StrReplaceInputParams {
2
+ command: string;
3
+ path: string;
4
+ view_range?: [number, number];
5
+ old_str?: string;
6
+ new_str?: string;
7
+ file_text?: string;
8
+ insert_line?: number;
9
+ insert_text?: string;
10
+ }
11
+ declare function formatLinesWithNumbers(content: string, viewRange?: [number, number]): string;
12
+ declare function isBinaryFile(filePath: string): boolean;
13
+ declare function getUniqueOccurences(contents: string, old_str: string): {
14
+ uniqueContext: string;
15
+ lineNumber: number;
16
+ }[];
17
+ declare function escapeRegExp(text: string): string;
18
+ export { escapeRegExp, formatLinesWithNumbers, getUniqueOccurences, isBinaryFile, };
19
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/tools/file-operations/shared/helpers.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IAGb,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAG9B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,SAAS,CAAC,EAAE,MAAM,CAAC;IAKnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,iBAAS,sBAAsB,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,GAC3B,MAAM,CAaR;AAED,iBAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CA2D/C;AAED,iBAAS,mBAAmB,CAC1B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,CAyDjD;AAED,iBAAS,YAAY,CAAC,IAAI,EAAE,MAAM,UAEjC;AAED,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,mBAAmB,EACnB,YAAY,GACb,CAAC"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.escapeRegExp = escapeRegExp;
4
+ exports.formatLinesWithNumbers = formatLinesWithNumbers;
5
+ exports.getUniqueOccurences = getUniqueOccurences;
6
+ exports.isBinaryFile = isBinaryFile;
7
+ function formatLinesWithNumbers(content, viewRange) {
8
+ const lines = content.split("\n");
9
+ if (viewRange) {
10
+ const [start, end] = viewRange;
11
+ const endLine = end === -1 ? lines.length : end;
12
+ return lines
13
+ .slice(start - 1, endLine)
14
+ .map((line, idx) => `${start + idx}: ${line}`)
15
+ .join("\n");
16
+ }
17
+ return lines.map((line, idx) => `${idx + 1}: ${line}`).join("\n");
18
+ }
19
+ function isBinaryFile(filePath) {
20
+ const binaryExtensions = new Set([
21
+ // Images
22
+ ".jpg",
23
+ ".jpeg",
24
+ ".png",
25
+ ".gif",
26
+ ".bmp",
27
+ ".svg",
28
+ ".webp",
29
+ ".ico",
30
+ // Audio
31
+ ".mp3",
32
+ ".wav",
33
+ ".flac",
34
+ ".aac",
35
+ ".ogg",
36
+ // Video
37
+ ".mp4",
38
+ ".avi",
39
+ ".mov",
40
+ ".wmv",
41
+ ".flv",
42
+ ".webm",
43
+ // Archives
44
+ ".zip",
45
+ ".rar",
46
+ ".7z",
47
+ ".tar",
48
+ ".gz",
49
+ ".bz2",
50
+ // Executables
51
+ ".exe",
52
+ ".dll",
53
+ ".so",
54
+ ".dylib",
55
+ // Documents (binary formats)
56
+ ".pdf",
57
+ ".doc",
58
+ ".docx",
59
+ ".xls",
60
+ ".xlsx",
61
+ ".ppt",
62
+ ".pptx",
63
+ // Fonts
64
+ ".ttf",
65
+ ".otf",
66
+ ".woff",
67
+ ".woff2",
68
+ // Other binary
69
+ ".bin",
70
+ ".dat",
71
+ ".db",
72
+ ".sqlite",
73
+ ".node",
74
+ ]);
75
+ const extension = filePath.toLowerCase().substring(filePath.lastIndexOf("."));
76
+ return binaryExtensions.has(extension);
77
+ }
78
+ function getUniqueOccurences(contents, old_str) {
79
+ const lines = contents.split("\n");
80
+ const lineIndices = [];
81
+ lines.forEach((line, index) => {
82
+ if (line.includes(old_str)) {
83
+ lineIndices.push(index);
84
+ }
85
+ });
86
+ if (lineIndices.length === 0) {
87
+ return [];
88
+ }
89
+ if (lineIndices.length == 1) {
90
+ // line number should be 1-indexed, hence we add 1 to the line index
91
+ return [{ uniqueContext: old_str, lineNumber: lineIndices[0] + 1 }];
92
+ }
93
+ const uniqueContexts = [];
94
+ const maxContextSize = Math.min(10, lines.length);
95
+ for (const lineIndex of lineIndices) {
96
+ let contextSize = 0; // Start with just the line itself
97
+ let isUnique = false;
98
+ let context = "";
99
+ while (!isUnique && contextSize < maxContextSize) {
100
+ // Expand context to include more lines (both above and below)
101
+ const startLine = Math.max(0, lineIndex - contextSize);
102
+ const endLine = Math.min(lines.length - 1, lineIndex + contextSize);
103
+ // Extract the context as a group of lines
104
+ context = lines.slice(startLine, endLine + 1).join("\n");
105
+ // Check if this context is unique among all occurrences
106
+ isUnique = lineIndices.every((idx) => {
107
+ if (idx === lineIndex)
108
+ return true; // Skip self
109
+ const otherStartLine = Math.max(0, idx - contextSize);
110
+ const otherEndLine = Math.min(lines.length - 1, idx + contextSize);
111
+ const otherContext = lines
112
+ .slice(otherStartLine, otherEndLine + 1)
113
+ .join("\n");
114
+ return context !== otherContext;
115
+ });
116
+ // If not unique, expand context by one more line in each direction
117
+ if (!isUnique) {
118
+ contextSize++;
119
+ }
120
+ }
121
+ // Only add context if we actually found a unique one
122
+ if (isUnique) {
123
+ uniqueContexts.push({
124
+ uniqueContext: context,
125
+ lineNumber: lineIndex + 1,
126
+ });
127
+ }
128
+ }
129
+ return uniqueContexts;
130
+ }
131
+ function escapeRegExp(text) {
132
+ return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
133
+ }
@@ -0,0 +1,14 @@
1
+ import { IDashboardAPIClient, ToolResult } from "@empiricalrun/shared-types";
2
+ import type { StrReplaceInputParams } from "../shared/helpers";
3
+ type FileViewExecutorOptions = {
4
+ use: "fs" | "github";
5
+ };
6
+ type FileViewExecutorParams = {
7
+ input: StrReplaceInputParams;
8
+ repoName?: string;
9
+ apiClient?: IDashboardAPIClient;
10
+ repoPath: string;
11
+ };
12
+ declare function fileViewExecutor(params: FileViewExecutorParams, options?: FileViewExecutorOptions): Promise<ToolResult>;
13
+ export { fileViewExecutor };
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/file-operations/view/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAQ7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG/D,KAAK,uBAAuB,GAAG;IAC7B,GAAG,EAAE,IAAI,GAAG,QAAQ,CAAC;CACtB,CAAC;AAEF,KAAK,sBAAsB,GAAG;IAC5B,KAAK,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,sBAAsB,EAC9B,OAAO,CAAC,EAAE,uBAAuB,GAChC,OAAO,CAAC,UAAU,CAAC,CAkDrB;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,56 @@
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.fileViewExecutor = fileViewExecutor;
7
+ const path_1 = __importDefault(require("path"));
8
+ const file_info_1 = require("../../../file-info");
9
+ const git_1 = require("../../executor/utils/git");
10
+ const helpers_1 = require("../shared/helpers");
11
+ async function fileViewExecutor(params, options) {
12
+ const { input, repoName, apiClient, repoPath } = params;
13
+ const filePath = input.path;
14
+ if (filePath === undefined || filePath === null) {
15
+ return {
16
+ result: "Error: path is required",
17
+ isError: true,
18
+ };
19
+ }
20
+ if ((0, helpers_1.isBinaryFile)(filePath)) {
21
+ return {
22
+ result: "Error: File is binary, which is not supported",
23
+ isError: true,
24
+ };
25
+ }
26
+ const { use } = options || {};
27
+ const wantsToUseGitHub = use && use === "github";
28
+ const canUseGitHub = wantsToUseGitHub && apiClient && repoName;
29
+ if (wantsToUseGitHub && !canUseGitHub) {
30
+ return {
31
+ result: "Error: GitHub integration is not available",
32
+ isError: true,
33
+ };
34
+ }
35
+ try {
36
+ if (canUseGitHub) {
37
+ const branchName = await (0, git_1.getCurrentBranchName)(repoName);
38
+ return (0, file_info_1.viewFileUsingGitHub)({
39
+ input,
40
+ filePath,
41
+ repoName,
42
+ apiClient,
43
+ branchName,
44
+ });
45
+ }
46
+ const absoluteFilePath = path_1.default.join(repoPath, filePath);
47
+ return (0, file_info_1.viewFileUsingFileSystem)({ input, filePath, absoluteFilePath });
48
+ }
49
+ catch (error) {
50
+ const msg = error instanceof Error ? error.message : "Unknown error occurred";
51
+ return {
52
+ result: `Error in tool execution: ${msg}`,
53
+ isError: true,
54
+ };
55
+ }
56
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/grep/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AA8HnE,eAAO,MAAM,QAAQ,EAAE,IAkBtB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/grep/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAc,MAAM,4BAA4B,CAAC;AA+HnE,eAAO,MAAM,QAAQ,EAAE,IAUtB,CAAC"}
@@ -9,6 +9,7 @@ const path_1 = __importDefault(require("path"));
9
9
  const util_1 = require("util");
10
10
  const zod_1 = require("zod");
11
11
  const repo_tree_1 = require("../../utils/repo-tree");
12
+ const grep_1 = require("../definitions/grep");
12
13
  const ripgrep_1 = require("./ripgrep");
13
14
  const GrepInputSchema = zod_1.z.object({
14
15
  pattern: zod_1.z
@@ -116,15 +117,7 @@ All paths are relative to the current working directory.`;
116
117
  }
117
118
  }
118
119
  exports.grepTool = {
119
- schema: {
120
- name: "grep",
121
- description: `Search for a pattern in files using ripgrep.
122
- If ripgrep is not available, it will fall back to using system grep.
123
-
124
- Search is case insensitive and regex patterns are not supported.`,
125
- parameters: GrepInputSchema,
126
- },
127
- needsBrowser: false,
120
+ ...grep_1.grepTool,
128
121
  execute: async ({ input, repoPath }) => {
129
122
  if ((0, ripgrep_1.isRgAvailable)()) {
130
123
  return usingRipgrep(input, repoPath);
@@ -1,5 +1,5 @@
1
- import { Match, Options } from "./types";
2
- export * from "./types";
1
+ import { Match, Options } from "../types";
2
+ export * from "../types";
3
3
  export declare function isRgAvailable(): boolean;
4
4
  export declare function ripgrep(cwd: string, options: Options): Array<Match>;
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/grep/ripgrep/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAEvD,cAAc,SAAS,CAAC;AAcxB,wBAAgB,aAAa,YAS5B;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAiDnE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/grep/ripgrep/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAgB,MAAM,UAAU,CAAC;AAExD,cAAc,UAAU,CAAC;AAczB,wBAAgB,aAAa,YAS5B;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAiDnE"}
@@ -17,8 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.isRgAvailable = isRgAvailable;
18
18
  exports.ripgrep = ripgrep;
19
19
  const child_process_1 = require("child_process");
20
- const types_1 = require("./types");
21
- __exportStar(require("./types"), exports);
20
+ const types_1 = require("../types");
21
+ __exportStar(require("../types"), exports);
22
22
  function formatResults(stdout) {
23
23
  stdout = stdout.trim();
24
24
  if (!stdout) {
@@ -37,7 +37,7 @@ function isRgAvailable() {
37
37
  (0, child_process_1.execSync)(command);
38
38
  return true;
39
39
  }
40
- catch (error) {
40
+ catch {
41
41
  return false;
42
42
  }
43
43
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/grep/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,cAAc,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAE/D,MAAM,MAAM,OAAO,GAAG,cAAc,GAAG;IACrC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE;QACJ,IAAI,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QACF,KAAK,EAAE;YACL,IAAI,EAAE,MAAM,CAAC;SACd,CAAC;QACF,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;KACxC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAE7C,qBAAa,YAAY;IACvB,KAAK,EAAE,aAAa,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;gBAEH,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM;IAKhD,IAAI,OAAO,IAAI,MAAM,CAEpB;CACF"}