git-coco 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/index.d.ts +263 -2
  2. package/dist/index.esm.mjs +6 -1
  3. package/dist/index.js +9 -0
  4. package/package.json +11 -4
  5. package/dist/commands/changelog/handler.d.ts +0 -3
  6. package/dist/commands/changelog/index.d.ts +0 -10
  7. package/dist/commands/changelog/options.d.ts +0 -16
  8. package/dist/commands/commit/handler.d.ts +0 -3
  9. package/dist/commands/commit/index.d.ts +0 -10
  10. package/dist/commands/commit/options.d.ts +0 -15
  11. package/dist/commands/init/handler.d.ts +0 -3
  12. package/dist/commands/init/index.d.ts +0 -10
  13. package/dist/commands/init/options.d.ts +0 -15
  14. package/dist/commands/types.d.ts +0 -14
  15. package/dist/index.esm.mjs.map +0 -1
  16. package/dist/lib/config/constants.d.ts +0 -13
  17. package/dist/lib/config/loadConfig.d.ts +0 -19
  18. package/dist/lib/config/services/env.d.ts +0 -9
  19. package/dist/lib/config/services/git.d.ts +0 -15
  20. package/dist/lib/config/services/ignore.d.ts +0 -15
  21. package/dist/lib/config/services/project.d.ts +0 -9
  22. package/dist/lib/config/services/xdg.d.ts +0 -8
  23. package/dist/lib/config/types.d.ts +0 -83
  24. package/dist/lib/langchain/chains/summarize.d.ts +0 -11
  25. package/dist/lib/langchain/executeChain.d.ts +0 -6
  26. package/dist/lib/langchain/prompts/changelog.d.ts +0 -3
  27. package/dist/lib/langchain/prompts/commitDefault.d.ts +0 -3
  28. package/dist/lib/langchain/prompts/summarize.d.ts +0 -3
  29. package/dist/lib/langchain/utils.d.ts +0 -48
  30. package/dist/lib/parsers/default/index.d.ts +0 -2
  31. package/dist/lib/parsers/default/utils/collectDiffs.d.ts +0 -8
  32. package/dist/lib/parsers/default/utils/createDiffTree.d.ts +0 -13
  33. package/dist/lib/parsers/default/utils/summarizeDiffs.d.ts +0 -26
  34. package/dist/lib/parsers/noResult.d.ts +0 -8
  35. package/dist/lib/simple-git/createCommit.d.ts +0 -2
  36. package/dist/lib/simple-git/getChanges.d.ts +0 -15
  37. package/dist/lib/simple-git/getChangesByCommit.d.ts +0 -13
  38. package/dist/lib/simple-git/getCommitLogCurrentBranch.d.ts +0 -9
  39. package/dist/lib/simple-git/getCommitLogRange.d.ts +0 -7
  40. package/dist/lib/simple-git/getCurrentBranchName.d.ts +0 -5
  41. package/dist/lib/simple-git/getDiff.d.ts +0 -7
  42. package/dist/lib/simple-git/getDiffFromCommmit.d.ts +0 -10
  43. package/dist/lib/simple-git/getRepo.d.ts +0 -2
  44. package/dist/lib/simple-git/getStatus.d.ts +0 -3
  45. package/dist/lib/simple-git/getSummaryText.d.ts +0 -3
  46. package/dist/lib/simple-git/helpers.d.ts +0 -6
  47. package/dist/lib/types.d.ts +0 -47
  48. package/dist/lib/ui/editPrompt.d.ts +0 -2
  49. package/dist/lib/ui/editResult.d.ts +0 -2
  50. package/dist/lib/ui/generateAndReviewLoop.d.ts +0 -16
  51. package/dist/lib/ui/getUserReviewDecision.d.ts +0 -2
  52. package/dist/lib/ui/handleResult.d.ts +0 -5
  53. package/dist/lib/ui/helpers.d.ts +0 -3
  54. package/dist/lib/ui/logResult.d.ts +0 -1
  55. package/dist/lib/ui/logSuccess.d.ts +0 -1
  56. package/dist/lib/utils/getPathFromFilePath.d.ts +0 -6
  57. package/dist/lib/utils/getTokenizer.d.ts +0 -9
  58. package/dist/lib/utils/logger.d.ts +0 -23
  59. package/dist/lib/utils/removeUndefined.d.ts +0 -9
  60. package/dist/lib/utils/updateFileSection.d.ts +0 -1
  61. package/dist/stats.html +0 -5305
