claude-git-hooks 2.1.0 → 2.3.1
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 +240 -0
- package/README.md +280 -78
- package/bin/claude-hooks +295 -119
- package/lib/config.js +164 -0
- package/lib/hooks/pre-commit.js +180 -67
- package/lib/hooks/prepare-commit-msg.js +47 -41
- package/lib/utils/claude-client.js +107 -16
- package/lib/utils/claude-diagnostics.js +266 -0
- package/lib/utils/file-operations.js +1 -65
- package/lib/utils/file-utils.js +65 -0
- package/lib/utils/installation-diagnostics.js +145 -0
- package/lib/utils/package-info.js +75 -0
- package/lib/utils/preset-loader.js +214 -0
- package/lib/utils/prompt-builder.js +83 -67
- package/lib/utils/resolution-prompt.js +12 -2
- package/package.json +49 -50
- package/templates/ANALYZE_DIFF.md +33 -0
- package/templates/COMMIT_MESSAGE.md +24 -0
- package/templates/CUSTOMIZATION_GUIDE.md +656 -0
- package/templates/SUBAGENT_INSTRUCTION.md +1 -0
- package/templates/config.example.json +41 -0
- package/templates/pre-commit +40 -2
- package/templates/prepare-commit-msg +40 -2
- package/templates/presets/ai/ANALYSIS_PROMPT.md +133 -0
- package/templates/presets/ai/PRE_COMMIT_GUIDELINES.md +176 -0
- package/templates/presets/ai/config.json +12 -0
- package/templates/presets/ai/preset.json +42 -0
- package/templates/presets/backend/ANALYSIS_PROMPT.md +85 -0
- package/templates/presets/backend/PRE_COMMIT_GUIDELINES.md +87 -0
- package/templates/presets/backend/config.json +12 -0
- package/templates/presets/backend/preset.json +49 -0
- package/templates/presets/database/ANALYSIS_PROMPT.md +114 -0
- package/templates/presets/database/PRE_COMMIT_GUIDELINES.md +143 -0
- package/templates/presets/database/config.json +12 -0
- package/templates/presets/database/preset.json +38 -0
- package/templates/presets/default/config.json +12 -0
- package/templates/presets/default/preset.json +53 -0
- package/templates/presets/frontend/ANALYSIS_PROMPT.md +99 -0
- package/templates/presets/frontend/PRE_COMMIT_GUIDELINES.md +95 -0
- package/templates/presets/frontend/config.json +12 -0
- package/templates/presets/frontend/preset.json +50 -0
- package/templates/presets/fullstack/ANALYSIS_PROMPT.md +107 -0
- package/templates/presets/fullstack/CONSISTENCY_CHECKS.md +147 -0
- package/templates/presets/fullstack/PRE_COMMIT_GUIDELINES.md +125 -0
- package/templates/presets/fullstack/config.json +12 -0
- package/templates/presets/fullstack/preset.json +55 -0
- package/templates/shared/ANALYSIS_PROMPT.md +103 -0
- package/templates/shared/ANALYZE_DIFF.md +33 -0
- package/templates/shared/COMMIT_MESSAGE.md +24 -0
- package/templates/shared/PRE_COMMIT_GUIDELINES.md +145 -0
- package/templates/shared/RESOLUTION_PROMPT.md +32 -0
- package/templates/check-version.sh +0 -266
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,246 @@ 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.3.1] - 2025-11-13
|
|
9
|
+
|
|
10
|
+
### 🔄 Changed
|
|
11
|
+
|
|
12
|
+
- **Configuration Priority** - Updated merge order: `defaults < user config < preset config`
|
|
13
|
+
- **Rationale**: User sets general preferences in `.claude/config.json`, preset provides tech-stack-specific overrides (highest priority)
|
|
14
|
+
- **Effect**: Presets now correctly override user settings (e.g., preset's `model: sonnet` wins over user's `model: haiku`)
|
|
15
|
+
- **Files updated**: `lib/config.js:116` (merge logic), README.md:222 (documentation)
|
|
16
|
+
|
|
17
|
+
### ✨ Added
|
|
18
|
+
|
|
19
|
+
- **Installation Diagnostics Utility** - New `lib/utils/installation-diagnostics.js`
|
|
20
|
+
- **Purpose**: Reusable error diagnostics with actionable remediation steps
|
|
21
|
+
- **Exports**: `formatError()`, `getInstallationDiagnostics()`, `isInstallationHealthy()`
|
|
22
|
+
- **Use case**: Detects installation in wrong directory (common cause of "presets not found" errors)
|
|
23
|
+
- **Extensible**: Documented future enhancements (file permissions, Claude CLI check, etc.)
|
|
24
|
+
|
|
25
|
+
- **Enhanced Error Messages** - Better guidance when installation fails
|
|
26
|
+
- **Presets not found** (`lib/utils/preset-loader.js:194`): Shows current vs repo root directory
|
|
27
|
+
- **Hook scripts missing** (`templates/pre-commit:76`, `templates/prepare-commit-msg:76`): Early `.claude/` check with remediation steps
|
|
28
|
+
- **npm package issues**: Suggests verifying `npm list -g claude-git-hooks`
|
|
29
|
+
|
|
30
|
+
- **Bash Wrapper Early Validation** - Hooks now check `.claude/` exists before attempting execution
|
|
31
|
+
- **Why**: Fails fast with helpful message if installation incomplete or performed from wrong directory
|
|
32
|
+
- **Effect**: Users immediately know to `cd` to repo root and reinstall
|
|
33
|
+
|
|
34
|
+
- **Claude Error Diagnostics** - New `lib/utils/claude-diagnostics.js`
|
|
35
|
+
- **Purpose**: Detects and formats Claude CLI errors with actionable solutions
|
|
36
|
+
- **Error types**: Rate limit, authentication, network, invalid response, generic
|
|
37
|
+
- **Exports**: `detectClaudeError()`, `formatClaudeError()`, `ClaudeErrorType`, `isRecoverableError()`
|
|
38
|
+
- **Integration**: `lib/utils/claude-client.js:147` automatically detects and formats errors
|
|
39
|
+
- **Effect**: Users see clear guidance (e.g., "Rate limit resets in 2 hours, switch to haiku model")
|
|
40
|
+
|
|
41
|
+
### 📚 Documentation
|
|
42
|
+
|
|
43
|
+
- **CUSTOMIZATION_GUIDE.md** - Comprehensive preset creation guide in `/templates`
|
|
44
|
+
- Visual flowchart showing prompt assembly (8-step diagram)
|
|
45
|
+
- Step-by-step preset creation tutorial
|
|
46
|
+
- Placeholder system reference with examples
|
|
47
|
+
- Preset kickstart prompt for Claude-assisted generation
|
|
48
|
+
- **Burst limit warning**: Explains why git hooks hit rate limits when manual CLI doesn't
|
|
49
|
+
- Referenced in README.md:333 for discoverability
|
|
50
|
+
|
|
51
|
+
- **Utility Modules Reference** - New section in README.md:596
|
|
52
|
+
- Table of all `lib/utils/` modules with purpose and key exports
|
|
53
|
+
- Usage examples for other Claude instances
|
|
54
|
+
- Promotes code reuse across projects
|
|
55
|
+
|
|
56
|
+
- **README-NPM.md** - Complete rewrite for npm package page
|
|
57
|
+
- **Length**: 266 lines (up from 145 lines, but more focused)
|
|
58
|
+
- **Updated**: v2.3.0 presets, v2.2.0 config centralization, v2.0.0 cross-platform
|
|
59
|
+
- **Added**: Configuration priority explanation, troubleshooting, "What's New" section
|
|
60
|
+
- **Removed**: Outdated v1.x references, environment variable examples
|
|
61
|
+
|
|
62
|
+
### 🎯 User Experience
|
|
63
|
+
|
|
64
|
+
- **Clearer error context**: Errors now show current directory vs repository root
|
|
65
|
+
- **Actionable solutions**: Every error includes specific commands to fix the issue
|
|
66
|
+
- **Installation verification**: Early checks prevent confusing downstream errors
|
|
67
|
+
- **Better documentation**: Users can find utility functions and customization guides easily
|
|
68
|
+
- **Claude error clarity**: Rate limits, auth failures, and network errors now show specific remediation steps
|
|
69
|
+
|
|
70
|
+
## [2.3.0] - 2025-11-11
|
|
71
|
+
|
|
72
|
+
### ✨ Added
|
|
73
|
+
|
|
74
|
+
- **Preset System (Phase 3)**
|
|
75
|
+
- 🎯 6 built-in presets: `backend`, `frontend`, `fullstack`, `database`, `ai`, `default`
|
|
76
|
+
- 📦 Self-contained preset packages with custom prompts and configurations
|
|
77
|
+
- 🔍 Smart file filtering per preset (`.java` for backend, `.tsx` for frontend, etc.)
|
|
78
|
+
- 🎨 Rich metadata: tech stack, focus areas, file extensions, display names
|
|
79
|
+
- 🔌 Template inheritance with placeholder replacement ({{TECH_STACK}}, {{FOCUS_AREAS}})
|
|
80
|
+
- 🛠️ Manual preset selection via CLI: `claude-hooks --set-preset <name>`
|
|
81
|
+
- 📋 Preset management commands: `presets`, `preset current`, `--set-preset`
|
|
82
|
+
- 📖 See `next-steps/V2.3.0_PHASE3_PRESETS_FINAL.md` for full specification
|
|
83
|
+
|
|
84
|
+
- **CLI Enhancements**
|
|
85
|
+
- 🏷️ Added `--version`, `-v`, and `version` commands to display current version
|
|
86
|
+
- 📊 Version check on install with interactive update prompt (skippable with `--skip-auth` or `--force`)
|
|
87
|
+
|
|
88
|
+
### 🐛 Fixed
|
|
89
|
+
|
|
90
|
+
- **Critical Bug**: `prepare-commit-msg` now properly loads merged config (preset + user overrides)
|
|
91
|
+
- Was using sync default import instead of async `getConfig()`
|
|
92
|
+
- Preset settings were being ignored in commit message generation
|
|
93
|
+
- **Template Name Mismatch**: Fixed config.js template paths
|
|
94
|
+
- `COMMIT_MESSAGE.md` (was `CLAUDE_COMMIT_MESSAGE.md`)
|
|
95
|
+
- `ANALYZE_DIFF.md` (was `CLAUDE_ANALYZE_DIFF.md`)
|
|
96
|
+
- **Missing Auto-Update**: `checkVersionAndPromptUpdate()` now called during install
|
|
97
|
+
|
|
98
|
+
### 🗑️ Removed
|
|
99
|
+
|
|
100
|
+
- ❌ Deleted `readPassword()` function (24 lines) - unused since v2.0.0 sudo removal
|
|
101
|
+
- ❌ Deleted `setMode()` function (5 lines) - empty implementation, never used
|
|
102
|
+
- ❌ Deleted `readMultipleFiles()` function (62 lines) - exported but never imported
|
|
103
|
+
- ❌ Removed `"main": "lib/index.js"` from package.json - CLI-only package
|
|
104
|
+
- ❌ Deleted obsolete root template `CLAUDE_PRE_COMMIT_SONAR.md`
|
|
105
|
+
|
|
106
|
+
### 🔄 Changed
|
|
107
|
+
|
|
108
|
+
- **Commit Message Timeout**: Increased from 120s to 180s for complex analysis
|
|
109
|
+
- **Config Loading**: All hooks now use async `getConfig()` for proper preset merging
|
|
110
|
+
|
|
111
|
+
### 📚 Documentation
|
|
112
|
+
|
|
113
|
+
- 📖 Updated CHANGELOG with v2.3.0 release notes
|
|
114
|
+
- 📝 Marked Phase 3 preset system as IMPLEMENTED in spec
|
|
115
|
+
|
|
116
|
+
### 🎯 Preset Examples
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
# List available presets
|
|
120
|
+
claude-hooks presets
|
|
121
|
+
|
|
122
|
+
# Set backend preset (filters to .java, .xml, .yml files)
|
|
123
|
+
claude-hooks --set-preset backend
|
|
124
|
+
|
|
125
|
+
# Check active preset
|
|
126
|
+
claude-hooks preset current
|
|
127
|
+
|
|
128
|
+
# All presets installed during: claude-hooks install
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### 📦 Available Presets
|
|
132
|
+
|
|
133
|
+
1. **backend** - Spring Boot + SQL Server (Java, XML, YAML)
|
|
134
|
+
2. **frontend** - React + Material-UI (JS, JSX, TS, TSX, CSS)
|
|
135
|
+
3. **fullstack** - Backend + Frontend + DB with consistency checks
|
|
136
|
+
4. **database** - SQL Server migrations and procedures
|
|
137
|
+
5. **ai** - Node.js + Claude CLI integration
|
|
138
|
+
6. **default** - General-purpose scripting
|
|
139
|
+
|
|
140
|
+
### 📋 Migration from v2.2.0
|
|
141
|
+
|
|
142
|
+
No breaking changes. Presets are opt-in:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Continue using defaults (no preset)
|
|
146
|
+
git commit -m "message"
|
|
147
|
+
|
|
148
|
+
# Or activate a preset
|
|
149
|
+
claude-hooks --set-preset backend
|
|
150
|
+
git commit -m "message" # Now filters to .java, .xml, .yml only
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## [2.2.0] - 2025-11-04
|
|
154
|
+
|
|
155
|
+
### ✨ Added
|
|
156
|
+
|
|
157
|
+
- **Configuration Centralization (Phase 1)**
|
|
158
|
+
- 📁 Created `lib/config.js` - single source of truth for all configurable values
|
|
159
|
+
- 🔧 User override support via `.claude/config.json` with deep merge
|
|
160
|
+
- 📊 Structured config: analysis, commitMessage, subagents, templates, output, system, git
|
|
161
|
+
- 🚫 Eliminated environment variables (except OS for platform detection)
|
|
162
|
+
- 📖 See `next-steps/V2.2.0_CONFIG_CENTRALIZATION.md` for details
|
|
163
|
+
|
|
164
|
+
- **Prompt Externalization (Phase 2)**
|
|
165
|
+
- 📝 Extracted ALL embedded prompts to external .md template files
|
|
166
|
+
- 🔌 Created `loadPrompt()` utility - combines load + variable replacement
|
|
167
|
+
- 📄 New templates: `COMMIT_MESSAGE.md`, `ANALYZE_DIFF.md`
|
|
168
|
+
- 🎯 JavaScript is now completely "prompt-agnostic"
|
|
169
|
+
- 📖 See `next-steps/V2.2.0_PHASE2_PROMPTS.md` for details
|
|
170
|
+
|
|
171
|
+
- **Parallel Analysis**
|
|
172
|
+
- 🚀 True OS-level parallel execution using multiple Claude CLI processes simultaneously
|
|
173
|
+
- ⚡ `analyzeCodeParallel()` function runs batches via Node.js `Promise.all()`
|
|
174
|
+
- 📊 Configurable `batchSize` for optimal speed/cost balance (default: 2)
|
|
175
|
+
- 🔀 Automatic result consolidation with worst-case quality gate logic
|
|
176
|
+
- 📈 Real-time console output showing parallel batch launches and completion
|
|
177
|
+
- 🎯 Enabled by default for commits with 3+ files
|
|
178
|
+
- ⏱️ Speed improvement: up to 4x faster with `batchSize: 1`
|
|
179
|
+
|
|
180
|
+
### 🔄 Changed
|
|
181
|
+
|
|
182
|
+
- **Configuration Migration**
|
|
183
|
+
- ♻️ Migrated `lib/hooks/pre-commit.js` to use centralized config
|
|
184
|
+
- ♻️ Migrated `lib/hooks/prepare-commit-msg.js` to use centralized config
|
|
185
|
+
- ♻️ Migrated `lib/utils/claude-client.js` to use centralized config
|
|
186
|
+
- 🔧 `process.env.DEBUG` → `config.system.debug`
|
|
187
|
+
- 🔧 All hardcoded timeouts now configurable
|
|
188
|
+
|
|
189
|
+
- **Prompt Migration**
|
|
190
|
+
- ♻️ `prepare-commit-msg.js`: 40 lines → 15 lines (62% reduction)
|
|
191
|
+
- ♻️ `bin/claude-hooks`: 30 lines → 10 lines (67% reduction)
|
|
192
|
+
- 🎨 Prompts now editable without touching JavaScript code
|
|
193
|
+
|
|
194
|
+
- **Template Loading**
|
|
195
|
+
- 📂 Enhanced `loadTemplate()` with fallback: `.claude/` → `templates/`
|
|
196
|
+
- 🔀 Enables per-project customization of prompts
|
|
197
|
+
|
|
198
|
+
### 🗑️ Removed
|
|
199
|
+
|
|
200
|
+
- ❌ Deleted `buildCommitMessagePrompt()` - unused legacy code
|
|
201
|
+
- ❌ Removed all `process.env` references except OS check
|
|
202
|
+
|
|
203
|
+
### 📚 Documentation
|
|
204
|
+
|
|
205
|
+
- 📖 Added `next-steps/V2.2.0_CONFIG_CENTRALIZATION.md`
|
|
206
|
+
- 📖 Added `next-steps/V2.2.0_PHASE2_PROMPTS.md`
|
|
207
|
+
- 📝 Updated configuration examples and customization guides
|
|
208
|
+
|
|
209
|
+
### 🎯 Benefits
|
|
210
|
+
|
|
211
|
+
- **Maintainability:** Prompts editable by non-developers
|
|
212
|
+
- **Flexibility:** Easy A/B testing of prompt styles
|
|
213
|
+
- **Customization:** Per-project overrides via `.claude/config.json`
|
|
214
|
+
- **Simplicity:** Clear separation of concerns (JS = logic, .md = content)
|
|
215
|
+
|
|
216
|
+
### 📋 Migration Guide
|
|
217
|
+
|
|
218
|
+
No breaking changes. All defaults match previous behavior.
|
|
219
|
+
|
|
220
|
+
**Optional: Customize configuration**
|
|
221
|
+
```bash
|
|
222
|
+
# Create project config
|
|
223
|
+
mkdir -p .claude
|
|
224
|
+
cat > .claude/config.json << 'EOF'
|
|
225
|
+
{
|
|
226
|
+
"analysis": {
|
|
227
|
+
"maxFileSize": 200000,
|
|
228
|
+
"maxFiles": 15
|
|
229
|
+
},
|
|
230
|
+
"subagents": {
|
|
231
|
+
"enabled": true,
|
|
232
|
+
"model": "sonnet"
|
|
233
|
+
},
|
|
234
|
+
"system": {
|
|
235
|
+
"debug": true
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
EOF
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Optional: Customize prompts**
|
|
242
|
+
```bash
|
|
243
|
+
# Override commit message prompt
|
|
244
|
+
cp templates/COMMIT_MESSAGE.md .claude/
|
|
245
|
+
# Edit .claude/COMMIT_MESSAGE.md as needed
|
|
246
|
+
```
|
|
247
|
+
|
|
8
248
|
## [2.1.0] - 2025-11-04
|
|
9
249
|
|
|
10
250
|
### Changed
|