pi-lens
Version:
Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo
38 lines (37 loc) • 1.32 kB
JavaScript
/**
* Session Summary — generates turn_end and session-end summaries
*/
export function formatSessionSummary(stats) {
if (stats.totalShown === 0)
return "";
const lines = [
"## Diagnostic Summary",
"",
`Shown to agent: ${stats.totalShown}`,
`Auto-fixed: ${stats.totalAutoFixed} (${pct(stats.totalAutoFixed, stats.totalShown)}%)`,
`Fixed by agent: ${stats.totalAgentFixed} (${pct(stats.totalAgentFixed, stats.totalShown)}%)`,
"",
];
if (stats.topViolations.length > 0) {
lines.push("Top violations:");
for (const { ruleId, count } of stats.topViolations.slice(0, 5)) {
lines.push(` - ${ruleId} (${count}x)`);
}
}
return lines.join("\n");
}
function pct(part, total) {
if (total === 0)
return "0";
return Math.round((part / total) * 100).toString();
}
export function formatSlopScoreSummary(summary) {
if (summary.totalRuleDiagnostics === 0 || summary.totalKlocWritten <= 0) {
return "";
}
const topRules = summary.ruleCounts.slice(0, 3);
const detail = topRules.length > 0
? " (" + topRules.map((entry) => entry.ruleId + " ×" + entry.count).join(", ") + ")"
: "";
return `Slop score: ${summary.scorePerKloc.toFixed(1)}/KLOC${detail}`;
}