Skip to content

Commit c45923f

Browse files
committed
refactor: update CLI command structure to use 'generate' subcommand
- Change commitment invocation from `commitment --message-only` to `commitment generate --message-only` across all documentation and examples - Update hook scripts in git-hooks, husky, lefthook, lint-staged, and simple-git-hooks examples - Enhance lefthook and lint-staged examples with detailed commit message validation and formatting steps - Update init.ts to reflect new command structure in generated hooks - Update CHANGELOG.md and all documentation (CLI.md, HOOKS.md) to reflect new command syntax - Maintain backward compatibility with $2 parameter check for preserving user-specified messages 🤖 Generated with Claude via commitment
1 parent ab92345 commit c45923f

17 files changed

Lines changed: 170 additions & 62 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ If you previously used `--no-ai`:
3030
npx commitment --no-ai --message-only > "$1"
3131

3232
# After
33-
npx commitment --message-only > "$1"
33+
npx commitment generate --message-only > "$1"
3434
```
3535

3636
**Why This Change?**

docs/CLI.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Output only the commit message to stdout (no decorations, no commit).
9393
- **Default**: `false`
9494
- **Example**:
9595
```bash
96-
npx commitment --message-only
96+
npx commitment generate --message-only
9797
```
9898

9999
**Use Cases:**
@@ -103,7 +103,7 @@ Output only the commit message to stdout (no decorations, no commit).
103103

104104
**Output:**
105105
```bash
106-
$ npx commitment --message-only
106+
$ npx commitment generate --message-only
107107
feat: add user authentication
108108

109109
- Implement JWT token generation
@@ -223,7 +223,7 @@ Creates `.husky/prepare-commit-msg`:
223223
#!/bin/sh
224224
# commitment: AI-powered commit messages
225225
if [ -z "$2" ]; then
226-
exec < /dev/tty && npx commitment --message-only > "$1" || exit 1
226+
exec < /dev/tty && npx commitment generate --message-only > "$1" || exit 1
227227
fi
228228
```
229229

@@ -234,7 +234,7 @@ Updates `package.json`:
234234
```json
235235
{
236236
"simple-git-hooks": {
237-
"prepare-commit-msg": "[ -z \"$2\" ] && npx commitment --message-only > $1"
237+
"prepare-commit-msg": "[ -z \"$2\" ] && npx commitment generate --message-only > $1"
238238
}
239239
}
240240
```
@@ -247,7 +247,7 @@ Creates `.git/hooks/prepare-commit-msg`:
247247
#!/bin/sh
248248
# commitment: AI-powered commit messages
249249
if [ -z "$2" ]; then
250-
npx commitment --message-only > "$1" || exit 1
250+
npx commitment generate --message-only > "$1" || exit 1
251251
fi
252252
```
253253

docs/HOOKS.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ npx husky add .husky/prepare-commit-msg
133133
# commitment: AI-powered commit messages
134134
# Only run for regular commits (not merge, squash, or when message specified)
135135
if [ -z "$2" ]; then
136-
exec < /dev/tty && npx commitment --message-only > "$1" || exit 1
136+
exec < /dev/tty && npx commitment generate --message-only > "$1" || exit 1
137137
fi
138138
```
139139

@@ -196,7 +196,7 @@ npm install -D simple-git-hooks
196196
"prepare": "simple-git-hooks"
197197
},
198198
"simple-git-hooks": {
199-
"prepare-commit-msg": "[ -z \"$2\" ] && npx commitment --message-only > $1"
199+
"prepare-commit-msg": "[ -z \"$2\" ] && npx commitment generate --message-only > $1"
200200
}
201201
}
202202
```
@@ -213,13 +213,13 @@ npx simple-git-hooks
213213

214214
The hook is a one-liner shell command:
215215
```bash
216-
[ -z "$2" ] && npx commitment --message-only > $1
216+
[ -z "$2" ] && npx commitment generate --message-only > $1
217217
```
218218

219219
**Breakdown:**
220220
- `[ -z "$2" ]` - Check if `$2` (commit source) is empty
221221
- `&&` - If true (regular commit), run commitment
222-
- `npx commitment --message-only` - Generate message
222+
- `npx commitment generate --message-only` - Generate message
223223
- `> $1` - Write to commit message file
224224

