From 7e2fecc03245379dbbdf343c46920e61c6cc2dfd Mon Sep 17 00:00:00 2001 From: Victor Giers Date: Sat, 24 May 2025 14:53:06 +0200 Subject: [PATCH] auto-git: [change] main.js --- main.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/main.js b/main.js index 65ef21b..4494941 100644 --- a/main.js +++ b/main.js @@ -202,6 +202,38 @@ async function getCommitsForLLM(folderPath, hashes) { return commits; } +async function getPrompt(folderPath, hashes) { + const commits = await getCommitsForLLM(folderPath, hashes); + + if (commits.length === 1) { + // Only one commit: Prompt LLM for a message just for this diff. + const diff = commits[0].diff; + return `You're a professional programmer who writes git commit messages all day. +Generate a concise git commit message for these changes: + + ${diff} + +-------------------------------------- + +Answer VERY BRIEFLY. Don't give any feedback on the code, just analyze what changed and write the git commit message. Keep it short! A commit message MUST NOT BE STRAIGHT TO THE POINT! +Also reply to my message, just give me the commit message.`; + } else if (commits.length > 1) { + // Multiple commits: Squash them, give all diffs as a big change. + const combinedDiffs = commits.map(c => c.diff).join('\n\n'); + return `You're a professional programmer who writes git commit messages all day. +Analyze the following code changes (from multiple commits). To squash them into a single commit I need a concise git commit message from you describing the changes in a single sentence. +Here are the combined diffs: + ${combinedDiffs} + +-------------------------------------- + +Even if this might seem like a lot of code, I need you to answer VERY BRIEFLY. A git commit message to be precise is what I need from you, to protocol these changes. +Don't give any feedback on the code! Just analyze what changed and write the git commit message. Keep it short! A commit message MUST NOT BE STRAIGHT TO THE POINT! +Don't reply to my message, just give me the commit message.`; + } else { + throw new Error('No commits found for LLM prompt.'); + } +} // 3. LLM Streaming Call