@aiready/context-analyzer 0.9.23 → 0.9.26
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 +11 -11
- package/.turbo/turbo-test.log +21 -24
- package/dist/chunk-HOUDVRG2.mjs +1422 -0
- package/dist/chunk-PJD4VCIH.mjs +1722 -0
- package/dist/chunk-XZ645X5U.mjs +1425 -0
- package/dist/cli.js +368 -8
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +368 -8
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
- package/src/__tests__/file-classification.test.ts +596 -10
- package/src/analyzer.ts +651 -8
- package/src/index.ts +11 -3
- package/src/types.ts +6 -0
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
calculatePathEntropy,
|
|
13
13
|
calculateDirectoryDistance,
|
|
14
14
|
classifyFile,
|
|
15
|
+
adjustCohesionForClassification,
|
|
15
16
|
adjustFragmentationForClassification,
|
|
16
17
|
getClassificationRecommendations,
|
|
17
18
|
} from './analyzer';
|
|
@@ -289,6 +290,13 @@ export async function analyzeContext(
|
|
|
289
290
|
// Classify the file to help distinguish real issues from false positives
|
|
290
291
|
const fileClassification = classifyFile(node, cohesionScore, domains);
|
|
291
292
|
|
|
293
|
+
// Adjust cohesion based on classification (utility/service/handler files get boosted)
|
|
294
|
+
const adjustedCohesionScore = adjustCohesionForClassification(
|
|
295
|
+
cohesionScore,
|
|
296
|
+
fileClassification,
|
|
297
|
+
node
|
|
298
|
+
);
|
|
299
|
+
|
|
292
300
|
// Adjust fragmentation based on classification
|
|
293
301
|
const adjustedFragmentationScore = adjustFragmentationForClassification(
|
|
294
302
|
fragmentationScore,
|
|
@@ -302,7 +310,7 @@ export async function analyzeContext(
|
|
|
302
310
|
issues
|
|
303
311
|
);
|
|
304
312
|
|
|
305
|
-
// Re-analyze issues with adjusted fragmentation
|
|
313
|
+
// Re-analyze issues with adjusted cohesion and fragmentation
|
|
306
314
|
const {
|
|
307
315
|
severity: adjustedSeverity,
|
|
308
316
|
issues: adjustedIssues,
|
|
@@ -312,7 +320,7 @@ export async function analyzeContext(
|
|
|
312
320
|
file,
|
|
313
321
|
importDepth,
|
|
314
322
|
contextBudget,
|
|
315
|
-
cohesionScore,
|
|
323
|
+
cohesionScore: adjustedCohesionScore, // Use adjusted cohesion
|
|
316
324
|
fragmentationScore: adjustedFragmentationScore,
|
|
317
325
|
maxDepth,
|
|
318
326
|
maxContextBudget,
|
|
@@ -329,7 +337,7 @@ export async function analyzeContext(
|
|
|
329
337
|
dependencyCount: dependencyList.length,
|
|
330
338
|
dependencyList,
|
|
331
339
|
circularDeps: circularDeps.filter((cycle) => cycle.includes(file)),
|
|
332
|
-
cohesionScore,
|
|
340
|
+
cohesionScore: adjustedCohesionScore, // Report adjusted cohesion
|
|
333
341
|
domains,
|
|
334
342
|
exportCount: node.exports.length,
|
|
335
343
|
contextBudget,
|
package/src/types.ts
CHANGED
|
@@ -50,6 +50,12 @@ export type FileClassification =
|
|
|
50
50
|
| 'barrel-export' // Re-exports from other modules (index.ts files)
|
|
51
51
|
| 'type-definition' // Primarily type/interface definitions
|
|
52
52
|
| 'cohesive-module' // Single domain, high cohesion (acceptable large files)
|
|
53
|
+
| 'utility-module' // Utility/helper files with cohesive purpose despite multi-domain
|
|
54
|
+
| 'service-file' // Service files orchestrating multiple dependencies
|
|
55
|
+
| 'lambda-handler' // Lambda/API handlers with single business purpose
|
|
56
|
+
| 'email-template' // Email templates/layouts with structural cohesion
|
|
57
|
+
| 'parser-file' // Parser/transformer files with single transformation purpose
|
|
58
|
+
| 'nextjs-page' // Next.js App Router page with SEO/structured data exports
|
|
53
59
|
| 'mixed-concerns' // Multiple domains, potential refactoring candidate
|
|
54
60
|
| 'unknown'; // Unable to classify
|
|
55
61
|
|