onbuzz 3.3.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 (506) hide show
  1. package/LICENSE +267 -0
  2. package/README.md +425 -0
  3. package/bin/cli.js +556 -0
  4. package/bin/loxia-terminal-v2.js +162 -0
  5. package/bin/loxia-terminal.js +90 -0
  6. package/bin/start-with-terminal.js +200 -0
  7. package/node_modules/@isaacs/balanced-match/LICENSE.md +23 -0
  8. package/node_modules/@isaacs/balanced-match/README.md +60 -0
  9. package/node_modules/@isaacs/balanced-match/dist/commonjs/index.d.ts +9 -0
  10. package/node_modules/@isaacs/balanced-match/dist/commonjs/index.d.ts.map +1 -0
  11. package/node_modules/@isaacs/balanced-match/dist/commonjs/index.js +59 -0
  12. package/node_modules/@isaacs/balanced-match/dist/commonjs/index.js.map +1 -0
  13. package/node_modules/@isaacs/balanced-match/dist/commonjs/package.json +3 -0
  14. package/node_modules/@isaacs/balanced-match/dist/esm/index.d.ts +9 -0
  15. package/node_modules/@isaacs/balanced-match/dist/esm/index.d.ts.map +1 -0
  16. package/node_modules/@isaacs/balanced-match/dist/esm/index.js +54 -0
  17. package/node_modules/@isaacs/balanced-match/dist/esm/index.js.map +1 -0
  18. package/node_modules/@isaacs/balanced-match/dist/esm/package.json +3 -0
  19. package/node_modules/@isaacs/balanced-match/package.json +79 -0
  20. package/node_modules/@isaacs/brace-expansion/LICENSE +23 -0
  21. package/node_modules/@isaacs/brace-expansion/README.md +97 -0
  22. package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.d.ts +6 -0
  23. package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
  24. package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js +199 -0
  25. package/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js.map +1 -0
  26. package/node_modules/@isaacs/brace-expansion/dist/commonjs/package.json +3 -0
  27. package/node_modules/@isaacs/brace-expansion/dist/esm/index.d.ts +6 -0
  28. package/node_modules/@isaacs/brace-expansion/dist/esm/index.d.ts.map +1 -0
  29. package/node_modules/@isaacs/brace-expansion/dist/esm/index.js +195 -0
  30. package/node_modules/@isaacs/brace-expansion/dist/esm/index.js.map +1 -0
  31. package/node_modules/@isaacs/brace-expansion/dist/esm/package.json +3 -0
  32. package/node_modules/@isaacs/brace-expansion/package.json +60 -0
  33. package/node_modules/glob/LICENSE.md +63 -0
  34. package/node_modules/glob/README.md +1177 -0
  35. package/node_modules/glob/dist/commonjs/glob.d.ts +388 -0
  36. package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -0
  37. package/node_modules/glob/dist/commonjs/glob.js +247 -0
  38. package/node_modules/glob/dist/commonjs/glob.js.map +1 -0
  39. package/node_modules/glob/dist/commonjs/has-magic.d.ts +14 -0
  40. package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -0
  41. package/node_modules/glob/dist/commonjs/has-magic.js +27 -0
  42. package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -0
  43. package/node_modules/glob/dist/commonjs/ignore.d.ts +24 -0
  44. package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -0
  45. package/node_modules/glob/dist/commonjs/ignore.js +119 -0
  46. package/node_modules/glob/dist/commonjs/ignore.js.map +1 -0
  47. package/node_modules/glob/dist/commonjs/index.d.ts +97 -0
  48. package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -0
  49. package/node_modules/glob/dist/commonjs/index.js +68 -0
  50. package/node_modules/glob/dist/commonjs/index.js.map +1 -0
  51. package/node_modules/glob/dist/commonjs/index.min.js +4 -0
  52. package/node_modules/glob/dist/commonjs/index.min.js.map +7 -0
  53. package/node_modules/glob/dist/commonjs/package.json +3 -0
  54. package/node_modules/glob/dist/commonjs/pattern.d.ts +76 -0
  55. package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -0
  56. package/node_modules/glob/dist/commonjs/pattern.js +219 -0
  57. package/node_modules/glob/dist/commonjs/pattern.js.map +1 -0
  58. package/node_modules/glob/dist/commonjs/processor.d.ts +59 -0
  59. package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -0
  60. package/node_modules/glob/dist/commonjs/processor.js +301 -0
  61. package/node_modules/glob/dist/commonjs/processor.js.map +1 -0
  62. package/node_modules/glob/dist/commonjs/walker.d.ts +97 -0
  63. package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -0
  64. package/node_modules/glob/dist/commonjs/walker.js +387 -0
  65. package/node_modules/glob/dist/commonjs/walker.js.map +1 -0
  66. package/node_modules/glob/dist/esm/glob.d.ts +388 -0
  67. package/node_modules/glob/dist/esm/glob.d.ts.map +1 -0
  68. package/node_modules/glob/dist/esm/glob.js +243 -0
  69. package/node_modules/glob/dist/esm/glob.js.map +1 -0
  70. package/node_modules/glob/dist/esm/has-magic.d.ts +14 -0
  71. package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -0
  72. package/node_modules/glob/dist/esm/has-magic.js +23 -0
  73. package/node_modules/glob/dist/esm/has-magic.js.map +1 -0
  74. package/node_modules/glob/dist/esm/ignore.d.ts +24 -0
  75. package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -0
  76. package/node_modules/glob/dist/esm/ignore.js +115 -0
  77. package/node_modules/glob/dist/esm/ignore.js.map +1 -0
  78. package/node_modules/glob/dist/esm/index.d.ts +97 -0
  79. package/node_modules/glob/dist/esm/index.d.ts.map +1 -0
  80. package/node_modules/glob/dist/esm/index.js +55 -0
  81. package/node_modules/glob/dist/esm/index.js.map +1 -0
  82. package/node_modules/glob/dist/esm/index.min.js +4 -0
  83. package/node_modules/glob/dist/esm/index.min.js.map +7 -0
  84. package/node_modules/glob/dist/esm/package.json +3 -0
  85. package/node_modules/glob/dist/esm/pattern.d.ts +76 -0
  86. package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -0
  87. package/node_modules/glob/dist/esm/pattern.js +215 -0
  88. package/node_modules/glob/dist/esm/pattern.js.map +1 -0
  89. package/node_modules/glob/dist/esm/processor.d.ts +59 -0
  90. package/node_modules/glob/dist/esm/processor.d.ts.map +1 -0
  91. package/node_modules/glob/dist/esm/processor.js +294 -0
  92. package/node_modules/glob/dist/esm/processor.js.map +1 -0
  93. package/node_modules/glob/dist/esm/walker.d.ts +97 -0
  94. package/node_modules/glob/dist/esm/walker.d.ts.map +1 -0
  95. package/node_modules/glob/dist/esm/walker.js +381 -0
  96. package/node_modules/glob/dist/esm/walker.js.map +1 -0
  97. package/node_modules/glob/node_modules/minimatch/LICENSE.md +55 -0
  98. package/node_modules/glob/node_modules/minimatch/README.md +453 -0
  99. package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
  100. package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
  101. package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
  102. package/node_modules/glob/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
  103. package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.d.ts +20 -0
  104. package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
  105. package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.js +591 -0
  106. package/node_modules/glob/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
  107. package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
  108. package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
  109. package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.js +152 -0
  110. package/node_modules/glob/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
  111. package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.d.ts +15 -0
  112. package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
  113. package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.js +30 -0
  114. package/node_modules/glob/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
  115. package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.d.ts +94 -0
  116. package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
  117. package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js +1029 -0
  118. package/node_modules/glob/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
  119. package/node_modules/glob/node_modules/minimatch/dist/commonjs/package.json +3 -0
  120. package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.d.ts +22 -0
  121. package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
  122. package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
  123. package/node_modules/glob/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
  124. package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
  125. package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
  126. package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
  127. package/node_modules/glob/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
  128. package/node_modules/glob/node_modules/minimatch/dist/esm/ast.d.ts +20 -0
  129. package/node_modules/glob/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
  130. package/node_modules/glob/node_modules/minimatch/dist/esm/ast.js +587 -0
  131. package/node_modules/glob/node_modules/minimatch/dist/esm/ast.js.map +1 -0
  132. package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
  133. package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
  134. package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js +148 -0
  135. package/node_modules/glob/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
  136. package/node_modules/glob/node_modules/minimatch/dist/esm/escape.d.ts +15 -0
  137. package/node_modules/glob/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
  138. package/node_modules/glob/node_modules/minimatch/dist/esm/escape.js +26 -0
  139. package/node_modules/glob/node_modules/minimatch/dist/esm/escape.js.map +1 -0
  140. package/node_modules/glob/node_modules/minimatch/dist/esm/index.d.ts +94 -0
  141. package/node_modules/glob/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
  142. package/node_modules/glob/node_modules/minimatch/dist/esm/index.js +1016 -0
  143. package/node_modules/glob/node_modules/minimatch/dist/esm/index.js.map +1 -0
  144. package/node_modules/glob/node_modules/minimatch/dist/esm/package.json +3 -0
  145. package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.d.ts +22 -0
  146. package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
  147. package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.js +34 -0
  148. package/node_modules/glob/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
  149. package/node_modules/glob/node_modules/minimatch/package.json +67 -0
  150. package/node_modules/glob/package.json +101 -0
  151. package/node_modules/minipass/LICENSE +15 -0
  152. package/node_modules/minipass/README.md +825 -0
  153. package/node_modules/minipass/dist/commonjs/index.d.ts +549 -0
  154. package/node_modules/minipass/dist/commonjs/index.d.ts.map +1 -0
  155. package/node_modules/minipass/dist/commonjs/index.js +1028 -0
  156. package/node_modules/minipass/dist/commonjs/index.js.map +1 -0
  157. package/node_modules/minipass/dist/commonjs/package.json +3 -0
  158. package/node_modules/minipass/dist/esm/index.d.ts +549 -0
  159. package/node_modules/minipass/dist/esm/index.d.ts.map +1 -0
  160. package/node_modules/minipass/dist/esm/index.js +1018 -0
  161. package/node_modules/minipass/dist/esm/index.js.map +1 -0
  162. package/node_modules/minipass/dist/esm/package.json +3 -0
  163. package/node_modules/minipass/package.json +82 -0
  164. package/node_modules/package-json-from-dist/LICENSE.md +63 -0
  165. package/node_modules/package-json-from-dist/README.md +110 -0
  166. package/node_modules/package-json-from-dist/dist/commonjs/index.d.ts +89 -0
  167. package/node_modules/package-json-from-dist/dist/commonjs/index.d.ts.map +1 -0
  168. package/node_modules/package-json-from-dist/dist/commonjs/index.js +134 -0
  169. package/node_modules/package-json-from-dist/dist/commonjs/index.js.map +1 -0
  170. package/node_modules/package-json-from-dist/dist/commonjs/package.json +3 -0
  171. package/node_modules/package-json-from-dist/dist/esm/index.d.ts +89 -0
  172. package/node_modules/package-json-from-dist/dist/esm/index.d.ts.map +1 -0
  173. package/node_modules/package-json-from-dist/dist/esm/index.js +129 -0
  174. package/node_modules/package-json-from-dist/dist/esm/index.js.map +1 -0
  175. package/node_modules/package-json-from-dist/dist/esm/package.json +3 -0
  176. package/node_modules/package-json-from-dist/package.json +68 -0
  177. package/node_modules/path-scurry/LICENSE.md +55 -0
  178. package/node_modules/path-scurry/README.md +636 -0
  179. package/node_modules/path-scurry/dist/commonjs/index.d.ts +1115 -0
  180. package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -0
  181. package/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
  182. package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -0
  183. package/node_modules/path-scurry/dist/commonjs/package.json +3 -0
  184. package/node_modules/path-scurry/dist/esm/index.d.ts +1115 -0
  185. package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -0
  186. package/node_modules/path-scurry/dist/esm/index.js +1983 -0
  187. package/node_modules/path-scurry/dist/esm/index.js.map +1 -0
  188. package/node_modules/path-scurry/dist/esm/package.json +3 -0
  189. package/node_modules/path-scurry/node_modules/lru-cache/LICENSE.md +55 -0
  190. package/node_modules/path-scurry/node_modules/lru-cache/README.md +383 -0
  191. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts +1323 -0
  192. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -0
  193. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +1589 -0
  194. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js.map +1 -0
  195. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
  196. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js.map +7 -0
  197. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +3 -0
  198. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts +1323 -0
  199. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -0
  200. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +1585 -0
  201. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js.map +1 -0
  202. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +2 -0
  203. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js.map +7 -0
  204. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +3 -0
  205. package/node_modules/path-scurry/node_modules/lru-cache/package.json +101 -0
  206. package/node_modules/path-scurry/package.json +88 -0
  207. package/node_modules/rimraf/LICENSE.md +55 -0
  208. package/node_modules/rimraf/README.md +226 -0
  209. package/node_modules/rimraf/dist/commonjs/default-tmp.d.ts +3 -0
  210. package/node_modules/rimraf/dist/commonjs/default-tmp.d.ts.map +1 -0
  211. package/node_modules/rimraf/dist/commonjs/default-tmp.js +58 -0
  212. package/node_modules/rimraf/dist/commonjs/default-tmp.js.map +1 -0
  213. package/node_modules/rimraf/dist/commonjs/error.d.ts +6 -0
  214. package/node_modules/rimraf/dist/commonjs/error.d.ts.map +1 -0
  215. package/node_modules/rimraf/dist/commonjs/error.js +10 -0
  216. package/node_modules/rimraf/dist/commonjs/error.js.map +1 -0
  217. package/node_modules/rimraf/dist/commonjs/fix-eperm.d.ts +3 -0
  218. package/node_modules/rimraf/dist/commonjs/fix-eperm.d.ts.map +1 -0
  219. package/node_modules/rimraf/dist/commonjs/fix-eperm.js +38 -0
  220. package/node_modules/rimraf/dist/commonjs/fix-eperm.js.map +1 -0
  221. package/node_modules/rimraf/dist/commonjs/fs.d.ts +15 -0
  222. package/node_modules/rimraf/dist/commonjs/fs.d.ts.map +1 -0
  223. package/node_modules/rimraf/dist/commonjs/fs.js +33 -0
  224. package/node_modules/rimraf/dist/commonjs/fs.js.map +1 -0
  225. package/node_modules/rimraf/dist/commonjs/ignore-enoent.d.ts +3 -0
  226. package/node_modules/rimraf/dist/commonjs/ignore-enoent.d.ts.map +1 -0
  227. package/node_modules/rimraf/dist/commonjs/ignore-enoent.js +24 -0
  228. package/node_modules/rimraf/dist/commonjs/ignore-enoent.js.map +1 -0
  229. package/node_modules/rimraf/dist/commonjs/index.d.ts +50 -0
  230. package/node_modules/rimraf/dist/commonjs/index.d.ts.map +1 -0
  231. package/node_modules/rimraf/dist/commonjs/index.js +78 -0
  232. package/node_modules/rimraf/dist/commonjs/index.js.map +1 -0
  233. package/node_modules/rimraf/dist/commonjs/opt-arg.d.ts +34 -0
  234. package/node_modules/rimraf/dist/commonjs/opt-arg.d.ts.map +1 -0
  235. package/node_modules/rimraf/dist/commonjs/opt-arg.js +53 -0
  236. package/node_modules/rimraf/dist/commonjs/opt-arg.js.map +1 -0
  237. package/node_modules/rimraf/dist/commonjs/package.json +3 -0
  238. package/node_modules/rimraf/dist/commonjs/path-arg.d.ts +4 -0
  239. package/node_modules/rimraf/dist/commonjs/path-arg.d.ts.map +1 -0
  240. package/node_modules/rimraf/dist/commonjs/path-arg.js +48 -0
  241. package/node_modules/rimraf/dist/commonjs/path-arg.js.map +1 -0
  242. package/node_modules/rimraf/dist/commonjs/readdir-or-error.d.ts +3 -0
  243. package/node_modules/rimraf/dist/commonjs/readdir-or-error.d.ts.map +1 -0
  244. package/node_modules/rimraf/dist/commonjs/readdir-or-error.js +19 -0
  245. package/node_modules/rimraf/dist/commonjs/readdir-or-error.js.map +1 -0
  246. package/node_modules/rimraf/dist/commonjs/retry-busy.d.ts +8 -0
  247. package/node_modules/rimraf/dist/commonjs/retry-busy.d.ts.map +1 -0
  248. package/node_modules/rimraf/dist/commonjs/retry-busy.js +65 -0
  249. package/node_modules/rimraf/dist/commonjs/retry-busy.js.map +1 -0
  250. package/node_modules/rimraf/dist/commonjs/rimraf-manual.d.ts +3 -0
  251. package/node_modules/rimraf/dist/commonjs/rimraf-manual.d.ts.map +1 -0
  252. package/node_modules/rimraf/dist/commonjs/rimraf-manual.js +8 -0
  253. package/node_modules/rimraf/dist/commonjs/rimraf-manual.js.map +1 -0
  254. package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.d.ts +4 -0
  255. package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.d.ts.map +1 -0
  256. package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.js +138 -0
  257. package/node_modules/rimraf/dist/commonjs/rimraf-move-remove.js.map +1 -0
  258. package/node_modules/rimraf/dist/commonjs/rimraf-native.d.ts +4 -0
  259. package/node_modules/rimraf/dist/commonjs/rimraf-native.d.ts.map +1 -0
  260. package/node_modules/rimraf/dist/commonjs/rimraf-native.js +24 -0
  261. package/node_modules/rimraf/dist/commonjs/rimraf-native.js.map +1 -0
  262. package/node_modules/rimraf/dist/commonjs/rimraf-posix.d.ts +4 -0
  263. package/node_modules/rimraf/dist/commonjs/rimraf-posix.d.ts.map +1 -0
  264. package/node_modules/rimraf/dist/commonjs/rimraf-posix.js +103 -0
  265. package/node_modules/rimraf/dist/commonjs/rimraf-posix.js.map +1 -0
  266. package/node_modules/rimraf/dist/commonjs/rimraf-windows.d.ts +4 -0
  267. package/node_modules/rimraf/dist/commonjs/rimraf-windows.d.ts.map +1 -0
  268. package/node_modules/rimraf/dist/commonjs/rimraf-windows.js +159 -0
  269. package/node_modules/rimraf/dist/commonjs/rimraf-windows.js.map +1 -0
  270. package/node_modules/rimraf/dist/commonjs/use-native.d.ts +4 -0
  271. package/node_modules/rimraf/dist/commonjs/use-native.d.ts.map +1 -0
  272. package/node_modules/rimraf/dist/commonjs/use-native.js +18 -0
  273. package/node_modules/rimraf/dist/commonjs/use-native.js.map +1 -0
  274. package/node_modules/rimraf/dist/esm/bin.d.mts +3 -0
  275. package/node_modules/rimraf/dist/esm/bin.d.mts.map +1 -0
  276. package/node_modules/rimraf/dist/esm/bin.mjs +250 -0
  277. package/node_modules/rimraf/dist/esm/bin.mjs.map +1 -0
  278. package/node_modules/rimraf/dist/esm/default-tmp.d.ts +3 -0
  279. package/node_modules/rimraf/dist/esm/default-tmp.d.ts.map +1 -0
  280. package/node_modules/rimraf/dist/esm/default-tmp.js +55 -0
  281. package/node_modules/rimraf/dist/esm/default-tmp.js.map +1 -0
  282. package/node_modules/rimraf/dist/esm/error.d.ts +6 -0
  283. package/node_modules/rimraf/dist/esm/error.d.ts.map +1 -0
  284. package/node_modules/rimraf/dist/esm/error.js +5 -0
  285. package/node_modules/rimraf/dist/esm/error.js.map +1 -0
  286. package/node_modules/rimraf/dist/esm/fix-eperm.d.ts +3 -0
  287. package/node_modules/rimraf/dist/esm/fix-eperm.d.ts.map +1 -0
  288. package/node_modules/rimraf/dist/esm/fix-eperm.js +33 -0
  289. package/node_modules/rimraf/dist/esm/fix-eperm.js.map +1 -0
  290. package/node_modules/rimraf/dist/esm/fs.d.ts +15 -0
  291. package/node_modules/rimraf/dist/esm/fs.d.ts.map +1 -0
  292. package/node_modules/rimraf/dist/esm/fs.js +18 -0
  293. package/node_modules/rimraf/dist/esm/fs.js.map +1 -0
  294. package/node_modules/rimraf/dist/esm/ignore-enoent.d.ts +3 -0
  295. package/node_modules/rimraf/dist/esm/ignore-enoent.d.ts.map +1 -0
  296. package/node_modules/rimraf/dist/esm/ignore-enoent.js +19 -0
  297. package/node_modules/rimraf/dist/esm/ignore-enoent.js.map +1 -0
  298. package/node_modules/rimraf/dist/esm/index.d.ts +50 -0
  299. package/node_modules/rimraf/dist/esm/index.d.ts.map +1 -0
  300. package/node_modules/rimraf/dist/esm/index.js +70 -0
  301. package/node_modules/rimraf/dist/esm/index.js.map +1 -0
  302. package/node_modules/rimraf/dist/esm/opt-arg.d.ts +34 -0
  303. package/node_modules/rimraf/dist/esm/opt-arg.d.ts.map +1 -0
  304. package/node_modules/rimraf/dist/esm/opt-arg.js +46 -0
  305. package/node_modules/rimraf/dist/esm/opt-arg.js.map +1 -0
  306. package/node_modules/rimraf/dist/esm/package.json +3 -0
  307. package/node_modules/rimraf/dist/esm/path-arg.d.ts +4 -0
  308. package/node_modules/rimraf/dist/esm/path-arg.d.ts.map +1 -0
  309. package/node_modules/rimraf/dist/esm/path-arg.js +46 -0
  310. package/node_modules/rimraf/dist/esm/path-arg.js.map +1 -0
  311. package/node_modules/rimraf/dist/esm/readdir-or-error.d.ts +3 -0
  312. package/node_modules/rimraf/dist/esm/readdir-or-error.d.ts.map +1 -0
  313. package/node_modules/rimraf/dist/esm/readdir-or-error.js +14 -0
  314. package/node_modules/rimraf/dist/esm/readdir-or-error.js.map +1 -0
  315. package/node_modules/rimraf/dist/esm/retry-busy.d.ts +8 -0
  316. package/node_modules/rimraf/dist/esm/retry-busy.d.ts.map +1 -0
  317. package/node_modules/rimraf/dist/esm/retry-busy.js +60 -0
  318. package/node_modules/rimraf/dist/esm/retry-busy.js.map +1 -0
  319. package/node_modules/rimraf/dist/esm/rimraf-manual.d.ts +3 -0
  320. package/node_modules/rimraf/dist/esm/rimraf-manual.d.ts.map +1 -0
  321. package/node_modules/rimraf/dist/esm/rimraf-manual.js +5 -0
  322. package/node_modules/rimraf/dist/esm/rimraf-manual.js.map +1 -0
  323. package/node_modules/rimraf/dist/esm/rimraf-move-remove.d.ts +4 -0
  324. package/node_modules/rimraf/dist/esm/rimraf-move-remove.d.ts.map +1 -0
  325. package/node_modules/rimraf/dist/esm/rimraf-move-remove.js +133 -0
  326. package/node_modules/rimraf/dist/esm/rimraf-move-remove.js.map +1 -0
  327. package/node_modules/rimraf/dist/esm/rimraf-native.d.ts +4 -0
  328. package/node_modules/rimraf/dist/esm/rimraf-native.d.ts.map +1 -0
  329. package/node_modules/rimraf/dist/esm/rimraf-native.js +19 -0
  330. package/node_modules/rimraf/dist/esm/rimraf-native.js.map +1 -0
  331. package/node_modules/rimraf/dist/esm/rimraf-posix.d.ts +4 -0
  332. package/node_modules/rimraf/dist/esm/rimraf-posix.d.ts.map +1 -0
  333. package/node_modules/rimraf/dist/esm/rimraf-posix.js +98 -0
  334. package/node_modules/rimraf/dist/esm/rimraf-posix.js.map +1 -0
  335. package/node_modules/rimraf/dist/esm/rimraf-windows.d.ts +4 -0
  336. package/node_modules/rimraf/dist/esm/rimraf-windows.d.ts.map +1 -0
  337. package/node_modules/rimraf/dist/esm/rimraf-windows.js +154 -0
  338. package/node_modules/rimraf/dist/esm/rimraf-windows.js.map +1 -0
  339. package/node_modules/rimraf/dist/esm/use-native.d.ts +4 -0
  340. package/node_modules/rimraf/dist/esm/use-native.d.ts.map +1 -0
  341. package/node_modules/rimraf/dist/esm/use-native.js +15 -0
  342. package/node_modules/rimraf/dist/esm/use-native.js.map +1 -0
  343. package/node_modules/rimraf/package.json +92 -0
  344. package/package.json +152 -0
  345. package/scripts/install-scanners.js +258 -0
  346. package/scripts/watchdog.js +147 -0
  347. package/src/analyzers/CSSAnalyzer.js +297 -0
  348. package/src/analyzers/ConfigValidator.js +690 -0
  349. package/src/analyzers/ESLintAnalyzer.js +320 -0
  350. package/src/analyzers/JavaScriptAnalyzer.js +261 -0
  351. package/src/analyzers/PrettierFormatter.js +247 -0
  352. package/src/analyzers/PythonAnalyzer.js +283 -0
  353. package/src/analyzers/SecurityAnalyzer.js +729 -0
  354. package/src/analyzers/SparrowAnalyzer.js +341 -0
  355. package/src/analyzers/TypeScriptAnalyzer.js +247 -0
  356. package/src/analyzers/codeCloneDetector/analyzer.js +344 -0
  357. package/src/analyzers/codeCloneDetector/detector.js +250 -0
  358. package/src/analyzers/codeCloneDetector/index.js +192 -0
  359. package/src/analyzers/codeCloneDetector/parser.js +199 -0
  360. package/src/analyzers/codeCloneDetector/reporter.js +148 -0
  361. package/src/analyzers/codeCloneDetector/scanner.js +88 -0
  362. package/src/core/agentPool.js +1957 -0
  363. package/src/core/agentScheduler.js +3212 -0
  364. package/src/core/contextManager.js +709 -0
  365. package/src/core/flowExecutor.js +928 -0
  366. package/src/core/messageProcessor.js +808 -0
  367. package/src/core/orchestrator.js +584 -0
  368. package/src/core/stateManager.js +1500 -0
  369. package/src/index.js +972 -0
  370. package/src/interfaces/cli.js +553 -0
  371. package/src/interfaces/terminal/__tests__/smoke/advancedFeatures.test.js +208 -0
  372. package/src/interfaces/terminal/__tests__/smoke/agentControl.test.js +236 -0
  373. package/src/interfaces/terminal/__tests__/smoke/agents.test.js +138 -0
  374. package/src/interfaces/terminal/__tests__/smoke/components.test.js +137 -0
  375. package/src/interfaces/terminal/__tests__/smoke/connection.test.js +350 -0
  376. package/src/interfaces/terminal/__tests__/smoke/enhancements.test.js +156 -0
  377. package/src/interfaces/terminal/__tests__/smoke/imports.test.js +332 -0
  378. package/src/interfaces/terminal/__tests__/smoke/messages.test.js +256 -0
  379. package/src/interfaces/terminal/__tests__/smoke/tools.test.js +388 -0
  380. package/src/interfaces/terminal/api/apiClient.js +299 -0
  381. package/src/interfaces/terminal/api/messageRouter.js +262 -0
  382. package/src/interfaces/terminal/api/session.js +266 -0
  383. package/src/interfaces/terminal/api/websocket.js +497 -0
  384. package/src/interfaces/terminal/components/AgentCreator.js +705 -0
  385. package/src/interfaces/terminal/components/AgentEditor.js +678 -0
  386. package/src/interfaces/terminal/components/AgentSwitcher.js +330 -0
  387. package/src/interfaces/terminal/components/ErrorBoundary.js +92 -0
  388. package/src/interfaces/terminal/components/ErrorPanel.js +264 -0
  389. package/src/interfaces/terminal/components/Header.js +28 -0
  390. package/src/interfaces/terminal/components/HelpPanel.js +231 -0
  391. package/src/interfaces/terminal/components/InputBox.js +118 -0
  392. package/src/interfaces/terminal/components/Layout.js +603 -0
  393. package/src/interfaces/terminal/components/LoadingSpinner.js +71 -0
  394. package/src/interfaces/terminal/components/MessageList.js +281 -0
  395. package/src/interfaces/terminal/components/MultilineTextInput.js +251 -0
  396. package/src/interfaces/terminal/components/SearchPanel.js +265 -0
  397. package/src/interfaces/terminal/components/SettingsPanel.js +415 -0
  398. package/src/interfaces/terminal/components/StatusBar.js +65 -0
  399. package/src/interfaces/terminal/components/TextInput.js +127 -0
  400. package/src/interfaces/terminal/config/agentEditorConstants.js +227 -0
  401. package/src/interfaces/terminal/config/constants.js +393 -0
  402. package/src/interfaces/terminal/index.js +168 -0
  403. package/src/interfaces/terminal/state/useAgentControl.js +496 -0
  404. package/src/interfaces/terminal/state/useAgents.js +537 -0
  405. package/src/interfaces/terminal/state/useConnection.js +444 -0
  406. package/src/interfaces/terminal/state/useMessages.js +630 -0
  407. package/src/interfaces/terminal/state/useTools.js +554 -0
  408. package/src/interfaces/terminal/utils/debugLogger.js +44 -0
  409. package/src/interfaces/terminal/utils/settingsStorage.js +232 -0
  410. package/src/interfaces/terminal/utils/theme.js +85 -0
  411. package/src/interfaces/webServer.js +5457 -0
  412. package/src/modules/fileExplorer/controller.js +413 -0
  413. package/src/modules/fileExplorer/index.js +37 -0
  414. package/src/modules/fileExplorer/middleware.js +92 -0
  415. package/src/modules/fileExplorer/routes.js +158 -0
  416. package/src/modules/fileExplorer/types.js +44 -0
  417. package/src/services/agentActivityService.js +399 -0
  418. package/src/services/aiService.js +2618 -0
  419. package/src/services/apiKeyManager.js +334 -0
  420. package/src/services/benchmarkService.js +196 -0
  421. package/src/services/budgetService.js +565 -0
  422. package/src/services/contextInjectionService.js +268 -0
  423. package/src/services/conversationCompactionService.js +1103 -0
  424. package/src/services/credentialVault.js +685 -0
  425. package/src/services/errorHandler.js +810 -0
  426. package/src/services/fileAttachmentService.js +547 -0
  427. package/src/services/flowContextService.js +189 -0
  428. package/src/services/memoryService.js +521 -0
  429. package/src/services/modelRouterService.js +365 -0
  430. package/src/services/modelsService.js +323 -0
  431. package/src/services/ollamaService.js +452 -0
  432. package/src/services/portRegistry.js +336 -0
  433. package/src/services/portTracker.js +223 -0
  434. package/src/services/projectDetector.js +404 -0
  435. package/src/services/promptService.js +372 -0
  436. package/src/services/qualityInspector.js +796 -0
  437. package/src/services/scheduleService.js +725 -0
  438. package/src/services/serviceRegistry.js +386 -0
  439. package/src/services/skillsService.js +486 -0
  440. package/src/services/telegramService.js +920 -0
  441. package/src/services/tokenCountingService.js +316 -0
  442. package/src/services/visualEditorBridge.js +1033 -0
  443. package/src/services/visualEditorServer.js +1727 -0
  444. package/src/services/whatsappService.js +663 -0
  445. package/src/tools/__tests__/webTool.e2e.test.js +569 -0
  446. package/src/tools/__tests__/webTool.unit.test.js +195 -0
  447. package/src/tools/agentCommunicationTool.js +1343 -0
  448. package/src/tools/agentDelayTool.js +498 -0
  449. package/src/tools/asyncToolManager.js +604 -0
  450. package/src/tools/baseTool.js +887 -0
  451. package/src/tools/browserTool.js +897 -0
  452. package/src/tools/cloneDetectionTool.js +581 -0
  453. package/src/tools/codeMapTool.js +857 -0
  454. package/src/tools/dependencyResolverTool.js +1212 -0
  455. package/src/tools/docxTool.js +623 -0
  456. package/src/tools/excelTool.js +636 -0
  457. package/src/tools/fileContentReplaceTool.js +840 -0
  458. package/src/tools/fileTreeTool.js +833 -0
  459. package/src/tools/filesystemTool.js +1217 -0
  460. package/src/tools/helpTool.js +198 -0
  461. package/src/tools/imageTool.js +1034 -0
  462. package/src/tools/importAnalyzerTool.js +1056 -0
  463. package/src/tools/jobDoneTool.js +388 -0
  464. package/src/tools/memoryTool.js +554 -0
  465. package/src/tools/pdfTool.js +627 -0
  466. package/src/tools/seekTool.js +883 -0
  467. package/src/tools/skillsTool.js +276 -0
  468. package/src/tools/staticAnalysisTool.js +2146 -0
  469. package/src/tools/taskManagerTool.js +2836 -0
  470. package/src/tools/terminalTool.js +2486 -0
  471. package/src/tools/userPromptTool.js +474 -0
  472. package/src/tools/videoTool.js +1139 -0
  473. package/src/tools/visionTool.js +507 -0
  474. package/src/tools/visualEditorTool.js +1175 -0
  475. package/src/tools/webTool.js +3114 -0
  476. package/src/tools/whatsappTool.js +457 -0
  477. package/src/types/agent.js +519 -0
  478. package/src/types/contextReference.js +972 -0
  479. package/src/types/conversation.js +730 -0
  480. package/src/types/toolCommand.js +747 -0
  481. package/src/utilities/attachmentValidator.js +288 -0
  482. package/src/utilities/browserStealth.js +630 -0
  483. package/src/utilities/configManager.js +618 -0
  484. package/src/utilities/constants.js +870 -0
  485. package/src/utilities/directoryAccessManager.js +566 -0
  486. package/src/utilities/fileProcessor.js +307 -0
  487. package/src/utilities/humanBehavior.js +453 -0
  488. package/src/utilities/jsonRepair.js +242 -0
  489. package/src/utilities/logger.js +436 -0
  490. package/src/utilities/platformUtils.js +255 -0
  491. package/src/utilities/platformUtils.test.js +98 -0
  492. package/src/utilities/stealthConstants.js +377 -0
  493. package/src/utilities/structuredFileValidator.js +699 -0
  494. package/src/utilities/tagParser.js +878 -0
  495. package/src/utilities/toolConstants.js +415 -0
  496. package/src/utilities/userDataDir.js +300 -0
  497. package/web-ui/build/brands/autopilot/favicon.svg +1 -0
  498. package/web-ui/build/brands/autopilot/logo.webp +0 -0
  499. package/web-ui/build/brands/onbuzz/favicon.svg +1 -0
  500. package/web-ui/build/brands/onbuzz/logo-text.webp +0 -0
  501. package/web-ui/build/brands/onbuzz/logo.webp +0 -0
  502. package/web-ui/build/index.html +15 -0
  503. package/web-ui/build/logo.png +0 -0
  504. package/web-ui/build/logo2.png +0 -0
  505. package/web-ui/build/static/index-SmQFfvBs.js +746 -0
  506. package/web-ui/build/static/index-V2ySwjHp.css +1 -0
