@kyubiware/commit-mint 0.4.1 → 0.5.0

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,6 +1,53 @@
1
- # commit-mint
1
+ # 🌿 commit-mint
2
2
 
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.
3
+ [![npm version](https://img.shields.io/npm/v/@kyubiware/commit-mint.svg)](https://www.npmjs.com/package/@kyubiware/commit-mint)
4
+
5
+ > Auto-group your changes into clean, conventional commits. AI handles the grouping, messages, and hook failures so you don't have to.
6
+
7
+ ```
8
+ ┌ 🌿 commit-mint
9
+
10
+ ◇ Files analyzed
11
+
12
+ ● Commit group 1 of 3: "Reading view refactor"
13
+
14
+ ◇ Message generated
15
+
16
+ ● feat(compound): add compound utilities and token handling for text study
17
+
18
+ ◇ Committed successfully.
19
+
20
+ ● ✓ prettier
21
+ │ ✓ eslint
22
+ │ ✓ tsc
23
+ │ ✓ vitest
24
+ ◇ Message generated
25
+
26
+ ● feat(text-study): add compound component support to ReadingInspectorPanel
27
+
28
+ ◇ Committed successfully.
29
+
30
+ ● ✓ prettier
31
+ │ ✓ eslint
32
+ │ ✓ tsc
33
+ │ ✓ vitest
34
+
35
+ ● Commit group 3 of 3: "Reading study list update"
36
+ ◇ Message generated
37
+
38
+ ● feat(reading-study-list-body): add compound component support to reading study list
39
+
40
+ ◇ Committed successfully.
41
+
42
+ ● ✓ prettier
43
+ │ ✓ eslint
44
+ │ ✓ tsc
45
+ │ ✓ vitest
46
+
47
+ └ All groups committed.
48
+ ```
49
+
50
+ Requires **Node.js 18+**.
4
51
 
5
52
  ## Quick Start
6
53
 
@@ -9,46 +56,69 @@ npm install -g @kyubiware/commit-mint
9
56
  ```
10
57
 
11
58
  ```bash
12
- cmint
59
+ cmint -a
13
60
  ```
14
61
 
15
- Requires **Node.js 18+**.
62
+ On first run, you'll be prompted for a `GROQ_API_KEY` if it's not set in `~/.commit-mint` or as an environment variable. It's saved for future runs.
16
63
 
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
- ```
64
+ ## Why commit-mint?
65
+
66
+ - **Auto-group by intent.** AI reads your diff and groups files into logical commits. No more `feat: update stuff` that bundles unrelated changes.
67
+ - **Zero-prompt auto mode.** `cmint -a` stages, groups, generates messages, and commits without a single prompt. Walk away and come back to clean history.
68
+ - **Hook failures handled in-flow.** When pre-commit hooks fail, you get a parsed error summary and a menu to copy, skip, retry, or edit. No raw stderr dumps.
69
+ - **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.
70
+ - **Message caching on failure.** A failed commit caches its message. Fix the error, run `cmint --retry`, and pick up exactly where you left off.
71
+ - **Review before you commit.** Every message can be accepted, edited, or reviewed with OpenCode before it hits the repo.
72
+
73
+ ## Auto mode (`-a`)
74
+
75
+ `cmint -a` is the primary way to use commit-mint. It runs the full pipeline with no prompts:
76
+
77
+ 1. AI analyzes all changed files
78
+ 2. Files are grouped into logical commits by intent
79
+ 3. Each group gets its own AI-generated conventional commit message
80
+ 4. Groups are committed sequentially
81
+ 5. Hook failures per group trigger the recovery menu
82
+
83
+ Use this when you want clean history without the ceremony.
84
+
85
+ ## Manual mode
86
+
87
+ Run `cmint` without flags for the interactive flow:
88
+
89
+ 1. **Staging menu** — stage all, select files, auto-group, or cancel
90
+ 2. **File selection** — multi-select specific files if you don't want everything
91
+ 3. **Message review** — review the AI-generated message before committing
92
+ 4. **Commit attempt** — hooks run, recovery menu appears on failure
93
+
94
+ If only one file changed, it's staged automatically.
25
95
 
26
96
  ## Usage
27
97
 
28
98
  ```bash
29
- # Normal commit flow (interactive staging if multiple files)
30
- cmint
31
-
32
- # Auto-group files into commits with auto-accepted messages (no prompts)
99
+ # Auto-group and commit everything (no prompts)
33
100
  cmint -a
34
101
 
102
+ # Normal interactive flow
103
+ cmint
104
+
35
105
  # Skip AI, provide your own message
36
106
  cmint -m "feat: add dark mode"
37
107
 
38
- # Pass context hint to AI for better messages
108
+ # Pass context hint for better messages
39
109
  cmint -H "refactoring auth module"
40
- cmint --hint "splitting monolith into services"
41
110
 
42
111
  # Retry last failed commit (uses cached message)
43
- cmint --retry
44
112
  cmint -r
45
113
 
46
114
  # Review staged changes with AI
47
- cmint --review
48
115
  cmint -R
49
116
 
50
- # Debug mode — timestamped stderr output
51
- cmint --debug
117
+ # Skip pre-commit checks
118
+ cmint -n
119
+
120
+ # Debug mode
121
+ cmint -d
52
122
 
53
123
  # Configuration
54
124
  cmint config get GROQ_API_KEY
@@ -56,49 +126,27 @@ cmint config set GROQ_API_KEY=gsk_...
56
126
  cmint config set model openai/gpt-oss-20b
57
127
  ```
58
128
 
59
- ### First run
60
-
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.
62
-
63
- ### Interactive staging
64
-
65
- When you have multiple changed files, commit-mint shows an interactive staging menu:
129
+ | Flag | Description |
130
+ |------|-------------|
131
+ | `-a, --auto` | Auto-group files into commits, accept all messages |
132
+ | `-m, --message` | Provide a commit message directly (skip AI) |
133
+ | `-H, --hint` | Add context hint for AI message generation |
134
+ | `-r, --retry` | Retry the last failed commit |
135
+ | `-R, --review` | Review staged changes with a coding model |
136
+ | `-n, --noCheck` | Skip pre-commit checks |
137
+ | `-d, --debug` | Enable debug output |
138
+ | `-h, --help` | Show help |
139
+ | `-v, --version` | Show version |
66
140
 
67
- - **Stage all files** — auto-stage everything
68
- - **Select files** — multi-select specific files to stage
69
- - **Auto-group into commits** — AI groups files into logical commits (see below)
70
- - **Cancel**
141
+ ## Message review
71
142
 
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 use `cmint --auto` / `cmint -a` to auto-group and auto-accept all commit messages with no prompts.
86
-
87
- ### Message review
88
-
89
- Before every commit, you can review the generated message:
143
+ Before every commit, choose what to do with the generated message:
90
144
 
91
145
  - **Use as-is** — accept the AI-generated message
92
146
  - **Edit** — modify the message in a prompt
93
- - **Review with OpenCode** — run a code review on your staged changes before committing
147
+ - **Review with OpenCode** — run a code review on staged changes before committing
94
148
  - **Cancel** — exit (message is cached for `--retry`)
95
149
 
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
-
102
150
  ## Recovery menu
103
151
 
104
152
  When a pre-commit hook blocks your commit, commit-mint parses the error output and presents an interactive menu:
@@ -122,23 +170,75 @@ When a pre-commit hook blocks your commit, commit-mint parses the error output a
122
170
 
123
171
  | Option | What it does |
124
172
  |--------|-------------|
125
- | **Copy error report** | Copies parsed, clean error output to clipboard — paste it into another terminal for an AI agent to fix |
126
- | **Skip hooks** | Re-runs `git commit --no-verify` with the same message — for when hooks are wrong or you'll fix later |
127
- | **Re-stage & retry** | Runs `git add -A` again (picks up fixes made in another terminal), then retries the commit |
173
+ | **Copy error report** | Copies parsed, clean error output to clipboard |
174
+ | **Skip hooks** | Re-runs `git commit --no-verify` with the same message |
175
+ | **Re-stage & retry** | Runs `git add -A` again, then retries the commit |
128
176
  | **Edit message** | Opens a prompt to modify the commit message, then retries |
129
177
  | **Cancel** | Exits. Commit message is cached for `cmint --retry` |
130
178
 
131
- ### Supported hook tools
179
+ The recovery menu also appears when cmint config pre-commit checks fail.
180
+
181
+ commit-mint parses errors from **lint-staged**, **biome**, **TypeScript** (`tsc`), **vitest** / **jest**, and **ESLint**. Unrecognized output falls back to raw stderr.
132
182
 
133
- commit-mint parses errors from:
183
+ ## Pre-commit checks
134
184
 
135
- - **lint-staged** task failure detection
136
- - **biome** lint/format errors with file:line:col
137
- - **TypeScript** (`tsc`) — type errors with TS error codes
138
- - **vitest** / **jest** — test failure detection
139
- - **ESLint** — lint error/warning detection
185
+ Define custom checks in a cmint config file at your project root. Supported file names (checked in priority order):
186
+ `.cmintrc`, `.cmintrc.json`, `.cmintrc.{mjs,mts,js,ts,cjs,cts}`, `cmint.config.{mjs,mts,js,ts,cjs,cts}`
140
187
 
141
- Unrecognized error output is shown as raw fallback.
188
+ They run after staging, before AI message generation, so a failing check never wastes an API call.
189
+
190
+ ```js
191
+ export default {
192
+ // String: matched files are appended as arguments
193
+ "*.{js,ts,json}": "biome check --write --no-errors-on-unmatched",
194
+
195
+ // Function: receive matched filenames, return command(s)
196
+ "*.ts": () => ["tsc --noEmit", "vitest run --passWithNoTests"],
197
+ };
198
+ ```
199
+
200
+ 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.
201
+
202
+ ### TypeScript config
203
+
204
+ Use `.cmintrc.ts` or `cmint.config.ts` for type safety without adding commit-mint as a project dependency. Add an inline interface and use `satisfies`:
205
+
206
+ ```ts
207
+ interface Cmintrc {
208
+ [glob: string]: string | string[] | ((filenames: string[]) => string | string[]);
209
+ }
210
+
211
+ export default {
212
+ "*.{js,ts,json}": "biome check --write --no-errors-on-unmatched",
213
+ "*.ts": () => ["tsc --noEmit", "vitest run --passWithNoTests"],
214
+ } satisfies Cmintrc;
215
+ ```
216
+
217
+ This gives you editor autocomplete and catches invalid values (e.g. numbers, objects) at edit time — no package install needed.
218
+
219
+ Checks execute sequentially and fail fast. Each command has a 60-second timeout.
220
+
221
+ ### When checks run
222
+
223
+ - **Manual mode**: The staging menu shows a "Run checks" option when a cmint config file exists
224
+ - **Auto-group mode**: Checks run automatically on all staged files before grouping
225
+ - **Normal commit**: Checks run on staged files after staging, before diff/AI
226
+
227
+ ### Check failure menu
228
+
229
+ When a check fails, you get a menu with three options:
230
+
231
+ | Option | What it does |
232
+ |--------|-------------|
233
+ | **Copy error report** | Copies the error output to clipboard |
234
+ | **Skip checks** | Proceeds without running checks |
235
+ | **Cancel** | Exits. Message is cached for `cmint --retry` |
236
+
237
+ Pass `--noCheck` or `-n` to skip checks entirely.
238
+
239
+ ## Code review
240
+
241
+ Run `cmint --review` or `cmint -R` to review staged changes without committing. commit-mint checks for [OpenCode](https://github.com/opencode-ai/opencode) first, then falls back to Groq API. The review covers bugs, security issues, performance problems, and edge cases.
142
242
 
143
243
  ## Configuration
144
244
 
@@ -179,6 +279,7 @@ cmint --help
179
279
  --message, -m Provide a commit message directly (skip AI generation)
180
280
  --hint, -H Add context hint for AI commit message generation
181
281
  --review, -R Review staged changes with a coding model (default: false)
282
+ --noCheck, -n Skip pre-commit checks (default: false)
182
283
  --debug, -d Enable debug output (default: false)
183
284
  --help, -h Show help
184
285
  --version, -v Show version
@@ -189,7 +290,7 @@ cmint --help
189
290
 
190
291
  ## Retry persistence
191
292
 
192
- Failed commit messages are cached to `~/.cache/commit-mint/<repo-hash>.json`. Running `cmint --retry` reuses the last message without regenerating useful after fixing errors flagged by the recovery menu.
293
+ 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.
193
294
 
194
295
  ## How it works
195
296
 
@@ -208,6 +309,7 @@ commit-mint/
208
309
  │ │ ├── grouping.ts # AI-powered file grouping into logical commits
209
310
  │ │ ├── review-ai.ts # AI code review via Groq
210
311
  │ │ ├── hooks.ts # Hook error parser (lint-staged, biome, tsc, etc.)
312
+ │ │ ├── checks.ts # Pre-commit checks via cmint config files (glob matching, command execution)
211
313
  │ │ ├── config.ts # INI config read/write at ~/.commit-mint
212
314
  │ │ └── clipboard.ts # Cross-platform clipboard (xclip/wl-copy/pbcopy)
213
315
  │ ├── ui/
@@ -219,18 +321,6 @@ commit-mint/
219
321
  │ └── debug.ts # Timestamped debug logging to stderr
220
322
  ```
221
323
 
222
- ## Key differentiators
223
-
224
- 1. **Hook error parsing** — No other commit tool parses lint-staged/biome/eslint output into a clean summary
225
- 2. **Interactive recovery menu** — Copy/skip/retry/edit as an in-flow choice, not a manual post-mortem
226
- 3. **Message caching on failure** — `--retry` restores the last message without regenerating
227
- 4. **Re-stage & retry loop** — Fix errors in another terminal, come back, hit "re-stage & retry"
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
233
-
234
324
  ## Requirements
235
325
 
236
326
  - **Node.js 18+**
@@ -240,7 +330,7 @@ commit-mint/
240
330
 
241
331
  ## Non-goals
242
332
 
243
- - Not a hook manager — use husky, lefthook
333
+ - Not a git hook manager — cmint config checks run in-flow, not via git hooks. For git hooks, use husky or lefthook
244
334
  - Not a linter/formatter — use biome, eslint, prettier
245
335
  - Not a git TUI — use lazygit, gitui
246
336
  - Not a commitizen replacement — just generates conventional commit messages via AI