git-coco 0.7.6 → 0.8.1
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 +1 -1
- package/dist/index.d.ts +125 -63
- package/dist/index.esm.mjs +318 -155
- package/dist/index.js +318 -155
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/git-coco)
|
|
7
7
|
[](https://www.npmjs.com/package/git-coco)
|
|
8
8
|
|
|
9
|
-
`coco`, the Commit Copilot,
|
|
9
|
+
`coco`, the Commit Copilot, transcends being merely a robotic scribe for crafting git commit messages. Leveraging the capabilities of [LangChain🦜🔗](https://js.langchain.com/) and LLMs, `coco` is committed to providing a suite of insightful tools aimed at enhancing and streamlining your git workflow!
|
|
10
10
|
|
|
11
11
|
## Commands
|
|
12
12
|
|
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,13 @@ declare class Logger {
|
|
|
236
292
|
}
|
|
237
293
|
|
|
238
294
|
type TokenCounter = Awaited<ReturnType<typeof getTokenCounter>>;
|
|
239
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Retrieves the token counter for a given model name.
|
|
297
|
+
*
|
|
298
|
+
* @param {TikTokenModel} modelName - The name of the Tiktoken model.
|
|
299
|
+
* @returns A promise that resolves to a function that calculates the number of tokens in a given text.
|
|
300
|
+
*/
|
|
301
|
+
declare const getTokenCounter: (modelName: TiktokenModel) => Promise<(text: string) => number>;
|
|
240
302
|
|
|
241
303
|
type FileChangeStatus = 'modified' | 'renamed' | 'added' | 'deleted' | 'untracked' | 'unknown';
|
|
242
304
|
interface FileChange {
|