specweave 0.26.4 → 0.26.9

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 (82) hide show
  1. package/CLAUDE.md +154 -4
  2. package/bin/specweave.js +15 -0
  3. package/dist/plugins/specweave-github/lib/completion-calculator.js +2 -2
  4. package/dist/plugins/specweave-github/lib/completion-calculator.js.map +1 -1
  5. package/dist/plugins/specweave-github/lib/github-feature-sync.d.ts +28 -1
  6. package/dist/plugins/specweave-github/lib/github-feature-sync.d.ts.map +1 -1
  7. package/dist/plugins/specweave-github/lib/github-feature-sync.js +191 -19
  8. package/dist/plugins/specweave-github/lib/github-feature-sync.js.map +1 -1
  9. package/dist/plugins/specweave-github/lib/user-story-issue-builder.d.ts +3 -0
  10. package/dist/plugins/specweave-github/lib/user-story-issue-builder.d.ts.map +1 -1
  11. package/dist/plugins/specweave-github/lib/user-story-issue-builder.js +25 -2
  12. package/dist/plugins/specweave-github/lib/user-story-issue-builder.js.map +1 -1
  13. package/dist/src/cli/commands/archive.d.ts +10 -0
  14. package/dist/src/cli/commands/archive.d.ts.map +1 -0
  15. package/dist/src/cli/commands/archive.js +78 -0
  16. package/dist/src/cli/commands/archive.js.map +1 -0
  17. package/dist/src/cli/commands/init.js +2 -2
  18. package/dist/src/cli/commands/init.js.map +1 -1
  19. package/dist/src/cli/helpers/init/initial-increment-generator.d.ts.map +1 -1
  20. package/dist/src/cli/helpers/init/initial-increment-generator.js +48 -8
  21. package/dist/src/cli/helpers/init/initial-increment-generator.js.map +1 -1
  22. package/dist/src/core/increment/increment-reopener.d.ts.map +1 -1
  23. package/dist/src/core/increment/increment-reopener.js +13 -14
  24. package/dist/src/core/increment/increment-reopener.js.map +1 -1
  25. package/dist/src/core/increment/metadata-manager.d.ts.map +1 -1
  26. package/dist/src/core/increment/metadata-manager.js +19 -0
  27. package/dist/src/core/increment/metadata-manager.js.map +1 -1
  28. package/dist/src/core/increment/status-change-sync-trigger.d.ts +85 -0
  29. package/dist/src/core/increment/status-change-sync-trigger.d.ts.map +1 -0
  30. package/dist/src/core/increment/status-change-sync-trigger.js +137 -0
  31. package/dist/src/core/increment/status-change-sync-trigger.js.map +1 -0
  32. package/dist/src/core/increment/sync-circuit-breaker.d.ts +64 -0
  33. package/dist/src/core/increment/sync-circuit-breaker.d.ts.map +1 -0
  34. package/dist/src/core/increment/sync-circuit-breaker.js +95 -0
  35. package/dist/src/core/increment/sync-circuit-breaker.js.map +1 -0
  36. package/dist/src/core/living-docs/living-docs-sync.d.ts +12 -0
  37. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
  38. package/dist/src/core/living-docs/living-docs-sync.js +157 -24
  39. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
  40. package/dist/src/init/repo/types.d.ts +1 -1
  41. package/package.json +2 -2
  42. package/plugins/specweave/agents/pm/AGENT.md +13 -7
  43. package/plugins/specweave/commands/sync-diagnostics.md +227 -0
  44. package/plugins/specweave/hooks/docs-changed.sh.backup +79 -0
  45. package/plugins/specweave/hooks/human-input-required.sh.backup +75 -0
  46. package/plugins/specweave/hooks/post-first-increment.sh.backup +61 -0
  47. package/plugins/specweave/hooks/post-increment-change.sh.backup +98 -0
  48. package/plugins/specweave/hooks/post-increment-completion.sh.backup +231 -0
  49. package/plugins/specweave/hooks/post-increment-planning.sh.backup +1048 -0
  50. package/plugins/specweave/hooks/post-increment-status-change.sh.backup +147 -0
  51. package/plugins/specweave/hooks/post-spec-update.sh.backup +158 -0
  52. package/plugins/specweave/hooks/post-user-story-complete.sh.backup +179 -0
  53. package/plugins/specweave/hooks/pre-command-deduplication.sh.backup +83 -0
  54. package/plugins/specweave/hooks/pre-implementation.sh.backup +67 -0
  55. package/plugins/specweave/hooks/pre-task-completion.sh.backup +194 -0
  56. package/plugins/specweave/hooks/pre-tool-use.sh.backup +133 -0
  57. package/plugins/specweave/hooks/user-prompt-submit.sh +20 -8
  58. package/plugins/specweave/hooks/user-prompt-submit.sh.backup +386 -0
  59. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js +19 -0
  60. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js.map +1 -1
  61. package/plugins/specweave/skills/brownfield-analyzer/SKILL.md +267 -868
  62. package/plugins/specweave/skills/increment-planner/SKILL.md +379 -1245
  63. package/plugins/specweave/skills/role-orchestrator/SKILL.md +293 -969
  64. package/plugins/specweave-ado/hooks/post-living-docs-update.sh.backup +353 -0
  65. package/plugins/specweave-ado/hooks/post-task-completion.sh.backup +172 -0
  66. package/plugins/specweave-ado/lib/ado-multi-project-sync.js +1 -0
  67. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +170 -0
  68. package/plugins/specweave-docs/skills/technical-writing/SKILL.md +333 -839
  69. package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +1080 -0
  70. package/plugins/specweave-github/hooks/post-task-completion.sh.backup +258 -0
  71. package/plugins/specweave-github/lib/completion-calculator.js +1 -1
  72. package/plugins/specweave-github/lib/completion-calculator.ts +2 -2
  73. package/plugins/specweave-github/lib/github-feature-sync.js +152 -18
  74. package/plugins/specweave-github/lib/github-feature-sync.ts +225 -22
  75. package/plugins/specweave-github/lib/user-story-issue-builder.js +21 -1
  76. package/plugins/specweave-github/lib/user-story-issue-builder.ts +31 -3
  77. package/plugins/specweave-jira/hooks/post-task-completion.sh.backup +172 -0
  78. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  79. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +981 -0
  80. package/plugins/specweave-release/hooks/post-task-completion.sh.backup +110 -0
  81. package/plugins/specweave-testing/skills/tdd-expert/SKILL.md +269 -749
  82. package/plugins/specweave-testing/skills/unit-testing-expert/SKILL.md +318 -810