225225
### Plain Git Hooks
@@ -253,7 +253,7 @@ chmod +x .git/hooks/prepare-commit-msg
253253
# commitment: AI-powered commit messages
254254
# Only run for regular commits (not merge, squash, or when message specified)
255255
if [ -z "$2" ]; then
256-
npx commitment --message-only > "$1" || exit 1
256+
npx commitment generate --message-only > "$1" || exit 1
257257
fi
258258
```
259259

@@ -315,7 +315,7 @@ The hook uses git's `$2` parameter (commit source) to decide whether to generate
315315
```bash
316316
if [ -z "$2" ]; then
317317
# $2 is empty → regular commit → generate
318-
npx commitment --message-only > "$1"
318+
npx commitment generate --message-only > "$1"
319319
fi
320320
```
321321

@@ -377,7 +377,7 @@ fi
377377

378378
# Otherwise generate AI message
379379
if [ -z "$2" ]; then
380-
exec < /dev/tty && npx commitment --message-only > "$1" || exit 1
380+
exec < /dev/tty && npx commitment generate --message-only > "$1" || exit 1
381381
fi
382382
```
383383

@@ -389,7 +389,7 @@ fi
389389

390390
if [ -z "$2" ]; then
391391
# Generate message, fail commit if AI fails
392-
npx commitment --message-only > "$1"
392+
npx commitment generate --message-only > "$1"
393393

394394
if [ $? -ne 0 ]; then
395395
echo "❌ Failed to generate commit message"
@@ -406,7 +406,7 @@ fi
406406

407407
if [ -z "$2" ]; then
408408
# Try AI generation
409-
if ! npx commitment --message-only > "$1" 2>/dev/null; then
409+
if ! npx commitment generate --message-only > "$1" 2>/dev/null; then
410410
# If AI fails, use template
411411
cat > "$1" << EOF
412412
feat:
@@ -440,7 +440,7 @@ Add timeout to prevent hanging:
440440

441441
if [ -z "$2" ]; then
442442
# 30 second timeout
443-
timeout 30 npx commitment --message-only > "$1" || exit 1
443+
timeout 30 npx commitment generate --message-only > "$1" || exit 1
444444
fi
445445
```
446446

@@ -460,7 +460,7 @@ if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "master" ]; then
460460
fi
461461

462462
if [ -z "$2" ]; then
463-
exec < /dev/tty && npx commitment --message-only > "$1" || exit 1
463+
exec < /dev/tty && npx commitment generate --message-only > "$1" || exit 1
464464
fi
465465
```
466466

@@ -474,7 +474,7 @@ fi
474474
if git diff --cached --name-only | grep -v "\.md$" > /dev/null; then
475475
# Has non-markdown changes, use AI
476476
if [ -z "$2" ]; then
477-
exec < /dev/tty && npx commitment --message-only > "$1" || exit 1
477+
exec < /dev/tty && npx commitment generate --message-only > "$1" || exit 1
478478
fi
479479
else
480480
# Only markdown changes, use simple message
@@ -576,7 +576,7 @@ cat .husky/prepare-commit-msg
576576
Should have `if [ -z "$2" ]` check:
577577
```bash
578578
if [ -z "$2" ]; then
579-
npx commitment --message-only > "$1"
579+
npx commitment generate --message-only > "$1"
580580
fi
581581
```
582582

@@ -612,7 +612,7 @@ if [ -n "$CI" ]; then
612612
fi
613613

614614
if [ -z "$2" ]; then
615-
exec < /dev/tty && npx commitment --message-only > "$1" || exit 1
615+
exec < /dev/tty && npx commitment generate --message-only > "$1" || exit 1
616616
fi
617617
```
618618

@@ -705,7 +705,7 @@ npm run lint-staged
705705

706706
# commitment integration
707707
if [ -z "$2" ]; then
708-
exec < /dev/tty && npx commitment --message-only > "$1" || exit 1
708+
exec < /dev/tty && npx commitment generate --message-only > "$1" || exit 1
709709
fi
710710
```
711711

@@ -741,7 +741,7 @@ Provide template for when AI fails:
741741
# .husky/prepare-commit-msg
742742

743743
if [ -z "$2" ]; then
744-
if ! exec < /dev/tty npx commitment --message-only > "$1" 2>/dev/null; then
744+
if ! exec < /dev/tty npx commitment generate --message-only > "$1" 2>/dev/null; then
745745
# AI failed, use template
746746
cat > "$1" << 'EOF'
747747
# Enter commit message following Conventional Commits:
@@ -787,7 +787,7 @@ echo "[$(date)] prepare-commit-msg started" >> "$LOG_FILE"
787787
echo " Args: $*" >> "$LOG_FILE"
788788

