tianxincode 1.0.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 (374) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +57 -0
  3. package/dist/api/api.types.d.ts +350 -0
  4. package/dist/api/api.types.d.ts.map +1 -0
  5. package/dist/api/api.types.js +12 -0
  6. package/dist/api/api.types.js.map +1 -0
  7. package/dist/api/chat.routes.d.ts +26 -0
  8. package/dist/api/chat.routes.d.ts.map +1 -0
  9. package/dist/api/chat.routes.js +275 -0
  10. package/dist/api/chat.routes.js.map +1 -0
  11. package/dist/api/config.routes.d.ts +10 -0
  12. package/dist/api/config.routes.d.ts.map +1 -0
  13. package/dist/api/config.routes.js +150 -0
  14. package/dist/api/config.routes.js.map +1 -0
  15. package/dist/api/db.routes.d.ts +12 -0
  16. package/dist/api/db.routes.d.ts.map +1 -0
  17. package/dist/api/db.routes.js +108 -0
  18. package/dist/api/db.routes.js.map +1 -0
  19. package/dist/api/files.routes.d.ts +14 -0
  20. package/dist/api/files.routes.d.ts.map +1 -0
  21. package/dist/api/files.routes.js +220 -0
  22. package/dist/api/files.routes.js.map +1 -0
  23. package/dist/api/filesystem.routes.d.ts +10 -0
  24. package/dist/api/filesystem.routes.d.ts.map +1 -0
  25. package/dist/api/filesystem.routes.js +181 -0
  26. package/dist/api/filesystem.routes.js.map +1 -0
  27. package/dist/api/index.d.ts +6 -0
  28. package/dist/api/index.d.ts.map +1 -0
  29. package/dist/api/index.js +25 -0
  30. package/dist/api/index.js.map +1 -0
  31. package/dist/api/lsp.d.ts +5 -0
  32. package/dist/api/lsp.d.ts.map +1 -0
  33. package/dist/api/lsp.js +103 -0
  34. package/dist/api/lsp.js.map +1 -0
  35. package/dist/api/projects.routes.d.ts +18 -0
  36. package/dist/api/projects.routes.d.ts.map +1 -0
  37. package/dist/api/projects.routes.js +306 -0
  38. package/dist/api/projects.routes.js.map +1 -0
  39. package/dist/api/session.routes.d.ts +18 -0
  40. package/dist/api/session.routes.d.ts.map +1 -0
  41. package/dist/api/session.routes.js +186 -0
  42. package/dist/api/session.routes.js.map +1 -0
  43. package/dist/api/skills.routes.d.ts +6 -0
  44. package/dist/api/skills.routes.d.ts.map +1 -0
  45. package/dist/api/skills.routes.js +54 -0
  46. package/dist/api/skills.routes.js.map +1 -0
  47. package/dist/cli/args.d.ts +49 -0
  48. package/dist/cli/args.d.ts.map +1 -0
  49. package/dist/cli/args.js +77 -0
  50. package/dist/cli/args.js.map +1 -0
  51. package/dist/cli/cli.types.d.ts +22 -0
  52. package/dist/cli/cli.types.d.ts.map +1 -0
  53. package/dist/cli/cli.types.js +5 -0
  54. package/dist/cli/cli.types.js.map +1 -0
  55. package/dist/cli/commands.d.ts +30 -0
  56. package/dist/cli/commands.d.ts.map +1 -0
  57. package/dist/cli/commands.js +263 -0
  58. package/dist/cli/commands.js.map +1 -0
  59. package/dist/cli/index.d.ts +7 -0
  60. package/dist/cli/index.d.ts.map +1 -0
  61. package/dist/cli/index.js +6 -0
  62. package/dist/cli/index.js.map +1 -0
  63. package/dist/components/App.d.ts +34 -0
  64. package/dist/components/App.d.ts.map +1 -0
  65. package/dist/components/App.js +639 -0
  66. package/dist/components/App.js.map +1 -0
  67. package/dist/config/index.d.ts +2 -0
  68. package/dist/config/index.d.ts.map +1 -0
  69. package/dist/config/index.js +2 -0
  70. package/dist/config/index.js.map +1 -0
  71. package/dist/config/tx.config.d.ts +31 -0
  72. package/dist/config/tx.config.d.ts.map +1 -0
  73. package/dist/config/tx.config.js +29 -0
  74. package/dist/config/tx.config.js.map +1 -0
  75. package/dist/index.d.ts +15 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +79 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/lsp/client.d.ts +55 -0
  80. package/dist/lsp/client.d.ts.map +1 -0
  81. package/dist/lsp/client.js +252 -0
  82. package/dist/lsp/client.js.map +1 -0
  83. package/dist/lsp/downloader.d.ts +17 -0
  84. package/dist/lsp/downloader.d.ts.map +1 -0
  85. package/dist/lsp/downloader.js +302 -0
  86. package/dist/lsp/downloader.js.map +1 -0
  87. package/dist/lsp/index.d.ts +13 -0
  88. package/dist/lsp/index.d.ts.map +1 -0
  89. package/dist/lsp/index.js +30 -0
  90. package/dist/lsp/index.js.map +1 -0
  91. package/dist/lsp/launch.d.ts +17 -0
  92. package/dist/lsp/launch.d.ts.map +1 -0
  93. package/dist/lsp/launch.js +69 -0
  94. package/dist/lsp/launch.js.map +1 -0
  95. package/dist/lsp/manager.d.ts +19 -0
  96. package/dist/lsp/manager.d.ts.map +1 -0
  97. package/dist/lsp/manager.js +251 -0
  98. package/dist/lsp/manager.js.map +1 -0
  99. package/dist/lsp/server.d.ts +11 -0
  100. package/dist/lsp/server.d.ts.map +1 -0
  101. package/dist/lsp/server.js +302 -0
  102. package/dist/lsp/server.js.map +1 -0
  103. package/dist/lsp/sql.d.ts +11 -0
  104. package/dist/lsp/sql.d.ts.map +1 -0
  105. package/dist/lsp/sql.js +23 -0
  106. package/dist/lsp/sql.js.map +1 -0
  107. package/dist/lsp/types.d.ts +58 -0
  108. package/dist/lsp/types.d.ts.map +1 -0
  109. package/dist/lsp/types.js +13 -0
  110. package/dist/lsp/types.js.map +1 -0
  111. package/dist/modules/ai/ai.service.d.ts +182 -0
  112. package/dist/modules/ai/ai.service.d.ts.map +1 -0
  113. package/dist/modules/ai/ai.service.js +280 -0
  114. package/dist/modules/ai/ai.service.js.map +1 -0
  115. package/dist/modules/ai/ai.types.d.ts +54 -0
  116. package/dist/modules/ai/ai.types.d.ts.map +1 -0
  117. package/dist/modules/ai/ai.types.js +2 -0
  118. package/dist/modules/ai/ai.types.js.map +1 -0
  119. package/dist/modules/ai/index.d.ts +6 -0
  120. package/dist/modules/ai/index.d.ts.map +1 -0
  121. package/dist/modules/ai/index.js +5 -0
  122. package/dist/modules/ai/index.js.map +1 -0
  123. package/dist/modules/ai/openai.provider.d.ts +138 -0
  124. package/dist/modules/ai/openai.provider.d.ts.map +1 -0
  125. package/dist/modules/ai/openai.provider.js +279 -0
  126. package/dist/modules/ai/openai.provider.js.map +1 -0
  127. package/dist/modules/ai/react/index.d.ts +5 -0
  128. package/dist/modules/ai/react/index.d.ts.map +1 -0
  129. package/dist/modules/ai/react/index.js +4 -0
  130. package/dist/modules/ai/react/index.js.map +1 -0
  131. package/dist/modules/ai/react/prompt/role.txt +51 -0
  132. package/dist/modules/ai/react/react.parser.d.ts +75 -0
  133. package/dist/modules/ai/react/react.parser.d.ts.map +1 -0
  134. package/dist/modules/ai/react/react.parser.js +278 -0
  135. package/dist/modules/ai/react/react.parser.js.map +1 -0
  136. package/dist/modules/ai/react/react.prompts.d.ts +26 -0
  137. package/dist/modules/ai/react/react.prompts.d.ts.map +1 -0
  138. package/dist/modules/ai/react/react.prompts.js +180 -0
  139. package/dist/modules/ai/react/react.prompts.js.map +1 -0
  140. package/dist/modules/ai/react/react.types.d.ts +47 -0
  141. package/dist/modules/ai/react/react.types.d.ts.map +1 -0
  142. package/dist/modules/ai/react/react.types.js +2 -0
  143. package/dist/modules/ai/react/react.types.js.map +1 -0
  144. package/dist/modules/ai/react.agent.d.ts +40 -0
  145. package/dist/modules/ai/react.agent.d.ts.map +1 -0
  146. package/dist/modules/ai/react.agent.js +136 -0
  147. package/dist/modules/ai/react.agent.js.map +1 -0
  148. package/dist/modules/ai/summarizer/index.d.ts +4 -0
  149. package/dist/modules/ai/summarizer/index.d.ts.map +1 -0
  150. package/dist/modules/ai/summarizer/index.js +3 -0
  151. package/dist/modules/ai/summarizer/index.js.map +1 -0
  152. package/dist/modules/ai/summarizer/summarizer.prompts.d.ts +15 -0
  153. package/dist/modules/ai/summarizer/summarizer.prompts.d.ts.map +1 -0
  154. package/dist/modules/ai/summarizer/summarizer.prompts.js +47 -0
  155. package/dist/modules/ai/summarizer/summarizer.prompts.js.map +1 -0
  156. package/dist/modules/ai/summarizer/summarizer.service.d.ts +24 -0
  157. package/dist/modules/ai/summarizer/summarizer.service.d.ts.map +1 -0
  158. package/dist/modules/ai/summarizer/summarizer.service.js +153 -0
  159. package/dist/modules/ai/summarizer/summarizer.service.js.map +1 -0
  160. package/dist/modules/ai/summarizer/summarizer.types.d.ts +21 -0
  161. package/dist/modules/ai/summarizer/summarizer.types.d.ts.map +1 -0
  162. package/dist/modules/ai/summarizer/summarizer.types.js +5 -0
  163. package/dist/modules/ai/summarizer/summarizer.types.js.map +1 -0
  164. package/dist/modules/config/config.service.d.ts +32 -0
  165. package/dist/modules/config/config.service.d.ts.map +1 -0
  166. package/dist/modules/config/config.service.js +163 -0
  167. package/dist/modules/config/config.service.js.map +1 -0
  168. package/dist/modules/config/config.types.d.ts +44 -0
  169. package/dist/modules/config/config.types.d.ts.map +1 -0
  170. package/dist/modules/config/config.types.js +21 -0
  171. package/dist/modules/config/config.types.js.map +1 -0
  172. package/dist/modules/config/index.d.ts +10 -0
  173. package/dist/modules/config/index.d.ts.map +1 -0
  174. package/dist/modules/config/index.js +10 -0
  175. package/dist/modules/config/index.js.map +1 -0
  176. package/dist/modules/context/context.service.d.ts +46 -0
  177. package/dist/modules/context/context.service.d.ts.map +1 -0
  178. package/dist/modules/context/context.service.js +216 -0
  179. package/dist/modules/context/context.service.js.map +1 -0
  180. package/dist/modules/context/context.types.d.ts +30 -0
  181. package/dist/modules/context/context.types.d.ts.map +1 -0
  182. package/dist/modules/context/context.types.js +5 -0
  183. package/dist/modules/context/context.types.js.map +1 -0
  184. package/dist/modules/context/index.d.ts +10 -0
  185. package/dist/modules/context/index.d.ts.map +1 -0
  186. package/dist/modules/context/index.js +10 -0
  187. package/dist/modules/context/index.js.map +1 -0
  188. package/dist/modules/db/db.service.d.ts +97 -0
  189. package/dist/modules/db/db.service.d.ts.map +1 -0
  190. package/dist/modules/db/db.service.js +387 -0
  191. package/dist/modules/db/db.service.js.map +1 -0
  192. package/dist/modules/db/db.types.d.ts +8 -0
  193. package/dist/modules/db/db.types.d.ts.map +1 -0
  194. package/dist/modules/db/db.types.js +7 -0
  195. package/dist/modules/db/db.types.js.map +1 -0
  196. package/dist/modules/db/index.d.ts +10 -0
  197. package/dist/modules/db/index.d.ts.map +1 -0
  198. package/dist/modules/db/index.js +9 -0
  199. package/dist/modules/db/index.js.map +1 -0
  200. package/dist/modules/logger/index.d.ts +2 -0
  201. package/dist/modules/logger/index.d.ts.map +1 -0
  202. package/dist/modules/logger/index.js +2 -0
  203. package/dist/modules/logger/index.js.map +1 -0
  204. package/dist/modules/logger/logger.d.ts +26 -0
  205. package/dist/modules/logger/logger.d.ts.map +1 -0
  206. package/dist/modules/logger/logger.js +57 -0
  207. package/dist/modules/logger/logger.js.map +1 -0
  208. package/dist/modules/memory/index.d.ts +9 -0
  209. package/dist/modules/memory/index.d.ts.map +1 -0
  210. package/dist/modules/memory/index.js +9 -0
  211. package/dist/modules/memory/index.js.map +1 -0
  212. package/dist/modules/memory/memory.service.d.ts +191 -0
  213. package/dist/modules/memory/memory.service.d.ts.map +1 -0
  214. package/dist/modules/memory/memory.service.js +282 -0
  215. package/dist/modules/memory/memory.service.js.map +1 -0
  216. package/dist/modules/memory/memory.types.d.ts +13 -0
  217. package/dist/modules/memory/memory.types.d.ts.map +1 -0
  218. package/dist/modules/memory/memory.types.js +5 -0
  219. package/dist/modules/memory/memory.types.js.map +1 -0
  220. package/dist/modules/session/index.d.ts +9 -0
  221. package/dist/modules/session/index.d.ts.map +1 -0
  222. package/dist/modules/session/index.js +9 -0
  223. package/dist/modules/session/index.js.map +1 -0
  224. package/dist/modules/session/session.service.d.ts +252 -0
  225. package/dist/modules/session/session.service.d.ts.map +1 -0
  226. package/dist/modules/session/session.service.js +406 -0
  227. package/dist/modules/session/session.service.js.map +1 -0
  228. package/dist/modules/session/session.types.d.ts +34 -0
  229. package/dist/modules/session/session.types.d.ts.map +1 -0
  230. package/dist/modules/session/session.types.js +5 -0
  231. package/dist/modules/session/session.types.js.map +1 -0
  232. package/dist/modules/skill/index.d.ts +8 -0
  233. package/dist/modules/skill/index.d.ts.map +1 -0
  234. package/dist/modules/skill/index.js +7 -0
  235. package/dist/modules/skill/index.js.map +1 -0
  236. package/dist/modules/skill/skill.service.d.ts +72 -0
  237. package/dist/modules/skill/skill.service.d.ts.map +1 -0
  238. package/dist/modules/skill/skill.service.js +283 -0
  239. package/dist/modules/skill/skill.service.js.map +1 -0
  240. package/dist/modules/skill/skill.tool.d.ts +19 -0
  241. package/dist/modules/skill/skill.tool.d.ts.map +1 -0
  242. package/dist/modules/skill/skill.tool.js +92 -0
  243. package/dist/modules/skill/skill.tool.js.map +1 -0
  244. package/dist/modules/skill/skill.txt +18 -0
  245. package/dist/modules/skill/skill.types.d.ts +40 -0
  246. package/dist/modules/skill/skill.types.d.ts.map +1 -0
  247. package/dist/modules/skill/skill.types.js +6 -0
  248. package/dist/modules/skill/skill.types.js.map +1 -0
  249. package/dist/modules/skill/skills.manager.d.ts +30 -0
  250. package/dist/modules/skill/skills.manager.d.ts.map +1 -0
  251. package/dist/modules/skill/skills.manager.js +182 -0
  252. package/dist/modules/skill/skills.manager.js.map +1 -0
  253. package/dist/modules/tools/builtin/bash.d.ts +3 -0
  254. package/dist/modules/tools/builtin/bash.d.ts.map +1 -0
  255. package/dist/modules/tools/builtin/bash.js +124 -0
  256. package/dist/modules/tools/builtin/bash.js.map +1 -0
  257. package/dist/modules/tools/builtin/bash.tool.d.ts +6 -0
  258. package/dist/modules/tools/builtin/bash.tool.d.ts.map +1 -0
  259. package/dist/modules/tools/builtin/bash.tool.js +52 -0
  260. package/dist/modules/tools/builtin/bash.tool.js.map +1 -0
  261. package/dist/modules/tools/builtin/bash.txt +81 -0
  262. package/dist/modules/tools/builtin/code_search.d.ts +3 -0
  263. package/dist/modules/tools/builtin/code_search.d.ts.map +1 -0
  264. package/dist/modules/tools/builtin/code_search.js +85 -0
  265. package/dist/modules/tools/builtin/code_search.js.map +1 -0
  266. package/dist/modules/tools/builtin/code_search.txt +18 -0
  267. package/dist/modules/tools/builtin/edit-file.tool.d.ts +6 -0
  268. package/dist/modules/tools/builtin/edit-file.tool.d.ts.map +1 -0
  269. package/dist/modules/tools/builtin/edit-file.tool.js +58 -0
  270. package/dist/modules/tools/builtin/edit-file.tool.js.map +1 -0
  271. package/dist/modules/tools/builtin/edit_file.d.ts +3 -0
  272. package/dist/modules/tools/builtin/edit_file.d.ts.map +1 -0
  273. package/dist/modules/tools/builtin/edit_file.js +69 -0
  274. package/dist/modules/tools/builtin/edit_file.js.map +1 -0
  275. package/dist/modules/tools/builtin/edit_file.txt +10 -0
  276. package/dist/modules/tools/builtin/glob.d.ts +3 -0
  277. package/dist/modules/tools/builtin/glob.d.ts.map +1 -0
  278. package/dist/modules/tools/builtin/glob.js +84 -0
  279. package/dist/modules/tools/builtin/glob.js.map +1 -0
  280. package/dist/modules/tools/builtin/glob.tool.d.ts +6 -0
  281. package/dist/modules/tools/builtin/glob.tool.d.ts.map +1 -0
  282. package/dist/modules/tools/builtin/glob.tool.js +81 -0
  283. package/dist/modules/tools/builtin/glob.tool.js.map +1 -0
  284. package/dist/modules/tools/builtin/glob.txt +10 -0
  285. package/dist/modules/tools/builtin/grep.d.ts +3 -0
  286. package/dist/modules/tools/builtin/grep.d.ts.map +1 -0
  287. package/dist/modules/tools/builtin/grep.js +93 -0
  288. package/dist/modules/tools/builtin/grep.js.map +1 -0
  289. package/dist/modules/tools/builtin/grep.tool.d.ts +6 -0
  290. package/dist/modules/tools/builtin/grep.tool.d.ts.map +1 -0
  291. package/dist/modules/tools/builtin/grep.tool.js +96 -0
  292. package/dist/modules/tools/builtin/grep.tool.js.map +1 -0
  293. package/dist/modules/tools/builtin/grep.txt +12 -0
  294. package/dist/modules/tools/builtin/index.d.ts +8 -0
  295. package/dist/modules/tools/builtin/index.d.ts.map +1 -0
  296. package/dist/modules/tools/builtin/index.js +88 -0
  297. package/dist/modules/tools/builtin/index.js.map +1 -0
  298. package/dist/modules/tools/builtin/lsp.d.ts +7 -0
  299. package/dist/modules/tools/builtin/lsp.d.ts.map +1 -0
  300. package/dist/modules/tools/builtin/lsp.js +125 -0
  301. package/dist/modules/tools/builtin/lsp.js.map +1 -0
  302. package/dist/modules/tools/builtin/lsp.txt +19 -0
  303. package/dist/modules/tools/builtin/memory.d.ts +3 -0
  304. package/dist/modules/tools/builtin/memory.d.ts.map +1 -0
  305. package/dist/modules/tools/builtin/memory.js +76 -0
  306. package/dist/modules/tools/builtin/memory.js.map +1 -0
  307. package/dist/modules/tools/builtin/memory.txt +36 -0
  308. package/dist/modules/tools/builtin/read-file.tool.d.ts +6 -0
  309. package/dist/modules/tools/builtin/read-file.tool.d.ts.map +1 -0
  310. package/dist/modules/tools/builtin/read-file.tool.js +46 -0
  311. package/dist/modules/tools/builtin/read-file.tool.js.map +1 -0
  312. package/dist/modules/tools/builtin/read_file.d.ts +3 -0
  313. package/dist/modules/tools/builtin/read_file.d.ts.map +1 -0
  314. package/dist/modules/tools/builtin/read_file.js +99 -0
  315. package/dist/modules/tools/builtin/read_file.js.map +1 -0
  316. package/dist/modules/tools/builtin/read_file.txt +15 -0
  317. package/dist/modules/tools/builtin/todo_read.d.ts +6 -0
  318. package/dist/modules/tools/builtin/todo_read.d.ts.map +1 -0
  319. package/dist/modules/tools/builtin/todo_read.js +24 -0
  320. package/dist/modules/tools/builtin/todo_read.js.map +1 -0
  321. package/dist/modules/tools/builtin/todo_read.txt +14 -0
  322. package/dist/modules/tools/builtin/todo_write.d.ts +6 -0
  323. package/dist/modules/tools/builtin/todo_write.d.ts.map +1 -0
  324. package/dist/modules/tools/builtin/todo_write.js +45 -0
  325. package/dist/modules/tools/builtin/todo_write.js.map +1 -0
  326. package/dist/modules/tools/builtin/todo_write.txt +46 -0
  327. package/dist/modules/tools/builtin/web_fetch.d.ts +3 -0
  328. package/dist/modules/tools/builtin/web_fetch.d.ts.map +1 -0
  329. package/dist/modules/tools/builtin/web_fetch.js +51 -0
  330. package/dist/modules/tools/builtin/web_fetch.js.map +1 -0
  331. package/dist/modules/tools/builtin/web_fetch.txt +15 -0
  332. package/dist/modules/tools/builtin/web_search.d.ts +3 -0
  333. package/dist/modules/tools/builtin/web_search.d.ts.map +1 -0
  334. package/dist/modules/tools/builtin/web_search.js +99 -0
  335. package/dist/modules/tools/builtin/web_search.js.map +1 -0
  336. package/dist/modules/tools/builtin/web_search.txt +16 -0
  337. package/dist/modules/tools/builtin/write-file.tool.d.ts +6 -0
  338. package/dist/modules/tools/builtin/write-file.tool.d.ts.map +1 -0
  339. package/dist/modules/tools/builtin/write-file.tool.js +38 -0
  340. package/dist/modules/tools/builtin/write-file.tool.js.map +1 -0
  341. package/dist/modules/tools/builtin/write_file.d.ts +3 -0
  342. package/dist/modules/tools/builtin/write_file.d.ts.map +1 -0
  343. package/dist/modules/tools/builtin/write_file.js +46 -0
  344. package/dist/modules/tools/builtin/write_file.js.map +1 -0
  345. package/dist/modules/tools/builtin/write_file.txt +9 -0
  346. package/dist/modules/tools/index.d.ts +11 -0
  347. package/dist/modules/tools/index.d.ts.map +1 -0
  348. package/dist/modules/tools/index.js +10 -0
  349. package/dist/modules/tools/index.js.map +1 -0
  350. package/dist/modules/tools/tool.service.d.ts +207 -0
  351. package/dist/modules/tools/tool.service.d.ts.map +1 -0
  352. package/dist/modules/tools/tool.service.js +331 -0
  353. package/dist/modules/tools/tool.service.js.map +1 -0
  354. package/dist/modules/tools/tool.types.d.ts +39 -0
  355. package/dist/modules/tools/tool.types.d.ts.map +1 -0
  356. package/dist/modules/tools/tool.types.js +5 -0
  357. package/dist/modules/tools/tool.types.js.map +1 -0
  358. package/dist/web/index.d.ts +10 -0
  359. package/dist/web/index.d.ts.map +1 -0
  360. package/dist/web/index.js +20 -0
  361. package/dist/web/index.js.map +1 -0
  362. package/dist/web/web.service.d.ts +95 -0
  363. package/dist/web/web.service.d.ts.map +1 -0
  364. package/dist/web/web.service.js +396 -0
  365. package/dist/web/web.service.js.map +1 -0
  366. package/package.json +57 -0
  367. package/web/dist/assets/Layout-Bb76CGAL.js +1 -0
  368. package/web/dist/assets/element-icons-B-tDfklg.woff +0 -0
  369. package/web/dist/assets/element-icons-_lZGOqcG.ttf +0 -0
  370. package/web/dist/assets/index-DQRR0ggU.js +199 -0
  371. package/web/dist/assets/index-KTH-myBB.css +1 -0
  372. package/web/dist/index.html +14 -0
  373. package/web/index.html +13 -0
  374. package/web/package.json +24 -0
