tianxincode 1.0.48 → 1.0.49

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 (298) hide show
  1. package/README.md +200 -200
  2. package/dist/cli/commands.js +18 -18
  3. package/dist/core/ai/agents/caller/prompts/role.txt +50 -50
  4. package/dist/core/ai/agents/chat/chat.agent.js +30 -30
  5. package/dist/core/ai/agents/chat/prompts/role.txt +30 -30
  6. package/dist/core/ai/agents/code/code.agent.js +6 -6
  7. package/dist/core/ai/agents/code/prompts/role.txt +50 -50
  8. package/dist/core/ai/agents/common/prompt/role.txt +51 -51
  9. package/dist/core/ai/agents/common/prompts.js +26 -26
  10. package/dist/core/ai/agents/design/design.agent.js +6 -6
  11. package/dist/core/ai/agents/design/prompts/role.txt +36 -36
  12. package/dist/core/ai/agents/dream/prompts/init.txt +20 -20
  13. package/dist/core/ai/agents/mem/mem.agent.js +5 -5
  14. package/dist/core/ai/agents/mem/prompts/role.txt +35 -35
  15. package/dist/core/ai/agents/skill/prompts/role.txt +61 -61
  16. package/dist/core/ai/agents/skill/skill.agent.js +26 -26
  17. package/dist/core/ai/agents/summarizer/prompts/role.txt +30 -30
  18. package/dist/core/ai/agents/task/prompts/role.txt +50 -50
  19. package/dist/core/ai/agents/task/task.agent.js +30 -30
  20. package/dist/core/db/db.service.d.ts.map +1 -1
  21. package/dist/core/db/db.service.js +2 -0
  22. package/dist/core/db/db.service.js.map +1 -1
  23. package/dist/core/db/init_sql/ai_log.init.js +15 -15
  24. package/dist/core/db/init_sql/code_snippet.init.js +11 -11
  25. package/dist/core/db/init_sql/config.init.js +15 -15
  26. package/dist/core/db/init_sql/custom_action.init.js +10 -10
  27. package/dist/core/db/init_sql/dingding.init.js +9 -9
  28. package/dist/core/db/init_sql/email.init.js +14 -14
  29. package/dist/core/db/init_sql/lsp.init.js +8 -8
  30. package/dist/core/db/init_sql/message_file.init.js +11 -11
  31. package/dist/core/db/init_sql/project.init.js +20 -20
  32. package/dist/core/db/init_sql/provider.init.js +35 -35
  33. package/dist/core/db/init_sql/scheduler.init.js +32 -32
  34. package/dist/core/db/init_sql/session.init.js +23 -23
  35. package/dist/core/db/init_sql/spec.init.js +15 -15
  36. package/dist/core/db/init_sql/waf_gateway.init.js +9 -9
  37. package/dist/core/db/init_sql/zihao.init.js +11 -11
  38. package/dist/core/lsp/sql.js +11 -11
  39. package/dist/core/tools/provider/bash.txt +47 -47
  40. package/dist/core/tools/provider/code_search.txt +20 -20
  41. package/dist/core/tools/provider/edit_file.txt +13 -13
  42. package/dist/core/tools/provider/glob.txt +12 -12
  43. package/dist/core/tools/provider/grep.txt +14 -14
  44. package/dist/core/tools/provider/lsp.txt +19 -19
  45. package/dist/core/tools/provider/memory.txt +21 -21
  46. package/dist/core/tools/provider/read_file.txt +17 -17
  47. package/dist/core/tools/provider/todo_read.txt +16 -16
  48. package/dist/core/tools/provider/todo_write.txt +48 -48
  49. package/dist/core/tools/provider/web_fetch.txt +17 -17
  50. package/dist/core/tools/provider/web_search.txt +18 -18
  51. package/dist/core/tools/provider/write_file.txt +11 -11
  52. package/dist/gateway/api/skill/detail_skill.d.ts.map +1 -1
  53. package/dist/gateway/api/skill/detail_skill.js +7 -5
  54. package/dist/gateway/api/skill/detail_skill.js.map +1 -1
  55. package/dist/gateway/cli/commands.js +18 -18
  56. package/dist/modules/ai/agents/chat/prompts/role.txt +30 -30
  57. package/dist/modules/ai/agents/code/prompts/role.txt +50 -50
  58. package/dist/modules/ai/agents/mem/prompts/role.txt +35 -35
  59. package/dist/modules/ai/agents/skill/prompts/role.txt +61 -61
  60. package/dist/modules/ai/agents/task/prompts/role.txt +50 -50
  61. package/dist/modules/ai/ai-log.service.js +10 -10
  62. package/dist/modules/ai/provider/openai/prompt/role.txt +51 -51
  63. package/dist/modules/ai/summarizer/summarizer.prompts.js +30 -30
  64. package/dist/modules/config/config.service.js +5 -5
  65. package/dist/modules/db/db.service.js +252 -252
  66. package/dist/modules/email/email.config.repository.js +1 -1
  67. package/dist/modules/repositories/project.repository.d.ts +28 -0
  68. package/dist/modules/repositories/project.repository.d.ts.map +1 -0
  69. package/dist/modules/repositories/project.repository.js +47 -0
  70. package/dist/modules/repositories/project.repository.js.map +1 -0
  71. package/dist/modules/scheduler/task-log.service.js +1 -1
  72. package/dist/modules/services/project/project.service.d.ts +14 -0
  73. package/dist/modules/services/project/project.service.d.ts.map +1 -0
  74. package/dist/modules/services/project/project.service.js +47 -0
  75. package/dist/modules/services/project/project.service.js.map +1 -0
  76. package/dist/modules/skill/skill.txt +36 -36
  77. package/dist/modules/spec/spec.injector.js +24 -24
  78. package/dist/modules/tools/provider/bash.txt +47 -47
  79. package/dist/modules/tools/provider/code_search.txt +20 -20
  80. package/dist/modules/tools/provider/edit_file.txt +13 -13
  81. package/dist/modules/tools/provider/glob.txt +12 -12
  82. package/dist/modules/tools/provider/grep.txt +14 -14
  83. package/dist/modules/tools/provider/lsp.txt +19 -19
  84. package/dist/modules/tools/provider/memory.txt +21 -21
  85. package/dist/modules/tools/provider/read_file.txt +17 -17
  86. package/dist/modules/tools/provider/todo_read.txt +16 -16
  87. package/dist/modules/tools/provider/todo_write.txt +48 -48
  88. package/dist/modules/tools/provider/web_fetch.txt +17 -17
  89. package/dist/modules/tools/provider/web_search.txt +18 -18
  90. package/dist/modules/tools/provider/write_file.txt +11 -11
  91. package/dist/modules/waf-gateway/waf-gateway.module.js +8 -8
  92. package/dist/modules/waf-gateway/waf-gateway.service.js +12 -12
  93. package/dist/repositories/project.repository.d.ts +28 -0
  94. package/dist/repositories/project.repository.d.ts.map +1 -0
  95. package/dist/repositories/project.repository.js +47 -0
  96. package/dist/repositories/project.repository.js.map +1 -0
  97. package/dist/repository/ai_log.repository.js +1 -1
  98. package/dist/repository/config.repository.js +5 -5
  99. package/dist/repository/email.repository.js +1 -1
  100. package/dist/repository/memory.repository.js +1 -1
  101. package/dist/repository/project.repository.js +3 -3
  102. package/dist/repository/scheduler.repository.js +2 -2
  103. package/dist/repository/session.repository.js +1 -1
  104. package/dist/repository/zihao-config.repository.js +1 -1
  105. package/dist/services/skill/skill.tool.d.ts.map +1 -1
  106. package/dist/services/skill/skill.tool.js +6 -1
  107. package/dist/services/skill/skill.tool.js.map +1 -1
  108. package/dist/services/skill/skill.txt +36 -36
  109. package/package.json +76 -76
  110. package/scripts/copy-txt.js +31 -31
  111. package/scripts/ink-scroll-demo.tsx +147 -147
  112. package/tsconfig.test.json +9 -9
  113. package/web/dist/assets/{ConfirmDialog-B2bVsPFI.js → ConfirmDialog-B03GcCHQ.js} +1 -1
  114. package/web/dist/assets/PcLayout-CYW3zqcs.css +1 -0
  115. package/web/dist/assets/{PcLayout-DeXNBHu2.js → PcLayout-ZTdJNg7G.js} +1 -1
  116. package/web/dist/assets/{aiLogsView-JvjhLmyo.js → aiLogsView-Bt8Xg1Qx.js} +1 -1
  117. package/web/dist/assets/{cssMode-sYHhwUZh.js → cssMode-CBb6D87U.js} +1 -1
  118. package/web/dist/assets/{customActionsView-Cvmzxvl4.js → customActionsView-DdjnHzwm.js} +1 -1
  119. package/web/dist/assets/deployView-CD7ji9IS.css +1 -0
  120. package/web/dist/assets/{deployView-CjV4ySrf.js → deployView-Cj51_Job.js} +1 -1
  121. package/web/dist/assets/designView-C3pSX4nP.css +1 -0
  122. package/web/dist/assets/designView-RT8tKEN9.js +18 -0
  123. package/web/dist/assets/devWorkflowView-BTozmaiN.js +36 -0
  124. package/web/dist/assets/devWorkflowView-DYhIfbCB.css +1 -0
  125. package/web/dist/assets/devWorkflowViewApp-CErbhC2s.css +1 -0
  126. package/web/dist/assets/{devWorkflowViewApp-DPlFgiS_.js → devWorkflowViewApp-DLslXEq9.js} +3 -3
  127. package/web/dist/assets/{fileZihao-DvZmuTYu.js → fileZihao-CtZ4bUIH.js} +1 -1
  128. package/web/dist/assets/{freemarker2-DTyAQBBj.js → freemarker2-CX3jc3l2.js} +1 -1
  129. package/web/dist/assets/gitChanges-D6QxPcii.css +1 -0
  130. package/web/dist/assets/{gitChanges-Cpf4HHoF.js → gitChanges-DFRvzL5I.js} +1 -1
  131. package/web/dist/assets/gitChangesApp-Bjn-MCmr.css +1 -0
  132. package/web/dist/assets/{gitChangesApp-BOURDd_l.js → gitChangesApp-ZI7-V8oB.js} +2 -2
  133. package/web/dist/assets/{handlebars-DiWIXxOG.js → handlebars-CTaQD6FN.js} +1 -1
  134. package/web/dist/assets/{html-BCQWkFzH.js → html-BruJsfYv.js} +1 -1
  135. package/web/dist/assets/{htmlMode-BbMA34cR.js → htmlMode-wewroXLr.js} +1 -1
  136. package/web/dist/assets/{index-C_tz4Wda.css → index-C0xmVTIn.css} +1 -1
  137. package/web/dist/assets/{index-C7axH05o.js → index-Cn73hS12.js} +9 -9
  138. package/web/dist/assets/{javascript-By4MYHaO.js → javascript-B4ku8P1-.js} +1 -1
  139. package/web/dist/assets/{jsonMode-5JIz7tDN.js → jsonMode-BIvVuBMG.js} +1 -1
  140. package/web/dist/assets/{liquid-BQBVii4f.js → liquid-Bo3G0Ep7.js} +1 -1
  141. package/web/dist/assets/{mdx-Cwk7nqzM.js → mdx-Duv0ylZz.js} +1 -1
  142. package/web/dist/assets/{mediaChat-DivTDoIv.js → mediaChat-RT7iqqYb.js} +1 -1
  143. package/web/dist/assets/{python-L_kGfe1T.js → python-CEhCctGm.js} +1 -1
  144. package/web/dist/assets/{razor-XGuHliMI.js → razor-DPK8nTD7.js} +1 -1
  145. package/web/dist/assets/{taskView-BcJ3LAxp.js → taskView-sOyebRqn.js} +1 -1
  146. package/web/dist/assets/{terminalView-q-UKzK0M.js → terminalView-GTYtDlus.js} +2 -2
  147. package/web/dist/assets/{terminalView-CQVYh6D3.css → terminalView-eZ0agsPP.css} +1 -1
  148. package/web/dist/assets/{tsMode-SuiD3mJa.js → tsMode-BZvUU1nf.js} +1 -1
  149. package/web/dist/assets/{typescript-DJcyqRjT.js → typescript-CmEn-k1B.js} +1 -1
  150. package/web/dist/assets/{wikiView-ygHSGyPp.css → wikiView-C-oqMnJM.css} +1 -1
  151. package/web/dist/assets/{wikiView-B3GIPUlD.js → wikiView-CRjg-cZ8.js} +1 -1
  152. package/web/dist/assets/{xml-DQgCzk55.js → xml-bjvdKeyy.js} +1 -1
  153. package/web/dist/assets/{yaml-DBdEYBPA.js → yaml-N5RXWxJk.js} +1 -1
  154. package/web/dist/index.html +2 -2
  155. package/web/package.json +28 -28
  156. package/dist/modules/ai/react/index.d.ts +0 -5
  157. package/dist/modules/ai/react/index.d.ts.map +0 -1
  158. package/dist/modules/ai/react/index.js +0 -4
  159. package/dist/modules/ai/react/index.js.map +0 -1
  160. package/dist/modules/ai/react/prompt/role.txt +0 -51
  161. package/dist/modules/ai/react/provider.parser.d.ts +0 -20
  162. package/dist/modules/ai/react/provider.parser.d.ts.map +0 -1
  163. package/dist/modules/ai/react/provider.parser.js +0 -88
  164. package/dist/modules/ai/react/provider.parser.js.map +0 -1
  165. package/dist/modules/ai/react/react.parser.d.ts +0 -80
  166. package/dist/modules/ai/react/react.parser.d.ts.map +0 -1
  167. package/dist/modules/ai/react/react.parser.js +0 -365
  168. package/dist/modules/ai/react/react.parser.js.map +0 -1
  169. package/dist/modules/ai/react/react.prompts.d.ts +0 -26
  170. package/dist/modules/ai/react/react.prompts.d.ts.map +0 -1
  171. package/dist/modules/ai/react/react.prompts.js +0 -170
  172. package/dist/modules/ai/react/react.prompts.js.map +0 -1
  173. package/dist/modules/ai/react/react.types.d.ts +0 -50
  174. package/dist/modules/ai/react/react.types.d.ts.map +0 -1
  175. package/dist/modules/ai/react/react.types.js +0 -2
  176. package/dist/modules/ai/react/react.types.js.map +0 -1
  177. package/dist/modules/ai/react/react.validator.d.ts +0 -14
  178. package/dist/modules/ai/react/react.validator.d.ts.map +0 -1
  179. package/dist/modules/ai/react/react.validator.js +0 -53
  180. package/dist/modules/ai/react/react.validator.js.map +0 -1
  181. package/dist/modules/ai/react.agent.d.ts +0 -82
  182. package/dist/modules/ai/react.agent.d.ts.map +0 -1
  183. package/dist/modules/ai/react.agent.js +0 -220
  184. package/dist/modules/ai/react.agent.js.map +0 -1
  185. package/dist/modules/skill/skill.service.d.ts +0 -72
  186. package/dist/modules/skill/skill.service.d.ts.map +0 -1
  187. package/dist/modules/skill/skill.service.js +0 -283
  188. package/dist/modules/skill/skill.service.js.map +0 -1
  189. package/dist/modules/tools/builtin/bash.d.ts +0 -3
  190. package/dist/modules/tools/builtin/bash.d.ts.map +0 -1
  191. package/dist/modules/tools/builtin/bash.js +0 -126
  192. package/dist/modules/tools/builtin/bash.js.map +0 -1
  193. package/dist/modules/tools/builtin/bash.tool.d.ts +0 -6
  194. package/dist/modules/tools/builtin/bash.tool.d.ts.map +0 -1
  195. package/dist/modules/tools/builtin/bash.tool.js +0 -52
  196. package/dist/modules/tools/builtin/bash.tool.js.map +0 -1
  197. package/dist/modules/tools/builtin/bash.txt +0 -69
  198. package/dist/modules/tools/builtin/code_search.d.ts +0 -3
  199. package/dist/modules/tools/builtin/code_search.d.ts.map +0 -1
  200. package/dist/modules/tools/builtin/code_search.js +0 -86
  201. package/dist/modules/tools/builtin/code_search.js.map +0 -1
  202. package/dist/modules/tools/builtin/code_search.txt +0 -41
  203. package/dist/modules/tools/builtin/edit-file.tool.d.ts +0 -6
  204. package/dist/modules/tools/builtin/edit-file.tool.d.ts.map +0 -1
  205. package/dist/modules/tools/builtin/edit-file.tool.js +0 -58
  206. package/dist/modules/tools/builtin/edit-file.tool.js.map +0 -1
  207. package/dist/modules/tools/builtin/edit_file.d.ts +0 -3
  208. package/dist/modules/tools/builtin/edit_file.d.ts.map +0 -1
  209. package/dist/modules/tools/builtin/edit_file.js +0 -105
  210. package/dist/modules/tools/builtin/edit_file.js.map +0 -1
  211. package/dist/modules/tools/builtin/edit_file.txt +0 -61
  212. package/dist/modules/tools/builtin/glob.d.ts +0 -3
  213. package/dist/modules/tools/builtin/glob.d.ts.map +0 -1
  214. package/dist/modules/tools/builtin/glob.js +0 -85
  215. package/dist/modules/tools/builtin/glob.js.map +0 -1
  216. package/dist/modules/tools/builtin/glob.tool.d.ts +0 -6
  217. package/dist/modules/tools/builtin/glob.tool.d.ts.map +0 -1
  218. package/dist/modules/tools/builtin/glob.tool.js +0 -81
  219. package/dist/modules/tools/builtin/glob.tool.js.map +0 -1
  220. package/dist/modules/tools/builtin/glob.txt +0 -33
  221. package/dist/modules/tools/builtin/grep.d.ts +0 -3
  222. package/dist/modules/tools/builtin/grep.d.ts.map +0 -1
  223. package/dist/modules/tools/builtin/grep.js +0 -94
  224. package/dist/modules/tools/builtin/grep.js.map +0 -1
  225. package/dist/modules/tools/builtin/grep.tool.d.ts +0 -6
  226. package/dist/modules/tools/builtin/grep.tool.d.ts.map +0 -1
  227. package/dist/modules/tools/builtin/grep.tool.js +0 -96
  228. package/dist/modules/tools/builtin/grep.tool.js.map +0 -1
  229. package/dist/modules/tools/builtin/grep.txt +0 -37
  230. package/dist/modules/tools/builtin/index.d.ts +0 -8
  231. package/dist/modules/tools/builtin/index.d.ts.map +0 -1
  232. package/dist/modules/tools/builtin/index.js +0 -80
  233. package/dist/modules/tools/builtin/index.js.map +0 -1
  234. package/dist/modules/tools/builtin/lsp.d.ts +0 -7
  235. package/dist/modules/tools/builtin/lsp.d.ts.map +0 -1
  236. package/dist/modules/tools/builtin/lsp.js +0 -126
  237. package/dist/modules/tools/builtin/lsp.js.map +0 -1
  238. package/dist/modules/tools/builtin/lsp.txt +0 -45
  239. package/dist/modules/tools/builtin/memory.d.ts +0 -3
  240. package/dist/modules/tools/builtin/memory.d.ts.map +0 -1
  241. package/dist/modules/tools/builtin/memory.js +0 -77
  242. package/dist/modules/tools/builtin/memory.js.map +0 -1
  243. package/dist/modules/tools/builtin/memory.txt +0 -58
  244. package/dist/modules/tools/builtin/read-file.tool.d.ts +0 -6
  245. package/dist/modules/tools/builtin/read-file.tool.d.ts.map +0 -1
  246. package/dist/modules/tools/builtin/read-file.tool.js +0 -46
  247. package/dist/modules/tools/builtin/read-file.tool.js.map +0 -1
  248. package/dist/modules/tools/builtin/read_file.d.ts +0 -3
  249. package/dist/modules/tools/builtin/read_file.d.ts.map +0 -1
  250. package/dist/modules/tools/builtin/read_file.js +0 -107
  251. package/dist/modules/tools/builtin/read_file.js.map +0 -1
  252. package/dist/modules/tools/builtin/read_file.txt +0 -38
  253. package/dist/modules/tools/builtin/todo_read.d.ts +0 -6
  254. package/dist/modules/tools/builtin/todo_read.d.ts.map +0 -1
  255. package/dist/modules/tools/builtin/todo_read.js +0 -25
  256. package/dist/modules/tools/builtin/todo_read.js.map +0 -1
  257. package/dist/modules/tools/builtin/todo_read.txt +0 -34
  258. package/dist/modules/tools/builtin/todo_write.d.ts +0 -6
  259. package/dist/modules/tools/builtin/todo_write.d.ts.map +0 -1
  260. package/dist/modules/tools/builtin/todo_write.js +0 -46
  261. package/dist/modules/tools/builtin/todo_write.js.map +0 -1
  262. package/dist/modules/tools/builtin/todo_write.txt +0 -67
  263. package/dist/modules/tools/builtin/web_fetch.d.ts +0 -3
  264. package/dist/modules/tools/builtin/web_fetch.d.ts.map +0 -1
  265. package/dist/modules/tools/builtin/web_fetch.js +0 -52
  266. package/dist/modules/tools/builtin/web_fetch.js.map +0 -1
  267. package/dist/modules/tools/builtin/web_fetch.txt +0 -38
  268. package/dist/modules/tools/builtin/web_search.d.ts +0 -3
  269. package/dist/modules/tools/builtin/web_search.d.ts.map +0 -1
  270. package/dist/modules/tools/builtin/web_search.js +0 -100
  271. package/dist/modules/tools/builtin/web_search.js.map +0 -1
  272. package/dist/modules/tools/builtin/web_search.txt +0 -43
  273. package/dist/modules/tools/builtin/write-file.tool.d.ts +0 -6
  274. package/dist/modules/tools/builtin/write-file.tool.d.ts.map +0 -1
  275. package/dist/modules/tools/builtin/write-file.tool.js +0 -38
  276. package/dist/modules/tools/builtin/write-file.tool.js.map +0 -1
  277. package/dist/modules/tools/builtin/write_file.d.ts +0 -3
  278. package/dist/modules/tools/builtin/write_file.d.ts.map +0 -1
  279. package/dist/modules/tools/builtin/write_file.js +0 -61
  280. package/dist/modules/tools/builtin/write_file.js.map +0 -1
  281. package/dist/modules/tools/builtin/write_file.txt +0 -58
  282. package/dist/modules/tools/provider/openai/tools.d.ts +0 -3
  283. package/dist/modules/tools/provider/openai/tools.d.ts.map +0 -1
  284. package/dist/modules/tools/provider/openai/tools.js +0 -212
  285. package/dist/modules/tools/provider/openai/tools.js.map +0 -1
  286. package/dist/modules/tools/provider/skill.d.ts +0 -6
  287. package/dist/modules/tools/provider/skill.d.ts.map +0 -1
  288. package/dist/modules/tools/provider/skill.js +0 -64
  289. package/dist/modules/tools/provider/skill.js.map +0 -1
  290. package/web/dist/assets/PcLayout-L-XuK1oQ.css +0 -1
  291. package/web/dist/assets/deployView-hCh3_M8H.css +0 -1
  292. package/web/dist/assets/designView-CqZ75hOS.css +0 -1
  293. package/web/dist/assets/designView-DrUNRVEE.js +0 -18
  294. package/web/dist/assets/devWorkflowView-BpdJTMEb.js +0 -36
  295. package/web/dist/assets/devWorkflowView-D7EKjoLj.css +0 -1
  296. package/web/dist/assets/devWorkflowViewApp-BYYMIdCm.css +0 -1
  297. package/web/dist/assets/gitChanges-BYj-Y2K-.css +0 -1
  298. package/web/dist/assets/gitChangesApp-Btw-XKcP.css +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"code_search.js","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/code_search.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG;IACjB,QAAQ,EAAE,oBAAoB;IAC9B,SAAS,EAAE;QACT,OAAO,EAAE,MAAM;KAChB;IACD,cAAc,EAAE,IAAI;IACpB,OAAO,EAAE,KAAK;CACN,CAAA;AAyBV,MAAM,CAAC,MAAM,cAAc,GAAS;IAClC,IAAI,EAAE,aAAa;IACnB,WAAW,EAAE,EAAE;IACf,eAAe,EAAE,iBAAiB;IAClC,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,KAAK,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,y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A;QAC3D,CAAC;IACH,CAAC;CACF,CAAA"}
