/** * ReportGenerator * Generates a visual HTML dashboard based on the ContextComposition. * Apple-inspired design: clean whitespace, SF Pro typography, single blue accent. */ import type { ContextComposition } from "./analyzer"; import type { Insight } from "./insights"; export class ReportGenerator { public static generateHTML( composition: ContextComposition, insights: Insight[], contextWindow: number = 128_000, actualTokens?: number | null, ): string { // Use Pi's actual token count when available const total = actualTokens != null && actualTokens > 0 ? actualTokens : composition.total.tokens; const usagePercent = total > 0 ? Math.round((total / contextWindow) * 100) : 0; const fileCards = composition.files_detail .map( (file) => `
${ReportGenerator.escapeHtml(insight.message)}
${insight.command ? `${insight.command}Session context window breakdown with actionable recommendations
No insights available yet — the context composition is balanced.
`}