@aiready/context-analyzer 0.19.17 → 0.19.21
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-lint.log +2 -22
- package/.turbo/turbo-test.log +23 -23
- package/coverage/analyzer.ts.html +1369 -0
- package/coverage/ast-utils.ts.html +382 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/classifier.ts.html +1771 -0
- package/coverage/clover.xml +1245 -0
- package/coverage/cluster-detector.ts.html +385 -0
- package/coverage/coverage-final.json +15 -0
- package/coverage/defaults.ts.html +262 -0
- package/coverage/favicon.png +0 -0
- package/coverage/graph-builder.ts.html +859 -0
- package/coverage/index.html +311 -0
- package/coverage/index.ts.html +124 -0
- package/coverage/metrics.ts.html +748 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/provider.ts.html +283 -0
- package/coverage/remediation.ts.html +502 -0
- package/coverage/scoring.ts.html +619 -0
- package/coverage/semantic-analysis.ts.html +1201 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/coverage/summary.ts.html +625 -0
- package/coverage/types.ts.html +571 -0
- package/dist/chunk-736QSHJP.mjs +1807 -0
- package/dist/chunk-CCBNKQYB.mjs +1812 -0
- package/dist/chunk-JUHHOSHG.mjs +1808 -0
- package/dist/cli.js +393 -379
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +65 -6
- package/dist/index.d.ts +65 -6
- package/dist/index.js +396 -380
- package/dist/index.mjs +3 -1
- package/package.json +2 -2
- package/src/__tests__/cluster-detector.test.ts +138 -0
- package/src/__tests__/provider.test.ts +78 -0
- package/src/__tests__/remediation.test.ts +94 -0
- package/src/analyzer.ts +244 -1
- package/src/classifier.ts +100 -35
- package/src/index.ts +1 -242
- package/src/provider.ts +2 -1
package/dist/cli.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -192,56 +192,116 @@ declare function calculatePathEntropy(files: string[]): number;
|
|
|
192
192
|
*/
|
|
193
193
|
declare function calculateDirectoryDistance(files: string[]): number;
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Constants for file classifications to avoid magic strings
|
|
197
|
+
*/
|
|
198
|
+
declare const Classification: {
|
|
199
|
+
BARREL: "barrel-export";
|
|
200
|
+
TYPE_DEFINITION: "type-definition";
|
|
201
|
+
NEXTJS_PAGE: "nextjs-page";
|
|
202
|
+
LAMBDA_HANDLER: "lambda-handler";
|
|
203
|
+
SERVICE: "service-file";
|
|
204
|
+
EMAIL_TEMPLATE: "email-template";
|
|
205
|
+
PARSER: "parser-file";
|
|
206
|
+
COHESIVE_MODULE: "cohesive-module";
|
|
207
|
+
UTILITY_MODULE: "utility-module";
|
|
208
|
+
MIXED_CONCERNS: "mixed-concerns";
|
|
209
|
+
UNKNOWN: "unknown";
|
|
210
|
+
};
|
|
195
211
|
/**
|
|
196
212
|
* Classify a file into a specific type for better analysis context
|
|
213
|
+
*
|
|
214
|
+
* @param node The dependency node representing the file
|
|
215
|
+
* @param cohesionScore The calculated cohesion score for the file
|
|
216
|
+
* @param domains The detected domains/concerns for the file
|
|
217
|
+
* @returns The determined file classification
|
|
197
218
|
*/
|
|
198
219
|
declare function classifyFile(node: DependencyNode, cohesionScore?: number, domains?: string[]): FileClassification;
|
|
199
220
|
/**
|
|
200
221
|
* Detect if a file is a barrel export (index.ts)
|
|
222
|
+
*
|
|
223
|
+
* @param node The dependency node to check
|
|
224
|
+
* @returns True if the file appears to be a barrel export
|
|
201
225
|
*/
|
|
202
226
|
declare function isBarrelExport(node: DependencyNode): boolean;
|
|
203
227
|
/**
|
|
204
228
|
* Detect if a file is primarily type definitions
|
|
229
|
+
*
|
|
230
|
+
* @param node The dependency node to check
|
|
231
|
+
* @returns True if the file appears to be primarily types
|
|
205
232
|
*/
|
|
206
233
|
declare function isTypeDefinition(node: DependencyNode): boolean;
|
|
207
234
|
/**
|
|
208
235
|
* Detect if a file is a utility module
|
|
236
|
+
*
|
|
237
|
+
* @param node The dependency node to check
|
|
238
|
+
* @returns True if the file appears to be a utility module
|
|
209
239
|
*/
|
|
210
240
|
declare function isUtilityModule(node: DependencyNode): boolean;
|
|
211
241
|
/**
|
|
212
242
|
* Detect if a file is a Lambda/API handler
|
|
243
|
+
*
|
|
244
|
+
* @param node The dependency node to check
|
|
245
|
+
* @returns True if the file appears to be a Lambda handler
|
|
213
246
|
*/
|
|
214
247
|
declare function isLambdaHandler(node: DependencyNode): boolean;
|
|
215
248
|
/**
|
|
216
249
|
* Detect if a file is a service file
|
|
250
|
+
*
|
|
251
|
+
* @param node The dependency node to check
|
|
252
|
+
* @returns True if the file appears to be a service file
|
|
217
253
|
*/
|
|
218
254
|
declare function isServiceFile(node: DependencyNode): boolean;
|
|
219
255
|
/**
|
|
220
256
|
* Detect if a file is an email template/layout
|
|
257
|
+
*
|
|
258
|
+
* @param node The dependency node to check
|
|
259
|
+
* @returns True if the file appears to be an email template
|
|
221
260
|
*/
|
|
222
261
|
declare function isEmailTemplate(node: DependencyNode): boolean;
|
|
223
262
|
/**
|
|
224
263
|
* Detect if a file is a parser/transformer
|
|
264
|
+
*
|
|
265
|
+
* @param node The dependency node to check
|
|
266
|
+
* @returns True if the file appears to be a parser
|
|
225
267
|
*/
|
|
226
268
|
declare function isParserFile(node: DependencyNode): boolean;
|
|
227
269
|
/**
|
|
228
270
|
* Detect if a file is a session/state management file
|
|
271
|
+
*
|
|
272
|
+
* @param node The dependency node to check
|
|
273
|
+
* @returns True if the file appears to be a session/state file
|
|
229
274
|
*/
|
|
230
275
|
declare function isSessionFile(node: DependencyNode): boolean;
|
|
231
276
|
/**
|
|
232
277
|
* Detect if a file is a configuration or schema file
|
|
278
|
+
*
|
|
279
|
+
* @param node The dependency node to check
|
|
280
|
+
* @returns True if the file appears to be a config file
|
|
233
281
|
*/
|
|
234
282
|
declare function isConfigFile(node: DependencyNode): boolean;
|
|
235
283
|
/**
|
|
236
284
|
* Detect if a file is a Next.js App Router page
|
|
285
|
+
*
|
|
286
|
+
* @param node The dependency node to check
|
|
287
|
+
* @returns True if the file appears to be a Next.js page
|
|
237
288
|
*/
|
|
238
289
|
declare function isNextJsPage(node: DependencyNode): boolean;
|
|
239
290
|
/**
|
|
240
291
|
* Adjust cohesion score based on file classification
|
|
292
|
+
*
|
|
293
|
+
* @param baseCohesion The initial cohesion score
|
|
294
|
+
* @param classification The file classification
|
|
295
|
+
* @param node Optional dependency node for further context
|
|
296
|
+
* @returns The adjusted cohesion score
|
|
241
297
|
*/
|
|
242
298
|
declare function adjustCohesionForClassification(baseCohesion: number, classification: FileClassification, node?: DependencyNode): number;
|
|
243
299
|
/**
|
|
244
300
|
* Adjust fragmentation score based on file classification
|
|
301
|
+
*
|
|
302
|
+
* @param baseFragmentation The initial fragmentation score
|
|
303
|
+
* @param classification The file classification
|
|
304
|
+
* @returns The adjusted fragmentation score
|
|
245
305
|
*/
|
|
246
306
|
declare function adjustFragmentationForClassification(baseFragmentation: number, classification: FileClassification): number;
|
|
247
307
|
|
|
@@ -301,6 +361,10 @@ declare function analyzeIssues(params: {
|
|
|
301
361
|
recommendations: string[];
|
|
302
362
|
potentialSavings: number;
|
|
303
363
|
};
|
|
364
|
+
/**
|
|
365
|
+
* Analyze AI context window cost for a codebase
|
|
366
|
+
*/
|
|
367
|
+
declare function analyzeContext(options: ContextAnalyzerOptions): Promise<ContextAnalysisResult[]>;
|
|
304
368
|
|
|
305
369
|
/**
|
|
306
370
|
* Calculate AI Readiness Score for context efficiency (0-100)
|
|
@@ -351,9 +415,4 @@ declare function inferDomain(name: string, filePath?: string, domainOptions?: {
|
|
|
351
415
|
declare function getCoUsageData(file: string, coUsageMatrix: Map<string, Map<string, number>>): CoUsageData;
|
|
352
416
|
declare function findConsolidationCandidates(graph: DependencyGraph, coUsageMatrix: Map<string, Map<string, number>>, typeGraph: Map<string, Set<string>>, minCoUsage?: number, minSharedTypes?: number): any[];
|
|
353
417
|
|
|
354
|
-
|
|
355
|
-
* Analyze AI context window cost for a codebase
|
|
356
|
-
*/
|
|
357
|
-
declare function analyzeContext(options: ContextAnalyzerOptions): Promise<ContextAnalysisResult[]>;
|
|
358
|
-
|
|
359
|
-
export { type CoUsageData, type ContextAnalysisResult, type ContextAnalyzerOptions, ContextAnalyzerProvider, type ContextSummary, type DependencyGraph, type DependencyNode, type DomainAssignment, type DomainSignals, type ExportInfo, type FileClassification, type ModuleCluster, type TypeDependency, adjustCohesionForClassification, adjustFragmentationForClassification, analyzeContext, analyzeIssues, buildCoUsageMatrix, buildDependencyGraph, buildTypeGraph, calculateCohesion, calculateContextBudget, calculateContextScore, calculateDirectoryDistance, calculateDomainConfidence, calculateEnhancedCohesion, calculateFragmentation, calculateImportDepth, calculatePathEntropy, calculateStructuralCohesionFromCoUsage, classifyFile, detectCircularDependencies, detectModuleClusters, extractDomainKeywordsFromPaths, extractExports, findConsolidationCandidates, findSemanticClusters, generateSummary, getClassificationRecommendations, getCoUsageData, getGeneralRecommendations, getSmartDefaults, getTransitiveDependencies, inferDomain, inferDomainFromSemantics, isBarrelExport, isConfigFile, isEmailTemplate, isLambdaHandler, isNextJsPage, isParserFile, isServiceFile, isSessionFile, isTypeDefinition, isUtilityModule, mapScoreToRating };
|
|
418
|
+
export { Classification, type CoUsageData, type ContextAnalysisResult, type ContextAnalyzerOptions, ContextAnalyzerProvider, type ContextSummary, type DependencyGraph, type DependencyNode, type DomainAssignment, type DomainSignals, type ExportInfo, type FileClassification, type ModuleCluster, type TypeDependency, adjustCohesionForClassification, adjustFragmentationForClassification, analyzeContext, analyzeIssues, buildCoUsageMatrix, buildDependencyGraph, buildTypeGraph, calculateCohesion, calculateContextBudget, calculateContextScore, calculateDirectoryDistance, calculateDomainConfidence, calculateEnhancedCohesion, calculateFragmentation, calculateImportDepth, calculatePathEntropy, calculateStructuralCohesionFromCoUsage, classifyFile, detectCircularDependencies, detectModuleClusters, extractDomainKeywordsFromPaths, extractExports, findConsolidationCandidates, findSemanticClusters, generateSummary, getClassificationRecommendations, getCoUsageData, getGeneralRecommendations, getSmartDefaults, getTransitiveDependencies, inferDomain, inferDomainFromSemantics, isBarrelExport, isConfigFile, isEmailTemplate, isLambdaHandler, isNextJsPage, isParserFile, isServiceFile, isSessionFile, isTypeDefinition, isUtilityModule, mapScoreToRating };
|
package/dist/index.d.ts
CHANGED
|
@@ -192,56 +192,116 @@ declare function calculatePathEntropy(files: string[]): number;
|
|
|
192
192
|
*/
|
|
193
193
|
declare function calculateDirectoryDistance(files: string[]): number;
|
|
194
194
|
|
|
195
|
+
/**
|
|
196
|
+
* Constants for file classifications to avoid magic strings
|
|
197
|
+
*/
|
|
198
|
+
declare const Classification: {
|
|
199
|
+
BARREL: "barrel-export";
|
|
200
|
+
TYPE_DEFINITION: "type-definition";
|
|
201
|
+
NEXTJS_PAGE: "nextjs-page";
|
|
202
|
+
LAMBDA_HANDLER: "lambda-handler";
|
|
203
|
+
SERVICE: "service-file";
|
|
204
|
+
EMAIL_TEMPLATE: "email-template";
|
|
205
|
+
PARSER: "parser-file";
|
|
206
|
+
COHESIVE_MODULE: "cohesive-module";
|
|
207
|
+
UTILITY_MODULE: "utility-module";
|
|
208
|
+
MIXED_CONCERNS: "mixed-concerns";
|
|
209
|
+
UNKNOWN: "unknown";
|
|
210
|
+
};
|
|
195
211
|
/**
|
|
196
212
|
* Classify a file into a specific type for better analysis context
|
|
213
|
+
*
|
|
214
|
+
* @param node The dependency node representing the file
|
|
215
|
+
* @param cohesionScore The calculated cohesion score for the file
|
|
216
|
+
* @param domains The detected domains/concerns for the file
|
|
217
|
+
* @returns The determined file classification
|
|
197
218
|
*/
|
|
198
219
|
declare function classifyFile(node: DependencyNode, cohesionScore?: number, domains?: string[]): FileClassification;
|
|
199
220
|
/**
|
|
200
221
|
* Detect if a file is a barrel export (index.ts)
|
|
222
|
+
*
|
|
223
|
+
* @param node The dependency node to check
|
|
224
|
+
* @returns True if the file appears to be a barrel export
|
|
201
225
|
*/
|
|
202
226
|
declare function isBarrelExport(node: DependencyNode): boolean;
|
|
203
227
|
/**
|
|
204
228
|
* Detect if a file is primarily type definitions
|
|
229
|
+
*
|
|
230
|
+
* @param node The dependency node to check
|
|
231
|
+
* @returns True if the file appears to be primarily types
|
|
205
232
|
*/
|
|
206
233
|
declare function isTypeDefinition(node: DependencyNode): boolean;
|
|
207
234
|
/**
|
|
208
235
|
* Detect if a file is a utility module
|
|
236
|
+
*
|
|
237
|
+
* @param node The dependency node to check
|
|
238
|
+
* @returns True if the file appears to be a utility module
|
|
209
239
|
*/
|
|
210
240
|
declare function isUtilityModule(node: DependencyNode): boolean;
|
|
211
241
|
/**
|
|
212
242
|
* Detect if a file is a Lambda/API handler
|
|
243
|
+
*
|
|
244
|
+
* @param node The dependency node to check
|
|
245
|
+
* @returns True if the file appears to be a Lambda handler
|
|
213
246
|
*/
|
|
214
247
|
declare function isLambdaHandler(node: DependencyNode): boolean;
|
|
215
248
|
/**
|
|
216
249
|
* Detect if a file is a service file
|
|
250
|
+
*
|
|
251
|
+
* @param node The dependency node to check
|
|
252
|
+
* @returns True if the file appears to be a service file
|
|
217
253
|
*/
|
|
218
254
|
declare function isServiceFile(node: DependencyNode): boolean;
|
|
219
255
|
/**
|
|
220
256
|
* Detect if a file is an email template/layout
|
|
257
|
+
*
|
|
258
|
+
* @param node The dependency node to check
|
|
259
|
+
* @returns True if the file appears to be an email template
|
|
221
260
|
*/
|
|
222
261
|
declare function isEmailTemplate(node: DependencyNode): boolean;
|
|
223
262
|
/**
|
|
224
263
|
* Detect if a file is a parser/transformer
|
|
264
|
+
*
|
|
265
|
+
* @param node The dependency node to check
|
|
266
|
+
* @returns True if the file appears to be a parser
|
|
225
267
|
*/
|
|
226
268
|
declare function isParserFile(node: DependencyNode): boolean;
|
|
227
269
|
/**
|
|
228
270
|
* Detect if a file is a session/state management file
|
|
271
|
+
*
|
|
272
|
+
* @param node The dependency node to check
|
|
273
|
+
* @returns True if the file appears to be a session/state file
|
|
229
274
|
*/
|
|
230
275
|
declare function isSessionFile(node: DependencyNode): boolean;
|
|
231
276
|
/**
|
|
232
277
|
* Detect if a file is a configuration or schema file
|
|
278
|
+
*
|
|
279
|
+
* @param node The dependency node to check
|
|
280
|
+
* @returns True if the file appears to be a config file
|
|
233
281
|
*/
|
|
234
282
|
declare function isConfigFile(node: DependencyNode): boolean;
|
|
235
283
|
/**
|
|
236
284
|
* Detect if a file is a Next.js App Router page
|
|
285
|
+
*
|
|
286
|
+
* @param node The dependency node to check
|
|
287
|
+
* @returns True if the file appears to be a Next.js page
|
|
237
288
|
*/
|
|
238
289
|
declare function isNextJsPage(node: DependencyNode): boolean;
|
|
239
290
|
/**
|
|
240
291
|
* Adjust cohesion score based on file classification
|
|
292
|
+
*
|
|
293
|
+
* @param baseCohesion The initial cohesion score
|
|
294
|
+
* @param classification The file classification
|
|
295
|
+
* @param node Optional dependency node for further context
|
|
296
|
+
* @returns The adjusted cohesion score
|
|
241
297
|
*/
|
|
242
298
|
declare function adjustCohesionForClassification(baseCohesion: number, classification: FileClassification, node?: DependencyNode): number;
|
|
243
299
|
/**
|
|
244
300
|
* Adjust fragmentation score based on file classification
|
|
301
|
+
*
|
|
302
|
+
* @param baseFragmentation The initial fragmentation score
|
|
303
|
+
* @param classification The file classification
|
|
304
|
+
* @returns The adjusted fragmentation score
|
|
245
305
|
*/
|
|
246
306
|
declare function adjustFragmentationForClassification(baseFragmentation: number, classification: FileClassification): number;
|
|
247
307
|
|
|
@@ -301,6 +361,10 @@ declare function analyzeIssues(params: {
|
|
|
301
361
|
recommendations: string[];
|
|
302
362
|
potentialSavings: number;
|
|
303
363
|
};
|
|
364
|
+
/**
|
|
365
|
+
* Analyze AI context window cost for a codebase
|
|
366
|
+
*/
|
|
367
|
+
declare function analyzeContext(options: ContextAnalyzerOptions): Promise<ContextAnalysisResult[]>;
|
|
304
368
|
|
|
305
369
|
/**
|
|
306
370
|
* Calculate AI Readiness Score for context efficiency (0-100)
|
|
@@ -351,9 +415,4 @@ declare function inferDomain(name: string, filePath?: string, domainOptions?: {
|
|
|
351
415
|
declare function getCoUsageData(file: string, coUsageMatrix: Map<string, Map<string, number>>): CoUsageData;
|
|
352
416
|
declare function findConsolidationCandidates(graph: DependencyGraph, coUsageMatrix: Map<string, Map<string, number>>, typeGraph: Map<string, Set<string>>, minCoUsage?: number, minSharedTypes?: number): any[];
|
|
353
417
|
|
|
354
|
-
|
|
355
|
-
* Analyze AI context window cost for a codebase
|
|
356
|
-
*/
|
|
357
|
-
declare function analyzeContext(options: ContextAnalyzerOptions): Promise<ContextAnalysisResult[]>;
|
|
358
|
-
|
|
359
|
-
export { type CoUsageData, type ContextAnalysisResult, type ContextAnalyzerOptions, ContextAnalyzerProvider, type ContextSummary, type DependencyGraph, type DependencyNode, type DomainAssignment, type DomainSignals, type ExportInfo, type FileClassification, type ModuleCluster, type TypeDependency, adjustCohesionForClassification, adjustFragmentationForClassification, analyzeContext, analyzeIssues, buildCoUsageMatrix, buildDependencyGraph, buildTypeGraph, calculateCohesion, calculateContextBudget, calculateContextScore, calculateDirectoryDistance, calculateDomainConfidence, calculateEnhancedCohesion, calculateFragmentation, calculateImportDepth, calculatePathEntropy, calculateStructuralCohesionFromCoUsage, classifyFile, detectCircularDependencies, detectModuleClusters, extractDomainKeywordsFromPaths, extractExports, findConsolidationCandidates, findSemanticClusters, generateSummary, getClassificationRecommendations, getCoUsageData, getGeneralRecommendations, getSmartDefaults, getTransitiveDependencies, inferDomain, inferDomainFromSemantics, isBarrelExport, isConfigFile, isEmailTemplate, isLambdaHandler, isNextJsPage, isParserFile, isServiceFile, isSessionFile, isTypeDefinition, isUtilityModule, mapScoreToRating };
|
|
418
|
+
export { Classification, type CoUsageData, type ContextAnalysisResult, type ContextAnalyzerOptions, ContextAnalyzerProvider, type ContextSummary, type DependencyGraph, type DependencyNode, type DomainAssignment, type DomainSignals, type ExportInfo, type FileClassification, type ModuleCluster, type TypeDependency, adjustCohesionForClassification, adjustFragmentationForClassification, analyzeContext, analyzeIssues, buildCoUsageMatrix, buildDependencyGraph, buildTypeGraph, calculateCohesion, calculateContextBudget, calculateContextScore, calculateDirectoryDistance, calculateDomainConfidence, calculateEnhancedCohesion, calculateFragmentation, calculateImportDepth, calculatePathEntropy, calculateStructuralCohesionFromCoUsage, classifyFile, detectCircularDependencies, detectModuleClusters, extractDomainKeywordsFromPaths, extractExports, findConsolidationCandidates, findSemanticClusters, generateSummary, getClassificationRecommendations, getCoUsageData, getGeneralRecommendations, getSmartDefaults, getTransitiveDependencies, inferDomain, inferDomainFromSemantics, isBarrelExport, isConfigFile, isEmailTemplate, isLambdaHandler, isNextJsPage, isParserFile, isServiceFile, isSessionFile, isTypeDefinition, isUtilityModule, mapScoreToRating };
|