@amnesia2k/git-aic 2.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.
- package/LICENSE +21 -0
- package/README.md +312 -0
- package/bin/cli.ts +546 -0
- package/dist/bin/cli.d.ts +2 -0
- package/dist/bin/cli.js +394 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/src/config.d.ts +4 -0
- package/dist/src/config.js +6 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/git.d.ts +14 -0
- package/dist/src/git.js +116 -0
- package/dist/src/git.js.map +1 -0
- package/dist/src/llm.d.ts +9 -0
- package/dist/src/llm.js +201 -0
- package/dist/src/llm.js.map +1 -0
- package/dist/src/prompt.d.ts +7 -0
- package/dist/src/prompt.js +127 -0
- package/dist/src/prompt.js.map +1 -0
- package/package.json +51 -0
- package/src/config.ts +7 -0
- package/src/git.ts +141 -0
- package/src/llm.ts +340 -0
- package/src/prompt.ts +144 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Olatilewa Olatoye
|
|
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,312 @@
|
|
|
1
|
+
# Git AIC: AI-Powered Conventional Commits
|
|
2
|
+
|
|
3
|
+
Git AIC is a TypeScript CLI for two related workflows inside a Git repository:
|
|
4
|
+
|
|
5
|
+
- generating AI-assisted conventional commit messages from staged changes
|
|
6
|
+
- generating AI-explained markdown diff reports from selected working-tree changes
|
|
7
|
+
|
|
8
|
+
It is built for local Git usage with interactive file selection, Gemini-based summarization, and a low-friction terminal UX.
|
|
9
|
+
|
|
10
|
+
## What It Does
|
|
11
|
+
|
|
12
|
+
### Commit flow
|
|
13
|
+
|
|
14
|
+
`git aic`
|
|
15
|
+
|
|
16
|
+
- inspects the repository for changed files
|
|
17
|
+
- auto-stages deleted files for commit workflows
|
|
18
|
+
- lets you choose which files should be part of the commit when there are multiple changed files
|
|
19
|
+
- stages newly selected files and unstages deselected staged files
|
|
20
|
+
- sends the staged diff to Gemini
|
|
21
|
+
- generates a Conventional Commits style message
|
|
22
|
+
- commits with that message
|
|
23
|
+
|
|
24
|
+
`git aic --push / git aic -p`
|
|
25
|
+
|
|
26
|
+
- runs the same commit flow
|
|
27
|
+
- pushes after a successful commit
|
|
28
|
+
|
|
29
|
+
### Diff report flow
|
|
30
|
+
|
|
31
|
+
`git aic --diff / git aic -d`
|
|
32
|
+
|
|
33
|
+
- inspects the repository for changed files
|
|
34
|
+
- lets you choose which files should be included in the report when there are multiple changed files
|
|
35
|
+
- does **not** stage or unstage files for the diff workflow
|
|
36
|
+
- reads the selected changes directly from the working tree
|
|
37
|
+
- generates a markdown report in `git-diffs/`
|
|
38
|
+
- explains each selected file diff with AI
|
|
39
|
+
- includes current repo metadata such as branch and base commit hash
|
|
40
|
+
|
|
41
|
+
## Key Behaviors
|
|
42
|
+
|
|
43
|
+
- **Conventional commit generation**: Commit messages are guided by strict prompt rules.
|
|
44
|
+
- **Single logical change stays one line**: If multiple files all belong to one logical change, the generated commit message stays a one-line summary.
|
|
45
|
+
- **Unrelated changes may become a list**: If the changes are clearly unrelated, the generated commit message may use a summary line plus bullet points.
|
|
46
|
+
- **Interactive file selection**: Multi-file changes open a selector so the user can choose the exact file set to commit, push, or document.
|
|
47
|
+
- **AI diff reports**: Diff reports explain the selected changes before showing the raw patch.
|
|
48
|
+
- **Structured diff naming**: Report filenames use a concise `type-topic.md` format such as `feat-auth-flow.md`.
|
|
49
|
+
- **Organized output**: Reports are written to `git-diffs/` in the current working directory.
|
|
50
|
+
- **Git ignore support**: On the first diff report run that creates `git-diffs/`, the tool adds `git-diffs/` to the current directory’s `.gitignore` if it is not already ignored.
|
|
51
|
+
- **Visible loading states**: Uses `cli-loaders` with the `arrows_3` loader and step-specific status messages.
|
|
52
|
+
- **Retry-safe AI requests**: Retries temporary Gemini rate limits and transient failures, then falls back cleanly if needed.
|
|
53
|
+
|
|
54
|
+
## Diff Report Contents
|
|
55
|
+
|
|
56
|
+
Each generated markdown report includes:
|
|
57
|
+
|
|
58
|
+
- report title
|
|
59
|
+
- metadata section
|
|
60
|
+
- generated timestamp
|
|
61
|
+
- current branch
|
|
62
|
+
- short base commit hash
|
|
63
|
+
- full base commit hash
|
|
64
|
+
- selected file list
|
|
65
|
+
- one section per file
|
|
66
|
+
- AI explanation above the raw diff block
|
|
67
|
+
|
|
68
|
+
## Installation
|
|
69
|
+
|
|
70
|
+
### 1. Global Installation (Standard)
|
|
71
|
+
|
|
72
|
+
The easiest way to use Git AIC is to install it globally via `npm` or `bun`:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm install -g @amnesia2k/git-aic
|
|
76
|
+
# or
|
|
77
|
+
bun install -g @amnesia2k/git-aic
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Once installed, you can skip the manual setup and use the built-in configuration commands:
|
|
81
|
+
|
|
82
|
+
- `git-aic set-key <your-key>`
|
|
83
|
+
- `git-aic alias`
|
|
84
|
+
|
|
85
|
+
### 2. Local Development (Clone)
|
|
86
|
+
|
|
87
|
+
For developers or users who want to run the tool from the source code:
|
|
88
|
+
|
|
89
|
+
1. Clone the repository:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
git clone https://github.com/amnesia2k/git-aic.git
|
|
93
|
+
cd git-aic
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
2. Install dependencies:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
bun install
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
3. (Optional) Link the package locally:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
npm link
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Configuration & API Key
|
|
109
|
+
|
|
110
|
+
Git AIC requires a Google Gemini API key.
|
|
111
|
+
|
|
112
|
+
### A. Persistent Configuration (Recommended)
|
|
113
|
+
|
|
114
|
+
You can securely store your API key in your user profile:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
git-aic set-key your_gemini_api_key_here
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
To see your current configuration:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
git-aic show
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### B. Environment Variables (Manual)
|
|
127
|
+
|
|
128
|
+
Alternatively, you can set the `GEMINI_COMMIT_MESSAGE_API_KEY` variable.
|
|
129
|
+
|
|
130
|
+
**Windows PowerShell:**
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
setx GEMINI_COMMIT_MESSAGE_API_KEY "your_gemini_api_key_here"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**MacOS & Linux:**
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
export GEMINI_COMMIT_MESSAGE_API_KEY=your_gemini_api_key_here
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Restart the terminal after setting the variable.
|
|
143
|
+
|
|
144
|
+
## Usage
|
|
145
|
+
|
|
146
|
+
### 1. The "git aic" Alias
|
|
147
|
+
|
|
148
|
+
To use the tool as a native Git subcommand (`git aic`), you need to set up a Git alias.
|
|
149
|
+
|
|
150
|
+
#### Option A: Automatic Setup (Global NPM)
|
|
151
|
+
|
|
152
|
+
If you installed via NPM, run:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
git-aic alias
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### Option B: Manual Setup (Local Clone)
|
|
159
|
+
|
|
160
|
+
If you are running from a local clone, point the alias to your entry point:
|
|
161
|
+
|
|
162
|
+
**Windows PowerShell:**
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
git config --global alias.aic '!npx tsx "C:/Users/YourName/path/to/git-aic/bin/cli.ts"'
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**macOS / Linux:**
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
git config --global alias.aic '!npx tsx "/Users/YourName/path/to/git-aic/bin/cli.ts"'
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 2. Commands
|
|
175
|
+
|
|
176
|
+
**Generate and create a commit:**
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
git aic
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
**Generate, commit, and push:**
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
git aic --push
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Generate a markdown diff report:**
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
git aic --diff
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Show current configuration:**
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
git aic show
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Display help:**
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
git aic help
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
> [!TIP]
|
|
207
|
+
> Use `git aic help` or `git aic -h` to see the help menu. Git reserves `--help` for its own internal documentation search, which causes raw `--help` to fail on custom aliases.
|
|
208
|
+
|
|
209
|
+
**Also supported:**
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
git aic -d : This is a shortcut for `git aic --diff`
|
|
213
|
+
git aic -p : This is a shortcut for `git aic --push`
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Important Workflow Notes
|
|
217
|
+
|
|
218
|
+
### Commit mode stages files
|
|
219
|
+
|
|
220
|
+
Commit workflows are based on the staged diff.
|
|
221
|
+
|
|
222
|
+
When you select files for commit mode:
|
|
223
|
+
|
|
224
|
+
- unselected staged files are unstaged
|
|
225
|
+
- selected unstaged files are staged
|
|
226
|
+
- the final commit message is generated from the resulting staged diff
|
|
227
|
+
|
|
228
|
+
### Diff mode does not stage files
|
|
229
|
+
|
|
230
|
+
Diff report workflows are based on the selected changes directly.
|
|
231
|
+
|
|
232
|
+
When you select files for `-d` / `--diff`:
|
|
233
|
+
|
|
234
|
+
- the tool does not stage files
|
|
235
|
+
- the tool does not unstage files
|
|
236
|
+
- the tool reads the selected diffs and generates the markdown report from them
|
|
237
|
+
|
|
238
|
+
This keeps the report flow non-destructive and avoids changing index state unnecessarily.
|
|
239
|
+
|
|
240
|
+
## Example Output Location
|
|
241
|
+
|
|
242
|
+
Example generated report paths:
|
|
243
|
+
|
|
244
|
+
- `git-diffs/feat-auth-flow.md`
|
|
245
|
+
- `git-diffs/fix-config-loading.md`
|
|
246
|
+
- `git-diffs/refactor-cli-loader.md`
|
|
247
|
+
|
|
248
|
+
If a filename already exists, numeric suffixes are used:
|
|
249
|
+
|
|
250
|
+
- `feat-auth-flow.md`
|
|
251
|
+
- `feat-auth-flow-1.md`
|
|
252
|
+
- `feat-auth-flow-2.md`
|
|
253
|
+
|
|
254
|
+
<!-- ## Tech Stack
|
|
255
|
+
|
|
256
|
+
- TypeScript
|
|
257
|
+
- Node.js
|
|
258
|
+
- Commander.js
|
|
259
|
+
- Chalk
|
|
260
|
+
- `@clack/prompts`
|
|
261
|
+
- `simple-git`
|
|
262
|
+
- Axios
|
|
263
|
+
- Google Gemini
|
|
264
|
+
- `cli-loaders` -->
|
|
265
|
+
|
|
266
|
+
## Technologies Used
|
|
267
|
+
|
|
268
|
+
| Technology | Description |
|
|
269
|
+
| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
|
|
270
|
+
|  | Primary language for robust and scalable code. |
|
|
271
|
+
|  | JavaScript runtime used to execute the CLI tool. |
|
|
272
|
+
|  | Fast all-in-one JavaScript runtime. |
|
|
273
|
+
|  | Large Language Model for intelligent commit message generation. |
|
|
274
|
+
|  | Promise-based HTTP client for API requests. |
|
|
275
|
+
|  | Facilitates Git operations programmatically. |
|
|
276
|
+
|  | Interactive command-line interface prompts. |
|
|
277
|
+
|  | Provides animated terminal loaders for visible CLI progress. |
|
|
278
|
+
|  | Terminal string styling for enhanced readability. |
|
|
279
|
+
|  | Framework for building robust command-line interfaces. |
|
|
280
|
+
|  | Runs the TypeScript CLI entrypoint directly during local usage. |
|
|
281
|
+
|  | Supports direct TypeScript execution in the project scripts. |
|
|
282
|
+
|
|
283
|
+
<!-- ## Contributing
|
|
284
|
+
|
|
285
|
+
We welcome contributions to Git AIC! If you have suggestions for improvements or new features, please feel free to contribute.
|
|
286
|
+
|
|
287
|
+
-- ✨ Fork the repository to your GitHub account.
|
|
288
|
+
-- 🛠️ Create a new branch for your feature or bug fix: `git checkout -b feature/your-feature-name`.
|
|
289
|
+
-- 💡 Implement your changes and ensure they align with the project's coding style.
|
|
290
|
+
-- 📝 Commit your changes with a descriptive, Conventional Commit-style message.
|
|
291
|
+
-- 🚀 Push your branch and open a pull request. -->
|
|
292
|
+
|
|
293
|
+
## License
|
|
294
|
+
|
|
295
|
+
This project is licensed under the [MIT License](LICENSE). See the file for details.
|
|
296
|
+
|
|
297
|
+
## Author Info
|
|
298
|
+
|
|
299
|
+
Developed by a passionate software engineer.
|
|
300
|
+
|
|
301
|
+
- **Olatilewa Olatoye**
|
|
302
|
+
- LinkedIn: [`[Olatilewa Olatoye]`](https://www.linkedin.com/in/olatilewaolatoye)
|
|
303
|
+
- X (formerly Twitter): [`[@olathedev_]`](https://x.com/olathedev_)
|
|
304
|
+
|
|
305
|
+
## Badges
|
|
306
|
+
|
|
307
|
+
[](https://www.typescriptlang.org/)
|
|
308
|
+
[](https://nodejs.org/en/)
|
|
309
|
+
[](https://www.npmjs.com/package/@amnesia2k/git-aic)
|
|
310
|
+
[](https://opensource.org/licenses/MIT)
|
|
311
|
+
|
|
312
|
+
[](https://www.npmjs.com/package/dokugen)
|