@@ -0,0 +1,227 @@
1
+ ---
2
+ name: sync-diagnostics
3
+ description: Show sync circuit breaker diagnostics and status
4
+ ---
5
+
6
+ You are executing the SpecWeave sync diagnostics command. This shows the current state of the sync circuit breaker and recent sync activity.
7
+
8
+ ## Purpose
9
+
10
+ Display diagnostic information about automatic sync system:
11
+ - Circuit breaker state (closed, open, half-open)
12
+ - Recent failure count
13
+ - Last failure timestamp
14
+ - Auto-reset countdown (if circuit open)
15
+ - Sync status for active increments
16
+
17
+ ## Implementation
18
+
19
+ ```typescript
20
+ import { StatusChangeSyncTrigger } from '../../../src/core/increment/status-change-sync-trigger.js';
21
+ import { ActiveIncrementManager } from '../../../src/core/increment/active-increment-manager.js';
22
+ import { MetadataManager } from '../../../src/core/increment/metadata-manager.js';
23
+ import * as path from 'path';
24
+
25
+ // Get circuit breaker state
26
+ const breakerState = StatusChangeSyncTrigger.getCircuitBreakerState();
27
+
28
+ console.log('');
29
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
30
+ console.log('🔧 SYNC DIAGNOSTICS');
31
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
32
+ console.log('');
33
+
34
+ // Circuit Breaker Status
35
+ console.log('🔴 Circuit Breaker Status');
36
+ console.log('');
37
+
38
+ const stateEmoji = {
39
+ 'closed': '✅',
40
+ 'open': '🔴',
41
+ 'half-open': '⚠️'
42
+ };
43
+
44
+ console.log(` State: ${stateEmoji[breakerState.state]} ${breakerState.state.toUpperCase()}`);
45
+ console.log(` Failures: ${breakerState.failures}/3`);
46
+
47
+ if (breakerState.lastFailure) {
48
+ const elapsed = Date.now() - breakerState.lastFailure.getTime();
49
+ const elapsedMin = Math.floor(elapsed / 60000);
50
+ const resetIn = Math.max(0, 5 - elapsedMin);
51
+
52
+ console.log(` Last Failure: ${breakerState.lastFailure.toISOString()}`);
53
+ console.log(` Elapsed: ${elapsedMin} minutes ago`);
54
+
55
+ if (breakerState.state === 'open') {
56
+ console.log(` ⏰ Auto-reset in: ${resetIn} minutes`);
57
+ }
58
+ } else {
59
+ console.log(` Last Failure: None`);
60
+ }
61
+
62
+ console.log('');
63
+
64
+ // Sync Status Explanation
65
+ if (breakerState.state === 'closed') {
66
+ console.log('✅ Automatic sync is ENABLED');
67
+ console.log(' Status changes will trigger GitHub/JIRA/ADO sync');
68
+ } else if (breakerState.state === 'open') {
69
+ console.log('🔴 Automatic sync is DISABLED');
70
+ console.log(' Circuit breaker opened due to repeated failures');
71
+ console.log('');
72
+ console.log(' Possible causes:');
73
+ console.log(' • GitHub/JIRA/ADO API is down or slow');
74
+ console.log(' • Network connectivity issues');
75
+ console.log(' • Authentication token expired');
76
+ console.log(' • Rate limit exceeded');
77
+ console.log('');
78
+ console.log(' Actions:');
79
+ console.log(' 1. Check external service status');
80
+ console.log(' 2. Verify network connectivity');
81
+ console.log(' 3. Wait for auto-reset (${resetIn} minutes)');
82
+ console.log(' 4. Or manually sync: /specweave:sync-progress');
83
+ } else if (breakerState.state === 'half-open') {
84
+ console.log('⚠️ Automatic sync is TESTING');
85
+ console.log(' Circuit breaker is testing if service recovered');
86
+ console.log(' Next sync will close or reopen circuit');
87
+ }
88
+
89
+ console.log('');
90
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
91
+ console.log('📊 ACTIVE INCREMENTS');
92
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
93
+ console.log('');
94
+
95
+ // Show active increments
96
+ const activeManager = new ActiveIncrementManager();
97
+ const activeIncrements = activeManager.getActiveIncrements();
98
+
99
+ if (activeIncrements.length === 0) {
100
+ console.log(' ℹ️ No active increments');
101
+ } else {
102
+ for (const incrementId of activeIncrements) {
103
+ try {
104
+ const metadata = MetadataManager.read(incrementId);
105
+ console.log(` 📦 ${incrementId}`);
106
+ console.log(` Status: ${metadata.status}`);
107
+ console.log(` Last Activity: ${metadata.lastActivity || 'Unknown'}`);
108
+
109
+ // Show sync status
110
+ if (metadata.external_tools?.github) {
111
+ console.log(` 🔗 GitHub: Synced`);
112
+ }
113
+ if (metadata.external_tools?.jira) {
114
+ console.log(` 🔗 JIRA: Synced`);
115
+ }
116
+ if (metadata.external_tools?.ado) {
117
+ console.log(` 🔗 Azure DevOps: Synced`);
118
+ }
119
+
120
+ console.log('');
121
+ } catch (err) {
122
+ console.log(` ⚠️ ${incrementId}: Error reading metadata`);
123
+ }
124
+ }
125
+ }
126
+
127
+ console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
128
+ console.log('');
129
+ console.log('💡 Troubleshooting:');
130
+ console.log('');
131
+ console.log(' • Manual sync: /specweave:sync-progress [increment-id]');
132
+ console.log(' • Reset circuit: (automatic after 5 minutes)');
133
+ console.log(' • Check logs: .specweave/logs/');
134
+ console.log(' • GitHub status: https://www.githubstatus.com/');
135
+ console.log('');
136
+ ```
137
+
138
+ ## Example Output
139
+
140
+ ### Circuit Closed (Normal)
141
+
142
+ ```
143
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
144
+ 🔧 SYNC DIAGNOSTICS
145
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
146
+
147
+ 🔴 Circuit Breaker Status
148
+
149
+ State: ✅ CLOSED
150
+ Failures: 0/3
151
+ Last Failure: None
152
+
153
+ ✅ Automatic sync is ENABLED
154
+ Status changes will trigger GitHub/JIRA/ADO sync
155
+
156
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
157
+ 📊 ACTIVE INCREMENTS
158
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
159
+
160
+ 📦 0058-fix-status-sync-and-auto-github-update
161
+ Status: active
162
+ Last Activity: 2025-11-24T12:34:56.789Z
163
+ 🔗 GitHub: Synced
164
+
165
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
166
+ ```
167
+
168
+ ### Circuit Open (Failure Mode)
169
+
170
+ ```
171
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
172
+ 🔧 SYNC DIAGNOSTICS
173
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
174
+
175
+ 🔴 Circuit Breaker Status
176
+
177
+ State: 🔴 OPEN
178
+ Failures: 3/3
179
+ Last Failure: 2025-11-24T12:30:00.000Z
180
+ Elapsed: 3 minutes ago
181
+ ⏰ Auto-reset in: 2 minutes
182
+
183
+ 🔴 Automatic sync is DISABLED
184
+ Circuit breaker opened due to repeated failures
185
+
186
+ Possible causes:
187
+ • GitHub/JIRA/ADO API is down or slow
188
+ • Network connectivity issues
189
+ • Authentication token expired
190
+ • Rate limit exceeded
191
+
192
+ Actions:
193
+ 1. Check external service status
194
+ 2. Verify network connectivity
195
+ 3. Wait for auto-reset (2 minutes)
196
+ 4. Or manually sync: /specweave:sync-progress
197
+
198
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
199
+ ```
200
+
201
+ ## Use Cases
202
+
203
+ ### 1. Check Sync Health
204
+
205
+ ```bash
206
+ /specweave:sync-diagnostics
207
+ ```
208
+
209
+ Quickly see if automatic sync is working or if circuit breaker opened.
210
+
211
+ ### 2. Troubleshoot Sync Failures
212
+
213
+ When sync isn't working, diagnostics shows:
214
+ - How many failures occurred
215
+ - When last failure happened
216
+ - How long until auto-reset
217
+ - What to check next
218
+
219
+ ### 3. Monitor Active Increments
220
+
221
+ See which increments are active and synced to external tools.
222
+
223
+ ## See Also
224
+
225
+ - `/specweave:sync-progress` - Manual sync command
226
+ - ADR-0070 (Hook Consolidation)
227
+ - Circuit Breaker Pattern Documentation
@@ -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
@@ -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"
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env bash
2
+ # SpecWeave Post-First-Increment Hook
3
+ #
4
+ # Triggers after the first increment is completed
5
+ # Congratulates the user on completing their first increment
6
+ #
7
+ # NON-INTERACTIVE: Just shows a message (hooks run in background)
8
+
9
+ set -euo pipefail
10
+
11
+ # Get project root (where .specweave/ lives)
12
+ PROJECT_ROOT="$(pwd)"
13
+
14
+ # Check if .specweave directory exists
15
+ if [ ! -d ".specweave" ]; then
16
+ # Not in SpecWeave project, skip
17
+ exit 0
18
+ fi
19
+
20
+ # Check if this is the first increment completion
21
+ # Count completed increments in .specweave/increments/
22
+ COMPLETED_COUNT=0
23
+ if [ -d ".specweave/increments" ]; then
24
+ # Count directories that have COMPLETION-REPORT.md or completion metadata
25
+ for inc_dir in .specweave/increments/[0-9][0-9][0-9][0-9]-*/; do
26
+ if [ -d "$inc_dir" ]; then
27
+ if [ -f "${inc_dir}reports/COMPLETION-REPORT.md" ] || \
28
+ [ -f "${inc_dir}COMPLETION-SUMMARY.md" ] || \
29
+ ([ -f "${inc_dir}metadata.json" ] && grep -q '"status".*"completed"' "${inc_dir}metadata.json" 2>/dev/null); then
30
+ COMPLETED_COUNT=$((COMPLETED_COUNT + 1))
31
+ fi
32
+ fi
33
+ done
34
+ fi
35
+
36
+ # Only trigger on first completion
37
+ if [ "$COMPLETED_COUNT" -ne 1 ]; then
38
+ exit 0
39
+ fi
40
+
41
+ # Show congratulations message (non-interactive)
42
+ echo ""
43
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
44
+ echo "🎉 Congratulations! You completed your first increment!"
45
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
46
+ echo ""
47
+ echo "✅ Your increment has been documented in:"
48
+ echo " .specweave/increments/[increment-id]/"
49
+ echo ""
50
+ echo "📚 View your documentation:"
51
+ echo " - Specs: .specweave/docs/internal/specs/"
52
+ echo " - Architecture: .specweave/docs/internal/architecture/"
53
+ echo ""
54
+ echo "🚀 Next steps:"
55
+ echo " - Review your increment: /specweave:status"
56
+ echo " - Start next increment: /specweave:increment \"feature name\""
57
+ echo ""
58
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
59
+ echo ""
60
+
61
+ exit 0
@@ -0,0 +1,98 @@
1
+ #!/bin/bash
2
+
3
+ # SpecWeave Post-Increment-Change Hook
4
+ # Runs automatically after increment files (spec.md, plan.md, tasks.md) are modified
5
+ #
6
+ # Trigger: File watcher or git hook (pre-commit/post-commit)
7
+ # Purpose: Sync increment file changes to GitHub issues
8
+ #
9
+ # What it does:
10
+ # 1. Detects which file changed (spec.md, plan.md, tasks.md)
11
+ # 2. Invokes GitHub sync for increment changes
12
+ # 3. Updates GitHub issue with scope/plan/task changes
13
+ #
14
+ # Usage:
15
+ # ./post-increment-change.sh <incrementId> <changedFile>
16
+ #
17
+ # Example:
18
+ # ./post-increment-change.sh 0015-hierarchical-sync spec.md
19
+
20
+ set -e
21
+
22
+ # Find project root
23
+ find_project_root() {
24
+ local dir="$1"
25
+ while [ "$dir" != "/" ]; do
26
+ if [ -d "$dir/.specweave" ]; then
27
+ echo "$dir"
28
+ return 0
29
+ fi
30
+ dir="$(dirname "$dir")"
31
+ done
32
+ pwd
33
+ }
34
+
35
+ PROJECT_ROOT="$(find_project_root "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")"
36
+ cd "$PROJECT_ROOT" 2>/dev/null || true
37
+
38
+ # Configuration
39
+ LOGS_DIR=".specweave/logs"
40
+ DEBUG_LOG="$LOGS_DIR/hooks-debug.log"
41
+
42
+ mkdir -p "$LOGS_DIR" 2>/dev/null || true
43
+
44
+ # Arguments
45
+ INCREMENT_ID="$1"
46
+ CHANGED_FILE="$2"
47
+
48
+ if [ -z "$INCREMENT_ID" ] || [ -z "$CHANGED_FILE" ]; then
49
+ echo "Usage: $0 <incrementId> <changedFile>" >&2
50
+ echo "Example: $0 0015-hierarchical-sync spec.md" >&2
51
+ exit 1
52
+ fi
53
+
54
+ echo "[$(date)] 📝 Increment file changed: $CHANGED_FILE" >> "$DEBUG_LOG" 2>/dev/null || true
55
+
56
+ # Validate changed file
57
+ case "$CHANGED_FILE" in
58
+ spec.md|plan.md|tasks.md)
59
+ ;;
60
+ *)
61
+ echo "[$(date)] ⚠️ Unknown file type: $CHANGED_FILE (skipping sync)" >> "$DEBUG_LOG" 2>/dev/null || true
62
+ exit 0
63
+ ;;
64
+ esac
65
+
66
+ # Check if Node.js available
67
+ if ! command -v node &> /dev/null; then
68
+ echo "[$(date)] ⚠️ Node.js not found, skipping sync" >> "$DEBUG_LOG" 2>/dev/null || true
69
+ exit 0
70
+ fi
71
+
72
+ # Check if GitHub CLI available
73
+ if ! command -v gh &> /dev/null; then
74
+ echo "[$(date)] ℹ️ GitHub CLI not found, skipping sync" >> "$DEBUG_LOG" 2>/dev/null || true
75
+ exit 0
76
+ fi
77
+
78
+ # Check if authenticated
79
+ if ! gh auth status &> /dev/null; then
80
+ echo "[$(date)] ℹ️ GitHub CLI not authenticated, skipping sync" >> "$DEBUG_LOG" 2>/dev/null || true
81
+ exit 0
82
+ fi
83
+
84
+ # Sync to GitHub
85
+ echo "[$(date)] 🔄 Syncing $CHANGED_FILE changes to GitHub..." >> "$DEBUG_LOG" 2>/dev/null || true
86
+
87
+ node dist/plugins/specweave-github/lib/github-sync-increment-changes.js "$INCREMENT_ID" "$CHANGED_FILE" 2>&1 | tee -a "$DEBUG_LOG" >/dev/null || {
88
+ echo "[$(date)] ⚠️ Failed to sync increment changes (non-blocking)" >> "$DEBUG_LOG" 2>/dev/null || true
89
+ }
90
+
91
+ echo "[$(date)] ✅ Post-increment-change hook complete" >> "$DEBUG_LOG" 2>/dev/null || true
92
+
93
+ # Update status line cache (increment changed)
94
+ HOOK_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
95
+ bash "$HOOK_DIR/lib/update-status-line.sh" 2>/dev/null || true
96
+
97
+ # Return success (non-blocking)
98
+ exit 0