feat(aiCommitExt): add user-suggested commit-message refinement
This commit is contained in:
+12
-2
@@ -88,14 +88,24 @@ async function handleGenerateCommitMessage(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
const userSuggestion = await vscode.window.showInputBox({
|
||||
prompt: "Suggest a commit message (optional)",
|
||||
placeHolder: "e.g., added login button",
|
||||
ignoreFocusOut: true,
|
||||
});
|
||||
|
||||
if (userSuggestion === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
const commitMessage = await vscode.window.withProgress(
|
||||
{
|
||||
location: vscode.ProgressLocation.Notification,
|
||||
cancellable: false,
|
||||
title: "Generating commit message...",
|
||||
title: userSuggestion ? "Improving commit message..." : "Generating commit message...",
|
||||
},
|
||||
async () => {
|
||||
return await generateCommitMessage();
|
||||
return await generateCommitMessage({ userSuggestion: userSuggestion || undefined });
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
+17
-1
@@ -5,6 +5,7 @@ import { output } from "./extension";
|
||||
|
||||
export interface GenerateOptions {
|
||||
model?: string;
|
||||
userSuggestion?: string;
|
||||
}
|
||||
|
||||
let opencodeAvailableCache: boolean | null = null;
|
||||
@@ -47,12 +48,27 @@ export async function generateCommitMessage(
|
||||
const config = vscode.workspace.getConfiguration("aiCommitExt");
|
||||
const model = options.model || config.get<string>("model", "");
|
||||
|
||||
const prompt = `${DEFAULT_PROMPT}
|
||||
let prompt: string;
|
||||
if (options.userSuggestion) {
|
||||
prompt = `The user suggested: "${options.userSuggestion}"
|
||||
|
||||
Improve this commit message to be concise and follow Conventional Commit format.
|
||||
Format: <type>(<scope>): <description>
|
||||
Max 72 characters for the subject line.
|
||||
Types: feat, fix, refactor, docs, style, test, chore, perf, ci, build, revert
|
||||
|
||||
Here are the git changes:
|
||||
${diff}
|
||||
|
||||
Only output the improved commit message, nothing else.`;
|
||||
} else {
|
||||
prompt = `${DEFAULT_PROMPT}
|
||||
|
||||
Here are the git changes:
|
||||
${diff}
|
||||
|
||||
Generate a concise Conventional Commit message for these changes:`;
|
||||
}
|
||||
|
||||
const log = `[${Date.now()}]\r\n${prompt}`;
|
||||
output.appendLine(log);
|
||||
|
||||
Reference in New Issue
Block a user