-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.windsurfrules
248 lines (179 loc) · 4.9 KB
/
.windsurfrules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# `cmai` - AI Commit Message Generator
A command-line tool that automatically generates conventional commit messages using AI, based on your staged git changes.
Your commit messages will look like this:
![Example Git Commit Messages](./example-commit-message.png)
## Features
- 🤖 AI-powered commit message generation (using `google/gemini-flash-1.5-8b` - SUPER CHEAP!)
- Around $0.00001/commit -> $1 per 100K commit messages!
- 📝 Follows [Conventional Commits](https://www.conventionalcommits.org/) format
- 🔒 Secure local API key storage
- 🚀 Automatic git commit and push
- 🐛 Debug mode for troubleshooting
- 💻 Cross-platform support (Windows, Linux, macOS)
## Prerequisites
- Git installed and configured
- For Windows: Git Bash or WSL installed
- For Linux/macOS: Bash shell environment
- An [OpenRouter](https://openrouter.ai/) API key
- `curl` installed
## Installation
### Linux/macOS
1. Clone this repository:
```bash
git clone https://github.com/mrgoonie/cmai.git
cd cmai
```
2. Run the installation script:
```bash
./install.sh
```
This will:
- Create necessary directories
- Install the script globally as `cmai`
- Set up proper permissions
### Windows
1. Clone this repository:
```bash
git clone https://github.com/mrgoonie/cmai.git
cd cmai
```
2. Run the installation script in Git Bash:
```bash
./install.sh
```
Or manually:
- Copy `git-commit.sh` to `%USERPROFILE%\git-commit-ai\`
- Add the directory to your PATH environment variable
- Rename `git-commit.sh` to `cmai.sh`
This will:
- Create necessary directories
- Install the script globally as `cmai`
- Set up proper permissions
## Configuration
Set up your OpenRouter API key:
```bash
cmai <your_openrouter_api_key>
```
The API key will be securely stored in:
- Linux/macOS: `~/.config/git-commit-ai/config`
- Windows: `%USERPROFILE%\.config\git-commit-ai\config`
## Usage
![Usage Demonstration](./usage.png)
1. Make your code changes
2. Generate commit message and commit changes:
```bash
cmai
```
To also push changes to remote:
```bash
cmai --push
# or
cmai -p
```
To use a different AI model:
```bash
cmai --model qwen/qwen-2.5-coder-32b-instruct
```
List of available models: https://openrouter.ai/models
This will:
- Stage all changes
- Generate a commit message using AI
- Commit the changes
- Push to the remote repository (if --push flag is used)
### Debug Mode
To see detailed information about what's happening:
```bash
cmai --debug
```
You can combine flags:
```bash
cmai --debug --push
```
## Examples
```bash
# First time setup with API key
cmai your_openrouter_api_key
# Normal usage
cmai
# Commit and push
cmai --push
# Debug mode
cmai --debug
# Debug mode with push
cmai --debug --push
# Use a different AI model
cmai --model qwen/qwen-2.5-coder-32b-instruct
# Combine multiple flags
cmai --debug --push --model qwen/qwen-2.5-coder-32b-instruct
```
Example generated commit messages:
- `feat(api): add user authentication system`
- `fix(data): resolve memory leak in data processing`
- `docs(api): update API documentation`
- `style(ui): improve responsive layout for mobile devices`
## Directory Structure
### Linux/macOS
```
~
├── git-commit-ai/
│ └── git-commit.sh
├── .config/
│ └── git-commit-ai/
│ └── config
└── usr/
└── local/
└── bin/
└── cmai -> ~/git-commit-ai/git-commit.sh
```
### Windows
```
%USERPROFILE%
├── git-commit-ai/
│ └── cmai.sh
└── .config/
└── git-commit-ai/
└── config
```
## Security
- API key is stored locally with restricted permissions (600)
- Configuration directory is protected (700)
- No data is stored or logged except the API key
- All communication is done via HTTPS
## Troubleshooting
1. **No API key found**
- Run `cmai your_openrouter_api_key` to configure
2. **Permission denied**
- Check file permissions: `ls -la ~/.config/git-commit-ai`
- Should show: `drwx------` for directory and `-rw-------` for config file
3. **Debug mode**
- Run with `--debug` flag to see detailed logs
- Check API responses and git operations
4. **Windows-specific issues**
- Make sure Git Bash is installed
- Check if curl is available in Git Bash
- Verify PATH environment variable includes the installation directory
## Uninstallation
### Linux/macOS
```bash
bash
sudo rm /usr/local/bin/cmai
rm -rf ~/git-commit-ai
rm -rf ~/.config/git-commit-ai
```
### Windows
```bash
rm -rf "$USERPROFILE/git-commit-ai"
rm -rf "$USERPROFILE/.config/git-commit-ai"
```
Then remove the directory from your PATH environment variable
## Contributing
1. Fork the repository
2. Create your feature branch
3. Commit your changes (using `cmai` 😉)
4. Push to the branch
5. Create a Pull Request
## License
MIT License - see LICENSE file for details
## Acknowledgments
- [OpenRouter](https://openrouter.ai/) for providing the AI API
- [Conventional Commits](https://www.conventionalcommits.org/) for the commit message format