claude-git-hooks 1.5.3 → 1.5.4

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 CHANGED
@@ -5,6 +5,25 @@ 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
+ ## [1.5.4] - 2024-12-22
9
+
10
+ ### Fixed
11
+
12
+ - 🔧 **Generación de prompt de resolución en modo SonarQube**
13
+ - Ahora se genera correctamente `claude_resolution_prompt.md` cuando el Quality Gate falla
14
+ - El archivo se genera cuando hay `blockingIssues`, independiente del tipo de fallo
15
+ - Corregido el flujo para que siempre muestre los issues críticos antes de generar el prompt
16
+
17
+ - 🎯 **Unificación de lógica de análisis**
18
+ - Eliminada lógica duplicada entre modo "clásico" y SonarQube
19
+ - Ahora siempre se usa modo SonarQube (como se especificó en v1.4.1)
20
+ - Simplificación del flujo de decisión en el pre-commit hook
21
+
22
+ ### Changed
23
+
24
+ - 📝 Refactorización del hook pre-commit para mayor claridad y mantenibilidad
25
+ - 🔄 La función `generate_resolution_prompt` ahora se llama consistentemente cuando hay issues bloqueantes
26
+
8
27
  ## [1.5.3] - 2025-09-12
9
28
 
10
29
  ### Fixed
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
package/bin/claude-hooks CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-git-hooks",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "Git hooks con Claude CLI para análisis de código y generación automática de mensajes de commit",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
File without changes
File without changes
@@ -5,7 +5,6 @@ repo:{{REPO_NAME}}
5
5
  branch:{{BRANCH_NAME}}
6
6
  commit:{{COMMIT_SHA}}
7
7
  files:{{FILE_COUNT}}
8
- mode:{{ANALYSIS_MODE}}
9
8
 
10
9
  CRITICAL_ISSUES:
11
10
  {{BLOCKING_ISSUES}}
File without changes
@@ -332,125 +332,95 @@ if $CLAUDE_CLI < "$PROMPT_FILE" > "$RESPONSE_FILE" 2>&1; then
332
332
  BLOCKING_ISSUES=$(echo "$JSON_RESPONSE" | jq -r '.blockingIssues[].description' 2>/dev/null | sed '/^$/d')
333
333
  fi
334
334
 
335
+ # Always use SonarQube mode (as per v1.4.1)
335
336
  QUALITY_GATE=$(echo "$JSON_RESPONSE" | jq -r '.QUALITY_GATE // ""' 2>/dev/null)
336
-
337
- if [ -n "$QUALITY_GATE" ] && [ "$QUALITY_GATE" != "null" ]; then
338
- # Show SonarQube style results
339
- echo
340
- echo "╔════════════════════════════════════════════════════════════════════╗"
341
- echo "║ CODE QUALITY ANALYSIS ║"
342
- echo "╚════════════════════════════════════════════════════════════════════╝"
337
+
338
+ # Show SonarQube style results
339
+ echo
340
+ echo "╔════════════════════════════════════════════════════════════════════╗"
341
+ echo "║ CODE QUALITY ANALYSIS ║"
342
+ echo "╚════════════════════════════════════════════════════════════════════╝"
343
+ echo
344
+
345
+ # Quality Gate Status
346
+ if [ "$QUALITY_GATE" = "PASSED" ]; then
347
+ echo -e "${GREEN}✓ Quality Gate: PASSED${NC}"
348
+ else
349
+ echo -e "${RED}✗ Quality Gate: FAILED${NC}"
350
+ fi
351
+ echo
352
+
353
+ # Metrics
354
+ METRICS=$(echo "$JSON_RESPONSE" | jq -r '.metrics // {}' 2>/dev/null)
355
+ if [ "$METRICS" != "{}" ] && [ "$METRICS" != "null" ]; then
356
+ echo "📊 METRICS"
357
+ echo "├─ Reliability: $(echo "$METRICS" | jq -r '.reliability // "?"' 2>/dev/null)"
358
+ echo "├─ Security: $(echo "$METRICS" | jq -r '.security // "?"' 2>/dev/null)"
359
+ echo "├─ Maintainability: $(echo "$METRICS" | jq -r '.maintainability // "?"' 2>/dev/null)"
360
+ echo "├─ Coverage: $(echo "$METRICS" | jq -r '.coverage // "?"' 2>/dev/null)%"
361
+ echo "├─ Duplications: $(echo "$METRICS" | jq -r '.duplications // "?"' 2>/dev/null)%"
362
+ echo "└─ Complexity: $(echo "$METRICS" | jq -r '.complexity // "?"' 2>/dev/null)"
343
363
  echo
