Skip to content

Commit 2b2ff15

Browse files
committed
docs: update 2 files and create 1 file
1 parent 42eaaad commit 2b2ff15

3 files changed

Lines changed: 38 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ This extensions adds a button to the Git extension sidebar - clicking it sends a
88

99
## Note
1010

11-
This extension is not available in the extensions library. You can build and install it locally though.
11+
- This extension is not available in the extensions library. You can build and install it locally though.
12+
- This was developed with Cursor quickly, the code and quality has not been verified.
1213

1314
## Benefits
1415

docs/development/about.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# About
2+
3+
## Overview
4+
5+
This extension adds a command and SCM title-bar action to generate a Git commit message using a local LLM (OpenAI-compatible API such as Ollama). It gathers a unified Git diff, prompts the model to produce a conventional commit-style message, and places the result in the Source Control input box.
6+
7+
## Libraries and APIs
8+
9+
- **VS Code**: Uses `vscode` to register the command, show progress and notifications, access the Git extension (`vscode.git`), and write to the SCM input box or clipboard.
10+
- **Node.js stdlib**: Uses `child_process.exec` (promisified) to run `git` as a fallback for diffs.
11+
- **HTTP**: Uses global `fetch` in the VS Code runtime to call an OpenAI-compatible chat completions endpoint.
12+
13+
## Getting the Git diff
14+
15+
- **Primary path (Git API)**: Retrieves the first repository from `vscode.git` and tries `repo.diffWithHEAD()`; if unavailable, tries `repo.diffIndexWithHEAD()`.
16+
- **Fallback (CLI)**: If the API path fails or doesn’t yield a string, runs `git diff --staged` in the repository root using `exec`.
17+
- **Validation**: If the resulting diff is empty, the command errors and prompts you to stage changes.
18+
19+
## Calling the LLM
20+
21+
- **Endpoint and model**: Configured via Settings → `llmCommitMsg.endpoint` (default `http://localhost:11434/v1`) and `llmCommitMsg.model` (default `gemma3`).
22+
- **Prompts**: Sends a system prompt to guide style and a user prompt embedding the unified diff in a fenced `diff` block; truncates very large diffs to keep requests reasonable.
23+
- **Request**: POSTs to `<endpoint>/chat/completions` with `stream: false`, then reads `choices[0].message.content` from the response.
24+
- **Cleanup**: Strips outer triple-backtick fences if present to return plain text.
25+
26+
## Applying the result in VS Code
27+
28+
- If available, writes the generated message to `repo.inputBox.value` so it appears in the SCM view.
29+
- If not, copies to the clipboard and shows a notification.
30+
- The command runs under a progress notification and surfaces success/error messages.
31+
32+
## Configuration
33+
34+
- **llmCommitMsg.endpoint**: Base URL of the OpenAI-compatible API (e.g., Ollama). Default: `http://localhost:11434/v1`.
35+
- **llmCommitMsg.model**: Model name used for generation. Default: `gemma3`.

docs/usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Generate a commit message from your staged changes.
44

55
## Steps
66

7-
1. Stage the changes you want included in the message.
7+
1. **Stage** the changes you want included in the message.
88
1. Open the Source Control view in VS Code.
99
1. Click the `Generate Commit Message (LLM)` action in the SCM title bar, or run the command from the Command Palette.
1010
1. The extension fills the commit message input. If it cannot, it copies the message to the clipboard and shows a notification.

0 commit comments

Comments
 (0)