@kud/ai-conventional-commit-cli 0.4.0 → 0.4.2

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.
Files changed (3) hide show
  1. package/README.md +146 -116
  2. package/dist/index.js +10 -2
  3. package/package.json +10 -2
package/README.md CHANGED
@@ -1,145 +1,183 @@
1
1
  # ai-conventional-commit
2
2
 
3
- Opinionated, style-aware AI assistant for crafting, splitting, and refining git commit messages via the local `opencode` CLI. Uses your installed `opencode` models (default `github-copilot/gpt-5`).
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 often miss context. ai-conventional-commit inspects your staged diff, learns your repo's commit style, and produces Conventional Commit messages (single or split) with explanations—optionally decorated with gitmoji.
41
+ Manual commit messages are often noisy, inconsistent, and context‑poor. This tool:
8
42
 
9
- ## Key Features
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
- - Style fingerprinting (average title length, scope usage ratio, gitmoji ratio, top prefixes)
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
- - Privacy tiers governing diff detail sent to model
17
- - Title normalization + guardrails (length, conventional schema, secret heuristic)
18
- - Plugin system (transform + validate phases)
19
- - Session persistence for later refinement (`.git/.aicc-cache/last-session.json`)
20
- - Deterministic mock provider mode for tests / CI
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 (Dev)
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
- ### Optional Alias (Short Name)
33
-
34
- If you prefer a shorter alias, add this to your shell profile:
70
+ Local + npx:
35
71
 
36
72
  ```bash
37
- alias aicc='ai-conventional-commit'
73
+ npm install --save-dev @kud/ai-conventional-commit-cli
74
+ npx ai-conventional-commit --help
38
75
  ```
39
76
 
40
- ## Publishing
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 publish
80
+ npm install
81
+ npm run build
82
+ npm link
83
+ ai-conventional-commit --help
46
84
  ```
47
85
 
48
- Only `dist`, `README.md`, and `LICENSE` are included in the published package (see the `files` field). If you need to test the packaging result first:
86
+ Optional shell alias:
49
87
 
50
88
  ```bash
51
- npm publish --dry-run
89
+ alias aicc='ai-conventional-commit'
52
90
  ```
53
91
 
54
92
  ## Quick Start
55
93
 
56
94
  ```bash
57
- # Stage your changes
95
+ # Stage changes
58
96
  git add .
97
+
59
98
  # Generate a single commit suggestion
60
99
  ai-conventional-commit
61
- # Multi-commit proposal (interactive confirm)
100
+
101
+ # Propose multiple commits (interactive confirm + real selective staging)
62
102
  ai-conventional-commit split
63
- # Use gitmoji with emoji+type form
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 sessions first commit making it shorter
110
+ # Refine previous session's first commit (shorter wording)
70
111
  ai-conventional-commit refine --shorter
71
112
  ```
72
113
 
73
- ## Timed Output
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
- Final success lines now include count + duration, e.g.:
141
+ ### Split Workflow (illustrative)
76
142
 
77
143
  ```
78
- commit created in 850ms.
79
- 3 commits created in 2.4s.
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
- Durations under 100ms show raw milliseconds; otherwise one decimal second precision.
149
+ Each proposed commit is _actually_ staged & committed with only its files.
83
150
 
84
- ## Commands
151
+ ### Refinement
85
152
 
86
- | Command | Purpose |
87
- | --------------------------------- | ------------------------------------------- |
88
- | `ai-conventional-commit` | Generate single commit suggestion (default) |
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 | Example | Notes |
125
- | ------------------ | ------------------------- | ------------------------------------ |
126
- | standard (default) | `feat: add search box` | No emoji decoration |
127
- | gitmoji | `✨ feat: add search box` | Emoji + conventional type retained |
128
- | gitmoji-pure | `✨: add search box` | Type removed, emoji acts as category |
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 (`--gitmoji` or `--gitmoji-pure`, shorthand `--gitmoji[-pure]`) or config (`gitmoji: true`, `gitmojiMode`).
166
+ Enable via CLI flags or config (`gitmoji: true`, `gitmojiMode`).
131
167
 
132
168
  ## Privacy Modes
133
169
 
134
- | Mode | Data Sent to Model |
135
- | ------ | --------------------------------------------------------------------- |
136
- | low | Hunk headers + first 40 changed/context lines per hunk (may truncate) |
137
- | medium | File + hunk hash + line counts + function context only |
138
- | high | File names with aggregate add/remove counts only |
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
- Uses cosmiconfig; supports JSON, YAML, etc. Example:
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
- ### Environment Overrides
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
- (Note: Environment variable prefix remains `AICC_` for backward compatibility.)
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
- Types: feat, fix, chore, docs, refactor, test, ci, perf, style, build, revert, merge, security, release.
175
- Malformed titles are auto-normalized (fallback to `chore:`) before gitmoji formatting.
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. Transform runs once on candidate list; validate runs per chosen candidate before commit.
223
+ Register via `plugins` array. `transform` runs once over the candidate list; `validate` runs per chosen candidate before commit.
198
224
 
199
- ## Refinement Workflow
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
- Use `AICC_DEBUG_PROVIDER=mock` to bypass model invocation and get a deterministic single commit JSON payload for faster tests / CI.
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 centralized in `src/title-format.ts` (`formatCommitTitle`). Ensures consistent application across generate, split, and refine flows; tests in `test/title-format.test.ts`.
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 on body; pair with a dedicated scanner (e.g., gitleaks) for stronger assurance.
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-flag experimental behavior
262
+ - Featureflag experimental behavior
233
263
 
234
264
  ## License
235
265
 
package/dist/index.js CHANGED
@@ -1134,7 +1134,7 @@ async function loadConfig(cwd = process.cwd()) {
1134
1134
  // package.json
1135
1135
  var package_default = {
1136
1136
  name: "@kud/ai-conventional-commit-cli",
1137
- version: "0.4.0",
1137
+ version: "0.4.2",
1138
1138
  type: "module",
1139
1139
  description: "Opinionated, style-aware AI assistant for crafting and splitting git commits (opencode-based, provider-agnostic).",
1140
1140
  bin: {
@@ -1192,7 +1192,15 @@ var package_default = {
1192
1192
  engines: {
1193
1193
  node: ">=18.17"
1194
1194
  },
1195
- license: "MIT"
1195
+ license: "MIT",
1196
+ repository: {
1197
+ type: "git",
1198
+ url: "git+https://github.com/kud/ai-conventional-commit-cli.git"
1199
+ },
1200
+ bugs: {
1201
+ url: "https://github.com/kud/ai-conventional-commit-cli/issues"
1202
+ },
1203
+ homepage: "https://github.com/kud/ai-conventional-commit-cli#readme"
1196
1204
  };
1197
1205
 
1198
1206
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kud/ai-conventional-commit-cli",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "Opinionated, style-aware AI assistant for crafting and splitting git commits (opencode-based, provider-agnostic).",
6
6
  "bin": {
@@ -58,5 +58,13 @@
58
58
  "engines": {
59
59
  "node": ">=18.17"
60
60
  },
61
- "license": "MIT"
61
+ "license": "MIT",
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/kud/ai-conventional-commit-cli.git"
65
+ },
66
+ "bugs": {
67
+ "url": "https://github.com/kud/ai-conventional-commit-cli/issues"
68
+ },
69
+ "homepage": "https://github.com/kud/ai-conventional-commit-cli#readme"
62
70
  }