claude-git-hooks 2.14.4 → 2.16.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +116 -5
  2. package/LICENSE +20 -20
  3. package/bin/claude-hooks +84 -84
  4. package/lib/commands/analyze-diff.js +0 -1
  5. package/lib/commands/bump-version.js +346 -114
  6. package/lib/commands/create-pr.js +1 -1
  7. package/lib/commands/debug.js +1 -1
  8. package/lib/commands/generate-changelog.js +5 -6
  9. package/lib/commands/helpers.js +11 -6
  10. package/lib/commands/install.js +7 -8
  11. package/lib/commands/migrate-config.js +24 -2
  12. package/lib/commands/setup-github.js +1 -1
  13. package/lib/commands/update.js +1 -1
  14. package/lib/config.js +0 -4
  15. package/lib/hooks/prepare-commit-msg.js +2 -2
  16. package/lib/utils/changelog-generator.js +6 -8
  17. package/lib/utils/claude-client.js +7 -6
  18. package/lib/utils/claude-diagnostics.js +14 -21
  19. package/lib/utils/file-operations.js +1 -1
  20. package/lib/utils/file-utils.js +0 -1
  21. package/lib/utils/git-operations.js +0 -1
  22. package/lib/utils/github-api.js +3 -3
  23. package/lib/utils/github-client.js +2 -2
  24. package/lib/utils/installation-diagnostics.js +1 -1
  25. package/lib/utils/interactive-ui.js +93 -0
  26. package/lib/utils/prompt-builder.js +4 -6
  27. package/lib/utils/sanitize.js +13 -14
  28. package/lib/utils/task-id.js +18 -20
  29. package/lib/utils/telemetry.js +5 -7
  30. package/lib/utils/version-manager.js +676 -296
  31. package/package.json +68 -60
  32. package/templates/config.advanced.example.json +113 -113
  33. package/templates/pre-commit +7 -0
  34. package/templates/presets/ai/config.json +5 -5
  35. package/templates/presets/backend/config.json +5 -5
  36. package/templates/presets/backend/preset.json +49 -49
  37. package/templates/presets/database/config.json +5 -5
  38. package/templates/presets/database/preset.json +38 -38
  39. package/templates/presets/default/config.json +5 -5
  40. package/templates/presets/default/preset.json +53 -53
  41. package/templates/presets/frontend/config.json +5 -5
  42. package/templates/presets/frontend/preset.json +50 -50
  43. package/templates/presets/fullstack/config.json +5 -5
  44. package/templates/presets/fullstack/preset.json +55 -55
