@google/gemini-cli-core 0.1.0-development.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +156 -0
  3. package/dist/.last_build +0 -0
  4. package/dist/index.d.ts +7 -0
  5. package/dist/index.js +8 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/src/__mocks__/fs/promises.d.ts +11 -0
  8. package/dist/src/__mocks__/fs/promises.js +17 -0
  9. package/dist/src/__mocks__/fs/promises.js.map +1 -0
  10. package/dist/src/code_assist/codeAssist.d.ts +8 -0
  11. package/dist/src/code_assist/codeAssist.js +19 -0
  12. package/dist/src/code_assist/codeAssist.js.map +1 -0
  13. package/dist/src/code_assist/converter.d.ts +68 -0
  14. package/dist/src/code_assist/converter.js +125 -0
  15. package/dist/src/code_assist/converter.js.map +1 -0
  16. package/dist/src/code_assist/converter.test.d.ts +6 -0
  17. package/dist/src/code_assist/converter.test.js +229 -0
  18. package/dist/src/code_assist/converter.test.js.map +1 -0
  19. package/dist/src/code_assist/oauth2.d.ts +26 -0
  20. package/dist/src/code_assist/oauth2.js +277 -0
  21. package/dist/src/code_assist/oauth2.js.map +1 -0
  22. package/dist/src/code_assist/oauth2.test.d.ts +6 -0
  23. package/dist/src/code_assist/oauth2.test.js +195 -0
  24. package/dist/src/code_assist/oauth2.test.js.map +1 -0
  25. package/dist/src/code_assist/server.d.ts +35 -0
  26. package/dist/src/code_assist/server.js +123 -0
  27. package/dist/src/code_assist/server.js.map +1 -0
  28. package/dist/src/code_assist/server.test.d.ts +6 -0
  29. package/dist/src/code_assist/server.test.js +123 -0
  30. package/dist/src/code_assist/server.test.js.map +1 -0
  31. package/dist/src/code_assist/setup.d.ts +15 -0
  32. package/dist/src/code_assist/setup.js +67 -0
  33. package/dist/src/code_assist/setup.js.map +1 -0
  34. package/dist/src/code_assist/types.d.ts +148 -0
  35. package/dist/src/code_assist/types.js +46 -0
  36. package/dist/src/code_assist/types.js.map +1 -0
  37. package/dist/src/config/config.d.ts +175 -0
  38. package/dist/src/config/config.js +385 -0
  39. package/dist/src/config/config.js.map +1 -0
  40. package/dist/src/config/config.test.d.ts +6 -0
  41. package/dist/src/config/config.test.js +263 -0
  42. package/dist/src/config/config.test.js.map +1 -0
  43. package/dist/src/config/flashFallback.test.d.ts +6 -0
  44. package/dist/src/config/flashFallback.test.js +115 -0
  45. package/dist/src/config/flashFallback.test.js.map +1 -0
  46. package/dist/src/config/models.d.ts +8 -0
  47. package/dist/src/config/models.js +9 -0
  48. package/dist/src/config/models.js.map +1 -0
  49. package/dist/src/core/client.d.ts +39 -0
  50. package/dist/src/core/client.js +386 -0
  51. package/dist/src/core/client.js.map +1 -0
  52. package/dist/src/core/client.test.d.ts +6 -0
  53. package/dist/src/core/client.test.js +630 -0
  54. package/dist/src/core/client.test.js.map +1 -0
  55. package/dist/src/core/contentGenerator.d.ts +29 -0
  56. package/dist/src/core/contentGenerator.js +71 -0
  57. package/dist/src/core/contentGenerator.js.map +1 -0
  58. package/dist/src/core/contentGenerator.test.d.ts +6 -0
  59. package/dist/src/core/contentGenerator.test.js +45 -0
  60. package/dist/src/core/contentGenerator.test.js.map +1 -0
  61. package/dist/src/core/coreToolScheduler.d.ts +104 -0
  62. package/dist/src/core/coreToolScheduler.js +397 -0
  63. package/dist/src/core/coreToolScheduler.js.map +1 -0
  64. package/dist/src/core/coreToolScheduler.test.d.ts +6 -0
  65. package/dist/src/core/coreToolScheduler.test.js +318 -0
  66. package/dist/src/core/coreToolScheduler.test.js.map +1 -0
  67. package/dist/src/core/geminiChat.d.ts +116 -0
  68. package/dist/src/core/geminiChat.js +491 -0
  69. package/dist/src/core/geminiChat.js.map +1 -0
  70. package/dist/src/core/geminiChat.test.d.ts +6 -0
  71. package/dist/src/core/geminiChat.test.js +422 -0
  72. package/dist/src/core/geminiChat.test.js.map +1 -0
  73. package/dist/src/core/geminiRequest.d.ts +13 -0
  74. package/dist/src/core/geminiRequest.js +45 -0
  75. package/dist/src/core/geminiRequest.js.map +1 -0
  76. package/dist/src/core/geminiRequest.test.d.ts +6 -0
  77. package/dist/src/core/geminiRequest.test.js +72 -0
  78. package/dist/src/core/geminiRequest.test.js.map +1 -0
  79. package/dist/src/core/logger.d.ts +35 -0
  80. package/dist/src/core/logger.js +235 -0
  81. package/dist/src/core/logger.js.map +1 -0
  82. package/dist/src/core/logger.test.d.ts +6 -0
  83. package/dist/src/core/logger.test.js +387 -0
  84. package/dist/src/core/logger.test.js.map +1 -0
  85. package/dist/src/core/modelCheck.d.ts +14 -0
  86. package/dist/src/core/modelCheck.js +55 -0
  87. package/dist/src/core/modelCheck.js.map +1 -0
  88. package/dist/src/core/nonInteractiveToolExecutor.d.ts +12 -0
  89. package/dist/src/core/nonInteractiveToolExecutor.js +92 -0
  90. package/dist/src/core/nonInteractiveToolExecutor.js.map +1 -0
  91. package/dist/src/core/nonInteractiveToolExecutor.test.d.ts +6 -0
  92. package/dist/src/core/nonInteractiveToolExecutor.test.js +181 -0
  93. package/dist/src/core/nonInteractiveToolExecutor.test.js.map +1 -0
  94. package/dist/src/core/prompts.d.ts +12 -0
  95. package/dist/src/core/prompts.js +334 -0
  96. package/dist/src/core/prompts.js.map +1 -0
  97. package/dist/src/core/prompts.test.d.ts +6 -0
  98. package/dist/src/core/prompts.test.js +97 -0
  99. package/dist/src/core/prompts.test.js.map +1 -0
  100. package/dist/src/core/tokenLimits.d.ts +10 -0
  101. package/dist/src/core/tokenLimits.js +27 -0
  102. package/dist/src/core/tokenLimits.js.map +1 -0
  103. package/dist/src/core/turn.d.ts +96 -0
  104. package/dist/src/core/turn.js +125 -0
  105. package/dist/src/core/turn.js.map +1 -0
  106. package/dist/src/core/turn.test.d.ts +6 -0
  107. package/dist/src/core/turn.test.js +236 -0
  108. package/dist/src/core/turn.test.js.map +1 -0
  109. package/dist/src/index.d.ts +46 -0
  110. package/dist/src/index.js +54 -0
  111. package/dist/src/index.js.map +1 -0
  112. package/dist/src/index.test.d.ts +6 -0
  113. package/dist/src/index.test.js +12 -0
  114. package/dist/src/index.test.js.map +1 -0
  115. package/dist/src/services/fileDiscoveryService.d.ts +35 -0
  116. package/dist/src/services/fileDiscoveryService.js +91 -0
  117. package/dist/src/services/fileDiscoveryService.js.map +1 -0
  118. package/dist/src/services/fileDiscoveryService.test.d.ts +6 -0
  119. package/dist/src/services/fileDiscoveryService.test.js +102 -0
  120. package/dist/src/services/fileDiscoveryService.test.js.map +1 -0
  121. package/dist/src/services/gitService.d.ts +21 -0
  122. package/dist/src/services/gitService.js +105 -0
  123. package/dist/src/services/gitService.js.map +1 -0
  124. package/dist/src/services/gitService.test.d.ts +6 -0
  125. package/dist/src/services/gitService.test.js +233 -0
  126. package/dist/src/services/gitService.test.js.map +1 -0
  127. package/dist/src/telemetry/clearcut-logger/clearcut-logger.d.ts +33 -0
  128. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js +364 -0
  129. package/dist/src/telemetry/clearcut-logger/clearcut-logger.js.map +1 -0
  130. package/dist/src/telemetry/clearcut-logger/event-metadata-key.d.ts +43 -0
  131. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js +109 -0
  132. package/dist/src/telemetry/clearcut-logger/event-metadata-key.js.map +1 -0
  133. package/dist/src/telemetry/constants.d.ts +19 -0
  134. package/dist/src/telemetry/constants.js +20 -0
  135. package/dist/src/telemetry/constants.js.map +1 -0
  136. package/dist/src/telemetry/index.d.ts +18 -0
  137. package/dist/src/telemetry/index.js +20 -0
  138. package/dist/src/telemetry/index.js.map +1 -0
  139. package/dist/src/telemetry/loggers.d.ts +13 -0
  140. package/dist/src/telemetry/loggers.js +187 -0
  141. package/dist/src/telemetry/loggers.js.map +1 -0
  142. package/dist/src/telemetry/loggers.test.d.ts +6 -0
  143. package/dist/src/telemetry/loggers.test.js +525 -0
  144. package/dist/src/telemetry/loggers.test.js.map +1 -0
  145. package/dist/src/telemetry/metrics.d.ts +19 -0
  146. package/dist/src/telemetry/metrics.js +144 -0
  147. package/dist/src/telemetry/metrics.js.map +1 -0
  148. package/dist/src/telemetry/metrics.test.d.ts +6 -0
  149. package/dist/src/telemetry/metrics.test.js +162 -0
  150. package/dist/src/telemetry/metrics.test.js.map +1 -0
  151. package/dist/src/telemetry/sdk.d.ts +9 -0
  152. package/dist/src/telemetry/sdk.js +116 -0
  153. package/dist/src/telemetry/sdk.js.map +1 -0
  154. package/dist/src/telemetry/telemetry.test.d.ts +6 -0
  155. package/dist/src/telemetry/telemetry.test.js +50 -0
  156. package/dist/src/telemetry/telemetry.test.js.map +1 -0
  157. package/dist/src/telemetry/types.d.ts +91 -0
  158. package/dist/src/telemetry/types.js +176 -0
  159. package/dist/src/telemetry/types.js.map +1 -0
  160. package/dist/src/telemetry/uiTelemetry.d.ts +67 -0
  161. package/dist/src/telemetry/uiTelemetry.js +131 -0
  162. package/dist/src/telemetry/uiTelemetry.js.map +1 -0
  163. package/dist/src/telemetry/uiTelemetry.test.d.ts +6 -0
  164. package/dist/src/telemetry/uiTelemetry.test.js +411 -0
  165. package/dist/src/telemetry/uiTelemetry.test.js.map +1 -0
  166. package/dist/src/tools/diffOptions.d.ts +7 -0
  167. package/dist/src/tools/diffOptions.js +10 -0
  168. package/dist/src/tools/diffOptions.js.map +1 -0
  169. package/dist/src/tools/edit.d.ts +84 -0
  170. package/dist/src/tools/edit.js +359 -0
  171. package/dist/src/tools/edit.js.map +1 -0
  172. package/dist/src/tools/edit.test.d.ts +6 -0
  173. package/dist/src/tools/edit.test.js +500 -0
  174. package/dist/src/tools/edit.test.js.map +1 -0
  175. package/dist/src/tools/glob.d.ts +71 -0
  176. package/dist/src/tools/glob.js +215 -0
  177. package/dist/src/tools/glob.js.map +1 -0
  178. package/dist/src/tools/glob.test.d.ts +6 -0
  179. package/dist/src/tools/glob.test.js +293 -0
  180. package/dist/src/tools/glob.test.js.map +1 -0
  181. package/dist/src/tools/grep.d.ts +81 -0
  182. package/dist/src/tools/grep.js +427 -0
  183. package/dist/src/tools/grep.js.map +1 -0
  184. package/dist/src/tools/grep.test.d.ts +6 -0
  185. package/dist/src/tools/grep.test.js +185 -0
  186. package/dist/src/tools/grep.test.js.map +1 -0
  187. package/dist/src/tools/ls.d.ts +94 -0
  188. package/dist/src/tools/ls.js +215 -0
  189. package/dist/src/tools/ls.js.map +1 -0
  190. package/dist/src/tools/mcp-client.d.ts +56 -0
  191. package/dist/src/tools/mcp-client.js +302 -0
  192. package/dist/src/tools/mcp-client.js.map +1 -0
  193. package/dist/src/tools/mcp-client.test.d.ts +6 -0
  194. package/dist/src/tools/mcp-client.test.js +608 -0
  195. package/dist/src/tools/mcp-client.test.js.map +1 -0
  196. package/dist/src/tools/mcp-tool.d.ts +23 -0
  197. package/dist/src/tools/mcp-tool.js +119 -0
  198. package/dist/src/tools/mcp-tool.js.map +1 -0
  199. package/dist/src/tools/mcp-tool.test.d.ts +6 -0
  200. package/dist/src/tools/mcp-tool.test.js +173 -0
  201. package/dist/src/tools/mcp-tool.test.js.map +1 -0
  202. package/dist/src/tools/memoryTool.d.ts +28 -0
  203. package/dist/src/tools/memoryTool.js +171 -0
  204. package/dist/src/tools/memoryTool.js.map +1 -0
  205. package/dist/src/tools/memoryTool.test.d.ts +6 -0
  206. package/dist/src/tools/memoryTool.test.js +181 -0
  207. package/dist/src/tools/memoryTool.test.js.map +1 -0
  208. package/dist/src/tools/modifiable-tool.d.ts +29 -0
  209. package/dist/src/tools/modifiable-tool.js +85 -0
  210. package/dist/src/tools/modifiable-tool.js.map +1 -0
  211. package/dist/src/tools/modifiable-tool.test.d.ts +6 -0
  212. package/dist/src/tools/modifiable-tool.test.js +204 -0
  213. package/dist/src/tools/modifiable-tool.test.js.map +1 -0
  214. package/dist/src/tools/read-file.d.ts +36 -0
  215. package/dist/src/tools/read-file.js +103 -0
  216. package/dist/src/tools/read-file.js.map +1 -0
  217. package/dist/src/tools/read-file.test.d.ts +6 -0
  218. package/dist/src/tools/read-file.test.js +180 -0
  219. package/dist/src/tools/read-file.test.js.map +1 -0
  220. package/dist/src/tools/read-many-files.d.ts +65 -0
  221. package/dist/src/tools/read-many-files.js +344 -0
  222. package/dist/src/tools/read-many-files.js.map +1 -0
  223. package/dist/src/tools/read-many-files.test.d.ts +6 -0
  224. package/dist/src/tools/read-many-files.test.js +300 -0
  225. package/dist/src/tools/read-many-files.test.js.map +1 -0
  226. package/dist/src/tools/shell.d.ts +43 -0
  227. package/dist/src/tools/shell.js +421 -0
  228. package/dist/src/tools/shell.js.map +1 -0
  229. package/dist/src/tools/shell.test.d.ts +6 -0
  230. package/dist/src/tools/shell.test.js +321 -0
  231. package/dist/src/tools/shell.test.js.map +1 -0
  232. package/dist/src/tools/tool-registry.d.ts +67 -0
  233. package/dist/src/tools/tool-registry.js +326 -0
  234. package/dist/src/tools/tool-registry.js.map +1 -0
  235. package/dist/src/tools/tool-registry.test.d.ts +6 -0
  236. package/dist/src/tools/tool-registry.test.js +353 -0
  237. package/dist/src/tools/tool-registry.test.js.map +1 -0
  238. package/dist/src/tools/tools.d.ts +179 -0
  239. package/dist/src/tools/tools.js +88 -0
  240. package/dist/src/tools/tools.js.map +1 -0
  241. package/dist/src/tools/web-fetch.d.ts +29 -0
  242. package/dist/src/tools/web-fetch.js +240 -0
  243. package/dist/src/tools/web-fetch.js.map +1 -0
  244. package/dist/src/tools/web-fetch.test.d.ts +6 -0
  245. package/dist/src/tools/web-fetch.test.js +70 -0
  246. package/dist/src/tools/web-fetch.test.js.map +1 -0
  247. package/dist/src/tools/web-search.d.ts +49 -0
  248. package/dist/src/tools/web-search.js +119 -0
  249. package/dist/src/tools/web-search.js.map +1 -0
  250. package/dist/src/tools/write-file.d.ts +50 -0
  251. package/dist/src/tools/write-file.js +261 -0
  252. package/dist/src/tools/write-file.js.map +1 -0
  253. package/dist/src/tools/write-file.test.d.ts +6 -0
  254. package/dist/src/tools/write-file.test.js +413 -0
  255. package/dist/src/tools/write-file.test.js.map +1 -0
  256. package/dist/src/utils/LruCache.d.ts +13 -0
  257. package/dist/src/utils/LruCache.js +38 -0
  258. package/dist/src/utils/LruCache.js.map +1 -0
  259. package/dist/src/utils/bfsFileSearch.d.ts +22 -0
  260. package/dist/src/utils/bfsFileSearch.js +62 -0
  261. package/dist/src/utils/bfsFileSearch.js.map +1 -0
  262. package/dist/src/utils/bfsFileSearch.test.d.ts +6 -0
  263. package/dist/src/utils/bfsFileSearch.test.js +129 -0
  264. package/dist/src/utils/bfsFileSearch.test.js.map +1 -0
  265. package/dist/src/utils/editCorrector.d.ts +53 -0
  266. package/dist/src/utils/editCorrector.js +546 -0
  267. package/dist/src/utils/editCorrector.js.map +1 -0
  268. package/dist/src/utils/editCorrector.test.d.ts +6 -0
  269. package/dist/src/utils/editCorrector.test.js +560 -0
  270. package/dist/src/utils/editCorrector.test.js.map +1 -0
  271. package/dist/src/utils/editor.d.ts +28 -0
  272. package/dist/src/utils/editor.js +163 -0
  273. package/dist/src/utils/editor.js.map +1 -0
  274. package/dist/src/utils/editor.test.d.ts +6 -0
  275. package/dist/src/utils/editor.test.js +293 -0
  276. package/dist/src/utils/editor.test.js.map +1 -0
  277. package/dist/src/utils/errorReporting.d.ts +14 -0
  278. package/dist/src/utils/errorReporting.js +88 -0
  279. package/dist/src/utils/errorReporting.js.map +1 -0
  280. package/dist/src/utils/errorReporting.test.d.ts +6 -0
  281. package/dist/src/utils/errorReporting.test.js +124 -0
  282. package/dist/src/utils/errorReporting.test.js.map +1 -0
  283. package/dist/src/utils/errors.d.ts +14 -0
  284. package/dist/src/utils/errors.js +54 -0
  285. package/dist/src/utils/errors.js.map +1 -0
  286. package/dist/src/utils/fetch.d.ts +11 -0
  287. package/dist/src/utils/fetch.js +51 -0
  288. package/dist/src/utils/fetch.js.map +1 -0
  289. package/dist/src/utils/fileUtils.d.ts +49 -0
  290. package/dist/src/utils/fileUtils.js +284 -0
  291. package/dist/src/utils/fileUtils.js.map +1 -0
  292. package/dist/src/utils/fileUtils.test.d.ts +6 -0
  293. package/dist/src/utils/fileUtils.test.js +321 -0
  294. package/dist/src/utils/fileUtils.test.js.map +1 -0
  295. package/dist/src/utils/flashFallback.integration.test.d.ts +6 -0
  296. package/dist/src/utils/flashFallback.integration.test.js +112 -0
  297. package/dist/src/utils/flashFallback.integration.test.js.map +1 -0
  298. package/dist/src/utils/generateContentResponseUtilities.d.ts +14 -0
  299. package/dist/src/utils/generateContentResponseUtilities.js +92 -0
  300. package/dist/src/utils/generateContentResponseUtilities.js.map +1 -0
  301. package/dist/src/utils/generateContentResponseUtilities.test.d.ts +6 -0
  302. package/dist/src/utils/generateContentResponseUtilities.test.js +273 -0
  303. package/dist/src/utils/generateContentResponseUtilities.test.js.map +1 -0
  304. package/dist/src/utils/getFolderStructure.d.ts +30 -0
  305. package/dist/src/utils/getFolderStructure.js +247 -0
  306. package/dist/src/utils/getFolderStructure.js.map +1 -0
  307. package/dist/src/utils/getFolderStructure.test.d.ts +6 -0
  308. package/dist/src/utils/getFolderStructure.test.js +300 -0
  309. package/dist/src/utils/getFolderStructure.test.js.map +1 -0
  310. package/dist/src/utils/gitIgnoreParser.d.ts +20 -0
  311. package/dist/src/utils/gitIgnoreParser.js +64 -0
  312. package/dist/src/utils/gitIgnoreParser.js.map +1 -0
  313. package/dist/src/utils/gitIgnoreParser.test.d.ts +6 -0
  314. package/dist/src/utils/gitIgnoreParser.test.js +145 -0
  315. package/dist/src/utils/gitIgnoreParser.test.js.map +1 -0
  316. package/dist/src/utils/gitUtils.d.ts +17 -0
  317. package/dist/src/utils/gitUtils.js +61 -0
  318. package/dist/src/utils/gitUtils.js.map +1 -0
  319. package/dist/src/utils/memoryDiscovery.d.ts +14 -0
  320. package/dist/src/utils/memoryDiscovery.js +219 -0
  321. package/dist/src/utils/memoryDiscovery.js.map +1 -0
  322. package/dist/src/utils/memoryDiscovery.test.d.ts +6 -0
  323. package/dist/src/utils/memoryDiscovery.test.js +432 -0
  324. package/dist/src/utils/memoryDiscovery.test.js.map +1 -0
  325. package/dist/src/utils/memoryImportProcessor.d.ts +35 -0
  326. package/dist/src/utils/memoryImportProcessor.js +141 -0
  327. package/dist/src/utils/memoryImportProcessor.js.map +1 -0
  328. package/dist/src/utils/memoryImportProcessor.test.d.ts +6 -0
  329. package/dist/src/utils/memoryImportProcessor.test.js +170 -0
  330. package/dist/src/utils/memoryImportProcessor.test.js.map +1 -0
  331. package/dist/src/utils/messageInspectors.d.ts +8 -0
  332. package/dist/src/utils/messageInspectors.js +16 -0
  333. package/dist/src/utils/messageInspectors.js.map +1 -0
  334. package/dist/src/utils/nextSpeakerChecker.d.ts +12 -0
  335. package/dist/src/utils/nextSpeakerChecker.js +111 -0
  336. package/dist/src/utils/nextSpeakerChecker.js.map +1 -0
  337. package/dist/src/utils/nextSpeakerChecker.test.d.ts +6 -0
  338. package/dist/src/utils/nextSpeakerChecker.test.js +152 -0
  339. package/dist/src/utils/nextSpeakerChecker.test.js.map +1 -0
  340. package/dist/src/utils/paths.d.ts +47 -0
  341. package/dist/src/utils/paths.js +136 -0
  342. package/dist/src/utils/paths.js.map +1 -0
  343. package/dist/src/utils/retry.d.ts +21 -0
  344. package/dist/src/utils/retry.js +220 -0
  345. package/dist/src/utils/retry.js.map +1 -0
  346. package/dist/src/utils/retry.test.d.ts +6 -0
  347. package/dist/src/utils/retry.test.js +322 -0
  348. package/dist/src/utils/retry.test.js.map +1 -0
  349. package/dist/src/utils/schemaValidator.d.ts +17 -0
  350. package/dist/src/utils/schemaValidator.js +50 -0
  351. package/dist/src/utils/schemaValidator.js.map +1 -0
  352. package/dist/src/utils/session.d.ts +6 -0
  353. package/dist/src/utils/session.js +8 -0
  354. package/dist/src/utils/session.js.map +1 -0
  355. package/dist/src/utils/testUtils.d.ts +29 -0
  356. package/dist/src/utils/testUtils.js +70 -0
  357. package/dist/src/utils/testUtils.js.map +1 -0
  358. package/dist/src/utils/user_id.d.ts +17 -0
  359. package/dist/src/utils/user_id.js +70 -0
  360. package/dist/src/utils/user_id.js.map +1 -0
  361. package/dist/src/utils/user_id.test.d.ts +6 -0
  362. package/dist/src/utils/user_id.test.js +42 -0
  363. package/dist/src/utils/user_id.test.js.map +1 -0
  364. package/dist/tsconfig.tsbuildinfo +1 -0
  365. package/package.json +60 -0