344
-
345
- # Quality Gate Status
346
- if [ "$QUALITY_GATE" = "PASSED" ]; then
347
- echo -e "${GREEN}✓ Quality Gate: PASSED${NC}"
348
- else
349
- echo -e "${RED}✗ Quality Gate: FAILED${NC}"
350
- fi
364
+ fi
365
+
366
+ # Issues Summary
367
+ ISSUES=$(echo "$JSON_RESPONSE" | jq -r '.issues // {}' 2>/dev/null)
368
+ if [ "$ISSUES" != "{}" ] && [ "$ISSUES" != "null" ]; then
369
+ echo "📋 ISSUES SUMMARY"
370
+ BLOCKER=$(echo "$ISSUES" | jq -r '.blocker // 0' 2>/dev/null)
371
+ CRITICAL=$(echo "$ISSUES" | jq -r '.critical // 0' 2>/dev/null)
372
+ MAJOR=$(echo "$ISSUES" | jq -r '.major // 0' 2>/dev/null)
373
+ MINOR=$(echo "$ISSUES" | jq -r '.minor // 0' 2>/dev/null)
374
+ INFO=$(echo "$ISSUES" | jq -r '.info // 0' 2>/dev/null)
375
+ TOTAL=$((BLOCKER + CRITICAL + MAJOR + MINOR + INFO))
376
+
377
+ echo "Total: $TOTAL issues found"
378
+ [ "$BLOCKER" -gt 0 ] && echo -e " ${RED}🔴 Blocker: $BLOCKER${NC}"
379
+ [ "$CRITICAL" -gt 0 ] && echo -e " ${RED}🟠 Critical: $CRITICAL${NC}"
380
+ [ "$MAJOR" -gt 0 ] && echo -e " ${YELLOW}🟡 Major: $MAJOR${NC}"
381
+ [ "$MINOR" -gt 0 ] && echo " 🔵 Minor: $MINOR"
382
+ [ "$INFO" -gt 0 ] && echo " ⚪ Info: $INFO"
351
383
  echo
352
-
353
- # Metrics
354
- METRICS=$(echo "$JSON_RESPONSE" | jq -r '.metrics // {}' 2>/dev/null)
355
- if [ "$METRICS" != "{}" ] && [ "$METRICS" != "null" ]; then
356
- echo "📊 METRICS"
357
- echo "├─ Reliability: $(echo "$METRICS" | jq -r '.reliability // "?"' 2>/dev/null)"
358
- echo "├─ Security: $(echo "$METRICS" | jq -r '.security // "?"' 2>/dev/null)"
359
- echo "├─ Maintainability: $(echo "$METRICS" | jq -r '.maintainability // "?"' 2>/dev/null)"
360
- echo "├─ Coverage: $(echo "$METRICS" | jq -r '.coverage // "?"' 2>/dev/null)%"
361
- echo "├─ Duplications: $(echo "$METRICS" | jq -r '.duplications // "?"' 2>/dev/null)%"
362
- echo "└─ Complexity: $(echo "$METRICS" | jq -r '.complexity // "?"' 2>/dev/null)"
363
- echo
364
- fi
365
-
366
- # Issues Summary
367
- ISSUES=$(echo "$JSON_RESPONSE" | jq -r '.issues // {}' 2>/dev/null)
368
- if [ "$ISSUES" != "{}" ] && [ "$ISSUES" != "null" ]; then
369
- echo "📋 ISSUES SUMMARY"
370
- BLOCKER=$(echo "$ISSUES" | jq -r '.blocker // 0' 2>/dev/null)
371
- CRITICAL=$(echo "$ISSUES" | jq -r '.critical // 0' 2>/dev/null)
372
- MAJOR=$(echo "$ISSUES" | jq -r '.major // 0' 2>/dev/null)
373
- MINOR=$(echo "$ISSUES" | jq -r '.minor // 0' 2>/dev/null)
374
- INFO=$(echo "$ISSUES" | jq -r '.info // 0' 2>/dev/null)
375
- TOTAL=$((BLOCKER + CRITICAL + MAJOR + MINOR + INFO))
376
-
377
- echo "Total: $TOTAL issues found"
378
- [ "$BLOCKER" -gt 0 ] && echo -e " ${RED}🔴 Blocker: $BLOCKER${NC}"
379
- [ "$CRITICAL" -gt 0 ] && echo -e " ${RED}🟠 Critical: $CRITICAL${NC}"
380
- [ "$MAJOR" -gt 0 ] && echo -e " ${YELLOW}🟡 Major: $MAJOR${NC}"
381
- [ "$MINOR" -gt 0 ] && echo " 🔵 Minor: $MINOR"
382
- [ "$INFO" -gt 0 ] && echo " ⚪ Info: $INFO"
383
- echo
384
- fi
385
-
386
- # Detailed Issues
387
- DETAILS_COUNT=$(echo "$JSON_RESPONSE" | jq -r '.details | length' 2>/dev/null)
388
- if [ "$DETAILS_COUNT" -gt 0 ] 2>/dev/null; then
389
- echo "🔍 DETAILED ISSUES"
390
- echo "$JSON_RESPONSE" | jq -r '.details[]? |
391
- "[\(.severity)] \(.type) in \(.file):\(.line // "?")\n \(.message)\n"' 2>/dev/null
392
- fi
393
-
394
- # Security Hotspots
395
- HOTSPOTS=$(echo "$JSON_RESPONSE" | jq -r '.securityHotspots // 0' 2>/dev/null)
396
- if [ "$HOTSPOTS" -gt 0 ] 2>/dev/null; then
397
- echo "🔥 SECURITY HOTSPOTS: $HOTSPOTS found"
398
- echo " Review security-sensitive code carefully"
384
+ fi
399
385
 
