git-aicommit 2.0.2 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example CHANGED
@@ -1,2 +1 @@
1
1
  OPENAI_API_KEY=
2
- GIT_AI_COMMIT_CONFIG_NAME=.git-ai-commit-config.js
package/README.md CHANGED
@@ -14,11 +14,57 @@ npm install -g git-aicommit
14
14
 
15
15
  ## Configuration
16
16
 
17
- This cli tool uses configuration file located where `GIT_AI_COMMIT_CONFIG_NAME` points at,
18
- defaults to `~/.git-ai-commit-config.js`.
17
+ This cli tool uses [standard rc files](https://www.npmjs.com/package/rc#standards):
18
+
19
+ - local `.git-aicommitrc`
20
+ - `$HOME/.git-aicommitrc`
21
+ - `$HOME/.git-aicommit/config`
22
+ - `$HOME/.config/git-aicommit`
23
+ - `$HOME/.config/git-aicommit/config`
24
+ - `/etc/git-aicommitrc`
25
+ - `/etc/git-aicommit/config`
19
26
 
20
27
  Or [default config](config.js) is used if no config file is found.
21
28
 
29
+ To override default config, create a config file and export an object with the following properties:
30
+
31
+ ```bash
32
+ touch $HOME/.git-aicommitrc
33
+ ```
34
+
35
+ ```js
36
+ // $HOME/.git-aicommitrc
37
+ module.exports = {
38
+ openAiKey: process.env.OPENAI_API_KEY,
39
+ addAllChangesBeforeCommit: true,
40
+ autocommit: true,
41
+ openCommitTextEditor: false,
42
+ promptBeforeDiff: 'Read the following git diff for a multiple files:',
43
+ promptAfterDiff: 'Generate 1 to 3 paragraphs to explain this diff to a human without mentioning changes themselves:',
44
+ excludeFromDiff: [
45
+ '*.lock'
46
+ ],
47
+ diffFilter: 'ACMRTUXB',
48
+ completionPromptParams: {
49
+ model: "text-davinci-002",
50
+ max_tokens: 500,
51
+ temperature: 0.2,
52
+ top_p: 1,
53
+ presence_penalty: 0,
54
+ frequency_penalty: 0,
55
+ best_of: 1,
56
+ n: 1,
57
+ stream: false,
58
+ stop: ["\n\n\n"],
59
+ }
60
+ }
61
+ ```
62
+
63
+ ### Command line arguments
64
+
65
+ ```bash
66
+ git-aicommit --openAiKey="sk-..." --completionPromptParams.temperature=0.3 --no-autocommit
67
+ ```
22
68
  ## Usage
23
69
 
24
70
  ```bash
package/autocommit.js CHANGED
@@ -3,12 +3,9 @@
3
3
  require('dotenv').config();
4
4
  const {Configuration, OpenAIApi} = require("openai");
5
5
  const {execSync, spawn} = require("child_process");
6
+ const rc = require('rc');
6
7
 
7
- const os = require('os');
8
- const fs = require('fs');
9
-
10
- const configFilename = process.env.GIT_AI_COMMIT_CONFIG_NAME || '.git-ai-commit-config.js';
11
- const configPath = os.homedir() + '/' + configFilename;
8
+ const defaultConfig = require('./config.js');
12
9
 
13
10
  // if (!fs.existsSync(configPath)) {
14
11
  // TODO: param to create default config file
@@ -18,7 +15,7 @@ const configPath = os.homedir() + '/' + configFilename;
18
15
  // console.log(`Created default config file at ${configPath}`);
19
16
  // }
20
17
 
21
- const config = !fs.existsSync(configPath) ? require('./config.js') : require(configPath);
18
+ const config = rc('git-aicommit', defaultConfig);
22
19
 
23
20
  try {
24
21
  execSync(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-aicommit",
3
- "version": "2.0.2",
3
+ "version": "3.0.0",
4
4
  "description": "Generates auto commit messages with OpenAI GPT3 model",
5
5
  "main": "autocommit.js",
6
6
  "repository": "https://github.com/shanginn/autocommit",
@@ -8,7 +8,8 @@
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
10
  "dotenv": "^16.0.2",
11
- "openai": "^3.0.0"
11
+ "openai": "^3.0.0",
12
+ "rc": "1.2.8"
12
13
  },
13
14
  "preferGlobal": true,
14
15
  "bin": {