@aiready/context-analyzer 0.9.41 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-test.log +21 -20
- package/dist/chunk-4SYIJ7CU.mjs +1538 -0
- package/dist/chunk-4XQVYYPC.mjs +1470 -0
- package/dist/chunk-5CLU3HYU.mjs +1475 -0
- package/dist/chunk-5K73Q3OQ.mjs +1520 -0
- package/dist/chunk-6AVS4KTM.mjs +1536 -0
- package/dist/chunk-6I4552YB.mjs +1467 -0
- package/dist/chunk-6LPITDKG.mjs +1539 -0
- package/dist/chunk-AECWO7NQ.mjs +1539 -0
- package/dist/chunk-AJC3FR6G.mjs +1509 -0
- package/dist/chunk-CVGIDSMN.mjs +1522 -0
- package/dist/chunk-DXG5NIYL.mjs +1527 -0
- package/dist/chunk-G3CCJCBI.mjs +1521 -0
- package/dist/chunk-GFADGYXZ.mjs +1752 -0
- package/dist/chunk-GTRIBVS6.mjs +1467 -0
- package/dist/chunk-H4HWBQU6.mjs +1530 -0
- package/dist/chunk-JH535NPP.mjs +1619 -0
- package/dist/chunk-KGFWKSGJ.mjs +1442 -0
- package/dist/chunk-N2GQWNFG.mjs +1527 -0
- package/dist/chunk-NQA3F2HJ.mjs +1532 -0
- package/dist/chunk-NXXQ2U73.mjs +1467 -0
- package/dist/chunk-QDGPR3L6.mjs +1518 -0
- package/dist/chunk-SAVOSPM3.mjs +1522 -0
- package/dist/chunk-SIX4KMF2.mjs +1468 -0
- package/dist/chunk-SPAM2YJE.mjs +1537 -0
- package/dist/chunk-UG7OPVHB.mjs +1521 -0
- package/dist/chunk-VIJTZPBI.mjs +1470 -0
- package/dist/chunk-W37E7MW5.mjs +1403 -0
- package/dist/chunk-W76FEISE.mjs +1538 -0
- package/dist/chunk-WCFQYXQA.mjs +1532 -0
- package/dist/chunk-XY77XABG.mjs +1545 -0
- package/dist/chunk-YCGDIGOG.mjs +1467 -0
- package/dist/cli.js +768 -1160
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +196 -64
- package/dist/index.d.ts +196 -64
- package/dist/index.js +937 -1209
- package/dist/index.mjs +65 -3
- package/package.json +2 -2
- package/src/__tests__/contract.test.ts +38 -0
- package/src/analyzer.ts +143 -2177
- package/src/ast-utils.ts +94 -0
- package/src/classifier.ts +497 -0
- package/src/cluster-detector.ts +100 -0
- package/src/defaults.ts +59 -0
- package/src/graph-builder.ts +272 -0
- package/src/index.ts +30 -519
- package/src/metrics.ts +231 -0
- package/src/remediation.ts +139 -0
- package/src/scoring.ts +12 -34
- package/src/semantic-analysis.ts +192 -126
- package/src/summary.ts +168 -0
package/dist/index.mjs
CHANGED
|
@@ -1,30 +1,92 @@
|
|
|
1
1
|
import {
|
|
2
|
+
adjustCohesionForClassification,
|
|
2
3
|
adjustFragmentationForClassification,
|
|
3
4
|
analyzeContext,
|
|
5
|
+
analyzeIssues,
|
|
4
6
|
buildCoUsageMatrix,
|
|
7
|
+
buildDependencyGraph,
|
|
5
8
|
buildTypeGraph,
|
|
9
|
+
calculateCohesion,
|
|
10
|
+
calculateContextBudget,
|
|
6
11
|
calculateContextScore,
|
|
12
|
+
calculateDirectoryDistance,
|
|
7
13
|
calculateDomainConfidence,
|
|
14
|
+
calculateEnhancedCohesion,
|
|
15
|
+
calculateFragmentation,
|
|
16
|
+
calculateImportDepth,
|
|
17
|
+
calculatePathEntropy,
|
|
18
|
+
calculateStructuralCohesionFromCoUsage,
|
|
8
19
|
classifyFile,
|
|
20
|
+
detectCircularDependencies,
|
|
21
|
+
detectModuleClusters,
|
|
22
|
+
extractDomainKeywordsFromPaths,
|
|
23
|
+
extractExports,
|
|
24
|
+
extractImportsFromContent,
|
|
9
25
|
findConsolidationCandidates,
|
|
10
26
|
findSemanticClusters,
|
|
11
27
|
generateSummary,
|
|
28
|
+
getClassificationRecommendations,
|
|
12
29
|
getCoUsageData,
|
|
30
|
+
getGeneralRecommendations,
|
|
13
31
|
getSmartDefaults,
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
getTransitiveDependencies,
|
|
33
|
+
inferDomain,
|
|
34
|
+
inferDomainFromSemantics,
|
|
35
|
+
isBarrelExport,
|
|
36
|
+
isConfigFile,
|
|
37
|
+
isEmailTemplate,
|
|
38
|
+
isLambdaHandler,
|
|
39
|
+
isNextJsPage,
|
|
40
|
+
isParserFile,
|
|
41
|
+
isServiceFile,
|
|
42
|
+
isSessionFile,
|
|
43
|
+
isTypeDefinition,
|
|
44
|
+
isUtilityModule,
|
|
45
|
+
mapScoreToRating
|
|
46
|
+
} from "./chunk-GFADGYXZ.mjs";
|
|
16
47
|
export {
|
|
48
|
+
adjustCohesionForClassification,
|
|
17
49
|
adjustFragmentationForClassification,
|
|
18
50
|
analyzeContext,
|
|
51
|
+
analyzeIssues,
|
|
19
52
|
buildCoUsageMatrix,
|
|
53
|
+
buildDependencyGraph,
|
|
20
54
|
buildTypeGraph,
|
|
55
|
+
calculateCohesion,
|
|
56
|
+
calculateContextBudget,
|
|
21
57
|
calculateContextScore,
|
|
58
|
+
calculateDirectoryDistance,
|
|
22
59
|
calculateDomainConfidence,
|
|
60
|
+
calculateEnhancedCohesion,
|
|
61
|
+
calculateFragmentation,
|
|
62
|
+
calculateImportDepth,
|
|
63
|
+
calculatePathEntropy,
|
|
64
|
+
calculateStructuralCohesionFromCoUsage,
|
|
23
65
|
classifyFile,
|
|
66
|
+
detectCircularDependencies,
|
|
67
|
+
detectModuleClusters,
|
|
68
|
+
extractDomainKeywordsFromPaths,
|
|
69
|
+
extractExports,
|
|
70
|
+
extractImportsFromContent,
|
|
24
71
|
findConsolidationCandidates,
|
|
25
72
|
findSemanticClusters,
|
|
26
73
|
generateSummary,
|
|
74
|
+
getClassificationRecommendations,
|
|
27
75
|
getCoUsageData,
|
|
76
|
+
getGeneralRecommendations,
|
|
28
77
|
getSmartDefaults,
|
|
29
|
-
|
|
78
|
+
getTransitiveDependencies,
|
|
79
|
+
inferDomain,
|
|
80
|
+
inferDomainFromSemantics,
|
|
81
|
+
isBarrelExport,
|
|
82
|
+
isConfigFile,
|
|
83
|
+
isEmailTemplate,
|
|
84
|
+
isLambdaHandler,
|
|
85
|
+
isNextJsPage,
|
|
86
|
+
isParserFile,
|
|
87
|
+
isServiceFile,
|
|
88
|
+
isSessionFile,
|
|
89
|
+
isTypeDefinition,
|
|
90
|
+
isUtilityModule,
|
|
91
|
+
mapScoreToRating
|
|
30
92
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiready/context-analyzer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
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.
|
|
52
|
+
"@aiready/core": "0.18.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/node": "^24.0.0",
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { analyzeContext, generateSummary } from '../index';
|
|
3
|
+
import { validateSpokeOutput } from '../../../core/src/types/contract';
|
|
4
|
+
|
|
5
|
+
// Mock core functions
|
|
6
|
+
vi.mock('@aiready/core', async (importOriginal) => {
|
|
7
|
+
const actual = await importOriginal<typeof import('@aiready/core')>();
|
|
8
|
+
return {
|
|
9
|
+
...actual,
|
|
10
|
+
scanFiles: vi.fn().mockResolvedValue(['file1.ts']),
|
|
11
|
+
readFileContent: vi
|
|
12
|
+
.fn()
|
|
13
|
+
.mockResolvedValue('import { a } from "./b"; export const x = 1;'),
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('Context Analyzer Contract Validation', () => {
|
|
18
|
+
it('should produce output matching the SpokeOutput contract', async () => {
|
|
19
|
+
const results = await analyzeContext({
|
|
20
|
+
rootDir: './test',
|
|
21
|
+
} as any);
|
|
22
|
+
|
|
23
|
+
const summary = generateSummary(results);
|
|
24
|
+
|
|
25
|
+
const fullOutput = {
|
|
26
|
+
results,
|
|
27
|
+
summary,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const validation = validateSpokeOutput('context-analyzer', fullOutput);
|
|
31
|
+
|
|
32
|
+
if (!validation.valid) {
|
|
33
|
+
console.error('Contract Validation Errors:', validation.errors);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
expect(validation.valid).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
});
|