Skip to content

Commit 74f7fba

Browse files
refactor: enhance lazycommit with prompt integration, update config defaults, README formatting
1 parent 45c2c5a commit 74f7fba

File tree

5 files changed

+245
-375
lines changed

5 files changed

+245
-375
lines changed

README.md

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,8 @@ This feature can be useful if your project follows the Conventional Commits stan
105105

106106
Lazycommit now lets you review the generated message, optionally edit it, and then confirm before it is committed.
107107

108-
- **Single commit**:
109-
- You’ll see a menu: Use as-is, Edit, or Cancel
110-
- If you choose Edit, you can modify the message; then you’ll be asked to confirm the final message before committing
111-
- **Multi-commit**:
112-
- For each group, you can optionally edit the message
113-
- You will then be asked to confirm the final message for that group before it commits
108+
- You'll see a menu: Use as-is, Edit, or Cancel
109+
- If you choose Edit, you can modify the message; then you'll be asked to confirm the final message before committing
114110

115111
Example (single commit):
116112

@@ -130,33 +126,15 @@ You can exclude specific files from AI analysis using the `--exclude` flag:
130126
lazycommit --exclude package-lock.json --exclude dist/
131127
```
132128

133-
#### Automatic multi-commit mode
134-
135-
When you stage many files, `lazycommit` can automatically split your changes into logical groups and create multiple commits with proper Conventional Commit messages.
136-
137-
- Auto-trigger: when staged files ≥ 5, or when the diff is large
138-
- Grouping: buckets by type/scope (e.g., `feat(api)`, `docs`, `ci`, `build`, `test`, `chore`)
139-
- Deep split: if everything falls into one big bucket (e.g., `app/api/*`), it auto-splits by second-level directory (like `analytics`, `projects`, `sessions`)
140-
- Token-safe AI: each group uses a compact `git diff --cached --numstat` summary (not full diffs) to generate the commit line
141-
142-
Usage:
143-
144-
```sh
145-
# Just run as usual; grouping triggers automatically when applicable
146-
lazycommit
147-
148-
# Force grouping even for < 5 files
149-
lazycommit --split
150-
```
151-
152129
#### Handling large diffs
153130

154-
For large commits with many files, lazycommit automatically stays within API limits and maintains clean history:
131+
For large commits with many files, lazycommit automatically stays within API limits and generates relevant commit messages:
155132

156-
- **Automatic detection**: Large diffs and many-file changes are detected
157-
- **Logical grouping**: Files are grouped into conventional buckets; single huge buckets are auto-split by second-level directory (e.g., `app/api/<group>/...`)
158-
- **Token-safe summaries**: Each group sends a small `--numstat` summary to AI instead of full diffs
159-
- **Sequential commits**: In multi-commit mode, groups are committed one-by-one with their own messages
133+
- **Smart summarization**: Uses `git diff --cached --numstat` to create compact summaries of all changes
134+
- **Context snippets**: Includes truncated diff snippets from top changed files for better context
135+
- **Token-safe processing**: Keeps prompts small while maintaining accuracy for 20+ file changes
136+
- **Single commit**: Always generates one commit message, no matter how many files are staged
137+
- **Enhanced analysis**: Uses improved prompts and smart truncation for better commit message quality
160138

161139
### Git hook
162140

@@ -290,10 +268,10 @@ lazycommit config set timeout=20000 # 20s
290268

291269
The maximum character length of the generated commit message.
292270

293-
Default: `50`
271+
Default: `100`
294272

295273
```sh
296-
lazycommit config set max-length=100
274+
lazycommit config set max-length=150
297275
```
298276

299277
#### type
@@ -323,13 +301,14 @@ The tool uses Groq's fast inference API to provide quick and accurate commit mes
323301

324302
For large commits that exceed API token limits, lazycommit automatically:
325303

326-
1. **Detects large/many-file diffs** and switches to a scalable flow
327-
2. **Groups files** by conventional type/scope; if only one large bucket remains, **auto-splits by second-level directory** (e.g., `app/api/<group>/...`)
328-
3. **Generates messages per group** using compact `git diff --cached --numstat` summaries (not full diffs)
329-
4. **Commits sequentially** per group with clear, conventional messages
330-
5. When a single commit is requested, **uses compact summaries** to generate conventional messages efficiently
304+
1. **Detects large/many-file diffs** and switches to enhanced analysis mode
305+
2. **Creates compact summaries** using `git diff --cached --numstat` to capture all changes efficiently
306+
3. **Includes context snippets** from the most changed files to provide semantic context
307+
4. **Generates a single commit message** that accurately reflects all changes without hitting API limits
308+
5. **Smart truncation** preserves sentence structure and meaning when messages approach length limits
309+
6. **Enhanced prompts** provide better context for AI to generate complete, professional commit messages
331310

332-
This ensures you can commit large changes (like new features, refactoring, or initial project setup) without hitting API limits, while keeping a clean history.
311+
This ensures you can commit large changes (like new features, refactoring, or initial project setup) without hitting API limits, while maintaining accuracy, relevance, and high-quality commit messages.
333312

334313
## Troubleshooting
335314

@@ -365,7 +344,7 @@ If you get a 413 error, your diff is too large for the API. Try these solutions:
365344

366345
- **Use the GPT-OSS-20B model** (default): `lazycommit config set model "openai/gpt-oss-20b"`
367346
- Exclude unnecessary files: `lazycommit --exclude "*.log" --exclude "*.tmp"`
368-
- Use automatic multi-commit mode to split large changes into logical groups
347+
- Use the built-in large diff handling for better context and accuracy
369348
- Lower generate count: `lazycommit config set generate=1` (default)
370349
- Reduce timeout: `lazycommit config set timeout=5000` for faster failures
371350

0 commit comments

Comments
 (0)