aicommit2 2.4.26 → 2.4.27
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 +72 -0
- package/dist/cli.mjs +88 -84
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -376,6 +376,11 @@ aicommit2 --all # or -a
|
|
|
376
376
|
- When enabled, shows detailed log messages including readline errors and other diagnostic information
|
|
377
377
|
- Useful for troubleshooting issues or understanding the tool's internal operations
|
|
378
378
|
- Can also be set via config: `aicommit2 config set logLevel=verbose`
|
|
379
|
+
- `--output` or `-o`: Output format for non-interactive mode (default: **none**)
|
|
380
|
+
- Use `--output json` for JSON Lines format (one JSON object per line)
|
|
381
|
+
- Outputs `{"subject":"...","body":"..."}` for each generated message
|
|
382
|
+
- Designed for integration with tools like [LazyGit](#lazygit-integration)
|
|
383
|
+
- Skips TUI and exits after outputting messages
|
|
379
384
|
|
|
380
385
|
Examples:
|
|
381
386
|
|
|
@@ -396,6 +401,73 @@ aicommit2 -d -c
|
|
|
396
401
|
aicommit2 --verbose # or -v
|
|
397
402
|
```
|
|
398
403
|
|
|
404
|
+
### LazyGit Integration
|
|
405
|
+
|
|
406
|
+
AICommit2 supports non-interactive JSON output mode for seamless integration with [LazyGit](https://github.com/jesseduffield/lazygit).
|
|
407
|
+
|
|
408
|
+
#### Setup
|
|
409
|
+
|
|
410
|
+
Use the `--output json` flag to get AI-generated commit messages in JSON Lines format:
|
|
411
|
+
|
|
412
|
+
```sh
|
|
413
|
+
aicommit2 --output json
|
|
414
|
+
# Output: {"subject":"feat: add user authentication","body":""}
|
|
415
|
+
# Output: {"subject":"fix: resolve login bug","body":"Fixes issue with session handling"}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Each line is a separate JSON object with `subject` and `body` fields, compatible with LazyGit's `menuFromCommand` prompt type.
|
|
419
|
+
|
|
420
|
+
#### LazyGit Configuration
|
|
421
|
+
|
|
422
|
+
Add the following to your LazyGit config file (`~/.config/lazygit/config.yml` or `~/Library/Application Support/lazygit/config.yml` on macOS):
|
|
423
|
+
|
|
424
|
+
```yaml
|
|
425
|
+
customCommands:
|
|
426
|
+
# AI commit with body (Shift+C in files panel)
|
|
427
|
+
- key: "C"
|
|
428
|
+
context: "files"
|
|
429
|
+
description: "AI commit with aicommit2"
|
|
430
|
+
prompts:
|
|
431
|
+
- type: "menuFromCommand"
|
|
432
|
+
title: "Select commit message"
|
|
433
|
+
key: "Commit"
|
|
434
|
+
command: "aicommit2 --output json --include-body"
|
|
435
|
+
filter: '"subject":"(?P<subject>[^"]+)","body":"(?P<body>[^"]*)"'
|
|
436
|
+
valueFormat: '{{ .subject }}<SEP>{{ .body }}'
|
|
437
|
+
labelFormat: '{{ .subject }}'
|
|
438
|
+
command: bash -c 'MSG="{{ .Form.Commit }}" && SUBJ="${MSG%%<SEP>*}" && BODY="${MSG#*<SEP>}" && git commit -m "$SUBJ" ${BODY:+-m "$BODY"}'
|
|
439
|
+
|
|
440
|
+
# AI commit with editable subject and body (Shift+A in files panel)
|
|
441
|
+
- key: "A"
|
|
442
|
+
context: "files"
|
|
443
|
+
description: "AI commit (editable)"
|
|
444
|
+
prompts:
|
|
445
|
+
- type: "menuFromCommand"
|
|
446
|
+
title: "Select commit message"
|
|
447
|
+
key: "Subject"
|
|
448
|
+
command: "aicommit2 --output json"
|
|
449
|
+
filter: '"subject":"(?P<subject>[^"]+)"'
|
|
450
|
+
valueFormat: '{{ .subject }}'
|
|
451
|
+
labelFormat: '{{ .subject }}'
|
|
452
|
+
- type: "input"
|
|
453
|
+
title: "Edit subject"
|
|
454
|
+
key: "FinalSubject"
|
|
455
|
+
initialValue: '{{ .Form.Subject }}'
|
|
456
|
+
- type: "input"
|
|
457
|
+
title: "Add body (optional)"
|
|
458
|
+
key: "Body"
|
|
459
|
+
initialValue: ''
|
|
460
|
+
command: bash -c 'git commit -m "{{ .Form.FinalSubject }}" {{ if .Form.Body }}-m "{{ .Form.Body }}"{{ end }}'
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
#### Usage in LazyGit
|
|
464
|
+
|
|
465
|
+
1. Stage your changes in LazyGit
|
|
466
|
+
2. Press `Shift+C` to generate AI commit messages and select one
|
|
467
|
+
3. Or press `Shift+A` to generate messages with the ability to edit before committing
|
|
468
|
+
|
|
469
|
+
> **Note:** The editable mode (`Shift+A`) currently supports editing the subject only. The AI-generated body is not carried over to the edit prompt.
|
|
470
|
+
|
|
399
471
|
### Git hook
|
|
400
472
|
|
|
401
473
|
You can also integrate _aicommit2_ with Git via the [`prepare-commit-msg`](https://git-scm.com/docs/githooks#_prepare_commit_msg) hook. This lets you use Git like you normally would, and edit the commit message before committing.
|