@kyubiware/commit-mint 0.6.0 → 0.6.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
@@ -2,13 +2,13 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@kyubiware/commit-mint.svg)](https://www.npmjs.com/package/@kyubiware/commit-mint)
4
4
  [![CI](https://img.shields.io/github/actions/workflow/status/kyubiware/commit-mint/ci.yml)](https://github.com/kyubiware/commit-mint/actions)
5
- [![Node](https://img.shields.io/badge/node-%3E%3D18-3c873a)](https://nodejs.org)
6
- [![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)
5
+ [![GitHub stars](https://img.shields.io/github/stars/kyubiware/commit-mint?style=flat&logo=github)](https://github.com/kyubiware/commit-mint)
7
6
 
8
- A commit tool that handles hook failures. Generates conventional commit messages
9
- from your diff, auto-groups unrelated changes into separate commits, runs your
10
- checks before any API call, and gives you a recovery menu when hooks block the
11
- commit instead of dumping raw stderr.
7
+ - Runs your pre-commit checks on changed files, then digests failures into a
8
+ structured error report you can copy to clipboard paste straight into a
9
+ coding agent.
10
+ - Looks at what you changed and uses AI to group files into logical commits.
11
+ - Generates a good commit message for each group.
12
12
 
13
13
  ## Install
14
14
 
@@ -28,16 +28,13 @@ API key. The key is saved to `~/.commit-mint` (INI).
28
28
  ## Usage
29
29
 
30
30
  ```bash
31
- cmint # interactive: stage → checks → review → commit
32
- cmint -a # auto-group, generate messages, commit everything
33
- cmint -m "feat: ..." # skip AI, use your own message
34
- cmint -H "context" # hint to the AI (e.g. "refactor only, no behavior change")
35
- cmint -r # retry the last failed commit (cached message)
36
- cmint -N # skip pre-flight checks
37
- cmint -d # debug logging to stderr
38
- cmint config # edit provider, model, locale, etc.
31
+ cmint # interactive: stage → checks → review → commit
32
+ cmint -a # auto-group, generate messages, commit everything
33
+ cmint config # edit provider, model, locale, etc.
39
34
  ```
40
35
 
36
+ See [all flags](#all-flags) for the full list.
37
+
41
38
  ## Pre-flight checks (`.cmintrc`)
42
39
 
43
40
  `.cmintrc` is commit-mint's pre-commit check system. The config syntax is
@@ -45,55 +42,10 @@ identical to [lint-staged](https://github.com/okonet/lint-staged) — glob keys
45
42
  mapping to shell commands — but the checks run inside commit-mint's flow, not
46
43
  as a separate git hook.
47
44
 
48
- This matters for three reasons:
49
-
50
- **1. Checks run before the AI call.** commit-mint runs checks before
51
- generating the commit message. A failing check short-circuits before any API
52
- call. With lint-staged, the hook fires after the message is already finalized
53
- (if the AI call was made) or the user has typed one in — so a broken check
54
- wastes the message.
55
-
56
- **2. Failures get a recovery menu, not raw stderr.** lint-staged prints whatever
57
- the tool emitted and exits. commit-mint parses biome, tsc, vitest/jest, eslint,
58
- and lint-staged output into structured errors. Then commit-mint lets you copy the error report to clipboard,
59
- so you can paste straight to your coding agent.
60
-
61
- **3. Live retry.** After your coding agent fixes the error in another terminal, pick "Retry checks" in
62
- the menu, no need to exit and re-run `cmint`.
63
-
64
- Same syntax, fewer moving parts, and the checks live in the same process as
65
- the rest of the commit.
66
-
67
- ### Config file names
68
-
69
- Checked in this order. First match wins.
70
-
71
- ```
72
- .cmintrc
73
- .cmintrc.json
74
- .cmintrc.mjs
75
- .cmintrc.mts
76
- .cmintrc.js
77
- .cmintrc.ts
78
- .cmintrc.cjs
79
- .cmintrc.cts
80
- cmint.config.mjs
81
- cmint.config.mts
82
- cmint.config.js
83
- cmint.config.ts
84
- cmint.config.cjs
85
- cmint.config.cts
86
- ```
87
-
88
- `.ts`/`.cts`/`.cjs` are loaded via [jiti](https://github.com/unjs/jiti) — use
89
- TypeScript syntax freely. `.json` is parsed as plain JSON. Everything else is
90
- loaded as ESM with `import default`.
91
-
92
- ### Config shape
45
+ **Already using lint-staged?** Rename your config file to `.cmintrc` — same
46
+ syntax, no changes needed.
93
47
 
94
- A default export. Each key is a [picomatch](https://github.com/micromatch/picomatch)
95
- glob; each value is a command string, a string array, or a function that
96
- returns either.
48
+ Run `cmint config` to auto-generate one, or create it manually:
97
49
 
98
50
  ```ts
99
51
  // .cmintrc.ts
@@ -103,85 +55,25 @@ export default {
103
55
  };
104
56
  ```
105
57
 
106
- This is the actual `.cmintrc.ts` commit-mint ships with for its own
107
- development — biome on staged JS/TS/JSON, then tsc + vitest + build on staged
108
- TS.
58
+ (This is the actual `.cmintrc.ts` commit-mint ships with for its own
59
+ development.)
109
60
 
110
- **String commands** get matched files appended as trailing arguments. Files
111
- with spaces in their paths are quoted automatically.
61
+ Checks run inside commit-mint's flow for three reasons:
112
62
 
113
- ```ts
114
- export default {
115
- "*.ts": "eslint --fix", // runs `eslint --fix src/foo.ts src/bar.ts`
116
- };
117
- ```
63
+ **1. Checks run before the AI call.** A failing check short-circuits before
64
+ any API call. With lint-staged, the hook fires after the message is already
65
+ finalized a broken check wastes the message.
118
66
 
119
- **String arrays** run sequentially, each as a separate command. First failure
120
- stops the run.
67
+ **2. Failures get a recovery menu, not raw stderr.** commit-mint parses biome,
68
+ tsc, vitest/jest, eslint, and lint-staged output into structured errors, then
69
+ lets you copy the error report to clipboard — paste straight into a coding
70
+ agent.
121
71
 
122
- ```ts
123
- export default {
124
- "*.ts": ["eslint --fix", "prettier --write"],
125
- };
126
- ```
72
+ **3. Live retry.** Fix the error in another terminal, pick "Retry checks" in
73
+ the menu — no need to exit and re-run `cmint`.
127
74
 
128
- **Function commands** receive the matched files and return a command or array
129
- of commands. Use these when the command depends on the file list, or you want
130
- multiple commands from one glob:
131
-
132
- ```ts
133
- export default {
134
- "*.ts": (files) =>
135
- files.length > 5 ? `vitest run ${files.join(" ")}` : "vitest run",
136
- };
137
- ```
138
-
139
- ### Glob matching
140
-
141
- - Globs without a `/` match at any depth (e.g. `*.ts` matches `src/foo.ts` and
142
- `a/b/c.ts`).
143
- - Dotfiles are included.
144
- - Paths with spaces are quoted before being appended.
145
-
146
- ### Behavior
147
-
148
- - Checks run after `git add`, before the AI call.
149
- - Globs are processed in declaration order.
150
- - Commands run sequentially per glob. First failure stops the run (fail-fast)
151
- and skips remaining globs.
152
- - 60s timeout per command. ENOENT (command not found) and timeouts are
153
- reported back to the menu as their own error.
154
- - Skipped entirely with `cmint -N`.
155
-
156
- ### Failure menu
157
-
158
- When a check fails, the same `parseHookErrors` pipeline that handles git
159
- hooks runs, and a menu appears:
160
-
161
- ```
162
- Pre-commit check failed
163
- • [biome] src/services/ai.ts:12:1 lint/suspicious/noExplicitAny — Unexpected any...
164
- • [tsc] src/services/ai.ts:55:18 — error TS2345: Argument of type 'string' is...
165
-
166
- What do you want to do?
167
- Copy error report to clipboard
168
- View full error output
169
- Retry checks
170
- Skip checks and commit
171
- Cancel
172
- ```
173
-
174
- - **Copy error report** — copies the raw stderr (works with `wl-copy`,
175
- `xclip`, `xsel`, or `pbcopy`).
176
- - **View full error output** — shows the raw stderr.
177
- - **Retry checks** — re-runs the same checks. Fix in another terminal, hit
178
- enter, no restart.
179
- - **Skip checks and commit** — proceed to commit despite the failure.
180
- - **Cancel** — exit. The message is cached so `cmint -r` re-attempts with the
181
- same message.
182
-
183
- For tsc failures specifically, the summary includes up to 3 file:line:column
184
- diagnostics inline, with a `+N more` line if there are more.
75
+ Config shape details, file name patterns, and the failure menu are documented
76
+ [below](#config-reference).
185
77
 
186
78
  ## Auto-group mode (`-a`)
187
79
 
@@ -207,6 +99,50 @@ What do you want to stage?
207
99
  Run checks
208
100
  ```
209
101
 
102
+ ## AI Agent Mode
103
+
104
+ `cmint --agent` runs non-interactively with JSON output for AI coding agents.
105
+
106
+ | Combination | Behavior |
107
+ |---|---|
108
+ | `--agent` | Auto-group, AI generates, no review, JSON output |
109
+ | `--agent --message "msg"` | Single-commit mode, use provided message, no AI |
110
+ | `--agent --retry` | ERROR: incompatible (exit 1) |
111
+ | `--agent --noCheck` | Skip user-defined checks |
112
+ | `--agent --hint "..."` | Pass hint to AI |
113
+ | `--agent --debug` | Verbose logging to stderr |
114
+
115
+ ### JSON output schema
116
+
117
+ The command returns a single JSON object to stdout.
118
+
119
+ ```json
120
+ {"status":"success","commits":[{"message":"feat: add X","hash":"abc123","files":["src/a.ts"]}]}
121
+ {"status":"no_changes","commits":[]}
122
+ {"status":"failure","commits":[],"errors":["error detail"]}
123
+ {"status":"cancelled","commits":[]}
124
+ ```
125
+
126
+ ### Exit codes
127
+
128
+ | Code | Meaning |
129
+ |------|---------|
130
+ | 0 | Success |
131
+ | 1 | Generic error |
132
+ | 2 | No changes |
133
+ | 3 | Git error |
134
+ | 4 | AI error |
135
+ | 5 | Check failure |
136
+ | 6 | Hook failure |
137
+
138
+ ### AI Coding Agent Integration
139
+
140
+ For OpenCode or other AI coding environments, you can install cmint as a skill:
141
+
142
+ ```bash
143
+ npx skills add kyubiware/commit-mint
144
+ ```
145
+
210
146
  ## Recovery menu
211
147
 
212
148
  When a git hook blocks the commit, commit-mint parses the output and shows:
@@ -277,6 +213,7 @@ timeout.
277
213
  | `type` | — | Force commit type prefix |
278
214
  | `timeout` | `10000` | AI request timeout in ms |
279
215
  | `proxy` | — | Proxy URL for API requests |
216
+ | `--agent` | `false` | Headless JSON-output mode for AI agents |
280
217
 
281
218
  API key lookup checks the env var first, then the INI file.
282
219
 
@@ -297,6 +234,126 @@ files` for the rest. In auto-group mode, lockfiles (`package-lock.json`,
297
234
  alongside their companion manifest (e.g. `package-lock.json` stays with
298
235
  `package.json`).
299
236
 
237
+ ## All flags
238
+
239
+ | Flag | Description |
240
+ | ----------------------- | ------------------------------------------------ |
241
+ | `-m`, `--message` | Use your own message instead of AI generation |
242
+ | `-H`, `--hint` | Context hint to the AI (e.g. "refactor only") |
243
+ | `-r`, `--retry` | Retry last failed commit (cached message) |
244
+ | `-N`, `--noCheck` | Skip pre-flight checks |
245
+ | `-d`, `--debug` | Debug logging to stderr |
246
+ | `--agent` | Headless JSON mode for AI coding agents |
247
+
248
+ ## Config reference
249
+
250
+ ### Config file names
251
+
252
+ Checked in this order. First match wins.
253
+
254
+ ```
255
+ .cmintrc
256
+ .cmintrc.json
257
+ .cmintrc.mjs
258
+ .cmintrc.mts
259
+ .cmintrc.js
260
+ .cmintrc.ts
261
+ .cmintrc.cjs
262
+ .cmintrc.cts
263
+ cmint.config.mjs
264
+ cmint.config.mts
265
+ cmint.config.js
266
+ cmint.config.ts
267
+ cmint.config.cjs
268
+ cmint.config.cts
269
+ ```
270
+
271
+ `.ts`/`.cts`/`.cjs` are loaded via [jiti](https://github.com/unjs/jiti) — use
272
+ TypeScript syntax freely. `.json` is parsed as plain JSON. Everything else is
273
+ loaded as ESM with `import default`.
274
+
275
+ ### Config shape
276
+
277
+ A default export. Each key is a [picomatch](https://github.com/micromatch/picomatch)
278
+ glob; each value is a command string, a string array, or a function that
279
+ returns either.
280
+
281
+ **String commands** get matched files appended as trailing arguments. Files
282
+ with spaces in their paths are quoted automatically.
283
+
284
+ ```ts
285
+ export default {
286
+ "*.ts": "eslint --fix", // runs `eslint --fix src/foo.ts src/bar.ts`
287
+ };
288
+ ```
289
+
290
+ **String arrays** run sequentially, each as a separate command. First failure
291
+ stops the run.
292
+
293
+ ```ts
294
+ export default {
295
+ "*.ts": ["eslint --fix", "prettier --write"],
296
+ };
297
+ ```
298
+
299
+ **Function commands** receive the matched files and return a command or array
300
+ of commands. Use these when the command depends on the file list, or you want
301
+ multiple commands from one glob:
302
+
303
+ ```ts
304
+ export default {
305
+ "*.ts": (files) =>
306
+ files.length > 5 ? `vitest run ${files.join(" ")}` : "vitest run",
307
+ };
308
+ ```
309
+
310
+ ### Glob matching
311
+
312
+ - Globs without a `/` match at any depth (e.g. `*.ts` matches `src/foo.ts` and
313
+ `a/b/c.ts`).
314
+ - Dotfiles are included.
315
+ - Paths with spaces are quoted before being appended.
316
+
317
+ ### Behavior
318
+
319
+ - Checks run after `git add`, before the AI call.
320
+ - Globs are processed in declaration order.
321
+ - Commands run sequentially per glob. First failure stops the run (fail-fast)
322
+ and skips remaining globs.
323
+ - 60s timeout per command. ENOENT (command not found) and timeouts are
324
+ reported back to the menu as their own error.
325
+ - Skipped entirely with `cmint -N`.
326
+
327
+ ### Failure menu
328
+
329
+ When a check fails, the same `parseHookErrors` pipeline that handles git
330
+ hooks runs, and a menu appears:
331
+
332
+ ```
333
+ Pre-commit check failed
334
+ • [biome] src/services/ai.ts:12:1 lint/suspicious/noExplicitAny — Unexpected any...
335
+ • [tsc] src/services/ai.ts:55:18 — error TS2345: Argument of type 'string' is...
336
+
337
+ What do you want to do?
338
+ Copy error report to clipboard
339
+ View full error output
340
+ Retry checks
341
+ Skip checks and commit
342
+ Cancel
343
+ ```
344
+
345
+ - **Copy error report** — copies the raw stderr (works with `wl-copy`,
346
+ `xclip`, `xsel`, or `pbcopy`).
347
+ - **View full error output** — shows the raw stderr.
348
+ - **Retry checks** — re-runs the same checks. Fix in another terminal, hit
349
+ enter, no restart.
350
+ - **Skip checks and commit** — proceed to commit despite the failure.
351
+ - **Cancel** — exit. The message is cached so `cmint -r` re-attempts with the
352
+ same message.
353
+
354
+ For tsc failures specifically, the summary includes up to 3 file:line:column
355
+ diagnostics inline, with a `+N more` line if there are more.
356
+
300
357
  ## Requirements
301
358
 
302
359
  - Node.js 18+