specweave 0.23.10 → 0.23.14
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/.claude-plugin/marketplace.json +7 -7
- package/CLAUDE.md +384 -1449
- package/dist/src/cli/commands/cleanup-cache.d.ts +14 -0
- package/dist/src/cli/commands/cleanup-cache.d.ts.map +1 -0
- package/dist/src/cli/commands/cleanup-cache.js +63 -0
- package/dist/src/cli/commands/cleanup-cache.js.map +1 -0
- package/dist/src/cli/commands/init.js +40 -0
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/helpers/async-project-loader.d.ts +148 -0
- package/dist/src/cli/helpers/async-project-loader.d.ts.map +1 -0
- package/dist/src/cli/helpers/async-project-loader.js +351 -0
- package/dist/src/cli/helpers/async-project-loader.js.map +1 -0
- package/dist/src/cli/helpers/cancelation-handler.d.ts +123 -0
- package/dist/src/cli/helpers/cancelation-handler.d.ts.map +1 -0
- package/dist/src/cli/helpers/cancelation-handler.js +187 -0
- package/dist/src/cli/helpers/cancelation-handler.js.map +1 -0
- package/dist/src/cli/helpers/import-strategy-prompter.d.ts +43 -0
- package/dist/src/cli/helpers/import-strategy-prompter.d.ts.map +1 -0
- package/dist/src/cli/helpers/import-strategy-prompter.js +136 -0
- package/dist/src/cli/helpers/import-strategy-prompter.js.map +1 -0
- package/dist/src/cli/helpers/issue-tracker/ado.d.ts +5 -2
- package/dist/src/cli/helpers/issue-tracker/ado.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/ado.js +90 -40
- package/dist/src/cli/helpers/issue-tracker/ado.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/jira.d.ts +2 -1
- package/dist/src/cli/helpers/issue-tracker/jira.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/jira.js +120 -35
- package/dist/src/cli/helpers/issue-tracker/jira.js.map +1 -1
- package/dist/src/cli/helpers/progress-tracker.d.ts +121 -0
- package/dist/src/cli/helpers/progress-tracker.d.ts.map +1 -0
- package/dist/src/cli/helpers/progress-tracker.js +202 -0
- package/dist/src/cli/helpers/progress-tracker.js.map +1 -0
- package/dist/src/cli/helpers/project-count-fetcher.d.ts +69 -0
- package/dist/src/cli/helpers/project-count-fetcher.d.ts.map +1 -0
- package/dist/src/cli/helpers/project-count-fetcher.js +173 -0
- package/dist/src/cli/helpers/project-count-fetcher.js.map +1 -0
- package/dist/src/config/types.d.ts +14 -14
- package/dist/src/core/cache/cache-manager.d.ts +119 -0
- package/dist/src/core/cache/cache-manager.d.ts.map +1 -0
- package/dist/src/core/cache/cache-manager.js +304 -0
- package/dist/src/core/cache/cache-manager.js.map +1 -0
- package/dist/src/core/cache/rate-limit-checker.d.ts +92 -0
- package/dist/src/core/cache/rate-limit-checker.d.ts.map +1 -0
- package/dist/src/core/cache/rate-limit-checker.js +160 -0
- package/dist/src/core/cache/rate-limit-checker.js.map +1 -0
- package/dist/src/core/progress/cancelation-handler.d.ts +79 -0
- package/dist/src/core/progress/cancelation-handler.d.ts.map +1 -0
- package/dist/src/core/progress/cancelation-handler.js +111 -0
- package/dist/src/core/progress/cancelation-handler.js.map +1 -0
- package/dist/src/core/progress/error-logger.d.ts +58 -0
- package/dist/src/core/progress/error-logger.d.ts.map +1 -0
- package/dist/src/core/progress/error-logger.js +99 -0
- package/dist/src/core/progress/error-logger.js.map +1 -0
- package/dist/src/core/progress/import-state.d.ts +71 -0
- package/dist/src/core/progress/import-state.d.ts.map +1 -0
- package/dist/src/core/progress/import-state.js +96 -0
- package/dist/src/core/progress/import-state.js.map +1 -0
- package/dist/src/core/progress/progress-tracker.d.ts +139 -0
- package/dist/src/core/progress/progress-tracker.d.ts.map +1 -0
- package/dist/src/core/progress/progress-tracker.js +223 -0
- package/dist/src/core/progress/progress-tracker.js.map +1 -0
- package/dist/src/init/architecture/types.d.ts +6 -6
- package/dist/src/integrations/ado/ado-client.d.ts +25 -0
- package/dist/src/integrations/ado/ado-client.d.ts.map +1 -1
- package/dist/src/integrations/ado/ado-client.js +67 -0
- package/dist/src/integrations/ado/ado-client.js.map +1 -1
- package/dist/src/integrations/ado/ado-dependency-loader.d.ts +99 -0
- package/dist/src/integrations/ado/ado-dependency-loader.d.ts.map +1 -0
- package/dist/src/integrations/ado/ado-dependency-loader.js +207 -0
- package/dist/src/integrations/ado/ado-dependency-loader.js.map +1 -0
- package/dist/src/integrations/jira/jira-client.d.ts +32 -0
- package/dist/src/integrations/jira/jira-client.d.ts.map +1 -1
- package/dist/src/integrations/jira/jira-client.js +81 -0
- package/dist/src/integrations/jira/jira-client.js.map +1 -1
- package/dist/src/integrations/jira/jira-dependency-loader.d.ts +101 -0
- package/dist/src/integrations/jira/jira-dependency-loader.d.ts.map +1 -0
- package/dist/src/integrations/jira/jira-dependency-loader.js +200 -0
- package/dist/src/integrations/jira/jira-dependency-loader.js.map +1 -0
- package/package.json +1 -1
- package/plugins/specweave/.claude-plugin/plugin.json +20 -0
- package/plugins/specweave/agents/architect/AGENT.md +100 -602
- package/plugins/specweave/agents/pm/AGENT.md +96 -597
- package/plugins/specweave/agents/pm/AGENT.md.bak +1893 -0
- package/plugins/specweave/agents/pm/AGENT.md.bak2 +1754 -0
- package/plugins/specweave/commands/check-hooks.md +257 -0
- package/plugins/specweave/hooks/docs-changed.sh +9 -1
- package/plugins/specweave/hooks/docs-changed.sh.backup +79 -0
- package/plugins/specweave/hooks/human-input-required.sh +9 -1
- package/plugins/specweave/hooks/human-input-required.sh.backup +75 -0
- package/plugins/specweave/hooks/post-edit-spec.sh +202 -31
- package/plugins/specweave/hooks/post-first-increment.sh.backup +61 -0
- package/plugins/specweave/hooks/post-increment-change.sh +6 -1
- package/plugins/specweave/hooks/post-increment-change.sh.backup +98 -0
- package/plugins/specweave/hooks/post-increment-completion.sh +6 -1
- package/plugins/specweave/hooks/post-increment-completion.sh.backup +231 -0
- package/plugins/specweave/hooks/post-increment-planning.sh +6 -1
- package/plugins/specweave/hooks/post-increment-planning.sh.backup +1048 -0
- package/plugins/specweave/hooks/post-increment-status-change.sh +6 -1
- package/plugins/specweave/hooks/post-increment-status-change.sh.backup +147 -0
- package/plugins/specweave/hooks/post-metadata-change.sh +7 -1
- package/plugins/specweave/hooks/post-spec-update.sh.backup +158 -0
- package/plugins/specweave/hooks/post-task-completion.sh +225 -228
- package/plugins/specweave/hooks/post-user-story-complete.sh.backup +179 -0
- package/plugins/specweave/hooks/post-write-spec.sh +207 -31
- package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +83 -0
- package/plugins/specweave/hooks/pre-edit-spec.sh +151 -0
- package/plugins/specweave/hooks/pre-implementation.sh +9 -1
- package/plugins/specweave/hooks/pre-implementation.sh.backup +67 -0
- package/plugins/specweave/hooks/pre-task-completion.sh +14 -8
- package/plugins/specweave/hooks/pre-task-completion.sh.backup +194 -0
- package/plugins/specweave/hooks/pre-tool-use.sh +9 -1
- package/plugins/specweave/hooks/pre-tool-use.sh.backup +133 -0
- package/plugins/specweave/hooks/pre-write-spec.sh +151 -0
- package/plugins/specweave/hooks/test-pretooluse-env.sh +72 -0
- package/plugins/specweave/hooks/user-prompt-submit.sh.backup +386 -0
- package/plugins/specweave/skills/compliance-architecture/SKILL.md +374 -0
- package/plugins/specweave/skills/external-sync-wizard/SKILL.md +610 -0
- package/plugins/specweave/skills/pm-closure-validation/SKILL.md +541 -0
- package/plugins/specweave/skills/roadmap-planner/SKILL.md +473 -0
- package/plugins/specweave-ado/commands/refresh-cache.js +25 -0
- package/plugins/specweave-ado/commands/refresh-cache.ts +40 -0
- package/plugins/specweave-ado/hooks/post-living-docs-update.sh +9 -2
- package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +353 -0
- package/plugins/specweave-ado/hooks/post-task-completion.sh +10 -2
- package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +172 -0
- package/plugins/specweave-github/hooks/post-task-completion.sh +10 -2
- package/plugins/specweave-github/hooks/post-task-completion.sh.backup +258 -0
- package/plugins/specweave-jira/commands/refresh-cache.js +25 -0
- package/plugins/specweave-jira/commands/refresh-cache.ts +40 -0
- package/plugins/specweave-jira/hooks/post-task-completion.sh +10 -2
- package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +172 -0
- package/plugins/specweave-kafka-streams/commands/topology.md +437 -0
- package/plugins/specweave-n8n/commands/workflow-template.md +262 -0
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +252 -6465
- package/plugins/specweave-release/hooks/post-task-completion.sh.backup +110 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Validate hook health and display performance metrics (Tier 2 monitoring)
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# /specweave:check-hooks - Hook Health Dashboard
|
|
6
|
+
|
|
7
|
+
**Purpose:** Display comprehensive hook performance metrics, detection rates, and health status.
|
|
8
|
+
|
|
9
|
+
**Tier 2 Feature:** This command validates the PreToolUse coordination layer is working correctly.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Instructions for Claude
|
|
14
|
+
|
|
15
|
+
When this command is executed, perform the following analysis:
|
|
16
|
+
|
|
17
|
+
### 1. **Read Hook Metrics File**
|
|
18
|
+
|
|
19
|
+
Location: `.specweave/state/hook-metrics.jsonl`
|
|
20
|
+
|
|
21
|
+
The metrics file contains JSONL (JSON Lines) format - one JSON object per line.
|
|
22
|
+
|
|
23
|
+
Each entry has:
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"timestamp": "2025-11-22T01:30:00Z",
|
|
27
|
+
"hook": "pre-edit-spec|post-edit-spec|pre-write-spec|post-write-spec",
|
|
28
|
+
"event": "file_detected|tier2_success|tier1_fallback",
|
|
29
|
+
"file_path": "/path/to/file.md",
|
|
30
|
+
"method": "pretooluse|env_content|env_result|env_args|mtime"
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### 2. **Calculate Key Metrics**
|
|
35
|
+
|
|
36
|
+
**Tier 2 Success Rate:**
|
|
37
|
+
```
|
|
38
|
+
Tier 2 Rate = (tier2_success events) / (total post-tool events) * 100%
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Target:** >95% (Tier 2 should handle most cases)
|
|
42
|
+
|
|
43
|
+
**Detection Method Breakdown:**
|
|
44
|
+
- `pretooluse`: Tier 2 PreToolUse coordination (best)
|
|
45
|
+
- `env_content`: Environment variable (TOOL_USE_CONTENT)
|
|
46
|
+
- `env_result`: Environment variable (TOOL_RESULT)
|
|
47
|
+
- `env_args`: Environment variable (TOOL_USE_ARGS)
|
|
48
|
+
- `mtime`: File modification time fallback (Tier 1)
|
|
49
|
+
|
|
50
|
+
**Fallback Rate:**
|
|
51
|
+
```
|
|
52
|
+
Fallback Rate = (mtime detections) / (total detections) * 100%
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Target:** <5% (should rarely need mtime fallback)
|
|
56
|
+
|
|
57
|
+
### 3. **Check Hook Health Status**
|
|
58
|
+
|
|
59
|
+
**Circuit Breaker Status:**
|
|
60
|
+
- File: `.specweave/state/.hook-circuit-breaker`
|
|
61
|
+
- If exists: Read failure count
|
|
62
|
+
- If count ≥ 3: ⚠️ CIRCUIT BREAKER OPEN (hooks disabled)
|
|
63
|
+
- If count < 3: ✅ Circuit breaker OK
|
|
64
|
+
- If doesn't exist: ✅ No failures detected
|
|
65
|
+
|
|
66
|
+
**Kill Switch Status:**
|
|
67
|
+
- Check environment variable: `SPECWEAVE_DISABLE_HOOKS`
|
|
68
|
+
- If set to "1": ⚠️ HOOKS MANUALLY DISABLED
|
|
69
|
+
- If not set or "0": ✅ Hooks enabled
|
|
70
|
+
|
|
71
|
+
**Lock Files Status:**
|
|
72
|
+
- Check for stale locks:
|
|
73
|
+
- `.specweave/state/.hook-post-edit.lock`
|
|
74
|
+
- `.specweave/state/.hook-post-write.lock`
|
|
75
|
+
- If older than 10 seconds: ⚠️ Stale lock detected
|
|
76
|
+
- If not present: ✅ No locks
|
|
77
|
+
|
|
78
|
+
### 4. **Read Recent Hook Logs**
|
|
79
|
+
|
|
80
|
+
Location: `.specweave/logs/hooks-debug.log`
|
|
81
|
+
|
|
82
|
+
**Look for:**
|
|
83
|
+
- Recent errors or warnings
|
|
84
|
+
- Debounce effectiveness (count "Debounced" messages)
|
|
85
|
+
- PreToolUse signal messages
|
|
86
|
+
- Circuit breaker trips
|
|
87
|
+
|
|
88
|
+
**Time window:** Last 100 lines or last 1 hour
|
|
89
|
+
|
|
90
|
+
### 5. **Output Format**
|
|
91
|
+
|
|
92
|
+
Display results in this format:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
🔍 SpecWeave Hook Health Dashboard (Tier 2)
|
|
96
|
+
═══════════════════════════════════════════════════════════
|
|
97
|
+
|
|
98
|
+
📊 DETECTION METRICS (Last 24 hours)
|
|
99
|
+
────────────────────────────────────
|
|
100
|
+
Total Hook Executions: 156
|
|
101
|
+
Tier 2 Success (PreToolUse): 149 (95.5%) ✅
|
|
102
|
+
Tier 1 Fallback (env vars): 5 (3.2%)
|
|
103
|
+
Tier 1 Fallback (mtime): 2 (1.3%)
|
|
104
|
+
|
|
105
|
+
Detection Method Breakdown:
|
|
106
|
+
• pretooluse: 149 (95.5%) ✅ Target: >95%
|
|
107
|
+
• env_content: 3 (1.9%)
|
|
108
|
+
• env_args: 2 (1.3%)
|
|
109
|
+
• mtime: 2 (1.3%) ✅ Target: <5%
|
|
110
|
+
|
|
111
|
+
🏥 HEALTH STATUS
|
|
112
|
+
────────────────────────────────────
|
|
113
|
+
Circuit Breaker: ✅ OK (0 failures)
|
|
114
|
+
Kill Switch: ✅ Hooks enabled
|
|
115
|
+
Stale Locks: ✅ None detected
|
|
116
|
+
Debounce Efficiency: 87% (136/156 skipped)
|
|
117
|
+
|
|
118
|
+
⚡ PERFORMANCE
|
|
119
|
+
────────────────────────────────────
|
|
120
|
+
Average Hook Latency: ~3ms
|
|
121
|
+
Debounce Window: 5 seconds
|
|
122
|
+
Background Updates: Active
|
|
123
|
+
Metrics Collection: Active
|
|
124
|
+
|
|
125
|
+
📝 RECENT ACTIVITY (Last 10 events)
|
|
126
|
+
────────────────────────────────────
|
|
127
|
+
[2025-11-22 01:30:15] post-edit-spec: File from PreToolUse signal: /path/to/spec.md
|
|
128
|
+
[2025-11-22 01:30:10] pre-edit-spec: Signaled PostToolUse for: /path/to/spec.md
|
|
129
|
+
[2025-11-22 01:29:45] post-edit-spec: Debounced (2s since last update)
|
|
130
|
+
...
|
|
131
|
+
|
|
132
|
+
✅ SUMMARY
|
|
133
|
+
────────────────────────────────────
|
|
134
|
+
Status: HEALTHY ✅
|
|
135
|
+
|
|
136
|
+
Tier 2 coordination is working correctly (95.5% success rate).
|
|
137
|
+
Fallback rate is within acceptable range (<5%).
|
|
138
|
+
No health issues detected.
|
|
139
|
+
|
|
140
|
+
Recommendations:
|
|
141
|
+
• None - system performing optimally
|
|
142
|
+
|
|
143
|
+
To disable hooks temporarily:
|
|
144
|
+
export SPECWEAVE_DISABLE_HOOKS=1
|
|
145
|
+
|
|
146
|
+
To reset circuit breaker:
|
|
147
|
+
rm .specweave/state/.hook-circuit-breaker
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### 6. **Health Assessment Logic**
|
|
151
|
+
|
|
152
|
+
**Determine overall status:**
|
|
153
|
+
|
|
154
|
+
- ✅ **HEALTHY** if:
|
|
155
|
+
- Tier 2 success rate >90%
|
|
156
|
+
- Fallback rate <10%
|
|
157
|
+
- No circuit breaker trips
|
|
158
|
+
- Hooks enabled
|
|
159
|
+
|
|
160
|
+
- ⚠️ **WARNING** if:
|
|
161
|
+
- Tier 2 success rate 70-90%
|
|
162
|
+
- Fallback rate 10-30%
|
|
163
|
+
- Circuit breaker count 1-2
|
|
164
|
+
|
|
165
|
+
- ❌ **CRITICAL** if:
|
|
166
|
+
- Tier 2 success rate <70%
|
|
167
|
+
- Fallback rate >30%
|
|
168
|
+
- Circuit breaker open (count ≥ 3)
|
|
169
|
+
- Hooks manually disabled
|
|
170
|
+
|
|
171
|
+
### 7. **Troubleshooting Recommendations**
|
|
172
|
+
|
|
173
|
+
Based on status, provide targeted recommendations:
|
|
174
|
+
|
|
175
|
+
**If Tier 2 success rate <95%:**
|
|
176
|
+
```
|
|
177
|
+
⚠️ PreToolUse coordination not working optimally
|
|
178
|
+
|
|
179
|
+
Recommendations:
|
|
180
|
+
1. Check if PreToolUse hooks are registered in plugin.json
|
|
181
|
+
2. Verify hook files are executable (chmod +x)
|
|
182
|
+
3. Review .specweave/logs/hooks-debug.log for PreToolUse errors
|
|
183
|
+
4. Consider filing bug with Anthropic (environment variable passing)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
**If fallback rate >10%:**
|
|
187
|
+
```
|
|
188
|
+
⚠️ High fallback rate detected
|
|
189
|
+
|
|
190
|
+
Recommendations:
|
|
191
|
+
1. Tier 2 coordination may not be working
|
|
192
|
+
2. Environment variables still not being passed
|
|
193
|
+
3. Consider Tier 3 implementation (filesystem watcher)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**If circuit breaker open:**
|
|
197
|
+
```
|
|
198
|
+
❌ Hooks disabled due to consecutive failures
|
|
199
|
+
|
|
200
|
+
Immediate actions:
|
|
201
|
+
1. Review .specweave/logs/hooks-debug.log for errors
|
|
202
|
+
2. Fix underlying issues
|
|
203
|
+
3. Reset circuit breaker: rm .specweave/state/.hook-circuit-breaker
|
|
204
|
+
4. Restart Claude Code
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### 8. **Error Handling**
|
|
208
|
+
|
|
209
|
+
If metrics file doesn't exist:
|
|
210
|
+
```
|
|
211
|
+
⚠️ No metrics data available
|
|
212
|
+
|
|
213
|
+
This is normal for:
|
|
214
|
+
• New SpecWeave installation
|
|
215
|
+
• First run after Tier 2 upgrade
|
|
216
|
+
|
|
217
|
+
Metrics will be collected automatically as you work.
|
|
218
|
+
Run this command again after a few Edit/Write operations.
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
If logs not accessible:
|
|
222
|
+
```
|
|
223
|
+
⚠️ Could not read hook logs
|
|
224
|
+
|
|
225
|
+
Check file permissions:
|
|
226
|
+
.specweave/logs/hooks-debug.log
|
|
227
|
+
.specweave/state/hook-metrics.jsonl
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## Implementation Notes
|
|
233
|
+
|
|
234
|
+
**For Claude:**
|
|
235
|
+
1. Parse JSONL file line by line (each line is a JSON object)
|
|
236
|
+
2. Calculate metrics using simple counting
|
|
237
|
+
3. Display results using the template above
|
|
238
|
+
4. Adjust recommendations based on actual metrics
|
|
239
|
+
5. Keep output concise but informative
|
|
240
|
+
|
|
241
|
+
**Time-based filtering:**
|
|
242
|
+
- Default: Last 24 hours
|
|
243
|
+
- Option: All time (if user requests)
|
|
244
|
+
- Filter by comparing timestamp field
|
|
245
|
+
|
|
246
|
+
**Edge cases:**
|
|
247
|
+
- Empty metrics file → Show "waiting for data" message
|
|
248
|
+
- Corrupted JSONL → Skip invalid lines, report count
|
|
249
|
+
- Missing state directory → Create it, show initialization message
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## Related Documentation
|
|
254
|
+
|
|
255
|
+
- ADR-0060: Hook Performance Optimization
|
|
256
|
+
- `.specweave/increments/0050-*/reports/hook-crash-analysis.md`
|
|
257
|
+
- CLAUDE.md: "Hook Performance Best Practices"
|
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
# Detects if documentation was changed during implementation
|
|
6
6
|
# Triggers review workflow if needed
|
|
7
7
|
|
|
8
|
-
set
|
|
8
|
+
set +e # EMERGENCY FIX: Prevents Claude Code crashes
|
|
9
|
+
|
|
10
|
+
# EMERGENCY KILL SWITCH
|
|
11
|
+
if [[ "${SPECWEAVE_DISABLE_HOOKS:-0}" == "1" ]]; then
|
|
12
|
+
exit 0
|
|
13
|
+
fi
|
|
9
14
|
|
|
10
15
|
# Find project root by searching upward for .specweave/ directory
|
|
11
16
|
# Works regardless of where hook is installed (source or .claude/hooks/)
|
|
@@ -77,3 +82,6 @@ if [ -n "$DOC_CHANGES" ]; then
|
|
|
77
82
|
mkdir -p "$LOGS_DIR"
|
|
78
83
|
echo "[$(date)] Documentation changed: $DOC_CHANGES" >> "$LOGS_DIR/hooks.log"
|
|
79
84
|
fi
|
|
85
|
+
|
|
86
|
+
# ALWAYS exit 0 - NEVER let hook errors crash Claude Code
|
|
87
|
+
exit 0
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# SpecWeave Docs-Changed Hook
|
|
4
|
+
# Runs after file changes are detected
|
|
5
|
+
# Detects if documentation was changed during implementation
|
|
6
|
+
# Triggers review workflow if needed
|
|
7
|
+
|
|
8
|
+
set -e
|
|
9
|
+
|
|
10
|
+
# Find project root by searching upward for .specweave/ directory
|
|
11
|
+
# Works regardless of where hook is installed (source or .claude/hooks/)
|
|
12
|
+
find_project_root() {
|
|
13
|
+
local dir="$1"
|
|
14
|
+
while [ "$dir" != "/" ]; do
|
|
15
|
+
if [ -d "$dir/.specweave" ]; then
|
|
16
|
+
echo "$dir"
|
|
17
|
+
return 0
|
|
18
|
+
fi
|
|
19
|
+
dir="$(dirname "$dir")"
|
|
20
|
+
done
|
|
21
|
+
# Fallback: try current directory
|
|
22
|
+
if [ -d "$(pwd)/.specweave" ]; then
|
|
23
|
+
pwd
|
|
24
|
+
else
|
|
25
|
+
echo "$(pwd)"
|
|
26
|
+
fi
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
PROJECT_ROOT="$(find_project_root "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")"
|
|
30
|
+
cd "$PROJECT_ROOT"
|
|
31
|
+
|
|
32
|
+
# Colors
|
|
33
|
+
RED='\033[0;31m'
|
|
34
|
+
YELLOW='\033[1;33m'
|
|
35
|
+
NC='\033[0m'
|
|
36
|
+
|
|
37
|
+
# Get changed files (git)
|
|
38
|
+
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
39
|
+
# Not a git repository, skip
|
|
40
|
+
exit 0
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
CHANGED_FILES=$(git diff --name-only HEAD 2>/dev/null || echo "")
|
|
44
|
+
|
|
45
|
+
if [ -z "$CHANGED_FILES" ]; then
|
|
46
|
+
# No changes
|
|
47
|
+
exit 0
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
# Check if any documentation files changed
|
|
51
|
+
DOC_CHANGES=$(echo "$CHANGED_FILES" | grep -E '\.specweave/(docs|increments/.*/.*\.md)' || true)
|
|
52
|
+
|
|
53
|
+
if [ -n "$DOC_CHANGES" ]; then
|
|
54
|
+
echo -e "${RED}⚠️ Documentation changed during implementation${NC}"
|
|
55
|
+
echo ""
|
|
56
|
+
echo "📋 Files changed:"
|
|
57
|
+
echo "$DOC_CHANGES" | sed 's/^/ /'
|
|
58
|
+
echo ""
|
|
59
|
+
echo -e "${YELLOW}🔔 Recommended actions:${NC}"
|
|
60
|
+
echo " 1. Review documentation changes"
|
|
61
|
+
echo " 2. Update tasks.md if architecture changed"
|
|
62
|
+
echo " 3. Type /review-docs to see full impact"
|
|
63
|
+
echo ""
|
|
64
|
+
|
|
65
|
+
# Play notification sound
|
|
66
|
+
case "$(uname -s)" in
|
|
67
|
+
Darwin)
|
|
68
|
+
afplay /System/Library/Sounds/Ping.aiff 2>/dev/null &
|
|
69
|
+
;;
|
|
70
|
+
Linux)
|
|
71
|
+
paplay /usr/share/sounds/freedesktop/stereo/dialog-warning.oga 2>/dev/null || true
|
|
72
|
+
;;
|
|
73
|
+
esac
|
|
74
|
+
|
|
75
|
+
# Log to hooks log
|
|
76
|
+
LOGS_DIR=".specweave/logs"
|
|
77
|
+
mkdir -p "$LOGS_DIR"
|
|
78
|
+
echo "[$(date)] Documentation changed: $DOC_CHANGES" >> "$LOGS_DIR/hooks.log"
|
|
79
|
+
fi
|
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
# 2. Log the question/requirement
|
|
9
9
|
# 3. Record in current increment's work log (if applicable)
|
|
10
10
|
|
|
11
|
-
set
|
|
11
|
+
set +e # EMERGENCY FIX: Prevents Claude Code crashes
|
|
12
|
+
|
|
13
|
+
# EMERGENCY KILL SWITCH
|
|
14
|
+
if [[ "${SPECWEAVE_DISABLE_HOOKS:-0}" == "1" ]]; then
|
|
15
|
+
exit 0
|
|
16
|
+
fi
|
|
12
17
|
|
|
13
18
|
# Find project root by searching upward for .specweave/ directory
|
|
14
19
|
# Works regardless of where hook is installed (source or .claude/hooks/)
|
|
@@ -73,3 +78,6 @@ if [ -n "$CURRENT_WORK" ] && [ -d "$CURRENT_WORK" ]; then
|
|
|
73
78
|
fi
|
|
74
79
|
|
|
75
80
|
echo "✅ Hook complete"
|
|
81
|
+
|
|
82
|
+
# ALWAYS exit 0 - NEVER let hook errors crash Claude Code
|
|
83
|
+
exit 0
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# SpecWeave Human-Input-Required Hook
|
|
4
|
+
# Runs when Claude needs clarification or approval
|
|
5
|
+
#
|
|
6
|
+
# Actions:
|
|
7
|
+
# 1. Play notification sound (Ping.aiff)
|
|
8
|
+
# 2. Log the question/requirement
|
|
9
|
+
# 3. Record in current increment's work log (if applicable)
|
|
10
|
+
|
|
11
|
+
set -e
|
|
12
|
+
|
|
13
|
+
# Find project root by searching upward for .specweave/ directory
|
|
14
|
+
# Works regardless of where hook is installed (source or .claude/hooks/)
|
|
15
|
+
find_project_root() {
|
|
16
|
+
local dir="$1"
|
|
17
|
+
while [ "$dir" != "/" ]; do
|
|
18
|
+
if [ -d "$dir/.specweave" ]; then
|
|
19
|
+
echo "$dir"
|
|
20
|
+
return 0
|
|
21
|
+
fi
|
|
22
|
+
dir="$(dirname "$dir")"
|
|
23
|
+
done
|
|
24
|
+
# Fallback: try current directory
|
|
25
|
+
if [ -d "$(pwd)/.specweave" ]; then
|
|
26
|
+
pwd
|
|
27
|
+
else
|
|
28
|
+
echo "$(pwd)"
|
|
29
|
+
fi
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
PROJECT_ROOT="$(find_project_root "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")"
|
|
33
|
+
cd "$PROJECT_ROOT"
|
|
34
|
+
|
|
35
|
+
# Get question/requirement (passed as argument or default)
|
|
36
|
+
QUESTION="${1:-User input required}"
|
|
37
|
+
|
|
38
|
+
echo "❓ Human input required"
|
|
39
|
+
|
|
40
|
+
# 1. Play notification sound (cross-platform)
|
|
41
|
+
play_sound() {
|
|
42
|
+
case "$(uname -s)" in
|
|
43
|
+
Darwin)
|
|
44
|
+
afplay /System/Library/Sounds/Ping.aiff 2>/dev/null &
|
|
45
|
+
;;
|
|
46
|
+
Linux)
|
|
47
|
+
paplay /usr/share/sounds/freedesktop/stereo/dialog-question.oga 2>/dev/null || \
|
|
48
|
+
aplay /usr/share/sounds/alsa/Side_Left.wav 2>/dev/null || true
|
|
49
|
+
;;
|
|
50
|
+
MINGW*|MSYS*|CYGWIN*)
|
|
51
|
+
powershell -c "(New-Object Media.SoundPlayer 'C:\Windows\Media\notify.wav').PlaySync();" 2>/dev/null || true
|
|
52
|
+
;;
|
|
53
|
+
esac
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
play_sound &
|
|
57
|
+
|
|
58
|
+
# 2. Log to main hooks log
|
|
59
|
+
LOGS_DIR=".specweave/logs"
|
|
60
|
+
mkdir -p "$LOGS_DIR"
|
|
61
|
+
echo "[$(date)] Human input required: $QUESTION" >> "$LOGS_DIR/hooks.log"
|
|
62
|
+
|
|
63
|
+
# 3. Log to current work context (if exists)
|
|
64
|
+
CURRENT_WORK=$(find .specweave/work -maxdepth 1 -type d -name "current-*" | head -1 || true)
|
|
65
|
+
|
|
66
|
+
if [ -n "$CURRENT_WORK" ] && [ -d "$CURRENT_WORK" ]; then
|
|
67
|
+
echo "" >> "$CURRENT_WORK/notes.md"
|
|
68
|
+
echo "## Input Required ($(date +%Y-%m-%d\ %H:%M))" >> "$CURRENT_WORK/notes.md"
|
|
69
|
+
echo "" >> "$CURRENT_WORK/notes.md"
|
|
70
|
+
echo "$QUESTION" >> "$CURRENT_WORK/notes.md"
|
|
71
|
+
echo "" >> "$CURRENT_WORK/notes.md"
|
|
72
|
+
echo "📝 Logged to $CURRENT_WORK/notes.md"
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
echo "✅ Hook complete"
|