claude-git-hooks 2.16.0 → 2.17.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 +38 -5
- package/README.md +3 -0
- package/lib/commands/help.js +34 -170
- package/lib/commands/helpers.js +20 -0
- package/lib/commands/hooks.js +12 -8
- package/lib/commands/install.js +8 -31
- package/lib/utils/installation-diagnostics.js +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,9 +5,37 @@ 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.17.1] - 2026-03-02
|
|
9
|
+
|
|
10
|
+
### 🐛 Fixed
|
|
11
|
+
|
|
12
|
+
- Installer no longer crashes with `ENOTDIR` when running inside a Git worktree where `.git` is a file pointer instead of a directory
|
|
13
|
+
- Hook management commands (`enable`, `disable`, `status`, `uninstall`) now correctly resolve the hooks path in worktree repos
|
|
14
|
+
|
|
15
|
+
### 🔧 Changed
|
|
16
|
+
|
|
17
|
+
- Extracted `getGitHooksPath()` to `helpers.js` — uses `git rev-parse --git-common-dir` to find the shared hooks directory in both regular repos and worktrees
|
|
18
|
+
|
|
19
|
+
## [2.17.0] - 2026-02-16
|
|
20
|
+
|
|
21
|
+
### ✨ Added
|
|
22
|
+
|
|
23
|
+
- Automatic GitHub token setup now runs after installation
|
|
24
|
+
|
|
25
|
+
### 🔧 Changed
|
|
26
|
+
|
|
27
|
+
- Simplified CLI help output to show concise command reference instead of verbose documentation
|
|
28
|
+
- Commands in help output are now listed in alphabetical order for easier navigation
|
|
29
|
+
- Installation success message now shows single help reference instead of detailed usage examples
|
|
30
|
+
|
|
31
|
+
### 🗑️ Removed
|
|
32
|
+
|
|
33
|
+
- Removed extensive inline documentation from help output (use README for detailed docs)
|
|
34
|
+
|
|
8
35
|
## [2.16.0] - 2026-02-15
|
|
9
36
|
|
|
10
37
|
### ✨ Added
|
|
38
|
+
|
|
11
39
|
- Multi-file version discovery with recursive scanning up to 3 levels deep
|
|
12
40
|
- Per-file version editing with `--interactive` flag for advanced control
|
|
13
41
|
- Support for additional project types: build.gradle, build.gradle.kts, pyproject.toml, Cargo.toml, version.sbt
|
|
@@ -18,22 +46,25 @@ y este proyecto adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.h
|
|
|
18
46
|
- New UI components: `promptToggleList()` and `promptEditField()` in interactive-ui.js
|
|
19
47
|
|
|
20
48
|
### 🔧 Changed
|
|
49
|
+
|
|
21
50
|
- Refactored version-manager.js to use new discovery-based API with `discoverVersionFiles()`, `updateVersionFiles()`, and `modifySuffix()`
|
|
22
51
|
- Bump-version workflow now supports selecting specific files to update
|
|
23
52
|
- Each file can have an independent target version when using per-file editing mode
|
|
24
53
|
- Updated CLAUDE.md documentation with new version bump flow and API changes
|
|
25
54
|
|
|
26
55
|
### ⚠️ Deprecated
|
|
27
|
-
- Legacy version-manager functions `detectProjectType()`, `getCurrentVersion()`, `updateVersion()`, and `getDiscoveredPaths()` replaced by new discovery API
|
|
28
56
|
|
|
57
|
+
- Legacy version-manager functions `detectProjectType()`, `getCurrentVersion()`, `updateVersion()`, and `getDiscoveredPaths()` replaced by new discovery API
|
|
29
58
|
|
|
30
59
|
## [2.15.5] - 2026-02-12
|
|
31
60
|
|
|
32
61
|
### ✨ Added
|
|
62
|
+
|
|
33
63
|
- Added comprehensive CI-safe integration test suite that runs without Claude CLI dependency
|
|
34
64
|
- Added new test scripts: `test:integration:ci` for CI environments and `test:changed` for testing only modified files
|
|
35
65
|
|
|
36
66
|
### 🔧 Changed
|
|
67
|
+
|
|
37
68
|
- Optimized CI matrix to run full OS/Node.js combinations only on push events, reducing PR build times
|
|
38
69
|
- Refactored integration tests to verify installation workflow, hook lifecycle, config persistence, and CLI routing
|
|
39
70
|
- Improved timeout handling in Claude CLI client by clearing timeouts consistently on all exit paths
|
|
@@ -41,35 +72,37 @@ y este proyecto adhiere a [Semantic Versioning](https://semver.org/spec/v2.0.0.h
|
|
|
41
72
|
- Reduced Jest verbosity and coverage reporters for cleaner CI output
|
|
42
73
|
|
|
43
74
|
### 🐛 Fixed
|
|
75
|
+
|
|
44
76
|
- Fixed potential timeout leak in claude-client.js where timeouts were not cleared on error or stdin failures
|
|
45
77
|
|
|
46
78
|
### 🗑️ 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
79
|
|
|
80
|
+
- 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)
|
|
49
81
|
|
|
50
82
|
## [2.15.4] - 2026-02-11
|
|
51
83
|
|
|
52
84
|
### ✨ Added
|
|
85
|
+
|
|
53
86
|
- Added comprehensive unit tests for claude-diagnostics.js covering error detection, formatting, and recovery classification
|
|
54
87
|
- Added unit tests for file-utils.js covering directory creation and file writing operations
|
|
55
88
|
|
|
56
|
-
|
|
57
89
|
## [2.15.3] - 2026-02-10
|
|
58
90
|
|
|
59
91
|
### ✨ Added
|
|
92
|
+
|
|
60
93
|
- Unit tests for `generate-changelog.js` command covering CHANGELOG generation, version detection, and error handling
|
|
61
94
|
- Unit tests for `github-client.js` covering CODEOWNERS parsing, reviewer detection, and GitHub repo parsing
|
|
62
95
|
- Unit tests for `hooks.js` command covering enable, disable, status, and uninstall operations
|
|
63
96
|
|
|
64
|
-
|
|
65
97
|
## [2.15.2] - 2026-02-10
|
|
66
98
|
|
|
67
99
|
### 🔧 Changed
|
|
100
|
+
|
|
68
101
|
- The bump-version command now uses the configured default branch (from github.pr.defaultBase) in the 'Next steps' output instead of hardcoded 'main'
|
|
69
102
|
|
|
70
103
|
### 🐛 Fixed
|
|
71
|
-
- Fixed cross-platform path assertions in unit tests to use partial matching instead of exact paths, improving Windows compatibility
|
|
72
104
|
|
|
105
|
+
- Fixed cross-platform path assertions in unit tests to use partial matching instead of exact paths, improving Windows compatibility
|
|
73
106
|
|
|
74
107
|
## [2.15.1] - 2026-02-10
|
|
75
108
|
|
package/README.md
CHANGED
|
@@ -243,8 +243,11 @@ claude-hooks --help # Full command reference
|
|
|
243
243
|
| `helpers.js` | **Shared CLI utilities** - colors, output, platform detection | `colors`, `error()`, `success()`, `info()`, `checkGitRepo()`, `Entertainment` |
|
|
244
244
|
| `install.js` | **Installation logic** - dependencies, hooks, templates | `runInstall()`, `extractLegacySettings()` |
|
|
245
245
|
| `hooks.js` | **Hook management** - enable, disable, status, uninstall | `runEnable()`, `runDisable()`, `runStatus()`, `runUninstall()` |
|
|
246
|
+
| `analyze.js` | **Interactive code analysis** - analyze before committing | `runAnalyze()` |
|
|
246
247
|
| `analyze-diff.js` | **Diff analysis** - generate PR metadata from git diff | `runAnalyzeDiff()` |
|
|
247
248
|
| `create-pr.js` | **PR creation** - full workflow via Octokit | `runCreatePr()` |
|
|
249
|
+
| `bump-version.js` | **Version management** - bump with CHANGELOG and Git tag | `runBumpVersion()` |
|
|
250
|
+
| `generate-changelog.js` | **CHANGELOG generation** - standalone command | `runGenerateChangelog()` |
|
|
248
251
|
| `setup-github.js` | **Token setup** - interactive GitHub configuration | `runSetupGitHub()` |
|
|
249
252
|
| `presets.js` | **Preset management** - list, set, show current | `runShowPresets()`, `runSetPreset()`, `runCurrentPreset()` |
|
|
250
253
|
| `update.js` | **Self-update** - check and install latest version | `runUpdate()` |
|
package/lib/commands/help.js
CHANGED
|
@@ -24,176 +24,40 @@ Claude Git Hooks - Code analysis and automatic messages with Claude CLI
|
|
|
24
24
|
Usage: claude-hooks <command> [options]
|
|
25
25
|
|
|
26
26
|
Commands:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
--
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
preset current
|
|
53
|
-
|
|
54
|
-
--
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
Examples:
|
|
63
|
-
claude-hooks install # Install all hooks
|
|
64
|
-
claude-hooks install --skip-auth # Install without verifying authentication
|
|
65
|
-
claude-hooks update # Update to the latest version
|
|
66
|
-
claude-hooks disable pre-commit # Disable only pre-commit
|
|
67
|
-
claude-hooks enable # Enable all hooks
|
|
68
|
-
claude-hooks status # View current status
|
|
69
|
-
claude-hooks analyze-diff main # Analyze differences with main
|
|
70
|
-
claude-hooks setup-github # Configure GitHub token for PR creation
|
|
71
|
-
claude-hooks create-pr develop # Create PR targeting develop branch
|
|
72
|
-
claude-hooks bump-version minor # Bump minor version with tag
|
|
73
|
-
claude-hooks bump-version patch --suffix SNAPSHOT # Add SNAPSHOT version
|
|
74
|
-
claude-hooks bump-version major --update-changelog # Bump and update CHANGELOG
|
|
75
|
-
claude-hooks generate-changelog # Generate CHANGELOG for current version
|
|
76
|
-
claude-hooks generate-changelog 2.7.0 --release # Generate for specific release
|
|
77
|
-
claude-hooks presets # List available presets
|
|
78
|
-
claude-hooks --set-preset backend # Set backend preset
|
|
79
|
-
claude-hooks preset current # Show current preset
|
|
80
|
-
claude-hooks telemetry show # Show telemetry statistics
|
|
81
|
-
claude-hooks telemetry clear # Clear telemetry data
|
|
82
|
-
claude-hooks --debug true # Enable debug mode
|
|
83
|
-
claude-hooks --debug status # Check debug status
|
|
84
|
-
|
|
85
|
-
Commit use cases:
|
|
86
|
-
git commit -m "message" # Manual message + blocking analysis
|
|
87
|
-
git commit -m "auto" # Automatic message + blocking analysis
|
|
88
|
-
git commit --no-verify -m "auto" # Automatic message without analysis
|
|
89
|
-
git commit --no-verify -m "msg" # Manual message without analysis
|
|
90
|
-
|
|
91
|
-
Analyze-diff use case:
|
|
92
|
-
claude-hooks analyze-diff main # Analyze changes vs main and generate:
|
|
93
|
-
→ PR Title: "feat: add user authentication module"
|
|
94
|
-
→ PR Description: "## Summary\n- Added JWT authentication..."
|
|
95
|
-
→ Suggested branch: "feature/user-authentication"
|
|
96
|
-
|
|
97
|
-
Create-pr use case (v2.5.0+):
|
|
98
|
-
claude-hooks create-pr develop # Create PR targeting develop:
|
|
99
|
-
→ Validates GitHub token
|
|
100
|
-
→ Extracts task-id from branch (IX-123, #456, LIN-123)
|
|
101
|
-
→ Checks version alignment (package.json, pom.xml, CHANGELOG, tags)
|
|
102
|
-
→ Detects and prompts to push unpushed tags
|
|
103
|
-
→ Analyzes diff and generates PR metadata with Claude
|
|
104
|
-
→ Creates PR directly via GitHub API (Octokit)
|
|
105
|
-
→ Adds labels based on preset
|
|
106
|
-
→ Returns PR URL
|
|
107
|
-
|
|
108
|
-
Token configuration:
|
|
109
|
-
→ .claude/settings.local.json (recommended, gitignored)
|
|
110
|
-
→ GITHUB_TOKEN environment variable
|
|
111
|
-
→ Claude Desktop config (auto-detected)
|
|
112
|
-
|
|
113
|
-
Bump-version use case (v2.12.0+):
|
|
114
|
-
claude-hooks bump-version patch --update-changelog
|
|
115
|
-
→ Validates prerequisites (clean working dir, valid branch, remote)
|
|
116
|
-
→ Detects project type (Node.js, Maven, or both)
|
|
117
|
-
→ Increments version (major/minor/patch)
|
|
118
|
-
→ Updates package.json and/or pom.xml
|
|
119
|
-
→ Generates CHANGELOG entry with Claude (if --update-changelog)
|
|
120
|
-
→ Creates annotated Git tag (v2.7.0)
|
|
121
|
-
→ Pushes tag to remote
|
|
122
|
-
|
|
123
|
-
Version workflow examples:
|
|
124
|
-
2.7.0 → 2.8.0-SNAPSHOT # Start development
|
|
125
|
-
2.8.0-SNAPSHOT → 2.8.0-RC # Release candidate
|
|
126
|
-
2.8.0-RC → 2.8.0 # Final release
|
|
127
|
-
|
|
128
|
-
Integration with create-pr:
|
|
129
|
-
→ Automatically detects version misalignment
|
|
130
|
-
→ Prompts to push unpushed tags before PR creation
|
|
131
|
-
→ Warns if local version <= remote version
|
|
132
|
-
|
|
133
|
-
Generate-changelog use case (v2.12.0+):
|
|
134
|
-
claude-hooks generate-changelog [version]
|
|
135
|
-
→ Standalone CHANGELOG generation (no version bump)
|
|
136
|
-
→ Auto-detects version from package.json or pom.xml
|
|
137
|
-
→ Analyzes commits since last tag using Claude
|
|
138
|
-
→ Updates CHANGELOG.md with categorized entries
|
|
139
|
-
→ Useful when bump-version CHANGELOG step fails
|
|
140
|
-
→ Can mark as released or unreleased
|
|
141
|
-
|
|
142
|
-
Examples:
|
|
143
|
-
claude-hooks generate-changelog # Use current version
|
|
144
|
-
claude-hooks generate-changelog 2.7.0 --release # Specific release
|
|
145
|
-
claude-hooks generate-changelog --base-branch develop # Compare vs develop
|
|
146
|
-
|
|
147
|
-
Presets (v2.3.0+):
|
|
148
|
-
Built-in tech-stack specific configurations:
|
|
149
|
-
- backend: Spring Boot + SQL Server (.java, .xml, .yml)
|
|
150
|
-
- frontend: React + Material-UI (.js, .jsx, .ts, .tsx, .css)
|
|
151
|
-
- fullstack: Backend + Frontend with API consistency checks
|
|
152
|
-
- database: SQL Server migrations and procedures (.sql)
|
|
153
|
-
- ai: Node.js + Claude CLI integration (.js, .json, .md)
|
|
154
|
-
- default: General-purpose mixed languages
|
|
155
|
-
|
|
156
|
-
Configuration (v2.2.0+):
|
|
157
|
-
Create .claude/config.json in your project to customize:
|
|
158
|
-
- Preset selection
|
|
159
|
-
- Analysis settings (maxFileSize, maxFiles, timeout)
|
|
160
|
-
- Commit message generation (autoKeyword, timeout)
|
|
161
|
-
- Parallel execution (enabled, model, batchSize)
|
|
162
|
-
- Template paths and output files
|
|
163
|
-
- Debug mode
|
|
164
|
-
|
|
165
|
-
Example: .claude/config.json
|
|
166
|
-
{
|
|
167
|
-
"preset": "backend",
|
|
168
|
-
"analysis": { "maxFiles": 30, "timeout": 180000 },
|
|
169
|
-
"subagents": {
|
|
170
|
-
"enabled": true, // Enable parallel execution
|
|
171
|
-
"model": "haiku", // haiku (fast) | sonnet | opus
|
|
172
|
-
"batchSize": 2 // Files per batch (1=fastest)
|
|
173
|
-
},
|
|
174
|
-
"system": { "debug": true }
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
Parallel Analysis (v2.2.0+):
|
|
178
|
-
When analyzing 3+ files, parallel execution runs multiple Claude CLI
|
|
179
|
-
processes simultaneously for faster analysis:
|
|
180
|
-
- batchSize: 1 → Maximum speed (1 file per process)
|
|
181
|
-
- batchSize: 2 → Balanced (2 files per process)
|
|
182
|
-
- batchSize: 4+ → Fewer API calls but slower
|
|
183
|
-
- Speed improvement: up to 4x faster with batchSize: 1
|
|
184
|
-
|
|
185
|
-
Debug Mode:
|
|
186
|
-
Enable detailed logging for troubleshooting:
|
|
187
|
-
- CLI: claude-hooks --debug true
|
|
188
|
-
- Config: "system": { "debug": true } in .claude/config.json
|
|
189
|
-
- Check status: claude-hooks --debug status
|
|
190
|
-
|
|
191
|
-
Customization:
|
|
192
|
-
Override prompts by copying to .claude/:
|
|
193
|
-
cp templates/COMMIT_MESSAGE.md .claude/
|
|
194
|
-
cp templates/ANALYZE_DIFF.md .claude/
|
|
195
|
-
cp templates/CLAUDE_PRE_COMMIT.md .claude/
|
|
196
|
-
# Edit as needed - system uses .claude/ version if exists
|
|
27
|
+
analyze [--unstaged | --all] Analyze code interactively before committing
|
|
28
|
+
analyze-diff [base] Analyze diff and generate PR metadata
|
|
29
|
+
bump-version [type] [options] Bump version with CHANGELOG and Git tag
|
|
30
|
+
<type>: major | minor | patch (optional for suffix-only operations)
|
|
31
|
+
--dry-run Preview changes without applying
|
|
32
|
+
--interactive Force file selection menu
|
|
33
|
+
--no-commit Skip automatic commit
|
|
34
|
+
--no-tag Skip Git tag creation
|
|
35
|
+
--push Push tag to remote
|
|
36
|
+
--remove-suffix Remove version suffix (no type required)
|
|
37
|
+
--set-suffix <value> Set/replace version suffix (no type required)
|
|
38
|
+
--suffix <value> Add version suffix (e.g., SNAPSHOT)
|
|
39
|
+
--update-changelog [branch] Generate CHANGELOG entry
|
|
40
|
+
create-pr [base] Create PR with auto-generated metadata
|
|
41
|
+
--debug <true | false | status> Toggle debug mode
|
|
42
|
+
disable [hook] Disable hooks (all or specific)
|
|
43
|
+
enable [hook] Enable hooks (all or specific)
|
|
44
|
+
generate-changelog [version] Generate CHANGELOG entry independently
|
|
45
|
+
--base-branch <branch> Compare against branch (default: main)
|
|
46
|
+
--release Mark as released
|
|
47
|
+
help, --help, -h Show this help
|
|
48
|
+
install [options] Install hooks in current repository
|
|
49
|
+
--force Reinstall even if already exist
|
|
50
|
+
--skip-auth Skip Claude authentication check
|
|
51
|
+
migrate-config Migrate legacy config to v2.8.0 format
|
|
52
|
+
preset current Show current active preset
|
|
53
|
+
presets List all available presets
|
|
54
|
+
--set-preset <name> Set the active preset
|
|
55
|
+
setup-github Configure GitHub token for PR creation
|
|
56
|
+
status Show hook status
|
|
57
|
+
telemetry [show | clear] View or clear telemetry data
|
|
58
|
+
uninstall Remove hooks from repository
|
|
59
|
+
update Update to latest version
|
|
60
|
+
--version, -v Show current version
|
|
197
61
|
|
|
198
62
|
More information: https://github.com/pablorovito/claude-git-hooks
|
|
199
63
|
`);
|
package/lib/commands/helpers.js
CHANGED
|
@@ -95,6 +95,26 @@ export function getTemplatesPath() {
|
|
|
95
95
|
return path.join(__dirname, '..', '..', 'templates');
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Get the git hooks directory, correctly handling worktrees.
|
|
100
|
+
* In a worktree, hooks live in the main repo's .git/hooks, not the worktree's .git file.
|
|
101
|
+
* Uses `git rev-parse --git-common-dir` to find the shared git directory.
|
|
102
|
+
* @returns {string} Path to the git hooks directory
|
|
103
|
+
*/
|
|
104
|
+
export function getGitHooksPath() {
|
|
105
|
+
try {
|
|
106
|
+
let gitCommonDir = execSync('git rev-parse --git-common-dir', { encoding: 'utf8' }).trim();
|
|
107
|
+
// Handle Windows paths when running under WSL (e.g. C:\... -> /mnt/c/...)
|
|
108
|
+
if (/^[A-Za-z]:/.test(gitCommonDir)) {
|
|
109
|
+
gitCommonDir = gitCommonDir.replace(/^([A-Za-z]):/, (_, drive) => `/mnt/${drive.toLowerCase()}`);
|
|
110
|
+
gitCommonDir = gitCommonDir.replace(/\\/g, '/');
|
|
111
|
+
}
|
|
112
|
+
return path.join(gitCommonDir, 'hooks');
|
|
113
|
+
} catch (e) {
|
|
114
|
+
return path.join('.git', 'hooks');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
98
118
|
/**
|
|
99
119
|
* Detect if running on Windows
|
|
100
120
|
* Why: Need to use 'wsl claude' instead of 'claude' on Windows
|
package/lib/commands/hooks.js
CHANGED
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
success,
|
|
11
11
|
info,
|
|
12
12
|
warning,
|
|
13
|
-
checkGitRepo
|
|
13
|
+
checkGitRepo,
|
|
14
|
+
getGitHooksPath
|
|
14
15
|
} from './helpers.js';
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -22,11 +23,12 @@ export function runEnable(hookName) {
|
|
|
22
23
|
error('You are not in a Git repository.');
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
const hooksDir = getGitHooksPath();
|
|
25
27
|
const hooks = hookName ? [hookName] : ['pre-commit', 'prepare-commit-msg'];
|
|
26
28
|
|
|
27
29
|
hooks.forEach(hook => {
|
|
28
|
-
const disabledPath =
|
|
29
|
-
const enabledPath =
|
|
30
|
+
const disabledPath = path.join(hooksDir, `${hook}.disabled`);
|
|
31
|
+
const enabledPath = path.join(hooksDir, hook);
|
|
30
32
|
|
|
31
33
|
if (fs.existsSync(disabledPath)) {
|
|
32
34
|
fs.renameSync(disabledPath, enabledPath);
|
|
@@ -48,11 +50,12 @@ export function runDisable(hookName) {
|
|
|
48
50
|
error('You are not in a Git repository.');
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
const hooksDir = getGitHooksPath();
|
|
51
54
|
const hooks = hookName ? [hookName] : ['pre-commit', 'prepare-commit-msg'];
|
|
52
55
|
|
|
53
56
|
hooks.forEach(hook => {
|
|
54
|
-
const enabledPath =
|
|
55
|
-
const disabledPath =
|
|
57
|
+
const enabledPath = path.join(hooksDir, hook);
|
|
58
|
+
const disabledPath = path.join(hooksDir, `${hook}.disabled`);
|
|
56
59
|
|
|
57
60
|
if (fs.existsSync(enabledPath)) {
|
|
58
61
|
fs.renameSync(enabledPath, disabledPath);
|
|
@@ -75,10 +78,11 @@ export function runStatus() {
|
|
|
75
78
|
|
|
76
79
|
info('Claude Git Hooks status:\n');
|
|
77
80
|
|
|
81
|
+
const hooksDir = getGitHooksPath();
|
|
78
82
|
const hooks = ['pre-commit', 'prepare-commit-msg'];
|
|
79
83
|
hooks.forEach(hook => {
|
|
80
|
-
const enabledPath =
|
|
81
|
-
const disabledPath =
|
|
84
|
+
const enabledPath = path.join(hooksDir, hook);
|
|
85
|
+
const disabledPath = path.join(hooksDir, `${hook}.disabled`);
|
|
82
86
|
|
|
83
87
|
if (fs.existsSync(enabledPath)) {
|
|
84
88
|
success(`${hook}: enabled`);
|
|
@@ -135,7 +139,7 @@ export function runUninstall() {
|
|
|
135
139
|
|
|
136
140
|
info('Uninstalling Claude Git Hooks...');
|
|
137
141
|
|
|
138
|
-
const hooksPath =
|
|
142
|
+
const hooksPath = getGitHooksPath();
|
|
139
143
|
const hooks = ['pre-commit', 'prepare-commit-msg'];
|
|
140
144
|
|
|
141
145
|
hooks.forEach(hook => {
|
package/lib/commands/install.js
CHANGED
|
@@ -23,12 +23,14 @@ import {
|
|
|
23
23
|
warning,
|
|
24
24
|
checkGitRepo,
|
|
25
25
|
getTemplatesPath,
|
|
26
|
+
getGitHooksPath,
|
|
26
27
|
isWindows,
|
|
27
28
|
getClaudeCommand,
|
|
28
29
|
getPackageJson,
|
|
29
30
|
getLatestVersion,
|
|
30
31
|
Entertainment
|
|
31
32
|
} from './helpers.js';
|
|
33
|
+
import { runSetupGitHub } from './setup-github.js';
|
|
32
34
|
|
|
33
35
|
/**
|
|
34
36
|
* Function to check version (used by hooks)
|
|
@@ -401,7 +403,7 @@ export async function runInstall(args) {
|
|
|
401
403
|
await checkAndInstallDependencies(skipAuth);
|
|
402
404
|
|
|
403
405
|
const templatesPath = getTemplatesPath();
|
|
404
|
-
const hooksPath =
|
|
406
|
+
const hooksPath = getGitHooksPath();
|
|
405
407
|
|
|
406
408
|
// Create hooks directory if it doesn't exist
|
|
407
409
|
if (!fs.existsSync(hooksPath)) {
|
|
@@ -654,34 +656,9 @@ export async function runInstall(args) {
|
|
|
654
656
|
updateGitignore();
|
|
655
657
|
|
|
656
658
|
success('Claude Git Hooks installed successfully! 🎉');
|
|
657
|
-
console.log('\
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
console.log('
|
|
661
|
-
|
|
662
|
-
console.log(' 📁 All templates installed in .claude/');
|
|
663
|
-
console.log(' 📝 Edit .claude/config.json (minimal by default)');
|
|
664
|
-
console.log(' 📂 Examples: .claude/config_example/');
|
|
665
|
-
console.log(' 📦 Backups: .claude/config_old/');
|
|
666
|
-
console.log(' 🎯 Presets: backend, frontend, fullstack, database, ai, default');
|
|
667
|
-
console.log(' 🚀 Parallel analysis enabled by default (hardcoded)');
|
|
668
|
-
console.log(' 🐛 Debug mode: claude-hooks --debug true');
|
|
669
|
-
console.log('\n🔗 GitHub PR Creation (v2.5.0+):');
|
|
670
|
-
console.log(' claude-hooks setup-github # Configure GitHub token');
|
|
671
|
-
console.log(' claude-hooks create-pr main # Create PR with auto-metadata');
|
|
672
|
-
console.log('\n📖 Minimal config.json (v2.8.0):');
|
|
673
|
-
console.log(' {');
|
|
674
|
-
console.log(' "version": "2.8.0",');
|
|
675
|
-
console.log(' "preset": "backend"');
|
|
676
|
-
console.log(' }');
|
|
677
|
-
console.log('\n📖 With GitHub customization:');
|
|
678
|
-
console.log(' {');
|
|
679
|
-
console.log(' "version": "2.8.0",');
|
|
680
|
-
console.log(' "preset": "backend",');
|
|
681
|
-
console.log(' "overrides": {');
|
|
682
|
-
console.log(' "github": { "pr": { "reviewers": ["your-username"] } }');
|
|
683
|
-
console.log(' }');
|
|
684
|
-
console.log(' }');
|
|
685
|
-
console.log('\n🔧 Advanced: see .claude/config_example/config.advanced.example.json');
|
|
686
|
-
console.log('\nFor more options: claude-hooks --help');
|
|
659
|
+
console.log('\nRun claude-hooks --help to see all available commands.');
|
|
660
|
+
|
|
661
|
+
// Run GitHub token setup
|
|
662
|
+
console.log('');
|
|
663
|
+
await runSetupGitHub();
|
|
687
664
|
}
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
import fs from 'fs';
|
|
23
23
|
import path from 'path';
|
|
24
24
|
import { getRepoRoot } from './git-operations.js';
|
|
25
|
+
import { getGitHooksPath } from '../commands/helpers.js';
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Gets installation diagnostics
|
|
@@ -60,7 +61,7 @@ export const getInstallationDiagnostics = () => {
|
|
|
60
61
|
diagnostics.presetsDirPath = path.join(diagnostics.claudeDirPath, 'presets');
|
|
61
62
|
diagnostics.presetsDirExists = fs.existsSync(diagnostics.presetsDirPath);
|
|
62
63
|
|
|
63
|
-
const gitHooksPath =
|
|
64
|
+
const gitHooksPath = getGitHooksPath();
|
|
64
65
|
diagnostics.gitHooksExists = fs.existsSync(gitHooksPath);
|
|
65
66
|
} catch (error) {
|
|
66
67
|
// Not in a git repository - diagnostics.repoRoot will be null
|