Skip to content

Commit 3768828

Browse files
committed
docs(readme): update README for Ollama integration
- Added dual provider support with a new `diffCommit.provider` configuration option - Implemented Ollama integration with model selection and server configuration - Added new commands for Ollama setup and model switching: - `DiffCommit: Configure Ollama Model` - `DiffCommit: Change Ollama Model` - Added new configuration settings: - `diffCommit.ollamaHostname` for server connection - `diffCommit.ollamaModel` for model selection - Updated documentation with Ollama requirements and setup instructions - Enhanced error handling for Ollama-specific scenarios - Updated workflow documentation to include provider selection
1 parent 68d9ad8 commit 3768828

File tree

1 file changed

+118
-28
lines changed

1 file changed

+118
-28
lines changed

README.md

Lines changed: 118 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Diff Commit
22

3-
Diff Commit is a VSCode extension that helps you generate commit messages following the conventional commits specification using Anthropic's AI models like Claude 3.5 Sonnet. Commit messages are generated using the diff of staged changes and entered directly into the SCM message input or previewed in a new editor window.
3+
Diff Commit is a VSCode extension that helps you generate commit messages following the conventional commits specification using AI models. Choose between Anthropic's cloud-based models like Claude 4 Sonnet or local Ollama models for offline usage. Commit messages are generated using the diff of staged changes and entered directly into the SCM message input or previewed in a new editor window.
44

