@kud/ai-conventional-commit-cli 0.2.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/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ ...
7
+ (Complete MIT text—add your name and year.)
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # ai-conventional-commit
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`).
4
+
5
+ Formerly referenced as `aicc` in examples. The canonical command name is now `ai-conventional-commit`.
6
+
7
+ ## Why
8
+
9
+ 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.
10
+
11
+ ## Key Features
12
+
13
+ - Style fingerprinting (average title length, scope usage ratio, gitmoji ratio, top prefixes)
14
+ - Single (`ai-conventional-commit` / `ai-conventional-commit generate`) or multi-commit planning (`ai-conventional-commit split`)
15
+ - Refinement workflow (`ai-conventional-commit refine`) to iteratively tweak a prior result
16
+ - Gitmoji modes: `--gitmoji` (emoji + type) and `--gitmoji-pure` (emoji only)
17
+ - Reasoning depth control (`--reasoning low|medium|high`) influences explanation verbosity
18
+ - Privacy tiers governing diff detail sent to model
19
+ - Title normalization + guardrails (length, conventional schema, secret heuristic)
20
+ - Plugin system (transform + validate phases)
21
+ - Session persistence for later refinement (`.git/.aicc-cache/last-session.json`)
22
+ - Deterministic mock provider mode for tests / CI
23
+
24
+ ## Install (Dev)
25
+
26
+ ```bash
27
+ npm install
28
+ npm run build
29
+ npm link
30
+ # then
31
+ ai-conventional-commit --help
32
+ ```
33
+
34
+ ### Optional Alias (Short Name)
35
+
36
+ If you prefer the shorter historical alias, add this to your shell profile:
37
+
38
+ ```bash
39
+ alias aicc='ai-conventional-commit'
40
+ ```
41
+
42
+ After that you can type `aicc` instead of the full command. All subsequent examples use the full name for clarity.
43
+
44
+ ## Publishing
45
+
46
+ A build is automatically produced on `npm publish` via the `prepublishOnly` script so you can simply bump the version and run:
47
+
48
+ ```bash
49
+ npm publish
50
+ ```
51
+
52
+ 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:
53
+
54
+ ```bash
55
+ npm publish --dry-run
56
+ ```
57
+
58
+ The shorter `aicc` binary has been removed from the package itself; create a local alias if you still prefer it.
59
+
60
+ ## Quick Start
61
+
62
+ ```bash
63
+ # Stage your changes
64
+ git add .
65
+ # Generate a single commit suggestion
66
+ ai-conventional-commit
67
+ # Multi-commit proposal (interactive confirm)
68
+ ai-conventional-commit split
69
+ # Use gitmoji with emoji+type form
70
+ ai-conventional-commit --gitmoji
71
+ # Pure gitmoji (emoji: subject)
72
+ ai-conventional-commit --gitmoji-pure
73
+ # Increase reasoning verbosity
74
+ ai-conventional-commit --reasoning=high
75
+ # Refine previous session’s first commit making it shorter
76
+ ai-conventional-commit refine --shorter
77
+ ```
78
+
79
+ ## Gitmoji Modes
80
+
81
+ | Mode | Example | Notes |
82
+ | ------------------ | ------------------------- | ------------------------------------ |
83
+ | standard (default) | `feat: add search box` | No emoji decoration |
84
+ | gitmoji | `✨ feat: add search box` | Emoji + conventional type retained |
85
+ | gitmoji-pure | `✨: add search box` | Type removed, emoji acts as category |
86
+
87
+ Enable via CLI flags (`--gitmoji` / `--gitmoji-pure`) or config (`gitmoji: true`, `gitmojiMode`).
88
+
89
+ ## Reasoning Depth
90
+
91
+ Controls verbosity of reasons array in the JSON returned by the model:
92
+
93
+ - low: minimal
94
+ - medium: balanced
95
+ - high: detailed, more hunk-specific references
96
+
97
+ Configured with `--reasoning` or in config (`reasoning`).
98
+
99
+ ## Privacy Modes
100
+
101
+ | Mode | Data Sent to Model |
102
+ | ------ | --------------------------------------------------------------------- |
103
+ | low | Hunk headers + first 40 changed/context lines per hunk (may truncate) |
104
+ | medium | File + hunk hash + line counts + function context only |
105
+ | high | File names with aggregate add/remove counts only |
106
+
107
+ ## Configuration (.aiccrc)
108
+
109
+ Uses cosmiconfig; supports JSON, YAML, etc. Example:
110
+
111
+ ```json
112
+ {
113
+ "model": "github-copilot/gpt-5",
114
+ "privacy": "low",
115
+ "gitmoji": true,
116
+ "gitmojiMode": "gitmoji",
117
+ "reasoning": "low",
118
+ "styleSamples": 120,
119
+ "plugins": ["./src/sample-plugin/example-plugin.ts"],
120
+ "maxTokens": 512
121
+ }
122
+ ```
123
+
124
+ ### Environment Overrides
125
+
126
+ (Note: Environment variable prefix remains `AICC_` for backward compatibility.)
127
+
128
+ - `AICC_MODEL`
129
+ - `AICC_PRIVACY`
130
+ - `AICC_STYLE_SAMPLES`
131
+ - `AICC_GITMOJI` ("true")
132
+ - `AICC_MAX_TOKENS`
133
+ - `AICC_VERBOSE`
134
+ - `AICC_MODEL_TIMEOUT_MS`
135
+ - `AICC_DEBUG` (provider debug logs)
136
+ - `AICC_PRINT_LOGS` (stream model raw output)
137
+ - `AICC_DEBUG_PROVIDER=mock` (deterministic JSON response)
138
+ - `AICC_REASONING` (low|medium|high)
139
+
140
+ ## Conventional Commits Enforcement
141
+
142
+ Types: feat, fix, chore, docs, refactor, test, ci, perf, style, build, revert, merge, security, release.
143
+ Malformed titles are auto-normalized (fallback to `chore:`) before gitmoji formatting.
144
+
145
+ ## Plugin API
146
+
147
+ ```ts
148
+ interface PluginContext {
149
+ cwd: string;
150
+ env: NodeJS.ProcessEnv;
151
+ }
152
+ interface Plugin {
153
+ name: string;
154
+ transformCandidates?(
155
+ candidates: CommitCandidate[],
156
+ ctx: PluginContext,
157
+ ): CommitCandidate[] | Promise<CommitCandidate[]>;
158
+ validateCandidate?(
159
+ candidate: CommitCandidate,
160
+ ctx: PluginContext,
161
+ ): string | string[] | void | Promise<string | string[] | void>;
162
+ }
163
+ ```
164
+
165
+ Register via `plugins` array. Transform runs once on candidate list; validate runs per chosen candidate before commit.
166
+
167
+ ## Refinement Workflow
168
+
169
+ 1. Generate (`ai-conventional-commit` or `ai-conventional-commit split`) – session stored.
170
+ 2. Run `ai-conventional-commit refine` with flags (`--shorter`, `--longer`, `--scope=ui`, `--emoji`).
171
+ 3. Accept or reject refined candidate (does not auto-amend existing git history; just updates session cache for subsequent refinement or manual use).
172
+
173
+ ## Testing & Mocking
174
+
175
+ Use `AICC_DEBUG_PROVIDER=mock` to bypass model invocation and get a deterministic single commit JSON payload for faster tests / CI.
176
+
177
+ ## Title Formatting Helper
178
+
179
+ 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`.
180
+
181
+ ## Security
182
+
183
+ Lightweight heuristic secret scan on body; pair with a dedicated scanner (e.g., gitleaks) for stronger assurance.
184
+
185
+ ## Roadmap Ideas
186
+
187
+ - Embedding-based semantic clustering
188
+ - Local model (Ollama) fallback
189
+ - Streaming / partial UI updates
190
+ - Commit plan editing (accept subset, re-cluster)
191
+ - Scope inference heuristics
192
+ - Extended secret scanning
193
+
194
+ ## Contributing
195
+
196
+ PRs welcome. Please:
197
+
198
+ - Keep dependencies minimal
199
+ - Add tests for new formatting or parsing logic
200
+ - Feature-flag experimental behavior
201
+
202
+ ## License
203
+
204
+ MIT