@@ -0,0 +1,1056 @@
1
+ /**
2
+ * @file tools/importAnalyzerTool.js
3
+ * @description Modern tool for analyzing and detecting broken imports/exports in Node.js projects
4
+ */
5
+
6
+ import { promises as fs } from 'fs';
7
+ import path from 'path';
8
+ import { BaseTool } from './baseTool.js';
9
+ import TagParser from '../utilities/tagParser.js';
10
+
11
+ /**
12
+ * Configuration constants for the import analyzer
13
+ */
14
+ const ANALYZER_CONFIG = {
15
+ DEFAULT_MODE: 'full',
16
+ VALID_MODES: ['full', 'quick', 'fix'],
17
+ DEFAULT_OUTPUT: 'summary',
18
+ VALID_OUTPUTS: ['summary', 'detailed', 'json'],
19
+ DEFAULT_IGNORE_FILE: '.gitignore',
20
+ MAX_FILES: 10000, // Safety limit for file count
21
+ SUPPORTED_EXTENSIONS: ['.js', '.mjs', '.ts', '.jsx', '.tsx'],
22
+ DEFAULT_IGNORE_PATTERNS: ['node_modules', '.git', 'dist', 'build', 'coverage'],
23
+ FILE_READ_TIMEOUT: 5000 // Timeout for reading large files
24
+ };
25
+
26
+ /**
27
+ * ImportAnalyzerTool - Modern implementation
28
+ * Analyzes JavaScript/TypeScript projects to detect broken imports, missing exports, and dependency issues
29
+ */
30
+ export class ImportAnalyzerTool extends BaseTool {
31
+ constructor(config = {}, logger = null) {
32
+ super(config, logger);
33
+
34
+ // Override tool ID to match documentation (with hyphen)
35
+ this.id = 'import-analyzer';
36
+ }
37
+
38
+ /**
39
+ * Get tool description for agent system prompt
40
+ * @returns {string} Formatted tool description
41
+ */
42
+ getDescription() {
43
+ return `Tool: Import Analyzer - Analyze JavaScript/TypeScript imports and exports
44
+
45
+ **Purpose:** Analyzes JavaScript/TypeScript projects to detect broken imports, missing exports, circular dependencies, and unused exports.
46
+
47
+ **USAGE:**
48
+ \`\`\`json
49
+ {
50
+ "toolId": "import-analyzer",
51
+ "parameters": {
52
+ "path": "./src",
53
+ "mode": "full",
54
+ "output": "summary",
55
+ "ignoreFile": ".gitignore"
56
+ }
57
+ }
58
+ \`\`\`
59
+
60
+ **Parameters:**
61
+ - **path** (string, optional): Path to directory to analyze. Default: "."
62
+ - **mode** (string, optional): Analysis mode. Options:
63
+ - "full" - Complete analysis (default)
64
+ - "quick" - Fast scan for missing files only
65
+ - "fix" - Includes fix suggestions
66
+ - **output** (string, optional): Output format. Options:
67
+ - "summary" - Concise summary (default)
68
+ - "detailed" - Full report with fixes
69
+ - "json" - Machine-readable format
70
+ - **ignoreFile** (string, optional): Ignore file name. Default: ".gitignore"
71
+
72
+ **What It Detects:**
73
+ - Missing files (imports pointing to non-existent files)
74
+ - Missing exports (symbols not exported from target files)
75
+ - Circular dependencies (files that depend on each other in a loop)
76
+ - Unused exports (exports never imported anywhere)
77
+
78
+ **Examples:**
79
+
80
+ 1. Quick project scan:
81
+ \`\`\`json
82
+ {
83
+ "toolId": "import-analyzer",
84
+ "parameters": { "mode": "quick" }
85
+ }
86
+ \`\`\`
87
+
88
+ 2. Full analysis with detailed report:
89
+ \`\`\`json
90
+ {
91
+ "toolId": "import-analyzer",
92
+ "parameters": { "mode": "full", "output": "detailed" }
93
+ }
94
+ \`\`\`
95
+
96
+ 3. Analyze specific directory:
97
+ \`\`\`json
98
+ {
99
+ "toolId": "import-analyzer",
100
+ "parameters": { "path": "./src/components", "mode": "full" }
101
+ }
102
+ \`\`\`
103
+
104
+ **Notes:**
105
+ - Supports ES6 modules (import/export) and CommonJS (require/module.exports)
106
+ - Respects .gitignore patterns
107
+ - Correctly handles commented imports and multi-line statements
108
+ - Works with .js, .mjs, .ts, .jsx, .tsx files`;
109
+ }
110
+
111
+ /**
112
+ * Parse tool parameters from raw content (XML or JSON)
113
+ * @param {string|Object} content - Raw tool content or parsed object
114
+ * @returns {Object} Parsed parameters
115
+ */
116
+ parseParameters(content) {
117
+ // If already an object, validate and return
118
+ if (typeof content === 'object' && content !== null) {
119
+ return {
120
+ path: content.path || '.',
121
+ mode: content.mode || ANALYZER_CONFIG.DEFAULT_MODE,
122
+ output: content.output || ANALYZER_CONFIG.DEFAULT_OUTPUT,
123
+ ignoreFile: content.ignoreFile || ANALYZER_CONFIG.DEFAULT_IGNORE_FILE
124
+ };
125
+ }
126
+
127
+ // Parse XML content
128
+ if (typeof content === 'string') {
129
+ // Try modern XML format first: <import-analyzer>...</import-analyzer>
130
+ const modernPattern = /<import-analyzer([^>]*)>([\s\S]*?)<\/import-analyzer>/i;
131
+ const modernMatch = modernPattern.exec(content);
132
+
133
+ if (modernMatch) {
134
+ const attributesStr = modernMatch[1];
135
+ const innerContent = modernMatch[2];
136
+
137
+ // Parse attributes from opening tag
138
+ const pathAttr = /path=["']([^"']*)["']/i.exec(attributesStr);
139
+ const modeAttr = /mode=["']([^"']*)["']/i.exec(attributesStr);
140
+ const outputAttr = /output=["']([^"']*)["']/i.exec(attributesStr);
141
+ const ignoreFileAttr = /ignore-file=["']([^"']*)["']/i.exec(attributesStr);
142
+
143
+ // Extract from inner content
144
+ const pathPattern = /<path>(.*?)<\/path>/i;
145
+ const pathMatch = pathPattern.exec(innerContent);
146
+
147
+ const modePattern = /<mode>(.*?)<\/mode>/i;
148
+ const modeMatch = modePattern.exec(innerContent);
149
+
150
+ const outputPattern = /<output>(.*?)<\/output>/i;
151
+ const outputMatch = outputPattern.exec(innerContent);
152
+
153
+ const ignoreFilePattern = /<ignore-file>(.*?)<\/ignore-file>/i;
154
+ const ignoreFileMatch = ignoreFilePattern.exec(innerContent);
155
+
156
+ // Content takes precedence over attributes
157
+ const extractedPath = (pathMatch ? pathMatch[1].trim() : null) || (pathAttr ? pathAttr[1] : '.');
158
+ const extractedMode = (modeMatch ? modeMatch[1].trim() : null) || (modeAttr ? modeAttr[1] : ANALYZER_CONFIG.DEFAULT_MODE);
159
+ const extractedOutput = (outputMatch ? outputMatch[1].trim() : null) || (outputAttr ? outputAttr[1] : ANALYZER_CONFIG.DEFAULT_OUTPUT);
160
+ const extractedIgnoreFile = (ignoreFileMatch ? ignoreFileMatch[1].trim() : null) || (ignoreFileAttr ? ignoreFileAttr[1] : ANALYZER_CONFIG.DEFAULT_IGNORE_FILE);
161
+
162
+ return {
163
+ path: extractedPath,
164
+ mode: extractedMode,
165
+ output: extractedOutput,
166
+ ignoreFile: extractedIgnoreFile
167
+ };
168
+ }
169
+
170
+ // Try legacy format with TagParser
171
+ try {
172
+ const parsed = TagParser.parseTags(content, 'analyze');
173
+
174
+ if (parsed && parsed.length > 0) {
175
+ const analyzeCommand = parsed[0];
176
+
177
+ return {
178
+ path: analyzeCommand.attributes.path || '.',
179
+ mode: analyzeCommand.attributes.mode || ANALYZER_CONFIG.DEFAULT_MODE,
180
+ output: analyzeCommand.attributes.output || ANALYZER_CONFIG.DEFAULT_OUTPUT,
181
+ ignoreFile: analyzeCommand.attributes['ignore-file'] || ANALYZER_CONFIG.DEFAULT_IGNORE_FILE
182
+ };
183
+ }
184
+ } catch (error) {
185
+ // Fall through to error
186
+ }
187
+
188
+ throw new Error('Invalid import-analyzer format. Use <import-analyzer> tags or JSON format.');
189
+ }
190
+
191
+ throw new Error('Invalid parameter format. Expected string (XML) or object (JSON).');
192
+ }
193
+
194
+ /**
195
+ * Validate parameters
196
+ * @param {Object} params - Parameters to validate
197
+ * @throws {Error} If validation fails
198
+ * @private
199
+ */
200
+ _validateParameters(params) {
201
+ if (!params || typeof params !== 'object') {
202
+ throw new Error('Parameters must be an object');
203
+ }
204
+
205
+ if (params.path && typeof params.path !== 'string') {
206
+ throw new Error('path must be a string');
207
+ }
208
+
209
+ if (params.mode && !ANALYZER_CONFIG.VALID_MODES.includes(params.mode)) {
210
+ throw new Error(`Invalid mode: ${params.mode}. Must be one of: ${ANALYZER_CONFIG.VALID_MODES.join(', ')}`);
211
+ }
212
+
213
+ if (params.output && !ANALYZER_CONFIG.VALID_OUTPUTS.includes(params.output)) {
214
+ throw new Error(`Invalid output: ${params.output}. Must be one of: ${ANALYZER_CONFIG.VALID_OUTPUTS.join(', ')}`);
215
+ }
216
+
217
+ if (params.ignoreFile && typeof params.ignoreFile !== 'string') {
218
+ throw new Error('ignoreFile must be a string');
219
+ }
220
+ }
221
+
222
+ /**
223
+ * Validate and resolve file path
224
+ * @param {string} targetPath - Target path from parameters
225
+ * @param {Object} context - Execution context
226
+ * @returns {string} Resolved absolute path
227
+ * @throws {Error} If path is invalid or inaccessible
228
+ * @private
229
+ */
230
+ _resolveAndValidatePath(targetPath, context) {
231
+ const { projectDir, directoryAccess } = context;
232
+
233
+ // Determine working directory
234
+ let workingDirectory = projectDir || process.cwd();
235
+
236
+ if (directoryAccess && directoryAccess.workingDirectory) {
237
+ workingDirectory = directoryAccess.workingDirectory;
238
+ }
239
+
240
+ // Resolve the target path
241
+ const resolvedPath = path.isAbsolute(targetPath)
242
+ ? path.normalize(targetPath)
243
+ : path.normalize(path.join(workingDirectory, targetPath));
244
+
245
+ // Security: Check for path traversal
246
+ const realWorkingDir = path.normalize(workingDirectory);
247
+ if (!resolvedPath.startsWith(realWorkingDir)) {
248
+ throw new Error(`Path traversal detected: ${targetPath} resolves outside working directory`);
249
+ }
250
+
251
+ return resolvedPath;
252
+ }
253
+
254
+ /**
255
+ * Execute tool with parsed parameters
256
+ * @param {Object} params - Parsed parameters
257
+ * @param {Object} context - Execution context
258
+ * @returns {Promise<Object>} Execution result
259
+ */
260
+ async execute(params, context = {}) {
261
+ try {
262
+ // Validate parameters
263
+ this._validateParameters(params);
264
+
265
+ const { path: targetPath, mode, output, ignoreFile } = params;
266
+ const { projectDir, agentId, directoryAccess } = context;
267
+
268
+ // Resolve and validate path
269
+ const resolvedPath = this._resolveAndValidatePath(targetPath, context);
270
+
271
+ this.logger?.info('Import analyzer executing', {
272
+ mode,
273
+ resolvedPath,
274
+ output,
275
+ agentId
276
+ });
277
+
278
+ const outputLines = [];
279
+ outputLines.push(`🔍 Analyzing imports in: ${resolvedPath}`);
280
+ outputLines.push(`Mode: ${mode}`);
281
+ outputLines.push(`Output: ${output}\n`);
282
+
283
+ // Check if path exists
284
+ try {
285
+ await fs.access(resolvedPath);
286
+ } catch {
287
+ return {
288
+ success: false,
289
+ error: `Path does not exist: ${resolvedPath}`,
290
+ output: outputLines.join('\n')
291
+ };
292
+ }
293
+
294
+ // Run analysis
295
+ const analyzer = new ImportExportAnalyzer(resolvedPath, ignoreFile, this.logger);
296
+ const results = await analyzer.analyze(mode);
297
+
298
+ // Format output based on requested format
299
+ let formattedOutput;
300
+ switch (output) {
301
+ case 'json':
302
+ // For JSON output, don't include header lines
303
+ formattedOutput = JSON.stringify(results, null, 2);
304
+ break;
305
+ case 'detailed':
306
+ formattedOutput = this._formatDetailedOutput(results);
307
+ outputLines.push(formattedOutput);
308
+ break;
309
+ case 'summary':
310
+ default:
311
+ formattedOutput = this._formatSummaryOutput(results);
312
+ outputLines.push(formattedOutput);
313
+ break;
314
+ }
315
+
316
+ return {
317
+ success: true,
318
+ mode,
319
+ message: 'Import analysis completed',
320
+ statistics: {
321
+ totalFiles: results.summary.totalFiles,
322
+ totalImports: results.summary.totalImports,
323
+ totalExports: results.summary.totalExports,
324
+ issuesFound: results.fileNotFoundImports.length + Object.values(results.missingExports).reduce((sum, arr) => sum + arr.length, 0)
325
+ },
326
+ output: output === 'json' ? formattedOutput : outputLines.join('\n'),
327
+ results
328
+ };
329
+
330
+ } catch (error) {
331
+ this.logger?.error('Import analyzer error:', error);
332
+
333
+ return {
334
+ success: false,
335
+ error: error.message,
336
+ output: error.message
337
+ };
338
+ }
339
+ }
340
+
341
+ /**
342
+ * Format summary output
343
+ * @param {Object} results - Analysis results
344
+ * @returns {string} Formatted output
345
+ * @private
346
+ */
347
+ _formatSummaryOutput(results) {
348
+ const lines = [];
349
+
350
+ lines.push('📊 Import/Export Analysis Summary');
351
+ lines.push('================================\n');
352
+
353
+ lines.push(`📁 Files analyzed: ${results.summary.totalFiles}`);
354
+ lines.push(`📥 Total imports: ${results.summary.totalImports}`);
355
+ lines.push(`📤 Total exports: ${results.summary.totalExports}\n`);
356
+
357
+ // Critical issues
358
+ const missingFilesCount = results.fileNotFoundImports.length;
359
+ const missingExportsCount = Object.values(results.missingExports).reduce((sum, arr) => sum + arr.length, 0);
360
+ const circularDepsCount = results.circularDependencies ? results.circularDependencies.length : 0;
361
+
362
+ if (missingFilesCount > 0) {
363
+ lines.push(`❌ Missing files: ${missingFilesCount} imports pointing to non-existent files`);
364
+ }
365
+
366
+ if (missingExportsCount > 0) {
367
+ lines.push(`⚠️ Missing exports: ${missingExportsCount} symbols not exported from their sources`);
368
+ }
369
+
370
+ if (circularDepsCount > 0) {
371
+ lines.push(`🔄 Circular dependencies: ${circularDepsCount} circular dependency chains detected`);
372
+ }
373
+
374
+ if (missingFilesCount === 0 && missingExportsCount === 0 && circularDepsCount === 0) {
375
+ lines.push('✅ No import/export issues detected!');
376
+ } else {
377
+ lines.push('\n🔍 Top Issues to Fix:');
378
+
379
+ // Show top 5 files with issues
380
+ if (Object.keys(results.missingFiles || {}).length > 0) {
381
+ lines.push('\n Missing Files:');
382
+ Object.entries(results.missingFiles).slice(0, 3).forEach(([file, issues]) => {
383
+ lines.push(` • ${file} has ${issues.length} broken import(s)`);
384
+ });
385
+ }
386
+
387
+ if (Object.keys(results.missingExports).length > 0) {
388
+ lines.push('\n Missing Exports:');
389
+ Object.entries(results.missingExports).slice(0, 3).forEach(([file, issues]) => {
390
+ lines.push(` • ${file} imports ${issues.length} non-existent symbol(s)`);
391
+ });
392
+ }
393
+
394
+ lines.push('\n💡 Run with output="detailed" for complete analysis and fix suggestions');
395
+ }
396
+
397
+ return lines.join('\n');
398
+ }
399
+
400
+ /**
401
+ * Format detailed output
402
+ * @param {Object} results - Analysis results
403
+ * @returns {string} Formatted output
404
+ * @private
405
+ */
406
+ _formatDetailedOutput(results) {
407
+ const lines = [];
408
+
409
+ lines.push('📊 Detailed Import/Export Analysis Report');
410
+ lines.push('=========================================\n');
411
+
412
+ lines.push('📈 Statistics:');
413
+ lines.push(` • Files analyzed: ${results.summary.totalFiles}`);
414
+ lines.push(` • Total imports: ${results.summary.totalImports}`);
415
+ lines.push(` • Total exports: ${results.summary.totalExports}\n`);
416
+
417
+ // Missing files section
418
+ if (results.fileNotFoundImports.length > 0) {
419
+ lines.push('❌ MISSING FILES');
420
+ lines.push('─────────────────');
421
+
422
+ const fileGroups = {};
423
+ results.fileNotFoundImports.forEach(item => {
424
+ if (!fileGroups[item.importingFile]) {
425
+ fileGroups[item.importingFile] = [];
426
+ }
427
+ fileGroups[item.importingFile].push(item);
428
+ });
429
+
430
+ Object.entries(fileGroups).forEach(([file, imports]) => {
431
+ lines.push(`\n📄 ${file}:`);
432
+ imports.forEach(imp => {
433
+ const importType = imp.isDefault ? 'default' : imp.isNamespace ? 'namespace' : 'named';
434
+ lines.push(` ⚠️ Cannot find file: ${imp.importedFromFile}`);
435
+ lines.push(` Trying to import: ${imp.importedSymbol} (${importType})`);
436
+ lines.push(` 💡 Fix: Check if file exists or correct the import path`);
437
+ });
438
+ });
439
+ }
440
+
441
+ // Missing exports section
442
+ if (Object.keys(results.missingExports).length > 0) {
443
+ lines.push('\n⚠️ MISSING EXPORTS');
444
+ lines.push('──────────────────');
445
+
446
+ Object.entries(results.missingExports).forEach(([file, issues]) => {
447
+ lines.push(`\n📄 ${file}:`);
448
+ issues.forEach(issue => {
449
+ const importType = issue.isDefault ? 'default' : issue.isNamespace ? 'namespace' : 'named';
450
+ lines.push(` ❌ Symbol not exported: "${issue.importedSymbol}" (${importType})`);
451
+ lines.push(` From file: ${issue.importedFromFile}`);
452
+
453
+ if (issue.availableExports.length > 0) {
454
+ lines.push(` 📤 Available exports: ${issue.availableExports.join(', ')}`);
455
+
456
+ // Suggest potential fixes
457
+ if (issue.isDefault && issue.availableExports.includes('default')) {
458
+ lines.push(` 💡 Fix: Default export exists, check import syntax`);
459
+ } else if (issue.isDefault && !issue.availableExports.includes('default')) {
460
+ lines.push(` 💡 Fix: No default export. Use named import: { ${issue.availableExports[0] || 'symbolName'} }`);
461
+ } else {
462
+ // Check for similar names
463
+ const similar = issue.availableExports.find(exp =>
464
+ exp.toLowerCase() === issue.importedSymbol.toLowerCase()
465
+ );
466
+ if (similar) {
467
+ lines.push(` 💡 Fix: Did you mean "${similar}"? (case mismatch)`);
468
+ } else {
469
+ lines.push(` 💡 Fix: Add export for "${issue.importedSymbol}" or use one of the available exports`);
470
+ }
471
+ }
472
+ } else {
473
+ lines.push(` 📤 No exports found in target file`);
474
+ lines.push(` 💡 Fix: Add exports to ${issue.importedFromFile} or check if it's the correct file`);
475
+ }
476
+ });
477
+ });
478
+ }
479
+
480
+ // Circular dependencies
481
+ if (results.circularDependencies && results.circularDependencies.length > 0) {
482
+ lines.push('\n🔄 CIRCULAR DEPENDENCIES');
483
+ lines.push('────────────────────────');
484
+
485
+ results.circularDependencies.forEach((cycle, index) => {
486
+ lines.push(`\n Cycle ${index + 1}:`);
487
+ cycle.forEach((file, i) => {
488
+ if (i < cycle.length - 1) {
489
+ lines.push(` ${file} → ${cycle[i + 1]}`);
490
+ }
491
+ });
492
+ lines.push(` 💡 Fix: Refactor to break the circular dependency`);
493
+ });
494
+ }
495
+
496
+ // Unused exports (if available)
497
+ if (results.unusedExports && Object.keys(results.unusedExports).length > 0) {
498
+ lines.push('\n🗑️ POTENTIALLY UNUSED EXPORTS');
499
+ lines.push('──────────────────────────────');
500
+
501
+ Object.entries(results.unusedExports).slice(0, 10).forEach(([file, exports]) => {
502
+ lines.push(`\n📄 ${file}:`);
503
+ lines.push(` Unused: ${exports.join(', ')}`);
504
+ });
505
+
506
+ lines.push('\n 💡 Note: These exports are not imported within this project');
507
+ lines.push(' They might be used by external packages or could be removed');
508
+ }
509
+
510
+ // Summary and recommendations
511
+ lines.push('\n📋 RECOMMENDATIONS');
512
+ lines.push('──────────────────');
513
+
514
+ const totalIssues = results.fileNotFoundImports.length +
515
+ Object.values(results.missingExports).reduce((sum, arr) => sum + arr.length, 0);
516
+
517
+ if (totalIssues === 0) {
518
+ lines.push('✅ Your import/export structure looks good!');
519
+ } else {
520
+ lines.push(`Found ${totalIssues} issue(s) that need attention:`);
521
+
522
+ if (results.fileNotFoundImports.length > 0) {
523
+ lines.push(` 1. Fix ${results.fileNotFoundImports.length} missing file reference(s)`);
524
+ }
525
+
526
+ if (Object.keys(results.missingExports).length > 0) {
527
+ lines.push(` 2. Resolve ${Object.values(results.missingExports).reduce((sum, arr) => sum + arr.length, 0)} missing export(s)`);
528
+ }
529
+
530
+ if (results.circularDependencies && results.circularDependencies.length > 0) {
531
+ lines.push(` 3. Refactor ${results.circularDependencies.length} circular dependency chain(s)`);
532
+ }
533
+ }
534
+
535
+ return lines.join('\n');
536
+ }
537
+ }
538
+
539
+ /**
540
+ * Internal analyzer class
541
+ */
542
+ class ImportExportAnalyzer {
543
+ constructor(rootDir, ignoreFile = '.gitignore', logger = null) {
544
+ this.rootDir = path.resolve(rootDir);
545
+ this.ignoreFile = ignoreFile;
546
+ this.logger = logger;
547
+ this.ignorePatterns = [...ANALYZER_CONFIG.DEFAULT_IGNORE_PATTERNS];
548
+ this.imports = [];
549
+ this.exports = new Map();
550
+ this.dependencies = new Map(); // For circular dependency detection
551
+ }
552
+
553
+ async loadIgnoreFile() {
554
+ try {
555
+ const ignoreFilePath = path.join(this.rootDir, this.ignoreFile);
556
+ const content = await fs.readFile(ignoreFilePath, 'utf-8');
557
+ const patterns = content
558
+ .split('\n')
559
+ .map(line => line.trim())
560
+ .filter(line => line && !line.startsWith('#'));
561
+
562
+ this.ignorePatterns.push(...patterns);
563
+ this.logger?.debug('Loaded ignore patterns', { count: patterns.length });
564
+ } catch {
565
+ // Ignore file doesn't exist, use defaults
566
+ this.logger?.debug('No ignore file found, using defaults');
567
+ }
568
+ }
569
+
570
+ shouldIgnoreFile(filePath) {
571
+ const relativePath = path.relative(this.rootDir, filePath);
572
+ return this.ignorePatterns.some(pattern => {
573
+ if (pattern.includes('*')) {
574
+ const regex = new RegExp(pattern.replace(/\*/g, '.*'));
575
+ return regex.test(relativePath) || regex.test(path.basename(filePath));
576
+ }
577
+ return relativePath.includes(pattern) || path.basename(filePath) === pattern;
578
+ });
579
+ }
580
+
581
+ async getAllFiles(dir) {
582
+ const files = [];
583
+
584
+ const traverse = async (currentDir) => {
585
+ try {
586
+ const entries = await fs.readdir(currentDir, { withFileTypes: true });
587
+
588
+ for (const entry of entries) {
589
+ const fullPath = path.join(currentDir, entry.name);
590
+
591
+ if (this.shouldIgnoreFile(fullPath)) {
592
+ continue;
593
+ }
594
+
595
+ if (entry.isDirectory()) {
596
+ await traverse(fullPath);
597
+ } else if (entry.isFile()) {
598
+ const ext = path.extname(entry.name);
599
+ if (ANALYZER_CONFIG.SUPPORTED_EXTENSIONS.includes(ext)) {
600
+ files.push(fullPath);
601
+ }
602
+ }
603
+ }
604
+ } catch (error) {
605
+ // Skip directories we can't read
606
+ this.logger?.warn('Cannot read directory', { dir: currentDir, error: error.message });
607
+ }
608
+ };
609
+
610
+ await traverse(dir);
611
+
612
+ // Safety check
613
+ if (files.length > ANALYZER_CONFIG.MAX_FILES) {
614
+ this.logger?.warn(`File count exceeds limit: ${files.length} > ${ANALYZER_CONFIG.MAX_FILES}`);
615
+ throw new Error(`Too many files to analyze: ${files.length} (max: ${ANALYZER_CONFIG.MAX_FILES})`);
616
+ }
617
+
618
+ return files;
619
+ }
620
+
621
+ async parseImports(content, filePath) {
622
+ const imports = [];
623
+ const lines = content.split('\n');
624
+ const relativePath = this.getRelativePath(filePath);
625
+
626
+ // Track dependencies for circular detection
627
+ if (!this.dependencies.has(relativePath)) {
628
+ this.dependencies.set(relativePath, new Set());
629
+ }
630
+
631
+ for (let i = 0; i < lines.length; i++) {
632
+ const line = lines[i].trim();
633
+
634
+ if (line.startsWith('//') || line.startsWith('/*')) continue;
635
+
636
+ // Build multi-line statements
637
+ let fullStatement = line;
638
+ let j = i;
639
+ while (!fullStatement.includes(';') && !fullStatement.match(/from\s+['"`][^'"`]+['"`]/) && j < lines.length - 1) {
640
+ j++;
641
+ const nextLine = lines[j].trim();
642
+ // Skip commented lines when building multi-line statements
643
+ if (nextLine.startsWith('//') || nextLine.startsWith('/*')) {
644
+ continue;
645
+ }
646
+ fullStatement += ' ' + nextLine;
647
+ }
648
+
649
+ // ES6 imports
650
+ const importRegex = /import\s+(?:(?:\{([^}]+)\})|(?:([^,\s]+)(?:\s*,\s*\{([^}]+)\})?)|(?:\*\s+as\s+([^,\s]+)))\s+from\s+['"`]([^'"`]+)['"`]/g;
651
+ let match;
652
+
653
+ while ((match = importRegex.exec(fullStatement)) !== null) {
654
+ const [, namedImports, defaultImport, additionalNamed, namespaceImport, source] = match;
655
+ const resolvedSource = await this.resolveImportPath(source, filePath);
656
+
657
+ // Track dependency
658
+ if (!resolvedSource.isExternal && resolvedSource.exists) {
659
+ this.dependencies.get(relativePath).add(resolvedSource.path);
660
+ }
661
+
662
+ if (defaultImport) {
663
+ imports.push({
664
+ importingFile: relativePath,
665
+ importedSymbol: defaultImport.trim(),
666
+ importedFromFile: resolvedSource.path,
667
+ fileExists: resolvedSource.exists,
668
+ isExternal: resolvedSource.isExternal || false,
669
+ isDefault: true
670
+ });
671
+ }
672
+
673
+ if (namespaceImport) {
674
+ imports.push({
675
+ importingFile: relativePath,
676
+ importedSymbol: namespaceImport.trim(),
677
+ importedFromFile: resolvedSource.path,
678
+ fileExists: resolvedSource.exists,
679
+ isExternal: resolvedSource.isExternal || false,
680
+ isNamespace: true
681
+ });
682
+ }
683
+
684
+ const allNamedImports = [namedImports, additionalNamed].filter(Boolean).join(',');
685
+ if (allNamedImports) {
686
+ const symbols = allNamedImports.split(',').map(s => {
687
+ const parts = s.trim().split(/\s+as\s+/);
688
+ return parts[0].trim();
689
+ });
690
+
691
+ symbols.forEach(symbol => {
692
+ if (symbol) {
693
+ imports.push({
694
+ importingFile: relativePath,
695
+ importedSymbol: symbol,
696
+ importedFromFile: resolvedSource.path,
697
+ fileExists: resolvedSource.exists,
698
+ isExternal: resolvedSource.isExternal || false,
699
+ isDefault: false
700
+ });
701
+ }
702
+ });
703
+ }
704
+ }
705
+
706
+ // CommonJS requires
707
+ const requireRegex = /(?:const|let|var)\s+(?:\{([^}]+)\}|([^=\s]+))\s*=\s*require\(['"`]([^'"`]+)['"`]\)/g;
708
+ while ((match = requireRegex.exec(fullStatement)) !== null) {
709
+ const [, destructured, variable, source] = match;
710
+ const resolvedSource = await this.resolveImportPath(source, filePath);
711
+
712
+ // Track dependency
713
+ if (!resolvedSource.isExternal && resolvedSource.exists) {
714
+ this.dependencies.get(relativePath).add(resolvedSource.path);
715
+ }
716
+
717
+ if (destructured) {
718
+ const symbols = destructured.split(',').map(s => s.trim().split(':')[0].trim());
719
+ symbols.forEach(symbol => {
720
+ if (symbol) {
721
+ imports.push({
722
+ importingFile: relativePath,
723
+ importedSymbol: symbol,
724
+ importedFromFile: resolvedSource.path,
725
+ fileExists: resolvedSource.exists,
726
+ isExternal: resolvedSource.isExternal || false,
727
+ isDefault: false
728
+ });
729
+ }
730
+ });
731
+ } else if (variable) {
732
+ imports.push({
733
+ importingFile: relativePath,
734
+ importedSymbol: variable.trim(),
735
+ importedFromFile: resolvedSource.path,
736
+ fileExists: resolvedSource.exists,
737
+ isExternal: resolvedSource.isExternal || false,
738
+ isDefault: true
739
+ });
740
+ }
741
+ }
742
+
743
+ // Skip lines that were already processed as part of multi-line statement
744
+ i = j;
745
+ }
746
+
747
+ return imports;
748
+ }
749
+
750
+ parseExports(content) {
751
+ const exports = new Set();
752
+ const lines = content.split('\n');
753
+
754
+ for (const line of lines) {
755
+ const trimmedLine = line.trim();
756
+
757
+ if (trimmedLine.startsWith('//') || trimmedLine.startsWith('/*')) continue;
758
+
759
+ // Export default
760
+ if (/export\s+default\s+/.test(trimmedLine)) {
761
+ exports.add('default');
762
+ }
763
+
764
+ // Named exports
765
+ const namedExportMatch = trimmedLine.match(/export\s+\{([^}]+)\}/);
766
+ if (namedExportMatch) {
767
+ const symbols = namedExportMatch[1].split(',').map(s => {
768
+ const parts = s.trim().split(/\s+as\s+/);
769
+ return parts[parts.length - 1].trim();
770
+ });
771
+ symbols.forEach(symbol => exports.add(symbol));
772
+ }
773
+
774
+ // Direct exports
775
+ const directExportMatch = trimmedLine.match(/export\s+(?:const|let|var|function|class|async\s+function)\s+([^=\s(]+)/);
776
+ if (directExportMatch) {
777
+ exports.add(directExportMatch[1]);
778
+ }
779
+
780
+ // Export from
781
+ const exportFromMatch = trimmedLine.match(/export\s+\{([^}]+)\}\s+from/);
782
+ if (exportFromMatch) {
783
+ const symbols = exportFromMatch[1].split(',').map(s => {
784
+ const parts = s.trim().split(/\s+as\s+/);
785
+ return parts[parts.length - 1].trim();
786
+ });
787
+ symbols.forEach(symbol => exports.add(symbol));
788
+ }
789
+
790
+ // Export all
791
+ if (/export\s+\*\s+from/.test(trimmedLine)) {
792
+ exports.add('*');
793
+ }
794
+
795
+ // CommonJS exports
796
+ const moduleExportsMatch = trimmedLine.match(/module\.exports\s*=\s*\{([^}]+)\}/);
797
+ if (moduleExportsMatch) {
798
+ const symbols = moduleExportsMatch[1].split(',').map(s => {
799
+ const parts = s.trim().split(':');
800
+ return parts[0].trim();
801
+ });
802
+ symbols.forEach(symbol => exports.add(symbol));
803
+ }
804
+
805
+ if (/module\.exports\s*=\s*[^{]/.test(trimmedLine)) {
806
+ exports.add('default');
807
+ }
808
+
809
+ const moduleExportsPropMatch = trimmedLine.match(/module\.exports\.([^=\s]+)\s*=/);
810
+ if (moduleExportsPropMatch) {
811
+ exports.add(moduleExportsPropMatch[1]);
812
+ }
813
+
814
+ const exportsPropMatch = trimmedLine.match(/exports\.([^=\s]+)\s*=/);
815
+ if (exportsPropMatch) {
816
+ exports.add(exportsPropMatch[1]);
817
+ }
818
+ }
819
+
820
+ return exports;
821
+ }
822
+
823
+ async resolveImportPath(importPath, currentFile) {
824
+ if (importPath.startsWith('.')) {
825
+ const currentDir = path.dirname(currentFile);
826
+ const resolved = path.resolve(currentDir, importPath);
827
+
828
+ // Try with extension first if provided
829
+ if (path.extname(importPath)) {
830
+ try {
831
+ const stat = await fs.stat(resolved);
832
+ if (stat.isFile()) {
833
+ return {
834
+ path: this.getRelativePath(resolved),
835
+ exists: true
836
+ };
837
+ }
838
+ } catch {
839
+ // File doesn't exist
840
+ }
841
+ }
842
+
843
+ // Try different extensions
844
+ const extensions = ['', '.js', '.mjs', '.ts', '.jsx', '.tsx', '/index.js', '/index.ts', '/index.jsx', '/index.tsx'];
845
+ for (const ext of extensions) {
846
+ const withExt = resolved + ext;
847
+ try {
848
+ const stat = await fs.stat(withExt);
849
+ if (stat.isFile()) {
850
+ return {
851
+ path: this.getRelativePath(withExt),
852
+ exists: true
853
+ };
854
+ }
855
+ } catch {
856
+ // Try next
857
+ }
858
+ }
859
+
860
+ return {
861
+ path: this.getRelativePath(resolved),
862
+ exists: false
863
+ };
864
+ }
865
+
866
+ // Node modules or absolute imports
867
+ return {
868
+ path: importPath,
869
+ exists: true,
870
+ isExternal: true
871
+ };
872
+ }
873
+
874
+ getRelativePath(filePath) {
875
+ return path.relative(this.rootDir, filePath).replace(/\\/g, '/');
876
+ }
877
+
878
+ findCircularDependencies() {
879
+ const cycles = [];
880
+ const visited = new Set();
881
+ const recursionStack = new Set();
882
+
883
+ const dfs = (node, path = []) => {
884
+ if (recursionStack.has(node)) {
885
+ const cycleStart = path.indexOf(node);
886
+ if (cycleStart !== -1) {
887
+ cycles.push([...path.slice(cycleStart), node]);
888
+ }
889
+ return;
890
+ }
891
+
892
+ if (visited.has(node)) {
893
+ return;
894
+ }
895
+
896
+ visited.add(node);
897
+ recursionStack.add(node);
898
+ path.push(node);
899
+
900
+ const deps = this.dependencies.get(node) || new Set();
901
+ for (const dep of deps) {
902
+ dfs(dep, [...path]);
903
+ }
904
+
905
+ recursionStack.delete(node);
906
+ };
907
+
908
+ for (const node of this.dependencies.keys()) {
909
+ if (!visited.has(node)) {
910
+ dfs(node);
911
+ }
912
+ }
913
+
914
+ return cycles;
915
+ }
916
+
917
+ findUnusedExports() {
918
+ const usedExports = new Map();
919
+
920
+ // Track which exports are actually imported
921
+ for (const imp of this.imports) {
922
+ if (!imp.isExternal) {
923
+ if (!usedExports.has(imp.importedFromFile)) {
924
+ usedExports.set(imp.importedFromFile, new Set());
925
+ }
926
+ usedExports.get(imp.importedFromFile).add(imp.importedSymbol);
927
+ }
928
+ }
929
+
930
+ // Find exports that are never imported
931
+ const unusedExports = {};
932
+ for (const [file, exports] of this.exports.entries()) {
933
+ const used = usedExports.get(file) || new Set();
934
+ const unused = Array.from(exports).filter(exp => !used.has(exp) && exp !== '*');
935
+
936
+ if (unused.length > 0) {
937
+ unusedExports[file] = unused;
938
+ }
939
+ }
940
+
941
+ return unusedExports;
942
+ }
943
+
944
+ async analyze(mode = 'full') {
945
+ this.logger?.info('Starting import analysis', { mode, rootDir: this.rootDir });
946
+
947
+ await this.loadIgnoreFile();
948
+
949
+ const files = await this.getAllFiles(this.rootDir);
950
+ this.logger?.info('Found files', { count: files.length });
951
+
952
+ // Parse all files
953
+ for (const file of files) {
954
+ try {
955
+ const content = await fs.readFile(file, 'utf-8');
956
+ const relativeFile = this.getRelativePath(file);
957
+
958
+ const fileImports = await this.parseImports(content, file);
959
+ this.imports.push(...fileImports);
960
+
961
+ const fileExports = this.parseExports(content);
962
+ this.exports.set(relativeFile, fileExports);
963
+ } catch (error) {
964
+ // Skip files with errors
965
+ this.logger?.warn('Error parsing file', { file, error: error.message });
966
+ }
967
+ }
968
+
969
+ this.logger?.info('Parsed all files', { imports: this.imports.length, exports: this.exports.size });
970
+
971
+ // Analyze issues
972
+ const results = {
973
+ summary: {
974
+ totalFiles: files.length,
975
+ totalImports: this.imports.length,
976
+ totalExports: Array.from(this.exports.values()).reduce((sum, exports) => sum + exports.size, 0)
977
+ },
978
+ missingExports: {},
979
+ missingFiles: {},
980
+ fileNotFoundImports: []
981
+ };
982
+
983
+ // Check imports
984
+ for (const importEntry of this.imports) {
985
+ const { importingFile, importedSymbol, importedFromFile, isDefault, isNamespace, fileExists, isExternal } = importEntry;
986
+
987
+ if (!fileExists && !isExternal) {
988
+ results.fileNotFoundImports.push({
989
+ importingFile,
990
+ importedSymbol,
991
+ importedFromFile,
992
+ isDefault: isDefault || false,
993
+ isNamespace: isNamespace || false
994
+ });
995
+
996
+ if (!results.missingFiles[importingFile]) {
997
+ results.missingFiles[importingFile] = [];
998
+ }
999
+
1000
+ results.missingFiles[importingFile].push({
1001
+ missingFile: importedFromFile,
1002
+ importedSymbol,
1003
+ isDefault: isDefault || false,
1004
+ isNamespace: isNamespace || false
1005
+ });
1006
+
1007
+ continue;
1008
+ }
1009
+
1010
+ if (isExternal) continue;
1011
+
1012
+ const exportingFileExports = this.exports.get(importedFromFile);
1013
+ let exists = false;
1014
+
1015
+ if (exportingFileExports) {
1016
+ if (isNamespace) {
1017
+ exists = exportingFileExports.size > 0;
1018
+ } else if (isDefault) {
1019
+ exists = exportingFileExports.has('default');
1020
+ } else {
1021
+ exists = exportingFileExports.has(importedSymbol) || exportingFileExports.has('*');
1022
+ }
1023
+ }
1024
+
1025
+ if (!exists) {
1026
+ if (!results.missingExports[importingFile]) {
1027
+ results.missingExports[importingFile] = [];
1028
+ }
1029
+
1030
+ results.missingExports[importingFile].push({
1031
+ importedSymbol,
1032
+ importedFromFile,
1033
+ availableExports: exportingFileExports ? Array.from(exportingFileExports) : [],
1034
+ isDefault: isDefault || false,
1035
+ isNamespace: isNamespace || false
1036
+ });
1037
+ }
1038
+ }
1039
+
1040
+ // Additional analysis for full mode
1041
+ if (mode === 'full' || mode === 'fix') {
1042
+ this.logger?.info('Running full analysis');
1043
+ results.circularDependencies = this.findCircularDependencies();
1044
+ results.unusedExports = this.findUnusedExports();
1045
+ }
1046
+
1047
+ this.logger?.info('Analysis complete', {
1048
+ missingFiles: results.fileNotFoundImports.length,
1049
+ missingExports: Object.keys(results.missingExports).length
1050
+ });
1051
+
1052
+ return results;
1053
+ }
1054
+ }
1055
+
1056
+ export default ImportAnalyzerTool;