@theia/ai-ide 1.67.0-next.3 → 1.67.0-next.56

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 (306) hide show
  1. package/README.md +1 -0
  2. package/package.json +21 -21
  3. package/src/browser/ai-configuration/agent-configuration-widget.tsx +3 -3
  4. package/src/browser/context-file-validation-service-impl.spec.ts +405 -0
  5. package/src/browser/context-file-validation-service-impl.ts +120 -0
  6. package/src/browser/context-functions.spec.ts +155 -1
  7. package/src/browser/context-functions.ts +40 -6
  8. package/src/browser/file-changeset-functions.spec.ts +13 -13
  9. package/src/browser/file-changeset-functions.ts +9 -9
  10. package/src/browser/frontend-module.ts +12 -4
  11. package/src/browser/ide-chat-welcome-message-provider.tsx +64 -70
  12. package/src/browser/remember-command-contribution.ts +105 -0
  13. package/src/browser/workspace-functions.ts +68 -1
  14. package/src/common/ai-ide-preferences.ts +1 -1
  15. package/src/common/coder-replace-prompt-template.ts +8 -9
  16. package/src/common/command-prompt-template.ts +5 -5
  17. package/src/common/file-changeset-function-ids.ts +15 -1
  18. package/src/common/orchestrator-chat-agent.ts +2 -2
  19. package/lib/browser/ai-configuration/agent-configuration-widget.d.ts +0 -41
  20. package/lib/browser/ai-configuration/agent-configuration-widget.d.ts.map +0 -1
  21. package/lib/browser/ai-configuration/agent-configuration-widget.js +0 -333
  22. package/lib/browser/ai-configuration/agent-configuration-widget.js.map +0 -1
  23. package/lib/browser/ai-configuration/ai-configuration-service.d.ts +0 -18
  24. package/lib/browser/ai-configuration/ai-configuration-service.d.ts.map +0 -1
  25. package/lib/browser/ai-configuration/ai-configuration-service.js +0 -53
  26. package/lib/browser/ai-configuration/ai-configuration-service.js.map +0 -1
  27. package/lib/browser/ai-configuration/ai-configuration-view-contribution.d.ts +0 -14
  28. package/lib/browser/ai-configuration/ai-configuration-view-contribution.d.ts.map +0 -1
  29. package/lib/browser/ai-configuration/ai-configuration-view-contribution.js +0 -67
  30. package/lib/browser/ai-configuration/ai-configuration-view-contribution.js.map +0 -1
  31. package/lib/browser/ai-configuration/ai-configuration-widget.d.ts +0 -29
  32. package/lib/browser/ai-configuration/ai-configuration-widget.d.ts.map +0 -1
  33. package/lib/browser/ai-configuration/ai-configuration-widget.js +0 -118
  34. package/lib/browser/ai-configuration/ai-configuration-widget.js.map +0 -1
  35. package/lib/browser/ai-configuration/language-model-renderer.d.ts +0 -13
  36. package/lib/browser/ai-configuration/language-model-renderer.d.ts.map +0 -1
  37. package/lib/browser/ai-configuration/language-model-renderer.js +0 -104
  38. package/lib/browser/ai-configuration/language-model-renderer.js.map +0 -1
  39. package/lib/browser/ai-configuration/mcp-configuration-widget.d.ts +0 -43
  40. package/lib/browser/ai-configuration/mcp-configuration-widget.d.ts.map +0 -1
  41. package/lib/browser/ai-configuration/mcp-configuration-widget.js +0 -302
  42. package/lib/browser/ai-configuration/mcp-configuration-widget.js.map +0 -1
  43. package/lib/browser/ai-configuration/model-aliases-configuration-widget.d.ts +0 -41
  44. package/lib/browser/ai-configuration/model-aliases-configuration-widget.d.ts.map +0 -1
  45. package/lib/browser/ai-configuration/model-aliases-configuration-widget.js +0 -226
  46. package/lib/browser/ai-configuration/model-aliases-configuration-widget.js.map +0 -1
  47. package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.d.ts +0 -141
  48. package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.d.ts.map +0 -1
  49. package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.js +0 -508
  50. package/lib/browser/ai-configuration/prompt-fragments-configuration-widget.js.map +0 -1
  51. package/lib/browser/ai-configuration/template-settings-renderer.d.ts +0 -10
  52. package/lib/browser/ai-configuration/template-settings-renderer.d.ts.map +0 -1
  53. package/lib/browser/ai-configuration/template-settings-renderer.js +0 -48
  54. package/lib/browser/ai-configuration/template-settings-renderer.js.map +0 -1
  55. package/lib/browser/ai-configuration/token-usage-configuration-widget.d.ts +0 -22
  56. package/lib/browser/ai-configuration/token-usage-configuration-widget.d.ts.map +0 -1
  57. package/lib/browser/ai-configuration/token-usage-configuration-widget.js +0 -156
  58. package/lib/browser/ai-configuration/token-usage-configuration-widget.js.map +0 -1
  59. package/lib/browser/ai-configuration/tools-configuration-widget.d.ts +0 -30
  60. package/lib/browser/ai-configuration/tools-configuration-widget.d.ts.map +0 -1
  61. package/lib/browser/ai-configuration/tools-configuration-widget.js +0 -150
  62. package/lib/browser/ai-configuration/tools-configuration-widget.js.map +0 -1
  63. package/lib/browser/ai-configuration/variable-configuration-widget.d.ts +0 -19
  64. package/lib/browser/ai-configuration/variable-configuration-widget.d.ts.map +0 -1
  65. package/lib/browser/ai-configuration/variable-configuration-widget.js +0 -99
  66. package/lib/browser/ai-configuration/variable-configuration-widget.js.map +0 -1
  67. package/lib/browser/ai-ide-activation-service.d.ts +0 -18
  68. package/lib/browser/ai-ide-activation-service.d.ts.map +0 -1
  69. package/lib/browser/ai-ide-activation-service.js +0 -71
  70. package/lib/browser/ai-ide-activation-service.js.map +0 -1
  71. package/lib/browser/ai-terminal-functions.d.ts +0 -13
  72. package/lib/browser/ai-terminal-functions.d.ts.map +0 -1
  73. package/lib/browser/ai-terminal-functions.js +0 -114
  74. package/lib/browser/ai-terminal-functions.js.map +0 -1
  75. package/lib/browser/app-tester-chat-agent.d.ts +0 -35
  76. package/lib/browser/app-tester-chat-agent.d.ts.map +0 -1
  77. package/lib/browser/app-tester-chat-agent.js +0 -142
  78. package/lib/browser/app-tester-chat-agent.js.map +0 -1
  79. package/lib/browser/app-tester-chat-functions.d.ts +0 -25
  80. package/lib/browser/app-tester-chat-functions.d.ts.map +0 -1
  81. package/lib/browser/app-tester-chat-functions.js +0 -170
  82. package/lib/browser/app-tester-chat-functions.js.map +0 -1
  83. package/lib/browser/app-tester-prompt-template.d.ts +0 -6
  84. package/lib/browser/app-tester-prompt-template.d.ts.map +0 -1
  85. package/lib/browser/app-tester-prompt-template.js +0 -83
  86. package/lib/browser/app-tester-prompt-template.js.map +0 -1
  87. package/lib/browser/architect-agent.d.ts +0 -15
  88. package/lib/browser/architect-agent.d.ts.map +0 -1
  89. package/lib/browser/architect-agent.js +0 -68
  90. package/lib/browser/architect-agent.js.map +0 -1
  91. package/lib/browser/coder-agent.d.ts +0 -15
  92. package/lib/browser/coder-agent.d.ts.map +0 -1
  93. package/lib/browser/coder-agent.js +0 -81
  94. package/lib/browser/coder-agent.js.map +0 -1
  95. package/lib/browser/context-functions.d.ts +0 -14
  96. package/lib/browser/context-functions.d.ts.map +0 -1
  97. package/lib/browser/context-functions.js +0 -130
  98. package/lib/browser/context-functions.js.map +0 -1
  99. package/lib/browser/context-functions.spec.d.ts +0 -2
  100. package/lib/browser/context-functions.spec.d.ts.map +0 -1
  101. package/lib/browser/context-functions.spec.js +0 -93
  102. package/lib/browser/context-functions.spec.js.map +0 -1
  103. package/lib/browser/file-changeset-function.spec.d.ts +0 -2
  104. package/lib/browser/file-changeset-function.spec.d.ts.map +0 -1
  105. package/lib/browser/file-changeset-function.spec.js +0 -45
  106. package/lib/browser/file-changeset-function.spec.js.map +0 -1
  107. package/lib/browser/file-changeset-functions.d.ts +0 -87
  108. package/lib/browser/file-changeset-functions.d.ts.map +0 -1
  109. package/lib/browser/file-changeset-functions.js +0 -645
  110. package/lib/browser/file-changeset-functions.js.map +0 -1
  111. package/lib/browser/file-changeset-functions.spec.d.ts +0 -2
  112. package/lib/browser/file-changeset-functions.spec.d.ts.map +0 -1
  113. package/lib/browser/file-changeset-functions.spec.js +0 -179
  114. package/lib/browser/file-changeset-functions.spec.js.map +0 -1
  115. package/lib/browser/frontend-module.d.ts +0 -5
  116. package/lib/browser/frontend-module.d.ts.map +0 -1
  117. package/lib/browser/frontend-module.js +0 -214
  118. package/lib/browser/frontend-module.js.map +0 -1
  119. package/lib/browser/github-chat-agent.d.ts +0 -48
  120. package/lib/browser/github-chat-agent.d.ts.map +0 -1
  121. package/lib/browser/github-chat-agent.js +0 -222
  122. package/lib/browser/github-chat-agent.js.map +0 -1
  123. package/lib/browser/github-prompt-template.d.ts +0 -6
  124. package/lib/browser/github-prompt-template.d.ts.map +0 -1
  125. package/lib/browser/github-prompt-template.js +0 -53
  126. package/lib/browser/github-prompt-template.js.map +0 -1
  127. package/lib/browser/github-repo-variable-contribution.d.ts +0 -15
  128. package/lib/browser/github-repo-variable-contribution.d.ts.map +0 -1
  129. package/lib/browser/github-repo-variable-contribution.js +0 -82
  130. package/lib/browser/github-repo-variable-contribution.js.map +0 -1
  131. package/lib/browser/ide-chat-welcome-message-provider.d.ts +0 -11
  132. package/lib/browser/ide-chat-welcome-message-provider.d.ts.map +0 -1
  133. package/lib/browser/ide-chat-welcome-message-provider.js +0 -142
  134. package/lib/browser/ide-chat-welcome-message-provider.js.map +0 -1
  135. package/lib/browser/project-info-agent.d.ts +0 -13
  136. package/lib/browser/project-info-agent.d.ts.map +0 -1
  137. package/lib/browser/project-info-agent.js +0 -45
  138. package/lib/browser/project-info-agent.js.map +0 -1
  139. package/lib/browser/summarize-session-command-contribution.d.ts +0 -19
  140. package/lib/browser/summarize-session-command-contribution.d.ts.map +0 -1
  141. package/lib/browser/summarize-session-command-contribution.js +0 -118
  142. package/lib/browser/summarize-session-command-contribution.js.map +0 -1
  143. package/lib/browser/task-background-summary-variable.d.ts +0 -9
  144. package/lib/browser/task-background-summary-variable.d.ts.map +0 -1
  145. package/lib/browser/task-background-summary-variable.js +0 -60
  146. package/lib/browser/task-background-summary-variable.js.map +0 -1
  147. package/lib/browser/task-context-agent.d.ts +0 -13
  148. package/lib/browser/task-context-agent.d.ts.map +0 -1
  149. package/lib/browser/task-context-agent.js +0 -45
  150. package/lib/browser/task-context-agent.js.map +0 -1
  151. package/lib/browser/task-context-file-storage-service.d.ts +0 -40
  152. package/lib/browser/task-context-file-storage-service.d.ts.map +0 -1
  153. package/lib/browser/task-context-file-storage-service.js +0 -232
  154. package/lib/browser/task-context-file-storage-service.js.map +0 -1
  155. package/lib/browser/template-preference-contribution.d.ts +0 -17
  156. package/lib/browser/template-preference-contribution.d.ts.map +0 -1
  157. package/lib/browser/template-preference-contribution.js +0 -94
  158. package/lib/browser/template-preference-contribution.js.map +0 -1
  159. package/lib/browser/test/tool-provider-cancellation-test-util.spec.d.ts +0 -2
  160. package/lib/browser/test/tool-provider-cancellation-test-util.spec.d.ts.map +0 -1
  161. package/lib/browser/test/tool-provider-cancellation-test-util.spec.js +0 -52
  162. package/lib/browser/test/tool-provider-cancellation-test-util.spec.js.map +0 -1
  163. package/lib/browser/workspace-functions.d.ts +0 -75
  164. package/lib/browser/workspace-functions.d.ts.map +0 -1
  165. package/lib/browser/workspace-functions.js +0 -641
  166. package/lib/browser/workspace-functions.js.map +0 -1
  167. package/lib/browser/workspace-functions.spec.d.ts +0 -2
  168. package/lib/browser/workspace-functions.spec.d.ts.map +0 -1
  169. package/lib/browser/workspace-functions.spec.js +0 -161
  170. package/lib/browser/workspace-functions.spec.js.map +0 -1
  171. package/lib/browser/workspace-launch-provider.d.ts +0 -24
  172. package/lib/browser/workspace-launch-provider.d.ts.map +0 -1
  173. package/lib/browser/workspace-launch-provider.js +0 -216
  174. package/lib/browser/workspace-launch-provider.js.map +0 -1
  175. package/lib/browser/workspace-launch-provider.spec.d.ts +0 -2
  176. package/lib/browser/workspace-launch-provider.spec.d.ts.map +0 -1
  177. package/lib/browser/workspace-launch-provider.spec.js +0 -245
  178. package/lib/browser/workspace-launch-provider.spec.js.map +0 -1
  179. package/lib/browser/workspace-search-provider.d.ts +0 -15
  180. package/lib/browser/workspace-search-provider.d.ts.map +0 -1
  181. package/lib/browser/workspace-search-provider.js +0 -204
  182. package/lib/browser/workspace-search-provider.js.map +0 -1
  183. package/lib/browser/workspace-search-provider.spec.d.ts +0 -2
  184. package/lib/browser/workspace-search-provider.spec.d.ts.map +0 -1
  185. package/lib/browser/workspace-search-provider.spec.js +0 -82
  186. package/lib/browser/workspace-search-provider.spec.js.map +0 -1
  187. package/lib/browser/workspace-task-provider.d.ts +0 -15
  188. package/lib/browser/workspace-task-provider.d.ts.map +0 -1
  189. package/lib/browser/workspace-task-provider.js +0 -138
  190. package/lib/browser/workspace-task-provider.js.map +0 -1
  191. package/lib/browser/workspace-task-provider.spec.d.ts +0 -2
  192. package/lib/browser/workspace-task-provider.spec.d.ts.map +0 -1
  193. package/lib/browser/workspace-task-provider.spec.js +0 -109
  194. package/lib/browser/workspace-task-provider.spec.js.map +0 -1
  195. package/lib/common/ai-configuration-preferences.d.ts +0 -8
  196. package/lib/common/ai-configuration-preferences.d.ts.map +0 -1
  197. package/lib/common/ai-configuration-preferences.js +0 -41
  198. package/lib/common/ai-configuration-preferences.js.map +0 -1
  199. package/lib/common/ai-ide-preferences.d.ts +0 -5
  200. package/lib/common/ai-ide-preferences.d.ts.map +0 -1
  201. package/lib/common/ai-ide-preferences.js +0 -53
  202. package/lib/common/ai-ide-preferences.js.map +0 -1
  203. package/lib/common/ai-terminal-functions.d.ts +0 -2
  204. package/lib/common/ai-terminal-functions.d.ts.map +0 -1
  205. package/lib/common/ai-terminal-functions.js +0 -20
  206. package/lib/common/ai-terminal-functions.js.map +0 -1
  207. package/lib/common/app-tester-chat-functions.d.ts +0 -5
  208. package/lib/common/app-tester-chat-functions.d.ts.map +0 -1
  209. package/lib/common/app-tester-chat-functions.js +0 -23
  210. package/lib/common/app-tester-chat-functions.js.map +0 -1
  211. package/lib/common/architect-prompt-template.d.ts +0 -3
  212. package/lib/common/architect-prompt-template.d.ts.map +0 -1
  213. package/lib/common/architect-prompt-template.js +0 -81
  214. package/lib/common/architect-prompt-template.js.map +0 -1
  215. package/lib/common/browser-automation-protocol.d.ts +0 -15
  216. package/lib/common/browser-automation-protocol.d.ts.map +0 -1
  217. package/lib/common/browser-automation-protocol.js +0 -22
  218. package/lib/common/browser-automation-protocol.js.map +0 -1
  219. package/lib/common/coder-replace-prompt-template.d.ts +0 -11
  220. package/lib/common/coder-replace-prompt-template.d.ts.map +0 -1
  221. package/lib/common/coder-replace-prompt-template.js +0 -295
  222. package/lib/common/coder-replace-prompt-template.js.map +0 -1
  223. package/lib/common/command-chat-agents.d.ts +0 -36
  224. package/lib/common/command-chat-agents.d.ts.map +0 -1
  225. package/lib/common/command-chat-agents.js +0 -122
  226. package/lib/common/command-chat-agents.js.map +0 -1
  227. package/lib/common/command-prompt-template.d.ts +0 -3
  228. package/lib/common/command-prompt-template.d.ts.map +0 -1
  229. package/lib/common/command-prompt-template.js +0 -226
  230. package/lib/common/command-prompt-template.js.map +0 -1
  231. package/lib/common/context-files-variable.d.ts +0 -9
  232. package/lib/common/context-files-variable.d.ts.map +0 -1
  233. package/lib/common/context-files-variable.js +0 -52
  234. package/lib/common/context-files-variable.js.map +0 -1
  235. package/lib/common/context-functions.d.ts +0 -4
  236. package/lib/common/context-functions.d.ts.map +0 -1
  237. package/lib/common/context-functions.js +0 -22
  238. package/lib/common/context-functions.js.map +0 -1
  239. package/lib/common/context-variables.d.ts +0 -3
  240. package/lib/common/context-variables.d.ts.map +0 -1
  241. package/lib/common/context-variables.js +0 -21
  242. package/lib/common/context-variables.js.map +0 -1
  243. package/lib/common/file-changeset-function-ids.d.ts +0 -8
  244. package/lib/common/file-changeset-function-ids.d.ts.map +0 -1
  245. package/lib/common/file-changeset-function-ids.js +0 -26
  246. package/lib/common/file-changeset-function-ids.js.map +0 -1
  247. package/lib/common/github-repo-protocol.d.ts +0 -15
  248. package/lib/common/github-repo-protocol.d.ts.map +0 -1
  249. package/lib/common/github-repo-protocol.js +0 -21
  250. package/lib/common/github-repo-protocol.js.map +0 -1
  251. package/lib/common/orchestrator-chat-agent.d.ts +0 -36
  252. package/lib/common/orchestrator-chat-agent.d.ts.map +0 -1
  253. package/lib/common/orchestrator-chat-agent.js +0 -167
  254. package/lib/common/orchestrator-chat-agent.js.map +0 -1
  255. package/lib/common/orchestrator-prompt-template.d.ts +0 -3
  256. package/lib/common/orchestrator-prompt-template.d.ts.map +0 -1
  257. package/lib/common/orchestrator-prompt-template.js +0 -55
  258. package/lib/common/orchestrator-prompt-template.js.map +0 -1
  259. package/lib/common/project-info-prompt-template.d.ts +0 -6
  260. package/lib/common/project-info-prompt-template.d.ts.map +0 -1
  261. package/lib/common/project-info-prompt-template.js +0 -145
  262. package/lib/common/project-info-prompt-template.js.map +0 -1
  263. package/lib/common/summarize-session-commands.d.ts +0 -4
  264. package/lib/common/summarize-session-commands.d.ts.map +0 -1
  265. package/lib/common/summarize-session-commands.js +0 -28
  266. package/lib/common/summarize-session-commands.js.map +0 -1
  267. package/lib/common/task-context-prompt-template.d.ts +0 -8
  268. package/lib/common/task-context-prompt-template.d.ts.map +0 -1
  269. package/lib/common/task-context-prompt-template.js +0 -217
  270. package/lib/common/task-context-prompt-template.js.map +0 -1
  271. package/lib/common/universal-chat-agent.d.ts +0 -17
  272. package/lib/common/universal-chat-agent.d.ts.map +0 -1
  273. package/lib/common/universal-chat-agent.js +0 -47
  274. package/lib/common/universal-chat-agent.js.map +0 -1
  275. package/lib/common/universal-prompt-template.d.ts +0 -4
  276. package/lib/common/universal-prompt-template.d.ts.map +0 -1
  277. package/lib/common/universal-prompt-template.js +0 -32
  278. package/lib/common/universal-prompt-template.js.map +0 -1
  279. package/lib/common/workspace-functions.d.ts +0 -12
  280. package/lib/common/workspace-functions.d.ts.map +0 -1
  281. package/lib/common/workspace-functions.js +0 -30
  282. package/lib/common/workspace-functions.js.map +0 -1
  283. package/lib/common/workspace-preferences.d.ts +0 -10
  284. package/lib/common/workspace-preferences.d.ts.map +0 -1
  285. package/lib/common/workspace-preferences.js +0 -89
  286. package/lib/common/workspace-preferences.js.map +0 -1
  287. package/lib/common/workspace-search-provider-util.d.ts +0 -17
  288. package/lib/common/workspace-search-provider-util.d.ts.map +0 -1
  289. package/lib/common/workspace-search-provider-util.js +0 -51
  290. package/lib/common/workspace-search-provider-util.js.map +0 -1
  291. package/lib/node/app-tester-agent/browser-automation-impl.d.ts +0 -18
  292. package/lib/node/app-tester-agent/browser-automation-impl.d.ts.map +0 -1
  293. package/lib/node/app-tester-agent/browser-automation-impl.js +0 -96
  294. package/lib/node/app-tester-agent/browser-automation-impl.js.map +0 -1
  295. package/lib/node/backend-module.d.ts +0 -4
  296. package/lib/node/backend-module.d.ts.map +0 -1
  297. package/lib/node/backend-module.js +0 -45
  298. package/lib/node/backend-module.js.map +0 -1
  299. package/lib/node/github-repo-service-impl.d.ts +0 -7
  300. package/lib/node/github-repo-service-impl.d.ts.map +0 -1
  301. package/lib/node/github-repo-service-impl.js +0 -86
  302. package/lib/node/github-repo-service-impl.js.map +0 -1
  303. package/lib/package.spec.d.ts +0 -1
  304. package/lib/package.spec.d.ts.map +0 -1
  305. package/lib/package.spec.js +0 -26
  306. package/lib/package.spec.js.map +0 -1