55
The generated commit messages are compatible with [googleapis/release-please](https://github.com/googleapis/release-please) and other tools that use conventional commits.
66

@@ -19,10 +19,15 @@ The generated commit messages are compatible with [googleapis/release-please](ht
1919
- [`DiffCommit: Preview Commit Message`](#diffcommit-preview-commit-message)
2020
- [`DiffCommit: Update API Key`](#diffcommit-update-api-key)
2121
- [`DiffCommit: Delete API Key`](#diffcommit-delete-api-key)
22+
- [`DiffCommit: Configure Ollama Model`](#diffcommit-configure-ollama-model)
23+
- [`DiffCommit: Change Ollama Model`](#diffcommit-change-ollama-model)
2224
- [Configuration](#configuration)
25+
- [`diffCommit.provider`](#diffcommitprovider)
2326
- [`diffCommit.allowedTypes`](#diffcommitallowedtypes)
2427
- [`diffCommit.customInstructions`](#diffcommitcustominstructions)
2528
- [`diffCommit.model`](#diffcommitmodel)
29+
- [`diffCommit.ollamaHostname`](#diffcommitollamahostname)
30+
- [`diffCommit.ollamaModel`](#diffcommitollamamodel)
2631
- [`diffCommit.maxTokens`](#diffcommitmaxtokens)
2732
- [`diffCommit.temperature`](#diffcommittemperature)
2833
- [Error Handling](#error-handling)
@@ -33,7 +38,10 @@ The generated commit messages are compatible with [googleapis/release-please](ht
3338

3439
## Features
3540

36-
- Generate commit messages based on the diff of staged changes using Anthropic's AI models like Claude 4 Sonnet
41+
- **Dual Provider Support**: Choose between Anthropic's cloud-based models or local Ollama models for offline usage
42+
- Generate commit messages based on the diff of staged changes using AI models
43+
- **Anthropic Integration**: Access to Claude 4 Sonnet and other powerful cloud models with an API key
44+
- **Ollama Integration**: Use local models for complete offline functionality and privacy
3745
- Preview and edit generated commit messages before applying the commit
3846
- Uses markdown formatting for commit messages
3947
- Implements conventional commit format with type, scope, subject, and body
@@ -42,10 +50,16 @@ The generated commit messages are compatible with [googleapis/release-please](ht
4250

4351
## Requirements
4452

45-
- VSCode 1.9.4 or higher
53+
- VSCode 1.93.1 or higher
4654
- Git installed and configured in your workspace
55+
56+
**For Anthropic Provider:**
4757
- An [Anthropic API key](https://console.anthropic.com/settings/keys)
4858

59+
**For Ollama Provider:**
60+
- [Ollama](https://ollama.com/) installed and running locally
61+
- At least one model pulled (eg `ollama pull llama3.2` or `ollama pull mistral`)
62+
4963
## Installation
5064

5165
Install the extension directly from the [Visual Studio Code Marketplace](https://marketplace.visualstudio.com/items?itemName=tpsTech.diff-commit) or:
@@ -56,14 +70,17 @@ Install the extension directly from the [Visual Studio Code Marketplace](https:/
5670

5771
## Typical Workflow
5872

59-
1. Stage the changes that you wish to commit as normal
60-
2. Run the command: "DiffCommit: Generate Commit Message" (<kbd>Cmd</kbd>/<kbd>Ctrl</kbd> + <kbd>K</kbd> → <kbd>Cmd</kbd>/<kbd>Ctrl</kbd> + <kbd>G</kbd>)
61-
3. Monitor progress in the notification area as the extension:
73+
1. **Choose your provider** (first-time setup):
74+
- For **Anthropic**: Set up your API key using "DiffCommit: Update stored API Key"
75+
- For **Ollama**: Configure your local model using "DiffCommit: Configure Ollama Model"
76+
2. Stage the changes that you wish to commit as normal
77+
3. Run the command: "DiffCommit: Generate Commit Message" (<kbd>Cmd</kbd>/<kbd>Ctrl</kbd> + <kbd>K</kbd> → <kbd>Cmd</kbd>/<kbd>Ctrl</kbd> + <kbd>G</kbd>)
78+
4. Monitor progress in the notification area as the extension:
6279
- Retrieves the git diff
63-
- Validates your API key
80+
- Validates your configuration (API key or Ollama connection)
6481
- Generates the commit message
65-
4. Review the generated message in the Source Control message input
66-
5. Click 'Commit' to commit the changes with the generated message
82+
5. Review the generated message in the Source Control message input
83+
6. Click 'Commit' to commit the changes with the generated message
6784

6885
## Commands
6986

@@ -111,10 +128,50 @@ This will delete the stored API key from your system and prevent DiffCommit from
111128

112129
![Demo video of Diff Commit: Delete API Key](screenshots/diff-commit-cmd-delete.gif)
113130

131+
### `DiffCommit: Configure Ollama Model`
132+
133+
This command allows you to set up Ollama as your provider for the first time or switch from Anthropic to Ollama. It will:
134+
135+
1. Prompt you to enter the Ollama server hostname (defaults to `http://localhost:11434`)
136+
2. Test the connection to your Ollama server
137+
3. Display available models for selection
138+
4. Set the provider to Ollama and save your configuration
139+
140+
> [!NOTE]
141+
> Before using this command, ensure that:
142+
> - Ollama is installed and running on your system
143+
> - You have pulled at least one model (eg `ollama pull llama3.2`)
144+
145+
### `DiffCommit: Change Ollama Model`
146+
147+
This command allows you to change your currently selected Ollama model without changing the hostname. It will:
148+
149+
1. Connect to your configured Ollama server
150+
2. Display available models for selection
151+
3. Update your model configuration
152+
153+
> [!TIP]
154+
> Use this command when you want to try a different local model or have pulled new models to your Ollama installation.
155+
114156
## Configuration
115157

116158
DiffCommit provides the following settings to customise its behavior.
117159

160+
### `diffCommit.provider`
161+
162+
Choose the AI provider for generating commit messages. You can use either Anthropic's cloud-based models or local Ollama models.
163+
164+
| **Type** | **Options** | **Default Value** |
165+
| :------- | :---------- | :---------------- |
166+
| enum | "anthropic" | "anthropic" |
167+
| | "ollama" | |
168+
169+
- **"anthropic"**: Use Anthropic's Claude models (requires API key and internet connection)
170+
- **"ollama"**: Use local Ollama models (requires Ollama server to be running, works offline)
171+
172+
> [!TIP]
173+
> Use **Anthropic** for the most advanced language understanding and consistency, or **Ollama** for complete privacy and offline functionality.
174+
118175
### `diffCommit.allowedTypes`
119176

120177
A list of allowed commit types. If provided, this replaces the default options. You need to ensure all required commit types are included in the list.
@@ -136,7 +193,7 @@ Add additional custom instructions to the commit generation prompt. Useful for p
136193

137194
### `diffCommit.model`
138195

139-
The Anthropic AI model to use for generating commit messages.
196+
The Anthropic AI model to use for generating commit messages. This setting is only used when the provider is set to "anthropic".
140197

141198
| **Type** | **Options** | **Default Value** |
142199
| :------- | :------------------------- | :------------------ |
@@ -147,6 +204,31 @@ The Anthropic AI model to use for generating commit messages.
147204
| | "claude-opus-4-0" | |
148205
| | "claude-3-opus-latest" | |
149206

207+
### `diffCommit.ollamaHostname`
208+
209+
The URL of the local Ollama server. This setting is only used when the provider is set to "ollama".
210+
211+
| **Type** | **Description** | **Default Value** |
212+
| :------- | :--------------------------------------------------- | :----------------------- |
213+
| string | The hostname URL where your Ollama server is running | "http://localhost:11434" |
214+
215+
> [!NOTE]
216+
> Most users won't need to change this unless running Ollama on a different port or remote server.
217+
218+
### `diffCommit.ollamaModel`
219+
220+
The Ollama model to use for generating commit messages. This setting is only used when the provider is set to "ollama".
221+
222+
| **Type** | **Description** | **Default Value** |
223+
| :------- | :---------------------------------------------------------------------- | :---------------- |
224+
| string | The name of the Ollama model (e.g., "llama3.2", "mistral", "codellama") | "" |
225+
226+
> [!TIP]
227+
> Use the "DiffCommit: Configure Ollama Model" command to easily set this up. Popular models for code tasks include:
228+
> - **llama3.2**: General-purpose model with good reasoning
229+
> - **mistral**: Fast and efficient for most tasks
230+
> - **codellama**: Specialised for code-related tasks
231+
150232
### `diffCommit.maxTokens`
151233

152234
Maximum number of tokens to generate in the response. Higher values allow for longer commit messages but use more API tokens.
@@ -172,24 +254,32 @@ Controls randomness in the response. Lower values (like 0.3) produce more focuse
172254

173255
Diff Commit provides clear feedback for various scenarios to help troubleshoot issues. Here are the common messages you might encounter:
174256

175-
| | **Error** | **Description** |
176-
| :----------------------- | :--------------------------------------------------------------- | :------------------------------------------------------------ |
177-
| **Git Related** | Git extension not found in VSCode | VSCode's Git extension is not installed or enabled |
178-
| | No Git repository found in the current workspace | The current workspace is not a Git repository |
179-
| | No workspace folder found | No workspace is open in VSCode |
180-
| | No changes detected | No staged changes found to generate a commit message for |
181-
| **API Key Related** | API key is missing or not provided | No API key has been set |
182-
| | Invalid API key format (should start with sk-ant-api) | The provided API key doesn't match the expected format |
183-
| | Failed to access or update secure storage | Unable to store or retrieve the API key from secure storage |
184-
| **Anthropic API Errors** | Bad Request: Review your prompt and try again | Invalid request to the Anthropic API (400) |
185-
| | Unauthorized: Invalid API key, update your API key and try again | The API key is invalid or expired (401) |
186-
| | Forbidden: Permission denied, update your API key and try again | The API key doesn't have permission for this operation (403) |
187-
| | Rate Limited: Too many requests, try again later | You've exceeded your API rate limit (429) |
188-
| | Server Error: Anthropic API server error | An error occurred on Anthropic's servers (500) |
189-
| | Server Error: Anthropic Server Overloaded | The Anthropic API server is overloaded (529) |
190-
| **Other Errors** | Failed to write commit message to Source Control | Unable to update the SCM input box with the generated message |
191-
| | Failed to open commit message preview | Unable to open the preview editor |
192-
| | No commit message was generated by the API | The API response didn't contain a valid commit message |
257+
| | **Error** | **Description** |
258+
| :------------------------ | :------------------------------------------------------------------------------- | :------------------------------------------------------------ |
259+
| **Git Related** | Git extension not found in VSCode | VSCode's Git extension is not installed or enabled |
260+
| | No Git repository found in the current workspace | The current workspace is not a Git repository |
261+
| | No workspace folder found | No workspace is open in VSCode |
262+
| | No changes detected | No staged changes found to generate a commit message for |
263+
| **API Key Related** | API key is missing or not provided | No API key has been set for Anthropic provider |
264+
| | Invalid API key format (should start with sk-ant-api) | The provided API key doesn't match the expected format |
265+
| | Failed to access or update secure storage | Unable to store or retrieve the API key from secure storage |
266+
| **Anthropic API Errors** | Bad Request: Review your prompt and try again | Invalid request to the Anthropic API (400) |
267+
| | Unauthorized: Invalid API key, update your API key and try again | The API key is invalid or expired (401) |
268+
| | Forbidden: Permission denied, update your API key and try again | The API key doesn't have permission for this operation (403) |
269+
| | Rate Limited: Too many requests, try again later | You've exceeded your API rate limit (429) |
270+
| | Server Error: Anthropic API server error | An error occurred on Anthropic's servers (500) |
271+
| | Server Error: Anthropic Server Overloaded | The Anthropic API server is overloaded (529) |
272+
| **Ollama Related Errors** | Unable to connect to Ollama server | Ollama server is not running or not accessible |
273+
| | Ollama server not found | Invalid hostname or Ollama is not installed |
274+
| | No Ollama model selected. Please configure an Ollama model first | No Ollama model has been configured for the extension |
275+
| | Ollama model not specified | No Ollama model has been configured or selected |
276+
| | Model '[model-name]' not found. Please check if the model is available in Ollama | The specified model is not available in Ollama |
277+
| | No models found on the Ollama server | No models have been pulled to the Ollama installation |
278+
| | Invalid hostname URL | The provided Ollama hostname is not a valid URL |
279+
| | Ollama server error | An error occurred on the Ollama server (500) |
280+
| **Other Errors** | Failed to write commit message to Source Control | Unable to update the SCM input box with the generated message |
281+
| | Failed to open commit message preview | Unable to open the preview editor |
282+
| | No commit message was generated by the API | The API response didn't contain a valid commit message |
193283

194284
Each error includes specific guidance on how to resolve the issue. For persistent problems, please check your configuration and if appropriate, raise an issue on [GitHub](https://github.com/tsdevau/diff-commit/issues).
195285

0 commit comments

Comments
 (0)