1
0

auto-git:

[change] main.js
This commit is contained in:
2025-05-24 14:05:33 +02:00
parent 60147d16da
commit 5768b5f959

34
main.js
View File

@@ -204,22 +204,22 @@ async function getCommitsForLLM(folderPath, hashes) {
// 2. Prompt für LLM bauen // 2. Prompt für LLM bauen
async function generateLLMCommitMessages(folderPath, hashes) { async function generateLLMCommitMessages(folderPath, hashes) {
const commits = await getCommitsForLLM(folderPath, hashes); const commits = await getCommitsForLLM(folderPath, hashes);
const prompt = ` if(commits.length == 1){
Analyze the following git commits. For each commit, generate a concise commit message summarizing the actual change. const diff = commits[0].diff;
- ONLY output a JSON object mapping each commit hash to its new message. const prompt =
- Do NOT add any explanations, greetings, or extra text. `Generate a concise git commit message for these changes:
${diff}
Example Output: Don't give any feedback on the code, just analyze what changed and write the git commit message. Keep it short.`;
{ } else if (commits.length > 1) {
"1a2b3c4": "Fix bug in user registration", const prompt = `
"2b3c4d5": "Refactor login logic" Analyze the following code changes. We will squash them to a single commit and need a concise git commit message for that.
} Don't give any feedback on the code, just analyze what changed and write the git commit message. Keep it short.
Here are the commits (as JSON):
COMMITS (as JSON): ${JSON.stringify(commits, null, 2)}`; //actually we only need the diffs here.
return prompt;
${JSON.stringify(commits, null, 2)} } else {
`; //break, but this should never be reached
return prompt; }
} }
// 3. LLM Streaming Call // 3. LLM Streaming Call
@@ -338,7 +338,7 @@ async function runLLMCommitPipeline(folderPath, hashes) {
const prompt = await generateLLMCommitMessages(folderPath, hashes); const prompt = await generateLLMCommitMessages(folderPath, hashes);
// 2. LLM Call & Streaming Output für die Katze (optional) // 2. LLM Call & Streaming Output für die Katze (optional)
const llmOutput = await streamLLMCommitMessages(prompt, chunk => { /* Katze usw. */ }); const llmOutput = await streamLLMCommitMessages(prompt, chunk => { /* Katze usw. */ });
console.log('LLM Output:\n', llmOutput); // Nur ein einziges Mal //console.log('LLM Output:\n', llmOutput); // Nur ein einziges Mal
// 3. Robust parsen // 3. Robust parsen
const commitList = parseLLMCommitMessages(llmOutput); // [{commit, newMessage}] const commitList = parseLLMCommitMessages(llmOutput); // [{commit, newMessage}]
// 4. Hash->Message Mapping // 4. Hash->Message Mapping