@@ -1,641 +0,0 @@
1
- "use strict";
2
- var GetWorkspaceDirectoryStructure_1, FileContentFunction_1, GetWorkspaceFileList_1, FileDiagnosticProvider_1, FindFilesByPattern_1;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.FindFilesByPattern = exports.FileDiagnosticProvider = exports.GetWorkspaceFileList = exports.FileContentFunction = exports.GetWorkspaceDirectoryStructure = exports.WorkspaceFunctionScope = void 0;
5
- const tslib_1 = require("tslib");
6
- const core_1 = require("@theia/core");
7
- const inversify_1 = require("@theia/core/shared/inversify");
8
- const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
9
- const browser_1 = require("@theia/workspace/lib/browser");
10
- const workspace_functions_1 = require("../common/workspace-functions");
11
- const ignore_1 = require("ignore");
12
- const minimatch_1 = require("minimatch");
13
- const browser_2 = require("@theia/core/lib/browser");
14
- const workspace_preferences_1 = require("../common/workspace-preferences");
15
- const monaco_workspace_1 = require("@theia/monaco/lib/browser/monaco-workspace");
16
- const monaco_text_model_service_1 = require("@theia/monaco/lib/browser/monaco-text-model-service");
17
- const browser_3 = require("@theia/markers/lib/browser");
18
- const vscode_languageserver_protocol_1 = require("@theia/core/shared/vscode-languageserver-protocol");
19
- let WorkspaceFunctionScope = class WorkspaceFunctionScope {
20
- constructor() {
21
- this.GITIGNORE_FILE_NAME = '.gitignore';
22
- this.gitignoreWatcherInitialized = false;
23
- }
24
- async getWorkspaceRoot() {
25
- const wsRoots = await this.workspaceService.roots;
26
- if (wsRoots.length === 0) {
27
- throw new Error('No workspace has been opened yet');
28
- }
29
- return wsRoots[0].resource;
30
- }
31
- ensureWithinWorkspace(targetUri, workspaceRootUri) {
32
- if (!targetUri.toString().startsWith(workspaceRootUri.toString())) {
33
- throw new Error('Access outside of the workspace is not allowed');
34
- }
35
- }
36
- async resolveRelativePath(relativePath) {
37
- const workspaceRoot = await this.getWorkspaceRoot();
38
- return workspaceRoot.resolve(relativePath);
39
- }
40
- async initializeGitignoreWatcher(workspaceRoot) {
41
- if (this.gitignoreWatcherInitialized) {
42
- return;
43
- }
44
- const gitignoreUri = workspaceRoot.resolve(this.GITIGNORE_FILE_NAME);
45
- this.fileService.watch(gitignoreUri);
46
- this.fileService.onDidFilesChange(async (event) => {
47
- if (event.contains(gitignoreUri)) {
48
- this.gitignoreMatcher = undefined;
49
- }
50
- });
51
- this.gitignoreWatcherInitialized = true;
52
- }
53
- async shouldExclude(stat) {
54
- const shouldConsiderGitIgnore = this.preferences.get(workspace_preferences_1.CONSIDER_GITIGNORE_PREF, false);
55
- const userExcludePatterns = this.preferences.get(workspace_preferences_1.USER_EXCLUDE_PATTERN_PREF, []);
56
- if (this.isUserExcluded(stat.resource.path.base, userExcludePatterns)) {
57
- return true;
58
- }
59
- const workspaceRoot = await this.getWorkspaceRoot();
60
- if (shouldConsiderGitIgnore && (await this.isGitIgnored(stat, workspaceRoot))) {
61
- return true;
62
- }
63
- return false;
64
- }
65
- isUserExcluded(fileName, userExcludePatterns) {
66
- return userExcludePatterns.some(pattern => new minimatch_1.Minimatch(pattern, { dot: true }).match(fileName));
67
- }
68
- async isGitIgnored(stat, workspaceRoot) {
69
- await this.initializeGitignoreWatcher(workspaceRoot);
70
- const gitignoreUri = workspaceRoot.resolve(this.GITIGNORE_FILE_NAME);
71
- try {
72
- const fileStat = await this.fileService.resolve(gitignoreUri);
73
- if (fileStat) {
74
- if (!this.gitignoreMatcher) {
75
- const gitignoreContent = await this.fileService.read(gitignoreUri);
76
- this.gitignoreMatcher = (0, ignore_1.default)().add(gitignoreContent.value);
77
- }
78
- const relativePath = workspaceRoot.relative(stat.resource);
79
- if (relativePath) {
80
- const relativePathStr = relativePath.toString() + (stat.isDirectory ? '/' : '');
81
- if (this.gitignoreMatcher.ignores(relativePathStr)) {
82
- return true;
83
- }
84
- }
85
- }
86
- }
87
- catch {
88
- // If .gitignore does not exist or cannot be read, continue without error
89
- }
90
- return false;
91
- }
92
- };
93
- exports.WorkspaceFunctionScope = WorkspaceFunctionScope;
94
- tslib_1.__decorate([
95
- (0, inversify_1.inject)(browser_1.WorkspaceService),
96
- tslib_1.__metadata("design:type", browser_1.WorkspaceService)
97
- ], WorkspaceFunctionScope.prototype, "workspaceService", void 0);
98
- tslib_1.__decorate([
99
- (0, inversify_1.inject)(file_service_1.FileService),
100
- tslib_1.__metadata("design:type", file_service_1.FileService)
101
- ], WorkspaceFunctionScope.prototype, "fileService", void 0);
102
- tslib_1.__decorate([
103
- (0, inversify_1.inject)(core_1.PreferenceService),
104
- tslib_1.__metadata("design:type", Object)
105
- ], WorkspaceFunctionScope.prototype, "preferences", void 0);
106
- exports.WorkspaceFunctionScope = WorkspaceFunctionScope = tslib_1.__decorate([
107
- (0, inversify_1.injectable)()
108
- ], WorkspaceFunctionScope);
109
- let GetWorkspaceDirectoryStructure = GetWorkspaceDirectoryStructure_1 = class GetWorkspaceDirectoryStructure {
110
- getTool() {
111
- return {
112
- id: GetWorkspaceDirectoryStructure_1.ID,
113
- name: GetWorkspaceDirectoryStructure_1.ID,
114
- description: 'Retrieve the complete directory structure of the workspace, listing only directories (no file contents). ' +
115
- 'This structure excludes specific directories, such as node_modules and hidden files, ensuring paths are within workspace boundaries.',
116
- parameters: {
117
- type: 'object',
118
- properties: {},
119
- },
120
- handler: (_, ctx) => {
121
- const cancellationToken = ctx.response.cancellationToken;
122
- return this.getDirectoryStructure(cancellationToken);
123
- },
124
- };
125
- }
126
- async getDirectoryStructure(cancellationToken) {
127
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
128
- return { error: 'Operation cancelled by user' };
129
- }
130
- let workspaceRoot;
131
- try {
132
- workspaceRoot = await this.workspaceScope.getWorkspaceRoot();
133
- }
134
- catch (error) {
135
- return { error: error.message };
136
- }
137
- return this.buildDirectoryStructure(workspaceRoot, cancellationToken);
138
- }
139
- async buildDirectoryStructure(uri, cancellationToken) {
140
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
141
- return { error: 'Operation cancelled by user' };
142
- }
143
- const stat = await this.fileService.resolve(uri);
144
- const result = {};
145
- if (stat && stat.isDirectory && stat.children) {
146
- for (const child of stat.children) {
147
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
148
- return { error: 'Operation cancelled by user' };
149
- }
150
- if (!child.isDirectory || (await this.workspaceScope.shouldExclude(child))) {
151
- continue;
152
- }
153
- const dirName = child.resource.path.base;
154
- result[dirName] = await this.buildDirectoryStructure(child.resource, cancellationToken);
155
- }
156
- }
157
- return result;
158
- }
159
- };
160
- exports.GetWorkspaceDirectoryStructure = GetWorkspaceDirectoryStructure;
161
- GetWorkspaceDirectoryStructure.ID = workspace_functions_1.GET_WORKSPACE_DIRECTORY_STRUCTURE_FUNCTION_ID;
162
- tslib_1.__decorate([
163
- (0, inversify_1.inject)(file_service_1.FileService),
164
- tslib_1.__metadata("design:type", file_service_1.FileService)
165
- ], GetWorkspaceDirectoryStructure.prototype, "fileService", void 0);
166
- tslib_1.__decorate([
167
- (0, inversify_1.inject)(WorkspaceFunctionScope),
168
- tslib_1.__metadata("design:type", WorkspaceFunctionScope)
169
- ], GetWorkspaceDirectoryStructure.prototype, "workspaceScope", void 0);
170
- exports.GetWorkspaceDirectoryStructure = GetWorkspaceDirectoryStructure = GetWorkspaceDirectoryStructure_1 = tslib_1.__decorate([
171
- (0, inversify_1.injectable)()
172
- ], GetWorkspaceDirectoryStructure);
173
- let FileContentFunction = FileContentFunction_1 = class FileContentFunction {
174
- getTool() {
175
- return {
176
- id: FileContentFunction_1.ID,
177
- name: FileContentFunction_1.ID,
178
- description: 'Return the content of a specified file within the workspace. ' +
179
- 'The file path must be provided relative to the workspace root. Only files within ' +
180
- 'workspace boundaries are accessible; attempting to access files outside the workspace will return an error.',
181
- parameters: {
182
- type: 'object',
183
- properties: {
184
- file: {
185
- type: 'string',
186
- description: 'The relative path to the target file within the workspace. ' +
187
- 'This path is resolved from the workspace root, and only files within the workspace ' +
188
- 'boundaries are accessible. Attempting to access paths outside the workspace will result in an error.',
189
- }
190
- },
191
- required: ['file']
192
- },
193
- handler: (arg_string, ctx) => {
194
- const file = this.parseArg(arg_string);
195
- const cancellationToken = ctx.response.cancellationToken;
196
- return this.getFileContent(file, cancellationToken);
197
- },
198
- };
199
- }
200
- parseArg(arg_string) {
201
- const result = JSON.parse(arg_string);
202
- return result.file;
203
- }
204
- async getFileContent(file, cancellationToken) {
205
- var _a;
206
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
207
- return JSON.stringify({ error: 'Operation cancelled by user' });
208
- }
209
- let targetUri;
210
- try {
211
- const workspaceRoot = await this.workspaceScope.getWorkspaceRoot();
212
- targetUri = workspaceRoot.resolve(file);
213
- this.workspaceScope.ensureWithinWorkspace(targetUri, workspaceRoot);
214
- }
215
- catch (error) {
216
- return JSON.stringify({ error: error.message });
217
- }
218
- try {
219
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
220
- return JSON.stringify({ error: 'Operation cancelled by user' });
221
- }
222
- const openEditorValue = (_a = this.monacoWorkspace.getTextDocument(targetUri.toString())) === null || _a === void 0 ? void 0 : _a.getText();
223
- if (openEditorValue !== undefined) {
224
- return openEditorValue;
225
- }
226
- const fileContent = await this.fileService.read(targetUri);
227
- return fileContent.value;
228
- }
229
- catch (error) {
230
- return JSON.stringify({ error: 'File not found' });
231
- }
232
- }
233
- };
234
- exports.FileContentFunction = FileContentFunction;
235
- FileContentFunction.ID = workspace_functions_1.FILE_CONTENT_FUNCTION_ID;
236
- tslib_1.__decorate([
237
- (0, inversify_1.inject)(file_service_1.FileService),
238
- tslib_1.__metadata("design:type", file_service_1.FileService)
239
- ], FileContentFunction.prototype, "fileService", void 0);
240
- tslib_1.__decorate([
241
- (0, inversify_1.inject)(WorkspaceFunctionScope),
242
- tslib_1.__metadata("design:type", WorkspaceFunctionScope)
243
- ], FileContentFunction.prototype, "workspaceScope", void 0);
244
- tslib_1.__decorate([
245
- (0, inversify_1.inject)(monaco_workspace_1.MonacoWorkspace),
246
- tslib_1.__metadata("design:type", monaco_workspace_1.MonacoWorkspace)
247
- ], FileContentFunction.prototype, "monacoWorkspace", void 0);
248
- exports.FileContentFunction = FileContentFunction = FileContentFunction_1 = tslib_1.__decorate([
249
- (0, inversify_1.injectable)()
250
- ], FileContentFunction);
251
- let GetWorkspaceFileList = GetWorkspaceFileList_1 = class GetWorkspaceFileList {
252
- getTool() {
253
- return {
254
- id: GetWorkspaceFileList_1.ID,
255
- name: GetWorkspaceFileList_1.ID,
256
- parameters: {
257
- type: 'object',
258
- properties: {
259
- path: {
260
- type: 'string',
261
- description: 'Optional relative path to a directory within the workspace. ' +
262
- 'If no path is specified, the function lists contents directly in the workspace root. ' +
263
- 'Paths are resolved within workspace boundaries only; paths outside the workspace or unvalidated paths will result in an error.'
264
- }
265
- },
266
- required: ['path']
267
- },
268
- description: 'List files and directories within a specified workspace directory. ' +
269
- 'Paths are relative to the workspace root, and only workspace-contained paths are allowed. ' +
270
- 'If no path is provided, the root contents are listed. Paths outside the workspace will result in an error.',
271
- handler: (arg_string, ctx) => {
272
- const args = JSON.parse(arg_string);
273
- const cancellationToken = ctx.response.cancellationToken;
274
- return this.getProjectFileList(args.path, cancellationToken);
275
- },
276
- };
277
- }
278
- async getProjectFileList(path, cancellationToken) {
279
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
280
- return JSON.stringify({ error: 'Operation cancelled by user' });
281
- }
282
- let workspaceRoot;
283
- try {
284
- workspaceRoot = await this.workspaceScope.getWorkspaceRoot();
285
- }
286
- catch (error) {
287
- return JSON.stringify({ error: error.message });
288
- }
289
- const targetUri = path ? workspaceRoot.resolve(path) : workspaceRoot;
290
- this.workspaceScope.ensureWithinWorkspace(targetUri, workspaceRoot);
291
- try {
292
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
293
- return JSON.stringify({ error: 'Operation cancelled by user' });
294
- }
295
- const stat = await this.fileService.resolve(targetUri);
296
- if (!stat || !stat.isDirectory) {
297
- return JSON.stringify({ error: 'Directory not found' });
298
- }
299
- return await this.listFilesDirectly(targetUri, workspaceRoot, cancellationToken);
300
- }
301
- catch (error) {
302
- return JSON.stringify({ error: 'Directory not found' });
303
- }
304
- }
305
- async listFilesDirectly(uri, workspaceRootUri, cancellationToken) {
306
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
307
- return JSON.stringify({ error: 'Operation cancelled by user' });
308
- }
309
- const stat = await this.fileService.resolve(uri);
310
- const result = [];
311
- if (stat && stat.isDirectory) {
312
- if (await this.workspaceScope.shouldExclude(stat)) {
313
- return result;
314
- }
315
- const children = await this.fileService.resolve(uri);
316
- if (children.children) {
317
- for (const child of children.children) {
318
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
319
- return JSON.stringify({ error: 'Operation cancelled by user' });
320
- }
321
- if (await this.workspaceScope.shouldExclude(child)) {
322
- continue;
323
- }
324
- const itemName = child.resource.path.base;
325
- result.push(child.isDirectory ? `${itemName}/` : itemName);
326
- }
327
- }
328
- }
329
- return result;
330
- }
331
- };
332
- exports.GetWorkspaceFileList = GetWorkspaceFileList;
333
- GetWorkspaceFileList.ID = workspace_functions_1.GET_WORKSPACE_FILE_LIST_FUNCTION_ID;
334
- tslib_1.__decorate([
335
- (0, inversify_1.inject)(file_service_1.FileService),
336
- tslib_1.__metadata("design:type", file_service_1.FileService)
337
- ], GetWorkspaceFileList.prototype, "fileService", void 0);
338
- tslib_1.__decorate([
339
- (0, inversify_1.inject)(WorkspaceFunctionScope),
340
- tslib_1.__metadata("design:type", WorkspaceFunctionScope)
341
- ], GetWorkspaceFileList.prototype, "workspaceScope", void 0);
342
- exports.GetWorkspaceFileList = GetWorkspaceFileList = GetWorkspaceFileList_1 = tslib_1.__decorate([
343
- (0, inversify_1.injectable)()
344
- ], GetWorkspaceFileList);
345
- let FileDiagnosticProvider = FileDiagnosticProvider_1 = class FileDiagnosticProvider {
346
- getTool() {
347
- return {
348
- id: FileDiagnosticProvider_1.ID,
349
- name: FileDiagnosticProvider_1.ID,
350
- description: 'A function to retrieve diagnostics associated with a specific file in the workspace. ' +
351
- 'It will return a list of problems that includes the surrounding text a message describing the problem, ' +
352
- 'and optionally a code and a codeDescription field describing that code.',
353
- parameters: {
354
- type: 'object',
355
- properties: {
356
- file: {
357
- type: 'string',
358
- description: 'The relative path to the target file within the workspace. ' +
359
- 'This path is resolved from the workspace root, and only files within the workspace ' +
360
- 'boundaries are accessible. Attempting to access paths outside the workspace will result in an error.'
361
- }
362
- },
363
- required: ['file']
364
- },
365
- handler: async (arg, ctx) => {
366
- try {
367
- const { file } = JSON.parse(arg);
368
- const workspaceRoot = await this.workspaceScope.getWorkspaceRoot();
369
- const targetUri = workspaceRoot.resolve(file);
370
- this.workspaceScope.ensureWithinWorkspace(targetUri, workspaceRoot);
371
- // Safely extract cancellation token with type checks
372
- const cancellationToken = ctx.response.cancellationToken;
373
- return this.getDiagnosticsForFile(targetUri, cancellationToken);
374
- }
375
- catch (error) {
376
- return JSON.stringify({ error: error instanceof Error ? error.message : 'Unknown error.' });
377
- }
378
- }
379
- };
380
- }
381
- async getDiagnosticsForFile(uri, cancellationToken) {
382
- const toDispose = [];
383
- try {
384
- // Check for early cancellation
385
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
386
- return JSON.stringify({ error: 'Operation cancelled by user' });
387
- }
388
- let markers = this.problemManager.findMarkers({ uri });
389
- if (markers.length === 0) {
390
- // Open editor to ensure that the language services are active.
391
- await (0, browser_2.open)(this.openerService, uri);
392
- // Give some time to fetch problems in a newly opened editor.
393
- await new Promise((res, rej) => {
394
- const timeout = setTimeout(res, 5000);
395
- // Give another moment for additional markers to come in from different sources.
396
- const listener = this.problemManager.onDidChangeMarkers(changed => changed.isEqual(uri) && setTimeout(res, 500));
397
- toDispose.push(listener);
398
- // Handle cancellation
399
- if (cancellationToken) {
400
- const cancelListener = cancellationToken.onCancellationRequested(() => {
401
- clearTimeout(timeout);
402
- listener.dispose();
403
- rej(new Error('Operation cancelled by user'));
404
- });
405
- toDispose.push(cancelListener);
406
- }
407
- });
408
- markers = this.problemManager.findMarkers({ uri });
409
- }
410
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
411
- return JSON.stringify({ error: 'Operation cancelled by user' });
412
- }
413
- if (markers.length) {
414
- const editor = await this.modelService.createModelReference(uri);
415
- toDispose.push(editor);
416
- return JSON.stringify(markers.filter(marker => marker.data.severity !== vscode_languageserver_protocol_1.DiagnosticSeverity.Information && marker.data.severity !== vscode_languageserver_protocol_1.DiagnosticSeverity.Hint)
417
- .map(marker => {
418
- const contextRange = this.atLeastNLines(3, marker.data.range, editor.object.lineCount);
419
- const text = editor.object.getText(contextRange);
420
- const message = marker.data.message;
421
- const code = marker.data.code;
422
- const codeDescription = marker.data.codeDescription;
423
- return { text, message, code, codeDescription };
424
- }));
425
- }
426
- return JSON.stringify({
427
- error: 'No diagnostics were found. The file may contain no problems, or language services may not be available. Retrying may return fresh results.'
428
- });
429
- }
430
- catch (err) {
431
- if (err.message === 'Operation cancelled by user') {
432
- return JSON.stringify({ error: 'Operation cancelled by user' });
433
- }
434
- console.warn('Error when fetching markers for', uri.toString(), err);
435
- return JSON.stringify({ error: err instanceof Error ? err.message : 'Unknown error when fetching for problems for ' + uri.toString() });
436
- }
437
- finally {
438
- toDispose.forEach(disposable => disposable.dispose());
439
- }
440
- }
441
- /**
442
- * Expands the range provided until it contains at least {@link desiredLines} lines or reaches the end of the document
443
- * to attempt to provide the agent sufficient context to understand the diagnostic.
444
- */
445
- atLeastNLines(desiredLines, range, documentLineCount) {
446
- let startLine = range.start.line;
447
- let endLine = range.end.line;
448
- const desiredDifference = desiredLines - 1;
449
- while (endLine - startLine < desiredDifference && (startLine > 0 || endLine < documentLineCount - 1)) {
450
- if (startLine > 0) {
451
- startLine--;
452
- }
453
- else if (endLine < documentLineCount - 1) {
454
- endLine++;
455
- }
456
- if (endLine < documentLineCount - 1) {
457
- endLine++;
458
- }
459
- else if (startLine > 0) {
460
- startLine--;
461
- }
462
- }
463
- return { end: { character: Number.MAX_SAFE_INTEGER, line: endLine }, start: { character: 0, line: startLine } };
464
- }
465
- };
466
- exports.FileDiagnosticProvider = FileDiagnosticProvider;
467
- FileDiagnosticProvider.ID = workspace_functions_1.GET_FILE_DIAGNOSTICS_ID;
468
- tslib_1.__decorate([
469
- (0, inversify_1.inject)(WorkspaceFunctionScope),
470
- tslib_1.__metadata("design:type", WorkspaceFunctionScope)
471
- ], FileDiagnosticProvider.prototype, "workspaceScope", void 0);
472
- tslib_1.__decorate([
473
- (0, inversify_1.inject)(browser_3.ProblemManager),
474
- tslib_1.__metadata("design:type", browser_3.ProblemManager)
475
- ], FileDiagnosticProvider.prototype, "problemManager", void 0);
476
- tslib_1.__decorate([
477
- (0, inversify_1.inject)(monaco_text_model_service_1.MonacoTextModelService),
478
- tslib_1.__metadata("design:type", monaco_text_model_service_1.MonacoTextModelService)
479
- ], FileDiagnosticProvider.prototype, "modelService", void 0);
480
- tslib_1.__decorate([
481
- (0, inversify_1.inject)(browser_2.OpenerService),
482
- tslib_1.__metadata("design:type", Object)
483
- ], FileDiagnosticProvider.prototype, "openerService", void 0);
484
- exports.FileDiagnosticProvider = FileDiagnosticProvider = FileDiagnosticProvider_1 = tslib_1.__decorate([
485
- (0, inversify_1.injectable)()
486
- ], FileDiagnosticProvider);
487
- let FindFilesByPattern = FindFilesByPattern_1 = class FindFilesByPattern {
488
- getTool() {
489
- return {
490
- id: FindFilesByPattern_1.ID,
491
- name: FindFilesByPattern_1.ID,
492
- description: 'Find files in the workspace that match a given glob pattern. ' +
493
- 'This function allows efficient discovery of files using patterns like \'**/*.ts\' for all TypeScript files or ' +
494
- '\'src/**/*.js\' for JavaScript files in the src directory. The function respects gitignore patterns and user exclusions, ' +
495
- 'returns relative paths from the workspace root, and limits results to 200 files maximum.',
496
- parameters: {
497
- type: 'object',
498
- properties: {
499
- pattern: {
500
- type: 'string',
501
- description: 'Glob pattern to match files against. ' +
502
- 'Examples: \'**/*.ts\' (all TypeScript files), \'src/**/*.js\' (JS files in src), ' +
503
- '\'**/*.{js,ts}\' (JS or TS files), \'**/test/**\' (files in test directories). ' +
504
- 'Patterns are matched against paths relative to the workspace root.'
505
- },
506
- exclude: {
507
- type: 'array',
508
- items: { type: 'string' },
509
- description: 'Optional array of glob patterns to exclude from results. ' +
510
- 'Examples: [\'**/*.spec.ts\', \'**/*.test.js\', \'node_modules/**\']. ' +
511
- 'If not specified, common exclusions like node_modules, .git, and dist are applied automatically.'
512
- }
513
- },
514
- required: ['pattern']
515
- },
516
- handler: (arg_string, ctx) => {
517
- const args = JSON.parse(arg_string);
518
- const cancellationToken = ctx.response.cancellationToken;
519
- return this.findFiles(args.pattern, args.exclude, cancellationToken);
520
- },
521
- };
522
- }
523
- async findFiles(pattern, excludePatterns, cancellationToken) {
524
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
525
- return JSON.stringify({ error: 'Operation cancelled by user' });
526
- }
527
- let workspaceRoot;
528
- try {
529
- workspaceRoot = await this.workspaceScope.getWorkspaceRoot();
530
- }
531
- catch (error) {
532
- return JSON.stringify({ error: error.message });
533
- }
534
- try {
535
- // Build ignore patterns from gitignore and user preferences
536
- const ignorePatterns = await this.buildIgnorePatterns(workspaceRoot);
537
- const allExcludes = [...ignorePatterns];
538
- if (excludePatterns && excludePatterns.length > 0) {
539
- allExcludes.push(...excludePatterns);
540
- }
541
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
542
- return JSON.stringify({ error: 'Operation cancelled by user' });
543
- }
544
- const patternMatcher = new minimatch_1.Minimatch(pattern, { dot: false });
545
- const excludeMatchers = allExcludes.map(excludePattern => new minimatch_1.Minimatch(excludePattern, { dot: true }));
546
- const files = [];
547
- const maxResults = 200;
548
- await this.traverseDirectory(workspaceRoot, workspaceRoot, patternMatcher, excludeMatchers, files, maxResults, cancellationToken);
549
- if (cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) {
550
- return JSON.stringify({ error: 'Operation cancelled by user' });
551
- }
552
- const result = {
553
- files: files.slice(0, maxResults)
554
- };
555
- if (files.length > maxResults) {
556
- result.totalFound = files.length;
557
- result.truncated = true;
558
- }
559
- return JSON.stringify(result);
560
- }
561
- catch (error) {
562
- return JSON.stringify({ error: `Failed to find files: ${error.message}` });
563
- }
564
- }
565
- async buildIgnorePatterns(workspaceRoot) {
566
- const patterns = [];
567
- // Get user exclude patterns from preferences
568
- const userExcludePatterns = this.preferences.get(workspace_preferences_1.USER_EXCLUDE_PATTERN_PREF, []);
569
- patterns.push(...userExcludePatterns);
570
- // Add gitignore patterns if enabled
571
- const shouldConsiderGitIgnore = this.preferences.get(workspace_preferences_1.CONSIDER_GITIGNORE_PREF, false);
572
- if (shouldConsiderGitIgnore) {
573
- try {
574
- const gitignoreUri = workspaceRoot.resolve('.gitignore');
575
- const gitignoreContent = await this.fileService.read(gitignoreUri);
576
- const gitignoreLines = gitignoreContent.value
577
- .split('\n')
578
- .map(line => line.trim())
579
- .filter(line => line && !line.startsWith('#'));
580
- patterns.push(...gitignoreLines);
581
- }
582
- catch {
583
- // Gitignore file doesn't exist or can't be read, continue without it
584
- }
585
- }
586
- return patterns;
587
- }
588
- async traverseDirectory(currentUri, workspaceRoot, patternMatcher, excludeMatchers, results, maxResults, cancellationToken) {
589
- var _a;
590
- if ((cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) || results.length >= maxResults) {
591
- return;
592
- }
593
- try {
594
- const stat = await this.fileService.resolve(currentUri);
595
- if (!stat || !stat.isDirectory || !stat.children) {
596
- return;
597
- }
598
- for (const child of stat.children) {
599
- if ((cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.isCancellationRequested) || results.length >= maxResults) {
600
- break;
601
- }
602
- const relativePath = (_a = workspaceRoot.relative(child.resource)) === null || _a === void 0 ? void 0 : _a.toString();
603
- if (!relativePath) {
604
- continue;
605
- }
606
- const shouldExclude = excludeMatchers.some(matcher => matcher.match(relativePath)) ||
607
- (await this.workspaceScope.shouldExclude(child));
608
- if (shouldExclude) {
609
- continue;
610
- }
611
- if (child.isDirectory) {
612
- await this.traverseDirectory(child.resource, workspaceRoot, patternMatcher, excludeMatchers, results, maxResults, cancellationToken);
613
- }
614
- else if (patternMatcher.match(relativePath)) {
615
- results.push(relativePath);
616
- }
617
- }
618
- }
619
- catch {
620
- // If we can't access a directory, skip it
621
- }
622
- }
623
- };
624
- exports.FindFilesByPattern = FindFilesByPattern;
625
- FindFilesByPattern.ID = workspace_functions_1.FIND_FILES_BY_PATTERN_FUNCTION_ID;
626
- tslib_1.__decorate([
627
- (0, inversify_1.inject)(WorkspaceFunctionScope),
628
- tslib_1.__metadata("design:type", WorkspaceFunctionScope)
629
- ], FindFilesByPattern.prototype, "workspaceScope", void 0);
630
- tslib_1.__decorate([
631
- (0, inversify_1.inject)(core_1.PreferenceService),
632
- tslib_1.__metadata("design:type", Object)
633
- ], FindFilesByPattern.prototype, "preferences", void 0);
634
- tslib_1.__decorate([
635
- (0, inversify_1.inject)(file_service_1.FileService),
636
- tslib_1.__metadata("design:type", file_service_1.FileService)
637
- ], FindFilesByPattern.prototype, "fileService", void 0);
638
- exports.FindFilesByPattern = FindFilesByPattern = FindFilesByPattern_1 = tslib_1.__decorate([
639
- (0, inversify_1.injectable)()
640
- ], FindFilesByPattern);
641
- //# sourceMappingURL=workspace-functions.js.map