git-coco 0.7.5 → 0.8.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/README.md +41 -80
- package/dist/index.d.ts +119 -63
- package/dist/index.esm.mjs +258 -191
- package/dist/index.js +258 -191
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -6,123 +6,84 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/git-coco)
|
|
7
7
|
[](https://www.npmjs.com/package/git-coco)
|
|
8
8
|
|
|
9
|
-
Commit Copilot,
|
|
9
|
+
`coco`, the Commit Copilot, is not just your scribe for git commit messages. With the power of [LangChain🦜🔗](https://js.langchain.com/) and LLMs, it now brings you a suite of tools to streamline your git workflow!
|
|
10
10
|
|
|
11
|
+
## Commands
|
|
11
12
|
|
|
13
|
+
- **`commit`**: generates commit messages based on staged changes.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
- **`changelog`**: create changelogs for the current branch or a range of commits.
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
- **`init`**: step by step wizard to set up `coco` globally or for a project.
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
npm i git-coco --save-dev
|
|
19
|
-
```
|
|
19
|
+
## Getting Started
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
**`coco init`** is the first step to getting started with `coco`. It will guide you through the installation process, including setting up your OpenAI API key and configuring `coco` to your preferences.
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
# For local project use
|
|
25
|
+
npx git-coco@latest init -l project
|
|
26
|
+
|
|
27
|
+
# For global use
|
|
28
|
+
npx git-coco@latest init -l global
|
|
25
29
|
```
|
|
26
30
|
|
|
27
31
|
## Usage
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
1. [Interactive Mode](#interactive)
|
|
32
|
-
2. [Command Line Interface (CLI)](#cli)
|
|
33
|
+
### **`coco commit`**
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
Just type `coco` and let the friendly prompts guide you through the commit process!
|
|
35
|
+
Generates commit messages based on staged changes.
|
|
37
36
|
|
|
38
37
|
```bash
|
|
39
|
-
coco
|
|
40
|
-
```
|
|
38
|
+
coco
|
|
41
39
|
|
|
42
|
-
|
|
40
|
+
# or
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
- Customize your prompts for a personalized commit experience
|
|
46
|
-
|
|
47
|
-
### **Command Line Interface (CLI)**
|
|
48
|
-
|
|
49
|
-
If you're the type who likes to keep it simple, you can pass your commit message directly as a CLI argument:
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
coco --openAIApiKey="sk_your-openai-api-key"
|
|
42
|
+
coco commit
|
|
53
43
|
```
|
|
54
44
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
git commit -m $(coco)
|
|
59
|
-
```
|
|
45
|
+
### **`coco changelog`**
|
|
60
46
|
|
|
61
|
-
|
|
47
|
+
Creates changelogs.
|
|
62
48
|
|
|
63
49
|
```bash
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
# For the current branch
|
|
51
|
+
coco changelog
|
|
66
52
|
|
|
67
|
-
|
|
53
|
+
# For a specific range
|
|
54
|
+
coco changelog -r HEAD~5:HEAD
|
|
55
|
+
```
|
|
68
56
|
|
|
69
|
-
`coco.config` houses the project-level settings and can be defined in multiple places, adhering to a hierarchical order of priority. If the same configuration is found in multiple places, the higher priority one will be considered.
|
|
70
57
|
|
|
71
|
-
|
|
58
|
+
### Stdout vs. Interactive Mode
|
|
72
59
|
|
|
73
|
-
|
|
74
|
-
2. **Environment Variables**: Next in line are environment variables. You can set any configuration option as an environment variable.
|
|
75
|
-
3. **Project Config (`.coco.config.json`)**: Create a `.coco.config.json` file in your project root to set configurations. It's recommended to store your OpenAI API key here alongside any other project-specific configurations.
|
|
76
|
-
4. **Git Profile (`.gitconfig`)**: You can define `coco` settings under a `[coco]` section in your git profile. These settings will be used unless overridden by higher-priority ones.
|
|
77
|
-
5. **XDG Configuration Directory**: If `XDG_CONFIG_HOME` is set, `coco` will look for a `coco/config` file in this directory for configurations.
|
|
60
|
+
`coco` offers two modes of operation: **stdout** and **interactive**, defaulting to **stdout**. You can specify your preferred mode in your config file or via command line flags.
|
|
78
61
|
|
|
79
|
-
|
|
62
|
+
```bash
|
|
63
|
+
# Stdout mode
|
|
64
|
+
git commit -m $(coco)
|
|
80
65
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"openAIApiKey": "sk_your-openai-api-key",
|
|
84
|
-
}
|
|
66
|
+
# Interactive mode
|
|
67
|
+
coco -i
|
|
85
68
|
```
|
|
86
69
|
|
|
87
|
-
|
|
70
|
+
### Generate and commit all in one
|
|
88
71
|
|
|
89
|
-
|
|
90
|
-
[coco]
|
|
91
|
-
openAIApiKey = sk_your-openai-api-key
|
|
92
|
-
```
|
|
72
|
+
`coco` can generate and commit your changes in one command.
|
|
93
73
|
|
|
94
|
-
|
|
74
|
+
```bash
|
|
75
|
+
coco -s
|
|
76
|
+
```
|
|
95
77
|
|
|
96
|
-
|
|
78
|
+
## Configuration
|
|
97
79
|
|
|
98
|
-
|
|
99
|
-
|--------------------------|---------------------------------|-------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
|
|
100
|
-
| openAIApiKey | string | None | Your OpenAI API key |
|
|
101
|
-
| tokenLimit | number | 500 | Maximum number of tokens for the commit message |
|
|
102
|
-
| prompt | string | `"What are the changes in this commit?"` | Prompt for OpenAI GPT-3 |
|
|
103
|
-
| temperature | number | 0.4 | Controls randomness in GPT-3 output. Lower values yield focused output; higher values offer diversity |
|
|
104
|
-
| mode | `stdout` \| `interactive` | `stdout` | Preferred output method for generated commit messages |
|
|
105
|
-
| summarizePrompt | string | `"Summarize the changes in this large file:"` | GPT-3 prompt for summarizing large files |
|
|
106
|
-
| ignoredFiles | string[] | `["package-lock.json"]` | Paths of files to be excluded when generating commit messages |
|
|
107
|
-
| ignoredExtensions | string[] | `[".map", ".lock"]` | File extensions to be excluded when generating commit messages |
|
|
80
|
+
The `.coco.config` documentation has moved to our [wiki](https://github.com/gfargo/coco/wiki/Config-Overview). Here, you'll find detailed information on setting up and customizing your experience.
|
|
108
81
|
|
|
109
|
-
|
|
82
|
+
### **Ignoring Files**
|
|
110
83
|
|
|
111
|
-
|
|
112
|
-
- [x] Stdout 📤
|
|
113
|
-
- [x] LangChain integration 🦜
|
|
114
|
-
- [ ] Additional tests! 🧪
|
|
115
|
-
- [ ] Conventional commits 🔜
|
|
116
|
-
- [x] HuggingFace integration 🔜
|
|
117
|
-
- [ ] Google Vertex AI integration (?)
|
|
118
|
-
- [ ] Automatic changelog generation 🫣
|
|
119
|
-
- [ ] Rebase support 🔀
|
|
120
|
-
- [ ] `coco --amend b31dfc` 👩💻
|
|
84
|
+
You can specify files to be ignored when generating commit messages by adding them to your config file or via command line flags. Read more about ignoring files & extensions in the [wiki](https://github.com/gfargo/coco/wiki/Ignoring-Files-&-Extensions).
|
|
121
85
|
|
|
122
|
-
...and more! 🧑🔬 🚀
|
|
123
86
|
|
|
124
87
|
## Contribution
|
|
125
88
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
Please check out our [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
|
89
|
+
We welcome contributions! Check out our [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,78 @@
|
|
|
1
1
|
/// <reference types="yargs" />
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import { TiktokenModel, OpenAIInput } from 'langchain/dist/types/openai-types';
|
|
3
|
+
import { OllamaInput } from 'langchain/dist/util/ollama';
|
|
4
4
|
import { BaseLLMParams } from 'langchain/llms/base';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as yargs from 'yargs';
|
|
6
|
+
import * as langchain_llms_openai from 'langchain/llms/openai';
|
|
7
|
+
import { OpenAI } from 'langchain/llms/openai';
|
|
8
|
+
import { Ollama } from 'langchain/llms/ollama';
|
|
7
9
|
import { SimpleGit } from 'simple-git';
|
|
8
10
|
import { Color } from 'chalk';
|
|
9
11
|
|
|
12
|
+
type LLMProvider = 'openai' | 'ollama';
|
|
13
|
+
type OllamaModel = 'neural-chat' | 'starling-lm' | 'mistral' | 'llama2' | 'codellama' | 'llama2-uncensored' | 'llama2:13b' | 'llama2:70b' | 'orca-mini' | 'vicuna';
|
|
14
|
+
type LLMModel = TiktokenModel | OllamaModel;
|
|
15
|
+
interface BaseLLMService {
|
|
16
|
+
provider: LLMProvider;
|
|
17
|
+
model: LLMModel;
|
|
18
|
+
/**
|
|
19
|
+
* The maximum number of tokens per request.
|
|
20
|
+
*
|
|
21
|
+
* @default 1024
|
|
22
|
+
*/
|
|
23
|
+
tokenLimit?: number;
|
|
24
|
+
/**
|
|
25
|
+
* The temperature value controls the randomness of the generated output.
|
|
26
|
+
* Higher values (e.g., 0.8) make the output more random, while lower values (e.g., 0.2) make it more deterministic.
|
|
27
|
+
*
|
|
28
|
+
* @default 0.4
|
|
29
|
+
*/
|
|
30
|
+
temperature?: number;
|
|
31
|
+
/**
|
|
32
|
+
* The maximum number of requests to make concurrently.
|
|
33
|
+
*
|
|
34
|
+
* @default 6
|
|
35
|
+
*/
|
|
36
|
+
maxConcurrent?: number;
|
|
37
|
+
authentication: Authentication;
|
|
38
|
+
requestOptions?: {
|
|
39
|
+
timeout?: number;
|
|
40
|
+
maxRetries?: number;
|
|
41
|
+
};
|
|
42
|
+
fields?: OpenAIFields | OllamaFields;
|
|
43
|
+
}
|
|
44
|
+
type Authentication = {
|
|
45
|
+
type: 'None';
|
|
46
|
+
credentials: undefined;
|
|
47
|
+
} | {
|
|
48
|
+
type: 'OAuth';
|
|
49
|
+
credentials: {
|
|
50
|
+
clientId?: string;
|
|
51
|
+
clientSecret?: string;
|
|
52
|
+
token?: string;
|
|
53
|
+
};
|
|
54
|
+
} | {
|
|
55
|
+
type: 'APIKey';
|
|
56
|
+
credentials: {
|
|
57
|
+
apiKey: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
type OpenAIFields = Partial<OpenAIInput> & BaseLLMParams;
|
|
61
|
+
type OllamaFields = Partial<OllamaInput> & BaseLLMParams;
|
|
62
|
+
interface OpenAILLMService extends BaseLLMService {
|
|
63
|
+
provider: 'openai';
|
|
64
|
+
model: TiktokenModel;
|
|
65
|
+
fields?: OpenAIFields;
|
|
66
|
+
}
|
|
67
|
+
interface OllamaLLMService extends BaseLLMService {
|
|
68
|
+
provider: 'ollama';
|
|
69
|
+
model: OllamaModel;
|
|
70
|
+
endpoint: string;
|
|
71
|
+
fields?: OllamaFields;
|
|
72
|
+
}
|
|
73
|
+
type LLMService = OpenAILLMService | OllamaLLMService;
|
|
74
|
+
type LLMServiceAlias = 'openai' | 'ollama';
|
|
75
|
+
|
|
10
76
|
declare const _default$2: {
|
|
11
77
|
command: string;
|
|
12
78
|
desc: string;
|
|
@@ -19,10 +85,9 @@ declare const _default$2: {
|
|
|
19
85
|
openInEditor: boolean;
|
|
20
86
|
ignoredFiles: string[];
|
|
21
87
|
ignoredExtensions: string[];
|
|
22
|
-
service:
|
|
23
|
-
openAIApiKey: string
|
|
24
|
-
|
|
25
|
-
tokenLimit: number | undefined;
|
|
88
|
+
service: LLMServiceAlias;
|
|
89
|
+
openAIApiKey: string;
|
|
90
|
+
tokenLimit: number;
|
|
26
91
|
interactive: boolean;
|
|
27
92
|
help: boolean;
|
|
28
93
|
verbose: boolean;
|
|
@@ -36,10 +101,9 @@ declare const _default$2: {
|
|
|
36
101
|
openInEditor: boolean;
|
|
37
102
|
ignoredFiles: string[];
|
|
38
103
|
ignoredExtensions: string[];
|
|
39
|
-
service:
|
|
40
|
-
openAIApiKey: string
|
|
41
|
-
|
|
42
|
-
tokenLimit: number | undefined;
|
|
104
|
+
service: LLMServiceAlias;
|
|
105
|
+
openAIApiKey: string;
|
|
106
|
+
tokenLimit: number;
|
|
43
107
|
interactive: boolean;
|
|
44
108
|
help: boolean;
|
|
45
109
|
verbose: boolean;
|
|
@@ -62,10 +126,9 @@ declare const _default$1: {
|
|
|
62
126
|
openInEditor: boolean;
|
|
63
127
|
ignoredFiles: string[];
|
|
64
128
|
ignoredExtensions: string[];
|
|
65
|
-
service:
|
|
66
|
-
openAIApiKey: string
|
|
67
|
-
|
|
68
|
-
tokenLimit: number | undefined;
|
|
129
|
+
service: LLMServiceAlias;
|
|
130
|
+
openAIApiKey: string;
|
|
131
|
+
tokenLimit: number;
|
|
69
132
|
interactive: boolean;
|
|
70
133
|
help: boolean;
|
|
71
134
|
verbose: boolean;
|
|
@@ -80,10 +143,9 @@ declare const _default$1: {
|
|
|
80
143
|
openInEditor: boolean;
|
|
81
144
|
ignoredFiles: string[];
|
|
82
145
|
ignoredExtensions: string[];
|
|
83
|
-
service:
|
|
84
|
-
openAIApiKey: string
|
|
85
|
-
|
|
86
|
-
tokenLimit: number | undefined;
|
|
146
|
+
service: LLMServiceAlias;
|
|
147
|
+
openAIApiKey: string;
|
|
148
|
+
tokenLimit: number;
|
|
87
149
|
interactive: boolean;
|
|
88
150
|
help: boolean;
|
|
89
151
|
verbose: boolean;
|
|
@@ -117,45 +179,7 @@ declare const _default: {
|
|
|
117
179
|
options: Record<string, yargs.Options>;
|
|
118
180
|
};
|
|
119
181
|
|
|
120
|
-
|
|
121
|
-
type ServiceModel = TiktokenModel;
|
|
122
|
-
type Service = `${ServiceProvider}/${ServiceModel}`;
|
|
123
|
-
interface Config$1 {
|
|
124
|
-
/**
|
|
125
|
-
* The LLM model to use for generating results.
|
|
126
|
-
*
|
|
127
|
-
* @default 'openai/gpt-4'
|
|
128
|
-
*
|
|
129
|
-
* @example 'openai/gpt-4'
|
|
130
|
-
* @example 'openai/gpt-3.5-turbo'
|
|
131
|
-
* @example 'huggingface/bigscience/bloom'
|
|
132
|
-
**/
|
|
133
|
-
service?: Service;
|
|
134
|
-
/**
|
|
135
|
-
* The OpenAI API key.
|
|
136
|
-
*/
|
|
137
|
-
openAIApiKey?: string;
|
|
138
|
-
/**
|
|
139
|
-
* The HuggingFace Hub API key.
|
|
140
|
-
*/
|
|
141
|
-
huggingFaceHubApiKey?: string;
|
|
142
|
-
/**
|
|
143
|
-
* The maximum number of tokens per request.
|
|
144
|
-
*
|
|
145
|
-
* @default 1024
|
|
146
|
-
*/
|
|
147
|
-
tokenLimit?: number;
|
|
148
|
-
/**
|
|
149
|
-
* The prompt text used for generating results.
|
|
150
|
-
*/
|
|
151
|
-
prompt?: string;
|
|
152
|
-
/**
|
|
153
|
-
* The temperature value controls the randomness of the generated output.
|
|
154
|
-
* Higher values (e.g., 0.8) make the output more random, while lower values (e.g., 0.2) make it more deterministic.
|
|
155
|
-
*
|
|
156
|
-
* @default 0.4
|
|
157
|
-
*/
|
|
158
|
-
temperature?: number;
|
|
182
|
+
interface BaseConfig {
|
|
159
183
|
/**
|
|
160
184
|
* The output destination for the generated result.
|
|
161
185
|
* - 'stdout': Prints the result to the standard output. This is the default behavior.
|
|
@@ -163,7 +187,7 @@ interface Config$1 {
|
|
|
163
187
|
*
|
|
164
188
|
* @default 'stdout'
|
|
165
189
|
*/
|
|
166
|
-
mode
|
|
190
|
+
mode: 'stdout' | 'interactive';
|
|
167
191
|
/**
|
|
168
192
|
* Enable verbose logging.
|
|
169
193
|
*
|
|
@@ -176,6 +200,10 @@ interface Config$1 {
|
|
|
176
200
|
* @default false
|
|
177
201
|
*/
|
|
178
202
|
openInEditor?: boolean;
|
|
203
|
+
/**
|
|
204
|
+
* The prompt text used for generating results.
|
|
205
|
+
*/
|
|
206
|
+
prompt?: string;
|
|
179
207
|
/**
|
|
180
208
|
* The prompt text used specifically for generating summaries of large files.
|
|
181
209
|
*/
|
|
@@ -201,16 +229,44 @@ interface Config$1 {
|
|
|
201
229
|
*
|
|
202
230
|
* @default 'main'
|
|
203
231
|
*/
|
|
204
|
-
defaultBranch
|
|
232
|
+
defaultBranch: string;
|
|
233
|
+
}
|
|
234
|
+
interface OpenAIAliasConfig extends BaseConfig {
|
|
235
|
+
service: 'openai';
|
|
236
|
+
model?: OpenAILLMService['model'];
|
|
237
|
+
openAIApiKey: string;
|
|
238
|
+
}
|
|
239
|
+
interface OllamaAliasConfig extends BaseConfig {
|
|
240
|
+
service: 'ollama';
|
|
241
|
+
model?: OllamaLLMService['model'];
|
|
242
|
+
endpoint: string;
|
|
243
|
+
}
|
|
244
|
+
type ConfigWithServiceAlias = (OpenAIAliasConfig | OllamaAliasConfig) & Partial<BaseCommandOptions>;
|
|
245
|
+
type ConfigWithServiceObject = BaseConfig & Partial<BaseCommandOptions> & {
|
|
246
|
+
service: LLMService;
|
|
247
|
+
};
|
|
248
|
+
type Config$1 = ConfigWithServiceAlias | ConfigWithServiceObject;
|
|
249
|
+
|
|
250
|
+
interface BaseArgvOptions {
|
|
251
|
+
[x: string]: unknown;
|
|
252
|
+
interactive: boolean;
|
|
253
|
+
help: boolean;
|
|
254
|
+
verbose: boolean;
|
|
255
|
+
}
|
|
256
|
+
interface BaseCommandOptions extends BaseArgvOptions {
|
|
257
|
+
service: LLMServiceAlias;
|
|
258
|
+
openAIApiKey: string;
|
|
259
|
+
tokenLimit: number;
|
|
205
260
|
}
|
|
206
261
|
|
|
207
262
|
/**
|
|
208
263
|
* Get LLM Model Based on Configuration
|
|
264
|
+
*
|
|
209
265
|
* @param fields
|
|
210
266
|
* @param configuration
|
|
211
267
|
* @returns LLM Model
|
|
212
268
|
*/
|
|
213
|
-
declare function getLlm(
|
|
269
|
+
declare function getLlm(provider: 'openai' | 'ollama', model: TiktokenModel | OllamaModel, config: Config$1): Ollama | OpenAI<langchain_llms_openai.OpenAICallOptions>;
|
|
214
270
|
|
|
215
271
|
interface LoggerOptions {
|
|
216
272
|
color?: typeof Color;
|
|
@@ -236,7 +292,7 @@ declare class Logger {
|
|
|
236
292
|
}
|
|
237
293
|
|
|
238
294
|
type TokenCounter = Awaited<ReturnType<typeof getTokenCounter>>;
|
|
239
|
-
declare const getTokenCounter: (modelName:
|
|
295
|
+
declare const getTokenCounter: (modelName: TiktokenModel) => Promise<(text: string) => number>;
|
|
240
296
|
|
|
241
297
|
type FileChangeStatus = 'modified' | 'renamed' | 'added' | 'deleted' | 'untracked' | 'unknown';
|
|
242
298
|
interface FileChange {
|