@misaelabanto/commita 0.1.2

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.
@@ -0,0 +1,10 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(bun build:*)",
5
+ "Bash(./commita:*)",
6
+ "Bash(/Users/misaelabanto/Code/personal/commita/commita set:*)",
7
+ "Skill(commita)"
8
+ ]
9
+ }
10
+ }
@@ -0,0 +1,22 @@
1
+ # Provider: openai or gemini (default: openai)
2
+ PROVIDER=openai
3
+
4
+ # Model name (provider-specific)
5
+ # OpenAI examples: gpt-4o-mini, gpt-4o, gpt-4-turbo
6
+ # Gemini examples: gemini-2.5-flash, gemini-2.5-pro, gemini-1.5-pro
7
+ MODEL=gpt-4o-mini
8
+
9
+ # Prompt style: default, detailed, minimal, or custom
10
+ PROMPT_STYLE=default
11
+
12
+ # Commit style: conventional or emoji
13
+ COMMIT_STYLE=conventional
14
+
15
+ # API Keys (set the one for your chosen provider)
16
+ # For OpenAI:
17
+ OPENAI_API_KEY=your-openai-api-key-here
18
+
19
+ # For Gemini:
20
+ # GEMINI_API_KEY=your-gemini-api-key-here
21
+ # Or use GOOGLE_GENERATIVE_AI_API_KEY environment variable
22
+
@@ -0,0 +1,111 @@
1
+ ---
2
+ description: Use Bun instead of Node.js, npm, pnpm, or vite.
3
+ globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ Default to using Bun instead of Node.js.
8
+
9
+ - Use `bun <file>` instead of `node <file>` or `ts-node <file>`
10
+ - Use `bun test` instead of `jest` or `vitest`
11
+ - Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
12
+ - Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
13
+ - Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
14
+ - Bun automatically loads .env, so don't use dotenv.
15
+
16
+ ## APIs
17
+
18
+ - `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
19
+ - `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
20
+ - `Bun.redis` for Redis. Don't use `ioredis`.
21
+ - `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
22
+ - `WebSocket` is built-in. Don't use `ws`.
23
+ - Prefer `Bun.file` over `node:fs`'s readFile/writeFile
24
+ - Bun.$`ls` instead of execa.
25
+
26
+ ## Testing
27
+
28
+ Use `bun test` to run tests.
29
+
30
+ ```ts#index.test.ts
31
+ import { test, expect } from "bun:test";
32
+
33
+ test("hello world", () => {
34
+ expect(1).toBe(1);
35
+ });
36
+ ```
37
+
38
+ ## Frontend
39
+
40
+ Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.
41
+
42
+ Server:
43
+
44
+ ```ts#index.ts
45
+ import index from "./index.html"
46
+
47
+ Bun.serve({
48
+ routes: {
49
+ "/": index,
50
+ "/api/users/:id": {
51
+ GET: (req) => {
52
+ return new Response(JSON.stringify({ id: req.params.id }));
53
+ },
54
+ },
55
+ },
56
+ // optional websocket support
57
+ websocket: {
58
+ open: (ws) => {
59
+ ws.send("Hello, world!");
60
+ },
61
+ message: (ws, message) => {
62
+ ws.send(message);
63
+ },
64
+ close: (ws) => {
65
+ // handle close
66
+ }
67
+ },
68
+ development: {
69
+ hmr: true,
70
+ console: true,
71
+ }
72
+ })
73
+ ```
74
+
75
+ HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.
76
+
77
+ ```html#index.html
78
+ <html>
79
+ <body>
80
+ <h1>Hello, world!</h1>
81
+ <script type="module" src="./frontend.tsx"></script>
82
+ </body>
83
+ </html>
84
+ ```
85
+
86
+ With the following `frontend.tsx`:
87
+
88
+ ```tsx#frontend.tsx
89
+ import React from "react";
90
+
91
+ // import .css files directly and it works
92
+ import './index.css';
93
+
94
+ import { createRoot } from "react-dom/client";
95
+
96
+ const root = createRoot(document.body);
97
+
98
+ export default function Frontend() {
99
+ return <h1>Hello, world!</h1>;
100
+ }
101
+
102
+ root.render(<Frontend />);
103
+ ```
104
+
105
+ Then, run index.ts
106
+
107
+ ```sh
108
+ bun --hot ./index.ts
109
+ ```
110
+
111
+ For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
@@ -0,0 +1,103 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ build:
11
+ name: Build ${{ matrix.output }}
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ include:
16
+ - target: bun-darwin-x64
17
+ output: commita-darwin-amd64
18
+ - target: bun-darwin-arm64
19
+ output: commita-darwin-arm64
20
+ - target: bun-linux-x64
21
+ output: commita-linux-amd64
22
+ - target: bun-linux-arm64
23
+ output: commita-linux-arm64
24
+ - target: bun-windows-x64
25
+ output: commita-windows-amd64.exe
26
+
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+
30
+ - uses: oven-sh/setup-bun@v2
31
+
32
+ - run: bun install
33
+
34
+ - name: Build
35
+ run: bun build index.ts --compile --target=${{ matrix.target }} --outfile ${{ matrix.output }}
36
+
37
+ - uses: actions/upload-artifact@v4
38
+ with:
39
+ name: ${{ matrix.output }}
40
+ path: ${{ matrix.output }}
41
+ if-no-files-found: error
42
+
43
+ version:
44
+ name: Create version tag
45
+ needs: build
46
+ if: github.ref == 'refs/heads/main'
47
+ runs-on: ubuntu-latest
48
+ permissions:
49
+ contents: write
50
+ outputs:
51
+ new_tag: ${{ steps.tag.outputs.new_tag }}
52
+ steps:
53
+ - uses: actions/checkout@v4
54
+ with:
55
+ fetch-depth: 0
56
+
57
+ - id: tag
58
+ uses: mathieudutour/github-tag-action@v6.2
59
+ with:
60
+ github_token: ${{ secrets.GITHUB_TOKEN }}
61
+ tag_prefix: v
62
+ default_bump: patch
63
+ release_branches: main
64
+
65
+ - name: Bump package.json version
66
+ if: steps.tag.outputs.new_tag != ''
67
+ run: |
68
+ VERSION="${{ steps.tag.outputs.new_tag }}"
69
+ VERSION="${VERSION#v}"
70
+ jq --arg version "$VERSION" '.version = $version' package.json > package.tmp.json
71
+ mv package.tmp.json package.json
72
+
73
+ - name: Commit version bump
74
+ if: steps.tag.outputs.new_tag != ''
75
+ run: |
76
+ git config user.name "github-actions[bot]"
77
+ git config user.email "github-actions[bot]@users.noreply.github.com"
78
+ git add package.json
79
+ git commit -m "chore: bump version to ${{ steps.tag.outputs.new_tag }} [skip ci]"
80
+ git push origin main
81
+
82
+ release:
83
+ name: Release
84
+ needs: [build, version]
85
+ if: github.ref == 'refs/heads/main' && needs.version.outputs.new_tag != ''
86
+ runs-on: ubuntu-latest
87
+ permissions:
88
+ contents: write
89
+ steps:
90
+ - uses: actions/download-artifact@v4
91
+ with:
92
+ merge-multiple: true
93
+
94
+ - uses: softprops/action-gh-release@v2
95
+ with:
96
+ tag_name: ${{ needs.version.outputs.new_tag }}
97
+ generate_release_notes: true
98
+ files: |
99
+ commita-darwin-amd64
100
+ commita-darwin-arm64
101
+ commita-linux-amd64
102
+ commita-linux-arm64
103
+ commita-windows-amd64.exe
package/README.md ADDED
@@ -0,0 +1,388 @@
1
+ # Commita 🤖
2
+
3
+ AI-powered git auto-commit tool that intelligently groups your changes and generates meaningful commit messages.
4
+
5
+ ## Features
6
+
7
+ - **AI-Generated Commit Messages**: Uses OpenAI or Google Gemini to analyze diffs and create descriptive commit messages
8
+ - **Multiple AI Providers**: Support for both OpenAI and Google Gemini via the Vercel AI SDK
9
+ - **Intelligent File Grouping**: Automatically groups files by their directory structure for organized commits
10
+ - **Configurable**: Customize prompts, models, and commit styles
11
+ - **Multiple Commit Styles**: Support for conventional commits and emoji commits
12
+ - **Bulk Operations**: Process all changes at once with the `--all` flag
13
+ - **Pattern Filtering**: Exclude files using glob patterns with `--ignore`
14
+ - **Auto-Push**: Automatically pushes commits to remote (can be disabled)
15
+
16
+ ## Requirements
17
+
18
+ - An API key from one of the supported AI providers:
19
+ - **OpenAI** — get one at [platform.openai.com/api-keys](https://platform.openai.com/api-keys)
20
+ - **Google Gemini** — get one at [aistudio.google.com/api-keys](https://aistudio.google.com/api-keys)
21
+
22
+ ## Installation
23
+
24
+ ### Option 1 — bun (requires [Bun](https://bun.sh) ≥ 1.0)
25
+
26
+ ```bash
27
+ bun install -g @miselabanto/commita
28
+ ```
29
+
30
+ ### Option 2 — Shell script (no runtime required)
31
+
32
+ Downloads the correct pre-compiled binary for your OS and architecture directly from [GitHub Releases](https://github.com/misaelabanto/commita/releases):
33
+
34
+ ```bash
35
+ curl -fsSL https://raw.githubusercontent.com/misaelabanto/commita/main/install.sh | bash
36
+ ```
37
+
38
+ Supported platforms:
39
+
40
+ | OS | x86_64 | arm64 |
41
+ |---------|-------------------------|-------|
42
+ | macOS | ✅ | ✅ |
43
+ | Linux | ✅ | ✅ |
44
+ | Windows | ✅ (manual download) ¹ | ❌ |
45
+
46
+ > ¹ Windows users: download `commita-windows-amd64.exe` manually from the [Releases page](https://github.com/misaelabanto/commita/releases) and add it to your `PATH`.
47
+
48
+ ### Local Development
49
+
50
+ ```bash
51
+ git clone https://github.com/misaelabanto/commita.git
52
+ cd commita
53
+ bun install
54
+ ```
55
+
56
+ ## Quick Start
57
+
58
+ 1. Set your API key and provider:
59
+ ```bash
60
+ commita set OPENAI_API_KEY=sk-...
61
+ # or for Gemini:
62
+ commita set GEMINI_API_KEY=your-key
63
+ commita set PROVIDER=gemini
64
+ ```
65
+
66
+ 2. Navigate to your project and run:
67
+ ```bash
68
+ commita --all
69
+ ```
70
+
71
+ ## Configuration
72
+
73
+ ### `commita set` (recommended)
74
+
75
+ Set config values from the command line. By default values are saved globally to `~/.commita`. Use `--local` to save them to `.commita` in the current project instead.
76
+
77
+ ```bash
78
+ # Set values directly
79
+ commita set PROVIDER=openai
80
+ commita set MODEL=gpt-4o-mini
81
+
82
+ # Omit the value to be prompted securely (input is hidden for API keys)
83
+ commita set OPENAI_API_KEY
84
+ commita set GEMINI_API_KEY
85
+
86
+ # Save to the current project only
87
+ commita set PROVIDER=gemini --local
88
+ ```
89
+
90
+ ### `.commita` file (manual)
91
+
92
+ You can also create or edit a `.commita` file directly. Project-level (`./.commita`) takes precedence over global (`~/.commita`).
93
+
94
+ ```
95
+ PROVIDER=openai
96
+ MODEL=gpt-4o-mini
97
+ PROMPT_STYLE=default
98
+ COMMIT_STYLE=conventional
99
+ OPENAI_API_KEY=sk-...
100
+ ```
101
+
102
+ Or for Gemini:
103
+ ```
104
+ PROVIDER=gemini
105
+ MODEL=gemini-2.5-flash
106
+ PROMPT_STYLE=default
107
+ COMMIT_STYLE=conventional
108
+ GEMINI_API_KEY=your-gemini-api-key
109
+ ```
110
+
111
+ ### Environment Variables
112
+
113
+ ```bash
114
+ export COMMITA_PROVIDER=openai
115
+ export COMMITA_MODEL=gpt-4o-mini
116
+ export COMMITA_PROMPT_STYLE=default
117
+ export COMMITA_COMMIT_STYLE=emoji
118
+ export OPENAI_API_KEY=sk-...
119
+ ```
120
+
121
+ Or for Gemini:
122
+ ```bash
123
+ export COMMITA_PROVIDER=gemini
124
+ export COMMITA_MODEL=gemini-2.5-flash
125
+ export GEMINI_API_KEY=your-gemini-api-key
126
+ ```
127
+
128
+ ### Configuration Options
129
+
130
+ - **PROVIDER**: AI provider to use - `openai` or `gemini` (default: `openai`)
131
+ - **MODEL**: Model name to use (provider-specific)
132
+ - **OpenAI**: `gpt-4o-mini`, `gpt-4o`, `gpt-4-turbo`, etc.
133
+ - **Gemini**: `gemini-2.5-flash`, `gemini-2.5-pro`, `gemini-1.5-pro`, etc.
134
+ - **PROMPT_STYLE**: One of `default`, `detailed`, `minimal`, or `custom`
135
+ - **PROMPT_TEMPLATE**: Custom prompt template (when using custom style)
136
+ - **CUSTOM_PROMPT**: Complete custom prompt (when using custom style)
137
+ - **COMMIT_STYLE**: Either `conventional` or `emoji`
138
+ - **OPENAI_API_KEY**: Your OpenAI API key (required when `PROVIDER=openai`)
139
+ - **GEMINI_API_KEY**: Your Gemini API key (required when `PROVIDER=gemini`)
140
+
141
+ **Note**: You can also use `GOOGLE_GENERATIVE_AI_API_KEY` environment variable instead of `GEMINI_API_KEY`.
142
+
143
+ ### Prompt Styles
144
+
145
+ - **default**: Balanced analysis with clear instructions
146
+ - **detailed**: Deep analysis of code changes with context
147
+ - **minimal**: Quick, concise commit messages
148
+ - **custom**: Use your own prompt via `PROMPT_TEMPLATE` or `CUSTOM_PROMPT`
149
+
150
+ #### Using Custom Prompts
151
+
152
+ You can create your own prompt template using the `{diff}` placeholder:
153
+
154
+ ```
155
+ PROMPT_STYLE=custom
156
+ CUSTOM_PROMPT=Analyze this diff and create a commit message: {diff}
157
+ ```
158
+
159
+ Or use PROMPT_TEMPLATE for longer prompts:
160
+ ```
161
+ PROMPT_STYLE=custom
162
+ PROMPT_TEMPLATE=You are an expert developer. Analyze the following changes and generate a clear commit message in conventional commit format. The diff is: {diff}
163
+ ```
164
+
165
+ ### Commit Styles
166
+
167
+ **Conventional Commits:**
168
+ ```
169
+ feat(components): add new button component
170
+ fix(utils): correct string formatting bug
171
+ refactor(services): restructure API client
172
+ ```
173
+
174
+ **Emoji Commits:**
175
+ ```
176
+ ✨(components): add new button component
177
+ 🐛(utils): correct string formatting bug
178
+ ♻️(services): restructure API client
179
+ ```
180
+
181
+ Emoji mappings:
182
+ - feat → ✨
183
+ - fix → 🐛
184
+ - refactor → ♻️
185
+ - chore → 🔧
186
+ - docs → 📝
187
+ - style → 💄
188
+ - test → ✅
189
+ - perf → ⚡
190
+
191
+ ## Usage
192
+
193
+ **Important**: You must either have staged changes OR use the `--all` flag. The tool requires one of these to proceed.
194
+
195
+ ### Basic Usage (with staged changes)
196
+
197
+ ```bash
198
+ git add <files>
199
+ bun run index.ts
200
+ ```
201
+
202
+ ### Process All Changes
203
+
204
+ Group all unstaged changes by folder and create multiple commits:
205
+
206
+ ```bash
207
+ bun run index.ts --all
208
+ ```
209
+
210
+ ### Ignore Patterns
211
+
212
+ Exclude files matching patterns:
213
+
214
+ ```bash
215
+ bun run index.ts --all --ignore "*.log,node_modules/*,dist/*"
216
+ ```
217
+
218
+ ### Skip Pushing
219
+
220
+ Don't push commits to remote:
221
+
222
+ ```bash
223
+ bun run index.ts --all --no-push
224
+ ```
225
+
226
+ ### Custom Config File
227
+
228
+ Use a different config file:
229
+
230
+ ```bash
231
+ bun run index.ts --config .commita.local
232
+ ```
233
+
234
+ ## How It Works
235
+
236
+ ### Flow Example
237
+
238
+ Given these changes:
239
+ ```
240
+ src/components/button.tsx
241
+ src/components/carousel.tsx
242
+ src/utils/url.ts
243
+ src/utils/strings.ts
244
+ src/services/ai/ai.ts
245
+ src/services/profile/profile.ts
246
+ ```
247
+
248
+ Running `commita --all` will create commits like:
249
+
250
+ ```
251
+ feat(components): add new UI components
252
+ - Implement Button component with variants
253
+ - Add Carousel with auto-play feature
254
+
255
+ feat(utils): enhance utility functions
256
+ - Add URL parsing helper
257
+ - Improve string manipulation utilities
258
+
259
+ fix(ai): correct API integration
260
+ - Fix authentication flow
261
+ - Handle rate limiting
262
+
263
+ refactor(profile): restructure profile service
264
+ - Separate types into dedicated file
265
+ - Improve error handling
266
+ ```
267
+
268
+ ### Staged Changes Behavior
269
+
270
+ **Requirements**: You must provide either:
271
+ - Staged changes (via `git add`), OR
272
+ - The `--all` flag
273
+
274
+ **Behavior**:
275
+ - If you have **staged changes** and run without `--all`: processes staged files, grouped by folders, and creates multiple commits
276
+ - If you have **staged changes** and run with `--all`: ignores staged files and processes all unstaged changes grouped by folders
277
+ - If you have **no staged changes** and run without `--all`: exits with error
278
+ - **Note**: Commita temporarily unstages the files you selected so it can create one commit per folder, then restages and commits each group for you.
279
+ - Use this to control exactly which files get committed together
280
+
281
+ ## Advanced Usage Examples
282
+
283
+ ### Scenario 1: Multiple Feature Commits
284
+
285
+ You've been working on several features and want to commit them separately:
286
+
287
+ ```bash
288
+ bun run index.ts --all
289
+ ```
290
+
291
+ This will group files by their directories and create separate commits for each group.
292
+
293
+ ### Scenario 2: Exclude Generated Files
294
+
295
+ Ignore build artifacts and logs:
296
+
297
+ ```bash
298
+ bun run index.ts --all --ignore "dist/*,*.log,coverage/*"
299
+ ```
300
+
301
+ ### Scenario 3: Local Commits Only
302
+
303
+ Commit without pushing to remote:
304
+
305
+ ```bash
306
+ bun run index.ts --all --no-push
307
+ ```
308
+
309
+ ### Scenario 4: Using Emoji Style
310
+
311
+ Set in your `.commita`:
312
+ ```
313
+ COMMIT_STYLE=emoji
314
+ ```
315
+
316
+ Then run:
317
+ ```bash
318
+ bun run index.ts --all
319
+ ```
320
+
321
+ ## Troubleshooting
322
+
323
+ ### "OpenAI API key is required" or "Gemini API key is required"
324
+
325
+ Make sure you have set your API key for the selected provider:
326
+
327
+ **For OpenAI:**
328
+ - `.commita` file: `OPENAI_API_KEY=sk-...`
329
+ - Environment variable: `export OPENAI_API_KEY=sk-...`
330
+
331
+ **For Gemini:**
332
+ - `.commita` file: `GEMINI_API_KEY=your-key`
333
+ - Environment variable: `export GEMINI_API_KEY=your-key`
334
+ - Or use: `export GOOGLE_GENERATIVE_AI_API_KEY=your-key`
335
+
336
+ ### "No staged changes found"
337
+
338
+ This error occurs when you run the tool without the `--all` flag and have no staged changes. Either:
339
+ - Stage some changes: `git add <files>`
340
+ - Use the `--all` flag: `bun run index.ts --all`
341
+
342
+ ### Provider Selection
343
+
344
+ Make sure you've selected the correct provider and set the corresponding API key:
345
+ - Set `PROVIDER=openai` and provide `OPENAI_API_KEY`
346
+ - Set `PROVIDER=gemini` and provide `GEMINI_API_KEY` (or `GOOGLE_GENERATIVE_AI_API_KEY`)
347
+
348
+ ### Permission Denied
349
+
350
+ Make sure the script is executable:
351
+ ```bash
352
+ chmod +x index.ts
353
+ ```
354
+
355
+ ### Import Errors
356
+
357
+ The project uses Bun's built-in support for `@/` path aliases. Make sure you're running with Bun, not Node.js:
358
+ ```bash
359
+ bun run index.ts # ✓ Correct
360
+ node index.ts # ✗ Won't work
361
+ ```
362
+
363
+ ## Development
364
+
365
+ ```bash
366
+ bun install
367
+ bun run dev
368
+ ```
369
+
370
+ ### Running Tests
371
+
372
+ ```bash
373
+ bun test
374
+ ```
375
+
376
+ ### Build to Binary
377
+
378
+ ```bash
379
+ bun build index.ts --compile --outfile commita
380
+ ```
381
+
382
+ ## Contributing
383
+
384
+ Contributions are welcome! Please feel free to submit a Pull Request.
385
+
386
+ ## License
387
+
388
+ MIT
package/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bun
2
+
3
+ import { runCLI } from '@/cli/index.ts';
4
+ import 'dotenv/config';
5
+
6
+ await runCLI();
7
+