Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d51ae3a574 | |||
| 0c2c35ad72 | |||
| 558b6a9953 | |||
| a7f07dbeef |
@@ -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
@@ -2,7 +2,7 @@
|
|||||||
"name": "ai-commit-ext",
|
"name": "ai-commit-ext",
|
||||||
"displayName": "AI Commit Ext",
|
"displayName": "AI Commit Ext",
|
||||||
"description": "Generate commit messages using OpenCode AI",
|
"description": "Generate commit messages using OpenCode AI",
|
||||||
"version": "1.1.0",
|
"version": "1.2.2",
|
||||||
"publisher": "local",
|
"publisher": "local",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.110.0"
|
"vscode": "^1.110.0"
|
||||||
|
|||||||
+12
-2
@@ -88,14 +88,24 @@ async function handleGenerateCommitMessage(): Promise<void> {
|
|||||||
return;
|
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(
|
const commitMessage = await vscode.window.withProgress(
|
||||||
{
|
{
|
||||||
location: vscode.ProgressLocation.Notification,
|
location: vscode.ProgressLocation.Notification,
|
||||||
cancellable: false,
|
cancellable: false,
|
||||||
title: "Generating commit message...",
|
title: userSuggestion ? "Improving commit message..." : "Generating commit message...",
|
||||||
},
|
},
|
||||||
async () => {
|
async () => {
|
||||||
return await generateCommitMessage();
|
return await generateCommitMessage({ userSuggestion: userSuggestion || undefined });
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
+28
-2
@@ -5,6 +5,7 @@ import { output } from "./extension";
|
|||||||
|
|
||||||
export interface GenerateOptions {
|
export interface GenerateOptions {
|
||||||
model?: string;
|
model?: string;
|
||||||
|
userSuggestion?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
let opencodeAvailableCache: boolean | null = null;
|
let opencodeAvailableCache: boolean | null = null;
|
||||||
@@ -47,12 +48,27 @@ export async function generateCommitMessage(
|
|||||||
const config = vscode.workspace.getConfiguration("aiCommitExt");
|
const config = vscode.workspace.getConfiguration("aiCommitExt");
|
||||||
const model = options.model || config.get<string>("model", "");
|
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:
|
Here are the git changes:
|
||||||
${diff}
|
${diff}
|
||||||
|
|
||||||
Generate a concise Conventional Commit message for these changes:`;
|
Generate a concise Conventional Commit message for these changes:`;
|
||||||
|
}
|
||||||
|
|
||||||
const log = `[${Date.now()}]\r\n${prompt}`;
|
const log = `[${Date.now()}]\r\n${prompt}`;
|
||||||
output.appendLine(log);
|
output.appendLine(log);
|
||||||
@@ -64,7 +80,7 @@ Generate a concise Conventional Commit message for these changes:`;
|
|||||||
"--format",
|
"--format",
|
||||||
"default",
|
"default",
|
||||||
"-m",
|
"-m",
|
||||||
"opencode/gpt-5-nano",
|
"opencode/deepseek-v4-flash-free",
|
||||||
"--variant",
|
"--variant",
|
||||||
"minimal",
|
"minimal",
|
||||||
];
|
];
|
||||||
@@ -77,6 +93,16 @@ Generate a concise Conventional Commit message for these changes:`;
|
|||||||
stdio: ["pipe", "pipe", "pipe"],
|
stdio: ["pipe", "pipe", "pipe"],
|
||||||
shell: false,
|
shell: false,
|
||||||
cwd: repoRoot || undefined,
|
cwd: repoRoot || undefined,
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
OPENCODE_SERVER_PASSWORD: undefined,
|
||||||
|
OPENCODE_SERVER_USERNAME: undefined,
|
||||||
|
OPENCODE_CLIENT: undefined,
|
||||||
|
OPENCODE_HOST: undefined,
|
||||||
|
OPENCODE_PORT: undefined,
|
||||||
|
OPENCODE_SKIP_START: undefined,
|
||||||
|
OPENCODE_BINARY: undefined,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let stdout = "";
|
let stdout = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user