package/dist/index.d.ts CHANGED
@@ -1,2 +1,263 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ /// <reference types="yargs" />
2
+ import * as yargs from 'yargs';
3
+ import { Argv } from 'yargs';
4
+ import { HuggingFaceInference } from 'langchain/llms/hf';
5
+ import { BaseLLMParams } from 'langchain/llms/base';
6
+ import { OpenAIInput, AzureOpenAIInput, OpenAI } from 'langchain/llms/openai';
7
+ import { SimpleGit } from 'simple-git';
8
+ import { Color } from 'chalk';
9
+ import GPT3NodeTokenizer from 'gpt3-tokenizer';
10
+
11
+ interface Config$1 {
12
+ /**
13
+ * The LLM model to use for generating results.
14
+ *
15
+ * @default 'openai/gpt-4'
16
+ *
17
+ * @example 'openai/gpt-4'
18
+ * @example 'openai/gpt-3.5-turbo'
19
+ * @example 'huggingface/bigscience/bloom'
20
+ **/
21
+ model: string;
22
+ /**
23
+ * The OpenAI API key.
24
+ */
25
+ openAIApiKey?: string;
26
+ /**
27
+ * The HuggingFace Hub API key.
28
+ */
29
+ huggingFaceHubApiKey?: string;
30
+ /**
31
+ * The maximum number of tokens per request.
32
+ *
33
+ * @default 1024
34
+ */
35
+ tokenLimit?: number;
36
+ /**
37
+ * The prompt text used for generating results.
38
+ */
39
+ prompt?: string;
40
+ /**
41
+ * The temperature value controls the randomness of the generated output.
42
+ * Higher values (e.g., 0.8) make the output more random, while lower values (e.g., 0.2) make it more deterministic.
43
+ *
44
+ * @default 0.4
45
+ */
46
+ temperature?: number;
47
+ /**
48
+ * The output destination for the generated result.
49
+ * - 'stdout': Prints the result to the standard output. This is the default behavior.
50
+ * - 'interactive': Provides an interactive prompt for editing the result & committing the changes.
51
+ *
52
+ * @default 'stdout'
53
+ */
54
+ mode?: 'stdout' | 'interactive';
55
+ /**
56
+ * Enable verbose logging.
57
+ *
58
+ * @default false
59
+ */
60
+ verbose?: boolean;
61
+ /**
62
+ * Open the commit message in an editor for editing before proceeding.
63
+ *
64
+ * @default false
65
+ */
66
+ openInEditor?: boolean;
67
+ /**
68
+ * The prompt text used specifically for generating summaries of large files.
69
+ */
70
+ summarizePrompt?: string;
71
+ /**
72
+ * An array of file paths or patterns to be ignored during processing.
73
+ *
74
+ * Note: This is a list of patterns interpreted by the `minimatch` library.
75
+ * @see https://github.com/isaacs/minimatch
76
+ *
77
+ * @example ['package-lock.json', 'node_modules']
78
+ * @default ['package-lock.json', contents of .gitignore, contents of .ignore]
79
+ */
80
+ ignoredFiles?: string[];
81
+ /**
82
+ * An array of file extensions to be ignored during processing.
83
+ *
84
+ * @default ['.map', '.lock']
85
+ */
86
+ ignoredExtensions?: string[];
87
+ /**
88
+ * Default git branch for the repository.
89
+ *
90
+ * @default 'main'
91
+ */
92
+ defaultBranch?: string;
93
+ }
94
+
95
+ interface BaseArgvOptions {
96
+ interactive: boolean;
97
+ help: boolean;
98
+ verbose: boolean;
99
+ }
100
+ interface BaseCommandOptions extends BaseArgvOptions {
101
+ [x: string]: unknown;
102
+ model: string;
103
+ openAIApiKey: string;
104
+ huggingFaceHubApiKey: string;
105
+ tokenLimit: number;
106
+ }
107
+
108
+ interface CommitOptions$1 extends BaseCommandOptions {
109
+ prompt: string;
110
+ commit: boolean;
111
+ summarizePrompt: string;
112
+ openInEditor: boolean;
113
+ ignoredFiles: string[];
114
+ ignoredExtensions: string[];
115
+ }
116
+
117
+ declare function handler$2(argv: Argv<CommitOptions$1>['argv']): Promise<void>;
118
+
119
+ declare const _default$2: {
120
+ command: string;
121
+ desc: string;
122
+ builder: (yargs: yargs.Argv<{}>) => yargs.Argv<yargs.Omit<{}, string> & yargs.InferredOptionTypes<Record<string, yargs.Options>>>;
123
+ handler: typeof handler$2;
124
+ options: Record<string, yargs.Options>;
125
+ };
126
+
127
+ interface ChangelogOptions extends BaseCommandOptions {
128
+ range: string;
129
+ prompt: string;
130
+ commit: boolean;
131
+ summarizePrompt: string;
132
+ openInEditor: boolean;
133
+ ignoredFiles: string[];
134
+ ignoredExtensions: string[];
135
+ }
136
+
137
+ declare function handler$1(argv: Argv<ChangelogOptions>['argv']): Promise<void>;
138
+
139
+ declare const _default$1: {
140
+ command: string;
141
+ desc: string;
142
+ builder: (yargs: yargs.Argv<{}>) => yargs.Argv<yargs.Omit<{}, string> & yargs.InferredOptionTypes<Record<string, yargs.Options>>>;
143
+ handler: typeof handler$1;
144
+ options: Record<string, yargs.Options>;
145
+ };
146
+
147
+ interface CommitOptions extends BaseCommandOptions {
148
+ prompt: string;
149
+ commit: boolean;
150
+ summarizePrompt: string;
151
+ openInEditor: boolean;
152
+ ignoredFiles: string[];
153
+ ignoredExtensions: string[];
154
+ }
155
+
156
+ declare function handler(argv: Argv<CommitOptions>['argv']): Promise<void>;
157
+
158
+ declare const _default: {
159
+ command: string;
160
+ desc: string;
161
+ builder: (yargs: yargs.Argv<{}>) => yargs.Argv<yargs.Omit<{}, string> & yargs.InferredOptionTypes<Record<string, yargs.Options>>>;
162
+ handler: typeof handler;
163
+ options: Record<string, yargs.Options>;
164
+ };
165
+
166
+ /**
167
+ * Get LLM Model Based on Configuration
168
+ * @param fields
169
+ * @param configuration
170
+ * @returns LLM Model
171
+ */
172
+ declare function getModel(name: string, key: string, fields?: (Partial<OpenAIInput> & Partial<AzureOpenAIInput> & BaseLLMParams) | undefined): OpenAI | HuggingFaceInference;
173
+
174
+ interface LoggerOptions {
175
+ color?: typeof Color;
176
+ }
177
+ interface SpinnerOptions {
178
+ mode?: undefined | 'stop' | 'succeed' | 'warn' | 'fail';
179
+ color?: typeof Color;
180
+ }
181
+ interface Config {
182
+ verbose?: boolean;
183
+ }
184
+ declare class Logger {
185
+ private config;
186
+ private timerStart;
187
+ private spinner;
188
+ constructor(config: Config);
189
+ log(message: string, options?: LoggerOptions): Logger;
190
+ verbose(message: string, options?: LoggerOptions): Logger;
191
+ startTimer(): Logger;
192
+ stopTimer(message?: string, options?: LoggerOptions): Logger;
193
+ startSpinner(message: string, options?: Omit<SpinnerOptions, 'mode'>): Logger;
194
+ stopSpinner(message?: string | undefined, options?: SpinnerOptions): Logger;
195
+ }
196
+
197
+ /**
198
+ * Wrapper around GPT3NodeTokenizer to handle default export.
199
+ *
200
+ * @see https://github.com/botisan-ai/gpt3-tokenizer/issues/18
201
+ *
202
+ * @returns {GPT3NodeTokenizer} The GPT3NodeTokenizer instance.
203
+ */
204
+ declare const getTokenizer: () => GPT3NodeTokenizer;
205
+
206
+ type FileChangeStatus = 'modified' | 'renamed' | 'added' | 'deleted' | 'untracked' | 'unknown';
207
+ interface FileChange {
208
+ summary: string;
209
+ filePath: string;
210
+ oldFilePath?: string;
211
+ status: FileChangeStatus;
212
+ }
213
+ interface FileDiff {
214
+ file: string;
215
+ diff: string;
216
+ summary: string;
217
+ tokenCount: number;
218
+ }
219
+ interface DiffNode {
220
+ path: string;
221
+ diffs: FileDiff[];
222
+ children: DiffNode[];
223
+ }
224
+ interface DirectoryDiff {
225
+ path: string;
226
+ diffs: FileDiff[];
227
+ summary?: string;
228
+ tokenCount: number;
229
+ }
230
+ interface BaseParserOptions {
231
+ tokenizer: ReturnType<typeof getTokenizer>;
232
+ model: ReturnType<typeof getModel>;
233
+ git: SimpleGit;
234
+ logger: Logger;
235
+ }
236
+ interface BaseParserInput {
237
+ options: BaseParserOptions;
238
+ }
239
+ interface FileChangeParserInput extends BaseParserInput {
240
+ changes: FileChange[];
241
+ commit: '--staged' | string;
242
+ }
243
+ interface CommitLogParserInput extends BaseParserInput {
244
+ range: {
245
+ from: string;
246
+ to: string;
247
+ };
248
+ }
249
+
250
+ type types_d_BaseParserInput = BaseParserInput;
251
+ type types_d_BaseParserOptions = BaseParserOptions;
252
+ type types_d_CommitLogParserInput = CommitLogParserInput;
253
+ type types_d_DiffNode = DiffNode;
254
+ type types_d_DirectoryDiff = DirectoryDiff;
255
+ type types_d_FileChange = FileChange;
256
+ type types_d_FileChangeParserInput = FileChangeParserInput;
257
+ type types_d_FileChangeStatus = FileChangeStatus;
258
+ type types_d_FileDiff = FileDiff;
259
+ declare namespace types_d {
260
+ export type { types_d_BaseParserInput as BaseParserInput, types_d_BaseParserOptions as BaseParserOptions, types_d_CommitLogParserInput as CommitLogParserInput, types_d_DiffNode as DiffNode, types_d_DirectoryDiff as DirectoryDiff, types_d_FileChange as FileChange, types_d_FileChangeParserInput as FileChangeParserInput, types_d_FileChangeStatus as FileChangeStatus, types_d_FileDiff as FileDiff };
261
+ }
262
+
263
+ export { type Config$1 as Config, _default$1 as changelog, _default$2 as commit, _default as init, types_d as types };
@@ -1720,6 +1720,10 @@ var init = {
1720
1720
  options,
1721
1721
  };
