@kyubiware/commit-mint 0.2.1 → 0.3.1

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/README.md CHANGED
@@ -1,50 +1,55 @@
1
1
  # commit-mint
2
2
 
3
- > A commit tool that actually handles hook failures.
3
+ > commit-mint groups changed files into individual commits, generates commit messages, and cleanly handles commit hook failures. It wraps the entire commit lifecycle — stage, generate, review, attempt, recover, retry — so you never lose a message or stare at raw hook output again.
4
4
 
5
- > **⚠️ WORK IN PROGRESS** — This is an early-stage project. The core commit flow, hook error parsing, and recovery menu work, but AI message generation is still a placeholder (`generateMessage` always returns `"chore: initial commit"`). Expect breaking changes.
5
+ ## Quick Start
6
6
 
7
- ## The Problem
8
-
9
- When `git commit` fails due to pre-commit hooks (lint-staged, biome, eslint, tsc, vitest, jest), you get a wall of raw error output with no clear next step. Your commit message is lost. You fix the errors, try to remember or regenerate the message, and retry manually.
10
-
11
- Every existing AI commit tool has the same gap — they generate a message, call `git commit`, and if hooks fail, they just die.
12
-
13
- ## What commit-mint does differently
14
-
15
- commit-mint wraps the entire commit lifecycle — stage, generate, attempt, recover, retry — in one CLI tool:
16
-
17
- ```
18
- stage files → generate message → attempt commit → hooks fail?
19
- ├─ copy errors to clipboard
20
- ├─ skip hooks & commit
21
- └─ re-stage & retry
7
+ ```bash
8
+ npm install -g @kyubiware/commit-mint
22
9
  ```
23
10
 
24
- ## Installation
25
-
26
11
  ```bash
27
- npm install -g @kyubiware/commit-mint
12
+ cmint
28
13
  ```
29
14
 
30
15
  Requires **Node.js 18+**.
31
16
 
17
+ ```
18
+ stage files → generate message → review message → attempt commit → hooks fail?
19
+ ├─ copy errors to clipboard
20
+ ├─ skip hooks & commit
21
+ ├─ re-stage & retry
22
+ ├─ edit message
23
+ └─ cancel (cached for --retry)
24
+ ```
25
+
32
26
  ## Usage
33
27
 
34
28
  ```bash
35
- # Normal commit flow
29
+ # Normal commit flow (interactive staging if multiple files)
36
30
  cmint
37
31
 
38
- # Auto-stage all tracked files
32
+ # Auto-stage all tracked files (skip staging menu)
39
33
  cmint -a
40
34
 
41
35
  # Skip AI, provide your own message
42
36
  cmint -m "feat: add dark mode"
43
37
 
38
+ # Pass context hint to AI for better messages
39
+ cmint -H "refactoring auth module"
40
+ cmint --hint "splitting monolith into services"
41
+
44
42
  # Retry last failed commit (uses cached message)
45
43
  cmint --retry
46
44
  cmint -r
47
45
 
46
+ # Review staged changes with AI
47
+ cmint --review
48
+ cmint -R
49
+
50
+ # Debug mode — timestamped stderr output
51
+ cmint --debug
52
+
48
53
  # Configuration
49
54
  cmint config get GROQ_API_KEY
50
55
  cmint config set GROQ_API_KEY=gsk_...
@@ -55,6 +60,45 @@ cmint config set model openai/gpt-oss-20b
55
60
 
56
61
  If no `GROQ_API_KEY` is set in `~/.commit-mint` or `$GROQ_API_KEY`, you'll be prompted to enter one. It's saved to `~/.commit-mint` for future runs.
57
62
 
