@kud/ai-conventional-commit-cli 0.4.1 → 0.4.3
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 +146 -116
- package/dist/index.js +3 -1
- package/package.json +1 -1
- package/dist/index.cjs +0 -1200
- package/dist/index.d.cts +0 -1
package/README.md
CHANGED
|
@@ -1,145 +1,183 @@
|
|
|
1
1
|
# ai-conventional-commit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<b>AI‑assisted, style‑aware Conventional Commit generator & splitter</b><br/>
|
|
5
|
+
Opinionated CLI that learns your repo's commit style and produces polished single or multi commits – safely, quickly, repeatably.
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://www.npmjs.com/package/@kud/ai-conventional-commit-cli"><img alt="npm version" src="https://img.shields.io/npm/v/%40kud%2Fai-conventional-commit-cli?color=brightgreen" /></a>
|
|
10
|
+
<a href="https://www.npmjs.com/package/@kud/ai-conventional-commit-cli"><img alt="downloads" src="https://img.shields.io/npm/dm/%40kud%2Fai-conventional-commit-cli" /></a>
|
|
11
|
+
<a href="LICENSE"><img alt="license" src="https://img.shields.io/npm/l/%40kud%2Fai-conventional-commit-cli" /></a>
|
|
12
|
+
<a href="https://nodejs.org"><img alt="node version" src="https://img.shields.io/node/v/%40kud%2Fai-conventional-commit-cli" /></a>
|
|
13
|
+
<a href="https://www.conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg" /></a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
> TL;DR: Stage your changes, run `ai-conventional-commit` (or `split` for multiple commits), accept, done. Add `--gitmoji` if you like emoji. Refine later with `refine`.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Table of Contents
|
|
21
|
+
|
|
22
|
+
- [Why](#why)
|
|
23
|
+
- [Features](#features)
|
|
24
|
+
- [Install](#install)
|
|
25
|
+
- [Quick Start](#quick-start)
|
|
26
|
+
- [Command Reference](#command-reference)
|
|
27
|
+
- [Examples](#examples)
|
|
28
|
+
- [Gitmoji Modes](#gitmoji-modes)
|
|
29
|
+
- [Privacy Modes](#privacy-modes)
|
|
30
|
+
- [Configuration](#configuration-aiccrc)
|
|
31
|
+
- [Refinement Workflow](#refinement-workflow)
|
|
32
|
+
- [Plugin API](#plugin-api)
|
|
33
|
+
- [Title Formatting Helper](#title-formatting-helper)
|
|
34
|
+
- [Security](#security)
|
|
35
|
+
- [Roadmap Ideas](#roadmap-ideas)
|
|
36
|
+
- [Contributing](#contributing)
|
|
37
|
+
- [License](#license)
|
|
4
38
|
|
|
5
39
|
## Why
|
|
6
40
|
|
|
7
|
-
Manual commit messages are noisy, inconsistent, and
|
|
41
|
+
Manual commit messages are often noisy, inconsistent, and context‑poor. This tool:
|
|
8
42
|
|
|
9
|
-
|
|
43
|
+
- Learns _your_ recent commit style (length, scopes, emoji, prefixes)
|
|
44
|
+
- Respects Conventional Commits & normalizes edge cases
|
|
45
|
+
- Proposes **multi‑commit splits** when changes are logically separable
|
|
46
|
+
- Lets you iteratively refine wording – without rewriting history prematurely
|
|
10
47
|
|
|
11
|
-
|
|
12
|
-
- Single (`ai-conventional-commit` / `ai-conventional-commit generate`) or multi-commit planning (`ai-conventional-commit split`)
|
|
13
|
-
- Refinement workflow (`ai-conventional-commit refine`) to iteratively tweak a prior result
|
|
14
|
-
- Gitmoji modes: `--gitmoji[-pure]` (plain adds emoji + type, pure removes type)
|
|
48
|
+
## Features
|
|
15
49
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
50
|
+
| Category | Highlights |
|
|
51
|
+
| ------------------ | ------------------------------------------------------------------------ |
|
|
52
|
+
| Style Intelligence | Style fingerprint (avg length, scope ratio, gitmoji usage, top prefixes) |
|
|
53
|
+
| Generation Modes | Single, multi‑commit planning (`split`), iterative refinement (`refine`) |
|
|
54
|
+
| Commit Splitting | Real selective staging per proposed commit (no fake plan output) |
|
|
55
|
+
| Gitmoji | Standard / emoji+type / pure emoji modes |
|
|
56
|
+
| Guardrails | Title normalization, Conventional syntax enforcement, length checks |
|
|
57
|
+
| Privacy | Tiered diff detail (low / medium / high) |
|
|
58
|
+
| Plugins | Transform & validate hooks over candidates |
|
|
59
|
+
| Determinism | Mock provider for CI & tests (`AICC_DEBUG_PROVIDER=mock`) |
|
|
60
|
+
| UX | Timing output, scoped prompts, animated header (optional) |
|
|
21
61
|
|
|
22
|
-
## Install
|
|
62
|
+
## Install
|
|
63
|
+
|
|
64
|
+
Global (recommended for daily use):
|
|
23
65
|
|
|
24
66
|
```bash
|
|
25
|
-
npm install
|
|
26
|
-
npm run build
|
|
27
|
-
npm link
|
|
28
|
-
# then
|
|
29
|
-
ai-conventional-commit --help
|
|
67
|
+
npm install -g @kud/ai-conventional-commit-cli
|
|
30
68
|
```
|
|
31
69
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
If you prefer a shorter alias, add this to your shell profile:
|
|
70
|
+
Local + npx:
|
|
35
71
|
|
|
36
72
|
```bash
|
|
37
|
-
|
|
73
|
+
npm install --save-dev @kud/ai-conventional-commit-cli
|
|
74
|
+
npx ai-conventional-commit --help
|
|
38
75
|
```
|
|
39
76
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
A build is automatically produced on `npm publish` via the `prepublishOnly` script so you can simply bump the version and run:
|
|
77
|
+
From source (dev):
|
|
43
78
|
|
|
44
79
|
```bash
|
|
45
|
-
npm
|
|
80
|
+
npm install
|
|
81
|
+
npm run build
|
|
82
|
+
npm link
|
|
83
|
+
ai-conventional-commit --help
|
|
46
84
|
```
|
|
47
85
|
|
|
48
|
-
|
|
86
|
+
Optional shell alias:
|
|
49
87
|
|
|
50
88
|
```bash
|
|
51
|
-
|
|
89
|
+
alias aicc='ai-conventional-commit'
|
|
52
90
|
```
|
|
53
91
|
|
|
54
92
|
## Quick Start
|
|
55
93
|
|
|
56
94
|
```bash
|
|
57
|
-
# Stage
|
|
95
|
+
# Stage changes
|
|
58
96
|
git add .
|
|
97
|
+
|
|
59
98
|
# Generate a single commit suggestion
|
|
60
99
|
ai-conventional-commit
|
|
61
|
-
|
|
100
|
+
|
|
101
|
+
# Propose multiple commits (interactive confirm + real selective staging)
|
|
62
102
|
ai-conventional-commit split
|
|
63
|
-
|
|
103
|
+
|
|
104
|
+
# Add emoji decorations
|
|
64
105
|
ai-conventional-commit --gitmoji
|
|
65
|
-
# Pure gitmoji (emoji: subject)
|
|
66
|
-
ai-conventional-commit --gitmoji-pure
|
|
67
106
|
|
|
107
|
+
# Pure emoji style (emoji: subject)
|
|
108
|
+
ai-conventional-commit --gitmoji-pure
|
|
68
109
|
|
|
69
|
-
# Refine previous session
|
|
110
|
+
# Refine previous session's first commit (shorter wording)
|
|
70
111
|
ai-conventional-commit refine --shorter
|
|
71
112
|
```
|
|
72
113
|
|
|
73
|
-
##
|
|
114
|
+
## Command Reference
|
|
115
|
+
|
|
116
|
+
| Command | Purpose |
|
|
117
|
+
| --------------------------------- | ------------------------------------------- |
|
|
118
|
+
| `ai-conventional-commit` | Generate single commit suggestion (default) |
|
|
119
|
+
| `ai-conventional-commit generate` | Explicit alias of root |
|
|
120
|
+
| `ai-conventional-commit split` | Propose & execute multiple commits |
|
|
121
|
+
| `ai-conventional-commit refine` | Refine last session (or indexed) commit |
|
|
122
|
+
|
|
123
|
+
Helpful flags:
|
|
124
|
+
|
|
125
|
+
- `--gitmoji` / `--gitmoji-pure`
|
|
126
|
+
- `--model <provider/name>` (override)
|
|
127
|
+
- `--scope <scope>` (refine)
|
|
128
|
+
- `--shorter` / `--longer`
|
|
129
|
+
- `--emoji` (add appropriate emoji in refine)
|
|
130
|
+
|
|
131
|
+
## Examples
|
|
132
|
+
|
|
133
|
+
### Single Commit (standard)
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
feat(api): add pagination metadata to list endpoint
|
|
137
|
+
|
|
138
|
+
Adds `total`, `limit`, `offset` fields to response; updates tests.
|
|
139
|
+
```
|
|
74
140
|
|
|
75
|
-
|
|
141
|
+
### Split Workflow (illustrative)
|
|
76
142
|
|
|
77
143
|
```
|
|
78
|
-
|
|
79
|
-
|
|
144
|
+
1. refactor(parser): simplify token scanning (no behavior change)
|
|
145
|
+
2. feat(parser): support negated glob segments
|
|
146
|
+
3. test(parser): add cases for brace + extglob combos
|
|
80
147
|
```
|
|
81
148
|
|
|
82
|
-
|
|
149
|
+
Each proposed commit is _actually_ staged & committed with only its files.
|
|
83
150
|
|
|
84
|
-
|
|
151
|
+
### Refinement
|
|
85
152
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
| `ai-conventional-commit generate` | Same as root (explicit) |
|
|
90
|
-
| `ai-conventional-commit split` | Propose multiple commits (plan) |
|
|
91
|
-
| `ai-conventional-commit refine` | Refine last session result |
|
|
92
|
-
|
|
93
|
-
### Help Output
|
|
94
|
-
|
|
95
|
-
```text
|
|
96
|
-
$ ai-conventional-commit --help
|
|
97
|
-
ai-conventional-commit vX.Y.Z
|
|
98
|
-
|
|
99
|
-
Usage:
|
|
100
|
-
ai-conventional-commit [generate] [options] Generate a commit (default)
|
|
101
|
-
ai-conventional-commit split [options] Propose multiple commits
|
|
102
|
-
ai-conventional-commit refine [options] Refine last or indexed commit
|
|
103
|
-
|
|
104
|
-
Global Options:
|
|
105
|
-
-m, --model <provider/name> Override model provider/name
|
|
106
|
-
--gitmoji[-pure] Gitmoji modes (emoji + type / pure emoji only)
|
|
107
|
-
-h, --help Show this help
|
|
108
|
-
-V, --version Show version
|
|
109
|
-
|
|
110
|
-
Refine Options:
|
|
111
|
-
--shorter / --longer Adjust message length
|
|
112
|
-
--scope <scope> Add or replace scope
|
|
113
|
-
--emoji Add suitable gitmoji
|
|
114
|
-
--index <n> Select commit index
|
|
115
|
-
|
|
116
|
-
Examples:
|
|
117
|
-
ai-conventional-commit --gitmoji
|
|
118
|
-
ai-conventional-commit split --max 3
|
|
119
|
-
ai-conventional-commit refine --scope api --emoji
|
|
153
|
+
```
|
|
154
|
+
$ ai-conventional-commit refine --scope cli --shorter
|
|
155
|
+
✔ Updated: feat(cli): add split timing output
|
|
120
156
|
```
|
|
121
157
|
|
|
122
158
|
## Gitmoji Modes
|
|
123
159
|
|
|
124
|
-
| Mode
|
|
125
|
-
|
|
|
126
|
-
| standard
|
|
127
|
-
| gitmoji
|
|
128
|
-
| gitmoji-pure
|
|
160
|
+
| Mode | Example | Notes |
|
|
161
|
+
| ------------ | ------------------------- | ------------------------------------ |
|
|
162
|
+
| standard | `feat: add search box` | No emoji |
|
|
163
|
+
| gitmoji | `✨ feat: add search box` | Emoji + type retained |
|
|
164
|
+
| gitmoji-pure | `✨: add search box` | Type removed; emoji acts as category |
|
|
129
165
|
|
|
130
|
-
Enable via CLI flags
|
|
166
|
+
Enable via CLI flags or config (`gitmoji: true`, `gitmojiMode`).
|
|
131
167
|
|
|
132
168
|
## Privacy Modes
|
|
133
169
|
|
|
134
|
-
| Mode | Data Sent
|
|
135
|
-
| ------ |
|
|
136
|
-
| low | Hunk headers + first 40 changed/context lines per hunk
|
|
137
|
-
| medium | File + hunk hash + line counts + function context only
|
|
138
|
-
| high | File names
|
|
170
|
+
| Mode | Data Sent |
|
|
171
|
+
| ------ | ------------------------------------------------------ |
|
|
172
|
+
| low | Hunk headers + first 40 changed/context lines per hunk |
|
|
173
|
+
| medium | File + hunk hash + line counts + function context only |
|
|
174
|
+
| high | File names + aggregate add/remove counts only |
|
|
175
|
+
|
|
176
|
+
Pick based on sensitivity; higher privacy may reduce stylistic richness.
|
|
139
177
|
|
|
140
178
|
## Configuration (.aiccrc)
|
|
141
179
|
|
|
142
|
-
|
|
180
|
+
Resolves via cosmiconfig (JSON/YAML/etc). Example:
|
|
143
181
|
|
|
144
182
|
```json
|
|
145
183
|
{
|
|
@@ -147,32 +185,20 @@ Uses cosmiconfig; supports JSON, YAML, etc. Example:
|
|
|
147
185
|
"privacy": "low",
|
|
148
186
|
"gitmoji": true,
|
|
149
187
|
"gitmojiMode": "gitmoji",
|
|
150
|
-
|
|
151
188
|
"styleSamples": 120,
|
|
152
189
|
"plugins": ["./src/sample-plugin/example-plugin.ts"],
|
|
153
190
|
"maxTokens": 512
|
|
154
191
|
}
|
|
155
192
|
```
|
|
156
193
|
|
|
157
|
-
|
|
194
|
+
Environment overrides (prefix `AICC_`):
|
|
195
|
+
`MODEL`, `PRIVACY`, `STYLE_SAMPLES`, `GITMOJI`, `MAX_TOKENS`, `VERBOSE`, `MODEL_TIMEOUT_MS`, `DEBUG`, `PRINT_LOGS`, `DEBUG_PROVIDER=mock`.
|
|
158
196
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
- `AICC_MODEL`
|
|
162
|
-
- `AICC_PRIVACY`
|
|
163
|
-
- `AICC_STYLE_SAMPLES`
|
|
164
|
-
- `AICC_GITMOJI` ("true")
|
|
165
|
-
- `AICC_MAX_TOKENS`
|
|
166
|
-
- `AICC_VERBOSE`
|
|
167
|
-
- `AICC_MODEL_TIMEOUT_MS`
|
|
168
|
-
- `AICC_DEBUG` (provider debug logs)
|
|
169
|
-
- `AICC_PRINT_LOGS` (stream model raw output)
|
|
170
|
-
- `AICC_DEBUG_PROVIDER=mock` (deterministic JSON response)
|
|
171
|
-
|
|
172
|
-
## Conventional Commits Enforcement
|
|
197
|
+
## Refinement Workflow
|
|
173
198
|
|
|
174
|
-
|
|
175
|
-
|
|
199
|
+
1. Generate (`ai-conventional-commit` or `split`) – session cached under `.git/.aicc-cache/last-session.json`.
|
|
200
|
+
2. Run `refine` with flags (`--shorter`, `--longer`, `--scope=ui`, `--emoji`).
|
|
201
|
+
3. Accept or reject; refined output does _not_ auto‑amend history until you use it.
|
|
176
202
|
|
|
177
203
|
## Plugin API
|
|
178
204
|
|
|
@@ -194,25 +220,29 @@ interface Plugin {
|
|
|
194
220
|
}
|
|
195
221
|
```
|
|
196
222
|
|
|
197
|
-
Register via `plugins` array.
|
|
223
|
+
Register via `plugins` array. `transform` runs once over the candidate list; `validate` runs per chosen candidate before commit.
|
|
198
224
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
1. Generate (`ai-conventional-commit` or `ai-conventional-commit split`) – session stored.
|
|
202
|
-
2. Run `ai-conventional-commit refine` with flags (`--shorter`, `--longer`, `--scope=ui`, `--emoji`).
|
|
203
|
-
3. Accept or reject refined candidate (does not auto-amend existing git history; just updates session cache for subsequent refinement or manual use).
|
|
204
|
-
|
|
205
|
-
## Testing & Mocking
|
|
225
|
+
### Example Plugin (lightweight scope normalizer)
|
|
206
226
|
|
|
207
|
-
|
|
227
|
+
```ts
|
|
228
|
+
export default {
|
|
229
|
+
name: 'scope-normalizer',
|
|
230
|
+
transformCandidates(cands) {
|
|
231
|
+
return cands.map((c) => ({
|
|
232
|
+
...c,
|
|
233
|
+
title: c.title.replace('(UI)', '(ui)'),
|
|
234
|
+
}));
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
```
|
|
208
238
|
|
|
209
239
|
## Title Formatting Helper
|
|
210
240
|
|
|
211
|
-
All gitmoji + normalization logic
|
|
241
|
+
All gitmoji + normalization logic: `src/title-format.ts` (`formatCommitTitle`). Tested in `test/title-format.test.ts`.
|
|
212
242
|
|
|
213
243
|
## Security
|
|
214
244
|
|
|
215
|
-
Lightweight heuristic secret scan
|
|
245
|
+
Lightweight heuristic secret scan of commit body (add/removed lines) – not a substitute for dedicated scanners (e.g. gitleaks). Pair with your existing pipelines.
|
|
216
246
|
|
|
217
247
|
## Roadmap Ideas
|
|
218
248
|
|
|
@@ -229,7 +259,7 @@ PRs welcome. Please:
|
|
|
229
259
|
|
|
230
260
|
- Keep dependencies minimal
|
|
231
261
|
- Add tests for new formatting or parsing logic
|
|
232
|
-
- Feature
|
|
262
|
+
- Feature‑flag experimental behavior
|
|
233
263
|
|
|
234
264
|
## License
|
|
235
265
|
|
package/dist/index.js
CHANGED
|
@@ -596,6 +596,7 @@ function sectionTitle(label) {
|
|
|
596
596
|
}
|
|
597
597
|
function abortMessage() {
|
|
598
598
|
console.log("\u2514 \u{1F645}\u200D\u2640\uFE0F No commit created.");
|
|
599
|
+
console.log();
|
|
599
600
|
}
|
|
600
601
|
function finalSuccess(opts) {
|
|
601
602
|
const elapsedMs = Date.now() - opts.startedAt;
|
|
@@ -604,6 +605,7 @@ function finalSuccess(opts) {
|
|
|
604
605
|
const plural = opts.count !== 1;
|
|
605
606
|
if (plural) console.log(`\u2514 \u2728 ${opts.count} commits created in ${dur}.`);
|
|
606
607
|
else console.log(`\u2514 \u2728 commit created in ${dur}.`);
|
|
608
|
+
console.log();
|
|
607
609
|
}
|
|
608
610
|
function createPhasedSpinner(oraLib) {
|
|
609
611
|
const useAnim = process.stdout.isTTY && !process.env.AICC_NO_ANIMATION && !process.env.AICC_NO_SPINNER_ANIM;
|
|
@@ -1134,7 +1136,7 @@ async function loadConfig(cwd = process.cwd()) {
|
|
|
1134
1136
|
// package.json
|
|
1135
1137
|
var package_default = {
|
|
1136
1138
|
name: "@kud/ai-conventional-commit-cli",
|
|
1137
|
-
version: "0.4.
|
|
1139
|
+
version: "0.4.3",
|
|
1138
1140
|
type: "module",
|
|
1139
1141
|
description: "Opinionated, style-aware AI assistant for crafting and splitting git commits (opencode-based, provider-agnostic).",
|
|
1140
1142
|
bin: {
|
package/package.json
CHANGED