@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/metrics.d.ts DELETED
@@ -1,34 +0,0 @@
1
- import type { ExportInfo } from './types';
2
- /**
3
- * Calculate cohesion score (how related are exports in a file)
4
- */
5
- export declare function calculateEnhancedCohesion(exports: ExportInfo[], filePath?: string, options?: {
6
- coUsageMatrix?: Map<string, Map<string, number>>;
7
- weights?: {
8
- importBased?: number;
9
- structural?: number;
10
- domainBased?: number;
11
- };
12
- }): number;
13
- /**
14
- * Calculate structural cohesion for a file based on co-usage patterns.
15
- */
16
- export declare function calculateStructuralCohesionFromCoUsage(file: string, coUsageMatrix?: Map<string, Map<string, number>>): number;
17
- /**
18
- * Calculate fragmentation score (how scattered is a domain)
19
- */
20
- export declare function calculateFragmentation(files: string[], domain: string, options?: {
21
- useLogScale?: boolean;
22
- logBase?: number;
23
- sharedImportRatio?: number;
24
- dependencyCount?: number;
25
- }): number;
26
- /**
27
- * Calculate path entropy for a set of files
28
- */
29
- export declare function calculatePathEntropy(files: string[]): number;
30
- /**
31
- * Calculate directory-distance metric based on common ancestor depth
32
- */
33
- export declare function calculateDirectoryDistance(files: string[]): number;
34
- //# sourceMappingURL=metrics.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,UAAU,EAAE,EACrB,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE;IACR,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,GACA,MAAM,CA4ER;AAED;;GAEG;AACH,wBAAgB,sCAAsC,CACpD,IAAI,EAAE,MAAM,EACZ,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAC/C,MAAM,CAwBR;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE;IACR,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GACA,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAqB5D;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CA0BlE"}
package/dist/metrics.js DELETED
@@ -1,170 +0,0 @@
1
- import { calculateImportSimilarity } from '@aiready/core';
2
- import { isTestFile } from './ast-utils';
3
- /**
4
- * Calculate cohesion score (how related are exports in a file)
5
- */
6
- export function calculateEnhancedCohesion(exports, filePath, options) {
7
- if (exports.length <= 1)
8
- return 1;
9
- // Test files always have perfect cohesion by design
10
- if (filePath && isTestFile(filePath))
11
- return 1;
12
- // 1. Domain-based cohesion using entropy
13
- const domains = exports.map((e) => e.inferredDomain || 'unknown');
14
- const domainCounts = new Map();
15
- for (const d of domains)
16
- domainCounts.set(d, (domainCounts.get(d) || 0) + 1);
17
- // IF ALL DOMAINS MATCH, RETURN 1.0 IMMEDIATELY (Legacy test compatibility)
18
- if (domainCounts.size === 1 && domains[0] !== 'unknown') {
19
- if (!options?.weights)
20
- return 1;
21
- }
22
- const probs = Array.from(domainCounts.values()).map((c) => c / exports.length);
23
- let domainEntropy = 0;
24
- for (const p of probs) {
25
- if (p > 0)
26
- domainEntropy -= p * Math.log2(p);
27
- }
28
- const maxEntropy = Math.log2(Math.max(2, domainCounts.size));
29
- const domainScore = 1 - domainEntropy / maxEntropy;
30
- // 2. Import-based cohesion
31
- let importScoreTotal = 0;
32
- let pairsWithData = 0;
33
- let anyImportData = false;
34
- for (let i = 0; i < exports.length; i++) {
35
- for (let j = i + 1; j < exports.length; j++) {
36
- const exp1Imports = exports[i].imports;
37
- const exp2Imports = exports[j].imports;
38
- if (exp1Imports || exp2Imports) {
39
- anyImportData = true;
40
- const sim = calculateImportSimilarity({ ...exports[i], imports: exp1Imports || [] }, { ...exports[j], imports: exp2Imports || [] });
41
- importScoreTotal += sim;
42
- pairsWithData++;
43
- }
44
- }
45
- }
46
- const avgImportScore = pairsWithData > 0 ? importScoreTotal / pairsWithData : 0;
47
- // Weighted average
48
- let score = anyImportData
49
- ? domainScore * 0.4 + avgImportScore * 0.6
50
- : domainScore;
51
- if (anyImportData && score === 0 && domainScore === 0) {
52
- score = 0.1;
53
- }
54
- // Structural boost
55
- let structuralScore = 0;
56
- for (const exp of exports) {
57
- if (exp.dependencies && exp.dependencies.length > 0) {
58
- structuralScore += 1;
59
- }
60
- }
61
- if (structuralScore > 0) {
62
- score = Math.min(1, score + 0.1);
63
- }
64
- // Legacy fallback if no imports and domain Score was 1.0
65
- if (!options?.weights && !anyImportData && domainCounts.size === 1)
66
- return 1;
67
- return score;
68
- }
69
- /**
70
- * Calculate structural cohesion for a file based on co-usage patterns.
71
- */
72
- export function calculateStructuralCohesionFromCoUsage(file, coUsageMatrix) {
73
- if (!coUsageMatrix)
74
- return 1;
75
- const coUsages = coUsageMatrix.get(file);
76
- if (!coUsages || coUsages.size === 0)
77
- return 1;
78
- let total = 0;
79
- for (const count of coUsages.values())
80
- total += count;
81
- if (total === 0)
82
- return 1;
83
- const probs = [];
84
- for (const count of coUsages.values()) {
85
- if (count > 0)
86
- probs.push(count / total);
87
- }
88
- if (probs.length <= 1)
89
- return 1;
90
- let entropy = 0;
91
- for (const prob of probs) {
92
- entropy -= prob * Math.log2(prob);
93
- }
94
- const maxEntropy = Math.log2(probs.length);
95
- return maxEntropy > 0 ? 1 - entropy / maxEntropy : 1;
96
- }
97
- /**
98
- * Calculate fragmentation score (how scattered is a domain)
99
- */
100
- export function calculateFragmentation(files, domain, options) {
101
- if (files.length <= 1)
102
- return 0;
103
- const directories = new Set(files.map((f) => f.split('/').slice(0, -1).join('/')));
104
- const uniqueDirs = directories.size;
105
- let score = options?.useLogScale
106
- ? uniqueDirs <= 1
107
- ? 0
108
- : Math.log(uniqueDirs) /
109
- Math.log(options.logBase || Math.E) /
110
- (Math.log(files.length) / Math.log(options.logBase || Math.E))
111
- : (uniqueDirs - 1) / (files.length - 1);
112
- // Coupling Discount
113
- if (options?.sharedImportRatio && options.sharedImportRatio > 0.5) {
114
- const discount = (options.sharedImportRatio - 0.5) * 0.4;
115
- score = score * (1 - discount);
116
- }
117
- return score;
118
- }
119
- /**
120
- * Calculate path entropy for a set of files
121
- */
122
- export function calculatePathEntropy(files) {
123
- if (!files || files.length === 0)
124
- return 0;
125
- const dirCounts = new Map();
126
- for (const f of files) {
127
- const dir = f.split('/').slice(0, -1).join('/') || '.';
128
- dirCounts.set(dir, (dirCounts.get(dir) || 0) + 1);
129
- }
130
- const counts = Array.from(dirCounts.values());
131
- if (counts.length <= 1)
132
- return 0;
133
- const total = counts.reduce((s, v) => s + v, 0);
134
- let entropy = 0;
135
- for (const count of counts) {
136
- const prob = count / total;
137
- entropy -= prob * Math.log2(prob);
138
- }
139
- const maxEntropy = Math.log2(counts.length);
140
- return maxEntropy > 0 ? entropy / maxEntropy : 0;
141
- }
142
- /**
143
- * Calculate directory-distance metric based on common ancestor depth
144
- */
145
- export function calculateDirectoryDistance(files) {
146
- if (!files || files.length <= 1)
147
- return 0;
148
- const pathSegments = (p) => p.split('/').filter(Boolean);
149
- const commonAncestorDepth = (a, b) => {
150
- const minLen = Math.min(a.length, b.length);
151
- let i = 0;
152
- while (i < minLen && a[i] === b[i])
153
- i++;
154
- return i;
155
- };
156
- let totalNormalized = 0;
157
- let comparisons = 0;
158
- for (let i = 0; i < files.length; i++) {
159
- for (let j = i + 1; j < files.length; j++) {
160
- const segA = pathSegments(files[i]);
161
- const segB = pathSegments(files[j]);
162
- const shared = commonAncestorDepth(segA, segB);
163
- const maxDepth = Math.max(segA.length, segB.length);
164
- totalNormalized += 1 - (maxDepth > 0 ? shared / maxDepth : 0);
165
- comparisons++;
166
- }
167
- }
168
- return comparisons > 0 ? totalNormalized / comparisons : 0;
169
- }
170
- //# sourceMappingURL=metrics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":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IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YACpC,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAC/C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACpD,eAAe,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC9D,WAAW,EAAE,CAAC;QAChB,CAAC;IACH,CAAC;IAED,OAAO,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC"}
@@ -1,10 +0,0 @@
1
- import {
2
- analyzeContext,
3
- calculateCohesion
4
- } from "./chunk-BCEZGRXI.mjs";
5
- import "./chunk-64U3PNO3.mjs";
6
- import "./chunk-EMYD7NS6.mjs";
7
- export {
8
- analyzeContext,
9
- calculateCohesion
10
- };
@@ -1,10 +0,0 @@
1
- import {
2
- analyzeContext,
3
- calculateCohesion
4
- } from "./chunk-6FQYIG6I.mjs";
5
- import "./chunk-64U3PNO3.mjs";
6
- import "./chunk-EMYD7NS6.mjs";
7
- export {
8
- analyzeContext,
9
- calculateCohesion
10
- };
@@ -1,10 +0,0 @@
1
- import {
2
- analyzeContext,
3
- calculateCohesion
4
- } from "./chunk-M2EGQ36M.mjs";
5
- import "./chunk-64U3PNO3.mjs";
6
- import "./chunk-EMYD7NS6.mjs";
7
- export {
8
- analyzeContext,
9
- calculateCohesion
10
- };
@@ -1,10 +0,0 @@
1
- import {
2
- analyzeContext,
3
- calculateCohesion
4
- } from "./chunk-22ZO4EKZ.mjs";
5
- import "./chunk-64U3PNO3.mjs";
6
- import "./chunk-EMYD7NS6.mjs";
7
- export {
8
- analyzeContext,
9
- calculateCohesion
10
- };
@@ -1,10 +0,0 @@
1
- import {
2
- analyzeContext,
3
- calculateCohesion
4
- } from "./chunk-ILMLGJGI.mjs";
5
- import "./chunk-64U3PNO3.mjs";
6
- import "./chunk-EMYD7NS6.mjs";
7
- export {
8
- analyzeContext,
9
- calculateCohesion
10
- };
@@ -1,10 +0,0 @@
1
- import {
2
- analyzeContext,
3
- calculateCohesion
4
- } from "./chunk-OZE3FVZT.mjs";
5
- import "./chunk-64U3PNO3.mjs";
6
- import "./chunk-4U4LDWGF.mjs";
7
- export {
8
- analyzeContext,
9
- calculateCohesion
10
- };
@@ -1,6 +0,0 @@
1
- import { ToolProvider } from '@aiready/core';
2
- /**
3
- * Context Analyzer Tool Provider
4
- */
5
- export declare const ContextAnalyzerProvider: ToolProvider;
6
- //# sourceMappingURL=provider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,eAAe,CAAC;AAMvB;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,YA8CrC,CAAC"}
package/dist/provider.js DELETED
@@ -1,48 +0,0 @@
1
- import { ToolName, IssueType, SpokeOutputSchema, } from '@aiready/core';
2
- import { analyzeContext } from './analyzer';
3
- import { generateSummary } from './summary';
4
- import { calculateContextScore } from './scoring';
5
- /**
6
- * Context Analyzer Tool Provider
7
- */
8
- export const ContextAnalyzerProvider = {
9
- id: ToolName.ContextAnalyzer,
10
- alias: ['context', 'fragmentation', 'budget'],
11
- async analyze(options) {
12
- const results = await analyzeContext(options);
13
- const summary = generateSummary(results, options);
14
- // Normalize to SpokeOutput format
15
- const normalizedResults = results.map((r) => ({
16
- fileName: r.file,
17
- issues: r.issues.map((msg) => ({
18
- type: IssueType.ContextFragmentation,
19
- severity: r.severity,
20
- message: msg,
21
- location: { file: r.file, line: 1 },
22
- suggestion: r.recommendations[0],
23
- })),
24
- metrics: {
25
- tokenCost: r.tokenCost,
26
- complexityScore: r.importDepth,
27
- // Map other context-specific metrics if needed
28
- },
29
- }));
30
- return SpokeOutputSchema.parse({
31
- results: normalizedResults,
32
- summary: {
33
- ...summary,
34
- },
35
- metadata: {
36
- toolName: ToolName.ContextAnalyzer,
37
- version: '0.17.5',
38
- timestamp: new Date().toISOString(),
39
- },
40
- });
41
- },
42
- score(output, options) {
43
- const summary = output.summary;
44
- return calculateContextScore(summary, options.costConfig);
45
- },
46
- defaultWeight: 19,
47
- };
48
- //# sourceMappingURL=provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAMR,SAAS,EACT,iBAAiB,GAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAGlD;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAiB;IACnD,EAAE,EAAE,QAAQ,CAAC,eAAe;IAC5B,KAAK,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE,QAAQ,CAAC;IAE7C,KAAK,CAAC,OAAO,CAAC,OAAoB;QAChC,MAAM,OAAO,GAAG,MAAM,cAAc,CAAC,OAAiC,CAAC,CAAC;QACxE,MAA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CyclesFromFile
4
- } from "./chunk-64U3PNO3.mjs";
5
-
6
- // src/analyzers/python-context.ts
7
- import { getParser, estimateTokens } from "@aiready/core";
8
- import { resolve, relative, dirname, join } from "path";
9
- import fs from "fs";
10
- async function analyzePythonContext(files, rootDir) {
11
- const results = [];
12
- const parser = getParser("dummy.py");
13
- if (!parser) {
14
- console.warn("Python parser not available");
15
- return results;
16
- }
17
- const pythonFiles = files.filter((f) => f.toLowerCase().endsWith(".py"));
18
- void relative;
19
- void join;
20
- const dependencyGraph = await buildPythonDependencyGraph(
21
- pythonFiles,
22
- rootDir
23
- );
24
- for (const file of pythonFiles) {
25
- try {
26
- const code = await fs.promises.readFile(file, "utf-8");
27
- const result = parser.parse(code, file);
28
- const imports = result.imports.map((imp) => ({
29
- source: imp.source,
30
- specifiers: imp.specifiers,
31
- isRelative: imp.source.startsWith("."),
32
- resolvedPath: resolvePythonImport(file, imp.source, rootDir)
33
- }));
34
- const exports = result.exports.map((exp) => ({
35
- name: exp.name,
36
- type: exp.type
37
- }));
38
- const linesOfCode = code.split("\n").length;
39
- const importDepth = calculateImportDepthFromEdges(
40
- file,
41
- dependencyGraph,
42
- /* @__PURE__ */ new Set()
43
- );
44
- const contextBudget = estimateContextBudget(
45
- code,
46
- imports,
47
- dependencyGraph
48
- );
49
- const cohesion = calculatePythonCohesion(exports, imports);
50
- const circularDependencies = detectGraphCyclesFromFile(
51
- file,
52
- dependencyGraph
53
- ).map((cycle) => cycle.join(" -> "));
54
- results.push({
55
- file,
56
- importDepth,
57
- contextBudget,
58
- cohesion,
59
- imports,
60
- exports,
61
- metrics: {
62
- linesOfCode,
63
- importCount: imports.length,
64
- exportCount: exports.length,
65
- circularDependencies
66
- }
67
- });
68
- } catch (error) {
69
- console.warn(`Failed to analyze ${file}:`, error);
70
- }
71
- }
72
- return results;
73
- }
74
- async function buildPythonDependencyGraph(files, rootDir) {
75
- const graph = /* @__PURE__ */ new Map();
76
- const parser = getParser("dummy.py");
77
- if (!parser) return graph;
78
- for (const file of files) {
79
- try {
80
- const code = await fs.promises.readFile(file, "utf-8");
81
- const result = parser.parse(code, file);
82
- const dependencies = /* @__PURE__ */ new Set();
83
- for (const imp of result.imports) {
84
- const resolved = resolvePythonImport(file, imp.source, rootDir);
85
- if (resolved && files.includes(resolved)) {
86
- dependencies.add(resolved);
87
- }
88
- }
89
- graph.set(file, dependencies);
90
- } catch (error) {
91
- void error;
92
- }
93
- }
94
- return graph;
95
- }
96
- function resolvePythonImport(fromFile, importPath, rootDir) {
97
- const dir = dirname(fromFile);
98
- if (importPath.startsWith(".")) {
99
- const parts = importPath.split(".");
100
- let upCount = 0;
101
- while (parts[0] === "") {
102
- upCount++;
103
- parts.shift();
104
- }
105
- let targetDir = dir;
106
- for (let i = 0; i < upCount - 1; i++) {
107
- targetDir = dirname(targetDir);
108
- }
109
- const modulePath = parts.join("/");
110
- const possiblePaths = [
111
- resolve(targetDir, `${modulePath}.py`),
112
- resolve(targetDir, modulePath, "__init__.py")
113
- ];
114
- for (const path of possiblePaths) {
115
- if (fs.existsSync(path)) {
116
- return path;
117
- }
118
- }
119
- } else {
120
- const modulePath = importPath.replace(/\./g, "/");
121
- const possiblePaths = [
122
- resolve(rootDir, `${modulePath}.py`),
123
- resolve(rootDir, modulePath, "__init__.py")
124
- ];
125
- for (const path of possiblePaths) {
126
- if (fs.existsSync(path)) {
127
- return path;
128
- }
129
- }
130
- }
131
- return void 0;
132
- }
133
- function estimateContextBudget(code, imports, dependencyGraph) {
134
- void dependencyGraph;
135
- let budget = estimateTokens(code);
136
- const avgTokensPerDep = 500;
137
- budget += imports.length * avgTokensPerDep;
138
- return budget;
139
- }
140
- function calculatePythonCohesion(exports, imports) {
141
- if (exports.length === 0) return 1;
142
- const exportCount = exports.length;
143
- const importCount = imports.length;
144
- let cohesion = 1;
145
- if (exportCount > 10) {
146
- cohesion *= 0.6;
147
- } else if (exportCount > 5) {
148
- cohesion *= 0.8;
149
- }
150
- if (exportCount > 0) {
151
- const ratio = importCount / exportCount;
152
- if (ratio > 2) {
153
- cohesion *= 1.1;
154
- } else if (ratio < 0.5) {
155
- cohesion *= 0.9;
156
- }
157
- }
158
- return Math.min(1, Math.max(0, cohesion));
159
- }
160
- export {
161
- analyzePythonContext
162
- };