1722
1722
 
1723
+ var types = /*#__PURE__*/Object.freeze({
1724
+ __proto__: null
1725
+ });
1726
+
1723
1727
  yargs
1724
1728
  .scriptName('coco')
1725
1729
  .usage('$0 <cmd> [args]')
@@ -1740,4 +1744,5 @@ changelog.builder, changelog.handler)
1740
1744
  init.builder, init.handler)
1741
1745
  .demandCommand()
1742
1746
  .help().argv;
1743
- //# sourceMappingURL=index.esm.mjs.map
1747
+
1748
+ export { changelog, commit, init, types };
package/dist/index.js CHANGED
@@ -1741,6 +1741,10 @@ var init = {
1741
1741
  options,
1742
1742
  };
1743
1743
 
1744
+ var types = /*#__PURE__*/Object.freeze({
1745
+ __proto__: null
1746
+ });
1747
+
1744
1748
  yargs
1745
1749
  .scriptName('coco')
1746
1750
  .usage('$0 <cmd> [args]')
@@ -1761,3 +1765,8 @@ changelog.builder, changelog.handler)
1761
1765
  init.builder, init.handler)
1762
1766
  .demandCommand()
1763
1767
  .help().argv;
1768
+
1769
+ exports.changelog = changelog;
1770
+ exports.commit = commit;
1771
+ exports.init = init;
1772
+ exports.types = types;
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "git-coco",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "zero-effort git commits with coco.",
5
5
  "author": "gfargo <ghfargo@gmail.com>",
