@j0hanz/filesystem-context-mcp 1.2.6 → 1.2.7

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 (270) hide show
  1. package/dist/__tests__/lib/errors-classify.test.d.ts +2 -0
  2. package/dist/__tests__/lib/errors-classify.test.d.ts.map +1 -0
  3. package/dist/__tests__/lib/errors-classify.test.js +53 -0
  4. package/dist/__tests__/lib/errors-classify.test.js.map +1 -0
  5. package/dist/__tests__/lib/errors-detailed.test.d.ts +2 -0
  6. package/dist/__tests__/lib/errors-detailed.test.d.ts.map +1 -0
  7. package/dist/__tests__/lib/errors-detailed.test.js +38 -0
  8. package/dist/__tests__/lib/errors-detailed.test.js.map +1 -0
  9. package/dist/__tests__/lib/errors-is-node-error.test.d.ts +2 -0
  10. package/dist/__tests__/lib/errors-is-node-error.test.d.ts.map +1 -0
  11. package/dist/__tests__/lib/errors-is-node-error.test.js +21 -0
  12. package/dist/__tests__/lib/errors-is-node-error.test.js.map +1 -0
  13. package/dist/__tests__/lib/errors-mcp-error.test.d.ts +2 -0
  14. package/dist/__tests__/lib/errors-mcp-error.test.d.ts.map +1 -0
  15. package/dist/__tests__/lib/errors-mcp-error.test.js +29 -0
  16. package/dist/__tests__/lib/errors-mcp-error.test.js.map +1 -0
  17. package/dist/__tests__/lib/errors-node-map.test.d.ts +2 -0
  18. package/dist/__tests__/lib/errors-node-map.test.d.ts.map +1 -0
  19. package/dist/__tests__/lib/errors-node-map.test.js +16 -0
  20. package/dist/__tests__/lib/errors-node-map.test.js.map +1 -0
  21. package/dist/__tests__/lib/errors-suggestion.test.d.ts +2 -0
  22. package/dist/__tests__/lib/errors-suggestion.test.d.ts.map +1 -0
  23. package/dist/__tests__/lib/errors-suggestion.test.js +11 -0
  24. package/dist/__tests__/lib/errors-suggestion.test.js.map +1 -0
  25. package/dist/__tests__/lib/file-operations/analyze-directory-edge-cases.test.d.ts +2 -0
  26. package/dist/__tests__/lib/file-operations/analyze-directory-edge-cases.test.d.ts.map +1 -0
  27. package/dist/__tests__/lib/file-operations/analyze-directory-edge-cases.test.js +15 -0
  28. package/dist/__tests__/lib/file-operations/analyze-directory-edge-cases.test.js.map +1 -0
  29. package/dist/__tests__/lib/file-operations/analyze-directory.test.d.ts +2 -0
  30. package/dist/__tests__/lib/file-operations/analyze-directory.test.d.ts.map +1 -0
  31. package/dist/__tests__/lib/file-operations/analyze-directory.test.js +28 -0
  32. package/dist/__tests__/lib/file-operations/analyze-directory.test.js.map +1 -0
  33. package/dist/__tests__/lib/file-operations/directory-tree-edge-cases.test.d.ts +2 -0
  34. package/dist/__tests__/lib/file-operations/directory-tree-edge-cases.test.d.ts.map +1 -0
  35. package/dist/__tests__/lib/file-operations/directory-tree-edge-cases.test.js +29 -0
  36. package/dist/__tests__/lib/file-operations/directory-tree-edge-cases.test.js.map +1 -0
  37. package/dist/__tests__/lib/file-operations/directory-tree.test.d.ts +2 -0
  38. package/dist/__tests__/lib/file-operations/directory-tree.test.d.ts.map +1 -0
  39. package/dist/__tests__/lib/file-operations/directory-tree.test.js +75 -0
  40. package/dist/__tests__/lib/file-operations/directory-tree.test.js.map +1 -0
  41. package/dist/__tests__/lib/file-operations/get-file-info.test.d.ts +2 -0
  42. package/dist/__tests__/lib/file-operations/get-file-info.test.d.ts.map +1 -0
  43. package/dist/__tests__/lib/file-operations/get-file-info.test.js +17 -0
  44. package/dist/__tests__/lib/file-operations/get-file-info.test.js.map +1 -0
  45. package/dist/__tests__/lib/file-operations/list-directory-edge-cases.test.d.ts +2 -0
  46. package/dist/__tests__/lib/file-operations/list-directory-edge-cases.test.d.ts.map +1 -0
  47. package/dist/__tests__/lib/file-operations/list-directory-edge-cases.test.js +21 -0
  48. package/dist/__tests__/lib/file-operations/list-directory-edge-cases.test.js.map +1 -0
  49. package/dist/__tests__/lib/file-operations/list-directory.test.d.ts +2 -0
  50. package/dist/__tests__/lib/file-operations/list-directory.test.d.ts.map +1 -0
  51. package/dist/__tests__/lib/file-operations/list-directory.test.js +31 -0
  52. package/dist/__tests__/lib/file-operations/list-directory.test.js.map +1 -0
  53. package/dist/__tests__/lib/file-operations/read-media-file.test.d.ts +2 -0
  54. package/dist/__tests__/lib/file-operations/read-media-file.test.d.ts.map +1 -0
  55. package/dist/__tests__/lib/file-operations/read-media-file.test.js +21 -0
  56. package/dist/__tests__/lib/file-operations/read-media-file.test.js.map +1 -0
  57. package/dist/__tests__/lib/file-operations/read-multiple-files-edge-cases.test.d.ts +2 -0
  58. package/dist/__tests__/lib/file-operations/read-multiple-files-edge-cases.test.d.ts.map +1 -0
  59. package/dist/__tests__/lib/file-operations/read-multiple-files-edge-cases.test.js +19 -0
  60. package/dist/__tests__/lib/file-operations/read-multiple-files-edge-cases.test.js.map +1 -0
  61. package/dist/__tests__/lib/file-operations/read-multiple-files.test.d.ts +2 -0
  62. package/dist/__tests__/lib/file-operations/read-multiple-files.test.d.ts.map +1 -0
  63. package/dist/__tests__/lib/file-operations/read-multiple-files.test.js +39 -0
  64. package/dist/__tests__/lib/file-operations/read-multiple-files.test.js.map +1 -0
  65. package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.d.ts +2 -0
  66. package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.d.ts.map +1 -0
  67. package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.js +57 -0
  68. package/dist/__tests__/lib/file-operations/search-content-edge-cases.test.js.map +1 -0
  69. package/dist/__tests__/lib/file-operations/search-content.test.d.ts +2 -0
  70. package/dist/__tests__/lib/file-operations/search-content.test.d.ts.map +1 -0
  71. package/dist/__tests__/lib/file-operations/search-content.test.js +73 -0
  72. package/dist/__tests__/lib/file-operations/search-content.test.js.map +1 -0
  73. package/dist/__tests__/lib/file-operations/search-files-edge-cases.test.d.ts +2 -0
  74. package/dist/__tests__/lib/file-operations/search-files-edge-cases.test.d.ts.map +1 -0
  75. package/dist/__tests__/lib/file-operations/search-files-edge-cases.test.js +13 -0
  76. package/dist/__tests__/lib/file-operations/search-files-edge-cases.test.js.map +1 -0
  77. package/dist/__tests__/lib/file-operations/search-files.test.d.ts +2 -0
  78. package/dist/__tests__/lib/file-operations/search-files.test.d.ts.map +1 -0
  79. package/dist/__tests__/lib/file-operations/search-files.test.js +31 -0
  80. package/dist/__tests__/lib/file-operations/search-files.test.js.map +1 -0
  81. package/dist/__tests__/lib/fixtures/file-ops-fixture.d.ts +7 -0
  82. package/dist/__tests__/lib/fixtures/file-ops-fixture.d.ts.map +1 -0
  83. package/dist/__tests__/lib/fixtures/file-ops-fixture.js +87 -0
  84. package/dist/__tests__/lib/fixtures/file-ops-fixture.js.map +1 -0
  85. package/dist/__tests__/lib/fixtures/file-ops-hooks.d.ts +2 -0
  86. package/dist/__tests__/lib/fixtures/file-ops-hooks.d.ts.map +1 -0
  87. package/dist/__tests__/lib/fixtures/file-ops-hooks.js +13 -0
  88. package/dist/__tests__/lib/fixtures/file-ops-hooks.js.map +1 -0
  89. package/dist/__tests__/lib/fs-helpers/file-type.test.d.ts +2 -0
  90. package/dist/__tests__/lib/fs-helpers/file-type.test.d.ts.map +1 -0
  91. package/dist/__tests__/lib/fs-helpers/file-type.test.js +15 -0
  92. package/dist/__tests__/lib/fs-helpers/file-type.test.js.map +1 -0
  93. package/dist/__tests__/lib/fs-helpers/head-file-edge-cases.test.d.ts +2 -0
  94. package/dist/__tests__/lib/fs-helpers/head-file-edge-cases.test.d.ts.map +1 -0
  95. package/dist/__tests__/lib/fs-helpers/head-file-edge-cases.test.js +19 -0
  96. package/dist/__tests__/lib/fs-helpers/head-file-edge-cases.test.js.map +1 -0
  97. package/dist/__tests__/lib/fs-helpers/head-file.test.d.ts +2 -0
  98. package/dist/__tests__/lib/fs-helpers/head-file.test.d.ts.map +1 -0
  99. package/dist/__tests__/lib/fs-helpers/head-file.test.js +12 -0
  100. package/dist/__tests__/lib/fs-helpers/head-file.test.js.map +1 -0
  101. package/dist/__tests__/lib/fs-helpers/is-hidden.test.d.ts +2 -0
  102. package/dist/__tests__/lib/fs-helpers/is-hidden.test.d.ts.map +1 -0
  103. package/dist/__tests__/lib/fs-helpers/is-hidden.test.js +7 -0
  104. package/dist/__tests__/lib/fs-helpers/is-hidden.test.js.map +1 -0
  105. package/dist/__tests__/lib/fs-helpers/is-probably-binary.test.d.ts +2 -0
  106. package/dist/__tests__/lib/fs-helpers/is-probably-binary.test.d.ts.map +1 -0
  107. package/dist/__tests__/lib/fs-helpers/is-probably-binary.test.js +33 -0
  108. package/dist/__tests__/lib/fs-helpers/is-probably-binary.test.js.map +1 -0
  109. package/dist/__tests__/lib/fs-helpers/read-file-edge-cases.test.d.ts +2 -0
  110. package/dist/__tests__/lib/fs-helpers/read-file-edge-cases.test.d.ts.map +1 -0
  111. package/dist/__tests__/lib/fs-helpers/read-file-edge-cases.test.js +41 -0
  112. package/dist/__tests__/lib/fs-helpers/read-file-edge-cases.test.js.map +1 -0
  113. package/dist/__tests__/lib/fs-helpers/read-file.test.d.ts +2 -0
  114. package/dist/__tests__/lib/fs-helpers/read-file.test.d.ts.map +1 -0
  115. package/dist/__tests__/lib/fs-helpers/read-file.test.js +21 -0
  116. package/dist/__tests__/lib/fs-helpers/read-file.test.js.map +1 -0
  117. package/dist/__tests__/lib/fs-helpers/tail-file-edge-cases.test.d.ts +2 -0
  118. package/dist/__tests__/lib/fs-helpers/tail-file-edge-cases.test.d.ts.map +1 -0
  119. package/dist/__tests__/lib/fs-helpers/tail-file-edge-cases.test.js +26 -0
  120. package/dist/__tests__/lib/fs-helpers/tail-file-edge-cases.test.js.map +1 -0
  121. package/dist/__tests__/lib/fs-helpers/tail-file.test.d.ts +2 -0
  122. package/dist/__tests__/lib/fs-helpers/tail-file.test.d.ts.map +1 -0
  123. package/dist/__tests__/lib/fs-helpers/tail-file.test.js +11 -0
  124. package/dist/__tests__/lib/fs-helpers/tail-file.test.js.map +1 -0
  125. package/dist/__tests__/lib/path-validation.test.js +93 -104
  126. package/dist/__tests__/lib/path-validation.test.js.map +1 -1
  127. package/dist/__tests__/schemas/validators.test.js +111 -115
  128. package/dist/__tests__/schemas/validators.test.js.map +1 -1
  129. package/dist/__tests__/security/filesystem-boundary.test.js +41 -36
  130. package/dist/__tests__/security/filesystem-boundary.test.js.map +1 -1
  131. package/dist/lib/errors.d.ts +0 -18
  132. package/dist/lib/errors.d.ts.map +1 -1
  133. package/dist/lib/errors.js +33 -34
  134. package/dist/lib/errors.js.map +1 -1
  135. package/dist/lib/file-operations/analyze-directory.d.ts.map +1 -1
  136. package/dist/lib/file-operations/analyze-directory.js +74 -43
  137. package/dist/lib/file-operations/analyze-directory.js.map +1 -1
  138. package/dist/lib/file-operations/directory-helpers.d.ts +2 -19
  139. package/dist/lib/file-operations/directory-helpers.d.ts.map +1 -1
  140. package/dist/lib/file-operations/directory-helpers.js +26 -90
  141. package/dist/lib/file-operations/directory-helpers.js.map +1 -1
  142. package/dist/lib/file-operations/directory-tree-helpers.d.ts +38 -0
  143. package/dist/lib/file-operations/directory-tree-helpers.d.ts.map +1 -0
  144. package/dist/lib/file-operations/directory-tree-helpers.js +167 -0
  145. package/dist/lib/file-operations/directory-tree-helpers.js.map +1 -0
  146. package/dist/lib/file-operations/directory-tree.d.ts.map +1 -1
  147. package/dist/lib/file-operations/directory-tree.js +44 -154
  148. package/dist/lib/file-operations/directory-tree.js.map +1 -1
  149. package/dist/lib/file-operations/list-directory-helpers.d.ts +2 -1
  150. package/dist/lib/file-operations/list-directory-helpers.d.ts.map +1 -1
  151. package/dist/lib/file-operations/list-directory-helpers.js +16 -4
  152. package/dist/lib/file-operations/list-directory-helpers.js.map +1 -1
  153. package/dist/lib/file-operations/list-directory.d.ts +4 -2
  154. package/dist/lib/file-operations/list-directory.d.ts.map +1 -1
  155. package/dist/lib/file-operations/list-directory.js +39 -17
  156. package/dist/lib/file-operations/list-directory.js.map +1 -1
  157. package/dist/lib/file-operations/pattern-validator.d.ts +0 -10
  158. package/dist/lib/file-operations/pattern-validator.d.ts.map +1 -1
  159. package/dist/lib/file-operations/pattern-validator.js +44 -43
  160. package/dist/lib/file-operations/pattern-validator.js.map +1 -1
  161. package/dist/lib/file-operations/read-multiple-files.d.ts +3 -2
  162. package/dist/lib/file-operations/read-multiple-files.d.ts.map +1 -1
  163. package/dist/lib/file-operations/read-multiple-files.js +46 -29
  164. package/dist/lib/file-operations/read-multiple-files.js.map +1 -1
  165. package/dist/lib/file-operations/search/context-manager.d.ts +2 -0
  166. package/dist/lib/file-operations/search/context-manager.d.ts.map +1 -1
  167. package/dist/lib/file-operations/search/context-manager.js +11 -6
  168. package/dist/lib/file-operations/search/context-manager.js.map +1 -1
  169. package/dist/lib/file-operations/search/engine-options.d.ts +19 -0
  170. package/dist/lib/file-operations/search/engine-options.d.ts.map +1 -0
  171. package/dist/lib/file-operations/search/engine-options.js +32 -0
  172. package/dist/lib/file-operations/search/engine-options.js.map +1 -0
  173. package/dist/lib/file-operations/search/engine-stream.d.ts +6 -0
  174. package/dist/lib/file-operations/search/engine-stream.d.ts.map +1 -0
  175. package/dist/lib/file-operations/search/engine-stream.js +130 -0
  176. package/dist/lib/file-operations/search/engine-stream.js.map +1 -0
  177. package/dist/lib/file-operations/search/engine.d.ts +1 -17
  178. package/dist/lib/file-operations/search/engine.d.ts.map +1 -1
  179. package/dist/lib/file-operations/search/engine.js +7 -117
  180. package/dist/lib/file-operations/search/engine.js.map +1 -1
  181. package/dist/lib/file-operations/search/file-processor.d.ts.map +1 -1
  182. package/dist/lib/file-operations/search/file-processor.js +33 -25
  183. package/dist/lib/file-operations/search/file-processor.js.map +1 -1
  184. package/dist/lib/file-operations/search/match-strategy.d.ts.map +1 -1
  185. package/dist/lib/file-operations/search/match-strategy.js +49 -54
  186. package/dist/lib/file-operations/search/match-strategy.js.map +1 -1
  187. package/dist/lib/file-operations/search-files-helpers.d.ts +42 -0
  188. package/dist/lib/file-operations/search-files-helpers.d.ts.map +1 -0
  189. package/dist/lib/file-operations/search-files-helpers.js +180 -0
  190. package/dist/lib/file-operations/search-files-helpers.js.map +1 -0
  191. package/dist/lib/file-operations/search-files.d.ts +2 -9
  192. package/dist/lib/file-operations/search-files.d.ts.map +1 -1
  193. package/dist/lib/file-operations/search-files.js +8 -129
  194. package/dist/lib/file-operations/search-files.js.map +1 -1
  195. package/dist/lib/file-operations/sorting.d.ts +3 -2
  196. package/dist/lib/file-operations/sorting.d.ts.map +1 -1
  197. package/dist/lib/fs-helpers/binary-detect.d.ts.map +1 -1
  198. package/dist/lib/fs-helpers/binary-detect.js +16 -10
  199. package/dist/lib/fs-helpers/binary-detect.js.map +1 -1
  200. package/dist/lib/fs-helpers/fs-utils.d.ts.map +1 -1
  201. package/dist/lib/fs-helpers/fs-utils.js +16 -10
  202. package/dist/lib/fs-helpers/fs-utils.js.map +1 -1
  203. package/dist/lib/fs-helpers/readers/line-range.d.ts +4 -2
  204. package/dist/lib/fs-helpers/readers/line-range.d.ts.map +1 -1
  205. package/dist/lib/fs-helpers/readers/line-range.js +21 -15
  206. package/dist/lib/fs-helpers/readers/line-range.js.map +1 -1
  207. package/dist/lib/fs-helpers/readers/read-file.d.ts +6 -3
  208. package/dist/lib/fs-helpers/readers/read-file.d.ts.map +1 -1
  209. package/dist/lib/fs-helpers/readers/read-file.js +58 -19
  210. package/dist/lib/fs-helpers/readers/read-file.js.map +1 -1
  211. package/dist/lib/fs-helpers/readers/tail-file.d.ts.map +1 -1
  212. package/dist/lib/fs-helpers/readers/tail-file.js +27 -10
  213. package/dist/lib/fs-helpers/readers/tail-file.js.map +1 -1
  214. package/dist/lib/fs-helpers/readers/utf8.d.ts.map +1 -1
  215. package/dist/lib/fs-helpers/readers/utf8.js +20 -10
  216. package/dist/lib/fs-helpers/readers/utf8.js.map +1 -1
  217. package/dist/lib/path-validation/allowed-directories.d.ts +1 -2
  218. package/dist/lib/path-validation/allowed-directories.d.ts.map +1 -1
  219. package/dist/lib/path-validation/allowed-directories.js +25 -15
  220. package/dist/lib/path-validation/allowed-directories.js.map +1 -1
  221. package/dist/lib/path-validation/errors.d.ts +0 -1
  222. package/dist/lib/path-validation/errors.d.ts.map +1 -1
  223. package/dist/lib/path-validation/errors.js +26 -12
  224. package/dist/lib/path-validation/errors.js.map +1 -1
  225. package/dist/lib/path-validation/validators.d.ts.map +1 -1
  226. package/dist/lib/path-validation/validators.js +9 -3
  227. package/dist/lib/path-validation/validators.js.map +1 -1
  228. package/dist/lib/path-validation.d.ts +1 -1
  229. package/dist/lib/path-validation.d.ts.map +1 -1
  230. package/dist/lib/path-validation.js +1 -1
  231. package/dist/lib/path-validation.js.map +1 -1
  232. package/dist/schemas/outputs.d.ts +12 -12
  233. package/dist/server.d.ts.map +1 -1
  234. package/dist/server.js +79 -35
  235. package/dist/server.js.map +1 -1
  236. package/dist/tools/analyze-directory.d.ts.map +1 -1
  237. package/dist/tools/analyze-directory.js +1 -30
  238. package/dist/tools/analyze-directory.js.map +1 -1
  239. package/dist/tools/directory-tree.d.ts.map +1 -1
  240. package/dist/tools/directory-tree.js +11 -32
  241. package/dist/tools/directory-tree.js.map +1 -1
  242. package/dist/tools/get-file-info.d.ts.map +1 -1
  243. package/dist/tools/get-file-info.js +1 -12
  244. package/dist/tools/get-file-info.js.map +1 -1
  245. package/dist/tools/list-allowed-dirs.d.ts.map +1 -1
  246. package/dist/tools/list-allowed-dirs.js +9 -1
  247. package/dist/tools/list-allowed-dirs.js.map +1 -1
  248. package/dist/tools/list-directory.d.ts.map +1 -1
  249. package/dist/tools/list-directory.js +27 -50
  250. package/dist/tools/list-directory.js.map +1 -1
  251. package/dist/tools/read-file.d.ts.map +1 -1
  252. package/dist/tools/read-file.js +28 -20
  253. package/dist/tools/read-file.js.map +1 -1
  254. package/dist/tools/read-multiple-files.d.ts.map +1 -1
  255. package/dist/tools/read-multiple-files.js +15 -14
  256. package/dist/tools/read-multiple-files.js.map +1 -1
  257. package/dist/tools/search-content.d.ts.map +1 -1
  258. package/dist/tools/search-content.js +20 -17
  259. package/dist/tools/search-content.js.map +1 -1
  260. package/dist/tools/search-files.d.ts.map +1 -1
  261. package/dist/tools/search-files.js +1 -27
  262. package/dist/tools/search-files.js.map +1 -1
  263. package/dist/tools/shared/formatting.d.ts +13 -0
  264. package/dist/tools/shared/formatting.d.ts.map +1 -0
  265. package/dist/tools/shared/formatting.js +31 -0
  266. package/dist/tools/shared/formatting.js.map +1 -0
  267. package/dist/tools/shared/search-formatting.d.ts.map +1 -1
  268. package/dist/tools/shared/search-formatting.js +32 -33
  269. package/dist/tools/shared/search-formatting.js.map +1 -1
  270. package/package.json +1 -1
