1 Commits

Author SHA1 Message Date
JustZoe101 a7f07dbeef feat(aiCommitExt): add user-suggested commit-message refinement 2026-04-15 12:01:40 +02:00
4 changed files with 52 additions and 4 deletions
+22
View File
@@ -0,0 +1,22 @@
# AGENTS.md
## Build & Run
- **Compile**: `npm run compile` (or `tsc -p ./`)
- **Watch**: `npm run watch`
- **Package extension**: `npm run build` → produces `.vsix` file
- **Test**: Press F5 to launch extension in debug mode
## Project Structure
- `src/extension.ts` - Extension entry point, registers `aiCommitExt.generate` command
- `src/opencodeService.ts` - Spawns `opencode run` CLI, parses output for commit message
- `src/gitService.ts` - Uses VS Code Git extension API to get diffs and repo root
## Key Details
- Output compiled to `out/` directory
- Extension activates only on command invocation (not on startup)
- OpenCode CLI is required on PATH; checked via `which opencode`
- Generated message written to SCM input box via `repository.inputBox.value`
- Timeout: 120 seconds for OpenCode response
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "ai-commit-ext",
"displayName": "AI Commit Ext",
"description": "Generate commit messages using OpenCode AI",
"version": "1.1.0",
"version": "1.2.0",
"publisher": "local",
"engines": {
"vscode": "^1.110.0"
+12 -2
View File
@@ -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
View File
@@ -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);