@gguf/coder 0.3.1 → 0.3.3

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 (413) hide show
  1. package/package.json +5 -2
  2. package/.editorconfig +0 -16
  3. package/.env.example +0 -63
  4. package/.gitattributes +0 -1
  5. package/.semgrepignore +0 -19
  6. package/coder-dummy-file.ts +0 -52
  7. package/coder.config.example.json +0 -59
  8. package/coder.config.json +0 -13
  9. package/color_picker.html +0 -36
  10. package/scripts/extract-changelog.js +0 -73
  11. package/scripts/fetch-models.js +0 -143
  12. package/scripts/test.sh +0 -40
  13. package/scripts/update-homebrew-formula.sh +0 -125
  14. package/scripts/update-nix-version.sh +0 -157
  15. package/source/ai-sdk-client/AISDKClient.spec.ts +0 -117
  16. package/source/ai-sdk-client/AISDKClient.ts +0 -155
  17. package/source/ai-sdk-client/chat/chat-handler.spec.ts +0 -121
  18. package/source/ai-sdk-client/chat/chat-handler.ts +0 -276
  19. package/source/ai-sdk-client/chat/streaming-handler.spec.ts +0 -173
  20. package/source/ai-sdk-client/chat/streaming-handler.ts +0 -110
  21. package/source/ai-sdk-client/chat/tool-processor.spec.ts +0 -92
  22. package/source/ai-sdk-client/chat/tool-processor.ts +0 -70
  23. package/source/ai-sdk-client/converters/message-converter.spec.ts +0 -220
  24. package/source/ai-sdk-client/converters/message-converter.ts +0 -113
  25. package/source/ai-sdk-client/converters/tool-converter.spec.ts +0 -90
  26. package/source/ai-sdk-client/converters/tool-converter.ts +0 -46
  27. package/source/ai-sdk-client/error-handling/error-extractor.spec.ts +0 -55
  28. package/source/ai-sdk-client/error-handling/error-extractor.ts +0 -15
  29. package/source/ai-sdk-client/error-handling/error-parser.spec.ts +0 -169
  30. package/source/ai-sdk-client/error-handling/error-parser.ts +0 -161
  31. package/source/ai-sdk-client/index.ts +0 -7
  32. package/source/ai-sdk-client/providers/provider-factory.spec.ts +0 -71
  33. package/source/ai-sdk-client/providers/provider-factory.ts +0 -41
  34. package/source/ai-sdk-client/types.ts +0 -9
  35. package/source/ai-sdk-client-empty-message.spec.ts +0 -141
  36. package/source/ai-sdk-client-error-handling.spec.ts +0 -186
  37. package/source/ai-sdk-client-maxretries.spec.ts +0 -114
  38. package/source/ai-sdk-client-preparestep.spec.ts +0 -279
  39. package/source/app/App.spec.tsx +0 -32
  40. package/source/app/App.tsx +0 -480
  41. package/source/app/components/AppContainer.spec.tsx +0 -96
  42. package/source/app/components/AppContainer.tsx +0 -56
  43. package/source/app/components/ChatInterface.spec.tsx +0 -163
  44. package/source/app/components/ChatInterface.tsx +0 -144
  45. package/source/app/components/ModalSelectors.spec.tsx +0 -141
  46. package/source/app/components/ModalSelectors.tsx +0 -135
  47. package/source/app/helpers.spec.ts +0 -97
  48. package/source/app/helpers.ts +0 -63
  49. package/source/app/index.ts +0 -4
  50. package/source/app/types.ts +0 -39
  51. package/source/app/utils/appUtils.ts +0 -294
  52. package/source/app/utils/conversationState.ts +0 -310
  53. package/source/app.spec.tsx +0 -244
  54. package/source/cli.spec.ts +0 -73
  55. package/source/cli.tsx +0 -51
  56. package/source/client-factory.spec.ts +0 -48
  57. package/source/client-factory.ts +0 -178
  58. package/source/command-parser.spec.ts +0 -127
  59. package/source/command-parser.ts +0 -36
  60. package/source/commands/checkpoint.spec.tsx +0 -277
  61. package/source/commands/checkpoint.tsx +0 -366
  62. package/source/commands/clear.tsx +0 -22
  63. package/source/commands/custom-commands.tsx +0 -121
  64. package/source/commands/exit.ts +0 -21
  65. package/source/commands/export.spec.tsx +0 -131
  66. package/source/commands/export.tsx +0 -79
  67. package/source/commands/help.tsx +0 -120
  68. package/source/commands/index.ts +0 -17
  69. package/source/commands/init.tsx +0 -339
  70. package/source/commands/lsp-command.spec.tsx +0 -281
  71. package/source/commands/lsp.tsx +0 -120
  72. package/source/commands/mcp-command.spec.tsx +0 -313
  73. package/source/commands/mcp.tsx +0 -162
  74. package/source/commands/model-database.spec.tsx +0 -758
  75. package/source/commands/model-database.tsx +0 -418
  76. package/source/commands/model.ts +0 -12
  77. package/source/commands/provider.ts +0 -12
  78. package/source/commands/setup-config.tsx +0 -16
  79. package/source/commands/simple-commands.spec.tsx +0 -175
  80. package/source/commands/status.ts +0 -12
  81. package/source/commands/theme.ts +0 -12
  82. package/source/commands/update.spec.tsx +0 -261
  83. package/source/commands/update.tsx +0 -201
  84. package/source/commands/usage.spec.tsx +0 -495
  85. package/source/commands/usage.tsx +0 -100
  86. package/source/commands.spec.ts +0 -436
  87. package/source/commands.ts +0 -83
  88. package/source/components/assistant-message.spec.tsx +0 -796
  89. package/source/components/assistant-message.tsx +0 -34
  90. package/source/components/bash-execution-indicator.tsx +0 -21
  91. package/source/components/cancelling-indicator.tsx +0 -16
  92. package/source/components/chat-queue.spec.tsx +0 -83
  93. package/source/components/chat-queue.tsx +0 -36
  94. package/source/components/checkpoint-display.spec.tsx +0 -219
  95. package/source/components/checkpoint-display.tsx +0 -126
  96. package/source/components/checkpoint-selector.spec.tsx +0 -173
  97. package/source/components/checkpoint-selector.tsx +0 -173
  98. package/source/components/development-mode-indicator.spec.tsx +0 -268
  99. package/source/components/development-mode-indicator.tsx +0 -38
  100. package/source/components/message-box.spec.tsx +0 -427
  101. package/source/components/message-box.tsx +0 -87
  102. package/source/components/model-selector.tsx +0 -132
  103. package/source/components/provider-selector.tsx +0 -75
  104. package/source/components/random-spinner.tsx +0 -19
  105. package/source/components/security-disclaimer.tsx +0 -73
  106. package/source/components/status-connection-display.spec.tsx +0 -133
  107. package/source/components/status.tsx +0 -267
  108. package/source/components/theme-selector.tsx +0 -126
  109. package/source/components/tool-confirmation.tsx +0 -190
  110. package/source/components/tool-execution-indicator.tsx +0 -33
  111. package/source/components/tool-message.tsx +0 -85
  112. package/source/components/ui/titled-box.spec.tsx +0 -207
  113. package/source/components/ui/titled-box.tsx +0 -57
  114. package/source/components/usage/progress-bar.spec.tsx +0 -398
  115. package/source/components/usage/progress-bar.tsx +0 -30
  116. package/source/components/usage/usage-display.spec.tsx +0 -780
  117. package/source/components/usage/usage-display.tsx +0 -291
  118. package/source/components/user-input.spec.tsx +0 -327
  119. package/source/components/user-input.tsx +0 -533
  120. package/source/components/user-message.spec.tsx +0 -230
  121. package/source/components/user-message.tsx +0 -84
  122. package/source/components/welcome-message.tsx +0 -76
  123. package/source/config/env-substitution.ts +0 -65
  124. package/source/config/index.spec.ts +0 -171
  125. package/source/config/index.ts +0 -154
  126. package/source/config/paths.spec.ts +0 -241
  127. package/source/config/paths.ts +0 -55
  128. package/source/config/preferences.ts +0 -51
  129. package/source/config/themes.ts +0 -315
  130. package/source/constants.ts +0 -130
  131. package/source/context/mode-context.spec.ts +0 -79
  132. package/source/context/mode-context.ts +0 -24
  133. package/source/custom-commands/executor.spec.ts +0 -142
  134. package/source/custom-commands/executor.ts +0 -64
  135. package/source/custom-commands/loader.spec.ts +0 -314
  136. package/source/custom-commands/loader.ts +0 -153
  137. package/source/custom-commands/parser.ts +0 -196
  138. package/source/hooks/chat-handler/conversation/conversation-loop.spec.ts +0 -39
  139. package/source/hooks/chat-handler/conversation/conversation-loop.tsx +0 -511
  140. package/source/hooks/chat-handler/conversation/tool-executor.spec.ts +0 -50
  141. package/source/hooks/chat-handler/conversation/tool-executor.tsx +0 -109
  142. package/source/hooks/chat-handler/index.ts +0 -12
  143. package/source/hooks/chat-handler/state/streaming-state.spec.ts +0 -26
  144. package/source/hooks/chat-handler/state/streaming-state.ts +0 -19
  145. package/source/hooks/chat-handler/types.ts +0 -38
  146. package/source/hooks/chat-handler/useChatHandler.spec.tsx +0 -321
  147. package/source/hooks/chat-handler/useChatHandler.tsx +0 -194
  148. package/source/hooks/chat-handler/utils/context-checker.spec.ts +0 -60
  149. package/source/hooks/chat-handler/utils/context-checker.tsx +0 -73
  150. package/source/hooks/chat-handler/utils/message-helpers.spec.ts +0 -42
  151. package/source/hooks/chat-handler/utils/message-helpers.tsx +0 -36
  152. package/source/hooks/chat-handler/utils/tool-filters.spec.ts +0 -109
  153. package/source/hooks/chat-handler/utils/tool-filters.ts +0 -64
  154. package/source/hooks/useAppHandlers.tsx +0 -291
  155. package/source/hooks/useAppInitialization.tsx +0 -422
  156. package/source/hooks/useAppState.tsx +0 -311
  157. package/source/hooks/useDirectoryTrust.tsx +0 -98
  158. package/source/hooks/useInputState.ts +0 -414
  159. package/source/hooks/useModeHandlers.tsx +0 -302
  160. package/source/hooks/useNonInteractiveMode.ts +0 -140
  161. package/source/hooks/useTerminalWidth.tsx +0 -81
  162. package/source/hooks/useTheme.ts +0 -18
  163. package/source/hooks/useToolHandler.tsx +0 -349
  164. package/source/hooks/useUIState.ts +0 -61
  165. package/source/init/agents-template-generator.ts +0 -421
  166. package/source/init/existing-rules-extractor.ts +0 -319
  167. package/source/init/file-scanner.spec.ts +0 -227
  168. package/source/init/file-scanner.ts +0 -238
  169. package/source/init/framework-detector.ts +0 -382
  170. package/source/init/language-detector.ts +0 -269
  171. package/source/init/project-analyzer.spec.ts +0 -231
  172. package/source/init/project-analyzer.ts +0 -458
  173. package/source/lsp/index.ts +0 -31
  174. package/source/lsp/lsp-client.spec.ts +0 -508
  175. package/source/lsp/lsp-client.ts +0 -487
  176. package/source/lsp/lsp-manager.spec.ts +0 -477
  177. package/source/lsp/lsp-manager.ts +0 -419
  178. package/source/lsp/protocol.spec.ts +0 -502
  179. package/source/lsp/protocol.ts +0 -360
  180. package/source/lsp/server-discovery.spec.ts +0 -654
  181. package/source/lsp/server-discovery.ts +0 -515
  182. package/source/markdown-parser/html-entities.spec.ts +0 -88
  183. package/source/markdown-parser/html-entities.ts +0 -45
  184. package/source/markdown-parser/index.spec.ts +0 -281
  185. package/source/markdown-parser/index.ts +0 -126
  186. package/source/markdown-parser/table-parser.spec.ts +0 -133
  187. package/source/markdown-parser/table-parser.ts +0 -114
  188. package/source/markdown-parser/utils.spec.ts +0 -70
  189. package/source/markdown-parser/utils.ts +0 -13
  190. package/source/mcp/mcp-client.spec.ts +0 -81
  191. package/source/mcp/mcp-client.ts +0 -625
  192. package/source/mcp/transport-factory.spec.ts +0 -406
  193. package/source/mcp/transport-factory.ts +0 -312
  194. package/source/message-handler.ts +0 -67
  195. package/source/model-database/database-engine.spec.ts +0 -494
  196. package/source/model-database/database-engine.ts +0 -50
  197. package/source/model-database/model-database.spec.ts +0 -363
  198. package/source/model-database/model-database.ts +0 -91
  199. package/source/model-database/model-engine.spec.ts +0 -447
  200. package/source/model-database/model-engine.ts +0 -65
  201. package/source/model-database/model-fetcher.spec.ts +0 -583
  202. package/source/model-database/model-fetcher.ts +0 -330
  203. package/source/models/index.ts +0 -1
  204. package/source/models/models-cache.spec.ts +0 -214
  205. package/source/models/models-cache.ts +0 -78
  206. package/source/models/models-dev-client.spec.ts +0 -379
  207. package/source/models/models-dev-client.ts +0 -329
  208. package/source/models/models-types.ts +0 -68
  209. package/source/prompt-history.ts +0 -155
  210. package/source/security/command-injection.spec.ts +0 -240
  211. package/source/services/checkpoint-manager.spec.ts +0 -523
  212. package/source/services/checkpoint-manager.ts +0 -466
  213. package/source/services/file-snapshot.spec.ts +0 -569
  214. package/source/services/file-snapshot.ts +0 -220
  215. package/source/test-utils/render-with-theme.tsx +0 -48
  216. package/source/tokenization/index.ts +0 -1
  217. package/source/tokenization/tokenizer-factory.spec.ts +0 -170
  218. package/source/tokenization/tokenizer-factory.ts +0 -125
  219. package/source/tokenization/tokenizers/anthropic-tokenizer.spec.ts +0 -200
  220. package/source/tokenization/tokenizers/anthropic-tokenizer.ts +0 -43
  221. package/source/tokenization/tokenizers/fallback-tokenizer.spec.ts +0 -236
  222. package/source/tokenization/tokenizers/fallback-tokenizer.ts +0 -26
  223. package/source/tokenization/tokenizers/llama-tokenizer.spec.ts +0 -224
  224. package/source/tokenization/tokenizers/llama-tokenizer.ts +0 -41
  225. package/source/tokenization/tokenizers/openai-tokenizer.spec.ts +0 -184
  226. package/source/tokenization/tokenizers/openai-tokenizer.ts +0 -57
  227. package/source/tool-calling/index.ts +0 -5
  228. package/source/tool-calling/json-parser.spec.ts +0 -639
  229. package/source/tool-calling/json-parser.ts +0 -247
  230. package/source/tool-calling/tool-parser.spec.ts +0 -395
  231. package/source/tool-calling/tool-parser.ts +0 -120
  232. package/source/tool-calling/xml-parser.spec.ts +0 -662
  233. package/source/tool-calling/xml-parser.ts +0 -289
  234. package/source/tools/execute-bash.spec.tsx +0 -353
  235. package/source/tools/execute-bash.tsx +0 -219
  236. package/source/tools/execute-function.spec.ts +0 -130
  237. package/source/tools/fetch-url.spec.tsx +0 -342
  238. package/source/tools/fetch-url.tsx +0 -172
  239. package/source/tools/find-files.spec.tsx +0 -924
  240. package/source/tools/find-files.tsx +0 -293
  241. package/source/tools/index.ts +0 -102
  242. package/source/tools/lsp-get-diagnostics.tsx +0 -192
  243. package/source/tools/needs-approval.spec.ts +0 -282
  244. package/source/tools/read-file.spec.tsx +0 -801
  245. package/source/tools/read-file.tsx +0 -387
  246. package/source/tools/search-file-contents.spec.tsx +0 -1273
  247. package/source/tools/search-file-contents.tsx +0 -293
  248. package/source/tools/string-replace.spec.tsx +0 -730
  249. package/source/tools/string-replace.tsx +0 -548
  250. package/source/tools/tool-manager.ts +0 -210
  251. package/source/tools/tool-registry.spec.ts +0 -415
  252. package/source/tools/tool-registry.ts +0 -228
  253. package/source/tools/web-search.tsx +0 -223
  254. package/source/tools/write-file.spec.tsx +0 -559
  255. package/source/tools/write-file.tsx +0 -228
  256. package/source/types/app.ts +0 -37
  257. package/source/types/checkpoint.ts +0 -48
  258. package/source/types/commands.ts +0 -46
  259. package/source/types/components.ts +0 -27
  260. package/source/types/config.ts +0 -103
  261. package/source/types/core-connection-status.spec.ts +0 -67
  262. package/source/types/core.ts +0 -181
  263. package/source/types/hooks.ts +0 -50
  264. package/source/types/index.ts +0 -12
  265. package/source/types/markdown-parser.ts +0 -11
  266. package/source/types/mcp.ts +0 -52
  267. package/source/types/system.ts +0 -16
  268. package/source/types/tokenization.ts +0 -41
  269. package/source/types/ui.ts +0 -40
  270. package/source/types/usage.ts +0 -58
  271. package/source/types/utils.ts +0 -16
  272. package/source/usage/calculator.spec.ts +0 -385
  273. package/source/usage/calculator.ts +0 -104
  274. package/source/usage/storage.spec.ts +0 -703
  275. package/source/usage/storage.ts +0 -238
  276. package/source/usage/tracker.spec.ts +0 -456
  277. package/source/usage/tracker.ts +0 -102
  278. package/source/utils/atomic-deletion.spec.ts +0 -194
  279. package/source/utils/atomic-deletion.ts +0 -127
  280. package/source/utils/bounded-map.spec.ts +0 -300
  281. package/source/utils/bounded-map.ts +0 -193
  282. package/source/utils/checkpoint-utils.spec.ts +0 -222
  283. package/source/utils/checkpoint-utils.ts +0 -92
  284. package/source/utils/error-formatter.spec.ts +0 -169
  285. package/source/utils/error-formatter.ts +0 -194
  286. package/source/utils/file-autocomplete.spec.ts +0 -173
  287. package/source/utils/file-autocomplete.ts +0 -196
  288. package/source/utils/file-cache.spec.ts +0 -309
  289. package/source/utils/file-cache.ts +0 -195
  290. package/source/utils/file-content-loader.spec.ts +0 -180
  291. package/source/utils/file-content-loader.ts +0 -179
  292. package/source/utils/file-mention-handler.spec.ts +0 -261
  293. package/source/utils/file-mention-handler.ts +0 -84
  294. package/source/utils/file-mention-parser.spec.ts +0 -182
  295. package/source/utils/file-mention-parser.ts +0 -170
  296. package/source/utils/fuzzy-matching.spec.ts +0 -149
  297. package/source/utils/fuzzy-matching.ts +0 -146
  298. package/source/utils/indentation-normalizer.spec.ts +0 -216
  299. package/source/utils/indentation-normalizer.ts +0 -76
  300. package/source/utils/installation-detector.spec.ts +0 -178
  301. package/source/utils/installation-detector.ts +0 -153
  302. package/source/utils/logging/config.spec.ts +0 -311
  303. package/source/utils/logging/config.ts +0 -210
  304. package/source/utils/logging/console-facade.spec.ts +0 -184
  305. package/source/utils/logging/console-facade.ts +0 -384
  306. package/source/utils/logging/correlation.spec.ts +0 -679
  307. package/source/utils/logging/correlation.ts +0 -474
  308. package/source/utils/logging/formatters.spec.ts +0 -464
  309. package/source/utils/logging/formatters.ts +0 -207
  310. package/source/utils/logging/health-monitor/alerts/alert-manager.spec.ts +0 -93
  311. package/source/utils/logging/health-monitor/alerts/alert-manager.ts +0 -79
  312. package/source/utils/logging/health-monitor/checks/configuration-check.spec.ts +0 -56
  313. package/source/utils/logging/health-monitor/checks/configuration-check.ts +0 -43
  314. package/source/utils/logging/health-monitor/checks/logging-check.spec.ts +0 -56
  315. package/source/utils/logging/health-monitor/checks/logging-check.ts +0 -58
  316. package/source/utils/logging/health-monitor/checks/memory-check.spec.ts +0 -100
  317. package/source/utils/logging/health-monitor/checks/memory-check.ts +0 -78
  318. package/source/utils/logging/health-monitor/checks/performance-check.spec.ts +0 -56
  319. package/source/utils/logging/health-monitor/checks/performance-check.ts +0 -56
  320. package/source/utils/logging/health-monitor/checks/request-check.spec.ts +0 -56
  321. package/source/utils/logging/health-monitor/checks/request-check.ts +0 -76
  322. package/source/utils/logging/health-monitor/core/health-check-runner.spec.ts +0 -70
  323. package/source/utils/logging/health-monitor/core/health-check-runner.ts +0 -138
  324. package/source/utils/logging/health-monitor/core/health-monitor.spec.ts +0 -58
  325. package/source/utils/logging/health-monitor/core/health-monitor.ts +0 -344
  326. package/source/utils/logging/health-monitor/core/scoring.spec.ts +0 -65
  327. package/source/utils/logging/health-monitor/core/scoring.ts +0 -91
  328. package/source/utils/logging/health-monitor/index.ts +0 -15
  329. package/source/utils/logging/health-monitor/instances.ts +0 -48
  330. package/source/utils/logging/health-monitor/middleware/http-middleware.spec.ts +0 -141
  331. package/source/utils/logging/health-monitor/middleware/http-middleware.ts +0 -75
  332. package/source/utils/logging/health-monitor/types.ts +0 -126
  333. package/source/utils/logging/index.spec.ts +0 -284
  334. package/source/utils/logging/index.ts +0 -236
  335. package/source/utils/logging/integration.spec.ts +0 -441
  336. package/source/utils/logging/log-method-factory.spec.ts +0 -573
  337. package/source/utils/logging/log-method-factory.ts +0 -233
  338. package/source/utils/logging/log-query/aggregation/aggregator.spec.ts +0 -277
  339. package/source/utils/logging/log-query/aggregation/aggregator.ts +0 -159
  340. package/source/utils/logging/log-query/aggregation/facet-generator.spec.ts +0 -159
  341. package/source/utils/logging/log-query/aggregation/facet-generator.ts +0 -47
  342. package/source/utils/logging/log-query/index.ts +0 -23
  343. package/source/utils/logging/log-query/query/filter-predicates.spec.ts +0 -247
  344. package/source/utils/logging/log-query/query/filter-predicates.ts +0 -154
  345. package/source/utils/logging/log-query/query/query-builder.spec.ts +0 -182
  346. package/source/utils/logging/log-query/query/query-builder.ts +0 -151
  347. package/source/utils/logging/log-query/query/query-engine.spec.ts +0 -214
  348. package/source/utils/logging/log-query/query/query-engine.ts +0 -45
  349. package/source/utils/logging/log-query/storage/circular-buffer.spec.ts +0 -143
  350. package/source/utils/logging/log-query/storage/circular-buffer.ts +0 -75
  351. package/source/utils/logging/log-query/storage/index-manager.spec.ts +0 -150
  352. package/source/utils/logging/log-query/storage/index-manager.ts +0 -71
  353. package/source/utils/logging/log-query/storage/log-storage.spec.ts +0 -257
  354. package/source/utils/logging/log-query/storage/log-storage.ts +0 -80
  355. package/source/utils/logging/log-query/types.ts +0 -163
  356. package/source/utils/logging/log-query/utils/helpers.spec.ts +0 -263
  357. package/source/utils/logging/log-query/utils/helpers.ts +0 -72
  358. package/source/utils/logging/log-query/utils/sorting.spec.ts +0 -182
  359. package/source/utils/logging/log-query/utils/sorting.ts +0 -61
  360. package/source/utils/logging/logger-provider.spec.ts +0 -262
  361. package/source/utils/logging/logger-provider.ts +0 -362
  362. package/source/utils/logging/performance.spec.ts +0 -209
  363. package/source/utils/logging/performance.ts +0 -757
  364. package/source/utils/logging/pino-logger.spec.ts +0 -425
  365. package/source/utils/logging/pino-logger.ts +0 -514
  366. package/source/utils/logging/redaction.spec.ts +0 -490
  367. package/source/utils/logging/redaction.ts +0 -267
  368. package/source/utils/logging/request-tracker.spec.ts +0 -1198
  369. package/source/utils/logging/request-tracker.ts +0 -803
  370. package/source/utils/logging/transports.spec.ts +0 -505
  371. package/source/utils/logging/transports.ts +0 -305
  372. package/source/utils/logging/types.ts +0 -216
  373. package/source/utils/message-builder.spec.ts +0 -179
  374. package/source/utils/message-builder.ts +0 -101
  375. package/source/utils/message-queue.tsx +0 -486
  376. package/source/utils/paste-detection.spec.ts +0 -69
  377. package/source/utils/paste-detection.ts +0 -124
  378. package/source/utils/paste-roundtrip.spec.ts +0 -442
  379. package/source/utils/paste-utils.spec.ts +0 -128
  380. package/source/utils/paste-utils.ts +0 -52
  381. package/source/utils/programming-language-helper.spec.ts +0 -74
  382. package/source/utils/programming-language-helper.ts +0 -32
  383. package/source/utils/prompt-assembly.spec.ts +0 -221
  384. package/source/utils/prompt-processor.ts +0 -173
  385. package/source/utils/tool-args-parser.spec.ts +0 -136
  386. package/source/utils/tool-args-parser.ts +0 -54
  387. package/source/utils/tool-cancellation.spec.ts +0 -230
  388. package/source/utils/tool-cancellation.ts +0 -28
  389. package/source/utils/tool-result-display.spec.tsx +0 -469
  390. package/source/utils/tool-result-display.tsx +0 -90
  391. package/source/utils/update-checker.spec.ts +0 -383
  392. package/source/utils/update-checker.ts +0 -183
  393. package/source/wizard/config-wizard.spec.tsx +0 -103
  394. package/source/wizard/config-wizard.tsx +0 -382
  395. package/source/wizard/steps/location-step.spec.tsx +0 -186
  396. package/source/wizard/steps/location-step.tsx +0 -147
  397. package/source/wizard/steps/mcp-step.spec.tsx +0 -607
  398. package/source/wizard/steps/mcp-step.tsx +0 -632
  399. package/source/wizard/steps/provider-step.spec.tsx +0 -342
  400. package/source/wizard/steps/provider-step.tsx +0 -957
  401. package/source/wizard/steps/summary-step.spec.tsx +0 -749
  402. package/source/wizard/steps/summary-step.tsx +0 -228
  403. package/source/wizard/templates/mcp-templates.spec.ts +0 -613
  404. package/source/wizard/templates/mcp-templates.ts +0 -570
  405. package/source/wizard/templates/provider-templates.spec.ts +0 -152
  406. package/source/wizard/templates/provider-templates.ts +0 -485
  407. package/source/wizard/utils/fetch-cloud-models.spec.ts +0 -428
  408. package/source/wizard/utils/fetch-cloud-models.ts +0 -223
  409. package/source/wizard/utils/fetch-local-models.spec.ts +0 -297
  410. package/source/wizard/utils/fetch-local-models.ts +0 -192
  411. package/source/wizard/validation-array.spec.ts +0 -264
  412. package/source/wizard/validation.spec.ts +0 -373
  413. package/source/wizard/validation.ts +0 -232
