auto-git:
[change] main.js
This commit is contained in:
32
main.js
32
main.js
@@ -202,6 +202,38 @@ async function getCommitsForLLM(folderPath, hashes) {
|
|||||||
return commits;
|
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
|
// 3. LLM Streaming Call
|
||||||
|
|||||||
Reference in New Issue
Block a user