@mehmetsagir/git-ai 0.0.9 → 0.0.19

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 (66) hide show
  1. package/README.md +135 -297
  2. package/dist/commit.d.ts +1 -4
  3. package/dist/commit.d.ts.map +1 -1
  4. package/dist/commit.js +214 -208
  5. package/dist/commit.js.map +1 -1
  6. package/dist/config.d.ts +0 -39
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +3 -95
  9. package/dist/config.js.map +1 -1
  10. package/dist/git.d.ts +19 -51
  11. package/dist/git.d.ts.map +1 -1
  12. package/dist/git.js +137 -269
  13. package/dist/git.js.map +1 -1
  14. package/dist/index.js +54 -109
  15. package/dist/index.js.map +1 -1
  16. package/dist/openai.d.ts +2 -21
  17. package/dist/openai.d.ts.map +1 -1
  18. package/dist/openai.js +17 -96
  19. package/dist/openai.js.map +1 -1
  20. package/dist/prompts.d.ts +2 -16
  21. package/dist/prompts.d.ts.map +1 -1
  22. package/dist/prompts.js +32 -146
  23. package/dist/prompts.js.map +1 -1
  24. package/dist/reset.d.ts +0 -3
  25. package/dist/reset.d.ts.map +1 -1
  26. package/dist/reset.js +10 -20
  27. package/dist/reset.js.map +1 -1
  28. package/dist/setup.d.ts +0 -3
  29. package/dist/setup.d.ts.map +1 -1
  30. package/dist/setup.js +28 -156
  31. package/dist/setup.js.map +1 -1
  32. package/dist/stash.d.ts +2 -0
  33. package/dist/stash.d.ts.map +1 -0
  34. package/dist/stash.js +818 -0
  35. package/dist/stash.js.map +1 -0
  36. package/dist/types.d.ts +9 -23
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/utils/hunk-parser.d.ts +22 -0
  39. package/dist/utils/hunk-parser.d.ts.map +1 -0
  40. package/dist/utils/hunk-parser.js +155 -0
  41. package/dist/utils/hunk-parser.js.map +1 -0
  42. package/package.json +8 -9
  43. package/dist/add.d.ts +0 -5
  44. package/dist/add.d.ts.map +0 -1
  45. package/dist/add.js +0 -98
  46. package/dist/add.js.map +0 -1
  47. package/dist/commit-processor.d.ts +0 -6
  48. package/dist/commit-processor.d.ts.map +0 -1
  49. package/dist/commit-processor.js +0 -226
  50. package/dist/commit-processor.js.map +0 -1
  51. package/dist/update.d.ts +0 -9
  52. package/dist/update.d.ts.map +0 -1
  53. package/dist/update.js +0 -69
  54. package/dist/update.js.map +0 -1
  55. package/dist/user-management.d.ts +0 -10
  56. package/dist/user-management.d.ts.map +0 -1
  57. package/dist/user-management.js +0 -175
  58. package/dist/user-management.js.map +0 -1
  59. package/dist/users.d.ts +0 -9
  60. package/dist/users.d.ts.map +0 -1
  61. package/dist/users.js +0 -129
  62. package/dist/users.js.map +0 -1
  63. package/dist/utils/validation.d.ts +0 -24
  64. package/dist/utils/validation.d.ts.map +0 -1
  65. package/dist/utils/validation.js +0 -81
  66. package/dist/utils/validation.js.map +0 -1
package/README.md CHANGED
@@ -1,396 +1,234 @@
1
- # Git AI
1
+ # git-ai
2
2
 
3
- AI-powered git commit tool. Analyzes git diffs, groups them logically, and creates commit messages in Conventional Commits standard.
3
+ AI-powered git commit tool that analyzes your changes, groups them logically, and creates meaningful commits following the Conventional Commits standard.
4
4
 
5
5
  ## Features
6
6
 
7
- - 🤖 **AI-Powered Analysis**: Analyzes git diffs with OpenAI
8
- - 📦 **Smart Grouping**: Groups changes logically
9
- - 📝 **Conventional Commits**: Uses standard commit message format
10
- - 👤 **Multiple Git User Support**: Manages multiple git user profiles
11
- - 🔒 **Secure**: Commits are not pushed automatically, provides manual control
7
+ - **Smart Commit Grouping** - AI analyzes your changes and groups related files together by feature or purpose
8
+ - **Conventional Commits** - Automatically generates commit messages in standard format (`feat`, `fix`, `refactor`, `chore`, etc.)
9
+ - **Stash Viewer** - Browse and manage git stashes in a beautiful web UI with diff viewer
10
+ - **Safe Workflow** - Always shows a commit plan for your approval before making any changes
12
11
 
