ai-commit-report-generator-cli
Version:
An AI-powered CLI tool that generates weekly reports from your Git activity
85 lines (84 loc) • 4.29 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.aiSummaryConsoleRenderer = exports.aiReportConsoleRenderer = exports.AISummaryConsoleRenderer = exports.AIReportConsoleRenderer = void 0;
const chalk_1 = __importDefault(require("chalk"));
const date_fns_1 = require("date-fns");
class AIReportConsoleRenderer {
renderReport(reports) {
reports.forEach((report, index) => {
if (index > 0) {
console.log('\n' + '='.repeat(80) + '\n');
}
// Print the date header
const date = new Date(report.date);
console.log(chalk_1.default.bold.blue(`📅 Daily Report Summary - ${(0, date_fns_1.format)(date, 'MMMM do, yyyy')}\n`));
// Print Bullet Points
report.bulletPoints.forEach(point => {
// Print short description as a header
console.log(chalk_1.default.yellow('• ' + point.short));
// Print long description indented
if (point.long !== point.short) {
console.log(chalk_1.default.dim(' ' + point.long));
}
console.log(); // Add spacing between points
});
});
}
}
exports.AIReportConsoleRenderer = AIReportConsoleRenderer;
class AISummaryConsoleRenderer {
renderSummary(summariesEntries) {
summariesEntries.forEach((entry, index) => {
if (index > 0) {
console.log('\n' + '─'.repeat(80) + '\n');
}
// Commit Header
console.log(chalk_1.default.bold.blue(`📝 Commit ${index + 1} of ${summariesEntries.length}`));
console.log(chalk_1.default.dim(`Hash: ${entry.commit.hash}`));
console.log(chalk_1.default.white(`Author: ${entry.commit.username}`));
console.log(chalk_1.default.white(`Date: ${(0, date_fns_1.format)(new Date(entry.commit.date), 'MMMM do, yyyy HH:mm:ss')}`));
console.log(chalk_1.default.yellow(`Message: ${entry.commit.message}\n`));
// Statistics Section
if (entry.statistics.length > 0) {
console.log(chalk_1.default.bold.cyan('📊 Changes Statistics:'));
entry.statistics.forEach(stat => {
console.log(chalk_1.default.dim(` ${stat.fileName}`));
const changes = [];
if (stat.numberOfInsertions > 0)
changes.push(chalk_1.default.green(`+${stat.numberOfInsertions}`));
if (stat.numberOfDeletions > 0)
changes.push(chalk_1.default.red(`-${stat.numberOfDeletions}`));
console.log(` ${changes.join(', ')} (${stat.totalChanges} total)`);
});
console.log();
}
// AI Summary Section
if (entry.summary) {
// Main Summary
console.log(chalk_1.default.bold.magenta('🤖 AI Analysis:'));
console.log(chalk_1.default.white(` ${entry.summary.summary}\n`));
// Changes Section
if (entry.summary.changes.length > 0) {
console.log(chalk_1.default.bold.yellow('📋 Detailed Changes:'));
entry.summary.changes.forEach(change => {
const typeColor = {
'feature': chalk_1.default.green,
'fix': chalk_1.default.yellow,
'breaking change': chalk_1.default.red,
'refactor': chalk_1.default.blue
}[change.type];
console.log(` ${typeColor(`[${change.type.toUpperCase()}]`)}`);
console.log(chalk_1.default.dim(` ${change.description}`));
});
console.log();
}
}
});
}
}
exports.AISummaryConsoleRenderer = AISummaryConsoleRenderer;
exports.aiReportConsoleRenderer = new AIReportConsoleRenderer();
exports.aiSummaryConsoleRenderer = new AISummaryConsoleRenderer();