@kyubiware/commit-mint 0.5.5 → 0.5.6

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,11 +1,13 @@
1
- # commit-mint
1
+ # 🌿 commit-mint
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/@kyubiware/commit-mint.svg)](https://www.npmjs.com/package/@kyubiware/commit-mint)
4
4
  [![Build Status](https://img.shields.io/github/actions/workflow/status/kyubiware/commit-mint/ci.yml?style=flat-square)](https://github.com/kyubiware/commit-mint/actions)
5
5
  ![Node.js](https://img.shields.io/badge/Node.js->=18-3c873a?style=flat-square)
6
6
  [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](LICENSE)
7
7
 
8
- > Auto-group your changes into clean, conventional commits. AI handles the grouping, messages, and hook failures so you don't have to.
8
+ **AI commit messages that actually handle what goes wrong.**
9
+
10
+ commit-mint generates conventional commit messages from your diff — and when hooks fail, it parses the errors and gives you a recovery menu instead of dumping raw stderr. It auto-groups unrelated changes into separate commits, runs your checks before generating messages, and caches failed attempts for instant retries.
9
11
 
10
12
  ```
11
13
  ┌ commit-mint
@@ -20,7 +22,7 @@
20
22
 
21
23
  ◇ Committed successfully.
22
24
 
23
- ● ✓ prettier
25
+ ● ✓ biome
24
26
  │ ✓ eslint
25
27
  │ ✓ tsc
26
28
  │ ✓ vitest
@@ -35,65 +37,63 @@
35
37
  └ All groups committed.
36
38
  ```
37
39
 
38
- ## Quick start
40
+ ## Why commit-mint
39
41
 
40
- ```bash
41
- npm install -g @kyubiware/commit-mint
42
- cmint -a
43
- ```
44
-
45
- On first run, you'll be prompted for an API key if one isn't set. It's saved for future runs.
42
+ Most AI commit tools generate a message and hope for the best. commit-mint handles the full loop:
46
43
 
47
- ## Features
44
+ - **Auto-groups files by intent** — 10 changed files across 3 concerns? Three separate commits, each with its own message. No competitor does this.
45
+ - **Hook failures get a recovery menu** — Parsed errors from biome, tsc, vitest, eslint, and lint-staged. Copy, skip, restage, edit, or cancel. No raw stderr dumps.
46
+ - **Pre-flight checks before AI generation** — `.cmintrc` runs your checks after staging but before the API call, so a failing check never wastes tokens.
47
+ - **Works without OpenAI** — Groq, Cerebras, and Mistral out of the box. No OpenAI key required.
48
+ - **Cached retries** — Failed commit? Fix the error and `cmint --retry` picks up the same message.
48
49
 
49
- - **Auto-group by intent** — AI reads your diff and groups files into logical commits. No more `feat: update stuff` that bundles unrelated changes.
50
- - **Zero-prompt auto mode** — `cmint -a` stages, groups, generates messages, and commits without a single prompt.
51
- - **Hook failures handled in-flow** — Parsed error summary with a recovery menu to copy, skip, retry, or edit. No raw stderr dumps.
52
- - **Multi-provider AI** — Works with Groq, Cerebras, and Mistral out of the box. Per-provider model configuration supported.
53
- - **Built-in pre-commit checks** — Define checks in a cmint config file and run them before AI generation. A failing check never wastes an API call.
54
- - **Message caching on failure** — A failed commit caches its message. Fix the error, run `cmint --retry`, and pick up where you left off.
55
-
56
- ## Usage
50
+ ## Install
57
51
 
58
52
  ```bash
59
- # Auto-group and commit everything (no prompts)
60
- cmint -a
53
+ npm install -g @kyubiware/commit-mint
54
+ ```
61
55
 
62
- # Normal interactive flow
63
- cmint
56
+ Or try it without installing:
64
57
 
65
- # Skip AI, provide your own message
66
- cmint -m "feat: add dark mode"
58
+ ```bash
59
+ npx @kyubiware/commit-mint
60
+ ```
67
61
 
68
- # Pass context hint for better messages
69
- cmint -H "refactoring auth module"
62
+ ## Quick start
70
63
 
71
- # Retry last failed commit (uses cached message)
72
- cmint -r
64
+ ```bash
65
+ cmint config # set provider + API key (interactive wizard)
66
+ cmint -a # auto-group, generate messages, commit everything
67
+ ```
73
68
 
74
- # Skip pre-commit checks
75
- cmint -N
69
+ On first run you'll be prompted for an API key if one isn't configured. It's saved for future runs.
76
70
 
77
- # Debug mode
78
- cmint -d
71
+ ## Usage
79
72
 
80
- # Configuration
81
- cmint config get GROQ_API_KEY
82
- cmint config set GROQ_API_KEY=gsk_...
83
- cmint config set provider cerebras
84
- cmint config set model openai/gpt-oss-20b
73
+ ```bash
74
+ cmint -a # auto-group and commit everything
75
+ cmint # interactive flow (staging → checks → review → commit)
76
+ cmint -m "feat: ..." # skip AI, use your own message
77
+ cmint -H "context" # pass a hint for better AI messages
78
+ cmint -r # retry last failed commit (cached message)
79
+ cmint -N # skip pre-flight checks
80
+ cmint -d # debug mode (timestamped stderr)
81
+ cmint config # interactive configuration wizard
85
82
  ```
86
83
 
87
- | Flag | Description |
88
- |------|-------------|
89
- | `-a, --auto` | Auto-group files into commits, accept all messages |
90
- | `-m, --message` | Provide a commit message directly (skip AI) |
91
- | `-H, --hint` | Add context hint for AI message generation |
92
- | `-r, --retry` | Retry the last failed commit |
93
- | `-N, --noCheck` | Skip pre-commit checks |
94
- | `-d, --debug` | Enable debug output |
95
- | `-h, --help` | Show help |
96
- | `-v, --version` | Show version |
84
+ ## Comparison
85
+
86
+ | | commit-mint | aicommits | opencommit | cz-git | commitizen |
87
+ |---|:---:|:---:|:---:|:---:|:---:|
88
+ | **Auto-group files into commits** | | | | | — |
89
+ | **Hook failure recovery menu** | | | | — | — |
90
+ | **Pre-commit checks in-flow** | | | — | — | — |
91
+ | **AI message generation** | | | ✅ | ✅ | — |
92
+ | **No OpenAI required** | ✅ Groq, Cerebras, Mistral | Together, Ollama | — default OpenAI | — OpenAI only | n/a |
93
+ | **Message review before commit** | | | ✅ | ✅ interactive | ✅ interactive |
94
+ | **Zero-prompt auto mode** | ✅ | ✅ | ✅ | — | — |
95
+ | **Conventional commits** | ✅ | ✅ | ✅ | ✅ | ✅ |
96
+ | **Retry cached message** | ✅ | — | — | ✅ | — |
97
97
 
98
98
  ## Modes
99
99
 
@@ -101,41 +101,26 @@ cmint config set model openai/gpt-oss-20b
101
101
 
102
102
  `cmint -a` runs the full pipeline with no prompts:
103
103
 
104
- 1. AI analyzes all changed files
105
- 2. Files are grouped into logical commits by intent
106
- 3. Each group gets its own AI-generated conventional commit message
107
- 4. Groups are committed sequentially
108
- 5. Hook failures per group trigger the recovery menu
104
+ 1. Excluded files (lockfiles, generated) are committed upfront.
105
+ 2. `.cmintrc` checks run before AI grouping.
106
+ 3. AI groups files into logical commits by intent.
107
+ 4. Each group gets a generated conventional commit message.
108
+ 5. Groups are committed sequentially. Hook failures pause the sequence with a recovery menu.
109
109
 
110
110
  ### Manual mode
111
111
 
112
112
  Run `cmint` without flags for the interactive flow:
113
113
 
114
- 1. **Staging menu** — stage all, select files, auto-group, or run checks
115
- 2. **File selection** — multi-select specific files if you don't want everything
116
- 3. **Message review** — review the AI-generated message before committing
117
- 4. **Commit attempt** — hooks run, recovery menu appears on failure
118
-
119
- If only one file changed, it's staged automatically.
120
-
121
- ## Providers
122
-
123
- commit-mint supports multiple AI providers with per-provider configuration:
124
-
125
- | Provider | Env key | Default model |
126
- |----------|---------|---------------|
127
- | **Groq** | `GROQ_API_KEY` | `openai/gpt-oss-20b` |
128
- | **Cerebras** | `CEREBRAS_API_KEY` | `gpt-oss-120b` |
129
- | **Mistral** | `MISTRAL_API_KEY` | `mistral-small` |
130
-
131
- Switch providers with `cmint config set provider <name>`. Override the model per-provider with `cmint config set model_cerebras <model>`.
114
+ 1. **Staging menu** — stage all, select files, auto-group, or run checks.
115
+ 2. **Pre-flight checks** — `.cmintrc` checks run automatically (skip with `-N`).
116
+ 3. **Message review** — review the AI message before committing.
117
+ 4. **Commit** — hooks run, recovery menu on failure.
132
118
 
133
- > [!TIP]
134
- > All providers use OpenAI-compatible APIs. Groq uses the official SDK; Cerebras and Mistral use a built-in fetch client.
119
+ Single-file changes are staged automatically.
135
120
 
136
121
  ## Recovery menu
137
122
 
138
- When a pre-commit hook blocks your commit, commit-mint parses the error output and presents an interactive menu:
123
+ When a pre-commit hook blocks your commit, commit-mint parses the error and presents an interactive menu:
139
124
 
140
125
  ```
141
126
  ╭─────────────────────────────────────────────────╮
@@ -155,116 +140,62 @@ When a pre-commit hook blocks your commit, commit-mint parses the error output a
155
140
  ╰─────────────────────────────────────────────────╯
156
141
  ```
157
142
 
158
- | Option | What it does |
159
- |--------|-------------|
160
- | **Copy error report** | Copies parsed, clean error output to clipboard |
161
- | **View full output** | Shows raw stderr from the failed hook |
162
- | **Skip hooks** | Re-runs `git commit --no-verify` with the same message |
163
- | **Re-stage & retry** | Runs `git add -A` again, then retries the commit |
164
- | **Edit message** | Opens a prompt to modify the commit message, then retries |
165
- | **Cancel** | Exits. Commit message is cached for `cmint --retry` |
166
-
167
- Errors are parsed from **lint-staged**, **biome**, **TypeScript** (`tsc`), **vitest**/**jest**, and **ESLint**. Unrecognized output falls back to raw stderr.
143
+ Errors are parsed from **lint-staged**, **biome**, **tsc**, **vitest**/**jest**, and **eslint**. Unrecognized output falls back to raw stderr.
168
144
 
169
- ## Pre-commit checks
145
+ ## Pre-flight checks
170
146
 
171
- Define custom checks in a cmint config file at your project root. Supported file names (checked in priority order):
172
-
173
- `.cmintrc`, `.cmintrc.json`, `.cmintrc.{mjs,mts,js,ts,cjs,cts}`, `cmint.config.{mjs,mts,js,ts,cjs,cts}`
174
-
175
- Checks run after staging, before AI message generation, so a failing check never wastes an API call.
147
+ `.cmintrc` is commit-mint's in-flow replacement for lint-staged. Define checks once at your project root and commit-mint runs them after staging but before AI generation — so failing checks never waste an API call.
176
148
 
177
149
  ```js
150
+ // .cmintrc.ts
178
151
  export default {
179
- // String: matched files are appended as arguments
180
152
  "*.{js,ts,json}": "biome check --write --no-errors-on-unmatched",
181
-
182
- // Function: receive matched filenames, return command(s)
183
153
  "*.ts": () => ["tsc --noEmit", "vitest run --passWithNoTests"],
184
154
  };
185
155
  ```
186
156
 
187
- Glob patterns use [picomatch](https://github.com/micromatch/picomatch). String commands receive matched files as trailing arguments. Functions receive the matched file list and return one or more commands to run.
188
-
189
- ### TypeScript config
190
-
191
- Use `.cmintrc.ts` or `cmint.config.ts` for type safety without adding commit-mint as a project dependency:
192
-
193
- ```ts
194
- interface Cmintrc {
195
- [glob: string]: string | string[] | ((filenames: string[]) => string | string[]);
196
- }
197
-
198
- export default {
199
- "*.{js,ts,json}": "biome check --write --no-errors-on-unmatched",
200
- "*.ts": () => ["tsc --noEmit", "vitest run --passWithNoTests"],
201
- } satisfies Cmintrc;
202
- ```
203
-
204
- This gives you editor autocomplete and catches invalid values at edit time — no package install needed.
205
-
206
- Checks execute sequentially and fail fast. Each command has a 60-second timeout.
157
+ Glob patterns use [picomatch](https://github.com/micromatch/picomatch). String commands receive matched files as trailing arguments. Functions receive the file list and return one or more commands. Checks run sequentially and fail fast (60s timeout per command).
207
158
 
208
- ### Check failure menu
159
+ Supported config file names: `.cmintrc`, `.cmintrc.json`, `.cmintrc.{mjs,mts,js,ts,cjs,cts}`, `cmint.config.{mjs,mts,js,ts,cjs,cts}`
209
160
 
210
- When a check fails, you get a menu with four options:
161
+ ## Providers
211
162
 
212
- | Option | What it does |
213
- |--------|-------------|
214
- | **Copy error report** | Copies the error output to clipboard |
215
- | **View full output** | Shows the raw check output |
216
- | **Skip checks** | Proceeds without running checks |
217
- | **Cancel** | Exits. Message is cached for `cmint --retry` |
163
+ | Provider | Env key | Default model |
164
+ |----------|---------|---------------|
165
+ | **Groq** | `GROQ_API_KEY` | `openai/gpt-oss-20b` |
166
+ | **Cerebras** | `CEREBRAS_API_KEY` | `gpt-oss-120b` |
167
+ | **Mistral** | `MISTRAL_API_KEY` | `mistral-small` |
218
168
 
219
- Pass `--noCheck` or `-N` to skip checks entirely.
169
+ Use `cmint config` to switch providers or override the model per-provider. All providers use OpenAI-compatible APIs (Groq via official SDK, Cerebras and Mistral via built-in fetch client).
220
170
 
221
171
  ## Configuration
222
172
 
223
- Stored in `~/.commit-mint` (INI format). Set values via `cmint config set <key> <value>`.
224
-
225
- ```ini
226
- provider=groq
227
- GROQ_API_KEY=gsk_...
228
- model=openai/gpt-oss-20b
229
- locale=en
230
- max-length=100
231
- type=conventional
232
- timeout=10000
233
- proxy=
173
+ Stored in `~/.commit-mint` (INI format). Run the wizard:
174
+
175
+ ```bash
176
+ cmint config
234
177
  ```
235
178
 
236
179
  | Key | Default | Description |
237
180
  |-----|---------|-------------|
238
181
  | `provider` | `groq` | AI provider (`groq`, `cerebras`, or `mistral`) |
239
- | `GROQ_API_KEY` | | Groq API key (or set `GROQ_API_KEY` env var) |
240
- | `CEREBRAS_API_KEY` | — | Cerebras API key (or set `CEREBRAS_API_KEY` env var) |
241
- | `MISTRAL_API_KEY` | — | Mistral API key (or set `MISTRAL_API_KEY` env var) |
242
- | `model` | `openai/gpt-oss-20b` | Default AI model for message generation |
243
- | `model_groq` | — | Model override for Groq provider |
244
- | `model_cerebras` | — | Model override for Cerebras provider |
245
- | `model_mistral` | — | Model override for Mistral provider |
182
+ | `model` | `openai/gpt-oss-20b` | Default model (overridable per-provider with `model_groq`, `model_cerebras`, `model_mistral`) |
246
183
  | `locale` | `en` | Locale for generated messages |
247
- | `max-length` | `100` | Maximum commit message length |
248
- | `type` | — | Commit type prefix (e.g. `conventional`) |
184
+ | `max-length` | `100` | Max commit message length |
185
+ | `type` | — | Commit type prefix |
249
186
  | `timeout` | `10000` | AI request timeout in ms |
250
187
  | `proxy` | — | Proxy URL for API requests |
251
188
 
252
- Model resolution follows a chain: `model_<provider>` → global `model` → provider default. Per-provider keys prevent cross-provider model leaks when switching providers.
253
-
254
- ## Retry persistence
189
+ ## Excluded files
255
190
 
256
- Failed commit messages are cached to `~/.cache/commit-mint/<repo-hash>.json`. Running `cmint --retry` reuses the last message without regenerating. Fix errors in another terminal, come back, and retry.
191
+ Lockfiles, build output, and generated files are excluded from AI generation. When all staged files match excludes, commit-mint uses a hardcoded message (`chore: update lockfile` or `chore: update generated files`). In auto-group mode, lockfiles are promoted alongside their companion manifests (e.g. `package-lock.json` with `package.json`).
257
192
 
258
193
  ## Requirements
259
194
 
260
195
  - **Node.js 18+**
261
- - **Git** (any modern version)
262
- - **Linux** (primary target; macOS works via `pbcopy`; WSL untested)
263
- - **xclip**, **wl-copy**, **xsel**, or **pbcopy** for clipboard support
196
+ - **Git**
197
+ - Optional clipboard tool for error copy: `wl-copy`, `xclip`, `xsel`, or `pbcopy`
264
198
 
265
- ## Non-goals
199
+ ## License
266
200
 
267
- - Not a git hook manager — cmint config checks run in-flow, not via git hooks. For git hooks, use husky or lefthook.
268
- - Not a linter/formatter — use biome, eslint, or prettier.
269
- - Not a git TUI — use lazygit or gitui.
270
- - Not a commitizen replacement — generates conventional commit messages via AI.
201
+ [MIT](LICENSE)