13
12
  ## Installation
14
13
 
15
- ### Global Installation
16
-
17
14
  ```bash
18
15
  npm install -g @mehmetsagir/git-ai
19
16
  ```
20
17
 
21
- After installation, you can use `git-ai` command directly:
22
-
23
- ```bash
24
- git-ai setup
25
- git-ai commit
26
- ```
18
+ ## Setup
27
19
 
28
- ### Using with npx (no installation required)
20
+ Before using git-ai, you need to configure your OpenAI API key:
29
21
 
30
22
  ```bash
31
- npx @mehmetsagir/git-ai setup
32
- npx @mehmetsagir/git-ai commit
33
- ```
34
-
35
- ## Initial Setup
36
-
37
- Run the setup command on first use:
38
-
39
- ```bash
40
- # If installed globally
41
23
  git-ai setup
42
-
43
- # Or with npx
44
- npx @mehmetsagir/git-ai setup
45
24
  ```
46
25
 
47
- This command:
26
+ You'll be prompted to enter your OpenAI API key. Get one from [OpenAI Platform](https://platform.openai.com/api-keys).
48
27
 
49
- - Asks for your OpenAI API key
50
- - Detects your git user profiles
51
- - Allows you to select a default git user
52
- - Saves configuration to `~/.git-ai/config.json`
53
-
54
- ## Usage
28
+ ## Commands
55
29
 
56
- ### Creating Commits
30
+ ### `git-ai commit`
57
31
 
58
- **With default user:**
32
+ Analyze all changes in your repository and create intelligent commits.
59
33
 
60
34
  ```bash
61
- # If installed globally
62
35
  git-ai commit
63
-
64
- # Or with npx
65
- npx @mehmetsagir/git-ai commit
66
36
  ```
67
37
 
68
- **With a different user:**
69
-
70
- ```bash
71
- # Using shortcut (easiest method - single or multi-character)
72
- git-ai commit --user my
73
- git-ai commit --user g
74
- git-ai commit --user work
75
- git-ai commit -u personal
76
-
77
- # Using email
78
- git-ai commit --user user@example.com
79
-
80
- # Using user ID (ID shown during setup)
81
- git-ai commit --user global-user@example.com
82
- ```
83
-
84
- This command:
85
-
86
- 1. Analyzes git diffs (staged + unstaged)
87
- 2. Groups changes with OpenAI
88
- 3. Creates Conventional Commits format messages for each group
89
- 4. Shows commit plan and asks for confirmation
90
- 5. Creates each group as a separate commit after approval
91
- 6. **Does not push** - you need to push manually
92
-
93
- ### Example Output
38
+ **What it does:**
39
+ 1. Scans all changes (staged, unstaged, and untracked files)
40
+ 2. Sends diff to AI for analysis
41
+ 3. Groups related files together
42
+ 4. Generates commit messages for each group
43
+ 5. Shows you the commit plan for approval
44
+ 6. Creates commits after your confirmation
94
45
 
