@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.mjs CHANGED
@@ -1,58 +1,22 @@
1
1
  import {
2
- displayConsoleReport,
3
- generateHTMLReport,
4
- runInteractiveSetup
5
- } from "./chunk-J3SZQZNU.mjs";
6
- import {
7
- BARREL_EXPORT_MIN_EXPORTS,
8
- BARREL_EXPORT_TOKEN_LIMIT,
9
- CONFIG_NAME_PATTERNS,
10
- Classification,
11
- EMAIL_NAME_PATTERNS,
12
- HANDLER_NAME_PATTERNS,
13
- NEXTJS_METADATA_EXPORTS,
14
- PARSER_NAME_PATTERNS,
15
- SERVICE_NAME_PATTERNS,
16
- SESSION_NAME_PATTERNS,
17
2
  adjustCohesionForClassification,
18
3
  adjustFragmentationForClassification,
19
4
  analyzeContext,
20
- buildCoUsageMatrix,
21
5
  buildDependencyGraph,
22
- buildTypeGraph,
23
6
  calculateCohesion,
24
7
  calculateContextBudget,
25
- calculateDomainConfidence,
26
8
  calculateImportDepth,
27
9
  classifyFile,
28
10
  detectCircularDependencies,
29
11
  detectModuleClusters,
30
- extractDomainKeywordsFromPaths,
31
- extractExports,
32
- findSemanticClusters,
33
12
  getClassificationRecommendations,
34
- getCoUsageData,
35
13
  getGeneralRecommendations,
36
- getTransitiveDependencies,
37
- inferDomain,
38
- inferDomainFromSemantics,
39
- isBarrelExport,
40
- isBoilerplateBarrel,
41
- isConfigFile,
42
- isEmailTemplate,
43
- isHubAndSpokeFile,
44
- isLambdaHandler,
45
- isNextJsPage,
46
- isParserFile,
47
- isServiceFile,
48
- isSessionFile,
49
- isTypeDefinition,
50
- isUtilityModule
51
- } from "./chunk-ZA7HRDAH.mjs";
14
+ getTransitiveDependencies
15
+ } from "./chunk-ISWPFG2C.mjs";
52
16
  import "./chunk-64U3PNO3.mjs";
