ai-commit-report-generator-cli
Version:
An AI-powered CLI tool that generates weekly reports from your Git activity
84 lines (78 loc) • 3.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DailyReportAIGenerator = void 0;
const output_parsers_1 = require("@langchain/core/output_parsers");
const prompts_1 = require("@langchain/core/prompts");
const google_genai_1 = require("@langchain/google-genai");
const schemas_1 = require("./schemas");
const runnables_1 = require("@langchain/core/runnables");
class DailyReportAIGenerator {
constructor() {
this.parser = output_parsers_1.StructuredOutputParser.fromZodSchema(schemas_1.BulletPointsSchema);
this.prompt = new prompts_1.PromptTemplate({
template: `
You're a business report writer who specializes in making complex technical changes easy to understand for non-technical stakeholders. Your task is to create a clear, simple summary of the changes made.
Follow these steps:
1. Review the list of changes below:
{commits}
2. Create a bullet-point report that:
- Uses simple, everyday language
- Avoids technical terms and jargon
- Focuses on business value and user-facing improvements
- Explains changes in terms of what they mean for users/stakeholders
- Groups related changes together when possible
- Includes specific improvements and their benefits
3. Make sure each bullet point is:
- Written in plain English
- Easy to understand by someone with no technical background
- Focused on what was improved rather than how it was done
4. The number of bullet points should be equal to {numberOfCommits}
5. Follow this format:
{format_instructions}
`,
inputVariables: [
'commits',
'format_instructions',
'numberOfCommits'
]
});
this.llm = new google_genai_1.ChatGoogleGenerativeAI({
apiKey: process.env.GOOGLE_API_KEY,
modelName: "gemini-2.0-flash-exp",
});
}
generateReport(data) {
if (data.length === 0) {
throw new Error('No commits found');
}
const firstCommit = data[0].commit;
if (data.some(d => d.commit.date !== firstCommit.date)) {
throw new Error('Commits must be from the same day');
}
return this.buildChain().invoke({
numberOfCommits: data.length,
commits: data.map(d => `
- Commit: ${d.commit.hash}\n
**Date**:\n
${d.commit.date}\n
**Message**:\n
${d.commit.message}\n
**Summary**:\n
${d.summary.summary}\n
**Changes**\n
${d.summary.changes.map(f => `
- ${f}
`).join('\n')}
`).join('\n'),
format_instructions: this.parser.getFormatInstructions()
});
}
buildChain() {
return runnables_1.RunnableSequence.from([
this.prompt,
this.llm,
this.parser,
]);
}
}
exports.DailyReportAIGenerator = DailyReportAIGenerator;