Add "Change V5.5.0: Hook Efficiency Quick Wins (Sprint 8 Implementation)"
@@ -0,0 +1,106 @@
|
||||
# Change V5.5.0: Hook Efficiency Quick Wins
|
||||
|
||||
**Sprint:** 8
|
||||
**Status:** In Progress
|
||||
**Date:** 2026-01-29
|
||||
**Origin:** [RFC-Hook-Efficiency-Improvements](../RFC-Hook-Efficiency-Improvements.-)
|
||||
|
||||
---
|
||||
|
||||
## Scope
|
||||
|
||||
This sprint implements **Phase 1: Quick Wins** from the RFC, focusing on low-effort, high-impact optimizations.
|
||||
|
||||
### In Scope
|
||||
|
||||
| Change | Plugin | Impact |
|
||||
|--------|--------|--------|
|
||||
| Remove SessionStart hook | viz-platform | Eliminates pointless echo |
|
||||
| Add early git check | git-flow | Skips 90%+ of Bash invocations |
|
||||
| Add cooldown | project-hygiene | Reduces find operations |
|
||||
|
||||
### Explicitly Out of Scope
|
||||
|
||||
- SessionStart dispatcher consolidation (rejected - fights plugin architecture)
|
||||
- Shared hook library (rejected - creates coupling)
|
||||
- clarity-assist opt-in (deferred - requires user discussion)
|
||||
- Path filtering for PostToolUse hooks (deferred - case-by-case)
|
||||
|
||||
---
|
||||
|
||||
## Implementation Details
|
||||
|
||||
### 1. Remove viz-platform SessionStart Hook
|
||||
|
||||
**File:** `plugins/viz-platform/hooks/hooks.json`
|
||||
|
||||
**Current:**
|
||||
```json
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"event": "SessionStart",
|
||||
"type": "command",
|
||||
"command": "echo 'viz-platform plugin loaded'",
|
||||
"timeout": 5000
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
**After:**
|
||||
```json
|
||||
{
|
||||
"hooks": []
|
||||
}
|
||||
```
|
||||
|
||||
### 2. Add Early Git Check to git-flow Hooks
|
||||
|
||||
**Problem:** `commit-msg-check.sh` spawns Python to parse JSON even for non-git commands.
|
||||
|
||||
**Solution:** Add early check before JSON parsing:
|
||||
```bash
|
||||
# Quick check - exit immediately if not a git command
|
||||
if ! echo "$INPUT" | grep -q '"command".*git'; then
|
||||
exit 0
|
||||
fi
|
||||
```
|
||||
|
||||
**Files:**
|
||||
- `plugins/git-flow/hooks/branch-check.sh`
|
||||
- `plugins/git-flow/hooks/commit-msg-check.sh`
|
||||
|
||||
### 3. Add Cooldown to project-hygiene
|
||||
|
||||
**Problem:** Runs `find` across entire project on every file edit.
|
||||
|
||||
**Solution:** Add session-based cooldown (skip if ran recently):
|
||||
```bash
|
||||
LAST_RUN_FILE="/tmp/project-hygiene-${PPID}-last-run"
|
||||
if [[ -f "$LAST_RUN_FILE" ]]; then
|
||||
LAST_RUN=$(cat "$LAST_RUN_FILE")
|
||||
NOW=$(date +%s)
|
||||
if (( NOW - LAST_RUN < 60 )); then
|
||||
exit 0 # Skip if ran in last 60 seconds
|
||||
fi
|
||||
fi
|
||||
date +%s > "$LAST_RUN_FILE"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Verification
|
||||
|
||||
After implementation:
|
||||
1. Start new session - should be faster
|
||||
2. Run non-git bash commands - no hook overhead
|
||||
3. Edit files rapidly - cleanup shouldn't run on every edit
|
||||
4. Verify functionality still works when triggered
|
||||
|
||||
---
|
||||
|
||||
## References
|
||||
|
||||
- RFC: [Hook Efficiency Improvements](../RFC-Hook-Efficiency-Improvements.-)
|
||||
- Previous analysis identified 16 hooks across 12 plugins
|
||||
Reference in New Issue
Block a user