git-coco 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +120 -0
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.esm.mjs +1074 -0
  5. package/dist/index.esm.mjs.map +1 -0
  6. package/dist/index.js +1098 -0
  7. package/dist/lib/config/default.d.ts +7 -0
  8. package/dist/lib/config/index.d.ts +21 -0
  9. package/dist/lib/config/services/env.d.ts +8 -0
  10. package/dist/lib/config/services/git.d.ts +8 -0
  11. package/dist/lib/config/services/ignore.d.ts +15 -0
  12. package/dist/lib/config/services/project.d.ts +8 -0
  13. package/dist/lib/config/services/xdg.d.ts +8 -0
  14. package/dist/lib/config/services/yargs.d.ts +25 -0
  15. package/dist/lib/config/types.d.ts +63 -0
  16. package/dist/lib/langchain/chains/llm.d.ts +6 -0
  17. package/dist/lib/langchain/chains/summarize.d.ts +11 -0
  18. package/dist/lib/langchain/prompts/commitDefault.d.ts +3 -0
  19. package/dist/lib/langchain/prompts/summarize.d.ts +3 -0
  20. package/dist/lib/langchain/utils.d.ts +20 -0
  21. package/dist/lib/parsers/default/fileChangeParser.d.ts +2 -0
  22. package/dist/lib/parsers/default/utils/collectDiffs.d.ts +8 -0
  23. package/dist/lib/parsers/default/utils/createDiffTree.d.ts +12 -0
  24. package/dist/lib/parsers/default/utils/parseFileDiff.d.ts +4 -0
  25. package/dist/lib/parsers/default/utils/summarizeDiffs.d.ts +24 -0
  26. package/dist/lib/parsers/noResult.d.ts +8 -0
  27. package/dist/lib/types.d.ts +34 -0
  28. package/dist/lib/ui.d.ts +2 -0
  29. package/dist/lib/utils/getPathFromFilePath.d.ts +6 -0
  30. package/dist/lib/utils/getTokenizer.d.ts +9 -0
  31. package/dist/lib/utils/getTruncatedFilePath.d.ts +1 -0
  32. package/dist/lib/utils/git/constants.d.ts +1 -0
  33. package/dist/lib/utils/git/createCommit.d.ts +2 -0
  34. package/dist/lib/utils/git/getChanges.d.ts +43 -0
  35. package/dist/lib/utils/git/getStatus.d.ts +3 -0
  36. package/dist/lib/utils/git/getSummaryText.d.ts +2 -0
  37. package/dist/lib/utils/git/parsePatches.d.ts +18 -0
  38. package/dist/lib/utils/logger.d.ts +23 -0
  39. package/dist/lib/utils/readFile.d.ts +3 -0
  40. package/dist/lib/utils/removeUndefined.d.ts +9 -0
  41. package/dist/stats.html +5305 -0
  42. package/dist/types.d.ts +2 -0
  43. package/package.json +92 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 gfargo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,120 @@
