file-organizer-mcp 3.1.4 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (427) hide show
  1. package/ARCHITECTURE.md +676 -588
  2. package/CHANGELOG.md +273 -195
  3. package/README.md +887 -803
  4. package/dist/scripts/security-gates/path-traversal-fuzz.d.ts +23 -0
  5. package/dist/scripts/security-gates/path-traversal-fuzz.d.ts.map +1 -0
  6. package/dist/scripts/security-gates/path-traversal-fuzz.js +563 -0
  7. package/dist/scripts/security-gates/path-traversal-fuzz.js.map +1 -0
  8. package/dist/scripts/security-gates/run-all.d.ts +28 -0
  9. package/dist/scripts/security-gates/run-all.d.ts.map +1 -0
  10. package/dist/scripts/security-gates/run-all.js +248 -0
  11. package/dist/scripts/security-gates/run-all.js.map +1 -0
  12. package/dist/scripts/security-gates/sensitive-file-test.d.ts +23 -0
  13. package/dist/scripts/security-gates/sensitive-file-test.d.ts.map +1 -0
  14. package/dist/scripts/security-gates/sensitive-file-test.js +467 -0
  15. package/dist/scripts/security-gates/sensitive-file-test.js.map +1 -0
  16. package/dist/scripts/security-gates/static-analysis.d.ts +38 -0
  17. package/dist/scripts/security-gates/static-analysis.d.ts.map +1 -0
  18. package/dist/scripts/security-gates/static-analysis.js +489 -0
  19. package/dist/scripts/security-gates/static-analysis.js.map +1 -0
  20. package/dist/scripts/security-gates/toctou-test.d.ts +15 -0
  21. package/dist/scripts/security-gates/toctou-test.d.ts.map +1 -0
  22. package/dist/scripts/security-gates/toctou-test.js +438 -0
  23. package/dist/scripts/security-gates/toctou-test.js.map +1 -0
  24. package/dist/{config.d.ts → src/config.d.ts} +2 -0
  25. package/dist/src/config.d.ts.map +1 -0
  26. package/dist/{config.js → src/config.js} +30 -5
  27. package/dist/src/config.js.map +1 -0
  28. package/dist/{constants.d.ts → src/constants.d.ts} +1 -1
  29. package/dist/src/constants.d.ts.map +1 -0
  30. package/dist/{constants.js → src/constants.js} +15 -2
  31. package/dist/src/constants.js.map +1 -0
  32. package/dist/src/errors.d.ts.map +1 -0
  33. package/dist/{errors.js → src/errors.js} +1 -1
  34. package/dist/src/errors.js.map +1 -0
  35. package/dist/{index.d.ts → src/index.d.ts} +2 -2
  36. package/dist/src/index.d.ts.map +1 -0
  37. package/dist/{index.js → src/index.js} +14 -8
  38. package/dist/src/index.js.map +1 -0
  39. package/dist/src/readers/errors.d.ts +71 -0
  40. package/dist/src/readers/errors.d.ts.map +1 -0
  41. package/dist/src/readers/errors.js +106 -0
  42. package/dist/src/readers/errors.js.map +1 -0
  43. package/dist/src/readers/factory.d.ts +74 -0
  44. package/dist/src/readers/factory.d.ts.map +1 -0
  45. package/dist/src/readers/factory.js +102 -0
  46. package/dist/src/readers/factory.js.map +1 -0
  47. package/dist/src/readers/index.d.ts +22 -0
  48. package/dist/src/readers/index.d.ts.map +1 -0
  49. package/dist/src/readers/index.js +20 -0
  50. package/dist/src/readers/index.js.map +1 -0
  51. package/dist/src/readers/interfaces/audit-logger.d.ts +76 -0
  52. package/dist/src/readers/interfaces/audit-logger.d.ts.map +1 -0
  53. package/dist/src/readers/interfaces/audit-logger.js +8 -0
  54. package/dist/src/readers/interfaces/audit-logger.js.map +1 -0
  55. package/dist/src/readers/result.d.ts +86 -0
  56. package/dist/src/readers/result.d.ts.map +1 -0
  57. package/dist/src/readers/result.js +100 -0
  58. package/dist/src/readers/result.js.map +1 -0
  59. package/dist/src/readers/secure-file-reader.d.ts +216 -0
  60. package/dist/src/readers/secure-file-reader.d.ts.map +1 -0
  61. package/dist/src/readers/secure-file-reader.js +586 -0
  62. package/dist/src/readers/secure-file-reader.js.map +1 -0
  63. package/dist/src/readers/security/audit-logger.service.d.ts +200 -0
  64. package/dist/src/readers/security/audit-logger.service.d.ts.map +1 -0
  65. package/dist/src/readers/security/audit-logger.service.js +269 -0
  66. package/dist/src/readers/security/audit-logger.service.js.map +1 -0
  67. package/dist/src/readers/security/index.d.ts +160 -0
  68. package/dist/src/readers/security/index.d.ts.map +1 -0
  69. package/dist/src/readers/security/index.js +159 -0
  70. package/dist/src/readers/security/index.js.map +1 -0
  71. package/dist/src/readers/security/rate-limited-reader.d.ts +216 -0
  72. package/dist/src/readers/security/rate-limited-reader.d.ts.map +1 -0
  73. package/dist/src/readers/security/rate-limited-reader.js +331 -0
  74. package/dist/src/readers/security/rate-limited-reader.js.map +1 -0
  75. package/dist/src/readers/security/sensitive-file-patterns.d.ts +127 -0
  76. package/dist/src/readers/security/sensitive-file-patterns.d.ts.map +1 -0
  77. package/dist/src/readers/security/sensitive-file-patterns.js +293 -0
  78. package/dist/src/readers/security/sensitive-file-patterns.js.map +1 -0
  79. package/dist/src/readers/types.d.ts +89 -0
  80. package/dist/src/readers/types.d.ts.map +1 -0
  81. package/dist/src/readers/types.js +39 -0
  82. package/dist/src/readers/types.js.map +1 -0
  83. package/dist/{schemas → src/schemas}/common.schemas.d.ts +1 -1
  84. package/dist/src/schemas/common.schemas.d.ts.map +1 -0
  85. package/dist/{schemas → src/schemas}/common.schemas.js +1 -1
  86. package/dist/src/schemas/common.schemas.js.map +1 -0
  87. package/dist/{schemas → src/schemas}/index.d.ts +1 -1
  88. package/dist/src/schemas/index.d.ts.map +1 -0
  89. package/dist/{schemas → src/schemas}/index.js +1 -1
  90. package/dist/src/schemas/index.js.map +1 -0
  91. package/dist/{schemas → src/schemas}/organize.schemas.d.ts +1 -1
  92. package/dist/src/schemas/organize.schemas.d.ts.map +1 -0
  93. package/dist/{schemas → src/schemas}/organize.schemas.js +1 -1
  94. package/dist/src/schemas/organize.schemas.js.map +1 -0
  95. package/dist/src/schemas/rename.schemas.d.ts.map +1 -0
  96. package/dist/{schemas → src/schemas}/rename.schemas.js +9 -1
  97. package/dist/src/schemas/rename.schemas.js.map +1 -0
  98. package/dist/{schemas → src/schemas}/scan.schemas.d.ts +1 -1
  99. package/dist/src/schemas/scan.schemas.d.ts.map +1 -0
  100. package/dist/{schemas → src/schemas}/scan.schemas.js +1 -1
  101. package/dist/src/schemas/scan.schemas.js.map +1 -0
  102. package/dist/{schemas → src/schemas}/security.schemas.d.ts +1 -1
  103. package/dist/src/schemas/security.schemas.d.ts.map +1 -0
  104. package/dist/{schemas → src/schemas}/security.schemas.js +1 -1
  105. package/dist/src/schemas/security.schemas.js.map +1 -0
  106. package/dist/src/server.d.ts +10 -0
  107. package/dist/src/server.d.ts.map +1 -0
  108. package/dist/{server.js → src/server.js} +51 -34
  109. package/dist/src/server.js.map +1 -0
  110. package/dist/{services → src/services}/auto-organize.service.d.ts +41 -4
  111. package/dist/src/services/auto-organize.service.d.ts.map +1 -0
  112. package/dist/{services → src/services}/auto-organize.service.js +174 -10
  113. package/dist/src/services/auto-organize.service.js.map +1 -0
  114. package/dist/{services → src/services}/categorizer.service.d.ts +1 -1
  115. package/dist/src/services/categorizer.service.d.ts.map +1 -0
  116. package/dist/{services → src/services}/categorizer.service.js +12 -7
  117. package/dist/src/services/categorizer.service.js.map +1 -0
  118. package/dist/{services → src/services}/duplicate-finder.service.d.ts +1 -1
  119. package/dist/src/services/duplicate-finder.service.d.ts.map +1 -0
  120. package/dist/{services → src/services}/duplicate-finder.service.js +49 -49
  121. package/dist/src/services/duplicate-finder.service.js.map +1 -0
  122. package/dist/src/services/file-scanner.service.d.ts +46 -0
  123. package/dist/src/services/file-scanner.service.d.ts.map +1 -0
  124. package/dist/{services → src/services}/file-scanner.service.js +57 -15
  125. package/dist/src/services/file-scanner.service.js.map +1 -0
  126. package/dist/{services → src/services}/hash-calculator.service.d.ts +1 -1
  127. package/dist/src/services/hash-calculator.service.d.ts.map +1 -0
  128. package/dist/{services → src/services}/hash-calculator.service.js +9 -4
  129. package/dist/src/services/hash-calculator.service.js.map +1 -0
  130. package/dist/{services → src/services}/index.d.ts +2 -1
  131. package/dist/src/services/index.d.ts.map +1 -0
  132. package/dist/{services → src/services}/index.js +2 -1
  133. package/dist/src/services/index.js.map +1 -0
  134. package/dist/src/services/metadata.service.d.ts.map +1 -0
  135. package/dist/{services → src/services}/metadata.service.js +3 -3
  136. package/dist/src/services/metadata.service.js.map +1 -0
  137. package/dist/{services → src/services}/organizer.service.d.ts +17 -1
  138. package/dist/src/services/organizer.service.d.ts.map +1 -0
  139. package/dist/{services → src/services}/organizer.service.js +71 -40
  140. package/dist/src/services/organizer.service.js.map +1 -0
  141. package/dist/{services → src/services}/path-validator.service.d.ts +15 -1
  142. package/dist/src/services/path-validator.service.d.ts.map +1 -0
  143. package/dist/{services → src/services}/path-validator.service.js +26 -28
  144. package/dist/src/services/path-validator.service.js.map +1 -0
  145. package/dist/{services → src/services}/renaming.service.d.ts +1 -1
  146. package/dist/src/services/renaming.service.d.ts.map +1 -0
  147. package/dist/{services → src/services}/renaming.service.js +24 -18
  148. package/dist/src/services/renaming.service.js.map +1 -0
  149. package/dist/{services → src/services}/rollback.service.d.ts +7 -1
  150. package/dist/src/services/rollback.service.d.ts.map +1 -0
  151. package/dist/{services → src/services}/rollback.service.js +99 -32
  152. package/dist/src/services/rollback.service.js.map +1 -0
  153. package/dist/src/services/scheduler-state.service.d.ts +130 -0
  154. package/dist/src/services/scheduler-state.service.d.ts.map +1 -0
  155. package/dist/src/services/scheduler-state.service.js +315 -0
  156. package/dist/src/services/scheduler-state.service.js.map +1 -0
  157. package/dist/{services → src/services}/security/rate-limiter.service.d.ts +1 -1
  158. package/dist/src/services/security/rate-limiter.service.d.ts.map +1 -0
  159. package/dist/{services → src/services}/security/rate-limiter.service.js +3 -3
  160. package/dist/src/services/security/rate-limiter.service.js.map +1 -0
  161. package/dist/{services → src/services}/streaming-scanner.service.d.ts +1 -1
  162. package/dist/src/services/streaming-scanner.service.d.ts.map +1 -0
  163. package/dist/{services → src/services}/streaming-scanner.service.js +5 -5
  164. package/dist/src/services/streaming-scanner.service.js.map +1 -0
  165. package/dist/{tools → src/tools}/duplicate-management.d.ts +1 -1
  166. package/dist/src/tools/duplicate-management.d.ts.map +1 -0
  167. package/dist/{tools → src/tools}/duplicate-management.js +43 -24
  168. package/dist/src/tools/duplicate-management.js.map +1 -0
  169. package/dist/{tools → src/tools}/file-analysis.d.ts +1 -1
  170. package/dist/src/tools/file-analysis.d.ts.map +1 -0
  171. package/dist/{tools → src/tools}/file-analysis.js +9 -3
  172. package/dist/src/tools/file-analysis.js.map +1 -0
  173. package/dist/{tools → src/tools}/file-categorization.d.ts +1 -1
  174. package/dist/src/tools/file-categorization.d.ts.map +1 -0
  175. package/dist/{tools → src/tools}/file-categorization.js +13 -4
  176. package/dist/src/tools/file-categorization.js.map +1 -0
  177. package/dist/{tools → src/tools}/file-duplicates.d.ts +1 -1
  178. package/dist/src/tools/file-duplicates.d.ts.map +1 -0
  179. package/dist/{tools → src/tools}/file-duplicates.js +5 -3
  180. package/dist/src/tools/file-duplicates.js.map +1 -0
  181. package/dist/{tools → src/tools}/file-listing.d.ts +1 -1
  182. package/dist/src/tools/file-listing.d.ts.map +1 -0
  183. package/dist/{tools → src/tools}/file-listing.js +4 -2
  184. package/dist/src/tools/file-listing.js.map +1 -0
  185. package/dist/{tools → src/tools}/file-management.d.ts +1 -1
  186. package/dist/src/tools/file-management.d.ts.map +1 -0
  187. package/dist/{tools → src/tools}/file-management.js +22 -16
  188. package/dist/src/tools/file-management.js.map +1 -0
  189. package/dist/{tools → src/tools}/file-organization.d.ts +1 -1
  190. package/dist/src/tools/file-organization.d.ts.map +1 -0
  191. package/dist/{tools → src/tools}/file-organization.js +12 -5
  192. package/dist/src/tools/file-organization.js.map +1 -0
  193. package/dist/src/tools/file-reader.tool.d.ts +70 -0
  194. package/dist/src/tools/file-reader.tool.d.ts.map +1 -0
  195. package/dist/src/tools/file-reader.tool.js +310 -0
  196. package/dist/src/tools/file-reader.tool.js.map +1 -0
  197. package/dist/{tools → src/tools}/file-renaming.d.ts +1 -1
  198. package/dist/src/tools/file-renaming.d.ts.map +1 -0
  199. package/dist/{tools → src/tools}/file-renaming.js +22 -13
  200. package/dist/src/tools/file-renaming.js.map +1 -0
  201. package/dist/{tools → src/tools}/file-scanning.d.ts +1 -1
  202. package/dist/src/tools/file-scanning.d.ts.map +1 -0
  203. package/dist/{tools → src/tools}/file-scanning.js +15 -5
  204. package/dist/src/tools/file-scanning.js.map +1 -0
  205. package/dist/{tools → src/tools}/index.d.ts +24 -22
  206. package/dist/src/tools/index.d.ts.map +1 -0
  207. package/dist/{tools → src/tools}/index.js +30 -27
  208. package/dist/src/tools/index.js.map +1 -0
  209. package/dist/{tools → src/tools}/metadata-inspection.d.ts +1 -1
  210. package/dist/src/tools/metadata-inspection.d.ts.map +1 -0
  211. package/dist/{tools → src/tools}/metadata-inspection.js +5 -3
  212. package/dist/src/tools/metadata-inspection.js.map +1 -0
  213. package/dist/{tools → src/tools}/organization-preview.d.ts +1 -1
  214. package/dist/src/tools/organization-preview.d.ts.map +1 -0
  215. package/dist/{tools → src/tools}/organization-preview.js +12 -5
  216. package/dist/src/tools/organization-preview.js.map +1 -0
  217. package/dist/{tools → src/tools}/rollback.d.ts +1 -1
  218. package/dist/src/tools/rollback.d.ts.map +1 -0
  219. package/dist/{tools → src/tools}/rollback.js +13 -8
  220. package/dist/src/tools/rollback.js.map +1 -0
  221. package/dist/{tools → src/tools}/watch.tool.d.ts +1 -1
  222. package/dist/src/tools/watch.tool.d.ts.map +1 -0
  223. package/dist/{tools → src/tools}/watch.tool.js +51 -38
  224. package/dist/src/tools/watch.tool.js.map +1 -0
  225. package/dist/src/tui/client-detector.d.ts.map +1 -0
  226. package/dist/{tui → src/tui}/client-detector.js +13 -42
  227. package/dist/src/tui/client-detector.js.map +1 -0
  228. package/dist/{index.d.ts.map → src/tui/index.d.ts.map} +1 -1
  229. package/dist/src/tui/index.js.map +1 -0
  230. package/dist/{tui → src/tui}/screens.d.ts.map +1 -1
  231. package/dist/{tui → src/tui}/screens.js.map +1 -1
  232. package/dist/src/tui/setup-wizard.d.ts.map +1 -0
  233. package/dist/{tui → src/tui}/setup-wizard.js +10 -10
  234. package/dist/src/tui/setup-wizard.js.map +1 -0
  235. package/dist/{types.d.ts → src/types.d.ts} +1 -1
  236. package/dist/src/types.d.ts.map +1 -0
  237. package/dist/{types.js → src/types.js} +1 -1
  238. package/dist/src/types.js.map +1 -0
  239. package/dist/src/utils/cron-utils.d.ts +44 -0
  240. package/dist/src/utils/cron-utils.d.ts.map +1 -0
  241. package/dist/src/utils/cron-utils.js +301 -0
  242. package/dist/src/utils/cron-utils.js.map +1 -0
  243. package/dist/src/utils/diagnostics.d.ts.map +1 -0
  244. package/dist/src/utils/diagnostics.js.map +1 -0
  245. package/dist/{utils → src/utils}/error-handler.d.ts +1 -1
  246. package/dist/src/utils/error-handler.d.ts.map +1 -0
  247. package/dist/{utils → src/utils}/error-handler.js +1 -1
  248. package/dist/src/utils/error-handler.js.map +1 -0
  249. package/dist/{utils → src/utils}/file-utils.d.ts +1 -1
  250. package/dist/src/utils/file-utils.d.ts.map +1 -0
  251. package/dist/{utils → src/utils}/file-utils.js +1 -1
  252. package/dist/src/utils/file-utils.js.map +1 -0
  253. package/dist/{utils → src/utils}/formatters.d.ts +1 -1
  254. package/dist/src/utils/formatters.d.ts.map +1 -0
  255. package/dist/{utils → src/utils}/formatters.js +1 -1
  256. package/dist/src/utils/formatters.js.map +1 -0
  257. package/dist/{utils → src/utils}/index.d.ts +2 -1
  258. package/dist/src/utils/index.d.ts.map +1 -0
  259. package/dist/{utils → src/utils}/index.js +2 -1
  260. package/dist/src/utils/index.js.map +1 -0
  261. package/dist/{utils → src/utils}/logger.d.ts +1 -1
  262. package/dist/src/utils/logger.d.ts.map +1 -0
  263. package/dist/{utils → src/utils}/logger.js +8 -6
  264. package/dist/src/utils/logger.js.map +1 -0
  265. package/dist/{utils → src/utils}/path-security.d.ts +1 -1
  266. package/dist/src/utils/path-security.d.ts.map +1 -0
  267. package/dist/{utils → src/utils}/path-security.js +1 -1
  268. package/dist/src/utils/path-security.js.map +1 -0
  269. package/package.json +16 -3
  270. package/dist/config.d.ts.map +0 -1
  271. package/dist/config.js.map +0 -1
  272. package/dist/constants.d.ts.map +0 -1
  273. package/dist/constants.js.map +0 -1
  274. package/dist/errors.d.ts.map +0 -1
  275. package/dist/errors.js.map +0 -1
  276. package/dist/index.js.map +0 -1
  277. package/dist/schemas/common.schemas.d.ts.map +0 -1
  278. package/dist/schemas/common.schemas.js.map +0 -1
  279. package/dist/schemas/index.d.ts.map +0 -1
  280. package/dist/schemas/index.js.map +0 -1
  281. package/dist/schemas/organize.schemas.d.ts.map +0 -1
  282. package/dist/schemas/organize.schemas.js.map +0 -1
  283. package/dist/schemas/rename.schemas.d.ts.map +0 -1
  284. package/dist/schemas/rename.schemas.js.map +0 -1
  285. package/dist/schemas/scan.schemas.d.ts.map +0 -1
  286. package/dist/schemas/scan.schemas.js.map +0 -1
  287. package/dist/schemas/security.schemas.d.ts.map +0 -1
  288. package/dist/schemas/security.schemas.js.map +0 -1
  289. package/dist/server.d.ts +0 -10
  290. package/dist/server.d.ts.map +0 -1
  291. package/dist/server.js.map +0 -1
  292. package/dist/services/auto-organize.service.d.ts.map +0 -1
  293. package/dist/services/auto-organize.service.js.map +0 -1
  294. package/dist/services/categorizer.service.d.ts.map +0 -1
  295. package/dist/services/categorizer.service.js.map +0 -1
  296. package/dist/services/duplicate-finder.service.d.ts.map +0 -1
  297. package/dist/services/duplicate-finder.service.js.map +0 -1
  298. package/dist/services/file-scanner.service.d.ts +0 -23
  299. package/dist/services/file-scanner.service.d.ts.map +0 -1
  300. package/dist/services/file-scanner.service.js.map +0 -1
  301. package/dist/services/hash-calculator.service.d.ts.map +0 -1
  302. package/dist/services/hash-calculator.service.js.map +0 -1
  303. package/dist/services/index.d.ts.map +0 -1
  304. package/dist/services/index.js.map +0 -1
  305. package/dist/services/metadata.service.d.ts.map +0 -1
  306. package/dist/services/metadata.service.js.map +0 -1
  307. package/dist/services/organizer.service.d.ts.map +0 -1
  308. package/dist/services/organizer.service.js.map +0 -1
  309. package/dist/services/path-validator.service.d.ts.map +0 -1
  310. package/dist/services/path-validator.service.js.map +0 -1
  311. package/dist/services/renaming.service.d.ts.map +0 -1
  312. package/dist/services/renaming.service.js.map +0 -1
  313. package/dist/services/rollback.service.d.ts.map +0 -1
  314. package/dist/services/rollback.service.js.map +0 -1
  315. package/dist/services/security/rate-limiter.service.d.ts.map +0 -1
  316. package/dist/services/security/rate-limiter.service.js.map +0 -1
  317. package/dist/services/streaming-scanner.service.d.ts.map +0 -1
  318. package/dist/services/streaming-scanner.service.js.map +0 -1
  319. package/dist/tests/test-dryrun.d.ts +0 -2
  320. package/dist/tests/test-dryrun.d.ts.map +0 -1
  321. package/dist/tests/test-dryrun.js +0 -56
  322. package/dist/tests/test-dryrun.js.map +0 -1
  323. package/dist/tests/test-duplicate-scoring.d.ts +0 -2
  324. package/dist/tests/test-duplicate-scoring.d.ts.map +0 -1
  325. package/dist/tests/test-duplicate-scoring.js +0 -84
  326. package/dist/tests/test-duplicate-scoring.js.map +0 -1
  327. package/dist/tests/test-edge-cases.d.ts +0 -10
  328. package/dist/tests/test-edge-cases.d.ts.map +0 -1
  329. package/dist/tests/test-edge-cases.js +0 -129
  330. package/dist/tests/test-edge-cases.js.map +0 -1
  331. package/dist/tests/test-filename-conflict.d.ts +0 -2
  332. package/dist/tests/test-filename-conflict.d.ts.map +0 -1
  333. package/dist/tests/test-filename-conflict.js +0 -70
  334. package/dist/tests/test-filename-conflict.js.map +0 -1
  335. package/dist/tests/test-overwrite-bug.d.ts +0 -2
  336. package/dist/tests/test-overwrite-bug.d.ts.map +0 -1
  337. package/dist/tests/test-overwrite-bug.js +0 -73
  338. package/dist/tests/test-overwrite-bug.js.map +0 -1
  339. package/dist/tests/test-pagination.d.ts +0 -7
  340. package/dist/tests/test-pagination.d.ts.map +0 -1
  341. package/dist/tests/test-pagination.js +0 -105
  342. package/dist/tests/test-pagination.js.map +0 -1
  343. package/dist/tests/test-phase1.d.ts +0 -7
  344. package/dist/tests/test-phase1.d.ts.map +0 -1
  345. package/dist/tests/test-phase1.js +0 -47
  346. package/dist/tests/test-phase1.js.map +0 -1
  347. package/dist/tests/test-phase3-advanced.d.ts +0 -2
  348. package/dist/tests/test-phase3-advanced.d.ts.map +0 -1
  349. package/dist/tests/test-phase3-advanced.js +0 -82
  350. package/dist/tests/test-phase3-advanced.js.map +0 -1
  351. package/dist/tests/test-phase3.d.ts +0 -2
  352. package/dist/tests/test-phase3.d.ts.map +0 -1
  353. package/dist/tests/test-phase3.js +0 -84
  354. package/dist/tests/test-phase3.js.map +0 -1
  355. package/dist/tests/test-rollback-fix.d.ts +0 -2
  356. package/dist/tests/test-rollback-fix.d.ts.map +0 -1
  357. package/dist/tests/test-rollback-fix.js +0 -85
  358. package/dist/tests/test-rollback-fix.js.map +0 -1
  359. package/dist/tests/test-security-enhanced.d.ts +0 -2
  360. package/dist/tests/test-security-enhanced.d.ts.map +0 -1
  361. package/dist/tests/test-security-enhanced.js +0 -44
  362. package/dist/tests/test-security-enhanced.js.map +0 -1
  363. package/dist/tests/test-security.d.ts +0 -2
  364. package/dist/tests/test-security.d.ts.map +0 -1
  365. package/dist/tests/test-security.js +0 -59
  366. package/dist/tests/test-security.js.map +0 -1
  367. package/dist/tools/duplicate-management.d.ts.map +0 -1
  368. package/dist/tools/duplicate-management.js.map +0 -1
  369. package/dist/tools/file-analysis.d.ts.map +0 -1
  370. package/dist/tools/file-analysis.js.map +0 -1
  371. package/dist/tools/file-categorization.d.ts.map +0 -1
  372. package/dist/tools/file-categorization.js.map +0 -1
  373. package/dist/tools/file-duplicates.d.ts.map +0 -1
  374. package/dist/tools/file-duplicates.js.map +0 -1
  375. package/dist/tools/file-listing.d.ts.map +0 -1
  376. package/dist/tools/file-listing.js.map +0 -1
  377. package/dist/tools/file-management.d.ts.map +0 -1
  378. package/dist/tools/file-management.js.map +0 -1
  379. package/dist/tools/file-organization.d.ts.map +0 -1
  380. package/dist/tools/file-organization.js.map +0 -1
  381. package/dist/tools/file-renaming.d.ts.map +0 -1
  382. package/dist/tools/file-renaming.js.map +0 -1
  383. package/dist/tools/file-scanning.d.ts.map +0 -1
  384. package/dist/tools/file-scanning.js.map +0 -1
  385. package/dist/tools/index.d.ts.map +0 -1
  386. package/dist/tools/index.js.map +0 -1
  387. package/dist/tools/metadata-inspection.d.ts.map +0 -1
  388. package/dist/tools/metadata-inspection.js.map +0 -1
  389. package/dist/tools/organization-preview.d.ts.map +0 -1
  390. package/dist/tools/organization-preview.js.map +0 -1
  391. package/dist/tools/rollback.d.ts.map +0 -1
  392. package/dist/tools/rollback.js.map +0 -1
  393. package/dist/tools/watch.tool.d.ts.map +0 -1
  394. package/dist/tools/watch.tool.js.map +0 -1
  395. package/dist/tui/client-detector.d.ts.map +0 -1
  396. package/dist/tui/client-detector.js.map +0 -1
  397. package/dist/tui/index.d.ts.map +0 -1
  398. package/dist/tui/index.js.map +0 -1
  399. package/dist/tui/setup-wizard.d.ts.map +0 -1
  400. package/dist/tui/setup-wizard.js.map +0 -1
  401. package/dist/types.d.ts.map +0 -1
  402. package/dist/types.js.map +0 -1
  403. package/dist/utils/diagnostics.d.ts.map +0 -1
  404. package/dist/utils/diagnostics.js.map +0 -1
  405. package/dist/utils/error-handler.d.ts.map +0 -1
  406. package/dist/utils/error-handler.js.map +0 -1
  407. package/dist/utils/file-utils.d.ts.map +0 -1
  408. package/dist/utils/file-utils.js.map +0 -1
  409. package/dist/utils/formatters.d.ts.map +0 -1
  410. package/dist/utils/formatters.js.map +0 -1
  411. package/dist/utils/index.d.ts.map +0 -1
  412. package/dist/utils/index.js.map +0 -1
  413. package/dist/utils/logger.d.ts.map +0 -1
  414. package/dist/utils/logger.js.map +0 -1
  415. package/dist/utils/path-security.d.ts.map +0 -1
  416. package/dist/utils/path-security.js.map +0 -1
  417. /package/dist/{errors.d.ts → src/errors.d.ts} +0 -0
  418. /package/dist/{schemas → src/schemas}/rename.schemas.d.ts +0 -0
  419. /package/dist/{services → src/services}/metadata.service.d.ts +0 -0
  420. /package/dist/{tui → src/tui}/client-detector.d.ts +0 -0
  421. /package/dist/{tui → src/tui}/index.d.ts +0 -0
  422. /package/dist/{tui → src/tui}/index.js +0 -0
  423. /package/dist/{tui → src/tui}/screens.d.ts +0 -0
  424. /package/dist/{tui → src/tui}/screens.js +0 -0
  425. /package/dist/{tui → src/tui}/setup-wizard.d.ts +0 -0
  426. /package/dist/{utils → src/utils}/diagnostics.d.ts +0 -0
  427. /package/dist/{utils → src/utils}/diagnostics.js +0 -0
