UNPKG

marsdevs-git-workreport

Version:

🚀 Advanced Git Work Report Generator with AI-Powered Summaries - Generate intelligent daily work reports from Git commit history using Claude AI or OpenRouter. Perfect for DevOps teams, development companies, and client reporting with comprehensive stati

176 lines • 7.12 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.ReportGenerator = void 0; const fs = __importStar(require("fs")); const path = __importStar(require("path")); class ReportGenerator { /** * Generate report in the specified format */ generateReport(report, options = {}) { const format = options.format || 'text'; switch (format.toLowerCase()) { case 'json': return this.generateJsonReport(report); case 'markdown': return this.generateMarkdownReport(report, options); case 'text': default: return this.generateTextReport(report, options); } } /** * Generate JSON format report */ generateJsonReport(report) { return JSON.stringify(report, null, 2); } /** * Generate text format report */ generateTextReport(report, options) { const lines = []; // Header lines.push('='.repeat(80)); lines.push(`GIT WORK REPORT - ${report.date}`); lines.push('='.repeat(80)); lines.push(''); // Summary lines.push('SUMMARY:'); lines.push(` Date: ${report.date}`); lines.push(` Total Commits: ${report.totalCommits}`); lines.push(` Total Lines Changed: ${report.totalLinesChanged}`); lines.push(` Authors: ${report.authors.join(', ')}`); lines.push(''); // AI Summary lines.push('AI-GENERATED SUMMARY:'); if (report.totalCommits === 0) { lines.push(` ${report.aiSummary}`); } else if (!options.anthropicApiKey && !options.openrouterApiKey) { lines.push(` ${report.aiSummary}`); lines.push(` Note: No AI API key provided. For AI-powered summaries, use --anthropic-key YOUR_API_KEY or --openrouter-key YOUR_API_KEY`); } else { lines.push(` ${report.aiSummary}`); } lines.push(''); if (options.includeStats !== false && report.totalCommits > 0) { lines.push('STATISTICS:'); lines.push(` Insertions: ${report.totalInsertions} lines`); lines.push(` Deletions: ${report.totalDeletions} lines`); lines.push(` Net Changes: ${report.totalInsertions - report.totalDeletions} lines`); lines.push(` Average Commits per Author: ${report.authors.length > 0 ? (report.totalCommits / report.authors.length).toFixed(2) : '0.00'}`); lines.push(''); } if (report.totalCommits === 0) { lines.push('No commits found for the specified date.'); } lines.push('='.repeat(80)); lines.push(`Report generated on ${new Date().toLocaleString()}`); return lines.join('\n'); } /** * Generate markdown format report */ generateMarkdownReport(report, options) { const lines = []; // Header lines.push(`# Git Work Report - ${report.date}`); lines.push(''); lines.push(`**Generated:** ${new Date().toLocaleString()}`); lines.push(''); // Summary lines.push('## Summary'); lines.push(''); lines.push('| Metric | Value |'); lines.push('|--------|-------|'); lines.push(`| Date | ${report.date} |`); lines.push(`| Total Commits | ${report.totalCommits} |`); lines.push(`| Total Lines Changed | ${report.totalLinesChanged} |`); lines.push(`| Authors | ${report.authors.join(', ')} |`); lines.push(''); // AI Summary lines.push('## AI-Generated Summary'); lines.push(''); if (report.totalCommits === 0) { lines.push(`> ${report.aiSummary}`); } else if (!options.anthropicApiKey && !options.openrouterApiKey) { lines.push(`> ${report.aiSummary}`); lines.push(''); lines.push('> **Note:** No AI API key provided. For AI-powered summaries, use `--anthropic-key YOUR_API_KEY` or `--openrouter-key YOUR_API_KEY`'); } else { lines.push(`> ${report.aiSummary}`); } lines.push(''); if (options.includeStats !== false && report.totalCommits > 0) { lines.push('## Statistics'); lines.push(''); lines.push(`- **Insertions:** ${report.totalInsertions} lines`); lines.push(`- **Deletions:** ${report.totalDeletions} lines`); lines.push(`- **Net Changes:** ${report.totalInsertions - report.totalDeletions} lines`); lines.push(`- **Average Commits per Author:** ${report.authors.length > 0 ? (report.totalCommits / report.authors.length).toFixed(2) : '0.00'}`); lines.push(''); } if (report.totalCommits === 0) { lines.push('## No Commits Found'); lines.push(''); lines.push('No commits were found for the specified date.'); } return lines.join('\n'); } /** * Save report to file */ saveReport(content, outputPath, format) { if (!outputPath) { const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); const ext = format === 'json' ? 'json' : format === 'markdown' ? 'md' : 'txt'; outputPath = `work-report-${timestamp}.${ext}`; } // Ensure directory exists const dir = path.dirname(outputPath); if (dir !== '.' && !fs.existsSync(dir)) { fs.mkdirSync(dir, { recursive: true }); } fs.writeFileSync(outputPath, content, 'utf8'); return outputPath; } } exports.ReportGenerator = ReportGenerator; //# sourceMappingURL=report-generator.js.map