789789
if [ -z "$2" ]; then
790-
if exec < /dev/tty npx commitment --message-only > "$1" 2>> "$LOG_FILE"; then
790+
if exec < /dev/tty npx commitment generate --message-only > "$1" 2>> "$LOG_FILE"; then
791791
echo " Result: Success" >> "$LOG_FILE"
792792
else
793793
echo " Result: Failed ($?)" >> "$LOG_FILE"

docs/constitutions/v3/architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ lefthook.yml text eol=lf
626626
```bash
627627
# Only run for regular commits (not merge, squash, or when message specified)
628628
if [ -z "$2" ]; then
629-
npx commitment --message-only > "$1"
629+
npx commitment generate --message-only > "$1"
630630
fi
631631
```
632632

docs/constitutions/v3/patterns.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,12 @@ async function initCommand(options: InitOptions): Promise<void> {
373373
#!/bin/sh
374374
# Only run for regular commits (not merge, squash, or when message specified)
375375
if [ -z "$2" ]; then
376-
npx commitment --message-only > "$1"
376+
npx commitment generate --message-only > "$1"
377377
fi
378378

379379
❌ Wrong:
380380
#!/bin/sh
381-
npx commitment --message-only > "$1" # ❌ Overrides user messages!
381+
npx commitment generate --message-only > "$1" # ❌ Overrides user messages!
382382
```
383383

384384
**Why:** `$2` contains commit source:

examples/git-hooks/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cat > .git/hooks/prepare-commit-msg << 'EOF'
4343
#!/bin/sh
4444
# Only run for regular commits
4545
if [ -z "$2" ]; then
46-
npx commitment --message-only > "$1" || true
46+
npx commitment generate --message-only > "$1" || true
4747
fi
4848
EOF
4949

@@ -100,7 +100,7 @@ You can combine multiple prepare-commit-msg behaviors:
100100
# Only run for regular commits
101101
if [ -z "$2" ]; then
102102
# Generate AI commit message
103-
npx commitment --message-only > "$1" || true
103+
npx commitment generate --message-only > "$1" || true
104104

105105
# Add issue number from branch name
106106
BRANCH_NAME=$(git symbolic-ref --short HEAD)
@@ -123,7 +123,7 @@ BRANCH_NAME=$(git symbolic-ref --short HEAD)
123123

124124
# Only generate for feature branches
125125
if [[ $BRANCH_NAME == feature/* ]] && [ -z "$2" ]; then
126-
npx commitment --message-only > "$1" || true
126+
npx commitment generate --message-only > "$1" || true
127127
fi
128128
```
129129

examples/git-hooks/prepare-commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
# Only run for regular commits
66
if [ -z "$2" ]; then
7-
npx commitment --message-only > "$1" || true
7+
npx commitment generate --message-only > "$1" || true
88
fi

examples/global-install/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ cat > .git/hooks/prepare-commit-msg << 'EOF'
6262
#!/bin/sh
6363
# Generate commit message with commitment (global install)
6464
if [ -z "$2" ]; then
65-
commitment --message-only > "$1" || true
65+
commitment generate --message-only > "$1" || true
6666
fi
6767
EOF
6868

@@ -204,7 +204,7 @@ mkdir -p ~/.git-templates/hooks
204204
cat > ~/.git-templates/hooks/prepare-commit-msg << 'EOF'
205205
#!/bin/sh
206206
if [ -z "$2" ]; then
207-
commitment --message-only > "$1" || true
207+
commitment generate --message-only > "$1" || true
208208
fi
209209
EOF
210210

examples/husky/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ cat > .husky/prepare-commit-msg << 'EOF'
5252
#!/bin/sh
5353
# Generate commit message with AI
5454
if [ -z "$2" ]; then
55-
exec < /dev/tty && npx commitment --message-only > "$1" || true
55+
exec < /dev/tty && npx commitment generate --message-only > "$1" || true
5656
fi
5757
EOF
5858

examples/husky/prepare-commit-msg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
# Only run for regular commits (not merge, squash, etc.)
66
if [ -z "$2" ]; then
7-
exec < /dev/tty && npx commitment --message-only > "$1" || true
7+
exec < /dev/tty && npx commitment generate --message-only > "$1" || true
88
fi

0 commit comments

Comments
 (0)