@aiready/context-analyzer 0.22.9 → 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.
- package/.turbo/turbo-build.log +33 -32
- package/.turbo/turbo-format-check.log +1 -1
- package/.turbo/turbo-lint.log +8 -0
- package/dist/chunk-HD4Y3GYL.mjs +124 -0
- package/dist/{chunk-M2EGQ36M.mjs → chunk-ISWPFG2C.mjs} +43 -98
- package/dist/{chunk-BQCISA2F.mjs → chunk-QW6ULRML.mjs} +32 -6
- package/dist/{chunk-WHB7QI7N.mjs → chunk-T733LS62.mjs} +23 -4
- package/dist/{cli-action-CXIHOVAC.mjs → cli-action-FV4G4OB6.mjs} +3 -3
- package/dist/{cli-action-3CWN7PBE.mjs → cli-action-HYSWE7F4.mjs} +3 -3
- package/dist/{cli-action-MLFCIW2O.mjs → cli-action-VIQZSWSP.mjs} +3 -3
- package/dist/{cli-action-E7UGP4KE.mjs → cli-action-W7TESWAV.mjs} +6 -8
- package/dist/cli.js +236 -191
- package/dist/cli.mjs +1 -1
- package/dist/console-report-AP4JYNQY.mjs +74 -0
- package/dist/html-report-ULELSIYG.mjs +73 -0
- package/dist/index.d.mts +69 -337
- package/dist/index.d.ts +69 -337
- package/dist/index.js +90 -452
- package/dist/index.mjs +9 -157
- package/dist/interactive-setup-JGFBFI3M.mjs +75 -0
- package/dist/{orchestrator-3ERQS3NW.mjs → orchestrator-QNE2E4TE.mjs} +2 -2
- package/dist/summary-GQRWW3A2.mjs +7 -0
- package/dist/summary-JTBS7CPM.mjs +7 -0
- package/dist/summary-TZFB6ZFM.mjs +7 -0
- package/package.json +2 -2
- package/src/__tests__/file-classification.fixtures.ts +57 -0
- package/src/__tests__/file-classification.test.ts +24 -929
- package/src/__tests__/provider.test.ts +6 -72
- package/src/classifier.ts +42 -42
- package/src/cli-action.ts +11 -6
- package/src/index.ts +30 -27
- package/src/provider.ts +1 -1
- package/src/summary.ts +65 -10
- package/dist/__tests__/analyzer.test.d.ts +0 -2
- package/dist/__tests__/analyzer.test.d.ts.map +0 -1
- package/dist/__tests__/analyzer.test.js +0 -198
- package/dist/__tests__/analyzer.test.js.map +0 -1
- package/dist/__tests__/auto-detection.test.d.ts +0 -2
- package/dist/__tests__/auto-detection.test.d.ts.map +0 -1
- package/dist/__tests__/auto-detection.test.js +0 -132
- package/dist/__tests__/auto-detection.test.js.map +0 -1
- package/dist/__tests__/cluster-detector.test.d.ts +0 -2
- package/dist/__tests__/cluster-detector.test.d.ts.map +0 -1
- package/dist/__tests__/cluster-detector.test.js +0 -121
- package/dist/__tests__/cluster-detector.test.js.map +0 -1
- package/dist/__tests__/contract.test.d.ts +0 -2
- package/dist/__tests__/contract.test.d.ts.map +0 -1
- package/dist/__tests__/contract.test.js +0 -59
- package/dist/__tests__/contract.test.js.map +0 -1
- package/dist/__tests__/enhanced-cohesion.test.d.ts +0 -2
- package/dist/__tests__/enhanced-cohesion.test.d.ts.map +0 -1
- package/dist/__tests__/enhanced-cohesion.test.js +0 -119
- package/dist/__tests__/enhanced-cohesion.test.js.map +0 -1
- package/dist/__tests__/file-classification.test.d.ts +0 -2
- package/dist/__tests__/file-classification.test.d.ts.map +0 -1
- package/dist/__tests__/file-classification.test.js +0 -749
- package/dist/__tests__/file-classification.test.js.map +0 -1
- package/dist/__tests__/fragmentation-advanced.test.d.ts +0 -2
- package/dist/__tests__/fragmentation-advanced.test.d.ts.map +0 -1
- package/dist/__tests__/fragmentation-advanced.test.js +0 -44
- package/dist/__tests__/fragmentation-advanced.test.js.map +0 -1
- package/dist/__tests__/fragmentation-coupling.test.d.ts +0 -2
- package/dist/__tests__/fragmentation-coupling.test.d.ts.map +0 -1
- package/dist/__tests__/fragmentation-coupling.test.js +0 -52
- package/dist/__tests__/fragmentation-coupling.test.js.map +0 -1
- package/dist/__tests__/fragmentation-log.test.d.ts +0 -2
- package/dist/__tests__/fragmentation-log.test.d.ts.map +0 -1
- package/dist/__tests__/fragmentation-log.test.js +0 -29
- package/dist/__tests__/fragmentation-log.test.js.map +0 -1
- package/dist/__tests__/provider.test.d.ts +0 -2
- package/dist/__tests__/provider.test.d.ts.map +0 -1
- package/dist/__tests__/provider.test.js +0 -72
- package/dist/__tests__/provider.test.js.map +0 -1
- package/dist/__tests__/remediation.test.d.ts +0 -2
- package/dist/__tests__/remediation.test.d.ts.map +0 -1
- package/dist/__tests__/remediation.test.js +0 -61
- package/dist/__tests__/remediation.test.js.map +0 -1
- package/dist/__tests__/scoring.test.d.ts +0 -2
- package/dist/__tests__/scoring.test.d.ts.map +0 -1
- package/dist/__tests__/scoring.test.js +0 -298
- package/dist/__tests__/scoring.test.js.map +0 -1
- package/dist/__tests__/structural-cohesion.test.d.ts +0 -2
- package/dist/__tests__/structural-cohesion.test.d.ts.map +0 -1
- package/dist/__tests__/structural-cohesion.test.js +0 -35
- package/dist/__tests__/structural-cohesion.test.js.map +0 -1
- package/dist/analyzer.d.ts +0 -37
- package/dist/analyzer.d.ts.map +0 -1
- package/dist/analyzer.js +0 -283
- package/dist/analyzer.js.map +0 -1
- package/dist/analyzers/python-context.d.ts +0 -38
- package/dist/analyzers/python-context.d.ts.map +0 -1
- package/dist/analyzers/python-context.js +0 -234
- package/dist/analyzers/python-context.js.map +0 -1
- package/dist/ast-utils.d.ts +0 -16
- package/dist/ast-utils.d.ts.map +0 -1
- package/dist/ast-utils.js +0 -81
- package/dist/ast-utils.js.map +0 -1
- package/dist/chunk-22ZO4EKZ.mjs +0 -1297
- package/dist/chunk-2HE27YEV.mjs +0 -1739
- package/dist/chunk-45P4RDYP.mjs +0 -607
- package/dist/chunk-474DEGWW.mjs +0 -1792
- package/dist/chunk-4SYIJ7CU.mjs +0 -1538
- package/dist/chunk-4U4LDWGF.mjs +0 -360
- package/dist/chunk-4XQVYYPC.mjs +0 -1470
- package/dist/chunk-5CLU3HYU.mjs +0 -1475
- package/dist/chunk-5K73Q3OQ.mjs +0 -1520
- package/dist/chunk-5N5DCJOV.mjs +0 -583
- package/dist/chunk-6AVS4KTM.mjs +0 -1536
- package/dist/chunk-6FQYIG6I.mjs +0 -1298
- package/dist/chunk-6I4552YB.mjs +0 -1467
- package/dist/chunk-6LPITDKG.mjs +0 -1539
- package/dist/chunk-72QC5QUS.mjs +0 -549
- package/dist/chunk-736QSHJP.mjs +0 -1807
- package/dist/chunk-7LUSCLGR.mjs +0 -2058
- package/dist/chunk-7VK3XTSH.mjs +0 -1756
- package/dist/chunk-7ZEJGWLN.mjs +0 -1363
- package/dist/chunk-AECWO7NQ.mjs +0 -1539
- package/dist/chunk-AEK3MZC5.mjs +0 -709
- package/dist/chunk-AJC3FR6G.mjs +0 -1509
- package/dist/chunk-AMPK6SWS.mjs +0 -1754
- package/dist/chunk-BA7QGUHN.mjs +0 -1722
- package/dist/chunk-BCEZGRXI.mjs +0 -1297
- package/dist/chunk-BD4NWUVG.mjs +0 -1242
- package/dist/chunk-BEZPBI5C.mjs +0 -1829
- package/dist/chunk-BHCRDEE4.mjs +0 -1745
- package/dist/chunk-BW463GQB.mjs +0 -1767
- package/dist/chunk-CAX2MOUZ.mjs +0 -1801
- package/dist/chunk-CBWM3EK5.mjs +0 -1854
- package/dist/chunk-CCBNKQYB.mjs +0 -1812
- package/dist/chunk-CDIVYADN.mjs +0 -2110
- package/dist/chunk-CVGIDSMN.mjs +0 -1522
- package/dist/chunk-D25B5LZR.mjs +0 -1739
- package/dist/chunk-D3SIHB2V.mjs +0 -2118
- package/dist/chunk-DD7UVNE3.mjs +0 -678
- package/dist/chunk-DMRZMS2U.mjs +0 -964
- package/dist/chunk-DXG5NIYL.mjs +0 -1527
- package/dist/chunk-EBXG2Q5Y.mjs +0 -2059
- package/dist/chunk-EH3PMNZQ.mjs +0 -569
- package/dist/chunk-EMYD7NS6.mjs +0 -137
- package/dist/chunk-EVX2W2BK.mjs +0 -1896
- package/dist/chunk-EWFR366Y.mjs +0 -1740
- package/dist/chunk-EX7HCWAO.mjs +0 -625
- package/dist/chunk-FNPSK3CG.mjs +0 -1760
- package/dist/chunk-FO6YT6RG.mjs +0 -1751
- package/dist/chunk-FYI56A5M.mjs +0 -1892
- package/dist/chunk-G3CCJCBI.mjs +0 -1521
- package/dist/chunk-G7PO3DNK.mjs +0 -1072
- package/dist/chunk-GFADGYXZ.mjs +0 -1752
- package/dist/chunk-GTRIBVS6.mjs +0 -1467
- package/dist/chunk-GXTGOLZT.mjs +0 -92
- package/dist/chunk-H4HWBQU6.mjs +0 -1530
- package/dist/chunk-HDFXSEFW.mjs +0 -605
- package/dist/chunk-HOUDVRG2.mjs +0 -1422
- package/dist/chunk-HQNHM2X7.mjs +0 -997
- package/dist/chunk-I54HL4FZ.mjs +0 -781
- package/dist/chunk-I77HFFZU.mjs +0 -1876
- package/dist/chunk-IKRP7ECY.mjs +0 -1754
- package/dist/chunk-ILMLGJGI.mjs +0 -1295
- package/dist/chunk-IPIE5TXJ.mjs +0 -1741
- package/dist/chunk-IRWCPDWD.mjs +0 -779
- package/dist/chunk-J3MUOWHC.mjs +0 -1747
- package/dist/chunk-J5TA3AZU.mjs +0 -1795
- package/dist/chunk-JH535NPP.mjs +0 -1619
- package/dist/chunk-JUHHOSHG.mjs +0 -1808
- package/dist/chunk-JZ2SE4DB.mjs +0 -1116
- package/dist/chunk-K2WFOBAZ.mjs +0 -1821
- package/dist/chunk-K6U64EL3.mjs +0 -517
- package/dist/chunk-KDUUZQBK.mjs +0 -1692
- package/dist/chunk-KGFWKSGJ.mjs +0 -1442
- package/dist/chunk-KGVMS4R5.mjs +0 -1750
- package/dist/chunk-KWIS5FQP.mjs +0 -1739
- package/dist/chunk-KYSZF5N6.mjs +0 -1876
- package/dist/chunk-LERPI33Y.mjs +0 -2060
- package/dist/chunk-M64RHH4D.mjs +0 -1896
- package/dist/chunk-MBE4AQP5.mjs +0 -1362
- package/dist/chunk-MR7WXHIE.mjs +0 -1833
- package/dist/chunk-MZP3G7TF.mjs +0 -2118
- package/dist/chunk-N2GQWNFG.mjs +0 -1527
- package/dist/chunk-N6XBOOVA.mjs +0 -564
- package/dist/chunk-NJUW6VED.mjs +0 -610
- package/dist/chunk-NOHK5DLU.mjs +0 -2173
- package/dist/chunk-NQA3F2HJ.mjs +0 -1532
- package/dist/chunk-NXXQ2U73.mjs +0 -1467
- package/dist/chunk-OP4G6GLN.mjs +0 -1876
- package/dist/chunk-ORLC5Y4J.mjs +0 -1787
- package/dist/chunk-OTCQL7DY.mjs +0 -2045
- package/dist/chunk-OUYSZZ7X.mjs +0 -1846
- package/dist/chunk-OZE3FVZT.mjs +0 -1089
- package/dist/chunk-P3T3H27S.mjs +0 -1895
- package/dist/chunk-P5YV5WIX.mjs +0 -1803
- package/dist/chunk-P74BO725.mjs +0 -1296
- package/dist/chunk-PDN74MG3.mjs +0 -1834
- package/dist/chunk-PJD4VCIH.mjs +0 -1722
- package/dist/chunk-PVVCCE6W.mjs +0 -755
- package/dist/chunk-PVVMK56C.mjs +0 -1793
- package/dist/chunk-Q2GDZ2FZ.mjs +0 -1794
- package/dist/chunk-QDGPR3L6.mjs +0 -1518
- package/dist/chunk-RQCIJO5Z.mjs +0 -1116
- package/dist/chunk-RRB2C34Q.mjs +0 -1738
- package/dist/chunk-RYIB5CWD.mjs +0 -781
- package/dist/chunk-S6OPP4L5.mjs +0 -1791
- package/dist/chunk-SAVOSPM3.mjs +0 -1522
- package/dist/chunk-SFK6XTJE.mjs +0 -2110
- package/dist/chunk-SIX4KMF2.mjs +0 -1468
- package/dist/chunk-SPAM2YJE.mjs +0 -1537
- package/dist/chunk-T6ZCOPPI.mjs +0 -538
- package/dist/chunk-TPF75CNP.mjs +0 -581
- package/dist/chunk-TWWPY7FD.mjs +0 -1754
- package/dist/chunk-U5R2FTCR.mjs +0 -1803
- package/dist/chunk-UG7OPVHB.mjs +0 -1521
- package/dist/chunk-UMZTAWDA.mjs +0 -1812
- package/dist/chunk-UU4HZ7ZT.mjs +0 -1849
- package/dist/chunk-UXC6QUZ7.mjs +0 -1801
- package/dist/chunk-VBWXHKGD.mjs +0 -1895
- package/dist/chunk-VIJTZPBI.mjs +0 -1470
- package/dist/chunk-VLV6MXPL.mjs +0 -1750
- package/dist/chunk-VTALAPQZ.mjs +0 -1241
- package/dist/chunk-W2KNBN6W.mjs +0 -1849
- package/dist/chunk-W37E7MW5.mjs +0 -1403
- package/dist/chunk-W76FEISE.mjs +0 -1538
- package/dist/chunk-WCFQYXQA.mjs +0 -1532
- package/dist/chunk-WKOZOHOU.mjs +0 -2060
- package/dist/chunk-WTQJNY4U.mjs +0 -1785
- package/dist/chunk-XBFM2Z4O.mjs +0 -1792
- package/dist/chunk-XIXAWCMS.mjs +0 -1760
- package/dist/chunk-XTAXUNQN.mjs +0 -1742
- package/dist/chunk-XY77XABG.mjs +0 -1545
- package/dist/chunk-XZ645X5U.mjs +0 -1425
- package/dist/chunk-Y6FXYEAI.mjs +0 -10
- package/dist/chunk-YCGDIGOG.mjs +0 -1467
- package/dist/chunk-YYB6NZE3.mjs +0 -1869
- package/dist/chunk-Z5WY6A4P.mjs +0 -1754
- package/dist/chunk-ZAMFWKIB.mjs +0 -1842
- package/dist/classifier.d.ts +0 -114
- package/dist/classifier.d.ts.map +0 -1
- package/dist/classifier.js +0 -439
- package/dist/classifier.js.map +0 -1
- package/dist/cli-action-SA7SCYNV.mjs +0 -95
- package/dist/cli-action-VCXBZGZP.mjs +0 -95
- package/dist/cli-action-YAJOJCXJ.mjs +0 -95
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cluster-detector.d.ts +0 -8
- package/dist/cluster-detector.d.ts.map +0 -1
- package/dist/cluster-detector.js +0 -70
- package/dist/cluster-detector.js.map +0 -1
- package/dist/defaults.d.ts +0 -7
- package/dist/defaults.d.ts.map +0 -1
- package/dist/defaults.js +0 -54
- package/dist/defaults.js.map +0 -1
- package/dist/graph-builder.d.ts +0 -33
- package/dist/graph-builder.d.ts.map +0 -1
- package/dist/graph-builder.js +0 -225
- package/dist/graph-builder.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/metrics.d.ts +0 -34
- package/dist/metrics.d.ts.map +0 -1
- package/dist/metrics.js +0 -170
- package/dist/metrics.js.map +0 -1
- package/dist/orchestrator-3L3NAZYP.mjs +0 -10
- package/dist/orchestrator-5AL3XBPZ.mjs +0 -10
- package/dist/orchestrator-KMAKMHTD.mjs +0 -10
- package/dist/orchestrator-MONOZHVW.mjs +0 -10
- package/dist/orchestrator-R6MZT4Z2.mjs +0 -10
- package/dist/orchestrator-ZR7JSKWI.mjs +0 -10
- package/dist/provider.d.ts +0 -6
- package/dist/provider.d.ts.map +0 -1
- package/dist/provider.js +0 -48
- package/dist/provider.js.map +0 -1
- package/dist/python-context-3GZKN3LR.mjs +0 -162
- package/dist/python-context-GOH747QU.mjs +0 -202
- package/dist/python-context-O2EN3M6Z.mjs +0 -162
- package/dist/python-context-PAETRLDY.mjs +0 -185
- package/dist/python-context-TBI5FVFY.mjs +0 -203
- package/dist/python-context-UOPTQH44.mjs +0 -192
- package/dist/remediation.d.ts +0 -25
- package/dist/remediation.d.ts.map +0 -1
- package/dist/remediation.js +0 -98
- package/dist/remediation.js.map +0 -1
- package/dist/scoring.d.ts +0 -9
- package/dist/scoring.d.ts.map +0 -1
- package/dist/scoring.js +0 -142
- package/dist/scoring.js.map +0 -1
- package/dist/semantic-analysis.d.ts +0 -33
- package/dist/semantic-analysis.d.ts.map +0 -1
- package/dist/semantic-analysis.js +0 -303
- package/dist/semantic-analysis.js.map +0 -1
- package/dist/summary-7PZVW72O.mjs +0 -7
- package/dist/summary-LKUCJAIS.mjs +0 -7
- package/dist/summary.d.ts +0 -6
- package/dist/summary.d.ts.map +0 -1
- package/dist/summary.js +0 -92
- package/dist/summary.js.map +0 -1
- package/dist/types.d.ts +0 -124
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/output-formatter.d.ts +0 -14
- package/dist/utils/output-formatter.d.ts.map +0 -1
- package/dist/utils/output-formatter.js +0 -338
- 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
|
-
|
|
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-
|
|
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
|
|
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-
|
|
270
|
-
const { generateSummary: generateSummary2 } = await import("./summary-
|
|
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(
|
|
273
|
+
ToolRegistry.register(CONTEXT_ANALYZER_PROVIDER);
|
|
386
274
|
export {
|
|
387
|
-
|
|
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
|
-
|
|
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-
|
|
4
|
+
} from "./chunk-ISWPFG2C.mjs";
|
|
5
5
|
import "./chunk-64U3PNO3.mjs";
|
|
6
|
-
import "./chunk-
|
|
6
|
+
import "./chunk-JSM7Q5CY.mjs";
|
|
7
7
|
export {
|
|
8
8
|
analyzeContext,
|
|
9
9
|
calculateCohesion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/context-analyzer",
|
|
3
|
-
"version": "0.22.
|
|
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.
|
|
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
|
+
});
|