@@ -0,0 +1,215 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import fs from 'fs';
7
+ import path from 'path';
8
+ import { glob } from 'glob';
9
+ import { SchemaValidator } from '../utils/schemaValidator.js';
10
+ import { BaseTool } from './tools.js';
11
+ import { shortenPath, makeRelative } from '../utils/paths.js';
12
+ /**
13
+ * Sorts file entries based on recency and then alphabetically.
14
+ * Recent files (modified within recencyThresholdMs) are listed first, newest to oldest.
15
+ * Older files are listed after recent ones, sorted alphabetically by path.
16
+ */
17
+ export function sortFileEntries(entries, nowTimestamp, recencyThresholdMs) {
18
+ const sortedEntries = [...entries];
19
+ sortedEntries.sort((a, b) => {
20
+ const mtimeA = a.mtimeMs ?? 0;
21
+ const mtimeB = b.mtimeMs ?? 0;
22
+ const aIsRecent = nowTimestamp - mtimeA < recencyThresholdMs;
23
+ const bIsRecent = nowTimestamp - mtimeB < recencyThresholdMs;
24
+ if (aIsRecent && bIsRecent) {
25
+ return mtimeB - mtimeA;
26
+ }
27
+ else if (aIsRecent) {
28
+ return -1;
29
+ }
30
+ else if (bIsRecent) {
31
+ return 1;
32
+ }
33
+ else {
34
+ return a.fullpath().localeCompare(b.fullpath());
35
+ }
36
+ });
37
+ return sortedEntries;
38
+ }
39
+ /**
40
+ * Implementation of the Glob tool logic
41
+ */
42
+ export class GlobTool extends BaseTool {
43
+ rootDirectory;
44
+ config;
45
+ static Name = 'glob';
46
+ /**
47
+ * Creates a new instance of the GlobLogic
48
+ * @param rootDirectory Root directory to ground this tool in.
49
+ */
50
+ constructor(rootDirectory, config) {
51
+ super(GlobTool.Name, 'FindFiles', 'Efficiently finds files matching specific glob patterns (e.g., `src/**/*.ts`, `**/*.md`), returning absolute paths sorted by modification time (newest first). Ideal for quickly locating files based on their name or path structure, especially in large codebases.', {
52
+ properties: {
53
+ pattern: {
54
+ description: "The glob pattern to match against (e.g., '**/*.py', 'docs/*.md').",
55
+ type: 'string',
56
+ },
57
+ path: {
58
+ description: 'Optional: The absolute path to the directory to search within. If omitted, searches the root directory.',
59
+ type: 'string',
60
+ },
61
+ case_sensitive: {
62
+ description: 'Optional: Whether the search should be case-sensitive. Defaults to false.',
63
+ type: 'boolean',
64
+ },
65
+ respect_git_ignore: {
66
+ description: 'Optional: Whether to respect .gitignore patterns when finding files. Only available in git repositories. Defaults to true.',
67
+ type: 'boolean',
68
+ },
69
+ },
70
+ required: ['pattern'],
71
+ type: 'object',
72
+ });
73
+ this.rootDirectory = rootDirectory;
74
+ this.config = config;
75
+ this.rootDirectory = path.resolve(rootDirectory);
76
+ }
77
+ /**
78
+ * Checks if a given path is within the root directory bounds.
79
+ * This security check prevents accessing files outside the designated root directory.
80
+ *
81
+ * @param pathToCheck The absolute path to validate
82
+ * @returns True if the path is within the root directory, false otherwise
83
+ */
84
+ isWithinRoot(pathToCheck) {
85
+ const absolutePathToCheck = path.resolve(pathToCheck);
86
+ const normalizedPath = path.normalize(absolutePathToCheck);
87
+ const normalizedRoot = path.normalize(this.rootDirectory);
88
+ const rootWithSep = normalizedRoot.endsWith(path.sep)
89
+ ? normalizedRoot
90
+ : normalizedRoot + path.sep;
91
+ return (normalizedPath === normalizedRoot ||
92
+ normalizedPath.startsWith(rootWithSep));
93
+ }
94
+ /**
95
+ * Validates the parameters for the tool.
96
+ */
97
+ validateToolParams(params) {
98
+ if (this.schema.parameters &&
99
+ !SchemaValidator.validate(this.schema.parameters, params)) {
100
+ return "Parameters failed schema validation. Ensure 'pattern' is a string, 'path' (if provided) is a string, and 'case_sensitive' (if provided) is a boolean.";
101
+ }
102
+ const searchDirAbsolute = path.resolve(this.rootDirectory, params.path || '.');
103
+ if (!this.isWithinRoot(searchDirAbsolute)) {
104
+ return `Search path ("${searchDirAbsolute}") resolves outside the tool's root directory ("${this.rootDirectory}").`;
105
+ }
106
+ const targetDir = searchDirAbsolute || this.rootDirectory;
107
+ try {
108
+ if (!fs.existsSync(targetDir)) {
109
+ return `Search path does not exist ${targetDir}`;
110
+ }
111
+ if (!fs.statSync(targetDir).isDirectory()) {
112
+ return `Search path is not a directory: ${targetDir}`;
113
+ }
114
+ }
115
+ catch (e) {
116
+ return `Error accessing search path: ${e}`;
117
+ }
118
+ if (!params.pattern ||
119
+ typeof params.pattern !== 'string' ||
120
+ params.pattern.trim() === '') {
121
+ return "The 'pattern' parameter cannot be empty.";
122
+ }
123
+ return null;
124
+ }
125
+ /**
126
+ * Gets a description of the glob operation.
127
+ */
128
+ getDescription(params) {
129
+ let description = `'${params.pattern}'`;
130
+ if (params.path) {
131
+ const searchDir = path.resolve(this.rootDirectory, params.path || '.');
132
+ const relativePath = makeRelative(searchDir, this.rootDirectory);
133
+ description += ` within ${shortenPath(relativePath)}`;
134
+ }
135
+ return description;
136
+ }
137
+ /**
138
+ * Executes the glob search with the given parameters
139
+ */
140
+ async execute(params, signal) {
141
+ const validationError = this.validateToolParams(params);
142
+ if (validationError) {
143
+ return {
144
+ llmContent: `Error: Invalid parameters provided. Reason: ${validationError}`,
145
+ returnDisplay: validationError,
146
+ };
147
+ }
148
+ try {
149
+ const searchDirAbsolute = path.resolve(this.rootDirectory, params.path || '.');
150
+ // Get centralized file discovery service
151
+ const respectGitIgnore = params.respect_git_ignore ??
152
+ this.config.getFileFilteringRespectGitIgnore();
153
+ const fileDiscovery = this.config.getFileService();
154
+ const entries = (await glob(params.pattern, {
155
+ cwd: searchDirAbsolute,
156
+ withFileTypes: true,
157
+ nodir: true,
158
+ stat: true,
159
+ nocase: !params.case_sensitive,
160
+ dot: true,
161
+ ignore: ['**/node_modules/**', '**/.git/**'],
162
+ follow: false,
163
+ signal,
164
+ }));
165
+ // Apply git-aware filtering if enabled and in git repository
166
+ let filteredEntries = entries;
167
+ let gitIgnoredCount = 0;
168
+ if (respectGitIgnore) {
169
+ const relativePaths = entries.map((p) => path.relative(this.rootDirectory, p.fullpath()));
170
+ const filteredRelativePaths = fileDiscovery.filterFiles(relativePaths, {
171
+ respectGitIgnore,
172
+ });
173
+ const filteredAbsolutePaths = new Set(filteredRelativePaths.map((p) => path.resolve(this.rootDirectory, p)));
174
+ filteredEntries = entries.filter((entry) => filteredAbsolutePaths.has(entry.fullpath()));
175
+ gitIgnoredCount = entries.length - filteredEntries.length;
176
+ }
177
+ if (!filteredEntries || filteredEntries.length === 0) {
178
+ let message = `No files found matching pattern "${params.pattern}" within ${searchDirAbsolute}.`;
179
+ if (gitIgnoredCount > 0) {
180
+ message += ` (${gitIgnoredCount} files were git-ignored)`;
181
+ }
182
+ return {
183
+ llmContent: message,
184
+ returnDisplay: `No files found`,
185
+ };
186
+ }
187
+ // Set filtering such that we first show the most recent files
188
+ const oneDayInMs = 24 * 60 * 60 * 1000;
189
+ const nowTimestamp = new Date().getTime();
190
+ // Sort the filtered entries using the new helper function
191
+ const sortedEntries = sortFileEntries(filteredEntries, nowTimestamp, oneDayInMs);
192
+ const sortedAbsolutePaths = sortedEntries.map((entry) => entry.fullpath());
193
+ const fileListDescription = sortedAbsolutePaths.join('\n');
194
+ const fileCount = sortedAbsolutePaths.length;
195
+ let resultMessage = `Found ${fileCount} file(s) matching "${params.pattern}" within ${searchDirAbsolute}`;
196
+ if (gitIgnoredCount > 0) {
197
+ resultMessage += ` (${gitIgnoredCount} additional files were git-ignored)`;
198
+ }
199
+ resultMessage += `, sorted by modification time (newest first):\n${fileListDescription}`;
200
+ return {
201
+ llmContent: resultMessage,
202
+ returnDisplay: `Found ${fileCount} matching file(s)`,
203
+ };
204
+ }
205
+ catch (error) {
206
+ const errorMessage = error instanceof Error ? error.message : String(error);
207
+ console.error(`GlobLogic execute Error: ${errorMessage}`, error);
208
+ return {
209
+ llmContent: `Error during glob search operation: ${errorMessage}`,
210
+ returnDisplay: `Error: An unexpected error occurred.`,
211
+ };
212
+ }
213
+ }
214
+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2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export {};
@@ -0,0 +1,293 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { GlobTool, sortFileEntries } from './glob.js';
7
+ import { partListUnionToString } from '../core/geminiRequest.js';
8
+ import path from 'path';
9
+ import fs from 'fs/promises';
10
+ import os from 'os';
11
+ import { describe, it, expect, beforeEach, afterEach } from 'vitest'; // Removed vi
12
+ import { FileDiscoveryService } from '../services/fileDiscoveryService.js';
13
+ describe('GlobTool', () => {
14
+ let tempRootDir; // This will be the rootDirectory for the GlobTool instance
15
+ let globTool;
16
+ const abortSignal = new AbortController().signal;
17
+ // Mock config for testing
18
+ const mockConfig = {
19
+ getFileService: () => new FileDiscoveryService(tempRootDir),
20
+ getFileFilteringRespectGitIgnore: () => true,
21
+ };
22
+ beforeEach(async () => {
23
+ // Create a unique root directory for each test run
24
+ tempRootDir = await fs.mkdtemp(path.join(os.tmpdir(), 'glob-tool-root-'));
25
+ globTool = new GlobTool(tempRootDir, mockConfig);
26
+ // Create some test files and directories within this root
27
+ // Top-level files
28
+ await fs.writeFile(path.join(tempRootDir, 'fileA.txt'), 'contentA');
29
+ await fs.writeFile(path.join(tempRootDir, 'FileB.TXT'), 'contentB'); // Different case for testing
30
+ // Subdirectory and files within it
31
+ await fs.mkdir(path.join(tempRootDir, 'sub'));
32
+ await fs.writeFile(path.join(tempRootDir, 'sub', 'fileC.md'), 'contentC');
33
+ await fs.writeFile(path.join(tempRootDir, 'sub', 'FileD.MD'), 'contentD'); // Different case
34
+ // Deeper subdirectory
35
+ await fs.mkdir(path.join(tempRootDir, 'sub', 'deep'));
36
+ await fs.writeFile(path.join(tempRootDir, 'sub', 'deep', 'fileE.log'), 'contentE');
37
+ // Files for mtime sorting test
38
+ await fs.writeFile(path.join(tempRootDir, 'older.sortme'), 'older_content');
39
+ // Ensure a noticeable difference in modification time
40
+ await new Promise((resolve) => setTimeout(resolve, 50));
41
+ await fs.writeFile(path.join(tempRootDir, 'newer.sortme'), 'newer_content');
42
+ });
43
+ afterEach(async () => {
44
+ // Clean up the temporary root directory
45
+ await fs.rm(tempRootDir, { recursive: true, force: true });
46
+ });
47
+ describe('execute', () => {
48
+ it('should find files matching a simple pattern in the root', async () => {
49
+ const params = { pattern: '*.txt' };
50
+ const result = await globTool.execute(params, abortSignal);
51
+ expect(result.llmContent).toContain('Found 2 file(s)');
52
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'fileA.txt'));
53
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'FileB.TXT'));
54
+ expect(result.returnDisplay).toBe('Found 2 matching file(s)');
55
+ });
56
+ it('should find files case-sensitively when case_sensitive is true', async () => {
57
+ const params = { pattern: '*.txt', case_sensitive: true };
58
+ const result = await globTool.execute(params, abortSignal);
59
+ expect(result.llmContent).toContain('Found 1 file(s)');
60
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'fileA.txt'));
61
+ expect(result.llmContent).not.toContain(path.join(tempRootDir, 'FileB.TXT'));
62
+ });
63
+ it('should find files case-insensitively by default (pattern: *.TXT)', async () => {
64
+ const params = { pattern: '*.TXT' };
65
+ const result = await globTool.execute(params, abortSignal);
66
+ expect(result.llmContent).toContain('Found 2 file(s)');
67
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'fileA.txt'));
68
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'FileB.TXT'));
69
+ });
70
+ it('should find files case-insensitively when case_sensitive is false (pattern: *.TXT)', async () => {
71
+ const params = {
72
+ pattern: '*.TXT',
73
+ case_sensitive: false,
74
+ };
75
+ const result = await globTool.execute(params, abortSignal);
76
+ expect(result.llmContent).toContain('Found 2 file(s)');
77
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'fileA.txt'));
78
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'FileB.TXT'));
79
+ });
80
+ it('should find files using a pattern that includes a subdirectory', async () => {
81
+ const params = { pattern: 'sub/*.md' };
82
+ const result = await globTool.execute(params, abortSignal);
83
+ expect(result.llmContent).toContain('Found 2 file(s)');
84
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'fileC.md'));
85
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'FileD.MD'));
86
+ });
87
+ it('should find files in a specified relative path (relative to rootDir)', async () => {
88
+ const params = { pattern: '*.md', path: 'sub' };
89
+ const result = await globTool.execute(params, abortSignal);
90
+ expect(result.llmContent).toContain('Found 2 file(s)');
91
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'fileC.md'));
92
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'FileD.MD'));
93
+ });
94
+ it('should find files using a deep globstar pattern (e.g., **/*.log)', async () => {
95
+ const params = { pattern: '**/*.log' };
96
+ const result = await globTool.execute(params, abortSignal);
97
+ expect(result.llmContent).toContain('Found 1 file(s)');
98
+ expect(result.llmContent).toContain(path.join(tempRootDir, 'sub', 'deep', 'fileE.log'));
99
+ });
100
+ it('should return "No files found" message when pattern matches nothing', async () => {
101
+ const params = { pattern: '*.nonexistent' };
102
+ const result = await globTool.execute(params, abortSignal);
103
+ expect(result.llmContent).toContain('No files found matching pattern "*.nonexistent"');
104
+ expect(result.returnDisplay).toBe('No files found');
105
+ });
106
+ it('should correctly sort files by modification time (newest first)', async () => {
107
+ const params = { pattern: '*.sortme' };
108
+ const result = await globTool.execute(params, abortSignal);
109
+ const llmContent = partListUnionToString(result.llmContent);
110
+ expect(llmContent).toContain('Found 2 file(s)');
111
+ // Ensure llmContent is a string for TypeScript type checking
112
+ expect(typeof llmContent).toBe('string');
113
+ const filesListed = llmContent
114
+ .substring(llmContent.indexOf(':') + 1)
115
+ .trim()
116
+ .split('\n');
117
+ expect(filesListed[0]).toContain(path.join(tempRootDir, 'newer.sortme'));
118
+ expect(filesListed[1]).toContain(path.join(tempRootDir, 'older.sortme'));
119
+ });
120
+ });
121
+ describe('validateToolParams', () => {
122
+ it('should return null for valid parameters (pattern only)', () => {
123
+ const params = { pattern: '*.js' };
124
+ expect(globTool.validateToolParams(params)).toBeNull();
125
+ });
126
+ it('should return null for valid parameters (pattern and path)', () => {
127
+ const params = { pattern: '*.js', path: 'sub' };
128
+ expect(globTool.validateToolParams(params)).toBeNull();
129
+ });
130
+ it('should return null for valid parameters (pattern, path, and case_sensitive)', () => {
131
+ const params = {
132
+ pattern: '*.js',
133
+ path: 'sub',
134
+ case_sensitive: true,
135
+ };
136
+ expect(globTool.validateToolParams(params)).toBeNull();
137
+ });
138
+ it('should return error if pattern is missing (schema validation)', () => {
139
+ // Need to correctly define this as an object without pattern
140
+ const params = { path: '.' };
141
+ // @ts-expect-error - We're intentionally creating invalid params for testing
142
+ expect(globTool.validateToolParams(params)).toContain('Parameters failed schema validation');
143
+ });
144
+ it('should return error if pattern is an empty string', () => {
145
+ const params = { pattern: '' };
146
+ expect(globTool.validateToolParams(params)).toContain("The 'pattern' parameter cannot be empty.");
147
+ });
148
+ it('should return error if pattern is only whitespace', () => {
149
+ const params = { pattern: ' ' };
150
+ expect(globTool.validateToolParams(params)).toContain("The 'pattern' parameter cannot be empty.");
151
+ });
152
+ it('should return error if path is provided but is not a string (schema validation)', () => {
153
+ const params = {
154
+ pattern: '*.ts',
155
+ path: 123,
156
+ };
157
+ // @ts-expect-error - We're intentionally creating invalid params for testing
158
+ expect(globTool.validateToolParams(params)).toContain('Parameters failed schema validation');
159
+ });
160
+ it('should return error if case_sensitive is provided but is not a boolean (schema validation)', () => {
161
+ const params = {
162
+ pattern: '*.ts',
163
+ case_sensitive: 'true',
164
+ };
165
+ // @ts-expect-error - We're intentionally creating invalid params for testing
166
+ expect(globTool.validateToolParams(params)).toContain('Parameters failed schema validation');
167
+ });
168
+ it("should return error if search path resolves outside the tool's root directory", () => {
169
+ // Create a globTool instance specifically for this test, with a deeper root
170
+ const deeperRootDir = path.join(tempRootDir, 'sub');
171
+ const specificGlobTool = new GlobTool(deeperRootDir, mockConfig);
172
+ // const params: GlobToolParams = { pattern: '*.txt', path: '..' }; // This line is unused and will be removed.
173
+ // This should be fine as tempRootDir is still within the original tempRootDir (the parent of deeperRootDir)
174
+ // Let's try to go further up.
175
+ const paramsOutside = {
176
+ pattern: '*.txt',
177
+ path: '../../../../../../../../../../tmp',
178
+ }; // Definitely outside
179
+ expect(specificGlobTool.validateToolParams(paramsOutside)).toContain("resolves outside the tool's root directory");
180
+ });
181
+ it('should return error if specified search path does not exist', async () => {
182
+ const params = {
183
+ pattern: '*.txt',
184
+ path: 'nonexistent_subdir',
185
+ };
186
+ expect(globTool.validateToolParams(params)).toContain('Search path does not exist');
187
+ });
188
+ it('should return error if specified search path is a file, not a directory', async () => {
189
+ const params = { pattern: '*.txt', path: 'fileA.txt' };
190
+ expect(globTool.validateToolParams(params)).toContain('Search path is not a directory');
191
+ });
192
+ });
193
+ });
194
+ describe('sortFileEntries', () => {
195
+ const nowTimestamp = new Date('2024-01-15T12:00:00.000Z').getTime();
196
+ const oneDayInMs = 24 * 60 * 60 * 1000;
197
+ const createFileEntry = (fullpath, mtimeDate) => ({
198
+ fullpath: () => fullpath,
199
+ mtimeMs: mtimeDate.getTime(),
200
+ });
201
+ it('should sort a mix of recent and older files correctly', () => {
202
+ const recentTime1 = new Date(nowTimestamp - 1 * 60 * 60 * 1000); // 1 hour ago
203
+ const recentTime2 = new Date(nowTimestamp - 2 * 60 * 60 * 1000); // 2 hours ago
204
+ const olderTime1 = new Date(nowTimestamp - (oneDayInMs + 1 * 60 * 60 * 1000)); // 25 hours ago
205
+ const olderTime2 = new Date(nowTimestamp - (oneDayInMs + 2 * 60 * 60 * 1000)); // 26 hours ago
206
+ const entries = [
207
+ createFileEntry('older_zebra.txt', olderTime2),
208
+ createFileEntry('recent_alpha.txt', recentTime1),
209
+ createFileEntry('older_apple.txt', olderTime1),
210
+ createFileEntry('recent_beta.txt', recentTime2),
211
+ createFileEntry('older_banana.txt', olderTime1), // Same mtime as apple
212
+ ];
213
+ const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
214
+ const sortedPaths = sorted.map((e) => e.fullpath());
215
+ expect(sortedPaths).toEqual([
216
+ 'recent_alpha.txt', // Recent, newest
217
+ 'recent_beta.txt', // Recent, older
218
+ 'older_apple.txt', // Older, alphabetical
219
+ 'older_banana.txt', // Older, alphabetical
220
+ 'older_zebra.txt', // Older, alphabetical
221
+ ]);
222
+ });
223
+ it('should sort only recent files by mtime descending', () => {
224
+ const recentTime1 = new Date(nowTimestamp - 1000); // Newest
225
+ const recentTime2 = new Date(nowTimestamp - 2000);
226
+ const recentTime3 = new Date(nowTimestamp - 3000); // Oldest recent
227
+ const entries = [
228
+ createFileEntry('c.txt', recentTime2),
229
+ createFileEntry('a.txt', recentTime3),
230
+ createFileEntry('b.txt', recentTime1),
231
+ ];
232
+ const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
233
+ expect(sorted.map((e) => e.fullpath())).toEqual([
234
+ 'b.txt',
235
+ 'c.txt',
236
+ 'a.txt',
237
+ ]);
238
+ });
239
+ it('should sort only older files alphabetically by path', () => {
240
+ const olderTime = new Date(nowTimestamp - 2 * oneDayInMs); // All equally old
241
+ const entries = [
242
+ createFileEntry('zebra.txt', olderTime),
243
+ createFileEntry('apple.txt', olderTime),
244
+ createFileEntry('banana.txt', olderTime),
245
+ ];
246
+ const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
247
+ expect(sorted.map((e) => e.fullpath())).toEqual([
248
+ 'apple.txt',
249
+ 'banana.txt',
250
+ 'zebra.txt',
251
+ ]);
252
+ });
253
+ it('should handle an empty array', () => {
254
+ const entries = [];
255
+ const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
256
+ expect(sorted).toEqual([]);
257
+ });
258
+ it('should correctly sort files when mtimes are identical for older files', () => {
259
+ const olderTime = new Date(nowTimestamp - 2 * oneDayInMs);
260
+ const entries = [
261
+ createFileEntry('b.txt', olderTime),
262
+ createFileEntry('a.txt', olderTime),
263
+ ];
264
+ const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
265
+ expect(sorted.map((e) => e.fullpath())).toEqual(['a.txt', 'b.txt']);
266
+ });
267
+ it('should correctly sort files when mtimes are identical for recent files (maintaining mtime sort)', () => {
268
+ const recentTime = new Date(nowTimestamp - 1000);
269
+ const entries = [
270
+ createFileEntry('b.txt', recentTime),
271
+ createFileEntry('a.txt', recentTime),
272
+ ];
273
+ const sorted = sortFileEntries(entries, nowTimestamp, oneDayInMs);
274
+ expect(sorted.map((e) => e.fullpath())).toContain('a.txt');
275
+ expect(sorted.map((e) => e.fullpath())).toContain('b.txt');
276
+ expect(sorted.length).toBe(2);
277
+ });
278
+ it('should use recencyThresholdMs parameter correctly', () => {
279
+ const justOverThreshold = new Date(nowTimestamp - (1000 + 1)); // Barely older
280
+ const justUnderThreshold = new Date(nowTimestamp - (1000 - 1)); // Barely recent
281
+ const customThresholdMs = 1000; // 1 second
282
+ const entries = [
283
+ createFileEntry('older_file.txt', justOverThreshold),
284
+ createFileEntry('recent_file.txt', justUnderThreshold),
285
+ ];
286
+ const sorted = sortFileEntries(entries, nowTimestamp, customThresholdMs);
287
+ expect(sorted.map((e) => e.fullpath())).toEqual([
288
+ 'recent_file.txt',
289
+ 'older_file.txt',
290
+ ]);
291
+ });
292
+ });
293
+ //# sourceMappingURL=glob.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.test.js","sourceRoot":"","sources":["../../../src/tools/glob.test.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAA4B,eAAe,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,EAAE,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AAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,iBAAiB,GAAG,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe;QAC9E,MAAM,kBAAkB,GAAG,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB;QAChF,MAAM,iBAAiB,GAAG,IAAI,CAAC,CAAC,WAAW;QAE3C,MAAM,OAAO,GAAe;YAC1B,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;YACpD,eAAe,CAAC,iBAAiB,EAAE,kBAAkB,CAAC;SACvD,CAAC;QACF,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,CAAC,CAAC;QACzE,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YAC9C,iBAAiB;YACjB,gBAAgB;SACjB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { BaseTool, ToolResult } from './tools.js';
7
+ /**
8
+ * Parameters for the GrepTool
9
+ */
10
+ export interface GrepToolParams {
11
+ /**
12
+ * The regular expression pattern to search for in file contents
13
+ */
14
+ pattern: string;
15
+ /**
16
+ * The directory to search in (optional, defaults to current directory relative to root)
17
+ */
18
+ path?: string;
19
+ /**
20
+ * File pattern to include in the search (e.g. "*.js", "*.{ts,tsx}")
21
+ */
22
+ include?: string;
23
+ }
24
+ /**
25
+ * Implementation of the Grep tool logic (moved from CLI)
26
+ */
27
+ export declare class GrepTool extends BaseTool<GrepToolParams, ToolResult> {
28
+ private rootDirectory;
29
+ static readonly Name = "search_file_content";
30
+ /**
31
+ * Creates a new instance of the GrepLogic
32
+ * @param rootDirectory Root directory to ground this tool in. All operations will be restricted to this directory.
33
+ */
34
+ constructor(rootDirectory: string);
35
+ /**
36
+ * Checks if a path is within the root directory and resolves it.
37
+ * @param relativePath Path relative to the root directory (or undefined for root).
38
+ * @returns The absolute path if valid and exists.
39
+ * @throws {Error} If path is outside root, doesn't exist, or isn't a directory.
40
+ */
41
+ private resolveAndValidatePath;
42
+ /**
43
+ * Validates the parameters for the tool
44
+ * @param params Parameters to validate
45
+ * @returns An error message string if invalid, null otherwise
46
+ */
47
+ validateToolParams(params: GrepToolParams): string | null;
48
+ /**
49
+ * Executes the grep search with the given parameters
50
+ * @param params Parameters for the grep search
51
+ * @returns Result of the grep search
52
+ */
53
+ execute(params: GrepToolParams, signal: AbortSignal): Promise<ToolResult>;
54
+ /**
55
+ * Checks if a command is available in the system's PATH.
56
+ * @param {string} command The command name (e.g., 'git', 'grep').
57
+ * @returns {Promise<boolean>} True if the command is available, false otherwise.
58
+ */
59
+ private isCommandAvailable;
60
+ /**
61
+ * Parses the standard output of grep-like commands (git grep, system grep).
62
+ * Expects format: filePath:lineNumber:lineContent
63
+ * Handles colons within file paths and line content correctly.
64
+ * @param {string} output The raw stdout string.
65
+ * @param {string} basePath The absolute directory the search was run from, for relative paths.
66
+ * @returns {GrepMatch[]} Array of match objects.
67
+ */
68
+ private parseGrepOutput;
69
+ /**
70
+ * Gets a description of the grep operation
71
+ * @param params Parameters for the grep operation
72
+ * @returns A string describing the grep
73
+ */
74
+ getDescription(params: GrepToolParams): string;
75
+ /**
76
+ * Performs the actual search using the prioritized strategies.
77
+ * @param options Search options including pattern, absolute path, and include glob.
78
+ * @returns A promise resolving to an array of match objects.
79
+ */
80
+ private performGrepSearch;
81
+ }