package/ARCHITECTURE.md CHANGED
@@ -1,588 +1,676 @@
1
- # Architecture Documentation
2
-
3
- ## 🏗️ System Overview
4
-
5
- File Organizer MCP is a security-hardened Model Context Protocol (MCP) server that provides intelligent file organization capabilities to Large Language Models (LLMs). The architecture follows a layered service pattern with comprehensive security validation at every level.
6
-
7
- ### Core Principles
8
-
9
- 1. **Security First** - Multi-layer validation and sanitization
10
- 2. **Service Isolation** - Clear separation of concerns
11
- 3. **Type Safety** - Strict TypeScript with Zod validation
12
- 4. **Testability** - Dependency injection and modular design
13
- 5. **Performance** - Streaming operations and resource limits
14
-
15
- ## 📐 Architecture Layers
16
-
17
- ```
18
- ┌─────────────────────────────────────────────────────────────┐
19
- │ MCP Client (LLM) │
20
- └─────────────────────────┬───────────────────────────────────┘
21
- │ JSON-RPC 2.0
22
- ┌─────────────────────────▼───────────────────────────────────┐
23
- │ MCP Server Layer │
24
- │ (server.ts - Protocol Handler) │
25
- └─────────────────────────┬───────────────────────────────────┘
26
-
27
- ┌─────────────────────────▼───────────────────────────────────┐
28
- │ Tools Layer │
29
- │ ┌──────────┬──────────┬───────────┬─────────────┐ │
30
- │ │ Scan │ Organize │ Duplicate │ Categorize │ │
31
- │ │ Files │ Files │ Find │ Files │ │
32
- │ └──────────┴──────────┴───────────┴─────────────┘ │
33
- └─────────────────────────┬───────────────────────────────────┘
34
-
35
- ┌─────────────────────────▼───────────────────────────────────┐
36
- │ Services Layer │
37
- │ ┌────────────┬──────────────┬─────────────┬──────────┐ │
38
- │ │ Path │ Organizer │ Hash │ Scanner │ │
39
- │ │ Validator │ Service │ Calculator │ Service │ │
40
- │ └────────────┴──────────────┴─────────────┴──────────┘ │
41
- └─────────────────────────┬───────────────────────────────────┘
42
-
43
- ┌─────────────────────────▼───────────────────────────────────┐
44
- │ Utils Layer │
45
- │ ┌──────────┬──────────┬───────────┬──────────┐ │
46
- │ │ Logger │ Error │ File │ Format- │ │
47
- │ │ │ Handler │ Utils │ ters │ │
48
- │ └──────────┴──────────┴───────────┴──────────┘ │
49
- └─────────────────────────┬───────────────────────────────────┘
50
-
51
- ┌─────────────────────────▼───────────────────────────────────┐
52
- │ File System │
53
- └─────────────────────────────────────────────────────────────┘
54
- ```
55
-
56
- ## 🔐 Security Architecture
57
-
58
- ### 8-Layer Path Validation Pipeline
59
-
60
- Every file path goes through these validation layers:
61
-
62
- ```typescript
63
- Input Path
64
-
65
- 1. Type Validation (Zod Schema)
66
-
67
- 2. Null Byte & Basic Sanitization
68
-
69
- 3. Path Normalization & Windows Case Adjustment
70
-
71
- 4. Traversal Sequence Prevention (../)
72
-
73
- 5. Absolute Path Resolution
74
-
75
- 6. Security Check (Whitelist & Blacklist)
76
-
77
- 7. Symlink Resolution & Target Validation
78
-
79
- 8. Existence & Access Check
80
-
81
- Validated Path ✅
82
- ```
83
-
84
- **Implementation:** [`src/services/path-validator.service.ts`](file:///c:/Users/NewAdmin/Desktop/File-Organizer-MCP/src/services/path-validator.service.ts)
85
-
86
- ### Race Condition Mitigation (TOCTOU Protection)
87
-
88
- **Problem:** Time-of-Check-Time-of-Use vulnerabilities can occur when a file is checked, then used later, allowing an attacker to swap the file between operations.
89
-
90
- **Solution:** Multi-layered approach:
91
-
92
- ```typescript
93
- // Layer 1: File Descriptor Validation
94
- // Open file with O_NOFOLLOW to prevent symlink following
95
- const handle = await fs.open(path, constants.O_RDONLY | constants.O_NOFOLLOW);
96
-
97
- // Layer 2: Atomic Copy Operations
98
- // Use COPYFILE_EXCL to ensure destination doesn't exist
99
- await fs.copyFile(source, dest, constants.COPYFILE_EXCL);
100
-
101
- // Layer 3: Safe Overwrites
102
- // Move existing file to backup before replacing
103
- const backupPath = path.join('.file-organizer-backups', `${Date.now()}_overwrite_${basename}`);
104
- await fs.rename(existingFile, backupPath);
105
- ```
106
-
107
- **Limitations:**
108
-
109
- - File deletion on Windows uses path-based locking (not file descriptor)
110
- - Symlinks are blocked for security but may limit legitimate use cases
111
-
112
- ### Resource Protection
113
-
114
- ```typescript
115
- // Security Constants
116
- const SECURITY_LIMITS = {
117
- MAX_FILE_SIZE: 100 * 1024 * 1024, // 100 MB
118
- MAX_FILES: 10000, // Per operation
119
- MAX_DEPTH: 10, // Directory recursion
120
- MAX_PATH_LENGTH: 4096, // Characters
121
- };
122
- ```
123
-
124
- ## 📦 Core Components
125
-
126
- ### 1. Server Layer (`server.ts`)
127
-
128
- **Responsibility:** MCP protocol handling and tool registration
129
-
130
- ```typescript
131
- // Key responsibilities:
132
- - Initialize MCP server
133
- - Register tools with schemas
134
- - Handle tool invocations
135
- - Manage error responses
136
- - Coordinate with services
137
- ```
138
-
139
- **Key Features:**
140
-
141
- - Automatic tool discovery from `tools/` directory
142
- - Structured response formatting (JSON/Markdown)
143
- - Centralized error handling
144
-
145
- ### 2. Tools Layer (`tools/`)
146
-
147
- **Responsibility:** MCP tool implementations (user-facing API)
148
-
149
- Each tool follows this pattern:
150
-
151
- ```typescript
152
- export const toolDefinition: ToolDefinition = {
153
- name: 'tool_name',
154
- description: 'What it does',
155
- inputSchema: ZodSchema, // Validation
156
- };
157
-
158
- export async function handleTool(args: ToolArgs): Promise<ToolResponse> {
159
- // 1. Validate inputs (Zod)
160
- // 2. Validate security (PathValidator)
161
- // 3. Call service layer
162
- // 4. Format response
163
- // 5. Handle errors
164
- }
165
- ```
166
-
167
- **Available Tools:**
168
-
169
- 1. **List Files in Directory** (`file_organizer_list_files`)
170
- 2. **Scan Directory for Detailed Info** (`file_organizer_scan_directory`)
171
- 3. **Categorize Files by Type** (`file_organizer_categorize_files`)
172
- 4. **Find Largest Files** (`file_organizer_find_largest_files`)
173
- 5. **Find Duplicate Files** (`file_organizer_find_duplicate_files`)
174
- 6. **Preview File Organization Plan** (`file_organizer_preview_organization`)
175
- 7. **Get Available File Categories** (`file_organizer_get_categories`)
176
- 8. **Analyze Duplicate Files with Smart Recommendations** (`file_organizer_analyze_duplicates`)
177
- 9. **Organize Files** (`file_organizer_organize_files`)
178
- 10. **Set Custom Organization Rules** (`file_organizer_set_custom_rules`)
179
- 11. **Delete Duplicate Files** (`file_organizer_delete_duplicates`)
180
- 12. **Undo Last Organization Operation** (`file_organizer_undo_last_operation`)
181
-
182
- ### 3. Services Layer (`services/`)
183
-
184
- **Responsibility:** Core business logic
185
-
186
- #### PathValidatorService
187
-
188
- ```typescript
189
- class PathValidatorService {
190
- // Multi-layer path validation
191
- async validateStrictPath(inputPath: unknown, options?: ValidatePathOptions): Promise<string>;
192
-
193
- // Symlink resolution
194
- async resolvePath(path: string): Promise<string>;
195
-
196
- // Containment checking
197
- isPathWithinRoots(path: string, roots: string[]): boolean;
198
- }
199
- ```
200
-
201
- #### OrganizerService
202
-
203
- ```typescript
204
- class OrganizerService {
205
- // Generate organization plan
206
- async generateOrganizationPlan(
207
- directory: string,
208
- files: FileWithSize[],
209
- strategy?: ConflictStrategy // 'rename' | 'skip' | 'overwrite' | 'overwrite_if_newer'
210
- ): Promise<OrganizationPlan>;
211
-
212
- // Execute organization with safety guarantees
213
- async organize(
214
- directory: string,
215
- files: FileWithSize[],
216
- options?: OrganizeOptions
217
- ): Promise<OrganizeResult>;
218
-
219
- // Safety mechanisms:
220
- // 1. File descriptor validation before move
221
- // 2. Atomic copy with COPYFILE_EXCL (race-safe)
222
- // 3. Automatic backup to .file-organizer-backups/ on overwrite
223
- // 4. Retry loop for race condition recovery
224
- }
225
- ```
226
-
227
- #### HashCalculatorService
228
-
229
- ```typescript
230
- class HashCalculatorService {
231
- // Streaming hash calculation
232
- async calculateHash(filePath: string): Promise<string>;
233
-
234
- // Find duplicates (memory-safe)
235
- async findDuplicates(files: FileWithSize[]): Promise<DuplicateGroup[]>;
236
- }
237
- ```
238
-
239
- #### FileScannerService
240
-
241
- ```typescript
242
- class FileScannerService {
243
- // Recursive directory scanning
244
- async getAllFiles(directory: string, options?: ScanOptions): Promise<FileWithSize[]>;
245
-
246
- // Size calculation
247
- async calculateDirectorySize(directory: string): Promise<number>;
248
- }
249
- ```
250
-
251
- #### CategorizerService
252
-
253
- ```typescript
254
- class CategorizerService {
255
- // File categorization
256
- getCategory(fileName: string): CategoryName;
257
-
258
- // Custom rules support
259
- setCustomRules(rules: CategoryRule[]): void;
260
-
261
- // Category statistics
262
- categorizeFiles(files: FileWithSize[]): CategoryBreakdown;
263
- }
264
- ```
265
-
266
- #### RollbackService
267
-
268
- ```typescript
269
- class RollbackService {
270
- // Create rollback manifest
271
- async createManifest(actions: OrganizeAction[]): Promise<string>;
272
-
273
- // Execute rollback
274
- async rollback(manifestId: string): Promise<RollbackResult>;
275
-
276
- // List available rollbacks
277
- async listRollbacks(): Promise<RollbackManifest[]>;
278
- }
279
- ```
280
-
281
- ### 4. Utils Layer (`utils/`)
282
-
283
- **Responsibility:** Shared utility functions
284
-
285
- #### Logger
286
-
287
- ```typescript
288
- class Logger {
289
- // Structured JSON logging to stderr (MCP stdio protocol)
290
- debug(message: string, context?: Record<string, any>): void;
291
- info(message: string, context?: Record<string, any>): void;
292
- warn(message: string, context?: Record<string, any>): void;
293
- error(message: string, error?: Error, context?: Record<string, any>): void;
294
-
295
- // Features:
296
- // - ISO 8601 timestamps
297
- // - Configurable log levels (debug/info/warn/error)
298
- // - Error stack traces for error logs
299
- // - JSON format for machine parsing
300
- }
301
- ```
302
-
303
- - **error-handler.ts** - Centralized error handling
304
- - **file-utils.ts** - File system helpers
305
- - **formatters.ts** - Data formatting (bytes, dates, etc.)
306
-
307
- ### 5. Schemas Layer (`schemas/`)
308
-
309
- **Responsibility:** Input validation using Zod
310
-
311
- ```typescript
312
- // Example: Path validation
313
- export const PathSchema = z
314
- .string()
315
- .min(1, 'Path cannot be empty')
316
- .max(4096, 'Path exceeds maximum length')
317
- .refine((path) => !path.includes('\0'), 'Path contains null bytes');
318
- ```
319
-
320
- ## 🔄 Data Flow
321
-
322
- ### Example: Organize Files Operation
323
-
324
- ```
325
- 1. LLM Request
326
-
327
- 2. MCP Server (server.ts)
328
- - Parse JSON-RPC request
329
- - Route to organize tool
330
-
331
- 3. Tool Handler (tools/file-organization.ts)
332
- - Validate args with Zod
333
- - Call PathValidatorService
334
-
335
- 4. PathValidatorService
336
- - 7-layer validation
337
- - Return validated path
338
-
339
- 5. FileScannerService
340
- - Scan directory
341
- - Apply resource limits
342
-
343
- 6. CategorizerService
344
- - Categorize each file
345
-
346
- 7. OrganizerService
347
- - Generate organization plan
348
- - Check conflicts
349
- - Execute moves (if not dry run)
350
-
351
- 8. RollbackService
352
- - Create rollback manifest
353
-
354
- 9. Tool Handler
355
- - Format response (JSON/Markdown)
356
-
357
- 10. MCP Server
358
- - Send JSON-RPC response
359
-
360
- 11. LLM receives result
361
- ```
362
-
363
- ## 💾 File Organization
364
-
365
- ### Source Structure
366
-
367
- ```
368
- src/
369
- ├── server.ts # MCP server entry point
370
- ├── index.ts # Main entry point
371
- ├── types.ts # TypeScript type definitions
372
- ├── constants.ts # Application constants
373
- ├── config.ts # Configuration management
374
-
375
- ├── services/ # Core business logic
376
- │ ├── path-validator.service.ts
377
- │ ├── organizer.service.ts
378
- │ ├── hash-calculator.service.ts
379
- │ ├── file-scanner.service.ts
380
- │ ├── categorizer.service.ts
381
- │ └── rollback.service.ts
382
-
383
- ├── tools/ # MCP tool implementations
384
- │ ├── file-scanning.ts
385
- │ ├── file-organization.ts
386
- │ ├── file-duplicates.ts
387
- │ ├── file-categorization.ts
388
- │ └── ...
389
-
390
- ├── schemas/ # Zod validation schemas
391
- │ ├── security.schemas.ts
392
- │ ├── common.schemas.ts
393
- │ ├── scan.schemas.ts
394
- │ └── organize.schemas.ts
395
-
396
- └── utils/ # Shared utilities
397
- ├── logger.ts
398
- ├── error-handler.ts
399
- ├── file-utils.ts
400
- └── formatters.ts
401
- ```
402
-
403
- ## 🧪 Testing Architecture
404
-
405
- ### Test Structure
406
-
407
- ```
408
- tests/
409
- ├── unit/ # Unit tests for services
410
- │ ├── services/
411
- │ │ ├── path-validator.test.ts
412
- │ │ ├── organizer.test.ts
413
- │ │ └── ...
414
- └── utils/
415
-
416
- ├── integration/ # Integration tests for tools
417
- ├── tools/
418
- │ └── organize.test.ts
419
- │ └── edge-cases.test.ts
420
-
421
- └── performance/ # Performance benchmarks
422
- └── performance.test.ts
423
- ```
424
-
425
- ### Test Philosophy
426
-
427
- 1. **Unit Tests** - Test services in isolation
428
- 2. **Integration Tests** - Test complete workflows
429
- 3. **Security Tests** - Validate all security controls
430
- 4. **Performance Tests** - Ensure scalability
431
-
432
- ## 🚀 Performance Considerations
433
-
434
- ### Streaming Operations
435
-
436
- Large files are processed using streams to avoid memory exhaustion:
437
-
438
- ```typescript
439
- // Hash calculation uses streams
440
- const hash = crypto.createHash('sha256');
441
- const stream = createReadStream(filePath, { highWaterMark: 64 * 1024 });
442
- stream.on('data', (chunk) => hash.update(chunk));
443
- ```
444
-
445
- ### Resource Limits
446
-
447
- ```typescript
448
- // Enforced at multiple levels:
449
- - File size: Skip files > 100MB for hashing
450
- - File count: Max 10,000 files per operation
451
- - Recursion depth: Max 10 levels
452
- - Path length: Max 4,096 characters
453
- ```
454
-
455
- ### Caching Strategy
456
-
457
- - Category mappings cached in-memory
458
- - File stats cached during single operation
459
- - No persistent caching (stateless design)
460
-
461
- ## 🔧 Configuration
462
-
463
- ### Configuration System (`config.ts`)
464
-
465
- The server uses a platform-aware configuration system that combines hardcoded defaults with user customization.
466
-
467
- **Structure:**
468
-
469
- ```typescript
470
- export const CONFIG = {
471
- VERSION: '3.0.0',
472
-
473
- security: {
474
- enablePathValidation: true,
475
- allowCustomDirectories: true,
476
- logAccess: true,
477
- maxScanDepth: 10,
478
- maxFilesPerOperation: 10000,
479
- },
480
-
481
- paths: {
482
- defaultAllowed: getDefaultAllowedDirs(), // Platform-aware safe directories
483
- customAllowed: loadCustomAllowedDirs(), // User-defined from config.json
484
- alwaysBlocked: getAlwaysBlockedPatterns(), // System protection patterns
485
- },
486
- };
487
- ```
488
-
489
- **Default Allowed Directories:**
490
-
491
- - **Windows:** Desktop, Documents, Downloads, Pictures, Videos, Music, OneDrive, Projects
492
- - **macOS:** Desktop, Documents, Downloads, Movies, Music, Pictures, iCloud Drive, Projects
493
- - **Linux:** Desktop, Documents, Downloads, Music, Pictures, Videos, ~/dev, ~/workspace
494
-
495
- **User Configuration:**
496
-
497
- - **Windows:** `%APPDATA%\file-organizer-mcp\config.json`
498
- - **macOS:** `~/Library/Application Support/file-organizer-mcp/config.json`
499
- - **Linux:** `~/.config/file-organizer-mcp/config.json`
500
-
501
- **Config File Format:**
502
-
503
- ```json
504
- {
505
- "customAllowedDirectories": ["C:\\Users\\Name\\CustomFolder", "D:\\Projects"],
506
- "settings": {
507
- "maxScanDepth": 10,
508
- "logAccess": true
509
- }
510
- }
511
- ```
512
-
513
- ## 🎯 Design Patterns
514
-
515
- ### Dependency Injection
516
-
517
- ```typescript
518
- // Services receive dependencies via constructor
519
- class OrganizerService {
520
- constructor(
521
- private categorizer: CategorizerService,
522
- private rollback?: RollbackService
523
- ) {}
524
- }
525
- ```
526
-
527
- ### Error Handling
528
-
529
- ```typescript
530
- // Centralized error handling
531
- try {
532
- const result = await operation();
533
- } catch (error) {
534
- return createErrorResponse(error);
535
- }
536
- ```
537
-
538
- ### Type Safety
539
-
540
- ```typescript
541
- // Strict types with Zod runtime validation
542
- const ArgsSchema = z.object({
543
- directory: PathSchema,
544
- dry_run: z.boolean().optional(),
545
- });
546
-
547
- type Args = z.infer<typeof ArgsSchema>;
548
- ```
549
-
550
- ## 📊 Monitoring & Logging
551
-
552
- ### Structured Logging
553
-
554
- ```json
555
- {
556
- "timestamp": "2026-02-02T14:09:04.413Z",
557
- "level": "info",
558
- "message": "Created rollback manifest: uuid (6 actions)"
559
- }
560
- ```
561
-
562
- ### Log Levels
563
-
564
- - `error` - Critical failures
565
- - `warn` - Recoverable issues (e.g., skipped files)
566
- - `info` - Operation milestones
567
- - `debug` - Detailed diagnostics
568
-
569
- ## 🔮 Future Architecture Changes
570
-
571
- ### Planned Improvements
572
-
573
- 1. **Plugin System** - Allow custom categorization rules
574
- 2. **Database Layer** - Persistent state for large operations
575
- 3. **Queue System** - Background processing for large directories
576
- 4. **Metrics Collection** - Performance monitoring
577
- 5. **Multi-language Support** - i18n infrastructure
578
-
579
- ## 📚 References
580
-
581
- - [Model Context Protocol Spec](https://modelcontextprotocol.io)
582
- - [Zod Documentation](https://zod.dev)
583
- - [TypeScript Handbook](https://www.typescriptlang.org/docs)
584
-
585
- ---
586
-
587
- **Last Updated:** February 3, 2026
588
- **Version:** 3.0.0
1
+ # Architecture Documentation
2
+
3
+ ## 🏗️ System Overview
4
+
5
+ File Organizer MCP is a security-hardened Model Context Protocol (MCP) server that provides intelligent file organization capabilities to Large Language Models (LLMs). The architecture follows a layered service pattern with comprehensive security validation at every level.
6
+
7
+ ### Core Principles
8
+
9
+ 1. **Security First** - Multi-layer validation and sanitization
10
+ 2. **Service Isolation** - Clear separation of concerns
11
+ 3. **Type Safety** - Strict TypeScript with Zod validation
12
+ 4. **Testability** - Dependency injection and modular design
13
+ 5. **Performance** - Streaming operations and resource limits
14
+
15
+ ## 📐 Architecture Layers
16
+
17
+ ```
18
+ ┌─────────────────────────────────────────────────────────────┐
19
+ │ MCP Client (LLM) │
20
+ └─────────────────────────┬───────────────────────────────────┘
21
+ │ JSON-RPC 2.0
22
+ ┌─────────────────────────▼───────────────────────────────────┐
23
+ │ MCP Server Layer │
24
+ │ (server.ts - Protocol Handler) │
25
+ └─────────────────────────┬───────────────────────────────────┘
26
+
27
+ ┌─────────────────────────▼───────────────────────────────────┐
28
+ │ Tools Layer │
29
+ │ ┌──────────┬──────────┬───────────┬─────────────┐ │
30
+ │ │ Scan │ Organize │ Duplicate │ Categorize │ │
31
+ │ │ Files │ Files │ Find │ Files │ │
32
+ │ └──────────┴──────────┴───────────┴─────────────┘ │
33
+ └─────────────────────────┬───────────────────────────────────┘
34
+
35
+ ┌─────────────────────────▼───────────────────────────────────┐
36
+ │ Services Layer │
37
+ │ ┌────────────┬──────────────┬─────────────┬──────────┐ │
38
+ │ │ Path │ Organizer │ Hash │ Scanner │ │
39
+ │ │ Validator │ Service │ Calculator │ Service │ │
40
+ │ └────────────┴──────────────┴─────────────┴──────────┘ │
41
+ └─────────────────────────┬───────────────────────────────────┘
42
+
43
+ ┌─────────────────────────▼───────────────────────────────────┐
44
+ │ Utils Layer │
45
+ │ ┌──────────┬──────────┬───────────┬──────────┐ │
46
+ │ │ Logger │ Error │ File │ Format- │ │
47
+ │ │ │ Handler │ Utils │ ters │ │
48
+ │ └──────────┴──────────┴───────────┴──────────┘ │
49
+ └─────────────────────────┬───────────────────────────────────┘
50
+
51
+ ┌─────────────────────────▼───────────────────────────────────┐
52
+ │ File System │
53
+ └─────────────────────────────────────────────────────────────┘
54
+ ```
55
+
56
+ ## 🔐 Security Architecture
57
+
58
+ ### 8-Layer Path Validation Pipeline
59
+
60
+ Every file path goes through these validation layers:
61
+
62
+ ```typescript
63
+ Input Path
64
+
65
+ 1. Type Validation (Zod Schema)
66
+
67
+ 2. Null Byte & Basic Sanitization
68
+
69
+ 3. Path Normalization & Windows Case Adjustment
70
+
71
+ 4. Traversal Sequence Prevention (../)
72
+
73
+ 5. Absolute Path Resolution
74
+
75
+ 6. Security Check (Whitelist & Blacklist)
76
+
77
+ 7. Symlink Resolution & Target Validation
78
+
79
+ 8. Existence & Access Check
80
+
81
+ Validated Path ✅
82
+ ```
83
+
84
+ **Implementation:** [`src/services/path-validator.service.ts`](file:///c:/Users/NewAdmin/Desktop/File-Organizer-MCP/src/services/path-validator.service.ts)
85
+
86
+ ### Race Condition Mitigation (TOCTOU Protection) - v3.1.4 Updates
87
+
88
+ **Problem:** Time-of-Check-Time-of-Use vulnerabilities can occur when a file is checked, then used later, allowing an attacker to swap the file between operations.
89
+
90
+ **v3.1.4 TOCTOU Fixes and Race Condition Prevention:**
91
+
92
+ 1. **File Descriptor Validation**
93
+ - Open files with `O_NOFOLLOW` flag to prevent symlink attacks
94
+ - Use file descriptors directly rather than path strings after initial validation
95
+ - Release file handles immediately after use to minimize attack window
96
+
97
+ 2. **Atomic File Operations**
98
+ - Use `COPYFILE_EXCL` flag for atomic copy operations (fails if destination exists)
99
+ - Use `O_EXCL` flag when creating files to prevent race conditions
100
+ - Utilize `rename()` for atomic moves within the same filesystem
101
+
102
+ 3. **Retry Logic with Jitter**
103
+ - Implement exponential backoff with random jitter for retry operations
104
+ - Maximum 3 retries with increasing delays (10ms, 50ms, 100ms)
105
+ - Fail fast after retries to prevent denial-of-service
106
+
107
+ 4. **Safe Overwrite Pattern**
108
+ - Write to temporary file in target directory first
109
+ - Sync file to disk before atomic rename
110
+ - Move existing file to backup before replacing
111
+
112
+ ```typescript
113
+ // Safe overwrite with atomic rename
114
+ const tempPath = path.join(targetDir, `.tmp_${Date.now()}_${basename}`);
115
+ await fs.writeFile(tempPath, content);
116
+ await fs.rename(tempPath, targetPath); // Atomic on same filesystem
117
+ ```
118
+
119
+ 5. **Verification After Operations**
120
+ - Re-validate file stats after critical operations
121
+ - Verify file hash matches expected value after write
122
+ - Check file permissions haven't changed unexpectedly
123
+
124
+ **Limitations:**
125
+
126
+ - File deletion on Windows uses path-based locking (not file descriptor)
127
+ - Symlinks are blocked for security but may limit legitimate use cases
128
+
129
+ ### Resource Protection
130
+
131
+ ```typescript
132
+ // Security Constants
133
+ const SECURITY_LIMITS = {
134
+ MAX_FILE_SIZE: 100 * 1024 * 1024, // 100 MB
135
+ MAX_FILES: 10000, // Per operation
136
+ MAX_DEPTH: 10, // Directory recursion
137
+ MAX_PATH_LENGTH: 4096, // Characters
138
+ };
139
+ ```
140
+
141
+ ## 📦 Core Components
142
+
143
+ ### 1. Server Layer (`server.ts`)
144
+
145
+ **Responsibility:** MCP protocol handling and tool registration
146
+
147
+ ```typescript
148
+ // Key responsibilities:
149
+ - Initialize MCP server
150
+ - Register tools with schemas
151
+ - Handle tool invocations
152
+ - Manage error responses
153
+ - Coordinate with services
154
+ ```
155
+
156
+ **Key Features:**
157
+
158
+ - Automatic tool discovery from `tools/` directory
159
+ - Structured response formatting (JSON/Markdown)
160
+ - Centralized error handling
161
+
162
+ ### 2. Tools Layer (`tools/`)
163
+
164
+ **Responsibility:** MCP tool implementations (user-facing API)
165
+
166
+ Each tool follows this pattern:
167
+
168
+ ```typescript
169
+ export const toolDefinition: ToolDefinition = {
170
+ name: 'tool_name',
171
+ description: 'What it does',
172
+ inputSchema: ZodSchema, // Validation
173
+ };
174
+
175
+ export async function handleTool(args: ToolArgs): Promise<ToolResponse> {
176
+ // 1. Validate inputs (Zod)
177
+ // 2. Validate security (PathValidator)
178
+ // 3. Call service layer
179
+ // 4. Format response
180
+ // 5. Handle errors
181
+ }
182
+ ```
183
+
184
+ **Available Tools:**
185
+
186
+ 1. **List Files in Directory** (`file_organizer_list_files`)
187
+ 2. **Scan Directory for Detailed Info** (`file_organizer_scan_directory`)
188
+ 3. **Categorize Files by Type** (`file_organizer_categorize_files`)
189
+ 4. **Find Largest Files** (`file_organizer_find_largest_files`)
190
+ 5. **Find Duplicate Files** (`file_organizer_find_duplicate_files`)
191
+ 6. **Preview File Organization Plan** (`file_organizer_preview_organization`)
192
+ 7. **Get Available File Categories** (`file_organizer_get_categories`)
193
+ 8. **Analyze Duplicate Files with Smart Recommendations** (`file_organizer_analyze_duplicates`)
194
+ 9. **Organize Files** (`file_organizer_organize_files`)
195
+ 10. **Set Custom Organization Rules** (`file_organizer_set_custom_rules`)
196
+ 11. **Delete Duplicate Files** (`file_organizer_delete_duplicates`)
197
+ 12. **Undo Last Organization Operation** (`file_organizer_undo_last_operation`)
198
+
199
+ ### 3. Services Layer (`services/`)
200
+
201
+ **Responsibility:** Core business logic
202
+
203
+ **Service Versions:** All services v3.1.3 or v3.1.4
204
+
205
+ #### PathValidatorService (v3.1.3)
206
+
207
+ ```typescript
208
+ class PathValidatorService {
209
+ // Multi-layer path validation
210
+ async validateStrictPath(inputPath: unknown, options?: ValidatePathOptions): Promise<string>;
211
+
212
+ // Symlink resolution
213
+ async resolvePath(path: string): Promise<string>;
214
+
215
+ // Containment checking
216
+ isPathWithinRoots(path: string, roots: string[]): boolean;
217
+ }
218
+ ```
219
+
220
+ #### OrganizerService (v3.1.4)
221
+
222
+ ```typescript
223
+ class OrganizerService {
224
+ // Generate organization plan
225
+ async generateOrganizationPlan(
226
+ directory: string,
227
+ files: FileWithSize[],
228
+ strategy?: ConflictStrategy // 'rename' | 'skip' | 'overwrite' | 'overwrite_if_newer'
229
+ ): Promise<OrganizationPlan>;
230
+
231
+ // Execute organization with safety guarantees
232
+ async organize(
233
+ directory: string,
234
+ files: FileWithSize[],
235
+ options?: OrganizeOptions
236
+ ): Promise<OrganizeResult>;
237
+
238
+ // Safety mechanisms:
239
+ // 1. File descriptor validation before move
240
+ // 2. Atomic copy with COPYFILE_EXCL (race-safe)
241
+ // 3. Automatic backup to .file-organizer-backups/ on overwrite
242
+ // 4. Retry loop for race condition recovery
243
+ }
244
+ ```
245
+
246
+ #### HashCalculatorService
247
+
248
+ ```typescript
249
+ class HashCalculatorService {
250
+ // Streaming hash calculation
251
+ async calculateHash(filePath: string): Promise<string>;
252
+
253
+ // Find duplicates (memory-safe)
254
+ async findDuplicates(files: FileWithSize[]): Promise<DuplicateGroup[]>;
255
+ }
256
+ ```
257
+
258
+ #### FileScannerService (v3.1.4)
259
+
260
+ ```typescript
261
+ class FileScannerService {
262
+ // Recursive directory scanning
263
+ async getAllFiles(directory: string, options?: ScanOptions): Promise<FileWithSize[]>;
264
+
265
+ // Size calculation
266
+ async calculateDirectorySize(directory: string): Promise<number>;
267
+ }
268
+ ```
269
+
270
+ #### CategorizerService
271
+
272
+ ```typescript
273
+ class CategorizerService {
274
+ // File categorization
275
+ getCategory(fileName: string): CategoryName;
276
+
277
+ // Custom rules support
278
+ setCustomRules(rules: CategoryRule[]): void;
279
+
280
+ // Category statistics
281
+ categorizeFiles(files: FileWithSize[]): CategoryBreakdown;
282
+ }
283
+ ```
284
+
285
+ #### RollbackService (v3.1.4)
286
+
287
+ ```typescript
288
+ class RollbackService {
289
+ // Create rollback manifest
290
+ async createManifest(actions: OrganizeAction[]): Promise<string>;
291
+
292
+ // Execute rollback
293
+ async rollback(manifestId: string): Promise<RollbackResult>;
294
+
295
+ // List available rollbacks
296
+ async listRollbacks(): Promise<RollbackManifest[]>;
297
+ }
298
+ ```
299
+
300
+ ### 4. File Reader Module (`readers/`) ⭐ NEW in v3.2.0
301
+
302
+ **Responsibility:** Secure file reading with comprehensive security controls
303
+
304
+ **Architecture:** 3-layer security architecture with Result-based error handling
305
+
306
+ #### SecureFileReader
307
+
308
+ ```typescript
309
+ class SecureFileReader {
310
+ // Read file with full security validation
311
+ async read(
312
+ filePath: string,
313
+ options?: Partial<FileReadOptions>
314
+ ): Promise<Result<FileReadResult, FileReadError>>;
315
+
316
+ // Create readable stream for large files
317
+ async readStream(
318
+ filePath: string,
319
+ options?: Partial<FileReadOptions>
320
+ ): Promise<Result<Readable, FileReadError>>;
321
+
322
+ // Read raw buffer (binary data)
323
+ async readBuffer(
324
+ filePath: string,
325
+ options?: Partial<FileReadOptions>
326
+ ): Promise<Result<Buffer, FileReadError>>;
327
+ }
328
+ ```
329
+
330
+ **Security Layers:**
331
+
332
+ 1. **Layer 1 - Input Validation:**
333
+ - Path validation using PathValidatorService
334
+ - Sensitive file pattern checking (47+ patterns)
335
+ - Zod schema validation for inputs
336
+
337
+ 2. **Layer 2 - Security Controls:**
338
+ - Rate limiting (120 req/min, 2000 req/hour)
339
+ - Audit logging (all operations logged)
340
+ - Size limits (default 10MB, max 100MB)
341
+
342
+ 3. **Layer 3 - Execution:**
343
+ - TOCTOU-safe file opening with O_NOFOLLOW
344
+ - SHA-256 checksum calculation
345
+ - Streaming for large files (>100KB)
346
+
347
+ **Error Types:**
348
+
349
+ - `FileNotFoundError` - File doesn't exist
350
+ - `FileAccessDeniedError` - Permission denied or sensitive file
351
+ - `FileTooLargeError` - Exceeds size limit
352
+ - `PathValidationError` - Security check failed
353
+ - `RateLimitError` - Too many requests
354
+
355
+ #### FileReaderFactory
356
+
357
+ ```typescript
358
+ class FileReaderFactory {
359
+ // Create with default settings
360
+ static createDefault(): SecureFileReader;
361
+
362
+ // Create with custom options
363
+ static createWithOptions(options: ReaderOptions): SecureFileReader;
364
+ }
365
+ ```
366
+
367
+ **Integration:** The File Reader is exposed via the `file_organizer_read_file` MCP tool with Zod schema validation.
368
+
369
+ ### 5. Utils Layer (`utils/`)
370
+
371
+ **Responsibility:** Shared utility functions
372
+
373
+ #### Logger
374
+
375
+ ```typescript
376
+ class Logger {
377
+ // Structured JSON logging to stderr (MCP stdio protocol)
378
+ debug(message: string, context?: Record<string, any>): void;
379
+ info(message: string, context?: Record<string, any>): void;
380
+ warn(message: string, context?: Record<string, any>): void;
381
+ error(message: string, error?: Error, context?: Record<string, any>): void;
382
+
383
+ // Features:
384
+ // - ISO 8601 timestamps
385
+ // - Configurable log levels (debug/info/warn/error)
386
+ // - Error stack traces for error logs
387
+ // - JSON format for machine parsing
388
+ }
389
+ ```
390
+
391
+ - **error-handler.ts** - Centralized error handling
392
+ - **file-utils.ts** - File system helpers
393
+ - **formatters.ts** - Data formatting (bytes, dates, etc.)
394
+
395
+ ### 5. Schemas Layer (`schemas/`)
396
+
397
+ **Responsibility:** Input validation using Zod
398
+
399
+ ```typescript
400
+ // Example: Path validation
401
+ export const PathSchema = z
402
+ .string()
403
+ .min(1, 'Path cannot be empty')
404
+ .max(4096, 'Path exceeds maximum length')
405
+ .refine((path) => !path.includes('\0'), 'Path contains null bytes');
406
+ ```
407
+
408
+ ## 🔄 Data Flow
409
+
410
+ ### Example: Organize Files Operation
411
+
412
+ ```
413
+ 1. LLM Request
414
+
415
+ 2. MCP Server (server.ts)
416
+ - Parse JSON-RPC request
417
+ - Route to organize tool
418
+
419
+ 3. Tool Handler (tools/file-organization.ts)
420
+ - Validate args with Zod
421
+ - Call PathValidatorService
422
+
423
+ 4. PathValidatorService
424
+ - 7-layer validation
425
+ - Return validated path
426
+
427
+ 5. FileScannerService
428
+ - Scan directory
429
+ - Apply resource limits
430
+
431
+ 6. CategorizerService
432
+ - Categorize each file
433
+
434
+ 7. OrganizerService
435
+ - Generate organization plan
436
+ - Check conflicts
437
+ - Execute moves (if not dry run)
438
+
439
+ 8. RollbackService
440
+ - Create rollback manifest
441
+
442
+ 9. Tool Handler
443
+ - Format response (JSON/Markdown)
444
+
445
+ 10. MCP Server
446
+ - Send JSON-RPC response
447
+
448
+ 11. LLM receives result
449
+ ```
450
+
451
+ ## 💾 File Organization
452
+
453
+ ### Source Structure
454
+
455
+ ```
456
+ src/
457
+ ├── server.ts # MCP server entry point
458
+ ├── index.ts # Main entry point
459
+ ├── types.ts # TypeScript type definitions
460
+ ├── constants.ts # Application constants
461
+ ├── config.ts # Configuration management
462
+
463
+ ├── services/ # Core business logic
464
+ │ ├── path-validator.service.ts
465
+ │ ├── organizer.service.ts
466
+ │ ├── hash-calculator.service.ts
467
+ │ ├── file-scanner.service.ts
468
+ │ ├── categorizer.service.ts
469
+ │ └── rollback.service.ts
470
+
471
+ ├── tools/ # MCP tool implementations
472
+ │ ├── file-scanning.ts
473
+ │ ├── file-organization.ts
474
+ │ ├── file-duplicates.ts
475
+ │ ├── file-categorization.ts
476
+ │ └── ...
477
+
478
+ ├── schemas/ # Zod validation schemas
479
+ │ ├── security.schemas.ts
480
+ │ ├── common.schemas.ts
481
+ │ ├── scan.schemas.ts
482
+ │ └── organize.schemas.ts
483
+
484
+ └── utils/ # Shared utilities
485
+ ├── logger.ts
486
+ ├── error-handler.ts
487
+ ├── file-utils.ts
488
+ └── formatters.ts
489
+ ```
490
+
491
+ ## 🧪 Testing Architecture
492
+
493
+ ### Test Structure
494
+
495
+ ```
496
+ tests/
497
+ ├── unit/ # Unit tests for services
498
+ │ ├── services/
499
+ │ │ ├── path-validator.test.ts
500
+ │ │ ├── organizer.test.ts
501
+ │ │ └── ...
502
+ │ └── utils/
503
+
504
+ ├── integration/ # Integration tests for tools
505
+ │ ├── tools/
506
+ │ │ └── organize.test.ts
507
+ │ └── edge-cases.test.ts
508
+
509
+ └── performance/ # Performance benchmarks
510
+ └── performance.test.ts
511
+ ```
512
+
513
+ ### Test Philosophy
514
+
515
+ 1. **Unit Tests** - Test services in isolation
516
+ 2. **Integration Tests** - Test complete workflows
517
+ 3. **Security Tests** - Validate all security controls
518
+ 4. **Performance Tests** - Ensure scalability
519
+
520
+ ## 🚀 Performance Considerations
521
+
522
+ ### Streaming Operations
523
+
524
+ Large files are processed using streams to avoid memory exhaustion:
525
+
526
+ ```typescript
527
+ // Hash calculation uses streams
528
+ const hash = crypto.createHash('sha256');
529
+ const stream = createReadStream(filePath, { highWaterMark: 64 * 1024 });
530
+ stream.on('data', (chunk) => hash.update(chunk));
531
+ ```
532
+
533
+ ### Resource Limits
534
+
535
+ ```typescript
536
+ // Enforced at multiple levels:
537
+ - File size: Skip files > 100MB for hashing
538
+ - File count: Max 10,000 files per operation
539
+ - Recursion depth: Max 10 levels
540
+ - Path length: Max 4,096 characters
541
+ ```
542
+
543
+ ### Caching Strategy
544
+
545
+ - Category mappings cached in-memory
546
+ - File stats cached during single operation
547
+ - No persistent caching (stateless design)
548
+
549
+ ## 🔧 Configuration
550
+
551
+ ### Configuration System (`config.ts`)
552
+
553
+ The server uses a platform-aware configuration system that combines hardcoded defaults with user customization.
554
+
555
+ **Structure:**
556
+
557
+ ```typescript
558
+ export const CONFIG = {
559
+ VERSION: '3.1.5',
560
+
561
+ security: {
562
+ enablePathValidation: true,
563
+ allowCustomDirectories: true,
564
+ logAccess: true,
565
+ maxScanDepth: 10,
566
+ maxFilesPerOperation: 10000,
567
+ },
568
+
569
+ paths: {
570
+ defaultAllowed: getDefaultAllowedDirs(), // Platform-aware safe directories
571
+ customAllowed: loadCustomAllowedDirs(), // User-defined from config.json
572
+ alwaysBlocked: getAlwaysBlockedPatterns(), // System protection patterns
573
+ },
574
+ };
575
+ ```
576
+
577
+ **Default Allowed Directories:**
578
+
579
+ - **Windows:** Desktop, Documents, Downloads, Pictures, Videos, Music, OneDrive, Projects
580
+ - **macOS:** Desktop, Documents, Downloads, Movies, Music, Pictures, iCloud Drive, Projects
581
+ - **Linux:** Desktop, Documents, Downloads, Music, Pictures, Videos, ~/dev, ~/workspace
582
+
583
+ **User Configuration:**
584
+
585
+ - **Windows:** `%APPDATA%\file-organizer-mcp\config.json`
586
+ - **macOS:** `~/Library/Application Support/file-organizer-mcp/config.json`
587
+ - **Linux:** `~/.config/file-organizer-mcp/config.json`
588
+
589
+ **Config File Format:**
590
+
591
+ ```json
592
+ {
593
+ "customAllowedDirectories": ["C:\\Users\\Name\\CustomFolder", "D:\\Projects"],
594
+ "settings": {
595
+ "maxScanDepth": 10,
596
+ "logAccess": true
597
+ }
598
+ }
599
+ ```
600
+
601
+ ## 🎯 Design Patterns
602
+
603
+ ### Dependency Injection
604
+
605
+ ```typescript
606
+ // Services receive dependencies via constructor
607
+ class OrganizerService {
608
+ constructor(
609
+ private categorizer: CategorizerService,
610
+ private rollback?: RollbackService
611
+ ) {}
612
+ }
613
+ ```
614
+
615
+ ### Error Handling
616
+
617
+ ```typescript
618
+ // Centralized error handling
619
+ try {
620
+ const result = await operation();
621
+ } catch (error) {
622
+ return createErrorResponse(error);
623
+ }
624
+ ```
625
+
626
+ ### Type Safety
627
+
628
+ ```typescript
629
+ // Strict types with Zod runtime validation
630
+ const ArgsSchema = z.object({
631
+ directory: PathSchema,
632
+ dry_run: z.boolean().optional(),
633
+ });
634
+
635
+ type Args = z.infer<typeof ArgsSchema>;
636
+ ```
637
+
638
+ ## 📊 Monitoring & Logging
639
+
640
+ ### Structured Logging
641
+
642
+ ```json
643
+ {
644
+ "timestamp": "2026-02-08T00:00:00.000Z",
645
+ "level": "info",
646
+ "message": "Created rollback manifest: uuid (6 actions)"
647
+ }
648
+ ```
649
+
650
+ ### Log Levels
651
+
652
+ - `error` - Critical failures
653
+ - `warn` - Recoverable issues (e.g., skipped files)
654
+ - `info` - Operation milestones
655
+ - `debug` - Detailed diagnostics
656
+
657
+ ## 🔮 Future Architecture Changes
658
+
659
+ ### Planned Improvements
660
+
661
+ 1. **Plugin System** - Allow custom categorization rules
662
+ 2. **Database Layer** - Persistent state for large operations
663
+ 3. **Queue System** - Background processing for large directories
664
+ 4. **Metrics Collection** - Performance monitoring
665
+ 5. **Multi-language Support** - i18n infrastructure
666
+
667
+ ## 📚 References
668
+
669
+ - [Model Context Protocol Spec](https://modelcontextprotocol.io)
670
+ - [Zod Documentation](https://zod.dev)
671
+ - [TypeScript Handbook](https://www.typescriptlang.org/docs)
672
+
673
+ ---
674
+
675
+ **Last Updated:** February 8, 2026
676
+ **Version:** 3.1.5