claude-git-hooks 2.8.0 → 2.10.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 CHANGED
@@ -5,6 +5,163 @@ 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.10.0] - 2026-02-02
9
+
10
+ ### 🏗️ Architecture - Modular CLI Refactoring
11
+
12
+ **Major refactoring: All CLI commands extracted to `lib/commands/` modules.**
13
+
14
+ This release implements a **modular, decoupled, reusable** architecture for better maintainability, testability, and extensibility.
15
+
16
+ ### ✨ Added
17
+
18
+ - **New `lib/commands/` directory** - One file per CLI command
19
+ - `helpers.js` - Shared CLI utilities (colors, output, platform detection, Entertainment)
20
+ - `install.js` - Installation logic (dependencies, hooks, templates, config migration)
21
+ - `hooks.js` - Hook management (enable, disable, status, uninstall)
22
+ - `analyze-diff.js` - Diff analysis (generate PR metadata from git diff)
23
+ - `create-pr.js` - PR creation (full Octokit workflow)
24
+ - `setup-github.js` - Token setup (interactive GitHub configuration)
25
+ - `presets.js` - Preset management (list, set, show current)
26
+ - `update.js` - Self-update (check and install latest version)
27
+ - `migrate-config.js` - Config migration (legacy to v2.8.0 format)
28
+ - `debug.js` - Debug toggle (enable/disable verbose logging)
29
+ - `telemetry-cmd.js` - Telemetry commands (show/clear statistics)
30
+ - `help.js` - Help display (usage information)
31
+
32
+ ### 🔄 Changed
33
+
34
+ - **`bin/claude-hooks` reduced from 2,300 to 111 lines** - Now a thin CLI router
35
+ - Only handles argument parsing and command dispatch
36
+ - All business logic moved to `lib/commands/` modules
37
+ - Imports and calls appropriate command module based on CLI argument
38
+
39
+ - **Design philosophy documented** - CLAUDE.md and README.md updated with:
40
+ - Purpose annotations for each component/layer
41
+ - Module responsibility descriptions
42
+ - Architectural decision rationale
43
+
44
+ ### 🎯 Benefits
45
+
46
+ | Aspect | Before | After |
47
+ |--------|--------|-------|
48
+ | `bin/claude-hooks` size | 2,277 lines | 111 lines |
49
+ | Command modules | 1 (`setup-github.js`) | 13 files |
50
+ | Testability | Hard (monolithic) | Easy (modular) |
51
+ | Finding code | Search entire file | Match filename to command |
52
+ | Adding commands | Edit large file | Create new module |
53
+
54
+ ### 📚 Documentation
55
+
56
+ - **README.md** - Added Command Modules table with purpose annotations
57
+ - **CLAUDE.md** - Updated directory structure with purpose for each file
58
+ - **README-NPM.md** - Added architecture section
59
+ - **CHANGELOG.md** - This entry
60
+
61
+ ### 🔧 Technical Details
62
+
63
+ **New module structure:**
64
+ ```
65
+ lib/commands/
66
+ ├── helpers.js (389 lines) - Shared utilities
67
+ ├── install.js (691 lines) - Installation
68
+ ├── hooks.js (148 lines) - Hook management
69
+ ├── analyze-diff.js (267 lines) - Diff analysis
70
+ ├── create-pr.js (374 lines) - PR creation
71
+ ├── presets.js (101 lines) - Preset commands
72
+ ├── update.js (67 lines) - Self-update
73
+ ├── migrate-config.js (103 lines) - Config migration
74
+ ├── debug.js (52 lines) - Debug mode
75
+ ├── telemetry-cmd.js (47 lines) - Telemetry
76
+ ├── help.js (147 lines) - Help display
77
+ └── setup-github.js (98 lines) - GitHub setup
78
+ ```
79
+
80
+ **Key patterns implemented:**
81
+ - **Command Pattern**: Each CLI command is a self-contained module
82
+ - **Thin Controller**: `bin/claude-hooks` only routes, doesn't implement
83
+ - **Separation of Concerns**: UI helpers in `helpers.js`, business logic in specific modules
84
+
85
+ ### 🗑️ Removed
86
+
87
+ - **Inline command implementations** from `bin/claude-hooks`:
88
+ - `install()` - moved to `lib/commands/install.js`
89
+ - `uninstall()` - moved to `lib/commands/hooks.js`
90
+ - `enable()` / `disable()` - moved to `lib/commands/hooks.js`
91
+ - `status()` - moved to `lib/commands/hooks.js`
92
+ - `analyzeDiff()` - moved to `lib/commands/analyze-diff.js`
93
+ - `createPr()` - moved to `lib/commands/create-pr.js`
94
+ - `showPresets()` / `setPreset()` / `currentPreset()` - moved to `lib/commands/presets.js`
95
+ - `update()` - moved to `lib/commands/update.js`
96
+ - `migrateConfig()` - moved to `lib/commands/migrate-config.js`
97
+ - `setDebug()` - moved to `lib/commands/debug.js`
98
+ - `showTelemetry()` / `clearTelemetry()` - moved to `lib/commands/telemetry-cmd.js`
99
+ - `showHelp()` / `showVersion()` - moved to `lib/commands/help.js`
100
+ - Helper functions (colors, log, error, success, etc.) - moved to `lib/commands/helpers.js`
101
+ - `Entertainment` class - moved to `lib/commands/helpers.js`
102
+
103
+ ### 📋 Migration
104
+
105
+ **No breaking changes.** All CLI commands work identically. This is an internal refactoring.
106
+
107
+ ```bash
108
+ # All commands work the same
109
+ claude-hooks install
110
+ claude-hooks create-pr develop
111
+ claude-hooks --set-preset backend
112
+ claude-hooks status
113
+ ```
114
+
115
+ ## [2.9.1] - 2025-12-30
116
+
117
+ ### 🐛 Fixed
118
+
119
+ - **Template path mismatch after v2.8.0 migration** - Fixed critical bug where templates were not found after config migration (#51)
120
+ - **What was broken**: After v2.8.0 moved templates from `.claude/` to `.claude/prompts/`, the code still looked in the old location
121
+ - **Root cause**: `prompt-builder.js` and `resolution-prompt.js` had hardcoded `.claude/` paths instead of `.claude/prompts/`
122
+ - **Symptom**: `ENOENT: no such file or directory` errors for `CLAUDE_ANALYSIS_PROMPT.md` and `CLAUDE_RESOLUTION_PROMPT.md`
123
+ - **Fix**: Updated default paths in template loading functions to `.claude/prompts/`
124
+ - **Files changed**:
125
+ - `lib/utils/prompt-builder.js:45,133,223,234-235,244` - Updated `loadTemplate`, `loadPrompt`, `buildAnalysisPrompt` defaults
126
+ - `lib/utils/resolution-prompt.js:183` - Updated `generateResolutionPrompt` template path
127
+ - **Impact**: Pre-commit analysis and resolution prompt generation now work correctly after v2.8.0+ installation
128
+
129
+ ### 🎯 User Experience
130
+
131
+ - **Before**: Users upgrading from v2.6.x to v2.8.0+ experienced "Template not found" errors even after successful installation
132
+ - **After**: Templates are found in correct `.claude/prompts/` directory as intended by v2.8.0 changes
133
+
134
+ ## [2.9.0] - 2025-12-26
135
+
136
+ ### ✨ Added
137
+
138
+ - **Local telemetry system with per-retry tracking** - Enabled by default for debugging JSON parsing failures (#50)
139
+ - **What it does**: Tracks JSON parsing failures and successes with full context, recording EVERY retry attempt individually
140
+ - **Key features**:
141
+ - **Granular tracking**: Records each retry attempt separately (not just final result)
142
+ - **Unique IDs**: Each event has unique ID (timestamp-counter-random) for deduplication
143
+ - **Success flag**: Boolean indicating whether attempt succeeded (true) or failed (false)
144
+ - **Retry metadata**: `retryAttempt` (0-3) and `totalRetries` (max configured)
145
+ - **Error types**: Tracks EXECUTION_ERROR, JSON_PARSE_ERROR, etc.
146
+ - **Hook coverage**: pre-commit, prepare-commit-msg, analyze-diff, create-pr
147
+ - **Privacy-first**: Local-only (`.claude/telemetry/`), no data leaves user's machine, no external transmission
148
+ - **Storage**: JSON lines format with automatic rotation (keeps last 30 days)
149
+ - **CLI commands**:
150
+ - `claude-hooks telemetry show` - Display statistics (failure rate, failures by batch size/model/hook, retry patterns)
151
+ - `claude-hooks telemetry clear` - Reset telemetry data
152
+ - **Enabled by default**: To disable, add `"system": { "telemetry": false }` to `.claude/config.json`
153
+ - **Files added**:
154
+ - `lib/utils/telemetry.js` - Telemetry collection with ID generation, retry tracking, and statistics
155
+ - **Files changed**:
156
+ - `lib/utils/claude-client.js:678-780,788-798` - Modified withRetry() to record telemetry on each attempt
157
+ - `lib/utils/claude-client.js:609-618,845-856` - Removed duplicate telemetry recordings
158
+ - `lib/hooks/pre-commit.js` - Pass telemetry context for analysis
159
+ - `lib/hooks/prepare-commit-msg.js` - Pass telemetry context for commit messages
160
+ - `lib/config.js` - Add telemetry config option (default: true)
161
+ - `bin/claude-hooks:1076-1091,1354-1366` - Add telemetry context to analyze-diff and create-pr
162
+ - `bin/claude-hooks` - Add telemetry CLI commands
163
+ - **Impact**: Enables diagnosis of retry patterns, identifies which retry attempts succeed, tracks transient vs persistent errors, helps optimize batch sizes and models
164
+
8
165
  ## [2.8.0] - 2025-12-24
9
166
 
10
167
  ### 🎨 Changed