46
+ **Example output:**
95
47
  ```
96
- 🤖 Git Commit AI
48
+ 🤖 Git AI
97
49
 
98
- Changes analyzed
50
+ Found 5 file(s), 8 change(s)
99
51
 
100
- ✓ Analysis complete: 3 groups created
52
+ Changes:
53
+ + src/new-feature.ts
54
+ ~ src/auth.ts
55
+ ~ src/config.ts
56
+ - src/old-file.ts
101
57
 
102
- ✓ 3 groups created
58
+ Created 3 commit group(s)
103
59
 
104
60
  📋 Commit Plan:
105
61
 
106
- Group 1: Authentication feature
107
- Files: auth.ts, auth.test.ts
108
- Commit: feat(auth): add OAuth2 authentication support
109
- Added OAuth2 authentication support. Implemented token refresh mechanism.
110
-
111
- Group 2: UI component updates
112
- Files: Button.tsx, Input.tsx, styles.css
113
- Commit: style(ui): update design system colors
114
- Updated design system colors. Improved dark mode support.
115
-
116
- Group 3: API endpoint refactoring
117
- Files: api/users.ts, api/types.ts
118
- Commit: refactor(api): simplify user endpoint logic
119
- Simplified user endpoint logic. Improved error handling.
120
-
121
- Do you approve this commit plan? (Y/n)
122
- ```
123
-
124
- ## Conventional Commits Format
125
-
126
- The tool uses the [Conventional Commits](https://www.conventionalcommits.org/) standard:
127
-
128
- ```
129
- <type>(<scope>): <subject>
130
-
131
- <body>
132
-
133
- <footer>
134
- ```
135
-
136
- ### Commit Types
137
-
138
- - `feat`: New feature
139
- - `fix`: Bug fix
140
- - `refactor`: Code refactoring
141
- - `style`: Formatting, styling changes
142
- - `docs`: Documentation
143
- - `test`: Tests
144
- - `chore`: Maintenance tasks
145
-
146
- ## Git User Management
147
-
148
- The tool allows you to manage multiple git user profiles:
149
-
150
- - Automatic detection from global and local git configs
151
- - List active git users
152
- - Default user selection (during setup)
153
- - Manual profile addition
154
- - Different user selection during commit with `--user` or `-u` flag
155
-
156
- ### User Management During Setup
157
-
158
- When running the setup command:
159
-
160
- 1. **Active git user profiles are listed:**
161
-
162
- ```
163
- 📋 Active Git User Profiles:
164
- 1. John Doe <john@example.com> (Global) [shortcut: g]
165
- 2. Jane Smith <jane@example.com> (Local) [shortcut: t]
166
- ```
62
+ 1. Add authentication feature
63
+ src/auth.ts
64
+ src/new-feature.ts
65
+ feat(auth): add login functionality
167
66
 
168
- 2. **Shortcuts can be added for each user:**
67
+ 2. Update configuration
68
+ src/config.ts
69
+ → refactor(config): simplify config handling
169
70
 
170
- - "Would you like to add a shortcut?" question is asked for each user
171
- - Shortcut key is entered (can be single or multi-character, e.g., `g`, `my`, `work`, `personal`)
172
- - Shortcuts can be used during commit
71
+ 3. Remove deprecated code
72
+ src/old-file.ts
73
+ chore: remove unused files
173
74
 
174
- 3. **Default user is selected:**
75
+ ? Proceed with commits? Yes
175
76
 
176
- - Automatically selected if there's only one user
177
- - Selection is made if there are multiple users
77
+ 3 commit(s) created
178
78
 
179
- 4. **Optionally, more profiles can be added**
180
-
181
- 5. **Default user can be updated after adding new profiles**
182
-
183
- ### User Selection During Commit
184
-
185
- **Default usage:**
186
-
187
- ```bash
188
- git-ai commit
189
- # Uses default user from config
79
+ Don't forget to push: git push
190
80
  ```
191
81
 
192
- **With different user:**
193
-
194
- ```bash
195
- # Using shortcut (easiest - recommended, single or multi-character)
196
- git-ai commit --user my
197
- git-ai commit --user work
198
- git-ai commit -u personal
82
+ ### `git-ai stash`
199
83
 
200
- # Using email address
201
- git-ai commit --user jane@example.com
202
-
203
- # Short form
204
- git-ai commit -u jane@example.com
205
-
206
- # Using user ID (ID shown during setup)
207
- git-ai commit --user local-jane@example.com
208
- ```
209
-
210
- **To view current users:**
84
+ Open a web-based UI to browse and manage your git stashes.
211
85
 
212
86
  ```bash
213
- git-ai list
214
- # or
215
- git-ai users
87
+ git-ai stash
216
88
  ```
217
89
 
218
- ## Commands
90
+ **Features:**
91
+ - View all stashes in a clean list
92
+ - Click to see changed files and full diff
93
+ - VS Code-style split diff view (Original | Modified)
94
+ - Apply stash to your working directory
95
+ - Delete stashes you no longer need
96
+ - Syntax highlighting for code changes
219
97
 
220
- All commands can be used with `git-ai` (if installed globally) or `npx @mehmetsagir/git-ai`:
98
+ ### `git-ai setup`
221
99
 
222
- ### Setup
100
+ Configure or update your OpenAI API key.
223
101
 
224
102
  ```bash
225
103
  git-ai setup
226
- # or
227
- npx @mehmetsagir/git-ai setup
228
104
  ```
229
105
 
230
- Initial setup - OpenAI API key and git user configuration.
106
+ ### `git-ai reset`
231
107
 
232
- ### Commit
108
+ Reset all configuration (removes stored API key).
233
109
 
234
110
  ```bash
235
- git-ai commit [--user <user>]
236
- # or
237
- npx @mehmetsagir/git-ai commit [--user <user>]
111
+ git-ai reset
238
112
  ```
239
113
 
240
- Analyze git diffs and create commits. Use `--user` or `-u` to specify a different git user.
114
+ ## Configuration
241
115
 
242
- ### Add User
116
+ Configuration is stored in `~/.git-ai/config.json`:
243
117
 
244
- ```bash
245
- git-ai add
246
- # or
247
- git-ai add-user
118
+ ```json
119
+ {
120
+ "openaiKey": "sk-..."
121
+ }
248
122
  ```
249
123
 
250
- Add a new git user profile.
124
+ ## Requirements
251
125
 
252
- ### List Users
126
+ - Node.js >= 14.0.0
127
+ - Git repository
128
+ - OpenAI API key
253
129
 
254
- ```bash
255
- git-ai list
256
- # or
257
- git-ai users
258
- ```
130
+ ## Contributing
259
131
 
260
- List all configured git user profiles.
132
+ Contributions are welcome! Here's how you can help:
261
133
 
262
- ### Remove User
134
+ ### Development Setup
263
135
 
264
- ```bash
265
- git-ai remove
266
- # or
267
- git-ai delete
268
- ```
136
+ 1. **Clone the repository**
137
+ ```bash
138
+ git clone https://github.com/mehmetsagir/git-ai.git
139
+ cd git-ai
140
+ ```
269
141
 
270
- Remove a git user profile interactively.
142
+ 2. **Install dependencies**
143
+ ```bash
144
+ npm install
145
+ ```
271
146
 
272
- ### Reset
147
+ 3. **Build the project**
148
+ ```bash
149
+ npm run build
150
+ ```
273
151
 
274
- ```bash
275
- git-ai reset
276
- ```
152
+ 4. **Test locally**
153
+ ```bash
154
+ # Run directly
155
+ node bin/git-ai [command]
277
156
 
278
- Reset all configuration (deletes OpenAI key and all git users).
157
+ # Or link globally
158
+ npm link
159
+ git-ai [command]
160
+ ```
279
161
 
280
- ### Update
162
+ ### Project Structure
281
163
 
282
- ```bash
283
- git-ai --update
164
+ ```
165
+ src/
166
+ ├── index.ts # CLI entry point and command routing
167
+ ├── git.ts # Git operations (using simple-git)
168
+ ├── openai.ts # OpenAI API integration
169
+ ├── commit.ts # Commit workflow logic
170
+ ├── stash.ts # Stash viewer web UI
171
+ ├── config.ts # Configuration management
172
+ ├── setup.ts # Setup wizard
173
+ ├── reset.ts # Reset configuration
174
+ ├── prompts.ts # AI prompts for commit analysis
175
+ ├── types.ts # TypeScript type definitions
176
+ └── utils/
177
+ ├── errors.ts # Error handling utilities
178
+ └── hunk-parser.ts # Diff parsing utilities
284
179
  ```
285
180
 
286
- Check for updates and update to the latest version. The tool also automatically checks for updates in the background and will notify you if a new version is available.
287
-
288
- ## Example Scenario
289
-
290
- 1. **Run setup:**
181
+ ### Making Changes
291
182
 
183
+ 1. Create a new branch for your feature
292
184
  ```bash
293
- # If installed globally
294
- git-ai setup
295
-
296
- # Or with npx
297
- npx @mehmetsagir/git-ai setup
185
+ git checkout -b feature/your-feature-name
298
186
  ```
299
187
 
300
- - 3 user profiles detected
301
- - Shortcuts added for each user:
302
- - `work@company.com` → shortcut: `w`
303
- - `personal@gmail.com` → shortcut: `p`
304
- - `other@example.com` → shortcut: `o`
305
- - `work@company.com` selected as default
306
-
307
- 2. **For work commit (default user):**
188
+ 2. Make your changes and test them locally
308
189
 
190
+ 3. Build and verify there are no TypeScript errors
309
191
  ```bash
310
- git-ai commit
311
- # Uses work@company.com
192
+ npm run build
312
193
  ```
313
194
 
314
- 3. **For personal project (using shortcut):**
315
-
195
+ 4. Commit your changes using conventional commits format
316
196
  ```bash
317
- git-ai commit --user p
318
- # or
319
- git-ai commit -u p
320
- # Uses personal@gmail.com
197
+ git commit -m "feat: add new feature"
321
198
  ```
322
199
 
323
- 4. **For other project (using shortcut):**
200
+ 5. Push and create a pull request
324
201
  ```bash
325
- git-ai commit --user o
326
- # Uses other@example.com
202
+ git push origin feature/your-feature-name
327
203
  ```
328
204
 
329
- ## Configuration
205
+ ### Commit Message Guidelines
330
206
 
331
- Configuration file: `~/.git-ai/config.json`
207
+ We follow [Conventional Commits](https://www.conventionalcommits.org/):
332
208
 
333
- ```json
334
- {
335
- "openaiKey": "sk-...",
336
- "gitUsers": [
337
- {
338
- "id": "global-user@example.com",
339
- "name": "John Doe",
340
- "email": "user@example.com",
341
- "scope": "global",
342
- "label": "John Doe <user@example.com> (Global)",
343
- "shortcut": "g"
344
- }
345
- ],
346
- "defaultGitUser": "global-user@example.com"
347
- }
348
- ```
209
+ - `feat:` - New features
210
+ - `fix:` - Bug fixes
211
+ - `refactor:` - Code changes that neither fix bugs nor add features
212
+ - `chore:` - Maintenance tasks
213
+ - `docs:` - Documentation changes
214
+ - `style:` - Code style changes (formatting, etc.)
215
+ - `test:` - Adding or updating tests
349
216
 
350
- ## Requirements
217
+ ### Reporting Issues
351
218
 
352
- - Node.js >= 14.0.0
353
- - OpenAI API key
354
- - Git repository
355
-
356
- ## Security
357
-
358
- - Your OpenAI API key is stored locally in `~/.git-ai/config.json`
359
- - Commits are not automatically pushed
360
- - Git user information is stored locally
219
+ Found a bug or have a suggestion? [Open an issue](https://github.com/mehmetsagir/git-ai/issues) with:
361
220
 
362
- ## Troubleshooting
363
-
364
- ### "OpenAI API key not found" error
365
-
366
- ```bash
367
- # If installed globally
368
- git-ai setup
369
-
370
- # Or with npx
371
- npx @mehmetsagir/git-ai setup
372
- ```
373
-
374
- ### "This directory is not a git repository" error
375
-
376
- Make sure you're in a git repository:
377
-
378
- ```bash
379
- git init # If it doesn't exist
380
- ```
381
-
382
- ### "No changes found to commit" error
383
-
384
- Make sure you have changes:
385
-
386
- ```bash
387
- git status
388
- ```
221
+ - Clear description of the problem or suggestion
222
+ - Steps to reproduce (for bugs)
223
+ - Expected vs actual behavior
224
+ - Your environment (Node.js version, OS, etc.)
389
225
 
390
226
  ## License
391
227
 
392
228
  MIT
393
229
 
394
- ## Contributing
230
+ ## Links
395
231
 
396
- Contributions are welcome! Please open an issue or submit a pull request.
232
+ - [GitHub Repository](https://github.com/mehmetsagir/git-ai)
233
+ - [npm Package](https://www.npmjs.com/package/@mehmetsagir/git-ai)
234
+ - [Report Issues](https://github.com/mehmetsagir/git-ai/issues)
package/dist/commit.d.ts CHANGED
@@ -1,5 +1,2 @@
1
- /**
2
- * Run commit command
3
- */
4
- export declare function runCommit(userFlag?: string | null): Promise<void>;
1
+ export declare function runCommit(): Promise<void>;
5
2
  //# sourceMappingURL=commit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../src/commit.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAsB,SAAS,CAAC,QAAQ,GAAE,MAAM,GAAG,IAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA4U7E"}
1
+ {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../src/commit.ts"],"names":[],"mappings":"AAUA,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAmN/C"}