1
+ # `coco` πŸ€–πŸ¦
2
+
3
+ Commit Copilot, or `coco`, is your personal scribe for git commit messages. Using [LangChainπŸ¦œπŸ”—](https://js.langchain.com/) to automate the task of creating meaningful commit messages based on your staged changes!
4
+
5
+ ## Installation
6
+
7
+ Get started by adding `coco` to your project's development dependencies:
8
+
9
+ ```bash
10
+ npm i git-coco --save-dev
11
+ ```
12
+
13
+ Or, for global access, you can install `coco` system-wide:
14
+
15
+ ```bash
16
+ npm i -g git-coco
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ There are two main ways to use `coco`:
22
+
23
+ 1. [Interactive Mode](#interactive)
24
+ 2. [Command Line Interface (CLI)](#cli)
25
+
26
+ ### **Interactive Mode**
27
+
28
+ Just type `coco` and let the friendly prompts guide you through the commit process!
29
+
30
+ ```bash
31
+ coco -i
32
+ ```
33
+
34
+ The interactive mode offers you several benefits:
35
+
36
+ - Preview and approve or regenerate the commit message before it's committed
37
+ - Customize your prompts for a personalized commit experience
38
+
39
+ ### **Command Line Interface (CLI)**
40
+
41
+ If you're the type who likes to keep it simple, you can pass your commit message directly as a CLI argument:
42
+
43
+ ```bash
44
+ coco --openAIApiKey="sk_your-openai-api-key"
45
+ ```
46
+
47
+ Assuming you've stored your API key in the config file ([learn more](#the-cococonfig)), you can also commit with:
48
+
49
+ ```bash
50
+ git commit -m $(coco)
51
+ ```
52
+
53
+ Alternatively, take advantage of `coco`'s full potential by allowing it to make the commit for you!
54
+
55
+ ```bash
56
+ coco -s
57
+ ```
58
+
59
+ ## **The `coco.config`**
60
+
61
+ `coco.config` houses the project-level settings and can be defined in multiple places, adhering to a hierarchical order of priority. If the same configuration is found in multiple places, the higher priority one will be considered.
62
+
63
+ From highest to lowest, the priority order is:
64
+
65
+ 1. **Command Line Flags**: Flags in the command line have the highest priority, and they override all other settings.
66
+ 2. **Environment Variables**: Next in line are environment variables. You can set any configuration option as an environment variable.
67
+ 3. **Project Config (`.coco.config.json`)**: Create a `.coco.config.json` file in your project root to set configurations. It's recommended to store your OpenAI API key here alongside any other project-specific configurations.
68
+ 4. **Git Profile (`.gitconfig`)**: You can define `coco` settings under a `[coco]` section in your git profile. These settings will be used unless overridden by higher-priority ones.
69
+ 5. **XDG Configuration Directory**: If `XDG_CONFIG_HOME` is set, `coco` will look for a `coco/config` file in this directory for configurations.
70
+
71
+ Here's an example `.coco.config.json` file:
72
+
73
+ ```json
74
+ {
75
+ "openAIApiKey": "sk_your-openai-api-key",
76
+ }
77
+ ```
78
+
79
+ And the same settings in `.gitconfig`:
80
+
81
+ ```ini
82
+ [coco]
83
+ openAIApiKey = sk_your-openai-api-key
84
+ ```
85
+
86
+ Remember, command line flags and environment variables should be defined in `UPPER_SNAKE_CASE`. For instance, the `openAIApiKey` setting becomes `OPENAI_API_KEY`.
87
+
88
+ ### Options
89
+
90
+ | Name | Type | Default Value | Description |
91
+ |--------------------------|---------------------------------|-------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
92
+ | openAIApiKey | string | None | Your OpenAI API key |
93
+ | tokenLimit | number | 500 | Maximum number of tokens for the commit message |
94
+ | prompt | string | `"What are the changes in this commit?"` | Prompt for OpenAI GPT-3 |
95
+ | temperature | number | 0.4 | Controls randomness in GPT-3 output. Lower values yield focused output; higher values offer diversity |
96
+ | mode | `stdout` \| `interactive` | `stdout` | Preferred output method for generated commit messages |
97
+ | summarizePrompt | string | `"Summarize the changes in this large file:"` | GPT-3 prompt for summarizing large files |
98
+ | ignoredFiles | string[] | `["package-lock.json"]` | Paths of files to be excluded when generating commit messages |
99
+ | ignoredExtensions | string[] | `[".map", ".lock"]` | File extensions to be excluded when generating commit messages |
100
+
101
+ ## Roadmap
102
+
103
+ - [x] Interactive mode πŸ€–
104
+ - [x] Stdout πŸ“€
105
+ - [x] LangChain integration 🦜
106
+ - [ ] Additional tests! πŸ§ͺ
107
+ - [ ] Conventional commits πŸ”œ
108
+ - [ ] HuggingFace integration πŸ”œ
109
+ - [ ] Google Vertex AI integration (?)
110
+ - [ ] Automatic changelog generation 🫣
111
+ - [ ] Rebase support πŸ”€
112
+ - [ ] `coco --amend b31dfc` πŸ‘©β€πŸ’»
113
+
114
+ ...and more! πŸ§‘β€πŸ”¬ πŸš€
115
+
116
+ ## Contribution
117
+
118
+ Have an idea for a feature or want to get involved, we welcome contributions!
119
+
120
+ Please check out our [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};