@@ -0,0 +1,21 @@
1
+ import * as path from 'node:path';
2
+ import { expect, it } from 'vitest';
3
+ import { readMediaFile } from '../../../lib/file-operations.js';
4
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
5
+ const getTestDir = useFileOpsFixture();
6
+ it('readMediaFile reads binary file as base64', async () => {
7
+ const result = await readMediaFile(path.join(getTestDir(), 'image.png'));
8
+ expect(result.mimeType).toBe('image/png');
9
+ expect(result.data).toBeTruthy();
10
+ expect(result.size).toBeGreaterThan(0);
11
+ });
12
+ it('readMediaFile returns correct MIME type for markdown files', async () => {
13
+ const result = await readMediaFile(path.join(getTestDir(), 'README.md'));
14
+ expect(result.mimeType).toBe('text/markdown');
15
+ expect(result.data).toBeTruthy();
16
+ expect(result.size).toBeGreaterThan(0);
17
+ });
18
+ it('readMediaFile rejects files too large', async () => {
19
+ await expect(readMediaFile(path.join(getTestDir(), 'image.png'), { maxSize: 1 })).rejects.toThrow('too large');
20
+ });
21
+ //# sourceMappingURL=read-media-file.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-media-file.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/read-media-file.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE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1 @@
1
+ {"version":3,"file":"read-multiple-files-edge-cases.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/read-multiple-files-edge-cases.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import * as path from 'node:path';
2
+ import { expect, it } from 'vitest';
3
+ import { readMultipleFiles } from '../../../lib/file-operations.js';
4
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
5
+ const getTestDir = useFileOpsFixture();
6
+ it('readMultipleFiles handles empty array', async () => {
7
+ const results = await readMultipleFiles([]);
8
+ expect(results.length).toBe(0);
9
+ });
10
+ it('readMultipleFiles handles all files failing', async () => {
11
+ const paths = [
12
+ path.join(getTestDir(), 'nonexistent1.txt'),
13
+ path.join(getTestDir(), 'nonexistent2.txt'),
14
+ ];
15
+ const results = await readMultipleFiles(paths);
16
+ expect(results.length).toBe(2);
17
+ expect(results.every((r) => r.error !== undefined)).toBe(true);
18
+ });
19
+ //# sourceMappingURL=read-multiple-files-edge-cases.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-multiple-files-edge-cases.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/read-multiple-files-edge-cases.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;AAEvC,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;IACrD,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC5C,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,6CAA6C,EAAE,KAAK,IAAI,EAAE;IAC3D,MAAM,KAAK,GAAG;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,kBAAkB,CAAC;QAC3C,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,kBAAkB,CAAC;KAC5C,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC/B,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=read-multiple-files.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-multiple-files.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/read-multiple-files.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+ import { expect, it } from 'vitest';
4
+ import { readMultipleFiles } from '../../../lib/file-operations.js';
5
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
6
+ const getTestDir = useFileOpsFixture();
7
+ it('readMultipleFiles reads multiple files in parallel', async () => {
8
+ const paths = [
9
+ path.join(getTestDir(), 'README.md'),
10
+ path.join(getTestDir(), 'src', 'index.ts'),
11
+ ];
12
+ const results = await readMultipleFiles(paths);
13
+ expect(results.length).toBe(2);
14
+ expect(results.every((r) => r.content !== undefined)).toBe(true);
15
+ });
16
+ it('readMultipleFiles handles individual file errors gracefully', async () => {
17
+ const paths = [
18
+ path.join(getTestDir(), 'README.md'),
19
+ path.join(getTestDir(), 'non-existent.txt'),
20
+ ];
21
+ const results = await readMultipleFiles(paths);
22
+ expect(results.length).toBe(2);
23
+ expect(results[0]?.content).toBeDefined();
24
+ expect(results[1]?.error).toBeDefined();
25
+ });
26
+ it('readMultipleFiles enforces total size cap for head/tail reads', async () => {
27
+ const big1 = path.join(getTestDir(), 'big1.log');
28
+ const big2 = path.join(getTestDir(), 'big2.log');
29
+ const largeContent = 'A'.repeat(50_000);
30
+ await fs.writeFile(big1, largeContent);
31
+ await fs.writeFile(big2, largeContent);
32
+ const results = await readMultipleFiles([big1, big2], {
33
+ head: 1,
34
+ maxTotalSize: 10,
35
+ });
36
+ expect(results.every((r) => r.error !== undefined)).toBe(true);
37
+ await Promise.all([fs.rm(big1), fs.rm(big2)]).catch(() => { });
38
+ });
39
+ //# sourceMappingURL=read-multiple-files.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-multiple-files.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/read-multiple-files.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;AAEvC,EAAE,CAAC,oDAAoD,EAAE,KAAK,IAAI,EAAE;IAClE,MAAM,KAAK,GAAG;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,WAAW,CAAC;QACpC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC;KAC3C,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,CAAC,O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,iBAAiB,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;QACpD,IAAI,EAAE,CAAC;QACP,YAAY,EAAE,EAAE;KACjB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/D,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;AAChE,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=search-content-edge-cases.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-content-edge-cases.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/search-content-edge-cases.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ import { expect, it } from 'vitest';
2
+ import { searchContent } from '../../../lib/file-operations.js';
3
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
4
+ const getTestDir = useFileOpsFixture();
5
+ it('searchContent handles empty search results', async () => {
6
+ const result = await searchContent(getTestDir(), 'xyznonexistent123', {
7
+ filePattern: '**/*.ts',
8
+ });
9
+ expect(result.matches.length).toBe(0);
10
+ expect(result.summary.filesMatched).toBe(0);
11
+ });
12
+ it('searchContent handles special regex characters safely', async () => {
13
+ const result = await searchContent(getTestDir(), 'hello\\.world', {
14
+ filePattern: '**/*.ts',
15
+ });
16
+ expect(result).toBeDefined();
17
+ });
18
+ it('searchContent throws on invalid regex syntax', async () => {
19
+ await expect(searchContent(getTestDir(), '(?')).rejects.toThrow(/Invalid regular expression|ReDoS/i);
20
+ });
21
+ it('searchContent respects maxResults limit', async () => {
22
+ const result = await searchContent(getTestDir(), '\\w+', {
23
+ filePattern: '**/*.ts',
24
+ maxResults: 1,
25
+ });
26
+ expect(result.matches.length).toBeLessThanOrEqual(1);
27
+ if (result.matches.length === 1) {
28
+ expect(result.summary.truncated).toBe(true);
29
+ }
30
+ });
31
+ it('searchContent respects maxFilesScanned limit', async () => {
32
+ const result = await searchContent(getTestDir(), 'export', {
33
+ filePattern: '**/*',
34
+ maxFilesScanned: 1,
35
+ });
36
+ expect(result.summary.filesScanned).toBeLessThanOrEqual(1);
37
+ });
38
+ it('searchContent handles timeout correctly', async () => {
39
+ const result = await searchContent(getTestDir(), 'export', {
40
+ filePattern: '**/*',
41
+ timeoutMs: 1,
42
+ });
43
+ expect(result).toBeDefined();
44
+ });
45
+ it('searchContent stops early when maxResults is 0', async () => {
46
+ const result = await searchContent(getTestDir(), 'Line', { maxResults: 0 });
47
+ expect(result.summary.truncated).toBe(true);
48
+ expect(result.summary.stoppedReason).toBe('maxResults');
49
+ });
50
+ it('searchContent matches literal strings when isLiteral=true', async () => {
51
+ const result = await searchContent(getTestDir(), 'Test.*Project', {
52
+ isLiteral: true,
53
+ filePattern: '**/*.md',
54
+ });
55
+ expect(result.matches.length).toBe(0);
56
+ });
57
+ //# sourceMappingURL=search-content-edge-cases.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-content-edge-cases.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/search-content-edge-cases.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;AAEvC,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;IAC1D,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,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
1
+ export {};
2
+ //# sourceMappingURL=search-content.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-content.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/search-content.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,73 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+ import { expect, it } from 'vitest';
4
+ import { searchContent } from '../../../lib/file-operations.js';
5
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
6
+ const getTestDir = useFileOpsFixture();
7
+ it('searchContent finds content in files', async () => {
8
+ const result = await searchContent(getTestDir(), 'hello');
9
+ expect(result.matches.length).toBeGreaterThan(0);
10
+ expect(result.matches[0]?.file).toContain('index.ts');
11
+ });
12
+ it('searchContent rejects file base path', async () => {
13
+ const filePath = path.join(getTestDir(), 'README.md');
14
+ await expect(searchContent(filePath, 'hello')).rejects.toThrow(/not a directory/i);
15
+ });
16
+ it('searchContent searches case-insensitively by default', async () => {
17
+ const result = await searchContent(getTestDir(), 'HELLO');
18
+ expect(result.matches.length).toBeGreaterThan(0);
19
+ });
20
+ it('searchContent respects case sensitivity when specified', async () => {
21
+ const result = await searchContent(getTestDir(), 'HELLO', {
22
+ caseSensitive: true,
23
+ });
24
+ expect(result.matches.length).toBe(0);
25
+ });
26
+ it('searchContent enforces wholeWord when literal', async () => {
27
+ const literalFile = path.join(getTestDir(), 'literal.txt');
28
+ await fs.writeFile(literalFile, 'concatenate cat scatter catapult cat\n');
29
+ const result = await searchContent(getTestDir(), 'cat', {
30
+ isLiteral: true,
31
+ wholeWord: true,
32
+ filePattern: '**/*.txt',
33
+ });
34
+ expect(result.matches.length).toBe(1);
35
+ expect(result.matches[0]?.matchCount).toBe(2);
36
+ await fs.rm(literalFile).catch(() => { });
37
+ });
38
+ it('searchContent skips binary files by default', async () => {
39
+ const result = await searchContent(getTestDir(), 'PNG');
40
+ expect(result.summary.skippedBinary).toBeGreaterThanOrEqual(0);
41
+ });
42
+ it('searchContent respects file pattern filter', async () => {
43
+ const result = await searchContent(getTestDir(), 'export', {
44
+ filePattern: '**/*.ts',
45
+ });
46
+ expect(result.matches.length).toBeGreaterThan(0);
47
+ expect(result.matches.every((m) => m.file.endsWith('.ts'))).toBe(true);
48
+ });
49
+ it('searchContent includes hidden files when requested', async () => {
50
+ const result = await searchContent(getTestDir(), 'hidden', {
51
+ includeHidden: true,
52
+ filePattern: '**/*',
53
+ isLiteral: true,
54
+ });
55
+ expect(result.matches.length).toBeGreaterThan(0);
56
+ expect(result.matches.some((m) => m.file.includes(`.hidden${path.sep}`))).toBe(true);
57
+ });
58
+ it('searchContent rejects unsafe regex patterns', async () => {
59
+ const unsafePatterns = ['(a+)+', '([a-zA-Z]+)*', '(.*a){25}'];
60
+ for (const pattern of unsafePatterns) {
61
+ await expect(searchContent(getTestDir(), pattern)).rejects.toThrow(/ReDoS|unsafe/i);
62
+ }
63
+ });
64
+ it('searchContent accepts safe regex patterns', async () => {
65
+ const safePatterns = ['hello', 'world\\d+', '[a-z]+', 'function\\s+\\w+'];
66
+ for (const pattern of safePatterns) {
67
+ const result = await searchContent(getTestDir(), pattern, {
68
+ filePattern: '**/*.ts',
69
+ });
70
+ expect(result).toBeDefined();
71
+ }
72
+ });
73
+ //# sourceMappingURL=search-content.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-content.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/search-content.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;AAEvC,EAAE,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AAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/B,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=search-files-edge-cases.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-files-edge-cases.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/search-files-edge-cases.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ import { expect, it } from 'vitest';
2
+ import { searchFiles } from '../../../lib/file-operations.js';
3
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
4
+ const getTestDir = useFileOpsFixture();
5
+ it('searchFiles handles complex glob patterns', async () => {
6
+ const result = await searchFiles(getTestDir(), '**/*.{ts,md}');
7
+ expect(result.results.length).toBeGreaterThan(0);
8
+ });
9
+ it('searchFiles handles negation in exclude patterns', async () => {
10
+ const result = await searchFiles(getTestDir(), '**/*', ['**/docs/**']);
11
+ expect(result.results.every((r) => !r.path.includes('docs'))).toBe(true);
12
+ });
13
+ //# sourceMappingURL=search-files-edge-cases.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-files-edge-cases.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/search-files-edge-cases.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;AAEvC,EAAE,CAAC,2CAA2C,EAAE,KAAK,IAAI,EAAE;IACzD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,EAAE,EAAE,cAAc,CAAC,CAAC;IAC/D,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;IAChE,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACvE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC3E,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=search-files.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-files.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/search-files.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,31 @@
1
+ import * as path from 'node:path';
2
+ import { expect, it } from 'vitest';
3
+ import { searchFiles } from '../../../lib/file-operations.js';
4
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
5
+ const getTestDir = useFileOpsFixture();
6
+ it('searchFiles finds files by glob pattern', async () => {
7
+ const result = await searchFiles(getTestDir(), '**/*.ts');
8
+ expect(result.results.length).toBe(2);
9
+ expect(result.results.some((r) => r.path.includes('index.ts'))).toBe(true);
10
+ const first = result.results.find((r) => r.type === 'file');
11
+ if (first) {
12
+ expect(first.modified).toBeInstanceOf(Date);
13
+ }
14
+ });
15
+ it('searchFiles finds markdown files', async () => {
16
+ const result = await searchFiles(getTestDir(), '**/*.md');
17
+ expect(result.results.length).toBe(2);
18
+ });
19
+ it('searchFiles returns empty results for non-matching patterns', async () => {
20
+ const result = await searchFiles(getTestDir(), '**/*.xyz');
21
+ expect(result.results.length).toBe(0);
22
+ });
23
+ it('searchFiles respects maxResults', async () => {
24
+ const result = await searchFiles(getTestDir(), '**/*', [], { maxResults: 1 });
25
+ expect(result.results.length).toBeLessThanOrEqual(1);
26
+ });
27
+ it('searchFiles rejects file base path', async () => {
28
+ const filePath = path.join(getTestDir(), 'README.md');
29
+ await expect(searchFiles(filePath, '**/*.ts')).rejects.toThrow(/not a directory/i);
30
+ });
31
+ //# sourceMappingURL=search-files.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-files.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/file-operations/search-files.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;AAEvC,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;IACvD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,UAAU,EAAE,EAAE,SAAS,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3E,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IAC5D,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,cAAc,CAAC,IAAI,C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OpsFixture(): Promise<void>;
6
+ export {};
7
+ //# sourceMappingURL=file-ops-fixture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-ops-fixture.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/fixtures/file-ops-fixture.ts"],"names":[],"mappings":"AAOA,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;CACjB;AA+FD,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,cAAc,CAAC,CAKrE;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAQ3D"}
@@ -0,0 +1,87 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as os from 'node:os';
3
+ import * as path from 'node:path';
4
+ import { normalizePath } from '../../../lib/path-utils.js';
5
+ import { setAllowedDirectories } from '../../../lib/path-validation.js';
6
+ const TEST_DIR_PREFIX = 'mcp-fileops-test-';
7
+ async function createBaseDir() {
8
+ return await fs.mkdtemp(path.join(os.tmpdir(), TEST_DIR_PREFIX));
9
+ }
10
+ async function createDirectories(base) {
11
+ await Promise.all([
12
+ fs.mkdir(path.join(base, 'src')),
13
+ fs.mkdir(path.join(base, 'docs')),
14
+ fs.mkdir(path.join(base, '.hidden')),
15
+ ]);
16
+ }
17
+ async function writeReadme(base) {
18
+ await fs.writeFile(path.join(base, 'README.md'), '# Test Project\nThis is a test.\n');
19
+ }
20
+ async function writeSourceFiles(base) {
21
+ await Promise.all([
22
+ fs.writeFile(path.join(base, 'src', 'index.ts'), 'export const hello = "world";\n'),
23
+ fs.writeFile(path.join(base, 'src', 'utils.ts'), 'export function add(a: number, b: number) { return a + b; }\n'),
24
+ ]);
25
+ }
26
+ async function writeDocs(base) {
27
+ await fs.writeFile(path.join(base, 'docs', 'guide.md'), '# Guide\nSome documentation.\n');
28
+ }
29
+ async function writeHidden(base) {
30
+ await fs.writeFile(path.join(base, '.hidden', 'secret.txt'), 'hidden content');
31
+ }
32
+ async function writeMultiline(base) {
33
+ const lines = Array.from({ length: 100 }, (_, i) => `Line ${i + 1}`).join('\n');
34
+ await fs.writeFile(path.join(base, 'multiline.txt'), lines);
35
+ }
36
+ async function writeBinary(base) {
37
+ const binaryData = Buffer.from([
38
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
39
+ ]);
40
+ await fs.writeFile(path.join(base, 'image.png'), binaryData);
41
+ }
42
+ async function populateTestDir(base) {
43
+ await Promise.all([
44
+ writeReadme(base),
45
+ writeSourceFiles(base),
46
+ writeDocs(base),
47
+ writeHidden(base),
48
+ writeMultiline(base),
49
+ writeBinary(base),
50
+ ]);
51
+ }
52
+ async function createFixture() {
53
+ const testDir = await createBaseDir();
54
+ await createDirectories(testDir);
55
+ await populateTestDir(testDir);
56
+ setAllowedDirectories([normalizePath(testDir)]);
57
+ return { testDir };
58
+ }
59
+ async function cleanupFixture(testDir) {
60
+ try {
61
+ await fs.rm(testDir, { recursive: true, force: true });
62
+ }
63
+ catch {
64
+ // ignore cleanup errors
65
+ }
66
+ }
67
+ let activeUsers = 0;
68
+ let fixturePromise = null;
69
+ let sharedFixture = null;
70
+ export async function acquireFileOpsFixture() {
71
+ activeUsers += 1;
72
+ fixturePromise ??= createFixture();
73
+ sharedFixture = await fixturePromise;
74
+ return sharedFixture;
75
+ }
76
+ export async function releaseFileOpsFixture() {
77
+ if (activeUsers === 0)
78
+ return;
79
+ activeUsers -= 1;
80
+ if (activeUsers !== 0 || !sharedFixture)
81
+ return;
82
+ const { testDir } = sharedFixture;
83
+ sharedFixture = null;
84
+ fixturePromise = null;
85
+ await cleanupFixture(testDir);
86
+ }
87
+ //# sourceMappingURL=file-ops-fixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-ops-fixture.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/fixtures/file-ops-fixture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,EAAE,MAAM,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2
+ //# sourceMappingURL=file-ops-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-ops-hooks.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/fixtures/file-ops-hooks.ts"],"names":[],"mappings":"AAOA,wBAAgB,iBAAiB,IAAI,MAAM,MAAM,CAShD"}
@@ -0,0 +1,13 @@
1
+ import { afterAll, beforeAll } from 'vitest';
2
+ import { acquireFileOpsFixture, releaseFileOpsFixture, } from './file-ops-fixture.js';
3
+ export function useFileOpsFixture() {
4
+ let testDir = '';
5
+ beforeAll(async () => {
6
+ ({ testDir } = await acquireFileOpsFixture());
7
+ });
8
+ afterAll(async () => {
9
+ await releaseFileOpsFixture();
10
+ });
11
+ return () => testDir;
12
+ }
13
+ //# sourceMappingURL=file-ops-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-ops-hooks.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/fixtures/file-ops-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE7C,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAE/B,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,SAAS,CAAC,KAAK,IAAI,EAAE;QACnB,CAAC,EAAE,OAAO,EAAE,GAAG,MAAM,qBAAqB,EAAE,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IACH,QAAQ,CAAC,KAAK,IAAI,EAAE;QAClB,MAAM,qBAAqB,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;AACvB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=file-type.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-type.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/fs-helpers/file-type.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+ import { expect, it } from 'vitest';
4
+ import { getFileType } from '../../../lib/fs-helpers.js';
5
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
6
+ const getTestDir = useFileOpsFixture();
7
+ it('getFileType identifies files', async () => {
8
+ const stats = await fs.stat(path.join(getTestDir(), 'README.md'));
9
+ expect(getFileType(stats)).toBe('file');
10
+ });
11
+ it('getFileType identifies directories', async () => {
12
+ const stats = await fs.stat(getTestDir());
13
+ expect(getFileType(stats)).toBe('directory');
14
+ });
15
+ //# sourceMappingURL=file-type.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-type.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/fs-helpers/file-type.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;AAEvC,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;IAC5C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;IAClE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC1C,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;IAClD,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1C,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=head-file-edge-cases.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"head-file-edge-cases.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/fs-helpers/head-file-edge-cases.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import * as fs from 'node:fs/promises';
2
+ import * as path from 'node:path';
3
+ import { expect, it } from 'vitest';
4
+ import { headFile } from '../../../lib/fs-helpers.js';
5
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
6
+ const getTestDir = useFileOpsFixture();
7
+ it('headFile handles requesting more lines than file has', async () => {
8
+ const content = await headFile(path.join(getTestDir(), 'multiline.txt'), 200);
9
+ const lines = content.split('\n');
10
+ expect(lines.length).toBe(100);
11
+ });
12
+ it('headFile handles empty file', async () => {
13
+ const emptyFile = path.join(getTestDir(), 'empty-head.txt');
14
+ await fs.writeFile(emptyFile, '');
15
+ const content = await headFile(emptyFile, 5);
16
+ expect(content).toBe('');
17
+ await fs.rm(emptyFile);
18
+ });
19
+ //# sourceMappingURL=head-file-edge-cases.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"head-file-edge-cases.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/fs-helpers/head-file-edge-cases.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;AAEvC,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;IACpE,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,eAAe,CAAC,EAAE,GAAG,CAAC,CAAC;IAC9E,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;IAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,gBAAgB,CAAC,CAAC;IAC5D,MAAM,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAElC,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEzB,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AACzB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=head-file.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"head-file.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/fs-helpers/head-file.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import * as path from 'node:path';
2
+ import { expect, it } from 'vitest';
3
+ import { headFile } from '../../../lib/fs-helpers.js';
4
+ import { useFileOpsFixture } from '../fixtures/file-ops-hooks.js';
5
+ const getTestDir = useFileOpsFixture();
6
+ it('headFile returns first N lines', async () => {
7
+ const content = await headFile(path.join(getTestDir(), 'multiline.txt'), 5);
8
+ const lines = content.split('\n');
9
+ expect(lines[0]).toBe('Line 1');
10
+ expect(lines.length).toBeLessThanOrEqual(5);
11
+ });
12
+ //# sourceMappingURL=head-file.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"head-file.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/fs-helpers/head-file.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAElE,MAAM,UAAU,GAAG,iBAAiB,EAAE,CAAC;AAEvC,EAAE,CAAC,gCAAgC,EAAE,KAAK,IAAI,EAAE;IAC9C,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5E,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=is-hidden.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-hidden.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/fs-helpers/is-hidden.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { expect, it } from 'vitest';
2
+ import { isHidden } from '../../../lib/fs-helpers.js';
3
+ it('isHidden identifies hidden files', () => {
4
+ expect(isHidden('.git')).toBe(true);
5
+ expect(isHidden('file.txt')).toBe(false);
6
+ });
7
+ //# sourceMappingURL=is-hidden.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-hidden.test.js","sourceRoot":"","sources":["../../../../src/__tests__/lib/fs-helpers/is-hidden.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAC1C,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=is-probably-binary.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-probably-binary.test.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/lib/fs-helpers/is-probably-binary.test.ts"],"names":[],"mappings":""}