@localtech/claude-code-toolkit 1.0.3 → 1.0.4
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/package.json +1 -1
- package/templates/.claude/hooks/README.md +342 -0
- package/templates/.claude/hooks/custom/intelligent-workflows.sh +336 -0
- package/templates/.claude/hooks/hook-manager.sh +300 -0
- package/templates/.claude/hooks/post-commit/smart-automations.sh +249 -0
- package/templates/.claude/hooks/pre-commit/code-quality-guardian.sh +257 -0
- package/templates/.claude/hooks/pre-push/deployment-guardian.sh +334 -0
- package/templates/.claude/memory/context.md +39 -0
- package/templates/.claude/memory/decisions.md +29 -0
- package/templates/.claude/memory/learnings.md +31 -0
- package/templates/.claude/memory/patterns.md +72 -0
- package/templates/.claude/memory/preferences.md +23 -0
- package/templates/.claude/skills/claude-code-hooks-master/SKILL.md +358 -0
- package/templates/.claude/skills/mobile-ui-ux-master/MobileCardGrid.tsx +270 -0
- package/templates/.claude/skills/mobile-ui-ux-master/SKILL.md +172 -0
- package/templates/.claude/skills/mobile-ui-ux-master/card-grid-template.html +260 -0
- package/templates/.claude/skills/mobile-ui-ux-master/mobile-ux-checklist.md +140 -0
- package/templates/.claude/skills/professional-documentation-writer/SKILL.md +42 -0
- package/templates/AGENTS.md +127 -0
- package/templates/CLAUDE.md +101 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# HOOK: hook-manager
|
|
3
|
+
# DESCRIPTION: Central hook management and orchestration system
|
|
4
|
+
# AUTHOR: Claude Code Hooks Master
|
|
5
|
+
# VERSION: 1.0.0
|
|
6
|
+
|
|
7
|
+
set -e
|
|
8
|
+
|
|
9
|
+
# Colors and logging
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
YELLOW='\033[1;33m'
|
|
13
|
+
RED='\033[0;31m'
|
|
14
|
+
PURPLE='\033[0;35m'
|
|
15
|
+
NC='\033[0m'
|
|
16
|
+
|
|
17
|
+
log_info() {
|
|
18
|
+
echo -e "${BLUE}[HOOKS]${NC} $1"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
log_success() {
|
|
22
|
+
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
log_warn() {
|
|
26
|
+
echo -e "${YELLOW}[WARN]${NC} $1"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
log_error() {
|
|
30
|
+
echo -e "${RED}[ERROR]${NC} $1"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
log_ai() {
|
|
34
|
+
echo -e "${PURPLE}[🤖]${NC} $1"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# Hook configuration
|
|
38
|
+
HOOK_DIR=".claude/hooks"
|
|
39
|
+
declare -A HOOK_TYPES=(
|
|
40
|
+
["pre-commit"]="code-quality-guardian.sh"
|
|
41
|
+
["post-commit"]="smart-automations.sh"
|
|
42
|
+
["pre-push"]="deployment-guardian.sh"
|
|
43
|
+
["custom"]="intelligent-workflows.sh"
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
# Make hooks executable
|
|
47
|
+
setup_hooks() {
|
|
48
|
+
log_info "Setting up Claude Code hooks..."
|
|
49
|
+
|
|
50
|
+
for hook_type in "${!HOOK_TYPES[@]}"; do
|
|
51
|
+
local hook_file="$HOOK_DIR/$hook_type/${HOOK_TYPES[$hook_type]}"
|
|
52
|
+
|
|
53
|
+
if [ -f "$hook_file" ]; then
|
|
54
|
+
chmod +x "$hook_file"
|
|
55
|
+
log_success "Made $hook_type hook executable"
|
|
56
|
+
else
|
|
57
|
+
log_warn "Hook file not found: $hook_file"
|
|
58
|
+
fi
|
|
59
|
+
done
|
|
60
|
+
|
|
61
|
+
log_success "Hook setup completed"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# Install git hooks
|
|
65
|
+
install_git_hooks() {
|
|
66
|
+
log_info "Installing Git hooks integration..."
|
|
67
|
+
|
|
68
|
+
local git_hooks_dir=".git/hooks"
|
|
69
|
+
if [ ! -d "$git_hooks_dir" ]; then
|
|
70
|
+
log_error "Git repository not found - cannot install hooks"
|
|
71
|
+
return 1
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
# Create pre-commit hook
|
|
75
|
+
cat > "$git_hooks_dir/pre-commit" << 'EOF'
|
|
76
|
+
#!/bin/bash
|
|
77
|
+
# Claude Code Pre-commit Hook
|
|
78
|
+
|
|
79
|
+
# Get the directory where this script is located
|
|
80
|
+
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../.claude/hooks"
|
|
81
|
+
PRE_COMMIT_HOOK="$HOOK_DIR/pre-commit/code-quality-guardian.sh"
|
|
82
|
+
|
|
83
|
+
if [ -x "$PRE_COMMIT_HOOK" ]; then
|
|
84
|
+
echo "Running Claude Code pre-commit quality checks..."
|
|
85
|
+
if ! "$PRE_COMMIT_HOOK"; then
|
|
86
|
+
echo "Pre-commit checks failed. Please fix issues and try again."
|
|
87
|
+
exit 1
|
|
88
|
+
fi
|
|
89
|
+
else
|
|
90
|
+
echo "Warning: Claude Code pre-commit hook not found or not executable"
|
|
91
|
+
fi
|
|
92
|
+
EOF
|
|
93
|
+
|
|
94
|
+
# Create post-commit hook
|
|
95
|
+
cat > "$git_hooks_dir/post-commit" << 'EOF'
|
|
96
|
+
#!/bin/bash
|
|
97
|
+
# Claude Code Post-commit Hook
|
|
98
|
+
|
|
99
|
+
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../.claude/hooks"
|
|
100
|
+
POST_COMMIT_HOOK="$HOOK_DIR/post-commit/smart-automations.sh"
|
|
101
|
+
|
|
102
|
+
if [ -x "$POST_COMMIT_HOOK" ]; then
|
|
103
|
+
echo "Running Claude Code post-commit automations..."
|
|
104
|
+
"$POST_COMMIT_HOOK" &
|
|
105
|
+
else
|
|
106
|
+
echo "Warning: Claude Code post-commit hook not found"
|
|
107
|
+
fi
|
|
108
|
+
EOF
|
|
109
|
+
|
|
110
|
+
# Create pre-push hook
|
|
111
|
+
cat > "$git_hooks_dir/pre-push" << 'EOF'
|
|
112
|
+
#!/bin/bash
|
|
113
|
+
# Claude Code Pre-push Hook
|
|
114
|
+
|
|
115
|
+
HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/../../.claude/hooks"
|
|
116
|
+
PRE_PUSH_HOOK="$HOOK_DIR/pre-push/deployment-guardian.sh"
|
|
117
|
+
|
|
118
|
+
if [ -x "$PRE_PUSH_HOOK" ]; then
|
|
119
|
+
echo "Running Claude Code pre-push deployment checks..."
|
|
120
|
+
if ! "$PRE_PUSH_HOOK"; then
|
|
121
|
+
echo "Pre-push checks failed. Please fix issues and try again."
|
|
122
|
+
exit 1
|
|
123
|
+
fi
|
|
124
|
+
else
|
|
125
|
+
echo "Warning: Claude Code pre-push hook not found or not executable"
|
|
126
|
+
fi
|
|
127
|
+
EOF
|
|
128
|
+
|
|
129
|
+
# Make git hooks executable
|
|
130
|
+
chmod +x "$git_hooks_dir/pre-commit"
|
|
131
|
+
chmod +x "$git_hooks_dir/post-commit"
|
|
132
|
+
chmod +x "$git_hooks_dir/pre-push"
|
|
133
|
+
|
|
134
|
+
log_success "Git hooks installed successfully"
|
|
135
|
+
log_info "Hooks will now run automatically on git operations"
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
# Test all hooks
|
|
139
|
+
test_hooks() {
|
|
140
|
+
log_info "Testing all Claude Code hooks..."
|
|
141
|
+
|
|
142
|
+
local test_results=()
|
|
143
|
+
|
|
144
|
+
for hook_type in "${!HOOK_TYPES[@]}"; do
|
|
145
|
+
local hook_file="$HOOK_DIR/$hook_type/${HOOK_TYPES[$hook_type]}"
|
|
146
|
+
|
|
147
|
+
if [ -f "$hook_file" ]; then
|
|
148
|
+
log_info "Testing $hook_type hook..."
|
|
149
|
+
|
|
150
|
+
# Basic syntax check
|
|
151
|
+
if bash -n "$hook_file" 2>/dev/null; then
|
|
152
|
+
log_success "$hook_type hook syntax is valid"
|
|
153
|
+
test_results+=("$hook_type: PASS")
|
|
154
|
+
else
|
|
155
|
+
log_error "$hook_type hook has syntax errors"
|
|
156
|
+
test_results+=("$hook_type: FAIL - Syntax Error")
|
|
157
|
+
fi
|
|
158
|
+
|
|
159
|
+
# Check if executable
|
|
160
|
+
if [ -x "$hook_file" ]; then
|
|
161
|
+
log_success "$hook_type hook is executable"
|
|
162
|
+
else
|
|
163
|
+
log_warn "$hook_type hook is not executable"
|
|
164
|
+
fi
|
|
165
|
+
else
|
|
166
|
+
log_error "$hook_type hook file not found: $hook_file"
|
|
167
|
+
test_results+=("$hook_type: FAIL - Missing")
|
|
168
|
+
fi
|
|
169
|
+
done
|
|
170
|
+
|
|
171
|
+
echo
|
|
172
|
+
log_info "Hook Test Results:"
|
|
173
|
+
for result in "${test_results[@]}"; do
|
|
174
|
+
echo " $result"
|
|
175
|
+
done
|
|
176
|
+
|
|
177
|
+
# Check for failures
|
|
178
|
+
if echo "${test_results[@]}" | grep -q "FAIL"; then
|
|
179
|
+
log_error "Some hooks have issues - please fix before using"
|
|
180
|
+
return 1
|
|
181
|
+
else
|
|
182
|
+
log_success "All hooks are properly configured!"
|
|
183
|
+
fi
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
# Run specific hook manually
|
|
187
|
+
run_hook() {
|
|
188
|
+
local hook_type="$1"
|
|
189
|
+
|
|
190
|
+
if [ -z "$hook_type" ]; then
|
|
191
|
+
log_error "Please specify a hook type to run"
|
|
192
|
+
echo "Available hooks: ${!HOOK_TYPES[*]}"
|
|
193
|
+
return 1
|
|
194
|
+
fi
|
|
195
|
+
|
|
196
|
+
if [ -z "${HOOK_TYPES[$hook_type]}" ]; then
|
|
197
|
+
log_error "Unknown hook type: $hook_type"
|
|
198
|
+
echo "Available hooks: ${!HOOK_TYPES[*]}"
|
|
199
|
+
return 1
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
local hook_file="$HOOK_DIR/$hook_type/${HOOK_TYPES[$hook_type]}"
|
|
203
|
+
|
|
204
|
+
if [ ! -f "$hook_file" ]; then
|
|
205
|
+
log_error "Hook file not found: $hook_file"
|
|
206
|
+
return 1
|
|
207
|
+
fi
|
|
208
|
+
|
|
209
|
+
if [ ! -x "$hook_file" ]; then
|
|
210
|
+
log_error "Hook file is not executable: $hook_file"
|
|
211
|
+
return 1
|
|
212
|
+
fi
|
|
213
|
+
|
|
214
|
+
log_info "Running $hook_type hook manually..."
|
|
215
|
+
"$hook_file"
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
# Show hook status
|
|
219
|
+
status() {
|
|
220
|
+
log_info "Claude Code Hooks Status"
|
|
221
|
+
echo "=========================="
|
|
222
|
+
|
|
223
|
+
for hook_type in "${!HOOK_TYPES[@]}"; do
|
|
224
|
+
local hook_file="$HOOK_DIR/$hook_type/${HOOK_TYPES[$hook_type]}"
|
|
225
|
+
|
|
226
|
+
echo
|
|
227
|
+
echo "$hook_type hook:"
|
|
228
|
+
echo " File: $hook_file"
|
|
229
|
+
|
|
230
|
+
if [ -f "$hook_file" ]; then
|
|
231
|
+
echo " Status: ✅ Exists"
|
|
232
|
+
|
|
233
|
+
if [ -x "$hook_file" ]; then
|
|
234
|
+
echo " Executable: ✅ Yes"
|
|
235
|
+
else
|
|
236
|
+
echo " Executable: ❌ No"
|
|
237
|
+
fi
|
|
238
|
+
|
|
239
|
+
# Check git hook integration
|
|
240
|
+
local git_hook=".git/hooks/$hook_type"
|
|
241
|
+
if [ -x "$git_hook" ] && [ -f "$git_hook" ]; then
|
|
242
|
+
echo " Git Integration: ✅ Installed"
|
|
243
|
+
else
|
|
244
|
+
echo " Git Integration: ❌ Not installed"
|
|
245
|
+
fi
|
|
246
|
+
else
|
|
247
|
+
echo " Status: ❌ Missing"
|
|
248
|
+
fi
|
|
249
|
+
done
|
|
250
|
+
|
|
251
|
+
echo
|
|
252
|
+
log_info "Quick Actions:"
|
|
253
|
+
echo " Setup hooks: $0 setup"
|
|
254
|
+
echo " Install git hooks: $0 install"
|
|
255
|
+
echo " Test hooks: $0 test"
|
|
256
|
+
echo " Run hook: $0 run <hook-type>"
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
# Main command dispatcher
|
|
260
|
+
main() {
|
|
261
|
+
case "${1:-}" in
|
|
262
|
+
setup)
|
|
263
|
+
setup_hooks
|
|
264
|
+
;;
|
|
265
|
+
install)
|
|
266
|
+
install_git_hooks
|
|
267
|
+
;;
|
|
268
|
+
test)
|
|
269
|
+
test_hooks
|
|
270
|
+
;;
|
|
271
|
+
run)
|
|
272
|
+
run_hook "$2"
|
|
273
|
+
;;
|
|
274
|
+
status|"")
|
|
275
|
+
status
|
|
276
|
+
;;
|
|
277
|
+
help|--help|-h)
|
|
278
|
+
echo "Claude Code Hooks Manager"
|
|
279
|
+
echo "Usage: $0 <command> [options]"
|
|
280
|
+
echo ""
|
|
281
|
+
echo "Commands:"
|
|
282
|
+
echo " setup - Make all hooks executable"
|
|
283
|
+
echo " install - Install git hooks integration"
|
|
284
|
+
echo " test - Test all hooks for issues"
|
|
285
|
+
echo " run <type> - Run specific hook manually"
|
|
286
|
+
echo " status - Show hooks status (default)"
|
|
287
|
+
echo " help - Show this help"
|
|
288
|
+
echo ""
|
|
289
|
+
echo "Hook Types: ${!HOOK_TYPES[*]}"
|
|
290
|
+
;;
|
|
291
|
+
*)
|
|
292
|
+
log_error "Unknown command: $1"
|
|
293
|
+
echo "Run '$0 help' for usage information"
|
|
294
|
+
exit 1
|
|
295
|
+
;;
|
|
296
|
+
esac
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
# Run main function
|
|
300
|
+
main "$@"
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# HOOK: post-commit-smart-automations
|
|
3
|
+
# DESCRIPTION: Intelligent post-commit automations for documentation, notifications, and workflow optimization
|
|
4
|
+
# AUTHOR: Claude Code Hooks Master
|
|
5
|
+
# VERSION: 1.0.0
|
|
6
|
+
|
|
7
|
+
set -e
|
|
8
|
+
|
|
9
|
+
# Colors for output
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
BLUE='\033[0;34m'
|
|
12
|
+
YELLOW='\033[1;33m'
|
|
13
|
+
RED='\033[0;31m'
|
|
14
|
+
NC='\033[0m'
|
|
15
|
+
|
|
16
|
+
log_info() {
|
|
17
|
+
echo -e "${BLUE}[AUTO]${NC} $1"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
log_success() {
|
|
21
|
+
echo -e "${GREEN}[DONE]${NC} $1"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
log_warn() {
|
|
25
|
+
echo -e "${YELLOW}[WARN]${NC} $1"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# Get commit information
|
|
29
|
+
get_commit_info() {
|
|
30
|
+
COMMIT_HASH=$(git rev-parse HEAD)
|
|
31
|
+
COMMIT_MSG=$(git log -1 --pretty=%B)
|
|
32
|
+
COMMIT_AUTHOR=$(git log -1 --pretty=%an)
|
|
33
|
+
COMMIT_EMAIL=$(git log -1 --pretty=%ae)
|
|
34
|
+
CHANGED_FILES=$(git diff --name-only HEAD~1)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
# Analyze commit type and impact
|
|
38
|
+
analyze_commit_impact() {
|
|
39
|
+
local commit_msg="$1"
|
|
40
|
+
local changed_files="$2"
|
|
41
|
+
|
|
42
|
+
# Determine commit type
|
|
43
|
+
if echo "$commit_msg" | grep -q -i "feat\|feature\|add"; then
|
|
44
|
+
COMMIT_TYPE="feature"
|
|
45
|
+
elif echo "$commit_msg" | grep -q -i "fix\|bug\|hotfix"; then
|
|
46
|
+
COMMIT_TYPE="fix"
|
|
47
|
+
elif echo "$commit_msg" | grep -q -i "docs\|documentation"; then
|
|
48
|
+
COMMIT_TYPE="docs"
|
|
49
|
+
elif echo "$commit_msg" | grep -q -i "test\|spec"; then
|
|
50
|
+
COMMIT_TYPE="test"
|
|
51
|
+
elif echo "$commit_msg" | grep -q -i "refactor\|style"; then
|
|
52
|
+
COMMIT_TYPE="refactor"
|
|
53
|
+
else
|
|
54
|
+
COMMIT_TYPE="other"
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
# Determine impact level
|
|
58
|
+
if echo "$changed_files" | grep -q -E "(package\.json|core|config|src/index)"; then
|
|
59
|
+
IMPACT_LEVEL="high"
|
|
60
|
+
elif echo "$changed_files" | grep -q -E "(src/|components/|api/)"; then
|
|
61
|
+
IMPACT_LEVEL="medium"
|
|
62
|
+
else
|
|
63
|
+
IMPACT_LEVEL="low"
|
|
64
|
+
fi
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# Documentation automation
|
|
68
|
+
run_docs_automation() {
|
|
69
|
+
log_info "Running documentation automation..."
|
|
70
|
+
|
|
71
|
+
# Check if documentation needs updating
|
|
72
|
+
if echo "$CHANGED_FILES" | grep -q -E "\.(js|ts|py)$"; then
|
|
73
|
+
log_info "Code changes detected - checking documentation needs..."
|
|
74
|
+
|
|
75
|
+
# Trigger Claude Code documentation skill
|
|
76
|
+
if command -v claude_code_run_skill &> /dev/null; then
|
|
77
|
+
log_info "Using Claude Code documentation skill..."
|
|
78
|
+
claude_code_run_skill "professional-documentation-writer" "update-api-docs" || true
|
|
79
|
+
else
|
|
80
|
+
log_warn "Claude Code skills not available - skipping automated docs"
|
|
81
|
+
fi
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
# Update README if necessary
|
|
85
|
+
if echo "$CHANGED_FILES" | grep -q -E "(README|readme)"; then
|
|
86
|
+
log_info "README changes detected - validating format..."
|
|
87
|
+
# Could add README validation here
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
log_success "Documentation automation completed"
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# Memory system integration
|
|
94
|
+
update_memory_system() {
|
|
95
|
+
log_info "Updating project memory system..."
|
|
96
|
+
|
|
97
|
+
local memory_dir=".claude/memory"
|
|
98
|
+
if [ ! -d "$memory_dir" ]; then
|
|
99
|
+
log_warn "Memory system not found - skipping memory updates"
|
|
100
|
+
return 0
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
# Add to decisions memory for architectural decisions
|
|
104
|
+
if echo "$COMMIT_MSG" | grep -q -i "decision\|architect\|design"; then
|
|
105
|
+
{
|
|
106
|
+
echo "## $(date '+%Y-%m-%d %H:%M:%S') - Architecture Decision"
|
|
107
|
+
echo "**Decision**: $COMMIT_MSG"
|
|
108
|
+
echo "**Files Changed**: $CHANGED_FILES"
|
|
109
|
+
echo "**Impact**: $IMPACT_LEVEL"
|
|
110
|
+
echo
|
|
111
|
+
} >> "$memory_dir/decisions.md"
|
|
112
|
+
log_success "Added to decisions memory"
|
|
113
|
+
fi
|
|
114
|
+
|
|
115
|
+
# Add to learnings memory for insights
|
|
116
|
+
if echo "$COMMIT_MSG" | grep -q -i "learn\|discover\|find\|improve"; then
|
|
117
|
+
{
|
|
118
|
+
echo "## $(date '+%Y-%m-%d %H:%M:%S') - Development Learning"
|
|
119
|
+
echo "**Insight**: $COMMIT_MSG"
|
|
120
|
+
echo "**Context**: Commit $COMMIT_HASH"
|
|
121
|
+
echo "**Files**: $CHANGED_FILES"
|
|
122
|
+
echo
|
|
123
|
+
} >> "$memory_dir/learnings.md"
|
|
124
|
+
log_success "Added to learnings memory"
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
# Update context with recent changes
|
|
128
|
+
{
|
|
129
|
+
echo "## Recent Changes"
|
|
130
|
+
echo "- $(date '+%Y-%m-%d'): $COMMIT_MSG"
|
|
131
|
+
echo " - Type: $COMMIT_TYPE, Impact: $IMPACT_LEVEL"
|
|
132
|
+
echo " - Files: $(echo "$CHANGED_FILES" | wc -l) files changed"
|
|
133
|
+
} >> "$memory_dir/context.md"
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# Notification system
|
|
137
|
+
send_notifications() {
|
|
138
|
+
log_info "Sending notifications..."
|
|
139
|
+
|
|
140
|
+
# Skip notifications for low-impact changes
|
|
141
|
+
if [ "$IMPACT_LEVEL" = "low" ] && [ "$COMMIT_TYPE" = "other" ]; then
|
|
142
|
+
log_info "Low-impact change - skipping notifications"
|
|
143
|
+
return 0
|
|
144
|
+
fi
|
|
145
|
+
|
|
146
|
+
# In a real implementation, you would integrate with:
|
|
147
|
+
# - Slack/Discord webhooks
|
|
148
|
+
# - Email notifications
|
|
149
|
+
# - Project management tools (Jira, Linear, etc.)
|
|
150
|
+
# - CI/CD status updates
|
|
151
|
+
|
|
152
|
+
log_info "Would notify team about: $COMMIT_TYPE change ($IMPACT_LEVEL impact)"
|
|
153
|
+
log_info "Commit: $COMMIT_HASH by $COMMIT_AUTHOR"
|
|
154
|
+
|
|
155
|
+
# Example notification payload (you would send this to your notification service)
|
|
156
|
+
local notification_data="{
|
|
157
|
+
\"commit\": \"$COMMIT_HASH\",
|
|
158
|
+
\"author\": \"$COMMIT_AUTHOR\",
|
|
159
|
+
\"message\": \"$COMMIT_MSG\",
|
|
160
|
+
\"type\": \"$COMMIT_TYPE\",
|
|
161
|
+
\"impact\": \"$IMPACT_LEVEL\",
|
|
162
|
+
\"files_changed\": $(echo "$CHANGED_FILES" | wc -l)
|
|
163
|
+
}"
|
|
164
|
+
|
|
165
|
+
# For now, just log what would be sent
|
|
166
|
+
log_success "Notification prepared (integrate with your notification service)"
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
# Backup automation
|
|
170
|
+
run_backup_automation() {
|
|
171
|
+
# Only backup for significant changes
|
|
172
|
+
if [ "$IMPACT_LEVEL" != "high" ]; then
|
|
173
|
+
return 0
|
|
174
|
+
fi
|
|
175
|
+
|
|
176
|
+
log_info "Running backup automation for high-impact change..."
|
|
177
|
+
|
|
178
|
+
local backup_dir=".claude/backups"
|
|
179
|
+
mkdir -p "$backup_dir"
|
|
180
|
+
|
|
181
|
+
local timestamp=$(date '+%Y%m%d_%H%M%S')
|
|
182
|
+
local backup_file="$backup_dir/backup_$timestamp.tar.gz"
|
|
183
|
+
|
|
184
|
+
# Create backup of critical files
|
|
185
|
+
if [ -d "src" ] && [ -d "package.json" ]; then
|
|
186
|
+
tar -czf "$backup_file" src/ package.json tsconfig.json 2>/dev/null || true
|
|
187
|
+
log_success "Backup created: $backup_file"
|
|
188
|
+
fi
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
# Performance monitoring
|
|
192
|
+
update_performance_metrics() {
|
|
193
|
+
local metrics_file=".claude/metrics/commit-metrics.json"
|
|
194
|
+
|
|
195
|
+
mkdir -p "$(dirname "$metrics_file")"
|
|
196
|
+
|
|
197
|
+
# Calculate some basic metrics
|
|
198
|
+
local commit_size=$(echo "$CHANGED_FILES" | wc -l)
|
|
199
|
+
local test_files=$(echo "$CHANGED_FILES" | grep -c "\.test\." || echo "0")
|
|
200
|
+
local config_files=$(echo "$CHANGED_FILES" | grep -c -E "(package\.json|config|\.env)" || echo "0")
|
|
201
|
+
|
|
202
|
+
# Create/update metrics
|
|
203
|
+
local metrics="{
|
|
204
|
+
\"timestamp\": \"$(date -Iseconds)\",
|
|
205
|
+
\"commit_hash\": \"$COMMIT_HASH\",
|
|
206
|
+
\"commit_type\": \"$COMMIT_TYPE\",
|
|
207
|
+
\"impact_level\": \"$IMPACT_LEVEL\",
|
|
208
|
+
\"files_changed\": $commit_size,
|
|
209
|
+
\"test_files\": $test_files,
|
|
210
|
+
\"config_files\": $config_files,
|
|
211
|
+
\"author\": \"$COMMIT_AUTHOR\"
|
|
212
|
+
}"
|
|
213
|
+
|
|
214
|
+
echo "$metrics" >> "$metrics_file"
|
|
215
|
+
log_success "Performance metrics updated"
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
# Main execution
|
|
219
|
+
main() {
|
|
220
|
+
log_info "🤖 Claude Code Smart Automations - Post-commit Hook"
|
|
221
|
+
echo "======================================================="
|
|
222
|
+
|
|
223
|
+
# Get commit information
|
|
224
|
+
get_commit_info
|
|
225
|
+
|
|
226
|
+
# Analyze commit
|
|
227
|
+
analyze_commit_impact "$COMMIT_MSG" "$CHANGED_FILES"
|
|
228
|
+
|
|
229
|
+
log_info "Commit Analysis:"
|
|
230
|
+
echo " Type: $COMMIT_TYPE"
|
|
231
|
+
echo " Impact: $IMPACT_LEVEL"
|
|
232
|
+
echo " Author: $COMMIT_AUTHOR"
|
|
233
|
+
echo " Files: $(echo "$CHANGED_FILES" | wc -l)"
|
|
234
|
+
echo
|
|
235
|
+
|
|
236
|
+
# Run automations based on commit characteristics
|
|
237
|
+
run_docs_automation
|
|
238
|
+
update_memory_system
|
|
239
|
+
send_notifications
|
|
240
|
+
run_backup_automation
|
|
241
|
+
update_performance_metrics
|
|
242
|
+
|
|
243
|
+
echo
|
|
244
|
+
log_success "🎉 All post-commit automations completed successfully!"
|
|
245
|
+
log_info "Commit $COMMIT_HASH processed and automated workflows triggered"
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
# Run main function
|
|
249
|
+
main "$@"
|