diff --git a/src/vs/workbench/contrib/void/browser/voidSCM.ts b/src/vs/workbench/contrib/void/browser/voidSCM.ts index 703febcd..ed8f6328 100644 --- a/src/vs/workbench/contrib/void/browser/voidSCM.ts +++ b/src/vs/workbench/contrib/void/browser/voidSCM.ts @@ -69,10 +69,15 @@ class GenerateCommitMessageService extends Disposable implements IGenerateCommit const requestId = this.setRequestId() try { const { path, repo } = this.gitRepoInfo() - const [stat, sampledDiffs] = await Promise.all([this.voidSCM.gitStat(path), this.voidSCM.gitSampledDiffs(path)]) + const [stat, sampledDiffs, branch, log] = await Promise.all([ + this.voidSCM.gitStat(path), + this.voidSCM.gitSampledDiffs(path), + this.voidSCM.gitBranch(path), + this.voidSCM.gitLog(path) + ]) this.checkIsCurrentRequest(requestId) const modelOptions = this.prepareModelOptions() - const prompt = this.preparePrompt(stat, sampledDiffs) + const prompt = this.preparePrompt(stat, sampledDiffs, branch, log) const { messages, separateSystemMessage } = this.prepareMessages(prompt, modelOptions) const commitMessage = await this.sendLLMMessage(messages, separateSystemMessage!, modelOptions) this.checkIsCurrentRequest(requestId) @@ -151,20 +156,29 @@ class GenerateCommitMessageService extends Disposable implements IGenerateCommit } } - private preparePrompt(stat: string, sampledDiffs: string) { + private preparePrompt(stat: string, sampledDiffs: string, branch: string, log: string) { const section1 = `Section 1 - Summary of Changes (git diff --stat):` const section2 = `Section 2 - Sampled File Diffs (Top changed files):` + const section3 = `Section 3 - Current Git Branch:` + const section4 = `Section 4 - Last 5 Commits (excluding merges):` return ` - Based on the following Git changes, write a clear, concise commit message that accurately summarizes the intent of the code changes. +Based on the following Git changes, write a clear, concise commit message that accurately summarizes the intent of the code changes. - ${section1} +${section1} - ${stat} +${stat} - ${section2} +${section2} - ${sampledDiffs} - `.trim() +${sampledDiffs} + +${section3} + +${branch} + +${section4} + +${log}`.trim() } private prepareMessages(prompt: string, modelOptions: ModelOptions) { diff --git a/src/vs/workbench/contrib/void/common/voidSCM.ts b/src/vs/workbench/contrib/void/common/voidSCM.ts index 3a4a5031..3571fb3d 100644 --- a/src/vs/workbench/contrib/void/common/voidSCM.ts +++ b/src/vs/workbench/contrib/void/common/voidSCM.ts @@ -14,6 +14,18 @@ export interface IVoidSCM { * @param path Path to the git repository */ gitSampledDiffs(path: string): Promise + /** + * Get the current git branch + * + * @param path Path to the git repository + */ + gitBranch(path: string): Promise + /** + * Get the last 5 commits excluding merges + * + * @param path Path to the git repository + */ + gitLog(path: string): Promise } export const IVoidSCM = createDecorator('voidSCMService') diff --git a/src/vs/workbench/contrib/void/electron-main/voidSCM.ts b/src/vs/workbench/contrib/void/electron-main/voidSCM.ts index c3261079..9f8d211e 100644 --- a/src/vs/workbench/contrib/void/electron-main/voidSCM.ts +++ b/src/vs/workbench/contrib/void/electron-main/voidSCM.ts @@ -53,6 +53,14 @@ export class VoidSCM implements IVoidSCM { const diffs = await Promise.all(topFiles.map(async ({ file }) => ({ file, diff: await getSampledDiff(file, path) }))) return diffs.map(({ file, diff }) => `==== ${file} ====\n${diff}`).join('\n\n') } + + gitBranch(path: string): Promise { + return git('git branch --show-current', path) + } + + gitLog(path: string): Promise { + return git('git log --pretty=format:"%h|%s|%ad" --date=short --no-merges -n 5', path) + } } registerSingleton(IVoidSCM, VoidSCM, InstantiationType.Delayed)