@@ -1,41 +0,0 @@
1
- ### 工具code_search
2
- 使用 Exa Code API 搜索编程相关的代码和上下文。
3
-
4
- **功能**:
5
- - 为任何编程任务提供最高质量和最新鲜的上下文
6
- - 提供库、SDK 和 API 的全面代码示例、文档和 API 参考
7
- - 用于任何编程相关问题
8
- - 优化用于查找特定编程模式和解决方案
9
-
10
- **使用说明**:
11
- - 可调整的 token 数量(1000-50000)用于聚焦或全面的结果
12
- - 默认 5000 tokens 为大多数查询提供平衡的上下文
13
- - 特定问题用较低值,全面文档用较高值
14
- - 支持关于框架、库、API 和编程概念的查询
15
-
16
- **示例**:
17
- - 'React useState hook examples'
18
- - 'Python pandas dataframe filtering'
19
- - 'Express.js middleware'
20
-
21
- 举例:
22
- ```xml
23
- <react>
24
- <thought>查找 React useEffect 的最佳实践示例</thought>
25
- <action>
26
- <action_name>code_search</action_name>
27
- <action_input>
28
- <query>React useEffect best practices cleanup</query>
29
- <tokens>5000</tokens>
30
- </action_input>
31
- </action>
32
- <keep_context>true</keep_context>
33
- </react>
34
- ```
35
-
36
- 参数说明:
37
-
38
- | 字段 | 类型 | 说明 |
39
- |------|------|
40
- | `query` | string | 搜索查询字符串,用于查找 APIs、库和 SDK 的相关上下文(必需) |
41
- | `tokens` | number | 返回的 token 数量(可选,1000-50000,默认 5000) |
@@ -1,6 +0,0 @@
1
- /**
2
- * 文件编辑工具
3
- */
4
- import { Tool } from '../tool.types.js';
5
- export declare const editFileTool: Tool;
6
- //# sourceMappingURL=edit-file.tool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edit-file.tool.d.ts","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/edit-file.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,eAAO,MAAM,YAAY,EAAE,IA4D1B,CAAC"}
@@ -1,58 +0,0 @@
1
- /**
2
- * 文件编辑工具
3
- */
4
- import * as fs from 'fs';
5
- export const editFileTool = {
6
- name: 'edit_file',
7
- description: '编辑文件,替换指定内容。支持精确替换和全部替换。',
8
- parameters: {
9
- type: 'object',
10
- properties: {
11
- file_path: {
12
- type: 'string',
13
- description: '文件的绝对路径',
14
- },
15
- old_string: {
16
- type: 'string',
17
- description: '要被替换的内容',
18
- },
19
- new_string: {
20
- type: 'string',
21
- description: '替换后的新内容',
22
- },
23
- replace_all: {
24
- type: 'boolean',
25
- description: '是否替换所有匹配项(默认 false)',
26
- },
27
- },
28
- required: ['file_path', 'old_string', 'new_string'],
29
- },
30
- execute: async (params) => {
31
- const { file_path, old_string, new_string, replace_all = false } = params;
32
- if (!fs.existsSync(file_path)) {
33
- return `错误: 文件不存在: ${file_path}`;
34
- }
35
- try {
36
- let content = fs.readFileSync(file_path, 'utf-8');
37
- if (!content.includes(old_string)) {
38
- return `错误: 未找到要替换的内容`;
39
- }
40
- if (replace_all) {
41
- content = content.split(old_string).join(new_string);
42
- }
43
- else {
44
- const firstIndex = content.indexOf(old_string);
45
- if (content.indexOf(old_string, firstIndex + 1) !== -1) {
46
- return `错误: 找到多个匹配项,请使用 replace_all 或提供更多上下文`;
47
- }
48
- content = content.replace(old_string, new_string);
49
- }
50
- fs.writeFileSync(file_path, content, 'utf-8');
51
- return `成功: 文件已更新 ${file_path}`;
52
- }
53
- catch (error) {
54
- return `错误: 编辑文件失败: ${error instanceof Error ? error.message : String(error)}`;
55
- }
56
- },
57
- };
58
- //# sourceMappingURL=edit-file.tool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edit-file.tool.js","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/edit-file.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,MAAM,CAAC,MAAM,YAAY,GAAS;IAChC,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,0BAA0B;IACvC,UAAU,EAAE;QACV,IA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AO,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YACpD,CAAC;YAED,EAAE,CAAC,aAAa,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,aAAa,SAAS,EAAE,CAAC;QAClC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,eAAe,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACjF,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -1,3 +0,0 @@
1
- import { Tool } from '../tool.types.js';
2
- export declare const editFileTool: Tool;
3
- //# sourceMappingURL=edit_file.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edit_file.d.ts","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/edit_file.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAA2B,MAAM,kBAAkB,CAAA;AAEhE,eAAO,MAAM,YAAY,EAAE,IAiH1B,CAAA"}
@@ -1,105 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- export const editFileTool = {
4
- name: 'edit_file',
5
- description: '',
6
- descriptionFile: 'edit_file.txt',
7
- parameters: {
8
- type: 'object',
9
- properties: {
10
- file_path: {
11
- type: 'string',
12
- description: '文件绝对路径'
13
- },
14
- old_string: {
15
- type: 'string',
16
- description: '<![CDATA[要被替换的内容(必须精确匹配)]]>'
17
- },
18
- new_string: {
19
- type: 'string',
20
- description: '<![CDATA[替换后的新内容]]>'
21
- },
22
- replace_all: {
23
- type: 'boolean',
24
- description: '是否替换所有匹配项(可选,默认 false)'
25
- }
26
- },
27
- required: ['file_path', 'old_string', 'new_string']
28
- },
29
- execute: async (params, context) => {
30
- const extractCDATA = (str) => {
31
- if (!str)
32
- return '';
33
- const cdataMatch = str.match(/^<!\[CDATA\[([\s\S]*?)\]\]>$/);
34
- return cdataMatch ? cdataMatch[1] : str;
35
- };
36
- const normalizeLineEndings = (str) => {
37
- return str.replace(/\r\n/g, '\n');
38
- };
39
- let { file_path, old_string, new_string, replace_all = false } = params;
40
- old_string = extractCDATA(old_string);
41
- new_string = extractCDATA(new_string);
42
- if (!file_path) {
43
- return {
44
- success: false,
45
- output: '',
46
- error: `Missing required parameter: file_path. Available parameters: ${Object.keys(params).join(', ')}`
47
- };
48
- }
49
- if (!old_string) {
50
- return {
51
- success: false,
52
- output: '',
53
- error: 'Missing required parameter: old_string'
54
- };
55
- }
56
- if (!new_string) {
57
- return {
58
- success: false,
59
- output: '',
60
- error: 'Missing required parameter: new_string'
61
- };
62
- }
63
- if (file_path.startsWith('@')) {
64
- file_path = file_path.substring(1);
65
- }
66
- if (!path.isAbsolute(file_path)) {
67
- file_path = path.resolve(context.workDir || process.cwd(), file_path);
68
- }
69
- const exists = await fs.promises.access(file_path).then(() => true).catch(() => false);
70
- if (!exists) {
71
- return { success: false, output: '', error: `File not found: ${file_path}` };
72
- }
73
- const content = await fs.promises.readFile(file_path, 'utf-8');
74
- const normalizedContent = normalizeLineEndings(content);
75
- const normalizedOldString = normalizeLineEndings(old_string);
76
- const normalizedNewString = normalizeLineEndings(new_string);
77
- if (!normalizedContent.includes(normalizedOldString)) {
78
- return { success: false, output: '', error: 'old_string not found in content' };
79
- }
80
- let newContent;
81
- if (replace_all) {
82
- newContent = normalizedContent.split(normalizedOldString).join(normalizedNewString);
83
- }
84
- else {
85
- const firstIndex = normalizedContent.indexOf(normalizedOldString);
86
- const secondIndex = normalizedContent.indexOf(normalizedOldString, firstIndex + normalizedOldString.length);
87
- if (secondIndex !== -1) {
88
- return {
89
- success: false,
90
- output: '',
91
- error: 'Found multiple matches. Use replace_all=true or provide more context to make old_string unique.'
92
- };
93
- }
94
- newContent = normalizedContent.replace(normalizedOldString, normalizedNewString);
95
- }
96
- await fs.promises.writeFile(file_path, newContent, 'utf-8');
97
- const count = replace_all ? (normalizedContent.split(normalizedOldString).length - 1) : 1;
98
- return {
99
- success: true,
100
- output: `成功: 文件已更新 ${file_path}${count > 1 ? ` (${count} 处替换)` : ''}`,
101
- metadata: { path: file_path, replacements: count }
102
- };
103
- }
104
- };
105
- //# sourceMappingURL=edit_file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"edit_file.js","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/edit_file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AAGvB,MAAM,CAAC,MAAM,YAAY,GAAS;IAChC,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,EAAE;IACf,eAAe,EAAE,eAAe;IAChC,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,QAAQ;aACtB;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6BAA6B;aAC3C;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,qBAAqB;aACnC;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,wBAAwB;aACtC;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC;KACpD;IACD,OAAO,EAAE,KAAK,EAAE,MAA8F,EAAE,OAAoB,EAAuB,EAAE;QAC3J,MAAM,YAAY,GAAG,CAAC,GAAuB,EAAU,EAAE;YACvD,IAAI,CAAC,GAAG;gBAAE,OAAO,EAAE,CAAA;YACnB,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAA;YAC5D,OAAO,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;QACzC,CAAC,CAAA;QAED,MAAM,oBAAoB,GAAG,CAAC,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B,CAAC,OAAO,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,CAAA;QAClF,CAAC;QAED,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAA;QAE3D,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;QACzF,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM,EAAE,aAAa,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACrE,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,EAAE;SACnD,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -1,61 +0,0 @@
1
- ### 工具edit_file
2
- 对文件执行精确的字符串替换。
3
-
4
- **功能**:
5
- - 在编辑前,**必须**至少使用过一次 Read 工具。未读取文件就编辑会报错
6
- - 从 Read 工具输出编辑文本时,确保保留精确的缩进(空格/制表符)。行号前缀格式是:行号 + 冒号 + 空格(如 `1: `)。`old_string` 和 `new_string` 中**禁止**包含行号前缀的任何部分
7
- - **优先**编辑现有文件,**禁止**创建新文件除非明确需要
8
- - 只有用户明确要求时才使用表情符号
9
- - 如果 `old_string` 在文件中找不到会**失败**
10
- - 如果 `old_string` 在文件中出现多次会**失败**,可以提供更多上下文使其唯一,或使用 `replace_all` 替换所有匹配项
11
- - `replace_all` 用于在整个文件中替换和重命名字符串
12
-
13
- **注意**:old_string 和 new_string 中内容必须用 <![CDATA[ ]]> 包裹。
14
-
15
- **举例**:
16
- 正确例子
17
- ```xml
18
- <react>
19
- <thought>在 App.tsx 中添加调试日志</thought>
20
- <action>
21
- <action_name>edit_file</action_name>
22
- <action_input>
23
- <file_path>E:\ai\txcode\src\components\App.tsx</file_path>
24
- <old_string><![CDATA[if (trimmedInput.startsWith('/')) {
25
- const result = await executeCommand(trimmedInput);]]></old_string>
26
- <new_string><![CDATA[if (trimmedInput.startsWith('/')) {
27
- console.log('[DEBUG] executeCommand input:', trimmedInput);
28
- const result = await executeCommand(trimmedInput);]]></new_string>
29
- </action_input>
30
- </action>
31
- <keep_context>true</keep_context>
32
- </react>
33
- ```
34
-
35
- 错误例子(错误的方式,old_string和new_string 没有用<![CDATA[ ]]> 包裹):
36
- ```xml
37
- <react>
38
- <thought>在 App.tsx 中添加调试日志</thought>
39
- <action>
40
- <action_name>edit_file</action_name>
41
- <action_input>
42
- <file_path>E:\ai\txcode\src\components\App.tsx</file_path>
43
- <old_string>if (trimmedInput.startsWith('/')) {
44
- const result = await executeCommand(trimmedInput);</old_string>
45
- <new_string>if (trimmedInput.startsWith('/')) {
46
- console.log('[DEBUG] executeCommand input:', trimmedInput);
47
- const result = await executeCommand(trimmedInput);</new_string>
48
- </action_input>
49
- </action>
50
- <keep_context>true</keep_context>
51
- </react>
52
- ```
53
-
54
- 参数说明:
55
-
56
- | 字段 | 类型 | 说明 |
57
- |------|------|
58
- | `file_path` | string | 文件绝对路径 |
59
- | `old_string` | string | 要被替换的内容(必须精确匹配),用 <![CDATA[ ]]> 包裹 |
60
- | `new_string` | string | 替换后的新内容,用 <![CDATA[ ]]> 包裹 |
61
- | `replace_all` | boolean | 是否替换所有匹配项(可选,默认 false) |
@@ -1,3 +0,0 @@
1
- import { Tool } from '../tool.types.js';
2
- export declare const globTool: Tool;
3
- //# sourceMappingURL=glob.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/glob.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAA2B,MAAM,kBAAkB,CAAA;AAqDhE,eAAO,MAAM,QAAQ,EAAE,IA2CtB,CAAA"}
@@ -1,85 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- const IGNORE_DIRS = ['node_modules', '.git', 'dist', 'build', '.next', 'coverage', '.cache', '__pycache__'];
4
- function matchGlob(pattern, filePath) {
5
- const normalizedPattern = pattern.replace(/\\/g, '/');
6
- const normalizedPath = filePath.replace(/\\/g, '/');
7
- const regexStr = normalizedPattern
8
- .replace(/[.+^${}()|[\]\\]/g, '\\$&')
9
- .replace(/\*\*/g, '<<DOUBLESTAR>>')
10
- .replace(/\*/g, '[^/]*')
11
- .replace(/<<DOUBLESTAR>>/g, '.*')
12
- .replace(/\?/g, '[^/]');
13
- const regex = new RegExp(`^${regexStr}$`, 'i');
14
- return regex.test(normalizedPath);
15
- }
16
- function glob(pattern, dir) {
17
- const results = [];
18
- const walk = (currentDir) => {
19
- try {
20
- const entries = fs.readdirSync(currentDir, { withFileTypes: true });
21
- for (const entry of entries) {
22
- if (entry.isDirectory()) {
23
- if (!IGNORE_DIRS.includes(entry.name) && !entry.name.startsWith('.')) {
24
- const fullPath = path.join(currentDir, entry.name);
25
- const relativePath = path.relative(dir, fullPath).replace(/\\/g, '/');
26
- if (matchGlob(pattern, relativePath) || matchGlob(pattern, entry.name)) {
27
- results.push(relativePath);
28
- }
29
- walk(fullPath);
30
- }
31
- }
32
- else {
33
- const fullPath = path.join(currentDir, entry.name);
34
- const relativePath = path.relative(dir, fullPath).replace(/\\/g, '/');
35
- if (matchGlob(pattern, relativePath) || matchGlob(pattern, entry.name)) {
36
- results.push(relativePath);
37
- }
38
- }
39
- }
40
- }
41
- catch { }
42
- };
43
- walk(dir);
44
- return results.sort();
45
- }
46
- export const globTool = {
47
- name: 'glob',
48
- description: '',
49
- descriptionFile: 'glob.txt',
50
- parameters: {
51
- type: 'object',
52
- properties: {
53
- pattern: {
54
- type: 'string',
55
- description: 'glob 模式,如 "**/*.ts" 匹配所有 ts 文件'
56
- },
57
- directory: {
58
- type: 'string',
59
- description: '搜索目录的绝对路径(可选,默认当前工作目录)'
60
- }
61
- },
62
- required: ['pattern']
63
- },
64
- execute: async (params, context) => {
65
- const { pattern, directory } = params;
66
- const dir = directory ? path.resolve(directory) : (context.workDir || process.cwd());
67
- const exists = await fs.promises.access(dir).then(() => true).catch(() => false);
68
- if (!exists) {
69
- return { success: false, output: '', error: `Directory not found: ${dir}` };
70
- }
71
- const results = glob(pattern, dir);
72
- if (results.length === 0) {
73
- return { success: true, output: `未找到匹配文件: ${pattern}\n搜索目录: ${dir}` };
74
- }
75
- const maxShow = 100;
76
- const shown = results.length > maxShow ? results.slice(0, maxShow) : results;
77
- const output = `找到 ${results.length} 个文件${results.length > maxShow ? `(显示前 ${maxShow} 个)` : ''}:\n${shown.join('\n')}\n\n搜索目录: ${dir}${results.length > maxShow ? `\n... 还有 ${results.length - maxShow} 个文件` : ''}`;
78
- return {
79
- success: true,
80
- output,
81
- metadata: { total: results.length, pattern, directory: dir }
82
- };
83
- }
84
- };
85
- //# sourceMappingURL=glob.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"glob.js","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/glob.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AAGvB,MAAM,WAAW,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAA;AAE3G,SAAS,SAAS,CAAC,OAAe,EAAE,QAAgB;IAClD,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACrD,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAEnD,MAAM,QAAQ,GAAG,iBAAiB;SAC/B,OAAO,CAAC,mBAAmB,EAAE,MAAM,CAAC;SACpC,OAAO,CAAC,OAAO,EAAE,gBAAgB,CAAC;SAClC,OAAO,CAAC,KAAK,EAAE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;CACF,CAAA"}
@@ -1,6 +0,0 @@
1
- /**
2
- * 文件搜索工具(Glob)
3
- */
4
- import { Tool } from '../tool.types.js';
5
- export declare const globTool: Tool;
6
- //# sourceMappingURL=glob.tool.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"glob.tool.d.ts","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/glob.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAoDxC,eAAO,MAAM,QAAQ,EAAE,IAoCtB,CAAC"}
@@ -1,81 +0,0 @@
1
- /**
2
- * 文件搜索工具(Glob)
3
- */
4
- import * as fs from 'fs';
5
- import * as path from 'path';
6
- function glob(pattern, dir) {
7
- const results = [];
8
- const ignore = ['node_modules', '.git', 'dist', 'build', '.next', 'coverage'];
9
- const walk = (currentDir) => {
10
- const entries = fs.readdirSync(currentDir, { withFileTypes: true });
11
- for (const entry of entries) {
12
- if (entry.isDirectory()) {
13
- if (!ignore.includes(entry.name)) {
14
- walk(path.join(currentDir, entry.name));
15
- }
16
- }
17
- else {
18
- const fullPath = path.join(currentDir, entry.name);
19
- const relativePath = path.relative(dir, fullPath);
20
- if (matchGlob(pattern, relativePath) || matchGlob(pattern, entry.name)) {
21
- results.push(relativePath);
22
- }
23
- }
24
- }
25
- };
26
- walk(dir);
27
- return results;
28
- }
29
- function matchGlob(pattern, filePath) {
30
- const parts = pattern.split('/');
31
- const fileParts = filePath.split('/');
32
- if (parts.length === 1) {
33
- return minimatch(filePath, pattern);
34
- }
35
- return minimatch(filePath, pattern);
36
- }
37
- function minimatch(str, pattern) {
38
- const regexStr = pattern
39
- .replace(/[.+^${}()|[\]\\]/g, '\\$&')
40
- .replace(/\*\*/g, '<<DOUBLESTAR>>')
41
- .replace(/\*/g, '[^/]*')
42
- .replace(/<<DOUBLESTAR>>/g, '.*')
43
- .replace(/\?/g, '[^/]');
44
- const regex = new RegExp(`^${regexStr}$`);
45
- return regex.test(str);
46
- }
47
- export const globTool = {
48
- name: 'find_files',
49
- description: '使用 glob 模式搜索文件。支持 ** 和 * 通配符。',
50
- parameters: {
51
- type: 'object',
52
- properties: {
53
- pattern: {
54
- type: 'string',
55
- description: 'glob 模式,如 "**/*.ts" 或 "*.ts"',
56
- },
57
- directory: {
58
- type: 'string',
59
- description: '搜索目录(可选,默认当前目录)',
60
- },
61
- },
62
- required: ['pattern'],
63
- },
64
- execute: async (params) => {
65
- const { pattern, directory = process.cwd() } = params;
66
- try {
67
- const results = glob(pattern, directory);
68
- if (results.length === 0) {
69
- return `未找到匹配文件: ${pattern}`;
70
- }
71
- if (results.length > 100) {
72
- return `找到 ${results.length} 个文件,显示前 100 个:\n${results.slice(0, 100).join('\n')}`;
73
- }
74
- return `找到 ${results.length} 个文件:\n${results.join('\n')}`;
75
- }
76
- catch (error) {
77
- return `错误: ${error instanceof Error ? error.message : String(error)}`;
78
- }
79
- },
80
- };
81
- //# sourceMappingURL=glob.tool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"glob.tool.js","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/glob.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAG7B,SAAS,IAAI,CAAC,OAAe,EAAE,GAAW;IACxC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAE9E,MAAM,IAAI,GAAG,CAAC,UAAkB,EAAE,EAAE;QAClC,MAAM,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAEpE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YAC5B,IAAI,KAAK,C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,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACzE,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -1,33 +0,0 @@
1
- ### 工具glob
2
- 快速的文件模式匹配工具,适用于任何规模的代码库。
3
-
4
- **功能**:
5
- - 支持 glob 模式如 "**/*.js" 或 "src/**/*.ts"
6
- - 返回匹配文件的路径,按修改时间排序
7
- - 当你需要按名称模式查找文件时使用此工具
8
-
9
- **注意**:当你需要进行可能需要多轮 glob 和 grep 的开放式搜索时,使用 Task 工具。
10
-
11
- **最佳实践**:可以并行调用多个工具,总是更好地批量执行多个可能有用的搜索。
12
-
13
- 举例:
14
- ```xml
15
- <react>
16
- <thought>查找所有 TypeScript 组件文件</thought>
17
- <action>
18
- <action_name>glob</action_name>
19
- <action_input>
20
- <pattern>src/**/*.tsx</pattern>
21
- <directory>E:\ai\txcode</directory>
22
- </action_input>
23
- </action>
24
- <keep_context>true</keep_context>
25
- </react>
26
- ```
27
-
28
- 参数说明:
29
-
30
- | 字段 | 类型 | 说明 |
31
- |------|------|
32
- | `pattern` | string | glob 模式,如 "**/*.ts" 匹配所有 ts 文件 |
33
- | `directory` | string | 搜索目录的绝对路径(可选,默认当前工作目录) |
@@ -1,3 +0,0 @@
1
- import { Tool } from '../tool.types.js';
2
- export declare const grepTool: Tool;
3
- //# sourceMappingURL=grep.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/grep.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAA2B,MAAM,kBAAkB,CAAA;AAWhE,eAAO,MAAM,QAAQ,EAAE,IA2FtB,CAAA"}
@@ -1,94 +0,0 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
- const IGNORE_DIRS = ['node_modules', '.git', 'dist', 'build', '.next', 'coverage', '.cache'];
4
- const MAX_RESULTS = 100;
5
- function matchGlob(pattern, filePath) {
6
- const normalizedPattern = pattern.replace(/\./g, '\\.').replace(/\*/g, '[^/]*').replace(/\?/g, '[^/]');
7
- const normalizedPath = filePath.replace(/\\/g, '/');
8
- return new RegExp(`^${normalizedPattern}$`, 'i').test(normalizedPath);
9
- }
10
- export const grepTool = {
11
- name: 'grep',
12
- description: '',
13
- descriptionFile: 'grep.txt',
14
- parameters: {
15
- type: 'object',
16
- properties: {
17
- pattern: {
18
- type: 'string',
19
- description: '正则表达式模式'
20
- },
21
- directory: {
22
- type: 'string',
23
- description: '搜索目录(可选)'
24
- },
25
- include: {
26
- type: 'string',
27
- description: '文件模式过滤(可选,如 "*.ts")'
28
- }
29
- },
30
- required: ['pattern']
31
- },
32
- execute: async (params, context) => {
33
- const { pattern, directory, include } = params;
34
- const dir = directory ? path.resolve(directory) : (context.workDir || process.cwd());
35
- let regex;
36
- try {
37
- regex = new RegExp(pattern, 'g');
38
- }
39
- catch {
40
- return { success: false, output: '', error: `Invalid regex pattern: ${pattern}` };
41
- }
42
- const results = [];
43
- const walk = (currentDir) => {
44
- if (results.length >= MAX_RESULTS)
45
- return;
46
- try {
47
- const entries = fs.readdirSync(currentDir, { withFileTypes: true });
48
- for (const entry of entries) {
49
- if (results.length >= MAX_RESULTS)
50
- break;
51
- const fullPath = path.join(currentDir, entry.name);
52
- if (entry.isDirectory()) {
53
- if (!IGNORE_DIRS.includes(entry.name) && !entry.name.startsWith('.')) {
54
- walk(fullPath);
55
- }
56
- }
57
- else {
58
- const relativePath = path.relative(dir, fullPath).replace(/\\/g, '/');
59
- if (include && !matchGlob(include, relativePath) && !matchGlob(include, entry.name)) {
60
- continue;
61
- }
62
- try {
63
- const content = fs.readFileSync(fullPath, 'utf-8');
64
- const lines = content.split('\n');
65
- for (let i = 0; i < lines.length && results.length < MAX_RESULTS; i++) {
66
- regex.lastIndex = 0;
67
- if (regex.test(lines[i])) {
68
- results.push({
69
- file: relativePath,
70
- line: i + 1,
71
- content: lines[i].trim().slice(0, 200)
72
- });
73
- }
74
- }
75
- }
76
- catch { }
77
- }
78
- }
79
- }
80
- catch { }
81
- };
82
- walk(dir);
83
- if (results.length === 0) {
84
- return { success: true, output: `未找到匹配: ${pattern}`, metadata: { pattern, directory: dir } };
85
- }
86
- const output = `找到 ${results.length} 处匹配:\n${results.map(r => `${r.file}:${r.line}: ${r.content}`).join('\n')}`;
87
- return {
88
- success: true,
89
- output,
90
- metadata: { total: results.length, pattern, directory: dir }
91
- };
92
- }
93
- };
94
- //# sourceMappingURL=grep.js.map