claude-git-hooks 2.7.1 → 2.8.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/CHANGELOG.md +113 -0
- package/README.md +65 -51
- package/bin/claude-hooks +306 -25
- package/lib/config.js +176 -83
- package/lib/hooks/prepare-commit-msg.js +2 -3
- package/lib/utils/claude-client.js +153 -59
- package/lib/utils/claude-diagnostics.js +50 -6
- package/package.json +1 -1
- package/templates/config.advanced.example.json +113 -0
- package/templates/config.example.json +53 -36
- package/templates/presets/ai/config.json +5 -12
- package/templates/presets/backend/config.json +5 -12
- package/templates/presets/database/config.json +5 -12
- package/templates/presets/default/config.json +5 -12
- package/templates/presets/frontend/config.json +5 -12
- package/templates/presets/fullstack/config.json +5 -12
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,119 @@ Todos los cambios notables en este proyecto se documentarán en este archivo.
|
|
|
5
5
|
El formato está basado en [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
y este proyecto adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.8.0] - 2025-12-24
|
|
9
|
+
|
|
10
|
+
### 🎨 Changed
|
|
11
|
+
|
|
12
|
+
- **Simplified configuration format** - New v2.8.0 config structure reduces redundancy and improves maintainability
|
|
13
|
+
- **What changed**: Config now uses `version` field and `overrides` structure, 21 parameters moved to hardcoded defaults
|
|
14
|
+
- **New format**: `{ "version": "2.8.0", "preset": "backend", "overrides": {...} }`
|
|
15
|
+
- **Old format**: `{ "preset": "backend", "analysis": {...}, "subagents": {...}, ... }` (20+ top-level keys)
|
|
16
|
+
- **User-configurable** (5 params): `preset`, `github.pr.*`, `subagents.batchSize`
|
|
17
|
+
- **Hardcoded** (21 params): `analysis.*` (maxFileSize, maxFiles, timeout), `commitMessage.*`, `templates.*`, etc.
|
|
18
|
+
- **Advanced** (3 params): `analysis.ignoreExtensions`, `commitMessage.taskIdPattern`, `subagents.model`
|
|
19
|
+
- **Files changed**:
|
|
20
|
+
- `lib/config.js:1-280` - Split into HARDCODED and defaults, added legacy format detection
|
|
21
|
+
- `templates/config.example.json` - New simplified format with examples
|
|
22
|
+
- `templates/config.advanced.example.json` - Advanced parameters with documentation
|
|
23
|
+
- `bin/claude-hooks:483-570` - Auto-migration during install
|
|
24
|
+
- **Impact**: Cleaner config files, sensible defaults work for 99% of users
|
|
25
|
+
|
|
26
|
+
- **Automatic config migration** - Legacy configs auto-migrate during installation with backup
|
|
27
|
+
- **What changed**: `claude-hooks install` detects legacy format and migrates automatically
|
|
28
|
+
- **Migration process**: Backup to `.claude/config_old/`, extract allowed params, create v2.8.0 config
|
|
29
|
+
- **Preserved settings**: `github.pr.*`, `subagents.batchSize`, and advanced params (with warnings)
|
|
30
|
+
- **Files changed**:
|
|
31
|
+
- `bin/claude-hooks:510-530,1942-2115` - Auto-migration in install, new `migrate-config` command
|
|
32
|
+
- **Impact**: Seamless upgrade path, settings preserved, zero manual work
|
|
33
|
+
|
|
34
|
+
- **Organized prompt templates** - All .md files moved to `.claude/prompts/` subdirectory
|
|
35
|
+
- **What changed**: Installation creates `.claude/prompts/` and places markdown templates there
|
|
36
|
+
- **Old location**: `.claude/CLAUDE_ANALYSIS_PROMPT.md`, `.claude/CLAUDE_PRE_COMMIT.md`, etc.
|
|
37
|
+
- **New location**: `.claude/prompts/CLAUDE_ANALYSIS_PROMPT.md`, `.claude/prompts/CLAUDE_PRE_COMMIT.md`, etc.
|
|
38
|
+
- **Auto-cleanup**: Old .md files in `.claude/` root are automatically removed during installation
|
|
39
|
+
- **Files changed**:
|
|
40
|
+
- `bin/claude-hooks:401-457` - Creates prompts directory, moves .md files, cleans up old files
|
|
41
|
+
- `lib/config.js:57` - Updated `templates.baseDir` to `.claude/prompts`
|
|
42
|
+
- **Impact**: Cleaner `.claude/` directory structure, prompts separated from config files
|
|
43
|
+
|
|
44
|
+
- **Parallel analysis enabled by default** - Subagents now hardcoded to enabled (was opt-in)
|
|
45
|
+
- **What changed**: `subagents.enabled` moved from user config to hardcoded `true`
|
|
46
|
+
- **Why**: Faster analysis is universally beneficial, no reason to disable
|
|
47
|
+
- **Files changed**: `lib/config.js:52-54` - Hardcoded `enabled: true`, `model: 'haiku'`, `batchSize: 3`
|
|
48
|
+
- **Impact**: All users get faster analysis out-of-box (4x speedup on 3+ files)
|
|
49
|
+
|
|
50
|
+
### ✨ Added
|
|
51
|
+
|
|
52
|
+
- **Config example files** - Split documentation into simple and advanced examples
|
|
53
|
+
- `templates/config.example.json` - Minimal config (99% of users) with inline examples
|
|
54
|
+
- `templates/config.advanced.example.json` - Advanced parameters with full documentation
|
|
55
|
+
- Installation copies both to `.claude/config_example/` for reference
|
|
56
|
+
- **Impact**: Clear guidance for common use cases, power users can tinker safely
|
|
57
|
+
|
|
58
|
+
- **Manual config migration command** - New `claude-hooks migrate-config` for manual upgrades
|
|
59
|
+
- Checks config version, creates backup in `.claude/config_old/`
|
|
60
|
+
- Extracts allowed parameters, warns about advanced params
|
|
61
|
+
- Shows diff preview before writing
|
|
62
|
+
- **Impact**: Users can migrate at their pace, review changes before applying
|
|
63
|
+
|
|
64
|
+
### 🔧 Fixed
|
|
65
|
+
|
|
66
|
+
- **Preset name now correctly displayed in hooks** - Fixed config loader not including preset name in final config
|
|
67
|
+
- **What was broken**: Hooks always showed "Default (General-purpose)" preset regardless of actual preset configured
|
|
68
|
+
- **Root cause**: Config loader extracted `presetName` but never added it to the final merged config object
|
|
69
|
+
- **Fix**: Add `preset` field to final config object after merge operations
|
|
70
|
+
- **Files changed**: `lib/config.js:181-184`
|
|
71
|
+
- **Impact**: Hooks now correctly display configured preset (e.g., "AI", "Backend", "Frontend")
|
|
72
|
+
|
|
73
|
+
- **Example configs no longer clutter .claude/** - Example files only exist in `.claude/config_example/`
|
|
74
|
+
- **What was broken**: Installation copied `*example.json` to both `.claude/` and `.claude/config_example/`
|
|
75
|
+
- **Fix**: Filter `*example.json` during template copy, only place in `config_example/`
|
|
76
|
+
- **Files changed**: `bin/claude-hooks:410-415,498-507`
|
|
77
|
+
- **Impact**: Cleaner `.claude/` directory without redundant example files
|
|
78
|
+
|
|
79
|
+
### ⚠️ Breaking Changes
|
|
80
|
+
|
|
81
|
+
- **Config format change** - Legacy config format (pre-v2.8.0) requires migration
|
|
82
|
+
- **Migration**: Automatic during `install`, or manual via `claude-hooks migrate-config`
|
|
83
|
+
- **Compatibility**: Legacy format still works with deprecation warning until v3.0.0
|
|
84
|
+
- **Action required**: None (auto-migrates), but consider running `migrate-config` to see diff
|
|
85
|
+
|
|
86
|
+
- **Template location change** - .md files moved from `.claude/` to `.claude/prompts/`
|
|
87
|
+
- **Migration**: Automatic during `install --force`
|
|
88
|
+
- **Custom templates**: If you customized templates, move them to `.claude/prompts/` manually
|
|
89
|
+
- **Impact**: Low - most users don't customize, system checks both locations
|
|
90
|
+
|
|
91
|
+
- **Hardcoded parameters** - 21 parameters no longer user-configurable in .claude/config.json
|
|
92
|
+
- **Removed from user config**: `analysis.*` (except ignoreExtensions), `commitMessage.*` (except taskIdPattern), `templates.*`, `output.*`, `system.*`, `git.*`, `subagents.enabled`, `subagents.model` (except in advanced config)
|
|
93
|
+
- **Rationale**: Sensible defaults work for everyone, reduces configuration complexity
|
|
94
|
+
- **Override**: Advanced params available in `config.advanced.example.json` (use with caution)
|
|
95
|
+
|
|
96
|
+
## [2.7.2] - 2025-12-23
|
|
97
|
+
|
|
98
|
+
### ✨ Added
|
|
99
|
+
|
|
100
|
+
- **Retry logic for PR commands** - Added automatic retry for `create-pr` and `analyze-diff` commands (#49)
|
|
101
|
+
- **What changed**: Both commands now use `executeClaudeWithRetry()` with exponential backoff (2s, 4s, 8s delays)
|
|
102
|
+
- **Impact**: PR creation and diff analysis now automatically recover from transient Claude API errors
|
|
103
|
+
- **Files changed**:
|
|
104
|
+
- `lib/utils/claude-client.js:676-745,846` - Created reusable `withRetry()` wrapper and `executeClaudeWithRetry()` export
|
|
105
|
+
- `bin/claude-hooks:11,972,1234` - Updated create-pr and analyze-diff to use retry logic
|
|
106
|
+
|
|
107
|
+
### 🐛 Fixed
|
|
108
|
+
|
|
109
|
+
- **Windows WSL timeout** - Increased WSL availability check from 3s to 15s to handle system load (#49)
|
|
110
|
+
- `lib/config.js:78` - Made configurable via `config.system.wslCheckTimeout`
|
|
111
|
+
- `lib/utils/claude-client.js:107` - Uses config value for WSL check
|
|
112
|
+
- **Duplicate task ID logging** - Removed redundant log in prepare-commit-msg (#49)
|
|
113
|
+
- `lib/hooks/prepare-commit-msg.js:191-193` - Removed duplicate logger.info call
|
|
114
|
+
|
|
115
|
+
### 🎯 Improved
|
|
116
|
+
|
|
117
|
+
- **Error diagnostics** - Added timing information to all error contexts (#49)
|
|
118
|
+
- `lib/utils/claude-client.js:248-340` - Added `elapsedTime`, `timeoutValue`, `retryAttempt` to errors
|
|
119
|
+
- `lib/utils/claude-diagnostics.js:118-143,187-344` - Created `formatTimingInfo()` helper, updated all error formatters
|
|
120
|
+
|
|
8
121
|
## [2.7.1] - 2025-12-22
|
|
9
122
|
|
|
10
123
|
### 🐛 Fixed
|
package/README.md
CHANGED
|
@@ -164,16 +164,20 @@ export GITHUB_PERSONAL_ACCESS_TOKEN="ghp_tu_token_aqui"
|
|
|
164
164
|
### 4. Configurar reviewers y labels (opcional)
|
|
165
165
|
|
|
166
166
|
```bash
|
|
167
|
-
# Ver
|
|
167
|
+
# Ver .claude/config_example/ para más ejemplos
|
|
168
168
|
cat > .claude/config.json << 'EOF'
|
|
169
169
|
{
|
|
170
|
-
"
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
"
|
|
175
|
-
"
|
|
176
|
-
"
|
|
170
|
+
"version": "2.8.0",
|
|
171
|
+
"preset": "backend",
|
|
172
|
+
"overrides": {
|
|
173
|
+
"github": {
|
|
174
|
+
"pr": {
|
|
175
|
+
"defaultBase": "develop",
|
|
176
|
+
"reviewers": ["tu-usuario-github", "teammate"],
|
|
177
|
+
"labelRules": {
|
|
178
|
+
"backend": ["backend", "java"],
|
|
179
|
+
"frontend": ["frontend", "react"]
|
|
180
|
+
}
|
|
177
181
|
}
|
|
178
182
|
}
|
|
179
183
|
}
|
|
@@ -206,40 +210,41 @@ Ver `templates/config.github.example.json` para configuración avanzada (reviewe
|
|
|
206
210
|
|
|
207
211
|
Toda idea es bienvenida, aunque parezca espantosa. Si hay bugs, incluirlos también. Dónde? en https://github.com/mscope-S-L/git-hooks/issues/new.
|
|
208
212
|
|
|
209
|
-
### 🔧 Configuración Avanzada (v2.
|
|
213
|
+
### 🔧 Configuración Avanzada (v2.8.0+)
|
|
210
214
|
|
|
211
215
|
```bash
|
|
212
|
-
# Configuración vía .claude/config.json
|
|
216
|
+
# Configuración vía .claude/config.json (v2.8.0+)
|
|
213
217
|
.claude/
|
|
214
|
-
├── config.json # Configuración principal (
|
|
215
|
-
├──
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
#
|
|
218
|
+
├── config.json # Configuración principal (formato simplificado)
|
|
219
|
+
├── config_example/ # Ejemplos de configuración
|
|
220
|
+
│ ├── config.example.json # Configuración básica
|
|
221
|
+
│ └── config.advanced.example.json # Parámetros avanzados
|
|
222
|
+
└── prompts/ # Templates de prompts (v2.8.0+)
|
|
223
|
+
├── CLAUDE_PRE_COMMIT.md # Criterios de análisis
|
|
224
|
+
└── CLAUDE_ANALYSIS_PROMPT.md # Template del prompt
|
|
225
|
+
|
|
226
|
+
# Ejemplo de config.json v2.8.0 (formato simplificado)
|
|
219
227
|
cat > .claude/config.json << 'EOF'
|
|
220
228
|
{
|
|
229
|
+
"version": "2.8.0",
|
|
221
230
|
"preset": "backend",
|
|
222
|
-
"
|
|
223
|
-
"
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
"
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
"subagents": {
|
|
233
|
-
"enabled": true,
|
|
234
|
-
"model": "haiku",
|
|
235
|
-
"batchSize": 3
|
|
236
|
-
},
|
|
237
|
-
"system": {
|
|
238
|
-
"debug": true
|
|
231
|
+
"overrides": {
|
|
232
|
+
"github": {
|
|
233
|
+
"pr": {
|
|
234
|
+
"defaultBase": "main",
|
|
235
|
+
"reviewers": ["tech-lead"]
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
"subagents": {
|
|
239
|
+
"batchSize": 2
|
|
240
|
+
}
|
|
239
241
|
}
|
|
240
242
|
}
|
|
241
243
|
EOF
|
|
242
244
|
|
|
245
|
+
# Para configuración avanzada, consultar:
|
|
246
|
+
# .claude/config_example/config.advanced.example.json
|
|
247
|
+
|
|
243
248
|
# Personalizar patrón de task-id
|
|
244
249
|
# Default: 1-3 letras + separador + 3-5 dígitos
|
|
245
250
|
# Ejemplos válidos: ABC-12345, IX-123, DE 4567
|
|
@@ -357,31 +362,40 @@ git commit -m "fix: resolver issues"
|
|
|
357
362
|
### ⚡ Tips y Trucos
|
|
358
363
|
|
|
359
364
|
1. **Mensaje automático**: Usa `"auto"` como mensaje para que Claude lo genere con task-id automático
|
|
360
|
-
2. **Task-ID pattern**: Default 1-3 letras + separador + 3-5 dígitos (ABC-12345, IX-123). Configurable en `.claude/config.json`
|
|
365
|
+
2. **Task-ID pattern**: Default 1-3 letras + separador + 3-5 dígitos (ABC-12345, IX-123). Configurable en `.claude/config_example/config.advanced.example.json`
|
|
361
366
|
3. **Skip auth**: Usa `--skip-auth` en CI/CD o desarrollo local
|
|
362
367
|
4. **Force install**: Usa `--force` para reinstalar sin confirmación
|
|
363
|
-
5. **Debug**: Activa con `claude-hooks --debug true`
|
|
364
|
-
6. **Archivos grandes**: Se omiten automáticamente archivos > 1MB
|
|
365
|
-
7. **Límite de archivos**: Máximo
|
|
368
|
+
5. **Debug**: Activa con `claude-hooks --debug true`
|
|
369
|
+
6. **Archivos grandes**: Se omiten automáticamente archivos > 1MB (hardcoded desde v2.8.0)
|
|
370
|
+
7. **Límite de archivos**: Máximo 20 archivos por commit (hardcoded desde v2.8.0)
|
|
366
371
|
|
|
367
|
-
### 🚀 Parallel Analysis (v2.
|
|
372
|
+
### 🚀 Parallel Analysis (Enabled by default desde v2.8.0)
|
|
368
373
|
|
|
369
|
-
**When analyzing 3+ files**, parallel execution runs multiple Claude CLI processes simultaneously for faster analysis
|
|
374
|
+
**When analyzing 3+ files**, parallel execution runs multiple Claude CLI processes simultaneously for faster analysis.
|
|
375
|
+
|
|
376
|
+
**Configuración automática (hardcoded):**
|
|
377
|
+
- ✅ **Enabled**: `true` (siempre activo)
|
|
378
|
+
- ⚡ **Model**: `haiku` (rápido y económico)
|
|
379
|
+
- 📦 **BatchSize**: `3` files per batch (puede overridearse)
|
|
380
|
+
|
|
381
|
+
**Customizar batch size (opcional):**
|
|
370
382
|
|
|
371
383
|
```bash
|
|
372
|
-
#
|
|
384
|
+
# En .claude/config.json v2.8.0
|
|
373
385
|
{
|
|
374
|
-
"
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
"
|
|
386
|
+
"version": "2.8.0",
|
|
387
|
+
"preset": "backend",
|
|
388
|
+
"overrides": {
|
|
389
|
+
"subagents": {
|
|
390
|
+
"batchSize": 2
|
|
391
|
+
}
|
|
378
392
|
}
|
|
379
393
|
}
|
|
380
394
|
```
|
|
381
395
|
|
|
382
|
-
**Model options:**
|
|
396
|
+
**Model options (solo en config avanzado):**
|
|
383
397
|
|
|
384
|
-
- `haiku` - Fast & cheap (default
|
|
398
|
+
- `haiku` - Fast & cheap (default)
|
|
385
399
|
- `sonnet` - Balanced quality/speed
|
|
386
400
|
- `opus` - Maximum quality (slower)
|
|
387
401
|
|
|
@@ -422,9 +436,9 @@ git commit -m "fix: resolver issues"
|
|
|
422
436
|
|
|
423
437
|
**Archivos clave para modificar:**
|
|
424
438
|
|
|
425
|
-
- `.claude/config.json` - Configuración principal (v2.
|
|
426
|
-
- `.claude/CLAUDE_PRE_COMMIT.md` - Criterios (backend/frontend/data/db)
|
|
427
|
-
- `.claude/CLAUDE_ANALYSIS_PROMPT.md` - Template del prompt
|
|
439
|
+
- `.claude/config.json` - Configuración principal (v2.8.0+)
|
|
440
|
+
- `.claude/prompts/CLAUDE_PRE_COMMIT.md` - Criterios (backend/frontend/data/db)
|
|
441
|
+
- `.claude/prompts/CLAUDE_ANALYSIS_PROMPT.md` - Template del prompt
|
|
428
442
|
|
|
429
443
|
**Crear o modificar presets personalizados:**
|
|
430
444
|
|
|
@@ -439,7 +453,7 @@ cat templates/CUSTOMIZATION_GUIDE.md
|
|
|
439
453
|
**Ejemplo:**
|
|
440
454
|
|
|
441
455
|
```bash
|
|
442
|
-
vim .claude/CLAUDE_PRE_COMMIT.md # Agregar reglas API REST/Spring Boot
|
|
456
|
+
vim .claude/prompts/CLAUDE_PRE_COMMIT.md # Agregar reglas API REST/Spring Boot
|
|
443
457
|
```
|
|
444
458
|
|
|
445
459
|
## 🔧 Configuración Previa Importante
|
|
@@ -537,8 +551,8 @@ Si no existe un `.gitignore`, se creará uno nuevo. Si ya existe, las entradas s
|
|
|
537
551
|
- Omite archivos mayores a 1MB
|
|
538
552
|
- Límite de 30 archivos por commit
|
|
539
553
|
3. **Construye prompt inteligente**:
|
|
540
|
-
- Usa template de prompt desde `.claude/CLAUDE_ANALYSIS_PROMPT*.md`
|
|
541
|
-
- Lee las pautas desde `.claude/CLAUDE_PRE_COMMIT*.md`
|
|
554
|
+
- Usa template de prompt desde `.claude/prompts/CLAUDE_ANALYSIS_PROMPT*.md`
|
|
555
|
+
- Lee las pautas desde `.claude/prompts/CLAUDE_PRE_COMMIT*.md`
|
|
542
556
|
- Incluye el diff completo para archivos nuevos
|
|
543
557
|
- Muestra solo cambios para archivos existentes
|
|
544
558
|
4. **Envía a Claude CLI para revisión**
|