@aiready/context-analyzer 0.22.8 → 0.22.11

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 (304) hide show
  1. package/.turbo/turbo-build.log +33 -32
  2. package/.turbo/turbo-format-check.log +2 -2
  3. package/.turbo/turbo-lint.log +9 -1
  4. package/.turbo/turbo-test.log +23 -23
  5. package/.turbo/turbo-type-check.log +1 -1
  6. package/dist/chunk-HD4Y3GYL.mjs +124 -0
  7. package/dist/{chunk-M2EGQ36M.mjs → chunk-ISWPFG2C.mjs} +43 -98
  8. package/dist/{chunk-BQCISA2F.mjs → chunk-QW6ULRML.mjs} +32 -6
  9. package/dist/{chunk-WHB7QI7N.mjs → chunk-T733LS62.mjs} +23 -4
  10. package/dist/{cli-action-CXIHOVAC.mjs → cli-action-FV4G4OB6.mjs} +3 -3
  11. package/dist/{cli-action-3CWN7PBE.mjs → cli-action-HYSWE7F4.mjs} +3 -3
  12. package/dist/{cli-action-MLFCIW2O.mjs → cli-action-VIQZSWSP.mjs} +3 -3
  13. package/dist/{cli-action-E7UGP4KE.mjs → cli-action-W7TESWAV.mjs} +6 -8
  14. package/dist/cli.js +236 -191
  15. package/dist/cli.mjs +1 -1
  16. package/dist/console-report-AP4JYNQY.mjs +74 -0
  17. package/dist/html-report-ULELSIYG.mjs +73 -0
  18. package/dist/index.d.mts +69 -337
  19. package/dist/index.d.ts +69 -337
  20. package/dist/index.js +90 -452
  21. package/dist/index.mjs +9 -157
  22. package/dist/interactive-setup-JGFBFI3M.mjs +75 -0
  23. package/dist/{orchestrator-3ERQS3NW.mjs → orchestrator-QNE2E4TE.mjs} +2 -2
  24. package/dist/summary-GQRWW3A2.mjs +7 -0
  25. package/dist/summary-JTBS7CPM.mjs +7 -0
  26. package/dist/summary-TZFB6ZFM.mjs +7 -0
  27. package/package.json +2 -2
  28. package/src/__tests__/file-classification.fixtures.ts +57 -0
  29. package/src/__tests__/file-classification.test.ts +24 -929
  30. package/src/__tests__/provider.test.ts +6 -72
  31. package/src/classifier.ts +42 -42
  32. package/src/cli-action.ts +11 -6
  33. package/src/index.ts +30 -27
  34. package/src/provider.ts +1 -1
  35. package/src/summary.ts +65 -10
  36. package/dist/__tests__/analyzer.test.d.ts +0 -2
  37. package/dist/__tests__/analyzer.test.d.ts.map +0 -1
  38. package/dist/__tests__/analyzer.test.js +0 -198
  39. package/dist/__tests__/analyzer.test.js.map +0 -1
  40. package/dist/__tests__/auto-detection.test.d.ts +0 -2
  41. package/dist/__tests__/auto-detection.test.d.ts.map +0 -1
  42. package/dist/__tests__/auto-detection.test.js +0 -132
  43. package/dist/__tests__/auto-detection.test.js.map +0 -1
  44. package/dist/__tests__/cluster-detector.test.d.ts +0 -2
  45. package/dist/__tests__/cluster-detector.test.d.ts.map +0 -1
  46. package/dist/__tests__/cluster-detector.test.js +0 -121
  47. package/dist/__tests__/cluster-detector.test.js.map +0 -1
  48. package/dist/__tests__/contract.test.d.ts +0 -2
  49. package/dist/__tests__/contract.test.d.ts.map +0 -1
  50. package/dist/__tests__/contract.test.js +0 -59
  51. package/dist/__tests__/contract.test.js.map +0 -1
  52. package/dist/__tests__/enhanced-cohesion.test.d.ts +0 -2
  53. package/dist/__tests__/enhanced-cohesion.test.d.ts.map +0 -1
  54. package/dist/__tests__/enhanced-cohesion.test.js +0 -119
  55. package/dist/__tests__/enhanced-cohesion.test.js.map +0 -1
  56. package/dist/__tests__/file-classification.test.d.ts +0 -2
  57. package/dist/__tests__/file-classification.test.d.ts.map +0 -1
  58. package/dist/__tests__/file-classification.test.js +0 -749
  59. package/dist/__tests__/file-classification.test.js.map +0 -1
  60. package/dist/__tests__/fragmentation-advanced.test.d.ts +0 -2
  61. package/dist/__tests__/fragmentation-advanced.test.d.ts.map +0 -1
  62. package/dist/__tests__/fragmentation-advanced.test.js +0 -44
  63. package/dist/__tests__/fragmentation-advanced.test.js.map +0 -1
  64. package/dist/__tests__/fragmentation-coupling.test.d.ts +0 -2
  65. package/dist/__tests__/fragmentation-coupling.test.d.ts.map +0 -1
  66. package/dist/__tests__/fragmentation-coupling.test.js +0 -52
  67. package/dist/__tests__/fragmentation-coupling.test.js.map +0 -1
  68. package/dist/__tests__/fragmentation-log.test.d.ts +0 -2
  69. package/dist/__tests__/fragmentation-log.test.d.ts.map +0 -1
  70. package/dist/__tests__/fragmentation-log.test.js +0 -29
  71. package/dist/__tests__/fragmentation-log.test.js.map +0 -1
  72. package/dist/__tests__/provider.test.d.ts +0 -2
  73. package/dist/__tests__/provider.test.d.ts.map +0 -1
  74. package/dist/__tests__/provider.test.js +0 -72
  75. package/dist/__tests__/provider.test.js.map +0 -1
  76. package/dist/__tests__/remediation.test.d.ts +0 -2
  77. package/dist/__tests__/remediation.test.d.ts.map +0 -1
  78. package/dist/__tests__/remediation.test.js +0 -61
  79. package/dist/__tests__/remediation.test.js.map +0 -1
  80. package/dist/__tests__/scoring.test.d.ts +0 -2
  81. package/dist/__tests__/scoring.test.d.ts.map +0 -1
  82. package/dist/__tests__/scoring.test.js +0 -298
  83. package/dist/__tests__/scoring.test.js.map +0 -1
  84. package/dist/__tests__/structural-cohesion.test.d.ts +0 -2
  85. package/dist/__tests__/structural-cohesion.test.d.ts.map +0 -1
  86. package/dist/__tests__/structural-cohesion.test.js +0 -35
  87. package/dist/__tests__/structural-cohesion.test.js.map +0 -1
  88. package/dist/analyzer.d.ts +0 -37
  89. package/dist/analyzer.d.ts.map +0 -1
  90. package/dist/analyzer.js +0 -283
  91. package/dist/analyzer.js.map +0 -1
  92. package/dist/analyzers/python-context.d.ts +0 -38
  93. package/dist/analyzers/python-context.d.ts.map +0 -1
  94. package/dist/analyzers/python-context.js +0 -234
  95. package/dist/analyzers/python-context.js.map +0 -1
  96. package/dist/ast-utils.d.ts +0 -16
  97. package/dist/ast-utils.d.ts.map +0 -1
  98. package/dist/ast-utils.js +0 -81
  99. package/dist/ast-utils.js.map +0 -1
  100. package/dist/chunk-22ZO4EKZ.mjs +0 -1297
  101. package/dist/chunk-2HE27YEV.mjs +0 -1739
  102. package/dist/chunk-45P4RDYP.mjs +0 -607
  103. package/dist/chunk-474DEGWW.mjs +0 -1792
  104. package/dist/chunk-4SYIJ7CU.mjs +0 -1538
  105. package/dist/chunk-4U4LDWGF.mjs +0 -360
  106. package/dist/chunk-4XQVYYPC.mjs +0 -1470
  107. package/dist/chunk-5CLU3HYU.mjs +0 -1475
  108. package/dist/chunk-5K73Q3OQ.mjs +0 -1520
  109. package/dist/chunk-5N5DCJOV.mjs +0 -583
  110. package/dist/chunk-6AVS4KTM.mjs +0 -1536
  111. package/dist/chunk-6FQYIG6I.mjs +0 -1298
  112. package/dist/chunk-6I4552YB.mjs +0 -1467
  113. package/dist/chunk-6LPITDKG.mjs +0 -1539
  114. package/dist/chunk-72QC5QUS.mjs +0 -549
  115. package/dist/chunk-736QSHJP.mjs +0 -1807
  116. package/dist/chunk-7LUSCLGR.mjs +0 -2058
  117. package/dist/chunk-7VK3XTSH.mjs +0 -1756
  118. package/dist/chunk-7ZEJGWLN.mjs +0 -1363
  119. package/dist/chunk-AECWO7NQ.mjs +0 -1539
  120. package/dist/chunk-AEK3MZC5.mjs +0 -709
  121. package/dist/chunk-AJC3FR6G.mjs +0 -1509
  122. package/dist/chunk-AMPK6SWS.mjs +0 -1754
  123. package/dist/chunk-BA7QGUHN.mjs +0 -1722
  124. package/dist/chunk-BCEZGRXI.mjs +0 -1297
  125. package/dist/chunk-BD4NWUVG.mjs +0 -1242
  126. package/dist/chunk-BEZPBI5C.mjs +0 -1829
  127. package/dist/chunk-BHCRDEE4.mjs +0 -1745
  128. package/dist/chunk-BW463GQB.mjs +0 -1767
  129. package/dist/chunk-CAX2MOUZ.mjs +0 -1801
  130. package/dist/chunk-CBWM3EK5.mjs +0 -1854
  131. package/dist/chunk-CCBNKQYB.mjs +0 -1812
  132. package/dist/chunk-CDIVYADN.mjs +0 -2110
  133. package/dist/chunk-CVGIDSMN.mjs +0 -1522
  134. package/dist/chunk-D25B5LZR.mjs +0 -1739
  135. package/dist/chunk-D3SIHB2V.mjs +0 -2118
  136. package/dist/chunk-DD7UVNE3.mjs +0 -678
  137. package/dist/chunk-DMRZMS2U.mjs +0 -964
  138. package/dist/chunk-DXG5NIYL.mjs +0 -1527
  139. package/dist/chunk-EBXG2Q5Y.mjs +0 -2059
  140. package/dist/chunk-EH3PMNZQ.mjs +0 -569
  141. package/dist/chunk-EMYD7NS6.mjs +0 -137
  142. package/dist/chunk-EVX2W2BK.mjs +0 -1896
  143. package/dist/chunk-EWFR366Y.mjs +0 -1740
  144. package/dist/chunk-EX7HCWAO.mjs +0 -625
  145. package/dist/chunk-FNPSK3CG.mjs +0 -1760
  146. package/dist/chunk-FO6YT6RG.mjs +0 -1751
  147. package/dist/chunk-FYI56A5M.mjs +0 -1892
  148. package/dist/chunk-G3CCJCBI.mjs +0 -1521
  149. package/dist/chunk-G7PO3DNK.mjs +0 -1072
  150. package/dist/chunk-GFADGYXZ.mjs +0 -1752
  151. package/dist/chunk-GTRIBVS6.mjs +0 -1467
  152. package/dist/chunk-GXTGOLZT.mjs +0 -92
  153. package/dist/chunk-H4HWBQU6.mjs +0 -1530
  154. package/dist/chunk-HDFXSEFW.mjs +0 -605
  155. package/dist/chunk-HOUDVRG2.mjs +0 -1422
  156. package/dist/chunk-HQNHM2X7.mjs +0 -997
  157. package/dist/chunk-I54HL4FZ.mjs +0 -781
  158. package/dist/chunk-I77HFFZU.mjs +0 -1876
  159. package/dist/chunk-IKRP7ECY.mjs +0 -1754
  160. package/dist/chunk-ILMLGJGI.mjs +0 -1295
  161. package/dist/chunk-IPIE5TXJ.mjs +0 -1741
  162. package/dist/chunk-IRWCPDWD.mjs +0 -779
  163. package/dist/chunk-J3MUOWHC.mjs +0 -1747
  164. package/dist/chunk-J5TA3AZU.mjs +0 -1795
  165. package/dist/chunk-JH535NPP.mjs +0 -1619
  166. package/dist/chunk-JUHHOSHG.mjs +0 -1808
  167. package/dist/chunk-JZ2SE4DB.mjs +0 -1116
  168. package/dist/chunk-K2WFOBAZ.mjs +0 -1821
  169. package/dist/chunk-K6U64EL3.mjs +0 -517
  170. package/dist/chunk-KDUUZQBK.mjs +0 -1692
  171. package/dist/chunk-KGFWKSGJ.mjs +0 -1442
  172. package/dist/chunk-KGVMS4R5.mjs +0 -1750
  173. package/dist/chunk-KWIS5FQP.mjs +0 -1739
  174. package/dist/chunk-KYSZF5N6.mjs +0 -1876
  175. package/dist/chunk-LERPI33Y.mjs +0 -2060
  176. package/dist/chunk-M64RHH4D.mjs +0 -1896
  177. package/dist/chunk-MBE4AQP5.mjs +0 -1362
  178. package/dist/chunk-MR7WXHIE.mjs +0 -1833
  179. package/dist/chunk-MZP3G7TF.mjs +0 -2118
  180. package/dist/chunk-N2GQWNFG.mjs +0 -1527
  181. package/dist/chunk-N6XBOOVA.mjs +0 -564
  182. package/dist/chunk-NJUW6VED.mjs +0 -610
  183. package/dist/chunk-NOHK5DLU.mjs +0 -2173
  184. package/dist/chunk-NQA3F2HJ.mjs +0 -1532
  185. package/dist/chunk-NXXQ2U73.mjs +0 -1467
  186. package/dist/chunk-OP4G6GLN.mjs +0 -1876
  187. package/dist/chunk-ORLC5Y4J.mjs +0 -1787
  188. package/dist/chunk-OTCQL7DY.mjs +0 -2045
  189. package/dist/chunk-OUYSZZ7X.mjs +0 -1846
  190. package/dist/chunk-OZE3FVZT.mjs +0 -1089
  191. package/dist/chunk-P3T3H27S.mjs +0 -1895
  192. package/dist/chunk-P5YV5WIX.mjs +0 -1803
  193. package/dist/chunk-P74BO725.mjs +0 -1296
  194. package/dist/chunk-PDN74MG3.mjs +0 -1834
  195. package/dist/chunk-PJD4VCIH.mjs +0 -1722
  196. package/dist/chunk-PVVCCE6W.mjs +0 -755
  197. package/dist/chunk-PVVMK56C.mjs +0 -1793
  198. package/dist/chunk-Q2GDZ2FZ.mjs +0 -1794
  199. package/dist/chunk-QDGPR3L6.mjs +0 -1518
  200. package/dist/chunk-RQCIJO5Z.mjs +0 -1116
  201. package/dist/chunk-RRB2C34Q.mjs +0 -1738
  202. package/dist/chunk-RYIB5CWD.mjs +0 -781
  203. package/dist/chunk-S6OPP4L5.mjs +0 -1791
  204. package/dist/chunk-SAVOSPM3.mjs +0 -1522
  205. package/dist/chunk-SFK6XTJE.mjs +0 -2110
  206. package/dist/chunk-SIX4KMF2.mjs +0 -1468
  207. package/dist/chunk-SPAM2YJE.mjs +0 -1537
  208. package/dist/chunk-T6ZCOPPI.mjs +0 -538
  209. package/dist/chunk-TPF75CNP.mjs +0 -581
  210. package/dist/chunk-TWWPY7FD.mjs +0 -1754
  211. package/dist/chunk-U5R2FTCR.mjs +0 -1803
  212. package/dist/chunk-UG7OPVHB.mjs +0 -1521
  213. package/dist/chunk-UMZTAWDA.mjs +0 -1812
  214. package/dist/chunk-UU4HZ7ZT.mjs +0 -1849
  215. package/dist/chunk-UXC6QUZ7.mjs +0 -1801
  216. package/dist/chunk-VBWXHKGD.mjs +0 -1895
  217. package/dist/chunk-VIJTZPBI.mjs +0 -1470
  218. package/dist/chunk-VLV6MXPL.mjs +0 -1750
  219. package/dist/chunk-VTALAPQZ.mjs +0 -1241
  220. package/dist/chunk-W2KNBN6W.mjs +0 -1849
  221. package/dist/chunk-W37E7MW5.mjs +0 -1403
  222. package/dist/chunk-W76FEISE.mjs +0 -1538
  223. package/dist/chunk-WCFQYXQA.mjs +0 -1532
  224. package/dist/chunk-WKOZOHOU.mjs +0 -2060
  225. package/dist/chunk-WTQJNY4U.mjs +0 -1785
  226. package/dist/chunk-XBFM2Z4O.mjs +0 -1792
  227. package/dist/chunk-XIXAWCMS.mjs +0 -1760
  228. package/dist/chunk-XTAXUNQN.mjs +0 -1742
  229. package/dist/chunk-XY77XABG.mjs +0 -1545
  230. package/dist/chunk-XZ645X5U.mjs +0 -1425
  231. package/dist/chunk-Y6FXYEAI.mjs +0 -10
  232. package/dist/chunk-YCGDIGOG.mjs +0 -1467
  233. package/dist/chunk-YYB6NZE3.mjs +0 -1869
  234. package/dist/chunk-Z5WY6A4P.mjs +0 -1754
  235. package/dist/chunk-ZAMFWKIB.mjs +0 -1842
  236. package/dist/classifier.d.ts +0 -114
  237. package/dist/classifier.d.ts.map +0 -1
  238. package/dist/classifier.js +0 -439
  239. package/dist/classifier.js.map +0 -1
  240. package/dist/cli-action-SA7SCYNV.mjs +0 -95
  241. package/dist/cli-action-VCXBZGZP.mjs +0 -95
  242. package/dist/cli-action-YAJOJCXJ.mjs +0 -95
  243. package/dist/cli.d.ts.map +0 -1
  244. package/dist/cli.js.map +0 -1
  245. package/dist/cluster-detector.d.ts +0 -8
  246. package/dist/cluster-detector.d.ts.map +0 -1
  247. package/dist/cluster-detector.js +0 -70
  248. package/dist/cluster-detector.js.map +0 -1
  249. package/dist/defaults.d.ts +0 -7
  250. package/dist/defaults.d.ts.map +0 -1
  251. package/dist/defaults.js +0 -54
  252. package/dist/defaults.js.map +0 -1
  253. package/dist/graph-builder.d.ts +0 -33
  254. package/dist/graph-builder.d.ts.map +0 -1
  255. package/dist/graph-builder.js +0 -225
  256. package/dist/graph-builder.js.map +0 -1
  257. package/dist/index.d.ts.map +0 -1
  258. package/dist/index.js.map +0 -1
  259. package/dist/metrics.d.ts +0 -34
  260. package/dist/metrics.d.ts.map +0 -1
  261. package/dist/metrics.js +0 -170
  262. package/dist/metrics.js.map +0 -1
  263. package/dist/orchestrator-3L3NAZYP.mjs +0 -10
  264. package/dist/orchestrator-5AL3XBPZ.mjs +0 -10
  265. package/dist/orchestrator-KMAKMHTD.mjs +0 -10
  266. package/dist/orchestrator-MONOZHVW.mjs +0 -10
  267. package/dist/orchestrator-R6MZT4Z2.mjs +0 -10
  268. package/dist/orchestrator-ZR7JSKWI.mjs +0 -10
  269. package/dist/provider.d.ts +0 -6
  270. package/dist/provider.d.ts.map +0 -1
  271. package/dist/provider.js +0 -48
  272. package/dist/provider.js.map +0 -1
  273. package/dist/python-context-3GZKN3LR.mjs +0 -162
  274. package/dist/python-context-GOH747QU.mjs +0 -202
  275. package/dist/python-context-O2EN3M6Z.mjs +0 -162
  276. package/dist/python-context-PAETRLDY.mjs +0 -185
  277. package/dist/python-context-TBI5FVFY.mjs +0 -203
  278. package/dist/python-context-UOPTQH44.mjs +0 -192
  279. package/dist/remediation.d.ts +0 -25
  280. package/dist/remediation.d.ts.map +0 -1
  281. package/dist/remediation.js +0 -98
  282. package/dist/remediation.js.map +0 -1
  283. package/dist/scoring.d.ts +0 -9
  284. package/dist/scoring.d.ts.map +0 -1
  285. package/dist/scoring.js +0 -142
  286. package/dist/scoring.js.map +0 -1
  287. package/dist/semantic-analysis.d.ts +0 -33
  288. package/dist/semantic-analysis.d.ts.map +0 -1
  289. package/dist/semantic-analysis.js +0 -303
  290. package/dist/semantic-analysis.js.map +0 -1
  291. package/dist/summary-7PZVW72O.mjs +0 -7
  292. package/dist/summary-LKUCJAIS.mjs +0 -7
  293. package/dist/summary.d.ts +0 -6
  294. package/dist/summary.d.ts.map +0 -1
  295. package/dist/summary.js +0 -92
  296. package/dist/summary.js.map +0 -1
  297. package/dist/types.d.ts +0 -124
  298. package/dist/types.d.ts.map +0 -1
  299. package/dist/types.js +0 -2
  300. package/dist/types.js.map +0 -1
  301. package/dist/utils/output-formatter.d.ts +0 -14
  302. package/dist/utils/output-formatter.d.ts.map +0 -1
  303. package/dist/utils/output-formatter.js +0 -338
  304. package/dist/utils/output-formatter.js.map +0 -1