@@ -0,0 +1,58 @@
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
@@ -0,0 +1 @@
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,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,SAAS;aACvB;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,SAAS;aACvB;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,SAAS;aACvB;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,SAAS;gBACf,WAAW,EAAE,qBAAqB;aACnC;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC;KACpD;IACD,OAAO,EAAE,KAAK,EAAE,MAKf,EAAmB,EAAE;QACpB,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QAE1E,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC9B,OAAO,cAAc,SAAS,EAAE,CAAC;QACnC,CAAC;QAED,IAAI,CAAC;YACH,IAAI,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAElD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;gBAClC,OAAO,eAAe,CAAC;YACzB,CAAC;YAED,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YACvD,CAAC;iBAAM,CAAC;gBACN,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;gBAC/C,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;oBACvD,OAAO,sCAAsC,CAAC;gBAChD,CAAC;gBACD,OAAO,GAAG,OAAO,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"}
@@ -0,0 +1,3 @@
1
+ import { Tool } from '../tool.types.js';
2
+ export declare const editFileTool: Tool;
3
+ //# sourceMappingURL=edit_file.d.ts.map
@@ -0,0 +1 @@
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,IAwE1B,CAAA"}
@@ -0,0 +1,69 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ export const editFileTool = {
4
+ name: 'edit_file',
5
+ description: '',
6
+ parameters: {
7
+ type: 'object',
8
+ properties: {
9
+ file_path: {
10
+ type: 'string',
11
+ description: '文件绝对路径'
12
+ },
13
+ old_string: {
14
+ type: 'string',
15
+ description: '要被替换的内容(必须精确匹配)'
16
+ },
17
+ new_string: {
18
+ type: 'string',
19
+ description: '替换后的新内容'
20
+ },
21
+ replace_all: {
22
+ type: 'boolean',
23
+ description: '是否替换所有匹配项(可选,默认 false)'
24
+ }
25
+ },
26
+ required: ['file_path', 'old_string', 'new_string']
27
+ },
28
+ execute: async (params, context) => {
29
+ let { file_path, old_string, new_string, replace_all = false } = params;
30
+ if (file_path.startsWith('@')) {
31
+ file_path = file_path.substring(1);
32
+ }
33
+ if (!path.isAbsolute(file_path)) {
34
+ file_path = path.resolve(context.workDir || process.cwd(), file_path);
35
+ }
36
+ const exists = await fs.promises.access(file_path).then(() => true).catch(() => false);
37
+ if (!exists) {
38
+ return { success: false, output: '', error: `File not found: ${file_path}` };
39
+ }
40
+ const content = await fs.promises.readFile(file_path, 'utf-8');
41
+ if (!content.includes(old_string)) {
42
+ return { success: false, output: '', error: 'old_string not found in content' };
43
+ }
44
+ let newContent;
45
+ if (replace_all) {
46
+ newContent = content.split(old_string).join(new_string);
47
+ }
48
+ else {
49
+ const firstIndex = content.indexOf(old_string);
50
+ const secondIndex = content.indexOf(old_string, firstIndex + old_string.length);
51
+ if (secondIndex !== -1) {
52
+ return {
53
+ success: false,
54
+ output: '',
55
+ error: 'Found multiple matches. Use replace_all=true or provide more context to make old_string unique.'
56
+ };
57
+ }
58
+ newContent = content.replace(old_string, new_string);
59
+ }
60
+ await fs.promises.writeFile(file_path, newContent, 'utf-8');
61
+ const count = replace_all ? (content.split(old_string).length - 1) : 1;
62
+ return {
63
+ success: true,
64
+ output: `成功: 文件已更新 ${file_path}${count > 1 ? ` (${count} 处替换)` : ''}`,
65
+ metadata: { path: file_path, replacements: count }
66
+ };
67
+ }
68
+ };
69
+ //# sourceMappingURL=edit_file.js.map
@@ -0,0 +1 @@
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,CA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AE,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"}
@@ -0,0 +1,10 @@
1
+ 对文件执行精确的字符串替换。
2
+
3
+ **使用说明**:
4
+ - 在编辑前,**必须**至少使用过一次 Read 工具。未读取文件就编辑会报错
5
+ - 从 Read 工具输出编辑文本时,确保保留精确的缩进(空格/制表符)。行号前缀格式是:行号 + 冒号 + 空格(如 `1: `)。`oldString` 和 `newString` 中**禁止**包含行号前缀的任何部分
6
+ - **优先**编辑现有文件,**禁止**创建新文件除非明确需要
7
+ - 只有用户明确要求时才使用表情符号
8
+ - 如果 `oldString` 在文件中找不到会**失败**,报错 "oldString not found in content"
9
+ - 如果 `oldString` 在文件中出现多次会**失败**,报错 "Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match."。可以提供更多上下文使其唯一,或使用 `replaceAll` 替换所有匹配项
10
+ - `replaceAll` 用于在整个文件中替换和重命名字符串
@@ -0,0 +1,3 @@
1
+ import { Tool } from '../tool.types.js';
2
+ export declare const globTool: Tool;
3
+ //# sourceMappingURL=glob.d.ts.map
@@ -0,0 +1 @@
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,IA0CtB,CAAA"}
@@ -0,0 +1,84 @@
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
+ parameters: {
50
+ type: 'object',
51
+ properties: {
52
+ pattern: {
53
+ type: 'string',
54
+ description: 'glob 模式,如 "**/*.ts" 匹配所有 ts 文件'
55
+ },
56
+ directory: {
57
+ type: 'string',
58
+ description: '搜索目录的绝对路径(可选,默认当前工作目录)'
59
+ }
60
+ },
61
+ required: ['pattern']
62
+ },
63
+ execute: async (params, context) => {
64
+ const { pattern, directory } = params;
65
+ const dir = directory ? path.resolve(directory) : (context.workDir || process.cwd());
66
+ const exists = await fs.promises.access(dir).then(() => true).catch(() => false);
67
+ if (!exists) {
68
+ return { success: false, output: '', error: `Directory not found: ${dir}` };
69
+ }
70
+ const results = glob(pattern, dir);
71
+ if (results.length === 0) {
72
+ return { success: true, output: `未找到匹配文件: ${pattern}\n搜索目录: ${dir}` };
73
+ }
74
+ const maxShow = 100;
75
+ const shown = results.length > maxShow ? results.slice(0, maxShow) : results;
76
+ const output = `找到 ${results.length} 个文件${results.length > maxShow ? `(显示前 ${maxShow} 个)` : ''}:\n${shown.join('\n')}\n\n搜索目录: ${dir}${results.length > maxShow ? `\n... 还有 ${results.length - maxShow} 个文件` : ''}`;
77
+ return {
78
+ success: true,
79
+ output,
80
+ metadata: { total: results.length, pattern, directory: dir }
81
+ };
82
+ }
83
+ };
84
+ //# sourceMappingURL=glob.js.map
@@ -0,0 +1 @@
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,OAAO,CAAC;SACvB,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC;SACh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../tool.types.js';
5
+ export declare const globTool: Tool;
6
+ //# sourceMappingURL=glob.tool.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,81 @@
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
@@ -0,0 +1 @@
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;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AC,IAAI,CAAC,EAAE,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"}
@@ -0,0 +1,10 @@
1
+ 快速的文件模式匹配工具,适用于任何规模的代码库。
2
+
3
+ **功能**:
4
+ - 支持 glob 模式如 "**/*.js" 或 "src/**/*.ts"
5
+ - 返回匹配文件的路径,按修改时间排序
6
+ - 当你需要按名称模式查找文件时使用此工具
7
+
8
+ **注意**:当你需要进行可能需要多轮 glob 和 grep 的开放式搜索时,使用 Task 工具。
9
+
10
+ **最佳实践**:可以并行调用多个工具,总是更好地批量执行多个可能有用的搜索。
@@ -0,0 +1,3 @@
1
+ import { Tool } from '../tool.types.js';
2
+ export declare const grepTool: Tool;
3
+ //# sourceMappingURL=grep.d.ts.map
@@ -0,0 +1 @@
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,IA0FtB,CAAA"}
@@ -0,0 +1,93 @@
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
+ parameters: {
14
+ type: 'object',
15
+ properties: {
16
+ pattern: {
17
+ type: 'string',
18
+ description: '正则表达式模式'
19
+ },
20
+ directory: {
21
+ type: 'string',
22
+ description: '搜索目录(可选)'
23
+ },
24
+ include: {
25
+ type: 'string',
26
+ description: '文件模式过滤(可选,如 "*.ts")'
27
+ }
28
+ },
29
+ required: ['pattern']
30
+ },
31
+ execute: async (params, context) => {
32
+ const { pattern, directory, include } = params;
33
+ const dir = directory ? path.resolve(directory) : (context.workDir || process.cwd());
34
+ let regex;
35
+ try {
36
+ regex = new RegExp(pattern, 'g');
37
+ }
38
+ catch {
39
+ return { success: false, output: '', error: `Invalid regex pattern: ${pattern}` };
40
+ }
41
+ const results = [];
42
+ const walk = (currentDir) => {
43
+ if (results.length >= MAX_RESULTS)
44
+ return;
45
+ try {
46
+ const entries = fs.readdirSync(currentDir, { withFileTypes: true });
47
+ for (const entry of entries) {
48
+ if (results.length >= MAX_RESULTS)
49
+ break;
50
+ const fullPath = path.join(currentDir, entry.name);
51
+ if (entry.isDirectory()) {
52
+ if (!IGNORE_DIRS.includes(entry.name) && !entry.name.startsWith('.')) {
53
+ walk(fullPath);
54
+ }
55
+ }
56
+ else {
57
+ const relativePath = path.relative(dir, fullPath).replace(/\\/g, '/');
58
+ if (include && !matchGlob(include, relativePath) && !matchGlob(include, entry.name)) {
59
+ continue;
60
+ }
61
+ try {
62
+ const content = fs.readFileSync(fullPath, 'utf-8');
63
+ const lines = content.split('\n');
64
+ for (let i = 0; i < lines.length && results.length < MAX_RESULTS; i++) {
65
+ regex.lastIndex = 0;
66
+ if (regex.test(lines[i])) {
67
+ results.push({
68
+ file: relativePath,
69
+ line: i + 1,
70
+ content: lines[i].trim().slice(0, 200)
71
+ });
72
+ }
73
+ }
74
+ }
75
+ catch { }
76
+ }
77
+ }
78
+ }
79
+ catch { }
80
+ };
81
+ walk(dir);
82
+ if (results.length === 0) {
83
+ return { success: true, output: `未找到匹配: ${pattern}`, metadata: { pattern, directory: dir } };
84
+ }
85
+ const output = `找到 ${results.length} 处匹配:\n${results.map(r => `${r.file}:${r.line}: ${r.content}`).join('\n')}`;
86
+ return {
87
+ success: true,
88
+ output,
89
+ metadata: { total: results.length, pattern, directory: dir }
90
+ };
91
+ }
92
+ };
93
+ //# sourceMappingURL=grep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep.js","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/grep.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,CAAC,CAAA;AAC5F,MAAM,WAAW,GAAG,GAAG,CAAA;AAEvB,SAAS,SAAS,CAAC,OAAe,EAAE,QAAgB;IAClD,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACtG,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACnD,OAAO,IAAI,MAAM,CAAC,IAAI,iBAAiB,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;AACvE,CAAC;AAED,MAAM,CAAC,MAAM,QAAQ,GAAS;IAC5B,IAAI,EAAE,MAAM;IACZ,WAAW,EAAE,EAAE;IACf,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,SAAS;aACvB;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,UAAU;aACxB;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAA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C,GAAG,CAAC,CAAA;QAET,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,EAAE,CAAA;QAC9F,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,UAAU,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAA;QAE/G,OAAO;YACL,OAAO,EAAE,IAAI;YACb,MAAM;YACN,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE;SAC7D,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * 内容搜索工具(Grep)
3
+ */
4
+ import { Tool } from '../tool.types.js';
5
+ export declare const grepTool: Tool;
6
+ //# sourceMappingURL=grep.tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep.tool.d.ts","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/grep.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AA0ExC,eAAO,MAAM,QAAQ,EAAE,IAyCtB,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * 内容搜索工具(Grep)
3
+ */
4
+ import * as fs from 'fs';
5
+ import * as path from 'path';
6
+ function grep(pattern, dir, filePattern) {
7
+ const results = [];
8
+ const regex = new RegExp(pattern, 'g');
9
+ const ignore = ['node_modules', '.git', 'dist', 'build', '.next', 'coverage'];
10
+ const maxResults = 100;
11
+ const walk = (currentDir) => {
12
+ if (results.length >= maxResults)
13
+ return;
14
+ const entries = fs.readdirSync(currentDir, { withFileTypes: true });
15
+ for (const entry of entries) {
16
+ if (results.length >= maxResults)
17
+ break;
18
+ if (entry.isDirectory()) {
19
+ if (!ignore.includes(entry.name)) {
20
+ walk(path.join(currentDir, entry.name));
21
+ }
22
+ }
23
+ else {
24
+ const fullPath = path.join(currentDir, entry.name);
25
+ const relativePath = path.relative(dir, fullPath);
26
+ if (filePattern && !matchGlob(filePattern, relativePath)) {
27
+ continue;
28
+ }
29
+ try {
30
+ const content = fs.readFileSync(fullPath, 'utf-8');
31
+ const lines = content.split('\n');
32
+ for (let i = 0; i < lines.length && results.length < maxResults; i++) {
33
+ if (regex.test(lines[i])) {
34
+ results.push({
35
+ file: relativePath,
36
+ line: i + 1,
37
+ content: lines[i].trim().slice(0, 200),
38
+ });
39
+ }
40
+ }
41
+ }
42
+ catch { }
43
+ }
44
+ }
45
+ };
46
+ walk(dir);
47
+ return results;
48
+ }
49
+ function matchGlob(pattern, filePath) {
50
+ const regex = new RegExp('^' + pattern
51
+ .replace(/\*\*/g, '<<DOUBLESTAR>>')
52
+ .replace(/\*/g, '[^/]*')
53
+ .replace(/<<DOUBLESTAR>>/g, '.*')
54
+ .replace(/\?/g, '[^/]')
55
+ .replace(/\./g, '\\.')
56
+ .replace(/\\/g, '/')
57
+ + '$');
58
+ return regex.test(filePath.replace(/\\/g, '/'));
59
+ }
60
+ export const grepTool = {
61
+ name: 'search_content',
62
+ description: '在文件中搜索正则表达式模式。返回匹配的文件名和行号。',
63
+ parameters: {
64
+ type: 'object',
65
+ properties: {
66
+ pattern: {
67
+ type: 'string',
68
+ description: '正则表达式模式',
69
+ },
70
+ directory: {
71
+ type: 'string',
72
+ description: '搜索目录(可选)',
73
+ },
74
+ include: {
75
+ type: 'string',
76
+ description: '文件模式过滤(可选,如 "*.ts")',
77
+ },
78
+ },
79
+ required: ['pattern'],
80
+ },
81
+ execute: async (params) => {
82
+ const { pattern, directory = process.cwd(), include } = params;
83
+ try {
84
+ const results = grep(pattern, directory, include);
85
+ if (results.length === 0) {
86
+ return `未找到匹配: ${pattern}`;
87
+ }
88
+ const output = results.map(r => `${r.file}:${r.line}: ${r.content}`).join('\n');
89
+ return `找到 ${results.length} 处匹配:\n${output}`;
90
+ }
91
+ catch (error) {
92
+ return `错误: ${error instanceof Error ? error.message : String(error)}`;
93
+ }
94
+ },
95
+ };
96
+ //# sourceMappingURL=grep.tool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"grep.tool.js","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/grep.tool.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAS7B,SAAS,IAAI,CACX,OAAe,EACf,GAAW,EACX,WAAoB;IAEpB,MAAM,OAAO,GAAY,EAAE,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACvC,MAAM,MAAM,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IAC9E,MAAM,UAAU,GAAG,GAAG,CAAC;IAEvB,MAAM,IAAI,GAAG,CAAC,UAAkB,EAAE,EAAE;QAClC,IAAI,OAAO,CAAC,MAAM,IAAI,UAAU;YAAE,OAAO;QAEzC,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,OAAO,CAAC,MAAM,IAAI,UAAU;gBAAE,MAAM;YAExC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,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YAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChF,OAAO,MAAM,OAAO,CAAC,MAAM,UAAU,MAAM,EAAE,CAAC;QAChD,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"}
@@ -0,0 +1,12 @@
1
+ 快速的内容搜索工具,适用于任何规模的代码库。
2
+
3
+ **功能**:
4
+ - 使用正则表达式搜索文件内容
5
+ - 支持完整正则语法(如 "log.*Error", "function\s+\w+" 等)
6
+ - 用 `include` 参数按文件模式过滤(如 "*.js", "*.{ts,tsx}")
7
+ - 返回有匹配的文件路径和行号,按修改时间排序
8
+ - 当你需要查找包含特定模式的文件时使用此工具
9
+
10
+ **注意**:
11
+ - 如果需要识别/统计文件中的匹配数量,直接用 Bash 工具运行 `rg` (ripgrep),**不要**用 Grep
12
+ - 当你需要可能需要多轮搜索的开放式搜索时,使用 Task 工具
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 内置工具导出
3
+ */
4
+ import { Tool } from '../tool.types.js';
5
+ export declare function getBuiltinTools(): Promise<Tool[]>;
6
+ export declare function getBuiltinToolsInstance(): Promise<Tool[]>;
7
+ export declare const builtinTools: Tool[];
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/tools/builtin/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAgCvC,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAkDvD;AAID,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAK/D;AAED,eAAO,MAAM,YAAY,EAAE,IAAI,EAAO,CAAA"}