53
17
  import {
54
18
  generateSummary
55
- } from "./chunk-BTDF2ZA4.mjs";
19
+ } from "./chunk-HD4Y3GYL.mjs";
56
20
  import {
57
21
  calculateDirectoryDistance,
58
22
  calculateEnhancedCohesion,
@@ -262,12 +226,12 @@ function mapScoreToRating(score) {
262
226
  }
263
227
 
264
228
  // src/provider.ts
265
- var ContextAnalyzerProvider = {
229
+ var CONTEXT_ANALYZER_PROVIDER = {
266
230
  id: ToolName2.ContextAnalyzer,
267
231
  alias: ["context", "fragmentation", "budget"],
268
232
  async analyze(options) {
269
- const { analyzeContext: analyzeContext2 } = await import("./orchestrator-62YVSQFV.mjs");
270
- const { generateSummary: generateSummary2 } = await import("./summary-RSPRRY6S.mjs");
233
+ const { analyzeContext: analyzeContext2 } = await import("./orchestrator-QNE2E4TE.mjs");
234
+ const { generateSummary: generateSummary2 } = await import("./summary-TZFB6ZFM.mjs");
271
235
  const results = await analyzeContext2(options);
272
236
  const summary = generateSummary2(results, options);
273
237
  const normalizedResults = results.map(
@@ -305,107 +269,18 @@ var ContextAnalyzerProvider = {
305
269
  defaultWeight: 19
306
270
  };
307
271
 
308
- // src/defaults.ts
309
- import { scanFiles } from "@aiready/core";
310
- async function getSmartDefaults(directory, userOptions) {
311
- const files = await scanFiles({
312
- rootDir: directory,
313
- include: userOptions.include,
314
- exclude: userOptions.exclude
315
- });
316
- const estimatedBlocks = files.length;
317
- let maxDepth;
318
- let maxContextBudget;
319
- let minCohesion;
320
- let maxFragmentation;
321
- if (estimatedBlocks < 100) {
322
- maxDepth = 5;
323
- maxContextBudget = 8e3;
324
- minCohesion = 0.5;
325
- maxFragmentation = 0.5;
326
- } else if (estimatedBlocks < 500) {
327
- maxDepth = 6;
328
- maxContextBudget = 15e3;
329
- minCohesion = 0.45;
330
- maxFragmentation = 0.6;
331
- } else if (estimatedBlocks < 2e3) {
332
- maxDepth = 8;
333
- maxContextBudget = 25e3;
334
- minCohesion = 0.4;
335
- maxFragmentation = 0.7;
336
- } else {
337
- maxDepth = 12;
338
- maxContextBudget = 4e4;
339
- minCohesion = 0.35;
340
- maxFragmentation = 0.8;
341
- }
342
- return {
343
- maxDepth,
344
- maxContextBudget,
345
- minCohesion,
346
- maxFragmentation,
347
- focus: "all",
348
- includeNodeModules: false,
349
- rootDir: userOptions.rootDir || directory,
350
- include: userOptions.include,
351
- exclude: userOptions.exclude
352
- };
353
- }
354
-
355
- // src/semantic/consolidation.ts
356
- function findConsolidationCandidates(graph, coUsageMatrix, typeGraph, minCoUsage = 5, minSharedTypes = 2) {
357
- const candidates = [];
358
- for (const [fileA, coUsages] of coUsageMatrix) {
359
- const nodeA = graph.nodes.get(fileA);
360
- if (!nodeA) continue;
361
- for (const [fileB, count] of coUsages) {
362
- if (fileB <= fileA || count < minCoUsage) continue;
363
- const nodeB = graph.nodes.get(fileB);
364
- if (!nodeB) continue;
365
- const typesA = new Set(
366
- nodeA.exports.flatMap((e) => e.typeReferences || [])
367
- );
368
- const typesB = new Set(
369
- nodeB.exports.flatMap((e) => e.typeReferences || [])
370
- );
371
- const sharedTypes = Array.from(typesA).filter((t) => typesB.has(t));
372
- if (sharedTypes.length >= minSharedTypes || count >= minCoUsage * 2) {
373
- candidates.push({
374
- files: [fileA, fileB],
375
- reason: `High co-usage (${count}x)`,
376
- strength: count / 10
377
- });
378
- }
379
- }
380
- }
381
- return candidates.sort((a, b) => b.strength - a.strength);
382
- }
383
-
384
272
  // src/index.ts
385
- ToolRegistry.register(ContextAnalyzerProvider);
273
+ ToolRegistry.register(CONTEXT_ANALYZER_PROVIDER);
386
274
  export {
387
- BARREL_EXPORT_MIN_EXPORTS,
388
- BARREL_EXPORT_TOKEN_LIMIT,
389
- CONFIG_NAME_PATTERNS,
390
- Classification,
391
- ContextAnalyzerProvider,
392
- EMAIL_NAME_PATTERNS,
393
- HANDLER_NAME_PATTERNS,
394
- NEXTJS_METADATA_EXPORTS,
395
- PARSER_NAME_PATTERNS,
396
- SERVICE_NAME_PATTERNS,
397
- SESSION_NAME_PATTERNS,
275
+ CONTEXT_ANALYZER_PROVIDER,
398
276
  adjustCohesionForClassification,
399
277
  adjustFragmentationForClassification,
400
278
  analyzeContext,
401
- buildCoUsageMatrix,
402
279
  buildDependencyGraph,
403
- buildTypeGraph,
404
280
  calculateCohesion,
405
281
  calculateContextBudget,
406
282
  calculateContextScore,
407
283
  calculateDirectoryDistance,
408
- calculateDomainConfidence,
409
284
  calculateEnhancedCohesion,
410
285
  calculateFragmentation,
411
286
  calculateImportDepth,
@@ -414,32 +289,9 @@ export {
414
289
  classifyFile,
415
290
  detectCircularDependencies,
416
291
  detectModuleClusters,
417
- displayConsoleReport,
418
- extractDomainKeywordsFromPaths,
419
- extractExports,
420
- findConsolidationCandidates,
421
- findSemanticClusters,
422
- generateHTMLReport,
423
292
  generateSummary,
424
293
  getClassificationRecommendations,
425
- getCoUsageData,
426
294
  getGeneralRecommendations,
427
- getSmartDefaults,
428
295
  getTransitiveDependencies,
429
- inferDomain,
430
- inferDomainFromSemantics,
431
- isBarrelExport,
432
- isBoilerplateBarrel,
433
- isConfigFile,
434
- isEmailTemplate,
435
- isHubAndSpokeFile,
436
- isLambdaHandler,
437
- isNextJsPage,
438
- isParserFile,
439
- isServiceFile,
440
- isSessionFile,
441
- isTypeDefinition,
442
- isUtilityModule,
443
- mapScoreToRating,
444
- runInteractiveSetup
296
+ mapScoreToRating
445
297
  };
@@ -0,0 +1,75 @@
1
+ // src/report/interactive-setup.ts
2
+ import chalk from "chalk";
3
+ import { existsSync, readFileSync } from "fs";
4
+ import { join } from "path";
5
+ import prompts from "prompts";
6
+ async function runInteractiveSetup(directory, current) {
7
+ console.log(chalk.yellow("\u{1F9ED} Interactive mode: let's tailor the analysis."));
8
+ const pkgPath = join(directory, "package.json");
9
+ let deps = {};
10
+ if (existsSync(pkgPath)) {
11
+ try {
12
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
13
+ deps = { ...pkg.dependencies || {}, ...pkg.devDependencies || {} };
14
+ } catch (e) {
15
+ void e;
16
+ }
17
+ }
18
+ const hasNextJs = existsSync(join(directory, ".next")) || !!deps["next"];
19
+ const hasCDK = existsSync(join(directory, "cdk.out")) || !!deps["aws-cdk-lib"] || Object.keys(deps).some((d) => d.startsWith("@aws-cdk/"));
20
+ const recommendedExcludes = new Set(current.exclude || []);
21
+ if (hasNextJs && !Array.from(recommendedExcludes).some((p) => p.includes(".next"))) {
22
+ recommendedExcludes.add("**/.next/**");
23
+ }
24
+ if (hasCDK && !Array.from(recommendedExcludes).some((p) => p.includes("cdk.out"))) {
25
+ recommendedExcludes.add("**/cdk.out/**");
26
+ }
27
+ const { applyExcludes } = await prompts({
28
+ type: "toggle",
29
+ name: "applyExcludes",
30
+ message: `Detected ${hasNextJs ? "Next.js " : ""}${hasCDK ? "AWS CDK " : ""}frameworks. Apply recommended excludes?`,
31
+ initial: true,
32
+ active: "yes",
33
+ inactive: "no"
34
+ });
35
+ const nextOptions = { ...current };
36
+ if (applyExcludes) {
37
+ nextOptions.exclude = Array.from(recommendedExcludes);
38
+ }
39
+ const { focusArea } = await prompts({
40
+ type: "select",
41
+ name: "focusArea",
42
+ message: "Which areas to focus?",
43
+ choices: [
44
+ { title: "Frontend (web app)", value: "frontend" },
45
+ { title: "Backend (API/infra)", value: "backend" },
46
+ { title: "Both", value: "both" }
47
+ ],
48
+ initial: 2
49
+ });
50
+ if (focusArea === "frontend") {
51
+ nextOptions.include = ["**/*.{ts,tsx,js,jsx}"];
52
+ nextOptions.exclude = Array.from(
53
+ /* @__PURE__ */ new Set([
54
+ ...nextOptions.exclude || [],
55
+ "**/cdk.out/**",
56
+ "**/infra/**",
57
+ "**/server/**",
58
+ "**/backend/**"
59
+ ])
60
+ );
61
+ } else if (focusArea === "backend") {
62
+ nextOptions.include = [
63
+ "**/api/**",
64
+ "**/server/**",
65
+ "**/backend/**",
66
+ "**/infra/**",
67
+ "**/*.{ts,js,py,java}"
68
+ ];
69
+ }
70
+ console.log(chalk.green("\u2713 Interactive configuration applied."));
71
+ return nextOptions;
72
+ }
73
+ export {
74
+ runInteractiveSetup
75
+ };
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  analyzeContext,
3
3
  calculateCohesion
4
- } from "./chunk-P74BO725.mjs";
4
+ } from "./chunk-ISWPFG2C.mjs";
5
5
  import "./chunk-64U3PNO3.mjs";
6
- import "./chunk-EMYD7NS6.mjs";
6
+ import "./chunk-JSM7Q5CY.mjs";
7
7
  export {
8
8
  analyzeContext,
9
9
  calculateCohesion
@@ -0,0 +1,7 @@
1
+ import {
2
+ generateSummary
3
+ } from "./chunk-T733LS62.mjs";
4
+ import "./chunk-JSM7Q5CY.mjs";
5
+ export {
6
+ generateSummary
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ generateSummary
3
+ } from "./chunk-QW6ULRML.mjs";
4
+ import "./chunk-JSM7Q5CY.mjs";
5
+ export {
6
+ generateSummary
7
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ generateSummary
3
+ } from "./chunk-HD4Y3GYL.mjs";
4
+ import "./chunk-JSM7Q5CY.mjs";
5
+ export {
6
+ generateSummary
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/context-analyzer",
3
- "version": "0.22.8",
3
+ "version": "0.22.11",
4
4
  "description": "AI context window cost analysis - detect fragmented code, deep import chains, and expensive context budgets",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -49,7 +49,7 @@
49
49
  "commander": "^14.0.0",
50
50
  "chalk": "^5.3.0",
51
51
  "prompts": "^2.4.2",
52
- "@aiready/core": "0.24.8"
52
+ "@aiready/core": "0.24.12"
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/node": "^24.0.0",
@@ -0,0 +1,57 @@
1
+ import type { DependencyNode } from '../types';
2
+
3
+ export const createNode = (
4
+ overrides: Partial<DependencyNode>
5
+ ): DependencyNode => ({
6
+ file: 'test.ts',
7
+ imports: [],
8
+ exports: [],
9
+ tokenCost: 100,
10
+ linesOfCode: 50,
11
+ ...overrides,
12
+ });
13
+
14
+ export const BARREL_EXPORT_NODE = createNode({
15
+ file: 'src/index.ts',
16
+ imports: ['../module1', '../module2', '../module3'],
17
+ exports: [
18
+ { name: 'func1', type: 'function', inferredDomain: 'module1' },
19
+ { name: 'func2', type: 'function', inferredDomain: 'module2' },
20
+ { name: 'func3', type: 'function', inferredDomain: 'module3' },
21
+ ],
22
+ linesOfCode: 20,
23
+ });
24
+
25
+ export const TYPE_DEFINITION_NODE = createNode({
26
+ file: 'src/types.ts',
27
+ exports: [
28
+ { name: 'User', type: 'interface', inferredDomain: 'user' },
29
+ { name: 'Order', type: 'interface', inferredDomain: 'order' },
30
+ { name: 'Product', type: 'type', inferredDomain: 'product' },
31
+ { name: 'Status', type: 'type', inferredDomain: 'unknown' },
32
+ ],
33
+ linesOfCode: 100,
34
+ });
35
+
36
+ export const COHESIVE_MODULE_NODE = createNode({
37
+ file: 'src/calculator.ts',
38
+ exports: [
39
+ { name: 'calculate', type: 'function', inferredDomain: 'calc' },
40
+ { name: 'format', type: 'function', inferredDomain: 'calc' },
41
+ { name: 'validate', type: 'function', inferredDomain: 'calc' },
42
+ ],
43
+ imports: ['../utils'],
44
+ linesOfCode: 300,
45
+ });
46
+
47
+ export const MIXED_CONCERNS_NODE = createNode({
48
+ file: 'src/audit.ts',
49
+ exports: [
50
+ { name: 'auditStatus', type: 'function', inferredDomain: 'audit' },
51
+ { name: 'createJob', type: 'function', inferredDomain: 'job' },
52
+ { name: 'LineItem', type: 'interface', inferredDomain: 'order' },
53
+ { name: 'SupportingDoc', type: 'type', inferredDomain: 'doc' },
54
+ ],
55
+ imports: ['../auth', '../job', '../order'],
56
+ linesOfCode: 384,
57
+ });