400
- echo
401
- fi
402
-
403
- # Check if commit should be blocked
404
- if [ "$QUALITY_GATE" = "FAILED" ] || [ "$APPROVED" = "false" ]; then
405
- echo
406
- error "❌ Commit blocked due to quality gate failure"
407
- exit 1
408
- fi
409
-
386
+ # Detailed Issues
387
+ DETAILS_COUNT=$(echo "$JSON_RESPONSE" | jq -r '.details | length' 2>/dev/null)
388
+ if [ "$DETAILS_COUNT" -gt 0 ] 2>/dev/null; then
389
+ echo "🔍 DETAILED ISSUES"
390
+ echo "$JSON_RESPONSE" | jq -r '.details[]? |
391
+ "[\(.severity)] \(.type) in \(.file):\(.line // "?")\n \(.message)\n"' 2>/dev/null
392
+ fi
393
+
394
+ # Security Hotspots
395
+ HOTSPOTS=$(echo "$JSON_RESPONSE" | jq -r '.securityHotspots // 0' 2>/dev/null)
396
+ if [ "$HOTSPOTS" -gt 0 ] 2>/dev/null; then
397
+ echo "🔥 SECURITY HOTSPOTS: $HOTSPOTS found"
398
+ echo " Review security-sensitive code carefully"
410
399
  echo
411
- log "✅ Code analysis completed. Quality gate passed."
412
- else
413
- # Show results in classic format
400
+ fi
401
+
402
+ # Check if commit should be blocked
403
+ if [ "$QUALITY_GATE" = "FAILED" ] || [ "$APPROVED" = "false" ]; then
414
404
  echo
415
- echo "=== REVIEW RESULTS ==="
416
- echo "Score: $SCORE/10"
417
-
418
- if [ -n "$RECOMMENDATIONS" ] && [ "$RECOMMENDATIONS" != "null" ]; then
405
+ error " Commit blocked due to quality gate failure"
406
+
407
+ # Show blocking issues if they exist
408
+ if [ -n "$BLOCKING_ISSUES" ] && [ "$BLOCKING_ISSUES" != "null" ]; then
419
409
  echo
420
- echo "=== RECOMMENDATIONS ==="
421
- echo "$RECOMMENDATIONS" | sed 's/^/- /'
422
- fi
423
-
424
- # Check if the commit should be blocked
425
- if [ "$APPROVED" = "false" ]; then
426
- error "❌ Commit rejected due to critical issues"
427
- if [ -n "$BLOCKING_ISSUES" ] && [ "$BLOCKING_ISSUES" != "null" ]; then
428
- echo
429
- echo "=== CRITICAL ISSUES ==="
430
- echo "$BLOCKING_ISSUES" | sed 's/^/- /'
431
-
432
- # Generate AI-friendly resolution prompt
433
- generate_resolution_prompt
434
- fi
435
- exit 1
410
+ echo "=== CRITICAL ISSUES ==="
411
+ echo "$BLOCKING_ISSUES" | sed 's/^/- /'
436
412
  fi
437
413
 
438
- # Show additional details if they exist
439
- DETAILS=$(echo "$JSON_RESPONSE" | jq -r '.details // null')
440
- if [ -n "$DETAILS" ] && [ "$DETAILS" != "null" ]; then
441
- echo
442
- echo "=== ADDITIONAL DETAILS ==="
443
- # If details is a string, print it directly
444
- if echo "$DETAILS" | jq -e 'type == "string"' >/dev/null 2>&1; then
445
- echo "$DETAILS" | jq -r '.'
446
- # If it's an object or array, format it
447
- else
448
- echo "$DETAILS" | jq '.'
449
- fi
414
+ # Generate AI-friendly resolution prompt if there are blocking issues
415
+ if [ "$BLOCKING_COUNT" -gt 0 ]; then
416
+ generate_resolution_prompt
450
417
  fi
451
-
452
- log "✅ Review completed. Commit approved (Score: $SCORE/10)"
418
+
419
+ exit 1
453
420
  fi
421
+
422
+ echo
423
+ log "✅ Code analysis completed. Quality gate passed."
454
424
 
455
425
  else
456
426
  error "Error executing Claude CLI"
File without changes