package/CHANGELOG.md CHANGED
@@ -5,84 +5,195 @@ 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.14.4] - 2026-02-06
8
+ ## [2.16.0] - 2026-02-15
9
+
10
+ ### ✨ Added
11
+ - Multi-file version discovery with recursive scanning up to 3 levels deep
12
+ - Per-file version editing with `--interactive` flag for advanced control
13
+ - Support for additional project types: build.gradle, build.gradle.kts, pyproject.toml, Cargo.toml, version.sbt
14
+ - Suffix-only operations with `--remove-suffix` and `--set-suffix` flags
15
+ - Interactive file selection menu when version mismatch detected or `--interactive` enabled
16
+ - Version files discovery table showing all detected files with versions
17
+ - Automatic rollback of version changes on failure
18
+ - New UI components: `promptToggleList()` and `promptEditField()` in interactive-ui.js
19
+
20
+ ### 🔧 Changed
21
+ - Refactored version-manager.js to use new discovery-based API with `discoverVersionFiles()`, `updateVersionFiles()`, and `modifySuffix()`
22
+ - Bump-version workflow now supports selecting specific files to update
23
+ - Each file can have an independent target version when using per-file editing mode
24
+ - Updated CLAUDE.md documentation with new version bump flow and API changes
25
+
26
+ ### ⚠️ Deprecated
27
+ - Legacy version-manager functions `detectProjectType()`, `getCurrentVersion()`, `updateVersion()`, and `getDiscoveredPaths()` replaced by new discovery API
28
+
29
+
30
+ ## [2.15.5] - 2026-02-12
31
+
32
+ ### ✨ Added
33
+ - Added comprehensive CI-safe integration test suite that runs without Claude CLI dependency
34
+ - Added new test scripts: `test:integration:ci` for CI environments and `test:changed` for testing only modified files
35
+
36
+ ### 🔧 Changed
37
+ - Optimized CI matrix to run full OS/Node.js combinations only on push events, reducing PR build times
38
+ - Refactored integration tests to verify installation workflow, hook lifecycle, config persistence, and CLI routing
39
+ - Improved timeout handling in Claude CLI client by clearing timeouts consistently on all exit paths
40
+ - Simplified template variable replacement in prompt-builder with cleaner regex handling
41
+ - Reduced Jest verbosity and coverage reporters for cleaner CI output
42
+
43
+ ### 🐛 Fixed
44
+ - Fixed potential timeout leak in claude-client.js where timeouts were not cleared on error or stdin failures
45
+
46
+ ### 🗑️ Removed
47
+ - Removed unused variables and parameters across multiple modules (analyze-diff, create-pr, install, config, changelog-generator, claude-client, claude-diagnostics, file-utils, git-operations, prompt-builder)
48
+
49
+
50
+ ## [2.15.4] - 2026-02-11
51
+
52
+ ### ✨ Added
53
+ - Added comprehensive unit tests for claude-diagnostics.js covering error detection, formatting, and recovery classification
54
+ - Added unit tests for file-utils.js covering directory creation and file writing operations
55
+
56
+
57
+ ## [2.15.3] - 2026-02-10
58
+
59
+ ### ✨ Added
60
+ - Unit tests for `generate-changelog.js` command covering CHANGELOG generation, version detection, and error handling
61
+ - Unit tests for `github-client.js` covering CODEOWNERS parsing, reviewer detection, and GitHub repo parsing
62
+ - Unit tests for `hooks.js` command covering enable, disable, status, and uninstall operations
63
+
64
+
65
+ ## [2.15.2] - 2026-02-10
9
66
 
10
67
  ### 🔧 Changed
11
68
  - The bump-version command now uses the configured default branch (from github.pr.defaultBase) in the 'Next steps' output instead of hardcoded 'main'
12
69
 
