claude-git-hooks 2.6.1 → 2.6.3

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,50 @@ 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.6.3]
9
+
10
+ ### 🐛 Fixed
11
+
12
+ - **WSL timeout error misreporting** - Fixed misleading error message when WSL times out under system load (#49)
13
+ - **What was broken**: ETIMEDOUT errors during WSL Claude verification were misreported as "Claude CLI not found in WSL"
14
+ - **Root cause**: Catch block in WSL verification treated all errors identically, including transient ETIMEDOUT timeouts from system load
15
+ - **Fix**: Added error type differentiation to distinguish between ETIMEDOUT (transient timeout), ENOENT (missing CLI), and generic WSL errors
16
+ - **Files changed**:
17
+ - `lib/utils/claude-client.js:109-146` - Enhanced error detection with three distinct error paths
18
+ - **Impact**:
19
+ - ETIMEDOUT: Clear message "Timeout connecting to WSL - system under heavy load" with suggestion to retry or skip
20
+ - ENOENT: Preserved original "Claude CLI not found in WSL" with installation instructions
21
+ - Generic: New fallback "Failed to verify Claude CLI in WSL" with WSL diagnostic suggestions
22
+ - **Compatibility**: No breaking changes, improves error accuracy for Windows WSL users
23
+
24
+ ### 🎯 User Experience
25
+
26
+ - **Before**: Users experiencing system load timeouts saw misleading "Claude CLI not found" error and tried reinstalling unnecessarily
27
+ - **After**: Clear distinction between transient timeouts (retry/skip) and missing CLI (install) with actionable suggestions for each
28
+ - **Debug**: All error cases now include context with platform, wslPath, error type, and specific remediation steps
29
+
30
+ ## [2.6.2] - 2025-12-12
31
+
32
+ ### 🐛 Fixed
33
+
34
+ - **Parallel analysis stdin error handling** - Added graceful error handling for EOF errors during parallel execution (#43)
35
+ - **What was broken**: Unhandled 'error' events on stdin stream when Claude CLI process terminates unexpectedly during parallel analysis
36
+ - **Root cause**: `stdin.write()` failures emit asynchronous 'error' events that weren't being caught, causing uncaught exceptions with large prompts (18+ files) in parallel mode
37
+ - **Fix**: Added explicit error handler on `stdin` stream before writing prompt
38
+ - **Files changed**:
39
+ - `lib/utils/claude-client.js:287-308` - Added stdin error handler with detailed diagnostics
40
+ - **Impact**:
41
+ - Provides clear error message: "Failed to write to Claude stdin - process terminated unexpectedly"
42
+ - Logs diagnostic info: prompt length, error code, duration
43
+ - Suggests actionable fix: "Try reducing batch size or number of files per commit"
44
+ - **Compatibility**: No breaking changes, improves error reporting for all platforms
45
+
46
+ ### 🎯 User Experience
47
+
48
+ - **Before**: Cryptic unhandled 'write EOF' exceptions crashed commit process with no actionable information
49
+ - **After**: Clear error message with diagnostic context and suggested remediation
50
+ - **Debug**: Added structured logging with prompt length and timing when EOF errors occur
51
+
8
52
  ## [2.6.1] - 2025-12-04
9
53
 
10
54
  ### 🐛 Fixed
@@ -96,11 +140,13 @@ y este proyecto adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.h
96
140
  ### 🔧 Technical Details
97
141
 
98
142
  **DEP0190 Explanation**:
143
+
99
144
  - **What**: Node.js 24 deprecates `spawn(cmd, args, { shell: true })`
100
145
  - **Why**: Args are not escaped, just concatenated → shell injection risk
101
146
  - **Fix**: Use absolute executable paths, remove `shell: true`
102
147
 
103
148
  **Files Changed**:
149
+
104
150
  - `lib/utils/claude-client.js` - Command resolution and spawn call
105
151
  - `lib/utils/which-command.js` - NEW utility for path resolution
106
152
  - `package.json` - Platform documentation
@@ -109,6 +155,7 @@ y este proyecto adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.h
109
155
  - `MIGRATION_NODE24.md` - NEW migration guide
110
156
 
111
157
  **Backward Compatibility**:
158
+
112
159
  - ✅ Works on Node 16.9.0+ (unchanged)
113
160
  - ✅ Works on Node 18 (unchanged)
114
161
  - ✅ Works on Node 20 (unchanged)
@@ -127,6 +174,7 @@ y este proyecto adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.h
127
174
  ### 📋 Migration Checklist
128
175
 
129
176
  For users on Node 24:
177
+
130
178
  - [x] Update to claude-git-hooks 2.6.0
131
179
  - [x] Verify no DEP0190 warnings: `claude-hooks install`
132
180
  - [x] Test pre-commit hook: `git commit`
@@ -107,11 +107,40 @@ const getClaudeCommand = () => {
107
107
  logger.debug('claude-client - getClaudeCommand', 'Using WSL Claude CLI', { wslPath });
108
108
  return { command: wslPath, args: ['claude'] };
109
109
  } catch (wslError) {
110
- throw new ClaudeClientError('Claude CLI not found in WSL', {
110
+ // Differentiate error types for accurate user feedback
111
+ const errorMsg = wslError.message || '';
112
+
113
+ // Timeout: Transient system load issue
114
+ if (errorMsg.includes('ETIMEDOUT')) {
115
+ throw new ClaudeClientError('Timeout connecting to WSL - system under heavy load', {
116
+ context: {
117
+ platform: 'Windows',
118
+ wslPath,
119
+ error: 'ETIMEDOUT',
120
+ suggestion: 'System is busy. Wait a moment and try again, or skip analysis: git commit --no-verify'
121
+ }
122
+ });
123
+ }
124
+
125
+ // Not found: Claude CLI missing in WSL
126
+ if (errorMsg.includes('ENOENT') || errorMsg.includes('command not found')) {
127
+ throw new ClaudeClientError('Claude CLI not found in WSL', {
128
+ context: {
129
+ platform: 'Windows',
130
+ wslPath,
131
+ error: 'ENOENT',
132
+ suggestion: 'Install Claude in WSL: wsl -e bash -c "npm install -g @anthropic-ai/claude-cli"'
133
+ }
134
+ });
135
+ }
136
+
137
+ // Generic error: Other WSL issues
138
+ throw new ClaudeClientError('Failed to verify Claude CLI in WSL', {
111
139
  context: {
112
140
  platform: 'Windows',
113
141
  wslPath,
114
- wslError: wslError.message
142
+ error: errorMsg,
143
+ suggestion: 'Check WSL is functioning: wsl --version, or skip analysis: git commit --no-verify'
115
144
  }
116
145
  });
117
146
  }
@@ -280,13 +309,40 @@ const executeClaude = (prompt, { timeout = 120000, allowedTools = [] } = {}) =>
280
309
 
281
310
  // Write prompt to stdin
282
311
  // Why: Claude CLI reads prompt from stdin, not command arguments
312
+
313
+ // Handle stdin errors (e.g., EOF when process terminates unexpectedly)
314
+ // Why: write() failures can emit 'error' events asynchronously
315
+ // Common in parallel execution with large prompts
316
+ claude.stdin.on('error', (error) => {
317
+ logger.error(
318
+ 'claude-client - executeClaude',
319
+ 'stdin stream error (process may have terminated early)',
320
+ {
321
+ error: error.message,
322
+ code: error.code,
323
+ promptLength: prompt.length,
324
+ duration: Date.now() - startTime
325
+ }
326
+ );
327
+
328
+ reject(new ClaudeClientError('Failed to write to Claude stdin - process terminated unexpectedly', {
329
+ cause: error,
330
+ context: {
331
+ promptLength: prompt.length,
332
+ errorCode: error.code,
333
+ errorMessage: error.message,
334
+ suggestion: 'Try reducing batch size or number of files per commit'
335
+ }
336
+ }));
337
+ });
338
+
283
339
  try {
284
340
  claude.stdin.write(prompt);
285
341
  claude.stdin.end();
286
342
  } catch (error) {
287
343
  logger.error(
288
344
  'claude-client - executeClaude',
289
- 'Failed to write prompt to Claude CLI stdin',
345
+ 'Failed to write prompt to Claude CLI stdin (synchronous error)',
290
346
  error
291
347
  );
292
348
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-git-hooks",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "Git hooks with Claude CLI for code analysis and automatic commit messages",
5
5
  "type": "module",
6
6
  "bin": {