63
+ ### Interactive staging
64
+
65
+ When you have multiple changed files, commit-mint shows an interactive staging menu:
66
+
67
+ - **Stage all files** — auto-stage everything (same as `cmint -a`)
68
+ - **Select files** — multi-select specific files to stage
69
+ - **Auto-group into commits** — AI groups files into logical commits (see below)
70
+ - **Cancel**
71
+
72
+ If only one file has changed, it's staged automatically.
73
+
74
+ ### Auto-group
75
+
76
+ The auto-group feature uses AI to analyze your changed files and group them into logical, cohesive commits. Each group is committed separately with its own AI-generated message.
77
+
78
+ ```
79
+ 1. AI analyzes changed files → proposes groups (name, description, files)
80
+ 2. You confirm or cancel the groupings
81
+ 3. For each group: stage → generate message → review → commit
82
+ 4. Hook failures show the recovery menu per-group
83
+ ```
84
+
85
+ Select "Auto-group into commits" from the staging menu, or it's automatically available when you have multiple changed files.
86
+
87
+ ### Message review
88
+
89
+ Before every commit, you can review the generated message:
90
+
91
+ - **Use as-is** — accept the AI-generated message
92
+ - **Edit** — modify the message in a prompt
93
+ - **Review with OpenCode** — run a code review on your staged changes before committing
94
+ - **Cancel** — exit (message is cached for `--retry`)
95
+
96
+ ### Code review
97
+
98
+ Use `cmint --review` or `cmint -R` to review staged changes without committing. commit-mint checks for [OpenCode](https://github.com/opencode-ai/opencode) first — if available, it uses OpenCode for the review. Otherwise, it falls back to the Groq API.
99
+
100
+ The review looks for bugs, security issues, performance problems, code quality, and edge cases. Results are shown in a structured report, with an option to copy findings to clipboard.
101
+
58
102
  ## Recovery menu
59
103
 
60
104
  When a pre-commit hook blocks your commit, commit-mint parses the error output and presents an interactive menu:
@@ -104,9 +148,9 @@ Stored in `~/.commit-mint` (INI format):
104
148
  GROQ_API_KEY=gsk_...
105
149
  model=openai/gpt-oss-20b
106
150
  locale=en
107
- max-length=100
108
151
  type=conventional
109
152
  timeout=10000
153
+ proxy=
110
154
  ```
111
155
 
112
156
  | Key | Default | Description |
@@ -114,9 +158,9 @@ timeout=10000
114
158
  | `GROQ_API_KEY` | — | Groq API key for AI message generation |
115
159
  | `model` | `openai/gpt-oss-20b` | AI model for commit message generation |
116
160
  | `locale` | `en` | Locale for generated messages |
117
- | `max-length` | `100` | Max commit message length |
118
161
  | `type` | — | Commit type prefix (e.g. `conventional`) |
119
162
  | `timeout` | `10000` | AI request timeout (ms) |
163
+ | `proxy` | — | Proxy URL for API requests |
120
164
 
121
165
  You can also set `GROQ_API_KEY` via environment variable.
122
166
 
@@ -133,6 +177,9 @@ cmint --help
133
177
  --retry, -r Retry the last failed commit (default: false)
134
178
  --all, -a Auto-stage all tracked files (default: false)
135
179
  --message, -m Provide a commit message directly (skip AI generation)
180
+ --hint, -H Add context hint for AI commit message generation
181
+ --review, -R Review staged changes with a coding model (default: false)
182
+ --debug, -d Enable debug output (default: false)
136
183
  --help, -h Show help
137
184
  --version, -v Show version
138
185
 
@@ -152,25 +199,37 @@ commit-mint/
152
199
  │ ├── cli.ts # Entry point, argument parsing (cleye)
153
200
  │ ├── commands/
154
201
  │ │ ├── commit.ts # Main commit flow orchestrator
202
+ │ │ ├── auto-group.ts # Auto-group multi-commit flow
203
+ │ │ ├── review.ts # Code review command
155
204
  │ │ └── config.ts # Config get/set subcommand
156
205
  │ ├── services/
157
206
  │ │ ├── git.ts # Git operations (stage, commit, diff, HEAD)
207
+ │ │ ├── ai.ts # Groq AI commit message generation (3-tier diff compression)
208
+ │ │ ├── grouping.ts # AI-powered file grouping into logical commits
209
+ │ │ ├── review-ai.ts # AI code review via Groq
158
210
  │ │ ├── hooks.ts # Hook error parser (lint-staged, biome, tsc, etc.)
159
211
  │ │ ├── config.ts # INI config read/write at ~/.commit-mint
160
212
  │ │ └── clipboard.ts # Cross-platform clipboard (xclip/wl-copy/pbcopy)
161
213
  │ ├── ui/
162
- │ │ └── menu.ts # Interactive recovery TUI (@clack/prompts)
214
+ │ │ ├── menu.ts # Interactive recovery TUI + staging menu
215
+ │ │ ├── grouping.ts # Grouping confirmation UI
216
+ │ │ └── review-message.ts # Message review step (use/edit/review/cancel)
163
217
  │ └── utils/
164
- └── cache.ts # Commit message persistence at ~/.cache/commit-mint/
218
+ ├── cache.ts # Commit message persistence at ~/.cache/commit-mint/
219
+ │ └── debug.ts # Timestamped debug logging to stderr
165
220
  ```
166
221
 
167
222
  ## Key differentiators
168
223
 
169
224
  1. **Hook error parsing** — No other commit tool parses lint-staged/biome/eslint output into a clean summary
170
- 2. **Interactive recovery menu** — Copy/skip/retry as an in-flow choice, not a manual post-mortem
225
+ 2. **Interactive recovery menu** — Copy/skip/retry/edit as an in-flow choice, not a manual post-mortem
171
226
  3. **Message caching on failure** — `--retry` restores the last message without regenerating
172
227
  4. **Re-stage & retry loop** — Fix errors in another terminal, come back, hit "re-stage & retry"
173
- 5. **Clipboard integration** — Copy error report and hand it to an AI coding agent for fixes
228
+ 5. **Auto-group** — AI groups changed files into logical commits, each committed separately
229
+ 6. **In-flow code review** — Review staged changes with OpenCode or Groq before committing
230
+ 7. **Message review step** — Accept, edit, or review the AI-generated message before committing
231
+ 8. **Post-commit summary** — Shows which hook tools passed/failed after every successful commit
232
+ 9. **Clipboard integration** — Copy error report and hand it to an AI coding agent for fixes
174
233
 
175
234
  ## Requirements
176
235