package/dist/index.js CHANGED
@@ -406,30 +406,6 @@ function buildCoUsageMatrix(graph) {
406
406
  }
407
407
  return coUsageMatrix;
408
408
  }
409
- function findSemanticClusters(coUsageMatrix, minCoUsage = 3) {
410
- const clusters = /* @__PURE__ */ new Map();
411
- const visited = /* @__PURE__ */ new Set();
412
- for (const [file, coUsages] of coUsageMatrix) {
413
- if (visited.has(file)) continue;
414
- const cluster = [file];
415
- visited.add(file);
416
- for (const [relatedFile, count] of coUsages) {
417
- if (count >= minCoUsage && !visited.has(relatedFile)) {
418
- cluster.push(relatedFile);
419
- visited.add(relatedFile);
420
- }
421
- }
422
- if (cluster.length > 1) clusters.set(file, cluster);
423
- }
424
- return clusters;
425
- }
426
- function getCoUsageData(file, coUsageMatrix) {
427
- return {
428
- file,
429
- coImportedWith: coUsageMatrix.get(file) || /* @__PURE__ */ new Map(),
430
- sharedImporters: []
431
- };
432
- }
433
409
  var init_co_usage = __esm({
434
410
  "src/semantic/co-usage.ts"() {
435
411
  "use strict";
@@ -1040,66 +1016,66 @@ var init_file_classifiers = __esm({
1040
1016
  // src/classifier.ts
1041
1017
  function classifyFile(node, cohesionScore = 1, domains = []) {
1042
1018
  if (isBoilerplateBarrel(node)) {
1043
- return Classification.BOILERPLATE;
1019
+ return CLASSIFICATION.BOILERPLATE;
1044
1020
  }
1045
1021
  if (isBarrelExport(node)) {
1046
- return Classification.BARREL;
1022
+ return CLASSIFICATION.BARREL;
1047
1023
  }
1048
1024
  if (isTypeDefinition(node)) {
1049
- return Classification.TYPE_DEFINITION;
1025
+ return CLASSIFICATION.TYPE_DEFINITION;
1050
1026
  }
1051
1027
  if (isNextJsPage(node)) {
1052
- return Classification.NEXTJS_PAGE;
1028
+ return CLASSIFICATION.NEXTJS_PAGE;
1053
1029
  }
1054
1030
  if (isLambdaHandler(node)) {
1055
- return Classification.LAMBDA_HANDLER;
1031
+ return CLASSIFICATION.LAMBDA_HANDLER;
1056
1032
  }
1057
1033
  if (isServiceFile(node)) {
1058
- return Classification.SERVICE;
1034
+ return CLASSIFICATION.SERVICE;
1059
1035
  }
1060
1036
  if (isEmailTemplate(node)) {
1061
- return Classification.EMAIL_TEMPLATE;
1037
+ return CLASSIFICATION.EMAIL_TEMPLATE;
1062
1038
  }
1063
1039
  if (isParserFile(node)) {
1064
- return Classification.PARSER;
1040
+ return CLASSIFICATION.PARSER;
1065
1041
  }
1066
1042
  if (isSessionFile(node)) {
1067
1043
  if (cohesionScore >= 0.25 && domains.length <= 1)
1068
- return Classification.COHESIVE_MODULE;
1069
- return Classification.UTILITY_MODULE;
1044
+ return CLASSIFICATION.COHESIVE_MODULE;
1045
+ return CLASSIFICATION.UTILITY_MODULE;
1070
1046
  }
1071
1047
  if (isUtilityModule(node)) {
1072
- return Classification.UTILITY_MODULE;
1048
+ return CLASSIFICATION.UTILITY_MODULE;
1073
1049
  }
1074
1050
  if (isConfigFile(node)) {
1075
- return Classification.COHESIVE_MODULE;
1051
+ return CLASSIFICATION.COHESIVE_MODULE;
1076
1052
  }
1077
1053
  if (isHubAndSpokeFile(node)) {
1078
- return Classification.SPOKE_MODULE;
1054
+ return CLASSIFICATION.SPOKE_MODULE;
1079
1055
  }
1080
1056
  if (domains.length <= 1 && domains[0] !== "unknown") {
1081
- return Classification.COHESIVE_MODULE;
1057
+ return CLASSIFICATION.COHESIVE_MODULE;
1082
1058
  }
1083
1059
  if (domains.length > 1 && cohesionScore < 0.4) {
1084
- return Classification.MIXED_CONCERNS;
1060
+ return CLASSIFICATION.MIXED_CONCERNS;
1085
1061
  }
1086
1062
  if (cohesionScore >= 0.7) {
1087
- return Classification.COHESIVE_MODULE;
1063
+ return CLASSIFICATION.COHESIVE_MODULE;
1088
1064
  }
1089
- return Classification.UNKNOWN;
1065
+ return CLASSIFICATION.UNKNOWN;
1090
1066
  }
1091
1067
  function adjustCohesionForClassification(baseCohesion, classification, node) {
1092
1068
  switch (classification) {
1093
- case Classification.BOILERPLATE:
1069
+ case CLASSIFICATION.BOILERPLATE:
1094
1070
  return 0.2;
1095
1071
  // Redundant indirection is low cohesion (architectural theater)
1096
- case Classification.BARREL:
1072
+ case CLASSIFICATION.BARREL:
1097
1073
  return 1;
1098
- case Classification.TYPE_DEFINITION:
1074
+ case CLASSIFICATION.TYPE_DEFINITION:
1099
1075
  return 1;
1100
- case Classification.NEXTJS_PAGE:
1076
+ case CLASSIFICATION.NEXTJS_PAGE:
1101
1077
  return 1;
1102
- case Classification.UTILITY_MODULE: {
1078
+ case CLASSIFICATION.UTILITY_MODULE: {
1103
1079
  if (node && hasRelatedExportNames(
1104
1080
  (node.exports || []).map((e) => e.name.toLowerCase())
1105
1081
  )) {
@@ -1107,19 +1083,19 @@ function adjustCohesionForClassification(baseCohesion, classification, node) {
1107
1083
  }
1108
1084
  return Math.max(0.75, Math.min(1, baseCohesion + 0.35));
1109
1085
  }
1110
- case Classification.SERVICE:
1086
+ case CLASSIFICATION.SERVICE:
1111
1087
  return Math.max(0.72, Math.min(1, baseCohesion + 0.3));
1112
- case Classification.LAMBDA_HANDLER:
1088
+ case CLASSIFICATION.LAMBDA_HANDLER:
1113
1089
  return Math.max(0.75, Math.min(1, baseCohesion + 0.35));
1114
- case Classification.EMAIL_TEMPLATE:
1090
+ case CLASSIFICATION.EMAIL_TEMPLATE:
1115
1091
  return Math.max(0.72, Math.min(1, baseCohesion + 0.3));
1116
- case Classification.PARSER:
1092
+ case CLASSIFICATION.PARSER:
1117
1093
  return Math.max(0.7, Math.min(1, baseCohesion + 0.3));
1118
- case Classification.SPOKE_MODULE:
1094
+ case CLASSIFICATION.SPOKE_MODULE:
1119
1095
  return Math.max(baseCohesion, 0.6);
1120
- case Classification.COHESIVE_MODULE:
1096
+ case CLASSIFICATION.COHESIVE_MODULE:
1121
1097
  return Math.max(baseCohesion, 0.7);
1122
- case Classification.MIXED_CONCERNS:
1098
+ case CLASSIFICATION.MIXED_CONCERNS:
1123
1099
  return baseCohesion;
1124
1100
  default:
1125
1101
  return Math.min(1, baseCohesion + 0.1);
@@ -1168,37 +1144,37 @@ function hasRelatedExportNames(exportNames) {
1168
1144
  }
1169
1145
  function adjustFragmentationForClassification(baseFragmentation, classification) {
1170
1146
  switch (classification) {
1171
- case Classification.BOILERPLATE:
1147
+ case CLASSIFICATION.BOILERPLATE:
1172
1148
  return baseFragmentation * 1.5;
1173
1149
  // Redundant barrels increase fragmentation
1174
- case Classification.BARREL:
1150
+ case CLASSIFICATION.BARREL:
1175
1151
  return 0;
1176
- case Classification.TYPE_DEFINITION:
1152
+ case CLASSIFICATION.TYPE_DEFINITION:
1177
1153
  return 0;
1178
- case Classification.UTILITY_MODULE:
1179
- case Classification.SERVICE:
1180
- case Classification.LAMBDA_HANDLER:
1181
- case Classification.EMAIL_TEMPLATE:
1182
- case Classification.PARSER:
1183
- case Classification.NEXTJS_PAGE:
1154
+ case CLASSIFICATION.UTILITY_MODULE:
1155
+ case CLASSIFICATION.SERVICE:
1156
+ case CLASSIFICATION.LAMBDA_HANDLER:
1157
+ case CLASSIFICATION.EMAIL_TEMPLATE:
1158
+ case CLASSIFICATION.PARSER:
1159
+ case CLASSIFICATION.NEXTJS_PAGE:
1184
1160
  return baseFragmentation * 0.2;
1185
- case Classification.SPOKE_MODULE:
1161
+ case CLASSIFICATION.SPOKE_MODULE:
1186
1162
  return baseFragmentation * 0.15;
1187
1163
  // Heavily discount intentional monorepo separation
1188
- case Classification.COHESIVE_MODULE:
1164
+ case CLASSIFICATION.COHESIVE_MODULE:
1189
1165
  return baseFragmentation * 0.3;
1190
- case Classification.MIXED_CONCERNS:
1166
+ case CLASSIFICATION.MIXED_CONCERNS:
1191
1167
  return baseFragmentation;
1192
1168
  default:
1193
1169
  return baseFragmentation * 0.7;
1194
1170
  }
1195
1171
  }
1196
- var Classification;
1172
+ var CLASSIFICATION;
1197
1173
  var init_classifier = __esm({
1198
1174
  "src/classifier.ts"() {
1199
1175
  "use strict";
1200
1176
  init_file_classifiers();
1201
- Classification = {
1177
+ CLASSIFICATION = {
1202
1178
  BARREL: "barrel-export",
1203
1179
  BOILERPLATE: "boilerplate-barrel",
1204
1180
  TYPE_DEFINITION: "type-definition",
@@ -1786,11 +1762,37 @@ function generateSummary(results, options = {}) {
1786
1762
  const deepFiles = results.filter((r) => r.importDepth > 5).map((r) => ({ file: r.file, depth: r.importDepth }));
1787
1763
  const maxImportDepth = Math.max(0, ...results.map((r) => r.importDepth));
1788
1764
  const moduleMap = /* @__PURE__ */ new Map();
1765
+ const rootDir = config.rootDir || "";
1789
1766
  results.forEach((r) => {
1790
- const parts = r.file.split("/");
1767
+ let relativePath = r.file;
1768
+ if (rootDir && r.file.startsWith(rootDir)) {
1769
+ relativePath = r.file.slice(rootDir.length);
1770
+ if (relativePath.startsWith("/")) relativePath = relativePath.slice(1);
1771
+ }
1772
+ const parts = relativePath.split("/");
1791
1773
  let domain = "root";
1792
- if (parts.length > 2) {
1793
- domain = parts.slice(0, 2).join("/");
1774
+ const domainIndicators = ["packages", "apps", "src", "lib", "modules"];
1775
+ for (let i = 0; i < parts.length - 1; i++) {
1776
+ if (domainIndicators.includes(parts[i]) && parts[i + 1]) {
1777
+ domain = `${parts[i]}/${parts[i + 1]}`;
1778
+ break;
1779
+ }
1780
+ }
1781
+ if (domain === "root" && parts.length > 1) {
1782
+ const skipPrefixes = [
1783
+ "src",
1784
+ "lib",
1785
+ "dist",
1786
+ "build",
1787
+ "out",
1788
+ "node_modules"
1789
+ ];
1790
+ for (let i = 0; i < parts.length - 1; i++) {
1791
+ if (!skipPrefixes.includes(parts[i]) && parts[i] !== "") {
1792
+ domain = parts[i];
1793
+ break;
1794
+ }
1795
+ }
1794
1796
  }
1795
1797
  if (!moduleMap.has(domain)) moduleMap.set(domain, []);
1796
1798
  moduleMap.get(domain).push(r);
@@ -1800,14 +1802,21 @@ function generateSummary(results, options = {}) {
1800
1802
  const clusterTokens = files.reduce((sum, f) => sum + f.tokenCost, 0);
1801
1803
  const filePaths = files.map((f) => f.file);
1802
1804
  const avgEntropy = calculatePathEntropy(filePaths);
1803
- const fragmentationScore = Math.min(1, avgEntropy * (files.length / 10));
1805
+ const avgCohesion2 = files.reduce((sum, f) => sum + f.cohesionScore, 0) / files.length;
1806
+ const cohesionFactor = avgCohesion2 < 0.5 ? (0.5 - avgCohesion2) * 2 : 0;
1807
+ const entropyFactor = avgEntropy > 0.7 ? (avgEntropy - 0.7) * 3.33 : 0;
1808
+ const sizeFactor = files.length > 20 ? Math.min(1, (files.length - 20) / 80) : 0;
1809
+ const fragmentationScore = Math.min(
1810
+ 1,
1811
+ cohesionFactor * 0.5 + entropyFactor * 0.3 + sizeFactor * 0.2
1812
+ );
1804
1813
  if (fragmentationScore > 0.4) {
1805
1814
  fragmentedModules.push({
1806
1815
  domain,
1807
1816
  files: filePaths,
1808
1817
  fragmentationScore,
1809
1818
  totalTokens: clusterTokens,
1810
- avgCohesion: files.reduce((sum, f) => sum + f.cohesionScore, 0) / files.length,
1819
+ avgCohesion: avgCohesion2,
1811
1820
  suggestedStructure: {
1812
1821
  targetFiles: Math.ceil(files.length / 2),
1813
1822
  consolidationPlan: [
@@ -1867,28 +1876,15 @@ var init_summary = __esm({
1867
1876
  // src/index.ts
1868
1877
  var index_exports = {};
1869
1878
  __export(index_exports, {
1870
- BARREL_EXPORT_MIN_EXPORTS: () => BARREL_EXPORT_MIN_EXPORTS,
1871
- BARREL_EXPORT_TOKEN_LIMIT: () => BARREL_EXPORT_TOKEN_LIMIT,
1872
- CONFIG_NAME_PATTERNS: () => CONFIG_NAME_PATTERNS,
1873
- Classification: () => Classification,
1874
- ContextAnalyzerProvider: () => ContextAnalyzerProvider,
1875
- EMAIL_NAME_PATTERNS: () => EMAIL_NAME_PATTERNS,
1876
- HANDLER_NAME_PATTERNS: () => HANDLER_NAME_PATTERNS,
1877
- NEXTJS_METADATA_EXPORTS: () => NEXTJS_METADATA_EXPORTS,
1878
- PARSER_NAME_PATTERNS: () => PARSER_NAME_PATTERNS,
1879
- SERVICE_NAME_PATTERNS: () => SERVICE_NAME_PATTERNS,
1880
- SESSION_NAME_PATTERNS: () => SESSION_NAME_PATTERNS,
1879
+ CONTEXT_ANALYZER_PROVIDER: () => CONTEXT_ANALYZER_PROVIDER,
1881
1880
  adjustCohesionForClassification: () => adjustCohesionForClassification,
1882
1881
  adjustFragmentationForClassification: () => adjustFragmentationForClassification,
1883
1882
  analyzeContext: () => analyzeContext,
1884
- buildCoUsageMatrix: () => buildCoUsageMatrix,
1885
1883
  buildDependencyGraph: () => buildDependencyGraph,
1886
- buildTypeGraph: () => buildTypeGraph,
1887
1884
  calculateCohesion: () => calculateCohesion,
1888
1885
  calculateContextBudget: () => calculateContextBudget,
1889
1886
  calculateContextScore: () => calculateContextScore,
1890
1887
  calculateDirectoryDistance: () => calculateDirectoryDistance,
1891
- calculateDomainConfidence: () => calculateDomainConfidence,
1892
1888
  calculateEnhancedCohesion: () => calculateEnhancedCohesion,
1893
1889
  calculateFragmentation: () => calculateFragmentation,
1894
1890
  calculateImportDepth: () => calculateImportDepth,
@@ -1897,37 +1893,14 @@ __export(index_exports, {
1897
1893
  classifyFile: () => classifyFile,
1898
1894
  detectCircularDependencies: () => detectCircularDependencies,
1899
1895
  detectModuleClusters: () => detectModuleClusters,
1900
- displayConsoleReport: () => displayConsoleReport,
1901
- extractDomainKeywordsFromPaths: () => extractDomainKeywordsFromPaths,
1902
- extractExports: () => extractExports,
1903
- findConsolidationCandidates: () => findConsolidationCandidates,
1904
- findSemanticClusters: () => findSemanticClusters,
1905
- generateHTMLReport: () => generateHTMLReport,
1906
1896
  generateSummary: () => generateSummary,
1907
1897
  getClassificationRecommendations: () => getClassificationRecommendations,
1908
- getCoUsageData: () => getCoUsageData,
1909
1898
  getGeneralRecommendations: () => getGeneralRecommendations,
1910
- getSmartDefaults: () => getSmartDefaults,
1911
1899
  getTransitiveDependencies: () => getTransitiveDependencies,
1912
- inferDomain: () => inferDomain,
1913
- inferDomainFromSemantics: () => inferDomainFromSemantics,
1914
- isBarrelExport: () => isBarrelExport,
1915
- isBoilerplateBarrel: () => isBoilerplateBarrel,
1916
- isConfigFile: () => isConfigFile,
1917
- isEmailTemplate: () => isEmailTemplate,
1918
- isHubAndSpokeFile: () => isHubAndSpokeFile,
1919
- isLambdaHandler: () => isLambdaHandler,
1920
- isNextJsPage: () => isNextJsPage,
1921
- isParserFile: () => isParserFile,
1922
- isServiceFile: () => isServiceFile,
1923
- isSessionFile: () => isSessionFile,
1924
- isTypeDefinition: () => isTypeDefinition,
1925
- isUtilityModule: () => isUtilityModule,
1926
- mapScoreToRating: () => mapScoreToRating,
1927
- runInteractiveSetup: () => runInteractiveSetup
1900
+ mapScoreToRating: () => mapScoreToRating
1928
1901
  });
1929
1902
  module.exports = __toCommonJS(index_exports);
1930
- var import_core12 = require("@aiready/core");
1903
+ var import_core10 = require("@aiready/core");
1931
1904
 
1932
1905
  // src/provider.ts
1933
1906
  var import_core9 = require("@aiready/core");
@@ -2117,7 +2090,7 @@ function mapScoreToRating(score) {
2117
2090
  }
2118
2091
 
2119
2092
  // src/provider.ts
2120
- var ContextAnalyzerProvider = {
2093
+ var CONTEXT_ANALYZER_PROVIDER = {
2121
2094
  id: import_core9.ToolName.ContextAnalyzer,
2122
2095
  alias: ["context", "fragmentation", "budget"],
2123
2096
  async analyze(options) {
@@ -2162,336 +2135,24 @@ var ContextAnalyzerProvider = {
2162
2135
 
2163
2136
  // src/index.ts
2164
2137
  init_orchestrator();
2165
- init_graph_builder();
2166
2138
  init_metrics();
2167
- init_classifier();
2168
2139
  init_cluster_detector();
2140
+ init_graph_builder();
2141
+ init_classifier();
2169
2142
  init_remediation();
2170
-
2171
- // src/defaults.ts
2172
- var import_core10 = require("@aiready/core");
2173
- async function getSmartDefaults(directory, userOptions) {
2174
- const files = await (0, import_core10.scanFiles)({
2175
- rootDir: directory,
2176
- include: userOptions.include,
2177
- exclude: userOptions.exclude
2178
- });
2179
- const estimatedBlocks = files.length;
2180
- let maxDepth;
2181
- let maxContextBudget;
2182
- let minCohesion;
2183
- let maxFragmentation;
2184
- if (estimatedBlocks < 100) {
2185
- maxDepth = 5;
2186
- maxContextBudget = 8e3;
2187
- minCohesion = 0.5;
2188
- maxFragmentation = 0.5;
2189
- } else if (estimatedBlocks < 500) {
2190
- maxDepth = 6;
2191
- maxContextBudget = 15e3;
2192
- minCohesion = 0.45;
2193
- maxFragmentation = 0.6;
2194
- } else if (estimatedBlocks < 2e3) {
2195
- maxDepth = 8;
2196
- maxContextBudget = 25e3;
2197
- minCohesion = 0.4;
2198
- maxFragmentation = 0.7;
2199
- } else {
2200
- maxDepth = 12;
2201
- maxContextBudget = 4e4;
2202
- minCohesion = 0.35;
2203
- maxFragmentation = 0.8;
2204
- }
2205
- return {
2206
- maxDepth,
2207
- maxContextBudget,
2208
- minCohesion,
2209
- maxFragmentation,
2210
- focus: "all",
2211
- includeNodeModules: false,
2212
- rootDir: userOptions.rootDir || directory,
2213
- include: userOptions.include,
2214
- exclude: userOptions.exclude
2215
- };
2216
- }
2217
-
2218
- // src/index.ts
2219
2143
  init_summary();
2220
- init_co_usage();
2221
- init_type_graph();
2222
- init_domain_inference();
2223
-
2224
- // src/semantic/consolidation.ts
2225
- function findConsolidationCandidates(graph, coUsageMatrix, typeGraph, minCoUsage = 5, minSharedTypes = 2) {
2226
- const candidates = [];
2227
- for (const [fileA, coUsages] of coUsageMatrix) {
2228
- const nodeA = graph.nodes.get(fileA);
2229
- if (!nodeA) continue;
2230
- for (const [fileB, count] of coUsages) {
2231
- if (fileB <= fileA || count < minCoUsage) continue;
2232
- const nodeB = graph.nodes.get(fileB);
2233
- if (!nodeB) continue;
2234
- const typesA = new Set(
2235
- nodeA.exports.flatMap((e) => e.typeReferences || [])
2236
- );
2237
- const typesB = new Set(
2238
- nodeB.exports.flatMap((e) => e.typeReferences || [])
2239
- );
2240
- const sharedTypes = Array.from(typesA).filter((t) => typesB.has(t));
2241
- if (sharedTypes.length >= minSharedTypes || count >= minCoUsage * 2) {
2242
- candidates.push({
2243
- files: [fileA, fileB],
2244
- reason: `High co-usage (${count}x)`,
2245
- strength: count / 10
2246
- });
2247
- }
2248
- }
2249
- }
2250
- return candidates.sort((a, b) => b.strength - a.strength);
2251
- }
2252
-
2253
- // src/index.ts
2254
- init_classification_patterns();
2255
- init_file_classifiers();
2256
-
2257
- // src/report/console-report.ts
2258
- var import_chalk = __toESM(require("chalk"));
2259
- function displayConsoleReport(summary, results, maxResults = 10) {
2260
- const divider = "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
2261
- const totalIssues = summary.criticalIssues + summary.majorIssues + summary.minorIssues;
2262
- console.log(import_chalk.default.bold("\u{1F4CA} Context Analysis Summary:\n"));
2263
- console.log(` \u2022 Total Files: ${import_chalk.default.cyan(summary.totalFiles)}`);
2264
- console.log(
2265
- ` \u2022 Total Tokens: ${import_chalk.default.cyan(summary.totalTokens.toLocaleString())}`
2266
- );
2267
- console.log(
2268
- ` \u2022 Avg Budget: ${import_chalk.default.cyan(summary.avgContextBudget.toFixed(0))} tokens`
2269
- );
2270
- console.log(
2271
- ` \u2022 Potential Saving: ${import_chalk.default.green(summary.totalPotentialSavings.toLocaleString())} tokens`
2272
- );
2273
- console.log();
2274
- if (totalIssues > 0) {
2275
- console.log(import_chalk.default.bold("\u26A0\uFE0F Issues Detected:\n"));
2276
- console.log(` \u2022 ${import_chalk.default.red("\u{1F534} Critical:")} ${summary.criticalIssues}`);
2277
- console.log(` \u2022 ${import_chalk.default.yellow("\u{1F7E1} Major:")} ${summary.majorIssues}`);
2278
- console.log(` \u2022 ${import_chalk.default.blue("\u{1F535} Minor:")} ${summary.minorIssues}`);
2279
- console.log();
2280
- } else {
2281
- console.log(import_chalk.default.green("\u2705 No significant context issues detected!\n"));
2282
- }
2283
- if (summary.fragmentedModules.length > 0) {
2284
- console.log(import_chalk.default.bold("\u{1F9E9} Top Fragmented Modules:\n"));
2285
- summary.fragmentedModules.slice(0, maxResults).forEach((mod) => {
2286
- const scoreColor = mod.fragmentationScore > 0.7 ? import_chalk.default.red : mod.fragmentationScore > 0.4 ? import_chalk.default.yellow : import_chalk.default.green;
2287
- console.log(
2288
- ` ${scoreColor("\u25A0")} ${import_chalk.default.white(mod.domain)} ${import_chalk.default.dim(`(${mod.files.length} files, ${(mod.fragmentationScore * 100).toFixed(0)}% frag)`)}`
2289
- );
2290
- });
2291
- console.log();
2292
- }
2293
- if (summary.topExpensiveFiles.length > 0) {
2294
- console.log(import_chalk.default.bold("\u{1F4B8} Most Expensive Files (Context Budget):\n"));
2295
- summary.topExpensiveFiles.slice(0, maxResults).forEach((item) => {
2296
- const fileName = item.file.split("/").slice(-2).join("/");
2297
- const severityColor = item.severity === "critical" ? import_chalk.default.red : item.severity === "major" ? import_chalk.default.yellow : import_chalk.default.blue;
2298
- console.log(
2299
- ` ${severityColor("\u25CF")} ${import_chalk.default.white(fileName)} ${import_chalk.default.dim(`- ${item.contextBudget.toLocaleString()} tokens`)}`
2300
- );
2301
- });
2302
- console.log();
2303
- }
2304
- if (totalIssues > 0) {
2305
- console.log(import_chalk.default.bold("\u{1F4A1} Top Recommendations:\n"));
2306
- const topFiles = results.filter((r) => r.severity === "critical" || r.severity === "major").slice(0, 3);
2307
- topFiles.forEach((result, index) => {
2308
- const fileName = result.file.split("/").slice(-2).join("/");
2309
- console.log(import_chalk.default.cyan(` ${index + 1}. ${fileName}`));
2310
- result.recommendations.slice(0, 2).forEach((rec) => {
2311
- console.log(import_chalk.default.dim(` \u2022 ${rec}`));
2312
- });
2313
- });
2314
- console.log();
2315
- }
2316
- console.log(import_chalk.default.cyan(divider));
2317
- console.log(
2318
- import_chalk.default.dim(
2319
- "\n\u2B50 Like aiready? Star us on GitHub: https://github.com/caopengau/aiready-context-analyzer"
2320
- )
2321
- );
2322
- console.log(
2323
- import_chalk.default.dim(
2324
- "\u{1F41B} Found a bug? Report it: https://github.com/caopengau/aiready-context-analyzer/issues\n"
2325
- )
2326
- );
2327
- }
2328
-
2329
- // src/report/html-report.ts
2330
- var import_core11 = require("@aiready/core");
2331
- function generateHTMLReport(summary, results) {
2332
- const totalIssues = summary.criticalIssues + summary.majorIssues + summary.minorIssues;
2333
- void results;
2334
- const stats = [
2335
- { value: summary.totalFiles, label: "Files Analyzed" },
2336
- { value: summary.totalTokens.toLocaleString(), label: "Total Tokens" },
2337
- { value: summary.avgContextBudget.toFixed(0), label: "Avg Context Budget" },
2338
- {
2339
- value: totalIssues,
2340
- label: "Total Issues",
2341
- color: totalIssues > 0 ? "#f39c12" : void 0
2342
- }
2343
- ];
2344
- const sections = [];
2345
- if (totalIssues > 0) {
2346
- sections.push({
2347
- title: "\u26A0\uFE0F Issues Summary",
2348
- content: (0, import_core11.generateIssueSummary)(
2349
- summary.criticalIssues,
2350
- summary.majorIssues,
2351
- summary.minorIssues,
2352
- summary.totalPotentialSavings
2353
- )
2354
- });
2355
- }
2356
- if (summary.fragmentedModules.length > 0) {
2357
- sections.push({
2358
- title: "\u{1F9E9} Fragmented Modules",
2359
- content: (0, import_core11.generateTable)({
2360
- headers: ["Domain", "Files", "Fragmentation", "Token Cost"],
2361
- rows: summary.fragmentedModules.map((m) => [
2362
- m.domain,
2363
- String(m.files.length),
2364
- `${(m.fragmentationScore * 100).toFixed(0)}%`,
2365
- m.totalTokens.toLocaleString()
2366
- ])
2367
- })
2368
- });
2369
- }
2370
- if (summary.topExpensiveFiles.length > 0) {
2371
- sections.push({
2372
- title: "\u{1F4B8} Most Expensive Files",
2373
- content: (0, import_core11.generateTable)({
2374
- headers: ["File", "Context Budget", "Severity"],
2375
- rows: summary.topExpensiveFiles.map((f) => [
2376
- f.file,
2377
- `${f.contextBudget.toLocaleString()} tokens`,
2378
- `<span class="issue-${f.severity}">${f.severity.toUpperCase()}</span>`
2379
- ])
2380
- })
2381
- });
2382
- }
2383
- return (0, import_core11.generateStandardHtmlReport)(
2384
- {
2385
- title: "Context Analysis Report",
2386
- packageName: "context-analyzer",
2387
- packageUrl: "https://github.com/caopengau/aiready-context-analyzer",
2388
- bugUrl: "https://github.com/caopengau/aiready-context-analyzer/issues",
2389
- emoji: "\u{1F9E0}"
2390
- },
2391
- stats,
2392
- sections
2393
- );
2394
- }
2395
-
2396
- // src/report/interactive-setup.ts
2397
- var import_chalk2 = __toESM(require("chalk"));
2398
- var import_fs2 = require("fs");
2399
- var import_path3 = require("path");
2400
- var import_prompts = __toESM(require("prompts"));
2401
- async function runInteractiveSetup(directory, current) {
2402
- console.log(import_chalk2.default.yellow("\u{1F9ED} Interactive mode: let's tailor the analysis."));
2403
- const pkgPath = (0, import_path3.join)(directory, "package.json");
2404
- let deps = {};
2405
- if ((0, import_fs2.existsSync)(pkgPath)) {
2406
- try {
2407
- const pkg = JSON.parse((0, import_fs2.readFileSync)(pkgPath, "utf-8"));
2408
- deps = { ...pkg.dependencies || {}, ...pkg.devDependencies || {} };
2409
- } catch (e) {
2410
- void e;
2411
- }
2412
- }
2413
- const hasNextJs = (0, import_fs2.existsSync)((0, import_path3.join)(directory, ".next")) || !!deps["next"];
2414
- const hasCDK = (0, import_fs2.existsSync)((0, import_path3.join)(directory, "cdk.out")) || !!deps["aws-cdk-lib"] || Object.keys(deps).some((d) => d.startsWith("@aws-cdk/"));
2415
- const recommendedExcludes = new Set(current.exclude || []);
2416
- if (hasNextJs && !Array.from(recommendedExcludes).some((p) => p.includes(".next"))) {
2417
- recommendedExcludes.add("**/.next/**");
2418
- }
2419
- if (hasCDK && !Array.from(recommendedExcludes).some((p) => p.includes("cdk.out"))) {
2420
- recommendedExcludes.add("**/cdk.out/**");
2421
- }
2422
- const { applyExcludes } = await (0, import_prompts.default)({
2423
- type: "toggle",
2424
- name: "applyExcludes",
2425
- message: `Detected ${hasNextJs ? "Next.js " : ""}${hasCDK ? "AWS CDK " : ""}frameworks. Apply recommended excludes?`,
2426
- initial: true,
2427
- active: "yes",
2428
- inactive: "no"
2429
- });
2430
- const nextOptions = { ...current };
2431
- if (applyExcludes) {
2432
- nextOptions.exclude = Array.from(recommendedExcludes);
2433
- }
2434
- const { focusArea } = await (0, import_prompts.default)({
2435
- type: "select",
2436
- name: "focusArea",
2437
- message: "Which areas to focus?",
2438
- choices: [
2439
- { title: "Frontend (web app)", value: "frontend" },
2440
- { title: "Backend (API/infra)", value: "backend" },
2441
- { title: "Both", value: "both" }
2442
- ],
2443
- initial: 2
2444
- });
2445
- if (focusArea === "frontend") {
2446
- nextOptions.include = ["**/*.{ts,tsx,js,jsx}"];
2447
- nextOptions.exclude = Array.from(
2448
- /* @__PURE__ */ new Set([
2449
- ...nextOptions.exclude || [],
2450
- "**/cdk.out/**",
2451
- "**/infra/**",
2452
- "**/server/**",
2453
- "**/backend/**"
2454
- ])
2455
- );
2456
- } else if (focusArea === "backend") {
2457
- nextOptions.include = [
2458
- "**/api/**",
2459
- "**/server/**",
2460
- "**/backend/**",
2461
- "**/infra/**",
2462
- "**/*.{ts,js,py,java}"
2463
- ];
2464
- }
2465
- console.log(import_chalk2.default.green("\u2713 Interactive configuration applied."));
2466
- return nextOptions;
2467
- }
2468
-
2469
- // src/index.ts
2470
- import_core12.ToolRegistry.register(ContextAnalyzerProvider);
2144
+ import_core10.ToolRegistry.register(CONTEXT_ANALYZER_PROVIDER);
2471
2145
  // Annotate the CommonJS export names for ESM import in node:
2472
2146
  0 && (module.exports = {
2473
- BARREL_EXPORT_MIN_EXPORTS,
2474
- BARREL_EXPORT_TOKEN_LIMIT,
2475
- CONFIG_NAME_PATTERNS,
2476
- Classification,
2477
- ContextAnalyzerProvider,
2478
- EMAIL_NAME_PATTERNS,
2479
- HANDLER_NAME_PATTERNS,
2480
- NEXTJS_METADATA_EXPORTS,
2481
- PARSER_NAME_PATTERNS,
2482
- SERVICE_NAME_PATTERNS,
2483
- SESSION_NAME_PATTERNS,
2147
+ CONTEXT_ANALYZER_PROVIDER,
2484
2148
  adjustCohesionForClassification,
2485
2149
  adjustFragmentationForClassification,
2486
2150
  analyzeContext,
2487
- buildCoUsageMatrix,
2488
2151
  buildDependencyGraph,
2489
- buildTypeGraph,
2490
2152
  calculateCohesion,
2491
2153
  calculateContextBudget,
2492
2154
  calculateContextScore,
2493
2155
  calculateDirectoryDistance,
2494
- calculateDomainConfidence,
2495
2156
  calculateEnhancedCohesion,
2496
2157
  calculateFragmentation,
2497
2158
  calculateImportDepth,
@@ -2500,32 +2161,9 @@ import_core12.ToolRegistry.register(ContextAnalyzerProvider);
2500
2161
  classifyFile,
2501
2162
  detectCircularDependencies,
2502
2163
  detectModuleClusters,
2503
- displayConsoleReport,
2504
- extractDomainKeywordsFromPaths,
2505
- extractExports,
2506
- findConsolidationCandidates,
2507
- findSemanticClusters,
2508
- generateHTMLReport,
2509
2164
  generateSummary,
2510
2165
  getClassificationRecommendations,
2511
- getCoUsageData,
2512
2166
  getGeneralRecommendations,
2513
- getSmartDefaults,
2514
2167
  getTransitiveDependencies,
2515
- inferDomain,
2516
- inferDomainFromSemantics,
2517
- isBarrelExport,
2518
- isBoilerplateBarrel,
2519
- isConfigFile,
2520
- isEmailTemplate,
2521
- isHubAndSpokeFile,
2522
- isLambdaHandler,
2523
- isNextJsPage,
2524
- isParserFile,
2525
- isServiceFile,
2526
- isSessionFile,
2527
- isTypeDefinition,
2528
- isUtilityModule,
2529
- mapScoreToRating,
2530
- runInteractiveSetup
2168
+ mapScoreToRating
2531
2169
  });