Skip to content

Commit 8fe8e61

Browse files
authoredAug 27, 2024
refactoring_v1 (di-sukharev#391)
1 parent 68c9ed3 commit 8fe8e61

30 files changed

+72651
-69274
lines changed
 

‎.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ uncaughtExceptions.log
1010
.vscode
1111
src/*.json
1212
.idea
13-
test.ts
13+
test.ts
14+
notes.md

‎README.md

+29-19
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div>
33
<img src=".github/logo-grad.svg" alt="OpenCommit logo"/>
44
<h1 align="center">OpenCommit</h1>
5-
<h4 align="center">Follow the bird <a href="https://twitter.com/_sukharev_"><img src="https://img.shields.io/twitter/follow/_sukharev_?style=flat&label=_sukharev_&logo=twitter&color=0bf&logoColor=fff" align="center"></a>
5+
<h4 align="center">Author <a href="https://twitter.com/_sukharev_"><img src="https://img.shields.io/twitter/follow/_sukharev_?style=flat&label=_sukharev_&logo=twitter&color=0bf&logoColor=fff" align="center"></a>
66
</div>
77
<h2>Auto-generate meaningful commits in a second</h2>
88
<p>Killing lame commits with AI 🤯🔫</p>
@@ -16,7 +16,7 @@
1616
<img src=".github/opencommit-example.png" alt="OpenCommit example"/>
1717
</div>
1818

19-
All the commits in this repo are authored by OpenCommit — look at [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emojis and long commit descriptions are configurable.
19+
All the commits in this repo are authored by OpenCommit — look at [the commits](https://github.com/di-sukharev/opencommit/commit/eae7618d575ee8d2e9fff5de56da79d40c4bc5fc) to see how OpenCommit works. Emojis and long commit descriptions are configurable, basically everything is.
2020

2121
## Setup OpenCommit as a CLI tool
2222

@@ -58,6 +58,8 @@ git add <files...>
5858
oco
5959
```
6060

61+
Running `git add` is optional, `oco` will do it for you.
62+
6163
### Running locally with Ollama
6264

6365
You can also run it with local model through ollama:
@@ -68,20 +70,21 @@ You can also run it with local model through ollama:
6870

6971
```sh
7072
git add <files...>
71-
OCO_AI_PROVIDER='ollama' opencommit
73+
oco config set OCO_AI_PROVIDER='ollama'
7274
```
7375

74-
If you want to use a model other than mistral, you can do so by setting the `OCO_AI_PROVIDER` environment variable as follows:
76+
If you want to use a model other than mistral (default), you can do so by setting the `OCO_AI_PROVIDER` environment variable as follows:
7577

7678
```sh
77-
OCO_AI_PROVIDER='ollama/llama3:8b' opencommit
79+
oco config set OCO_AI_PROVIDER='ollama/llama3:8b'
7880
```
7981

80-
if you have ollama that is set up in docker/ on another machine with GPUs (not locally), you can change the default endpoint url.
82+
If you have ollama that is set up in docker/ on another machine with GPUs (not locally), you can change the default endpoint url.
83+
8184
You can do so by setting the `OCO_OLLAMA_API_URL` environment variable as follows:
8285

8386
```sh
84-
OCO_OLLAMA_API_URL='http://192.168.1.10:11434/api/chat' opencommit
87+
oco config set OCO_OLLAMA_API_URL='http://192.168.1.10:11434/api/chat'
8588
```
8689

8790
where 192.168.1.10 is example of endpoint URL, where you have ollama set up.
@@ -95,6 +98,7 @@ There are multiple optional flags that can be used with the `oco` command:
9598
Link to the GitMoji specification: https://gitmoji.dev/
9699

97100
This flag can only be used if the `OCO_EMOJI` configuration item is set to `true`. This flag allows users to use all emojis in the GitMoji specification, By default, the GitMoji full specification is set to `false`, which only includes 10 emojis (🐛✨📝🚀✅♻️⬆️🔧🌐💡).
101+
98102
This is due to limit the number of tokens sent in each request. However, if you would like to use the full GitMoji specification, you can use the `--fgm` flag.
99103

100104
```
@@ -116,28 +120,32 @@ oco --yes
116120
Create a `.env` file and add OpenCommit config variables there like this:
117121

118122
```env
123+
...
119124
OCO_OPENAI_API_KEY=<your OpenAI API token>
120125
OCO_TOKENS_MAX_INPUT=<max model token limit (default: 4096)>
121126
OCO_TOKENS_MAX_OUTPUT=<max response tokens (default: 500)>
122127
OCO_OPENAI_BASE_PATH=<may be used to set proxy path to OpenAI api>
123128
OCO_DESCRIPTION=<postface a message with ~3 sentences description of the changes>
124129
OCO_EMOJI=<boolean, add GitMoji>
125-
OCO_MODEL=<either 'gpt-4o', 'gpt-4', 'gpt-4-turbo', 'gpt-3.5-turbo' (default), 'gpt-3.5-turbo-0125', 'gpt-4-1106-preview', 'gpt-4-turbo-preview' or 'gpt-4-0125-preview'>
130+
OCO_MODEL=<either 'gpt-4o', 'gpt-4', 'gpt-4-turbo', 'gpt-3.5-turbo' (default), 'gpt-3.5-turbo-0125', 'gpt-4-1106-preview', 'gpt-4-turbo-preview' or 'gpt-4-0125-preview' or any string basically, but it should be a valid model name>
126131
OCO_LANGUAGE=<locale, scroll to the bottom to see options>
127132
OCO_MESSAGE_TEMPLATE_PLACEHOLDER=<message template placeholder, default: '$msg'>
128133
OCO_PROMPT_MODULE=<either conventional-commit or @commitlint, default: conventional-commit>
129134
OCO_ONE_LINE_COMMIT=<one line commit message, default: false>
130-
OCO_AI_PROVIDER=<anthropic, azure, ollama or ollama/model default ollama model: mistral>
135+
OCO_AI_PROVIDER=<openai (default), anthropic, azure, ollama or ollama/model>
136+
...
131137
```
132138

139+
This are not all the config options, but you get the point.
140+
133141
### Global config for all repos
134142

135143
Local config still has more priority than Global config, but you may set `OCO_MODEL` and `OCO_LOCALE` globally and set local configs for `OCO_EMOJI` and `OCO_DESCRIPTION` per repo which is more convenient.
136144

137145
Simply set any of the variables above like this:
138146

139147
```sh
140-
oco config set OCO_MODEL=gpt-4o
148+
oco config set OCO_MODEL=gpt-4o-mini
141149
```
142150

143151
Configure [GitMoji](https://gitmoji.dev/) to preface a message.
@@ -152,20 +160,22 @@ To remove preface emojis:
152160
oco config set OCO_EMOJI=false
153161
```
154162

163+
Other config options are behaving the same.
164+
155165
### Switch to GPT-4 or other models
156166

157-
By default, OpenCommit uses `gpt-4o` model.
167+
By default, OpenCommit uses `gpt-4o-mini` model.
158168

159-
You may switch to GPT-4 which performs better, but costs ~x15 times more 🤠
169+
You may switch to gpt-4o which performs better, but costs more 🤠
160170

161171
```sh
162-
oco config set OCO_MODEL=gpt-4
172+
oco config set OCO_MODEL=gpt-4o
163173
```
164174

165175
or for as a cheaper option:
166176

167177
```sh
168-
oco config set OCO_MODEL=gpt-4o-mini
178+
oco config set OCO_MODEL=gpt-3.5-turbo
169179
```
170180

171181
### Switch to Azure OpenAI
@@ -178,7 +188,7 @@ You could switch to [Azure OpenAI Service](https://learn.microsoft.com/azure/cog
178188
opencommit config set OCO_AI_PROVIDER=azure
179189
```
180190

181-
Of course need to set 'OPENAI_API_KEY'. And also need to set the
191+
Of course need to set 'OCO_OPENAI_API_KEY'. And also need to set the
182192
'OPENAI_BASE_PATH' for the endpoint and set the deployment name to
183193
'model'.
184194

@@ -201,9 +211,9 @@ oco config set OCO_LANGUAGE=française
201211
The default language setting is **English**
202212
All available languages are currently listed in the [i18n](https://github.com/di-sukharev/opencommit/tree/master/src/i18n) folder
203213

204-
### Push to git
214+
### Push to git (gonna be deprecated)
205215

206-
Pushing to git is on by default but if you would like to turn it off just use:
216+
A prompt to ushing to git is on by default but if you would like to turn it off just use:
207217

208218
```sh
209219
oco config set OCO_GITPUSH=false
@@ -291,7 +301,7 @@ In our codebase, the implementation of this feature can be found in the followin
291301
292302
```javascript
293303
commitMessage = messageTemplate.replace(
294-
config?.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
304+
config.OCO_MESSAGE_TEMPLATE_PLACEHOLDER,
295305
commitMessage
296306
);
297307
```
@@ -348,7 +358,7 @@ Or follow the process of your IDE Source Control feature, when it calls `git com
348358
349359
OpenCommit is now available as a GitHub Action which automatically improves all new commits messages when you push to remote!
350360
351-
This is great if you want to make sure all of the commits in all of your repository branches are meaningful and not lame like `fix1` or `done2`.
361+
This is great if you want to make sure all commits in all of your repository branches are meaningful and not lame like `fix1` or `done2`.
352362
353363
Create a file `.github/workflows/opencommit.yml` with the contents below:
354364

‎example.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)
Failed to load comments.