@@ -1,924 +0,0 @@
1
- import {mkdirSync, rmSync, writeFileSync} from 'node:fs';
2
- import {join} from 'node:path';
3
- import test from 'ava';
4
- import {render} from 'ink-testing-library';
5
- import React from 'react';
6
- import {themes} from '../config/themes';
7
- import {ThemeContext} from '../hooks/useTheme';
8
- import {findFilesTool} from './find-files';
9
-
10
- // ============================================================================
11
- // Test Helpers
12
- // ============================================================================
13
-
14
- console.log(`\nfind-files.spec.tsx – ${React.version}`);
15
-
16
- // Create a mock theme provider for tests
17
- function TestThemeProvider({children}: {children: React.ReactNode}) {
18
- const themeContextValue = {
19
- currentTheme: 'tokyo-night' as const,
20
- colors: themes['tokyo-night'].colors,
21
- setCurrentTheme: () => {},
22
- };
23
-
24
- return (
25
- <ThemeContext.Provider value={themeContextValue}>
26
- {children}
27
- </ThemeContext.Provider>
28
- );
29
- }
30
-
31
- // ============================================================================
32
- // Tests for FindFilesFormatter Component Rendering
33
- // ============================================================================
34
-
35
- test('FindFilesFormatter renders with pattern', t => {
36
- const formatter = findFilesTool.formatter;
37
- if (!formatter) {
38
- t.fail('Formatter is not defined');
39
- return;
40
- }
41
-
42
- const element = formatter(
43
- {pattern: '*.tsx', maxResults: 50},
44
- 'Found 15 matches',
45
- );
46
- const {lastFrame} = render(<TestThemeProvider>{element}</TestThemeProvider>);
47
-
48
- const output = lastFrame();
49
- t.truthy(output);
50
- t.regex(output!, /find_files/);
51
- t.regex(output!, /\*\.tsx/);
52
- t.regex(output!, /15/);
53
- });
54
-
55
- test('FindFilesFormatter shows 0 results when no matches', t => {
56
- const formatter = findFilesTool.formatter;
57
- if (!formatter) {
58
- t.fail('Formatter is not defined');
59
- return;
60
- }
61
-
62
- const element = formatter(
63
- {pattern: '*.nonexistent'},
64
- 'No files or directories found',
65
- );
66
- const {lastFrame} = render(<TestThemeProvider>{element}</TestThemeProvider>);
67
-
68
- const output = lastFrame();
69
- t.truthy(output);
70
- t.regex(output!, /0/);
71
- });
72
-
73
- test('FindFilesFormatter handles error results gracefully', t => {
74
- const formatter = findFilesTool.formatter;
75
- if (!formatter) {
76
- t.fail('Formatter is not defined');
77
- return;
78
- }
79
-
80
- const element = formatter({pattern: '*.ts'}, 'Error: Something went wrong');
81
- const {lastFrame} = render(element);
82
-
83
- // Should return empty fragment for errors
84
- const output = lastFrame();
85
- t.is(output, '');
86
- });
87
-
88
- test('FindFilesFormatter displays pattern parameter', t => {
89
- const formatter = findFilesTool.formatter;
90
- if (!formatter) {
91
- t.fail('Formatter is not defined');
92
- return;
93
- }
94
-
95
- const element = formatter(
96
- {pattern: 'src/**/*.ts', maxResults: 50},
97
- 'Found 42 matches',
98
- );
99
- const {lastFrame} = render(<TestThemeProvider>{element}</TestThemeProvider>);
100
-
101
- const output = lastFrame();
102
- t.regex(output!, /Pattern:/);
103
- t.regex(output!, /src\/\*\*\/\*\.ts/);
104
- });
105
-
106
- test('FindFilesFormatter displays results count', t => {
107
- const formatter = findFilesTool.formatter;
108
- if (!formatter) {
109
- t.fail('Formatter is not defined');
110
- return;
111
- }
112
-
113
- const element = formatter({pattern: '*.ts'}, 'Found 23 matches');
114
- const {lastFrame} = render(<TestThemeProvider>{element}</TestThemeProvider>);
115
-
116
- const output = lastFrame();
117
- t.regex(output!, /Results:/);
118
- t.regex(output!, /23/);
119
- });
120
-
121
- test('FindFilesFormatter renders without crashing', t => {
122
- const formatter = findFilesTool.formatter;
123
- if (!formatter) {
124
- t.fail('Formatter is not defined');
125
- return;
126
- }
127
-
128
- const element = formatter({pattern: '*.tsx'}, 'Found 5 matches');
129
- const {lastFrame} = render(<TestThemeProvider>{element}</TestThemeProvider>);
130
-
131
- // Should render without errors
132
- t.truthy(lastFrame());
133
- });
134
-
135
- // ============================================================================
136
- // Tests for find_files Tool Handler - Gitignore Integration
137
- // ============================================================================
138
-
139
- test.serial('find_files respects .gitignore patterns', async t => {
140
- t.timeout(10000);
141
- const testDir = join(process.cwd(), 'test-find-gitignore-temp');
142
-
143
- try {
144
- // Create test directory structure
145
- mkdirSync(testDir, {recursive: true});
146
- mkdirSync(join(testDir, 'src'), {recursive: true});
147
- mkdirSync(join(testDir, 'build'), {recursive: true});
148
-
149
- // Create .gitignore
150
- writeFileSync(join(testDir, '.gitignore'), 'build/\n*.ignored\n');
151
-
152
- // Create test files
153
- writeFileSync(join(testDir, 'src', 'component.tsx'), 'export const Comp');
154
- writeFileSync(join(testDir, 'build', 'output.tsx'), 'compiled code');
155
- writeFileSync(join(testDir, 'file.ignored'), 'should be ignored');
156
-
157
- // Save current directory
158
- const originalCwd = process.cwd();
159
-
160
- try {
161
- // Change to test directory
162
- process.chdir(testDir);
163
-
164
- // Test pattern search - should exclude ignored files
165
- const result = await findFilesTool.tool.execute!(
166
- {
167
- pattern: '**/*.tsx',
168
- maxResults: 50,
169
- },
170
- {toolCallId: 'test', messages: []},
171
- );
172
-
173
- t.false(
174
- result.includes('build/'),
175
- 'Should not include ignored directory',
176
- );
177
- t.true(
178
- result.includes('src/component.tsx'),
179
- 'Should include non-ignored files',
180
- );
181
- } finally {
182
- // Restore original directory
183
- process.chdir(originalCwd);
184
- }
185
- } finally {
186
- // Cleanup
187
- rmSync(testDir, {recursive: true, force: true});
188
- }
189
- });
190
-
191
- test.serial(
192
- 'find_files uses hardcoded ignores when no .gitignore exists',
193
- async t => {
194
- t.timeout(10000);
195
- const testDir = join(process.cwd(), 'test-find-no-gitignore-temp');
196
-
197
- try {
198
- // Create test directory without .gitignore
199
- mkdirSync(testDir, {recursive: true});
200
- mkdirSync(join(testDir, 'node_modules'), {recursive: true});
201
- mkdirSync(join(testDir, 'src'), {recursive: true});
202
-
203
- // Create test files
204
- writeFileSync(join(testDir, 'node_modules', 'package.js'), 'module code');
205
- writeFileSync(join(testDir, 'src', 'index.js'), 'source code');
206
-
207
- // Save current directory
208
- const originalCwd = process.cwd();
209
-
210
- try {
211
- // Change to test directory
212
- process.chdir(testDir);
213
-
214
- // Test pattern search - should exclude node_modules even without .gitignore
215
- const result = await findFilesTool.tool.execute!(
216
- {
217
- pattern: '**/*.js',
218
- maxResults: 50,
219
- },
220
- {toolCallId: 'test', messages: []},
221
- );
222
-
223
- t.false(
224
- result.includes('node_modules'),
225
- 'Should ignore node_modules by default',
226
- );
227
- t.true(
228
- result.includes('src/index.js'),
229
- 'Should include non-ignored files',
230
- );
231
- } finally {
232
- // Restore original directory
233
- process.chdir(originalCwd);
234
- }
235
- } finally {
236
- // Cleanup
237
- rmSync(testDir, {recursive: true, force: true});
238
- }
239
- },
240
- );
241
-
242
- // ============================================================================
243
- // Tests for find_files Tool Handler - Pattern Matching
244
- // ============================================================================
245
-
246
- test.serial('find_files handles directory patterns (dir/**)', async t => {
247
- t.timeout(10000);
248
- const testDir = join(process.cwd(), 'test-find-dir-pattern-temp');
249
-
250
- try {
251
- // Create test directory structure
252
- mkdirSync(testDir, {recursive: true});
253
- mkdirSync(join(testDir, 'scripts'), {recursive: true});
254
- mkdirSync(join(testDir, 'src'), {recursive: true});
255
-
256
- // Create test files
257
- writeFileSync(join(testDir, 'scripts', 'build.sh'), '#!/bin/bash');
258
- writeFileSync(join(testDir, 'scripts', 'test.js'), 'console.log()');
259
- writeFileSync(join(testDir, 'src', 'app.ts'), 'export const app');
260
-
261
- const originalCwd = process.cwd();
262
-
263
- try {
264
- process.chdir(testDir);
265
-
266
- const result = await findFilesTool.tool.execute!(
267
- {
268
- pattern: 'scripts/**',
269
- maxResults: 50,
270
- },
271
- {toolCallId: 'test', messages: []},
272
- );
273
-
274
- t.true(
275
- result.includes('scripts/build.sh'),
276
- 'Should include scripts dir files',
277
- );
278
- t.true(
279
- result.includes('scripts/test.js'),
280
- 'Should include all files in scripts',
281
- );
282
- t.false(result.includes('src/'), 'Should not include other directories');
283
- } finally {
284
- process.chdir(originalCwd);
285
- }
286
- } finally {
287
- rmSync(testDir, {recursive: true, force: true});
288
- }
289
- });
290
-
291
- test.serial('find_files handles wildcard patterns (**/*.ext)', async t => {
292
- t.timeout(10000);
293
- const testDir = join(process.cwd(), 'test-find-wildcard-temp');
294
-
295
- try {
296
- mkdirSync(testDir, {recursive: true});
297
- mkdirSync(join(testDir, 'src'), {recursive: true});
298
- mkdirSync(join(testDir, 'lib'), {recursive: true});
299
-
300
- writeFileSync(join(testDir, 'src', 'index.ts'), 'source');
301
- writeFileSync(join(testDir, 'lib', 'utils.ts'), 'utils');
302
- writeFileSync(join(testDir, 'readme.md'), 'docs');
303
-
304
- const originalCwd = process.cwd();
305
-
306
- try {
307
- process.chdir(testDir);
308
-
309
- const result = await findFilesTool.tool.execute!(
310
- {
311
- pattern: '**/*.ts',
312
- maxResults: 50,
313
- },
314
- {toolCallId: 'test', messages: []},
315
- );
316
-
317
- t.true(result.includes('src/index.ts'), 'Should find .ts in src');
318
- t.true(result.includes('lib/utils.ts'), 'Should find .ts in lib');
319
- t.false(result.includes('readme.md'), 'Should not include .md files');
320
- } finally {
321
- process.chdir(originalCwd);
322
- }
323
- } finally {
324
- rmSync(testDir, {recursive: true, force: true});
325
- }
326
- });
327
-
328
- test.serial('find_files handles brace expansion patterns', async t => {
329
- t.timeout(10000);
330
- const testDir = join(process.cwd(), 'test-find-brace-temp');
331
-
332
- try {
333
- mkdirSync(testDir, {recursive: true});
334
- mkdirSync(join(testDir, 'src'), {recursive: true});
335
-
336
- writeFileSync(join(testDir, 'src', 'comp.tsx'), 'tsx file');
337
- writeFileSync(join(testDir, 'src', 'util.ts'), 'ts file');
338
- writeFileSync(join(testDir, 'src', 'style.css'), 'css file');
339
-
340
- const originalCwd = process.cwd();
341
-
342
- try {
343
- process.chdir(testDir);
344
-
345
- const result = await findFilesTool.tool.execute!(
346
- {
347
- pattern: '*.{ts,tsx}',
348
- maxResults: 50,
349
- },
350
- {toolCallId: 'test', messages: []},
351
- );
352
-
353
- t.true(
354
- result.includes('comp.tsx') || result.includes('util.ts'),
355
- 'Should find .ts and .tsx files',
356
- );
357
- t.false(result.includes('style.css'), 'Should not include .css files');
358
- } finally {
359
- process.chdir(originalCwd);
360
- }
361
- } finally {
362
- rmSync(testDir, {recursive: true, force: true});
363
- }
364
- });
365
-
366
- test.serial('find_files handles simple patterns (*.ext)', async t => {
367
- t.timeout(10000);
368
- const testDir = join(process.cwd(), 'test-find-simple-temp');
369
-
370
- try {
371
- mkdirSync(testDir, {recursive: true});
372
-
373
- writeFileSync(join(testDir, 'file1.json'), '{}');
374
- writeFileSync(join(testDir, 'file2.json'), '{}');
375
- writeFileSync(join(testDir, 'file3.txt'), 'text');
376
-
377
- const originalCwd = process.cwd();
378
-
379
- try {
380
- process.chdir(testDir);
381
-
382
- const result = await findFilesTool.tool.execute!(
383
- {
384
- pattern: '*.json',
385
- maxResults: 50,
386
- },
387
- {toolCallId: 'test', messages: []},
388
- );
389
-
390
- t.true(result.includes('file1.json'), 'Should find .json files');
391
- t.true(result.includes('file2.json'), 'Should find all .json files');
392
- t.false(result.includes('file3.txt'), 'Should not include .txt files');
393
- } finally {
394
- process.chdir(originalCwd);
395
- }
396
- } finally {
397
- rmSync(testDir, {recursive: true, force: true});
398
- }
399
- });
400
-
401
- test.serial(
402
- 'find_files handles directory-prefixed wildcard patterns (dir/*.ext)',
403
- async t => {
404
- t.timeout(10000);
405
- const testDir = join(process.cwd(), 'test-find-dir-wildcard-temp');
406
-
407
- try {
408
- mkdirSync(testDir, {recursive: true});
409
- mkdirSync(join(testDir, 'scripts'), {recursive: true});
410
- mkdirSync(join(testDir, 'src'), {recursive: true});
411
-
412
- writeFileSync(join(testDir, 'scripts', 'build.sh'), '#!/bin/bash');
413
- writeFileSync(join(testDir, 'scripts', 'test.sh'), '#!/bin/bash');
414
- writeFileSync(join(testDir, 'scripts', 'readme.md'), 'docs');
415
- writeFileSync(join(testDir, 'src', 'index.ts'), 'source');
416
- writeFileSync(join(testDir, 'root.sh'), '#!/bin/bash');
417
-
418
- const originalCwd = process.cwd();
419
-
420
- try {
421
- process.chdir(testDir);
422
-
423
- // Test scripts/*.sh pattern
424
- const result = await findFilesTool.tool.execute!(
425
- {
426
- pattern: 'scripts/*.sh',
427
- maxResults: 50,
428
- },
429
- {toolCallId: 'test', messages: []},
430
- );
431
-
432
- t.true(
433
- result.includes('scripts/build.sh'),
434
- 'Should find .sh files in scripts directory',
435
- );
436
- t.true(
437
- result.includes('scripts/test.sh'),
438
- 'Should find all .sh files in scripts directory',
439
- );
440
- t.false(
441
- result.includes('scripts/readme.md'),
442
- 'Should not include non-.sh files in scripts',
443
- );
444
- t.false(
445
- result.includes('src/index.ts'),
446
- 'Should not include files from other directories',
447
- );
448
- t.false(
449
- result.includes('root.sh'),
450
- 'Should not include .sh files in root when pattern specifies scripts/',
451
- );
452
- } finally {
453
- process.chdir(originalCwd);
454
- }
455
- } finally {
456
- rmSync(testDir, {recursive: true, force: true});
457
- }
458
- },
459
- );
460
-
461
- test.serial(
462
- 'find_files includes directories when they match pattern',
463
- async t => {
464
- t.timeout(10000);
465
- const testDir = join(process.cwd(), 'test-find-dirs-temp');
466
-
467
- try {
468
- mkdirSync(testDir, {recursive: true});
469
- mkdirSync(join(testDir, 'components'), {recursive: true});
470
- mkdirSync(join(testDir, 'utils'), {recursive: true});
471
-
472
- writeFileSync(join(testDir, 'components', 'Button.tsx'), 'component');
473
-
474
- const originalCwd = process.cwd();
475
-
476
- try {
477
- process.chdir(testDir);
478
-
479
- const result = await findFilesTool.tool.execute!(
480
- {
481
- pattern: 'components',
482
- maxResults: 50,
483
- },
484
- {toolCallId: 'test', messages: []},
485
- );
486
-
487
- // Should find the directory itself
488
- t.true(result.includes('components'), 'Should find directory by name');
489
- } finally {
490
- process.chdir(originalCwd);
491
- }
492
- } finally {
493
- rmSync(testDir, {recursive: true, force: true});
494
- }
495
- },
496
- );
497
-
498
- // ============================================================================
499
- // Tests for find_files Tool Handler - Basic Functionality
500
- // ============================================================================
501
-
502
- test.serial(
503
- 'find_files returns no files message for nonexistent pattern',
504
- async t => {
505
- t.timeout(10000);
506
- const result = await findFilesTool.tool.execute!(
507
- {
508
- pattern: '**/*.veryuniqueextension',
509
- maxResults: 50,
510
- },
511
- {toolCallId: 'test', messages: []},
512
- );
513
-
514
- t.regex(result, /No files or directories found/);
515
- },
516
- );
517
-
518
- // ============================================================================
519
- // Tests for find_files Tool Configuration
520
- // ============================================================================
521
-
522
- test('find_files tool has correct name', t => {
523
- t.is(findFilesTool.name, 'find_files');
524
- });
525
-
526
- test('find_files tool does not require confirmation', t => {
527
- t.false(findFilesTool.tool.needsApproval);
528
- });
529
-
530
- test('find_files tool has handler function', t => {
531
- t.is(typeof findFilesTool.tool.execute, 'function');
532
- });
533
-
534
- test('find_files tool has formatter function', t => {
535
- t.is(typeof findFilesTool.formatter, 'function');
536
- });
537
-
538
- // ============================================================================
539
- // Tests for maxResults Cap
540
- // ============================================================================
541
-
542
- test.serial('find_files enforces max cap of 100 results', async t => {
543
- t.timeout(10000);
544
- // Request more than 100 results but should be capped at 100
545
- const result = await findFilesTool.tool.execute!(
546
- {
547
- pattern: '**/*.ts',
548
- maxResults: 500, // Request 500, but should cap at 100
549
- },
550
- {toolCallId: 'test', messages: []},
551
- );
552
-
553
- // Check that the result doesn't exceed 100 matches
554
- const firstLine = result.split('\n')[0];
555
- const matchCount = firstLine.match(/Found (\d+)/);
556
-
557
- if (matchCount) {
558
- const count = parseInt(matchCount[1], 10);
559
- t.true(count <= 100, `Found ${count} matches, should be max 100`);
560
- }
561
- });
562
-
563
- test.serial('find_files respects maxResults when less than cap', async t => {
564
- t.timeout(10000);
565
- const result = await findFilesTool.tool.execute!(
566
- {
567
- pattern: '**/*.ts',
568
- maxResults: 10, // Request only 10
569
- },
570
- {toolCallId: 'test', messages: []},
571
- );
572
-
573
- // Should respect the lower limit
574
- t.truthy(result);
575
- t.false(result.includes('Error'));
576
- });
577
-
578
- // ============================================================================
579
- // Edge Cases and Stress Tests
580
- // ============================================================================
581
-
582
- test.serial('find_files handles special characters in patterns', async t => {
583
- t.timeout(10000);
584
- const testDir = join(process.cwd(), 'test-find-special-chars-temp');
585
-
586
- try {
587
- mkdirSync(testDir, {recursive: true});
588
- writeFileSync(join(testDir, 'file-with-dash.ts'), 'content');
589
- writeFileSync(join(testDir, 'file_with_underscore.ts'), 'content');
590
- writeFileSync(join(testDir, 'file.with.dots.ts'), 'content');
591
-
592
- const originalCwd = process.cwd();
593
-
594
- try {
595
- process.chdir(testDir);
596
-
597
- const result = await findFilesTool.tool.execute!(
598
- {
599
- pattern: '*.ts',
600
- maxResults: 50,
601
- },
602
- {toolCallId: 'test', messages: []},
603
- );
604
-
605
- t.true(result.includes('file-with-dash.ts'), 'Should handle dashes');
606
- t.true(
607
- result.includes('file_with_underscore.ts'),
608
- 'Should handle underscores',
609
- );
610
- t.true(
611
- result.includes('file.with.dots.ts'),
612
- 'Should handle multiple dots',
613
- );
614
- } finally {
615
- process.chdir(originalCwd);
616
- }
617
- } finally {
618
- rmSync(testDir, {recursive: true, force: true});
619
- }
620
- });
621
-
622
- test.serial('find_files handles deeply nested directories', async t => {
623
- t.timeout(10000);
624
- const testDir = join(process.cwd(), 'test-find-deep-temp');
625
-
626
- try {
627
- const deepPath = join(testDir, 'a', 'b', 'c', 'd', 'e');
628
- mkdirSync(deepPath, {recursive: true});
629
- writeFileSync(join(deepPath, 'deep.ts'), 'content');
630
-
631
- const originalCwd = process.cwd();
632
-
633
- try {
634
- process.chdir(testDir);
635
-
636
- const result = await findFilesTool.tool.execute!(
637
- {
638
- pattern: '**/*.ts',
639
- maxResults: 50,
640
- },
641
- {toolCallId: 'test', messages: []},
642
- );
643
-
644
- t.true(
645
- result.includes('deep.ts'),
646
- 'Should find files in deeply nested directories',
647
- );
648
- } finally {
649
- process.chdir(originalCwd);
650
- }
651
- } finally {
652
- rmSync(testDir, {recursive: true, force: true});
653
- }
654
- });
655
-
656
- test.serial('find_files handles empty directories gracefully', async t => {
657
- t.timeout(10000);
658
- const testDir = join(process.cwd(), 'test-find-empty-temp');
659
-
660
- try {
661
- mkdirSync(testDir, {recursive: true});
662
- mkdirSync(join(testDir, 'empty-dir'), {recursive: true});
663
-
664
- const originalCwd = process.cwd();
665
-
666
- try {
667
- process.chdir(testDir);
668
-
669
- const result = await findFilesTool.tool.execute!(
670
- {
671
- pattern: '*.ts',
672
- maxResults: 50,
673
- },
674
- {toolCallId: 'test', messages: []},
675
- );
676
-
677
- t.regex(
678
- result,
679
- /No files or directories found/,
680
- 'Should handle empty directories',
681
- );
682
- } finally {
683
- process.chdir(originalCwd);
684
- }
685
- } finally {
686
- rmSync(testDir, {recursive: true, force: true});
687
- }
688
- });
689
-
690
- test.serial('find_files handles pattern with no wildcards', async t => {
691
- t.timeout(10000);
692
- const testDir = join(process.cwd(), 'test-find-exact-temp');
693
-
694
- try {
695
- mkdirSync(testDir, {recursive: true});
696
- writeFileSync(join(testDir, 'exact-file.ts'), 'content');
697
- writeFileSync(join(testDir, 'other-file.ts'), 'content');
698
-
699
- const originalCwd = process.cwd();
700
-
701
- try {
702
- process.chdir(testDir);
703
-
704
- const result = await findFilesTool.tool.execute!(
705
- {
706
- pattern: 'exact-file.ts',
707
- maxResults: 50,
708
- },
709
- {toolCallId: 'test', messages: []},
710
- );
711
-
712
- t.true(result.includes('exact-file.ts'), 'Should find exact filename');
713
- t.false(result.includes('other-file.ts'), 'Should not find other files');
714
- } finally {
715
- process.chdir(originalCwd);
716
- }
717
- } finally {
718
- rmSync(testDir, {recursive: true, force: true});
719
- }
720
- });
721
-
722
- test.serial('find_files handles patterns with subdirectory prefix', async t => {
723
- t.timeout(10000);
724
- const testDir = join(process.cwd(), 'test-find-subdir-temp');
725
-
726
- try {
727
- mkdirSync(testDir, {recursive: true});
728
- mkdirSync(join(testDir, 'src'), {recursive: true});
729
- mkdirSync(join(testDir, 'src', 'components'), {recursive: true});
730
- writeFileSync(join(testDir, 'src', 'components', 'Button.tsx'), 'content');
731
- writeFileSync(join(testDir, 'src', 'index.ts'), 'content');
732
-
733
- const originalCwd = process.cwd();
734
-
735
- try {
736
- process.chdir(testDir);
737
-
738
- const result = await findFilesTool.tool.execute!(
739
- {
740
- pattern: 'src/components/**/*.tsx',
741
- maxResults: 50,
742
- },
743
- {toolCallId: 'test', messages: []},
744
- );
745
-
746
- t.true(
747
- result.includes('Button.tsx'),
748
- 'Should find files with subdirectory prefix',
749
- );
750
- t.false(
751
- result.includes('index.ts'),
752
- 'Should not find files outside pattern',
753
- );
754
- } finally {
755
- process.chdir(originalCwd);
756
- }
757
- } finally {
758
- rmSync(testDir, {recursive: true, force: true});
759
- }
760
- });
761
-
762
- test.serial('find_files handles symlinks gracefully', async t => {
763
- t.timeout(10000);
764
- const testDir = join(process.cwd(), 'test-find-symlink-temp');
765
-
766
- try {
767
- mkdirSync(testDir, {recursive: true});
768
- mkdirSync(join(testDir, 'real-dir'), {recursive: true});
769
- writeFileSync(join(testDir, 'real-dir', 'file.ts'), 'content');
770
-
771
- const originalCwd = process.cwd();
772
-
773
- try {
774
- process.chdir(testDir);
775
-
776
- // Just verify it doesn't crash with symlinks present
777
- const result = await findFilesTool.tool.execute!(
778
- {
779
- pattern: '**/*.ts',
780
- maxResults: 50,
781
- },
782
- {toolCallId: 'test', messages: []},
783
- );
784
-
785
- t.truthy(result);
786
- t.false(result.includes('Error'));
787
- } finally {
788
- process.chdir(originalCwd);
789
- }
790
- } finally {
791
- rmSync(testDir, {recursive: true, force: true});
792
- }
793
- });
794
-
795
- test.serial(
796
- 'find_files handles multiple file extensions in brace pattern',
797
- async t => {
798
- t.timeout(10000);
799
- const testDir = join(process.cwd(), 'test-find-multi-ext-temp');
800
-
801
- try {
802
- mkdirSync(testDir, {recursive: true});
803
- writeFileSync(join(testDir, 'file.ts'), 'content');
804
- writeFileSync(join(testDir, 'file.tsx'), 'content');
805
- writeFileSync(join(testDir, 'file.js'), 'content');
806
- writeFileSync(join(testDir, 'file.jsx'), 'content');
807
-
808
- const originalCwd = process.cwd();
809
-
810
- try {
811
- process.chdir(testDir);
812
-
813
- const result = await findFilesTool.tool.execute!(
814
- {
815
- pattern: '*.{ts,tsx,js,jsx}',
816
- maxResults: 50,
817
- },
818
- {toolCallId: 'test', messages: []},
819
- );
820
-
821
- t.true(result.includes('file.ts'), 'Should find .ts');
822
- t.true(result.includes('file.tsx'), 'Should find .tsx');
823
- t.true(result.includes('file.js'), 'Should find .js');
824
- t.true(result.includes('file.jsx'), 'Should find .jsx');
825
- } finally {
826
- process.chdir(originalCwd);
827
- }
828
- } finally {
829
- rmSync(testDir, {recursive: true, force: true});
830
- }
831
- },
832
- );
833
-
834
- test.serial('find_files handles files with no extension', async t => {
835
- t.timeout(10000);
836
- const testDir = join(process.cwd(), 'test-find-no-ext-temp');
837
-
838
- try {
839
- mkdirSync(testDir, {recursive: true});
840
- writeFileSync(join(testDir, 'Makefile'), 'content');
841
- writeFileSync(join(testDir, 'Dockerfile'), 'content');
842
- writeFileSync(join(testDir, 'file.ts'), 'content');
843
-
844
- const originalCwd = process.cwd();
845
-
846
- try {
847
- process.chdir(testDir);
848
-
849
- const result = await findFilesTool.tool.execute!(
850
- {
851
- pattern: 'Makefile',
852
- maxResults: 50,
853
- },
854
- {toolCallId: 'test', messages: []},
855
- );
856
-
857
- t.true(
858
- result.includes('Makefile'),
859
- 'Should find files without extension',
860
- );
861
- } finally {
862
- process.chdir(originalCwd);
863
- }
864
- } finally {
865
- rmSync(testDir, {recursive: true, force: true});
866
- }
867
- });
868
-
869
- test.serial(
870
- 'find_files correctly excludes all hardcoded ignore patterns',
871
- async t => {
872
- t.timeout(10000);
873
- const testDir = join(process.cwd(), 'test-find-hardcoded-temp');
874
-
875
- try {
876
- mkdirSync(testDir, {recursive: true});
877
- const ignoreDirs = [
878
- 'node_modules',
879
- '.git',
880
- 'dist',
881
- 'build',
882
- 'coverage',
883
- '.next',
884
- '.nuxt',
885
- 'out',
886
- '.cache',
887
- ];
888
-
889
- for (const dir of ignoreDirs) {
890
- mkdirSync(join(testDir, dir), {recursive: true});
891
- writeFileSync(join(testDir, dir, 'file.ts'), 'content');
892
- }
893
-
894
- mkdirSync(join(testDir, 'src'), {recursive: true});
895
- writeFileSync(join(testDir, 'src', 'file.ts'), 'content');
896
-
897
- const originalCwd = process.cwd();
898
-
899
- try {
900
- process.chdir(testDir);
901
-
902
- const result = await findFilesTool.tool.execute!(
903
- {
904
- pattern: '**/*.ts',
905
- maxResults: 50,
906
- },
907
- {toolCallId: 'test', messages: []},
908
- );
909
-
910
- for (const dir of ignoreDirs) {
911
- t.false(result.includes(`${dir}/`), `Should exclude ${dir}`);
912
- }
913
- t.true(
914
- result.includes('src/file.ts'),
915
- 'Should include non-ignored files',
916
- );
917
- } finally {
918
- process.chdir(originalCwd);
919
- }
920
- } finally {
921
- rmSync(testDir, {recursive: true, force: true});
922
- }
923
- },
924
- );