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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | 11x 11x 11x 11x 11x 10x 11x 1x 1x 11x 1x 2x 11x | import { analyzeContext } from '../orchestrator';
import { generateSummary } from '../summary';
import {
generateIssueSummary,
generateTable,
generateStandardHtmlReport,
} from '@aiready/core';
/**
* Generate HTML report
*/
export function generateHTMLReport(
summary: ReturnType<typeof generateSummary>,
results: Awaited<ReturnType<typeof analyzeContext>>
): string {
const totalIssues =
summary.criticalIssues + summary.majorIssues + summary.minorIssues;
void results;
const stats = [
{ value: summary.totalFiles, label: 'Files Analyzed' },
{ value: summary.totalTokens.toLocaleString(), label: 'Total Tokens' },
{ value: summary.avgContextBudget.toFixed(0), label: 'Avg Context Budget' },
{
value: totalIssues,
label: 'Total Issues',
color: totalIssues > 0 ? '#f39c12' : undefined,
},
];
const sections: any[] = [];
if (totalIssues > 0) {
sections.push({
title: '⚠️ Issues Summary',
content: generateIssueSummary(
summary.criticalIssues,
summary.majorIssues,
summary.minorIssues,
summary.totalPotentialSavings
),
});
}
if (summary.fragmentedModules.length > 0) {
sections.push({
title: '🧩 Fragmented Modules',
content: generateTable({
headers: ['Domain', 'Files', 'Fragmentation', 'Token Cost'],
rows: summary.fragmentedModules.map((m) => [
m.domain,
String(m.files.length),
`${(m.fragmentationScore * 100).toFixed(0)}%`,
m.totalTokens.toLocaleString(),
]),
}),
});
}
if (summary.topExpensiveFiles.length > 0) {
sections.push({
title: '💸 Most Expensive Files',
content: generateTable({
headers: ['File', 'Context Budget', 'Severity'],
rows: summary.topExpensiveFiles.map((f) => [
f.file,
`${f.contextBudget.toLocaleString()} tokens`,
`<span class="issue-${f.severity}">${f.severity.toUpperCase()}</span>`,
]),
}),
});
}
return generateStandardHtmlReport(
{
title: 'Context Analysis Report',
packageName: 'context-analyzer',
packageUrl: 'https://github.com/caopengau/aiready-context-analyzer',
bugUrl: 'https://github.com/caopengau/aiready-context-analyzer/issues',
emoji: '🧠',
},
stats,
sections
);
}
|