6
6
  "license": "MIT",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.esm.mjs",
9
9
  "files": [
10
- "dist"
10
+ "dist",
11
+ "!dist/dts"
11
12
  ],
13
+ "types": "dist/index.d.ts",
12
14
  "homepage": "https://github.com/gfargo/coco#readme",
13
15
  "bugs": {
14
16
  "url": "https://github.com/gfargo/coco/issues"
@@ -21,15 +23,19 @@
21
23
  "url": "git+https://github.com/gfargo/coco.git"
22
24
  },
23
25
  "scripts": {
24
- "test": "jest",
25
26
  "start": "npm run dev",
26
27
  "dev": "tsx watch src/index.ts",
27
28
  "build": "rollup -c",
28
29
  "build:watch": "rollup -c -w",
30
+ "clean": "rimraf dist && rimraf coverage",
29
31
  "lint": "eslint src",
30
32
  "lint:fix": "eslint --fix src",
33
+ "format": "prettier --write src",
34
+ "test": "npm run test:jest && npm run test:publish",
35
+ "test:publish": "npm run lint && npm publish --dry-run",
36
+ "test:jest": "jest",
31
37
  "release": "release-it",
32
- "prepublishOnly": "rimraf dist && npm run build",
38
+ "prepublishOnly": "npm run clean && npm run build",
33
39
  "coco": "npm run coco:ts",
34
40
  "coco:ts": "tsx src/index.ts",
35
41
  "coco:cjs": "node dist/index.js",
@@ -60,6 +66,7 @@
60
66
  "rollup": "^3.26.1",
61
67
  "rollup-plugin-banner2": "^1.2.2",
62
68
  "rollup-plugin-bin": "^1.0.0",
69
+ "rollup-plugin-dts": "^6.1.0",
63
70
  "rollup-plugin-executable": "^1.6.3",
64
71
  "rollup-plugin-peer-deps-external": "^2.2.4",
65
72
  "rollup-plugin-preserve-shebangs": "^0.2.0",
@@ -1,3 +0,0 @@
1
- import { Argv } from 'yargs';
2
- import { ChangelogOptions } from './options';
3
- export declare function handler(argv: Argv<ChangelogOptions>['argv']): Promise<void>;
@@ -1,10 +0,0 @@
1
- /// <reference types="yargs" />
2
- import { handler } from './handler';
3
- declare const _default: {
4
- command: string;
5
- desc: string;
6
- builder: (yargs: import("yargs").Argv<{}>) => import("yargs").Argv<import("yargs").Omit<{}, string> & import("yargs").InferredOptionTypes<Record<string, import("yargs").Options>>>;
7
- handler: typeof handler;
8
- options: Record<string, import("yargs").Options>;
9
- };
10
- export default _default;
@@ -1,16 +0,0 @@
1
- import { Options, Argv } from 'yargs';
2
- import { BaseCommandOptions } from '../types';
3
- export interface ChangelogOptions extends BaseCommandOptions {
4
- range: string;
5
- prompt: string;
6
- commit: boolean;
7
- summarizePrompt: string;
8
- openInEditor: boolean;
9
- ignoredFiles: string[];
10
- ignoredExtensions: string[];
11
- }
12
- /**
13
- * Command line options via yargs
14
- */
15
- export declare const options: Record<string, Options>;
16
- export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, string> & import("yargs").InferredOptionTypes<Record<string, Options>>>;
@@ -1,3 +0,0 @@
1
- import { CommitOptions } from './options';
2
- import { Argv } from 'yargs';
3
- export declare function handler(argv: Argv<CommitOptions>['argv']): Promise<void>;
@@ -1,10 +0,0 @@
1
- /// <reference types="yargs" />
2
- import { handler } from './handler';
3
- declare const _default: {
4
- command: string;
5
- desc: string;
6
- builder: (yargs: import("yargs").Argv<{}>) => import("yargs").Argv<import("yargs").Omit<{}, string> & import("yargs").InferredOptionTypes<Record<string, import("yargs").Options>>>;
7
- handler: typeof handler;
8
- options: Record<string, import("yargs").Options>;
9
- };
10
- export default _default;
@@ -1,15 +0,0 @@
1
- import { Options, Argv } from 'yargs';
2
- import { BaseCommandOptions } from '../types';
3
- export interface CommitOptions extends BaseCommandOptions {
4
- prompt: string;
5
- commit: boolean;
6
- summarizePrompt: string;
7
- openInEditor: boolean;
8
- ignoredFiles: string[];
9
- ignoredExtensions: string[];
10
- }
11
- /**
12
- * Command line options via yargs
13
- */
14
- export declare const options: Record<string, Options>;
15
- export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, string> & import("yargs").InferredOptionTypes<Record<string, Options>>>;
@@ -1,3 +0,0 @@
1
- import { CommitOptions } from './options';
2
- import { Argv } from 'yargs';
3
- export declare function handler(argv: Argv<CommitOptions>['argv']): Promise<void>;
@@ -1,10 +0,0 @@
1
- /// <reference types="yargs" />
2
- import { handler } from './handler';
3
- declare const _default: {
4
- command: string;
5
- desc: string;
6
- builder: (yargs: import("yargs").Argv<{}>) => import("yargs").Argv<import("yargs").Omit<{}, string> & import("yargs").InferredOptionTypes<Record<string, import("yargs").Options>>>;
7
- handler: typeof handler;
8
- options: Record<string, import("yargs").Options>;
9
- };
10
- export default _default;
@@ -1,15 +0,0 @@
1
- import { Options, Argv } from 'yargs';
2
- import { BaseCommandOptions } from '../types';
3
- export interface CommitOptions extends BaseCommandOptions {
4
- prompt: string;
5
- commit: boolean;
6
- summarizePrompt: string;
7
- openInEditor: boolean;
8
- ignoredFiles: string[];
9
- ignoredExtensions: string[];
10
- }
11
- /**
12
- * Command line options via yargs
13
- */
14
- export declare const options: Record<string, Options>;
15
- export declare const builder: (yargs: Argv) => Argv<import("yargs").Omit<{}, string> & import("yargs").InferredOptionTypes<Record<string, Options>>>;
@@ -1,14 +0,0 @@
1
- import { Config } from '../lib/config/types';
2
- interface BaseArgvOptions {
3
- interactive: boolean;
4
- help: boolean;
5
- verbose: boolean;
6
- }
7
- export interface BaseCommandOptions extends BaseArgvOptions {
8
- [x: string]: unknown;
9
- model: string;
10
- openAIApiKey: string;
11
- huggingFaceHubApiKey: string;
12
- tokenLimit: number;
13
- }
14
- export { Config };