UNPKG

scai

Version:

> AI-powered CLI tool for commit messages **and** pull request reviews — using local models.

48 lines (43 loc) 1.89 kB
import { Config } from '../../config.js'; import { generate } from '../../lib/generate.js'; export const changelogModule = { name: 'changelogModule', description: 'Generates changelog entry based on Git diff', async run(input) { const model = Config.getModel(); const prompt = ` Using the Git diff below, return **only meaningful user-facing changes** as clean markdown bullet points. Analyze the intent of each change and summarize it in plain English — do not copy code or include explanations. ONLY return the bullet points! If no meaningful changes are present, return the text: "NO UPDATE". --- DIFF START --- ${input.content} --- DIFF END --- `.trim(); const response = await generate({ content: prompt }, model); // Check if we received a meaningful result or "NO UPDATE" const content = response?.content?.trim(); if (content === 'NO UPDATE') { console.log("⚠️ No meaningful updates found. Returning 'NO UPDATE'."); return { content: response.content, summary: 'NO UPDATE', suggestions: response?.suggestions ?? [], filepath: input.filepath, }; } // Split the content into lines const lines = content?.split('\n').map(line => line.trim()) ?? []; // Filter out non-bullet lines (now including the '•' symbol) const bulletLines = lines.filter(line => /^([*-+•]|\d+\.)\s/.test(line)); // Join the filtered lines into the final changelog entry const filtered = bulletLines.join('\n'); // Return the processed content and filtered changelog return { content: response.content, summary: filtered, suggestions: response?.suggestions ?? [], filepath: input.filepath, }; } };