70
+ ### 🐛 Fixed
71
+ - Fixed cross-platform path assertions in unit tests to use partial matching instead of exact paths, improving Windows compatibility
72
+
73
+
74
+ ## [2.15.1] - 2026-02-10
75
+
76
+ ### 🐛 Fixed
77
+
78
+ - Fixed cross-platform test compatibility for Windows environments by updating path assertions to use partial matching instead of exact Unix paths
79
+ - Fixed CI workflow to properly skip integration tests that require Claude CLI, with clear documentation about manual testing requirements
80
+ - Fixed Unix-specific tests to be skipped on Windows platform
81
+ - Fixed executable file permissions for bin/claude-hooks and hook templates (pre-commit, prepare-commit-msg)
82
+
83
+ ## [2.15.0] - 2026-02-10
84
+
85
+ ### ✨ Added
86
+
87
+ - Comprehensive testing suite with GitHub Actions CI workflow including lint, smoke tests, unit tests, integration tests, and dogfooding checks
88
+ - Cross-platform unit tests running on Ubuntu, Windows, and macOS with Node.js 18, 20, and 22
89
+ - Codecov integration for coverage reporting on unit and integration tests
90
+ - Per-module coverage thresholds for critical modules (config.js, helpers.js, git-operations.js, preset-loader.js, analysis-engine.js)
91
+
92
+ ### 🔧 Changed
93
+
94
+ - Updated ESLint configuration from ECMAScript 2021 to 2022
95
+ - Improved Jest configuration with separate coverage reporters (text, text-summary, lcov, html) and adjusted global coverage thresholds
96
+ - Updated .gitignore to track test files (\*.test.js) while ignoring coverage directory
97
+
98
+ ### 🐛 Fixed
99
+
100
+ - Fixed ESLint linting issues across utility and command modules including string concatenation, switch case indentation, and arrow function formatting (#68)
101
+
102
+ ## [2.14.4] - 2026-02-09
103
+
104
+ ### 🔧 Changed
105
+
106
+ - The migrate-config command now detects and fixes incorrectly placed preset fields in config overrides
107
+
108
+ ### 🐛 Fixed
109
+
110
+ - Fixed preset field being incorrectly placed inside overrides when using --set-preset command (#66)
13
111
 
14
112
  ## [2.14.3] - 2026-02-06
15
113
 
114
+ ### 🔧 Changed
115
+
116
+ - The bump-version command now uses the configured default branch (from github.pr.defaultBase) in the 'Next steps' output instead of hardcoded 'main'
16
117
 
17
118
  ## [2.14.2] - 2026-02-06
18
119
 
19
120
  ### ✨ Added
121
+
20
122
  - New `--push` flag for `bump-version` command to explicitly push tags to remote when desired
21
123
 
22
124
  ### 🔧 Changed
125
+
23
126
  - Changed `bump-version` default behavior to keep tags local instead of automatically pushing to remote (#65)
24
127
  - Tags are now pushed by `create-pr` command or manually with `--push` flag, providing better control over the release workflow
25
128
  - Updated documentation in README.md, README-NPM.md, and CLAUDE.md to reflect new tag push behavior
26
129
 
27
130
  ### ⚠️ Deprecated
131
+
28
132
  - The `--no-push` flag for `bump-version` is no longer needed as tags now stay local by default
29
133
 
30
134
  ### 🗑️ Removed
31
- - Removed RFC-001 documentation file (pr-metadata-engine-refactor.md) as the refactor has been completed
32
135
 
136
+ - Removed RFC-001 documentation file (pr-metadata-engine-refactor.md) as the refactor has been completed
33
137
 
34
138
  ## [2.14.1] - 2026-02-06
35
139
 
36
140
  ### 🔧 Changed
141
+
37
142
  - Improved `bump-version` command workflow - now automatically stages and commits version changes with conventional commit format before tag creation
38
143
  - Enhanced `bump-version` command flexibility - added `--no-commit` flag for manual workflows where users prefer to commit changes themselves
39
144
  - Improved error handling in `bump-version` - provides clearer guidance when staging or committing fails, with manual fallback instructions
40
145
  - Enhanced next-steps guidance in `bump-version` output - adapts instructions based on flags used (--no-commit, --no-push, --no-tag)
41
146
 
42
147
  ### 🐛 Fixed
148
+
43
149
  - Fixed `bump-version` workflow inconsistency - prevented tag creation when using `--no-commit` flag, as tags should only be created after changes are committed
44
150
  - Fixed potential git history issues - version bump commits now use `--no-verify` flag to bypass pre-commit hooks and prevent circular execution
45
151
 
46
152
  ### 🗑️ Removed
47
- - Removed redundant fallback warnings from `analyze-diff` and `create-pr` commands - warnings were unnecessary as base branch resolution now throws clear errors with suggestions instead
48
153
 
154
+ - Removed redundant fallback warnings from `analyze-diff` and `create-pr` commands - warnings were unnecessary as base branch resolution now throws clear errors with suggestions instead
49
155
 
50
156
  ## [2.14.0] - 2026-02-06
51
157
 
52
158
  ### ✨ Added
159
+
53
160
  - PR metadata engine (`pr-metadata-engine.js`) - centralized module for generating PR titles, descriptions, and test plans from branch diffs with timeout resilience (#63)
54
161
  - Tiered diff reduction system - automatically truncates large diffs using context reduction, proportional budgets, and stat-only summaries to prevent timeouts
55
162
  - Extended git operations - added `fetchRemote()`, `branchExists()`, `resolveBaseBranch()`, `getChangedFilesBetweenRefs()`, `getDiffBetweenRefs()`, and `getCommitsBetweenRefs()` to `git-operations.js`
56
163
  - RFC-001 documentation - comprehensive design specification for PR metadata engine refactor with timeout resilience strategy
57
164
 
58
165
  ### 🔧 Changed
166
+
59
167
  - Refactored `analyze-diff` command to use shared PR metadata engine - reduced from 262 to ~80 lines by eliminating duplicate git logic
60
168
  - Refactored `create-pr` command to use shared PR metadata engine - eliminated duplicate diff extraction logic (lines 340-420)
61
169
  - Improved timeout error handling - timeout errors now include `errorInfo` and are classified as recoverable for automatic retry with exponential backoff
62
170
  - Updated CLAUDE.md with PR metadata engine architecture, new git operations exports, and tiered diff reduction strategy
63
171
 
64
172
  ### 🐛 Fixed
173
+
65
174
  - Fixed timeout failures in `analyze-diff` for large diffs - now uses tiered reduction instead of monolithic diff processing
66
175
  - Fixed inconsistent behavior between `analyze-diff` and `create-pr` commands - both now share identical analysis logic via unified engine
67
176
 
68
177
  ### 🗑️ Removed
69
- - Removed unreliable `SUBAGENT_INSTRUCTION` text hint - replaced with deterministic tiered diff reduction for parallel processing
70
178
 
179
+ - Removed unreliable `SUBAGENT_INSTRUCTION` text hint - replaced with deterministic tiered diff reduction for parallel processing
71
180
 
72
181
  ## [2.13.0] - 2026-02-05
73
182
 
74
183
  ### ✨ Added
184
+
75
185
  - Interactive analysis command `claude-hooks analyze` - review all issues (INFO to BLOCKER) interactively before committing with auto-commit option
76
186
  - Shared analysis engine module (`analysis-engine.js`) - centralized file data building, analysis orchestration, and results display for both pre-commit hooks and interactive analysis
77
187
  - Support for version files in subdirectories - automatically searches parent directories when version files not found in repo root
78
188
  - Auto-commit functionality after interactive analysis - creates commit with auto-generated message when user confirms
79
189
 
80
190
  ### 🔧 Changed
191
+
81
192
  - Improved version detection logic for pom.xml files - enhanced reliability of version extraction in Maven projects
82
193
 
83
194
  ### 🐛 Fixed
84
- - Fixed version search logic for pom.xml files - corrected parsing issues in Maven version detection
85
195
 
196
+ - Fixed version search logic for pom.xml files - corrected parsing issues in Maven version detection
86
197
 
87
198
  ## [2.12.0] - 2026-02-03
88
199
 
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Pablo Rovito
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Pablo Rovito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/bin/claude-hooks CHANGED
@@ -34,90 +34,90 @@ async function main() {
34
34
  const command = args[0];
35
35
 
36
36
  switch (command) {
37
- case 'install':
38
- await runInstall(args.slice(1));
39
- break;
40
- case 'update':
41
- await runUpdate();
42
- break;
43
- case 'uninstall':
44
- runUninstall();
45
- break;
46
- case 'enable':
47
- runEnable(args[1]);
48
- break;
49
- case 'disable':
50
- runDisable(args[1]);
51
- break;
52
- case 'status':
53
- runStatus();
54
- break;
55
- case 'analyze':
56
- await runAnalyze({
57
- staged: !args.includes('--unstaged') && !args.includes('--all'),
58
- unstaged: args.includes('--unstaged'),
59
- all: args.includes('--all')
60
- });
61
- break;
62
- case 'analyze-diff':
63
- await runAnalyzeDiff(args.slice(1));
64
- break;
65
- case 'create-pr':
66
- await runCreatePr(args.slice(1));
67
- break;
68
- case 'setup-github':
69
- await runSetupGitHub();
70
- break;
71
- case 'presets':
72
- await runShowPresets();
73
- break;
74
- case '--set-preset':
75
- await runSetPreset(args[1]);
76
- break;
77
- case 'preset':
78
- // Handle subcommands: preset current
79
- if (args[1] === 'current') {
80
- await runCurrentPreset();
81
- } else {
82
- error(`Unknown preset subcommand: ${args[1]}`);
83
- }
84
- break;
85
- case 'migrate-config':
86
- await runMigrateConfig();
87
- break;
88
- case 'bump-version':
89
- await runBumpVersion(args.slice(1));
90
- break;
91
- case 'generate-changelog':
92
- await runGenerateChangelog(args.slice(1));
93
- break;
94
- case 'telemetry':
95
- // Handle subcommands: telemetry show, telemetry clear
96
- if (args[1] === 'show' || args[1] === undefined) {
97
- await runShowTelemetry();
98
- } else if (args[1] === 'clear') {
99
- await runClearTelemetry();
100
- } else {
101
- error(`Unknown telemetry subcommand: ${args[1]}`);
102
- }
103
- break;
104
- case '--debug':
105
- await runSetDebug(args[1]);
106
- break;
107
- case '--version':
108
- case '-v':
109
- case 'version':
110
- runShowVersion();
111
- break;
112
- case 'help':
113
- case '--help':
114
- case '-h':
115
- case undefined:
116
- runShowHelp();
117
- break;
118
- default:
119
- error(`Unknown command: ${command}`);
120
- runShowHelp();
37
+ case 'install':
38
+ await runInstall(args.slice(1));
39
+ break;
40
+ case 'update':
41
+ await runUpdate();
42
+ break;
43
+ case 'uninstall':
44
+ runUninstall();
45
+ break;
46
+ case 'enable':
47
+ runEnable(args[1]);
48
+ break;
49
+ case 'disable':
50
+ runDisable(args[1]);
51
+ break;
52
+ case 'status':
53
+ runStatus();
54
+ break;
55
+ case 'analyze':
56
+ await runAnalyze({
57
+ staged: !args.includes('--unstaged') && !args.includes('--all'),
58
+ unstaged: args.includes('--unstaged'),
59
+ all: args.includes('--all')
60
+ });
61
+ break;
62
+ case 'analyze-diff':
63
+ await runAnalyzeDiff(args.slice(1));
64
+ break;
65
+ case 'create-pr':
66
+ await runCreatePr(args.slice(1));
67
+ break;
68
+ case 'setup-github':
69
+ await runSetupGitHub();
70
+ break;
71
+ case 'presets':
72
+ await runShowPresets();
73
+ break;
74
+ case '--set-preset':
75
+ await runSetPreset(args[1]);
76
+ break;
77
+ case 'preset':
78
+ // Handle subcommands: preset current
79
+ if (args[1] === 'current') {
80
+ await runCurrentPreset();
81
+ } else {
82
+ error(`Unknown preset subcommand: ${args[1]}`);
83
+ }
84
+ break;
85
+ case 'migrate-config':
86
+ await runMigrateConfig();
87
+ break;
88
+ case 'bump-version':
89
+ await runBumpVersion(args.slice(1));
90
+ break;
91
+ case 'generate-changelog':
92
+ await runGenerateChangelog(args.slice(1));
93
+ break;
94
+ case 'telemetry':
95
+ // Handle subcommands: telemetry show, telemetry clear
96
+ if (args[1] === 'show' || args[1] === undefined) {
97
+ await runShowTelemetry();
98
+ } else if (args[1] === 'clear') {
99
+ await runClearTelemetry();
100
+ } else {
101
+ error(`Unknown telemetry subcommand: ${args[1]}`);
102
+ }
103
+ break;
104
+ case '--debug':
105
+ await runSetDebug(args[1]);
106
+ break;
107
+ case '--version':
108
+ case '-v':
109
+ case 'version':
110
+ runShowVersion();
111
+ break;
112
+ case 'help':
113
+ case '--help':
114
+ case '-h':
115
+ case undefined:
116
+ runShowHelp();
117
+ break;
118
+ default:
119
+ error(`Unknown command: ${command}`);
120
+ runShowHelp();
121
121
  }
122
122
  }
123
123
 
@@ -11,7 +11,6 @@ import {
11
11
  colors,
12
12
  error,
13
13
  info,
14
- warning,
15
14
  checkGitRepo
16
15
  } from './helpers.js';
17
16