Skip to content

Commit 7d41fdc

Browse files
"docs: Update project documentation"
1 parent 14825ba commit 7d41fdc

File tree

2 files changed

+61
-37
lines changed

2 files changed

+61
-37
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,10 @@ pnpm dlx 'KartikLabhshetwar/lazycommit#npm/develop'
246246
### Key files
247247

248248
- `src/cli.ts` - Main CLI entry point using cleye
249-
- `src/commands/lazycommit.ts` - Core commit message generation logic
250-
- `src/utils/groq.ts` - Groq API integration
249+
- `src/commands/lazycommit.ts` - Core commit message generation with smart grouping logic
250+
- `src/utils/groq.ts` - Groq API integration with retry/fallback mechanisms
251251
- `src/utils/config.ts` - Configuration management
252+
- `src/utils/git.ts` - Git operations and file analysis utilities
252253
- `package.json` - Project configuration and dependencies
253254
- `tsconfig.json` - TypeScript configuration
254255

@@ -268,6 +269,14 @@ pnpm dlx 'KartikLabhshetwar/lazycommit#npm/develop'
268269
3. Adding Node.js hashbang for executable
269270
4. Output to `dist/cli.mjs`
270271

272+
### Architecture highlights
273+
274+
- **Smart file grouping**: Automatically groups files by conventional commit types and scopes
275+
- **Token-safe AI integration**: Uses compact git summaries instead of full diffs to avoid rate limits
276+
- **Retry mechanisms**: Exponential backoff and model fallback for robust API handling
277+
- **Multi-commit workflow**: Creates logical, atomic commits for large changes
278+
- **Enhanced file classification**: Context-aware file type detection using git patterns
279+
271280
## Getting help
272281

