UNPKG

scai

Version:

> **AI-powered CLI for local code analysis, commit message suggestions, and natural-language queries.** 100% local, private, GDPR-friendly, made in Denmark/EU with ❤️.

45 lines (40 loc) 1.67 kB
// src/pipeline/modules/changeLogModule.ts import { Config } from '../../config.js'; import { generate } from '../../lib/generate.js'; export const changelogModule = { name: 'changelogModule', description: 'Generates a changelog entry based on Git diff', async run(input) { const model = Config.getModel(); const diffContent = typeof input.content === 'string' ? input.content : ''; 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 --- ${diffContent} --- DIFF END --- `.trim(); const response = await generate({ query: input.query, content: prompt, }); const rawContent = typeof response?.data === 'string' ? response.data.trim() : ''; if (!rawContent || rawContent === 'NO UPDATE') { console.log("⚠️ No meaningful updates found. Returning 'NO UPDATE'."); return { query: input.query, data: 'NO UPDATE', }; } // Split into lines and keep only bullet points const lines = rawContent.split('\n').map(line => line.trim()); const bulletLines = lines.filter(line => /^([*-+•]|\d+\.)\s/.test(line)); const filtered = bulletLines.join('\n'); return { query: input.query, data: filtered || 'NO UPDATE', }; } };