Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | 8x 8x 8x 5x 5x 5x 5x 3x 1x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x 8x | import { scanFiles } from '@aiready/core';
import type { ContextAnalyzerOptions } from './types';
/**
* Generate smart defaults for context analysis based on repository size
* Automatically tunes thresholds to target ~10 most serious issues
* @param directory - The root directory to analyze
* @param userOptions - Partial user-provided options to merge with defaults
* @returns Complete ContextAnalyzerOptions with smart defaults
*/
export async function getSmartDefaults(
directory: string,
userOptions: Partial<ContextAnalyzerOptions>
): Promise<ContextAnalyzerOptions> {
// Estimate repository size by scanning files
const files = await scanFiles({
rootDir: directory,
include: userOptions.include,
exclude: userOptions.exclude,
});
const estimatedBlocks = files.length;
let maxDepth: number;
let maxContextBudget: number;
let minCohesion: number;
let maxFragmentation: number;
if (estimatedBlocks < 100) {
maxDepth = 5;
maxContextBudget = 8000;
minCohesion = 0.5;
maxFragmentation = 0.5;
} else if (estimatedBlocks < 500) {
maxDepth = 6;
maxContextBudget = 15000;
minCohesion = 0.45;
maxFragmentation = 0.6;
} else if (estimatedBlocks < 2000) {
maxDepth = 8;
maxContextBudget = 25000;
minCohesion = 0.4;
maxFragmentation = 0.7;
} else {
maxDepth = 12;
maxContextBudget = 40000;
minCohesion = 0.35;
maxFragmentation = 0.8;
}
return {
maxDepth,
maxContextBudget,
minCohesion,
maxFragmentation,
focus: 'all',
includeNodeModules: false,
rootDir: userOptions.rootDir || directory,
include: userOptions.include,
exclude: userOptions.exclude,
};
}
|