273282
- Check existing [Issues](https://github.com/KartikLabhshetwar/lazycommit/issues)

README.md

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,33 @@ You can exclude specific files from AI analysis using the `--exclude` flag:
109109
lazycommit --exclude package-lock.json --exclude dist/
110110
```
111111

112+
#### Automatic multi-commit mode
113+
114+
When you stage many files, `lazycommit` can automatically split your changes into logical groups and create multiple commits with proper Conventional Commit messages.
115+
116+
- Auto-trigger: when staged files ≥ 5, or when the diff is large
117+
- Grouping: buckets by type/scope (e.g., `feat(api)`, `docs`, `ci`, `build`, `test`, `chore`)
118+
- Deep split: if everything falls into one big bucket (e.g., `app/api/*`), it auto-splits by second-level directory (like `analytics`, `projects`, `sessions`)
119+
- Token-safe AI: each group uses a compact `git diff --cached --numstat` summary (not full diffs) to generate the commit line
120+
121+
Usage:
122+
123+
```sh
124+
# Just run as usual; grouping triggers automatically when applicable
125+
lazycommit
126+
127+
# Force grouping even for < 5 files
128+
lazycommit --split
129+
```
130+
112131
#### Handling large diffs
113132

114-
For large commits with many files, lazycommit automatically stays within API limits:
133+
For large commits with many files, lazycommit automatically stays within API limits and maintains clean history:
115134

116-
- **Automatic detection**: Large diffs are detected
117-
- **Per-file splitting**: Diffs are split by file first
118-
- **Safe chunking**: Each file diff is chunked conservatively (default: 4000 tokens)
119-
- **Combination**: Results are combined into one concise message
135+
- **Automatic detection**: Large diffs and many-file changes are detected
136+
- **Logical grouping**: Files are grouped into conventional buckets; single huge buckets are auto-split by second-level directory (e.g., `app/api/<group>/...`)
137+
- **Token-safe summaries**: Each group sends a small `--numstat` summary to AI instead of full diffs
138+
- **Sequential commits**: In multi-commit mode, groups are committed one-by-one with their own messages
120139

121140
### Git hook
122141

@@ -229,7 +248,14 @@ lazycommit config set proxy=
229248

230249
#### model
231250

232-
Default: `openai/gpt-oss-120b`
251+
Default: `llama-3.1-8b-instant`
252+
253+
The Groq model to use for generating commit messages. Available models include:
254+
- `llama-3.1-8b-instant` (default) - Fast, efficient for conventional commits
255+
- `llama-3.1-70b-versatile` - More detailed but slower
256+
- `llama-3.1-120b-versatile` - Most capable but slowest
257+
258+
For conventional commit generation, the 8B instant model provides the best balance of speed and quality.
233259

234260
#### timeout
235261

@@ -267,17 +293,6 @@ You can clear this option by setting it to an empty string:
267293
lazycommit config set type=
268294
```
269295

270-
#### chunk-size
271-
272-
Default: `4000`
273-
274-
The maximum number of tokens per chunk when processing large diffs. This helps avoid API limits and keeps requests fast:
275-
276-
```sh
277-
lazycommit config set chunk-size 4000
278-
```
279-
280-
**Note**: Must be between 1000-8000 tokens (Groq API limit).
281296

282297
## How it works
283298

@@ -289,12 +304,13 @@ The tool uses Groq's fast inference API to provide quick and accurate commit mes
289304

290305
For large commits that exceed API token limits, lazycommit automatically:
291306

292-
1. **Splits by file** to avoid oversized requests
293-
2. **Chunks each file** into manageable pieces (default: 4000 tokens)
294-
3. **Processes chunks** and combines results into a single message
295-
4. **Falls back gracefully** to a high-level summary if needed
307+
1. **Detects large/many-file diffs** and switches to a scalable flow
308+
2. **Groups files** by conventional type/scope; if only one large bucket remains, **auto-splits by second-level directory** (e.g., `app/api/<group>/...`)
309+
3. **Generates messages per group** using compact `git diff --cached --numstat` summaries (not full diffs)
310+
4. **Commits sequentially** per group with clear, conventional messages
311+
5. When a single commit is requested, **uses compact summaries** to generate conventional messages efficiently
296312

297-
This ensures you can commit large changes (like new features, refactoring, or initial project setup) without hitting API limits.
313+
This ensures you can commit large changes (like new features, refactoring, or initial project setup) without hitting API limits, while keeping a clean history.
298314

299315
## Troubleshooting
300316

@@ -307,17 +323,12 @@ If you get a 413 error, your diff is too large for the API. Try these solutions:
307323
lazycommit --exclude "dist/**" --exclude "node_modules/**" --exclude ".next/**"
308324
```
309325

310-
2. **Reduce chunk size**:
311-
```sh
312-
lazycommit config set chunk-size 4000
313-
```
314-
315-
3. **Use a different model**:
326+
2. **Use a different model**:
316327
```sh
317328
lazycommit config set model "llama-3.1-70b-versatile"
318329
```
319330

320-
4. **Commit in smaller batches**:
331+
3. **Commit in smaller batches**:
321332
```sh
322333
git add src/ # Stage only source files
323334
lazycommit
@@ -329,19 +340,23 @@ If you get a 413 error, your diff is too large for the API. Try these solutions:
329340

330341
- Check your API key: `lazycommit config get GROQ_API_KEY`
331342
- Verify you have staged changes: `git status`
332-
- Try reducing chunk size or excluding large files
343+
- Try excluding large files or using a different model
333344

334345
### Slow performance with large diffs
335346

336-
- Reduce chunk size: `lazycommit config set chunk-size 4000`
347+
- **Use the 8B instant model** (default): `lazycommit config set model "llama-3.1-8b-instant"`
337348
- Exclude unnecessary files: `lazycommit --exclude "*.log" --exclude "*.tmp"`
349+
- Use automatic multi-commit mode to split large changes into logical groups
350+
- Lower generate count: `lazycommit config set generate=1` (default)
351+
- Reduce timeout: `lazycommit config set timeout=5000` for faster failures
338352

339353
## Why Groq?
340354

341-
- **Fast**: Groq provides ultra-fast inference speeds
342-
- **Cost-effective**: More affordable than traditional AI APIs
343-
- **Open source models**: Uses leading open-source language models
344-
- **Reliable**: High uptime and consistent performance
355+
- **Fast**: Groq provides ultra-fast inference speeds, especially with the 8B instant model
356+
- **Cost-effective**: More affordable than traditional AI APIs
357+
- **Open source models**: Uses leading open-source language models
358+
- **Reliable**: High uptime and consistent performance
359+
- **Optimized for commits**: The 8B instant model is perfectly sized for conventional commit generation
345360

346361
## Maintainers
347362

0 commit comments

Comments
 (0)