git-coco 0.14.0 → 0.14.2
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 +4 -0
- package/dist/index.d.ts +13 -3
- package/dist/index.esm.mjs +1208 -1258
- package/dist/index.js +1208 -1258
- package/package.json +2 -1
package/dist/index.esm.mjs
CHANGED
|
@@ -50,473 +50,19 @@ import { Writable } from 'node:stream';
|
|
|
50
50
|
import readline$1 from 'node:readline';
|
|
51
51
|
import * as readline from 'readline';
|
|
52
52
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
const SEPERATOR = chalk.blue('─────────────');
|
|
57
|
-
const DIVIDER = chalk.dim(`\\`);
|
|
58
|
-
const LOGO = chalk.green(`┌──────┐
|
|
59
|
-
│┏┏┓┏┏┓│
|
|
60
|
-
│┗┗┛┗┗┛│
|
|
61
|
-
└──────┘`);
|
|
62
|
-
chalk.green(`┌────┐
|
|
63
|
-
│coco│
|
|
64
|
-
└────┘`);
|
|
65
|
-
const bannerWithHeader = (banner) => {
|
|
66
|
-
return chalk.green(`┌────┐
|
|
67
|
-
│coco│ ${banner}
|
|
68
|
-
└────┘`);
|
|
69
|
-
};
|
|
70
|
-
const USAGE_BANNER = chalk.green(`${LOGO}
|
|
71
|
-
${chalk.bgGreen(`\xa0v${process.env.npm_package_version}\xa0`)}
|
|
72
|
-
`);
|
|
73
|
-
const getCommandUsageHeader = (command) => {
|
|
74
|
-
return chalk.green(`${USAGE_BANNER}\n${chalk.white('Command:')}\n\xa0\xa0\xa0\xa0\xa0 $0 ${chalk.greenBright(command)} [options]`);
|
|
75
|
-
};
|
|
76
|
-
const CONFIG_ALREADY_EXISTS = (path) => {
|
|
77
|
-
return `existing config found in '${path}', do you want to override it?`;
|
|
78
|
-
};
|
|
79
|
-
const severityColors = [
|
|
80
|
-
chalk.greenBright, // 1
|
|
81
|
-
chalk.green, // 2
|
|
82
|
-
chalk.cyan, // 3
|
|
83
|
-
chalk.yellowBright, // 4
|
|
84
|
-
chalk.yellow, // 5
|
|
85
|
-
chalk.bgYellow, // 6
|
|
86
|
-
chalk.red, // 7
|
|
87
|
-
chalk.redBright, // 8
|
|
88
|
-
chalk.bgRed, // 9
|
|
89
|
-
chalk.bgRedBright, // 10
|
|
90
|
-
];
|
|
91
|
-
const severityColor = (severity) => {
|
|
92
|
-
return severityColors[Math.min(severity - 1, severityColors.length - 1)];
|
|
93
|
-
};
|
|
94
|
-
const statusColor = (status) => {
|
|
95
|
-
switch (status) {
|
|
96
|
-
case 'completed':
|
|
97
|
-
return chalk.green;
|
|
98
|
-
case 'skipped':
|
|
99
|
-
return chalk.yellow;
|
|
100
|
-
case 'omitted':
|
|
101
|
-
return chalk.red;
|
|
102
|
-
default:
|
|
103
|
-
return chalk.blue;
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
const hotKey = (key) => chalk.dim(`(${key})`);
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Returns a new object with all undefined keys removed
|
|
110
|
-
*
|
|
111
|
-
* @param obj Object to remove undefined keys from
|
|
112
|
-
* @returns
|
|
113
|
-
*/
|
|
114
|
-
function removeUndefined(obj) {
|
|
115
|
-
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function updateFileSection({ filePath, startComment, endComment, getNewContent, confirmUpdate = true, confirmMessage = (path) => `A section already exists in ${path}, do you want to override it?`, }) {
|
|
119
|
-
const lines = fs__default.existsSync(filePath) ? fs__default.readFileSync(filePath, 'utf-8').split(/\r?\n/) : [];
|
|
120
|
-
const newLines = [];
|
|
121
|
-
let foundSection = false;
|
|
122
|
-
for (let i = 0; i < lines.length; i++) {
|
|
123
|
-
if (lines[i].trim() === startComment) {
|
|
124
|
-
foundSection = true;
|
|
125
|
-
if (confirmUpdate) {
|
|
126
|
-
const confirmOverwrite = await confirm({
|
|
127
|
-
message: typeof confirmMessage === 'function' ? confirmMessage(filePath) : confirmMessage,
|
|
128
|
-
default: false,
|
|
129
|
-
});
|
|
130
|
-
if (!confirmOverwrite) {
|
|
131
|
-
// keep all lines until the end comment
|
|
132
|
-
while (i < lines.length && lines[i].trim() !== endComment) {
|
|
133
|
-
newLines.push(lines[i]);
|
|
134
|
-
i++;
|
|
135
|
-
}
|
|
136
|
-
newLines.push(endComment);
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
newLines.push(startComment);
|
|
141
|
-
// Insert the new content
|
|
142
|
-
const newContent = await getNewContent();
|
|
143
|
-
newLines.push(newContent);
|
|
144
|
-
// Skip the existing content of the section
|
|
145
|
-
while (i < lines.length && lines[i].trim() !== endComment) {
|
|
146
|
-
i++;
|
|
147
|
-
}
|
|
148
|
-
newLines.push(endComment);
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
if (!foundSection || lines[i].trim() !== endComment) {
|
|
152
|
-
newLines.push(lines[i]);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
// If section wasn't found, append it at the end
|
|
156
|
-
if (!foundSection) {
|
|
157
|
-
newLines.push('\n' + startComment);
|
|
158
|
-
const newContent = await getNewContent();
|
|
159
|
-
newLines.push(newContent);
|
|
160
|
-
newLines.push(endComment);
|
|
161
|
-
}
|
|
162
|
-
// Write the updated contents back to the file
|
|
163
|
-
fs__default.writeFileSync(filePath, newLines.join('\n'));
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const template$5 = `GOAL: Use functional abstractions to summarize the following text
|
|
167
|
-
|
|
168
|
-
RULES: Avoid phrases like "this change", "this code", or "this function" etc. Instead refer to the function, variable, or class by name.
|
|
169
|
-
|
|
170
|
-
TEXT:"""{text}"""
|
|
171
|
-
`;
|
|
172
|
-
const inputVariables$4 = ['text'];
|
|
173
|
-
const SUMMARIZE_PROMPT = new PromptTemplate({
|
|
174
|
-
inputVariables: inputVariables$4,
|
|
175
|
-
template: template$5,
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Retrieves the provider and model from the given configuration object.
|
|
180
|
-
* @param config The configuration object.
|
|
181
|
-
* @returns An object containing the provider and model.
|
|
182
|
-
* @throws Error if the configuration is invalid or missing required properties.
|
|
183
|
-
*/
|
|
184
|
-
function getModelAndProviderFromConfig(config) {
|
|
185
|
-
if (!config.service) {
|
|
186
|
-
throw new Error('Invalid service: undefined');
|
|
187
|
-
}
|
|
188
|
-
const { provider, model } = config.service;
|
|
189
|
-
if (!model || !provider) {
|
|
190
|
-
throw new Error(`Invalid service: ${config.service}`);
|
|
191
|
-
}
|
|
192
|
-
return { provider, model };
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Retrieve appropriate API key based on selected model
|
|
196
|
-
* @param service
|
|
197
|
-
* @param options
|
|
198
|
-
* @returns API Key
|
|
199
|
-
*/
|
|
200
|
-
function getApiKeyForModel(config) {
|
|
201
|
-
const { provider } = getModelAndProviderFromConfig(config);
|
|
202
|
-
switch (provider) {
|
|
203
|
-
case 'openai':
|
|
204
|
-
return getDefaultServiceApiKey(config);
|
|
205
|
-
default:
|
|
206
|
-
return getDefaultServiceApiKey(config);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Retrieves the default service API key from the given configuration.
|
|
211
|
-
* @param config The configuration object.
|
|
212
|
-
* @returns The default service API key.
|
|
213
|
-
*/
|
|
214
|
-
function getDefaultServiceApiKey(config) {
|
|
215
|
-
const service = config.service;
|
|
216
|
-
if (service.authentication.type === 'APIKey') {
|
|
217
|
-
return service.authentication.credentials?.apiKey;
|
|
218
|
-
}
|
|
219
|
-
else if (service.authentication.type === 'OAuth') {
|
|
220
|
-
return service.authentication.credentials?.token;
|
|
221
|
-
}
|
|
222
|
-
return '';
|
|
223
|
-
}
|
|
224
|
-
const DEFAULT_OPENAI_LLM_SERVICE = {
|
|
225
|
-
provider: 'openai',
|
|
226
|
-
model: 'gpt-4',
|
|
227
|
-
tokenLimit: 2024,
|
|
228
|
-
temperature: 0.32,
|
|
229
|
-
authentication: {
|
|
230
|
-
type: 'APIKey',
|
|
231
|
-
credentials: {
|
|
232
|
-
apiKey: '',
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
};
|
|
236
|
-
const DEFAULT_OLLAMA_LLM_SERVICE = {
|
|
237
|
-
provider: 'ollama',
|
|
238
|
-
model: 'llama3',
|
|
239
|
-
endpoint: 'http://localhost:11434',
|
|
240
|
-
maxConcurrent: 1,
|
|
241
|
-
tokenLimit: 2024,
|
|
242
|
-
temperature: 0.4,
|
|
243
|
-
authentication: {
|
|
244
|
-
type: 'None',
|
|
245
|
-
credentials: undefined,
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
/**
|
|
249
|
-
* Retrieves the default service configuration based on the provided alias and optional model.
|
|
250
|
-
* @param provider - The alias of the service.
|
|
251
|
-
* @param model - The optional model to be used.
|
|
252
|
-
* @returns The default service configuration.
|
|
253
|
-
* @throws Error if the alias is invalid or undefined.
|
|
254
|
-
*/
|
|
255
|
-
function getDefaultServiceConfigFromAlias(provider, model) {
|
|
256
|
-
switch (provider) {
|
|
257
|
-
case 'ollama':
|
|
258
|
-
return {
|
|
259
|
-
...DEFAULT_OLLAMA_LLM_SERVICE,
|
|
260
|
-
model: model || DEFAULT_OLLAMA_LLM_SERVICE.model,
|
|
261
|
-
};
|
|
262
|
-
case 'openai':
|
|
263
|
-
default:
|
|
264
|
-
return {
|
|
265
|
-
...DEFAULT_OPENAI_LLM_SERVICE,
|
|
266
|
-
model: model || DEFAULT_OPENAI_LLM_SERVICE.model,
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
const DEFAULT_IGNORED_FILES = ['package-lock.json'];
|
|
272
|
-
const DEFAULT_IGNORED_EXTENSIONS = ['.map', '.lock'];
|
|
273
|
-
const COCO_CONFIG_START_COMMENT = '# -- start coco config --';
|
|
274
|
-
const COCO_CONFIG_END_COMMENT = '# -- end coco config --';
|
|
275
|
-
/**
|
|
276
|
-
* Default Config
|
|
277
|
-
*
|
|
278
|
-
* @type {Config}
|
|
279
|
-
*/
|
|
280
|
-
const DEFAULT_CONFIG$1 = {
|
|
281
|
-
mode: 'stdout',
|
|
282
|
-
verbose: false,
|
|
283
|
-
defaultBranch: 'main',
|
|
284
|
-
service: getDefaultServiceConfigFromAlias('openai'),
|
|
285
|
-
summarizePrompt: SUMMARIZE_PROMPT.template,
|
|
286
|
-
ignoredFiles: DEFAULT_IGNORED_FILES,
|
|
287
|
-
ignoredExtensions: DEFAULT_IGNORED_EXTENSIONS,
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Create a named export of all config keys for use in other modules.
|
|
291
|
-
*
|
|
292
|
-
* @see Used in `src/lib/config/services/env.ts` to validate all env vars.
|
|
293
|
-
*
|
|
294
|
-
* @type {string[]}
|
|
295
|
-
*/
|
|
296
|
-
const CONFIG_KEYS = Object.keys({
|
|
297
|
-
...DEFAULT_CONFIG$1,
|
|
298
|
-
prompt: '',
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* Load environment variables
|
|
303
|
-
*
|
|
304
|
-
* @param {Config} config
|
|
305
|
-
* @returns {Config} Updated config
|
|
306
|
-
**/
|
|
307
|
-
function loadEnvConfig(config) {
|
|
308
|
-
const envConfig = {};
|
|
309
|
-
const envKeys = [...CONFIG_KEYS, 'COCO_SERVICE_PROVIDER', 'COCO_SERVICE_MODEL', 'OPEN_AI_KEY'];
|
|
310
|
-
envKeys.forEach((key) => {
|
|
311
|
-
const envVarName = toEnvVarName(key);
|
|
312
|
-
const envValue = parseEnvValue(key, process.env[envVarName]);
|
|
313
|
-
if (envValue === undefined) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
if (key === 'COCO_SERVICE_PROVIDER' || key === 'COCO_SERVICE_MODEL' || key === 'OPEN_AI_KEY') {
|
|
317
|
-
// NOTE: We want to ensure that the service object is always defined
|
|
318
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
319
|
-
// @ts-ignore
|
|
320
|
-
envConfig.service = envConfig.service || {};
|
|
321
|
-
handleServiceEnvVar(envConfig.service, key, envValue);
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
if (key === 'service' || !envValue) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
envConfig[key] = envValue;
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
return { ...config, ...removeUndefined(envConfig) };
|
|
331
|
-
}
|
|
332
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
333
|
-
function handleServiceEnvVar(service, key, value) {
|
|
334
|
-
switch (key) {
|
|
335
|
-
case 'COCO_SERVICE_PROVIDER':
|
|
336
|
-
service.provider = value;
|
|
337
|
-
break;
|
|
338
|
-
case 'COCO_SERVICE_MODEL':
|
|
339
|
-
service.model = value;
|
|
340
|
-
break;
|
|
341
|
-
case 'OPEN_AI_KEY':
|
|
342
|
-
if (service.provider === 'openai') {
|
|
343
|
-
service.fields = { apiKey: value };
|
|
344
|
-
}
|
|
345
|
-
break;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
function parseEnvValue(key, value) {
|
|
349
|
-
switch (true) {
|
|
350
|
-
// Handle undefined values
|
|
351
|
-
case value === undefined:
|
|
352
|
-
return undefined;
|
|
353
|
-
// Handle comma separated strings for ignoredFiles and ignoredExtensions arrays
|
|
354
|
-
case (key === 'ignoredFiles' || key === 'ignoredExtensions') &&
|
|
355
|
-
typeof value === 'string' &&
|
|
356
|
-
value.includes(','):
|
|
357
|
-
return value.split(',');
|
|
358
|
-
// Handle boolean values
|
|
359
|
-
case typeof value === 'string' && (value === 'false' || value === 'true'):
|
|
360
|
-
return value === 'true';
|
|
361
|
-
// Handle number values
|
|
362
|
-
case typeof value === 'string' && !isNaN(Number(value)):
|
|
363
|
-
return Number(value);
|
|
364
|
-
default:
|
|
365
|
-
return value;
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
function toEnvVarName(key) {
|
|
369
|
-
if (key === 'service') {
|
|
370
|
-
return key;
|
|
371
|
-
}
|
|
372
|
-
if (key.includes('COCO_')) {
|
|
373
|
-
return key;
|
|
374
|
-
}
|
|
375
|
-
return `COCO_${key.replace(/([A-Z])/g, '_$1').toLocaleUpperCase()}`;
|
|
376
|
-
}
|
|
377
|
-
function formatEnvValue(value) {
|
|
378
|
-
if (typeof value === 'number') {
|
|
379
|
-
return `${value}`;
|
|
380
|
-
}
|
|
381
|
-
else if (Array.isArray(value)) {
|
|
382
|
-
return `${value.join(',')}`;
|
|
383
|
-
}
|
|
384
|
-
else if (typeof value === 'string') {
|
|
385
|
-
// Escape newlines and tabs in strings
|
|
386
|
-
return `${value.replace(/\n/g, '\\n').replace(/\t/g, '\\t')}`;
|
|
387
|
-
}
|
|
388
|
-
return `${value}`;
|
|
389
|
-
}
|
|
390
|
-
const appendToEnvFile = async (filePath, config) => {
|
|
391
|
-
const getNewContent = async () => {
|
|
392
|
-
return Object.entries(config)
|
|
393
|
-
.map(([key, value]) => {
|
|
394
|
-
if (key === 'service') {
|
|
395
|
-
const service = value;
|
|
396
|
-
return `${service.provider ? `COCO_SERVICE_PROVIDER=${service.provider}` : ''}\n${service.model ? `COCO_SERVICE_MODEL=${service.model}` : ''}\n${service.authentication.type === 'APIKey'
|
|
397
|
-
? `OPEN_AI_KEY=${service.authentication.credentials.apiKey}`
|
|
398
|
-
: ''}`;
|
|
399
|
-
}
|
|
400
|
-
const envVarName = toEnvVarName(key);
|
|
401
|
-
const envValue = formatEnvValue(value);
|
|
402
|
-
return `${envVarName}=${envValue}`;
|
|
403
|
-
})
|
|
404
|
-
.join('\n');
|
|
405
|
-
};
|
|
406
|
-
await updateFileSection({
|
|
407
|
-
filePath,
|
|
408
|
-
startComment: COCO_CONFIG_START_COMMENT,
|
|
409
|
-
endComment: COCO_CONFIG_END_COMMENT,
|
|
410
|
-
getNewContent,
|
|
411
|
-
confirmMessage: CONFIG_ALREADY_EXISTS,
|
|
412
|
-
});
|
|
413
|
-
};
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Load git profile config (from ~/.gitconfig)
|
|
417
|
-
*
|
|
418
|
-
* @param {Config} config
|
|
419
|
-
* @returns {Config} Updated config
|
|
420
|
-
**/
|
|
421
|
-
function loadGitConfig(config) {
|
|
422
|
-
const gitConfigPath = path.join(os.homedir(), '.gitconfig');
|
|
423
|
-
if (fs.existsSync(gitConfigPath)) {
|
|
424
|
-
const gitConfigRaw = fs.readFileSync(gitConfigPath, 'utf-8');
|
|
425
|
-
const gitConfigParsed = ini.parse(gitConfigRaw);
|
|
426
|
-
const gitConfigServiceObject = gitConfigParsed.coco?.service;
|
|
427
|
-
let service = config.service;
|
|
428
|
-
if (gitConfigServiceObject) {
|
|
429
|
-
const gitServiceConfig = JSON.parse(gitConfigServiceObject);
|
|
430
|
-
service = gitServiceConfig || config?.service;
|
|
431
|
-
}
|
|
432
|
-
config = {
|
|
433
|
-
...config,
|
|
434
|
-
service: service,
|
|
435
|
-
prompt: gitConfigParsed.coco?.prompt || config.prompt,
|
|
436
|
-
mode: gitConfigParsed.coco?.mode || config.mode,
|
|
437
|
-
summarizePrompt: gitConfigParsed.coco?.summarizePrompt || config.summarizePrompt,
|
|
438
|
-
ignoredFiles: gitConfigParsed.coco?.ignoredFiles || config.ignoredFiles,
|
|
439
|
-
ignoredExtensions: gitConfigParsed.coco?.ignoredExtensions || config.ignoredExtensions,
|
|
440
|
-
defaultBranch: gitConfigParsed.coco?.defaultBranch || config.defaultBranch,
|
|
441
|
-
verbose: gitConfigParsed.coco?.verbose || config.verbose,
|
|
442
|
-
};
|
|
443
|
-
}
|
|
444
|
-
return removeUndefined(config);
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Appends the provided configuration to a git config file.
|
|
448
|
-
*
|
|
449
|
-
* @param filePath - The path to the .gitconfig
|
|
450
|
-
* @param config - The configuration object to append.
|
|
451
|
-
*/
|
|
452
|
-
const appendToGitConfig = async (filePath, config) => {
|
|
453
|
-
if (!fs.existsSync(filePath)) {
|
|
454
|
-
throw new Error(`File ${filePath} does not exist.`);
|
|
455
|
-
}
|
|
456
|
-
const header = '[coco]';
|
|
457
|
-
const getNewContent = async () => {
|
|
458
|
-
const contentLines = [header];
|
|
459
|
-
for (const key in config) {
|
|
460
|
-
const value = config[key];
|
|
461
|
-
if (typeof value === 'object') {
|
|
462
|
-
// Serialize object to JSON string
|
|
463
|
-
contentLines.push(`\t${key} = ${JSON.stringify(value)}`);
|
|
464
|
-
}
|
|
465
|
-
else if (typeof value === 'string' && value.includes('\n')) {
|
|
466
|
-
// Wrap strings with new lines in quotes
|
|
467
|
-
contentLines.push(`\t${key} = ${JSON.stringify(value)}`);
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
contentLines.push(`\t${key} = ${value}`);
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
return contentLines.join('\n');
|
|
474
|
-
};
|
|
475
|
-
await updateFileSection({
|
|
476
|
-
filePath,
|
|
477
|
-
startComment: COCO_CONFIG_START_COMMENT,
|
|
478
|
-
endComment: COCO_CONFIG_END_COMMENT,
|
|
479
|
-
getNewContent,
|
|
480
|
-
confirmUpdate: true,
|
|
481
|
-
confirmMessage: CONFIG_ALREADY_EXISTS,
|
|
482
|
-
});
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* Load .gitignore in project root
|
|
487
|
-
*
|
|
488
|
-
* @param {Config} config
|
|
489
|
-
* @returns
|
|
490
|
-
*/
|
|
491
|
-
function loadGitignore(config) {
|
|
492
|
-
if (fs.existsSync('.gitignore')) {
|
|
493
|
-
const gitignoreContent = fs.readFileSync('.gitignore', 'utf-8');
|
|
494
|
-
config.ignoredFiles = [
|
|
495
|
-
...(config?.ignoredFiles || []),
|
|
496
|
-
...gitignoreContent.split('\n').filter((line) => line.trim() !== '' && !line.startsWith('#')),
|
|
497
|
-
];
|
|
498
|
-
}
|
|
499
|
-
return config;
|
|
500
|
-
}
|
|
53
|
+
// This file is auto-generated - DO NOT EDIT
|
|
54
|
+
/* eslint-disable */
|
|
501
55
|
/**
|
|
502
|
-
*
|
|
503
|
-
*
|
|
504
|
-
* @param {Config} config
|
|
505
|
-
* @returns
|
|
56
|
+
* Schema ID for JSON validation
|
|
506
57
|
*/
|
|
507
|
-
function loadIgnore(config) {
|
|
508
|
-
if (fs.existsSync('.ignore')) {
|
|
509
|
-
const ignoreContent = fs.readFileSync('.ignore', 'utf-8');
|
|
510
|
-
config.ignoredFiles = [
|
|
511
|
-
...(config?.ignoredFiles || []),
|
|
512
|
-
...ignoreContent.split('\n').filter((line) => line.trim() !== '' && !line.startsWith('#')),
|
|
513
|
-
];
|
|
514
|
-
}
|
|
515
|
-
return config;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
// this file is auto-generated by the 'build:schema' script
|
|
519
58
|
const SCHEMA_PUBLIC_URL = "http://git-co.co/schema.json";
|
|
59
|
+
/**
|
|
60
|
+
* Current build version from package.json
|
|
61
|
+
*/
|
|
62
|
+
const BUILD_VERSION = "0.14.2";
|
|
63
|
+
/**
|
|
64
|
+
* Generated JSON schema
|
|
65
|
+
*/
|
|
520
66
|
const schema$1 = {
|
|
521
67
|
"$id": "http://git-co.co/schema.json",
|
|
522
68
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
@@ -532,14 +78,17 @@ const schema$1 = {
|
|
|
532
78
|
"interactive": {
|
|
533
79
|
"type": "boolean"
|
|
534
80
|
},
|
|
535
|
-
"help": {
|
|
536
|
-
"type": "boolean"
|
|
537
|
-
},
|
|
538
81
|
"verbose": {
|
|
539
82
|
"type": "boolean",
|
|
540
83
|
"description": "Enable verbose logging.",
|
|
541
84
|
"default": false
|
|
542
85
|
},
|
|
86
|
+
"version": {
|
|
87
|
+
"type": "boolean"
|
|
88
|
+
},
|
|
89
|
+
"help": {
|
|
90
|
+
"type": "boolean"
|
|
91
|
+
},
|
|
543
92
|
"mode": {
|
|
544
93
|
"type": "string",
|
|
545
94
|
"enum": [
|
|
@@ -606,6 +155,9 @@ const schema$1 = {
|
|
|
606
155
|
},
|
|
607
156
|
{
|
|
608
157
|
"$ref": "#/definitions/OllamaLLMService"
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"$ref": "#/definitions/AnthropicLLMService"
|
|
609
161
|
}
|
|
610
162
|
]
|
|
611
163
|
},
|
|
@@ -620,321 +172,151 @@ const schema$1 = {
|
|
|
620
172
|
"$ref": "#/definitions/LLMModel"
|
|
621
173
|
},
|
|
622
174
|
"fields": {
|
|
623
|
-
"
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
"
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
"items": {
|
|
637
|
-
"type": "string"
|
|
638
|
-
}
|
|
639
|
-
},
|
|
640
|
-
"metadata": {
|
|
641
|
-
"type": "object",
|
|
642
|
-
"additionalProperties": {}
|
|
643
|
-
},
|
|
644
|
-
"maxConcurrency": {
|
|
645
|
-
"type": "number",
|
|
646
|
-
"description": "The maximum number of concurrent calls that can be made. Defaults to `Infinity`, which means no limit."
|
|
647
|
-
},
|
|
648
|
-
"maxRetries": {
|
|
649
|
-
"type": "number",
|
|
650
|
-
"description": "The maximum number of retries that can be made for a single call, with an exponential backoff between each attempt. Defaults to 6."
|
|
651
|
-
},
|
|
652
|
-
"onFailedAttempt": {
|
|
653
|
-
"$ref": "#/definitions/FailedAttemptHandler",
|
|
654
|
-
"description": "Custom handler to handle failed attempts. Takes the originally thrown error object as input, and should itself throw an error if the input error is not retryable."
|
|
655
|
-
},
|
|
656
|
-
"callbackManager": {
|
|
657
|
-
"$ref": "#/definitions/CallbackManager",
|
|
658
|
-
"deprecated": "Use `callbacks` instead"
|
|
659
|
-
},
|
|
660
|
-
"cache": {
|
|
661
|
-
"anyOf": [
|
|
662
|
-
{
|
|
663
|
-
"$ref": "#/definitions/BaseCache"
|
|
664
|
-
},
|
|
665
|
-
{
|
|
666
|
-
"type": "boolean"
|
|
667
|
-
}
|
|
668
|
-
]
|
|
669
|
-
},
|
|
670
|
-
"concurrency": {
|
|
671
|
-
"type": "number",
|
|
672
|
-
"deprecated": "Use `maxConcurrency` instead"
|
|
673
|
-
},
|
|
674
|
-
"bestOf": {
|
|
675
|
-
"type": "number",
|
|
676
|
-
"description": "Generates `bestOf` completions server side and returns the \"best\""
|
|
677
|
-
},
|
|
678
|
-
"batchSize": {
|
|
679
|
-
"type": "number",
|
|
680
|
-
"description": "Batch size to use when passing multiple documents to generate"
|
|
681
|
-
},
|
|
682
|
-
"temperature": {
|
|
683
|
-
"type": "number",
|
|
684
|
-
"description": "Sampling temperature to use"
|
|
685
|
-
},
|
|
686
|
-
"maxTokens": {
|
|
687
|
-
"type": "number",
|
|
688
|
-
"description": "Maximum number of tokens to generate in the completion. -1 returns as many tokens as possible given the prompt and the model's maximum context size."
|
|
689
|
-
},
|
|
690
|
-
"topP": {
|
|
691
|
-
"type": "number",
|
|
692
|
-
"description": "Total probability mass of tokens to consider at each step"
|
|
693
|
-
},
|
|
694
|
-
"frequencyPenalty": {
|
|
695
|
-
"type": "number",
|
|
696
|
-
"description": "Penalizes repeated tokens according to frequency"
|
|
697
|
-
},
|
|
698
|
-
"presencePenalty": {
|
|
699
|
-
"type": "number",
|
|
700
|
-
"description": "Penalizes repeated tokens"
|
|
701
|
-
},
|
|
702
|
-
"n": {
|
|
703
|
-
"type": "number",
|
|
704
|
-
"description": "Number of completions to generate for each prompt"
|
|
705
|
-
},
|
|
706
|
-
"logitBias": {
|
|
707
|
-
"type": "object",
|
|
708
|
-
"additionalProperties": {
|
|
709
|
-
"type": "number"
|
|
710
|
-
},
|
|
711
|
-
"description": "Dictionary used to adjust the probability of specific tokens being generated"
|
|
712
|
-
},
|
|
713
|
-
"user": {
|
|
714
|
-
"type": "string",
|
|
715
|
-
"description": "Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse."
|
|
716
|
-
},
|
|
717
|
-
"streaming": {
|
|
718
|
-
"type": "boolean",
|
|
719
|
-
"description": "Whether to stream the results or not. Enabling disables tokenUsage reporting"
|
|
720
|
-
},
|
|
721
|
-
"streamUsage": {
|
|
722
|
-
"type": "boolean",
|
|
723
|
-
"description": "Whether or not to include token usage data in streamed chunks.",
|
|
724
|
-
"default": true
|
|
725
|
-
},
|
|
726
|
-
"modelName": {
|
|
727
|
-
"type": "string",
|
|
728
|
-
"description": "Model name to use Alias for `model`"
|
|
729
|
-
},
|
|
730
|
-
"model": {
|
|
731
|
-
"type": "string",
|
|
732
|
-
"description": "Model name to use"
|
|
733
|
-
},
|
|
734
|
-
"modelKwargs": {
|
|
735
|
-
"type": "object",
|
|
736
|
-
"description": "Holds any additional parameters that are valid to pass to {@link * https://platform.openai.com/docs/api-reference/completions/create | } * `openai.createCompletion`} that are not explicitly specified on this class."
|
|
737
|
-
},
|
|
738
|
-
"stop": {
|
|
739
|
-
"type": "array",
|
|
740
|
-
"items": {
|
|
741
|
-
"type": "string"
|
|
742
|
-
},
|
|
743
|
-
"description": "List of stop words to use when generating Alias for `stopSequences`"
|
|
744
|
-
},
|
|
745
|
-
"stopSequences": {
|
|
746
|
-
"type": "array",
|
|
747
|
-
"items": {
|
|
748
|
-
"type": "string"
|
|
749
|
-
},
|
|
750
|
-
"description": "List of stop words to use when generating"
|
|
751
|
-
},
|
|
752
|
-
"timeout": {
|
|
753
|
-
"type": "number",
|
|
754
|
-
"description": "Timeout to use when making requests to OpenAI."
|
|
755
|
-
},
|
|
756
|
-
"openAIApiKey": {
|
|
757
|
-
"type": "string",
|
|
758
|
-
"description": "API key to use when making requests to OpenAI. Defaults to the value of `OPENAI_API_KEY` environment variable. Alias for `apiKey`"
|
|
759
|
-
},
|
|
760
|
-
"apiKey": {
|
|
761
|
-
"type": "string",
|
|
762
|
-
"description": "API key to use when making requests to OpenAI. Defaults to the value of `OPENAI_API_KEY` environment variable."
|
|
763
|
-
}
|
|
175
|
+
"type": "object",
|
|
176
|
+
"additionalProperties": false,
|
|
177
|
+
"properties": {
|
|
178
|
+
"verbose": {
|
|
179
|
+
"type": "boolean"
|
|
180
|
+
},
|
|
181
|
+
"callbacks": {
|
|
182
|
+
"$ref": "#/definitions/Callbacks"
|
|
183
|
+
},
|
|
184
|
+
"tags": {
|
|
185
|
+
"type": "array",
|
|
186
|
+
"items": {
|
|
187
|
+
"type": "string"
|
|
764
188
|
}
|
|
765
189
|
},
|
|
766
|
-
{
|
|
190
|
+
"metadata": {
|
|
767
191
|
"type": "object",
|
|
768
|
-
"additionalProperties":
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
"maxRetries": {
|
|
791
|
-
"type": "number",
|
|
792
|
-
"description": "The maximum number of retries that can be made for a single call, with an exponential backoff between each attempt. Defaults to 6."
|
|
793
|
-
},
|
|
794
|
-
"onFailedAttempt": {
|
|
795
|
-
"$ref": "#/definitions/FailedAttemptHandler",
|
|
796
|
-
"description": "Custom handler to handle failed attempts. Takes the originally thrown error object as input, and should itself throw an error if the input error is not retryable."
|
|
797
|
-
},
|
|
798
|
-
"callbackManager": {
|
|
799
|
-
"$ref": "#/definitions/CallbackManager",
|
|
800
|
-
"deprecated": "Use `callbacks` instead"
|
|
801
|
-
},
|
|
802
|
-
"cache": {
|
|
803
|
-
"anyOf": [
|
|
804
|
-
{
|
|
805
|
-
"$ref": "#/definitions/BaseCache"
|
|
806
|
-
},
|
|
807
|
-
{
|
|
808
|
-
"type": "boolean"
|
|
809
|
-
}
|
|
810
|
-
]
|
|
811
|
-
},
|
|
812
|
-
"concurrency": {
|
|
813
|
-
"type": "number",
|
|
814
|
-
"deprecated": "Use `maxConcurrency` instead"
|
|
815
|
-
},
|
|
816
|
-
"embeddingOnly": {
|
|
817
|
-
"type": "boolean"
|
|
818
|
-
},
|
|
819
|
-
"f16KV": {
|
|
820
|
-
"type": "boolean"
|
|
821
|
-
},
|
|
822
|
-
"frequencyPenalty": {
|
|
823
|
-
"type": "number"
|
|
824
|
-
},
|
|
825
|
-
"headers": {
|
|
826
|
-
"type": "object",
|
|
827
|
-
"additionalProperties": {
|
|
828
|
-
"type": "string"
|
|
829
|
-
}
|
|
830
|
-
},
|
|
831
|
-
"keepAlive": {
|
|
832
|
-
"type": "string"
|
|
833
|
-
},
|
|
834
|
-
"logitsAll": {
|
|
835
|
-
"type": "boolean"
|
|
836
|
-
},
|
|
837
|
-
"lowVram": {
|
|
838
|
-
"type": "boolean"
|
|
839
|
-
},
|
|
840
|
-
"mainGpu": {
|
|
841
|
-
"type": "number"
|
|
842
|
-
},
|
|
843
|
-
"model": {
|
|
844
|
-
"type": "string"
|
|
845
|
-
},
|
|
846
|
-
"baseUrl": {
|
|
847
|
-
"type": "string"
|
|
848
|
-
},
|
|
849
|
-
"mirostat": {
|
|
850
|
-
"type": "number"
|
|
851
|
-
},
|
|
852
|
-
"mirostatEta": {
|
|
853
|
-
"type": "number"
|
|
854
|
-
},
|
|
855
|
-
"mirostatTau": {
|
|
856
|
-
"type": "number"
|
|
857
|
-
},
|
|
858
|
-
"numBatch": {
|
|
859
|
-
"type": "number"
|
|
860
|
-
},
|
|
861
|
-
"numCtx": {
|
|
862
|
-
"type": "number"
|
|
863
|
-
},
|
|
864
|
-
"numGpu": {
|
|
865
|
-
"type": "number"
|
|
866
|
-
},
|
|
867
|
-
"numGqa": {
|
|
868
|
-
"type": "number"
|
|
869
|
-
},
|
|
870
|
-
"numKeep": {
|
|
871
|
-
"type": "number"
|
|
872
|
-
},
|
|
873
|
-
"numPredict": {
|
|
874
|
-
"type": "number"
|
|
875
|
-
},
|
|
876
|
-
"numThread": {
|
|
877
|
-
"type": "number"
|
|
878
|
-
},
|
|
879
|
-
"penalizeNewline": {
|
|
880
|
-
"type": "boolean"
|
|
881
|
-
},
|
|
882
|
-
"presencePenalty": {
|
|
883
|
-
"type": "number"
|
|
884
|
-
},
|
|
885
|
-
"repeatLastN": {
|
|
886
|
-
"type": "number"
|
|
887
|
-
},
|
|
888
|
-
"repeatPenalty": {
|
|
889
|
-
"type": "number"
|
|
890
|
-
},
|
|
891
|
-
"ropeFrequencyBase": {
|
|
892
|
-
"type": "number"
|
|
893
|
-
},
|
|
894
|
-
"ropeFrequencyScale": {
|
|
895
|
-
"type": "number"
|
|
896
|
-
},
|
|
897
|
-
"temperature": {
|
|
898
|
-
"type": "number"
|
|
899
|
-
},
|
|
900
|
-
"stop": {
|
|
901
|
-
"type": "array",
|
|
902
|
-
"items": {
|
|
903
|
-
"type": "string"
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
"tfsZ": {
|
|
907
|
-
"type": "number"
|
|
908
|
-
},
|
|
909
|
-
"topK": {
|
|
910
|
-
"type": "number"
|
|
911
|
-
},
|
|
912
|
-
"topP": {
|
|
913
|
-
"type": "number"
|
|
914
|
-
},
|
|
915
|
-
"typicalP": {
|
|
916
|
-
"type": "number"
|
|
917
|
-
},
|
|
918
|
-
"useMLock": {
|
|
919
|
-
"type": "boolean"
|
|
920
|
-
},
|
|
921
|
-
"useMMap": {
|
|
922
|
-
"type": "boolean"
|
|
192
|
+
"additionalProperties": {}
|
|
193
|
+
},
|
|
194
|
+
"maxConcurrency": {
|
|
195
|
+
"type": "number",
|
|
196
|
+
"description": "The maximum number of concurrent calls that can be made. Defaults to `Infinity`, which means no limit."
|
|
197
|
+
},
|
|
198
|
+
"maxRetries": {
|
|
199
|
+
"type": "number",
|
|
200
|
+
"description": "The maximum number of retries that can be made for a single call, with an exponential backoff between each attempt. Defaults to 6."
|
|
201
|
+
},
|
|
202
|
+
"onFailedAttempt": {
|
|
203
|
+
"$ref": "#/definitions/FailedAttemptHandler",
|
|
204
|
+
"description": "Custom handler to handle failed attempts. Takes the originally thrown error object as input, and should itself throw an error if the input error is not retryable."
|
|
205
|
+
},
|
|
206
|
+
"callbackManager": {
|
|
207
|
+
"$ref": "#/definitions/CallbackManager",
|
|
208
|
+
"deprecated": "Use `callbacks` instead"
|
|
209
|
+
},
|
|
210
|
+
"cache": {
|
|
211
|
+
"anyOf": [
|
|
212
|
+
{
|
|
213
|
+
"$ref": "#/definitions/BaseCache"
|
|
923
214
|
},
|
|
924
|
-
|
|
215
|
+
{
|
|
925
216
|
"type": "boolean"
|
|
926
|
-
},
|
|
927
|
-
"format": {
|
|
928
|
-
"$ref": "#/definitions/StringWithAutocomplete%3C%22json%22%3E"
|
|
929
217
|
}
|
|
930
|
-
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
"concurrency": {
|
|
221
|
+
"type": "number",
|
|
222
|
+
"deprecated": "Use `maxConcurrency` instead"
|
|
223
|
+
},
|
|
224
|
+
"bestOf": {
|
|
225
|
+
"type": "number",
|
|
226
|
+
"description": "Generates `bestOf` completions server side and returns the \"best\""
|
|
227
|
+
},
|
|
228
|
+
"batchSize": {
|
|
229
|
+
"type": "number",
|
|
230
|
+
"description": "Batch size to use when passing multiple documents to generate"
|
|
231
|
+
},
|
|
232
|
+
"temperature": {
|
|
233
|
+
"type": "number",
|
|
234
|
+
"description": "Sampling temperature to use"
|
|
235
|
+
},
|
|
236
|
+
"maxTokens": {
|
|
237
|
+
"type": "number",
|
|
238
|
+
"description": "Maximum number of tokens to generate in the completion. -1 returns as many tokens as possible given the prompt and the model's maximum context size."
|
|
239
|
+
},
|
|
240
|
+
"topP": {
|
|
241
|
+
"type": "number",
|
|
242
|
+
"description": "Total probability mass of tokens to consider at each step"
|
|
243
|
+
},
|
|
244
|
+
"frequencyPenalty": {
|
|
245
|
+
"type": "number",
|
|
246
|
+
"description": "Penalizes repeated tokens according to frequency"
|
|
247
|
+
},
|
|
248
|
+
"presencePenalty": {
|
|
249
|
+
"type": "number",
|
|
250
|
+
"description": "Penalizes repeated tokens"
|
|
251
|
+
},
|
|
252
|
+
"n": {
|
|
253
|
+
"type": "number",
|
|
254
|
+
"description": "Number of completions to generate for each prompt"
|
|
255
|
+
},
|
|
256
|
+
"logitBias": {
|
|
257
|
+
"type": "object",
|
|
258
|
+
"additionalProperties": {
|
|
259
|
+
"type": "number"
|
|
260
|
+
},
|
|
261
|
+
"description": "Dictionary used to adjust the probability of specific tokens being generated"
|
|
262
|
+
},
|
|
263
|
+
"user": {
|
|
264
|
+
"type": "string",
|
|
265
|
+
"description": "Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse."
|
|
266
|
+
},
|
|
267
|
+
"streaming": {
|
|
268
|
+
"type": "boolean",
|
|
269
|
+
"description": "Whether to stream the results or not. Enabling disables tokenUsage reporting"
|
|
270
|
+
},
|
|
271
|
+
"streamUsage": {
|
|
272
|
+
"type": "boolean",
|
|
273
|
+
"description": "Whether or not to include token usage data in streamed chunks.",
|
|
274
|
+
"default": true
|
|
275
|
+
},
|
|
276
|
+
"modelName": {
|
|
277
|
+
"type": "string",
|
|
278
|
+
"description": "Model name to use Alias for `model`"
|
|
279
|
+
},
|
|
280
|
+
"model": {
|
|
281
|
+
"type": "string",
|
|
282
|
+
"description": "Model name to use"
|
|
283
|
+
},
|
|
284
|
+
"modelKwargs": {
|
|
285
|
+
"type": "object",
|
|
286
|
+
"description": "Holds any additional parameters that are valid to pass to {@link * https://platform.openai.com/docs/api-reference/completions/create | } * `openai.createCompletion`} that are not explicitly specified on this class."
|
|
287
|
+
},
|
|
288
|
+
"stop": {
|
|
289
|
+
"type": "array",
|
|
290
|
+
"items": {
|
|
291
|
+
"type": "string"
|
|
292
|
+
},
|
|
293
|
+
"description": "List of stop words to use when generating Alias for `stopSequences`"
|
|
294
|
+
},
|
|
295
|
+
"stopSequences": {
|
|
296
|
+
"type": "array",
|
|
297
|
+
"items": {
|
|
298
|
+
"type": "string"
|
|
299
|
+
},
|
|
300
|
+
"description": "List of stop words to use when generating"
|
|
301
|
+
},
|
|
302
|
+
"timeout": {
|
|
303
|
+
"type": "number",
|
|
304
|
+
"description": "Timeout to use when making requests to OpenAI."
|
|
305
|
+
},
|
|
306
|
+
"openAIApiKey": {
|
|
307
|
+
"type": "string",
|
|
308
|
+
"description": "API key to use when making requests to OpenAI. Defaults to the value of `OPENAI_API_KEY` environment variable. Alias for `apiKey`"
|
|
309
|
+
},
|
|
310
|
+
"apiKey": {
|
|
311
|
+
"type": "string",
|
|
312
|
+
"description": "API key to use when making requests to OpenAI. Defaults to the value of `OPENAI_API_KEY` environment variable."
|
|
931
313
|
}
|
|
932
|
-
|
|
314
|
+
}
|
|
933
315
|
},
|
|
934
316
|
"tokenLimit": {
|
|
935
317
|
"type": "number",
|
|
936
318
|
"description": "The maximum number of tokens per request.",
|
|
937
|
-
"default":
|
|
319
|
+
"default": 2048
|
|
938
320
|
},
|
|
939
321
|
"temperature": {
|
|
940
322
|
"type": "number",
|
|
@@ -1044,7 +426,8 @@ const schema$1 = {
|
|
|
1044
426
|
"type": "string",
|
|
1045
427
|
"enum": [
|
|
1046
428
|
"openai",
|
|
1047
|
-
"ollama"
|
|
429
|
+
"ollama",
|
|
430
|
+
"anthropic"
|
|
1048
431
|
]
|
|
1049
432
|
},
|
|
1050
433
|
"LLMModel": {
|
|
@@ -1112,51 +495,76 @@ const schema$1 = {
|
|
|
1112
495
|
},
|
|
1113
496
|
{
|
|
1114
497
|
"$ref": "#/definitions/OllamaModel"
|
|
498
|
+
},
|
|
499
|
+
{
|
|
500
|
+
"$ref": "#/definitions/AnthropicModel"
|
|
1115
501
|
}
|
|
1116
502
|
]
|
|
1117
503
|
},
|
|
1118
504
|
"OllamaModel": {
|
|
1119
505
|
"type": "string",
|
|
1120
506
|
"enum": [
|
|
1121
|
-
"
|
|
1122
|
-
"
|
|
1123
|
-
"
|
|
1124
|
-
"mistral",
|
|
1125
|
-
"llama2",
|
|
1126
|
-
"codellama",
|
|
1127
|
-
"codellama:7b",
|
|
507
|
+
"codegemma:2b",
|
|
508
|
+
"codegemma:7b-code",
|
|
509
|
+
"codegemma",
|
|
1128
510
|
"codellama:13b",
|
|
1129
511
|
"codellama:34b",
|
|
1130
512
|
"codellama:70b",
|
|
1131
|
-
"
|
|
513
|
+
"codellama:7b",
|
|
514
|
+
"codellama:instruct",
|
|
515
|
+
"codellama:latest",
|
|
516
|
+
"codellama",
|
|
517
|
+
"gemma:2b",
|
|
518
|
+
"gemma:7b",
|
|
519
|
+
"gemma:latest",
|
|
520
|
+
"gemma",
|
|
1132
521
|
"llama2:13b",
|
|
1133
522
|
"llama2:70b",
|
|
1134
|
-
"
|
|
523
|
+
"llama2:chat",
|
|
524
|
+
"llama2:latest",
|
|
525
|
+
"llama2:text",
|
|
526
|
+
"llama2",
|
|
527
|
+
"llama3:70b-text",
|
|
528
|
+
"llama3:70b",
|
|
1135
529
|
"llama3:latest",
|
|
1136
530
|
"llama3:text",
|
|
1137
|
-
"llama3:70b",
|
|
1138
|
-
"llama3:
|
|
1139
|
-
"
|
|
1140
|
-
"
|
|
1141
|
-
"
|
|
1142
|
-
"
|
|
1143
|
-
"
|
|
1144
|
-
"
|
|
1145
|
-
"
|
|
1146
|
-
"
|
|
1147
|
-
"
|
|
531
|
+
"llama3.1:70b",
|
|
532
|
+
"llama3.1:8b",
|
|
533
|
+
"llama3.1:latest",
|
|
534
|
+
"llama3.2",
|
|
535
|
+
"llama3.2:latest",
|
|
536
|
+
"llama3.2:1b",
|
|
537
|
+
"llama3.2:3b",
|
|
538
|
+
"llama3.2:1b-instruct-fp16",
|
|
539
|
+
"llama3.2:1b-instruct-q3_K_M",
|
|
540
|
+
"llama3",
|
|
541
|
+
"mistral:7b",
|
|
542
|
+
"mistral:latest",
|
|
543
|
+
"mistral:text",
|
|
544
|
+
"mistral",
|
|
545
|
+
"phi3:14b",
|
|
546
|
+
"phi3:3.8b",
|
|
547
|
+
"phi3:instruct",
|
|
1148
548
|
"phi3:medium-128k",
|
|
1149
|
-
"
|
|
1150
|
-
"
|
|
1151
|
-
"
|
|
1152
|
-
"qwen2:1.5b",
|
|
549
|
+
"phi3:medium-4k",
|
|
550
|
+
"phi3:medium",
|
|
551
|
+
"phi3",
|
|
1153
552
|
"qwen2:0.5b",
|
|
1154
|
-
"
|
|
1155
|
-
"
|
|
1156
|
-
"
|
|
1157
|
-
"
|
|
1158
|
-
|
|
1159
|
-
|
|
553
|
+
"qwen2:1.5b",
|
|
554
|
+
"qwen2:72b-text",
|
|
555
|
+
"qwen2:72b",
|
|
556
|
+
"qwen2"
|
|
557
|
+
]
|
|
558
|
+
},
|
|
559
|
+
"AnthropicModel": {
|
|
560
|
+
"type": "string",
|
|
561
|
+
"enum": [
|
|
562
|
+
"claude-3-5-sonnet-20240620",
|
|
563
|
+
"claude-3-opus-20240229",
|
|
564
|
+
"claude-3-sonnet-20240229",
|
|
565
|
+
"claude-3-haiku-20240307",
|
|
566
|
+
"claude-2.1",
|
|
567
|
+
"claude-2.0"
|
|
1160
568
|
]
|
|
1161
569
|
},
|
|
1162
570
|
"Callbacks": {
|
|
@@ -1321,349 +729,335 @@ const schema$1 = {
|
|
|
1321
729
|
"additionalProperties": false,
|
|
1322
730
|
"description": "Base class for all caches. All caches should extend this class."
|
|
1323
731
|
},
|
|
1324
|
-
"
|
|
1325
|
-
"
|
|
1326
|
-
|
|
732
|
+
"OllamaLLMService": {
|
|
733
|
+
"type": "object",
|
|
734
|
+
"additionalProperties": false,
|
|
735
|
+
"properties": {
|
|
736
|
+
"provider": {
|
|
737
|
+
"$ref": "#/definitions/LLMProvider"
|
|
738
|
+
},
|
|
739
|
+
"model": {
|
|
740
|
+
"$ref": "#/definitions/LLMModel"
|
|
741
|
+
},
|
|
742
|
+
"endpoint": {
|
|
1327
743
|
"type": "string"
|
|
1328
744
|
},
|
|
1329
|
-
{
|
|
1330
|
-
"type": "
|
|
1331
|
-
"
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
745
|
+
"fields": {
|
|
746
|
+
"type": "object",
|
|
747
|
+
"additionalProperties": false,
|
|
748
|
+
"properties": {
|
|
749
|
+
"verbose": {
|
|
750
|
+
"type": "boolean"
|
|
751
|
+
},
|
|
752
|
+
"callbacks": {
|
|
753
|
+
"$ref": "#/definitions/Callbacks"
|
|
754
|
+
},
|
|
755
|
+
"tags": {
|
|
756
|
+
"type": "array",
|
|
757
|
+
"items": {
|
|
758
|
+
"type": "string"
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
"metadata": {
|
|
762
|
+
"type": "object",
|
|
763
|
+
"additionalProperties": {}
|
|
764
|
+
},
|
|
765
|
+
"maxConcurrency": {
|
|
766
|
+
"type": "number",
|
|
767
|
+
"description": "The maximum number of concurrent calls that can be made. Defaults to `Infinity`, which means no limit."
|
|
768
|
+
},
|
|
769
|
+
"maxRetries": {
|
|
770
|
+
"type": "number",
|
|
771
|
+
"description": "The maximum number of retries that can be made for a single call, with an exponential backoff between each attempt. Defaults to 6."
|
|
772
|
+
},
|
|
773
|
+
"onFailedAttempt": {
|
|
774
|
+
"$ref": "#/definitions/FailedAttemptHandler",
|
|
775
|
+
"description": "Custom handler to handle failed attempts. Takes the originally thrown error object as input, and should itself throw an error if the input error is not retryable."
|
|
776
|
+
},
|
|
777
|
+
"callbackManager": {
|
|
778
|
+
"$ref": "#/definitions/CallbackManager",
|
|
779
|
+
"deprecated": "Use `callbacks` instead"
|
|
780
|
+
},
|
|
781
|
+
"cache": {
|
|
782
|
+
"anyOf": [
|
|
783
|
+
{
|
|
784
|
+
"$ref": "#/definitions/BaseCache"
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
"type": "boolean"
|
|
788
|
+
}
|
|
789
|
+
]
|
|
790
|
+
},
|
|
791
|
+
"concurrency": {
|
|
792
|
+
"type": "number",
|
|
793
|
+
"deprecated": "Use `maxConcurrency` instead"
|
|
794
|
+
},
|
|
795
|
+
"embeddingOnly": {
|
|
796
|
+
"type": "boolean"
|
|
797
|
+
},
|
|
798
|
+
"f16KV": {
|
|
799
|
+
"type": "boolean"
|
|
800
|
+
},
|
|
801
|
+
"frequencyPenalty": {
|
|
802
|
+
"type": "number"
|
|
803
|
+
},
|
|
804
|
+
"headers": {
|
|
805
|
+
"type": "object",
|
|
806
|
+
"additionalProperties": {
|
|
807
|
+
"type": "string"
|
|
808
|
+
}
|
|
809
|
+
},
|
|
810
|
+
"keepAlive": {
|
|
811
|
+
"type": "string"
|
|
812
|
+
},
|
|
813
|
+
"logitsAll": {
|
|
814
|
+
"type": "boolean"
|
|
815
|
+
},
|
|
816
|
+
"lowVram": {
|
|
817
|
+
"type": "boolean"
|
|
818
|
+
},
|
|
819
|
+
"mainGpu": {
|
|
820
|
+
"type": "number"
|
|
821
|
+
},
|
|
822
|
+
"model": {
|
|
823
|
+
"type": "string"
|
|
824
|
+
},
|
|
825
|
+
"baseUrl": {
|
|
826
|
+
"type": "string"
|
|
827
|
+
},
|
|
828
|
+
"mirostat": {
|
|
829
|
+
"type": "number"
|
|
830
|
+
},
|
|
831
|
+
"mirostatEta": {
|
|
832
|
+
"type": "number"
|
|
833
|
+
},
|
|
834
|
+
"mirostatTau": {
|
|
835
|
+
"type": "number"
|
|
836
|
+
},
|
|
837
|
+
"numBatch": {
|
|
838
|
+
"type": "number"
|
|
839
|
+
},
|
|
840
|
+
"numCtx": {
|
|
841
|
+
"type": "number"
|
|
842
|
+
},
|
|
843
|
+
"numGpu": {
|
|
844
|
+
"type": "number"
|
|
845
|
+
},
|
|
846
|
+
"numGqa": {
|
|
847
|
+
"type": "number"
|
|
848
|
+
},
|
|
849
|
+
"numKeep": {
|
|
850
|
+
"type": "number"
|
|
851
|
+
},
|
|
852
|
+
"numPredict": {
|
|
853
|
+
"type": "number"
|
|
854
|
+
},
|
|
855
|
+
"numThread": {
|
|
856
|
+
"type": "number"
|
|
857
|
+
},
|
|
858
|
+
"penalizeNewline": {
|
|
859
|
+
"type": "boolean"
|
|
860
|
+
},
|
|
861
|
+
"presencePenalty": {
|
|
862
|
+
"type": "number"
|
|
863
|
+
},
|
|
864
|
+
"repeatLastN": {
|
|
865
|
+
"type": "number"
|
|
866
|
+
},
|
|
867
|
+
"repeatPenalty": {
|
|
868
|
+
"type": "number"
|
|
869
|
+
},
|
|
870
|
+
"ropeFrequencyBase": {
|
|
871
|
+
"type": "number"
|
|
872
|
+
},
|
|
873
|
+
"ropeFrequencyScale": {
|
|
874
|
+
"type": "number"
|
|
875
|
+
},
|
|
876
|
+
"temperature": {
|
|
877
|
+
"type": "number"
|
|
878
|
+
},
|
|
879
|
+
"stop": {
|
|
880
|
+
"type": "array",
|
|
881
|
+
"items": {
|
|
882
|
+
"type": "string"
|
|
883
|
+
}
|
|
884
|
+
},
|
|
885
|
+
"tfsZ": {
|
|
886
|
+
"type": "number"
|
|
887
|
+
},
|
|
888
|
+
"topK": {
|
|
889
|
+
"type": "number"
|
|
890
|
+
},
|
|
891
|
+
"topP": {
|
|
892
|
+
"type": "number"
|
|
893
|
+
},
|
|
894
|
+
"typicalP": {
|
|
895
|
+
"type": "number"
|
|
896
|
+
},
|
|
897
|
+
"useMLock": {
|
|
898
|
+
"type": "boolean"
|
|
899
|
+
},
|
|
900
|
+
"useMMap": {
|
|
901
|
+
"type": "boolean"
|
|
902
|
+
},
|
|
903
|
+
"vocabOnly": {
|
|
904
|
+
"type": "boolean"
|
|
905
|
+
},
|
|
906
|
+
"format": {
|
|
907
|
+
"$ref": "#/definitions/StringWithAutocomplete%3C%22json%22%3E"
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
},
|
|
911
|
+
"tokenLimit": {
|
|
912
|
+
"type": "number",
|
|
913
|
+
"description": "The maximum number of tokens per request.",
|
|
914
|
+
"default": 2048
|
|
1344
915
|
},
|
|
1345
|
-
"
|
|
1346
|
-
"
|
|
916
|
+
"temperature": {
|
|
917
|
+
"type": "number",
|
|
918
|
+
"description": "The temperature value controls the randomness of the generated output. Higher values (e.g., 0.8) make the output more random, while lower values (e.g., 0.2) make it more deterministic.",
|
|
919
|
+
"default": 0.4
|
|
1347
920
|
},
|
|
1348
|
-
"
|
|
1349
|
-
"type": "
|
|
921
|
+
"maxConcurrent": {
|
|
922
|
+
"type": "number",
|
|
923
|
+
"description": "The maximum number of requests to make concurrently.",
|
|
924
|
+
"default": 6
|
|
1350
925
|
},
|
|
1351
|
-
"
|
|
926
|
+
"authentication": {
|
|
1352
927
|
"anyOf": [
|
|
1353
928
|
{
|
|
1354
929
|
"type": "object",
|
|
1355
|
-
"additionalProperties": false,
|
|
1356
930
|
"properties": {
|
|
1357
|
-
"
|
|
1358
|
-
"type": "boolean"
|
|
1359
|
-
},
|
|
1360
|
-
"callbacks": {
|
|
1361
|
-
"$ref": "#/definitions/Callbacks"
|
|
1362
|
-
},
|
|
1363
|
-
"tags": {
|
|
1364
|
-
"type": "array",
|
|
1365
|
-
"items": {
|
|
1366
|
-
"type": "string"
|
|
1367
|
-
}
|
|
1368
|
-
},
|
|
1369
|
-
"metadata": {
|
|
1370
|
-
"type": "object",
|
|
1371
|
-
"additionalProperties": {}
|
|
1372
|
-
},
|
|
1373
|
-
"maxConcurrency": {
|
|
1374
|
-
"type": "number",
|
|
1375
|
-
"description": "The maximum number of concurrent calls that can be made. Defaults to `Infinity`, which means no limit."
|
|
1376
|
-
},
|
|
1377
|
-
"maxRetries": {
|
|
1378
|
-
"type": "number",
|
|
1379
|
-
"description": "The maximum number of retries that can be made for a single call, with an exponential backoff between each attempt. Defaults to 6."
|
|
1380
|
-
},
|
|
1381
|
-
"onFailedAttempt": {
|
|
1382
|
-
"$ref": "#/definitions/FailedAttemptHandler",
|
|
1383
|
-
"description": "Custom handler to handle failed attempts. Takes the originally thrown error object as input, and should itself throw an error if the input error is not retryable."
|
|
1384
|
-
},
|
|
1385
|
-
"callbackManager": {
|
|
1386
|
-
"$ref": "#/definitions/CallbackManager",
|
|
1387
|
-
"deprecated": "Use `callbacks` instead"
|
|
1388
|
-
},
|
|
1389
|
-
"cache": {
|
|
1390
|
-
"anyOf": [
|
|
1391
|
-
{
|
|
1392
|
-
"$ref": "#/definitions/BaseCache"
|
|
1393
|
-
},
|
|
1394
|
-
{
|
|
1395
|
-
"type": "boolean"
|
|
1396
|
-
}
|
|
1397
|
-
]
|
|
1398
|
-
},
|
|
1399
|
-
"concurrency": {
|
|
1400
|
-
"type": "number",
|
|
1401
|
-
"deprecated": "Use `maxConcurrency` instead"
|
|
1402
|
-
},
|
|
1403
|
-
"bestOf": {
|
|
1404
|
-
"type": "number",
|
|
1405
|
-
"description": "Generates `bestOf` completions server side and returns the \"best\""
|
|
1406
|
-
},
|
|
1407
|
-
"batchSize": {
|
|
1408
|
-
"type": "number",
|
|
1409
|
-
"description": "Batch size to use when passing multiple documents to generate"
|
|
1410
|
-
},
|
|
1411
|
-
"temperature": {
|
|
1412
|
-
"type": "number",
|
|
1413
|
-
"description": "Sampling temperature to use"
|
|
1414
|
-
},
|
|
1415
|
-
"maxTokens": {
|
|
1416
|
-
"type": "number",
|
|
1417
|
-
"description": "Maximum number of tokens to generate in the completion. -1 returns as many tokens as possible given the prompt and the model's maximum context size."
|
|
1418
|
-
},
|
|
1419
|
-
"topP": {
|
|
1420
|
-
"type": "number",
|
|
1421
|
-
"description": "Total probability mass of tokens to consider at each step"
|
|
1422
|
-
},
|
|
1423
|
-
"frequencyPenalty": {
|
|
1424
|
-
"type": "number",
|
|
1425
|
-
"description": "Penalizes repeated tokens according to frequency"
|
|
1426
|
-
},
|
|
1427
|
-
"presencePenalty": {
|
|
1428
|
-
"type": "number",
|
|
1429
|
-
"description": "Penalizes repeated tokens"
|
|
1430
|
-
},
|
|
1431
|
-
"n": {
|
|
1432
|
-
"type": "number",
|
|
1433
|
-
"description": "Number of completions to generate for each prompt"
|
|
1434
|
-
},
|
|
1435
|
-
"logitBias": {
|
|
1436
|
-
"type": "object",
|
|
1437
|
-
"additionalProperties": {
|
|
1438
|
-
"type": "number"
|
|
1439
|
-
},
|
|
1440
|
-
"description": "Dictionary used to adjust the probability of specific tokens being generated"
|
|
1441
|
-
},
|
|
1442
|
-
"user": {
|
|
1443
|
-
"type": "string",
|
|
1444
|
-
"description": "Unique string identifier representing your end-user, which can help OpenAI to monitor and detect abuse."
|
|
1445
|
-
},
|
|
1446
|
-
"streaming": {
|
|
1447
|
-
"type": "boolean",
|
|
1448
|
-
"description": "Whether to stream the results or not. Enabling disables tokenUsage reporting"
|
|
1449
|
-
},
|
|
1450
|
-
"streamUsage": {
|
|
1451
|
-
"type": "boolean",
|
|
1452
|
-
"description": "Whether or not to include token usage data in streamed chunks.",
|
|
1453
|
-
"default": true
|
|
1454
|
-
},
|
|
1455
|
-
"modelName": {
|
|
931
|
+
"type": {
|
|
1456
932
|
"type": "string",
|
|
1457
|
-
"
|
|
933
|
+
"const": "None"
|
|
1458
934
|
},
|
|
1459
|
-
"
|
|
935
|
+
"credentials": {
|
|
936
|
+
"not": {}
|
|
937
|
+
}
|
|
938
|
+
},
|
|
939
|
+
"required": [
|
|
940
|
+
"type"
|
|
941
|
+
],
|
|
942
|
+
"additionalProperties": false
|
|
943
|
+
},
|
|
944
|
+
{
|
|
945
|
+
"type": "object",
|
|
946
|
+
"properties": {
|
|
947
|
+
"type": {
|
|
1460
948
|
"type": "string",
|
|
1461
|
-
"
|
|
949
|
+
"const": "OAuth"
|
|
1462
950
|
},
|
|
1463
|
-
"
|
|
951
|
+
"credentials": {
|
|
1464
952
|
"type": "object",
|
|
1465
|
-
"
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
"type": "array",
|
|
1476
|
-
"items": {
|
|
1477
|
-
"type": "string"
|
|
953
|
+
"properties": {
|
|
954
|
+
"clientId": {
|
|
955
|
+
"type": "string"
|
|
956
|
+
},
|
|
957
|
+
"clientSecret": {
|
|
958
|
+
"type": "string"
|
|
959
|
+
},
|
|
960
|
+
"token": {
|
|
961
|
+
"type": "string"
|
|
962
|
+
}
|
|
1478
963
|
},
|
|
1479
|
-
"
|
|
1480
|
-
},
|
|
1481
|
-
"timeout": {
|
|
1482
|
-
"type": "number",
|
|
1483
|
-
"description": "Timeout to use when making requests to OpenAI."
|
|
1484
|
-
},
|
|
1485
|
-
"openAIApiKey": {
|
|
1486
|
-
"type": "string",
|
|
1487
|
-
"description": "API key to use when making requests to OpenAI. Defaults to the value of `OPENAI_API_KEY` environment variable. Alias for `apiKey`"
|
|
1488
|
-
},
|
|
1489
|
-
"apiKey": {
|
|
1490
|
-
"type": "string",
|
|
1491
|
-
"description": "API key to use when making requests to OpenAI. Defaults to the value of `OPENAI_API_KEY` environment variable."
|
|
964
|
+
"additionalProperties": false
|
|
1492
965
|
}
|
|
1493
|
-
}
|
|
966
|
+
},
|
|
967
|
+
"required": [
|
|
968
|
+
"type",
|
|
969
|
+
"credentials"
|
|
970
|
+
],
|
|
971
|
+
"additionalProperties": false
|
|
1494
972
|
},
|
|
1495
973
|
{
|
|
1496
974
|
"type": "object",
|
|
1497
|
-
"additionalProperties": false,
|
|
1498
975
|
"properties": {
|
|
1499
|
-
"
|
|
1500
|
-
"type": "
|
|
1501
|
-
|
|
1502
|
-
"callbacks": {
|
|
1503
|
-
"$ref": "#/definitions/Callbacks"
|
|
1504
|
-
},
|
|
1505
|
-
"tags": {
|
|
1506
|
-
"type": "array",
|
|
1507
|
-
"items": {
|
|
1508
|
-
"type": "string"
|
|
1509
|
-
}
|
|
976
|
+
"type": {
|
|
977
|
+
"type": "string",
|
|
978
|
+
"const": "APIKey"
|
|
1510
979
|
},
|
|
1511
|
-
"
|
|
980
|
+
"credentials": {
|
|
1512
981
|
"type": "object",
|
|
1513
|
-
"
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
"type": "number",
|
|
1517
|
-
"description": "The maximum number of concurrent calls that can be made. Defaults to `Infinity`, which means no limit."
|
|
1518
|
-
},
|
|
1519
|
-
"maxRetries": {
|
|
1520
|
-
"type": "number",
|
|
1521
|
-
"description": "The maximum number of retries that can be made for a single call, with an exponential backoff between each attempt. Defaults to 6."
|
|
1522
|
-
},
|
|
1523
|
-
"onFailedAttempt": {
|
|
1524
|
-
"$ref": "#/definitions/FailedAttemptHandler",
|
|
1525
|
-
"description": "Custom handler to handle failed attempts. Takes the originally thrown error object as input, and should itself throw an error if the input error is not retryable."
|
|
1526
|
-
},
|
|
1527
|
-
"callbackManager": {
|
|
1528
|
-
"$ref": "#/definitions/CallbackManager",
|
|
1529
|
-
"deprecated": "Use `callbacks` instead"
|
|
1530
|
-
},
|
|
1531
|
-
"cache": {
|
|
1532
|
-
"anyOf": [
|
|
1533
|
-
{
|
|
1534
|
-
"$ref": "#/definitions/BaseCache"
|
|
1535
|
-
},
|
|
1536
|
-
{
|
|
1537
|
-
"type": "boolean"
|
|
982
|
+
"properties": {
|
|
983
|
+
"apiKey": {
|
|
984
|
+
"type": "string"
|
|
1538
985
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
"
|
|
1544
|
-
},
|
|
1545
|
-
"embeddingOnly": {
|
|
1546
|
-
"type": "boolean"
|
|
1547
|
-
},
|
|
1548
|
-
"f16KV": {
|
|
1549
|
-
"type": "boolean"
|
|
1550
|
-
},
|
|
1551
|
-
"frequencyPenalty": {
|
|
1552
|
-
"type": "number"
|
|
1553
|
-
},
|
|
1554
|
-
"headers": {
|
|
1555
|
-
"type": "object",
|
|
1556
|
-
"additionalProperties": {
|
|
1557
|
-
"type": "string"
|
|
1558
|
-
}
|
|
1559
|
-
},
|
|
1560
|
-
"keepAlive": {
|
|
1561
|
-
"type": "string"
|
|
1562
|
-
},
|
|
1563
|
-
"logitsAll": {
|
|
1564
|
-
"type": "boolean"
|
|
1565
|
-
},
|
|
1566
|
-
"lowVram": {
|
|
1567
|
-
"type": "boolean"
|
|
1568
|
-
},
|
|
1569
|
-
"mainGpu": {
|
|
1570
|
-
"type": "number"
|
|
1571
|
-
},
|
|
1572
|
-
"model": {
|
|
1573
|
-
"type": "string"
|
|
1574
|
-
},
|
|
1575
|
-
"baseUrl": {
|
|
1576
|
-
"type": "string"
|
|
1577
|
-
},
|
|
1578
|
-
"mirostat": {
|
|
1579
|
-
"type": "number"
|
|
1580
|
-
},
|
|
1581
|
-
"mirostatEta": {
|
|
1582
|
-
"type": "number"
|
|
1583
|
-
},
|
|
1584
|
-
"mirostatTau": {
|
|
1585
|
-
"type": "number"
|
|
1586
|
-
},
|
|
1587
|
-
"numBatch": {
|
|
1588
|
-
"type": "number"
|
|
1589
|
-
},
|
|
1590
|
-
"numCtx": {
|
|
1591
|
-
"type": "number"
|
|
1592
|
-
},
|
|
1593
|
-
"numGpu": {
|
|
1594
|
-
"type": "number"
|
|
1595
|
-
},
|
|
1596
|
-
"numGqa": {
|
|
1597
|
-
"type": "number"
|
|
1598
|
-
},
|
|
1599
|
-
"numKeep": {
|
|
1600
|
-
"type": "number"
|
|
1601
|
-
},
|
|
1602
|
-
"numPredict": {
|
|
1603
|
-
"type": "number"
|
|
1604
|
-
},
|
|
1605
|
-
"numThread": {
|
|
1606
|
-
"type": "number"
|
|
1607
|
-
},
|
|
1608
|
-
"penalizeNewline": {
|
|
1609
|
-
"type": "boolean"
|
|
1610
|
-
},
|
|
1611
|
-
"presencePenalty": {
|
|
1612
|
-
"type": "number"
|
|
1613
|
-
},
|
|
1614
|
-
"repeatLastN": {
|
|
1615
|
-
"type": "number"
|
|
1616
|
-
},
|
|
1617
|
-
"repeatPenalty": {
|
|
1618
|
-
"type": "number"
|
|
1619
|
-
},
|
|
1620
|
-
"ropeFrequencyBase": {
|
|
1621
|
-
"type": "number"
|
|
1622
|
-
},
|
|
1623
|
-
"ropeFrequencyScale": {
|
|
1624
|
-
"type": "number"
|
|
1625
|
-
},
|
|
1626
|
-
"temperature": {
|
|
1627
|
-
"type": "number"
|
|
1628
|
-
},
|
|
1629
|
-
"stop": {
|
|
1630
|
-
"type": "array",
|
|
1631
|
-
"items": {
|
|
1632
|
-
"type": "string"
|
|
1633
|
-
}
|
|
1634
|
-
},
|
|
1635
|
-
"tfsZ": {
|
|
1636
|
-
"type": "number"
|
|
1637
|
-
},
|
|
1638
|
-
"topK": {
|
|
1639
|
-
"type": "number"
|
|
1640
|
-
},
|
|
1641
|
-
"topP": {
|
|
1642
|
-
"type": "number"
|
|
1643
|
-
},
|
|
1644
|
-
"typicalP": {
|
|
1645
|
-
"type": "number"
|
|
1646
|
-
},
|
|
1647
|
-
"useMLock": {
|
|
1648
|
-
"type": "boolean"
|
|
1649
|
-
},
|
|
1650
|
-
"useMMap": {
|
|
1651
|
-
"type": "boolean"
|
|
1652
|
-
},
|
|
1653
|
-
"vocabOnly": {
|
|
1654
|
-
"type": "boolean"
|
|
1655
|
-
},
|
|
1656
|
-
"format": {
|
|
1657
|
-
"$ref": "#/definitions/StringWithAutocomplete%3C%22json%22%3E"
|
|
986
|
+
},
|
|
987
|
+
"required": [
|
|
988
|
+
"apiKey"
|
|
989
|
+
],
|
|
990
|
+
"additionalProperties": false
|
|
1658
991
|
}
|
|
1659
|
-
}
|
|
992
|
+
},
|
|
993
|
+
"required": [
|
|
994
|
+
"type",
|
|
995
|
+
"credentials"
|
|
996
|
+
],
|
|
997
|
+
"additionalProperties": false
|
|
998
|
+
}
|
|
999
|
+
]
|
|
1000
|
+
},
|
|
1001
|
+
"requestOptions": {
|
|
1002
|
+
"type": "object",
|
|
1003
|
+
"properties": {
|
|
1004
|
+
"timeout": {
|
|
1005
|
+
"type": "number"
|
|
1006
|
+
},
|
|
1007
|
+
"maxRetries": {
|
|
1008
|
+
"type": "number"
|
|
1660
1009
|
}
|
|
1010
|
+
},
|
|
1011
|
+
"additionalProperties": false
|
|
1012
|
+
}
|
|
1013
|
+
},
|
|
1014
|
+
"required": [
|
|
1015
|
+
"authentication",
|
|
1016
|
+
"endpoint",
|
|
1017
|
+
"model",
|
|
1018
|
+
"provider"
|
|
1019
|
+
]
|
|
1020
|
+
},
|
|
1021
|
+
"StringWithAutocomplete<\"json\">": {
|
|
1022
|
+
"anyOf": [
|
|
1023
|
+
{
|
|
1024
|
+
"type": "string"
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
"type": "string",
|
|
1028
|
+
"enum": [
|
|
1029
|
+
"json"
|
|
1661
1030
|
]
|
|
1031
|
+
}
|
|
1032
|
+
],
|
|
1033
|
+
"description": "Represents a string value with autocompleted, but not required, suggestions."
|
|
1034
|
+
},
|
|
1035
|
+
"AnthropicLLMService": {
|
|
1036
|
+
"type": "object",
|
|
1037
|
+
"additionalProperties": false,
|
|
1038
|
+
"properties": {
|
|
1039
|
+
"provider": {
|
|
1040
|
+
"$ref": "#/definitions/LLMProvider"
|
|
1041
|
+
},
|
|
1042
|
+
"model": {
|
|
1043
|
+
"$ref": "#/definitions/LLMModel"
|
|
1044
|
+
},
|
|
1045
|
+
"fields": {
|
|
1046
|
+
"type": "object",
|
|
1047
|
+
"properties": {
|
|
1048
|
+
"temperature": {
|
|
1049
|
+
"type": "number"
|
|
1050
|
+
},
|
|
1051
|
+
"maxTokens": {
|
|
1052
|
+
"type": "number"
|
|
1053
|
+
}
|
|
1054
|
+
},
|
|
1055
|
+
"additionalProperties": false
|
|
1662
1056
|
},
|
|
1663
1057
|
"tokenLimit": {
|
|
1664
1058
|
"type": "number",
|
|
1665
1059
|
"description": "The maximum number of tokens per request.",
|
|
1666
|
-
"default":
|
|
1060
|
+
"default": 2048
|
|
1667
1061
|
},
|
|
1668
1062
|
"temperature": {
|
|
1669
1063
|
"type": "number",
|
|
@@ -1765,7 +1159,6 @@ const schema$1 = {
|
|
|
1765
1159
|
},
|
|
1766
1160
|
"required": [
|
|
1767
1161
|
"authentication",
|
|
1768
|
-
"endpoint",
|
|
1769
1162
|
"model",
|
|
1770
1163
|
"provider"
|
|
1771
1164
|
]
|
|
@@ -1773,6 +1166,476 @@ const schema$1 = {
|
|
|
1773
1166
|
}
|
|
1774
1167
|
};
|
|
1775
1168
|
|
|
1169
|
+
const isInteractive = (config) => {
|
|
1170
|
+
return config?.mode === 'interactive' || !!config?.interactive;
|
|
1171
|
+
};
|
|
1172
|
+
const SEPERATOR = chalk.blue('─────────────');
|
|
1173
|
+
const DIVIDER = chalk.dim(`\\`);
|
|
1174
|
+
const LOGO = chalk.green(`┌──────┐
|
|
1175
|
+
│┏┏┓┏┏┓│
|
|
1176
|
+
│┗┗┛┗┗┛│
|
|
1177
|
+
└──────┘`);
|
|
1178
|
+
chalk.green(`┌────┐
|
|
1179
|
+
│coco│
|
|
1180
|
+
└────┘`);
|
|
1181
|
+
const bannerWithHeader = (banner) => {
|
|
1182
|
+
return chalk.green(`┌────┐
|
|
1183
|
+
│coco│ ${banner}
|
|
1184
|
+
└────┘`);
|
|
1185
|
+
};
|
|
1186
|
+
const USAGE_BANNER = chalk.green(`${LOGO}
|
|
1187
|
+
${chalk.bgGreen(`\xa0v${BUILD_VERSION}\xa0`)}
|
|
1188
|
+
`);
|
|
1189
|
+
const getCommandUsageHeader = (command) => {
|
|
1190
|
+
return chalk.green(`${USAGE_BANNER}\n${chalk.white('Command:')}\n\xa0\xa0\xa0\xa0\xa0 $0 ${chalk.greenBright(command)} [options]`);
|
|
1191
|
+
};
|
|
1192
|
+
const CONFIG_ALREADY_EXISTS = (path) => {
|
|
1193
|
+
return `existing config found in '${path}', do you want to override it?`;
|
|
1194
|
+
};
|
|
1195
|
+
const severityColors = [
|
|
1196
|
+
chalk.greenBright, // 1
|
|
1197
|
+
chalk.green, // 2
|
|
1198
|
+
chalk.cyan, // 3
|
|
1199
|
+
chalk.yellowBright, // 4
|
|
1200
|
+
chalk.yellow, // 5
|
|
1201
|
+
chalk.bgYellow, // 6
|
|
1202
|
+
chalk.red, // 7
|
|
1203
|
+
chalk.redBright, // 8
|
|
1204
|
+
chalk.bgRed, // 9
|
|
1205
|
+
chalk.bgRedBright, // 10
|
|
1206
|
+
];
|
|
1207
|
+
const severityColor = (severity) => {
|
|
1208
|
+
return severityColors[Math.min(severity - 1, severityColors.length - 1)];
|
|
1209
|
+
};
|
|
1210
|
+
const statusColor = (status) => {
|
|
1211
|
+
switch (status) {
|
|
1212
|
+
case 'completed':
|
|
1213
|
+
return chalk.green;
|
|
1214
|
+
case 'skipped':
|
|
1215
|
+
return chalk.yellow;
|
|
1216
|
+
case 'omitted':
|
|
1217
|
+
return chalk.red;
|
|
1218
|
+
default:
|
|
1219
|
+
return chalk.blue;
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
const hotKey = (key) => chalk.dim(`(${key})`);
|
|
1223
|
+
|
|
1224
|
+
/**
|
|
1225
|
+
* Returns a new object with all undefined keys removed
|
|
1226
|
+
*
|
|
1227
|
+
* @param obj Object to remove undefined keys from
|
|
1228
|
+
* @returns
|
|
1229
|
+
*/
|
|
1230
|
+
function removeUndefined(obj) {
|
|
1231
|
+
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined));
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
async function updateFileSection({ filePath, startComment, endComment, getNewContent, confirmUpdate = true, confirmMessage = (path) => `A section already exists in ${path}, do you want to override it?`, }) {
|
|
1235
|
+
const lines = fs__default.existsSync(filePath) ? fs__default.readFileSync(filePath, 'utf-8').split(/\r?\n/) : [];
|
|
1236
|
+
const newLines = [];
|
|
1237
|
+
let foundSection = false;
|
|
1238
|
+
for (let i = 0; i < lines.length; i++) {
|
|
1239
|
+
if (lines[i].trim() === startComment) {
|
|
1240
|
+
foundSection = true;
|
|
1241
|
+
if (confirmUpdate) {
|
|
1242
|
+
const confirmOverwrite = await confirm({
|
|
1243
|
+
message: typeof confirmMessage === 'function' ? confirmMessage(filePath) : confirmMessage,
|
|
1244
|
+
default: false,
|
|
1245
|
+
});
|
|
1246
|
+
if (!confirmOverwrite) {
|
|
1247
|
+
// keep all lines until the end comment
|
|
1248
|
+
while (i < lines.length && lines[i].trim() !== endComment) {
|
|
1249
|
+
newLines.push(lines[i]);
|
|
1250
|
+
i++;
|
|
1251
|
+
}
|
|
1252
|
+
newLines.push(endComment);
|
|
1253
|
+
continue;
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
newLines.push(startComment);
|
|
1257
|
+
// Insert the new content
|
|
1258
|
+
const newContent = await getNewContent();
|
|
1259
|
+
newLines.push(newContent);
|
|
1260
|
+
// Skip the existing content of the section
|
|
1261
|
+
while (i < lines.length && lines[i].trim() !== endComment) {
|
|
1262
|
+
i++;
|
|
1263
|
+
}
|
|
1264
|
+
newLines.push(endComment);
|
|
1265
|
+
continue;
|
|
1266
|
+
}
|
|
1267
|
+
if (!foundSection || lines[i].trim() !== endComment) {
|
|
1268
|
+
newLines.push(lines[i]);
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
// If section wasn't found, append it at the end
|
|
1272
|
+
if (!foundSection) {
|
|
1273
|
+
newLines.push('\n' + startComment);
|
|
1274
|
+
const newContent = await getNewContent();
|
|
1275
|
+
newLines.push(newContent);
|
|
1276
|
+
newLines.push(endComment);
|
|
1277
|
+
}
|
|
1278
|
+
// Write the updated contents back to the file
|
|
1279
|
+
fs__default.writeFileSync(filePath, newLines.join('\n'));
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
const template$5 = `GOAL: Use functional abstractions to summarize the following text
|
|
1283
|
+
|
|
1284
|
+
RULES: Avoid phrases like "this change", "this code", or "this function" etc. Instead refer to the function, variable, or class by name.
|
|
1285
|
+
|
|
1286
|
+
TEXT:"""{text}"""
|
|
1287
|
+
`;
|
|
1288
|
+
const inputVariables$4 = ['text'];
|
|
1289
|
+
const SUMMARIZE_PROMPT = new PromptTemplate({
|
|
1290
|
+
inputVariables: inputVariables$4,
|
|
1291
|
+
template: template$5,
|
|
1292
|
+
});
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* Retrieves the provider and model from the given configuration object.
|
|
1296
|
+
* @param config The configuration object.
|
|
1297
|
+
* @returns An object containing the provider and model.
|
|
1298
|
+
* @throws Error if the configuration is invalid or missing required properties.
|
|
1299
|
+
*/
|
|
1300
|
+
function getModelAndProviderFromConfig(config) {
|
|
1301
|
+
if (!config.service) {
|
|
1302
|
+
throw new Error('Invalid service: undefined');
|
|
1303
|
+
}
|
|
1304
|
+
const { provider, model } = config.service;
|
|
1305
|
+
if (!model || !provider) {
|
|
1306
|
+
throw new Error(`Invalid service: ${config.service}`);
|
|
1307
|
+
}
|
|
1308
|
+
return { provider, model };
|
|
1309
|
+
}
|
|
1310
|
+
/**
|
|
1311
|
+
* Retrieve appropriate API key based on selected model
|
|
1312
|
+
* @param service
|
|
1313
|
+
* @param options
|
|
1314
|
+
* @returns API Key
|
|
1315
|
+
*/
|
|
1316
|
+
function getApiKeyForModel(config) {
|
|
1317
|
+
const { provider } = getModelAndProviderFromConfig(config);
|
|
1318
|
+
switch (provider) {
|
|
1319
|
+
case 'openai':
|
|
1320
|
+
return getDefaultServiceApiKey(config);
|
|
1321
|
+
default:
|
|
1322
|
+
return getDefaultServiceApiKey(config);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* Retrieves the default service API key from the given configuration.
|
|
1327
|
+
* @param config The configuration object.
|
|
1328
|
+
* @returns The default service API key.
|
|
1329
|
+
*/
|
|
1330
|
+
function getDefaultServiceApiKey(config) {
|
|
1331
|
+
const service = config.service;
|
|
1332
|
+
if (service.authentication.type === 'APIKey') {
|
|
1333
|
+
return service.authentication.credentials?.apiKey;
|
|
1334
|
+
}
|
|
1335
|
+
else if (service.authentication.type === 'OAuth') {
|
|
1336
|
+
return service.authentication.credentials?.token;
|
|
1337
|
+
}
|
|
1338
|
+
return '';
|
|
1339
|
+
}
|
|
1340
|
+
const DEFAULT_OPENAI_LLM_SERVICE = {
|
|
1341
|
+
provider: 'openai',
|
|
1342
|
+
model: 'gpt-4',
|
|
1343
|
+
tokenLimit: 2024,
|
|
1344
|
+
temperature: 0.32,
|
|
1345
|
+
authentication: {
|
|
1346
|
+
type: 'APIKey',
|
|
1347
|
+
credentials: {
|
|
1348
|
+
apiKey: '',
|
|
1349
|
+
},
|
|
1350
|
+
},
|
|
1351
|
+
};
|
|
1352
|
+
const DEFAULT_OLLAMA_LLM_SERVICE = {
|
|
1353
|
+
provider: 'ollama',
|
|
1354
|
+
model: 'llama3',
|
|
1355
|
+
endpoint: 'http://localhost:11434',
|
|
1356
|
+
maxConcurrent: 1,
|
|
1357
|
+
tokenLimit: 2024,
|
|
1358
|
+
temperature: 0.4,
|
|
1359
|
+
authentication: {
|
|
1360
|
+
type: 'None',
|
|
1361
|
+
credentials: undefined,
|
|
1362
|
+
},
|
|
1363
|
+
};
|
|
1364
|
+
/**
|
|
1365
|
+
* Retrieves the default service configuration based on the provided alias and optional model.
|
|
1366
|
+
* @param provider - The alias of the service.
|
|
1367
|
+
* @param model - The optional model to be used.
|
|
1368
|
+
* @returns The default service configuration.
|
|
1369
|
+
* @throws Error if the alias is invalid or undefined.
|
|
1370
|
+
*/
|
|
1371
|
+
function getDefaultServiceConfigFromAlias(provider, model) {
|
|
1372
|
+
switch (provider) {
|
|
1373
|
+
case 'anthropic':
|
|
1374
|
+
return {
|
|
1375
|
+
...DEFAULT_OPENAI_LLM_SERVICE,
|
|
1376
|
+
model: model || DEFAULT_OPENAI_LLM_SERVICE.model,
|
|
1377
|
+
};
|
|
1378
|
+
case 'ollama':
|
|
1379
|
+
return {
|
|
1380
|
+
...DEFAULT_OLLAMA_LLM_SERVICE,
|
|
1381
|
+
model: model || DEFAULT_OLLAMA_LLM_SERVICE.model,
|
|
1382
|
+
};
|
|
1383
|
+
case 'openai':
|
|
1384
|
+
default:
|
|
1385
|
+
return {
|
|
1386
|
+
...DEFAULT_OPENAI_LLM_SERVICE,
|
|
1387
|
+
model: model || DEFAULT_OPENAI_LLM_SERVICE.model,
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
const DEFAULT_IGNORED_FILES = ['package-lock.json', 'yarn.lock', 'node_modules'];
|
|
1393
|
+
const DEFAULT_IGNORED_EXTENSIONS = ['.map', '.lock'];
|
|
1394
|
+
const COCO_CONFIG_START_COMMENT = '# -- start coco config --';
|
|
1395
|
+
const COCO_CONFIG_END_COMMENT = '# -- end coco config --';
|
|
1396
|
+
/**
|
|
1397
|
+
* Default Config
|
|
1398
|
+
*
|
|
1399
|
+
* @type {Config}
|
|
1400
|
+
*/
|
|
1401
|
+
const DEFAULT_CONFIG$1 = {
|
|
1402
|
+
mode: 'stdout',
|
|
1403
|
+
verbose: false,
|
|
1404
|
+
defaultBranch: 'main',
|
|
1405
|
+
service: getDefaultServiceConfigFromAlias('openai'),
|
|
1406
|
+
summarizePrompt: SUMMARIZE_PROMPT.template,
|
|
1407
|
+
ignoredFiles: DEFAULT_IGNORED_FILES,
|
|
1408
|
+
ignoredExtensions: DEFAULT_IGNORED_EXTENSIONS,
|
|
1409
|
+
};
|
|
1410
|
+
/**
|
|
1411
|
+
* Create a named export of all config keys for use in other modules.
|
|
1412
|
+
*
|
|
1413
|
+
* @see Used in `src/lib/config/services/env.ts` to validate all env vars.
|
|
1414
|
+
*
|
|
1415
|
+
* @type {string[]}
|
|
1416
|
+
*/
|
|
1417
|
+
const CONFIG_KEYS = Object.keys({
|
|
1418
|
+
...DEFAULT_CONFIG$1,
|
|
1419
|
+
prompt: '',
|
|
1420
|
+
});
|
|
1421
|
+
|
|
1422
|
+
/**
|
|
1423
|
+
* Load environment variables
|
|
1424
|
+
*
|
|
1425
|
+
* @param {Config} config
|
|
1426
|
+
* @returns {Config} Updated config
|
|
1427
|
+
**/
|
|
1428
|
+
function loadEnvConfig(config) {
|
|
1429
|
+
const envConfig = {};
|
|
1430
|
+
const envKeys = [...CONFIG_KEYS, 'COCO_SERVICE_PROVIDER', 'COCO_SERVICE_MODEL', 'OPEN_AI_KEY'];
|
|
1431
|
+
envKeys.forEach((key) => {
|
|
1432
|
+
const envVarName = toEnvVarName(key);
|
|
1433
|
+
const envValue = parseEnvValue(key, process.env[envVarName]);
|
|
1434
|
+
if (envValue === undefined) {
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
if (key === 'COCO_SERVICE_PROVIDER' || key === 'COCO_SERVICE_MODEL' || key === 'OPEN_AI_KEY') {
|
|
1438
|
+
// NOTE: We want to ensure that the service object is always defined
|
|
1439
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
1440
|
+
// @ts-ignore
|
|
1441
|
+
envConfig.service = envConfig.service || {};
|
|
1442
|
+
handleServiceEnvVar(envConfig.service, key, envValue);
|
|
1443
|
+
}
|
|
1444
|
+
else {
|
|
1445
|
+
if (key === 'service' || !envValue) {
|
|
1446
|
+
return;
|
|
1447
|
+
}
|
|
1448
|
+
envConfig[key] = envValue;
|
|
1449
|
+
}
|
|
1450
|
+
});
|
|
1451
|
+
return { ...config, ...removeUndefined(envConfig) };
|
|
1452
|
+
}
|
|
1453
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1454
|
+
function handleServiceEnvVar(service, key, value) {
|
|
1455
|
+
switch (key) {
|
|
1456
|
+
case 'COCO_SERVICE_PROVIDER':
|
|
1457
|
+
service.provider = value;
|
|
1458
|
+
break;
|
|
1459
|
+
case 'COCO_SERVICE_MODEL':
|
|
1460
|
+
service.model = value;
|
|
1461
|
+
break;
|
|
1462
|
+
case 'OPEN_AI_KEY':
|
|
1463
|
+
if (service.provider === 'openai') {
|
|
1464
|
+
service.fields = { apiKey: value };
|
|
1465
|
+
}
|
|
1466
|
+
break;
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
function parseEnvValue(key, value) {
|
|
1470
|
+
switch (true) {
|
|
1471
|
+
// Handle undefined values
|
|
1472
|
+
case value === undefined:
|
|
1473
|
+
return undefined;
|
|
1474
|
+
// Handle comma separated strings for ignoredFiles and ignoredExtensions arrays
|
|
1475
|
+
case (key === 'ignoredFiles' || key === 'ignoredExtensions') &&
|
|
1476
|
+
typeof value === 'string' &&
|
|
1477
|
+
value.includes(','):
|
|
1478
|
+
return value.split(',');
|
|
1479
|
+
// Handle boolean values
|
|
1480
|
+
case typeof value === 'string' && (value === 'false' || value === 'true'):
|
|
1481
|
+
return value === 'true';
|
|
1482
|
+
// Handle number values
|
|
1483
|
+
case typeof value === 'string' && !isNaN(Number(value)):
|
|
1484
|
+
return Number(value);
|
|
1485
|
+
default:
|
|
1486
|
+
return value;
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
function toEnvVarName(key) {
|
|
1490
|
+
if (key === 'service') {
|
|
1491
|
+
return key;
|
|
1492
|
+
}
|
|
1493
|
+
if (key.includes('COCO_')) {
|
|
1494
|
+
return key;
|
|
1495
|
+
}
|
|
1496
|
+
return `COCO_${key.replace(/([A-Z])/g, '_$1').toLocaleUpperCase()}`;
|
|
1497
|
+
}
|
|
1498
|
+
function formatEnvValue(value) {
|
|
1499
|
+
if (typeof value === 'number') {
|
|
1500
|
+
return `${value}`;
|
|
1501
|
+
}
|
|
1502
|
+
else if (Array.isArray(value)) {
|
|
1503
|
+
return `${value.join(',')}`;
|
|
1504
|
+
}
|
|
1505
|
+
else if (typeof value === 'string') {
|
|
1506
|
+
// Escape newlines and tabs in strings
|
|
1507
|
+
return `${value.replace(/\n/g, '\\n').replace(/\t/g, '\\t')}`;
|
|
1508
|
+
}
|
|
1509
|
+
return `${value}`;
|
|
1510
|
+
}
|
|
1511
|
+
const appendToEnvFile = async (filePath, config) => {
|
|
1512
|
+
const getNewContent = async () => {
|
|
1513
|
+
return Object.entries(config)
|
|
1514
|
+
.map(([key, value]) => {
|
|
1515
|
+
if (key === 'service') {
|
|
1516
|
+
const service = value;
|
|
1517
|
+
return `${service.provider ? `COCO_SERVICE_PROVIDER=${service.provider}` : ''}\n${service.model ? `COCO_SERVICE_MODEL=${service.model}` : ''}\n${service.authentication.type === 'APIKey'
|
|
1518
|
+
? `OPEN_AI_KEY=${service.authentication.credentials.apiKey}`
|
|
1519
|
+
: ''}`;
|
|
1520
|
+
}
|
|
1521
|
+
const envVarName = toEnvVarName(key);
|
|
1522
|
+
const envValue = formatEnvValue(value);
|
|
1523
|
+
return `${envVarName}=${envValue}`;
|
|
1524
|
+
})
|
|
1525
|
+
.join('\n');
|
|
1526
|
+
};
|
|
1527
|
+
await updateFileSection({
|
|
1528
|
+
filePath,
|
|
1529
|
+
startComment: COCO_CONFIG_START_COMMENT,
|
|
1530
|
+
endComment: COCO_CONFIG_END_COMMENT,
|
|
1531
|
+
getNewContent,
|
|
1532
|
+
confirmMessage: CONFIG_ALREADY_EXISTS,
|
|
1533
|
+
});
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* Load git profile config (from ~/.gitconfig)
|
|
1538
|
+
*
|
|
1539
|
+
* @param {Config} config
|
|
1540
|
+
* @returns {Config} Updated config
|
|
1541
|
+
**/
|
|
1542
|
+
function loadGitConfig(config) {
|
|
1543
|
+
const gitConfigPath = path.join(os.homedir(), '.gitconfig');
|
|
1544
|
+
if (fs.existsSync(gitConfigPath)) {
|
|
1545
|
+
const gitConfigRaw = fs.readFileSync(gitConfigPath, 'utf-8');
|
|
1546
|
+
const gitConfigParsed = ini.parse(gitConfigRaw);
|
|
1547
|
+
const gitConfigServiceObject = gitConfigParsed.coco?.service;
|
|
1548
|
+
let service = config.service;
|
|
1549
|
+
if (gitConfigServiceObject) {
|
|
1550
|
+
const gitServiceConfig = JSON.parse(gitConfigServiceObject);
|
|
1551
|
+
service = gitServiceConfig || config?.service;
|
|
1552
|
+
}
|
|
1553
|
+
config = {
|
|
1554
|
+
...config,
|
|
1555
|
+
service: service,
|
|
1556
|
+
prompt: gitConfigParsed.coco?.prompt || config.prompt,
|
|
1557
|
+
mode: gitConfigParsed.coco?.mode || config.mode,
|
|
1558
|
+
summarizePrompt: gitConfigParsed.coco?.summarizePrompt || config.summarizePrompt,
|
|
1559
|
+
ignoredFiles: gitConfigParsed.coco?.ignoredFiles || config.ignoredFiles,
|
|
1560
|
+
ignoredExtensions: gitConfigParsed.coco?.ignoredExtensions || config.ignoredExtensions,
|
|
1561
|
+
defaultBranch: gitConfigParsed.coco?.defaultBranch || config.defaultBranch,
|
|
1562
|
+
verbose: gitConfigParsed.coco?.verbose || config.verbose,
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
return removeUndefined(config);
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Appends the provided configuration to a git config file.
|
|
1569
|
+
*
|
|
1570
|
+
* @param filePath - The path to the .gitconfig
|
|
1571
|
+
* @param config - The configuration object to append.
|
|
1572
|
+
*/
|
|
1573
|
+
const appendToGitConfig = async (filePath, config) => {
|
|
1574
|
+
if (!fs.existsSync(filePath)) {
|
|
1575
|
+
throw new Error(`File ${filePath} does not exist.`);
|
|
1576
|
+
}
|
|
1577
|
+
const header = '[coco]';
|
|
1578
|
+
const getNewContent = async () => {
|
|
1579
|
+
const contentLines = [header];
|
|
1580
|
+
for (const key in config) {
|
|
1581
|
+
const value = config[key];
|
|
1582
|
+
if (typeof value === 'object') {
|
|
1583
|
+
// Serialize object to JSON string
|
|
1584
|
+
contentLines.push(`\t${key} = ${JSON.stringify(value)}`);
|
|
1585
|
+
}
|
|
1586
|
+
else if (typeof value === 'string' && value.includes('\n')) {
|
|
1587
|
+
// Wrap strings with new lines in quotes
|
|
1588
|
+
contentLines.push(`\t${key} = ${JSON.stringify(value)}`);
|
|
1589
|
+
}
|
|
1590
|
+
else {
|
|
1591
|
+
contentLines.push(`\t${key} = ${value}`);
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
return contentLines.join('\n');
|
|
1595
|
+
};
|
|
1596
|
+
await updateFileSection({
|
|
1597
|
+
filePath,
|
|
1598
|
+
startComment: COCO_CONFIG_START_COMMENT,
|
|
1599
|
+
endComment: COCO_CONFIG_END_COMMENT,
|
|
1600
|
+
getNewContent,
|
|
1601
|
+
confirmUpdate: true,
|
|
1602
|
+
confirmMessage: CONFIG_ALREADY_EXISTS,
|
|
1603
|
+
});
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
/**
|
|
1607
|
+
* Load .gitignore in project root
|
|
1608
|
+
*
|
|
1609
|
+
* @param {Config} config
|
|
1610
|
+
* @returns
|
|
1611
|
+
*/
|
|
1612
|
+
function loadGitignore(config) {
|
|
1613
|
+
if (fs.existsSync('.gitignore')) {
|
|
1614
|
+
const gitignoreContent = fs.readFileSync('.gitignore', 'utf-8');
|
|
1615
|
+
config.ignoredFiles = [
|
|
1616
|
+
...(config?.ignoredFiles || []),
|
|
1617
|
+
...gitignoreContent.split('\n').filter((line) => line.trim() !== '' && !line.startsWith('#')),
|
|
1618
|
+
];
|
|
1619
|
+
}
|
|
1620
|
+
return config;
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Load .ignore in project root
|
|
1624
|
+
*
|
|
1625
|
+
* @param {Config} config
|
|
1626
|
+
* @returns
|
|
1627
|
+
*/
|
|
1628
|
+
function loadIgnore(config) {
|
|
1629
|
+
if (fs.existsSync('.ignore')) {
|
|
1630
|
+
const ignoreContent = fs.readFileSync('.ignore', 'utf-8');
|
|
1631
|
+
config.ignoredFiles = [
|
|
1632
|
+
...(config?.ignoredFiles || []),
|
|
1633
|
+
...ignoreContent.split('\n').filter((line) => line.trim() !== '' && !line.startsWith('#')),
|
|
1634
|
+
];
|
|
1635
|
+
}
|
|
1636
|
+
return config;
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1776
1639
|
const ajv = new Ajv({
|
|
1777
1640
|
allErrors: true,
|
|
1778
1641
|
verbose: true,
|
|
@@ -1836,14 +1699,26 @@ function parseServiceConfig(service) {
|
|
|
1836
1699
|
switch (service.provider) {
|
|
1837
1700
|
case 'openai':
|
|
1838
1701
|
return {
|
|
1839
|
-
provider: 'openai',
|
|
1702
|
+
provider: 'openai',
|
|
1703
|
+
model: service.model,
|
|
1704
|
+
authentication: {
|
|
1705
|
+
type: 'APIKey',
|
|
1706
|
+
credentials: {
|
|
1707
|
+
apiKey: service.apiKey
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
};
|
|
1711
|
+
case 'anthropic':
|
|
1712
|
+
return {
|
|
1713
|
+
provider: 'anthropic',
|
|
1840
1714
|
model: service.model,
|
|
1841
1715
|
authentication: {
|
|
1842
1716
|
type: 'APIKey',
|
|
1843
1717
|
credentials: {
|
|
1844
1718
|
apiKey: service.apiKey
|
|
1845
1719
|
}
|
|
1846
|
-
}
|
|
1720
|
+
},
|
|
1721
|
+
fields: service.fields
|
|
1847
1722
|
};
|
|
1848
1723
|
case 'ollama':
|
|
1849
1724
|
return {
|
|
@@ -1953,6 +1828,31 @@ function commandExecutor(handler) {
|
|
|
1953
1828
|
};
|
|
1954
1829
|
}
|
|
1955
1830
|
|
|
1831
|
+
const command$4 = 'changelog';
|
|
1832
|
+
/**
|
|
1833
|
+
* Command line options via yargs
|
|
1834
|
+
*/
|
|
1835
|
+
const options$4 = {
|
|
1836
|
+
range: {
|
|
1837
|
+
type: 'string',
|
|
1838
|
+
alias: 'r',
|
|
1839
|
+
description: 'Commit range e.g `HEAD~2:HEAD`',
|
|
1840
|
+
},
|
|
1841
|
+
branch: {
|
|
1842
|
+
type: 'string',
|
|
1843
|
+
alias: 'b',
|
|
1844
|
+
description: 'Target branch to compare against',
|
|
1845
|
+
},
|
|
1846
|
+
i: {
|
|
1847
|
+
type: 'boolean',
|
|
1848
|
+
alias: 'interactive',
|
|
1849
|
+
description: 'Toggle interactive mode',
|
|
1850
|
+
},
|
|
1851
|
+
};
|
|
1852
|
+
const builder$4 = (yargs) => {
|
|
1853
|
+
return yargs.options(options$4).usage(getCommandUsageHeader(command$4));
|
|
1854
|
+
};
|
|
1855
|
+
|
|
1956
1856
|
/**
|
|
1957
1857
|
* Get LLM Model Based on Configuration
|
|
1958
1858
|
*
|
|
@@ -2491,36 +2391,47 @@ const handler$4 = async (argv, logger) => {
|
|
|
2491
2391
|
});
|
|
2492
2392
|
};
|
|
2493
2393
|
|
|
2394
|
+
var changelog = {
|
|
2395
|
+
command: command$4,
|
|
2396
|
+
desc: 'Generate a changelog from current or target branch or provided commit range.',
|
|
2397
|
+
builder: builder$4,
|
|
2398
|
+
handler: commandExecutor(handler$4),
|
|
2399
|
+
options: options$4,
|
|
2400
|
+
};
|
|
2401
|
+
|
|
2402
|
+
const command$3 = 'commit';
|
|
2494
2403
|
/**
|
|
2495
2404
|
* Command line options via yargs
|
|
2496
2405
|
*/
|
|
2497
|
-
const options$
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2406
|
+
const options$3 = {
|
|
2407
|
+
i: {
|
|
2408
|
+
alias: 'interactive',
|
|
2409
|
+
description: 'Toggle interactive mode',
|
|
2410
|
+
type: 'boolean',
|
|
2502
2411
|
},
|
|
2503
|
-
|
|
2412
|
+
ignoredFiles: {
|
|
2413
|
+
description: 'Ignored files',
|
|
2414
|
+
type: 'array',
|
|
2415
|
+
},
|
|
2416
|
+
ignoredExtensions: {
|
|
2417
|
+
description: 'Ignored extensions',
|
|
2418
|
+
type: 'array',
|
|
2419
|
+
},
|
|
2420
|
+
append: {
|
|
2421
|
+
description: 'Add content to the end of the generated commit message',
|
|
2504
2422
|
type: 'string',
|
|
2505
|
-
alias: 'b',
|
|
2506
|
-
description: 'Target branch to compare against',
|
|
2507
2423
|
},
|
|
2508
|
-
|
|
2424
|
+
appendTicket: {
|
|
2425
|
+
description: 'Append ticket ID from branch name to the commit message',
|
|
2509
2426
|
type: 'boolean',
|
|
2510
|
-
|
|
2511
|
-
|
|
2427
|
+
},
|
|
2428
|
+
additional: {
|
|
2429
|
+
description: 'Add extra contextual information to the prompt',
|
|
2430
|
+
type: 'string',
|
|
2512
2431
|
},
|
|
2513
2432
|
};
|
|
2514
|
-
const builder$
|
|
2515
|
-
return yargs.options(options$
|
|
2516
|
-
};
|
|
2517
|
-
|
|
2518
|
-
var changelog = {
|
|
2519
|
-
command: 'changelog',
|
|
2520
|
-
desc: 'Generate a changelog from current or target branch or provided commit range.',
|
|
2521
|
-
builder: builder$4,
|
|
2522
|
-
handler: commandExecutor(handler$4),
|
|
2523
|
-
options: options$4,
|
|
2433
|
+
const builder$3 = (yargs) => {
|
|
2434
|
+
return yargs.options(options$3).usage(getCommandUsageHeader(command$3));
|
|
2524
2435
|
};
|
|
2525
2436
|
|
|
2526
2437
|
/**
|
|
@@ -6322,7 +6233,13 @@ const handler$3 = async (argv, logger) => {
|
|
|
6322
6233
|
logger.log(LOGO);
|
|
6323
6234
|
}
|
|
6324
6235
|
async function factory() {
|
|
6325
|
-
const changes = await getChanges({
|
|
6236
|
+
const changes = await getChanges({
|
|
6237
|
+
git,
|
|
6238
|
+
options: {
|
|
6239
|
+
ignoredFiles: config.ignoredFiles || undefined,
|
|
6240
|
+
ignoredExtensions: config.ignoredExtensions || undefined,
|
|
6241
|
+
},
|
|
6242
|
+
});
|
|
6326
6243
|
return changes.staged;
|
|
6327
6244
|
}
|
|
6328
6245
|
async function parser(changes) {
|
|
@@ -6392,46 +6309,27 @@ const handler$3 = async (argv, logger) => {
|
|
|
6392
6309
|
});
|
|
6393
6310
|
};
|
|
6394
6311
|
|
|
6312
|
+
var commit = {
|
|
6313
|
+
command: command$3,
|
|
6314
|
+
desc: 'Summarize the staged changes in a commit message.',
|
|
6315
|
+
builder: builder$3,
|
|
6316
|
+
handler: commandExecutor(handler$3),
|
|
6317
|
+
options: options$3,
|
|
6318
|
+
};
|
|
6319
|
+
|
|
6320
|
+
const command$2 = 'init';
|
|
6395
6321
|
/**
|
|
6396
6322
|
* Command line options via yargs
|
|
6397
6323
|
*/
|
|
6398
|
-
const options$
|
|
6399
|
-
|
|
6400
|
-
alias: 'interactive',
|
|
6401
|
-
description: 'Toggle interactive mode',
|
|
6402
|
-
type: 'boolean',
|
|
6403
|
-
},
|
|
6404
|
-
ignoredFiles: {
|
|
6405
|
-
description: 'Ignored files',
|
|
6406
|
-
type: 'array',
|
|
6407
|
-
},
|
|
6408
|
-
ignoredExtensions: {
|
|
6409
|
-
description: 'Ignored extensions',
|
|
6410
|
-
type: 'array',
|
|
6411
|
-
},
|
|
6412
|
-
append: {
|
|
6413
|
-
description: 'Add content to the end of the generated commit message',
|
|
6414
|
-
type: 'string',
|
|
6415
|
-
},
|
|
6416
|
-
appendTicket: {
|
|
6417
|
-
description: 'Append ticket ID from branch name to the commit message',
|
|
6418
|
-
type: 'boolean',
|
|
6419
|
-
},
|
|
6420
|
-
additional: {
|
|
6421
|
-
description: 'Add extra contextual information to the prompt',
|
|
6324
|
+
const options$2 = {
|
|
6325
|
+
scope: {
|
|
6422
6326
|
type: 'string',
|
|
6327
|
+
description: 'configure coco for the current user or project?',
|
|
6328
|
+
choices: ['global', 'project'],
|
|
6423
6329
|
},
|
|
6424
6330
|
};
|
|
6425
|
-
const builder$
|
|
6426
|
-
return yargs.options(options$
|
|
6427
|
-
};
|
|
6428
|
-
|
|
6429
|
-
var commit = {
|
|
6430
|
-
command: 'commit',
|
|
6431
|
-
desc: 'Summarize the staged changes in a commit message.',
|
|
6432
|
-
builder: builder$3,
|
|
6433
|
-
handler: commandExecutor(handler$3),
|
|
6434
|
-
options: options$3,
|
|
6331
|
+
const builder$2 = (yargs) => {
|
|
6332
|
+
return yargs.options(options$2).usage(getCommandUsageHeader(command$2));
|
|
6435
6333
|
};
|
|
6436
6334
|
|
|
6437
6335
|
/**
|
|
@@ -6867,28 +6765,48 @@ const handler$2 = async (argv, logger) => {
|
|
|
6867
6765
|
}
|
|
6868
6766
|
};
|
|
6869
6767
|
|
|
6870
|
-
/**
|
|
6871
|
-
* Command line options via yargs
|
|
6872
|
-
*/
|
|
6873
|
-
const options$2 = {
|
|
6874
|
-
scope: {
|
|
6875
|
-
type: 'string',
|
|
6876
|
-
description: 'configure coco for the current user or project?',
|
|
6877
|
-
choices: ['global', 'project'],
|
|
6878
|
-
},
|
|
6879
|
-
};
|
|
6880
|
-
const builder$2 = (yargs) => {
|
|
6881
|
-
return yargs.options(options$2).usage(getCommandUsageHeader(init.command));
|
|
6882
|
-
};
|
|
6883
|
-
|
|
6884
6768
|
var init = {
|
|
6885
|
-
command:
|
|
6769
|
+
command: command$2,
|
|
6886
6770
|
desc: 'install & configure coco globally or for the current project',
|
|
6887
6771
|
builder: builder$2,
|
|
6888
6772
|
handler: commandExecutor(handler$2),
|
|
6889
6773
|
options: options$2,
|
|
6890
6774
|
};
|
|
6891
6775
|
|
|
6776
|
+
const command$1 = 'recap';
|
|
6777
|
+
/**
|
|
6778
|
+
* Command line options via yargs
|
|
6779
|
+
*/
|
|
6780
|
+
const options$1 = {
|
|
6781
|
+
yesterday: {
|
|
6782
|
+
type: 'boolean',
|
|
6783
|
+
description: 'Recap for yesterday',
|
|
6784
|
+
},
|
|
6785
|
+
'last-week': {
|
|
6786
|
+
alias: 'week',
|
|
6787
|
+
type: 'boolean',
|
|
6788
|
+
description: 'Recap for last week',
|
|
6789
|
+
},
|
|
6790
|
+
'last-month': {
|
|
6791
|
+
alias: 'month',
|
|
6792
|
+
type: 'boolean',
|
|
6793
|
+
description: 'Recap for last month',
|
|
6794
|
+
},
|
|
6795
|
+
'last-tag': {
|
|
6796
|
+
alias: 'tag',
|
|
6797
|
+
type: 'boolean',
|
|
6798
|
+
description: 'Recap for last tag',
|
|
6799
|
+
},
|
|
6800
|
+
i: {
|
|
6801
|
+
type: 'boolean',
|
|
6802
|
+
alias: 'interactive',
|
|
6803
|
+
description: 'Toggle interactive mode',
|
|
6804
|
+
},
|
|
6805
|
+
};
|
|
6806
|
+
const builder$1 = (yargs) => {
|
|
6807
|
+
return yargs.options(options$1).usage(getCommandUsageHeader(command$1));
|
|
6808
|
+
};
|
|
6809
|
+
|
|
6892
6810
|
/**
|
|
6893
6811
|
* Formats a commit log into a readable string format.
|
|
6894
6812
|
*
|
|
@@ -7067,46 +6985,73 @@ const handler$1 = async (argv, logger) => {
|
|
|
7067
6985
|
});
|
|
7068
6986
|
};
|
|
7069
6987
|
|
|
6988
|
+
var recap = {
|
|
6989
|
+
command: command$1,
|
|
6990
|
+
desc: 'Summarize the changes in the repository over a specified timeframe.',
|
|
6991
|
+
builder: builder$1,
|
|
6992
|
+
handler: commandExecutor(handler$1),
|
|
6993
|
+
options: options$1,
|
|
6994
|
+
};
|
|
6995
|
+
|
|
6996
|
+
const command = 'review';
|
|
7070
6997
|
/**
|
|
7071
6998
|
* Command line options via yargs
|
|
7072
6999
|
*/
|
|
7073
|
-
const options
|
|
7074
|
-
yesterday: {
|
|
7075
|
-
type: 'boolean',
|
|
7076
|
-
description: 'Recap for yesterday',
|
|
7077
|
-
},
|
|
7078
|
-
'last-week': {
|
|
7079
|
-
alias: 'week',
|
|
7080
|
-
type: 'boolean',
|
|
7081
|
-
description: 'Recap for last week',
|
|
7082
|
-
},
|
|
7083
|
-
'last-month': {
|
|
7084
|
-
alias: 'month',
|
|
7085
|
-
type: 'boolean',
|
|
7086
|
-
description: 'Recap for last month',
|
|
7087
|
-
},
|
|
7088
|
-
'last-tag': {
|
|
7089
|
-
alias: 'tag',
|
|
7090
|
-
type: 'boolean',
|
|
7091
|
-
description: 'Recap for last tag',
|
|
7092
|
-
},
|
|
7000
|
+
const options = {
|
|
7093
7001
|
i: {
|
|
7094
7002
|
type: 'boolean',
|
|
7095
7003
|
alias: 'interactive',
|
|
7096
7004
|
description: 'Toggle interactive mode',
|
|
7097
7005
|
},
|
|
7006
|
+
'b': {
|
|
7007
|
+
type: 'string',
|
|
7008
|
+
alias: 'branch',
|
|
7009
|
+
description: 'Branch to review',
|
|
7010
|
+
},
|
|
7098
7011
|
};
|
|
7099
|
-
const builder
|
|
7100
|
-
return yargs.options(options
|
|
7012
|
+
const builder = (yargs) => {
|
|
7013
|
+
return yargs.options(options).usage(getCommandUsageHeader(command));
|
|
7101
7014
|
};
|
|
7102
7015
|
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7106
|
-
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
}
|
|
7016
|
+
/**
|
|
7017
|
+
* Retrieves the diff between the current branch and a specified target branch.
|
|
7018
|
+
*
|
|
7019
|
+
* @param {Object} options - The options for retrieving the diff.
|
|
7020
|
+
* @param {SimpleGit} options.git - The SimpleGit instance.
|
|
7021
|
+
* @param {Logger} options.logger - The logger for logging messages.
|
|
7022
|
+
* @param {string} options.targetBranch - The target branch to compare against.
|
|
7023
|
+
* @param {string[]} options.ignoredFiles - Array of specific files to ignore.
|
|
7024
|
+
* @param {string[]} options.ignoredExtensions - Array of file extensions to ignore.
|
|
7025
|
+
* @returns {Promise<string>} The diff between the current branch and the target branch.
|
|
7026
|
+
*/
|
|
7027
|
+
async function getDiffForBranch({ git, logger, targetBranch, ignoredFiles = [], ignoredExtensions = [], }) {
|
|
7028
|
+
try {
|
|
7029
|
+
// Get the current branch name
|
|
7030
|
+
const currentBranch = await getCurrentBranchName({ git });
|
|
7031
|
+
// Prepare ignore patterns
|
|
7032
|
+
const ignorePatterns = [
|
|
7033
|
+
...ignoredFiles.map((file) => `:!${file}`),
|
|
7034
|
+
...ignoredExtensions.map((ext) => `:!*${ext}`),
|
|
7035
|
+
];
|
|
7036
|
+
// Construct the diff command
|
|
7037
|
+
const diffArgs = [`${targetBranch}..${currentBranch}`];
|
|
7038
|
+
if (ignorePatterns.length > 0) {
|
|
7039
|
+
diffArgs.push('--');
|
|
7040
|
+
diffArgs.push(...ignorePatterns);
|
|
7041
|
+
}
|
|
7042
|
+
// Get the diff
|
|
7043
|
+
const diff = await git.diff(diffArgs);
|
|
7044
|
+
logger?.verbose(`Generated diff between "${currentBranch}" and "${targetBranch}"`, {
|
|
7045
|
+
color: 'blue',
|
|
7046
|
+
});
|
|
7047
|
+
return diff;
|
|
7048
|
+
}
|
|
7049
|
+
catch (error) {
|
|
7050
|
+
console.error('Error in getDiffForBranch:', error);
|
|
7051
|
+
logger?.log('Encountered an error getting diff between branches', { color: 'red' });
|
|
7052
|
+
return '';
|
|
7053
|
+
}
|
|
7054
|
+
}
|
|
7110
7055
|
|
|
7111
7056
|
function getDefaultExportFromCjs (x) {
|
|
7112
7057
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -28273,33 +28218,52 @@ const handler = async (argv, logger) => {
|
|
|
28273
28218
|
logger.log(LOGO);
|
|
28274
28219
|
}
|
|
28275
28220
|
async function factory() {
|
|
28276
|
-
|
|
28277
|
-
|
|
28278
|
-
|
|
28279
|
-
|
|
28221
|
+
if (argv.branch) {
|
|
28222
|
+
logger.verbose(`Generating diff for branch: ${argv.branch}`, { color: 'yellow' });
|
|
28223
|
+
const diff = await getDiffForBranch({
|
|
28224
|
+
git,
|
|
28225
|
+
logger,
|
|
28226
|
+
targetBranch: argv.branch,
|
|
28227
|
+
ignoredFiles: config.ignoredFiles || [],
|
|
28228
|
+
ignoredExtensions: config.ignoredExtensions || [],
|
|
28229
|
+
});
|
|
28230
|
+
return [diff];
|
|
28280
28231
|
}
|
|
28281
|
-
|
|
28282
|
-
|
|
28232
|
+
else {
|
|
28233
|
+
const { staged, unstaged, untracked } = await getChanges({
|
|
28234
|
+
git,
|
|
28235
|
+
options: {
|
|
28236
|
+
ignoredFiles: config.ignoredFiles || undefined,
|
|
28237
|
+
ignoredExtensions: config.ignoredExtensions || undefined,
|
|
28238
|
+
},
|
|
28239
|
+
});
|
|
28240
|
+
if (staged.length === 0 && unstaged?.length === 0 && untracked?.length === 0) {
|
|
28241
|
+
logger.log('No changes detected. Exiting...');
|
|
28242
|
+
process.exit(0);
|
|
28243
|
+
}
|
|
28244
|
+
if (INTERACTIVE) {
|
|
28245
|
+
logger.verbose(`Staged: ${staged.length}, Unstaged: ${unstaged?.length || 0}, Untracked: ${untracked?.length || 0}`);
|
|
28246
|
+
}
|
|
28247
|
+
const unstagedChanges = await fileChangeParser({
|
|
28248
|
+
changes: unstaged || [],
|
|
28249
|
+
commit: '--unstaged',
|
|
28250
|
+
options: { tokenizer, git, llm, logger },
|
|
28251
|
+
});
|
|
28252
|
+
const unstagedResponse = `Unstaged changes:\n${unstagedChanges}`;
|
|
28253
|
+
const untrackedChanges = await fileChangeParser({
|
|
28254
|
+
changes: untracked || [],
|
|
28255
|
+
commit: '--untracked',
|
|
28256
|
+
options: { tokenizer, git, llm, logger },
|
|
28257
|
+
});
|
|
28258
|
+
const untrackedResponse = `Untracked changes:\n${untrackedChanges}`;
|
|
28259
|
+
const stagedChanges = await fileChangeParser({
|
|
28260
|
+
changes: staged,
|
|
28261
|
+
commit: '--staged',
|
|
28262
|
+
options: { tokenizer, git, llm, logger },
|
|
28263
|
+
});
|
|
28264
|
+
const stagedResponse = `Staged changes:\n${stagedChanges}`;
|
|
28265
|
+
return [unstagedResponse, untrackedResponse, stagedResponse];
|
|
28283
28266
|
}
|
|
28284
|
-
const unstagedChanges = await fileChangeParser({
|
|
28285
|
-
changes: unstaged || [],
|
|
28286
|
-
commit: '--unstaged',
|
|
28287
|
-
options: { tokenizer, git, llm, logger },
|
|
28288
|
-
});
|
|
28289
|
-
const unstagedResponse = `Unstaged changes:\n${unstagedChanges}`;
|
|
28290
|
-
const untrackedChanges = await fileChangeParser({
|
|
28291
|
-
changes: untracked || [],
|
|
28292
|
-
commit: '--untracked',
|
|
28293
|
-
options: { tokenizer, git, llm, logger },
|
|
28294
|
-
});
|
|
28295
|
-
const untrackedResponse = `Untracked changes:\n${untrackedChanges}`;
|
|
28296
|
-
const stagedChanges = await fileChangeParser({
|
|
28297
|
-
changes: staged,
|
|
28298
|
-
commit: '--staged',
|
|
28299
|
-
options: { tokenizer, git, llm, logger },
|
|
28300
|
-
});
|
|
28301
|
-
const stagedResponse = `Staged changes:\n${stagedChanges}`;
|
|
28302
|
-
return [unstagedResponse, untrackedResponse, stagedResponse];
|
|
28303
28267
|
}
|
|
28304
28268
|
async function parser(changes) {
|
|
28305
28269
|
return changes.join('\n');
|
|
@@ -28363,22 +28327,8 @@ const handler = async (argv, logger) => {
|
|
|
28363
28327
|
await reviewer.start();
|
|
28364
28328
|
};
|
|
28365
28329
|
|
|
28366
|
-
/**
|
|
28367
|
-
* Command line options via yargs
|
|
28368
|
-
*/
|
|
28369
|
-
const options = {
|
|
28370
|
-
i: {
|
|
28371
|
-
type: 'boolean',
|
|
28372
|
-
alias: 'interactive',
|
|
28373
|
-
description: 'Toggle interactive mode',
|
|
28374
|
-
},
|
|
28375
|
-
};
|
|
28376
|
-
const builder = (yargs) => {
|
|
28377
|
-
return yargs.options(options).usage(getCommandUsageHeader(review.command));
|
|
28378
|
-
};
|
|
28379
|
-
|
|
28380
28330
|
var review = {
|
|
28381
|
-
command
|
|
28331
|
+
command,
|
|
28382
28332
|
desc: 'Review the staged changes',
|
|
28383
28333
|
builder,
|
|
28384
28334
|
handler: commandExecutor(handler),
|